[Mesa-dev] [PATCH 1/2] i965/skl: Upload qpitch in pixels for 1D textures
Neil Roberts
neil at linux.intel.com
Tue Feb 17 06:03:36 PST 2015
According to the bspec since Skylake the qpitch value in the surface
formats should be measured in pixels rather than rows for 1D textures.
---
src/mesa/drivers/dri/i965/gen8_surface_state.c | 30 +++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c b/src/mesa/drivers/dri/i965/gen8_surface_state.c
index d6b870e..4132b9b 100644
--- a/src/mesa/drivers/dri/i965/gen8_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c
@@ -145,6 +145,24 @@ gen8_emit_buffer_surface_state(struct brw_context *brw,
}
}
+static uint32_t
+qpitch_for_mt(struct brw_context *brw,
+ struct intel_mipmap_tree *mt,
+ uint32_t surf_type)
+{
+ uint32_t qpitch = mt->qpitch;
+
+ /* On Skylake+ for 1D linear surfaces the qpitch is measured in pixels
+ * rather than rows
+ */
+ if (brw->gen >= 9 &&
+ surf_type == BRW_SURFACE_1D &&
+ mt->tiling == I915_TILING_NONE)
+ qpitch *= mt->total_width;
+
+ return qpitch;
+}
+
static void
gen8_update_texture_surface(struct gl_context *ctx,
unsigned unit,
@@ -197,7 +215,11 @@ gen8_update_texture_surface(struct gl_context *ctx,
uint32_t *surf = allocate_surface_state(brw, surf_offset);
- surf[0] = translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
+ uint32_t surf_type = translate_tex_target(tObj->Target);
+
+ uint32_t qpitch = qpitch_for_mt(brw, mt, surf_type);
+
+ surf[0] = surf_type << BRW_SURFACE_TYPE_SHIFT |
tex_format << BRW_SURFACE_FORMAT_SHIFT |
vertical_alignment(mt) |
horizontal_alignment(mt) |
@@ -211,7 +233,7 @@ gen8_update_texture_surface(struct gl_context *ctx,
if (mt->logical_depth0 > 1 && tObj->Target != GL_TEXTURE_3D)
surf[0] |= GEN8_SURFACE_IS_ARRAY;
- surf[1] = SET_FIELD(mocs_wb, GEN8_SURFACE_MOCS) | mt->qpitch >> 2;
+ surf[1] = SET_FIELD(mocs_wb, GEN8_SURFACE_MOCS) | qpitch >> 2;
surf[2] = SET_FIELD(mt->logical_width0 - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(mt->logical_height0 - 1, GEN7_SURFACE_HEIGHT);
@@ -390,6 +412,8 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
uint32_t *surf =
allocate_surface_state(brw, &brw->wm.base.surf_offset[surf_index]);
+ uint32_t qpitch = qpitch_for_mt(brw, mt, surf_type);
+
surf[0] = (surf_type << BRW_SURFACE_TYPE_SHIFT) |
(is_array ? GEN7_SURFACE_IS_ARRAY : 0) |
(format << BRW_SURFACE_FORMAT_SHIFT) |
@@ -397,7 +421,7 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
horizontal_alignment(mt) |
surface_tiling_mode(tiling);
- surf[1] = SET_FIELD(mocs, GEN8_SURFACE_MOCS) | mt->qpitch >> 2;
+ surf[1] = SET_FIELD(mocs, GEN8_SURFACE_MOCS) | qpitch >> 2;
surf[2] = SET_FIELD(width - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(height - 1, GEN7_SURFACE_HEIGHT);
--
1.9.3
More information about the mesa-dev
mailing list