Courtney Goeltzenleuchter | 7087dde | 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 | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 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 | |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 54 | // Verify XGL driver initialization |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 55 | |
Courtney Goeltzenleuchter | 7087dde | 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 | |
| 61 | #include <xgl.h> |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 62 | #include "gtest-1.7.0/include/gtest/gtest.h" |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 63 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 64 | #include "xgldevice.h" |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 65 | #include "shader_il.h" |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 66 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 67 | class XglTest : public ::testing::Test { |
| 68 | public: |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 69 | void CreateImageTest(); |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 70 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 71 | XGL_DEVICE device() {return m_device->device();} |
| 72 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 73 | protected: |
| 74 | XGL_APPLICATION_INFO app_info; |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 75 | XGL_PHYSICAL_GPU objs[MAX_GPUS]; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 76 | XGL_UINT gpu_count; |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 77 | XglDevice *m_device; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 78 | |
| 79 | virtual void SetUp() { |
| 80 | XGL_RESULT err; |
| 81 | |
| 82 | this->app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO; |
| 83 | this->app_info.pNext = NULL; |
| 84 | this->app_info.pAppName = (const XGL_CHAR *) "base"; |
| 85 | this->app_info.appVersion = 1; |
| 86 | this->app_info.pEngineName = (const XGL_CHAR *) "unittest"; |
| 87 | this->app_info.engineVersion = 1; |
| 88 | this->app_info.apiVersion = XGL_MAKE_VERSION(0, 22, 0); |
| 89 | |
| 90 | err = xglInitAndEnumerateGpus(&app_info, NULL, |
| 91 | MAX_GPUS, &this->gpu_count, objs); |
| 92 | ASSERT_XGL_SUCCESS(err); |
| 93 | ASSERT_GE(1, this->gpu_count) << "No GPU available"; |
| 94 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 95 | this->m_device = new XglDevice(0, objs[0]); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | virtual void TearDown() { |
| 99 | xglInitAndEnumerateGpus(&this->app_info, NULL, 0, &gpu_count, NULL); |
| 100 | } |
| 101 | }; |
| 102 | |
| 103 | TEST(Initialization, xglInitAndEnumerateGpus) { |
| 104 | XGL_APPLICATION_INFO app_info = {}; |
| 105 | XGL_PHYSICAL_GPU objs[MAX_GPUS]; |
| 106 | XGL_UINT gpu_count; |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 107 | XGL_RESULT err; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 108 | XglGpu *gpu; |
| 109 | |
| 110 | app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO; |
| 111 | app_info.pNext = NULL; |
| 112 | app_info.pAppName = (const XGL_CHAR *) "base"; |
| 113 | app_info.appVersion = 1; |
| 114 | app_info.pEngineName = (const XGL_CHAR *) "unittest"; |
| 115 | app_info.engineVersion = 1; |
| 116 | app_info.apiVersion = XGL_MAKE_VERSION(0, 22, 0); |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 117 | |
| 118 | err = xglInitAndEnumerateGpus(&app_info, NULL, |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 119 | MAX_GPUS, &gpu_count, objs); |
| 120 | ASSERT_XGL_SUCCESS(err); |
| 121 | ASSERT_GE(1, gpu_count) << "No GPU available"; |
| 122 | |
| 123 | // TODO: Iterate over all GPUs |
| 124 | gpu = new XglGpu(0, objs[0]); |
| 125 | |
| 126 | // TODO: Verify destroy functions |
| 127 | } |
| 128 | |
| 129 | TEST_F(XglTest, AllocMemory) { |
| 130 | XGL_RESULT err; |
| 131 | XGL_MEMORY_ALLOC_INFO alloc_info = {}; |
| 132 | XGL_GPU_MEMORY gpu_mem; |
| 133 | XGL_UINT8 *pData; |
| 134 | |
| 135 | alloc_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 136 | alloc_info.allocationSize = 1024 * 1024; // 1MB |
| 137 | alloc_info.alignment = 0; |
| 138 | alloc_info.heapCount = 1; |
| 139 | alloc_info.heaps[0] = 0; // TODO: Reference other heaps |
| 140 | |
| 141 | // TODO: Pick heap properties indicated by heap info |
| 142 | alloc_info.flags = XGL_MEMORY_HEAP_CPU_VISIBLE_BIT; |
| 143 | |
| 144 | // TODO: Try variety of memory priorities |
| 145 | alloc_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
| 146 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 147 | err = xglAllocMemory(device(), &alloc_info, &gpu_mem); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 148 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 149 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 150 | err = xglMapMemory(gpu_mem, 0, (XGL_VOID **) &pData); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 151 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 152 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 153 | memset(pData, 0x55, alloc_info.allocationSize); |
| 154 | EXPECT_EQ(0x55, pData[0]) << "Memory read not same a write"; |
| 155 | |
| 156 | err = xglUnmapMemory(gpu_mem); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 157 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 158 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 159 | err = xglFreeMemory(gpu_mem); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 160 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 161 | } |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 162 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 163 | TEST_F(XglTest, Event) { |
| 164 | XGL_EVENT_CREATE_INFO event_info; |
| 165 | XGL_EVENT event; |
| 166 | XGL_UINT data_size; |
| 167 | XGL_MEMORY_REQUIREMENTS mem_req; |
| 168 | XGL_RESULT err; |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 169 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 170 | // typedef struct _XGL_EVENT_CREATE_INFO |
| 171 | // { |
| 172 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO |
| 173 | // const XGL_VOID* pNext; // Pointer to next structure |
| 174 | // XGL_FLAGS flags; // Reserved |
| 175 | // } XGL_EVENT_CREATE_INFO; |
| 176 | memset(&event_info, 0, sizeof(event_info)); |
| 177 | event_info.sType = XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 178 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 179 | err = xglCreateEvent(device(), &event_info, &event); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 180 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 181 | |
| 182 | err = xglGetObjectInfo(event, XGL_INFO_TYPE_MEMORY_REQUIREMENTS, |
| 183 | &data_size, &mem_req); |
| 184 | ASSERT_XGL_SUCCESS(err); |
| 185 | |
| 186 | // XGL_RESULT XGLAPI xglAllocMemory( |
| 187 | // XGL_DEVICE device, |
| 188 | // const XGL_MEMORY_ALLOC_INFO* pAllocInfo, |
| 189 | // XGL_GPU_MEMORY* pMem); |
| 190 | XGL_MEMORY_ALLOC_INFO mem_info; |
| 191 | XGL_GPU_MEMORY event_mem; |
| 192 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 193 | ASSERT_NE(0, mem_req.size) << "xglGetObjectInfo (Event): Failed - expect events to require memory"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 194 | |
| 195 | memset(&mem_info, 0, sizeof(mem_info)); |
| 196 | mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 197 | mem_info.allocationSize = mem_req.size; |
| 198 | mem_info.alignment = mem_req.alignment; |
| 199 | mem_info.heapCount = mem_req.heapCount; |
| 200 | memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS); |
| 201 | mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
| 202 | mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT; |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 203 | err = xglAllocMemory(device(), &mem_info, &event_mem); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 204 | ASSERT_XGL_SUCCESS(err); |
| 205 | |
| 206 | err = xglBindObjectMemory(event, event_mem, 0); |
| 207 | ASSERT_XGL_SUCCESS(err); |
| 208 | |
| 209 | err = xglResetEvent(event); |
| 210 | ASSERT_XGL_SUCCESS(err); |
| 211 | |
| 212 | err = xglGetEventStatus(event); |
| 213 | ASSERT_EQ(XGL_EVENT_RESET, err); |
| 214 | |
| 215 | err = xglSetEvent(event); |
| 216 | ASSERT_XGL_SUCCESS(err); |
| 217 | |
| 218 | err = xglGetEventStatus(event); |
| 219 | ASSERT_EQ(XGL_EVENT_SET, err); |
| 220 | |
| 221 | // TODO: Test actual synchronization with command buffer event. |
| 222 | |
| 223 | // All done with event memory, clean up |
| 224 | err = xglBindObjectMemory(event, XGL_NULL_HANDLE, 0); |
| 225 | ASSERT_XGL_SUCCESS(err); |
| 226 | |
| 227 | err = xglDestroyObject(event); |
| 228 | ASSERT_XGL_SUCCESS(err); |
| 229 | } |
| 230 | |
| 231 | TEST_F(XglTest, Fence) { |
| 232 | XGL_RESULT err; |
| 233 | XGL_FENCE_CREATE_INFO fence_info; |
| 234 | XGL_FENCE fence; |
| 235 | |
| 236 | memset(&fence_info, 0, sizeof(fence_info)); |
| 237 | |
| 238 | // typedef struct _XGL_FENCE_CREATE_INFO |
| 239 | // { |
| 240 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO |
| 241 | // const XGL_VOID* pNext; // Pointer to next structure |
| 242 | // XGL_FLAGS flags; // Reserved |
| 243 | fence_info.sType = XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 244 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 245 | err = xglCreateFence(device(), &fence_info, &fence); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 246 | ASSERT_XGL_SUCCESS(err); |
| 247 | |
| 248 | err = xglGetFenceStatus(fence); |
| 249 | // We've not submitted this fence on a command buffer so should get |
| 250 | // XGL_ERROR_UNAVAILABLE |
| 251 | EXPECT_EQ(XGL_ERROR_UNAVAILABLE, err); |
| 252 | |
| 253 | // Test glxWaitForFences |
| 254 | // XGL_RESULT XGLAPI xglWaitForFences( |
| 255 | // XGL_DEVICE device, |
| 256 | // XGL_UINT fenceCount, |
| 257 | // const XGL_FENCE* pFences, |
| 258 | // XGL_BOOL waitAll, |
| 259 | // XGL_UINT64 timeout); |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 260 | err = xglWaitForFences(device(), 1, &fence, XGL_TRUE, 0); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 261 | EXPECT_EQ(XGL_ERROR_UNAVAILABLE, err); |
| 262 | |
| 263 | // TODO: Attached to command buffer and test GetFenceStatus |
| 264 | // TODO: Add some commands and submit the command buffer |
| 265 | |
| 266 | err = xglDestroyObject(fence); |
| 267 | ASSERT_XGL_SUCCESS(err); |
| 268 | |
| 269 | } |
| 270 | |
| 271 | #define MAX_QUERY_SLOTS 10 |
| 272 | |
| 273 | TEST_F(XglTest, Query) { |
| 274 | XGL_QUERY_POOL_CREATE_INFO query_info; |
| 275 | XGL_QUERY_POOL query_pool; |
| 276 | XGL_UINT data_size; |
| 277 | XGL_MEMORY_REQUIREMENTS mem_req; |
| 278 | XGL_UINT query_result_size; |
| 279 | XGL_UINT *query_result_data; |
| 280 | XGL_RESULT err; |
| 281 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 282 | // typedef enum _XGL_QUERY_TYPE |
| 283 | // { |
| 284 | // XGL_QUERY_OCCLUSION = 0x00000000, |
| 285 | // XGL_QUERY_PIPELINE_STATISTICS = 0x00000001, |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 286 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 287 | // XGL_QUERY_TYPE_BEGIN_RANGE = XGL_QUERY_OCCLUSION, |
| 288 | // XGL_QUERY_TYPE_END_RANGE = XGL_QUERY_PIPELINE_STATISTICS, |
| 289 | // XGL_NUM_QUERY_TYPE = (XGL_QUERY_TYPE_END_RANGE - XGL_QUERY_TYPE_BEGIN_RANGE + 1), |
| 290 | // XGL_MAX_ENUM(_XGL_QUERY_TYPE) |
| 291 | // } XGL_QUERY_TYPE; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 292 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 293 | // typedef struct _XGL_QUERY_POOL_CREATE_INFO |
| 294 | // { |
| 295 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO |
| 296 | // const XGL_VOID* pNext; // Pointer to next structure |
| 297 | // XGL_QUERY_TYPE queryType; |
| 298 | // XGL_UINT slots; |
| 299 | // } XGL_QUERY_POOL_CREATE_INFO; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 300 | |
| 301 | memset(&query_info, 0, sizeof(query_info)); |
| 302 | query_info.sType = XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 303 | query_info.queryType = XGL_QUERY_OCCLUSION; |
| 304 | query_info.slots = MAX_QUERY_SLOTS; |
| 305 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 306 | // XGL_RESULT XGLAPI xglCreateQueryPool( |
| 307 | // XGL_DEVICE device, |
| 308 | // const XGL_QUERY_POOL_CREATE_INFO* pCreateInfo, |
| 309 | // XGL_QUERY_POOL* pQueryPool); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 310 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 311 | err = xglCreateQueryPool(device(), &query_info, &query_pool); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 312 | ASSERT_XGL_SUCCESS(err); |
| 313 | |
| 314 | err = xglGetObjectInfo(query_pool, XGL_INFO_TYPE_MEMORY_REQUIREMENTS, |
| 315 | &data_size, &mem_req); |
| 316 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 317 | ASSERT_NE(0, data_size) << "Invalid data_size"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 318 | |
| 319 | // XGL_RESULT XGLAPI xglAllocMemory( |
| 320 | // XGL_DEVICE device, |
| 321 | // const XGL_MEMORY_ALLOC_INFO* pAllocInfo, |
| 322 | // XGL_GPU_MEMORY* pMem); |
| 323 | XGL_MEMORY_ALLOC_INFO mem_info; |
| 324 | XGL_GPU_MEMORY query_mem; |
| 325 | |
| 326 | memset(&mem_info, 0, sizeof(mem_info)); |
| 327 | mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 328 | // TODO: Is a simple multiple all that's needed here? |
| 329 | mem_info.allocationSize = mem_req.size * MAX_QUERY_SLOTS; |
| 330 | mem_info.alignment = mem_req.alignment; |
| 331 | mem_info.heapCount = mem_req.heapCount; |
| 332 | memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS); |
| 333 | mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
| 334 | |
| 335 | // TODO: are the flags right? |
| 336 | // TODO: Should this be pinned? Or maybe a separate test with pinned. |
| 337 | mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT; |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 338 | err = xglAllocMemory(device(), &mem_info, &query_mem); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 339 | ASSERT_XGL_SUCCESS(err); |
| 340 | |
| 341 | err = xglBindObjectMemory(query_pool, query_mem, 0); |
| 342 | ASSERT_XGL_SUCCESS(err); |
| 343 | |
| 344 | // TODO: Test actual synchronization with command buffer event. |
| 345 | // TODO: Create command buffer |
| 346 | // TODO: xglCmdResetQueryPool |
| 347 | // TODO: xglCmdBeginQuery |
| 348 | // TODO: commands |
| 349 | // TOOD: xglCmdEndQuery |
| 350 | |
| 351 | err = xglGetQueryPoolResults(query_pool, 0, MAX_QUERY_SLOTS, |
| 352 | &query_result_size, XGL_NULL_HANDLE); |
| 353 | ASSERT_XGL_SUCCESS(err); |
| 354 | |
| 355 | if (query_result_size > 0) { |
| 356 | query_result_data = new XGL_UINT [query_result_size]; |
| 357 | err = xglGetQueryPoolResults(query_pool, 0, MAX_QUERY_SLOTS, |
| 358 | &query_result_size, query_result_data); |
| 359 | ASSERT_XGL_SUCCESS(err); |
| 360 | |
| 361 | // TODO: Test Query result data. |
| 362 | |
| 363 | } |
| 364 | |
| 365 | // All done with QueryPool memory, clean up |
| 366 | err = xglBindObjectMemory(query_pool, XGL_NULL_HANDLE, 0); |
| 367 | ASSERT_XGL_SUCCESS(err); |
| 368 | |
| 369 | err = xglDestroyObject(query_pool); |
| 370 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 371 | } |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 372 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 373 | void getQueue(XglDevice *device, XGL_QUEUE_TYPE qtype, const char *qname) |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 374 | { |
| 375 | int que_idx; |
| 376 | XGL_RESULT err; |
| 377 | XGL_QUEUE queue; |
| 378 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 379 | for (que_idx = 0; que_idx < device->queue_props->queueCount; que_idx++) { |
| 380 | err = xglGetDeviceQueue(device->device(), qtype, que_idx, &queue); |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 381 | ASSERT_EQ(XGL_SUCCESS, err) << "xglGetDeviceQueue: " << qname << " queue #" << que_idx << ": Failed with error: " << xgl_result_string(err); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | TEST_F(XglTest, Queue) |
| 386 | { |
| 387 | XGL_UINT que_idx; |
| 388 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 389 | ASSERT_NE(0, m_device->queue_props->queueCount) << "No heaps available for GPU #" << m_device->id << ": " << m_device->props.gpuName; |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 390 | |
| 391 | // XGL_RESULT XGLAPI xglGetDeviceQueue( |
| 392 | // XGL_DEVICE device, |
| 393 | // XGL_QUEUE_TYPE queueType, |
| 394 | // XGL_UINT queueIndex, |
| 395 | // XGL_QUEUE* pQueue); |
| 396 | /* |
| 397 | * queue handles are retrieved from the device by calling |
| 398 | * xglGetDeviceQueue() with a queue type and a requested logical |
| 399 | * queue ID. The logical queue ID is a sequential number starting |
| 400 | * from zero and referencing up to the number of queues requested |
| 401 | * at device creation. Each queue type has its own sequence of IDs |
| 402 | * starting at zero. |
| 403 | */ |
| 404 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 405 | for (que_idx = 0; que_idx < m_device->queue_props->queueCount; que_idx++) { |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 406 | |
| 407 | // typedef enum _XGL_QUEUE_FLAGS |
| 408 | // { |
| 409 | // XGL_QUEUE_GRAPHICS_BIT = 0x00000001, // Queue supports graphics operations |
| 410 | // XGL_QUEUE_COMPUTE_BIT = 0x00000002, // Queue supports compute operations |
| 411 | // XGL_QUEUE_DMA_BIT = 0x00000004, // Queue supports DMA operations |
| 412 | // XGL_QUEUE_EXTENDED_BIT = 0x80000000 // Extended queue |
| 413 | // } XGL_QUEUE_FLAGS; |
| 414 | |
| 415 | // typedef enum _XGL_QUEUE_TYPE |
| 416 | // { |
| 417 | // XGL_QUEUE_TYPE_GRAPHICS = 0x1, |
| 418 | // XGL_QUEUE_TYPE_COMPUTE = 0x2, |
| 419 | // XGL_QUEUE_TYPE_DMA = 0x3, |
| 420 | // XGL_MAX_ENUM(_XGL_QUEUE_TYPE) |
| 421 | // } XGL_QUEUE_TYPE; |
| 422 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 423 | if (m_device->queue_props->queueFlags & XGL_QUEUE_GRAPHICS_BIT) { |
| 424 | getQueue(m_device, XGL_QUEUE_TYPE_GRAPHICS, "Graphics"); |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 425 | } |
| 426 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 427 | if (m_device->queue_props->queueFlags & XGL_QUEUE_COMPUTE_BIT) { |
| 428 | getQueue(m_device, XGL_QUEUE_TYPE_GRAPHICS, "Compute"); |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 429 | } |
| 430 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 431 | if (m_device->queue_props->queueFlags & XGL_QUEUE_DMA_BIT) { |
| 432 | getQueue(m_device, XGL_QUEUE_TYPE_GRAPHICS, "DMA"); |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | // TODO: What do we do about EXTENDED_BIT? |
| 436 | |
| 437 | /* Guide: pg 34: |
| 438 | * The queue objects cannot be destroyed explicitly by an application |
| 439 | * and are automatically destroyed when the associated device is destroyed. |
| 440 | * Once the device is destroyed, attempting to use a queue results in |
| 441 | * undefined behavior. |
| 442 | */ |
| 443 | } |
| 444 | } |
| 445 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 446 | void XglTest::CreateImageTest() |
| 447 | { |
| 448 | XGL_RESULT err; |
| 449 | XGL_IMAGE image; |
| 450 | XGL_UINT w, h, mipCount; |
| 451 | XGL_SIZE size; |
| 452 | XGL_FORMAT fmt; |
| 453 | XGL_FORMAT_PROPERTIES image_fmt; |
Courtney Goeltzenleuchter | ac3b73a | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 454 | XGL_UINT data_size; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 455 | |
| 456 | w =512; |
| 457 | h = 256; |
| 458 | mipCount = 0; |
| 459 | |
| 460 | XGL_UINT _w = w; |
| 461 | XGL_UINT _h = h; |
| 462 | while( ( _w > 0 ) || ( _h > 0 ) ) |
| 463 | { |
| 464 | _w >>= 1; |
| 465 | _h >>= 1; |
| 466 | mipCount++; |
| 467 | } |
| 468 | |
| 469 | fmt.channelFormat = XGL_CH_FMT_R8G8B8A8; |
| 470 | fmt.numericFormat = XGL_NUM_FMT_UINT; |
| 471 | // TODO: Pick known good format rather than just expect common format |
| 472 | /* |
| 473 | * XXX: What should happen if given NULL HANDLE for the pData argument? |
| 474 | * We're not requesting XGL_INFO_TYPE_MEMORY_REQUIREMENTS so there is |
| 475 | * an expectation that pData is a valid pointer. |
| 476 | * However, why include a returned size value? That implies that the |
| 477 | * amount of data may vary and that doesn't work well for using a |
| 478 | * fixed structure. |
| 479 | */ |
| 480 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 481 | err = xglGetFormatInfo(device(), fmt, |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 482 | XGL_INFO_TYPE_FORMAT_PROPERTIES, |
| 483 | &size, &image_fmt); |
| 484 | ASSERT_XGL_SUCCESS(err); |
| 485 | |
| 486 | // typedef struct _XGL_IMAGE_CREATE_INFO |
| 487 | // { |
| 488 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO |
| 489 | // const XGL_VOID* pNext; // Pointer to next structure. |
| 490 | // XGL_IMAGE_TYPE imageType; |
| 491 | // XGL_FORMAT format; |
| 492 | // XGL_EXTENT3D extent; |
| 493 | // XGL_UINT mipLevels; |
| 494 | // XGL_UINT arraySize; |
| 495 | // XGL_UINT samples; |
| 496 | // XGL_IMAGE_TILING tiling; |
| 497 | // XGL_FLAGS usage; // XGL_IMAGE_USAGE_FLAGS |
| 498 | // XGL_FLAGS flags; // XGL_IMAGE_CREATE_FLAGS |
| 499 | // } XGL_IMAGE_CREATE_INFO; |
| 500 | |
| 501 | |
| 502 | XGL_IMAGE_CREATE_INFO imageCreateInfo = {}; |
| 503 | imageCreateInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 504 | imageCreateInfo.imageType = XGL_IMAGE_2D; |
| 505 | imageCreateInfo.format = fmt; |
| 506 | imageCreateInfo.arraySize = 1; |
| 507 | imageCreateInfo.extent.width = w; |
| 508 | imageCreateInfo.extent.height = h; |
| 509 | imageCreateInfo.extent.depth = 1; |
| 510 | imageCreateInfo.mipLevels = mipCount; |
| 511 | imageCreateInfo.samples = 1; |
| 512 | imageCreateInfo.tiling = XGL_LINEAR_TILING; |
| 513 | |
| 514 | // Image usage flags |
| 515 | // typedef enum _XGL_IMAGE_USAGE_FLAGS |
| 516 | // { |
| 517 | // XGL_IMAGE_USAGE_SHADER_ACCESS_READ_BIT = 0x00000001, |
| 518 | // XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT = 0x00000002, |
| 519 | // XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000004, |
| 520 | // XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT = 0x00000008, |
| 521 | // } XGL_IMAGE_USAGE_FLAGS; |
| 522 | imageCreateInfo.usage = XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT | XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 523 | |
| 524 | // XGL_RESULT XGLAPI xglCreateImage( |
| 525 | // XGL_DEVICE device, |
| 526 | // const XGL_IMAGE_CREATE_INFO* pCreateInfo, |
| 527 | // XGL_IMAGE* pImage); |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 528 | err = xglCreateImage(device(), &imageCreateInfo, &image); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 529 | ASSERT_XGL_SUCCESS(err); |
| 530 | |
Courtney Goeltzenleuchter | ac3b73a | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 531 | // Verify image resources |
| 532 | // XGL_RESULT XGLAPI xglGetImageSubresourceInfo( |
| 533 | // XGL_IMAGE image, |
| 534 | // const XGL_IMAGE_SUBRESOURCE* pSubresource, |
| 535 | // XGL_SUBRESOURCE_INFO_TYPE infoType, |
| 536 | // XGL_SIZE* pDataSize, |
| 537 | // XGL_VOID* pData); |
| 538 | // typedef struct _XGL_SUBRESOURCE_LAYOUT |
| 539 | // { |
| 540 | // XGL_GPU_SIZE offset; // Specified in bytes |
| 541 | // XGL_GPU_SIZE size; // Specified in bytes |
| 542 | // XGL_GPU_SIZE rowPitch; // Specified in bytes |
| 543 | // XGL_GPU_SIZE depthPitch; // Specified in bytes |
| 544 | // } XGL_SUBRESOURCE_LAYOUT; |
| 545 | |
| 546 | // typedef struct _XGL_IMAGE_SUBRESOURCE |
| 547 | // { |
| 548 | // XGL_IMAGE_ASPECT aspect; |
| 549 | // XGL_UINT mipLevel; |
| 550 | // XGL_UINT arraySlice; |
| 551 | // } XGL_IMAGE_SUBRESOURCE; |
| 552 | // typedef enum _XGL_SUBRESOURCE_INFO_TYPE |
| 553 | // { |
| 554 | // // Info type for xglGetImageSubresourceInfo() |
| 555 | // XGL_INFO_TYPE_SUBRESOURCE_LAYOUT = 0x00000000, |
| 556 | |
| 557 | // XGL_MAX_ENUM(_XGL_SUBRESOURCE_INFO_TYPE) |
| 558 | // } XGL_SUBRESOURCE_INFO_TYPE; |
| 559 | XGL_IMAGE_SUBRESOURCE subresource = {}; |
| 560 | subresource.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 561 | subresource.arraySlice = 0; |
| 562 | |
| 563 | _w = w; |
| 564 | _h = h; |
| 565 | while( ( _w > 0 ) || ( _h > 0 ) ) |
| 566 | { |
| 567 | XGL_SUBRESOURCE_LAYOUT layout = {}; |
| 568 | |
| 569 | err = xglGetImageSubresourceInfo(image, &subresource, XGL_INFO_TYPE_SUBRESOURCE_LAYOUT, |
| 570 | &data_size, &layout); |
| 571 | ASSERT_XGL_SUCCESS(err); |
| 572 | ASSERT_EQ(sizeof(XGL_SUBRESOURCE_LAYOUT), data_size) << "Invalid structure (XGL_SUBRESOURCE_LAYOUT) size"; |
| 573 | |
| 574 | // TODO: 4 should be replaced with pixel size for given format |
| 575 | EXPECT_LE(_w * 4, layout.rowPitch) << "Pitch does not match expected image pitch"; |
| 576 | _w >>= 1; |
| 577 | _h >>= 1; |
| 578 | |
| 579 | subresource.mipLevel++; |
| 580 | } |
| 581 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 582 | XGL_MEMORY_REQUIREMENTS mem_req; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 583 | err = xglGetObjectInfo(image, XGL_INFO_TYPE_MEMORY_REQUIREMENTS, |
| 584 | &data_size, &mem_req); |
| 585 | ASSERT_XGL_SUCCESS(err); |
| 586 | ASSERT_EQ(data_size, sizeof(mem_req)); |
| 587 | ASSERT_NE(0, mem_req.size) << "xglGetObjectInfo (Event): Failed - expect images to require memory"; |
| 588 | |
| 589 | // XGL_RESULT XGLAPI xglAllocMemory( |
| 590 | // XGL_DEVICE device, |
| 591 | // const XGL_MEMORY_ALLOC_INFO* pAllocInfo, |
| 592 | // XGL_GPU_MEMORY* pMem); |
| 593 | XGL_MEMORY_ALLOC_INFO mem_info; |
| 594 | XGL_GPU_MEMORY image_mem; |
| 595 | |
| 596 | memset(&mem_info, 0, sizeof(mem_info)); |
| 597 | mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 598 | mem_info.allocationSize = mem_req.size; |
| 599 | mem_info.alignment = mem_req.alignment; |
| 600 | mem_info.heapCount = mem_req.heapCount; |
| 601 | memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS); |
| 602 | mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
| 603 | mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT; |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 604 | err = xglAllocMemory(device(), &mem_info, &image_mem); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 605 | ASSERT_XGL_SUCCESS(err); |
| 606 | |
| 607 | err = xglBindObjectMemory(image, image_mem, 0); |
| 608 | ASSERT_XGL_SUCCESS(err); |
| 609 | |
| 610 | // typedef struct _XGL_IMAGE_VIEW_CREATE_INFO |
| 611 | // { |
| 612 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO |
| 613 | // const XGL_VOID* pNext; // Pointer to next structure |
| 614 | // XGL_IMAGE image; |
| 615 | // XGL_IMAGE_VIEW_TYPE viewType; |
| 616 | // XGL_FORMAT format; |
| 617 | // XGL_CHANNEL_MAPPING channels; |
| 618 | // XGL_IMAGE_SUBRESOURCE_RANGE subresourceRange; |
| 619 | // XGL_FLOAT minLod; |
| 620 | // } XGL_IMAGE_VIEW_CREATE_INFO; |
| 621 | XGL_IMAGE_VIEW_CREATE_INFO viewInfo = {}; |
| 622 | XGL_IMAGE_VIEW view; |
| 623 | viewInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 624 | viewInfo.image = image; |
| 625 | viewInfo.viewType = XGL_IMAGE_VIEW_2D; |
| 626 | viewInfo.format = fmt; |
| 627 | |
| 628 | viewInfo.channels.r = XGL_CHANNEL_SWIZZLE_R; |
| 629 | viewInfo.channels.g = XGL_CHANNEL_SWIZZLE_G; |
| 630 | viewInfo.channels.b = XGL_CHANNEL_SWIZZLE_B; |
| 631 | viewInfo.channels.a = XGL_CHANNEL_SWIZZLE_A; |
| 632 | |
| 633 | viewInfo.subresourceRange.baseArraySlice = 0; |
| 634 | viewInfo.subresourceRange.arraySize = 1; |
| 635 | viewInfo.subresourceRange.baseMipLevel = 0; |
| 636 | viewInfo.subresourceRange.mipLevels = 1; |
| 637 | viewInfo.subresourceRange.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 638 | |
| 639 | // XGL_RESULT XGLAPI xglCreateImageView( |
| 640 | // XGL_DEVICE device, |
| 641 | // const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, |
| 642 | // XGL_IMAGE_VIEW* pView); |
| 643 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 644 | err = xglCreateImageView(device(), &viewInfo, &view); |
Courtney Goeltzenleuchter | ac3b73a | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 645 | ASSERT_XGL_SUCCESS(err) << "xglCreateImageView failed"; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 646 | |
| 647 | // TODO: Test image memory. |
| 648 | |
| 649 | // All done with image memory, clean up |
| 650 | ASSERT_XGL_SUCCESS(xglBindObjectMemory(image, XGL_NULL_HANDLE, 0)); |
| 651 | |
| 652 | ASSERT_XGL_SUCCESS(xglFreeMemory(image_mem)); |
| 653 | |
| 654 | ASSERT_XGL_SUCCESS(xglDestroyObject(image)); |
| 655 | } |
| 656 | |
| 657 | TEST_F(XglTest, CreateImage) { |
| 658 | CreateImageTest(); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 659 | } |
| 660 | |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 661 | TEST_F(XglTest, CreateShader) { |
| 662 | void *code; |
| 663 | uint32_t codeSize; |
| 664 | struct bil_header *pBIL; |
| 665 | XGL_RESULT err; |
| 666 | |
| 667 | codeSize = sizeof(struct bil_header) + 100; |
| 668 | code = malloc(codeSize); |
| 669 | ASSERT_TRUE(NULL != code) << "malloc failed!"; |
| 670 | |
| 671 | memset(code, 0, codeSize); |
| 672 | |
| 673 | // Indicate that this is BIL data. |
| 674 | pBIL = (struct bil_header *) code; |
| 675 | pBIL->bil_magic = BILMagicNumber; |
| 676 | pBIL->bil_version = BILVersion; |
| 677 | |
| 678 | // typedef struct _XGL_SHADER_CREATE_INFO |
| 679 | // { |
| 680 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO |
| 681 | // const XGL_VOID* pNext; // Pointer to next structure |
| 682 | // XGL_SIZE codeSize; // Specified in bytes |
| 683 | // const XGL_VOID* pCode; |
| 684 | // XGL_FLAGS flags; // Reserved |
| 685 | // } XGL_SHADER_CREATE_INFO; |
| 686 | |
| 687 | XGL_SHADER_CREATE_INFO createInfo; |
| 688 | XGL_SHADER shader; |
| 689 | |
| 690 | createInfo.sType = XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO; |
| 691 | createInfo.pNext = NULL; |
| 692 | createInfo.pCode = code; |
| 693 | createInfo.codeSize = codeSize; |
| 694 | createInfo.flags = 0; |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame^] | 695 | err = xglCreateShader(device(), &createInfo, &shader); |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 696 | ASSERT_XGL_SUCCESS(err); |
| 697 | |
| 698 | ASSERT_XGL_SUCCESS(xglDestroyObject(shader)); |
| 699 | } |
| 700 | |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 701 | int main(int argc, char **argv) { |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 702 | ::testing::InitGoogleTest(&argc, argv); |
| 703 | return RUN_ALL_TESTS(); |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 704 | } |