=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: tests: Add test for invalid shader bytecode.
Alexandre Julliard
julliard at winehq.org
Wed Dec 12 13:44:45 CST 2018
Module: vkd3d
Branch: master
Commit: e9b33183cf68d21c5ceb504208406cc7a5fb0ef1
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=e9b33183cf68d21c5ceb504208406cc7a5fb0ef1
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Tue Dec 11 15:48:02 2018 +0100
tests: Add test for invalid shader bytecode.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
Makefile.am | 4 +++-
tests/.gitignore | 6 +++--
tests/vkd3d_shader_api.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 86c0184..a16f7ca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,7 +34,8 @@ vkd3d_demos_shaders = \
demos/triangle_vs.h
vkd3d_tests = \
- tests/vkd3d_api
+ tests/vkd3d_api \
+ tests/vkd3d_shader_api
vkd3d_cross_tests = \
tests/d3d12 \
@@ -137,6 +138,7 @@ AM_DEFAULT_SOURCE_EXT = .c
TESTS = $(vkd3d_tests) $(vkd3d_cross_tests)
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@
tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@
+tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la
if BUILD_DEMOS
DEMOS_LDADD = $(LDADD) libvkd3d-shader.la @XCB_LIBS@ @VULKAN_LIBS@
diff --git a/tests/.gitignore b/tests/.gitignore
index 87d1ea6..24258bf 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,2 +1,4 @@
-d3d12
-vkd3d_api
+/d3d12
+/d3d12_invalid_usage
+/vkd3d_api
+/vkd3d_shader_api
diff --git a/tests/vkd3d_shader_api.c b/tests/vkd3d_shader_api.c
new file mode 100644
index 0000000..ec439e1
--- /dev/null
+++ b/tests/vkd3d_shader_api.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2018 Józef Kucia 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
+ */
+
+#include "vkd3d_test.h"
+#include <vkd3d_shader.h>
+
+static void test_invalid_shaders(void)
+{
+ struct vkd3d_shader_code spirv;
+ int rc;
+
+ static const DWORD ps_break_code[] =
+ {
+#if 0
+ ps_4_0
+ dcl_constantbuffer cb0[1], immediateIndexed
+ dcl_output o0.xyzw
+ if_z cb0[0].x
+ mov o0.xyzw, l(1.000000,1.000000,1.000000,1.000000)
+ break
+ endif
+ mov o0.xyzw, l(0,0,0,0)
+ ret
+#endif
+ 0x43425844, 0x1316702a, 0xb1a7ebfc, 0xf477753e, 0x72605647, 0x00000001, 0x000000f8, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000080, 0x00000040, 0x00000020,
+ 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0400001f,
+ 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000,
+ 0x3f800000, 0x3f800000, 0x3f800000, 0x01000002, 0x01000015, 0x08000036, 0x001020f2, 0x00000000,
+ 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
+ };
+ static const struct vkd3d_shader_code ps_break = {ps_break_code, sizeof(ps_break_code)};
+
+ rc = vkd3d_shader_compile_dxbc(&ps_break, &spirv, VKD3D_SHADER_STRIP_DEBUG, NULL, NULL);
+ ok(rc == VKD3D_ERROR_INVALID_SHADER, "Got unexpected error code %d.\n", rc);
+}
+
+START_TEST(vkd3d_shader_api)
+{
+ run_test(test_invalid_shaders);
+}
More information about the wine-cvs
mailing list