vkd3d-shader/glsl: Implement VKD3DSIH_SAMPLE_C_LZ.

This commit is contained in:
Henri Verbeet 2024-10-18 20:27:01 +02:00
parent 5958e527e5
commit 21e9029177
Notes: Henri Verbeet 2024-10-22 20:55:33 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1206
2 changed files with 20 additions and 12 deletions

View File

@ -919,7 +919,7 @@ static void shader_glsl_sample(struct vkd3d_glsl_generator *gen, const struct vk
sampler_space = d->register_space; sampler_space = d->register_space;
shadow = d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE; shadow = d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE;
if (ins->opcode == VKD3DSIH_SAMPLE_C) if (ins->opcode == VKD3DSIH_SAMPLE_C || ins->opcode == VKD3DSIH_SAMPLE_C_LZ)
{ {
if (!shadow) if (!shadow)
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
@ -942,10 +942,13 @@ static void shader_glsl_sample(struct vkd3d_glsl_generator *gen, const struct vk
glsl_dst_init(&dst, gen, ins, &ins->dst[0]); glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
sample = vkd3d_string_buffer_get(&gen->string_buffers); sample = vkd3d_string_buffer_get(&gen->string_buffers);
if (ins->opcode == VKD3DSIH_SAMPLE_C_LZ)
vkd3d_string_buffer_printf(sample, "textureLod(");
else
vkd3d_string_buffer_printf(sample, "texture("); vkd3d_string_buffer_printf(sample, "texture(");
shader_glsl_print_combined_sampler_name(sample, gen, resource_idx, resource_space, sampler_idx, sampler_space); shader_glsl_print_combined_sampler_name(sample, gen, resource_idx, resource_space, sampler_idx, sampler_space);
vkd3d_string_buffer_printf(sample, ", "); vkd3d_string_buffer_printf(sample, ", ");
if (ins->opcode == VKD3DSIH_SAMPLE_C) if (ins->opcode == VKD3DSIH_SAMPLE_C || ins->opcode == VKD3DSIH_SAMPLE_C_LZ)
shader_glsl_print_shadow_coord(sample, gen, &ins->src[0], &ins->src[3], coord_size); shader_glsl_print_shadow_coord(sample, gen, &ins->src[0], &ins->src[3], coord_size);
else else
shader_glsl_print_src(sample, gen, &ins->src[0], shader_glsl_print_src(sample, gen, &ins->src[0],
@ -955,6 +958,10 @@ static void shader_glsl_sample(struct vkd3d_glsl_generator *gen, const struct vk
vkd3d_string_buffer_printf(sample, ", "); vkd3d_string_buffer_printf(sample, ", ");
shader_glsl_print_src(sample, gen, &ins->src[3], VKD3DSP_WRITEMASK_0, ins->src[3].reg.data_type); shader_glsl_print_src(sample, gen, &ins->src[3], VKD3DSP_WRITEMASK_0, ins->src[3].reg.data_type);
} }
else if (ins->opcode == VKD3DSIH_SAMPLE_C_LZ)
{
vkd3d_string_buffer_printf(sample, ", 0.0");
}
vkd3d_string_buffer_printf(sample, ")"); vkd3d_string_buffer_printf(sample, ")");
shader_glsl_print_swizzle(sample, ins->src[1].swizzle, ins->dst[0].write_mask); shader_glsl_print_swizzle(sample, ins->src[1].swizzle, ins->dst[0].write_mask);
@ -1549,6 +1556,7 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_SAMPLE: case VKD3DSIH_SAMPLE:
case VKD3DSIH_SAMPLE_B: case VKD3DSIH_SAMPLE_B:
case VKD3DSIH_SAMPLE_C: case VKD3DSIH_SAMPLE_C:
case VKD3DSIH_SAMPLE_C_LZ:
shader_glsl_sample(gen, ins); shader_glsl_sample(gen, ins);
break; break;
case VKD3DSIH_SQRT: case VKD3DSIH_SQRT:

View File

@ -27,7 +27,7 @@ float4 main() : sv_target
} }
[test] [test]
todo(glsl) draw quad draw quad
probe (0, 0) rgba (0.0, 0.0, 0.0, 1.0) probe (0, 0) rgba (0.0, 0.0, 0.0, 1.0)
[sampler 0] [sampler 0]
@ -36,7 +36,7 @@ address clamp clamp clamp
comparison less comparison less
[test] [test]
todo(glsl) draw quad draw quad
probe (0, 0) rgba (1.0, 0.0, 0.0, 1.0) probe (0, 0) rgba (1.0, 0.0, 0.0, 1.0)
[sampler 0] [sampler 0]
@ -45,7 +45,7 @@ address clamp clamp clamp
comparison equal comparison equal
[test] [test]
todo(glsl) draw quad draw quad
probe (0, 0) rgba (0.0, 1.0, 0.0, 1.0) probe (0, 0) rgba (0.0, 1.0, 0.0, 1.0)
[sampler 0] [sampler 0]
@ -54,7 +54,7 @@ address clamp clamp clamp
comparison less equal comparison less equal
[test] [test]
todo(glsl) draw quad draw quad
probe (0, 0) rgba (1.0, 1.0, 0.0, 1.0) probe (0, 0) rgba (1.0, 1.0, 0.0, 1.0)
[sampler 0] [sampler 0]
@ -63,7 +63,7 @@ address clamp clamp clamp
comparison greater comparison greater
[test] [test]
todo(glsl) draw quad draw quad
probe (0, 0) rgba (0.0, 0.0, 1.0, 1.0) probe (0, 0) rgba (0.0, 0.0, 1.0, 1.0)
[sampler 0] [sampler 0]
@ -72,7 +72,7 @@ address clamp clamp clamp
comparison not equal comparison not equal
[test] [test]
todo(glsl) draw quad draw quad
probe (0, 0) rgba (1.0, 0.0, 1.0, 1.0) probe (0, 0) rgba (1.0, 0.0, 1.0, 1.0)
[sampler 0] [sampler 0]
@ -81,7 +81,7 @@ address clamp clamp clamp
comparison greater equal comparison greater equal
[test] [test]
todo(glsl) draw quad draw quad
probe (0, 0) rgba (0.0, 1.0, 1.0, 1.0) probe (0, 0) rgba (0.0, 1.0, 1.0, 1.0)
[sampler 0] [sampler 0]
@ -90,7 +90,7 @@ address clamp clamp clamp
comparison always comparison always
[test] [test]
todo(glsl) draw quad draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0) probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
@ -118,7 +118,7 @@ float4 main() : sv_target
[test] [test]
uniform 0 float 0.5 uniform 0 float 0.5
uniform 1 float 0.00000007 uniform 1 float 0.00000007
todo(glsl) draw quad draw quad
probe (0, 0) rgba (0.0, 0.0, 1.0, 1.0) probe (0, 0) rgba (0.0, 0.0, 1.0, 1.0)