mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Introduce vkd3d_shader_get_supported_source_types().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
af73e16633
commit
5f4bd618ed
@ -750,6 +750,7 @@ struct vkd3d_shader_signature
|
|||||||
#ifndef VKD3D_SHADER_NO_PROTOTYPES
|
#ifndef VKD3D_SHADER_NO_PROTOTYPES
|
||||||
|
|
||||||
const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor);
|
const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor);
|
||||||
|
const enum vkd3d_shader_source_type *vkd3d_shader_get_supported_source_types(unsigned int *count);
|
||||||
|
|
||||||
int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
||||||
struct vkd3d_shader_code *out, char **messages);
|
struct vkd3d_shader_code *out, char **messages);
|
||||||
@ -782,6 +783,7 @@ void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature
|
|||||||
* Function pointer typedefs for vkd3d-shader functions.
|
* Function pointer typedefs for vkd3d-shader functions.
|
||||||
*/
|
*/
|
||||||
typedef const char *(*PFN_vkd3d_shader_get_version)(unsigned int *major, unsigned int *minor);
|
typedef const char *(*PFN_vkd3d_shader_get_version)(unsigned int *major, unsigned int *minor);
|
||||||
|
typedef const enum vkd3d_shader_source_type *(*PFN_vkd3d_shader_get_supported_source_types)(unsigned int *count);
|
||||||
|
|
||||||
typedef int (*PFN_vkd3d_shader_compile)(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 *out, char **messages);
|
struct vkd3d_shader_code *out, char **messages);
|
||||||
|
@ -9,6 +9,7 @@ global:
|
|||||||
vkd3d_shader_free_scan_descriptor_info;
|
vkd3d_shader_free_scan_descriptor_info;
|
||||||
vkd3d_shader_free_shader_code;
|
vkd3d_shader_free_shader_code;
|
||||||
vkd3d_shader_free_shader_signature;
|
vkd3d_shader_free_shader_signature;
|
||||||
|
vkd3d_shader_get_supported_source_types;
|
||||||
vkd3d_shader_get_version;
|
vkd3d_shader_get_version;
|
||||||
vkd3d_shader_parse_input_signature;
|
vkd3d_shader_parse_input_signature;
|
||||||
vkd3d_shader_parse_root_signature;
|
vkd3d_shader_parse_root_signature;
|
||||||
|
@ -255,17 +255,23 @@ static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser)
|
|||||||
|
|
||||||
static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info)
|
static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info)
|
||||||
{
|
{
|
||||||
|
const enum vkd3d_shader_source_type *source_types;
|
||||||
|
unsigned int count, i;
|
||||||
|
|
||||||
if (compile_info->type != VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO)
|
if (compile_info->type != VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO)
|
||||||
{
|
{
|
||||||
WARN("Invalid structure type %#x.\n", compile_info->type);
|
WARN("Invalid structure type %#x.\n", compile_info->type);
|
||||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (compile_info->source_type)
|
source_types = vkd3d_shader_get_supported_source_types(&count);
|
||||||
|
for (i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
case VKD3D_SHADER_SOURCE_DXBC_TPF:
|
if (source_types[i] == compile_info->source_type)
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
if (i == count)
|
||||||
|
{
|
||||||
WARN("Invalid shader source type %#x.\n", compile_info->source_type);
|
WARN("Invalid shader source type %#x.\n", compile_info->source_type);
|
||||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
@ -1037,3 +1043,16 @@ const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor)
|
|||||||
|
|
||||||
return "vkd3d-shader " PACKAGE_VERSION VKD3D_VCS_ID;
|
return "vkd3d-shader " PACKAGE_VERSION VKD3D_VCS_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const enum vkd3d_shader_source_type *vkd3d_shader_get_supported_source_types(unsigned int *count)
|
||||||
|
{
|
||||||
|
static const enum vkd3d_shader_source_type types[] =
|
||||||
|
{
|
||||||
|
VKD3D_SHADER_SOURCE_DXBC_TPF,
|
||||||
|
};
|
||||||
|
|
||||||
|
TRACE("count %p.\n", count);
|
||||||
|
|
||||||
|
*count = ARRAY_SIZE(types);
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
@ -75,6 +75,7 @@ static void test_invalid_shaders(void)
|
|||||||
|
|
||||||
static void test_vkd3d_shader_pfns(void)
|
static void test_vkd3d_shader_pfns(void)
|
||||||
{
|
{
|
||||||
|
PFN_vkd3d_shader_get_supported_source_types pfn_vkd3d_shader_get_supported_source_types;
|
||||||
PFN_vkd3d_shader_free_scan_descriptor_info pfn_vkd3d_shader_free_scan_descriptor_info;
|
PFN_vkd3d_shader_free_scan_descriptor_info pfn_vkd3d_shader_free_scan_descriptor_info;
|
||||||
PFN_vkd3d_shader_serialize_root_signature pfn_vkd3d_shader_serialize_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_find_signature_element pfn_vkd3d_shader_find_signature_element;
|
||||||
@ -90,11 +91,14 @@ static void test_vkd3d_shader_pfns(void)
|
|||||||
struct vkd3d_shader_versioned_root_signature_desc root_signature_desc;
|
struct vkd3d_shader_versioned_root_signature_desc root_signature_desc;
|
||||||
unsigned int major, minor, expected_major, expected_minor;
|
unsigned int major, minor, expected_major, expected_minor;
|
||||||
struct vkd3d_shader_scan_descriptor_info descriptor_info;
|
struct vkd3d_shader_scan_descriptor_info descriptor_info;
|
||||||
|
const enum vkd3d_shader_source_type *source_types;
|
||||||
struct vkd3d_shader_signature_element *element;
|
struct vkd3d_shader_signature_element *element;
|
||||||
struct vkd3d_shader_compile_info compile_info;
|
struct vkd3d_shader_compile_info compile_info;
|
||||||
struct vkd3d_shader_signature signature;
|
struct vkd3d_shader_signature signature;
|
||||||
struct vkd3d_shader_code dxbc, spirv;
|
struct vkd3d_shader_code dxbc, spirv;
|
||||||
const char *version, *p;
|
const char *version, *p;
|
||||||
|
unsigned int i, count;
|
||||||
|
bool b;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
static const struct vkd3d_shader_versioned_root_signature_desc empty_rs_desc =
|
static const struct vkd3d_shader_versioned_root_signature_desc empty_rs_desc =
|
||||||
@ -119,6 +123,7 @@ static void test_vkd3d_shader_pfns(void)
|
|||||||
};
|
};
|
||||||
static const struct vkd3d_shader_code vs = {vs_code, sizeof(vs_code)};
|
static const struct vkd3d_shader_code vs = {vs_code, sizeof(vs_code)};
|
||||||
|
|
||||||
|
pfn_vkd3d_shader_get_supported_source_types = vkd3d_shader_get_supported_source_types;
|
||||||
pfn_vkd3d_shader_free_scan_descriptor_info = vkd3d_shader_free_scan_descriptor_info;
|
pfn_vkd3d_shader_free_scan_descriptor_info = vkd3d_shader_free_scan_descriptor_info;
|
||||||
pfn_vkd3d_shader_serialize_root_signature = vkd3d_shader_serialize_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_find_signature_element = vkd3d_shader_find_signature_element;
|
||||||
@ -138,6 +143,21 @@ static void test_vkd3d_shader_pfns(void)
|
|||||||
ok(major == expected_major, "Got unexpected major version %u.\n", major);
|
ok(major == expected_major, "Got unexpected major version %u.\n", major);
|
||||||
ok(minor == expected_minor, "Got unexpected minor version %u.\n", minor);
|
ok(minor == expected_minor, "Got unexpected minor version %u.\n", minor);
|
||||||
|
|
||||||
|
source_types = pfn_vkd3d_shader_get_supported_source_types(&count);
|
||||||
|
ok(source_types, "Got unexpected source types array %p.\n", source_types);
|
||||||
|
ok(count, "Got unexpected source type count %u.\n", count);
|
||||||
|
|
||||||
|
b = false;
|
||||||
|
for (i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
if (source_types[i] == VKD3D_SHADER_SOURCE_DXBC_TPF)
|
||||||
|
{
|
||||||
|
b = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ok(b, "The dxbc-tpf source type is not supported.\n");
|
||||||
|
|
||||||
rc = pfn_vkd3d_shader_serialize_root_signature(&empty_rs_desc, &dxbc, NULL);
|
rc = pfn_vkd3d_shader_serialize_root_signature(&empty_rs_desc, &dxbc, NULL);
|
||||||
ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
|
ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
|
||||||
rc = pfn_vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc, NULL);
|
rc = pfn_vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user