From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/private/vkd3d_test.h | 3 +-- tests/d3d12.c | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/include/private/vkd3d_test.h b/include/private/vkd3d_test.h index 7eb72d3a29f2..c66b227d1e74 100644 --- a/include/private/vkd3d_test.h +++ b/include/private/vkd3d_test.h @@ -19,6 +19,7 @@ #ifndef __VKD3D_TEST_H #define __VKD3D_TEST_H
+#include "vkd3d_common.h" #include <assert.h> #include <inttypes.h> #include <stdarg.h> @@ -27,8 +28,6 @@ #include <stdlib.h> #include <string.h>
-#include "vkd3d_common.h" - static void vkd3d_test_main(int argc, char **argv); static const char *vkd3d_test_name;
diff --git a/tests/d3d12.c b/tests/d3d12.c index 90f848f1d6a0..caf94d235148 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -36,11 +36,6 @@ typedef int HRESULT; #endif
-#include <inttypes.h> -#include <limits.h> -#include <math.h> -#include <time.h> - #define COBJMACROS #define INITGUID #include "vkd3d_test.h" @@ -48,6 +43,11 @@ typedef int HRESULT; #define WIDL_C_INLINE_WRAPPERS #include "d3d12.h"
+#include <inttypes.h> +#include <limits.h> +#include <math.h> +#include <time.h> + #ifdef _WIN32 # include "dxgi1_4.h" #else
From: Józef Kucia jkucia@codeweavers.com
In order to use C functions which are not part of C99, e.g. strdup() and strncmp().
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- configure.ac | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/configure.ac b/configure.ac index a4db07230eaa..27c03a6c9400 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,8 @@ AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler]) AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools], [Build with SPIRV-Tools library (default: disabled)]))
+AC_USE_SYSTEM_EXTENSIONS + dnl Check for progs AM_PROG_AR AC_PROG_CC @@ -29,7 +31,7 @@ LT_PREREQ([2.4.2]) LT_INIT
dnl Check compiler specific flags -AC_SUBST([VKD3D_CFLAGS], [""]) +AC_SUBST([VKD3D_CFLAGS]) AS_IF([test "x${GCC}" = "xyes"], [VKD3D_CFLAGS="-Wall -pipe" VKD3D_CHECK_CFLAGS([-std=c99]) @@ -39,17 +41,6 @@ AS_IF([test "x${GCC}" = "xyes"], VKD3D_CHECK_CFLAGS([-Wvla]) VKD3D_CHECK_CFLAGS([-Wl,--no-undefined])])
-AC_EGREP_CPP(yes, - [#define _POSIX_C_SOURCE 200809L - #include <unistd.h> - #ifdef _POSIX_VERSION - #if _POSIX_VERSION == 200809L - yes - #endif - #endif], - [AC_DEFINE([_POSIX_C_SOURCE], [200809L], [Define the POSIX version.])], - []) - dnl Check for cross compilers VKD3D_CHECK_MINGW32_PROG([CROSSCC32], [CROSSTARGET32], [no]) VKD3D_CHECK_MINGW64_PROG([CROSSCC64], [CROSSTARGET64], [no])
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index cc07d96d7690..0684cd32718f 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2078,6 +2078,13 @@ static uint32_t vkd3d_dxbc_compiler_get_constant_float(struct vkd3d_dxbc_compile return vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_TYPE_FLOAT, 1, (uint32_t *)&value); }
+static uint32_t vkd3d_dxbc_compiler_get_constant_uint_vector(struct vkd3d_dxbc_compiler *compiler, + uint32_t value, unsigned int component_count) +{ + const uint32_t values[] = {value, value, value, value}; + return vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_TYPE_UINT, component_count, values); +} + static uint32_t vkd3d_dxbc_compiler_get_constant_float_vector(struct vkd3d_dxbc_compiler *compiler, float value, unsigned int component_count) { @@ -2624,7 +2631,6 @@ static uint32_t vkd3d_dxbc_compiler_emit_int_to_bool(struct vkd3d_dxbc_compiler enum vkd3d_shader_conditional_op condition, unsigned int component_count, uint32_t val_id) { struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; - static const uint32_t zero[VKD3D_VEC4_SIZE]; uint32_t type_id; SpvOp op;
@@ -2633,20 +2639,17 @@ static uint32_t vkd3d_dxbc_compiler_emit_int_to_bool(struct vkd3d_dxbc_compiler type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_BOOL, component_count); op = condition & VKD3D_SHADER_CONDITIONAL_OP_Z ? SpvOpIEqual : SpvOpINotEqual; return vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, op, type_id, val_id, - vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_TYPE_UINT, component_count, zero)); + vkd3d_dxbc_compiler_get_constant_uint_vector(compiler, 0, component_count)); }
static uint32_t vkd3d_dxbc_compiler_emit_bool_to_int(struct vkd3d_dxbc_compiler *compiler, unsigned int component_count, uint32_t val_id) { - static const uint32_t d3d_true[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; - static const uint32_t d3d_false[] = {0, 0, 0, 0}; - struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; uint32_t type_id, true_id, false_id;
- true_id = vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_TYPE_UINT, component_count, d3d_true); - false_id = vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_TYPE_UINT, component_count, d3d_false); + true_id = vkd3d_dxbc_compiler_get_constant_uint_vector(compiler, 0xffffffff, component_count); + false_id = vkd3d_dxbc_compiler_get_constant_uint_vector(compiler, 0, component_count); type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_UINT, component_count); return vkd3d_spirv_build_op_select(builder, type_id, val_id, true_id, false_id); } @@ -3885,9 +3888,7 @@ static void vkd3d_dxbc_compiler_emit_imad(struct vkd3d_dxbc_compiler *compiler, static void vkd3d_dxbc_compiler_emit_udiv(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { - static const uint32_t ffffffff[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; - - uint32_t type_id, val_id, src0_id, src1_id, condition_id, ffffffff_id; + uint32_t type_id, val_id, src0_id, src1_id, condition_id, uint_max_id; struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; const struct vkd3d_shader_dst_param *dst = instruction->dst; const struct vkd3d_shader_src_param *src = instruction->src; @@ -3904,12 +3905,12 @@ static void vkd3d_dxbc_compiler_emit_udiv(struct vkd3d_dxbc_compiler *compiler,
condition_id = vkd3d_dxbc_compiler_emit_int_to_bool(compiler, VKD3D_SHADER_CONDITIONAL_OP_NZ, component_count, src1_id); - ffffffff_id = vkd3d_dxbc_compiler_get_constant(compiler, - VKD3D_TYPE_UINT, component_count, ffffffff); + uint_max_id = vkd3d_dxbc_compiler_get_constant_uint_vector(compiler, + 0xffffffff, component_count);
val_id = vkd3d_spirv_build_op_udiv(builder, type_id, src0_id, src1_id); /* The SPIR-V spec says: "The resulting value is undefined if Operand 2 is 0." */ - val_id = vkd3d_spirv_build_op_select(builder, type_id, condition_id, val_id, ffffffff_id); + val_id = vkd3d_spirv_build_op_select(builder, type_id, condition_id, val_id, uint_max_id);
vkd3d_dxbc_compiler_emit_store_dst(compiler, &dst[0], val_id); } @@ -3927,13 +3928,13 @@ static void vkd3d_dxbc_compiler_emit_udiv(struct vkd3d_dxbc_compiler *compiler,
condition_id = vkd3d_dxbc_compiler_emit_int_to_bool(compiler, VKD3D_SHADER_CONDITIONAL_OP_NZ, component_count, src1_id); - ffffffff_id = vkd3d_dxbc_compiler_get_constant(compiler, - VKD3D_TYPE_UINT, component_count, ffffffff); + uint_max_id = vkd3d_dxbc_compiler_get_constant_uint_vector(compiler, + 0xffffffff, component_count); }
val_id = vkd3d_spirv_build_op_umod(builder, type_id, src0_id, src1_id); /* The SPIR-V spec says: "The resulting value is undefined if Operand 2 is 0." */ - val_id = vkd3d_spirv_build_op_select(builder, type_id, condition_id, val_id, ffffffff_id); + val_id = vkd3d_spirv_build_op_select(builder, type_id, condition_id, val_id, uint_max_id);
vkd3d_dxbc_compiler_emit_store_dst(compiler, &dst[1], val_id); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
In order to run cross-compiled tests under Wine.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/private/vkd3d_test.h | 56 +++++++++++++++++++++++++++++++++----------- tests/d3d12.c | 11 +++++---- 2 files changed, 48 insertions(+), 19 deletions(-)
diff --git a/include/private/vkd3d_test.h b/include/private/vkd3d_test.h index c66b227d1e74..f4a16273b2da 100644 --- a/include/private/vkd3d_test.h +++ b/include/private/vkd3d_test.h @@ -30,6 +30,7 @@
static void vkd3d_test_main(int argc, char **argv); static const char *vkd3d_test_name; +static const char *vkd3d_test_platform = "other";
#define START_TEST(name) \ static const char *vkd3d_test_name = #name; \ @@ -53,13 +54,8 @@ static const char *vkd3d_test_name; unsigned int vkd3d_line = line; \ VKD3D_TEST_TODO
-#ifdef _WIN32 -# define VKD3D_TEST_TODO(args...) \ - vkd3d_test_ok(vkd3d_line, args); } while (0) -#else # define VKD3D_TEST_TODO(args...) \ vkd3d_test_todo(vkd3d_line, args); } while (0) -#endif /* _WIN32 */
#define skip_(line) \ do { \ @@ -88,8 +84,14 @@ static struct unsigned int debug_level; } vkd3d_test_state;
-static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED -vkd3d_test_ok(unsigned int line, bool result, const char *fmt, ...) +static bool +vkd3d_test_platform_is_windows(void) +{ + return !strcmp(vkd3d_test_platform, "windows"); +} + +static void +vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list args) { if (result) { @@ -99,33 +101,44 @@ vkd3d_test_ok(unsigned int line, bool result, const char *fmt, ...) } else { - va_list args; - va_start(args, fmt); printf("%s:%d: Test failed: ", vkd3d_test_name, line); vprintf(fmt, args); - va_end(args); InterlockedIncrement(&vkd3d_test_state.failure_count); } }
static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED +vkd3d_test_ok(unsigned int line, bool result, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vkd3d_test_check_ok(line, result, fmt, args); + va_end(args); +} + +static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED vkd3d_test_todo(unsigned int line, bool result, const char *fmt, ...) { va_list args;
- if (result) + va_start(args, fmt); + if (vkd3d_test_platform_is_windows()) + { + vkd3d_test_check_ok(line, result, fmt, args); + } + else if (result) { printf("%s:%d Todo succeeded: ", vkd3d_test_name, line); + vprintf(fmt, args); InterlockedIncrement(&vkd3d_test_state.todo_success_count); } else { printf("%s:%d: Todo: ", vkd3d_test_name, line); + vprintf(fmt, args); InterlockedIncrement(&vkd3d_test_state.todo_count); } - - va_start(args, fmt); - vprintf(fmt, args); va_end(args); }
@@ -177,10 +190,20 @@ vkd3d_test_debug(const char *fmt, ...) int main(int argc, char **argv) { const char *debug_level = getenv("VKD3D_TEST_DEBUG"); + char *test_platform = getenv("VKD3D_TEST_PLATFORM");
memset(&vkd3d_test_state, 0, sizeof(vkd3d_test_state)); vkd3d_test_state.debug_level = !debug_level ? 0 : atoi(debug_level);
+ if (test_platform) + { + test_platform = strdup(test_platform); + vkd3d_test_platform = test_platform; + } + + if (vkd3d_test_state.debug_level > 1) + printf("Test platform: '%s'.\n", vkd3d_test_platform); + vkd3d_test_main(argc, argv);
printf("%s: %lu tests executed (%lu failures, %lu skipped, %lu todo).\n", @@ -193,6 +216,9 @@ int main(int argc, char **argv) (unsigned long)vkd3d_test_state.skip_count, (unsigned long)vkd3d_test_state.todo_count);
+ if (test_platform) + free(test_platform); + return vkd3d_test_state.failure_count || vkd3d_test_state.todo_success_count; }
@@ -225,6 +251,8 @@ int wmain(int argc, WCHAR **wargv) } assert(i == argc);
+ vkd3d_test_platform = "windows"; + ret = main(argc, argv);
for (i = 0; i < argc; ++i) diff --git a/tests/d3d12.c b/tests/d3d12.c index caf94d235148..1d8e62537569 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -5193,11 +5193,12 @@ static void test_bundle_state_inheritance(void) unsigned int x, y; HRESULT hr;
-#ifndef _WIN32 - /* Avoid 2048 test todos. */ - skip("Bundles are not implemented yet.\n"); - return; -#endif + if (!vkd3d_test_platform_is_windows()) + { + /* Avoid 2048 test todos. */ + skip("Bundles are not implemented yet.\n"); + return; + }
if (use_warp_device) {
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/private/vkd3d_test.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/private/vkd3d_test.h b/include/private/vkd3d_test.h index f4a16273b2da..888436ab3e8b 100644 --- a/include/private/vkd3d_test.h +++ b/include/private/vkd3d_test.h @@ -237,6 +237,12 @@ static char *vkd3d_test_strdupWtoA(WCHAR *str) return out; }
+static bool running_under_wine(void) +{ + HMODULE module = GetModuleHandleA("ntdll.dll"); + return module && GetProcAddress(module, "wine_server_call"); +} + int wmain(int argc, WCHAR **wargv) { char **argv; @@ -251,7 +257,7 @@ int wmain(int argc, WCHAR **wargv) } assert(i == argc);
- vkd3d_test_platform = "windows"; + vkd3d_test_platform = running_under_wine() ? "wine" : "windows";
ret = main(argc, argv);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 0684cd32718f..e749873f663b 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -3806,7 +3806,7 @@ static void vkd3d_dxbc_compiler_emit_dot(struct vkd3d_dxbc_compiler *compiler, write_mask = VKD3DSP_WRITEMASK_0 | VKD3DSP_WRITEMASK_1;
assert(instruction->src_count == ARRAY_SIZE(src_ids)); - for (i = 0; i < instruction->src_count; ++i) + for (i = 0; i < ARRAY_SIZE(src_ids); ++i) src_ids[i] = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[i], write_mask);
type_id = vkd3d_spirv_get_type_id(builder,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com