vkd3d-shader/glsl: Implement VKD3DSIH_IMUL.

This commit is contained in:
Henri Verbeet 2024-09-29 23:51:43 +02:00
parent 4dec4e9959
commit 25232f2b2b
Notes: Henri Verbeet 2024-10-03 19:35:31 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1143
2 changed files with 35 additions and 1 deletions

View File

@ -864,6 +864,37 @@ static void shader_glsl_movc(struct vkd3d_glsl_generator *gen, const struct vkd3
glsl_dst_cleanup(&dst, &gen->string_buffers); glsl_dst_cleanup(&dst, &gen->string_buffers);
} }
static void shader_glsl_mul_extended(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
{
struct glsl_src src[2];
struct glsl_dst dst;
uint32_t mask;
if (ins->dst[0].reg.type != VKD3DSPR_NULL)
{
/* FIXME: imulExtended()/umulExtended() from ARB_gpu_shader5/GLSL 4.00+. */
mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
shader_glsl_print_assignment(gen, &dst, "<unhandled 64-bit multiplication>");
glsl_dst_cleanup(&dst, &gen->string_buffers);
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
"Internal compiler error: Unhandled 64-bit integer multiplication.");
}
if (ins->dst[1].reg.type != VKD3DSPR_NULL)
{
mask = glsl_dst_init(&dst, gen, ins, &ins->dst[1]);
glsl_src_init(&src[0], gen, &ins->src[0], mask);
glsl_src_init(&src[1], gen, &ins->src[1], mask);
shader_glsl_print_assignment(gen, &dst, "%s * %s", src[0].str->buffer, src[1].str->buffer);
glsl_src_cleanup(&src[1], &gen->string_buffers);
glsl_src_cleanup(&src[0], &gen->string_buffers);
glsl_dst_cleanup(&dst, &gen->string_buffers);
}
}
static void shader_glsl_print_sysval_name(struct vkd3d_string_buffer *buffer, struct vkd3d_glsl_generator *gen, static void shader_glsl_print_sysval_name(struct vkd3d_string_buffer *buffer, struct vkd3d_glsl_generator *gen,
enum vkd3d_shader_sysval_semantic sysval, unsigned int idx) enum vkd3d_shader_sysval_semantic sysval, unsigned int idx)
{ {
@ -1077,6 +1108,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_LTO: case VKD3DSIH_LTO:
shader_glsl_relop(gen, ins, "<", "lessThan"); shader_glsl_relop(gen, ins, "<", "lessThan");
break; break;
case VKD3DSIH_IMUL:
shader_glsl_mul_extended(gen, ins);
break;
case VKD3DSIH_ISHL: case VKD3DSIH_ISHL:
shader_glsl_binop(gen, ins, "<<"); shader_glsl_binop(gen, ins, "<<");
break; break;

View File

@ -88,7 +88,7 @@ if(sm<4) uniform 0 float4 10 20 30 40
if(sm<4) uniform 4 float4 50 60 70 80 if(sm<4) uniform 4 float4 50 60 70 80
if(sm>=4) uniform 0 int4 10 20 30 40 if(sm>=4) uniform 0 int4 10 20 30 40
if(sm>=4) uniform 4 int4 50 60 70 80 if(sm>=4) uniform 4 int4 50 60 70 80
todo(glsl) draw quad draw quad
probe (0, 0) rgba (100, 120, 140, 160) probe (0, 0) rgba (100, 120, 140, 160)