mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader: Allow vkd3d_shader_compile_dxbc() to handle multiple source types.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b07c304440
commit
d6ec017077
@ -226,6 +226,14 @@ struct vkd3d_shader_transform_feedback_info
|
||||
unsigned int buffer_stride_count;
|
||||
};
|
||||
|
||||
enum vkd3d_shader_source_type
|
||||
{
|
||||
VKD3D_SHADER_SOURCE_NONE,
|
||||
VKD3D_SHADER_SOURCE_DXBC_TPF,
|
||||
|
||||
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SOURCE_TYPE),
|
||||
};
|
||||
|
||||
struct vkd3d_shader_compile_info
|
||||
{
|
||||
enum vkd3d_shader_structure_type type;
|
||||
@ -233,6 +241,8 @@ struct vkd3d_shader_compile_info
|
||||
|
||||
struct vkd3d_shader_code source;
|
||||
|
||||
enum vkd3d_shader_source_type source_type;
|
||||
|
||||
const struct vkd3d_shader_compile_option *options;
|
||||
unsigned int option_count;
|
||||
};
|
||||
@ -653,7 +663,7 @@ struct vkd3d_shader_signature
|
||||
|
||||
#ifndef VKD3D_SHADER_NO_PROTOTYPES
|
||||
|
||||
int vkd3d_shader_compile_dxbc(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 *spirv);
|
||||
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
|
||||
|
||||
int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
|
||||
@ -682,7 +692,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_compile_info *compile_info,
|
||||
typedef int (*PFN_vkd3d_shader_compile)(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *spirv);
|
||||
typedef void (*PFN_vkd3d_shader_free_shader_code)(struct vkd3d_shader_code *code);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
VKD3D_1_0
|
||||
{
|
||||
global:
|
||||
vkd3d_shader_compile_dxbc;
|
||||
vkd3d_shader_compile;
|
||||
vkd3d_shader_convert_root_signature;
|
||||
vkd3d_shader_find_signature_element;
|
||||
vkd3d_shader_free_root_signature;
|
||||
|
@ -103,7 +103,27 @@ static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser)
|
||||
free_shader_desc(&parser->shader_desc);
|
||||
}
|
||||
|
||||
int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv)
|
||||
static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info)
|
||||
{
|
||||
if (compile_info->type != VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO)
|
||||
{
|
||||
WARN("Invalid structure type %#x.\n", compile_info->type);
|
||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
switch (compile_info->source_type)
|
||||
{
|
||||
case VKD3D_SHADER_SOURCE_DXBC_TPF:
|
||||
break;
|
||||
default:
|
||||
WARN("Invalid shader source type %#x.\n", compile_info->source_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)
|
||||
{
|
||||
struct vkd3d_shader_instruction instruction;
|
||||
struct vkd3d_dxbc_compiler *spirv_compiler;
|
||||
@ -113,11 +133,8 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_compile_info *compile_in
|
||||
|
||||
TRACE("compile_info %p, spirv %p.\n", compile_info, spirv);
|
||||
|
||||
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 ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0)
|
||||
return ret;
|
||||
|
||||
scan_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO;
|
||||
scan_info.next = NULL;
|
||||
|
@ -1350,10 +1350,11 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
|
||||
compile_info.next = shader_interface;
|
||||
compile_info.source.code = code->pShaderBytecode;
|
||||
compile_info.source.size = code->BytecodeLength;
|
||||
compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
|
||||
compile_info.options = NULL;
|
||||
compile_info.option_count = 0;
|
||||
|
||||
if ((ret = vkd3d_shader_compile_dxbc(&compile_info, &spirv)) < 0)
|
||||
if ((ret = vkd3d_shader_compile(&compile_info, &spirv)) < 0)
|
||||
{
|
||||
WARN("Failed to compile shader, vkd3d result %d.\n", ret);
|
||||
return hresult_from_vkd3d_result(ret);
|
||||
|
@ -192,6 +192,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.options = options.compile_options;
|
||||
info.option_count = options.compile_option_count;
|
||||
|
||||
@ -201,7 +202,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = vkd3d_shader_compile_dxbc(&info, &spirv);
|
||||
ret = vkd3d_shader_compile(&info, &spirv);
|
||||
vkd3d_shader_free_shader_code(&info.source);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -59,10 +59,11 @@ static void test_invalid_shaders(void)
|
||||
info.next = NULL;
|
||||
info.source.code = ps_break_code;
|
||||
info.source.size = sizeof(ps_break_code);
|
||||
info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
|
||||
info.options = &option;
|
||||
info.option_count = 1;
|
||||
|
||||
rc = vkd3d_shader_compile_dxbc(&info, &spirv);
|
||||
rc = vkd3d_shader_compile(&info, &spirv);
|
||||
ok(rc == VKD3D_ERROR_INVALID_SHADER, "Got unexpected error code %d.\n", rc);
|
||||
}
|
||||
|
||||
@ -75,8 +76,8 @@ static void test_vkd3d_shader_pfns(void)
|
||||
PFN_vkd3d_shader_parse_root_signature pfn_vkd3d_shader_parse_root_signature;
|
||||
PFN_vkd3d_shader_free_root_signature pfn_vkd3d_shader_free_root_signature;
|
||||
PFN_vkd3d_shader_free_shader_code pfn_vkd3d_shader_free_shader_code;
|
||||
PFN_vkd3d_shader_compile_dxbc pfn_vkd3d_shader_compile_dxbc;
|
||||
PFN_vkd3d_shader_scan_dxbc pfn_vkd3d_shader_scan_dxbc;
|
||||
PFN_vkd3d_shader_compile pfn_vkd3d_shader_compile;
|
||||
|
||||
struct vkd3d_versioned_root_signature_desc root_signature_desc;
|
||||
struct vkd3d_shader_signature_element *element;
|
||||
@ -115,8 +116,8 @@ static void test_vkd3d_shader_pfns(void)
|
||||
pfn_vkd3d_shader_parse_root_signature = vkd3d_shader_parse_root_signature;
|
||||
pfn_vkd3d_shader_free_root_signature = vkd3d_shader_free_root_signature;
|
||||
pfn_vkd3d_shader_free_shader_code = vkd3d_shader_free_shader_code;
|
||||
pfn_vkd3d_shader_compile_dxbc = vkd3d_shader_compile_dxbc;
|
||||
pfn_vkd3d_shader_scan_dxbc = vkd3d_shader_scan_dxbc;
|
||||
pfn_vkd3d_shader_compile = vkd3d_shader_compile;
|
||||
|
||||
rc = pfn_vkd3d_shader_serialize_root_signature(&empty_rs_desc, &dxbc);
|
||||
ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
|
||||
@ -134,10 +135,11 @@ static void test_vkd3d_shader_pfns(void)
|
||||
compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
|
||||
compile_info.next = NULL;
|
||||
compile_info.source = vs;
|
||||
compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
|
||||
compile_info.options = NULL;
|
||||
compile_info.option_count = 0;
|
||||
|
||||
rc = pfn_vkd3d_shader_compile_dxbc(&compile_info, &spirv);
|
||||
rc = pfn_vkd3d_shader_compile(&compile_info, &spirv);
|
||||
ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
|
||||
pfn_vkd3d_shader_free_shader_code(&spirv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user