diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index 196405c9..d5c07d1d 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -365,18 +365,21 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment( { const struct vkd3d_shader_register *dst_reg = &dst->vsir->reg; struct vkd3d_string_buffer *buffer = gen->buffer; + uint32_t modifiers = dst->vsir->modifiers; bool close = true; va_list args; if (dst->vsir->shift) vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, "Internal compiler error: Unhandled destination shift %#x.", dst->vsir->shift); - if (dst->vsir->modifiers) + if (modifiers & ~VKD3DSPDM_SATURATE) vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, - "Internal compiler error: Unhandled destination modifier(s) %#x.", dst->vsir->modifiers); + "Internal compiler error: Unhandled destination modifier(s) %#x.", modifiers); shader_glsl_print_indent(buffer, gen->indent); vkd3d_string_buffer_printf(buffer, "%s%s = ", dst->register_name->buffer, dst->mask->buffer); + if (modifiers & VKD3DSPDM_SATURATE) + vkd3d_string_buffer_printf(buffer, "clamp("); switch (dst_reg->data_type) { @@ -399,7 +402,11 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment( vkd3d_string_buffer_vprintf(buffer, format, args); va_end(args); - vkd3d_string_buffer_printf(buffer, "%s;\n", close ? ")" : ""); + if (close) + vkd3d_string_buffer_printf(buffer, ")"); + if (modifiers & VKD3DSPDM_SATURATE) + vkd3d_string_buffer_printf(buffer, ", 0.0, 1.0)"); + vkd3d_string_buffer_printf(buffer, ";\n"); } static void shader_glsl_unhandled(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins) diff --git a/tests/hlsl/saturate.shader_test b/tests/hlsl/saturate.shader_test index cbc52635..c10a32dd 100644 --- a/tests/hlsl/saturate.shader_test +++ b/tests/hlsl/saturate.shader_test @@ -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, 0.0, 1.0, 0.0) [pixel shader] @@ -22,5 +22,5 @@ float4 main() : sv_target [test] uniform 0 float4 -2 0 2 -1 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (0.0, 0.0, 1.0, 0.0)