vkd3d-shader/glsl: Implement VKD3DSIH_ITOF.

This commit is contained in:
Atharva Nimbalkar 2021-07-14 03:41:32 +05:30 committed by Henri Verbeet
parent 91475c684f
commit b81cdcb488
Notes: Henri Verbeet 2024-09-24 14:10:34 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1106
5 changed files with 31 additions and 6 deletions

View File

@ -457,6 +457,28 @@ static void shader_glsl_relop(struct vkd3d_glsl_generator *gen,
glsl_dst_cleanup(&dst, &gen->string_buffers);
}
static void shader_glsl_cast(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins,
const char *scalar_constructor, const char *vector_constructor)
{
unsigned int component_count;
struct glsl_src src;
struct glsl_dst dst;
uint32_t mask;
mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
glsl_src_init(&src, gen, &ins->src[0], mask);
if ((component_count = vsir_write_mask_component_count(mask)) > 1)
shader_glsl_print_assignment(gen, &dst, "%s%u(%s)",
vector_constructor, component_count, src.str->buffer);
else
shader_glsl_print_assignment(gen, &dst, "%s(%s)",
scalar_constructor, src.str->buffer);
glsl_src_cleanup(&src, &gen->string_buffers);
glsl_dst_cleanup(&dst, &gen->string_buffers);
}
static void shader_glsl_mov(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
{
struct glsl_src src;
@ -665,6 +687,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_NEU:
shader_glsl_relop(gen, ins, "!=", "notEqual");
break;
case VKD3DSIH_ITOF:
shader_glsl_cast(gen, ins, "float", "vec");
break;
case VKD3DSIH_MOV:
shader_glsl_mov(gen, ins);
break;

View File

@ -36,7 +36,7 @@ float4 main() : sv_target
uniform 0 int4 11 12 0 0
uniform 4 int4 13 14 0 0
uniform 8 int4 20 21 22 23
todo(glsl) draw quad
draw quad
probe (320,240) rgba (13.0, 21.0, 0.0, 0.0)

View File

@ -27,7 +27,7 @@ float4 main() : SV_TARGET
uniform 0 float4 0.0 0.0 2.0 4.0
if(sm<4) uniform 4 float4 0 1 0 10
if(sm>=4) uniform 4 int4 0 1 0 10
todo(sm<4 | glsl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (0.0, 10.0, 1.0, 11.0)
@ -42,5 +42,5 @@ float4 main() : sv_target
[test]
if(sm<4) uniform 0 float4 1.0 1.0 1.0 0.0
if(sm>=4) uniform 0 uint4 0x00000001 0x00000002 0x80000000 0x00000000
todo(sm<4 | glsl) draw quad
todo(sm<4) draw quad
probe (0, 0) rgba (2.0, 2.0, 2.0, 0.0)

View File

@ -111,7 +111,7 @@ if(sm<4) uniform 8 float4 70 90 0 0
if(sm<4) uniform 12 float4 80 100 0 0
if(sm>=4) uniform 8 int4 70 90 0 0
if(sm>=4) uniform 12 int4 80 100 0 0
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (70, 80, 90, 100)
@ -216,7 +216,7 @@ if(sm<4) uniform 8 float4 70 90 0 0
if(sm<4) uniform 12 float4 80 100 0 0
if(sm>=4) uniform 8 int4 70 90 0 0
if(sm>=4) uniform 12 int4 80 100 0 0
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (70, 80, 90, 100)

View File

@ -33,7 +33,7 @@ if(sm<4) uniform 8 float4 0 1 -1 1000000
if(sm>=4) uniform 0 int4 2 3 4 0
if(sm>=4) uniform 4 int4 0 -10 10 1000000
if(sm>=4) uniform 8 int4 0 1 -1 1000000
todo(glsl) draw quad
draw quad
probe (0, 0) rgba (2.0, -10.0, -2.0, 1e12) 4