tests: Introduce an OpenGL shader runner.

This commit is contained in:
Henri Verbeet 2023-09-22 07:31:31 +02:00 committed by Alexandre Julliard
parent 4e1bf5e163
commit beb3f6e0c2
Notes: Alexandre Julliard 2023-11-22 22:49:31 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/486
6 changed files with 1033 additions and 11 deletions

View File

@ -392,13 +392,14 @@ TESTS = $(vkd3d_tests) $(vkd3d_cross_tests) $(vkd3d_shader_tests)
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @DL_LIBS@ tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @DL_LIBS@
tests_d3d12_invalid_usage_LDADD = $(LDADD) @DL_LIBS@ tests_d3d12_invalid_usage_LDADD = $(LDADD) @DL_LIBS@
tests_hlsl_d3d12_LDADD = $(LDADD) @DL_LIBS@ tests_hlsl_d3d12_LDADD = $(LDADD) @DL_LIBS@
tests_shader_runner_LDADD = $(LDADD) @DL_LIBS@ tests_shader_runner_CFLAGS = $(AM_CFLAGS) -I$(builddir)/tests @OPENGL_CFLAGS@
tests_shader_runner_CFLAGS = $(AM_CFLAGS) -I$(builddir)/tests tests_shader_runner_LDADD = $(LDADD) @OPENGL_LIBS@ @DL_LIBS@
tests_shader_runner_SOURCES = \ tests_shader_runner_SOURCES = \
tests/shader_runner.c \ tests/shader_runner.c \
tests/shader_runner_d3d9.c \ tests/shader_runner_d3d9.c \
tests/shader_runner_d3d11.c \ tests/shader_runner_d3d11.c \
tests/shader_runner_d3d12.c \ tests/shader_runner_d3d12.c \
tests/shader_runner_gl.c \
tests/shader_runner_vulkan.c tests/shader_runner_vulkan.c
tests_vkd3d_api_LDADD = libvkd3d.la @DL_LIBS@ tests_vkd3d_api_LDADD = libvkd3d.la @DL_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la

View File

@ -9,6 +9,7 @@ AC_ARG_VAR([WIDL], [widl IDL compiler])
AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler]) AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler])
AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler]) AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler])
AC_ARG_WITH([ncurses], AS_HELP_STRING([--with-ncurses], [Build with the ncurses library (default: test)])) AC_ARG_WITH([ncurses], AS_HELP_STRING([--with-ncurses], [Build with the ncurses library (default: test)]))
AC_ARG_WITH([opengl], AS_HELP_STRING([--with-opengl], [Build with the OpenGL library (default: test)]))
AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools], AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools],
[Build with SPIRV-Tools library (default: disabled)])) [Build with SPIRV-Tools library (default: disabled)]))
AC_ARG_WITH([xcb], AS_HELP_STRING([--with-xcb], [Build with XCB library (default: test)])) AC_ARG_WITH([xcb], AS_HELP_STRING([--with-xcb], [Build with XCB library (default: test)]))
@ -130,6 +131,10 @@ AS_IF([test "x$with_ncurses" != "xno"],
[PKG_CHECK_MODULES([NCURSES], [ncurses], [PKG_CHECK_MODULES([NCURSES], [ncurses],
[AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if you have ncurses.]) with_ncurses=yes], [AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if you have ncurses.]) with_ncurses=yes],
[with_ncurses=no])]) [with_ncurses=no])])
AS_IF([test "x$with_opengl" != "xno"],
[PKG_CHECK_MODULES([OPENGL], [egl opengl],
[AC_DEFINE([HAVE_OPENGL], [1], [Define to 1 if you have OpenGL.]) with_opengl=yes],
[with_opengl=no])])
AS_IF([test "x$with_spirv_tools" = "xyes"], AS_IF([test "x$with_spirv_tools" = "xyes"],
[PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools-shared], [PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools-shared],
[AC_DEFINE([HAVE_SPIRV_TOOLS], [1], [Define to 1 if you have SPIRV-Tools.])])], [AC_DEFINE([HAVE_SPIRV_TOOLS], [1], [Define to 1 if you have SPIRV-Tools.])])],
@ -187,6 +192,7 @@ AS_ECHO(["
widl: ${WIDL} widl: ${WIDL}
Have ncurses: ${with_ncurses} Have ncurses: ${with_ncurses}
Have OpenGL: ${with_opengl}
Have SPIRV-Tools: ${with_spirv_tools} Have SPIRV-Tools: ${with_spirv_tools}
Have xcb: ${HAVE_XCB} Have xcb: ${HAVE_XCB}
Have dxcompiler: ${HAVE_DXCOMPILER} Have dxcompiler: ${HAVE_DXCOMPILER}

View File

@ -19,8 +19,10 @@ RUN export DEBIAN_FRONTEND=noninteractive; \
doxygen doxygen-latex graphviz \ doxygen doxygen-latex graphviz \
mesa-vulkan-drivers mesa-vulkan-drivers:i386 \ mesa-vulkan-drivers mesa-vulkan-drivers:i386 \
vulkan-tools spirv-headers \ vulkan-tools spirv-headers \
libegl-dev libegl-dev:i386 \
libvulkan-dev libvulkan-dev:i386 \ libvulkan-dev libvulkan-dev:i386 \
libncurses-dev libncurses-dev:i386 \ libncurses-dev libncurses-dev:i386 \
libopengl-dev libopengl-dev:i386 \
libxcb1-dev libxcb1-dev:i386 \ libxcb1-dev libxcb1-dev:i386 \
libxcb-util-dev libxcb-util-dev:i386 \ libxcb-util-dev libxcb-util-dev:i386 \
libxcb-icccm4-dev libxcb-icccm4-dev:i386 \ libxcb-icccm4-dev libxcb-icccm4-dev:i386 \

View File

@ -395,7 +395,7 @@ void init_resource(struct resource *resource, const struct resource_params *para
resource->height = params->height; resource->height = params->height;
} }
static struct resource *get_resource(struct shader_runner *runner, enum resource_type type, unsigned int slot) struct resource *shader_runner_get_resource(struct shader_runner *runner, enum resource_type type, unsigned int slot)
{ {
struct resource *resource; struct resource *resource;
size_t i; size_t i;
@ -575,7 +575,7 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
"{\n" "{\n"
"}"; "}";
if (!get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, 0)) if (!shader_runner_get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, 0))
{ {
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
params.slot = 0; params.slot = 0;
@ -620,7 +620,7 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
unsigned int vertex_count; unsigned int vertex_count;
char *rest; char *rest;
if (!get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, 0)) if (!shader_runner_get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, 0))
{ {
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
params.slot = 0; params.slot = 0;
@ -667,7 +667,7 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
fatal_error("Malformed UAV index '%s'.\n", line); fatal_error("Malformed UAV index '%s'.\n", line);
line = rest; line = rest;
resource = get_resource(runner, RESOURCE_TYPE_UAV, slot); resource = shader_runner_get_resource(runner, RESOURCE_TYPE_UAV, slot);
} }
else if (match_string(line, "buffer uav", &line)) else if (match_string(line, "buffer uav", &line))
{ {
@ -677,7 +677,7 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
fatal_error("Malformed buffer UAV index '%s'.\n", line); fatal_error("Malformed buffer UAV index '%s'.\n", line);
line = rest; line = rest;
resource = get_resource(runner, RESOURCE_TYPE_BUFFER_UAV, slot); resource = shader_runner_get_resource(runner, RESOURCE_TYPE_BUFFER_UAV, slot);
} }
else if (match_string(line, "render target", &line)) else if (match_string(line, "render target", &line))
{ {
@ -687,11 +687,11 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
fatal_error("Malformed render target index '%s'.\n", line); fatal_error("Malformed render target index '%s'.\n", line);
line = rest; line = rest;
resource = get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, slot); resource = shader_runner_get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, slot);
} }
else else
{ {
resource = get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, 0); resource = shader_runner_get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, 0);
} }
rb = runner->ops->get_resource_readback(runner, resource); rb = runner->ops->get_resource_readback(runner, resource);
@ -829,7 +829,7 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
} }
} }
static struct sampler *get_sampler(struct shader_runner *runner, unsigned int slot) struct sampler *shader_runner_get_sampler(struct shader_runner *runner, unsigned int slot)
{ {
struct sampler *sampler; struct sampler *sampler;
size_t i; size_t i;
@ -1325,7 +1325,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
{ {
state = STATE_SAMPLER; state = STATE_SAMPLER;
if (!(current_sampler = get_sampler(runner, index))) if (!(current_sampler = shader_runner_get_sampler(runner, index)))
{ {
if (runner->sampler_count == MAX_SAMPLERS) if (runner->sampler_count == MAX_SAMPLERS)
fatal_error("Too many samplers declared.\n"); fatal_error("Too many samplers declared.\n");
@ -1640,6 +1640,11 @@ START_TEST(shader_runner)
#else #else
trace("Running tests from a Unix build\n"); trace("Running tests from a Unix build\n");
# ifdef HAVE_OPENGL
trace("Compiling shaders with vkd3d-shader and executing with OpenGL\n");
run_shader_tests_gl();
# endif
trace("Compiling shaders with vkd3d-shader and executing with Vulkan\n"); trace("Compiling shaders with vkd3d-shader and executing with Vulkan\n");
run_shader_tests_vulkan(); run_shader_tests_vulkan();

View File

@ -164,6 +164,8 @@ unsigned int get_vb_stride(const struct shader_runner *runner, unsigned int slot
void init_resource(struct resource *resource, const struct resource_params *params); void init_resource(struct resource *resource, const struct resource_params *params);
HRESULT dxc_compiler_compile_shader(void *dxc_compiler, enum shader_type type, unsigned int compile_options, HRESULT dxc_compiler_compile_shader(void *dxc_compiler, enum shader_type type, unsigned int compile_options,
const char *hlsl, ID3D10Blob **blob_out, ID3D10Blob **errors_out); const char *hlsl, ID3D10Blob **blob_out, ID3D10Blob **errors_out);
struct sampler *shader_runner_get_sampler(struct shader_runner *runner, unsigned int slot);
struct resource *shader_runner_get_resource(struct shader_runner *runner, enum resource_type type, unsigned int slot);
void run_shader_tests(struct shader_runner *runner, const struct shader_runner_ops *ops, void *dxc_compiler, void run_shader_tests(struct shader_runner *runner, const struct shader_runner_ops *ops, void *dxc_compiler,
enum shader_model minimum_shader_model, enum shader_model maximum_shader_model); enum shader_model minimum_shader_model, enum shader_model maximum_shader_model);
@ -172,6 +174,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_o
void run_shader_tests_d3d9(void); void run_shader_tests_d3d9(void);
void run_shader_tests_d3d11(void); void run_shader_tests_d3d11(void);
#else #else
void run_shader_tests_gl(void);
void run_shader_tests_vulkan(void); void run_shader_tests_vulkan(void);
#endif #endif
void run_shader_tests_d3d12(void *dxc_compiler, enum shader_model minimum_shader_model, void run_shader_tests_d3d12(void *dxc_compiler, enum shader_model minimum_shader_model,

1005
tests/shader_runner_gl.c Normal file

File diff suppressed because it is too large Load Diff