From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/vkd3d_d3d12.idl | 10 ---------- include/vkd3d_d3dcommon.idl | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/vkd3d_d3d12.idl b/include/vkd3d_d3d12.idl index 2ccfa22d344f..5bfc76718873 100644 --- a/include/vkd3d_d3d12.idl +++ b/include/vkd3d_d3d12.idl @@ -66,16 +66,6 @@ const UINT D3D12_SHADER_COMPONENT_MAPPING_SHIFT = 3; const UINT D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES = 1 << (D3D12_SHADER_COMPONENT_MAPPING_SHIFT * 4);
-typedef enum D3D_PRIMITIVE_TOPOLOGY -{ - D3D_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, - D3D_PRIMITIVE_TOPOLOGY_POINTLIST = 1, - D3D_PRIMITIVE_TOPOLOGY_LINELIST = 2, - D3D_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, - D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, - D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, -} D3D_PRIMITIVE_TOPOLOGY; - typedef enum D3D12_SHADER_MIN_PRECISION_SUPPORT { D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE = 0x0, diff --git a/include/vkd3d_d3dcommon.idl b/include/vkd3d_d3dcommon.idl index 1ddfce3c3d34..a874b6c869dd 100644 --- a/include/vkd3d_d3dcommon.idl +++ b/include/vkd3d_d3dcommon.idl @@ -20,6 +20,16 @@ import "vkd3d_windows.h";
#include "vkd3d_unknown.idl"
+typedef enum D3D_PRIMITIVE_TOPOLOGY +{ + D3D_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D_PRIMITIVE_TOPOLOGY_POINTLIST = 1, + D3D_PRIMITIVE_TOPOLOGY_LINELIST = 2, + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, +} D3D_PRIMITIVE_TOPOLOGY; + typedef enum D3D_FEATURE_LEVEL { D3D_FEATURE_LEVEL_9_1 = 0x9100,
From: Józef Kucia jkucia@codeweavers.com
We would like to allow building libvkd3d-shader as a standalone library without our Direct3D translation layers.
In the long term, it should be possible to build and use libvkd3d-shader without Win32 data types, Vulkan headers and libs.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/vkd3d_shader.h | 183 +++++++++++++++++++++++++- libs/vkd3d-shader/dxbc.c | 238 +++++++++++++++++----------------- libs/vkd3d-shader/vkd3d_shader_main.c | 14 +- libs/vkd3d/state.c | 14 +- libs/vkd3d/vkd3d_main.c | 15 ++- 5 files changed, 325 insertions(+), 139 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 48b51898d453..f99d21684b81 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -118,9 +118,186 @@ HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, const struct vkd3d_shader_interface *shader_interface); void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
+enum vkd3d_filter +{ + VKD3D_FILTER_MIN_MAG_MIP_POINT = 0x0, + VKD3D_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, + VKD3D_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, + VKD3D_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, + VKD3D_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + VKD3D_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + VKD3D_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + VKD3D_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + VKD3D_FILTER_ANISOTROPIC = 0x55, + VKD3D_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, + VKD3D_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, + VKD3D_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, + VKD3D_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, + VKD3D_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, + VKD3D_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, + VKD3D_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, + VKD3D_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, + VKD3D_FILTER_COMPARISON_ANISOTROPIC = 0xd5, + VKD3D_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100, + VKD3D_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101, + VKD3D_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104, + VKD3D_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105, + VKD3D_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110, + VKD3D_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111, + VKD3D_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114, + VKD3D_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 0x115, + VKD3D_FILTER_MINIMUM_ANISOTROPIC = 0x155, + VKD3D_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 0x180, + VKD3D_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181, + VKD3D_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184, + VKD3D_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185, + VKD3D_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190, + VKD3D_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191, + VKD3D_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194, + VKD3D_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195, + VKD3D_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_FILTER), +}; + +enum vkd3d_texture_address_mode +{ + VKD3D_TEXTURE_ADDRESS_MODE_WRAP = 1, + VKD3D_TEXTURE_ADDRESS_MODE_MIRROR = 2, + VKD3D_TEXTURE_ADDRESS_MODE_CLAMP = 3, + VKD3D_TEXTURE_ADDRESS_MODE_BORDER = 4, + VKD3D_TEXTURE_ADDRESS_MODE_MIRROR_ONCE = 5, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_TEXTURE_ADDRESS_MODE), +}; + +enum vkd3d_comparison_func +{ + VKD3D_COMPARISON_FUNC_NEVER = 1, + VKD3D_COMPARISON_FUNC_LESS = 2, + VKD3D_COMPARISON_FUNC_EQUAL = 3, + VKD3D_COMPARISON_FUNC_LESS_EQUAL = 4, + VKD3D_COMPARISON_FUNC_GREATER = 5, + VKD3D_COMPARISON_FUNC_NOT_EQUAL = 6, + VKD3D_COMPARISON_FUNC_GREATER_EQUAL = 7, + VKD3D_COMPARISON_FUNC_ALWAYS = 8, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_COMPARISON_FUNC), +}; + +enum vkd3d_static_border_color +{ + VKD3D_STATIC_BORDER_COLOR_TRANSPARENT_BLACK = 0, + VKD3D_STATIC_BORDER_COLOR_OPAQUE_BLACK = 1, + VKD3D_STATIC_BORDER_COLOR_OPAQUE_WHITE = 2, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_STATIC_BORDER_COLOR), +}; + +struct vkd3d_static_sampler_desc +{ + enum vkd3d_filter filter; + enum vkd3d_texture_address_mode address_u; + enum vkd3d_texture_address_mode address_v; + enum vkd3d_texture_address_mode address_w; + float mip_lod_bias; + unsigned int max_anisotropy; + enum vkd3d_comparison_func comparison_func; + enum vkd3d_static_border_color border_color; + float min_lod; + float max_lod; + unsigned int shader_register; + unsigned int register_space; + enum vkd3d_shader_visibility shader_visibility; +}; + +enum vkd3d_descriptor_range_type +{ + VKD3D_DESCRIPTOR_RANGE_TYPE_SRV = 0, + VKD3D_DESCRIPTOR_RANGE_TYPE_UAV = 1, + VKD3D_DESCRIPTOR_RANGE_TYPE_CBV = 2, + VKD3D_DESCRIPTOR_RANGE_TYPE_SAMPLER = 3, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_DESCRIPTOR_RANGE_TYPE), +}; + +struct vkd3d_descriptor_range +{ + enum vkd3d_descriptor_range_type range_type; + unsigned int descriptor_count; + unsigned int base_shader_register; + unsigned int register_space; + unsigned int descriptor_table_offset; +}; + +struct vkd3d_root_descriptor_table +{ + unsigned int descriptor_range_count; + const struct vkd3d_descriptor_range *descriptor_ranges; +}; + +struct vkd3d_root_constants +{ + unsigned int shader_register; + unsigned int register_space; + unsigned int value_count; +}; + +struct vkd3d_root_descriptor +{ + unsigned int shader_register; + unsigned int register_space; +}; + +enum vkd3d_root_parameter_type +{ + VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE = 0, + VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS = 1, + VKD3D_ROOT_PARAMETER_TYPE_CBV = 2, + VKD3D_ROOT_PARAMETER_TYPE_SRV = 3, + VKD3D_ROOT_PARAMETER_TYPE_UAV = 4, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_ROOT_PARAMETER_TYPE), +}; + +struct vkd3d_root_parameter +{ + enum vkd3d_root_parameter_type parameter_type; + union + { + struct vkd3d_root_descriptor_table descriptor_table; + struct vkd3d_root_constants constants; + struct vkd3d_root_descriptor descriptor; + } u; + enum vkd3d_shader_visibility shader_visibility; +}; + +enum vkd3d_root_signature_flags +{ + VKD3D_ROOT_SIGNATURE_FLAG_NONE = 0x0, + VKD3D_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0x1, + VKD3D_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS = 0x2, + VKD3D_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS = 0x4, + VKD3D_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS = 0x8, + VKD3D_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS = 0x10, + VKD3D_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS = 0x20, + VKD3D_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT = 0x40, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_ROOT_SIGNATURE_FLAGS), +}; + +struct vkd3d_root_signature_desc +{ + unsigned int parameter_count; + const struct vkd3d_root_parameter *parameters; + unsigned int static_sampler_count; + const struct vkd3d_static_sampler_desc *static_samplers; + enum vkd3d_root_signature_flags flags; +}; + HRESULT vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, - D3D12_ROOT_SIGNATURE_DESC *root_signature); -void vkd3d_shader_free_root_signature(D3D12_ROOT_SIGNATURE_DESC *root_signature); + struct vkd3d_root_signature_desc *root_signature); +void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_signature);
enum vkd3d_root_signature_version { @@ -129,7 +306,7 @@ enum vkd3d_root_signature_version VKD3D_FORCE_32_BIT_ENUM(VKD3D_ROOT_SIGNATURE_VERSION), };
-HRESULT vkd3d_shader_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *root_signature, +HRESULT vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature, enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc);
#define VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS 8 diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 8f6147a6a46d..ab18602980d5 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -2064,7 +2064,7 @@ HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, }
static HRESULT shader_parse_descriptor_ranges(const char *data, DWORD data_size, - DWORD offset, DWORD count, D3D12_DESCRIPTOR_RANGE *ranges) + DWORD offset, DWORD count, struct vkd3d_descriptor_range *ranges) { const char *ptr; unsigned int i; @@ -2078,26 +2078,26 @@ static HRESULT shader_parse_descriptor_ranges(const char *data, DWORD data_size,
for (i = 0; i < count; ++i) { - read_dword(&ptr, &ranges[i].RangeType); - read_dword(&ptr, &ranges[i].NumDescriptors); - read_dword(&ptr, &ranges[i].BaseShaderRegister); - read_dword(&ptr, &ranges[i].RegisterSpace); - read_dword(&ptr, &ranges[i].OffsetInDescriptorsFromTableStart); + read_dword(&ptr, &ranges[i].range_type); + read_dword(&ptr, &ranges[i].descriptor_count); + read_dword(&ptr, &ranges[i].base_shader_register); + read_dword(&ptr, &ranges[i].register_space); + read_dword(&ptr, &ranges[i].descriptor_table_offset);
TRACE("Type %#x, descriptor count %u, base shader register %u, " "register space %u, offset %u.\n", - ranges[i].RangeType, ranges[i].NumDescriptors, - ranges[i].BaseShaderRegister, ranges[i].RegisterSpace, - ranges[i].OffsetInDescriptorsFromTableStart); + ranges[i].range_type, ranges[i].descriptor_count, + ranges[i].base_shader_register, ranges[i].register_space, + ranges[i].descriptor_table_offset); }
return S_OK; }
static HRESULT shader_parse_descriptor_table(const char *data, DWORD data_size, - DWORD offset, D3D12_ROOT_DESCRIPTOR_TABLE *table) + DWORD offset, struct vkd3d_root_descriptor_table *table) { - D3D12_DESCRIPTOR_RANGE *ranges; + struct vkd3d_descriptor_range *ranges; const char *ptr; DWORD count;
@@ -2113,16 +2113,16 @@ static HRESULT shader_parse_descriptor_table(const char *data, DWORD data_size,
TRACE("Descriptor range count %u.\n", count);
- table->NumDescriptorRanges = count; + table->descriptor_range_count = count;
if (!(ranges = vkd3d_calloc(count, sizeof(*ranges)))) return E_OUTOFMEMORY; - table->pDescriptorRanges = ranges; + table->descriptor_ranges = ranges; return shader_parse_descriptor_ranges(data, data_size, offset, count, ranges); }
static HRESULT shader_parse_root_constants(const char *data, DWORD data_size, - DWORD offset, D3D12_ROOT_CONSTANTS *constants) + DWORD offset, struct vkd3d_root_constants *constants) { const char *ptr;
@@ -2133,18 +2133,18 @@ static HRESULT shader_parse_root_constants(const char *data, DWORD data_size, } ptr = &data[offset];
- read_dword(&ptr, &constants->ShaderRegister); - read_dword(&ptr, &constants->RegisterSpace); - read_dword(&ptr, &constants->Num32BitValues); + read_dword(&ptr, &constants->shader_register); + read_dword(&ptr, &constants->register_space); + read_dword(&ptr, &constants->value_count);
TRACE("Shader register %u, register space %u, 32-bit value count %u.\n", - constants->ShaderRegister, constants->RegisterSpace, constants->Num32BitValues); + constants->shader_register, constants->register_space, constants->value_count);
return S_OK; }
static HRESULT shader_parse_root_descriptor(const char *data, DWORD data_size, - DWORD offset, D3D12_ROOT_DESCRIPTOR *descriptor) + DWORD offset, struct vkd3d_root_descriptor *descriptor) { const char *ptr;
@@ -2155,17 +2155,17 @@ static HRESULT shader_parse_root_descriptor(const char *data, DWORD data_size, } ptr = &data[offset];
- read_dword(&ptr, &descriptor->ShaderRegister); - read_dword(&ptr, &descriptor->RegisterSpace); + read_dword(&ptr, &descriptor->shader_register); + read_dword(&ptr, &descriptor->register_space);
TRACE("Shader register %u, register space %u.\n", - descriptor->ShaderRegister, descriptor->RegisterSpace); + descriptor->shader_register, descriptor->register_space);
return S_OK; }
static HRESULT shader_parse_root_parameters(const char *data, DWORD data_size, - DWORD offset, DWORD count, D3D12_ROOT_PARAMETER *parameters) + DWORD offset, DWORD count, struct vkd3d_root_parameter *parameters) { const char *ptr; unsigned int i; @@ -2180,28 +2180,28 @@ static HRESULT shader_parse_root_parameters(const char *data, DWORD data_size,
for (i = 0; i < count; ++i) { - read_dword(&ptr, ¶meters[i].ParameterType); - read_dword(&ptr, ¶meters[i].ShaderVisibility); + read_dword(&ptr, ¶meters[i].parameter_type); + read_dword(&ptr, ¶meters[i].shader_visibility); read_dword(&ptr, &offset);
TRACE("Type %#x, shader visibility %#x.\n", - parameters[i].ParameterType, parameters[i].ShaderVisibility); + parameters[i].parameter_type, parameters[i].shader_visibility);
- switch (parameters[i].ParameterType) + switch (parameters[i].parameter_type) { - case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - hr = shader_parse_descriptor_table(data, data_size, offset, ¶meters[i].u.DescriptorTable); + case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: + hr = shader_parse_descriptor_table(data, data_size, offset, ¶meters[i].u.descriptor_table); break; - case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: - hr = shader_parse_root_constants(data, data_size, offset, ¶meters[i].u.Constants); + case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: + hr = shader_parse_root_constants(data, data_size, offset, ¶meters[i].u.constants); break; - case D3D12_ROOT_PARAMETER_TYPE_CBV: - case D3D12_ROOT_PARAMETER_TYPE_SRV: - case D3D12_ROOT_PARAMETER_TYPE_UAV: - hr = shader_parse_root_descriptor(data, data_size, offset, ¶meters[i].u.Descriptor); + case VKD3D_ROOT_PARAMETER_TYPE_CBV: + case VKD3D_ROOT_PARAMETER_TYPE_SRV: + case VKD3D_ROOT_PARAMETER_TYPE_UAV: + hr = shader_parse_root_descriptor(data, data_size, offset, ¶meters[i].u.descriptor); break; default: - FIXME("Unrecognized type %#x.\n", parameters[i].ParameterType); + FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type); return E_INVALIDARG; }
@@ -2213,7 +2213,7 @@ static HRESULT shader_parse_root_parameters(const char *data, DWORD data_size, }
static HRESULT shader_parse_static_samplers(const char *data, DWORD data_size, - DWORD offset, DWORD count, D3D12_STATIC_SAMPLER_DESC *sampler_descs) + DWORD offset, DWORD count, struct vkd3d_static_sampler_desc *sampler_descs) { const char *ptr; unsigned int i; @@ -2227,26 +2227,26 @@ static HRESULT shader_parse_static_samplers(const char *data, DWORD data_size,
for (i = 0; i < count; ++i) { - read_dword(&ptr, &sampler_descs[i].Filter); - read_dword(&ptr, &sampler_descs[i].AddressU); - read_dword(&ptr, &sampler_descs[i].AddressV); - read_dword(&ptr, &sampler_descs[i].AddressW); - read_float(&ptr, &sampler_descs[i].MipLODBias); - read_dword(&ptr, &sampler_descs[i].MaxAnisotropy); - read_dword(&ptr, &sampler_descs[i].ComparisonFunc); - read_dword(&ptr, &sampler_descs[i].BorderColor); - read_float(&ptr, &sampler_descs[i].MinLOD); - read_float(&ptr, &sampler_descs[i].MaxLOD); - read_dword(&ptr, &sampler_descs[i].ShaderRegister); - read_dword(&ptr, &sampler_descs[i].RegisterSpace); - read_dword(&ptr, &sampler_descs[i].ShaderVisibility); + read_dword(&ptr, &sampler_descs[i].filter); + read_dword(&ptr, &sampler_descs[i].address_u); + read_dword(&ptr, &sampler_descs[i].address_v); + read_dword(&ptr, &sampler_descs[i].address_w); + read_float(&ptr, &sampler_descs[i].mip_lod_bias); + read_dword(&ptr, &sampler_descs[i].max_anisotropy); + read_dword(&ptr, &sampler_descs[i].comparison_func); + read_dword(&ptr, &sampler_descs[i].border_color); + read_float(&ptr, &sampler_descs[i].min_lod); + read_float(&ptr, &sampler_descs[i].max_lod); + read_dword(&ptr, &sampler_descs[i].shader_register); + read_dword(&ptr, &sampler_descs[i].register_space); + read_dword(&ptr, &sampler_descs[i].shader_visibility); }
return S_OK; }
static HRESULT shader_parse_root_signature(const char *data, DWORD data_size, - D3D12_ROOT_SIGNATURE_DESC *desc) + struct vkd3d_root_signature_desc *desc) { const char *ptr = data; DWORD count, offset; @@ -2264,13 +2264,13 @@ static HRESULT shader_parse_root_signature(const char *data, DWORD data_size, read_dword(&ptr, &offset); TRACE("Parameter count %u, offset %u.\n", count, offset);
- desc->NumParameters = count; - if (desc->NumParameters) + desc->parameter_count = count; + if (desc->parameter_count) { - D3D12_ROOT_PARAMETER *parameters; - if (!(parameters = vkd3d_calloc(desc->NumParameters, sizeof(*parameters)))) + struct vkd3d_root_parameter *parameters; + if (!(parameters = vkd3d_calloc(desc->parameter_count, sizeof(*parameters)))) return E_OUTOFMEMORY; - desc->pParameters = parameters; + desc->parameters = parameters; if (FAILED(hr = shader_parse_root_parameters(data, data_size, offset, count, parameters))) return hr; } @@ -2279,26 +2279,26 @@ static HRESULT shader_parse_root_signature(const char *data, DWORD data_size, read_dword(&ptr, &offset); TRACE("Static sampler count %u, offset %u.\n", count, offset);
- desc->NumStaticSamplers = count; - if (desc->NumStaticSamplers) + desc->static_sampler_count = count; + if (desc->static_sampler_count) { - D3D12_STATIC_SAMPLER_DESC *samplers; - if (!(samplers = vkd3d_calloc(desc->NumStaticSamplers, sizeof(*samplers)))) + struct vkd3d_static_sampler_desc *samplers; + if (!(samplers = vkd3d_calloc(desc->static_sampler_count, sizeof(*samplers)))) return E_OUTOFMEMORY; - desc->pStaticSamplers = samplers; + desc->static_samplers = samplers; if (FAILED(hr = shader_parse_static_samplers(data, data_size, offset, count, samplers))) return hr; }
- read_dword(&ptr, &desc->Flags); - TRACE("Flags %#x.\n", desc->Flags); + read_dword(&ptr, &desc->flags); + TRACE("Flags %#x.\n", desc->flags);
return S_OK; }
static HRESULT rts0_handler(const char *data, DWORD data_size, DWORD tag, void *context) { - D3D12_ROOT_SIGNATURE_DESC *desc = context; + struct vkd3d_root_signature_desc *desc = context;
if (tag != TAG_RTS0) return S_OK; @@ -2307,7 +2307,7 @@ static HRESULT rts0_handler(const char *data, DWORD data_size, DWORD tag, void * }
HRESULT vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, - D3D12_ROOT_SIGNATURE_DESC *root_signature) + struct vkd3d_root_signature_desc *root_signature) { HRESULT hr;
@@ -2400,22 +2400,22 @@ static HRESULT shader_write_root_signature_header(struct root_signature_writer_c }
static HRESULT shader_write_descriptor_ranges(struct root_signature_writer_context *context, - const D3D12_ROOT_DESCRIPTOR_TABLE *table) + const struct vkd3d_root_descriptor_table *table) { - const D3D12_DESCRIPTOR_RANGE *ranges = table->pDescriptorRanges; + const struct vkd3d_descriptor_range *ranges = table->descriptor_ranges; unsigned int i;
- for (i = 0; i < table->NumDescriptorRanges; ++i) + for (i = 0; i < table->descriptor_range_count; ++i) { - if (!write_dword(context, ranges[i].RangeType)) + if (!write_dword(context, ranges[i].range_type)) return E_OUTOFMEMORY; - if (!write_dword(context, ranges[i].NumDescriptors)) + if (!write_dword(context, ranges[i].descriptor_count)) return E_OUTOFMEMORY; - if (!write_dword(context, ranges[i].BaseShaderRegister)) + if (!write_dword(context, ranges[i].base_shader_register)) return E_OUTOFMEMORY; - if (!write_dword(context, ranges[i].RegisterSpace)) + if (!write_dword(context, ranges[i].register_space)) return E_OUTOFMEMORY; - if (!write_dword(context, ranges[i].OffsetInDescriptorsFromTableStart)) + if (!write_dword(context, ranges[i].descriptor_table_offset)) return E_OUTOFMEMORY; }
@@ -2423,9 +2423,9 @@ static HRESULT shader_write_descriptor_ranges(struct root_signature_writer_conte }
static HRESULT shader_write_descriptor_table(struct root_signature_writer_context *context, - const D3D12_ROOT_DESCRIPTOR_TABLE *table) + const struct vkd3d_root_descriptor_table *table) { - if (!write_dword(context, table->NumDescriptorRanges)) + if (!write_dword(context, table->descriptor_range_count)) return E_OUTOFMEMORY; if (!write_dword(context, get_chunk_offset(context) + sizeof(DWORD))) /* offset */ return E_OUTOFMEMORY; @@ -2434,67 +2434,67 @@ static HRESULT shader_write_descriptor_table(struct root_signature_writer_contex }
static HRESULT shader_write_root_constants(struct root_signature_writer_context *context, - const D3D12_ROOT_CONSTANTS *constants) + const struct vkd3d_root_constants *constants) { - if (!write_dword(context, constants->ShaderRegister)) + if (!write_dword(context, constants->shader_register)) return E_OUTOFMEMORY; - if (!write_dword(context, constants->RegisterSpace)) + if (!write_dword(context, constants->register_space)) return E_OUTOFMEMORY; - if (!write_dword(context, constants->Num32BitValues)) + if (!write_dword(context, constants->value_count)) return E_OUTOFMEMORY;
return S_OK; }
static HRESULT shader_write_root_descriptor(struct root_signature_writer_context *context, - const D3D12_ROOT_DESCRIPTOR *descriptor) + const struct vkd3d_root_descriptor *descriptor) { - if (!write_dword(context, descriptor->ShaderRegister)) + if (!write_dword(context, descriptor->shader_register)) return E_OUTOFMEMORY; - if (!write_dword(context, descriptor->RegisterSpace)) + if (!write_dword(context, descriptor->register_space)) return E_OUTOFMEMORY;
return S_OK; }
static HRESULT shader_write_root_parameters(struct root_signature_writer_context *context, - const D3D12_ROOT_SIGNATURE_DESC *desc) + const struct vkd3d_root_signature_desc *desc) { - const D3D12_ROOT_PARAMETER *parameters = desc->pParameters; + const struct vkd3d_root_parameter *parameters = desc->parameters; size_t parameters_position; unsigned int i; HRESULT hr;
parameters_position = context->position; - for (i = 0; i < desc->NumParameters; ++i) + for (i = 0; i < desc->parameter_count; ++i) { - if (!write_dword(context, parameters[i].ParameterType)) + if (!write_dword(context, parameters[i].parameter_type)) return E_OUTOFMEMORY; - if (!write_dword(context, parameters[i].ShaderVisibility)) + if (!write_dword(context, parameters[i].shader_visibility)) return E_OUTOFMEMORY; if (!write_dword(context, 0xffffffff)) /* offset */ return E_OUTOFMEMORY; }
- for (i = 0; i < desc->NumParameters; ++i) + for (i = 0; i < desc->parameter_count; ++i) { context->data[parameters_position + 3 * i + 2] = get_chunk_offset(context); /* offset */
- switch (parameters[i].ParameterType) + switch (parameters[i].parameter_type) { - case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - hr = shader_write_descriptor_table(context, ¶meters[i].u.DescriptorTable); + case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: + hr = shader_write_descriptor_table(context, ¶meters[i].u.descriptor_table); break; - case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: - hr = shader_write_root_constants(context, ¶meters[i].u.Constants); + case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: + hr = shader_write_root_constants(context, ¶meters[i].u.constants); break; - case D3D12_ROOT_PARAMETER_TYPE_CBV: - case D3D12_ROOT_PARAMETER_TYPE_SRV: - case D3D12_ROOT_PARAMETER_TYPE_UAV: - hr = shader_write_root_descriptor(context, ¶meters[i].u.Descriptor); + case VKD3D_ROOT_PARAMETER_TYPE_CBV: + case VKD3D_ROOT_PARAMETER_TYPE_SRV: + case VKD3D_ROOT_PARAMETER_TYPE_UAV: + hr = shader_write_root_descriptor(context, ¶meters[i].u.descriptor); break; default: - FIXME("Unrecognized type %#x.\n", parameters[i].ParameterType); + FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type); return E_INVALIDARG; }
@@ -2506,38 +2506,38 @@ static HRESULT shader_write_root_parameters(struct root_signature_writer_context }
static HRESULT shader_write_static_samplers(struct root_signature_writer_context *context, - const D3D12_ROOT_SIGNATURE_DESC *desc) + const struct vkd3d_root_signature_desc *desc) { - const D3D12_STATIC_SAMPLER_DESC *samplers = desc->pStaticSamplers; + const struct vkd3d_static_sampler_desc *samplers = desc->static_samplers; unsigned int i;
- for (i = 0; i < desc->NumStaticSamplers; ++i) + for (i = 0; i < desc->static_sampler_count; ++i) { - if (!write_dword(context, samplers[i].Filter)) + if (!write_dword(context, samplers[i].filter)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].AddressU)) + if (!write_dword(context, samplers[i].address_u)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].AddressV)) + if (!write_dword(context, samplers[i].address_v)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].AddressW)) + if (!write_dword(context, samplers[i].address_w)) return E_OUTOFMEMORY; - if (!write_float(context, samplers[i].MipLODBias)) + if (!write_float(context, samplers[i].mip_lod_bias)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].MaxAnisotropy)) + if (!write_dword(context, samplers[i].max_anisotropy)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].ComparisonFunc)) + if (!write_dword(context, samplers[i].comparison_func)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].BorderColor)) + if (!write_dword(context, samplers[i].border_color)) return E_OUTOFMEMORY; - if (!write_float(context, samplers[i].MinLOD)) + if (!write_float(context, samplers[i].min_lod)) return E_OUTOFMEMORY; - if (!write_float(context, samplers[i].MaxLOD)) + if (!write_float(context, samplers[i].max_lod)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].ShaderRegister)) + if (!write_dword(context, samplers[i].shader_register)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].RegisterSpace)) + if (!write_dword(context, samplers[i].register_space)) return E_OUTOFMEMORY; - if (!write_dword(context, samplers[i].ShaderVisibility)) + if (!write_dword(context, samplers[i].shader_visibility)) return E_OUTOFMEMORY; }
@@ -2545,7 +2545,7 @@ static HRESULT shader_write_static_samplers(struct root_signature_writer_context }
static HRESULT shader_write_root_signature(struct root_signature_writer_context *context, - const D3D12_ROOT_SIGNATURE_DESC *desc) + const struct vkd3d_root_signature_desc *desc) { size_t samplers_offset_position; HRESULT hr; @@ -2553,18 +2553,18 @@ static HRESULT shader_write_root_signature(struct root_signature_writer_context if (!write_dword(context, 0x00000001)) return E_OUTOFMEMORY;
- if (!write_dword(context, desc->NumParameters)) + if (!write_dword(context, desc->parameter_count)) return E_OUTOFMEMORY; if (!write_dword(context, get_chunk_offset(context) + 4 * sizeof(DWORD))) /* offset */ return E_OUTOFMEMORY;
- if (!write_dword(context, desc->NumStaticSamplers)) + if (!write_dword(context, desc->static_sampler_count)) return E_OUTOFMEMORY; samplers_offset_position = context->position; if (!write_dword(context, 0xffffffff)) /* offset */ return E_OUTOFMEMORY;
- if (!write_dword(context, desc->Flags)) + if (!write_dword(context, desc->flags)) return E_OUTOFMEMORY;
if (FAILED(hr = shader_write_root_parameters(context, desc))) @@ -2574,7 +2574,7 @@ static HRESULT shader_write_root_signature(struct root_signature_writer_context return shader_write_static_samplers(context, desc); }
-HRESULT vkd3d_shader_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *root_signature, +HRESULT vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature, enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc) { struct root_signature_writer_context context; diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index bf1a3916888d..3578b053df8c 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -200,19 +200,19 @@ void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *shader_code) vkd3d_free((void *)shader_code->code); }
-void vkd3d_shader_free_root_signature(D3D12_ROOT_SIGNATURE_DESC *root_signature) +void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_signature) { unsigned int i;
- for (i = 0; i < root_signature->NumParameters; ++i) + for (i = 0; i < root_signature->parameter_count; ++i) { - const D3D12_ROOT_PARAMETER *parameter = &root_signature->pParameters[i]; + const struct vkd3d_root_parameter *parameter = &root_signature->parameters[i];
- if (parameter->ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) - vkd3d_free((void *)parameter->u.DescriptorTable.pDescriptorRanges); + if (parameter->parameter_type == VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) + vkd3d_free((void *)parameter->u.descriptor_table.descriptor_ranges); } - vkd3d_free((void *)root_signature->pParameters); - vkd3d_free((void *)root_signature->pStaticSamplers); + vkd3d_free((void *)root_signature->parameters); + vkd3d_free((void *)root_signature->static_samplers);
memset(root_signature, 0, sizeof(*root_signature)); } diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 6bbba1bb7859..befc44d6aee6 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1006,11 +1006,15 @@ HRESULT d3d12_root_signature_create(struct d3d12_device *device, const void *bytecode, size_t bytecode_length, struct d3d12_root_signature **root_signature) { const struct vkd3d_shader_code dxbc = {bytecode, bytecode_length}; - D3D12_ROOT_SIGNATURE_DESC root_signature_desc; + union + { + D3D12_ROOT_SIGNATURE_DESC d3d12; + struct vkd3d_root_signature_desc vkd3d; + } root_signature_desc; struct d3d12_root_signature *object; HRESULT hr;
- if (FAILED(hr = vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc))) + if (FAILED(hr = vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc.vkd3d))) { WARN("Failed to parse root signature, hr %#x.\n", hr); return hr; @@ -1018,12 +1022,12 @@ HRESULT d3d12_root_signature_create(struct d3d12_device *device,
if (!(object = vkd3d_malloc(sizeof(*object)))) { - vkd3d_shader_free_root_signature(&root_signature_desc); + vkd3d_shader_free_root_signature(&root_signature_desc.vkd3d); return E_OUTOFMEMORY; }
- hr = d3d12_root_signature_init(object, device, &root_signature_desc); - vkd3d_shader_free_root_signature(&root_signature_desc); + hr = d3d12_root_signature_init(object, device, &root_signature_desc.d3d12); + vkd3d_shader_free_root_signature(&root_signature_desc.vkd3d); if (FAILED(hr)) { vkd3d_free(object); diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index 7dd7a1d915ac..d4d660dc727d 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -79,7 +79,11 @@ struct d3d12_root_signature_deserializer ID3D12RootSignatureDeserializer ID3D12RootSignatureDeserializer_iface; LONG refcount;
- D3D12_ROOT_SIGNATURE_DESC desc; + union + { + D3D12_ROOT_SIGNATURE_DESC d3d12; + struct vkd3d_root_signature_desc vkd3d; + } desc; };
static struct d3d12_root_signature_deserializer *impl_from_ID3D12RootSignatureDeserializer( @@ -128,7 +132,7 @@ static ULONG STDMETHODCALLTYPE d3d12_root_signature_deserializer_Release(ID3D12R
if (!refcount) { - vkd3d_shader_free_root_signature(&deserializer->desc); + vkd3d_shader_free_root_signature(&deserializer->desc.vkd3d); vkd3d_free(deserializer); }
@@ -142,7 +146,7 @@ static const D3D12_ROOT_SIGNATURE_DESC * STDMETHODCALLTYPE d3d12_root_signature_
TRACE("iface %p.\n", iface);
- return &deserializer->desc; + return &deserializer->desc.d3d12; }
static const struct ID3D12RootSignatureDeserializerVtbl d3d12_root_signature_deserializer_vtbl = @@ -163,7 +167,7 @@ static HRESULT d3d12_root_signature_deserializer_init(struct d3d12_root_signatur deserializer->ID3D12RootSignatureDeserializer_iface.lpVtbl = &d3d12_root_signature_deserializer_vtbl; deserializer->refcount = 1;
- if (FAILED(hr = vkd3d_shader_parse_root_signature(dxbc, &deserializer->desc))) + if (FAILED(hr = vkd3d_shader_parse_root_signature(dxbc, &deserializer->desc.vkd3d))) { WARN("Failed to parse root signature, hr %#x.\n", hr); return hr; @@ -331,7 +335,8 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *root_sig *error_blob = NULL; }
- if (FAILED(hr = vkd3d_shader_serialize_root_signature(root_signature_desc, + if (FAILED(hr = vkd3d_shader_serialize_root_signature( + (const struct vkd3d_root_signature_desc *)root_signature_desc, (enum vkd3d_root_signature_version)version, &dxbc))) { WARN("Failed to serialize root signature, hr %#x.\n", hr);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/vkd3d_shader.h | 26 ++- libs/vkd3d-shader/dxbc.c | 313 +++++++++++++++---------------- libs/vkd3d-shader/spirv.c | 6 +- libs/vkd3d-shader/vkd3d_shader_main.c | 46 +++-- libs/vkd3d-shader/vkd3d_shader_private.h | 6 +- libs/vkd3d/state.c | 35 ++-- libs/vkd3d/utils.c | 20 ++ libs/vkd3d/vkd3d_main.c | 17 +- libs/vkd3d/vkd3d_private.h | 1 + 9 files changed, 252 insertions(+), 218 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index f99d21684b81..ed2fc8908263 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -19,7 +19,8 @@ #ifndef __VKD3D_SHADER_H #define __VKD3D_SHADER_H
-#include "vkd3d.h" +#include <stdbool.h> +#include <stdint.h>
#ifdef __cplusplus extern "C" { @@ -27,6 +28,17 @@ extern "C" {
#define VKD3D_FORCE_32_BIT_ENUM(name) name##_FORCE_32BIT = 0x7fffffff
+enum vkd3d_result +{ + VKD3D_OK = 0, + VKD3D_ERROR = -1, /* unspecified failure */ + VKD3D_ERROR_OUT_OF_MEMORY = -2, + VKD3D_ERROR_INVALID_ARGUMENT = -3, + VKD3D_ERROR_NOT_IMPLEMENTED = -4, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_RESULT), +}; + enum vkd3d_shader_compiler_option { VKD3D_SHADER_STRIP_DEBUG = 0x00000001, @@ -113,7 +125,7 @@ struct vkd3d_shader_interface unsigned int uav_counter_count; };
-HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_code *spirv, uint32_t compiler_options, const struct vkd3d_shader_interface *shader_interface); void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code); @@ -295,7 +307,7 @@ struct vkd3d_root_signature_desc enum vkd3d_root_signature_flags flags; };
-HRESULT vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_root_signature_desc *root_signature); void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_signature);
@@ -306,7 +318,7 @@ enum vkd3d_root_signature_version VKD3D_FORCE_32_BIT_ENUM(VKD3D_ROOT_SIGNATURE_VERSION), };
-HRESULT vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature, +int vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature, enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc);
#define VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS 8 @@ -317,7 +329,7 @@ struct vkd3d_shader_scan_info unsigned int uav_counter_mask : VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS; };
-HRESULT vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_scan_info *scan_info);
enum vkd3d_component_type @@ -362,7 +374,7 @@ struct vkd3d_shader_signature_element enum vkd3d_sysval_semantic sysval_semantic; enum vkd3d_component_type component_type; unsigned int register_index; - DWORD mask; + unsigned int mask; };
struct vkd3d_shader_signature @@ -371,7 +383,7 @@ struct vkd3d_shader_signature unsigned int element_count; };
-HRESULT vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_signature *signature); struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element( const struct vkd3d_shader_signature *signature, const char *semantic_name, diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index ab18602980d5..49e2c5020fee 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -1808,11 +1808,11 @@ static const char *shader_get_string(const char *data, size_t data_size, DWORD o return data + offset; }
-static HRESULT parse_dxbc(const char *data, SIZE_T data_size, - HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) +static int parse_dxbc(const char *data, SIZE_T data_size, + int (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) { const char *ptr = data; - HRESULT hr = S_OK; + int ret = VKD3D_OK; DWORD chunk_count; DWORD total_size; unsigned int i; @@ -1825,7 +1825,7 @@ static HRESULT parse_dxbc(const char *data, SIZE_T data_size, if (tag != TAG_DXBC) { WARN("Wrong tag.\n"); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; }
WARN("Ignoring DXBC checksum.\n"); @@ -1836,7 +1836,7 @@ static HRESULT parse_dxbc(const char *data, SIZE_T data_size, if (version != 0x00000001) { WARN("Got unexpected DXBC version %#x.\n", version); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; }
read_dword(&ptr, &total_size); @@ -1857,7 +1857,7 @@ static HRESULT parse_dxbc(const char *data, SIZE_T data_size, if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size)) { WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size); - return E_FAIL; + return VKD3D_ERROR_INVALID_ARGUMENT; }
chunk_ptr = data + chunk_offset; @@ -1869,17 +1869,17 @@ static HRESULT parse_dxbc(const char *data, SIZE_T data_size, { WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n", chunk_size, data_size, chunk_offset); - return E_FAIL; + return VKD3D_ERROR_INVALID_ARGUMENT; }
- hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx); - if (FAILED(hr)) break; + if ((ret = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx)) < 0) + break; }
- return hr; + return ret; }
-static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_size, +static int shader_parse_signature(DWORD tag, const char *data, DWORD data_size, struct vkd3d_shader_signature *s) { struct vkd3d_shader_signature_element *e; @@ -1890,7 +1890,7 @@ static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_si if (!require_space(0, 2, sizeof(DWORD), data_size)) { WARN("Invalid data size %#x.\n", data_size); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; }
read_dword(&ptr, &count); @@ -1901,13 +1901,13 @@ static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_si if (!require_space(ptr - data, count, 6 * sizeof(DWORD), data_size)) { WARN("Invalid count %#x (data size %#x).\n", count, data_size); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; }
if (!(e = vkd3d_calloc(count, sizeof(*e)))) { ERR("Failed to allocate input signature memory.\n"); - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; }
for (i = 0; i < count; ++i) @@ -1923,7 +1923,7 @@ static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_si { WARN("Invalid name offset %#x (data size %#x).\n", name_offset, data_size); vkd3d_free(e); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; } read_dword(&ptr, &e[i].semantic_index); read_dword(&ptr, &e[i].sysval_semantic); @@ -1940,15 +1940,15 @@ static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_si s->elements = e; s->element_count = count;
- return S_OK; + return VKD3D_OK; }
-static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void *ctx) +static int isgn_handler(const char *data, DWORD data_size, DWORD tag, void *ctx) { struct vkd3d_shader_signature *is = ctx;
if (tag != TAG_ISGN) - return S_OK; + return VKD3D_OK;
if (is->elements) { @@ -1958,26 +1958,21 @@ static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void * return shader_parse_signature(tag, data, data_size, is); }
-HRESULT shader_parse_input_signature(const void *dxbc, SIZE_T dxbc_length, +int shader_parse_input_signature(const void *dxbc, SIZE_T dxbc_length, struct vkd3d_shader_signature *signature) { - HRESULT hr; + int ret;
memset(signature, 0, sizeof(*signature)); - - if (FAILED(hr = parse_dxbc(dxbc, dxbc_length, isgn_handler, signature))) - { + if ((ret = parse_dxbc(dxbc, dxbc_length, isgn_handler, signature)) < 0) ERR("Failed to parse input signature.\n"); - return E_FAIL; - } - - return S_OK; + return ret; }
-static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *context) +static int shdr_handler(const char *data, DWORD data_size, DWORD tag, void *context) { struct vkd3d_shader_desc *desc = context; - HRESULT hr; + int ret;
switch (tag) { @@ -1987,8 +1982,8 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void * FIXME("Multiple input signatures.\n"); break; } - if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->input_signature))) - return hr; + if ((ret = shader_parse_signature(tag, data, data_size, &desc->input_signature)) < 0) + return ret; break;
case TAG_OSGN: @@ -1998,8 +1993,8 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void * FIXME("Multiple output signatures.\n"); break; } - if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->output_signature))) - return hr; + if ((ret = shader_parse_signature(tag, data, data_size, &desc->output_signature)) < 0) + return ret; break;
case TAG_PCSG: @@ -2008,8 +2003,8 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void * FIXME("Multiple patch constant signatures.\n"); break; } - if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->patch_constant_signature))) - return hr; + if ((ret = shader_parse_signature(tag, data, data_size, &desc->patch_constant_signature)) < 0) + return ret; break;
case TAG_SHDR: @@ -2029,7 +2024,7 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void * break; }
- return S_OK; + return VKD3D_OK; }
void free_shader_desc(struct vkd3d_shader_desc *desc) @@ -2039,10 +2034,10 @@ void free_shader_desc(struct vkd3d_shader_desc *desc) vkd3d_shader_free_shader_signature(&desc->patch_constant_signature); }
-HRESULT 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_desc *desc) { - HRESULT hr; + int ret;
desc->byte_code = NULL; desc->byte_code_size = 0; @@ -2050,20 +2045,20 @@ HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, memset(&desc->output_signature, 0, sizeof(desc->output_signature)); memset(&desc->patch_constant_signature, 0, sizeof(desc->patch_constant_signature));
- hr = parse_dxbc(dxbc, dxbc_length, shdr_handler, desc); + ret = parse_dxbc(dxbc, dxbc_length, shdr_handler, desc); if (!desc->byte_code) - hr = E_INVALIDARG; + ret = VKD3D_ERROR_INVALID_ARGUMENT;
- if (FAILED(hr)) + if (ret < 0) { - FIXME("Failed to parse shader, hr %#x.\n", hr); + FIXME("Failed to parse shader, vkd3d result %d.\n", ret); free_shader_desc(desc); }
- return hr; + return ret; }
-static HRESULT shader_parse_descriptor_ranges(const char *data, DWORD data_size, +static int shader_parse_descriptor_ranges(const char *data, DWORD data_size, DWORD offset, DWORD count, struct vkd3d_descriptor_range *ranges) { const char *ptr; @@ -2072,7 +2067,7 @@ static HRESULT shader_parse_descriptor_ranges(const char *data, DWORD data_size, if (!require_space(offset, 5 * count, sizeof(DWORD), data_size)) { WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; } ptr = &data[offset];
@@ -2091,10 +2086,10 @@ static HRESULT shader_parse_descriptor_ranges(const char *data, DWORD data_size, ranges[i].descriptor_table_offset); }
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_parse_descriptor_table(const char *data, DWORD data_size, +static int shader_parse_descriptor_table(const char *data, DWORD data_size, DWORD offset, struct vkd3d_root_descriptor_table *table) { struct vkd3d_descriptor_range *ranges; @@ -2104,7 +2099,7 @@ static HRESULT shader_parse_descriptor_table(const char *data, DWORD data_size, if (!require_space(offset, 2, sizeof(DWORD), data_size)) { WARN("Invalid data size %#x (offset %u).\n", data_size, offset); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; } ptr = &data[offset];
@@ -2116,12 +2111,12 @@ static HRESULT shader_parse_descriptor_table(const char *data, DWORD data_size, table->descriptor_range_count = count;
if (!(ranges = vkd3d_calloc(count, sizeof(*ranges)))) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; table->descriptor_ranges = ranges; return shader_parse_descriptor_ranges(data, data_size, offset, count, ranges); }
-static HRESULT shader_parse_root_constants(const char *data, DWORD data_size, +static int shader_parse_root_constants(const char *data, DWORD data_size, DWORD offset, struct vkd3d_root_constants *constants) { const char *ptr; @@ -2129,7 +2124,7 @@ static HRESULT shader_parse_root_constants(const char *data, DWORD data_size, if (!require_space(offset, 3, sizeof(DWORD), data_size)) { WARN("Invalid data size %#x (offset %u).\n", data_size, offset); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; } ptr = &data[offset];
@@ -2140,10 +2135,10 @@ static HRESULT shader_parse_root_constants(const char *data, DWORD data_size, TRACE("Shader register %u, register space %u, 32-bit value count %u.\n", constants->shader_register, constants->register_space, constants->value_count);
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_parse_root_descriptor(const char *data, DWORD data_size, +static int shader_parse_root_descriptor(const char *data, DWORD data_size, DWORD offset, struct vkd3d_root_descriptor *descriptor) { const char *ptr; @@ -2151,7 +2146,7 @@ static HRESULT shader_parse_root_descriptor(const char *data, DWORD data_size, if (!require_space(offset, 2, sizeof(DWORD), data_size)) { WARN("Invalid data size %#x (offset %u).\n", data_size, offset); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; } ptr = &data[offset];
@@ -2161,20 +2156,20 @@ static HRESULT shader_parse_root_descriptor(const char *data, DWORD data_size, TRACE("Shader register %u, register space %u.\n", descriptor->shader_register, descriptor->register_space);
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_parse_root_parameters(const char *data, DWORD data_size, +static int shader_parse_root_parameters(const char *data, DWORD data_size, DWORD offset, DWORD count, struct vkd3d_root_parameter *parameters) { const char *ptr; unsigned int i; - HRESULT hr; + int ret;
if (!require_space(offset, 3 * count, sizeof(DWORD), data_size)) { WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; } ptr = &data[offset];
@@ -2190,29 +2185,29 @@ static HRESULT shader_parse_root_parameters(const char *data, DWORD data_size, switch (parameters[i].parameter_type) { case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - hr = shader_parse_descriptor_table(data, data_size, offset, ¶meters[i].u.descriptor_table); + ret = shader_parse_descriptor_table(data, data_size, offset, ¶meters[i].u.descriptor_table); break; case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: - hr = shader_parse_root_constants(data, data_size, offset, ¶meters[i].u.constants); + ret = shader_parse_root_constants(data, data_size, offset, ¶meters[i].u.constants); break; case VKD3D_ROOT_PARAMETER_TYPE_CBV: case VKD3D_ROOT_PARAMETER_TYPE_SRV: case VKD3D_ROOT_PARAMETER_TYPE_UAV: - hr = shader_parse_root_descriptor(data, data_size, offset, ¶meters[i].u.descriptor); + ret = shader_parse_root_descriptor(data, data_size, offset, ¶meters[i].u.descriptor); break; default: FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; }
- if (FAILED(hr)) - return hr; + if (ret < 0) + return ret; }
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_parse_static_samplers(const char *data, DWORD data_size, +static int shader_parse_static_samplers(const char *data, DWORD data_size, DWORD offset, DWORD count, struct vkd3d_static_sampler_desc *sampler_descs) { const char *ptr; @@ -2221,7 +2216,7 @@ static HRESULT shader_parse_static_samplers(const char *data, DWORD data_size, if (!require_space(offset, 13 * count, sizeof(DWORD), data_size)) { WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; } ptr = &data[offset];
@@ -2242,20 +2237,20 @@ static HRESULT shader_parse_static_samplers(const char *data, DWORD data_size, read_dword(&ptr, &sampler_descs[i].shader_visibility); }
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_parse_root_signature(const char *data, DWORD data_size, +static int shader_parse_root_signature(const char *data, DWORD data_size, struct vkd3d_root_signature_desc *desc) { const char *ptr = data; DWORD count, offset; - HRESULT hr; + int ret;
if (!require_space(0, 6, sizeof(DWORD), data_size)) { WARN("Invalid data size %#x.\n", data_size); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; }
skip_dword_unknown(&ptr, 1); /* It seems to always be 0x00000001. */ @@ -2269,10 +2264,10 @@ static HRESULT shader_parse_root_signature(const char *data, DWORD data_size, { struct vkd3d_root_parameter *parameters; if (!(parameters = vkd3d_calloc(desc->parameter_count, sizeof(*parameters)))) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; desc->parameters = parameters; - if (FAILED(hr = shader_parse_root_parameters(data, data_size, offset, count, parameters))) - return hr; + if ((ret = shader_parse_root_parameters(data, data_size, offset, count, parameters)) < 0) + return ret; }
read_dword(&ptr, &count); @@ -2284,43 +2279,43 @@ static HRESULT shader_parse_root_signature(const char *data, DWORD data_size, { struct vkd3d_static_sampler_desc *samplers; if (!(samplers = vkd3d_calloc(desc->static_sampler_count, sizeof(*samplers)))) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; desc->static_samplers = samplers; - if (FAILED(hr = shader_parse_static_samplers(data, data_size, offset, count, samplers))) - return hr; + if ((ret = shader_parse_static_samplers(data, data_size, offset, count, samplers)) < 0) + return ret; }
read_dword(&ptr, &desc->flags); TRACE("Flags %#x.\n", desc->flags);
- return S_OK; + return VKD3D_OK; }
-static HRESULT rts0_handler(const char *data, DWORD data_size, DWORD tag, void *context) +static int rts0_handler(const char *data, DWORD data_size, DWORD tag, void *context) { struct vkd3d_root_signature_desc *desc = context;
if (tag != TAG_RTS0) - return S_OK; + return VKD3D_OK;
return shader_parse_root_signature(data, data_size, desc); }
-HRESULT vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_root_signature_desc *root_signature) { - HRESULT hr; + int ret;
TRACE("dxbc {%p, %zu}, root_signature %p.\n", dxbc->code, dxbc->size, root_signature);
memset(root_signature, 0, sizeof(*root_signature)); - if (FAILED(hr = parse_dxbc(dxbc->code, dxbc->size, rts0_handler, root_signature))) + if ((ret = parse_dxbc(dxbc->code, dxbc->size, rts0_handler, root_signature)) < 0) { vkd3d_shader_free_root_signature(root_signature); - return hr; + return ret; }
- return S_OK; + return VKD3D_OK; }
struct root_signature_writer_context @@ -2367,39 +2362,39 @@ static size_t get_chunk_offset(struct root_signature_writer_context *context) return (context->position - context->chunk_position) * sizeof(DWORD); }
-static HRESULT shader_write_root_signature_header(struct root_signature_writer_context *context) +static int shader_write_root_signature_header(struct root_signature_writer_context *context) { if (!write_dword(context, TAG_DXBC)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
WARN("DXBC checksum is not implemented.\n"); if (!write_dwords(context, 4, 0x00000000)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
if (!write_dword(context, 0x00000001)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
context->total_size_position = context->position; if (!write_dword(context, 0xffffffff)) /* total size */ - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
if (!write_dword(context, 1)) /* chunk count */ - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
/* chunk offset */ if (!write_dword(context, (context->position + 1) * sizeof(DWORD))) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
if (!write_dword(context, TAG_RTS0)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, 0xffffffff)) /* chunk size */ - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; context->chunk_position = context->position;
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_write_descriptor_ranges(struct root_signature_writer_context *context, +static int shader_write_descriptor_ranges(struct root_signature_writer_context *context, const struct vkd3d_root_descriptor_table *table) { const struct vkd3d_descriptor_range *ranges = table->descriptor_ranges; @@ -2408,72 +2403,72 @@ static HRESULT shader_write_descriptor_ranges(struct root_signature_writer_conte for (i = 0; i < table->descriptor_range_count; ++i) { if (!write_dword(context, ranges[i].range_type)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, ranges[i].descriptor_count)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, ranges[i].base_shader_register)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, ranges[i].register_space)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, ranges[i].descriptor_table_offset)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; }
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_write_descriptor_table(struct root_signature_writer_context *context, +static int shader_write_descriptor_table(struct root_signature_writer_context *context, const struct vkd3d_root_descriptor_table *table) { if (!write_dword(context, table->descriptor_range_count)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, get_chunk_offset(context) + sizeof(DWORD))) /* offset */ - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
return shader_write_descriptor_ranges(context, table); }
-static HRESULT shader_write_root_constants(struct root_signature_writer_context *context, +static int shader_write_root_constants(struct root_signature_writer_context *context, const struct vkd3d_root_constants *constants) { if (!write_dword(context, constants->shader_register)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, constants->register_space)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, constants->value_count)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_write_root_descriptor(struct root_signature_writer_context *context, +static int shader_write_root_descriptor(struct root_signature_writer_context *context, const struct vkd3d_root_descriptor *descriptor) { if (!write_dword(context, descriptor->shader_register)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, descriptor->register_space)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_write_root_parameters(struct root_signature_writer_context *context, +static int shader_write_root_parameters(struct root_signature_writer_context *context, const struct vkd3d_root_signature_desc *desc) { const struct vkd3d_root_parameter *parameters = desc->parameters; size_t parameters_position; unsigned int i; - HRESULT hr; + int ret;
parameters_position = context->position; for (i = 0; i < desc->parameter_count; ++i) { if (!write_dword(context, parameters[i].parameter_type)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, parameters[i].shader_visibility)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, 0xffffffff)) /* offset */ - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; }
for (i = 0; i < desc->parameter_count; ++i) @@ -2483,29 +2478,29 @@ static HRESULT shader_write_root_parameters(struct root_signature_writer_context switch (parameters[i].parameter_type) { case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - hr = shader_write_descriptor_table(context, ¶meters[i].u.descriptor_table); + ret = shader_write_descriptor_table(context, ¶meters[i].u.descriptor_table); break; case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: - hr = shader_write_root_constants(context, ¶meters[i].u.constants); + ret = shader_write_root_constants(context, ¶meters[i].u.constants); break; case VKD3D_ROOT_PARAMETER_TYPE_CBV: case VKD3D_ROOT_PARAMETER_TYPE_SRV: case VKD3D_ROOT_PARAMETER_TYPE_UAV: - hr = shader_write_root_descriptor(context, ¶meters[i].u.descriptor); + ret = shader_write_root_descriptor(context, ¶meters[i].u.descriptor); break; default: FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; }
- if (FAILED(hr)) - return hr; + if (ret < 0) + return ret; }
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_write_static_samplers(struct root_signature_writer_context *context, +static int shader_write_static_samplers(struct root_signature_writer_context *context, const struct vkd3d_root_signature_desc *desc) { const struct vkd3d_static_sampler_desc *samplers = desc->static_samplers; @@ -2514,93 +2509,93 @@ static HRESULT shader_write_static_samplers(struct root_signature_writer_context for (i = 0; i < desc->static_sampler_count; ++i) { if (!write_dword(context, samplers[i].filter)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].address_u)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].address_v)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].address_w)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_float(context, samplers[i].mip_lod_bias)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].max_anisotropy)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].comparison_func)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].border_color)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_float(context, samplers[i].min_lod)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_float(context, samplers[i].max_lod)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].shader_register)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].register_space)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, samplers[i].shader_visibility)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; }
- return S_OK; + return VKD3D_OK; }
-static HRESULT shader_write_root_signature(struct root_signature_writer_context *context, +static int shader_write_root_signature(struct root_signature_writer_context *context, const struct vkd3d_root_signature_desc *desc) { size_t samplers_offset_position; - HRESULT hr; + int ret;
if (!write_dword(context, 0x00000001)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
if (!write_dword(context, desc->parameter_count)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, get_chunk_offset(context) + 4 * sizeof(DWORD))) /* offset */ - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
if (!write_dword(context, desc->static_sampler_count)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY; samplers_offset_position = context->position; if (!write_dword(context, 0xffffffff)) /* offset */ - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
if (!write_dword(context, desc->flags)) - return E_OUTOFMEMORY; + return VKD3D_ERROR_OUT_OF_MEMORY;
- if (FAILED(hr = shader_write_root_parameters(context, desc))) - return hr; + if ((ret = shader_write_root_parameters(context, desc)) < 0) + return ret;
context->data[samplers_offset_position] = get_chunk_offset(context); return shader_write_static_samplers(context, desc); }
-HRESULT vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature, +int vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature, enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc) { struct root_signature_writer_context context; size_t total_size, chunk_size; - HRESULT hr; + int ret;
TRACE("root_signature %p, version %#x, dxbc %p.\n", root_signature, version, dxbc);
if (version != VKD3D_ROOT_SIGNATURE_VERSION_1_0) { FIXME("Root signature version %#x not supported.\n", version); - return E_NOTIMPL; + return VKD3D_ERROR_NOT_IMPLEMENTED; }
memset(dxbc, 0, sizeof(*dxbc)); memset(&context, 0, sizeof(context)); - if (FAILED(hr = shader_write_root_signature_header(&context))) + if ((ret = shader_write_root_signature_header(&context)) < 0) { vkd3d_free(context.data); - return hr; + return ret; }
- if (FAILED(hr = shader_write_root_signature(&context, root_signature))) + if ((ret = shader_write_root_signature(&context, root_signature)) < 0) { vkd3d_free(context.data); - return hr; + return ret; }
total_size = context.position * sizeof(DWORD); @@ -2611,5 +2606,5 @@ HRESULT vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_ dxbc->code = context.data; dxbc->size = total_size;
- return S_OK; + return VKD3D_OK; } diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 817af6c91ad9..5d04b58af228 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5951,7 +5951,7 @@ static void vkd3d_dxbc_compiler_emit_output_setup_function(struct vkd3d_dxbc_com vkd3d_spirv_build_op_function_end(builder); }
-bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, +int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, struct vkd3d_shader_code *spirv) { struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; @@ -5965,7 +5965,7 @@ bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, vkd3d_dxbc_compiler_emit_output_setup_function(compiler);
if (!vkd3d_spirv_compile_module(builder, spirv)) - return false; + return VKD3D_ERROR;
if (TRACE_ON()) { @@ -5973,7 +5973,7 @@ bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, vkd3d_spirv_validate(spirv); }
- return true; + return VKD3D_OK; }
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 3578b053df8c..1bb89b315333 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -26,16 +26,16 @@ struct vkd3d_shader_parser const DWORD *ptr; };
-static HRESULT vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, +static int vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, const struct vkd3d_shader_code *dxbc) { struct vkd3d_shader_desc *shader_desc = &parser->shader_desc; - HRESULT hr; + int ret;
- if (FAILED(hr = shader_extract_from_dxbc(dxbc->code, dxbc->size, shader_desc))) + if ((ret = shader_extract_from_dxbc(dxbc->code, dxbc->size, shader_desc)) < 0) { - WARN("Failed to extract shader, hr %#x.\n", hr); - return hr; + WARN("Failed to extract shader, vkd3d result %d.\n", ret); + return ret; }
if (!(parser->data = shader_sm4_init(shader_desc->byte_code, @@ -43,11 +43,11 @@ static HRESULT vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, { WARN("Failed to initialize shader parser.\n"); free_shader_desc(shader_desc); - return E_INVALIDARG; + return VKD3D_ERROR_INVALID_ARGUMENT; }
shader_sm4_read_header(parser->data, &parser->ptr, &parser->shader_version); - return S_OK; + return VKD3D_OK; }
static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser) @@ -56,7 +56,7 @@ static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser) free_shader_desc(&parser->shader_desc); }
-HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_code *spirv, uint32_t compiler_options, const struct vkd3d_shader_interface *shader_interface) { @@ -64,24 +64,23 @@ HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_dxbc_compiler *spirv_compiler; struct vkd3d_shader_scan_info scan_info; struct vkd3d_shader_parser parser; - HRESULT hr; bool ret;
TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface %p.\n", dxbc->code, dxbc->size, spirv, compiler_options, shader_interface);
- if (FAILED(hr = vkd3d_shader_scan_dxbc(dxbc, &scan_info))) - return hr; + if ((ret = vkd3d_shader_scan_dxbc(dxbc, &scan_info)) < 0) + return ret;
- if (FAILED(hr = vkd3d_shader_parser_init(&parser, dxbc))) - return hr; + if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0) + return ret;
if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser.shader_version, &parser.shader_desc, compiler_options, shader_interface, &scan_info))) { ERR("Failed to create DXBC compiler.\n"); vkd3d_shader_parser_destroy(&parser); - return hr; + return VKD3D_ERROR; }
while (!shader_sm4_is_end(parser.data, &parser.ptr)) @@ -93,7 +92,7 @@ HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, WARN("Encountered unrecognized or invalid instruction.\n"); vkd3d_dxbc_compiler_destroy(spirv_compiler); vkd3d_shader_parser_destroy(&parser); - return E_FAIL; + return VKD3D_ERROR_INVALID_ARGUMENT; }
vkd3d_dxbc_compiler_handle_instruction(spirv_compiler, &instruction); @@ -102,8 +101,7 @@ HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, ret = vkd3d_dxbc_compiler_generate_spirv(spirv_compiler, spirv); vkd3d_dxbc_compiler_destroy(spirv_compiler); vkd3d_shader_parser_destroy(&parser); - - return ret ? S_OK : E_FAIL; + return ret; }
static bool vkd3d_shader_instruction_is_uav_read(const struct vkd3d_shader_instruction *instruction) @@ -160,17 +158,17 @@ static void vkd3d_shader_scan_handle_instruction(struct vkd3d_shader_scan_info * vkd3d_shader_scan_record_uav_counter(scan_info, &instruction->src[0].reg); }
-HRESULT vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_scan_info *scan_info) { struct vkd3d_shader_instruction instruction; struct vkd3d_shader_parser parser; - HRESULT hr; + int ret;
TRACE("dxbc {%p, %zu}, scan_info %p.\n", dxbc->code, dxbc->size, scan_info);
- if (FAILED(hr = vkd3d_shader_parser_init(&parser, dxbc))) - return hr; + if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0) + return ret;
memset(scan_info, 0, sizeof(*scan_info));
@@ -182,14 +180,14 @@ HRESULT vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc, { WARN("Encountered unrecognized or invalid instruction.\n"); vkd3d_shader_parser_destroy(&parser); - return E_FAIL; + return VKD3D_ERROR_INVALID_ARGUMENT; }
vkd3d_shader_scan_handle_instruction(scan_info, &instruction); }
vkd3d_shader_parser_destroy(&parser); - return S_OK; + return VKD3D_OK; }
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *shader_code) @@ -217,7 +215,7 @@ void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_sig memset(root_signature, 0, sizeof(*root_signature)); }
-HRESULT vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_signature *signature) { TRACE("dxbc {%p, %zu}, signature %p.\n", dxbc->code, dxbc->size, signature); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index a3d2b4ad2298..b3e81a449112 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -768,11 +768,11 @@ void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct vkd3d_shader_instruction *ins) DECLSPEC_HIDDEN; BOOL shader_sm4_is_end(void *data, const DWORD **ptr) DECLSPEC_HIDDEN;
-HRESULT 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_desc *desc) DECLSPEC_HIDDEN; void free_shader_desc(struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
-HRESULT shader_parse_input_signature(const void *dxbc, SIZE_T dxbc_length, +int shader_parse_input_signature(const void *dxbc, SIZE_T dxbc_length, struct vkd3d_shader_signature *signature) DECLSPEC_HIDDEN;
struct vkd3d_dxbc_compiler; @@ -783,7 +783,7 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader const struct vkd3d_shader_scan_info *scan_info) DECLSPEC_HIDDEN; void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) DECLSPEC_HIDDEN; -bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, +int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, struct vkd3d_shader_code *spirv) DECLSPEC_HIDDEN; void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index befc44d6aee6..1749c007a77d 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1013,11 +1013,12 @@ HRESULT d3d12_root_signature_create(struct d3d12_device *device, } root_signature_desc; struct d3d12_root_signature *object; HRESULT hr; + int ret;
- if (FAILED(hr = vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc.vkd3d))) + if ((ret = vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc.vkd3d)) < 0) { - WARN("Failed to parse root signature, hr %#x.\n", hr); - return hr; + WARN("Failed to parse root signature, vkd3d result %d.\n", ret); + return hresult_from_vkd3d_result(ret); }
if (!(object = vkd3d_malloc(sizeof(*object)))) @@ -1269,7 +1270,7 @@ static HRESULT create_shader_stage(struct d3d12_device *device, struct VkShaderModuleCreateInfo shader_desc; struct vkd3d_shader_code spirv = {}; VkResult vr; - HRESULT hr; + int ret;
stage_desc->sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; stage_desc->pNext = NULL; @@ -1283,10 +1284,10 @@ static HRESULT create_shader_stage(struct d3d12_device *device, shader_desc.flags = 0;
dump_shader_stage(stage, code->pShaderBytecode, code->BytecodeLength); - if (FAILED(hr = vkd3d_shader_compile_dxbc(&dxbc, &spirv, 0, shader_interface))) + if ((ret = vkd3d_shader_compile_dxbc(&dxbc, &spirv, 0, shader_interface)) < 0) { - WARN("Failed to compile shader, hr %#x.\n", hr); - return hr; + WARN("Failed to compile shader, vkd3d result %d.\n", ret); + return hresult_from_vkd3d_result(ret); } shader_desc.codeSize = spirv.size; shader_desc.pCode = spirv.code; @@ -1389,6 +1390,7 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st struct vkd3d_shader_code dxbc; VkResult vr; HRESULT hr; + int ret;
state->ID3D12PipelineState_iface.lpVtbl = &d3d12_pipeline_state_vtbl; state->refcount = 1; @@ -1406,10 +1408,10 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st
dxbc.code = desc->CS.pShaderBytecode; dxbc.size = desc->CS.BytecodeLength; - if (FAILED(hr = vkd3d_shader_scan_dxbc(&dxbc, &shader_info))) + if ((ret = vkd3d_shader_scan_dxbc(&dxbc, &shader_info)) < 0) { - WARN("Failed to scan shader bytecode, hr %#x.\n", hr); - return hr; + WARN("Failed to scan shader bytecode, vkd3d result %d.\n", ret); + return hresult_from_vkd3d_result(ret); }
if (FAILED(hr = d3d12_pipeline_state_init_compute_uav_counters(state, @@ -1802,6 +1804,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s uint32_t mask; VkResult vr; HRESULT hr; + int ret;
static const struct { @@ -1849,10 +1852,11 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s if (!b->pShaderBytecode) continue;
- if (FAILED(hr = vkd3d_shader_scan_dxbc(&dxbc, &shader_info))) + if ((ret = vkd3d_shader_scan_dxbc(&dxbc, &shader_info)) < 0) { - WARN("Failed to scan shader bytecode, stage %#x, hr %#x.\n", shader_stages[i].stage, hr); - hr = E_FAIL; + WARN("Failed to scan shader bytecode, stage %#x, vkd3d result %d.\n", + shader_stages[i].stage, ret); + hr = hresult_from_vkd3d_result(ret); goto fail; } if (shader_info.uav_counter_mask) @@ -1863,8 +1867,11 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s goto fail;
if (shader_stages[i].stage == VK_SHADER_STAGE_VERTEX_BIT - && FAILED(hr = vkd3d_shader_parse_input_signature(&dxbc, &input_signature))) + && (ret = vkd3d_shader_parse_input_signature(&dxbc, &input_signature)) < 0) + { + hr = hresult_from_vkd3d_result(ret); goto fail; + }
++graphics->stage_count; } diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index b3a8027b6048..eef194ec8028 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -351,6 +351,26 @@ HRESULT hresult_from_vk_result(VkResult vr) } }
+HRESULT hresult_from_vkd3d_result(int vkd3d_result) +{ + switch (vkd3d_result) + { + case VKD3D_OK: + return S_OK; + case VKD3D_ERROR: + return E_FAIL; + case VKD3D_ERROR_OUT_OF_MEMORY: + return E_OUTOFMEMORY; + case VKD3D_ERROR_INVALID_ARGUMENT: + return E_INVALIDARG; + case VKD3D_ERROR_NOT_IMPLEMENTED: + return E_NOTIMPL; + default: + FIXME("Unhandled vkd3d result %d.\n", vkd3d_result); + return E_FAIL; + } +} + #define LOAD_GLOBAL_PFN(name) \ if (!(procs->name = (void *)vkGetInstanceProcAddr(NULL, #name))) \ { \ diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index d4d660dc727d..b58e6e5ac53c 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -162,15 +162,15 @@ static const struct ID3D12RootSignatureDeserializerVtbl d3d12_root_signature_des static HRESULT d3d12_root_signature_deserializer_init(struct d3d12_root_signature_deserializer *deserializer, const struct vkd3d_shader_code *dxbc) { - HRESULT hr; + int ret;
deserializer->ID3D12RootSignatureDeserializer_iface.lpVtbl = &d3d12_root_signature_deserializer_vtbl; deserializer->refcount = 1;
- if (FAILED(hr = vkd3d_shader_parse_root_signature(dxbc, &deserializer->desc.vkd3d))) + if ((ret = vkd3d_shader_parse_root_signature(dxbc, &deserializer->desc.vkd3d)) < 0) { - WARN("Failed to parse root signature, hr %#x.\n", hr); - return hr; + WARN("Failed to parse root signature, vkd3d result %d.\n", ret); + return hresult_from_vkd3d_result(ret); }
return S_OK; @@ -319,6 +319,7 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *root_sig struct vkd3d_shader_code dxbc; struct d3d_blob *blob_object; HRESULT hr; + int ret;
TRACE("root_signature_desc %p, version %#x, blob %p, error_blob %p.\n", root_signature_desc, version, blob, error_blob); @@ -335,12 +336,12 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *root_sig *error_blob = NULL; }
- if (FAILED(hr = vkd3d_shader_serialize_root_signature( + if ((ret = vkd3d_shader_serialize_root_signature( (const struct vkd3d_root_signature_desc *)root_signature_desc, - (enum vkd3d_root_signature_version)version, &dxbc))) + (enum vkd3d_root_signature_version)version, &dxbc)) < 0) { - WARN("Failed to serialize root signature, hr %#x.\n", hr); - return hr; + WARN("Failed to serialize root signature, vkd3d result %d.\n", ret); + return hresult_from_vkd3d_result(ret); }
if (FAILED(hr = d3d_blob_create((void *)dxbc.code, dxbc.size, &blob_object))) diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 89e4f23680c8..62b465223aa3 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -767,6 +767,7 @@ const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags) DECLSPEC const char *debug_vk_queue_flags(VkQueueFlags flags) DECLSPEC_HIDDEN;
HRESULT hresult_from_vk_result(VkResult vr) DECLSPEC_HIDDEN; +HRESULT hresult_from_vkd3d_result(int vkd3d_result) DECLSPEC_HIDDEN;
HRESULT vkd3d_load_vk_global_procs(struct vkd3d_vk_global_procs *procs, PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr) DECLSPEC_HIDDEN;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/vkd3d_shader_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index b3e81a449112..9c43a461f29b 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -607,7 +607,7 @@ enum vkd3d_decl_usage struct vkd3d_shader_semantic { enum vkd3d_decl_usage usage; - UINT usage_idx; + unsigned int usage_idx; enum vkd3d_shader_resource_type resource_type; enum vkd3d_data_type resource_data_type; struct vkd3d_shader_dst_param reg;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 5d04b58af228..89b1187399b6 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5686,6 +5686,7 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler vkd3d_dxbc_compiler_emit_dcl_stream(compiler, instruction); break; case VKD3DSIH_DCL_VERTICES_OUT: + case VKD3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT: vkd3d_dxbc_compiler_emit_dcl_vertices_out(compiler, instruction); break; case VKD3DSIH_DCL_INPUT_PRIMITIVE: @@ -5876,7 +5877,9 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler case VKD3DSIH_CUT_STREAM: vkd3d_dxbc_compiler_emit_cut_stream(compiler, instruction); break; + case VKD3DSIH_DCL_INPUT_CONTROL_POINT_COUNT: case VKD3DSIH_NOP: + /* nothing to do */ break; default: FIXME("Unhandled instruction %#x.\n", instruction->handler_idx);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com