mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/msl: Output the generated shader code.
This commit is contained in:
parent
2669ae16ea
commit
9e3b8ec98a
Notes:
Henri Verbeet
2024-11-20 15:00:07 +01:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1243
@ -39,6 +39,8 @@ struct msl_generator
|
|||||||
struct vkd3d_shader_message_context *message_context;
|
struct vkd3d_shader_message_context *message_context;
|
||||||
unsigned int indent;
|
unsigned int indent;
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
|
bool failed;
|
||||||
|
|
||||||
const struct vkd3d_shader_interface_info *interface_info;
|
const struct vkd3d_shader_interface_info *interface_info;
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info;
|
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info;
|
||||||
};
|
};
|
||||||
@ -51,6 +53,7 @@ static void VKD3D_PRINTF_FUNC(3, 4) msl_compiler_error(struct msl_generator *gen
|
|||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vkd3d_shader_verror(gen->message_context, &gen->location, error, fmt, args);
|
vkd3d_shader_verror(gen->message_context, &gen->location, error, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
gen->failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *msl_get_prefix(enum vkd3d_shader_type type)
|
static const char *msl_get_prefix(enum vkd3d_shader_type type)
|
||||||
@ -778,7 +781,7 @@ static void msl_generate_entrypoint(struct msl_generator *gen)
|
|||||||
vkd3d_string_buffer_printf(gen->buffer, " return output;\n}\n");
|
vkd3d_string_buffer_printf(gen->buffer, " return output;\n}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msl_generator_generate(struct msl_generator *gen)
|
static int msl_generator_generate(struct msl_generator *gen, struct vkd3d_shader_code *out)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_instruction_array *instructions = &gen->program->instructions;
|
const struct vkd3d_shader_instruction_array *instructions = &gen->program->instructions;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -829,6 +832,13 @@ static void msl_generator_generate(struct msl_generator *gen)
|
|||||||
|
|
||||||
if (TRACE_ON())
|
if (TRACE_ON())
|
||||||
vkd3d_string_buffer_trace(gen->buffer);
|
vkd3d_string_buffer_trace(gen->buffer);
|
||||||
|
|
||||||
|
if (gen->failed)
|
||||||
|
return VKD3D_ERROR_INVALID_SHADER;
|
||||||
|
|
||||||
|
vkd3d_shader_code_from_string_buffer(out, gen->buffer);
|
||||||
|
|
||||||
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msl_generator_cleanup(struct msl_generator *gen)
|
static void msl_generator_cleanup(struct msl_generator *gen)
|
||||||
@ -867,7 +877,8 @@ static int msl_generator_init(struct msl_generator *gen, struct vsir_program *pr
|
|||||||
|
|
||||||
int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
||||||
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
|
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
||||||
|
struct vkd3d_shader_message_context *message_context)
|
||||||
{
|
{
|
||||||
struct msl_generator generator;
|
struct msl_generator generator;
|
||||||
int ret;
|
int ret;
|
||||||
@ -879,8 +890,8 @@ int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
|
|
||||||
if ((ret = msl_generator_init(&generator, program, compile_info, descriptor_info, message_context)) < 0)
|
if ((ret = msl_generator_init(&generator, program, compile_info, descriptor_info, message_context)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
msl_generator_generate(&generator);
|
ret = msl_generator_generate(&generator, out);
|
||||||
msl_generator_cleanup(&generator);
|
msl_generator_cleanup(&generator);
|
||||||
|
|
||||||
return VKD3D_ERROR_INVALID_SHADER;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1680,7 +1680,7 @@ int vsir_program_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
case VKD3D_SHADER_TARGET_MSL:
|
case VKD3D_SHADER_TARGET_MSL:
|
||||||
if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
|
if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
ret = msl_compile(program, config_flags, &scan_descriptor_info, compile_info, message_context);
|
ret = msl_compile(program, config_flags, &scan_descriptor_info, compile_info, out, message_context);
|
||||||
vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
|
vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1658,7 +1658,8 @@ int spirv_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
|
|
||||||
int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
||||||
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context);
|
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
||||||
|
struct vkd3d_shader_message_context *message_context);
|
||||||
|
|
||||||
enum vkd3d_md5_variant
|
enum vkd3d_md5_variant
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user