From: Giovanni Mascellani gmascellani@codeweavers.com
--- tests/vkd3d_shader_stress.c | 57 ++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/tests/vkd3d_shader_stress.c b/tests/vkd3d_shader_stress.c index 6fa47b1f7..9a490e586 100644 --- a/tests/vkd3d_shader_stress.c +++ b/tests/vkd3d_shader_stress.c @@ -83,8 +83,13 @@ static bool compile_shader(const char *path) .log_level = VKD3D_SHADER_LOG_INFO, .source_name = path, }; + struct vkd3d_shader_hlsl_source_info source_info = + { + .type = VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO, + }; struct vkd3d_shader_code compiled_code; - const char *filename, *ext; + const char *filename, *ext, *profile; + char profile2[64]; bool ret = false; int res;
@@ -111,6 +116,56 @@ static bool compile_shader(const char *path) compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_DXIL; compile_info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY; } + else if (!strcmp(ext, "hlsl")) + { + char *ext2, *major_ptr; + unsigned long major; + + compile_info.source_type = VKD3D_SHADER_SOURCE_HLSL; + compile_info.next = &source_info; + + profile = strrchr(filename, '-'); + if (!profile) + { + fprintf(stderr, "Cannot decode profile for file %s.\n", path); + goto out; + } + ++profile; + + strncpy(profile2, profile, sizeof(profile2)); + profile2[sizeof(profile2) - 1] = '\0'; + if ((ext2 = strchr(profile2, '.'))) + *ext2 = '\0'; + source_info.profile = profile2; + + major_ptr = strchr(profile2, '_'); + if (!major_ptr) + { + fprintf(stderr, "Cannot decode major profile version for file %s.\n", path); + goto out; + } + ++major_ptr; + + major = strtoul(major_ptr, NULL, 10); + + switch (major) + { + case 1: + case 2: + case 3: + compile_info.target_type = VKD3D_SHADER_TARGET_D3D_BYTECODE; + break; + + case 4: + case 5: + compile_info.target_type = VKD3D_SHADER_TARGET_DXBC_TPF; + break; + + default: + fprintf(stderr, "Cannot compile shader with major profile version %lu for file %s.\n", major, path); + goto out; + } + } else { fprintf(stderr, "Cannot recognize extension %s for file %s.\n", ext, path);