mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Move VKD3D_SHADER_DUMP_PATH implementation from libvkd3d.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ad29886691
commit
1ae1f831f6
@ -1238,44 +1238,32 @@ static void shader_dump_interpolation_mode(struct vkd3d_string_buffer *buffer,
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_dump_version(struct vkd3d_string_buffer *buffer,
|
||||
const struct vkd3d_shader_version *shader_version)
|
||||
const char *shader_get_type_prefix(enum vkd3d_shader_type type)
|
||||
{
|
||||
const char *prefix;
|
||||
|
||||
switch (shader_version->type)
|
||||
switch (type)
|
||||
{
|
||||
case VKD3D_SHADER_TYPE_VERTEX:
|
||||
prefix = "vs";
|
||||
break;
|
||||
return "vs";
|
||||
|
||||
case VKD3D_SHADER_TYPE_HULL:
|
||||
prefix = "hs";
|
||||
break;
|
||||
return "hs";
|
||||
|
||||
case VKD3D_SHADER_TYPE_DOMAIN:
|
||||
prefix = "ds";
|
||||
break;
|
||||
return "ds";
|
||||
|
||||
case VKD3D_SHADER_TYPE_GEOMETRY:
|
||||
prefix = "gs";
|
||||
break;
|
||||
return "gs";
|
||||
|
||||
case VKD3D_SHADER_TYPE_PIXEL:
|
||||
prefix = "ps";
|
||||
break;
|
||||
return "ps";
|
||||
|
||||
case VKD3D_SHADER_TYPE_COMPUTE:
|
||||
prefix = "cs";
|
||||
break;
|
||||
return "cs";
|
||||
|
||||
default:
|
||||
FIXME("Unhandled shader type %#x.\n", shader_version->type);
|
||||
prefix = "unknown";
|
||||
break;
|
||||
FIXME("Unhandled shader type %#x.\n", type);
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
shader_addline(buffer, "%s_%u_%u\n", prefix, shader_version->major, shader_version->minor);
|
||||
}
|
||||
|
||||
static void shader_dump_instruction_flags(struct vkd3d_string_buffer *buffer,
|
||||
@ -1606,7 +1594,8 @@ void vkd3d_shader_trace(void *data)
|
||||
}
|
||||
|
||||
shader_sm4_read_header(data, &ptr, &shader_version);
|
||||
shader_dump_version(&buffer, &shader_version);
|
||||
shader_addline(&buffer, "%s_%u_%u\n",
|
||||
shader_get_type_prefix(shader_version.type), shader_version.major, shader_version.minor);
|
||||
|
||||
while (!shader_sm4_is_end(data, &ptr))
|
||||
{
|
||||
|
@ -18,9 +18,51 @@
|
||||
|
||||
#include "vkd3d_shader_private.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
STATIC_ASSERT(MEMBER_SIZE(struct vkd3d_shader_scan_info, uav_counter_mask) * CHAR_BIT >= VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS);
|
||||
STATIC_ASSERT(MEMBER_SIZE(struct vkd3d_shader_scan_info, uav_read_mask) * CHAR_BIT >= VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS);
|
||||
|
||||
static void vkd3d_shader_dump_blob(const char *path, const char *prefix, const void *data, size_t size)
|
||||
{
|
||||
static int shader_id = 0;
|
||||
char filename[1024];
|
||||
unsigned int id;
|
||||
FILE *f;
|
||||
|
||||
id = InterlockedIncrement(&shader_id) - 1;
|
||||
|
||||
snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s-%u.dxbc", path, prefix, id);
|
||||
if ((f = fopen(filename, "wb")))
|
||||
{
|
||||
if (fwrite(data, 1, size, f) != size)
|
||||
ERR("Failed to write shader to %s.\n", filename);
|
||||
if (fclose(f))
|
||||
ERR("Failed to close stream %s.\n", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("Failed to open %s for dumping shader.\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
static void vkd3d_shader_dump_shader(enum vkd3d_shader_type type, const struct vkd3d_shader_code *shader)
|
||||
{
|
||||
static bool enabled = true;
|
||||
const char *path;
|
||||
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
if (!(path = getenv("VKD3D_SHADER_DUMP_PATH")))
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
vkd3d_shader_dump_blob(path, shader_get_type_prefix(type), shader->code, shader->size);
|
||||
}
|
||||
|
||||
struct vkd3d_shader_parser
|
||||
{
|
||||
struct vkd3d_shader_desc shader_desc;
|
||||
@ -114,6 +156,8 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
|
||||
return ret;
|
||||
|
||||
vkd3d_shader_dump_shader(parser.shader_version.type, dxbc);
|
||||
|
||||
if (TRACE_ON())
|
||||
vkd3d_shader_trace(parser.data);
|
||||
|
||||
|
@ -791,6 +791,8 @@ static inline bool vkd3d_shader_register_is_output(const struct vkd3d_shader_reg
|
||||
|
||||
void vkd3d_shader_trace(void *data) DECLSPEC_HIDDEN;
|
||||
|
||||
const char *shader_get_type_prefix(enum vkd3d_shader_type type) DECLSPEC_HIDDEN;
|
||||
|
||||
void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
|
||||
const struct vkd3d_shader_signature *output_signature) DECLSPEC_HIDDEN;
|
||||
void shader_sm4_free(void *data) DECLSPEC_HIDDEN;
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include "vkd3d_private.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* ID3D12RootSignature */
|
||||
static inline struct d3d12_root_signature *impl_from_ID3D12RootSignature(ID3D12RootSignature *iface)
|
||||
{
|
||||
@ -1243,71 +1241,6 @@ struct d3d12_pipeline_state *unsafe_impl_from_ID3D12PipelineState(ID3D12Pipeline
|
||||
return impl_from_ID3D12PipelineState(iface);
|
||||
}
|
||||
|
||||
static void dump_shader(const char *path, const char *prefix, const void *data, size_t size)
|
||||
{
|
||||
static int shader_id = 0;
|
||||
char filename[1024];
|
||||
unsigned int id;
|
||||
FILE *f;
|
||||
|
||||
id = InterlockedIncrement(&shader_id) - 1;
|
||||
|
||||
snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s-%u.dxbc", path, prefix, id);
|
||||
if (!(f = fopen(filename, "wb")))
|
||||
{
|
||||
ERR("Failed to open %s for dumping shader.\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fwrite(data, 1, size, f) != size)
|
||||
ERR("Failed to write shader to %s.\n", filename);
|
||||
if (fclose(f))
|
||||
ERR("Failed to close stream %s.\n", filename);
|
||||
}
|
||||
|
||||
static void dump_shader_stage(VkShaderStageFlagBits stage, const void *data, size_t size)
|
||||
{
|
||||
static bool enabled = true;
|
||||
const char *prefix;
|
||||
const char *path;
|
||||
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
if (!(path = getenv("VKD3D_SHADER_DUMP_PATH")))
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (stage)
|
||||
{
|
||||
case VK_SHADER_STAGE_VERTEX_BIT:
|
||||
prefix = "vs";
|
||||
break;
|
||||
case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
|
||||
prefix = "hs";
|
||||
break;
|
||||
case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
|
||||
prefix = "ds";
|
||||
break;
|
||||
case VK_SHADER_STAGE_GEOMETRY_BIT:
|
||||
prefix = "gs";
|
||||
break;
|
||||
case VK_SHADER_STAGE_FRAGMENT_BIT:
|
||||
prefix = "ps";
|
||||
break;
|
||||
case VK_SHADER_STAGE_COMPUTE_BIT:
|
||||
prefix = "cs";
|
||||
break;
|
||||
default:
|
||||
prefix = "unk";
|
||||
break;
|
||||
}
|
||||
|
||||
dump_shader(path, prefix, data, size);
|
||||
}
|
||||
|
||||
static HRESULT create_shader_stage(struct d3d12_device *device,
|
||||
struct VkPipelineShaderStageCreateInfo *stage_desc, enum VkShaderStageFlagBits stage,
|
||||
const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface,
|
||||
@ -1331,7 +1264,6 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
|
||||
shader_desc.pNext = NULL;
|
||||
shader_desc.flags = 0;
|
||||
|
||||
dump_shader_stage(stage, code->pShaderBytecode, code->BytecodeLength);
|
||||
if ((ret = vkd3d_shader_compile_dxbc(&dxbc, &spirv, 0, shader_interface, compile_args)) < 0)
|
||||
{
|
||||
WARN("Failed to compile shader, vkd3d result %d.\n", ret);
|
||||
|
Loading…
Reference in New Issue
Block a user