[Mesa-dev] [PATCH V3 09/11] i965: Emit a second set of SURFACE_STATE for gather4 from textures.
Chris Forbes
chrisf at ijw.co.nz
Sun Sep 15 02:58:24 PDT 2013
This allows us to use a different surface format for gather4, which is
required for R32G32_FLOAT to work on Gen7.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
src/mesa/drivers/dri/i965/brw_context.h | 3 +-
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 57 ++++++++++++++++++-----
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 5 +-
3 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 3cf418f..214bcac 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -883,7 +883,8 @@ struct brw_context
void (*update_texture_surface)(struct gl_context *ctx,
unsigned unit,
- uint32_t *surf_offset);
+ uint32_t *surf_offset,
+ uint32_t (*tex_format_override)(uint32_t format));
void (*update_renderbuffer_surface)(struct brw_context *brw,
struct gl_renderbuffer *rb,
bool layered,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 25db2e0..10810dd 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -246,7 +246,8 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
static void
brw_update_texture_surface(struct gl_context *ctx,
unsigned unit,
- uint32_t *surf_offset)
+ uint32_t *surf_offset,
+ uint32_t (*tex_format_override)(uint32_t))
{
struct brw_context *brw = brw_context(ctx);
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
@@ -265,14 +266,17 @@ brw_update_texture_surface(struct gl_context *ctx,
surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
6 * 4, 32, surf_offset);
+ uint32_t tex_format = translate_tex_format(brw,
+ mt->format,
+ tObj->DepthMode,
+ sampler->sRGBDecode);
+ if (tex_format_override)
+ tex_format = tex_format_override(tex_format);
+
surf[0] = (translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
BRW_SURFACE_MIPMAPLAYOUT_BELOW << BRW_SURFACE_MIPLAYOUT_SHIFT |
BRW_SURFACE_CUBEFACE_ENABLES |
- (translate_tex_format(brw,
- mt->format,
- tObj->DepthMode,
- sampler->sRGBDecode) <<
- BRW_SURFACE_FORMAT_SHIFT));
+ tex_format << BRW_SURFACE_FORMAT_SHIFT);
surf[1] = intelObj->mt->region->bo->offset + intelObj->mt->offset; /* reloc */
@@ -736,7 +740,8 @@ const struct brw_tracked_state gen6_renderbuffer_surfaces = {
static void
update_stage_texture_surfaces(struct brw_context *brw,
const struct gl_program *prog,
- uint32_t *surf_offset)
+ uint32_t *surf_offset,
+ uint32_t (*tex_format_override)(uint32_t))
{
if (!prog)
return;
@@ -753,13 +758,22 @@ update_stage_texture_surfaces(struct brw_context *brw,
/* _NEW_TEXTURE */
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
- brw->vtbl.update_texture_surface(ctx, unit, surf_offset + s);
+ brw->vtbl.update_texture_surface(ctx, unit, surf_offset + s, tex_format_override);
}
}
}
}
+static uint32_t
+gather_format_override(uint32_t format) {
+ if (format == BRW_SURFACEFORMAT_R32G32_FLOAT)
+ return BRW_SURFACEFORMAT_R32G32_FLOAT_LD;
+ else
+ return format;
+}
+
+
/**
* Construct SURFACE_STATE objects for enabled textures.
*/
@@ -778,13 +792,34 @@ brw_update_texture_surfaces(struct brw_context *brw)
/* _NEW_TEXTURE */
update_stage_texture_surfaces(brw, vs,
brw->vs.base.surf_offset +
- SURF_INDEX_VEC4_TEXTURE(0));
+ SURF_INDEX_VEC4_TEXTURE(0),
+ NULL);
update_stage_texture_surfaces(brw, gs,
brw->gs.base.surf_offset +
- SURF_INDEX_VEC4_TEXTURE(0));
+ SURF_INDEX_VEC4_TEXTURE(0),
+ NULL);
update_stage_texture_surfaces(brw, fs,
brw->wm.base.surf_offset +
- SURF_INDEX_TEXTURE(0));
+ SURF_INDEX_TEXTURE(0),
+ NULL);
+
+ /* emit alternate set of surface state for gather. this
+ * allows the surface format to be overriden for only the
+ * gather4 messages. */
+ if (brw->gen >= 6) {
+ update_stage_texture_surfaces(brw, vs,
+ brw->vs.base.surf_offset +
+ SURF_INDEX_VEC4_GATHER_TEXTURE(0),
+ gather_format_override);
+ update_stage_texture_surfaces(brw, gs,
+ brw->gs.base.surf_offset +
+ SURF_INDEX_VEC4_GATHER_TEXTURE(0),
+ gather_format_override);
+ update_stage_texture_surfaces(brw, fs,
+ brw->wm.base.surf_offset +
+ SURF_INDEX_GATHER_TEXTURE(0),
+ gather_format_override);
+ }
brw->state.dirty.brw |= BRW_NEW_SURFACES;
}
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 37e3174..392207f 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -275,7 +275,8 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,
static void
gen7_update_texture_surface(struct gl_context *ctx,
unsigned unit,
- uint32_t *surf_offset)
+ uint32_t *surf_offset,
+ uint32_t (*tex_format_override)(uint32_t))
{
struct brw_context *brw = brw_context(ctx);
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
@@ -298,6 +299,8 @@ gen7_update_texture_surface(struct gl_context *ctx,
mt->format,
tObj->DepthMode,
sampler->sRGBDecode);
+ if (tex_format_override)
+ tex_format = tex_format_override(tex_format);
surf[0] = translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
tex_format << BRW_SURFACE_FORMAT_SHIFT |
--
1.8.4
More information about the mesa-dev
mailing list