blob: cb55b1a294f677b543d2568f2e965fb0eacbc26b [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 Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060031// VK tests
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060032//
33// Copyright (C) 2014 LunarG, Inc.
34//
35// Permission is hereby granted, free of charge, to any person obtaining a
36// copy of this software and associated documentation files (the "Software"),
37// to deal in the Software without restriction, including without limitation
38// the rights to use, copy, modify, merge, publish, distribute, sublicense,
39// and/or sell copies of the Software, and to permit persons to whom the
40// Software is furnished to do so, subject to the following conditions:
41//
42// The above copyright notice and this permission notice shall be included
43// in all copies or substantial portions of the Software.
44//
45// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
48// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
50// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
51// DEALINGS IN THE SOFTWARE.
52
53
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060054// Verify VK driver initialization
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060055
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060056#include <stdlib.h>
57#include <stdio.h>
58#include <stdbool.h>
59#include <string.h>
60
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060061#include <vulkan.h>
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060062
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060063#include "vktestbinding.h"
Chia-I Wufe84fe12014-12-29 15:39:23 +080064#include "test_common.h"
Cody Northrop054a4702015-03-17 14:54:35 -060065#include "icd-spv.h"
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060066
Jon Ashburn83a64252015-04-15 11:31:12 -060067#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
68
Tony-LunarGd61e1e52015-05-15 12:42:49 -060069class VkTest : public ::testing::Test {
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060070public:
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -060071 void CreateImageTest();
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -060072 void CreateCommandBufferTest();
73 void CreatePipelineTest();
74 void CreateShaderTest();
Courtney Goeltzenleuchterd2635502015-10-21 17:08:06 -060075 void CreateShader(VkShader *pshader, VkShaderStageFlagBits stage);
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060076
Chia-I Wuf368b602015-07-03 10:41:20 +080077 VkDevice device() {return m_device->handle();}
Courtney Goeltzenleuchtercc5eb3a2014-08-19 18:35:50 -060078
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060079protected:
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060080 VkApplicationInfo app_info;
81 VkInstance inst;
Tony Barbourd1c35722015-04-16 15:59:00 -060082 VkPhysicalDevice objs[16];
Mark Lobodzinski17caf572015-01-29 08:55:56 -060083 uint32_t gpu_count;
Chia-I Wufe84fe12014-12-29 15:39:23 +080084
Mark Lobodzinski17caf572015-01-29 08:55:56 -060085 uint32_t m_device_id;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060086 vk_testing::Device *m_device;
Tony Barbourd1c35722015-04-16 15:59:00 -060087 VkPhysicalDeviceProperties props;
Cody Northropd0802882015-08-03 17:04:53 -060088 std::vector<VkQueueFamilyProperties> queue_props;
Courtney Goeltzenleuchter18248e62015-03-05 18:09:39 -070089 uint32_t graphics_queue_node_index;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060090
91 virtual void SetUp() {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060092 VkResult err;
Courtney Goeltzenleuchter18248e62015-03-05 18:09:39 -070093 int i;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060094
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060095 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -060096 this->app_info.pNext = NULL;
Chia-I Wu3432a0c2015-10-27 18:04:07 +080097 this->app_info.pApplicationName = "base";
98 this->app_info.applicationVersion = 1;
Chia-I Wuf1a5a742014-12-27 15:16:07 +080099 this->app_info.pEngineName = "unittest";
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600100 this->app_info.engineVersion = 1;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600101 this->app_info.apiVersion = VK_API_VERSION;
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -0600102 VkInstanceCreateInfo inst_info = {};
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600103 inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
Jon Ashburnb317fad2015-04-04 14:52:07 -0600104 inst_info.pNext = NULL;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800105 inst_info.pApplicationInfo = &app_info;
Chia-I Wud50a7d72015-10-26 20:48:51 +0800106 inst_info.enabledLayerNameCount = 0;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600107 inst_info.ppEnabledLayerNames = NULL;
Chia-I Wud50a7d72015-10-26 20:48:51 +0800108 inst_info.enabledExtensionNameCount = 0;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600109 inst_info.ppEnabledExtensionNames = NULL;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800110 err = vkCreateInstance(&inst_info, NULL, &inst);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600111 ASSERT_VK_SUCCESS(err);
Jon Ashburn83a64252015-04-15 11:31:12 -0600112 err = vkEnumeratePhysicalDevices(inst, &this->gpu_count, NULL);
113 ASSERT_VK_SUCCESS(err);
114 ASSERT_LE(this->gpu_count, ARRAY_SIZE(objs)) << "Too many GPUs";
115 err = vkEnumeratePhysicalDevices(inst, &this->gpu_count, objs);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600116 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter58f3eff2015-10-07 13:28:58 -0600117 ASSERT_GE(this->gpu_count, (uint32_t) 1) << "No GPU available";
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600118
Chia-I Wufe84fe12014-12-29 15:39:23 +0800119 m_device_id = 0;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600120 this->m_device = new vk_testing::Device(objs[m_device_id]);
Chia-I Wufe84fe12014-12-29 15:39:23 +0800121 this->m_device->init();
122
Chia-I Wu999f0482015-07-03 10:32:05 +0800123 props = m_device->phy().properties();
Chia-I Wufe84fe12014-12-29 15:39:23 +0800124
Chia-I Wu999f0482015-07-03 10:32:05 +0800125 queue_props = this->m_device->phy().queue_properties();
Courtney Goeltzenleuchter18248e62015-03-05 18:09:39 -0700126 for (i = 0; i < queue_props.size(); i++) {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600127 if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
Courtney Goeltzenleuchter18248e62015-03-05 18:09:39 -0700128 graphics_queue_node_index = i;
129 break;
130 }
131 }
132 ASSERT_LT(i, queue_props.size()) << "Could not find a Queue with Graphics support";
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600133 }
134
135 virtual void TearDown() {
Tony Barbourc2f67f52015-06-02 14:55:46 -0600136 delete m_device;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800137 vkDestroyInstance(inst, NULL);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600138 }
139};
140
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800141TEST_F(VkTest, AllocateMemory) {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600142 VkResult err;
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600143 bool pass;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800144 VkMemoryAllocateInfo alloc_info = {};
Tony Barbourd1c35722015-04-16 15:59:00 -0600145 VkDeviceMemory gpu_mem;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600146 uint8_t *pData;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600147
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600148 alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600149 alloc_info.allocationSize = 1024 * 1024; // 1MB
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600150 alloc_info.memoryTypeIndex = 0;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600151
Tony Barbourcba4ab22015-07-29 14:27:38 -0600152 VkPhysicalDeviceMemoryProperties mem_props;
153 vkGetPhysicalDeviceMemoryProperties(m_device->phy().handle(), &mem_props);
154
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600155 pass = m_device->phy().set_memory_type(((1 << mem_props.memoryTypeCount) - 1), &alloc_info, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
156 ASSERT_TRUE(pass);
Tony Barbourcba4ab22015-07-29 14:27:38 -0600157
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800158 err = vkAllocateMemory(device(), &alloc_info, NULL, &gpu_mem);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600159 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -0600160
Mike Stroyanb050c682015-04-17 12:36:38 -0600161 err = vkMapMemory(device(), gpu_mem, 0, 0, 0, (void **) &pData);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600162 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600163
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600164 memset(pData, 0x55, alloc_info.allocationSize);
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600165 EXPECT_EQ(0x55, pData[0]) << "Memory read not same as write";
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600166
Mark Lobodzinski2141f652015-09-07 13:59:43 -0600167 vkUnmapMemory(device(), gpu_mem);
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600168
Chia-I Wuf7458c52015-10-26 21:10:41 +0800169 vkFreeMemory(device(), gpu_mem, NULL);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600170}
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600171
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600172TEST_F(VkTest, Event) {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600173 VkEventCreateInfo event_info;
174 VkEvent event;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600175 VkResult err;
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600176
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600177 // typedef struct VkEventCreateInfo_
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600178 // {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600179 // VkStructureType sType; // Must be VK_STRUCTURE_TYPE_EVENT_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600180 // const void* pNext; // Pointer to next structure
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600181 // VkFlags flags; // Reserved
182 // } VkEventCreateInfo;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600183 memset(&event_info, 0, sizeof(event_info));
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600184 event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO;
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600185
Chia-I Wuf7458c52015-10-26 21:10:41 +0800186 err = vkCreateEvent(device(), &event_info, NULL, &event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600187 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600188
Mike Stroyanb050c682015-04-17 12:36:38 -0600189 err = vkResetEvent(device(), event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600190 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600191
Mike Stroyanb050c682015-04-17 12:36:38 -0600192 err = vkGetEventStatus(device(), event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600193 ASSERT_EQ(VK_EVENT_RESET, err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600194
Mike Stroyanb050c682015-04-17 12:36:38 -0600195 err = vkSetEvent(device(), event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600196 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600197
Mike Stroyanb050c682015-04-17 12:36:38 -0600198 err = vkGetEventStatus(device(), event);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600199 ASSERT_EQ(VK_EVENT_SET, err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600200
201 // TODO: Test actual synchronization with command buffer event.
202
203 // All done with event memory, clean up
Chia-I Wuf7458c52015-10-26 21:10:41 +0800204 vkDestroyEvent(device(), event, NULL);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600205}
206
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600207#define MAX_QUERY_SLOTS 10
208
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600209TEST_F(VkTest, Query) {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600210 VkQueryPoolCreateInfo query_info;
211 VkQueryPool query_pool;
Chia-I Wu99ff89d2014-12-27 14:14:50 +0800212 size_t query_result_size;
Chia-I Wuccc93a72015-10-26 18:36:20 +0800213 uint8_t *query_result_data;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600214 VkResult err;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600215
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600216 // typedef enum VkQueryType_
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600217 // {
Tony Barbourd1c35722015-04-16 15:59:00 -0600218 // VK_QUERY_TYPE_OCCLUSION = 0x00000000,
219 // VK_QUERY_TYPE_PIPELINE_STATISTICS = 0x00000001,
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600220
Tony Barbourd1c35722015-04-16 15:59:00 -0600221 // VK_QUERY_TYPE_BEGIN_RANGE = VK_QUERY_TYPE_OCCLUSION,
222 // VK_QUERY_TYPE_END_RANGE = VK_QUERY_TYPE_PIPELINE_STATISTICS,
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600223 // VK_NUM_QUERY_TYPE = (VK_QUERY_TYPE_END_RANGE - VK_QUERY_TYPE_BEGIN_RANGE + 1),
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600224 // VK_MAX_ENUM(VkQueryType_)
225 // } VkQueryType;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600226
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600227 // typedef struct VkQueryPoolCreateInfo_
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600228 // {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600229 // VkStructureType sType; // Must be VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600230 // const void* pNext; // Pointer to next structure
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600231 // VkQueryType queryType;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600232 // uint32_t slots;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600233 // } VkQueryPoolCreateInfo;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600234
235 memset(&query_info, 0, sizeof(query_info));
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600236 query_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
Tony Barbourd1c35722015-04-16 15:59:00 -0600237 query_info.queryType = VK_QUERY_TYPE_OCCLUSION;
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600238 query_info.slots = MAX_QUERY_SLOTS;
239
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600240 // VkResult VKAPI vkCreateQueryPool(
241 // VkDevice device,
242 // const VkQueryPoolCreateInfo* pCreateInfo,
243 // VkQueryPool* pQueryPool);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600244
Chia-I Wuf7458c52015-10-26 21:10:41 +0800245 err = vkCreateQueryPool(device(), &query_info, NULL, &query_pool);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600246 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600247
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600248 // TODO: Test actual synchronization with command buffer event.
249 // TODO: Create command buffer
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600250 // TODO: vkCmdResetQueryPool
251 // TODO: vkCmdBeginQuery
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600252 // TODO: commands
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600253 // TOOD: vkCmdEndQuery
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600254
Chia-I Wuccc93a72015-10-26 18:36:20 +0800255 query_result_size = MAX_QUERY_SLOTS * sizeof(uint64_t);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600256 if (query_result_size > 0) {
Chia-I Wuccc93a72015-10-26 18:36:20 +0800257 query_result_data = new uint8_t [query_result_size];
Mike Stroyanb050c682015-04-17 12:36:38 -0600258 err = vkGetQueryPoolResults(device(), query_pool, 0, MAX_QUERY_SLOTS,
Chia-I Wuccc93a72015-10-26 18:36:20 +0800259 query_result_size, query_result_data,
260 sizeof(uint64_t), VK_QUERY_RESULT_64_BIT);
Jon Ashburne3f31082015-10-02 09:35:45 -0700261 //ASSERT_VK_SUCCESS(err); TODO fix once actually submit queries
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600262
263 // TODO: Test Query result data.
264
265 }
266
Chia-I Wuf7458c52015-10-26 21:10:41 +0800267 vkDestroyQueryPool(device(), query_pool, NULL);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600268}
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600269
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600270void getQueue(vk_testing::Device *device, uint32_t queue_node_index, const char *qname)
Courtney Goeltzenleuchter3dc07f22014-08-14 10:15:09 -0600271{
Cody Northropd2ad0342015-08-05 11:15:02 -0600272 uint32_t que_idx;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600273 VkQueue queue;
Courtney Goeltzenleuchter3dc07f22014-08-14 10:15:09 -0600274
Cody Northropd0802882015-08-03 17:04:53 -0600275 const VkQueueFamilyProperties props = device->phy().queue_properties()[queue_node_index];
Chia-I Wufe84fe12014-12-29 15:39:23 +0800276 for (que_idx = 0; que_idx < props.queueCount; que_idx++) {
Mark Lobodzinski40f7f402015-04-16 11:44:05 -0500277 // TODO: Need to add support for separate MEMMGR and work queues, including synchronization
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600278 vkGetDeviceQueue(device->handle(), queue_node_index, que_idx, &queue);
Courtney Goeltzenleuchter3dc07f22014-08-14 10:15:09 -0600279 }
280}
281
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600282void VkTest::CreateImageTest()
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600283{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600284 VkResult err;
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600285 bool pass;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600286 VkImage image;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600287 uint32_t w, h, mipCount;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600288 VkFormat fmt;
289 VkFormatProperties image_fmt;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600290
291 w =512;
292 h = 256;
293 mipCount = 0;
294
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600295 uint32_t _w = w;
296 uint32_t _h = h;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600297 while( ( _w > 0 ) || ( _h > 0 ) )
298 {
299 _w >>= 1;
300 _h >>= 1;
301 mipCount++;
302 }
303
Tony Barbourd1c35722015-04-16 15:59:00 -0600304 fmt = VK_FORMAT_R8G8B8A8_UINT;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600305 // TODO: Pick known good format rather than just expect common format
306 /*
307 * XXX: What should happen if given NULL HANDLE for the pData argument?
Tony Barbourd1c35722015-04-16 15:59:00 -0600308 * We're not requesting VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS so there is
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600309 * an expectation that pData is a valid pointer.
310 * However, why include a returned size value? That implies that the
311 * amount of data may vary and that doesn't work well for using a
312 * fixed structure.
313 */
314
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600315 vkGetPhysicalDeviceFormatProperties(objs[m_device_id], fmt, &image_fmt);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600316
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600317// typedef struct VkImageCreateInfo_
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600318// {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600319// VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600320// const void* pNext; // Pointer to next structure.
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600321// VkImageType imageType;
322// VkFormat format;
323// VkExtent3D extent;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600324// uint32_t mipLevels;
325// uint32_t arraySize;
326// uint32_t samples;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600327// VkImageTiling tiling;
328// VkFlags usage; // VkImageUsageFlags
329// VkFlags flags; // VkImageCreateFlags
330// } VkImageCreateInfo;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600331
332
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600333 VkImageCreateInfo imageCreateInfo = {};
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600334 imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
Tony Barbourd1c35722015-04-16 15:59:00 -0600335 imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600336 imageCreateInfo.format = fmt;
Courtney Goeltzenleuchter5d2aed42015-10-21 17:57:31 -0600337 imageCreateInfo.arrayLayers = 1;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600338 imageCreateInfo.extent.width = w;
339 imageCreateInfo.extent.height = h;
340 imageCreateInfo.extent.depth = 1;
341 imageCreateInfo.mipLevels = mipCount;
342 imageCreateInfo.samples = 1;
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600343 if (image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
344 imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR;
345 }
346 else if (image_fmt.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
347 imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
348 }
349 else {
350 FAIL() << "Neither Linear nor Optimal allowed for color attachment";
351 }
Cody Northropbb6fdb32015-06-17 08:28:19 -0600352 imageCreateInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
353 VK_IMAGE_USAGE_SAMPLED_BIT;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600354
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600355// VkResult VKAPI vkCreateImage(
356// VkDevice device,
357// const VkImageCreateInfo* pCreateInfo,
358// VkImage* pImage);
Chia-I Wuf7458c52015-10-26 21:10:41 +0800359 err = vkCreateImage(device(), &imageCreateInfo, NULL, &image);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600360 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600361
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600362 // Verify image resources
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600363// void VKAPI vkGetImageSubresourceLayout(
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600364// VkImage image,
365// const VkImageSubresource* pSubresource,
Tony Barbour59a47322015-06-24 16:06:58 -0600366// VkSubresourceLayout* pLayout);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600367// typedef struct VkSubresourceLayout_
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600368// {
Tony Barbourd1c35722015-04-16 15:59:00 -0600369// VkDeviceSize offset; // Specified in bytes
370// VkDeviceSize size; // Specified in bytes
371// VkDeviceSize rowPitch; // Specified in bytes
372// VkDeviceSize depthPitch; // Specified in bytes
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600373// } VkSubresourceLayout;
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600374
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600375// typedef struct VkImageSubresource_
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600376// {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600377// VkImageAspect aspect;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600378// uint32_t mipLevel;
Courtney Goeltzenleuchter4a261892015-09-10 16:38:41 -0600379// uint32_t arrayLayer;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600380// } VkImageSubresource;
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600381
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600382
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600383 if (image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
384 VkImageSubresource subresource = {};
Courtney Goeltzenleuchter908e7672015-10-21 17:00:51 -0600385 subresource.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
Courtney Goeltzenleuchter4a261892015-09-10 16:38:41 -0600386 subresource.arrayLayer = 0;
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600387
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600388 _w = w;
389 _h = h;
390 while ((_w > 0) || (_h > 0))
391 {
392 VkSubresourceLayout layout = {};
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600393 vkGetImageSubresourceLayout(device(), image, &subresource, &layout);
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600394
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600395 // TODO: 4 should be replaced with pixel size for given format
396 EXPECT_LE(_w * 4, layout.rowPitch) << "Pitch does not match expected image pitch";
397 _w >>= 1;
398 _h >>= 1;
399
400 subresource.mipLevel++;
401 }
Courtney Goeltzenleuchter7bf0ff82014-08-14 17:40:57 -0600402 }
403
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600404 VkMemoryRequirements mem_req;
Tony Barbourd1c35722015-04-16 15:59:00 -0600405 VkDeviceMemory image_mem;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600406
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600407 vkGetImageMemoryRequirements(device(), image, &mem_req);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600408
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600409 if (mem_req.size) {
410
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800411 // VkResult VKAPI vkAllocateMemory(
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600412 // VkDevice device,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800413 // const VkMemoryAllocateInfo* pAllocateInfo,
414 // VkDeviceMemory* pMemory);
415 VkMemoryAllocateInfo mem_info = {};
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600416
417 mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
418 mem_info.pNext = NULL;
419 mem_info.allocationSize = mem_req.size;
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600420 mem_info.memoryTypeIndex = 0;
421
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600422 pass = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
423 ASSERT_TRUE(pass);
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600424
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800425 err = vkAllocateMemory(device(), &mem_info, NULL, &image_mem);
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600426 ASSERT_VK_SUCCESS(err);
427
Tony Barbour67e99152015-07-10 14:10:27 -0600428 err = vkBindImageMemory(device(), image, image_mem, 0);
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600429 ASSERT_VK_SUCCESS(err);
430 }
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600431
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600432// typedef struct VkImageViewCreateInfo_
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600433// {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600434// VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600435// const void* pNext; // Pointer to next structure
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600436// VkImage image;
437// VkImageViewType viewType;
438// VkFormat format;
Chia-I Wu1b99bb22015-10-27 19:25:11 +0800439// VkComponentMapping channels;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600440// VkImageSubresourceRange subresourceRange;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600441// float minLod;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600442// } VkImageViewCreateInfo;
443 VkImageViewCreateInfo viewInfo = {};
444 VkImageView view;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600445 viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600446 viewInfo.image = image;
Tony Barbourd1c35722015-04-16 15:59:00 -0600447 viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600448 viewInfo.format = fmt;
449
Chia-I Wu1b99bb22015-10-27 19:25:11 +0800450 viewInfo.channels.r = VK_COMPONENT_SWIZZLE_R;
451 viewInfo.channels.g = VK_COMPONENT_SWIZZLE_G;
452 viewInfo.channels.b = VK_COMPONENT_SWIZZLE_B;
453 viewInfo.channels.a = VK_COMPONENT_SWIZZLE_A;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600454
Courtney Goeltzenleuchter4a261892015-09-10 16:38:41 -0600455 viewInfo.subresourceRange.baseArrayLayer = 0;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800456 viewInfo.subresourceRange.layerCount = 1;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600457 viewInfo.subresourceRange.baseMipLevel = 0;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800458 viewInfo.subresourceRange.levelCount = 1;
Courtney Goeltzenleuchterba724512015-09-10 17:58:54 -0600459 viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600460
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600461// VkResult VKAPI vkCreateImageView(
462// VkDevice device,
463// const VkImageViewCreateInfo* pCreateInfo,
464// VkImageView* pView);
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600465
Chia-I Wuf7458c52015-10-26 21:10:41 +0800466 err = vkCreateImageView(device(), &viewInfo, NULL, &view);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600467 ASSERT_VK_SUCCESS(err) << "vkCreateImageView failed";
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600468
469 // TODO: Test image memory.
470
471 // All done with image memory, clean up
Chia-I Wuf7458c52015-10-26 21:10:41 +0800472 vkDestroyImageView(device(), view, NULL);
473 vkDestroyImage(device(), image, NULL);
Courtney Goeltzenleuchter10642562015-06-22 16:26:54 -0600474
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600475 if (mem_req.size) {
Chia-I Wuf7458c52015-10-26 21:10:41 +0800476 vkFreeMemory(device(), image_mem, NULL);
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600477 }
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600478}
479
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600480TEST_F(VkTest, CreateImage) {
Courtney Goeltzenleuchter794555b2014-08-13 17:55:12 -0600481 CreateImageTest();
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600482}
483
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600484void VkTest::CreateCommandBufferTest()
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600485{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600486 VkResult err;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800487 VkCommandBufferAllocateInfo info = {};
488 VkCommandPool commandPool;
489 VkCommandBuffer commandBuffer;
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600490
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800491// typedef struct VkCommandBufferCreateInfo_
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600492// {
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800493// VkStructureType sType; // Must be VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600494// const void* pNext;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600495// VK_QUEUE_TYPE queueType;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600496// VkFlags flags;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800497// } VkCommandBufferAllocateInfo;
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600498
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800499 VkCommandPoolCreateInfo cmd_pool_info;
500 cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
Cody Northrope62183e2015-07-09 18:08:05 -0600501 cmd_pool_info.pNext = NULL,
502 cmd_pool_info.queueFamilyIndex = graphics_queue_node_index;
503 cmd_pool_info.flags = 0,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800504 err = vkCreateCommandPool(device(), &cmd_pool_info, NULL, &commandPool);
Cody Northrope62183e2015-07-09 18:08:05 -0600505 ASSERT_VK_SUCCESS(err) << "vkCreateCommandPool failed";
506
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800507 info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO;
508 info.commandPool = commandPool;
Chia-I Wud50a7d72015-10-26 20:48:51 +0800509 info.bufferCount = 1;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800510 info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
511 err = vkAllocateCommandBuffers(device(), &info, &commandBuffer);
512 ASSERT_VK_SUCCESS(err) << "vkAllocateCommandBuffers failed";
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600513
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800514 vkFreeCommandBuffers(device(), commandPool, 1, &commandBuffer);
515 vkDestroyCommandPool(device(), commandPool, NULL);
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600516}
517
Tony-LunarGd61e1e52015-05-15 12:42:49 -0600518TEST_F(VkTest, TestCommandBuffer) {
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600519 CreateCommandBufferTest();
520}
521
Courtney Goeltzenleuchterd2635502015-10-21 17:08:06 -0600522void VkTest::CreateShader(VkShader *pshader, VkShaderStageFlagBits stage)
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600523{
Chia-I Wu8094f192015-10-26 19:22:06 +0800524 uint32_t *code;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600525 uint32_t codeSize;
Cody Northrop3bfd27c2015-03-17 15:55:58 -0600526 struct icd_spv_header *pSPV;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600527 VkResult err;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600528
Chia-I Wu8094f192015-10-26 19:22:06 +0800529 codeSize = sizeof(struct icd_spv_header) + sizeof(uint32_t) * 25;
530 code = (uint32_t *) malloc(codeSize);
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600531 ASSERT_TRUE(NULL != code) << "malloc failed!";
532
533 memset(code, 0, codeSize);
534
Cody Northrop3bfd27c2015-03-17 15:55:58 -0600535 // Indicate that this is SPV data.
536 pSPV = (struct icd_spv_header *) code;
537 pSPV->magic = ICD_SPV_MAGIC;
538 pSPV->version = ICD_SPV_VERSION;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600539
Courtney Goeltzenleuchteree4027d2015-06-28 13:01:17 -0600540 VkShaderModuleCreateInfo moduleCreateInfo;
541 VkShaderModule module;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600542 VkShaderCreateInfo createInfo;
543 VkShader shader;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600544
Courtney Goeltzenleuchteree4027d2015-06-28 13:01:17 -0600545 moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
546 moduleCreateInfo.pNext = NULL;
547 moduleCreateInfo.pCode = code;
548 moduleCreateInfo.codeSize = codeSize;
549 moduleCreateInfo.flags = 0;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800550 err = vkCreateShaderModule(device(), &moduleCreateInfo, NULL, &module);
Courtney Goeltzenleuchteree4027d2015-06-28 13:01:17 -0600551 ASSERT_VK_SUCCESS(err);
552
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600553 createInfo.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO;
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600554 createInfo.pNext = NULL;
Courtney Goeltzenleuchteree4027d2015-06-28 13:01:17 -0600555 createInfo.module = module;
556 createInfo.pName = "main";
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600557 createInfo.flags = 0;
Cody Northropfd4bcfd2015-08-24 15:11:10 -0600558 createInfo.stage = stage;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800559 err = vkCreateShader(device(), &createInfo, NULL, &shader);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600560 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -0600561
Chia-I Wuf7458c52015-10-26 21:10:41 +0800562 vkDestroyShaderModule(device(), module, NULL);
Courtney Goeltzenleuchteree4027d2015-06-28 13:01:17 -0600563
Courtney Goeltzenleuchterde3513a2014-08-20 15:26:55 -0600564 *pshader = shader;
565}
566
Courtney Goeltzenleuchter75011f82014-08-12 09:59:36 -0600567int main(int argc, char **argv) {
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600568 ::testing::InitGoogleTest(&argc, argv);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600569 vk_testing::set_error_callback(test_error_callback);
Courtney Goeltzenleuchtercc9da542014-08-12 14:12:22 -0600570 return RUN_ALL_TESTS();
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -0600571}