From: Józef Kucia jkucia@codeweavers.com
--- libs/vkd3d/vkd3d_main.c | 51 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index e074d1cdbca9..913c9f50c5f9 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -248,7 +248,7 @@ struct d3d12_versioned_root_signature_deserializer { D3D12_VERSIONED_ROOT_SIGNATURE_DESC d3d12; struct vkd3d_versioned_root_signature_desc vkd3d; - } desc; + } desc, other_desc; };
STATIC_ASSERT(sizeof(D3D12_VERSIONED_ROOT_SIGNATURE_DESC) == sizeof(struct vkd3d_versioned_root_signature_desc)); @@ -301,20 +301,61 @@ static ULONG STDMETHODCALLTYPE d3d12_versioned_root_signature_deserializer_Relea if (!refcount) { vkd3d_shader_free_versioned_root_signature(&deserializer->desc.vkd3d); + vkd3d_shader_free_versioned_root_signature(&deserializer->other_desc.vkd3d); vkd3d_free(deserializer); }
return refcount; }
+static enum vkd3d_root_signature_version vkd3d_root_signature_version_from_d3d12(D3D_ROOT_SIGNATURE_VERSION version) +{ + switch (version) + { + case D3D_ROOT_SIGNATURE_VERSION_1_0: + return VKD3D_ROOT_SIGNATURE_VERSION_1_0; + case D3D_ROOT_SIGNATURE_VERSION_1_1: + return VKD3D_ROOT_SIGNATURE_VERSION_1_1; + default: + WARN("Unknown root signature version %#x.\n", version); + return 0; + } +} + static HRESULT STDMETHODCALLTYPE d3d12_versioned_root_signature_deserializer_GetRootSignatureDescAtVersion( ID3D12VersionedRootSignatureDeserializer *iface, D3D_ROOT_SIGNATURE_VERSION version, const D3D12_VERSIONED_ROOT_SIGNATURE_DESC **desc) { - FIXME("iface %p, version %#x, desc %p stub!\n", iface, version, desc); + struct d3d12_versioned_root_signature_deserializer *deserializer = impl_from_ID3D12VersionedRootSignatureDeserializer(iface); + int ret;
- *desc = NULL; - return E_NOTIMPL; + TRACE("iface %p, version %#x, desc %p.\n", iface, version, desc); + + if (version != D3D_ROOT_SIGNATURE_VERSION_1_0 && version != D3D_ROOT_SIGNATURE_VERSION_1_1) + { + WARN("Root signature version %#x not supported.\n", version); + return E_INVALIDARG; + } + + if (deserializer->desc.d3d12.Version == version) + { + *desc = &deserializer->desc.d3d12; + return S_OK; + } + + if (!deserializer->other_desc.d3d12.Version) + { + if ((ret = vkd3d_shader_convert_root_signature(&deserializer->other_desc.vkd3d, + vkd3d_root_signature_version_from_d3d12(version), &deserializer->desc.vkd3d)) < 0) + { + WARN("Failed to convert versioned root signature, vkd3d result %d.\n", ret); + return hresult_from_vkd3d_result(ret); + } + } + + assert(deserializer->other_desc.d3d12.Version == version); + *desc = &deserializer->other_desc.d3d12; + return S_OK; }
static const D3D12_VERSIONED_ROOT_SIGNATURE_DESC * STDMETHODCALLTYPE @@ -352,6 +393,8 @@ static HRESULT d3d12_versioned_root_signature_deserializer_init(struct d3d12_ver return hresult_from_vkd3d_result(ret); }
+ memset(&deserializer->other_desc, 0, sizeof(deserializer->other_desc)); + return S_OK; }
From: Józef Kucia jkucia@codeweavers.com
--- include/vkd3d_shader.h | 6 + libs/vkd3d-shader/dxbc.c | 193 +++++++++++++++++++++++++---- libs/vkd3d-shader/vkd3d_shader.map | 1 + 3 files changed, 174 insertions(+), 26 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index ae315e66d4db..4d2f8c2f2983 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -575,6 +575,9 @@ void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_sig 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);
+int vkd3d_shader_serialize_versioned_root_signature(const struct vkd3d_versioned_root_signature_desc *root_signature, + struct vkd3d_shader_code *dxbc); + int vkd3d_shader_convert_root_signature(struct vkd3d_versioned_root_signature_desc *dst, enum vkd3d_root_signature_version version, const struct vkd3d_versioned_root_signature_desc *src);
@@ -607,6 +610,9 @@ typedef void (*PFN_vkd3d_shader_free_root_signature)(struct vkd3d_root_signature typedef int (*PFN_vkd3d_shader_serialize_root_signature)(const struct vkd3d_root_signature_desc *root_signature, enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc);
+typedef int (*PFN_vkd3d_shader_serialize_versioned_root_signature)( + const struct vkd3d_versioned_root_signature_desc *root_signature, struct vkd3d_shader_code *dxbc); + typedef int (*PFN_vkd3d_shader_convert_root_signature)(struct vkd3d_versioned_root_signature_desc *dst, enum vkd3d_root_signature_version version, const struct vkd3d_versioned_root_signature_desc *src);
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 5903ed8ae155..fdf711d65615 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -2520,6 +2520,66 @@ int vkd3d_shader_parse_versioned_root_signature(const struct vkd3d_shader_code * return VKD3D_OK; }
+static unsigned int versioned_root_signature_get_parameter_count(const struct vkd3d_versioned_root_signature_desc *desc) +{ + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + return desc->u.v_1_0.parameter_count; + else + return desc->u.v_1_1.parameter_count; +} + +static enum vkd3d_root_parameter_type versioned_root_signature_get_parameter_type( + const struct vkd3d_versioned_root_signature_desc *desc, unsigned int i) +{ + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + return desc->u.v_1_0.parameters[i].parameter_type; + else + return desc->u.v_1_1.parameters[i].parameter_type; +} + +static enum vkd3d_shader_visibility versioned_root_signature_get_parameter_shader_visibility( + const struct vkd3d_versioned_root_signature_desc *desc, unsigned int i) +{ + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + return desc->u.v_1_0.parameters[i].shader_visibility; + else + return desc->u.v_1_1.parameters[i].shader_visibility; +} + +static const struct vkd3d_root_constants *versioned_root_signature_get_root_constants( + const struct vkd3d_versioned_root_signature_desc *desc, unsigned int i) +{ + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + return &desc->u.v_1_0.parameters[i].u.constants; + else + return &desc->u.v_1_1.parameters[i].u.constants; +} + +static unsigned int versioned_root_signature_get_static_sampler_count(const struct vkd3d_versioned_root_signature_desc *desc) +{ + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + return desc->u.v_1_0.static_sampler_count; + else + return desc->u.v_1_1.static_sampler_count; +} + +static const struct vkd3d_static_sampler_desc *versioned_root_signature_get_static_samplers( + const struct vkd3d_versioned_root_signature_desc *desc) +{ + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + return desc->u.v_1_0.static_samplers; + else + return desc->u.v_1_1.static_samplers; +} + +static unsigned int versioned_root_signature_get_flags(const struct vkd3d_versioned_root_signature_desc *desc) +{ + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + return desc->u.v_1_0.flags; + else + return desc->u.v_1_1.flags; +} + struct root_signature_writer_context { DWORD *data; @@ -2619,6 +2679,31 @@ static int shader_write_descriptor_ranges(struct root_signature_writer_context * return VKD3D_OK; }
+static int shader_write_descriptor_ranges1(struct root_signature_writer_context *context, + const struct vkd3d_root_descriptor_table1 *table) +{ + const struct vkd3d_descriptor_range1 *ranges = table->descriptor_ranges; + unsigned int i; + + for (i = 0; i < table->descriptor_range_count; ++i) + { + if (!write_dword(context, ranges[i].range_type)) + return VKD3D_ERROR_OUT_OF_MEMORY; + if (!write_dword(context, ranges[i].descriptor_count)) + return VKD3D_ERROR_OUT_OF_MEMORY; + if (!write_dword(context, ranges[i].base_shader_register)) + return VKD3D_ERROR_OUT_OF_MEMORY; + if (!write_dword(context, ranges[i].register_space)) + return VKD3D_ERROR_OUT_OF_MEMORY; + if (!write_dword(context, ranges[i].flags)) + return VKD3D_ERROR_OUT_OF_MEMORY; + if (!write_dword(context, ranges[i].descriptor_table_offset)) + return VKD3D_ERROR_OUT_OF_MEMORY; + } + + return VKD3D_OK; +} + static int shader_write_descriptor_table(struct root_signature_writer_context *context, const struct vkd3d_root_descriptor_table *table) { @@ -2630,6 +2715,17 @@ static int shader_write_descriptor_table(struct root_signature_writer_context *c return shader_write_descriptor_ranges(context, table); }
+static int shader_write_descriptor_table1(struct root_signature_writer_context *context, + const struct vkd3d_root_descriptor_table1 *table) +{ + if (!write_dword(context, table->descriptor_range_count)) + return VKD3D_ERROR_OUT_OF_MEMORY; + if (!write_dword(context, get_chunk_offset(context) + sizeof(DWORD))) /* offset */ + return VKD3D_ERROR_OUT_OF_MEMORY; + + return shader_write_descriptor_ranges1(context, table); +} + static int shader_write_root_constants(struct root_signature_writer_context *context, const struct vkd3d_root_constants *constants) { @@ -2654,44 +2750,63 @@ static int shader_write_root_descriptor(struct root_signature_writer_context *co return VKD3D_OK; }
+static int shader_write_root_descriptor1(struct root_signature_writer_context *context, + const struct vkd3d_root_descriptor1 *descriptor) +{ + if (!write_dword(context, descriptor->shader_register)) + return VKD3D_ERROR_OUT_OF_MEMORY; + if (!write_dword(context, descriptor->register_space)) + return VKD3D_ERROR_OUT_OF_MEMORY; + if (!write_dword(context, descriptor->flags)) + return VKD3D_ERROR_OUT_OF_MEMORY; + + return VKD3D_OK; +} + static int shader_write_root_parameters(struct root_signature_writer_context *context, - const struct vkd3d_root_signature_desc *desc) + const struct vkd3d_versioned_root_signature_desc *desc) { - const struct vkd3d_root_parameter *parameters = desc->parameters; + unsigned int parameter_count = versioned_root_signature_get_parameter_count(desc); size_t parameters_position; unsigned int i; int ret;
parameters_position = context->position; - for (i = 0; i < desc->parameter_count; ++i) + for (i = 0; i < parameter_count; ++i) { - if (!write_dword(context, parameters[i].parameter_type)) + if (!write_dword(context, versioned_root_signature_get_parameter_type(desc, i))) return VKD3D_ERROR_OUT_OF_MEMORY; - if (!write_dword(context, parameters[i].shader_visibility)) + if (!write_dword(context, versioned_root_signature_get_parameter_shader_visibility(desc, i))) return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, 0xffffffff)) /* offset */ return VKD3D_ERROR_OUT_OF_MEMORY; }
- for (i = 0; i < desc->parameter_count; ++i) + for (i = 0; i < parameter_count; ++i) { context->data[parameters_position + 3 * i + 2] = get_chunk_offset(context); /* offset */
- switch (parameters[i].parameter_type) + switch (versioned_root_signature_get_parameter_type(desc, i)) { case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - ret = shader_write_descriptor_table(context, ¶meters[i].u.descriptor_table); + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + ret = shader_write_descriptor_table(context, &desc->u.v_1_0.parameters[i].u.descriptor_table); + else + ret = shader_write_descriptor_table1(context, &desc->u.v_1_1.parameters[i].u.descriptor_table); break; case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: - ret = shader_write_root_constants(context, ¶meters[i].u.constants); + ret = shader_write_root_constants(context, versioned_root_signature_get_root_constants(desc, i)); break; case VKD3D_ROOT_PARAMETER_TYPE_CBV: case VKD3D_ROOT_PARAMETER_TYPE_SRV: case VKD3D_ROOT_PARAMETER_TYPE_UAV: - ret = shader_write_root_descriptor(context, ¶meters[i].u.descriptor); + if (desc->version == VKD3D_ROOT_SIGNATURE_VERSION_1_0) + ret = shader_write_root_descriptor(context, &desc->u.v_1_0.parameters[i].u.descriptor); + else + ret = shader_write_root_descriptor1(context, &desc->u.v_1_1.parameters[i].u.descriptor); break; default: - FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type); + FIXME("Unrecognized type %#x.\n", versioned_root_signature_get_parameter_type(desc, i)); return VKD3D_ERROR_INVALID_ARGUMENT; }
@@ -2703,12 +2818,12 @@ static int shader_write_root_parameters(struct root_signature_writer_context *co }
static int shader_write_static_samplers(struct root_signature_writer_context *context, - const struct vkd3d_root_signature_desc *desc) + const struct vkd3d_versioned_root_signature_desc *desc) { - const struct vkd3d_static_sampler_desc *samplers = desc->static_samplers; + const struct vkd3d_static_sampler_desc *samplers = versioned_root_signature_get_static_samplers(desc); unsigned int i;
- for (i = 0; i < desc->static_sampler_count; ++i) + for (i = 0; i < versioned_root_signature_get_static_sampler_count(desc); ++i) { if (!write_dword(context, samplers[i].filter)) return VKD3D_ERROR_OUT_OF_MEMORY; @@ -2742,26 +2857,26 @@ static int shader_write_static_samplers(struct root_signature_writer_context *co }
static int shader_write_root_signature(struct root_signature_writer_context *context, - const struct vkd3d_root_signature_desc *desc) + const struct vkd3d_versioned_root_signature_desc *desc) { size_t samplers_offset_position; int ret;
- if (!write_dword(context, 0x00000001)) + if (!write_dword(context, desc->version)) return VKD3D_ERROR_OUT_OF_MEMORY;
- if (!write_dword(context, desc->parameter_count)) + if (!write_dword(context, versioned_root_signature_get_parameter_count(desc))) return VKD3D_ERROR_OUT_OF_MEMORY; if (!write_dword(context, get_chunk_offset(context) + 4 * sizeof(DWORD))) /* offset */ return VKD3D_ERROR_OUT_OF_MEMORY;
- if (!write_dword(context, desc->static_sampler_count)) + if (!write_dword(context, versioned_root_signature_get_static_sampler_count(desc))) return VKD3D_ERROR_OUT_OF_MEMORY; samplers_offset_position = context->position; if (!write_dword(context, 0xffffffff)) /* offset */ return VKD3D_ERROR_OUT_OF_MEMORY;
- if (!write_dword(context, desc->flags)) + if (!write_dword(context, versioned_root_signature_get_flags(desc))) return VKD3D_ERROR_OUT_OF_MEMORY;
if ((ret = shader_write_root_parameters(context, desc)) < 0) @@ -2771,20 +2886,19 @@ static int shader_write_root_signature(struct root_signature_writer_context *con return shader_write_static_samplers(context, desc); }
-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) +static int shader_serialize_root_signature(const struct vkd3d_versioned_root_signature_desc *root_signature, + struct vkd3d_shader_code *dxbc) { struct root_signature_writer_context context; size_t total_size, chunk_size; uint32_t checksum[4]; int ret;
- TRACE("root_signature %p, version %#x, dxbc %p.\n", root_signature, version, dxbc); - - if (version != VKD3D_ROOT_SIGNATURE_VERSION_1_0) + if (root_signature->version != VKD3D_ROOT_SIGNATURE_VERSION_1_0 + && root_signature->version != VKD3D_ROOT_SIGNATURE_VERSION_1_1) { - FIXME("Root signature version %#x not supported.\n", version); - return VKD3D_ERROR_NOT_IMPLEMENTED; + WARN("Root signature version %#x not supported.\n", root_signature->version); + return VKD3D_ERROR_INVALID_ARGUMENT; }
memset(dxbc, 0, sizeof(*dxbc)); @@ -2815,6 +2929,33 @@ int vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc return VKD3D_OK; }
+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 vkd3d_versioned_root_signature_desc versioned_root_signature; + + TRACE("root_signature %p, version %#x, dxbc %p.\n", root_signature, version, dxbc); + + if (version != VKD3D_ROOT_SIGNATURE_VERSION_1_0) + { + WARN("Unexpected Root signature version %#x.\n", version); + return VKD3D_ERROR_INVALID_ARGUMENT; + } + + versioned_root_signature.version = VKD3D_ROOT_SIGNATURE_VERSION_1_0; + versioned_root_signature.u.v_1_0 = *root_signature; + + return shader_serialize_root_signature(&versioned_root_signature, dxbc); +} + +int vkd3d_shader_serialize_versioned_root_signature(const struct vkd3d_versioned_root_signature_desc *root_signature, + struct vkd3d_shader_code *dxbc) +{ + TRACE("root_signature %p, dxbc %p.\n", root_signature, dxbc); + + return shader_serialize_root_signature(root_signature, dxbc); +} + static void free_descriptor_ranges(const struct vkd3d_root_parameter *parameters, unsigned int count) { unsigned int i; diff --git a/libs/vkd3d-shader/vkd3d_shader.map b/libs/vkd3d-shader/vkd3d_shader.map index 2959c5756223..30c2c76f6866 100644 --- a/libs/vkd3d-shader/vkd3d_shader.map +++ b/libs/vkd3d-shader/vkd3d_shader.map @@ -12,6 +12,7 @@ global: vkd3d_shader_parse_versioned_root_signature; vkd3d_shader_scan_dxbc; vkd3d_shader_serialize_root_signature; + vkd3d_shader_serialize_versioned_root_signature;
local: *; };
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
--- libs/vkd3d/vkd3d_main.c | 45 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index 913c9f50c5f9..08ba989d874a 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -538,6 +538,8 @@ static HRESULT d3d_blob_create(void *buffer, SIZE_T size, struct d3d_blob **blob HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc, D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob) { + const struct vkd3d_root_signature_desc *vkd3d_desc; + enum vkd3d_root_signature_version vkd3d_version; struct vkd3d_shader_code dxbc; struct d3d_blob *blob_object; HRESULT hr; @@ -554,9 +556,9 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc, if (error_blob) *error_blob = NULL;
- if ((ret = vkd3d_shader_serialize_root_signature( - (const struct vkd3d_root_signature_desc *)desc, - (enum vkd3d_root_signature_version)version, &dxbc)) < 0) + vkd3d_desc = (const struct vkd3d_root_signature_desc *)desc; + vkd3d_version = vkd3d_root_signature_version_from_d3d12(version); + if ((ret = vkd3d_shader_serialize_root_signature(vkd3d_desc, vkd3d_version, &dxbc)) < 0) { WARN("Failed to serialize root signature, vkd3d result %d.\n", ret); if (error_blob) @@ -579,7 +581,40 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc, HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc, ID3DBlob **blob, ID3DBlob **error_blob) { - FIXME("desc %p, blob %p, error_blob %p stub!\n", desc, blob, error_blob); + const struct vkd3d_versioned_root_signature_desc *vkd3d_desc; + struct vkd3d_shader_code dxbc; + struct d3d_blob *blob_object; + HRESULT hr; + int ret; + + TRACE("desc %p, blob %p, error_blob %p.\n", desc, blob, error_blob); + + if (!blob) + { + WARN("Invalid blob parameter.\n"); + return E_INVALIDARG; + } + + if (error_blob) + *error_blob = NULL;
- return E_NOTIMPL; + vkd3d_desc = (const struct vkd3d_versioned_root_signature_desc *)desc; + if ((ret = vkd3d_shader_serialize_versioned_root_signature(vkd3d_desc, &dxbc)) < 0) + { + WARN("Failed to serialize root signature, vkd3d result %d.\n", ret); + if (error_blob) + FIXME("Ignoring error blob %p.\n", error_blob); + return hresult_from_vkd3d_result(ret); + } + + if (FAILED(hr = d3d_blob_create((void *)dxbc.code, dxbc.size, &blob_object))) + { + WARN("Failed to create blob object, hr %#x.\n", hr); + vkd3d_shader_free_shader_code(&dxbc); + return hr; + } + + *blob = &blob_object->ID3DBlob_iface; + + return S_OK; }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
--- include/vkd3d_shader.h | 6 ------ libs/vkd3d-shader/dxbc.c | 31 +++--------------------------- libs/vkd3d-shader/vkd3d_shader.map | 1 - libs/vkd3d/vkd3d_main.c | 15 ++++++++++----- tests/vkd3d_shader_api.c | 11 +++++++---- 5 files changed, 20 insertions(+), 44 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 4d2f8c2f2983..91b4b75652c6 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -572,9 +572,6 @@ void vkd3d_shader_free_versioned_root_signature(struct vkd3d_versioned_root_sign void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_signature);
/* FIXME: Add support for returning error messages (ID3DBlob). */ -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); - int vkd3d_shader_serialize_versioned_root_signature(const struct vkd3d_versioned_root_signature_desc *root_signature, struct vkd3d_shader_code *dxbc);
@@ -607,9 +604,6 @@ typedef int (*PFN_vkd3d_shader_parse_versioned_root_signature)(const struct vkd3 typedef void (*PFN_vkd3d_shader_free_versioned_root_signature)(struct vkd3d_versioned_root_signature_desc *root_signature); typedef void (*PFN_vkd3d_shader_free_root_signature)(struct vkd3d_root_signature_desc *root_signature);
-typedef int (*PFN_vkd3d_shader_serialize_root_signature)(const struct vkd3d_root_signature_desc *root_signature, - enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc); - typedef int (*PFN_vkd3d_shader_serialize_versioned_root_signature)( const struct vkd3d_versioned_root_signature_desc *root_signature, struct vkd3d_shader_code *dxbc);
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index fdf711d65615..1230f309fc14 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -2886,7 +2886,7 @@ static int shader_write_root_signature(struct root_signature_writer_context *con return shader_write_static_samplers(context, desc); }
-static int shader_serialize_root_signature(const struct vkd3d_versioned_root_signature_desc *root_signature, +int vkd3d_shader_serialize_versioned_root_signature(const struct vkd3d_versioned_root_signature_desc *root_signature, struct vkd3d_shader_code *dxbc) { struct root_signature_writer_context context; @@ -2894,6 +2894,8 @@ static int shader_serialize_root_signature(const struct vkd3d_versioned_root_sig uint32_t checksum[4]; int ret;
+ TRACE("root_signature %p, dxbc %p.\n", root_signature, dxbc); + if (root_signature->version != VKD3D_ROOT_SIGNATURE_VERSION_1_0 && root_signature->version != VKD3D_ROOT_SIGNATURE_VERSION_1_1) { @@ -2929,33 +2931,6 @@ static int shader_serialize_root_signature(const struct vkd3d_versioned_root_sig return VKD3D_OK; }
-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 vkd3d_versioned_root_signature_desc versioned_root_signature; - - TRACE("root_signature %p, version %#x, dxbc %p.\n", root_signature, version, dxbc); - - if (version != VKD3D_ROOT_SIGNATURE_VERSION_1_0) - { - WARN("Unexpected Root signature version %#x.\n", version); - return VKD3D_ERROR_INVALID_ARGUMENT; - } - - versioned_root_signature.version = VKD3D_ROOT_SIGNATURE_VERSION_1_0; - versioned_root_signature.u.v_1_0 = *root_signature; - - return shader_serialize_root_signature(&versioned_root_signature, dxbc); -} - -int vkd3d_shader_serialize_versioned_root_signature(const struct vkd3d_versioned_root_signature_desc *root_signature, - struct vkd3d_shader_code *dxbc) -{ - TRACE("root_signature %p, dxbc %p.\n", root_signature, dxbc); - - return shader_serialize_root_signature(root_signature, dxbc); -} - static void free_descriptor_ranges(const struct vkd3d_root_parameter *parameters, unsigned int count) { unsigned int i; diff --git a/libs/vkd3d-shader/vkd3d_shader.map b/libs/vkd3d-shader/vkd3d_shader.map index 30c2c76f6866..45e9c6a8d467 100644 --- a/libs/vkd3d-shader/vkd3d_shader.map +++ b/libs/vkd3d-shader/vkd3d_shader.map @@ -11,7 +11,6 @@ global: vkd3d_shader_parse_input_signature; vkd3d_shader_parse_versioned_root_signature; vkd3d_shader_scan_dxbc; - vkd3d_shader_serialize_root_signature; vkd3d_shader_serialize_versioned_root_signature;
local: *; diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index 08ba989d874a..c96732c8c1df 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -538,8 +538,7 @@ static HRESULT d3d_blob_create(void *buffer, SIZE_T size, struct d3d_blob **blob HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc, D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob) { - const struct vkd3d_root_signature_desc *vkd3d_desc; - enum vkd3d_root_signature_version vkd3d_version; + struct vkd3d_versioned_root_signature_desc vkd3d_desc; struct vkd3d_shader_code dxbc; struct d3d_blob *blob_object; HRESULT hr; @@ -547,6 +546,12 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc,
TRACE("desc %p, version %#x, blob %p, error_blob %p.\n", desc, version, blob, error_blob);
+ if (version != D3D_ROOT_SIGNATURE_VERSION_1_0) + { + WARN("Unexpected Root signature version %#x.\n", version); + return E_INVALIDARG; + } + if (!blob) { WARN("Invalid blob parameter.\n"); @@ -556,9 +561,9 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc, if (error_blob) *error_blob = NULL;
- vkd3d_desc = (const struct vkd3d_root_signature_desc *)desc; - vkd3d_version = vkd3d_root_signature_version_from_d3d12(version); - if ((ret = vkd3d_shader_serialize_root_signature(vkd3d_desc, vkd3d_version, &dxbc)) < 0) + vkd3d_desc.version = VKD3D_ROOT_SIGNATURE_VERSION_1_0; + vkd3d_desc.u.v_1_0 = *(const struct vkd3d_root_signature_desc *)desc; + if ((ret = vkd3d_shader_serialize_versioned_root_signature(&vkd3d_desc, &dxbc)) < 0) { WARN("Failed to serialize root signature, vkd3d result %d.\n", ret); if (error_blob) diff --git a/tests/vkd3d_shader_api.c b/tests/vkd3d_shader_api.c index 4e6080dbd901..260257b1c7d5 100644 --- a/tests/vkd3d_shader_api.c +++ b/tests/vkd3d_shader_api.c @@ -54,9 +54,9 @@ static void test_invalid_shaders(void)
static void test_vkd3d_shader_pfns(void) { + PFN_vkd3d_shader_serialize_versioned_root_signature pfn_vkd3d_shader_serialize_versioned_root_signature; PFN_vkd3d_shader_parse_versioned_root_signature pfn_vkd3d_shader_parse_versioned_root_signature; PFN_vkd3d_shader_free_versioned_root_signature pfn_vkd3d_shader_free_versioned_root_signature; - PFN_vkd3d_shader_serialize_root_signature pfn_vkd3d_shader_serialize_root_signature; PFN_vkd3d_shader_find_signature_element pfn_vkd3d_shader_find_signature_element; PFN_vkd3d_shader_free_shader_signature pfn_vkd3d_shader_free_shader_signature; PFN_vkd3d_shader_parse_input_signature pfn_vkd3d_shader_parse_input_signature; @@ -71,7 +71,10 @@ static void test_vkd3d_shader_pfns(void) struct vkd3d_shader_code dxbc, spirv; int rc;
- static const struct vkd3d_root_signature_desc empty_rs_desc; + static const struct vkd3d_versioned_root_signature_desc empty_rs_desc = + { + .version = VKD3D_ROOT_SIGNATURE_VERSION_1_0, + }; static const DWORD vs_code[] = { #if 0 @@ -90,9 +93,9 @@ static void test_vkd3d_shader_pfns(void) }; static const struct vkd3d_shader_code vs = {vs_code, sizeof(vs_code)};
+ pfn_vkd3d_shader_serialize_versioned_root_signature = vkd3d_shader_serialize_versioned_root_signature; pfn_vkd3d_shader_parse_versioned_root_signature = vkd3d_shader_parse_versioned_root_signature; pfn_vkd3d_shader_free_versioned_root_signature = vkd3d_shader_free_versioned_root_signature; - pfn_vkd3d_shader_serialize_root_signature = vkd3d_shader_serialize_root_signature; pfn_vkd3d_shader_find_signature_element = vkd3d_shader_find_signature_element; pfn_vkd3d_shader_free_shader_signature = vkd3d_shader_free_shader_signature; pfn_vkd3d_shader_parse_input_signature = vkd3d_shader_parse_input_signature; @@ -100,7 +103,7 @@ static void test_vkd3d_shader_pfns(void) pfn_vkd3d_shader_compile_dxbc = vkd3d_shader_compile_dxbc; pfn_vkd3d_shader_scan_dxbc = vkd3d_shader_scan_dxbc;
- rc = pfn_vkd3d_shader_serialize_root_signature(&empty_rs_desc, VKD3D_ROOT_SIGNATURE_VERSION_1_0, &dxbc); + rc = pfn_vkd3d_shader_serialize_versioned_root_signature(&empty_rs_desc, &dxbc); ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc); rc = pfn_vkd3d_shader_parse_versioned_root_signature(&dxbc, &root_signature_desc); ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
--- libs/vkd3d/command.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index cdccfe8dca56..f3271eb76940 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -441,7 +441,8 @@ create_fence: return vr; }
-static void d3d12_fence_destroy_vk_semaphores_locked(struct d3d12_fence *fence, bool destroy_all) +static void d3d12_fence_garbage_collect_vk_semaphores_locked(struct d3d12_fence *fence, + bool destroy_all) { struct d3d12_device *device = fence->device; const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; @@ -450,7 +451,7 @@ static void d3d12_fence_destroy_vk_semaphores_locked(struct d3d12_fence *fence, unsigned int i, j;
semaphore_count = fence->semaphore_count; - if (!destroy_all && fence->semaphore_count < VKD3D_MAX_VK_SYNC_OBJECTS_PER_D3D12_FENCE) + if (!destroy_all && semaphore_count < VKD3D_MAX_VK_SYNC_OBJECTS_PER_D3D12_FENCE) return;
for (i = 0, j = 0; i < fence->semaphore_count; ++i) @@ -491,7 +492,6 @@ static void d3d12_fence_destroy_vk_objects(struct d3d12_fence *fence) const struct vkd3d_vk_device_procs *vk_procs; struct d3d12_device *device = fence->device; unsigned int i; - int rc;
if ((rc = pthread_mutex_lock(&fence->mutex))) @@ -509,7 +509,7 @@ static void d3d12_fence_destroy_vk_objects(struct d3d12_fence *fence) fence->old_vk_fences[i] = VK_NULL_HANDLE; }
- d3d12_fence_destroy_vk_semaphores_locked(fence, true); + d3d12_fence_garbage_collect_vk_semaphores_locked(fence, true);
pthread_mutex_unlock(&fence->mutex); } @@ -528,8 +528,7 @@ static HRESULT d3d12_fence_add_vk_semaphore(struct d3d12_fence *fence, return E_FAIL; }
- /* Destroy old Vulkan semaphores. */ - d3d12_fence_destroy_vk_semaphores_locked(fence, false); + d3d12_fence_garbage_collect_vk_semaphores_locked(fence, false);
if (vkd3d_array_reserve((void **)&fence->semaphores, &fence->semaphores_size, fence->semaphore_count + 1, sizeof(*fence->semaphores)))
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com