Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
October 2020
- 82 participants
- 1618 messages
Oct. 1, 2020
[PATCH] include: Add DWRITE_MAKE_FONT_AXIS_TAG macro.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
include/dwrite_3.idl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/dwrite_3.idl b/include/dwrite_3.idl
index f5ee6157cd7..1b10454ec60 100644
--- a/include/dwrite_3.idl
+++ b/include/dwrite_3.idl
@@ -80,6 +80,12 @@ typedef struct DWRITE_FONT_PROPERTY
WCHAR const *localeName;
} DWRITE_FONT_PROPERTY;
+cpp_quote("#ifdef __cplusplus")
+cpp_quote("#define DWRITE_MAKE_FONT_AXIS_TAG(a,b,c,d) (static_cast<DWRITE_FONT_AXIS_TAG>(DWRITE_MAKE_OPENTYPE_TAG(a,b,c,d)))")
+cpp_quote("#else")
+cpp_quote("#define DWRITE_MAKE_FONT_AXIS_TAG(a,b,c,d) (DWRITE_MAKE_OPENTYPE_TAG(a,b,c,d))")
+cpp_quote("#endif")
+
typedef enum DWRITE_FONT_AXIS_TAG
{
DWRITE_FONT_AXIS_TAG_WEIGHT = 0x74686777, /* 'wght' */
--
2.28.0
Oct. 1, 2020
[PATCH v2] vcruntime140_1: Terminate on noexcept function trying to propagate exception.
by Daniel Lehman
Signed-off-by: Daniel Lehman <dlehman25(a)gmail.com>
---
v2: handle nested case
this should print 0x42:
wine64 tosend.exe
these should terminate():
wine64 tosend.exe 1
wine64 tosend.exe 1 1
wine64 tosend.exe 1 1 1
/* cl /EHsc /MD noexcept.cpp */
void do_throw(void) { throw int(0x42); }
void crash_without_tries(void) noexcept { do_throw(); }
void crash_with_tries(void) noexcept
{
try { do_throw(); } catch (float e) { /* bogus */ }
}
void crash_nested(void) noexcept
{
try {
try { throw 1; }
catch (int e) { throw; }
}
catch (float f) { /* bogus */ }
}
void works(void) noexcept
{
try { do_throw(); } catch (int e) { printf("0x%x\n", e); }
}
void works_nested(void) noexcept
{
try {
try { throw 1; }
catch (int e) { throw; }
}
catch (...) {
}
}
void works_nested2(void) noexcept
{
try {
try {
try { throw 1; }
catch (int e) { throw; }
}
catch (int e) { throw; }
}
catch (...) {
}
}
int main(int argc, char **argv)
{
try
{
switch (argc)
{
case 4: crash_nested(); break;
case 3: crash_without_tries(); break;
case 2: crash_with_tries(); break;
default:
works();
works_nested();
works_nested2();
break;
}
}
catch (...)
{
printf("%s: should not be printed\n", __FUNCTION__);
}
return 0;
}
---
dlls/vcruntime140_1/except_x86_64.c | 90 ++++++++++++++++-------------
1 file changed, 49 insertions(+), 41 deletions(-)
diff --git a/dlls/vcruntime140_1/except_x86_64.c b/dlls/vcruntime140_1/except_x86_64.c
index f66ae43721f..341f26a20c2 100644
--- a/dlls/vcruntime140_1/except_x86_64.c
+++ b/dlls/vcruntime140_1/except_x86_64.c
@@ -683,56 +683,64 @@ static DWORD cxx_frame_handler4(EXCEPTION_RECORD *rec, ULONG64 frame,
cxx_local_unwind4(orig_frame, dispatch, descr, trylevel, last_level);
return ExceptionContinueSearch;
}
- if (!descr->tryblock_map) return ExceptionContinueSearch;
-
- if (rec->ExceptionCode == CXX_EXCEPTION)
+ if (descr->tryblock_map)
{
- if (!rec->ExceptionInformation[1] && !rec->ExceptionInformation[2])
- {
- TRACE("rethrow detected.\n");
- *rec = *(EXCEPTION_RECORD*)*__current_exception();
- }
-
- exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
-
- if (TRACE_ON(seh))
+ if (rec->ExceptionCode == CXX_EXCEPTION)
{
- TRACE("handling C++ exception rec %p frame %lx descr %p\n", rec, frame, descr);
- dump_exception_type(exc_type, rec->ExceptionInformation[3]);
- }
- }
- else
- {
- _se_translator_function se_translator = get_se_translator();
-
- exc_type = NULL;
- TRACE("handling C exception code %x rec %p frame %lx descr %p\n",
- rec->ExceptionCode, rec, frame, descr);
+ if (!rec->ExceptionInformation[1] && !rec->ExceptionInformation[2])
+ {
+ TRACE("rethrow detected.\n");
+ *rec = *(EXCEPTION_RECORD*)*__current_exception();
+ }
- if (se_translator) {
- EXCEPTION_POINTERS except_ptrs;
- se_translator_ctx ctx;
+ exc_type = (cxx_exception_type *)rec->ExceptionInformation[2];
- ctx.dest_frame = frame;
- ctx.orig_frame = orig_frame;
- ctx.seh_rec = rec;
- ctx.dispatch = dispatch;
- ctx.descr = descr;
- ctx.trylevel = trylevel;
- __TRY
+ if (TRACE_ON(seh))
{
- except_ptrs.ExceptionRecord = rec;
- except_ptrs.ContextRecord = context;
- se_translator(rec->ExceptionCode, &except_ptrs);
+ TRACE("handling C++ exception rec %p frame %lx descr %p\n", rec, frame, descr);
+ dump_exception_type(exc_type, rec->ExceptionInformation[3]);
}
- __EXCEPT_CTX(se_translation_filter, &ctx)
- {
+ }
+ else
+ {
+ _se_translator_function se_translator = get_se_translator();
+
+ exc_type = NULL;
+ TRACE("handling C exception code %x rec %p frame %lx descr %p\n",
+ rec->ExceptionCode, rec, frame, descr);
+
+ if (se_translator) {
+ EXCEPTION_POINTERS except_ptrs;
+ se_translator_ctx ctx;
+
+ ctx.dest_frame = frame;
+ ctx.orig_frame = orig_frame;
+ ctx.seh_rec = rec;
+ ctx.dispatch = dispatch;
+ ctx.descr = descr;
+ ctx.trylevel = trylevel;
+ __TRY
+ {
+ except_ptrs.ExceptionRecord = rec;
+ except_ptrs.ContextRecord = context;
+ se_translator(rec->ExceptionCode, &except_ptrs);
+ }
+ __EXCEPT_CTX(se_translation_filter, &ctx)
+ {
+ }
+ __ENDTRY
}
- __ENDTRY
}
+
+ find_catch_block4(rec, context, NULL, frame, dispatch, descr, exc_type, orig_frame, trylevel);
}
- find_catch_block4(rec, context, NULL, frame, dispatch, descr, exc_type, orig_frame, trylevel);
+ if ((descr->header & FUNC_DESCR_NO_EXCEPT) &&
+ !(descr->header & FUNC_DESCR_IS_CATCH))
+ {
+ ERR("noexcept function propagating exception\n");
+ terminate();
+ }
return ExceptionContinueSearch;
}
@@ -759,7 +767,7 @@ EXCEPTION_DISPOSITION __cdecl __CxxFrameHandler4(EXCEPTION_RECORD *rec,
return ExceptionContinueSearch; /* handle only c++ exceptions */
if (descr.header & ~(FUNC_DESCR_IS_CATCH | FUNC_DESCR_UNWIND_MAP |
- FUNC_DESCR_TRYBLOCK_MAP | FUNC_DESCR_EHS))
+ FUNC_DESCR_TRYBLOCK_MAP | FUNC_DESCR_EHS | FUNC_DESCR_NO_EXCEPT))
{
FIXME("unsupported flags: %x\n", descr.header);
return ExceptionContinueSearch;
--
2.25.1
Oct. 1, 2020
[PATCH vkd3d 5/5] tests: Import vector indexing tests from Wine.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
Makefile.am | 6 ++++++
tests/hlsl-vector-indexing-uniform.shader_test | 16 ++++++++++++++++
tests/hlsl-vector-indexing.shader_test | 14 ++++++++++++++
tests/shader_runner_d3d12.c | 15 +++++++++++++++
4 files changed, 51 insertions(+)
create mode 100644 tests/hlsl-vector-indexing-uniform.shader_test
create mode 100644 tests/hlsl-vector-indexing.shader_test
diff --git a/Makefile.am b/Makefile.am
index bb69078c..27bc00b6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,6 +50,9 @@ vkd3d_shader_runners = \
tests/shader_runner_d3d12
vkd3d_shader_tests = \
+ tests/conditional.shader_test \
+ tests/hlsl-vector-indexing.shader_test \
+ tests/hlsl-vector-indexing-uniform.shader_test \
tests/math.shader_test \
tests/swizzle-0.shader_test \
tests/swizzle-1.shader_test \
@@ -178,6 +181,9 @@ tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la
SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12
XFAIL_TESTS = \
+ tests/conditional.shader_test \
+ tests/hlsl-vector-indexing.shader_test \
+ tests/hlsl-vector-indexing-uniform.shader_test \
tests/math.shader_test \
tests/swizzle-0.shader_test \
tests/swizzle-1.shader_test \
diff --git a/tests/hlsl-vector-indexing-uniform.shader_test b/tests/hlsl-vector-indexing-uniform.shader_test
new file mode 100644
index 00000000..2556b589
--- /dev/null
+++ b/tests/hlsl-vector-indexing-uniform.shader_test
@@ -0,0 +1,16 @@
+# Use a uniform to prevent the compiler from optimizing.
+
+[pixel shader]
+uniform int i;
+float4 main() : SV_TARGET
+{
+ float4 color = float4(0.5, 0.4, 0.3, 0.2);
+ color.g = color[i];
+ color.b = 0.8;
+ return color;
+}
+
+[test]
+uniform 0 uint 2
+draw quad
+probe all rgba (0.5, 0.3, 0.8, 0.2)
diff --git a/tests/hlsl-vector-indexing.shader_test b/tests/hlsl-vector-indexing.shader_test
new file mode 100644
index 00000000..b641d7f9
--- /dev/null
+++ b/tests/hlsl-vector-indexing.shader_test
@@ -0,0 +1,14 @@
+[pixel shader]
+float4 main() : SV_TARGET
+{
+ float4 color;
+ color[0] = 0.020;
+ color[1] = 0.245;
+ color[2] = 0.351;
+ color[3] = 1.0;
+ return color;
+}
+
+[test]
+draw quad
+probe all rgba (0.02, 0.245, 0.351, 1.0)
diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c
index e429d384..709fc006 100644
--- a/tests/shader_runner_d3d12.c
+++ b/tests/shader_runner_d3d12.c
@@ -211,6 +211,18 @@ static void parse_test_directive(struct shader_context *context, const char *lin
}
memcpy(context->uniforms + offset, &v, sizeof(v));
}
+ else if (match_string(line, "uint", &line))
+ {
+ unsigned int u;
+
+ sscanf(line, "%u", &u);
+ if (offset + 1 > context->uniform_count)
+ {
+ context->uniform_count = offset + 1;
+ context->uniforms = realloc(context->uniforms, context->uniform_count * sizeof(*context->uniforms));
+ }
+ memcpy(context->uniforms + offset, &u, sizeof(u));
+ }
}
else
{
@@ -271,6 +283,9 @@ START_TEST(shader_runner_d3d12)
while (fgets(line, sizeof(line), f))
{
+ if (line[0] == '\n')
+ continue;
+
if (line[0] == '[')
{
switch (state)
--
2.28.0
Oct. 1, 2020
[PATCH vkd3d 4/5] tests: Import HLSL conditional tests from Wine.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
tests/conditional.shader_test | 13 +++++++++
tests/d3d12_test_utils.h | 51 +++++++++++++++++++++--------------
tests/shader_runner_d3d12.c | 25 +++++++++++++++++
3 files changed, 69 insertions(+), 20 deletions(-)
create mode 100644 tests/conditional.shader_test
diff --git a/tests/conditional.shader_test b/tests/conditional.shader_test
new file mode 100644
index 00000000..70718f11
--- /dev/null
+++ b/tests/conditional.shader_test
@@ -0,0 +1,13 @@
+[pixel shader]
+float4 main(float4 pos : SV_POSITION) : SV_TARGET
+{
+ if(pos.x > 200.0)
+ return float4(0.1, 0.2, 0.3, 0.4);
+ else
+ return float4(0.9, 0.8, 0.7, 0.6);
+}
+
+[test]
+draw quad
+probe rect rgba (0, 0, 200, 480) (0.9, 0.8, 0.7, 0.6)
+probe rect rgba (200, 0, 440, 480) (0.1, 0.2, 0.3, 0.4)
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index ece48966..a1e039de 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -585,6 +585,36 @@ static void check_readback_data_uint_(unsigned int line, struct resource_readbac
ok_(line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z);
}
+#define check_readback_data_vec4(a, b, c, d) check_readback_data_vec4_(__LINE__, a, b, c, d)
+static void check_readback_data_vec4_(unsigned int line, struct resource_readback *rb,
+ const RECT *rect, const struct vec4 *expected, unsigned int max_diff)
+{
+ RECT r = {0, 0, rb->width, rb->height};
+ unsigned int x = 0, y = 0;
+ struct vec4 got = {0};
+ bool all_match = true;
+
+ if (rect)
+ r = *rect;
+
+ for (y = r.top; y < r.bottom; ++y)
+ {
+ for (x = r.left; x < r.right; ++x)
+ {
+ got = *get_readback_vec4(rb, x, y);
+ if (!compare_vec4(&got, expected, max_diff))
+ {
+ all_match = false;
+ break;
+ }
+ }
+ if (!all_match)
+ break;
+ }
+ ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
+ got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
+}
+
#define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__LINE__, a, b, c, d, e, f)
static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
@@ -603,29 +633,10 @@ static inline void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *t
const struct vec4 *expected, unsigned int max_diff)
{
struct resource_readback rb;
- unsigned int x = 0, y;
- bool all_match = true;
- struct vec4 got = {0};
get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
- for (y = 0; y < rb.height; ++y)
- {
- for (x = 0; x < rb.width; ++x)
- {
- got = *get_readback_vec4(&rb, x, y);
- if (!compare_vec4(&got, expected, max_diff))
- {
- all_match = false;
- break;
- }
- }
- if (!all_match)
- break;
- }
+ check_readback_data_vec4_(line, &rb, NULL, expected, max_diff);
release_resource_readback(&rb);
-
- ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
- got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
}
#define create_default_buffer(a, b, c, d) create_default_buffer_(__LINE__, a, b, c, d)
diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c
index f323a547..e429d384 100644
--- a/tests/shader_runner_d3d12.c
+++ b/tests/shader_runner_d3d12.c
@@ -167,6 +167,29 @@ static void parse_test_directive(struct shader_context *context, const char *lin
check_sub_resource_vec4(context->c.render_target, 0, context->c.queue, context->c.list, &v, ulps);
reset_command_list(context->c.list, context->c.allocator);
}
+ else if (match_string(line, "probe rect rgba", &line))
+ {
+ unsigned int x, y, w, h, ulps;
+ struct resource_readback rb;
+ struct vec4 v;
+ RECT rect;
+ int ret;
+
+ ret = sscanf(line, "( %u , %u , %u , %u ) ( %f , %f , %f , %f )", &x, &y, &w, &h, &v.x, &v.y, &v.z, &v.w);
+ if (ret < 8)
+ goto err;
+ if (ret < 9)
+ ulps = 0;
+
+ get_texture_readback_with_command_list(context->c.render_target, 0, &rb, context->c.queue, context->c.list);
+ rect.left = x;
+ rect.right = x + w;
+ rect.top = y;
+ rect.bottom = y + h;
+ check_readback_data_vec4(&rb, &rect, &v, ulps);
+ release_resource_readback(&rb);
+ reset_command_list(context->c.list, context->c.allocator);
+ }
else if (match_string(line, "uniform", &line))
{
unsigned int offset;
@@ -204,6 +227,8 @@ START_TEST(shader_runner_d3d12)
{
static const struct test_context_desc desc =
{
+ .rt_width = 640,
+ .rt_height = 480,
.no_root_signature = true,
.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT,
};
--
2.28.0
Oct. 1, 2020
[PATCH vkd3d 3/5] tests: Import math tests from Wine.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
Makefile.am | 2 ++
tests/math.shader_test | 15 +++++++++++++++
2 files changed, 17 insertions(+)
create mode 100644 tests/math.shader_test
diff --git a/Makefile.am b/Makefile.am
index 958be146..bb69078c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,6 +50,7 @@ vkd3d_shader_runners = \
tests/shader_runner_d3d12
vkd3d_shader_tests = \
+ tests/math.shader_test \
tests/swizzle-0.shader_test \
tests/swizzle-1.shader_test \
tests/swizzle-2.shader_test \
@@ -177,6 +178,7 @@ tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la
SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12
XFAIL_TESTS = \
+ tests/math.shader_test \
tests/swizzle-0.shader_test \
tests/swizzle-1.shader_test \
tests/swizzle-2.shader_test \
diff --git a/tests/math.shader_test b/tests/math.shader_test
new file mode 100644
index 00000000..2fe59a08
--- /dev/null
+++ b/tests/math.shader_test
@@ -0,0 +1,15 @@
+[pixel shader]
+float4 main(uniform float u, uniform float v, uniform float w, uniform float x,
+ uniform float y, uniform float z) : SV_TARGET
+{
+ return float4(x * y - z / w + --u / -v,
+ z * x / y + w / -v,
+ u + v - w,
+ x / y / w);
+}
+
+[test]
+uniform 0 float4 2.5 0.3 0.2 0.7
+uniform 4 float4 0.1 1.5 0.0 0.0
+draw quad
+probe all rgba (-12.43, 9.833333, 1.6, 35.0) 1
--
2.28.0
Oct. 1, 2020
[PATCH vkd3d 2/5] tests: Import HLSL swizzle tests from Wine.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
Makefile.am | 21 ++++++++++++++++++++-
tests/swizzle-0.shader_test | 15 +++++++++++++++
tests/swizzle-1.shader_test | 11 +++++++++++
tests/swizzle-2.shader_test | 11 +++++++++++
tests/swizzle-3.shader_test | 14 ++++++++++++++
tests/swizzle-4.shader_test | 13 +++++++++++++
tests/swizzle-5.shader_test | 10 ++++++++++
tests/swizzle-6.shader_test | 12 ++++++++++++
tests/swizzle-7.shader_test | 11 +++++++++++
9 files changed, 117 insertions(+), 1 deletion(-)
create mode 100644 tests/swizzle-0.shader_test
create mode 100644 tests/swizzle-1.shader_test
create mode 100644 tests/swizzle-2.shader_test
create mode 100644 tests/swizzle-3.shader_test
create mode 100644 tests/swizzle-4.shader_test
create mode 100644 tests/swizzle-5.shader_test
create mode 100644 tests/swizzle-6.shader_test
create mode 100644 tests/swizzle-7.shader_test
diff --git a/Makefile.am b/Makefile.am
index 5e2ea3ea..958be146 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,6 +49,16 @@ vkd3d_cross_tests = \
vkd3d_shader_runners = \
tests/shader_runner_d3d12
+vkd3d_shader_tests = \
+ tests/swizzle-0.shader_test \
+ tests/swizzle-1.shader_test \
+ tests/swizzle-2.shader_test \
+ tests/swizzle-3.shader_test \
+ tests/swizzle-4.shader_test \
+ tests/swizzle-5.shader_test \
+ tests/swizzle-6.shader_test \
+ tests/swizzle-7.shader_test
+
vkd3d_test_headers = \
tests/d3d12_crosstest.h \
tests/d3d12_test_utils.h
@@ -159,13 +169,22 @@ TEST_EXTENSIONS = .shader_test
if BUILD_TESTS
check_PROGRAMS = $(vkd3d_tests) $(vkd3d_cross_tests) $(vkd3d_shader_runners)
-TESTS = $(vkd3d_tests) $(vkd3d_cross_tests)
+TESTS = $(vkd3d_tests) $(vkd3d_cross_tests) $(vkd3d_shader_tests)
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @VULKAN_LIBS@
tests_d3d12_invalid_usage_LDADD = $(LDADD) @VULKAN_LIBS@
tests_shader_runner_d3d12_LDADD = $(LDADD) @VULKAN_LIBS@
tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la
SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12
+XFAIL_TESTS = \
+ tests/swizzle-0.shader_test \
+ tests/swizzle-1.shader_test \
+ tests/swizzle-2.shader_test \
+ tests/swizzle-3.shader_test \
+ tests/swizzle-4.shader_test \
+ tests/swizzle-5.shader_test \
+ tests/swizzle-6.shader_test \
+ tests/swizzle-7.shader_test
endif
if BUILD_DEMOS
diff --git a/tests/swizzle-0.shader_test b/tests/swizzle-0.shader_test
new file mode 100644
index 00000000..9be141cf
--- /dev/null
+++ b/tests/swizzle-0.shader_test
@@ -0,0 +1,15 @@
+[pixel shader]
+uniform float4 color;
+
+float4 main() : sv_target
+{
+ float4 ret = color;
+ ret.gb = ret.ra;
+ ret.ra = float2(0.0101, 0.0404);
+ return ret;
+}
+
+[test]
+uniform 0 float4 0.0303 0.08 0.07 0.0202
+draw quad
+probe all rgba (0.0101, 0.0303, 0.0202, 0.0404)
diff --git a/tests/swizzle-1.shader_test b/tests/swizzle-1.shader_test
new file mode 100644
index 00000000..40cdc010
--- /dev/null
+++ b/tests/swizzle-1.shader_test
@@ -0,0 +1,11 @@
+[pixel shader]
+float4 main() : SV_target
+{
+ float4 ret = float4(0.1, 0.2, 0.3, 0.4);
+ ret.wyz.yx = float2(0.5, 0.6).yx;
+ return ret;
+}
+
+[test]
+draw quad
+probe all rgba (0.1, 0.6, 0.3, 0.5)
diff --git a/tests/swizzle-2.shader_test b/tests/swizzle-2.shader_test
new file mode 100644
index 00000000..b07134c6
--- /dev/null
+++ b/tests/swizzle-2.shader_test
@@ -0,0 +1,11 @@
+[pixel shader]
+float4 main() : SV_target
+{
+ float4 ret;
+ ret.zwyx = float4(0.1, 0.2, 0.3, 0.4);
+ return ret;
+}
+
+[test]
+draw quad
+probe all rgba (0.4, 0.3, 0.1, 0.2)
diff --git a/tests/swizzle-3.shader_test b/tests/swizzle-3.shader_test
new file mode 100644
index 00000000..1ecf5a5c
--- /dev/null
+++ b/tests/swizzle-3.shader_test
@@ -0,0 +1,14 @@
+[pixel shader]
+float4 main() : SV_target
+{
+ float4 ret;
+ ret.yw.y = 0.1;
+ ret.xzy.yz.y.x = 0.2;
+ ret.yzwx.yzwx.wz.y = 0.3;
+ ret.zxy.xyz.zxy.xy.y = 0.4;
+ return ret;
+}
+
+[test]
+draw quad
+probe all rgba (0.3, 0.2, 0.4, 0.1)
diff --git a/tests/swizzle-4.shader_test b/tests/swizzle-4.shader_test
new file mode 100644
index 00000000..c09fa515
--- /dev/null
+++ b/tests/swizzle-4.shader_test
@@ -0,0 +1,13 @@
+[pixel shader]
+float4 main() : SV_target
+{
+ float4 ret;
+ ret.yxz.yx = float2(0.1, 0.2);
+ ret.w.x = 0.3;
+ ret.wzyx.zyx.yx.x = 0.4;
+ return ret;
+}
+
+[test]
+draw quad
+probe all rgba (0.1, 0.2, 0.4, 0.3)
diff --git a/tests/swizzle-5.shader_test b/tests/swizzle-5.shader_test
new file mode 100644
index 00000000..5a3ee1db
--- /dev/null
+++ b/tests/swizzle-5.shader_test
@@ -0,0 +1,10 @@
+[pixel shader]
+float4 main() : SV_target
+{
+ float4 ret = float4(0.1, 0.2, 0.3, 0.4).ywxz.zyyz;
+ return ret;
+}
+
+[test]
+draw quad
+probe all rgba (0.1, 0.4, 0.4, 0.1)
diff --git a/tests/swizzle-6.shader_test b/tests/swizzle-6.shader_test
new file mode 100644
index 00000000..04251c65
--- /dev/null
+++ b/tests/swizzle-6.shader_test
@@ -0,0 +1,12 @@
+[pixel shader]
+float4 main() : SV_target
+{
+ float4 ret = float4(0.1, 0.2, 0.3, 0.4);
+ ret.yxwz = ret;
+ ret = ret.wyzx;
+ return ret;
+}
+
+[test]
+draw quad
+probe all rgba (0.3, 0.1, 0.4, 0.2)
diff --git a/tests/swizzle-7.shader_test b/tests/swizzle-7.shader_test
new file mode 100644
index 00000000..15a4cd07
--- /dev/null
+++ b/tests/swizzle-7.shader_test
@@ -0,0 +1,11 @@
+[pixel shader]
+float4 main() : SV_target
+{
+ float4 ret;
+ ret.xyzw.xyzw = float4(0.1, 0.2, 0.3, 0.4);
+ return ret;
+}
+
+[test]
+draw quad
+probe all rgba (0.1, 0.2, 0.3, 0.4)
--
2.28.0
Oct. 1, 2020
[PATCH vkd3d v2 1/5] tests: Introduce a custom format and parser for shader-based tests.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
Makefile.am | 18 ++-
tests/.gitignore | 1 +
tests/d3d12.c | 101 ------------
tests/d3d12_crosstest.h | 1 +
tests/d3d12_test_utils.h | 103 ++++++++++++-
tests/shader_runner_d3d12.c | 300 ++++++++++++++++++++++++++++++++++++
6 files changed, 417 insertions(+), 107 deletions(-)
create mode 100644 tests/shader_runner_d3d12.c
diff --git a/Makefile.am b/Makefile.am
index 22a245e9..5e2ea3ea 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,6 +46,9 @@ vkd3d_cross_tests = \
tests/d3d12 \
tests/d3d12_invalid_usage
+vkd3d_shader_runners = \
+ tests/shader_runner_d3d12
+
vkd3d_test_headers = \
tests/d3d12_crosstest.h \
tests/d3d12_test_utils.h
@@ -151,13 +154,18 @@ vkd3d_compiler_LDADD = libvkd3d-shader.la @NCURSES_LIBS@
LDADD = libvkd3d.la libvkd3d-utils.la
AM_DEFAULT_SOURCE_EXT = .c
+
+TEST_EXTENSIONS = .shader_test
+
if BUILD_TESTS
-check_PROGRAMS = $(vkd3d_tests) $(vkd3d_cross_tests)
+check_PROGRAMS = $(vkd3d_tests) $(vkd3d_cross_tests) $(vkd3d_shader_runners)
TESTS = $(vkd3d_tests) $(vkd3d_cross_tests)
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @VULKAN_LIBS@
tests_d3d12_invalid_usage_LDADD = $(LDADD) @VULKAN_LIBS@
+tests_shader_runner_d3d12_LDADD = $(LDADD) @VULKAN_LIBS@
tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@
tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la
+SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12
endif
if BUILD_DEMOS
@@ -239,7 +247,7 @@ if HAVE_CROSSTARGET32
CROSS32_CC = @CROSSCC32@
CROSS32_DLLTOOL = @CROSSTARGET32(a)-dlltool
CROSS32_IMPLIBS = $(cross_implibs:=.cross32.a)
-CROSS32_EXEFILES = $(vkd3d_cross_tests:=.cross32.exe) $(vkd3d_demos:=.cross32.exe)
+CROSS32_EXEFILES = $(vkd3d_cross_tests:=.cross32.exe) $(vkd3d_demos:=.cross32.exe) $(vkd3d_shader_runners:=.cross32.exe)
CROSS32_FILES = $(CROSS32_IMPLIBS) $(CROSS32_EXEFILES)
CLEANFILES += $(CROSS32_FILES)
@@ -254,7 +262,7 @@ $(CROSS32_IMPLIBS): %.cross32.a: %.cross32.def
$(CROSS32_EXEFILES): %.cross32.exe: %.c $(CROSS32_IMPLIBS) $(widl_headers)
$(AM_V_CCLD)depbase=`echo $@ | $(SED) 's![^/]*$$!$(DEPDIR)/&!;s!\.exe$$!!'`; \
- $(CROSS32_CC) $(CROSS_CFLAGS) -MT $@ -MD -MP -MF $$depbase.Tpo -o $@ $< $(CROSS32_IMPLIBS) -ldxgi -lgdi32 && \
+ $(CROSS32_CC) $(CROSS_CFLAGS) -MT $@ -MD -MP -MF $$depbase.Tpo -o $@ $< $(CROSS32_IMPLIBS) -ldxgi -lgdi32 -ld3dcompiler_47 && \
$(am__mv) $$depbase.Tpo $$depbase.Po
else
crosstest32:
@@ -264,7 +272,7 @@ if HAVE_CROSSTARGET64
CROSS64_CC = @CROSSCC64@
CROSS64_DLLTOOL = @CROSSTARGET64(a)-dlltool
CROSS64_IMPLIBS = $(cross_implibs:=.cross64.a)
-CROSS64_EXEFILES = $(vkd3d_cross_tests:=.cross64.exe) $(vkd3d_demos:=.cross64.exe)
+CROSS64_EXEFILES = $(vkd3d_cross_tests:=.cross64.exe) $(vkd3d_demos:=.cross64.exe) $(vkd3d_shader_runners:=.cross64.exe)
CROSS64_FILES = $(CROSS64_IMPLIBS) $(CROSS64_EXEFILES)
CLEANFILES += $(CROSS64_FILES)
@@ -279,7 +287,7 @@ $(CROSS64_IMPLIBS): %.cross64.a: %.cross64.def
$(CROSS64_EXEFILES): %.cross64.exe: %.c $(CROSS64_IMPLIBS) $(widl_headers)
$(AM_V_CCLD)depbase=`echo $@ | sed 's![^/]*$$!$(DEPDIR)/&!;s!\.exe$$!!'`; \
- $(CROSS64_CC) $(CROSS_CFLAGS) -MT $@ -MD -MP -MF $$depbase.Tpo -o $@ $< $(CROSS64_IMPLIBS) -ldxgi -lgdi32 && \
+ $(CROSS64_CC) $(CROSS_CFLAGS) -MT $@ -MD -MP -MF $$depbase.Tpo -o $@ $< $(CROSS64_IMPLIBS) -ldxgi -lgdi32 -ld3dcompiler_47 && \
$(am__mv) $$depbase.Tpo $$depbase.Po
else
crosstest64:
diff --git a/tests/.gitignore b/tests/.gitignore
index 1854d55b..94d003dd 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,5 +1,6 @@
/d3d12
/d3d12_invalid_usage
+/shader_runner_d3d12
/vkd3d_api
/vkd3d_common
/vkd3d_shader_api
diff --git a/tests/d3d12.c b/tests/d3d12.c
index f0b2d545..5554178e 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -31,11 +31,6 @@ struct vec2
float x, y;
};
-struct vec4
-{
- float x, y, z, w;
-};
-
struct uvec4
{
unsigned int x, y, z, w;
@@ -46,39 +41,6 @@ struct ivec4
int x, y, z, w;
};
-static bool compare_float(float f, float g, unsigned int ulps)
-{
- int x, y;
- union
- {
- float f;
- int i;
- } u;
-
- u.f = f;
- x = u.i;
- u.f = g;
- y = u.i;
-
- if (x < 0)
- x = INT_MIN - x;
- if (y < 0)
- y = INT_MIN - y;
-
- if (abs(x - y) > ulps)
- return false;
-
- return true;
-}
-
-static bool compare_vec4(const struct vec4 *v1, const struct vec4 *v2, unsigned int ulps)
-{
- return compare_float(v1->x, v2->x, ulps)
- && compare_float(v1->y, v2->y, ulps)
- && compare_float(v1->z, v2->z, ulps)
- && compare_float(v1->w, v2->w, ulps);
-}
-
static bool compare_uvec4(const struct uvec4* v1, const struct uvec4 *v2)
{
return v1->x == v2->x && v1->y == v2->y && v1->z == v2->z && v1->w == v2->w;
@@ -408,11 +370,6 @@ static float get_readback_float(struct resource_readback *rb, unsigned int x, un
return *(float *)get_readback_data(rb, x, y, 0, sizeof(float));
}
-static const struct vec4 *get_readback_vec4(struct resource_readback *rb, unsigned int x, unsigned int y)
-{
- return get_readback_data(rb, x, y, 0, sizeof(struct vec4));
-}
-
static const struct uvec4 *get_readback_uvec4(struct resource_readback *rb, unsigned int x, unsigned int y)
{
return get_readback_data(rb, x, y, 0, sizeof(struct uvec4));
@@ -582,37 +539,6 @@ static void check_sub_resource_uint64_(unsigned int line, ID3D12Resource *textur
release_resource_readback(&rb);
}
-#define check_sub_resource_vec4(a, b, c, d, e, f) check_sub_resource_vec4_(__LINE__, a, b, c, d, e, f)
-static void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *texture,
- unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
- const struct vec4 *expected, unsigned int max_diff)
-{
- struct resource_readback rb;
- unsigned int x = 0, y;
- bool all_match = true;
- struct vec4 got = {0};
-
- get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
- for (y = 0; y < rb.height; ++y)
- {
- for (x = 0; x < rb.width; ++x)
- {
- got = *get_readback_vec4(&rb, x, y);
- if (!compare_vec4(&got, expected, max_diff))
- {
- all_match = false;
- break;
- }
- }
- if (!all_match)
- break;
- }
- release_resource_readback(&rb);
-
- ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
- got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
-}
-
#define check_sub_resource_uvec4(a, b, c, d, e) check_sub_resource_uvec4_(__LINE__, a, b, c, d, e)
static void check_sub_resource_uvec4_(unsigned int line, ID3D12Resource *texture,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
@@ -750,33 +676,6 @@ static ID3D12RootSignature *create_cb_root_signature_(unsigned int line,
return root_signature;
}
-#define create_32bit_constants_root_signature(a, b, c, e) \
- create_32bit_constants_root_signature_(__LINE__, a, b, c, e, 0)
-static ID3D12RootSignature *create_32bit_constants_root_signature_(unsigned int line,
- ID3D12Device *device, unsigned int reg_idx, unsigned int element_count,
- D3D12_SHADER_VISIBILITY shader_visibility, D3D12_ROOT_SIGNATURE_FLAGS flags)
-{
- D3D12_ROOT_SIGNATURE_DESC root_signature_desc;
- ID3D12RootSignature *root_signature = NULL;
- D3D12_ROOT_PARAMETER root_parameter;
- HRESULT hr;
-
- root_parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
- root_parameter.Constants.ShaderRegister = reg_idx;
- root_parameter.Constants.RegisterSpace = 0;
- root_parameter.Constants.Num32BitValues = element_count;
- root_parameter.ShaderVisibility = shader_visibility;
-
- memset(&root_signature_desc, 0, sizeof(root_signature_desc));
- root_signature_desc.NumParameters = 1;
- root_signature_desc.pParameters = &root_parameter;
- root_signature_desc.Flags = flags;
- hr = create_root_signature(device, &root_signature_desc, &root_signature);
- ok_(line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr);
-
- return root_signature;
-}
-
#define create_texture_root_signature(a, b, c, d) create_texture_root_signature_(__LINE__, a, b, c, d, NULL)
static ID3D12RootSignature *create_texture_root_signature_(unsigned int line,
ID3D12Device *device, D3D12_SHADER_VISIBILITY shader_visibility,
diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h
index 7ff835ad..f7a31804 100644
--- a/tests/d3d12_crosstest.h
+++ b/tests/d3d12_crosstest.h
@@ -46,6 +46,7 @@ typedef int HRESULT;
#define WIDL_C_INLINE_WRAPPERS
#include "vkd3d_d3d12.h"
#include "vkd3d_d3d12sdklayers.h"
+#include "vkd3d_d3dcompiler.h"
#include <inttypes.h>
#include <limits.h>
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index e4c8e586..ece48966 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -19,6 +19,11 @@
#ifndef __VKD3D_D3D12_TEST_UTILS_H
#define __VKD3D_D3D12_TEST_UTILS_H
+struct vec4
+{
+ float x, y, z, w;
+};
+
#define wait_queue_idle(a, b) wait_queue_idle_(__LINE__, a, b)
static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue);
static ID3D12Device *create_device(void);
@@ -53,6 +58,31 @@ static void set_viewport(D3D12_VIEWPORT *vp, float x, float y,
vp->MaxDepth = max_depth;
}
+static bool compare_float(float f, float g, unsigned int ulps)
+{
+ int x, y;
+ union
+ {
+ float f;
+ int i;
+ } u;
+
+ u.f = f;
+ x = u.i;
+ u.f = g;
+ y = u.i;
+
+ if (x < 0)
+ x = INT_MIN - x;
+ if (y < 0)
+ y = INT_MIN - y;
+
+ if (abs(x - y) > ulps)
+ return false;
+
+ return true;
+}
+
static bool compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
{
unsigned int diff = x > y ? x - y : y - x;
@@ -68,6 +98,14 @@ static bool compare_color(DWORD c1, DWORD c2, BYTE max_diff)
&& compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff);
}
+static bool compare_vec4(const struct vec4 *v1, const struct vec4 *v2, unsigned int ulps)
+{
+ return compare_float(v1->x, v2->x, ulps)
+ && compare_float(v1->y, v2->y, ulps)
+ && compare_float(v1->z, v2->z, ulps)
+ && compare_float(v1->w, v2->w, ulps);
+}
+
static D3D12_SHADER_BYTECODE shader_bytecode(const DWORD *code, size_t size)
{
D3D12_SHADER_BYTECODE shader_bytecode = { code, size };
@@ -501,6 +539,11 @@ static unsigned int get_readback_uint(struct resource_readback *rb,
return *(unsigned int *)get_readback_data(rb, x, y, z, sizeof(unsigned int));
}
+static const struct vec4 *get_readback_vec4(struct resource_readback *rb, unsigned int x, unsigned int y)
+{
+ return get_readback_data(rb, x, y, 0, sizeof(struct vec4));
+}
+
static void release_resource_readback(struct resource_readback *rb)
{
D3D12_RANGE range = {0, 0};
@@ -554,6 +597,37 @@ static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *t
release_resource_readback(&rb);
}
+#define check_sub_resource_vec4(a, b, c, d, e, f) check_sub_resource_vec4_(__LINE__, a, b, c, d, e, f)
+static inline void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *texture,
+ unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
+ const struct vec4 *expected, unsigned int max_diff)
+{
+ struct resource_readback rb;
+ unsigned int x = 0, y;
+ bool all_match = true;
+ struct vec4 got = {0};
+
+ get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
+ for (y = 0; y < rb.height; ++y)
+ {
+ for (x = 0; x < rb.width; ++x)
+ {
+ got = *get_readback_vec4(&rb, x, y);
+ if (!compare_vec4(&got, expected, max_diff))
+ {
+ all_match = false;
+ break;
+ }
+ }
+ if (!all_match)
+ break;
+ }
+ release_resource_readback(&rb);
+
+ ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
+ got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
+}
+
#define create_default_buffer(a, b, c, d) create_default_buffer_(__LINE__, a, b, c, d)
static inline ID3D12Resource *create_default_buffer_(unsigned int line, ID3D12Device *device,
size_t size, D3D12_RESOURCE_FLAGS resource_flags, D3D12_RESOURCE_STATES initial_resource_state)
@@ -595,7 +669,7 @@ static ID3D12Resource *create_default_texture_(unsigned int line, ID3D12Device *
#define create_default_texture(a, b, c, d, e, f) create_default_texture2d_(__LINE__, a, b, c, 1, 1, d, e, f)
#define create_default_texture2d(a, b, c, d, e, f, g, h) create_default_texture2d_(__LINE__, a, b, c, d, e, f, g, h)
-static ID3D12Resource *create_default_texture2d_(unsigned int line, ID3D12Device *device,
+static inline ID3D12Resource *create_default_texture2d_(unsigned int line, ID3D12Device *device,
unsigned int width, unsigned int height, unsigned int array_size, unsigned int miplevel_count,
DXGI_FORMAT format, D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES initial_state)
{
@@ -646,6 +720,33 @@ static ID3D12RootSignature *create_empty_root_signature_(unsigned int line,
return root_signature;
}
+#define create_32bit_constants_root_signature(a, b, c, e) \
+ create_32bit_constants_root_signature_(__LINE__, a, b, c, e, 0)
+static inline ID3D12RootSignature *create_32bit_constants_root_signature_(unsigned int line,
+ ID3D12Device *device, unsigned int reg_idx, unsigned int element_count,
+ D3D12_SHADER_VISIBILITY shader_visibility, D3D12_ROOT_SIGNATURE_FLAGS flags)
+{
+ D3D12_ROOT_SIGNATURE_DESC root_signature_desc;
+ ID3D12RootSignature *root_signature = NULL;
+ D3D12_ROOT_PARAMETER root_parameter;
+ HRESULT hr;
+
+ root_parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
+ root_parameter.Constants.ShaderRegister = reg_idx;
+ root_parameter.Constants.RegisterSpace = 0;
+ root_parameter.Constants.Num32BitValues = element_count;
+ root_parameter.ShaderVisibility = shader_visibility;
+
+ memset(&root_signature_desc, 0, sizeof(root_signature_desc));
+ root_signature_desc.NumParameters = 1;
+ root_signature_desc.pParameters = &root_parameter;
+ root_signature_desc.Flags = flags;
+ hr = create_root_signature(device, &root_signature_desc, &root_signature);
+ ok_(line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr);
+
+ return root_signature;
+}
+
static void init_pipeline_state_desc(D3D12_GRAPHICS_PIPELINE_STATE_DESC *desc,
ID3D12RootSignature *root_signature, DXGI_FORMAT rt_format,
const D3D12_SHADER_BYTECODE *vs, const D3D12_SHADER_BYTECODE *ps,
diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c
new file mode 100644
index 00000000..f323a547
--- /dev/null
+++ b/tests/shader_runner_d3d12.c
@@ -0,0 +1,300 @@
+/*
+ * Copyright 2020 Zebediah Figura for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/*
+ * This application contains code derived from piglit, the license for which
+ * follows:
+ *
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "d3d12_crosstest.h"
+#include <errno.h>
+
+static bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
+{
+ size_t new_capacity, max_capacity;
+ void *new_elements;
+
+ if (element_count <= *capacity)
+ return true;
+
+ max_capacity = ~(size_t)0 / element_size;
+ if (max_capacity < element_count)
+ return false;
+
+ new_capacity = max(*capacity, 4);
+ while (new_capacity < element_count && new_capacity <= max_capacity / 2)
+ new_capacity *= 2;
+
+ if (new_capacity < element_count)
+ new_capacity = element_count;
+
+ if (!(new_elements = realloc(*elements, new_capacity * element_size)))
+ return false;
+
+ *elements = new_elements;
+ *capacity = new_capacity;
+
+ return true;
+}
+
+struct shader_context
+{
+ struct test_context c;
+
+ ID3D10Blob *ps_code;
+
+ uint32_t *uniforms;
+ size_t uniform_count;
+};
+
+static ID3D10Blob *compile_shader(const char *source, const char *target)
+{
+ ID3D10Blob *blob = NULL, *errors = NULL;
+ HRESULT hr;
+
+ hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, 0, 0, &blob, &errors);
+ ok(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr);
+ if (errors)
+ {
+ if (vkd3d_test_state.debug_level)
+ trace("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
+ ID3D10Blob_Release(errors);
+ }
+ return blob;
+}
+
+enum parse_state
+{
+ STATE_NONE,
+ STATE_SHADER_PIXEL,
+ STATE_TEST,
+};
+
+static bool match_string(const char *line, const char *token, const char **const rest)
+{
+ size_t len = strlen(token);
+
+ if (strncmp(line, token, len) || !isspace(line[len]))
+ return false;
+ if (rest)
+ {
+ *rest = line + len;
+ while (isspace(**rest))
+ ++*rest;
+ }
+ return true;
+}
+
+static void parse_test_directive(struct shader_context *context, const char *line)
+{
+ const char *const orig_line = line;
+
+ if (match_string(line, "draw quad", &line))
+ {
+ D3D12_SHADER_BYTECODE ps
+ = {ID3D10Blob_GetBufferPointer(context->ps_code), ID3D10Blob_GetBufferSize(context->ps_code)};
+ ID3D12GraphicsCommandList *command_list = context->c.list;
+ static const float clear_color[4];
+ ID3D12PipelineState *pso;
+
+ context->c.root_signature = create_32bit_constants_root_signature(context->c.device,
+ 0, context->uniform_count, D3D12_SHADER_VISIBILITY_ALL);
+
+ pso = create_pipeline_state(context->c.device, context->c.root_signature,
+ context->c.render_target_desc.Format, NULL, &ps, NULL);
+
+ ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context->c.root_signature);
+ ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 0,
+ context->uniform_count, context->uniforms, 0);
+ ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context->c.rtv, false, NULL);
+ ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context->c.scissor_rect);
+ ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context->c.viewport);
+ ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context->c.rtv, clear_color, 0, NULL);
+ ID3D12GraphicsCommandList_SetPipelineState(command_list, pso);
+ ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
+ ID3D12PipelineState_Release(pso);
+ transition_resource_state(command_list, context->c.render_target,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ }
+ else if (match_string(line, "probe all rgba", &line))
+ {
+ unsigned int ulps;
+ struct vec4 v;
+ int ret;
+
+ ret = sscanf(line, "( %f , %f , %f , %f ) %u", &v.x, &v.y, &v.z, &v.w, &ulps);
+ if (ret < 4)
+ goto err;
+ if (ret < 5)
+ ulps = 0;
+ check_sub_resource_vec4(context->c.render_target, 0, context->c.queue, context->c.list, &v, ulps);
+ reset_command_list(context->c.list, context->c.allocator);
+ }
+ else if (match_string(line, "uniform", &line))
+ {
+ unsigned int offset;
+
+ if (!sscanf(line, "%u", &offset))
+ goto err;
+ line = strchr(line, ' ') + 1;
+
+ if (match_string(line, "float4", &line))
+ {
+ struct vec4 v;
+
+ if (sscanf(line, "%f %f %f %f", &v.x, &v.y, &v.z, &v.w) < 4)
+ goto err;
+ if (offset + 4 > context->uniform_count)
+ {
+ context->uniform_count = offset + 4;
+ context->uniforms = realloc(context->uniforms, context->uniform_count * sizeof(*context->uniforms));
+ }
+ memcpy(context->uniforms + offset, &v, sizeof(v));
+ }
+ }
+ else
+ {
+ goto err;
+ }
+
+ return;
+
+err:
+ fprintf(stderr, "Ignoring malformed line '%s'.\n", orig_line);
+}
+
+START_TEST(shader_runner_d3d12)
+{
+ static const struct test_context_desc desc =
+ {
+ .no_root_signature = true,
+ .rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT,
+ };
+ size_t shader_source_size = 0, shader_source_len = 0;
+ enum parse_state state = STATE_NONE;
+ struct shader_context context;
+ const char *filename = NULL;
+ char *shader_source = NULL;
+ unsigned int i;
+ char line[256];
+ FILE *f;
+
+ parse_args(argc, argv);
+ enable_d3d12_debug_layer(argc, argv);
+ init_adapter_info();
+
+ for (i = 1; i < argc; ++i)
+ {
+ if (argv[i][0] != '-')
+ {
+ filename = argv[i];
+ break;
+ }
+ }
+
+ if (!filename)
+ {
+ fprintf(stderr, "Usage: %s [file]\n", argv[0]);
+ return;
+ }
+
+ if (!(f = fopen(filename, "r")))
+ {
+ fprintf(stderr, "Unable to open '%s' for reading: %s\n", argv[1], strerror(errno));
+ return;
+ }
+
+ memset(&context, 0, sizeof(context));
+ init_test_context(&context.c, &desc);
+
+ while (fgets(line, sizeof(line), f))
+ {
+ if (line[0] == '[')
+ {
+ switch (state)
+ {
+ case STATE_NONE:
+ case STATE_TEST:
+ break;
+
+ case STATE_SHADER_PIXEL:
+ if (!(context.ps_code = compile_shader(shader_source, "ps_4_0")))
+ return;
+ shader_source_len = 0;
+ break;
+ }
+
+ if (!strcmp(line, "[pixel shader]\n"))
+ state = STATE_SHADER_PIXEL;
+ else if (!strcmp(line, "[test]\n"))
+ state = STATE_TEST;
+ }
+ else
+ {
+ switch (state)
+ {
+ case STATE_NONE:
+ if (line[0] != '#')
+ fprintf(stderr, "Ignoring line '%s' in %s.\n", line, argv[1]);
+ break;
+
+ case STATE_SHADER_PIXEL:
+ {
+ size_t len = strlen(line);
+
+ vkd3d_array_reserve((void **)&shader_source, &shader_source_size, shader_source_len + len + 1, 1);
+ memcpy(shader_source + shader_source_len, line, len + 1);
+ shader_source_len += len;
+ break;
+ }
+
+ case STATE_TEST:
+ if (line[0] != '#')
+ parse_test_directive(&context, line);
+ break;
+ }
+ }
+ }
+
+ ID3D10Blob_Release(context.ps_code);
+ destroy_test_context(&context.c);
+
+ fclose(f);
+}
--
2.28.0
Oct. 1, 2020