mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/glsl: Implement support for VKD3DSPR_TEMP registers.
This commit is contained in:
parent
337a030908
commit
2170fdc633
Notes:
Henri Verbeet
2024-07-30 16:37:56 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/969
@ -61,9 +61,18 @@ static void shader_glsl_print_indent(struct vkd3d_string_buffer *buffer, unsigne
|
||||
static void shader_glsl_print_register_name(struct vkd3d_string_buffer *buffer,
|
||||
struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_register *reg)
|
||||
{
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_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);
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled register type %#x.", reg->type);
|
||||
vkd3d_string_buffer_printf(buffer, "<unrecognised register %#x>", reg->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_glsl_print_swizzle(struct vkd3d_string_buffer *buffer, uint32_t swizzle, uint32_t mask)
|
||||
@ -228,6 +237,15 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_glsl_generate_declarations(struct vkd3d_glsl_generator *gen)
|
||||
{
|
||||
const struct vsir_program *program = gen->program;
|
||||
struct vkd3d_string_buffer *buffer = gen->buffer;
|
||||
|
||||
if (program->temp_count)
|
||||
vkd3d_string_buffer_printf(buffer, "vec4 r[%u];\n\n", program->temp_count);
|
||||
}
|
||||
|
||||
static int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *gen, struct vkd3d_shader_code *out)
|
||||
{
|
||||
const struct vkd3d_shader_instruction_array *instructions = &gen->program->instructions;
|
||||
@ -241,6 +259,8 @@ static int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *gen, struc
|
||||
|
||||
vkd3d_string_buffer_printf(buffer, "/* Generated by %s. */\n\n", vkd3d_shader_get_version(NULL, NULL));
|
||||
|
||||
shader_glsl_generate_declarations(gen);
|
||||
|
||||
vkd3d_string_buffer_printf(buffer, "void main()\n{\n");
|
||||
|
||||
++gen->indent;
|
||||
|
Loading…
Reference in New Issue
Block a user