[Piglit] [v3 07/11] ext_memory_object: Add tex layout command line

Topi Pohjolainen topi.pohjolainen at gmail.com
Thu Dec 21 12:02:50 UTC 2017


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 tests/spec/ext_memory_object/common.c    | 71 ++++++++++++++++++++++++++++++++
 tests/spec/ext_memory_object/common.h    | 39 ++++++++++++++++++
 tests/spec/ext_memory_object/vk_common.h |  9 ++++
 3 files changed, 119 insertions(+)
 create mode 100644 tests/spec/ext_memory_object/common.c
 create mode 100644 tests/spec/ext_memory_object/common.h

diff --git a/tests/spec/ext_memory_object/common.c b/tests/spec/ext_memory_object/common.c
new file mode 100644
index 000000000..c274f14df
--- /dev/null
+++ b/tests/spec/ext_memory_object/common.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2017 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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
+ * NON-INFRINGEMENT.  IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
+ * 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 "common.h"
+
+static void
+print_usage_and_exit(const char *usage_prefix)
+{
+	printf("Usage: %s <target> <format> <src_format> <src_tiling> "
+	       "<num_samples> <w> <h> <z> "
+	       "<first_level> <num_levels> <first_layer> <num_layers>\n",
+	       usage_prefix);
+	piglit_report_result(PIGLIT_FAIL);
+}
+
+static unsigned
+read_unsigned(const char *s, const char *usage_prefix)
+{
+	char *endptr = NULL;
+	unsigned res = strtol(s, &endptr, 0);
+	if (endptr != s + strlen(s))
+		print_usage_and_exit(usage_prefix);
+	
+	return res;
+}
+
+void
+parse_tex_layout(const char **args, unsigned num_args,
+		 const char *usage_prefix, struct tex_layout *layout)
+{
+	if (num_args < 12)
+		print_usage_and_exit(usage_prefix);
+
+	layout->target = piglit_get_gl_enum_from_name(args[0]);
+	layout->format = piglit_get_gl_enum_from_name(args[1]);
+
+	/* TODO: Add "tests/util/gen_dispatch.py" style generator and proper
+	 *       parser.
+	 */
+	layout->layout.src_format = VK_FORMAT_R8G8B8A8_UNORM;
+	layout->layout.src_tiling = VK_IMAGE_TILING_LINEAR;
+	layout->layout.num_samples = read_unsigned(args[4], usage_prefix);
+	layout->layout.w = read_unsigned(args[5], usage_prefix);
+	layout->layout.h = read_unsigned(args[6], usage_prefix);
+	layout->layout.z = read_unsigned(args[7], usage_prefix);
+	layout->layout.first_level = read_unsigned(args[8], usage_prefix);
+	layout->layout.num_levels = read_unsigned(args[9], usage_prefix);
+	layout->layout.first_layer = read_unsigned(args[10], usage_prefix);
+	layout->layout.num_layers = read_unsigned(args[11], usage_prefix);
+}
diff --git a/tests/spec/ext_memory_object/common.h b/tests/spec/ext_memory_object/common.h
new file mode 100644
index 000000000..69ebb3f4a
--- /dev/null
+++ b/tests/spec/ext_memory_object/common.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#ifndef COMMON_H
+#define COMMON_H
+
+#include "piglit-util-gl.h"
+#include "vk_common.h"
+
+struct tex_layout {
+	GLenum target, format;
+	struct vk_image_layout layout;
+};
+
+void
+parse_tex_layout(const char **args, unsigned num_args,
+		 const char *usage_prefix, struct tex_layout *layout);
+
+#endif
diff --git a/tests/spec/ext_memory_object/vk_common.h b/tests/spec/ext_memory_object/vk_common.h
index c9d920523..b092b142f 100644
--- a/tests/spec/ext_memory_object/vk_common.h
+++ b/tests/spec/ext_memory_object/vk_common.h
@@ -44,6 +44,15 @@ struct vk_vertex_buffer {
 	VkDeviceMemory mem;
 };
 
+struct vk_image_layout {
+	VkFormat src_format;
+	VkImageTiling src_tiling;
+	unsigned num_samples;
+	unsigned w, h, z;
+	unsigned first_level, num_levels;
+	unsigned first_layer, num_layers;
+};
+
 struct vk_image {
 	VkImage image;
 	VkDeviceMemory mem;
-- 
2.14.1



More information about the Piglit mailing list