mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
vkd3d-shader/dxil: Parse the gather offset as an int2.
Instead of an int3. Gather operations expect an offset with only two components. Currently the following field (which is the gather channel) is parsed as a third component, which leads to wrong and invalid results. This fixes a crash on a shader from WRC Generations.
This commit is contained in:
committed by
Henri Verbeet
parent
cb3367c66d
commit
065430547c
Notes:
Henri Verbeet
2025-11-12 15:31:08 +01:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1822
@@ -6142,11 +6142,14 @@ static unsigned int sm6_value_get_texel_offset(const struct sm6_value *value, st
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void instruction_set_texel_offset(struct vkd3d_shader_instruction *ins,
|
static void instruction_set_texel_offset(struct vkd3d_shader_instruction *ins,
|
||||||
const struct sm6_value **operands, struct sm6_parser *sm6)
|
const struct sm6_value **operands, unsigned int count, struct sm6_parser *sm6)
|
||||||
{
|
{
|
||||||
ins->texel_offset.u = sm6_value_get_texel_offset(operands[0], sm6);
|
ins->texel_offset.u = sm6_value_get_texel_offset(operands[0], sm6);
|
||||||
ins->texel_offset.v = sm6_value_get_texel_offset(operands[1], sm6);
|
ins->texel_offset.v = sm6_value_get_texel_offset(operands[1], sm6);
|
||||||
|
if (count == 3)
|
||||||
ins->texel_offset.w = sm6_value_get_texel_offset(operands[2], sm6);
|
ins->texel_offset.w = sm6_value_get_texel_offset(operands[2], sm6);
|
||||||
|
else
|
||||||
|
ins->texel_offset.w = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sm6_parser_emit_dx_sample(struct sm6_parser *sm6, enum dx_intrinsic_opcode op,
|
static void sm6_parser_emit_dx_sample(struct sm6_parser *sm6, enum dx_intrinsic_opcode op,
|
||||||
@@ -6228,7 +6231,7 @@ static void sm6_parser_emit_dx_sample(struct sm6_parser *sm6, enum dx_intrinsic_
|
|||||||
src_param_init_vector_from_reg(&src_params[0], &coord);
|
src_param_init_vector_from_reg(&src_params[0], &coord);
|
||||||
src_param_init_vector_from_handle(sm6, &src_params[1], &resource->u.handle);
|
src_param_init_vector_from_handle(sm6, &src_params[1], &resource->u.handle);
|
||||||
src_param_init_vector_from_handle(sm6, &src_params[2], &sampler->u.handle);
|
src_param_init_vector_from_handle(sm6, &src_params[2], &sampler->u.handle);
|
||||||
instruction_set_texel_offset(ins, &operands[6], sm6);
|
instruction_set_texel_offset(ins, &operands[6], 3, sm6);
|
||||||
|
|
||||||
instruction_dst_param_init_ssa_vector(ins, component_count, sm6);
|
instruction_dst_param_init_ssa_vector(ins, component_count, sm6);
|
||||||
}
|
}
|
||||||
@@ -6402,7 +6405,7 @@ static void sm6_parser_emit_dx_texture_gather(struct sm6_parser *sm6, enum dx_in
|
|||||||
if (extended_offset)
|
if (extended_offset)
|
||||||
src_param_init_vector_from_reg(&src_params[1], &offset);
|
src_param_init_vector_from_reg(&src_params[1], &offset);
|
||||||
else
|
else
|
||||||
instruction_set_texel_offset(ins, &operands[6], sm6);
|
instruction_set_texel_offset(ins, &operands[6], 2, sm6);
|
||||||
src_param_init_vector_from_handle(sm6, &src_params[1 + extended_offset], &resource->u.handle);
|
src_param_init_vector_from_handle(sm6, &src_params[1 + extended_offset], &resource->u.handle);
|
||||||
src_param_init_vector_from_handle(sm6, &src_params[2 + extended_offset], &sampler->u.handle);
|
src_param_init_vector_from_handle(sm6, &src_params[2 + extended_offset], &sampler->u.handle);
|
||||||
/* Swizzle stored in the sampler parameter is the scalar component index to be gathered. */
|
/* Swizzle stored in the sampler parameter is the scalar component index to be gathered. */
|
||||||
@@ -6448,7 +6451,7 @@ static void sm6_parser_emit_dx_texture_load(struct sm6_parser *sm6, enum dx_intr
|
|||||||
ins = state->ins;
|
ins = state->ins;
|
||||||
instruction_init_with_resource(ins, is_uav ? VSIR_OP_LD_UAV_TYPED
|
instruction_init_with_resource(ins, is_uav ? VSIR_OP_LD_UAV_TYPED
|
||||||
: is_multisample ? VSIR_OP_LD2DMS : VSIR_OP_LD, resource, sm6);
|
: is_multisample ? VSIR_OP_LD2DMS : VSIR_OP_LD, resource, sm6);
|
||||||
instruction_set_texel_offset(ins, &operands[5], sm6);
|
instruction_set_texel_offset(ins, &operands[5], 3, sm6);
|
||||||
|
|
||||||
for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
|
for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
|
||||||
ins->resource_data_type[i] = resource->u.handle.d->resource_data_type;
|
ins->resource_data_type[i] = resource->u.handle.d->resource_data_type;
|
||||||
|
|||||||
Reference in New Issue
Block a user