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 | |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 64 | #include "xgltestbinding.h" |
| 65 | #include "test_common.h" |
Cody Northrop | d4e020a | 2015-03-17 14:54:35 -0600 | [diff] [blame] | 66 | #include "icd-spv.h" |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 67 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 68 | class XglTest : public ::testing::Test { |
| 69 | public: |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 70 | void CreateImageTest(); |
Courtney Goeltzenleuchter | 0842df7 | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 71 | void CreateCommandBufferTest(); |
| 72 | void CreatePipelineTest(); |
| 73 | void CreateShaderTest(); |
| 74 | void CreateShader(XGL_SHADER *pshader); |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 75 | |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 76 | XGL_DEVICE device() {return m_device->obj();} |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 77 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 78 | protected: |
| 79 | XGL_APPLICATION_INFO app_info; |
Jon Ashburn | 670b176 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 80 | XGL_INSTANCE inst; |
Chia-I Wu | 9c877b2 | 2014-12-28 14:37:25 +0800 | [diff] [blame] | 81 | XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 82 | uint32_t gpu_count; |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 83 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 84 | uint32_t m_device_id; |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 85 | xgl_testing::Device *m_device; |
| 86 | XGL_PHYSICAL_GPU_PROPERTIES props; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 87 | std::vector<XGL_PHYSICAL_GPU_QUEUE_PROPERTIES> queue_props; |
| 88 | uint32_t graphics_queue_node_index; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 89 | |
| 90 | virtual void SetUp() { |
| 91 | XGL_RESULT err; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 92 | int i; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 93 | |
| 94 | this->app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO; |
| 95 | this->app_info.pNext = NULL; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 96 | this->app_info.pAppName = "base"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 97 | this->app_info.appVersion = 1; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 98 | this->app_info.pEngineName = "unittest"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 99 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | 211cc54 | 2015-02-23 17:40:15 -0700 | [diff] [blame] | 100 | this->app_info.apiVersion = XGL_API_VERSION; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 101 | |
Jon Ashburn | 670b176 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 102 | err = xglCreateInstance(&app_info, NULL, &inst); |
| 103 | ASSERT_XGL_SUCCESS(err); |
| 104 | err = xglEnumerateGpus(inst, XGL_MAX_PHYSICAL_GPUS, &this->gpu_count, |
| 105 | objs); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 106 | ASSERT_XGL_SUCCESS(err); |
Jon Ashburn | 19733c9 | 2014-11-26 11:06:49 -0700 | [diff] [blame] | 107 | ASSERT_GE(this->gpu_count, 1) << "No GPU available"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 108 | |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 109 | m_device_id = 0; |
| 110 | this->m_device = new xgl_testing::Device(objs[m_device_id]); |
| 111 | this->m_device->init(); |
| 112 | |
| 113 | props = m_device->gpu().properties(); |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 114 | |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 115 | queue_props = this->m_device->gpu().queue_properties(); |
| 116 | for (i = 0; i < queue_props.size(); i++) { |
| 117 | if (queue_props[i].queueFlags & XGL_QUEUE_GRAPHICS_BIT) { |
| 118 | graphics_queue_node_index = i; |
| 119 | break; |
| 120 | } |
| 121 | } |
| 122 | ASSERT_LT(i, queue_props.size()) << "Could not find a Queue with Graphics support"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | virtual void TearDown() { |
Jon Ashburn | 670b176 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 126 | xglDestroyInstance(inst); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 127 | } |
| 128 | }; |
| 129 | |
Jon Ashburn | 670b176 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 130 | TEST(Initialization, xglEnumerateGpus) { |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 131 | XGL_APPLICATION_INFO app_info = {}; |
Jon Ashburn | 670b176 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 132 | XGL_INSTANCE inst; |
Chia-I Wu | 9c877b2 | 2014-12-28 14:37:25 +0800 | [diff] [blame] | 133 | XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 134 | uint32_t gpu_count; |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 135 | XGL_RESULT err; |
Chia-I Wu | 9c877b2 | 2014-12-28 14:37:25 +0800 | [diff] [blame] | 136 | xgl_testing::PhysicalGpu *gpu; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 137 | char *layers[16]; |
| 138 | size_t layer_count; |
| 139 | char layer_buf[16][256]; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 140 | |
| 141 | app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO; |
| 142 | app_info.pNext = NULL; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 143 | app_info.pAppName = "base"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 144 | app_info.appVersion = 1; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 145 | app_info.pEngineName = "unittest"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 146 | app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | 211cc54 | 2015-02-23 17:40:15 -0700 | [diff] [blame] | 147 | app_info.apiVersion = XGL_API_VERSION; |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 148 | |
Jon Ashburn | 670b176 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 149 | err = xglCreateInstance(&app_info, NULL, &inst); |
| 150 | ASSERT_XGL_SUCCESS(err); |
| 151 | err = xglEnumerateGpus(inst, XGL_MAX_PHYSICAL_GPUS, &gpu_count, objs); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 152 | ASSERT_XGL_SUCCESS(err); |
Jon Ashburn | 19733c9 | 2014-11-26 11:06:49 -0700 | [diff] [blame] | 153 | ASSERT_GE(gpu_count, 1) << "No GPU available"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 154 | |
Jon Ashburn | 96f28fc | 2014-10-15 15:30:23 -0600 | [diff] [blame] | 155 | for (int i = 0; i < 16; i++) |
| 156 | layers[i] = &layer_buf[i][0]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 157 | err = xglEnumerateLayers(objs[0], 16, 256, &layer_count, (char * const *) layers, NULL); |
Jon Ashburn | 96f28fc | 2014-10-15 15:30:23 -0600 | [diff] [blame] | 158 | ASSERT_XGL_SUCCESS(err); |
| 159 | for (int i = 0; i < layer_count; i++) { |
| 160 | printf("Enumerated layers: %s ", layers[i]); |
| 161 | } |
| 162 | printf("\n"); |
| 163 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 164 | // TODO: Iterate over all GPUs |
Chia-I Wu | 9c877b2 | 2014-12-28 14:37:25 +0800 | [diff] [blame] | 165 | gpu = new xgl_testing::PhysicalGpu(objs[0]); |
Chia-I Wu | b7cf445 | 2014-12-16 00:04:02 +0800 | [diff] [blame] | 166 | delete gpu; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 167 | |
| 168 | // TODO: Verify destroy functions |
Jon Ashburn | 670b176 | 2015-01-29 15:48:00 -0700 | [diff] [blame] | 169 | err = xglDestroyInstance(inst); |
| 170 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | TEST_F(XglTest, AllocMemory) { |
| 174 | XGL_RESULT err; |
| 175 | XGL_MEMORY_ALLOC_INFO alloc_info = {}; |
| 176 | XGL_GPU_MEMORY gpu_mem; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 177 | uint8_t *pData; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 178 | |
| 179 | alloc_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 180 | alloc_info.allocationSize = 1024 * 1024; // 1MB |
Jon Ashburn | 542cd09 | 2015-01-20 13:55:32 -0700 | [diff] [blame] | 181 | alloc_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT | |
| 182 | XGL_MEMORY_PROPERTY_CPU_VISIBLE_BIT; |
Jon Ashburn | b4de98b | 2015-01-20 16:59:42 -0700 | [diff] [blame] | 183 | alloc_info.memType = XGL_MEMORY_TYPE_OTHER; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 184 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 185 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 186 | // TODO: Try variety of memory priorities |
| 187 | alloc_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
| 188 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 189 | err = xglAllocMemory(device(), &alloc_info, &gpu_mem); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 190 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 191 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 192 | err = xglMapMemory(gpu_mem, 0, (void **) &pData); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 193 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 194 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 195 | memset(pData, 0x55, alloc_info.allocationSize); |
| 196 | EXPECT_EQ(0x55, pData[0]) << "Memory read not same a write"; |
| 197 | |
| 198 | err = xglUnmapMemory(gpu_mem); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 199 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 200 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 201 | err = xglFreeMemory(gpu_mem); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 202 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 203 | } |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 204 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 205 | TEST_F(XglTest, Event) { |
| 206 | XGL_EVENT_CREATE_INFO event_info; |
| 207 | XGL_EVENT event; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 208 | XGL_MEMORY_REQUIREMENTS mem_req; |
Chia-I Wu | 54ed079 | 2014-12-27 14:14:50 +0800 | [diff] [blame] | 209 | size_t data_size = sizeof(mem_req); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 210 | XGL_RESULT err; |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 211 | |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 212 | // typedef struct _XGL_EVENT_CREATE_INFO |
| 213 | // { |
| 214 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 215 | // const void* pNext; // Pointer to next structure |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 216 | // XGL_FLAGS flags; // Reserved |
| 217 | // } XGL_EVENT_CREATE_INFO; |
| 218 | memset(&event_info, 0, sizeof(event_info)); |
| 219 | event_info.sType = XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 220 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 221 | err = xglCreateEvent(device(), &event_info, &event); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 222 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 223 | |
| 224 | err = xglGetObjectInfo(event, XGL_INFO_TYPE_MEMORY_REQUIREMENTS, |
| 225 | &data_size, &mem_req); |
| 226 | ASSERT_XGL_SUCCESS(err); |
| 227 | |
| 228 | // XGL_RESULT XGLAPI xglAllocMemory( |
| 229 | // XGL_DEVICE device, |
| 230 | // const XGL_MEMORY_ALLOC_INFO* pAllocInfo, |
| 231 | // XGL_GPU_MEMORY* pMem); |
| 232 | XGL_MEMORY_ALLOC_INFO mem_info; |
| 233 | XGL_GPU_MEMORY event_mem; |
| 234 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 235 | 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] | 236 | |
| 237 | memset(&mem_info, 0, sizeof(mem_info)); |
| 238 | mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 239 | mem_info.allocationSize = mem_req.size; |
Jon Ashburn | 542cd09 | 2015-01-20 13:55:32 -0700 | [diff] [blame] | 240 | mem_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 241 | mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
Jon Ashburn | 3276917 | 2015-01-20 15:06:59 -0700 | [diff] [blame] | 242 | mem_info.memType = XGL_MEMORY_TYPE_OTHER; |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 243 | err = xglAllocMemory(device(), &mem_info, &event_mem); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 244 | ASSERT_XGL_SUCCESS(err); |
| 245 | |
Jon Ashburn | ed62b41 | 2015-01-15 10:39:19 -0700 | [diff] [blame] | 246 | err = xglBindObjectMemory(event, 0, event_mem, 0); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 247 | ASSERT_XGL_SUCCESS(err); |
| 248 | |
| 249 | err = xglResetEvent(event); |
| 250 | ASSERT_XGL_SUCCESS(err); |
| 251 | |
| 252 | err = xglGetEventStatus(event); |
| 253 | ASSERT_EQ(XGL_EVENT_RESET, err); |
| 254 | |
| 255 | err = xglSetEvent(event); |
| 256 | ASSERT_XGL_SUCCESS(err); |
| 257 | |
| 258 | err = xglGetEventStatus(event); |
| 259 | ASSERT_EQ(XGL_EVENT_SET, err); |
| 260 | |
| 261 | // TODO: Test actual synchronization with command buffer event. |
| 262 | |
| 263 | // All done with event memory, clean up |
Jon Ashburn | ed62b41 | 2015-01-15 10:39:19 -0700 | [diff] [blame] | 264 | err = xglBindObjectMemory(event, 0, XGL_NULL_HANDLE, 0); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 265 | ASSERT_XGL_SUCCESS(err); |
| 266 | |
| 267 | err = xglDestroyObject(event); |
| 268 | ASSERT_XGL_SUCCESS(err); |
| 269 | } |
| 270 | |
| 271 | TEST_F(XglTest, Fence) { |
| 272 | XGL_RESULT err; |
| 273 | XGL_FENCE_CREATE_INFO fence_info; |
| 274 | XGL_FENCE fence; |
| 275 | |
| 276 | memset(&fence_info, 0, sizeof(fence_info)); |
| 277 | |
| 278 | // typedef struct _XGL_FENCE_CREATE_INFO |
| 279 | // { |
| 280 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 281 | // const void* pNext; // Pointer to next structure |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 282 | // XGL_FLAGS flags; // Reserved |
| 283 | fence_info.sType = XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 284 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 285 | err = xglCreateFence(device(), &fence_info, &fence); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 286 | ASSERT_XGL_SUCCESS(err); |
| 287 | |
| 288 | err = xglGetFenceStatus(fence); |
| 289 | // We've not submitted this fence on a command buffer so should get |
| 290 | // XGL_ERROR_UNAVAILABLE |
| 291 | EXPECT_EQ(XGL_ERROR_UNAVAILABLE, err); |
| 292 | |
| 293 | // Test glxWaitForFences |
| 294 | // XGL_RESULT XGLAPI xglWaitForFences( |
| 295 | // XGL_DEVICE device, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 296 | // uint32_t fenceCount, |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 297 | // const XGL_FENCE* pFences, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 298 | // bool32_t waitAll, |
| 299 | // uint64_t timeout); |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 300 | err = xglWaitForFences(device(), 1, &fence, XGL_TRUE, 0); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 301 | EXPECT_EQ(XGL_ERROR_UNAVAILABLE, err); |
| 302 | |
| 303 | // TODO: Attached to command buffer and test GetFenceStatus |
| 304 | // TODO: Add some commands and submit the command buffer |
| 305 | |
| 306 | err = xglDestroyObject(fence); |
| 307 | ASSERT_XGL_SUCCESS(err); |
| 308 | |
| 309 | } |
| 310 | |
| 311 | #define MAX_QUERY_SLOTS 10 |
| 312 | |
| 313 | TEST_F(XglTest, Query) { |
| 314 | XGL_QUERY_POOL_CREATE_INFO query_info; |
| 315 | XGL_QUERY_POOL query_pool; |
Chia-I Wu | 54ed079 | 2014-12-27 14:14:50 +0800 | [diff] [blame] | 316 | size_t data_size; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 317 | XGL_MEMORY_REQUIREMENTS mem_req; |
Chia-I Wu | 54ed079 | 2014-12-27 14:14:50 +0800 | [diff] [blame] | 318 | size_t query_result_size; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 319 | uint32_t *query_result_data; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 320 | XGL_RESULT err; |
| 321 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 322 | // typedef enum _XGL_QUERY_TYPE |
| 323 | // { |
| 324 | // XGL_QUERY_OCCLUSION = 0x00000000, |
| 325 | // XGL_QUERY_PIPELINE_STATISTICS = 0x00000001, |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 326 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 327 | // XGL_QUERY_TYPE_BEGIN_RANGE = XGL_QUERY_OCCLUSION, |
| 328 | // XGL_QUERY_TYPE_END_RANGE = XGL_QUERY_PIPELINE_STATISTICS, |
| 329 | // XGL_NUM_QUERY_TYPE = (XGL_QUERY_TYPE_END_RANGE - XGL_QUERY_TYPE_BEGIN_RANGE + 1), |
| 330 | // XGL_MAX_ENUM(_XGL_QUERY_TYPE) |
| 331 | // } XGL_QUERY_TYPE; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 332 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 333 | // typedef struct _XGL_QUERY_POOL_CREATE_INFO |
| 334 | // { |
| 335 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 336 | // const void* pNext; // Pointer to next structure |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 337 | // XGL_QUERY_TYPE queryType; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 338 | // uint32_t slots; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 339 | // } XGL_QUERY_POOL_CREATE_INFO; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 340 | |
| 341 | memset(&query_info, 0, sizeof(query_info)); |
| 342 | query_info.sType = XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 343 | query_info.queryType = XGL_QUERY_OCCLUSION; |
| 344 | query_info.slots = MAX_QUERY_SLOTS; |
| 345 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 346 | // XGL_RESULT XGLAPI xglCreateQueryPool( |
| 347 | // XGL_DEVICE device, |
| 348 | // const XGL_QUERY_POOL_CREATE_INFO* pCreateInfo, |
| 349 | // XGL_QUERY_POOL* pQueryPool); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 350 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 351 | err = xglCreateQueryPool(device(), &query_info, &query_pool); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 352 | ASSERT_XGL_SUCCESS(err); |
| 353 | |
Jon Ashburn | b8e4389 | 2014-09-25 14:36:58 -0600 | [diff] [blame] | 354 | data_size = sizeof(mem_req); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 355 | err = xglGetObjectInfo(query_pool, XGL_INFO_TYPE_MEMORY_REQUIREMENTS, |
| 356 | &data_size, &mem_req); |
| 357 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 358 | ASSERT_NE(0, data_size) << "Invalid data_size"; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 359 | |
| 360 | // XGL_RESULT XGLAPI xglAllocMemory( |
| 361 | // XGL_DEVICE device, |
| 362 | // const XGL_MEMORY_ALLOC_INFO* pAllocInfo, |
| 363 | // XGL_GPU_MEMORY* pMem); |
| 364 | XGL_MEMORY_ALLOC_INFO mem_info; |
| 365 | XGL_GPU_MEMORY query_mem; |
| 366 | |
| 367 | memset(&mem_info, 0, sizeof(mem_info)); |
| 368 | mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 369 | // TODO: Is a simple multiple all that's needed here? |
| 370 | mem_info.allocationSize = mem_req.size * MAX_QUERY_SLOTS; |
Jon Ashburn | 542cd09 | 2015-01-20 13:55:32 -0700 | [diff] [blame] | 371 | mem_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT; |
Jon Ashburn | 3276917 | 2015-01-20 15:06:59 -0700 | [diff] [blame] | 372 | mem_info.memType = XGL_MEMORY_TYPE_OTHER; |
Jon Ashburn | b4de98b | 2015-01-20 16:59:42 -0700 | [diff] [blame] | 373 | mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 374 | // TODO: Should this be pinned? Or maybe a separate test with pinned. |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 375 | err = xglAllocMemory(device(), &mem_info, &query_mem); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 376 | ASSERT_XGL_SUCCESS(err); |
| 377 | |
Jon Ashburn | ed62b41 | 2015-01-15 10:39:19 -0700 | [diff] [blame] | 378 | err = xglBindObjectMemory(query_pool, 0, query_mem, 0); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 379 | ASSERT_XGL_SUCCESS(err); |
| 380 | |
| 381 | // TODO: Test actual synchronization with command buffer event. |
| 382 | // TODO: Create command buffer |
| 383 | // TODO: xglCmdResetQueryPool |
| 384 | // TODO: xglCmdBeginQuery |
| 385 | // TODO: commands |
| 386 | // TOOD: xglCmdEndQuery |
| 387 | |
| 388 | err = xglGetQueryPoolResults(query_pool, 0, MAX_QUERY_SLOTS, |
| 389 | &query_result_size, XGL_NULL_HANDLE); |
| 390 | ASSERT_XGL_SUCCESS(err); |
| 391 | |
| 392 | if (query_result_size > 0) { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 393 | query_result_data = new uint32_t [query_result_size]; |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 394 | err = xglGetQueryPoolResults(query_pool, 0, MAX_QUERY_SLOTS, |
| 395 | &query_result_size, query_result_data); |
| 396 | ASSERT_XGL_SUCCESS(err); |
| 397 | |
| 398 | // TODO: Test Query result data. |
| 399 | |
| 400 | } |
| 401 | |
| 402 | // All done with QueryPool memory, clean up |
Jon Ashburn | ed62b41 | 2015-01-15 10:39:19 -0700 | [diff] [blame] | 403 | err = xglBindObjectMemory(query_pool, 0, XGL_NULL_HANDLE, 0); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 404 | ASSERT_XGL_SUCCESS(err); |
| 405 | |
| 406 | err = xglDestroyObject(query_pool); |
| 407 | ASSERT_XGL_SUCCESS(err); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 408 | } |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 409 | |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 410 | void getQueue(xgl_testing::Device *device, uint32_t queue_node_index, const char *qname) |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 411 | { |
| 412 | int que_idx; |
| 413 | XGL_RESULT err; |
| 414 | XGL_QUEUE queue; |
| 415 | |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 416 | const XGL_PHYSICAL_GPU_QUEUE_PROPERTIES props = device->gpu().queue_properties()[queue_node_index]; |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 417 | for (que_idx = 0; que_idx < props.queueCount; que_idx++) { |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 418 | err = xglGetDeviceQueue(device->obj(), queue_node_index, que_idx, &queue); |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 419 | ASSERT_EQ(XGL_SUCCESS, err) << "xglGetDeviceQueue: " << qname << " queue #" << que_idx << ": Failed with error: " << xgl_result_string(err); |
| 420 | } |
| 421 | } |
| 422 | |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 423 | |
| 424 | void print_queue_info(xgl_testing::Device *device, uint32_t queue_node_index) |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 425 | { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 426 | uint32_t que_idx; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 427 | XGL_PHYSICAL_GPU_QUEUE_PROPERTIES queue_props; |
| 428 | XGL_PHYSICAL_GPU_PROPERTIES props; |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 429 | |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 430 | props = device->gpu().properties(); |
| 431 | queue_props = device->gpu().queue_properties()[queue_node_index]; |
| 432 | ASSERT_NE(0, queue_props.queueCount) << "No Queues available at Node Index #" << queue_node_index << " GPU: " << props.gpuName; |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 433 | |
| 434 | // XGL_RESULT XGLAPI xglGetDeviceQueue( |
| 435 | // XGL_DEVICE device, |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 436 | // uint32_t queueNodeIndex, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 437 | // uint32_t queueIndex, |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 438 | // XGL_QUEUE* pQueue); |
| 439 | /* |
| 440 | * queue handles are retrieved from the device by calling |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 441 | * xglGetDeviceQueue() with a queue node index and a requested logical |
| 442 | * queue ID. The queue node index is the index into the array of |
| 443 | * XGL_PHYSICAL_GPU_QUEUE_PROPERTIES returned by GetGpuInfo. Each |
| 444 | * queue node index has different attributes specified by the XGL_QUEUE_FLAGS property. |
| 445 | * The logical queue ID is a sequential number starting from zero |
| 446 | * and referencing up to the number of queues supported of that node index |
| 447 | * at device creation. |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 448 | */ |
| 449 | |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 450 | for (que_idx = 0; que_idx < queue_props.queueCount; que_idx++) { |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 451 | |
| 452 | // typedef enum _XGL_QUEUE_FLAGS |
| 453 | // { |
| 454 | // XGL_QUEUE_GRAPHICS_BIT = 0x00000001, // Queue supports graphics operations |
| 455 | // XGL_QUEUE_COMPUTE_BIT = 0x00000002, // Queue supports compute operations |
| 456 | // XGL_QUEUE_DMA_BIT = 0x00000004, // Queue supports DMA operations |
| 457 | // XGL_QUEUE_EXTENDED_BIT = 0x80000000 // Extended queue |
| 458 | // } XGL_QUEUE_FLAGS; |
| 459 | |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 460 | if (queue_props.queueFlags & XGL_QUEUE_GRAPHICS_BIT) { |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 461 | getQueue(device, queue_node_index, "Graphics"); |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 462 | } |
| 463 | |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 464 | if (queue_props.queueFlags & XGL_QUEUE_COMPUTE_BIT) { |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 465 | getQueue(device, queue_node_index, "Compute"); |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 466 | } |
| 467 | |
Chia-I Wu | 3b78d31 | 2014-12-29 15:39:23 +0800 | [diff] [blame] | 468 | if (queue_props.queueFlags & XGL_QUEUE_DMA_BIT) { |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 469 | getQueue(device, queue_node_index, "DMA"); |
Courtney Goeltzenleuchter | cc32aa9 | 2014-08-14 10:15:09 -0600 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | // TODO: What do we do about EXTENDED_BIT? |
| 473 | |
| 474 | /* Guide: pg 34: |
| 475 | * The queue objects cannot be destroyed explicitly by an application |
| 476 | * and are automatically destroyed when the associated device is destroyed. |
| 477 | * Once the device is destroyed, attempting to use a queue results in |
| 478 | * undefined behavior. |
| 479 | */ |
| 480 | } |
| 481 | } |
| 482 | |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 483 | TEST_F(XglTest, Queue) |
| 484 | { |
| 485 | uint32_t i; |
| 486 | |
| 487 | for (i = 0; i < m_device->gpu().queue_properties().size(); i++) { |
| 488 | print_queue_info(m_device, i); |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 493 | void XglTest::CreateImageTest() |
| 494 | { |
| 495 | XGL_RESULT err; |
| 496 | XGL_IMAGE image; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 497 | uint32_t w, h, mipCount; |
| 498 | size_t size; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 499 | XGL_FORMAT fmt; |
| 500 | XGL_FORMAT_PROPERTIES image_fmt; |
Chia-I Wu | 54ed079 | 2014-12-27 14:14:50 +0800 | [diff] [blame] | 501 | size_t data_size; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 502 | |
| 503 | w =512; |
| 504 | h = 256; |
| 505 | mipCount = 0; |
| 506 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 507 | uint32_t _w = w; |
| 508 | uint32_t _h = h; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 509 | while( ( _w > 0 ) || ( _h > 0 ) ) |
| 510 | { |
| 511 | _w >>= 1; |
| 512 | _h >>= 1; |
| 513 | mipCount++; |
| 514 | } |
| 515 | |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 516 | fmt = XGL_FMT_R8G8B8A8_UINT; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 517 | // TODO: Pick known good format rather than just expect common format |
| 518 | /* |
| 519 | * XXX: What should happen if given NULL HANDLE for the pData argument? |
| 520 | * We're not requesting XGL_INFO_TYPE_MEMORY_REQUIREMENTS so there is |
| 521 | * an expectation that pData is a valid pointer. |
| 522 | * However, why include a returned size value? That implies that the |
| 523 | * amount of data may vary and that doesn't work well for using a |
| 524 | * fixed structure. |
| 525 | */ |
| 526 | |
Jon Ashburn | b8e4389 | 2014-09-25 14:36:58 -0600 | [diff] [blame] | 527 | size = sizeof(image_fmt); |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 528 | err = xglGetFormatInfo(device(), fmt, |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 529 | XGL_INFO_TYPE_FORMAT_PROPERTIES, |
| 530 | &size, &image_fmt); |
| 531 | ASSERT_XGL_SUCCESS(err); |
| 532 | |
| 533 | // typedef struct _XGL_IMAGE_CREATE_INFO |
| 534 | // { |
| 535 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 536 | // const void* pNext; // Pointer to next structure. |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 537 | // XGL_IMAGE_TYPE imageType; |
| 538 | // XGL_FORMAT format; |
| 539 | // XGL_EXTENT3D extent; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 540 | // uint32_t mipLevels; |
| 541 | // uint32_t arraySize; |
| 542 | // uint32_t samples; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 543 | // XGL_IMAGE_TILING tiling; |
| 544 | // XGL_FLAGS usage; // XGL_IMAGE_USAGE_FLAGS |
| 545 | // XGL_FLAGS flags; // XGL_IMAGE_CREATE_FLAGS |
| 546 | // } XGL_IMAGE_CREATE_INFO; |
| 547 | |
| 548 | |
| 549 | XGL_IMAGE_CREATE_INFO imageCreateInfo = {}; |
| 550 | imageCreateInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 551 | imageCreateInfo.imageType = XGL_IMAGE_2D; |
| 552 | imageCreateInfo.format = fmt; |
| 553 | imageCreateInfo.arraySize = 1; |
| 554 | imageCreateInfo.extent.width = w; |
| 555 | imageCreateInfo.extent.height = h; |
| 556 | imageCreateInfo.extent.depth = 1; |
| 557 | imageCreateInfo.mipLevels = mipCount; |
| 558 | imageCreateInfo.samples = 1; |
| 559 | imageCreateInfo.tiling = XGL_LINEAR_TILING; |
| 560 | |
| 561 | // Image usage flags |
| 562 | // typedef enum _XGL_IMAGE_USAGE_FLAGS |
| 563 | // { |
| 564 | // XGL_IMAGE_USAGE_SHADER_ACCESS_READ_BIT = 0x00000001, |
| 565 | // XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT = 0x00000002, |
| 566 | // XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000004, |
| 567 | // XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT = 0x00000008, |
| 568 | // } XGL_IMAGE_USAGE_FLAGS; |
| 569 | imageCreateInfo.usage = XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT | XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 570 | |
| 571 | // XGL_RESULT XGLAPI xglCreateImage( |
| 572 | // XGL_DEVICE device, |
| 573 | // const XGL_IMAGE_CREATE_INFO* pCreateInfo, |
| 574 | // XGL_IMAGE* pImage); |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 575 | err = xglCreateImage(device(), &imageCreateInfo, &image); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 576 | ASSERT_XGL_SUCCESS(err); |
| 577 | |
Courtney Goeltzenleuchter | ac3b73a | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 578 | // Verify image resources |
| 579 | // XGL_RESULT XGLAPI xglGetImageSubresourceInfo( |
| 580 | // XGL_IMAGE image, |
| 581 | // const XGL_IMAGE_SUBRESOURCE* pSubresource, |
| 582 | // XGL_SUBRESOURCE_INFO_TYPE infoType, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 583 | // size_t* pDataSize, |
| 584 | // void* pData); |
Courtney Goeltzenleuchter | ac3b73a | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 585 | // typedef struct _XGL_SUBRESOURCE_LAYOUT |
| 586 | // { |
| 587 | // XGL_GPU_SIZE offset; // Specified in bytes |
| 588 | // XGL_GPU_SIZE size; // Specified in bytes |
| 589 | // XGL_GPU_SIZE rowPitch; // Specified in bytes |
| 590 | // XGL_GPU_SIZE depthPitch; // Specified in bytes |
| 591 | // } XGL_SUBRESOURCE_LAYOUT; |
| 592 | |
| 593 | // typedef struct _XGL_IMAGE_SUBRESOURCE |
| 594 | // { |
| 595 | // XGL_IMAGE_ASPECT aspect; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 596 | // uint32_t mipLevel; |
| 597 | // uint32_t arraySlice; |
Courtney Goeltzenleuchter | ac3b73a | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 598 | // } XGL_IMAGE_SUBRESOURCE; |
| 599 | // typedef enum _XGL_SUBRESOURCE_INFO_TYPE |
| 600 | // { |
| 601 | // // Info type for xglGetImageSubresourceInfo() |
| 602 | // XGL_INFO_TYPE_SUBRESOURCE_LAYOUT = 0x00000000, |
| 603 | |
| 604 | // XGL_MAX_ENUM(_XGL_SUBRESOURCE_INFO_TYPE) |
| 605 | // } XGL_SUBRESOURCE_INFO_TYPE; |
| 606 | XGL_IMAGE_SUBRESOURCE subresource = {}; |
| 607 | subresource.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 608 | subresource.arraySlice = 0; |
| 609 | |
| 610 | _w = w; |
| 611 | _h = h; |
| 612 | while( ( _w > 0 ) || ( _h > 0 ) ) |
| 613 | { |
| 614 | XGL_SUBRESOURCE_LAYOUT layout = {}; |
Jon Ashburn | b8e4389 | 2014-09-25 14:36:58 -0600 | [diff] [blame] | 615 | data_size = sizeof(layout); |
Courtney Goeltzenleuchter | ac3b73a | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 616 | err = xglGetImageSubresourceInfo(image, &subresource, XGL_INFO_TYPE_SUBRESOURCE_LAYOUT, |
| 617 | &data_size, &layout); |
| 618 | ASSERT_XGL_SUCCESS(err); |
| 619 | ASSERT_EQ(sizeof(XGL_SUBRESOURCE_LAYOUT), data_size) << "Invalid structure (XGL_SUBRESOURCE_LAYOUT) size"; |
| 620 | |
| 621 | // TODO: 4 should be replaced with pixel size for given format |
| 622 | EXPECT_LE(_w * 4, layout.rowPitch) << "Pitch does not match expected image pitch"; |
| 623 | _w >>= 1; |
| 624 | _h >>= 1; |
| 625 | |
| 626 | subresource.mipLevel++; |
| 627 | } |
| 628 | |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 629 | XGL_MEMORY_ALLOC_IMAGE_INFO img_alloc = { |
| 630 | .sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO, |
| 631 | .pNext = NULL, |
| 632 | |
| 633 | }; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 634 | XGL_MEMORY_REQUIREMENTS mem_req; |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 635 | XGL_IMAGE_MEMORY_REQUIREMENTS img_reqs; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 636 | size_t img_reqs_size = sizeof(XGL_IMAGE_MEMORY_REQUIREMENTS); |
Jon Ashburn | b8e4389 | 2014-09-25 14:36:58 -0600 | [diff] [blame] | 637 | data_size = sizeof(mem_req); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 638 | err = xglGetObjectInfo(image, XGL_INFO_TYPE_MEMORY_REQUIREMENTS, |
| 639 | &data_size, &mem_req); |
| 640 | ASSERT_XGL_SUCCESS(err); |
| 641 | ASSERT_EQ(data_size, sizeof(mem_req)); |
| 642 | ASSERT_NE(0, mem_req.size) << "xglGetObjectInfo (Event): Failed - expect images to require memory"; |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 643 | err = xglGetObjectInfo(image, XGL_INFO_TYPE_IMAGE_MEMORY_REQUIREMENTS, |
| 644 | &img_reqs_size, &img_reqs); |
| 645 | ASSERT_XGL_SUCCESS(err); |
| 646 | ASSERT_EQ(img_reqs_size, sizeof(XGL_IMAGE_MEMORY_REQUIREMENTS)); |
| 647 | img_alloc.usage = img_reqs.usage; |
| 648 | img_alloc.formatClass = img_reqs.formatClass; |
| 649 | img_alloc.samples = img_reqs.samples; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 650 | // XGL_RESULT XGLAPI xglAllocMemory( |
| 651 | // XGL_DEVICE device, |
| 652 | // const XGL_MEMORY_ALLOC_INFO* pAllocInfo, |
| 653 | // XGL_GPU_MEMORY* pMem); |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 654 | XGL_MEMORY_ALLOC_INFO mem_info = {}; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 655 | XGL_GPU_MEMORY image_mem; |
| 656 | |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 657 | mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 658 | mem_info.pNext = &img_alloc; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 659 | mem_info.allocationSize = mem_req.size; |
Jon Ashburn | 542cd09 | 2015-01-20 13:55:32 -0700 | [diff] [blame] | 660 | mem_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT; |
Jon Ashburn | 3276917 | 2015-01-20 15:06:59 -0700 | [diff] [blame] | 661 | mem_info.memType = XGL_MEMORY_TYPE_IMAGE; |
Jon Ashburn | b4de98b | 2015-01-20 16:59:42 -0700 | [diff] [blame] | 662 | mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 663 | err = xglAllocMemory(device(), &mem_info, &image_mem); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 664 | ASSERT_XGL_SUCCESS(err); |
| 665 | |
Jon Ashburn | ed62b41 | 2015-01-15 10:39:19 -0700 | [diff] [blame] | 666 | err = xglBindObjectMemory(image, 0, image_mem, 0); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 667 | ASSERT_XGL_SUCCESS(err); |
| 668 | |
| 669 | // typedef struct _XGL_IMAGE_VIEW_CREATE_INFO |
| 670 | // { |
| 671 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 672 | // const void* pNext; // Pointer to next structure |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 673 | // XGL_IMAGE image; |
| 674 | // XGL_IMAGE_VIEW_TYPE viewType; |
| 675 | // XGL_FORMAT format; |
| 676 | // XGL_CHANNEL_MAPPING channels; |
| 677 | // XGL_IMAGE_SUBRESOURCE_RANGE subresourceRange; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 678 | // float minLod; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 679 | // } XGL_IMAGE_VIEW_CREATE_INFO; |
| 680 | XGL_IMAGE_VIEW_CREATE_INFO viewInfo = {}; |
| 681 | XGL_IMAGE_VIEW view; |
| 682 | viewInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 683 | viewInfo.image = image; |
| 684 | viewInfo.viewType = XGL_IMAGE_VIEW_2D; |
| 685 | viewInfo.format = fmt; |
| 686 | |
| 687 | viewInfo.channels.r = XGL_CHANNEL_SWIZZLE_R; |
| 688 | viewInfo.channels.g = XGL_CHANNEL_SWIZZLE_G; |
| 689 | viewInfo.channels.b = XGL_CHANNEL_SWIZZLE_B; |
| 690 | viewInfo.channels.a = XGL_CHANNEL_SWIZZLE_A; |
| 691 | |
| 692 | viewInfo.subresourceRange.baseArraySlice = 0; |
| 693 | viewInfo.subresourceRange.arraySize = 1; |
| 694 | viewInfo.subresourceRange.baseMipLevel = 0; |
| 695 | viewInfo.subresourceRange.mipLevels = 1; |
| 696 | viewInfo.subresourceRange.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 697 | |
| 698 | // XGL_RESULT XGLAPI xglCreateImageView( |
| 699 | // XGL_DEVICE device, |
| 700 | // const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, |
| 701 | // XGL_IMAGE_VIEW* pView); |
| 702 | |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 703 | err = xglCreateImageView(device(), &viewInfo, &view); |
Courtney Goeltzenleuchter | ac3b73a | 2014-08-14 17:40:57 -0600 | [diff] [blame] | 704 | ASSERT_XGL_SUCCESS(err) << "xglCreateImageView failed"; |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 705 | |
| 706 | // TODO: Test image memory. |
| 707 | |
| 708 | // All done with image memory, clean up |
Jon Ashburn | ed62b41 | 2015-01-15 10:39:19 -0700 | [diff] [blame] | 709 | ASSERT_XGL_SUCCESS(xglBindObjectMemory(image, 0, XGL_NULL_HANDLE, 0)); |
Courtney Goeltzenleuchter | 9c3aad0 | 2014-08-13 17:55:12 -0600 | [diff] [blame] | 710 | |
| 711 | ASSERT_XGL_SUCCESS(xglFreeMemory(image_mem)); |
| 712 | |
| 713 | ASSERT_XGL_SUCCESS(xglDestroyObject(image)); |
| 714 | } |
| 715 | |
| 716 | TEST_F(XglTest, CreateImage) { |
| 717 | CreateImageTest(); |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 718 | } |
| 719 | |
Courtney Goeltzenleuchter | 0842df7 | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 720 | void XglTest::CreateCommandBufferTest() |
| 721 | { |
| 722 | XGL_RESULT err; |
| 723 | XGL_CMD_BUFFER_CREATE_INFO info = {}; |
| 724 | XGL_CMD_BUFFER cmdBuffer; |
| 725 | |
| 726 | // typedef struct _XGL_CMD_BUFFER_CREATE_INFO |
| 727 | // { |
| 728 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 729 | // const void* pNext; |
Courtney Goeltzenleuchter | 0842df7 | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 730 | // XGL_QUEUE_TYPE queueType; |
| 731 | // XGL_FLAGS flags; |
| 732 | // } XGL_CMD_BUFFER_CREATE_INFO; |
| 733 | |
| 734 | info.sType = XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame^] | 735 | info.queueNodeIndex = graphics_queue_node_index; |
Courtney Goeltzenleuchter | 0842df7 | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 736 | err = xglCreateCommandBuffer(device(), &info, &cmdBuffer); |
| 737 | ASSERT_XGL_SUCCESS(err) << "xglCreateCommandBuffer failed"; |
| 738 | |
| 739 | ASSERT_XGL_SUCCESS(xglDestroyObject(cmdBuffer)); |
| 740 | } |
| 741 | |
| 742 | TEST_F(XglTest, TestComandBuffer) { |
| 743 | CreateCommandBufferTest(); |
| 744 | } |
| 745 | |
| 746 | void XglTest::CreateShader(XGL_SHADER *pshader) |
| 747 | { |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 748 | void *code; |
| 749 | uint32_t codeSize; |
Cody Northrop | acfb049 | 2015-03-17 15:55:58 -0600 | [diff] [blame] | 750 | struct icd_spv_header *pSPV; |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 751 | XGL_RESULT err; |
| 752 | |
Cody Northrop | acfb049 | 2015-03-17 15:55:58 -0600 | [diff] [blame] | 753 | codeSize = sizeof(struct icd_spv_header) + 100; |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 754 | code = malloc(codeSize); |
| 755 | ASSERT_TRUE(NULL != code) << "malloc failed!"; |
| 756 | |
| 757 | memset(code, 0, codeSize); |
| 758 | |
Cody Northrop | acfb049 | 2015-03-17 15:55:58 -0600 | [diff] [blame] | 759 | // Indicate that this is SPV data. |
| 760 | pSPV = (struct icd_spv_header *) code; |
| 761 | pSPV->magic = ICD_SPV_MAGIC; |
| 762 | pSPV->version = ICD_SPV_VERSION; |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 763 | |
| 764 | // typedef struct _XGL_SHADER_CREATE_INFO |
| 765 | // { |
| 766 | // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 767 | // const void* pNext; // Pointer to next structure |
| 768 | // size_t codeSize; // Specified in bytes |
| 769 | // const void* pCode; |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 770 | // XGL_FLAGS flags; // Reserved |
| 771 | // } XGL_SHADER_CREATE_INFO; |
| 772 | |
| 773 | XGL_SHADER_CREATE_INFO createInfo; |
| 774 | XGL_SHADER shader; |
| 775 | |
| 776 | createInfo.sType = XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO; |
| 777 | createInfo.pNext = NULL; |
| 778 | createInfo.pCode = code; |
| 779 | createInfo.codeSize = codeSize; |
| 780 | createInfo.flags = 0; |
Courtney Goeltzenleuchter | b85c581 | 2014-08-19 18:35:50 -0600 | [diff] [blame] | 781 | err = xglCreateShader(device(), &createInfo, &shader); |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 782 | ASSERT_XGL_SUCCESS(err); |
| 783 | |
Courtney Goeltzenleuchter | 0842df7 | 2014-08-20 15:26:55 -0600 | [diff] [blame] | 784 | *pshader = shader; |
| 785 | } |
| 786 | |
Courtney Goeltzenleuchter | 6b814b3 | 2014-08-12 09:59:36 -0600 | [diff] [blame] | 787 | int main(int argc, char **argv) { |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 788 | ::testing::InitGoogleTest(&argc, argv); |
Chia-I Wu | 1c9869e | 2014-12-28 14:27:28 +0800 | [diff] [blame] | 789 | xgl_testing::set_error_callback(test_error_callback); |
Courtney Goeltzenleuchter | ed56abc | 2014-08-12 14:12:22 -0600 | [diff] [blame] | 790 | return RUN_ALL_TESTS(); |
Courtney Goeltzenleuchter | 7087dde | 2014-08-11 18:19:35 -0600 | [diff] [blame] | 791 | } |