blob: 22b1d1fc92c48c2fcb5cb8bc65bd1c731c17855d [file] [log] [blame]
Courtney Goeltzenleuchter3470bdf2014-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 Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060031// VK tests
Courtney Goeltzenleuchter3470bdf2014-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 Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060054// Verify VK driver initialization
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -060055
56#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 Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060062#include "vktestbinding.h"
Chia-I Wufe84fe12014-12-29 15:39:23 +080063#include "test_common.h"
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -060064
Jon Ashburn83a64252015-04-15 11:31:12 -060065#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
66
Tony Barbour6918cd52015-04-09 12:58:51 -060067class VkImageTest : public ::testing::Test {
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -060068public:
Mark Lobodzinski17caf572015-01-29 08:55:56 -060069 void CreateImage(uint32_t w, uint32_t h);
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -060070 void DestroyImage();
71
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060072 void CreateImageView(VkImageViewCreateInfo* pCreateInfo,
73 VkImageView* pView);
74 void DestroyImageView(VkImageView imageView);
Chia-I Wuf368b602015-07-03 10:41:20 +080075 VkDevice device() {return m_device->handle();}
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -060076
77protected:
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060078 vk_testing::Device *m_device;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060079 VkApplicationInfo app_info;
Tony Barbourd1c35722015-04-16 15:59:00 -060080 VkPhysicalDevice objs[16];
Mark Lobodzinski17caf572015-01-29 08:55:56 -060081 uint32_t gpu_count;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060082 VkInstance inst;
83 VkImage m_image;
Mark Lobodzinski23065352015-05-29 09:32:35 -050084 VkDeviceMemory m_image_mem;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -060085
86 virtual void SetUp() {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060087 VkResult err;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -060088
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060089 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -060090 this->app_info.pNext = NULL;
Chia-I Wu3432a0c2015-10-27 18:04:07 +080091 this->app_info.pApplicationName = "base";
92 this->app_info.applicationVersion = 1;
Chia-I Wuf1a5a742014-12-27 15:16:07 +080093 this->app_info.pEngineName = "unittest";
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -060094 this->app_info.engineVersion = 1;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060095 this->app_info.apiVersion = VK_API_VERSION;
Courtney Goeltzenleuchter95487bc2015-04-14 18:48:46 -060096 VkInstanceCreateInfo inst_info = {};
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060097 inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
Jon Ashburnb317fad2015-04-04 14:52:07 -060098 inst_info.pNext = NULL;
Chia-I Wu3432a0c2015-10-27 18:04:07 +080099 inst_info.pApplicationInfo = &app_info;
Chia-I Wud50a7d72015-10-26 20:48:51 +0800100 inst_info.enabledLayerNameCount = 0;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600101 inst_info.ppEnabledLayerNames = NULL;
Chia-I Wud50a7d72015-10-26 20:48:51 +0800102 inst_info.enabledExtensionNameCount = 0;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600103 inst_info.ppEnabledExtensionNames = NULL;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800104 err = vkCreateInstance(&inst_info, NULL, &this->inst);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600105 ASSERT_VK_SUCCESS(err);
Jon Ashburn83a64252015-04-15 11:31:12 -0600106 err = vkEnumeratePhysicalDevices(this->inst, &this->gpu_count, NULL);
107 ASSERT_VK_SUCCESS(err);
108 ASSERT_LE(this->gpu_count, ARRAY_SIZE(objs)) << "Too many GPUs";
109 err = vkEnumeratePhysicalDevices(this->inst, &this->gpu_count, objs);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600110 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter58f3eff2015-10-07 13:28:58 -0600111 ASSERT_GE(this->gpu_count, (uint32_t) 1) << "No GPU available";
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600112
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600113 this->m_device = new vk_testing::Device(objs[0]);
Chia-I Wufe84fe12014-12-29 15:39:23 +0800114 this->m_device->init();
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600115 }
116
117 virtual void TearDown() {
Tony Barboure30ca4c2015-07-21 09:10:44 -0600118 delete this->m_device;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800119 vkDestroyInstance(this->inst, NULL);
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600120 }
121};
122
123
Tony Barbour6918cd52015-04-09 12:58:51 -0600124void VkImageTest::CreateImage(uint32_t w, uint32_t h)
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600125{
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600126 VkResult err;
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600127 bool pass;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600128 uint32_t mipCount;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600129 VkFormat fmt;
130 VkFormatProperties image_fmt;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600131
132 mipCount = 0;
133
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600134 uint32_t _w = w;
135 uint32_t _h = h;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600136 while( ( _w > 0 ) || ( _h > 0 ) )
137 {
138 _w >>= 1;
139 _h >>= 1;
140 mipCount++;
141 }
142
Tony Barbourd1c35722015-04-16 15:59:00 -0600143 fmt = VK_FORMAT_R8G8B8A8_UINT;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600144 // TODO: Pick known good format rather than just expect common format
145 /*
146 * XXX: What should happen if given NULL HANDLE for the pData argument?
Tony Barbourd1c35722015-04-16 15:59:00 -0600147 * We're not requesting VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS so there is
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600148 * an expectation that pData is a valid pointer.
149 * However, why include a returned size value? That implies that the
150 * amount of data may vary and that doesn't work well for using a
151 * fixed structure.
152 */
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600153 vkGetPhysicalDeviceFormatProperties(this->objs[0], fmt, &image_fmt);
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600154
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600155 // typedef struct VkImageCreateInfo_
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600156 // {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600157 // VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600158 // const void* pNext; // Pointer to next structure.
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600159 // VkImageType imageType;
160 // VkFormat format;
161 // VkExtent3D extent;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600162 // uint32_t mipLevels;
163 // uint32_t arraySize;
164 // uint32_t samples;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600165 // VkImageTiling tiling;
166 // VkFlags usage; // VkImageUsageFlags
167 // VkFlags flags; // VkImageCreateFlags
168 // } VkImageCreateInfo;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600169
170
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600171 VkImageCreateInfo imageCreateInfo = {};
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600172 imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
Tony Barbourd1c35722015-04-16 15:59:00 -0600173 imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600174 imageCreateInfo.format = fmt;
Courtney Goeltzenleuchter5d2aed42015-10-21 17:57:31 -0600175 imageCreateInfo.arrayLayers = 1;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600176 imageCreateInfo.extent.width = w;
177 imageCreateInfo.extent.height = h;
178 imageCreateInfo.extent.depth = 1;
179 imageCreateInfo.mipLevels = mipCount;
180 imageCreateInfo.samples = 1;
Tony Barbour9f0d6b22015-10-05 12:43:30 -0600181 if ((image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) &&
182 (image_fmt.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
183 {
Tony Barbourd1c35722015-04-16 15:59:00 -0600184 imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR;
Tony Barboura8bea1d2015-03-31 08:59:00 -0600185 }
Tony Barbour9f0d6b22015-10-05 12:43:30 -0600186 else if ((image_fmt.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) &&
187 (image_fmt.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
188 {
Tony Barbourd1c35722015-04-16 15:59:00 -0600189 imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
Tony Barboura8bea1d2015-03-31 08:59:00 -0600190 }
191 else {
192 ASSERT_TRUE(false) << "Cannot find supported tiling format - Exiting";
193 }
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600194
195 // Image usage flags
Courtney Goeltzenleuchter660f0ca2015-09-10 14:14:11 -0600196 // VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000008,
Courtney Goeltzenleuchterb9776ab2015-04-15 15:29:59 -0600197 //typedef enum VkImageUsageFlags_
198 //{
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800199 // VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 0x00000001, // Can be used as a source of transfer operations
200 // VK_IMAGE_USAGE_TRANSFER_DST_BIT = 0x00000002, // Can be used as a destination of transfer operations
Courtney Goeltzenleuchterb9776ab2015-04-15 15:29:59 -0600201 // VK_IMAGE_USAGE_SAMPLED_BIT = 0x00000004, // Can be sampled from (SAMPLED_IMAGE and COMBINED_IMAGE_SAMPLER descriptor types)
202 // VK_IMAGE_USAGE_STORAGE_BIT = 0x00000008, // Can be used as storage image (STORAGE_IMAGE descriptor type)
203 // VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000010, // Can be used as framebuffer color attachment
Courtney Goeltzenleuchter660f0ca2015-09-10 14:14:11 -0600204 // VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, // Can be used as framebuffer depth/stencil attachment
Courtney Goeltzenleuchterb9776ab2015-04-15 15:29:59 -0600205 // VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, // Image data not needed outside of rendering
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600206 // } VkImageUsageFlags;
Cody Northropbb6fdb32015-06-17 08:28:19 -0600207 imageCreateInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
208 VK_IMAGE_USAGE_SAMPLED_BIT;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600209
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600210 // VkResult VKAPI vkCreateImage(
211 // VkDevice device,
212 // const VkImageCreateInfo* pCreateInfo,
213 // VkImage* pImage);
Chia-I Wuf7458c52015-10-26 21:10:41 +0800214 err = vkCreateImage(device(), &imageCreateInfo, NULL, &m_image);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600215 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600216
Mark Lobodzinski23065352015-05-29 09:32:35 -0500217 VkMemoryRequirements mem_req;
Tony Barbourbdf0a312015-04-01 17:10:07 -0600218
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800219 VkMemoryAllocateInfo mem_info = {};
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600220 mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
Mark Lobodzinskie39f6952015-04-16 08:52:00 -0500221 mem_info.pNext = NULL;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600222
Courtney Goeltzenleuchter06d89472015-10-20 16:40:38 -0600223 vkGetImageMemoryRequirements(device(), m_image, &mem_req);
Jon Ashburn7e781952015-01-16 09:37:43 -0700224
Tony Barbour59a47322015-06-24 16:06:58 -0600225 ASSERT_NE(0, mem_req.size) << "vkGetObjectMemoryRequirements (Image): Failed - expect images to require memory";
Mark Lobodzinski23065352015-05-29 09:32:35 -0500226 mem_info.allocationSize = mem_req.size;
Mark Lobodzinskib3fbcd92015-07-02 16:49:40 -0600227 mem_info.memoryTypeIndex = 0;
228
Courtney Goeltzenleuchter1d2f0dd2015-10-22 11:03:31 -0600229 pass = m_device->phy().set_memory_type(mem_req.memoryTypeBits, &mem_info, 0);
230 ASSERT_TRUE(pass);
Jon Ashburn7e781952015-01-16 09:37:43 -0700231
Mark Lobodzinski23065352015-05-29 09:32:35 -0500232 /* allocate memory */
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800233 err = vkAllocateMemory(device(), &mem_info, NULL, &m_image_mem);
Mark Lobodzinski23065352015-05-29 09:32:35 -0500234 ASSERT_VK_SUCCESS(err);
Jon Ashburn7e781952015-01-16 09:37:43 -0700235
Mark Lobodzinski23065352015-05-29 09:32:35 -0500236 /* bind memory */
Tony Barbour67e99152015-07-10 14:10:27 -0600237 err = vkBindImageMemory(device(), m_image, m_image_mem, 0);
Mark Lobodzinski23065352015-05-29 09:32:35 -0500238 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600239}
240
Tony Barbour6918cd52015-04-09 12:58:51 -0600241void VkImageTest::DestroyImage()
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600242{
Mark Lobodzinski4dacaa72015-09-10 11:43:00 -0600243 // All done with image object and memory, clean up
Chia-I Wuf7458c52015-10-26 21:10:41 +0800244 vkDestroyImage(device(), m_image, NULL);
245 vkFreeMemory(device(), m_image_mem, NULL);
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600246}
247
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600248void VkImageTest::CreateImageView(VkImageViewCreateInfo *pCreateInfo,
249 VkImageView *pView)
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600250{
Courtney Goeltzenleuchter65fabb42015-09-24 17:47:18 -0600251 VkResult err;
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600252 pCreateInfo->image = this->m_image;
Chia-I Wuf7458c52015-10-26 21:10:41 +0800253 err = vkCreateImageView(device(), pCreateInfo, NULL, pView);
Courtney Goeltzenleuchter65fabb42015-09-24 17:47:18 -0600254 ASSERT_VK_SUCCESS(err);
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600255}
256
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600257void VkImageTest::DestroyImageView(VkImageView imageView)
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600258{
Chia-I Wuf7458c52015-10-26 21:10:41 +0800259 vkDestroyImageView(device(), imageView, NULL);
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600260}
261
Tony Barbour6918cd52015-04-09 12:58:51 -0600262TEST_F(VkImageTest, CreateImageViewTest) {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600263 VkFormat fmt;
264 VkImageView imageView;
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600265
Tony Barbourd1c35722015-04-16 15:59:00 -0600266 fmt = VK_FORMAT_R8G8B8A8_UINT;
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600267
268 CreateImage(512, 256);
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600269
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600270 // typedef struct VkImageViewCreateInfo_
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600271 // {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600272 // VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600273 // const void* pNext; // Pointer to next structure
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600274 // VkImage image;
275 // VkImageViewType viewType;
276 // VkFormat format;
Chia-I Wu1b99bb22015-10-27 19:25:11 +0800277 // VkComponentMapping channels;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600278 // VkImageSubresourceRange subresourceRange;
Mark Lobodzinski17caf572015-01-29 08:55:56 -0600279 // float minLod;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600280 // } VkImageViewCreateInfo;
281 VkImageViewCreateInfo viewInfo = {};
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600282 viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
Tony Barbourd1c35722015-04-16 15:59:00 -0600283 viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600284 viewInfo.format = fmt;
285
Chia-I Wu1b99bb22015-10-27 19:25:11 +0800286 viewInfo.channels.r = VK_COMPONENT_SWIZZLE_R;
287 viewInfo.channels.g = VK_COMPONENT_SWIZZLE_G;
288 viewInfo.channels.b = VK_COMPONENT_SWIZZLE_B;
289 viewInfo.channels.a = VK_COMPONENT_SWIZZLE_A;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600290
Courtney Goeltzenleuchter4a261892015-09-10 16:38:41 -0600291 viewInfo.subresourceRange.baseArrayLayer = 0;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800292 viewInfo.subresourceRange.layerCount = 1;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600293 viewInfo.subresourceRange.baseMipLevel = 0;
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800294 viewInfo.subresourceRange.levelCount = 1;
Courtney Goeltzenleuchterba724512015-09-10 17:58:54 -0600295 viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600296
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600297 // VkResult VKAPI vkCreateImageView(
298 // VkDevice device,
299 // const VkImageViewCreateInfo* pCreateInfo,
300 // VkImageView* pView);
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600301
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600302 CreateImageView(&viewInfo, &imageView);
303
304 DestroyImageView(imageView);
Tony Barboure30ca4c2015-07-21 09:10:44 -0600305 DestroyImage();
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600306}
307
308int main(int argc, char **argv) {
309 ::testing::InitGoogleTest(&argc, argv);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600310 vk_testing::set_error_callback(test_error_callback);
Courtney Goeltzenleuchter3470bdf2014-08-13 17:53:57 -0600311 return RUN_ALL_TESTS();
312}