diff options
author | Chris Forbes <[email protected]> | 2014-02-03 22:14:45 +1300 |
---|---|---|
committer | Chris Forbes <[email protected]> | 2014-02-08 10:32:19 +1300 |
commit | c2d51aaa11c2593edb9f4b9279745d39c79ff23c (patch) | |
tree | 7d41ad9bd4a5dc257ac27e99abb1f2fe4fd4b1ac | |
parent | 2b7bbd89e87c4025cfc5513a078b1e7a10640357 (diff) |
i965: Add surface format overrides for Gen6 gather
Signed-off-by: Chris Forbes <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 37 |
1 files changed, 32 insertions, 5 deletions
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 dd96c9bfd3c..d16953f9db0 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -282,15 +282,42 @@ brw_update_texture_surface(struct gl_context *ctx, surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, 6 * 4, 32, surf_offset); - (void) for_gather; /* no w/a to apply for this gen */ + uint32_t tex_format = translate_tex_format(brw, mt->format, + sampler->sRGBDecode); + + if (for_gather) { + /* Sandybridge's gather4 message is broken for integer formats. + * To work around this, we pretend the surface is UNORM for + * 8 or 16-bit formats, and emit shader instructions to recover + * the real INT/UINT value. For 32-bit formats, we pretend + * the surface is FLOAT, and simply reinterpret the resulting + * bits. + */ + switch (tex_format) { + case BRW_SURFACEFORMAT_R8_SINT: + case BRW_SURFACEFORMAT_R8_UINT: + tex_format = BRW_SURFACEFORMAT_R8_UNORM; + break; + + case BRW_SURFACEFORMAT_R16_SINT: + case BRW_SURFACEFORMAT_R16_UINT: + tex_format = BRW_SURFACEFORMAT_R16_UNORM; + break; + + case BRW_SURFACEFORMAT_R32_SINT: + case BRW_SURFACEFORMAT_R32_UINT: + tex_format = BRW_SURFACEFORMAT_R32_FLOAT; + break; + + default: + break; + } + } 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, - sampler->sRGBDecode) << - BRW_SURFACE_FORMAT_SHIFT)); + tex_format << BRW_SURFACE_FORMAT_SHIFT); surf[1] = intelObj->mt->region->bo->offset64 + intelObj->mt->offset; /* reloc */ |