mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/msl: Implement support for VKD3DSPR_TEMP registers.
This commit is contained in:
parent
ebc4f84185
commit
e8b14d765d
Notes:
Henri Verbeet
2024-09-24 14:11:38 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1111
@ -55,12 +55,44 @@ static void msl_print_indent(struct vkd3d_string_buffer *buffer, unsigned int in
|
||||
vkd3d_string_buffer_printf(buffer, "%*s", 4 * indent, "");
|
||||
}
|
||||
|
||||
static void msl_print_register_datatype(struct vkd3d_string_buffer *buffer,
|
||||
struct msl_generator *gen, const struct vkd3d_shader_register *reg)
|
||||
{
|
||||
vkd3d_string_buffer_printf(buffer, ".");
|
||||
switch (reg->data_type)
|
||||
{
|
||||
case VKD3D_DATA_FLOAT:
|
||||
vkd3d_string_buffer_printf(buffer, "f");
|
||||
break;
|
||||
case VKD3D_DATA_INT:
|
||||
vkd3d_string_buffer_printf(buffer, "i");
|
||||
break;
|
||||
case VKD3D_DATA_UINT:
|
||||
vkd3d_string_buffer_printf(buffer, "u");
|
||||
break;
|
||||
default:
|
||||
msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled register datatype %#x.", reg->data_type);
|
||||
vkd3d_string_buffer_printf(buffer, "<unrecognised register datatype %#x>", reg->data_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void msl_print_register_name(struct vkd3d_string_buffer *buffer,
|
||||
struct msl_generator *gen, const struct vkd3d_shader_register *reg)
|
||||
{
|
||||
msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled register type %#x.", reg->type);
|
||||
vkd3d_string_buffer_printf(buffer, "<unrecognised register %#x>", reg->type);
|
||||
switch (reg->type)
|
||||
{
|
||||
case VKD3DSPR_TEMP:
|
||||
vkd3d_string_buffer_printf(buffer, "r[%u]", reg->idx[0].offset);
|
||||
msl_print_register_datatype(buffer, gen, reg);
|
||||
break;
|
||||
default:
|
||||
msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled register type %#x.", reg->type);
|
||||
vkd3d_string_buffer_printf(buffer, "<unrecognised register %#x>", reg->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void msl_print_swizzle(struct vkd3d_string_buffer *buffer, uint32_t swizzle, uint32_t mask)
|
||||
@ -221,9 +253,21 @@ static void msl_generator_generate(struct msl_generator *gen)
|
||||
|
||||
vkd3d_string_buffer_printf(gen->buffer, "/* Generated by %s. */\n\n", vkd3d_shader_get_version(NULL, NULL));
|
||||
|
||||
vkd3d_string_buffer_printf(gen->buffer, "union vkd3d_vec4\n{\n");
|
||||
vkd3d_string_buffer_printf(gen->buffer, " uint4 u;\n");
|
||||
vkd3d_string_buffer_printf(gen->buffer, " int4 i;\n");
|
||||
vkd3d_string_buffer_printf(gen->buffer, " float4 f;\n};\n\n");
|
||||
|
||||
vkd3d_string_buffer_printf(gen->buffer, "void shader_main()\n{\n");
|
||||
|
||||
++gen->indent;
|
||||
|
||||
if (gen->program->temp_count)
|
||||
{
|
||||
msl_print_indent(gen->buffer, gen->indent);
|
||||
vkd3d_string_buffer_printf(gen->buffer, "vkd3d_vec4 r[%u];\n\n", gen->program->temp_count);
|
||||
}
|
||||
|
||||
for (i = 0; i < instructions->count; ++i)
|
||||
{
|
||||
msl_handle_instruction(gen, &instructions->elements[i]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user