vkd3d-shader/ir: Properly lower texldp.

This commit is contained in:
Francisco Casas 2024-12-10 15:01:43 -03:00 committed by Henri Verbeet
parent 02fc26507b
commit 825784322d
Notes: Henri Verbeet 2024-12-18 17:39:16 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1310
2 changed files with 62 additions and 6 deletions

View File

@ -703,6 +703,54 @@ static enum vkd3d_result vsir_program_lower_sm1_sincos(struct vsir_program *prog
return VKD3D_OK;
}
static enum vkd3d_result vsir_program_lower_texldp(struct vsir_program *program,
struct vkd3d_shader_instruction *tex, unsigned int *tmp_idx)
{
struct vkd3d_shader_instruction_array *instructions = &program->instructions;
struct vkd3d_shader_location *location = &tex->location;
struct vkd3d_shader_instruction *div_ins, *tex_ins;
size_t pos = tex - instructions->elements;
unsigned int w_comp;
w_comp = vsir_swizzle_get_component(tex->src[0].swizzle, 3);
if (!shader_instruction_array_insert_at(instructions, pos + 1, 2))
return VKD3D_ERROR_OUT_OF_MEMORY;
if (*tmp_idx == ~0u)
*tmp_idx = program->temp_count++;
div_ins = &instructions->elements[pos + 1];
tex_ins = &instructions->elements[pos + 2];
if (!vsir_instruction_init_with_params(program, div_ins, location, VKD3DSIH_DIV, 1, 2))
return VKD3D_ERROR_OUT_OF_MEMORY;
vsir_dst_param_init(&div_ins->dst[0], VKD3DSPR_TEMP, VKD3D_DATA_FLOAT, 1);
div_ins->dst[0].reg.dimension = VSIR_DIMENSION_VEC4;
div_ins->dst[0].reg.idx[0].offset = *tmp_idx;
div_ins->dst[0].write_mask = VKD3DSP_WRITEMASK_ALL;
div_ins->src[0] = tex->src[0];
div_ins->src[1] = tex->src[0];
div_ins->src[1].swizzle = vkd3d_shader_create_swizzle(w_comp, w_comp, w_comp, w_comp);
if (!vsir_instruction_init_with_params(program, tex_ins, location, VKD3DSIH_TEX, 1, 2))
return VKD3D_ERROR_OUT_OF_MEMORY;
tex_ins->dst[0] = tex->dst[0];
tex_ins->src[0].reg = div_ins->dst[0].reg;
tex_ins->src[0].swizzle = VKD3D_SHADER_NO_SWIZZLE;
tex_ins->src[1] = tex->src[1];
vkd3d_shader_instruction_make_nop(tex);
return VKD3D_OK;
}
static enum vkd3d_result vsir_program_lower_tex(struct vsir_program *program,
struct vkd3d_shader_instruction *tex, struct vkd3d_shader_message_context *message_context)
{
@ -904,8 +952,16 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr
break;
case VKD3DSIH_TEX:
if ((ret = vsir_program_lower_tex(program, ins, message_context)) < 0)
return ret;
if (ins->flags == VKD3DSI_TEXLD_PROJECT)
{
if ((ret = vsir_program_lower_texldp(program, ins, &tmp_idx)) < 0)
return ret;
}
else
{
if ((ret = vsir_program_lower_tex(program, ins, message_context)) < 0)
return ret;
}
break;
case VKD3DSIH_TEXLDD:

View File

@ -86,16 +86,16 @@ float4 main() : sv_target
[test]
uniform 0 float4 50.0 50.0 42.0 100
todo(sm<4 | msl) draw quad
todo(msl) draw quad
probe (0, 0) rgba(1.0, 1.0, 0, 1.0)
uniform 0 float4 0.075 0.025 -42.0 0.1
todo(sm<4 | msl) draw quad
todo(msl) draw quad
probe (0, 0) rgba(1.75, 0.25, 0, 1.0)
uniform 0 float4 0.5 1.5 0.0 2.0
todo(sm<4 | msl) draw quad
todo(msl) draw quad
probe (0, 0) rgba(0.25, 1.75, 0, 1.0)
uniform 0 float4 1.0 1.0 0.0 0.0
todo(sm<4 | msl) draw quad
todo(msl) draw quad
probe (0, 0) rgba(2.0, 2.0, 0, 1.0)
[sampler 0]