From a44cdbfdd256dcdb0e87d51b723dbd566d91b1f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 13 Jul 2016 10:52:02 +0200 Subject: [PATCH] wined3d: Use uintBitsToFloat() for float immediate shader constants. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes issues with special floating-point values in immediate constants. Inspired by a patch by Guillaume Charifi. Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/glsl_shader.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 2c042603d98..00903081a9d 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2548,7 +2548,10 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * switch (reg->data_type) { case WINED3D_DATA_FLOAT: - wined3d_ftoa(*(const float *)reg->immconst_data, register_name); + if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) + sprintf(register_name, "uintBitsToFloat(%#xu)", reg->immconst_data[0]); + else + wined3d_ftoa(*(const float *)reg->immconst_data, register_name); break; case WINED3D_DATA_INT: sprintf(register_name, "%#x", reg->immconst_data[0]); @@ -2568,12 +2571,21 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * switch (reg->data_type) { case WINED3D_DATA_FLOAT: - wined3d_ftoa(*(const float *)®->immconst_data[0], imm_str[0]); - wined3d_ftoa(*(const float *)®->immconst_data[1], imm_str[1]); - wined3d_ftoa(*(const float *)®->immconst_data[2], imm_str[2]); - wined3d_ftoa(*(const float *)®->immconst_data[3], imm_str[3]); - sprintf(register_name, "vec4(%s, %s, %s, %s)", - imm_str[0], imm_str[1], imm_str[2], imm_str[3]); + if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) + { + sprintf(register_name, "uintBitsToFloat(uvec4(%#xu, %#xu, %#xu, %#xu))", + reg->immconst_data[0], reg->immconst_data[1], + reg->immconst_data[2], reg->immconst_data[3]); + } + else + { + wined3d_ftoa(*(const float *)®->immconst_data[0], imm_str[0]); + wined3d_ftoa(*(const float *)®->immconst_data[1], imm_str[1]); + wined3d_ftoa(*(const float *)®->immconst_data[2], imm_str[2]); + wined3d_ftoa(*(const float *)®->immconst_data[3], imm_str[3]); + sprintf(register_name, "vec4(%s, %s, %s, %s)", + imm_str[0], imm_str[1], imm_str[2], imm_str[3]); + } break; case WINED3D_DATA_INT: sprintf(register_name, "ivec4(%#x, %#x, %#x, %#x)",