Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- include/vkd3d_shader.h | 13 +++++++++++-- libs/vkd3d-shader/vkd3d_shader_main.c | 18 ++++++++++++------ libs/vkd3d/state.c | 9 +++++++-- programs/vkd3d-compiler/main.c | 12 ++++++++---- tests/vkd3d_shader_api.c | 16 +++++++++++++--- 5 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index e57b913..ec449bb 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -30,6 +30,7 @@ extern "C" { enum vkd3d_shader_structure_type { /* 1.2 */ + VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO, VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO, VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO, VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_DOMAIN_SHADER_TARGET_INFO, @@ -218,6 +219,14 @@ struct vkd3d_shader_transform_feedback_info unsigned int buffer_stride_count; };
+struct vkd3d_shader_compile_info +{ + enum vkd3d_shader_structure_type type; + const void *next; + + struct vkd3d_shader_code source; +}; + enum vkd3d_shader_spirv_environment { VKD3D_SHADER_SPIRV_ENVIRONMENT_NONE, @@ -633,7 +642,7 @@ struct vkd3d_shader_signature
#ifndef VKD3D_SHADER_NO_PROTOTYPES
-int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv, unsigned int compiler_options, const struct vkd3d_shader_interface_info *shader_interface_info, const struct vkd3d_shader_spirv_target_info *target_info); @@ -665,7 +674,7 @@ void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature /* * Function pointer typedefs for vkd3d-shader functions. */ -typedef int (*PFN_vkd3d_shader_compile_dxbc)(const struct vkd3d_shader_code *dxbc, +typedef int (*PFN_vkd3d_shader_compile_dxbc)(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv, unsigned int compiler_options, const struct vkd3d_shader_interface_info *shader_interface_info, const struct vkd3d_shader_spirv_target_info *target_info); diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index a56682e..3d8829e 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -127,7 +127,7 @@ static int vkd3d_shader_validate_spirv_target_info(const struct vkd3d_shader_spi return VKD3D_OK; }
-int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, +int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv, unsigned int compiler_options, const struct vkd3d_shader_interface_info *shader_interface_info, const struct vkd3d_shader_spirv_target_info *info) @@ -138,8 +138,14 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_parser parser; int ret;
- TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface_info %p, info %p.\n", - dxbc->code, dxbc->size, spirv, compiler_options, shader_interface_info, info); + TRACE("compile_info %p, spirv %p, compiler_options %#x, shader_interface_info %p, info %p.\n", + compile_info, spirv, compiler_options, shader_interface_info, info); + + if (compile_info->type != VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO) + { + WARN("Invalid compile_info structure type %#x.\n", compile_info->type); + return VKD3D_ERROR_INVALID_ARGUMENT; + }
if (shader_interface_info && shader_interface_info->type != VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO) { @@ -152,13 +158,13 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
scan_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO; scan_info.next = NULL; - if ((ret = vkd3d_shader_scan_dxbc(dxbc, &scan_info)) < 0) + if ((ret = vkd3d_shader_scan_dxbc(&compile_info->source, &scan_info)) < 0) return ret;
- if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0) + if ((ret = vkd3d_shader_parser_init(&parser, &compile_info->source)) < 0) return ret;
- vkd3d_shader_dump_shader(parser.shader_version.type, dxbc); + vkd3d_shader_dump_shader(parser.shader_version.type, &compile_info->source);
if (TRACE_ON()) vkd3d_shader_trace(parser.data); diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 7b14198..fe44097 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1329,8 +1329,8 @@ static HRESULT create_shader_stage(struct d3d12_device *device, const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface, const struct vkd3d_shader_spirv_target_info *target_info) { - struct vkd3d_shader_code dxbc = {code->pShaderBytecode, code->BytecodeLength}; const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; + struct vkd3d_shader_compile_info compile_info; struct VkShaderModuleCreateInfo shader_desc; struct vkd3d_shader_code spirv = {0}; VkResult vr; @@ -1347,7 +1347,12 @@ static HRESULT create_shader_stage(struct d3d12_device *device, shader_desc.pNext = NULL; shader_desc.flags = 0;
- if ((ret = vkd3d_shader_compile_dxbc(&dxbc, &spirv, 0, shader_interface, target_info)) < 0) + compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; + compile_info.next = NULL; + compile_info.source.code = code->pShaderBytecode; + compile_info.source.size = code->BytecodeLength; + + if ((ret = vkd3d_shader_compile_dxbc(&compile_info, &spirv, 0, shader_interface, target_info)) < 0) { WARN("Failed to compile shader, vkd3d result %d.\n", ret); return hresult_from_vkd3d_result(ret); diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index dd94374..7e73ab0 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -148,7 +148,8 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
int main(int argc, char **argv) { - struct vkd3d_shader_code dxbc, spirv; + struct vkd3d_shader_compile_info info; + struct vkd3d_shader_code spirv; struct options options; int ret;
@@ -158,14 +159,17 @@ int main(int argc, char **argv) return 1; }
- if (!read_shader(&dxbc, options.filename)) + info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; + info.next = NULL; + + if (!read_shader(&info.source, options.filename)) { fprintf(stderr, "Failed to read DXBC shader.\n"); return 1; }
- ret = vkd3d_shader_compile_dxbc(&dxbc, &spirv, options.compiler_options, NULL, NULL); - vkd3d_shader_free_shader_code(&dxbc); + ret = vkd3d_shader_compile_dxbc(&info, &spirv, options.compiler_options, NULL, NULL); + vkd3d_shader_free_shader_code(&info.source); if (ret < 0) { fprintf(stderr, "Failed to compile DXBC shader, ret %d.\n", ret); diff --git a/tests/vkd3d_shader_api.c b/tests/vkd3d_shader_api.c index f9bec7e..8c9732c 100644 --- a/tests/vkd3d_shader_api.c +++ b/tests/vkd3d_shader_api.c @@ -23,6 +23,7 @@
static void test_invalid_shaders(void) { + struct vkd3d_shader_compile_info info; struct vkd3d_shader_code spirv; int rc;
@@ -48,9 +49,13 @@ static void test_invalid_shaders(void) 0x3f800000, 0x3f800000, 0x3f800000, 0x01000002, 0x01000015, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e, }; - static const struct vkd3d_shader_code ps_break = {ps_break_code, sizeof(ps_break_code)};
- rc = vkd3d_shader_compile_dxbc(&ps_break, &spirv, VKD3D_SHADER_STRIP_DEBUG, NULL, NULL); + info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; + info.next = NULL; + info.source.code = ps_break_code; + info.source.size = sizeof(ps_break_code); + + rc = vkd3d_shader_compile_dxbc(&info, &spirv, VKD3D_SHADER_STRIP_DEBUG, NULL, NULL); ok(rc == VKD3D_ERROR_INVALID_SHADER, "Got unexpected error code %d.\n", rc); }
@@ -68,6 +73,7 @@ static void test_vkd3d_shader_pfns(void)
struct vkd3d_versioned_root_signature_desc root_signature_desc; struct vkd3d_shader_signature_element *element; + struct vkd3d_shader_compile_info compile_info; struct vkd3d_shader_scan_info scan_info; struct vkd3d_shader_signature signature; struct vkd3d_shader_code dxbc, spirv; @@ -118,7 +124,11 @@ static void test_vkd3d_shader_pfns(void) ok(element, "Could not find shader signature element.\n"); pfn_vkd3d_shader_free_shader_signature(&signature);
- rc = pfn_vkd3d_shader_compile_dxbc(&vs, &spirv, 0, NULL, NULL); + compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; + compile_info.next = NULL; + compile_info.source = vs; + + rc = pfn_vkd3d_shader_compile_dxbc(&compile_info, &spirv, 0, NULL, NULL); ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc); pfn_vkd3d_shader_free_shader_code(&spirv);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73757
Your paranoid android.
=== debiant (build log) ===
Task: Patch failed to apply
=== debiant (build log) ===
Task: Patch failed to apply