mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader: Introduce vkd3d_shader_get_version().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
dae87cc1c0
commit
7dda2339a2
21
Makefile.am
21
Makefile.am
@ -1,6 +1,6 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
AM_CFLAGS = @VKD3D_CFLAGS@
|
||||
AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/dummy -I$(srcdir)/include/private
|
||||
AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include/private
|
||||
AM_LDFLAGS = -no-undefined
|
||||
|
||||
widl_headers = \
|
||||
@ -58,7 +58,8 @@ vkd3d_demos_headers = \
|
||||
demos/demo_win32.h \
|
||||
demos/demo_xcb.h
|
||||
|
||||
BUILT_SOURCES = $(widl_headers)
|
||||
BUILT_SOURCES = $(widl_headers) \
|
||||
include/private/vkd3d_version.h
|
||||
|
||||
noinst_LTLIBRARIES = libvkd3d-common.la
|
||||
libvkd3d_common_la_SOURCES = \
|
||||
@ -109,8 +110,7 @@ libvkd3d_la_SOURCES = \
|
||||
libs/vkd3d/vkd3d_main.c \
|
||||
libs/vkd3d/vkd3d_private.h \
|
||||
libs/vkd3d/vkd3d_shaders.h \
|
||||
libs/vkd3d/vulkan_procs.h \
|
||||
libs/vkd3d_version.c
|
||||
libs/vkd3d/vulkan_procs.h
|
||||
libvkd3d_la_LDFLAGS = $(AM_LDFLAGS) -version-info 2:0:1
|
||||
libvkd3d_la_LIBADD = libvkd3d-common.la libvkd3d-shader.la @DL_LIBS@ @PTHREAD_LIBS@
|
||||
if HAVE_LD_VERSION_SCRIPT
|
||||
@ -208,10 +208,15 @@ libvkd3d.pc: $(srcdir)/libs/vkd3d/libvkd3d.pc.in Makefile
|
||||
-e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \
|
||||
$< > $@
|
||||
|
||||
libs/vkd3d_version.c: dummy-vkd3d-version
|
||||
$(AM_V_GEN)version=`(GIT_DIR=$(top_srcdir)/.git git describe HEAD 2>/dev/null || echo "vkd3d-$(PACKAGE_VERSION)") | $(SED) -n -e '$$s/\(.*\)/const char vkd3d_build[] = "\1";/p'` && (echo $$version | cmp -s - $@) || echo $$version >$@ || ($(RM) $@ && exit 1)
|
||||
.SILENT: libs/vkd3d_version.c
|
||||
CLEANFILES += libs/vkd3d_version.c
|
||||
include/private/vkd3d_version.h: dummy-vkd3d-version
|
||||
@$(MKDIR_P) include/private
|
||||
version=`(GIT_DIR=$(top_srcdir)/.git git rev-parse --short HEAD 2>/dev/null || echo '') \
|
||||
| $(SED) -e 's!\(..*\)! (git \1)!' \
|
||||
| $(SED) -n -e '$$s!\(.*\)!#define VKD3D_VCS_ID "\1"!p'` \
|
||||
&& (echo $$version | cmp -s - $@) \
|
||||
|| echo $$version >$@ || ($(RM) $@ && exit 1)
|
||||
.SILENT: include/private/vkd3d_version.h
|
||||
CLEANFILES += include/private/vkd3d_version.h
|
||||
|
||||
.PHONY: dummy-vkd3d-version
|
||||
dummy-vkd3d-version:
|
||||
|
1
include/.gitignore
vendored
1
include/.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
config.h
|
||||
config.h.in
|
||||
private/vkd3d_version.h
|
||||
stamp-h1
|
||||
vkd3d_d3d12.h
|
||||
vkd3d_d3d12sdklayers.h
|
||||
|
@ -749,6 +749,8 @@ struct vkd3d_shader_signature
|
||||
|
||||
#ifndef VKD3D_SHADER_NO_PROTOTYPES
|
||||
|
||||
const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor);
|
||||
|
||||
int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, char **messages);
|
||||
void vkd3d_shader_free_messages(char *messages);
|
||||
@ -779,6 +781,8 @@ void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature
|
||||
/*
|
||||
* Function pointer typedefs for vkd3d-shader functions.
|
||||
*/
|
||||
typedef const char *(*PFN_vkd3d_shader_get_version)(unsigned int *major, unsigned int *minor);
|
||||
|
||||
typedef int (*PFN_vkd3d_shader_compile)(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, char **messages);
|
||||
typedef void (*PFN_vkd3d_shader_free_messages)(char *messages);
|
||||
|
@ -9,6 +9,7 @@ global:
|
||||
vkd3d_shader_free_scan_descriptor_info;
|
||||
vkd3d_shader_free_shader_code;
|
||||
vkd3d_shader_free_shader_signature;
|
||||
vkd3d_shader_get_version;
|
||||
vkd3d_shader_parse_input_signature;
|
||||
vkd3d_shader_parse_root_signature;
|
||||
vkd3d_shader_scan;
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "vkd3d_shader_private.h"
|
||||
#include "vkd3d_version.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -1027,3 +1028,21 @@ void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature
|
||||
vkd3d_free(signature->elements);
|
||||
signature->elements = NULL;
|
||||
}
|
||||
|
||||
const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
TRACE("major %p, minor %p.\n", major, minor);
|
||||
|
||||
if (major || minor)
|
||||
{
|
||||
vkd3d_parse_version(PACKAGE_VERSION, &x, &y);
|
||||
if (major)
|
||||
*major = x;
|
||||
if (minor)
|
||||
*minor = y;
|
||||
}
|
||||
|
||||
return "vkd3d-shader " PACKAGE_VERSION VKD3D_VCS_ID;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "vkd3d_private.h"
|
||||
#include "vkd3d_version.h"
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
@ -460,7 +461,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
|
||||
VkResult vr;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("Build: %s.\n", vkd3d_build);
|
||||
TRACE("Build: " PACKAGE_STRING VKD3D_VCS_ID ".\n");
|
||||
|
||||
if (!create_info->pfn_signal_event)
|
||||
{
|
||||
|
@ -83,15 +83,18 @@ 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_get_version pfn_vkd3d_shader_get_version;
|
||||
PFN_vkd3d_shader_compile pfn_vkd3d_shader_compile;
|
||||
PFN_vkd3d_shader_scan pfn_vkd3d_shader_scan;
|
||||
|
||||
struct vkd3d_shader_versioned_root_signature_desc root_signature_desc;
|
||||
unsigned int major, minor, expected_major, expected_minor;
|
||||
struct vkd3d_shader_scan_descriptor_info descriptor_info;
|
||||
struct vkd3d_shader_signature_element *element;
|
||||
struct vkd3d_shader_compile_info compile_info;
|
||||
struct vkd3d_shader_signature signature;
|
||||
struct vkd3d_shader_code dxbc, spirv;
|
||||
const char *version, *p;
|
||||
int rc;
|
||||
|
||||
static const struct vkd3d_shader_versioned_root_signature_desc empty_rs_desc =
|
||||
@ -124,9 +127,17 @@ 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_get_version = vkd3d_shader_get_version;
|
||||
pfn_vkd3d_shader_compile = vkd3d_shader_compile;
|
||||
pfn_vkd3d_shader_scan = vkd3d_shader_scan;
|
||||
|
||||
sscanf(PACKAGE_VERSION, "%d.%d", &expected_major, &expected_minor);
|
||||
version = pfn_vkd3d_shader_get_version(&major, &minor);
|
||||
p = strstr(version, "vkd3d-shader " PACKAGE_VERSION);
|
||||
ok(p == version, "Got unexpected version string \"%s\"\n", version);
|
||||
ok(major == expected_major, "Got unexpected major version %u.\n", major);
|
||||
ok(minor == expected_minor, "Got unexpected minor version %u.\n", minor);
|
||||
|
||||
rc = pfn_vkd3d_shader_serialize_root_signature(&empty_rs_desc, &dxbc, NULL);
|
||||
ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
|
||||
rc = pfn_vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc, NULL);
|
||||
@ -163,10 +174,36 @@ static void test_vkd3d_shader_pfns(void)
|
||||
pfn_vkd3d_shader_free_scan_descriptor_info(&descriptor_info);
|
||||
}
|
||||
|
||||
static void test_version(void)
|
||||
{
|
||||
unsigned int major, minor, expected_major, expected_minor;
|
||||
const char *version, *p;
|
||||
|
||||
sscanf(PACKAGE_VERSION, "%d.%d", &expected_major, &expected_minor);
|
||||
|
||||
version = vkd3d_shader_get_version(NULL, NULL);
|
||||
p = strstr(version, "vkd3d-shader " PACKAGE_VERSION);
|
||||
ok(p == version, "Got unexpected version string \"%s\"\n", version);
|
||||
|
||||
major = ~0u;
|
||||
vkd3d_shader_get_version(&major, NULL);
|
||||
ok(major == expected_major, "Got unexpected major version %u.\n", major);
|
||||
|
||||
minor = ~0u;
|
||||
vkd3d_shader_get_version(NULL, &minor);
|
||||
ok(minor == expected_minor, "Got unexpected minor version %u.\n", minor);
|
||||
|
||||
major = minor = ~0u;
|
||||
vkd3d_shader_get_version(&major, &minor);
|
||||
ok(major == expected_major, "Got unexpected major version %u.\n", major);
|
||||
ok(minor == expected_minor, "Got unexpected minor version %u.\n", minor);
|
||||
}
|
||||
|
||||
START_TEST(vkd3d_shader_api)
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
run_test(test_invalid_shaders);
|
||||
run_test(test_vkd3d_shader_pfns);
|
||||
run_test(test_version);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user