Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com>
---
 tests/spec/ext_memory_object/common.c | 71 +++++++++++++++++++++++++++++++++++
 tests/spec/ext_memory_object/common.h | 45 ++++++++++++++++++++++
 2 files changed, 116 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..4e629a787
--- /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 <src_format> <src_tiling> "
+              "<target> <format> <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);
+
+       /* TODO: Add "tests/util/gen_dispatch.py" style generator and proper
+        *       parser.
+        */
+       layout->src_format = VK_FORMAT_R8G8B8A8_UNORM;
+       layout->src_tiling = VK_IMAGE_TILING_LINEAR;
+
+       layout->target = piglit_get_gl_enum_from_name(args[2]);
+       layout->format = piglit_get_gl_enum_from_name(args[3]);
+       layout->num_samples = read_unsigned(args[4], usage_prefix);
+       layout->w = read_unsigned(args[5], usage_prefix);
+       layout->h = read_unsigned(args[6], usage_prefix);
+       layout->z = read_unsigned(args[7], usage_prefix);
+       layout->first_level = read_unsigned(args[8], usage_prefix);
+       layout->num_levels = read_unsigned(args[9], usage_prefix);
+       layout->first_layer = read_unsigned(args[10], usage_prefix);
+       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..35e54c529
--- /dev/null
+++ b/tests/spec/ext_memory_object/common.h
@@ -0,0 +1,45 @@
+/*
+ * 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 <vulkan/vulkan.h>
+
+struct tex_layout {
+       VkFormat src_format;
+       VkImageTiling src_tiling;
+
+       GLenum target, format;
+       unsigned num_samples;
+       unsigned w, h, z;
+       unsigned first_level, num_levels;
+       unsigned first_layer, num_layers;
+};
+
+void
+parse_tex_layout(const char **args, unsigned num_args,
+                const char *usage_prefix, struct tex_layout *layout);
+
+#endif
-- 
2.14.1

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to