[Mesa-dev] [PATCH 3/7] i965: Move texture swizzle resolving into dispatcher
Francisco Jerez
currojerez at riseup.net
Thu May 7 07:15:37 PDT 2015
From: Topi Pohjolainen <topi.pohjolainen at intel.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
[ Francisco Jerez: Non-trivial rebase. ]
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
---
src/mesa/drivers/dri/i965/brw_context.h | 4 ++--
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 20 +++++++++++++++-----
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 16 ++--------------
src/mesa/drivers/dri/i965/gen8_surface_state.c | 16 ++--------------
4 files changed, 21 insertions(+), 35 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index d599ba8..9e85dd7 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -983,10 +983,10 @@ struct brw_context
struct
{
- void (*update_texture_surface)(struct gl_context *ctx,
+ void (*update_texture_surface)(struct brw_context *brw,
struct intel_mipmap_tree *mt,
struct gl_texture_object *tObj,
- uint32_t tex_format,
+ uint32_t tex_format, unsigned swizzle,
uint32_t *surf_offset,
bool for_gather);
uint32_t (*update_renderbuffer_surface)(struct brw_context *brw,
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 7ed7e18..3dddf89 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -308,14 +308,13 @@ update_buffer_texture_surface(struct gl_context *ctx,
}
static void
-brw_update_texture_surface(struct gl_context *ctx,
+brw_update_texture_surface(struct brw_context *brw,
struct intel_mipmap_tree *mt,
struct gl_texture_object *tObj,
- uint32_t tex_format,
+ uint32_t tex_format, unsigned swizzle /* unused */,
uint32_t *surf_offset,
bool for_gather)
{
- struct brw_context *brw = brw_context(ctx);
struct intel_texture_object *intelObj = intel_texture_object(tObj);
uint32_t *surf;
@@ -801,6 +800,17 @@ update_texture_surface(struct gl_context *ctx,
struct intel_mipmap_tree *mt = intel_obj->mt;
const struct gl_texture_image *firstImage = obj->Image[0][obj->BaseLevel];
const struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
+
+ /* Handling GL_ALPHA as a surface format override breaks 1.30+ style
+ * texturing functions that return a float, as our code generation always
+ * selects the .x channel (which would always be 0).
+ */
+ const bool alpha_depth = obj->DepthMode == GL_ALPHA &&
+ (firstImage->_BaseFormat == GL_DEPTH_COMPONENT ||
+ firstImage->_BaseFormat == GL_DEPTH_STENCIL);
+ const unsigned swizzle = (unlikely(alpha_depth) ? SWIZZLE_XYZW :
+ brw_get_texture_swizzle(&brw->ctx, obj));
+
unsigned format = translate_tex_format(brw, intel_obj->_Format,
sampler->sRGBDecode);
if (obj->StencilSampling && firstImage->_BaseFormat == GL_DEPTH_STENCIL) {
@@ -810,8 +820,8 @@ update_texture_surface(struct gl_context *ctx,
format = BRW_SURFACEFORMAT_R8_UINT;
}
- brw->vtbl.update_texture_surface(ctx, mt, obj, format, surf_offset,
- for_gather);
+ brw->vtbl.update_texture_surface(brw, mt, obj, format, swizzle,
+ surf_offset, for_gather);
}
}
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 7e3ee67..7576b20 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -348,14 +348,13 @@ gen7_emit_texture_surface_state(struct brw_context *brw,
}
static void
-gen7_update_texture_surface(struct gl_context *ctx,
+gen7_update_texture_surface(struct brw_context *brw,
struct intel_mipmap_tree *mt,
struct gl_texture_object *obj,
- uint32_t tex_format,
+ uint32_t tex_format, unsigned swizzle,
uint32_t *surf_offset,
bool for_gather)
{
- struct brw_context *brw = brw_context(ctx);
struct intel_texture_object *intel_obj = intel_texture_object(obj);
/* If this is a view with restricted NumLayers, then our effective depth
* is not just the miptree depth.
@@ -363,17 +362,6 @@ gen7_update_texture_surface(struct gl_context *ctx,
const unsigned depth = (obj->Immutable && obj->Target != GL_TEXTURE_3D ?
obj->NumLayers : mt->logical_depth0);
- /* Handling GL_ALPHA as a surface format override breaks 1.30+ style
- * texturing functions that return a float, as our code generation always
- * selects the .x channel (which would always be 0).
- */
- struct gl_texture_image *firstImage = obj->Image[0][obj->BaseLevel];
- const bool alpha_depth = obj->DepthMode == GL_ALPHA &&
- (firstImage->_BaseFormat == GL_DEPTH_COMPONENT ||
- firstImage->_BaseFormat == GL_DEPTH_STENCIL);
- const unsigned swizzle = (unlikely(alpha_depth) ? SWIZZLE_XYZW :
- brw_get_texture_swizzle(&brw->ctx, obj));
-
if (for_gather && tex_format == BRW_SURFACEFORMAT_R32G32_FLOAT)
tex_format = BRW_SURFACEFORMAT_R32G32_FLOAT_LD;
diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c b/src/mesa/drivers/dri/i965/gen8_surface_state.c
index 4e518b5..6dc0f9b 100644
--- a/src/mesa/drivers/dri/i965/gen8_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c
@@ -247,15 +247,13 @@ gen8_emit_texture_surface_state(struct brw_context *brw,
}
static void
-gen8_update_texture_surface(struct gl_context *ctx,
+gen8_update_texture_surface(struct brw_context *brw,
struct intel_mipmap_tree *mt,
struct gl_texture_object *obj,
- uint32_t tex_format,
+ uint32_t tex_format, unsigned swizzle,
uint32_t *surf_offset,
bool for_gather)
{
- struct brw_context *brw = brw_context(ctx);
- struct gl_texture_image *firstImage = obj->Image[0][obj->BaseLevel];
struct intel_texture_object *intel_obj = intel_texture_object(obj);
/* If this is a view with restricted NumLayers, then our effective depth
* is not just the miptree depth.
@@ -263,16 +261,6 @@ gen8_update_texture_surface(struct gl_context *ctx,
const unsigned depth = (obj->Immutable && obj->Target != GL_TEXTURE_3D ?
obj->NumLayers : mt->logical_depth0);
- /* Handling GL_ALPHA as a surface format override breaks 1.30+ style
- * texturing functions that return a float, as our code generation always
- * selects the .x channel (which would always be 0).
- */
- const bool alpha_depth = obj->DepthMode == GL_ALPHA &&
- (firstImage->_BaseFormat == GL_DEPTH_COMPONENT ||
- firstImage->_BaseFormat == GL_DEPTH_STENCIL);
- const unsigned swizzle = (unlikely(alpha_depth) ? SWIZZLE_XYZW :
- brw_get_texture_swizzle(&brw->ctx, obj));
-
gen8_emit_texture_surface_state(brw, mt, obj->Target,
obj->MinLayer, obj->MinLayer + depth,
obj->MinLevel + obj->BaseLevel,
--
2.3.5
More information about the mesa-dev
mailing list