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 <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
This commit is contained in:
Kenneth Graunke
2014-07-26 11:36:33 -07:00
parent 8fbc96ca74
commit c2f231e181
3 changed files with 49 additions and 5 deletions
+45 -4
View File
@@ -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
+3
View File
@@ -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 */
@@ -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)
{