vkd3d-shader/glsl: Implement VKD3DSIH_MAX.

This commit is contained in:
Henri Verbeet 2024-05-03 15:33:00 +02:00
parent 2ea5f187f9
commit 4f054aed48
Notes: Henri Verbeet 2024-10-01 17:35:47 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1134
3 changed files with 20 additions and 9 deletions

View File

@ -455,16 +455,24 @@ static void shader_glsl_dot(struct vkd3d_glsl_generator *gen,
static void shader_glsl_intrinsic(struct vkd3d_glsl_generator *gen,
const struct vkd3d_shader_instruction *ins, const char *op)
{
struct vkd3d_string_buffer *args;
struct glsl_src src;
struct glsl_dst dst;
unsigned int i;
uint32_t mask;
mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
glsl_src_init(&src, gen, &ins->src[0], mask);
args = vkd3d_string_buffer_get(&gen->string_buffers);
shader_glsl_print_assignment(gen, &dst, "%s(%s)", op, src.str->buffer);
for (i = 0; i < ins->src_count; ++i)
{
glsl_src_init(&src, gen, &ins->src[i], mask);
vkd3d_string_buffer_printf(args, "%s%s", i ? ", " : "", src.str->buffer);
glsl_src_cleanup(&src, &gen->string_buffers);
}
shader_glsl_print_assignment(gen, &dst, "%s(%s)", op, args->buffer);
glsl_src_cleanup(&src, &gen->string_buffers);
vkd3d_string_buffer_release(&gen->string_buffers, args);
glsl_dst_cleanup(&dst, &gen->string_buffers);
}
@ -784,6 +792,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_LTO:
shader_glsl_relop(gen, ins, "<", "lessThan");
break;
case VKD3DSIH_MAX:
shader_glsl_intrinsic(gen, ins, "max");
break;
case VKD3DSIH_INE:
case VKD3DSIH_NEU:
shader_glsl_relop(gen, ins, "!=", "notEqual");

View File

@ -8,17 +8,17 @@ float4 main() : sv_target
[test]
uniform 0 float4 -0.1 10.0 0.0 0.0
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (1.0, 0.0, 0.0, 1.0)
[test]
uniform 0 float4 1.2 -0.1 0.0 0.0
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (1.0, 1.2, 0.0, 1.0)
[test]
uniform 0 float4 1.2 2.0 3.0 0.0
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (1.0, 1.2, 8.0, 1.0)
[pixel shader]
@ -31,7 +31,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.2 2.0 3.0 0.0
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (2.0, 2.4, 16.0, 2.0)
[pixel shader fail]

View File

@ -8,7 +8,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.7 -0.1 0.0 0.0
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (0.7, 2.1, 2.0, -1.0)
@ -24,7 +24,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.7 -0.1 0.4 0.8
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (0.7, 0.8, 0.7, 0.2)