| Courtney Goeltzenleuchter | 447ed58 | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 1 | // 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 Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 30 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 31 | //  VK tests | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 32 | // | 
 | 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 Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 54 | // Verify VK driver initialization | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 55 |  | 
| Courtney Goeltzenleuchter | 447ed58 | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 56 | #include <stdlib.h> | 
 | 57 | #include <stdio.h> | 
 | 58 | #include <stdbool.h> | 
 | 59 | #include <string.h> | 
 | 60 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 61 | #include <vulkan.h> | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 62 | #include "gtest-1.7.0/include/gtest/gtest.h" | 
| Courtney Goeltzenleuchter | 447ed58 | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 63 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 64 | #include "vktestbinding.h" | 
| Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 65 | #include "test_common.h" | 
| Cody Northrop | 054a470 | 2015-03-17 14:54:35 -0600 | [diff] [blame] | 66 | #include "icd-spv.h" | 
| Courtney Goeltzenleuchter | 447ed58 | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 67 |  | 
| Jon Ashburn | 83a6425 | 2015-04-15 11:31:12 -0600 | [diff] [blame] | 68 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) | 
 | 69 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 70 | class VkTest : public ::testing::Test { | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 71 | public: | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 72 |     void CreateImageTest(); | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 73 |     void CreateCommandBufferTest(); | 
 | 74 |     void CreatePipelineTest(); | 
 | 75 |     void CreateShaderTest(); | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 76 |     void CreateShader(VkShader *pshader); | 
| Courtney Goeltzenleuchter | 447ed58 | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 77 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 78 |     VkDevice device() {return m_device->obj();} | 
| Courtney Goeltzenleuchter | cc5eb3a | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 79 |  | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 80 | protected: | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 81 |     VkApplicationInfo app_info; | 
 | 82 |     VkInstance inst; | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 83 |     VkPhysicalDevice objs[16]; | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 84 |     uint32_t gpu_count; | 
| Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 85 |  | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 86 |     uint32_t m_device_id; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 87 |     vk_testing::Device *m_device; | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 88 |     VkPhysicalDeviceProperties props; | 
 | 89 |     std::vector<VkPhysicalDeviceQueueProperties> queue_props; | 
| Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 90 |     uint32_t graphics_queue_node_index; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 91 |  | 
 | 92 |     virtual void SetUp() { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 93 |         VkResult err; | 
| Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 94 |         int i; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 95 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 96 |         this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 97 |         this->app_info.pNext = NULL; | 
| Chia-I Wu | f1a5a74 | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 98 |         this->app_info.pAppName = "base"; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 99 |         this->app_info.appVersion = 1; | 
| Chia-I Wu | f1a5a74 | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 100 |         this->app_info.pEngineName = "unittest"; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 101 |         this->app_info.engineVersion = 1; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 102 |         this->app_info.apiVersion = VK_API_VERSION; | 
| Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 103 |         VkInstanceCreateInfo inst_info = {}; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 104 |         inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; | 
| Jon Ashburn | b317fad | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 105 |         inst_info.pNext = NULL; | 
 | 106 |         inst_info.pAppInfo = &app_info; | 
 | 107 |         inst_info.pAllocCb = NULL; | 
 | 108 |         inst_info.extensionCount = 0; | 
| Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 109 |         inst_info.pEnabledExtensions = NULL; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 110 |         err = vkCreateInstance(&inst_info, &inst); | 
 | 111 |         ASSERT_VK_SUCCESS(err); | 
| Jon Ashburn | 83a6425 | 2015-04-15 11:31:12 -0600 | [diff] [blame] | 112 |         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 Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 116 |         ASSERT_VK_SUCCESS(err); | 
| Jon Ashburn | bf843b2 | 2014-11-26 11:06:49 -0700 | [diff] [blame] | 117 |         ASSERT_GE(this->gpu_count, 1) << "No GPU available"; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 118 |  | 
| Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 119 |         m_device_id = 0; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 120 |         this->m_device = new vk_testing::Device(objs[m_device_id]); | 
| Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 121 |         this->m_device->init(); | 
 | 122 |  | 
 | 123 |         props = m_device->gpu().properties(); | 
| Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 124 |  | 
| Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 125 |         queue_props = this->m_device->gpu().queue_properties(); | 
 | 126 |         for (i = 0; i < queue_props.size(); i++) { | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 127 |             if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { | 
| Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 128 |                 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 Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 133 |     } | 
 | 134 |  | 
 | 135 |     virtual void TearDown() { | 
| Tony Barbour | c2f67f5 | 2015-06-02 14:55:46 -0600 | [diff] [blame] | 136 |         delete m_device; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 137 |         vkDestroyInstance(inst); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 138 |     } | 
 | 139 | }; | 
 | 140 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 141 | TEST_F(VkTest, AllocMemory) { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 142 |     VkResult err; | 
| Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 143 |     VkMemoryAllocInfo alloc_info = {}; | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 144 |     VkDeviceMemory gpu_mem; | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 145 |     uint8_t *pData; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 146 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 147 |     alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 148 |     alloc_info.allocationSize = 1024 * 1024; // 1MB | 
| Courtney Goeltzenleuchter | 908aa75 | 2015-06-18 17:01:41 -0600 | [diff] [blame] | 149 |     alloc_info.memProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | 
| Tony Barbour | f52346d | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 150 |  | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 151 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 152 |     err = vkAllocMemory(device(), &alloc_info, &gpu_mem); | 
 | 153 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | 447ed58 | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 154 |  | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 155 |     err = vkMapMemory(device(), gpu_mem, 0, 0, 0, (void **) &pData); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 156 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | 75011f8 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 157 |  | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 158 |     memset(pData, 0x55, alloc_info.allocationSize); | 
 | 159 |     EXPECT_EQ(0x55, pData[0]) << "Memory read not same a write"; | 
 | 160 |  | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 161 |     err = vkUnmapMemory(device(), gpu_mem); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 162 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | 75011f8 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 163 |  | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 164 |     err = vkFreeMemory(device(), gpu_mem); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 165 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 166 | } | 
| Courtney Goeltzenleuchter | 75011f8 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 167 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 168 | TEST_F(VkTest, Event) { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 169 |     VkEventCreateInfo event_info; | 
 | 170 |     VkEvent event; | 
 | 171 |     VkMemoryRequirements mem_req; | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 172 |     VkDeviceMemory event_mem; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 173 |     VkResult err; | 
| Courtney Goeltzenleuchter | 75011f8 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 174 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 175 |     //        typedef struct VkEventCreateInfo_ | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 176 |     //        { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 177 |     //            VkStructureType                      sType;      // Must be VK_STRUCTURE_TYPE_EVENT_CREATE_INFO | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 178 |     //            const void*                             pNext;      // Pointer to next structure | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 179 |     //            VkFlags                               flags;      // Reserved | 
 | 180 |     //        } VkEventCreateInfo; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 181 |     memset(&event_info, 0, sizeof(event_info)); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 182 |     event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | 
| Courtney Goeltzenleuchter | 75011f8 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 183 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 184 |     err = vkCreateEvent(device(), &event_info, &event); | 
 | 185 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 186 |  | 
| Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 187 |     err = vkGetObjectMemoryRequirements(device(), VK_OBJECT_TYPE_EVENT, event, &mem_req); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 188 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 189 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 190 |     if (mem_req.size) { | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 191 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 192 |         //        VkResult VKAPI vkAllocMemory( | 
 | 193 |         //            VkDevice                                  device, | 
 | 194 |         //            const VkMemoryAllocInfo*                pAllocInfo, | 
 | 195 |         //            VkDeviceMemory*                             pMem); | 
 | 196 |         VkMemoryAllocInfo mem_info; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 197 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 198 |         memset(&mem_info, 0, sizeof(mem_info)); | 
 | 199 |         mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; | 
 | 200 |         mem_info.allocationSize = mem_req.size; | 
| Courtney Goeltzenleuchter | 908aa75 | 2015-06-18 17:01:41 -0600 | [diff] [blame] | 201 |         mem_info.memProps = 0; | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 202 |         err = vkAllocMemory(device(), &mem_info, &event_mem); | 
 | 203 |         ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 204 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 205 |         err = vkBindObjectMemory(device(), VK_OBJECT_TYPE_EVENT, event, event_mem, 0); | 
 | 206 |         ASSERT_VK_SUCCESS(err); | 
 | 207 |     } | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 208 |     err = vkResetEvent(device(), event); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 209 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 210 |  | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 211 |     err = vkGetEventStatus(device(), event); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 212 |     ASSERT_EQ(VK_EVENT_RESET, err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 213 |  | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 214 |     err = vkSetEvent(device(), event); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 215 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 216 |  | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 217 |     err = vkGetEventStatus(device(), event); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 218 |     ASSERT_EQ(VK_EVENT_SET, err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 219 |  | 
 | 220 |     // TODO: Test actual synchronization with command buffer event. | 
 | 221 |  | 
 | 222 |     // All done with event memory, clean up | 
| Courtney Goeltzenleuchter | 1064256 | 2015-06-22 16:26:54 -0600 | [diff] [blame] | 223 |     err = vkDestroyObject(device(), VK_OBJECT_TYPE_EVENT, event); | 
 | 224 |     ASSERT_VK_SUCCESS(err); | 
 | 225 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 226 |     if (mem_req.size) { | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 227 |         err = vkFreeMemory(device(), event_mem); | 
 | 228 |         ASSERT_VK_SUCCESS(err); | 
 | 229 |     } | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 230 | } | 
 | 231 |  | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 232 | #define MAX_QUERY_SLOTS 10 | 
 | 233 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 234 | TEST_F(VkTest, Query) { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 235 |     VkQueryPoolCreateInfo query_info; | 
 | 236 |     VkQueryPool query_pool; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 237 |     VkMemoryRequirements mem_req; | 
| Chia-I Wu | 99ff89d | 2014-12-27 14:14:50 +0800 | [diff] [blame] | 238 |     size_t query_result_size; | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 239 |     uint32_t *query_result_data; | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 240 |     VkDeviceMemory query_mem; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 241 |     VkResult err; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 242 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 243 |     //        typedef enum VkQueryType_ | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 244 |     //        { | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 245 |     //            VK_QUERY_TYPE_OCCLUSION                                     = 0x00000000, | 
 | 246 |     //            VK_QUERY_TYPE_PIPELINE_STATISTICS                           = 0x00000001, | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 247 |  | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 248 |     //            VK_QUERY_TYPE_BEGIN_RANGE                              = VK_QUERY_TYPE_OCCLUSION, | 
 | 249 |     //            VK_QUERY_TYPE_END_RANGE                                = VK_QUERY_TYPE_PIPELINE_STATISTICS, | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 250 |     //            VK_NUM_QUERY_TYPE                                      = (VK_QUERY_TYPE_END_RANGE - VK_QUERY_TYPE_BEGIN_RANGE + 1), | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 251 |     //            VK_MAX_ENUM(VkQueryType_) | 
 | 252 |     //        } VkQueryType; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 253 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 254 |     //        typedef struct VkQueryPoolCreateInfo_ | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 255 |     //        { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 256 |     //            VkStructureType                      sType;      // Must be VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 257 |     //            const void*                             pNext;      // Pointer to next structure | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 258 |     //            VkQueryType                          queryType; | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 259 |     //            uint32_t                                slots; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 260 |     //        } VkQueryPoolCreateInfo; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 261 |  | 
 | 262 |     memset(&query_info, 0, sizeof(query_info)); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 263 |     query_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 264 |     query_info.queryType = VK_QUERY_TYPE_OCCLUSION; | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 265 |     query_info.slots = MAX_QUERY_SLOTS; | 
 | 266 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 267 |     //        VkResult VKAPI vkCreateQueryPool( | 
 | 268 |     //            VkDevice                                  device, | 
 | 269 |     //            const VkQueryPoolCreateInfo*           pCreateInfo, | 
 | 270 |     //            VkQueryPool*                             pQueryPool); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 271 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 272 |     err = vkCreateQueryPool(device(), &query_info, &query_pool); | 
 | 273 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 274 |  | 
| Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 275 |     err = vkGetObjectMemoryRequirements(device(), VK_OBJECT_TYPE_QUERY_POOL, query_pool, &mem_req); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 276 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 277 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 278 |     if (mem_req.size) { | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 279 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 280 |         //        VkResult VKAPI vkAllocMemory( | 
 | 281 |         //            VkDevice                                  device, | 
 | 282 |         //            const VkMemoryAllocInfo*                pAllocInfo, | 
 | 283 |         //            VkDeviceMemory*                             pMem); | 
 | 284 |         VkMemoryAllocInfo mem_info; | 
 | 285 |  | 
 | 286 |         memset(&mem_info, 0, sizeof(mem_info)); | 
 | 287 |         mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; | 
 | 288 |         // TODO: Is a simple multiple all that's needed here? | 
 | 289 |         mem_info.allocationSize = mem_req.size * MAX_QUERY_SLOTS; | 
| Courtney Goeltzenleuchter | 908aa75 | 2015-06-18 17:01:41 -0600 | [diff] [blame] | 290 |         mem_info.memProps = 0; | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 291 |         err = vkAllocMemory(device(), &mem_info, &query_mem); | 
 | 292 |         ASSERT_VK_SUCCESS(err); | 
 | 293 |  | 
 | 294 |         err = vkBindObjectMemory(device(), VK_OBJECT_TYPE_QUERY_POOL, query_pool, query_mem, 0); | 
 | 295 |         ASSERT_VK_SUCCESS(err); | 
 | 296 |     } | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 297 |     // TODO: Test actual synchronization with command buffer event. | 
 | 298 |     // TODO: Create command buffer | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 299 |     // TODO: vkCmdResetQueryPool | 
 | 300 |     // TODO: vkCmdBeginQuery | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 301 |     // TODO: commands | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 302 |     // TOOD: vkCmdEndQuery | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 303 |  | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 304 |     err = vkGetQueryPoolResults(device(), query_pool, 0, MAX_QUERY_SLOTS, | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 305 |                                  &query_result_size, VK_NULL_HANDLE, 0); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 306 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 307 |  | 
 | 308 |     if (query_result_size > 0) { | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 309 |         query_result_data = new uint32_t [query_result_size]; | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 310 |         err = vkGetQueryPoolResults(device(), query_pool, 0, MAX_QUERY_SLOTS, | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 311 |                                      &query_result_size, query_result_data, 0); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 312 |         ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 313 |  | 
 | 314 |         // TODO: Test Query result data. | 
 | 315 |  | 
 | 316 |     } | 
 | 317 |  | 
| Courtney Goeltzenleuchter | 1064256 | 2015-06-22 16:26:54 -0600 | [diff] [blame] | 318 |     err = vkDestroyObject(device(), VK_OBJECT_TYPE_QUERY_POOL, query_pool); | 
 | 319 |     ASSERT_VK_SUCCESS(err); | 
 | 320 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 321 |     if (mem_req.size) { | 
 | 322 |         // All done with QueryPool memory, clean up | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 323 |         err = vkFreeMemory(device(), query_mem); | 
 | 324 |         ASSERT_VK_SUCCESS(err); | 
 | 325 |     } | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 326 | } | 
| Courtney Goeltzenleuchter | 75011f8 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 327 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 328 | void getQueue(vk_testing::Device *device, uint32_t queue_node_index, const char *qname) | 
| Courtney Goeltzenleuchter | 3dc07f2 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 329 | { | 
 | 330 |     int que_idx; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 331 |     VkResult err; | 
 | 332 |     VkQueue queue; | 
| Courtney Goeltzenleuchter | 3dc07f2 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 333 |  | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 334 |     const VkPhysicalDeviceQueueProperties props = device->gpu().queue_properties()[queue_node_index]; | 
| Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 335 |     for (que_idx = 0; que_idx < props.queueCount; que_idx++) { | 
| Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 336 |         // TODO: Need to add support for separate MEMMGR and work queues, including synchronization | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 337 |         err = vkGetDeviceQueue(device->obj(), queue_node_index, que_idx, &queue); | 
 | 338 |         ASSERT_EQ(VK_SUCCESS, err) << "vkGetDeviceQueue: " << qname << " queue #" << que_idx << ": Failed with error: " << vk_result_string(err); | 
| Courtney Goeltzenleuchter | 3dc07f2 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 339 |     } | 
 | 340 | } | 
 | 341 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 342 | void VkTest::CreateImageTest() | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 343 | { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 344 |     VkResult err; | 
 | 345 |     VkImage image; | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 346 |     uint32_t w, h, mipCount; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 347 |     VkFormat fmt; | 
 | 348 |     VkFormatProperties image_fmt; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 349 |  | 
 | 350 |     w =512; | 
 | 351 |     h = 256; | 
 | 352 |     mipCount = 0; | 
 | 353 |  | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 354 |     uint32_t _w = w; | 
 | 355 |     uint32_t _h = h; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 356 |     while( ( _w > 0 ) || ( _h > 0 ) ) | 
 | 357 |     { | 
 | 358 |         _w >>= 1; | 
 | 359 |         _h >>= 1; | 
 | 360 |         mipCount++; | 
 | 361 |     } | 
 | 362 |  | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 363 |     fmt = VK_FORMAT_R8G8B8A8_UINT; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 364 |     // TODO: Pick known good format rather than just expect common format | 
 | 365 |     /* | 
 | 366 |      * XXX: What should happen if given NULL HANDLE for the pData argument? | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 367 |      * We're not requesting VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS so there is | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 368 |      * an expectation that pData is a valid pointer. | 
 | 369 |      * However, why include a returned size value? That implies that the | 
 | 370 |      * amount of data may vary and that doesn't work well for using a | 
 | 371 |      * fixed structure. | 
 | 372 |      */ | 
 | 373 |  | 
| Chris Forbes | bc0bb77 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 374 |     err = vkGetPhysicalDeviceFormatInfo(objs[m_device_id], fmt, &image_fmt); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 375 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 376 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 377 | //    typedef struct VkImageCreateInfo_ | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 378 | //    { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 379 | //        VkStructureType                      sType;                      // Must be VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 380 | //        const void*                             pNext;                      // Pointer to next structure. | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 381 | //        VkImageType                          imageType; | 
 | 382 | //        VkFormat                              format; | 
 | 383 | //        VkExtent3D                            extent; | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 384 | //        uint32_t                                mipLevels; | 
 | 385 | //        uint32_t                                arraySize; | 
 | 386 | //        uint32_t                                samples; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 387 | //        VkImageTiling                        tiling; | 
 | 388 | //        VkFlags                               usage;                      // VkImageUsageFlags | 
 | 389 | //        VkFlags                               flags;                      // VkImageCreateFlags | 
 | 390 | //    } VkImageCreateInfo; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 391 |  | 
 | 392 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 393 |     VkImageCreateInfo imageCreateInfo = {}; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 394 |     imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 395 |     imageCreateInfo.imageType = VK_IMAGE_TYPE_2D; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 396 |     imageCreateInfo.format = fmt; | 
 | 397 |     imageCreateInfo.arraySize = 1; | 
 | 398 |     imageCreateInfo.extent.width = w; | 
 | 399 |     imageCreateInfo.extent.height = h; | 
 | 400 |     imageCreateInfo.extent.depth = 1; | 
 | 401 |     imageCreateInfo.mipLevels = mipCount; | 
 | 402 |     imageCreateInfo.samples = 1; | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 403 |     if (image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) { | 
 | 404 |         imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR; | 
 | 405 |     } | 
 | 406 |     else if (image_fmt.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) { | 
 | 407 |         imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL; | 
 | 408 |     } | 
 | 409 |     else { | 
 | 410 |         FAIL() << "Neither Linear nor Optimal allowed for color attachment"; | 
 | 411 |     } | 
| Courtney Goeltzenleuchter | b9776ab | 2015-04-15 15:29:59 -0600 | [diff] [blame] | 412 |     imageCreateInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 413 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 414 | //    VkResult VKAPI vkCreateImage( | 
 | 415 | //        VkDevice                                  device, | 
 | 416 | //        const VkImageCreateInfo*                pCreateInfo, | 
 | 417 | //        VkImage*                                  pImage); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 418 |     err = vkCreateImage(device(), &imageCreateInfo, &image); | 
 | 419 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 420 |  | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 421 |     // Verify image resources | 
| Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 422 | //    VkResult VKAPI vkGetImageSubresourceLayout( | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 423 | //        VkImage                                   image, | 
 | 424 | //        const VkImageSubresource*                pSubresource, | 
| Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 425 | //        VkSubresourceLayout*                     pLayout); | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 426 | //    typedef struct VkSubresourceLayout_ | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 427 | //    { | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 428 | //        VkDeviceSize                            offset;                 // Specified in bytes | 
 | 429 | //        VkDeviceSize                            size;                   // Specified in bytes | 
 | 430 | //        VkDeviceSize                            rowPitch;               // Specified in bytes | 
 | 431 | //        VkDeviceSize                            depthPitch;             // Specified in bytes | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 432 | //    } VkSubresourceLayout; | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 433 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 434 | //    typedef struct VkImageSubresource_ | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 435 | //    { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 436 | //        VkImageAspect                        aspect; | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 437 | //        uint32_t                                mipLevel; | 
 | 438 | //        uint32_t                                arraySlice; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 439 | //    } VkImageSubresource; | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 440 |  | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 441 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 442 |     if (image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) { | 
 | 443 |         VkImageSubresource subresource = {}; | 
 | 444 |         subresource.aspect = VK_IMAGE_ASPECT_COLOR; | 
 | 445 |         subresource.arraySlice = 0; | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 446 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 447 |         _w = w; | 
 | 448 |         _h = h; | 
 | 449 |         while ((_w > 0) || (_h > 0)) | 
 | 450 |         { | 
 | 451 |             VkSubresourceLayout layout = {}; | 
| Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 452 |             err = vkGetImageSubresourceLayout(device(), image, &subresource, &layout); | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 453 |             ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 454 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 455 |             // TODO: 4 should be replaced with pixel size for given format | 
 | 456 |             EXPECT_LE(_w * 4, layout.rowPitch) << "Pitch does not match expected image pitch"; | 
 | 457 |             _w >>= 1; | 
 | 458 |             _h >>= 1; | 
 | 459 |  | 
 | 460 |             subresource.mipLevel++; | 
 | 461 |         } | 
| Courtney Goeltzenleuchter | 7bf0ff8 | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 462 |     } | 
 | 463 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 464 |     VkMemoryRequirements mem_req; | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 465 |     VkDeviceMemory image_mem; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 466 |  | 
| Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 467 |     err = vkGetObjectMemoryRequirements(device(), VK_OBJECT_TYPE_IMAGE, image, &mem_req); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 468 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 469 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 470 |     if (mem_req.size) { | 
 | 471 |  | 
 | 472 |         //        VkResult VKAPI vkAllocMemory( | 
 | 473 |         //            VkDevice                                  device, | 
 | 474 |         //            const VkMemoryAllocInfo*                pAllocInfo, | 
 | 475 |         //            VkDeviceMemory*                             pMem); | 
 | 476 |         VkMemoryAllocInfo mem_info = {}; | 
 | 477 |  | 
 | 478 |         mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; | 
 | 479 |         mem_info.pNext = NULL; | 
 | 480 |         mem_info.allocationSize = mem_req.size; | 
| Courtney Goeltzenleuchter | 908aa75 | 2015-06-18 17:01:41 -0600 | [diff] [blame] | 481 |         mem_info.memProps = 0; | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 482 |         err = vkAllocMemory(device(), &mem_info, &image_mem); | 
 | 483 |         ASSERT_VK_SUCCESS(err); | 
 | 484 |  | 
 | 485 |         err = vkBindObjectMemory(device(), VK_OBJECT_TYPE_IMAGE, image, image_mem, 0); | 
 | 486 |         ASSERT_VK_SUCCESS(err); | 
 | 487 |     } | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 488 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 489 | //    typedef struct VkImageViewCreateInfo_ | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 490 | //    { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 491 | //        VkStructureType                      sType;                  // Must be VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 492 | //        const void*                             pNext;                  // Pointer to next structure | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 493 | //        VkImage                               image; | 
 | 494 | //        VkImageViewType                     viewType; | 
 | 495 | //        VkFormat                              format; | 
 | 496 | //        VkChannelMapping                     channels; | 
 | 497 | //        VkImageSubresourceRange             subresourceRange; | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 498 | //        float                                   minLod; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 499 | //    } VkImageViewCreateInfo; | 
 | 500 |     VkImageViewCreateInfo viewInfo = {}; | 
 | 501 |     VkImageView view; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 502 |     viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 503 |     viewInfo.image = image; | 
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 504 |     viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 505 |     viewInfo.format = fmt; | 
 | 506 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 507 |     viewInfo.channels.r = VK_CHANNEL_SWIZZLE_R; | 
 | 508 |     viewInfo.channels.g = VK_CHANNEL_SWIZZLE_G; | 
 | 509 |     viewInfo.channels.b = VK_CHANNEL_SWIZZLE_B; | 
 | 510 |     viewInfo.channels.a = VK_CHANNEL_SWIZZLE_A; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 511 |  | 
 | 512 |     viewInfo.subresourceRange.baseArraySlice = 0; | 
 | 513 |     viewInfo.subresourceRange.arraySize = 1; | 
 | 514 |     viewInfo.subresourceRange.baseMipLevel = 0; | 
 | 515 |     viewInfo.subresourceRange.mipLevels = 1; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 516 |     viewInfo.subresourceRange.aspect = VK_IMAGE_ASPECT_COLOR; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 517 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 518 | //    VkResult VKAPI vkCreateImageView( | 
 | 519 | //        VkDevice                                  device, | 
 | 520 | //        const VkImageViewCreateInfo*           pCreateInfo, | 
 | 521 | //        VkImageView*                             pView); | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 522 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 523 |     err = vkCreateImageView(device(), &viewInfo, &view); | 
 | 524 |     ASSERT_VK_SUCCESS(err) << "vkCreateImageView failed"; | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 525 |  | 
 | 526 |     // TODO: Test image memory. | 
 | 527 |  | 
 | 528 |     // All done with image memory, clean up | 
| Courtney Goeltzenleuchter | 1064256 | 2015-06-22 16:26:54 -0600 | [diff] [blame] | 529 |     ASSERT_VK_SUCCESS(vkDestroyObject(device(), VK_OBJECT_TYPE_IMAGE_VIEW, view)); | 
 | 530 |     ASSERT_VK_SUCCESS(vkDestroyObject(device(), VK_OBJECT_TYPE_IMAGE, image)); | 
 | 531 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 532 |     if (mem_req.size) { | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 533 |         ASSERT_VK_SUCCESS(vkFreeMemory(device(), image_mem)); | 
 | 534 |     } | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 535 | } | 
 | 536 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 537 | TEST_F(VkTest, CreateImage) { | 
| Courtney Goeltzenleuchter | 794555b | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 538 |     CreateImageTest(); | 
| Courtney Goeltzenleuchter | 75011f8 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 539 | } | 
 | 540 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 541 | void VkTest::CreateCommandBufferTest() | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 542 | { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 543 |     VkResult err; | 
 | 544 |     VkCmdBufferCreateInfo info = {}; | 
 | 545 |     VkCmdBuffer cmdBuffer; | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 546 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 547 | //    typedef struct VkCmdBufferCreateInfo_ | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 548 | //    { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 549 | //        VkStructureType                      sType;      // Must be VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 550 | //        const void*                             pNext; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 551 | //        VK_QUEUE_TYPE                          queueType; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 552 | //        VkFlags                               flags; | 
 | 553 | //    } VkCmdBufferCreateInfo; | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 554 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 555 |     info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; | 
| Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 556 |     info.queueNodeIndex = graphics_queue_node_index; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 557 |     err = vkCreateCommandBuffer(device(), &info, &cmdBuffer); | 
 | 558 |     ASSERT_VK_SUCCESS(err) << "vkCreateCommandBuffer failed"; | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 559 |  | 
| Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 560 |     ASSERT_VK_SUCCESS(vkDestroyObject(device(), VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer)); | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 561 | } | 
 | 562 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 563 | TEST_F(VkTest, TestCommandBuffer) { | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 564 |     CreateCommandBufferTest(); | 
 | 565 | } | 
 | 566 |  | 
| Tony-LunarG | d61e1e5 | 2015-05-15 12:42:49 -0600 | [diff] [blame] | 567 | void VkTest::CreateShader(VkShader *pshader) | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 568 | { | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 569 |     void *code; | 
 | 570 |     uint32_t codeSize; | 
| Cody Northrop | 3bfd27c | 2015-03-17 15:55:58 -0600 | [diff] [blame] | 571 |     struct icd_spv_header *pSPV; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 572 |     VkResult err; | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 573 |  | 
| Cody Northrop | 3bfd27c | 2015-03-17 15:55:58 -0600 | [diff] [blame] | 574 |     codeSize = sizeof(struct icd_spv_header) + 100; | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 575 |     code = malloc(codeSize); | 
 | 576 |     ASSERT_TRUE(NULL != code) << "malloc failed!"; | 
 | 577 |  | 
 | 578 |     memset(code, 0, codeSize); | 
 | 579 |  | 
| Cody Northrop | 3bfd27c | 2015-03-17 15:55:58 -0600 | [diff] [blame] | 580 |     // Indicate that this is SPV data. | 
 | 581 |     pSPV = (struct icd_spv_header *) code; | 
 | 582 |     pSPV->magic = ICD_SPV_MAGIC; | 
 | 583 |     pSPV->version = ICD_SPV_VERSION; | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 584 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 585 | //    typedef struct VkShaderCreateInfo_ | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 586 | //    { | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 587 | //        VkStructureType                      sType;              // Must be VK_STRUCTURE_TYPE_SHADER_CREATE_INFO | 
| Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 588 | //        const void*                             pNext;              // Pointer to next structure | 
 | 589 | //        size_t                                  codeSize;           // Specified in bytes | 
 | 590 | //        const void*                             pCode; | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 591 | //        VkFlags                               flags;              // Reserved | 
 | 592 | //    } VkShaderCreateInfo; | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 593 |  | 
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 594 |     VkShaderCreateInfo createInfo; | 
 | 595 |     VkShader shader; | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 596 |  | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 597 |     createInfo.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO; | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 598 |     createInfo.pNext = NULL; | 
 | 599 |     createInfo.pCode = code; | 
 | 600 |     createInfo.codeSize = codeSize; | 
 | 601 |     createInfo.flags = 0; | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 602 |     err = vkCreateShader(device(), &createInfo, &shader); | 
 | 603 |     ASSERT_VK_SUCCESS(err); | 
| Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 604 |  | 
| Courtney Goeltzenleuchter | de3513a | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 605 |     *pshader = shader; | 
 | 606 | } | 
 | 607 |  | 
| Courtney Goeltzenleuchter | 75011f8 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 608 | int main(int argc, char **argv) { | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 609 |     ::testing::InitGoogleTest(&argc, argv); | 
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 610 |     vk_testing::set_error_callback(test_error_callback); | 
| Courtney Goeltzenleuchter | cc9da54 | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 611 |     return RUN_ALL_TESTS(); | 
| Courtney Goeltzenleuchter | 447ed58 | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 612 | } |