diff options
author | Kenneth Graunke <[email protected]> | 2014-07-26 11:36:33 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2014-08-02 05:14:42 -0700 |
commit | c2f231e18104e3300d9fab86600e7e0f6c77d1fb (patch) | |
tree | c3c39022135b9412f363cfa7fd2a466488d7360c | |
parent | 8fbc96ca74012d3f94564d88692e170bc4ef7937 (diff) |
i965: Make brw_upload_sampler_state_table handle Gen7+ as well.
This copies a few changes from gen7_upload_sampler_state_table; the next
patch will delete that function.
Gen7+ has per-stage sampler state pointer update packets, so we emit
them as soon as we emit a new table for a stage. On Gen6 and earlier,
we have a single packet, so we delay until we've changed everything
that's going to be changed.
v2: Split 3DSTATE_SAMPLER_STATE_POINTERS_XS packet emission into a
helper function (suggested by Topi Pohjolainen).
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_sampler_state.c | 49 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_state.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/gen7_sampler_state.c | 2 |
3 files changed, 49 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c index a14b5b38255..7ccf14640f8 100644 --- a/src/mesa/drivers/dri/i965/brw_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c @@ -39,11 +39,37 @@ #include "brw_context.h" #include "brw_state.h" #include "brw_defines.h" +#include "intel_batchbuffer.h" #include "intel_mipmap_tree.h" #include "main/macros.h" #include "main/samplerobj.h" +/** + * Emit a 3DSTATE_SAMPLER_STATE_POINTERS_{VS,HS,GS,DS,PS} packet. + */ +static void +gen7_emit_sampler_state_pointers_xs(struct brw_context *brw, + struct brw_stage_state *stage_state) +{ + static const uint16_t packet_headers[] = { + [MESA_SHADER_VERTEX] = _3DSTATE_SAMPLER_STATE_POINTERS_VS, + [MESA_SHADER_GEOMETRY] = _3DSTATE_SAMPLER_STATE_POINTERS_GS, + [MESA_SHADER_FRAGMENT] = _3DSTATE_SAMPLER_STATE_POINTERS_PS, + }; + + /* Ivybridge requires a workaround flush before VS packets. */ + if (brw->gen == 7 && !brw->is_haswell && !brw->is_baytrail && + stage_state->stage == MESA_SHADER_VERTEX) { + gen7_emit_vs_workaround_flush(brw); + } + + BEGIN_BATCH(2); + OUT_BATCH(packet_headers[stage_state->stage] << 16 | (2 - 2)); + OUT_BATCH(stage_state->sampler_offset); + ADVANCE_BATCH(); +} + uint32_t translate_wrap_mode(struct brw_context *brw, GLenum wrap, bool using_nearest) { @@ -402,9 +428,16 @@ brw_upload_sampler_state_table(struct brw_context *brw, if (SamplersUsed & (1 << s)) { const unsigned unit = prog->SamplerUnits[s]; if (ctx->Texture.Unit[unit]._Current) { - brw_update_sampler_state(brw, unit, - (struct brw_sampler_state *) sampler_state, - batch_offset_for_sampler_state); + if (brw->gen >= 7) { + gen7_update_sampler_state(brw, unit, + (struct gen7_sampler_state *) + sampler_state); + } else { + brw_update_sampler_state(brw, unit, + (struct brw_sampler_state *) + sampler_state, + batch_offset_for_sampler_state); + } } } @@ -412,7 +445,15 @@ brw_upload_sampler_state_table(struct brw_context *brw, batch_offset_for_sampler_state += size_in_bytes; } - brw->state.dirty.cache |= CACHE_NEW_SAMPLER; + if (brw->gen >= 7) { + /* Emit a 3DSTATE_SAMPLER_STATE_POINTERS_XS packet. */ + gen7_emit_sampler_state_pointers_xs(brw, stage_state); + } else { + /* Flag that the sampler state table pointer has changed; later atoms + * will handle it. + */ + brw->state.dirty.cache |= CACHE_NEW_SAMPLER; + } } static void diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 77de7851841..64652cbbeb6 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -252,6 +252,9 @@ void upload_default_color(struct brw_context *brw, void gen4_init_vtable_sampler_functions(struct brw_context *brw); /* gen7_sampler_state.c */ +void gen7_update_sampler_state(struct brw_context *brw, + int unit, + struct gen7_sampler_state *sampler_state); void gen7_init_vtable_sampler_functions(struct brw_context *brw); /* gen6_sf_state.c */ diff --git a/src/mesa/drivers/dri/i965/gen7_sampler_state.c b/src/mesa/drivers/dri/i965/gen7_sampler_state.c index b6d45cc0d3f..66af26a63e4 100644 --- a/src/mesa/drivers/dri/i965/gen7_sampler_state.c +++ b/src/mesa/drivers/dri/i965/gen7_sampler_state.c @@ -33,7 +33,7 @@ /** * Sets the sampler state for a single unit. */ -static void +void gen7_update_sampler_state(struct brw_context *brw, int unit, struct gen7_sampler_state *sampler) { |