vkd3d-shader/ir: Properly lower texldb.

This commit is contained in:
Francisco Casas 2024-12-04 15:16:45 -03:00 committed by Henri Verbeet
parent 59df26af79
commit 7cc802afd7
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 29 additions and 10 deletions

View File

@ -703,7 +703,8 @@ static enum vkd3d_result vsir_program_lower_sm1_sincos(struct vsir_program *prog
return VKD3D_OK; return VKD3D_OK;
} }
static enum vkd3d_result vsir_program_lower_tex(struct vsir_program *program, struct vkd3d_shader_instruction *tex) static enum vkd3d_result vsir_program_lower_tex(struct vsir_program *program,
struct vkd3d_shader_instruction *tex, struct vkd3d_shader_message_context *message_context)
{ {
unsigned int idx = tex->src[1].reg.idx[0].offset; unsigned int idx = tex->src[1].reg.idx[0].offset;
struct vkd3d_shader_src_param *srcs; struct vkd3d_shader_src_param *srcs;
@ -711,16 +712,34 @@ static enum vkd3d_result vsir_program_lower_tex(struct vsir_program *program, st
VKD3D_ASSERT(tex->src[1].reg.idx_count == 1); VKD3D_ASSERT(tex->src[1].reg.idx_count == 1);
VKD3D_ASSERT(!tex->src[1].reg.idx[0].rel_addr); VKD3D_ASSERT(!tex->src[1].reg.idx[0].rel_addr);
if (!(srcs = shader_src_param_allocator_get(&program->instructions.src_params, 3))) if (!(srcs = shader_src_param_allocator_get(&program->instructions.src_params, 4)))
return VKD3D_ERROR_OUT_OF_MEMORY; return VKD3D_ERROR_OUT_OF_MEMORY;
srcs[0] = tex->src[0]; srcs[0] = tex->src[0];
vsir_src_param_init_resource(&srcs[1], idx, idx); vsir_src_param_init_resource(&srcs[1], idx, idx);
vsir_src_param_init_sampler(&srcs[2], idx, idx); vsir_src_param_init_sampler(&srcs[2], idx, idx);
tex->opcode = VKD3DSIH_SAMPLE; if (!tex->flags)
tex->src = srcs; {
tex->src_count = 3; tex->opcode = VKD3DSIH_SAMPLE;
tex->src = srcs;
tex->src_count = 3;
}
else if (tex->flags == VKD3DSI_TEXLD_BIAS)
{
tex->opcode = VKD3DSIH_SAMPLE_B;
tex->src = srcs;
tex->src_count = 4;
srcs[3] = tex->src[0];
srcs[3].swizzle = VKD3D_SHADER_SWIZZLE(W, W, W, W);
}
else
{
vkd3d_shader_error(message_context, &tex->location,
VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, "Unhandled tex flags %#x.", tex->flags);
return VKD3D_ERROR_NOT_IMPLEMENTED;
}
return VKD3D_OK; return VKD3D_OK;
} }
@ -885,7 +904,7 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr
break; break;
case VKD3DSIH_TEX: case VKD3DSIH_TEX:
if ((ret = vsir_program_lower_tex(program, ins)) < 0) if ((ret = vsir_program_lower_tex(program, ins, message_context)) < 0)
return ret; return ret;
break; break;

View File

@ -37,11 +37,11 @@ probe (0, 0) rgba (10.0, 0.0, 10.0, 0.0)
uniform 0 float4 7.5 0.0 0.0 0.0 uniform 0 float4 7.5 0.0 0.0 0.0
todo(msl) draw quad todo(msl) draw quad
todo(sm<4) probe (0, 0) rgba(4.0, 0.0, 10.0, 0.0) probe (0, 0) rgba(4.0, 0.0, 10.0, 0.0)
uniform 0 float4 8.5 0.0 0.0 0.0 uniform 0 float4 8.5 0.0 0.0 0.0
todo(msl) draw quad todo(msl) draw quad
todo(sm<4) probe (0, 0) rgba(0.0, 0.0, 10.0, 0.0) probe (0, 0) rgba(0.0, 0.0, 10.0, 0.0)
[require] [require]
shader model >= 3.0 shader model >= 3.0
@ -65,8 +65,8 @@ probe (0, 0) rgba (10.0, 0.0, 10.0, 0.0)
uniform 0 float4 7.5 0.0 0.0 0.0 uniform 0 float4 7.5 0.0 0.0 0.0
todo(msl) draw quad todo(msl) draw quad
todo(sm<4) probe (0,0) rgba (4.0, 0.0, 10.0, 0.0) probe (0,0) rgba(4.0, 0.0, 10.0, 0.0)
uniform 0 float4 8.5 0.0 0.0 0.0 uniform 0 float4 8.5 0.0 0.0 0.0
todo(msl) draw quad todo(msl) draw quad
todo(sm<4) probe (0,0) rgba (0.0, 0.0, 10.0, 0.0) probe (0,0) rgba(0.0, 0.0, 10.0, 0.0)