vkd3d-shader: Dump HLSL shaders with a ".hlsl" suffix.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2021-09-01 15:45:05 +02:00 committed by Alexandre Julliard
parent 28092bb200
commit cfc09a210a
3 changed files with 25 additions and 7 deletions

View File

@ -1798,7 +1798,7 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
return VKD3D_ERROR_NOT_IMPLEMENTED; 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)) if (!hlsl_ctx_init(&ctx, profile, message_context))
return VKD3D_ERROR_OUT_OF_MEMORY; return VKD3D_ERROR_OUT_OF_MEMORY;

View File

@ -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)); 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; static int shader_id = 0;
char filename[1024]; 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; 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 ((f = fopen(filename, "wb")))
{ {
if (fwrite(data, 1, size, f) != size) 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; static bool enabled = true;
const char *path; const char *path;
@ -347,7 +363,8 @@ void vkd3d_shader_dump_shader(enum vkd3d_shader_type type, const struct vkd3d_sh
return; 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 struct vkd3d_shader_parser
@ -1022,7 +1039,7 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
return ret; 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) if (compile_info->target_type == VKD3D_SHADER_TARGET_D3D_ASM)
{ {

View File

@ -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, 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); 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, 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); struct vkd3d_shader_message_context *message_context, const char *source_name, struct vkd3d_shader_desc *desc);