diff options
author | Charmaine Lee <charmainel@vmware.com> | 2022-08-18 12:38:38 -0700 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2022-09-19 22:40:06 +0000 |
commit | 5c4d90f1aa373be43658b87dafd40c6fadfae0bb (patch) | |
tree | 373603dc1d134df8514a4688aa4b297550a2fe1f | |
parent | b47e856216e046b7e6571b2102df3fbc8600f353 (diff) |
svga: fix invalid component access of domain location
Tesscoord is declared as vec3 in the incoming shader but the z component
of a tesscoord should only be referenced in the domain shader if the
tessellator domain is of triangle type.
Fixes vmx crash running GFXBench-Tessellation with MTL Renderer.
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Reviewed-by: Min-Yu Huang <min-yuhuang@vmware.com>
(cherry picked from commit f73862d339fbeac14fe7e1e1dc9e73d3501e0c97)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18235>
-rw-r--r-- | src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c index a61a1b80882..f0d4ccc6a8f 100644 --- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c +++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c @@ -413,6 +413,7 @@ struct svga_shader_emitter_v10 boolean vertices_order_cw; boolean point_mode; unsigned tesscoord_sys_index; + unsigned swizzle_max; unsigned prim_id_index; /* primitive id */ struct { unsigned in_index; /* real tessinner input register */ @@ -1780,6 +1781,14 @@ emit_src_register(struct svga_shader_emitter_v10 *emit, operand0.numComponents = VGPU10_OPERAND_4_COMPONENT; operand0.operandType = VGPU10_OPERAND_TYPE_INPUT_DOMAIN_POINT; index = 0; + + /* Make sure swizzles are of those components allowed according + * to the tessellator domain. + */ + swizzleX = MIN2(swizzleX, emit->tes.swizzle_max); + swizzleY = MIN2(swizzleY, emit->tes.swizzle_max); + swizzleZ = MIN2(swizzleZ, emit->tes.swizzle_max); + swizzleW = MIN2(swizzleW, emit->tes.swizzle_max); } else if (index == emit->tes.inner.tgsi_index) { file = TGSI_FILE_TEMPORARY; @@ -3145,6 +3154,12 @@ emit_domain_shader_declarations(struct svga_shader_emitter_v10 *emit) end_emit_instruction(emit); emit_tessellator_domain(emit, emit->tes.prim_mode); + + /* Specify a max for swizzles of the domain point according to the + * tessellator domain type. + */ + emit->tes.swizzle_max = emit->tes.prim_mode == PIPE_PRIM_TRIANGLES ? + TGSI_SWIZZLE_Z : TGSI_SWIZZLE_Y; } |