From: Ben Widawsky Date: Fri, 17 Apr 2015 00:13:00 +0000 (-0700) Subject: i965: Add gen7+ sampler state to batch debug X-Git-Tag: upstream/17.1.0~18712 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7f0c7a5f90d084b1fb1e059367856436a19dca5a;p=platform%2Fupstream%2Fmesa.git i965: Add gen7+ sampler state to batch debug OLD: 0x00007e00: 0x10000000: WM SAMP0: filtering 0x00007e04: 0x000d0000: WM SAMP0: wrapping, lod 0x00007e08: 0x00000000: WM SAMP0: default color pointer 0x00007e0c: 0x00000090: WM SAMP0: chroma key, aniso NEW: 0x00007e00: 0x10000000: SAMPLER_STATE 0: Disabled = no, Base Mip: 0.0, Mip/Mag/Min Filter: NONE/NEAREST/NEAREST, LOD Bias: 0.0 0x00007e04: 0x000d0000: SAMPLER_STATE 0: Min LOD: 0.0, Max LOD: 13.0 0x00007e08: 0x00000000: SAMPLER_STATE 0: Border Color 0x00007e0c: 0x00000090: SAMPLER_STATE 0: Max aniso: RATIO 2:1, TC[XYZ] Address Control: CLAMP|CLAMP|WRAP v2: Move GET_BITS macro to here (with paren protection) Ben/Topi Add const to the sampler pointer (Topi) Signed-off-by: Ben Widawsky Reviewed-by: Topi Pohjolainen --- diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 11cb3fa..16cecc5 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -38,6 +38,7 @@ fieldval & field ## _MASK; \ }) +#define GET_BITS(data, high, low) ((data & INTEL_MASK((high), (low))) >> (low)) #define GET_FIELD(word, field) (((word) & field ## _MASK) >> field ## _SHIFT) #ifndef BRW_DEFINES_H diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c index c80a75f..738a974 100644 --- a/src/mesa/drivers/dri/i965/brw_state_dump.c +++ b/src/mesa/drivers/dri/i965/brw_state_dump.c @@ -33,6 +33,33 @@ #include "brw_eu.h" #include "brw_state.h" +static const char *sampler_mip_filter[] = { + "NONE", + "NEAREST", + "RSVD", + "LINEAR" +}; + +static const char *sampler_mag_filter[] = { + "NEAREST", + "LINEAR", + "ANISOTROPIC", + "FLEXIBLE (GEN8+)", + "RSVD", "RSVD", + "MONO", + "RSVD" +}; + +static const char *sampler_addr_mode[] = { + "WRAP", + "MIRROR", + "CLAMP", + "CUBE", + "CLAMP_BORDER", + "MIRROR_ONCE", + "HALF_BORDER" +}; + static void batch_out(struct brw_context *brw, const char *name, uint32_t offset, int index, char *fmt, ...) PRINTFLIKE(5, 6); @@ -259,6 +286,45 @@ static void dump_sampler_state(struct brw_context *brw, } } +static void gen7_dump_sampler_state(struct brw_context *brw, + uint32_t offset, uint32_t size) +{ + const uint32_t *samp = brw->batch.bo->virtual + offset; + char name[20]; + + for (int i = 0; i < size / 16; i++) { + sprintf(name, "SAMPLER_STATE %d", i); + batch_out(brw, name, offset, i, + "Disabled = %s, Base Mip: %u.%u, Mip/Mag/Min Filter: %s/%s/%s, LOD Bias: %d.%d\n", + GET_BITS(samp[0], 31, 31) ? "yes" : "no", + GET_BITS(samp[0], 26, 23), + GET_BITS(samp[0], 22, 22), + sampler_mip_filter[GET_FIELD(samp[0], BRW_SAMPLER_MIP_FILTER)], + sampler_mag_filter[GET_FIELD(samp[0], BRW_SAMPLER_MAG_FILTER)], + /* min filter defs are the same as mag */ + sampler_mag_filter[GET_FIELD(samp[0], BRW_SAMPLER_MIN_FILTER)], + GET_BITS(samp[0], 13, 10), + GET_BITS(samp[0], 9, 1) + ); + batch_out(brw, name, offset, i+1, "Min LOD: %u.%u, Max LOD: %u.%u\n", + GET_BITS(samp[1], 31, 28), + GET_BITS(samp[1], 27, 20), + GET_BITS(samp[1], 19, 16), + GET_BITS(samp[1], 15, 8) + ); + batch_out(brw, name, offset, i+2, "Border Color\n"); /* FINISHME: gen8+ */ + batch_out(brw, name, offset, i+3, "Max aniso: RATIO %d:1, TC[XYZ] Address Control: %s|%s|%s\n", + (GET_FIELD(samp[3], BRW_SAMPLER_MAX_ANISOTROPY) + 1) * 2, + sampler_addr_mode[GET_FIELD(samp[3], BRW_SAMPLER_TCX_WRAP_MODE)], + sampler_addr_mode[GET_FIELD(samp[3], BRW_SAMPLER_TCY_WRAP_MODE)], + sampler_addr_mode[GET_FIELD(samp[3], BRW_SAMPLER_TCZ_WRAP_MODE)] + ); + + samp += 4; + offset += 4 * sizeof(uint32_t); + } +} + static void dump_sf_viewport_state(struct brw_context *brw, uint32_t offset) { @@ -563,7 +629,10 @@ dump_state_batch(struct brw_context *brw) } break; case AUB_TRACE_SAMPLER_STATE: - dump_sampler_state(brw, offset, size); + if (brw->gen >= 7) + gen7_dump_sampler_state(brw, offset, size); + else + dump_sampler_state(brw, offset, size); break; case AUB_TRACE_SAMPLER_DEFAULT_COLOR: dump_sdc(brw, offset);