blob: 6abfd5b39bafb805400cb7d32b6fa0ae7a8b71bb [file] [log] [blame]
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -06001// Copyright 2005, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060030
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060031//
Courtney Goeltzenleuchterfcbe16f2015-10-29 13:50:34 -060032// Copyright (C) 2015 Valve Corporation
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060033//
34// Permission is hereby granted, free of charge, to any person obtaining a
35// copy of this software and associated documentation files (the "Software"),
36// to deal in the Software without restriction, including without limitation
37// the rights to use, copy, modify, merge, publish, distribute, sublicense,
38// and/or sell copies of the Software, and to permit persons to whom the
39// Software is furnished to do so, subject to the following conditions:
40//
41// The above copyright notice and this permission notice shall be included
42// in all copies or substantial portions of the Software.
43//
44// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
47// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
49// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
50// DEALINGS IN THE SOFTWARE.
51
52
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060053// Verify VK driver initialization
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060054
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060055#include <stdlib.h>
56#include <stdio.h>
57#include <stdbool.h>
58#include <string.h>
59
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060060#include <vulkan.h>
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060061
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060062#include "vktestbinding.h"
Chia-I Wufe84fe12014-12-29 15:39:23 +080063#include "test_common.h"
Cody Northrop054a4702015-03-17 14:54:35 -060064#include "icd-spv.h"
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060065
Jon Ashburn83a64252015-04-15 11:31:12 -060066#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
67
Tony-LunarGd61e1e52015-05-15 12:42:49 -060068class VkTest : public ::testing::Test {
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060069public:
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -060070 void CreateImageTest();
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -060071 void CreateCommandBufferTest();
72 void CreatePipelineTest();
73 void CreateShaderTest();
Chia-I Wu28e06912015-10-31 00:31:16 +080074 void CreateShader(VkShaderModule *pmodule, VkShaderStageFlagBits stage);
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060075
Chia-I Wuf368b602015-07-03 10:41:20 +080076 VkDevice device() {return m_device->handle();}
Courtney Goeltzenleuchtercc5eb3a2014-08-19 18:35:50 -060077
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060078protected:
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060079 VkApplicationInfo app_info;
80 VkInstance inst;
Tony Barbourd1c35722015-04-16 15:59:00 -060081 VkPhysicalDevice objs[16];
Mark Lobodzinski17caf572015-01-29 08:55:56 -060082 uint32_t gpu_count;
Chia-I Wufe84fe12014-12-29 15:39:23 +080083
Mark Lobodzinski17caf572015-01-29 08:55:56 -060084 uint32_t m_device_id;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060085 vk_testing::Device *m_device;
Tony Barbourd1c35722015-04-16 15:59:00 -060086 VkPhysicalDeviceProperties props;
Cody Northropd0802882015-08-03 17:04:53 -060087 std::vector<VkQueueFamilyProperties> queue_props;
Courtney Goeltzenleuchter18248e62015-03-05 18:09:39 -070088 uint32_t graphics_queue_node_index;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060089
90 virtual void SetUp() {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060091 VkResult err;
Courtney Goeltzenleuchter18248e62015-03-05 18:09:39 -070092 int i;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060093
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060094 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060095 this->app_info.pNext = NULL;
Chia-I Wu3432a0c2015-10-27 18:04:07 +080096 this->app_info.pApplicationName = "base";
97 this->app_info.applicationVersion = 1;
Chia-I Wuf1a5a742014-12-27 15:16:07 +080098 this->app_info.pEngineName = "unittest";
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060099 this->app_info.engineVersion = 1;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600100 this->app_info.apiVersion = VK_API_VERSION;
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -0600101 VkInstanceCreateInfo inst_info = {};
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600102 inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
Jon Ashburnb317fad2015-04-04 14:52:07 -0600103 inst_info.pNext = NULL;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800104 inst_info.pApplicationInfo = &app_info;
Chia-I Wud50a7d72015-10-26 20:48:51 +0800105 inst_info.enabledLayerNameCount = 0;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600106 inst_info.ppEnabledLayerNames = NULL;
Chia-I Wud50a7d72015-10-26 20:48:51 +0800107 inst_info.enabledExtensionNameCount = 0;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600108 inst_info.ppEnabledExtensionNames = NULL;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800109 err = vkCreateInstance(&inst_info, NULL, &inst);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600110 ASSERT_VK_SUCCESS(err);
Jon Ashburn83a64252015-04-15 11:31:12 -0600111 err = vkEnumeratePhysicalDevices(inst, &this->gpu_count, NULL);
112 ASSERT_VK_SUCCESS(err);
113 ASSERT_LE(this->gpu_count, ARRAY_SIZE(objs)) << "Too many GPUs";
114 err = vkEnumeratePhysicalDevices(inst, &this->gpu_count, objs);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600115 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter58f3eff2015-10-07 13:28:58 -0600116 ASSERT_GE(this->gpu_count, (uint32_t) 1) << "No GPU available";
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600117
Chia-I Wufe84fe12014-12-29 15:39:23 +0800118 m_device_id = 0;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600119 this->m_device = new vk_testing::Device(objs[m_device_id]);
Chia-I Wufe84fe12014-12-29 15:39:23 +0800120 this->m_device->init();
121
Chia-I Wu999f0482015-07-03 10:32:05 +0800122 props = m_device->phy().properties();
Chia-I Wufe84fe12014-12-29 15:39:23 +0800123
Chia-I Wu999f0482015-07-03 10:32:05 +0800124 queue_props = this->m_device->phy().queue_properties();
Courtney Goeltzenleuchter18248e62015-03-05 18:09:39 -0700125 for (i = 0; i < queue_props.size(); i++) {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600126 if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
Courtney Goeltzenleuchter18248e62015-03-05 18:09:39 -0700127 graphics_queue_node_index = i;
128 break;
129 }
130 }
131 ASSERT_LT(i, queue_props.size()) << "Could not find a Queue with Graphics support";
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600132 }
133
134 virtual void TearDown() {
Tony Barbourc2f67f52015-06-02 14:55:46 -0600135 delete m_device;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800136 vkDestroyInstance(inst, NULL);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600137 }
138};
139
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800140TEST_F(VkTest, AllocateMemory) {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600141 VkResult err;
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600142 bool pass;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800143 VkMemoryAllocateInfo alloc_info = {};
Tony Barbourd1c35722015-04-16 15:59:00 -0600144 VkDeviceMemory gpu_mem;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600145 uint8_t *pData;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600146
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600147 alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600148 alloc_info.allocationSize = 1024 * 1024; // 1MB
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600149 alloc_info.memoryTypeIndex = 0;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600150
Tony Barbourcba4ab22015-07-29 14:27:38 -0600151 VkPhysicalDeviceMemoryProperties mem_props;
152 vkGetPhysicalDeviceMemoryProperties(m_device->phy().handle(), &mem_props);
153
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600154 pass = m_device->phy().set_memory_type(((1 << mem_props.memoryTypeCount) - 1), &alloc_info, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
155 ASSERT_TRUE(pass);
Tony Barbourcba4ab22015-07-29 14:27:38 -0600156
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800157 err = vkAllocateMemory(device(), &alloc_info, NULL, &gpu_mem);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600158 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -0600159
Mike Stroyanb050c682015-04-17 12:36:38 -0600160 err = vkMapMemory(device(), gpu_mem, 0, 0, 0, (void **) &pData);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600161 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600162
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600163 memset(pData, 0x55, alloc_info.allocationSize);
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600164 EXPECT_EQ(0x55, pData[0]) << "Memory read not same as write";
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600165
Mark Lobodzinski2141f652015-09-07 13:59:43 -0600166 vkUnmapMemory(device(), gpu_mem);
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600167
Chia-I Wuf7458c52015-10-26 21:10:41 +0800168 vkFreeMemory(device(), gpu_mem, NULL);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600169}
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600170
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600171TEST_F(VkTest, Event) {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600172 VkEventCreateInfo event_info;
173 VkEvent event;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600174 VkResult err;
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600175
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600176 // typedef struct VkEventCreateInfo_
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600177 // {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600178 // VkStructureType sType; // Must be VK_STRUCTURE_TYPE_EVENT_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600179 // const void* pNext; // Pointer to next structure
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600180 // VkFlags flags; // Reserved
181 // } VkEventCreateInfo;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600182 memset(&event_info, 0, sizeof(event_info));
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600183 event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO;
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600184
Chia-I Wuf7458c52015-10-26 21:10:41 +0800185 err = vkCreateEvent(device(), &event_info, NULL, &event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600186 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600187
Mike Stroyanb050c682015-04-17 12:36:38 -0600188 err = vkResetEvent(device(), event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600189 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600190
Mike Stroyanb050c682015-04-17 12:36:38 -0600191 err = vkGetEventStatus(device(), event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600192 ASSERT_EQ(VK_EVENT_RESET, err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600193
Mike Stroyanb050c682015-04-17 12:36:38 -0600194 err = vkSetEvent(device(), event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600195 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600196
Mike Stroyanb050c682015-04-17 12:36:38 -0600197 err = vkGetEventStatus(device(), event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600198 ASSERT_EQ(VK_EVENT_SET, err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600199
200 // TODO: Test actual synchronization with command buffer event.
201
202 // All done with event memory, clean up
Chia-I Wuf7458c52015-10-26 21:10:41 +0800203 vkDestroyEvent(device(), event, NULL);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600204}
205
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600206#define MAX_QUERY_SLOTS 10
207
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600208TEST_F(VkTest, Query) {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600209 VkQueryPoolCreateInfo query_info;
210 VkQueryPool query_pool;
Chia-I Wu99ff89d2014-12-27 14:14:50 +0800211 size_t query_result_size;
Chia-I Wuccc93a72015-10-26 18:36:20 +0800212 uint8_t *query_result_data;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600213 VkResult err;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600214
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600215 // typedef enum VkQueryType_
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600216 // {
Tony Barbourd1c35722015-04-16 15:59:00 -0600217 // VK_QUERY_TYPE_OCCLUSION = 0x00000000,
218 // VK_QUERY_TYPE_PIPELINE_STATISTICS = 0x00000001,
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600219
Tony Barbourd1c35722015-04-16 15:59:00 -0600220 // VK_QUERY_TYPE_BEGIN_RANGE = VK_QUERY_TYPE_OCCLUSION,
221 // VK_QUERY_TYPE_END_RANGE = VK_QUERY_TYPE_PIPELINE_STATISTICS,
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600222 // VK_NUM_QUERY_TYPE = (VK_QUERY_TYPE_END_RANGE - VK_QUERY_TYPE_BEGIN_RANGE + 1),
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600223 // VK_MAX_ENUM(VkQueryType_)
224 // } VkQueryType;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600225
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600226 // typedef struct VkQueryPoolCreateInfo_
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600227 // {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600228 // VkStructureType sType; // Must be VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600229 // const void* pNext; // Pointer to next structure
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600230 // VkQueryType queryType;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600231 // uint32_t slots;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600232 // } VkQueryPoolCreateInfo;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600233
234 memset(&query_info, 0, sizeof(query_info));
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600235 query_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
Tony Barbourd1c35722015-04-16 15:59:00 -0600236 query_info.queryType = VK_QUERY_TYPE_OCCLUSION;
Chia-I Wuab83a0e2015-10-27 19:00:15 +0800237 query_info.entryCount = MAX_QUERY_SLOTS;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600238
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600239 // VkResult VKAPI vkCreateQueryPool(
240 // VkDevice device,
241 // const VkQueryPoolCreateInfo* pCreateInfo,
242 // VkQueryPool* pQueryPool);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600243
Chia-I Wuf7458c52015-10-26 21:10:41 +0800244 err = vkCreateQueryPool(device(), &query_info, NULL, &query_pool);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600245 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600246
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600247 // TODO: Test actual synchronization with command buffer event.
248 // TODO: Create command buffer
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600249 // TODO: vkCmdResetQueryPool
250 // TODO: vkCmdBeginQuery
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600251 // TODO: commands
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600252 // TOOD: vkCmdEndQuery
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600253
Chia-I Wuccc93a72015-10-26 18:36:20 +0800254 query_result_size = MAX_QUERY_SLOTS * sizeof(uint64_t);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600255 if (query_result_size > 0) {
Chia-I Wuccc93a72015-10-26 18:36:20 +0800256 query_result_data = new uint8_t [query_result_size];
Mike Stroyanb050c682015-04-17 12:36:38 -0600257 err = vkGetQueryPoolResults(device(), query_pool, 0, MAX_QUERY_SLOTS,
Chia-I Wuccc93a72015-10-26 18:36:20 +0800258 query_result_size, query_result_data,
259 sizeof(uint64_t), VK_QUERY_RESULT_64_BIT);
Jon Ashburne3f31082015-10-02 09:35:45 -0700260 //ASSERT_VK_SUCCESS(err); TODO fix once actually submit queries
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600261
262 // TODO: Test Query result data.
263
264 }
265
Chia-I Wuf7458c52015-10-26 21:10:41 +0800266 vkDestroyQueryPool(device(), query_pool, NULL);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600267}
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600268
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600269void getQueue(vk_testing::Device *device, uint32_t queue_node_index, const char *qname)
Courtney Goeltzenleuchter3dc07f22014-08-14 10:15:09 -0600270{
Cody Northropd2ad0342015-08-05 11:15:02 -0600271 uint32_t que_idx;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600272 VkQueue queue;
Courtney Goeltzenleuchter3dc07f22014-08-14 10:15:09 -0600273
Cody Northropd0802882015-08-03 17:04:53 -0600274 const VkQueueFamilyProperties props = device->phy().queue_properties()[queue_node_index];
Chia-I Wufe84fe12014-12-29 15:39:23 +0800275 for (que_idx = 0; que_idx < props.queueCount; que_idx++) {
Mark Lobodzinski40f7f402015-04-16 11:44:05 -0500276 // TODO: Need to add support for separate MEMMGR and work queues, including synchronization
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600277 vkGetDeviceQueue(device->handle(), queue_node_index, que_idx, &queue);
Courtney Goeltzenleuchter3dc07f22014-08-14 10:15:09 -0600278 }
279}
280
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600281void VkTest::CreateImageTest()
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600282{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600283 VkResult err;
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600284 bool pass;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600285 VkImage image;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600286 uint32_t w, h, mipCount;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600287 VkFormat fmt;
288 VkFormatProperties image_fmt;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600289
290 w =512;
291 h = 256;
292 mipCount = 0;
293
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600294 uint32_t _w = w;
295 uint32_t _h = h;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600296 while( ( _w > 0 ) || ( _h > 0 ) )
297 {
298 _w >>= 1;
299 _h >>= 1;
300 mipCount++;
301 }
302
Tony Barbourd1c35722015-04-16 15:59:00 -0600303 fmt = VK_FORMAT_R8G8B8A8_UINT;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600304 // TODO: Pick known good format rather than just expect common format
305 /*
306 * XXX: What should happen if given NULL HANDLE for the pData argument?
Tony Barbourd1c35722015-04-16 15:59:00 -0600307 * We're not requesting VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS so there is
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600308 * an expectation that pData is a valid pointer.
309 * However, why include a returned size value? That implies that the
310 * amount of data may vary and that doesn't work well for using a
311 * fixed structure.
312 */
313
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600314 vkGetPhysicalDeviceFormatProperties(objs[m_device_id], fmt, &image_fmt);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600315
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600316// typedef struct VkImageCreateInfo_
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600317// {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600318// VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600319// const void* pNext; // Pointer to next structure.
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600320// VkImageType imageType;
321// VkFormat format;
322// VkExtent3D extent;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600323// uint32_t mipLevels;
324// uint32_t arraySize;
Chia-I Wu5c17c962015-10-31 00:31:16 +0800325// VkSampleCountFlagBits samples;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600326// VkImageTiling tiling;
327// VkFlags usage; // VkImageUsageFlags
328// VkFlags flags; // VkImageCreateFlags
329// } VkImageCreateInfo;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600330
331
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600332 VkImageCreateInfo imageCreateInfo = {};
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600333 imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
Tony Barbourd1c35722015-04-16 15:59:00 -0600334 imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600335 imageCreateInfo.format = fmt;
Courtney Goeltzenleuchter5d2aed42015-10-21 17:57:31 -0600336 imageCreateInfo.arrayLayers = 1;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600337 imageCreateInfo.extent.width = w;
338 imageCreateInfo.extent.height = h;
339 imageCreateInfo.extent.depth = 1;
340 imageCreateInfo.mipLevels = mipCount;
Chia-I Wu5c17c962015-10-31 00:31:16 +0800341 imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600342 if (image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
343 imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR;
344 }
345 else if (image_fmt.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
346 imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
347 }
348 else {
349 FAIL() << "Neither Linear nor Optimal allowed for color attachment";
350 }
Cody Northropbb6fdb32015-06-17 08:28:19 -0600351 imageCreateInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
352 VK_IMAGE_USAGE_SAMPLED_BIT;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600353
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600354// VkResult VKAPI vkCreateImage(
355// VkDevice device,
356// const VkImageCreateInfo* pCreateInfo,
357// VkImage* pImage);
Chia-I Wuf7458c52015-10-26 21:10:41 +0800358 err = vkCreateImage(device(), &imageCreateInfo, NULL, &image);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600359 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600360
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600361 // Verify image resources
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600362// void VKAPI vkGetImageSubresourceLayout(
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600363// VkImage image,
364// const VkImageSubresource* pSubresource,
Tony Barbour59a47322015-06-24 16:06:58 -0600365// VkSubresourceLayout* pLayout);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600366// typedef struct VkSubresourceLayout_
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600367// {
Tony Barbourd1c35722015-04-16 15:59:00 -0600368// VkDeviceSize offset; // Specified in bytes
369// VkDeviceSize size; // Specified in bytes
370// VkDeviceSize rowPitch; // Specified in bytes
371// VkDeviceSize depthPitch; // Specified in bytes
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600372// } VkSubresourceLayout;
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600373
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600374// typedef struct VkImageSubresource_
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600375// {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600376// VkImageAspect aspect;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600377// uint32_t mipLevel;
Courtney Goeltzenleuchter4a261892015-09-10 16:38:41 -0600378// uint32_t arrayLayer;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600379// } VkImageSubresource;
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600380
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600381
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600382 if (image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
383 VkImageSubresource subresource = {};
Chia-I Wu52b07e72015-10-27 19:55:05 +0800384 subresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
Courtney Goeltzenleuchter4a261892015-09-10 16:38:41 -0600385 subresource.arrayLayer = 0;
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600386
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600387 _w = w;
388 _h = h;
389 while ((_w > 0) || (_h > 0))
390 {
391 VkSubresourceLayout layout = {};
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600392 vkGetImageSubresourceLayout(device(), image, &subresource, &layout);
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600393
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600394 // TODO: 4 should be replaced with pixel size for given format
395 EXPECT_LE(_w * 4, layout.rowPitch) << "Pitch does not match expected image pitch";
396 _w >>= 1;
397 _h >>= 1;
398
399 subresource.mipLevel++;
400 }
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600401 }
402
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600403 VkMemoryRequirements mem_req;
Tony Barbourd1c35722015-04-16 15:59:00 -0600404 VkDeviceMemory image_mem;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600405
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600406 vkGetImageMemoryRequirements(device(), image, &mem_req);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600407
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600408 if (mem_req.size) {
409
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800410 // VkResult VKAPI vkAllocateMemory(
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600411 // VkDevice device,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800412 // const VkMemoryAllocateInfo* pAllocateInfo,
413 // VkDeviceMemory* pMemory);
414 VkMemoryAllocateInfo mem_info = {};
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600415
416 mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
417 mem_info.pNext = NULL;
418 mem_info.allocationSize = mem_req.size;
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600419 mem_info.memoryTypeIndex = 0;
420
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600421 pass = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
422 ASSERT_TRUE(pass);
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600423
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800424 err = vkAllocateMemory(device(), &mem_info, NULL, &image_mem);
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600425 ASSERT_VK_SUCCESS(err);
426
Tony Barbour67e99152015-07-10 14:10:27 -0600427 err = vkBindImageMemory(device(), image, image_mem, 0);
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600428 ASSERT_VK_SUCCESS(err);
429 }
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600430
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600431// typedef struct VkImageViewCreateInfo_
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600432// {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600433// VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600434// const void* pNext; // Pointer to next structure
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600435// VkImage image;
436// VkImageViewType viewType;
437// VkFormat format;
Chia-I Wu1b99bb22015-10-27 19:25:11 +0800438// VkComponentMapping channels;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600439// VkImageSubresourceRange subresourceRange;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600440// float minLod;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600441// } VkImageViewCreateInfo;
442 VkImageViewCreateInfo viewInfo = {};
443 VkImageView view;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600444 viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600445 viewInfo.image = image;
Tony Barbourd1c35722015-04-16 15:59:00 -0600446 viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600447 viewInfo.format = fmt;
448
Chia-I Wuab83a0e2015-10-27 19:00:15 +0800449 viewInfo.components.r = VK_COMPONENT_SWIZZLE_R;
450 viewInfo.components.g = VK_COMPONENT_SWIZZLE_G;
451 viewInfo.components.b = VK_COMPONENT_SWIZZLE_B;
452 viewInfo.components.a = VK_COMPONENT_SWIZZLE_A;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600453
Courtney Goeltzenleuchter4a261892015-09-10 16:38:41 -0600454 viewInfo.subresourceRange.baseArrayLayer = 0;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800455 viewInfo.subresourceRange.layerCount = 1;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600456 viewInfo.subresourceRange.baseMipLevel = 0;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800457 viewInfo.subresourceRange.levelCount = 1;
Courtney Goeltzenleuchterba724512015-09-10 17:58:54 -0600458 viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600459
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600460// VkResult VKAPI vkCreateImageView(
461// VkDevice device,
462// const VkImageViewCreateInfo* pCreateInfo,
463// VkImageView* pView);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600464
Chia-I Wuf7458c52015-10-26 21:10:41 +0800465 err = vkCreateImageView(device(), &viewInfo, NULL, &view);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600466 ASSERT_VK_SUCCESS(err) << "vkCreateImageView failed";
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600467
468 // TODO: Test image memory.
469
470 // All done with image memory, clean up
Chia-I Wuf7458c52015-10-26 21:10:41 +0800471 vkDestroyImageView(device(), view, NULL);
472 vkDestroyImage(device(), image, NULL);
Courtney Goeltzenleuchter10642562015-06-22 16:26:54 -0600473
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600474 if (mem_req.size) {
Chia-I Wuf7458c52015-10-26 21:10:41 +0800475 vkFreeMemory(device(), image_mem, NULL);
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600476 }
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600477}
478
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600479TEST_F(VkTest, CreateImage) {
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600480 CreateImageTest();
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600481}
482
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600483void VkTest::CreateCommandBufferTest()
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600484{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600485 VkResult err;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800486 VkCommandBufferAllocateInfo info = {};
487 VkCommandPool commandPool;
488 VkCommandBuffer commandBuffer;
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600489
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800490// typedef struct VkCommandBufferCreateInfo_
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600491// {
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800492// VkStructureType sType; // Must be VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600493// const void* pNext;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600494// VK_QUEUE_TYPE queueType;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600495// VkFlags flags;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800496// } VkCommandBufferAllocateInfo;
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600497
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800498 VkCommandPoolCreateInfo cmd_pool_info;
499 cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
Cody Northrope62183e2015-07-09 18:08:05 -0600500 cmd_pool_info.pNext = NULL,
501 cmd_pool_info.queueFamilyIndex = graphics_queue_node_index;
502 cmd_pool_info.flags = 0,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800503 err = vkCreateCommandPool(device(), &cmd_pool_info, NULL, &commandPool);
Cody Northrope62183e2015-07-09 18:08:05 -0600504 ASSERT_VK_SUCCESS(err) << "vkCreateCommandPool failed";
505
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800506 info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO;
507 info.commandPool = commandPool;
Chia-I Wud50a7d72015-10-26 20:48:51 +0800508 info.bufferCount = 1;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800509 info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
510 err = vkAllocateCommandBuffers(device(), &info, &commandBuffer);
511 ASSERT_VK_SUCCESS(err) << "vkAllocateCommandBuffers failed";
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600512
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800513 vkFreeCommandBuffers(device(), commandPool, 1, &commandBuffer);
514 vkDestroyCommandPool(device(), commandPool, NULL);
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600515}
516
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600517TEST_F(VkTest, TestCommandBuffer) {
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600518 CreateCommandBufferTest();
519}
520
Chia-I Wu28e06912015-10-31 00:31:16 +0800521void VkTest::CreateShader(VkShaderModule *pmodule, VkShaderStageFlagBits stage)
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600522{
Chia-I Wu8094f192015-10-26 19:22:06 +0800523 uint32_t *code;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600524 uint32_t codeSize;
Cody Northrop3bfd27c2015-03-17 15:55:58 -0600525 struct icd_spv_header *pSPV;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600526 VkResult err;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600527
Chia-I Wu8094f192015-10-26 19:22:06 +0800528 codeSize = sizeof(struct icd_spv_header) + sizeof(uint32_t) * 25;
529 code = (uint32_t *) malloc(codeSize);
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600530 ASSERT_TRUE(NULL != code) << "malloc failed!";
531
532 memset(code, 0, codeSize);
533
Cody Northrop3bfd27c2015-03-17 15:55:58 -0600534 // Indicate that this is SPV data.
535 pSPV = (struct icd_spv_header *) code;
536 pSPV->magic = ICD_SPV_MAGIC;
537 pSPV->version = ICD_SPV_VERSION;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600538
Courtney Goeltzenleuchteree4027d2015-06-28 13:01:17 -0600539 VkShaderModuleCreateInfo moduleCreateInfo;
540 VkShaderModule module;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600541
Courtney Goeltzenleuchteree4027d2015-06-28 13:01:17 -0600542 moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
543 moduleCreateInfo.pNext = NULL;
544 moduleCreateInfo.pCode = code;
545 moduleCreateInfo.codeSize = codeSize;
546 moduleCreateInfo.flags = 0;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800547 err = vkCreateShaderModule(device(), &moduleCreateInfo, NULL, &module);
Courtney Goeltzenleuchteree4027d2015-06-28 13:01:17 -0600548 ASSERT_VK_SUCCESS(err);
549
Chia-I Wu28e06912015-10-31 00:31:16 +0800550 *pmodule = module;
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600551}
552
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600553int main(int argc, char **argv) {
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600554 ::testing::InitGoogleTest(&argc, argv);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600555 vk_testing::set_error_callback(test_error_callback);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600556 return RUN_ALL_TESTS();
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -0600557}