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);