Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -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 | |
| 30 | |
| 31 | // XGL tests |
| 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 | |
| 54 | // Verify XGL driver initialization |
| 55 | |
| 56 | #include <stdlib.h> |
| 57 | #include <stdio.h> |
| 58 | #include <stdbool.h> |
| 59 | #include <string.h> |
| 60 | |
| 61 | #include <xgl.h> |
| 62 | #include "gtest-1.7.0/include/gtest/gtest.h" |
Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 63 | #include "xgltestbinding.h" |
| 64 | #include "test_common.h" |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 65 | |
| 66 | class XglImageTest : public ::testing::Test { |
| 67 | public: |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 68 | void CreateImage(uint32_t w, uint32_t h); |
Courtney Goeltzenleuchter | 80ea59a | 2014-08-14 17:41:57 -0600 | [diff] [blame] | 69 | void DestroyImage(); |
| 70 | |
| 71 | void CreateImageView(XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, |
| 72 | XGL_IMAGE_VIEW* pView); |
| 73 | void DestroyImageView(XGL_IMAGE_VIEW imageView); |
Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 74 | XGL_DEVICE device() {return m_device->obj();} |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 75 | |
| 76 | protected: |
Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 77 | xgl_testing::Device *m_device; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 78 | XGL_APPLICATION_INFO app_info; |
Chia-I Wu | af11d92 | 2014-12-28 14:37:25 +0800 | [diff] [blame] | 79 | XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS]; |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 80 | uint32_t gpu_count; |
Jon Ashburn | 1e46489 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 81 | XGL_INSTANCE inst; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 82 | XGL_IMAGE m_image; |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 83 | XGL_GPU_MEMORY *m_image_mem; |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 84 | uint32_t m_num_mem; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 85 | |
| 86 | virtual void SetUp() { |
| 87 | XGL_RESULT err; |
| 88 | |
| 89 | this->app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO; |
| 90 | this->app_info.pNext = NULL; |
Chia-I Wu | f1a5a74 | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 91 | this->app_info.pAppName = "base"; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 92 | this->app_info.appVersion = 1; |
Chia-I Wu | f1a5a74 | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 93 | this->app_info.pEngineName = "unittest"; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 94 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | 5adee1c | 2015-02-23 17:40:15 -0700 | [diff] [blame] | 95 | this->app_info.apiVersion = XGL_API_VERSION; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 96 | |
Jon Ashburn | 1e46489 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 97 | err = xglCreateInstance(&app_info, NULL, &this->inst); |
| 98 | ASSERT_XGL_SUCCESS(err); |
| 99 | err = xglEnumerateGpus(this->inst, XGL_MAX_PHYSICAL_GPUS, |
| 100 | &this->gpu_count, objs); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 101 | ASSERT_XGL_SUCCESS(err); |
Jon Ashburn | bf843b2 | 2014-11-26 11:06:49 -0700 | [diff] [blame] | 102 | ASSERT_GE(this->gpu_count, 1) << "No GPU available"; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 103 | |
Chia-I Wu | fe84fe1 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 104 | this->m_device = new xgl_testing::Device(objs[0]); |
| 105 | this->m_device->init(); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | virtual void TearDown() { |
Jon Ashburn | 1e46489 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 109 | xglDestroyInstance(this->inst); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 110 | } |
| 111 | }; |
| 112 | |
| 113 | |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 114 | void XglImageTest::CreateImage(uint32_t w, uint32_t h) |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 115 | { |
| 116 | XGL_RESULT err; |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 117 | uint32_t mipCount; |
| 118 | size_t size; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 119 | XGL_FORMAT fmt; |
| 120 | XGL_FORMAT_PROPERTIES image_fmt; |
| 121 | |
| 122 | mipCount = 0; |
| 123 | |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 124 | uint32_t _w = w; |
| 125 | uint32_t _h = h; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 126 | while( ( _w > 0 ) || ( _h > 0 ) ) |
| 127 | { |
| 128 | _w >>= 1; |
| 129 | _h >>= 1; |
| 130 | mipCount++; |
| 131 | } |
| 132 | |
Jeremy Hayes | a058eee | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 133 | fmt = XGL_FMT_R8G8B8A8_UINT; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 134 | // TODO: Pick known good format rather than just expect common format |
| 135 | /* |
| 136 | * XXX: What should happen if given NULL HANDLE for the pData argument? |
| 137 | * We're not requesting XGL_INFO_TYPE_MEMORY_REQUIREMENTS so there is |
| 138 | * an expectation that pData is a valid pointer. |
| 139 | * However, why include a returned size value? That implies that the |
| 140 | * amount of data may vary and that doesn't work well for using a |
| 141 | * fixed structure. |
| 142 | */ |
Jon Ashburn | e494a1a | 2014-09-25 14:36:58 -0600 | [diff] [blame] | 143 | size = sizeof(image_fmt); |
Courtney Goeltzenleuchter | cc5eb3a | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 144 | err = xglGetFormatInfo(this->device(), fmt, |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 145 | XGL_INFO_TYPE_FORMAT_PROPERTIES, |
| 146 | &size, &image_fmt); |
| 147 | ASSERT_XGL_SUCCESS(err); |
| 148 | |
| 149 | // typedef struct _XGL_IMAGE_CREATE_INFO |
| 150 | // { |
| 151 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 152 | // const void* pNext; // Pointer to next structure. |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 153 | // XGL_IMAGE_TYPE imageType; |
| 154 | // XGL_FORMAT format; |
| 155 | // XGL_EXTENT3D extent; |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 156 | // uint32_t mipLevels; |
| 157 | // uint32_t arraySize; |
| 158 | // uint32_t samples; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 159 | // XGL_IMAGE_TILING tiling; |
| 160 | // XGL_FLAGS usage; // XGL_IMAGE_USAGE_FLAGS |
| 161 | // XGL_FLAGS flags; // XGL_IMAGE_CREATE_FLAGS |
| 162 | // } XGL_IMAGE_CREATE_INFO; |
| 163 | |
| 164 | |
| 165 | XGL_IMAGE_CREATE_INFO imageCreateInfo = {}; |
| 166 | imageCreateInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 167 | imageCreateInfo.imageType = XGL_IMAGE_2D; |
| 168 | imageCreateInfo.format = fmt; |
| 169 | imageCreateInfo.arraySize = 1; |
| 170 | imageCreateInfo.extent.width = w; |
| 171 | imageCreateInfo.extent.height = h; |
| 172 | imageCreateInfo.extent.depth = 1; |
| 173 | imageCreateInfo.mipLevels = mipCount; |
| 174 | imageCreateInfo.samples = 1; |
| 175 | imageCreateInfo.tiling = XGL_LINEAR_TILING; |
| 176 | |
| 177 | // Image usage flags |
| 178 | // typedef enum _XGL_IMAGE_USAGE_FLAGS |
| 179 | // { |
| 180 | // XGL_IMAGE_USAGE_SHADER_ACCESS_READ_BIT = 0x00000001, |
| 181 | // XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT = 0x00000002, |
| 182 | // XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000004, |
| 183 | // XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT = 0x00000008, |
| 184 | // } XGL_IMAGE_USAGE_FLAGS; |
| 185 | imageCreateInfo.usage = XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT | XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 186 | |
| 187 | // XGL_RESULT XGLAPI xglCreateImage( |
| 188 | // XGL_DEVICE device, |
| 189 | // const XGL_IMAGE_CREATE_INFO* pCreateInfo, |
| 190 | // XGL_IMAGE* pImage); |
Courtney Goeltzenleuchter | cc5eb3a | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 191 | err = xglCreateImage(device(), &imageCreateInfo, &m_image); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 192 | ASSERT_XGL_SUCCESS(err); |
| 193 | |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 194 | XGL_MEMORY_REQUIREMENTS *mem_req; |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 195 | size_t mem_reqs_size = sizeof(XGL_MEMORY_REQUIREMENTS); |
Jon Ashburn | 8a5da75 | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 196 | XGL_IMAGE_MEMORY_REQUIREMENTS img_reqs; |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 197 | size_t img_reqs_size = sizeof(XGL_IMAGE_MEMORY_REQUIREMENTS); |
| 198 | uint32_t num_allocations = 0; |
| 199 | size_t num_alloc_size = sizeof(num_allocations); |
Jon Ashburn | 8a5da75 | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 200 | XGL_MEMORY_ALLOC_IMAGE_INFO img_alloc = { |
| 201 | .sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO, |
| 202 | .pNext = NULL, |
| 203 | }; |
| 204 | XGL_MEMORY_ALLOC_INFO mem_info = {}; |
| 205 | mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 206 | mem_info.pNext = &img_alloc; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 207 | |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 208 | err = xglGetObjectInfo(m_image, XGL_INFO_TYPE_MEMORY_ALLOCATION_COUNT, |
| 209 | &num_alloc_size, &num_allocations); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 210 | ASSERT_XGL_SUCCESS(err); |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 211 | ASSERT_EQ(num_alloc_size,sizeof(num_allocations)); |
| 212 | mem_req = (XGL_MEMORY_REQUIREMENTS *) malloc(num_allocations * sizeof(XGL_MEMORY_REQUIREMENTS)); |
| 213 | m_image_mem = (XGL_GPU_MEMORY *) malloc(num_allocations * sizeof(XGL_GPU_MEMORY)); |
| 214 | m_num_mem = num_allocations; |
| 215 | err = xglGetObjectInfo(m_image, |
| 216 | XGL_INFO_TYPE_MEMORY_REQUIREMENTS, |
| 217 | &mem_reqs_size, mem_req); |
| 218 | ASSERT_XGL_SUCCESS(err); |
| 219 | ASSERT_EQ(mem_reqs_size, num_allocations * sizeof(XGL_MEMORY_REQUIREMENTS)); |
Jon Ashburn | 8a5da75 | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 220 | err = xglGetObjectInfo(m_image, |
| 221 | XGL_INFO_TYPE_IMAGE_MEMORY_REQUIREMENTS, |
| 222 | &img_reqs_size, &img_reqs); |
| 223 | ASSERT_XGL_SUCCESS(err); |
| 224 | ASSERT_EQ(img_reqs_size, sizeof(XGL_IMAGE_MEMORY_REQUIREMENTS)); |
| 225 | img_alloc.usage = img_reqs.usage; |
| 226 | img_alloc.formatClass = img_reqs.formatClass; |
| 227 | img_alloc.samples = img_reqs.samples; |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 228 | |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 229 | for (uint32_t i = 0; i < num_allocations; i ++) { |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 230 | ASSERT_NE(0, mem_req[i].size) << "xglGetObjectInfo (Image): Failed - expect images to require memory"; |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 231 | mem_info.allocationSize = mem_req[i].size; |
Jon Ashburn | e479243 | 2015-01-20 13:55:32 -0700 | [diff] [blame] | 232 | mem_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT; |
Jon Ashburn | e01ff7a | 2015-01-20 15:06:59 -0700 | [diff] [blame] | 233 | mem_info.memType = XGL_MEMORY_TYPE_IMAGE; |
Jon Ashburn | f505c8d | 2015-01-20 16:38:02 -0700 | [diff] [blame] | 234 | mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 235 | |
| 236 | /* allocate memory */ |
| 237 | err = xglAllocMemory(device(), &mem_info, &m_image_mem[i]); |
| 238 | ASSERT_XGL_SUCCESS(err); |
| 239 | |
| 240 | /* bind memory */ |
| 241 | err = xglBindObjectMemory(m_image, i, m_image_mem[i], 0); |
| 242 | ASSERT_XGL_SUCCESS(err); |
| 243 | } |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | void XglImageTest::DestroyImage() |
| 247 | { |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 248 | XGL_RESULT err; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 249 | // All done with image memory, clean up |
Jon Ashburn | 9b6eae5 | 2015-01-15 10:39:19 -0700 | [diff] [blame] | 250 | ASSERT_XGL_SUCCESS(xglBindObjectMemory(m_image, 0, XGL_NULL_HANDLE, 0)); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 251 | |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 252 | for (uint32_t i = 0 ; i < m_num_mem; i++) { |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 253 | err = xglFreeMemory(m_image_mem[i]); |
| 254 | ASSERT_XGL_SUCCESS(err); |
| 255 | } |
| 256 | |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 257 | |
| 258 | ASSERT_XGL_SUCCESS(xglDestroyObject(m_image)); |
| 259 | } |
| 260 | |
Courtney Goeltzenleuchter | 80ea59a | 2014-08-14 17:41:57 -0600 | [diff] [blame] | 261 | void XglImageTest::CreateImageView(XGL_IMAGE_VIEW_CREATE_INFO *pCreateInfo, |
| 262 | XGL_IMAGE_VIEW *pView) |
| 263 | { |
| 264 | pCreateInfo->image = this->m_image; |
Courtney Goeltzenleuchter | cc5eb3a | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 265 | ASSERT_XGL_SUCCESS(xglCreateImageView(device(), pCreateInfo, pView)); |
Courtney Goeltzenleuchter | 80ea59a | 2014-08-14 17:41:57 -0600 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | void XglImageTest::DestroyImageView(XGL_IMAGE_VIEW imageView) |
| 269 | { |
| 270 | ASSERT_XGL_SUCCESS(xglDestroyObject(imageView)); |
| 271 | } |
| 272 | |
| 273 | TEST_F(XglImageTest, CreateImageViewTest) { |
| 274 | XGL_FORMAT fmt; |
| 275 | XGL_IMAGE_VIEW imageView; |
Courtney Goeltzenleuchter | 80ea59a | 2014-08-14 17:41:57 -0600 | [diff] [blame] | 276 | |
Jeremy Hayes | a058eee | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 277 | fmt = XGL_FMT_R8G8B8A8_UINT; |
Courtney Goeltzenleuchter | 80ea59a | 2014-08-14 17:41:57 -0600 | [diff] [blame] | 278 | |
| 279 | CreateImage(512, 256); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 280 | |
| 281 | // typedef struct _XGL_IMAGE_VIEW_CREATE_INFO |
| 282 | // { |
| 283 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 284 | // const void* pNext; // Pointer to next structure |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 285 | // XGL_IMAGE image; |
| 286 | // XGL_IMAGE_VIEW_TYPE viewType; |
| 287 | // XGL_FORMAT format; |
| 288 | // XGL_CHANNEL_MAPPING channels; |
| 289 | // XGL_IMAGE_SUBRESOURCE_RANGE subresourceRange; |
Mark Lobodzinski | 17caf57 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 290 | // float minLod; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 291 | // } XGL_IMAGE_VIEW_CREATE_INFO; |
| 292 | XGL_IMAGE_VIEW_CREATE_INFO viewInfo = {}; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 293 | viewInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 294 | viewInfo.viewType = XGL_IMAGE_VIEW_2D; |
| 295 | viewInfo.format = fmt; |
| 296 | |
| 297 | viewInfo.channels.r = XGL_CHANNEL_SWIZZLE_R; |
| 298 | viewInfo.channels.g = XGL_CHANNEL_SWIZZLE_G; |
| 299 | viewInfo.channels.b = XGL_CHANNEL_SWIZZLE_B; |
| 300 | viewInfo.channels.a = XGL_CHANNEL_SWIZZLE_A; |
| 301 | |
| 302 | viewInfo.subresourceRange.baseArraySlice = 0; |
| 303 | viewInfo.subresourceRange.arraySize = 1; |
| 304 | viewInfo.subresourceRange.baseMipLevel = 0; |
| 305 | viewInfo.subresourceRange.mipLevels = 1; |
| 306 | viewInfo.subresourceRange.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 307 | |
| 308 | // XGL_RESULT XGLAPI xglCreateImageView( |
| 309 | // XGL_DEVICE device, |
| 310 | // const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, |
| 311 | // XGL_IMAGE_VIEW* pView); |
| 312 | |
Courtney Goeltzenleuchter | 80ea59a | 2014-08-14 17:41:57 -0600 | [diff] [blame] | 313 | CreateImageView(&viewInfo, &imageView); |
| 314 | |
| 315 | DestroyImageView(imageView); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | int main(int argc, char **argv) { |
| 319 | ::testing::InitGoogleTest(&argc, argv); |
Chia-I Wu | b76e0fa | 2014-12-28 14:27:28 +0800 | [diff] [blame] | 320 | xgl_testing::set_error_callback(test_error_callback); |
Courtney Goeltzenleuchter | 3470bdf | 2014-08-13 17:53:57 -0600 | [diff] [blame] | 321 | return RUN_ALL_TESTS(); |
| 322 | } |