Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 2 +- libs/vkd3d-shader/vkd3d_shader_main.c | 27 +++++++++++++++++++----- libs/vkd3d-shader/vkd3d_shader_private.h | 3 ++- 3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 7b246bfd..13ef6cf9 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1798,7 +1798,7 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d return VKD3D_ERROR_NOT_IMPLEMENTED; }
- vkd3d_shader_dump_shader(profile->type, &compile_info->source); + vkd3d_shader_dump_shader(compile_info->source_type, profile->type, &compile_info->source);
if (!hlsl_ctx_init(&ctx, profile, message_context)) return VKD3D_ERROR_OUT_OF_MEMORY; diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 16994d20..5fab5151 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -310,7 +310,8 @@ void set_u32(struct vkd3d_bytecode_buffer *buffer, size_t offset, uint32_t value memcpy(buffer->data + offset, &value, sizeof(value)); }
-static void vkd3d_shader_dump_blob(const char *path, const char *prefix, const void *data, size_t size) +static void vkd3d_shader_dump_blob(const char *path, const char *prefix, + const char *suffix, const void *data, size_t size) { static int shader_id = 0; char filename[1024]; @@ -319,7 +320,7 @@ static void vkd3d_shader_dump_blob(const char *path, const char *prefix, const v
id = InterlockedIncrement(&shader_id) - 1;
- snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s-%u.dxbc", path, prefix, id); + snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s-%u.%s", path, prefix, id, suffix); if ((f = fopen(filename, "wb"))) { if (fwrite(data, 1, size, f) != size) @@ -333,7 +334,22 @@ static void vkd3d_shader_dump_blob(const char *path, const char *prefix, const v } }
-void vkd3d_shader_dump_shader(enum vkd3d_shader_type type, const struct vkd3d_shader_code *shader) +static const char *shader_get_source_type_suffix(enum vkd3d_shader_source_type type) +{ + switch (type) + { + case VKD3D_SHADER_SOURCE_DXBC_TPF: + return "dxbc"; + case VKD3D_SHADER_SOURCE_HLSL: + return "hlsl"; + default: + FIXME("Unhandled source type %#x.\n", type); + return "bin"; + } +} + +void vkd3d_shader_dump_shader(enum vkd3d_shader_source_type source_type, + enum vkd3d_shader_type shader_type, const struct vkd3d_shader_code *shader) { static bool enabled = true; const char *path; @@ -347,7 +363,8 @@ void vkd3d_shader_dump_shader(enum vkd3d_shader_type type, const struct vkd3d_sh return; }
- vkd3d_shader_dump_blob(path, shader_get_type_prefix(type), shader->code, shader->size); + vkd3d_shader_dump_blob(path, shader_get_type_prefix(shader_type), + shader_get_source_type_suffix(source_type), shader->code, shader->size); }
struct vkd3d_shader_parser @@ -1022,7 +1039,7 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info return ret; }
- vkd3d_shader_dump_shader(parser.shader_version.type, &compile_info->source); + vkd3d_shader_dump_shader(compile_info->source_type, parser.shader_version.type, &compile_info->source);
if (compile_info->target_type == VKD3D_SHADER_TARGET_D3D_ASM) { diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 54ac5326..e195c12a 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -975,7 +975,8 @@ void vkd3d_shader_vnote(struct vkd3d_shader_message_context *context, const stru void vkd3d_shader_vwarning(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location, enum vkd3d_shader_error error, const char *format, va_list args);
-void vkd3d_shader_dump_shader(enum vkd3d_shader_type type, const struct vkd3d_shader_code *shader); +void vkd3d_shader_dump_shader(enum vkd3d_shader_source_type source_type, + enum vkd3d_shader_type shader_type, const struct vkd3d_shader_code *shader);
int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length, struct vkd3d_shader_message_context *message_context, const char *source_name, struct vkd3d_shader_desc *desc);