[PATCH] wined3d: Use intBitsToFloat() instead of uintBitsToFloat().

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] wined3d: Use intBitsToFloat() instead of uintBitsToFloat().

Paul Gofman
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47039

There is no uint type in GLSL version < 1.3, while ARB_shader_bit_encoding
may still be supported.

Signed-off-by: Paul Gofman <[hidden email]>
---
Supersedes patch https://source.winehq.org/patches/data/163199
(wined3d: Check GLSL version when using ARB_shader_bit_encoding with uvec4).

 dlls/wined3d/glsl_shader.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 7d4678965d..05736084b0 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -444,11 +444,11 @@ static void shader_glsl_append_imm_vec4(struct wined3d_string_buffer *buffer, co
 
     if (gl_info->supported[ARB_SHADER_BIT_ENCODING])
     {
-        const unsigned int *uint_values = (const unsigned int *)values;
+        const int *int_values = (const int *)values;
 
-        shader_addline(buffer, "uintBitsToFloat(uvec4(%#xu, %#xu, %#xu, %#xu))\n"
-                "        /* %s, %s, %s, %s */", uint_values[0], uint_values[1],
-                uint_values[2], uint_values[3], str[0], str[1], str[2], str[3]);
+        shader_addline(buffer, "intBitsToFloat(ivec4(%d, %d, %d, %d))\n"
+                "        /* %s, %s, %s, %s */", int_values[0], int_values[1],
+                int_values[2], int_values[3], str[0], str[1], str[2], str[3]);
     }
     else
         shader_addline(buffer, "vec4(%s, %s, %s, %s)", str[0], str[1], str[2], str[3]);
@@ -3288,7 +3288,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
                         case WINED3D_DATA_FLOAT:
                             if (gl_info->supported[ARB_SHADER_BIT_ENCODING])
                             {
-                                string_buffer_sprintf(register_name, "uintBitsToFloat(%#xu)", reg->u.immconst_data[0]);
+                                string_buffer_sprintf(register_name, "intBitsToFloat(%d)", reg->u.immconst_data[0]);
                             }
                             else
                             {
@@ -3318,7 +3318,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
                         case WINED3D_DATA_FLOAT:
                             if (gl_info->supported[ARB_SHADER_BIT_ENCODING])
                             {
-                                string_buffer_sprintf(register_name, "uintBitsToFloat(uvec4(%#xu, %#xu, %#xu, %#xu))",
+                                string_buffer_sprintf(register_name, "intBitsToFloat(ivec4(%d, %d, %d, %d))",
                                         reg->u.immconst_data[0], reg->u.immconst_data[1],
                                         reg->u.immconst_data[2], reg->u.immconst_data[3]);
                             }
--
2.20.1



Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] wined3d: Use intBitsToFloat() instead of uintBitsToFloat().

Henri Verbeet
On Fri, 19 Apr 2019 at 18:23, Paul Gofman <[hidden email]> wrote:
> -        shader_addline(buffer, "uintBitsToFloat(uvec4(%#xu, %#xu, %#xu, %#xu))\n"
> -                "        /* %s, %s, %s, %s */", uint_values[0], uint_values[1],
> -                uint_values[2], uint_values[3], str[0], str[1], str[2], str[3]);
> +        shader_addline(buffer, "intBitsToFloat(ivec4(%d, %d, %d, %d))\n"
> +                "        /* %s, %s, %s, %s */", int_values[0], int_values[1],
> +                int_values[2], int_values[3], str[0], str[1], str[2], str[3]);
Do we have to use %d? I'd expect %#x to work.