wined3d: Use uintBitsToFloat() for float immediate shader constants.

This fixes issues with special floating-point values in immediate
constants. Inspired by a patch by Guillaume Charifi.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-07-13 10:52:02 +02:00 committed by Alexandre Julliard
parent b7b58e85bc
commit a44cdbfdd2
1 changed files with 19 additions and 7 deletions

View File

@ -2548,7 +2548,10 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
switch (reg->data_type) switch (reg->data_type)
{ {
case WINED3D_DATA_FLOAT: 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; break;
case WINED3D_DATA_INT: case WINED3D_DATA_INT:
sprintf(register_name, "%#x", reg->immconst_data[0]); 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) switch (reg->data_type)
{ {
case WINED3D_DATA_FLOAT: case WINED3D_DATA_FLOAT:
wined3d_ftoa(*(const float *)&reg->immconst_data[0], imm_str[0]); if (gl_info->supported[ARB_SHADER_BIT_ENCODING])
wined3d_ftoa(*(const float *)&reg->immconst_data[1], imm_str[1]); {
wined3d_ftoa(*(const float *)&reg->immconst_data[2], imm_str[2]); sprintf(register_name, "uintBitsToFloat(uvec4(%#xu, %#xu, %#xu, %#xu))",
wined3d_ftoa(*(const float *)&reg->immconst_data[3], imm_str[3]); reg->immconst_data[0], reg->immconst_data[1],
sprintf(register_name, "vec4(%s, %s, %s, %s)", reg->immconst_data[2], reg->immconst_data[3]);
imm_str[0], imm_str[1], imm_str[2], imm_str[3]); }
else
{
wined3d_ftoa(*(const float *)&reg->immconst_data[0], imm_str[0]);
wined3d_ftoa(*(const float *)&reg->immconst_data[1], imm_str[1]);
wined3d_ftoa(*(const float *)&reg->immconst_data[2], imm_str[2]);
wined3d_ftoa(*(const float *)&reg->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; break;
case WINED3D_DATA_INT: case WINED3D_DATA_INT:
sprintf(register_name, "ivec4(%#x, %#x, %#x, %#x)", sprintf(register_name, "ivec4(%#x, %#x, %#x, %#x)",