diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 5c9e42ed..7b3494ea 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -234,6 +234,14 @@ enum vkd3d_shader_source_type VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SOURCE_TYPE), }; +enum vkd3d_shader_target_type +{ + VKD3D_SHADER_TARGET_NONE, + VKD3D_SHADER_TARGET_SPIRV_BINARY, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TARGET_TYPE), +}; + struct vkd3d_shader_compile_info { enum vkd3d_shader_structure_type type; @@ -242,6 +250,7 @@ struct vkd3d_shader_compile_info struct vkd3d_shader_code source; enum vkd3d_shader_source_type source_type; + enum vkd3d_shader_target_type target_type; const struct vkd3d_shader_compile_option *options; unsigned int option_count; @@ -663,7 +672,7 @@ struct vkd3d_shader_signature #ifndef VKD3D_SHADER_NO_PROTOTYPES -int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv); +int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out); void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code); int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, @@ -693,7 +702,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)(const struct vkd3d_shader_compile_info *compile_info, - struct vkd3d_shader_code *spirv); + struct vkd3d_shader_code *out); typedef void (*PFN_vkd3d_shader_free_shader_code)(struct vkd3d_shader_code *code); typedef int (*PFN_vkd3d_shader_parse_root_signature)(const struct vkd3d_shader_code *dxbc, diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 5e471221..32550948 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -120,10 +120,19 @@ static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_ return VKD3D_ERROR_INVALID_ARGUMENT; } + switch (compile_info->target_type) + { + case VKD3D_SHADER_TARGET_SPIRV_BINARY: + break; + default: + WARN("Invalid shader target type %#x.\n", compile_info->target_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } + return VKD3D_OK; } -int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv) +int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out) { struct vkd3d_shader_instruction instruction; struct vkd3d_dxbc_compiler *spirv_compiler; @@ -131,7 +140,7 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, s struct vkd3d_shader_parser parser; int ret; - TRACE("compile_info %p, spirv %p.\n", compile_info, spirv); + TRACE("compile_info %p, out %p.\n", compile_info, out); if ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0) return ret; @@ -174,7 +183,7 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, s } if (ret >= 0) - ret = vkd3d_dxbc_compiler_generate_spirv(spirv_compiler, spirv); + ret = vkd3d_dxbc_compiler_generate_spirv(spirv_compiler, out); vkd3d_dxbc_compiler_destroy(spirv_compiler); vkd3d_shader_parser_destroy(&parser); diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 2a1107fb..55953ac8 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1351,6 +1351,7 @@ static HRESULT create_shader_stage(struct d3d12_device *device, compile_info.source.code = code->pShaderBytecode; compile_info.source.size = code->BytecodeLength; compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF; + compile_info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY; compile_info.options = NULL; compile_info.option_count = 0; diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 9013f215..48ca42a7 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -193,6 +193,7 @@ int main(int argc, char **argv) info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; info.next = NULL; info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF; + info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY; info.options = options.compile_options; info.option_count = options.compile_option_count; diff --git a/tests/vkd3d_shader_api.c b/tests/vkd3d_shader_api.c index 5b47703a..6aef0044 100644 --- a/tests/vkd3d_shader_api.c +++ b/tests/vkd3d_shader_api.c @@ -60,6 +60,7 @@ static void test_invalid_shaders(void) info.source.code = ps_break_code; info.source.size = sizeof(ps_break_code); info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF; + info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY; info.options = &option; info.option_count = 1; @@ -136,6 +137,7 @@ static void test_vkd3d_shader_pfns(void) compile_info.next = NULL; compile_info.source = vs; compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF; + compile_info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY; compile_info.options = NULL; compile_info.option_count = 0;