blob: 6fd07b46ef249e2c961d07c6b28f79ca43a3c04e [file] [log] [blame]
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -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
30
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060031// VK tests
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -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 Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060054// Verify VK driver initialization
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060055
56#include <stdlib.h>
57#include <stdio.h>
58#include <stdbool.h>
59#include <string.h>
60
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060061#include <vulkan.h>
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060062#include "vktestbinding.h"
Chia-I Wu3b78d312014-12-29 15:39:23 +080063#include "test_common.h"
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060064
Jon Ashburn07b309a2015-04-15 11:31:12 -060065#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
66
Tony Barbour01999182015-04-09 12:58:51 -060067class VkImageTest : public ::testing::Test {
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060068public:
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060069 void CreateImage(uint32_t w, uint32_t h);
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -060070 void DestroyImage();
71
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060072 void CreateImageView(VkImageViewCreateInfo* pCreateInfo,
73 VkImageView* pView);
74 void DestroyImageView(VkImageView imageView);
Chia-I Wua2636292015-07-03 10:41:20 +080075 VkDevice device() {return m_device->handle();}
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060076
77protected:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060078 vk_testing::Device *m_device;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060079 VkApplicationInfo app_info;
Tony Barbour8205d902015-04-16 15:59:00 -060080 VkPhysicalDevice objs[16];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060081 uint32_t gpu_count;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060082 VkInstance inst;
83 VkImage m_image;
Mark Lobodzinski23182612015-05-29 09:32:35 -050084 VkDeviceMemory m_image_mem;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060085
86 virtual void SetUp() {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060087 VkResult err;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060088
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060089 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060090 this->app_info.pNext = NULL;
Chia-I Wu7461fcf2014-12-27 15:16:07 +080091 this->app_info.pAppName = "base";
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060092 this->app_info.appVersion = 1;
Chia-I Wu7461fcf2014-12-27 15:16:07 +080093 this->app_info.pEngineName = "unittest";
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -060094 this->app_info.engineVersion = 1;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060095 this->app_info.apiVersion = VK_API_VERSION;
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -060096 VkInstanceCreateInfo inst_info = {};
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060097 inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
Jon Ashburn29669a42015-04-04 14:52:07 -060098 inst_info.pNext = NULL;
99 inst_info.pAppInfo = &app_info;
100 inst_info.pAllocCb = NULL;
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600101 inst_info.layerCount = 0;
102 inst_info.ppEnabledLayerNames = NULL;
Jon Ashburn29669a42015-04-04 14:52:07 -0600103 inst_info.extensionCount = 0;
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600104 inst_info.ppEnabledExtensionNames = NULL;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600105 err = vkCreateInstance(&inst_info, &this->inst);
106 ASSERT_VK_SUCCESS(err);
Jon Ashburn07b309a2015-04-15 11:31:12 -0600107 err = vkEnumeratePhysicalDevices(this->inst, &this->gpu_count, NULL);
108 ASSERT_VK_SUCCESS(err);
109 ASSERT_LE(this->gpu_count, ARRAY_SIZE(objs)) << "Too many GPUs";
110 err = vkEnumeratePhysicalDevices(this->inst, &this->gpu_count, objs);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600111 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter0abdb662015-10-07 13:28:58 -0600112 ASSERT_GE(this->gpu_count, (uint32_t) 1) << "No GPU available";
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600113
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600114 this->m_device = new vk_testing::Device(objs[0]);
Chia-I Wu3b78d312014-12-29 15:39:23 +0800115 this->m_device->init();
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600116 }
117
118 virtual void TearDown() {
Tony Barbour52bbc2b2015-07-21 09:10:44 -0600119 delete this->m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600120 vkDestroyInstance(this->inst);
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600121 }
122};
123
124
Tony Barbour01999182015-04-09 12:58:51 -0600125void VkImageTest::CreateImage(uint32_t w, uint32_t h)
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600126{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600127 VkResult err;
Courtney Goeltzenleuchter37a43a62015-10-22 11:03:31 -0600128 bool pass;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600129 uint32_t mipCount;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600130 VkFormat fmt;
131 VkFormatProperties image_fmt;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600132
133 mipCount = 0;
134
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600135 uint32_t _w = w;
136 uint32_t _h = h;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600137 while( ( _w > 0 ) || ( _h > 0 ) )
138 {
139 _w >>= 1;
140 _h >>= 1;
141 mipCount++;
142 }
143
Tony Barbour8205d902015-04-16 15:59:00 -0600144 fmt = VK_FORMAT_R8G8B8A8_UINT;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600145 // TODO: Pick known good format rather than just expect common format
146 /*
147 * XXX: What should happen if given NULL HANDLE for the pData argument?
Tony Barbour8205d902015-04-16 15:59:00 -0600148 * We're not requesting VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS so there is
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600149 * an expectation that pData is a valid pointer.
150 * However, why include a returned size value? That implies that the
151 * amount of data may vary and that doesn't work well for using a
152 * fixed structure.
153 */
Courtney Goeltzenleuchter01d2ae12015-10-20 16:40:38 -0600154 vkGetPhysicalDeviceFormatProperties(this->objs[0], fmt, &image_fmt);
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600155
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600156 // typedef struct VkImageCreateInfo_
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600157 // {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600158 // VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600159 // const void* pNext; // Pointer to next structure.
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600160 // VkImageType imageType;
161 // VkFormat format;
162 // VkExtent3D extent;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600163 // uint32_t mipLevels;
164 // uint32_t arraySize;
165 // uint32_t samples;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600166 // VkImageTiling tiling;
167 // VkFlags usage; // VkImageUsageFlags
168 // VkFlags flags; // VkImageCreateFlags
169 // } VkImageCreateInfo;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600170
171
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600172 VkImageCreateInfo imageCreateInfo = {};
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600173 imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
Tony Barbour8205d902015-04-16 15:59:00 -0600174 imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600175 imageCreateInfo.format = fmt;
Courtney Goeltzenleuchter2ebc2342015-10-21 17:57:31 -0600176 imageCreateInfo.arrayLayers = 1;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600177 imageCreateInfo.extent.width = w;
178 imageCreateInfo.extent.height = h;
179 imageCreateInfo.extent.depth = 1;
180 imageCreateInfo.mipLevels = mipCount;
181 imageCreateInfo.samples = 1;
Tony Barbour6e046142015-10-05 12:43:30 -0600182 if ((image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) &&
183 (image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
184 {
Tony Barbour8205d902015-04-16 15:59:00 -0600185 imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR;
Tony Barbourbb6a4132015-03-31 08:59:00 -0600186 }
Tony Barbour6e046142015-10-05 12:43:30 -0600187 else if ((image_fmt.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) &&
188 (image_fmt.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
189 {
Tony Barbour8205d902015-04-16 15:59:00 -0600190 imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
Tony Barbourbb6a4132015-03-31 08:59:00 -0600191 }
192 else {
193 ASSERT_TRUE(false) << "Cannot find supported tiling format - Exiting";
194 }
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600195
196 // Image usage flags
Courtney Goeltzenleuchterc3b8eea2015-09-10 14:14:11 -0600197 // VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000008,
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600198 //typedef enum VkImageUsageFlags_
199 //{
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600200 // VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT = 0x00000001, // Can be used as a source of transfer operations
201 // VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT = 0x00000002, // Can be used as a destination of transfer operations
202 // VK_IMAGE_USAGE_SAMPLED_BIT = 0x00000004, // Can be sampled from (SAMPLED_IMAGE and COMBINED_IMAGE_SAMPLER descriptor types)
203 // VK_IMAGE_USAGE_STORAGE_BIT = 0x00000008, // Can be used as storage image (STORAGE_IMAGE descriptor type)
204 // VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000010, // Can be used as framebuffer color attachment
Courtney Goeltzenleuchterc3b8eea2015-09-10 14:14:11 -0600205 // VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, // Can be used as framebuffer depth/stencil attachment
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600206 // VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, // Image data not needed outside of rendering
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600207 // } VkImageUsageFlags;
Cody Northropd0d701b2015-06-17 08:28:19 -0600208 imageCreateInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
209 VK_IMAGE_USAGE_SAMPLED_BIT;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600210
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600211 // VkResult VKAPI vkCreateImage(
212 // VkDevice device,
213 // const VkImageCreateInfo* pCreateInfo,
214 // VkImage* pImage);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600215 err = vkCreateImage(device(), &imageCreateInfo, &m_image);
216 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600217
Mark Lobodzinski23182612015-05-29 09:32:35 -0500218 VkMemoryRequirements mem_req;
Tony Barbour901f3bc2015-04-01 17:10:07 -0600219
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600220 VkMemoryAllocInfo mem_info = {};
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600221 mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
Mark Lobodzinski97dcd042015-04-16 08:52:00 -0500222 mem_info.pNext = NULL;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600223
Courtney Goeltzenleuchter01d2ae12015-10-20 16:40:38 -0600224 vkGetImageMemoryRequirements(device(), m_image, &mem_req);
Jon Ashburna9ae3832015-01-16 09:37:43 -0700225
Tony Barbour426b9052015-06-24 16:06:58 -0600226 ASSERT_NE(0, mem_req.size) << "vkGetObjectMemoryRequirements (Image): Failed - expect images to require memory";
Mark Lobodzinski23182612015-05-29 09:32:35 -0500227 mem_info.allocationSize = mem_req.size;
Mark Lobodzinski72346292015-07-02 16:49:40 -0600228 mem_info.memoryTypeIndex = 0;
229
Courtney Goeltzenleuchter37a43a62015-10-22 11:03:31 -0600230 pass = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
231 ASSERT_TRUE(pass);
Jon Ashburna9ae3832015-01-16 09:37:43 -0700232
Mark Lobodzinski23182612015-05-29 09:32:35 -0500233 /* allocate memory */
234 err = vkAllocMemory(device(), &mem_info, &m_image_mem);
235 ASSERT_VK_SUCCESS(err);
Jon Ashburna9ae3832015-01-16 09:37:43 -0700236
Mark Lobodzinski23182612015-05-29 09:32:35 -0500237 /* bind memory */
Tony Barboure84a8d62015-07-10 14:10:27 -0600238 err = vkBindImageMemory(device(), m_image, m_image_mem, 0);
Mark Lobodzinski23182612015-05-29 09:32:35 -0500239 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600240}
241
Tony Barbour01999182015-04-09 12:58:51 -0600242void VkImageTest::DestroyImage()
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600243{
Mark Lobodzinski92122532015-09-10 11:43:00 -0600244 // All done with image object and memory, clean up
Mark Lobodzinski67b42b72015-09-07 13:59:43 -0600245 vkDestroyImage(device(), m_image);
Mark Lobodzinski92122532015-09-10 11:43:00 -0600246 vkFreeMemory(device(), m_image_mem);
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600247}
248
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600249void VkImageTest::CreateImageView(VkImageViewCreateInfo *pCreateInfo,
250 VkImageView *pView)
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -0600251{
Courtney Goeltzenleuchterf745e622015-09-24 17:47:18 -0600252 VkResult err;
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -0600253 pCreateInfo->image = this->m_image;
Courtney Goeltzenleuchterf745e622015-09-24 17:47:18 -0600254 err = vkCreateImageView(device(), pCreateInfo, pView);
255 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -0600256}
257
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600258void VkImageTest::DestroyImageView(VkImageView imageView)
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -0600259{
Mark Lobodzinski67b42b72015-09-07 13:59:43 -0600260 vkDestroyImageView(device(), imageView);
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -0600261}
262
Tony Barbour01999182015-04-09 12:58:51 -0600263TEST_F(VkImageTest, CreateImageViewTest) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600264 VkFormat fmt;
265 VkImageView imageView;
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -0600266
Tony Barbour8205d902015-04-16 15:59:00 -0600267 fmt = VK_FORMAT_R8G8B8A8_UINT;
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -0600268
269 CreateImage(512, 256);
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600270
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600271 // typedef struct VkImageViewCreateInfo_
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600272 // {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600273 // VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600274 // const void* pNext; // Pointer to next structure
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600275 // VkImage image;
276 // VkImageViewType viewType;
277 // VkFormat format;
278 // VkChannelMapping channels;
279 // VkImageSubresourceRange subresourceRange;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600280 // float minLod;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600281 // } VkImageViewCreateInfo;
282 VkImageViewCreateInfo viewInfo = {};
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600283 viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
Tony Barbour8205d902015-04-16 15:59:00 -0600284 viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600285 viewInfo.format = fmt;
286
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600287 viewInfo.channels.r = VK_CHANNEL_SWIZZLE_R;
288 viewInfo.channels.g = VK_CHANNEL_SWIZZLE_G;
289 viewInfo.channels.b = VK_CHANNEL_SWIZZLE_B;
290 viewInfo.channels.a = VK_CHANNEL_SWIZZLE_A;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600291
Courtney Goeltzenleuchter3dee8082015-09-10 16:38:41 -0600292 viewInfo.subresourceRange.baseArrayLayer = 0;
Courtney Goeltzenleuchter63f0ead2015-10-16 09:46:00 -0600293 viewInfo.subresourceRange.numLayers = 1;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600294 viewInfo.subresourceRange.baseMipLevel = 0;
Courtney Goeltzenleuchter63f0ead2015-10-16 09:46:00 -0600295 viewInfo.subresourceRange.numLevels = 1;
Courtney Goeltzenleuchteraeffeae2015-09-10 17:58:54 -0600296 viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600297
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600298 // VkResult VKAPI vkCreateImageView(
299 // VkDevice device,
300 // const VkImageViewCreateInfo* pCreateInfo,
301 // VkImageView* pView);
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600302
Courtney Goeltzenleuchter263e7f52014-08-14 17:41:57 -0600303 CreateImageView(&viewInfo, &imageView);
304
305 DestroyImageView(imageView);
Tony Barbour52bbc2b2015-07-21 09:10:44 -0600306 DestroyImage();
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600307}
308
309int main(int argc, char **argv) {
310 ::testing::InitGoogleTest(&argc, argv);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600311 vk_testing::set_error_callback(test_error_callback);
Courtney Goeltzenleuchter62928d12014-08-13 17:53:57 -0600312 return RUN_ALL_TESTS();
313}