blob: f8e2e8e20382bc6ac9c2e3fbb8f7908cebf958bb [file] [log] [blame]
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -06001// Copyright 2005, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060030
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 Goeltzenleuchter7087dde2014-08-11 18:19:35 -060054// Verify XGL driver initialization
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060055
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -060056#include <stdlib.h>
57#include <stdio.h>
58#include <stdbool.h>
59#include <string.h>
60
61#include <xgl.h>
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060062#include "gtest-1.7.0/include/gtest/gtest.h"
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -060063
Chia-I Wu3b78d312014-12-29 15:39:23 +080064#include "xgltestbinding.h"
65#include "test_common.h"
Chia-I Wu4115c892014-08-28 11:56:29 +080066#include "icd-bil.h"
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -060067
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060068class XglTest : public ::testing::Test {
69public:
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -060070 void CreateImageTest();
Courtney Goeltzenleuchter0842df72014-08-20 15:26:55 -060071 void CreateCommandBufferTest();
72 void CreatePipelineTest();
73 void CreateShaderTest();
74 void CreateShader(XGL_SHADER *pshader);
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -060075
Chia-I Wu3b78d312014-12-29 15:39:23 +080076 XGL_DEVICE device() {return m_device->obj();}
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -060077
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060078protected:
79 XGL_APPLICATION_INFO app_info;
Chia-I Wu9c877b22014-12-28 14:37:25 +080080 XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS];
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060081 XGL_UINT gpu_count;
Chia-I Wu3b78d312014-12-29 15:39:23 +080082
83 XGL_UINT m_device_id;
84 xgl_testing::Device *m_device;
85 XGL_PHYSICAL_GPU_PROPERTIES props;
86 XGL_PHYSICAL_GPU_QUEUE_PROPERTIES queue_props;
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060087
88 virtual void SetUp() {
89 XGL_RESULT err;
90
91 this->app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO;
92 this->app_info.pNext = NULL;
Chia-I Wu7461fcf2014-12-27 15:16:07 +080093 this->app_info.pAppName = "base";
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060094 this->app_info.appVersion = 1;
Chia-I Wu7461fcf2014-12-27 15:16:07 +080095 this->app_info.pEngineName = "unittest";
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -060096 this->app_info.engineVersion = 1;
97 this->app_info.apiVersion = XGL_MAKE_VERSION(0, 22, 0);
98
99 err = xglInitAndEnumerateGpus(&app_info, NULL,
Chia-I Wu9c877b22014-12-28 14:37:25 +0800100 XGL_MAX_PHYSICAL_GPUS, &this->gpu_count, objs);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600101 ASSERT_XGL_SUCCESS(err);
Jon Ashburn19733c92014-11-26 11:06:49 -0700102 ASSERT_GE(this->gpu_count, 1) << "No GPU available";
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600103
Chia-I Wu3b78d312014-12-29 15:39:23 +0800104 m_device_id = 0;
105 this->m_device = new xgl_testing::Device(objs[m_device_id]);
106 this->m_device->init();
107
108 props = m_device->gpu().properties();
109 queue_props = m_device->gpu().queue_properties()[0];
110
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600111 }
112
113 virtual void TearDown() {
114 xglInitAndEnumerateGpus(&this->app_info, NULL, 0, &gpu_count, NULL);
115 }
116};
117
118TEST(Initialization, xglInitAndEnumerateGpus) {
119 XGL_APPLICATION_INFO app_info = {};
Chia-I Wu9c877b22014-12-28 14:37:25 +0800120 XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS];
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600121 XGL_UINT gpu_count;
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -0600122 XGL_RESULT err;
Chia-I Wu9c877b22014-12-28 14:37:25 +0800123 xgl_testing::PhysicalGpu *gpu;
Jon Ashburn96f28fc2014-10-15 15:30:23 -0600124 XGL_CHAR *layers[16];
125 XGL_SIZE layer_count;
126 XGL_CHAR layer_buf[16][256];
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600127
128 app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO;
129 app_info.pNext = NULL;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800130 app_info.pAppName = "base";
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600131 app_info.appVersion = 1;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800132 app_info.pEngineName = "unittest";
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600133 app_info.engineVersion = 1;
134 app_info.apiVersion = XGL_MAKE_VERSION(0, 22, 0);
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -0600135
136 err = xglInitAndEnumerateGpus(&app_info, NULL,
Chia-I Wu9c877b22014-12-28 14:37:25 +0800137 XGL_MAX_PHYSICAL_GPUS, &gpu_count, objs);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600138 ASSERT_XGL_SUCCESS(err);
Jon Ashburn19733c92014-11-26 11:06:49 -0700139 ASSERT_GE(gpu_count, 1) << "No GPU available";
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600140
Jon Ashburn96f28fc2014-10-15 15:30:23 -0600141 for (int i = 0; i < 16; i++)
142 layers[i] = &layer_buf[i][0];
Mark Lobodzinski953a1692015-01-09 15:12:03 -0600143 err = xglEnumerateLayers(objs[0], 16, 256, &layer_count, (XGL_CHAR * const *) layers, NULL);
Jon Ashburn96f28fc2014-10-15 15:30:23 -0600144 ASSERT_XGL_SUCCESS(err);
145 for (int i = 0; i < layer_count; i++) {
146 printf("Enumerated layers: %s ", layers[i]);
147 }
148 printf("\n");
149
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600150 // TODO: Iterate over all GPUs
Chia-I Wu9c877b22014-12-28 14:37:25 +0800151 gpu = new xgl_testing::PhysicalGpu(objs[0]);
Chia-I Wub7cf4452014-12-16 00:04:02 +0800152 delete gpu;
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600153
154 // TODO: Verify destroy functions
155}
156
157TEST_F(XglTest, AllocMemory) {
158 XGL_RESULT err;
159 XGL_MEMORY_ALLOC_INFO alloc_info = {};
160 XGL_GPU_MEMORY gpu_mem;
161 XGL_UINT8 *pData;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700162 XGL_UINT localHeap[1] = {0};
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600163
164 alloc_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
165 alloc_info.allocationSize = 1024 * 1024; // 1MB
166 alloc_info.alignment = 0;
167 alloc_info.heapCount = 1;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700168 alloc_info.pHeaps = localHeap;
169
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600170
171 // TODO: Pick heap properties indicated by heap info
172 alloc_info.flags = XGL_MEMORY_HEAP_CPU_VISIBLE_BIT;
173
174 // TODO: Try variety of memory priorities
175 alloc_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
176
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600177 err = xglAllocMemory(device(), &alloc_info, &gpu_mem);
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600178 ASSERT_XGL_SUCCESS(err);
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -0600179
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600180 err = xglMapMemory(gpu_mem, 0, (XGL_VOID **) &pData);
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600181 ASSERT_XGL_SUCCESS(err);
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600182
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600183 memset(pData, 0x55, alloc_info.allocationSize);
184 EXPECT_EQ(0x55, pData[0]) << "Memory read not same a write";
185
186 err = xglUnmapMemory(gpu_mem);
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600187 ASSERT_XGL_SUCCESS(err);
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600188
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600189 err = xglFreeMemory(gpu_mem);
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600190 ASSERT_XGL_SUCCESS(err);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600191}
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600192
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600193TEST_F(XglTest, Event) {
194 XGL_EVENT_CREATE_INFO event_info;
195 XGL_EVENT event;
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600196 XGL_MEMORY_REQUIREMENTS mem_req;
Chia-I Wu54ed0792014-12-27 14:14:50 +0800197 size_t data_size = sizeof(mem_req);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600198 XGL_RESULT err;
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600199
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600200 // typedef struct _XGL_EVENT_CREATE_INFO
201 // {
202 // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO
203 // const XGL_VOID* pNext; // Pointer to next structure
204 // XGL_FLAGS flags; // Reserved
205 // } XGL_EVENT_CREATE_INFO;
206 memset(&event_info, 0, sizeof(event_info));
207 event_info.sType = XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO;
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600208
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600209 err = xglCreateEvent(device(), &event_info, &event);
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600210 ASSERT_XGL_SUCCESS(err);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600211
212 err = xglGetObjectInfo(event, XGL_INFO_TYPE_MEMORY_REQUIREMENTS,
213 &data_size, &mem_req);
214 ASSERT_XGL_SUCCESS(err);
215
216 // XGL_RESULT XGLAPI xglAllocMemory(
217 // XGL_DEVICE device,
218 // const XGL_MEMORY_ALLOC_INFO* pAllocInfo,
219 // XGL_GPU_MEMORY* pMem);
220 XGL_MEMORY_ALLOC_INFO mem_info;
221 XGL_GPU_MEMORY event_mem;
222
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600223 ASSERT_NE(0, mem_req.size) << "xglGetObjectInfo (Event): Failed - expect events to require memory";
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600224
Tony Barbourfa6cac72015-01-16 14:27:35 -0700225 XGL_UINT heapInfo[mem_req.heapCount];
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600226 memset(&mem_info, 0, sizeof(mem_info));
227 mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
228 mem_info.allocationSize = mem_req.size;
229 mem_info.alignment = mem_req.alignment;
230 mem_info.heapCount = mem_req.heapCount;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700231 mem_info.pHeaps = heapInfo;
232 memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600233 mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
234 mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT;
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600235 err = xglAllocMemory(device(), &mem_info, &event_mem);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600236 ASSERT_XGL_SUCCESS(err);
237
Jon Ashburned62b412015-01-15 10:39:19 -0700238 err = xglBindObjectMemory(event, 0, event_mem, 0);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600239 ASSERT_XGL_SUCCESS(err);
240
241 err = xglResetEvent(event);
242 ASSERT_XGL_SUCCESS(err);
243
244 err = xglGetEventStatus(event);
245 ASSERT_EQ(XGL_EVENT_RESET, err);
246
247 err = xglSetEvent(event);
248 ASSERT_XGL_SUCCESS(err);
249
250 err = xglGetEventStatus(event);
251 ASSERT_EQ(XGL_EVENT_SET, err);
252
253 // TODO: Test actual synchronization with command buffer event.
254
255 // All done with event memory, clean up
Jon Ashburned62b412015-01-15 10:39:19 -0700256 err = xglBindObjectMemory(event, 0, XGL_NULL_HANDLE, 0);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600257 ASSERT_XGL_SUCCESS(err);
258
259 err = xglDestroyObject(event);
260 ASSERT_XGL_SUCCESS(err);
261}
262
263TEST_F(XglTest, Fence) {
264 XGL_RESULT err;
265 XGL_FENCE_CREATE_INFO fence_info;
266 XGL_FENCE fence;
267
268 memset(&fence_info, 0, sizeof(fence_info));
269
270 // typedef struct _XGL_FENCE_CREATE_INFO
271 // {
272 // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO
273 // const XGL_VOID* pNext; // Pointer to next structure
274 // XGL_FLAGS flags; // Reserved
275 fence_info.sType = XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO;
276
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600277 err = xglCreateFence(device(), &fence_info, &fence);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600278 ASSERT_XGL_SUCCESS(err);
279
280 err = xglGetFenceStatus(fence);
281 // We've not submitted this fence on a command buffer so should get
282 // XGL_ERROR_UNAVAILABLE
283 EXPECT_EQ(XGL_ERROR_UNAVAILABLE, err);
284
285 // Test glxWaitForFences
286 // XGL_RESULT XGLAPI xglWaitForFences(
287 // XGL_DEVICE device,
288 // XGL_UINT fenceCount,
289 // const XGL_FENCE* pFences,
290 // XGL_BOOL waitAll,
291 // XGL_UINT64 timeout);
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600292 err = xglWaitForFences(device(), 1, &fence, XGL_TRUE, 0);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600293 EXPECT_EQ(XGL_ERROR_UNAVAILABLE, err);
294
295 // TODO: Attached to command buffer and test GetFenceStatus
296 // TODO: Add some commands and submit the command buffer
297
298 err = xglDestroyObject(fence);
299 ASSERT_XGL_SUCCESS(err);
300
301}
302
303#define MAX_QUERY_SLOTS 10
304
305TEST_F(XglTest, Query) {
306 XGL_QUERY_POOL_CREATE_INFO query_info;
307 XGL_QUERY_POOL query_pool;
Chia-I Wu54ed0792014-12-27 14:14:50 +0800308 size_t data_size;
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600309 XGL_MEMORY_REQUIREMENTS mem_req;
Chia-I Wu54ed0792014-12-27 14:14:50 +0800310 size_t query_result_size;
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600311 XGL_UINT *query_result_data;
312 XGL_RESULT err;
313
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600314 // typedef enum _XGL_QUERY_TYPE
315 // {
316 // XGL_QUERY_OCCLUSION = 0x00000000,
317 // XGL_QUERY_PIPELINE_STATISTICS = 0x00000001,
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600318
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600319 // XGL_QUERY_TYPE_BEGIN_RANGE = XGL_QUERY_OCCLUSION,
320 // XGL_QUERY_TYPE_END_RANGE = XGL_QUERY_PIPELINE_STATISTICS,
321 // XGL_NUM_QUERY_TYPE = (XGL_QUERY_TYPE_END_RANGE - XGL_QUERY_TYPE_BEGIN_RANGE + 1),
322 // XGL_MAX_ENUM(_XGL_QUERY_TYPE)
323 // } XGL_QUERY_TYPE;
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600324
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600325 // typedef struct _XGL_QUERY_POOL_CREATE_INFO
326 // {
327 // XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO
328 // const XGL_VOID* pNext; // Pointer to next structure
329 // XGL_QUERY_TYPE queryType;
330 // XGL_UINT slots;
331 // } XGL_QUERY_POOL_CREATE_INFO;
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600332
333 memset(&query_info, 0, sizeof(query_info));
334 query_info.sType = XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
335 query_info.queryType = XGL_QUERY_OCCLUSION;
336 query_info.slots = MAX_QUERY_SLOTS;
337
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600338 // XGL_RESULT XGLAPI xglCreateQueryPool(
339 // XGL_DEVICE device,
340 // const XGL_QUERY_POOL_CREATE_INFO* pCreateInfo,
341 // XGL_QUERY_POOL* pQueryPool);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600342
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600343 err = xglCreateQueryPool(device(), &query_info, &query_pool);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600344 ASSERT_XGL_SUCCESS(err);
345
Jon Ashburnb8e43892014-09-25 14:36:58 -0600346 data_size = sizeof(mem_req);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600347 err = xglGetObjectInfo(query_pool, XGL_INFO_TYPE_MEMORY_REQUIREMENTS,
348 &data_size, &mem_req);
349 ASSERT_XGL_SUCCESS(err);
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600350 ASSERT_NE(0, data_size) << "Invalid data_size";
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600351
352 // XGL_RESULT XGLAPI xglAllocMemory(
353 // XGL_DEVICE device,
354 // const XGL_MEMORY_ALLOC_INFO* pAllocInfo,
355 // XGL_GPU_MEMORY* pMem);
356 XGL_MEMORY_ALLOC_INFO mem_info;
357 XGL_GPU_MEMORY query_mem;
358
Tony Barbourfa6cac72015-01-16 14:27:35 -0700359 XGL_UINT heapInfo[mem_req.heapCount];
360
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600361 memset(&mem_info, 0, sizeof(mem_info));
362 mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
363 // TODO: Is a simple multiple all that's needed here?
364 mem_info.allocationSize = mem_req.size * MAX_QUERY_SLOTS;
365 mem_info.alignment = mem_req.alignment;
366 mem_info.heapCount = mem_req.heapCount;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700367 mem_info.pHeaps = heapInfo;
368 memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600369 mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
370
371 // TODO: are the flags right?
372 // TODO: Should this be pinned? Or maybe a separate test with pinned.
373 mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT;
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600374 err = xglAllocMemory(device(), &mem_info, &query_mem);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600375 ASSERT_XGL_SUCCESS(err);
376
Jon Ashburned62b412015-01-15 10:39:19 -0700377 err = xglBindObjectMemory(query_pool, 0, query_mem, 0);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600378 ASSERT_XGL_SUCCESS(err);
379
380 // TODO: Test actual synchronization with command buffer event.
381 // TODO: Create command buffer
382 // TODO: xglCmdResetQueryPool
383 // TODO: xglCmdBeginQuery
384 // TODO: commands
385 // TOOD: xglCmdEndQuery
386
387 err = xglGetQueryPoolResults(query_pool, 0, MAX_QUERY_SLOTS,
388 &query_result_size, XGL_NULL_HANDLE);
389 ASSERT_XGL_SUCCESS(err);
390
391 if (query_result_size > 0) {
392 query_result_data = new XGL_UINT [query_result_size];
393 err = xglGetQueryPoolResults(query_pool, 0, MAX_QUERY_SLOTS,
394 &query_result_size, query_result_data);
395 ASSERT_XGL_SUCCESS(err);
396
397 // TODO: Test Query result data.
398
399 }
400
401 // All done with QueryPool memory, clean up
Jon Ashburned62b412015-01-15 10:39:19 -0700402 err = xglBindObjectMemory(query_pool, 0, XGL_NULL_HANDLE, 0);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600403 ASSERT_XGL_SUCCESS(err);
404
405 err = xglDestroyObject(query_pool);
406 ASSERT_XGL_SUCCESS(err);
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600407}
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600408
Chia-I Wu3b78d312014-12-29 15:39:23 +0800409void getQueue(xgl_testing::Device *device, XGL_QUEUE_TYPE qtype, const char *qname)
Courtney Goeltzenleuchtercc32aa92014-08-14 10:15:09 -0600410{
411 int que_idx;
412 XGL_RESULT err;
413 XGL_QUEUE queue;
414
Chia-I Wu3b78d312014-12-29 15:39:23 +0800415 const XGL_PHYSICAL_GPU_QUEUE_PROPERTIES props = device->gpu().queue_properties()[0];
416 for (que_idx = 0; que_idx < props.queueCount; que_idx++) {
417 err = xglGetDeviceQueue(device->obj(), qtype, que_idx, &queue);
Courtney Goeltzenleuchtercc32aa92014-08-14 10:15:09 -0600418 ASSERT_EQ(XGL_SUCCESS, err) << "xglGetDeviceQueue: " << qname << " queue #" << que_idx << ": Failed with error: " << xgl_result_string(err);
419 }
420}
421
422TEST_F(XglTest, Queue)
423{
424 XGL_UINT que_idx;
425
Chia-I Wu3b78d312014-12-29 15:39:23 +0800426 ASSERT_NE(0, queue_props.queueCount) << "No heaps available for GPU #" << m_device_id << ": " << props.gpuName;
Courtney Goeltzenleuchtercc32aa92014-08-14 10:15:09 -0600427
428// XGL_RESULT XGLAPI xglGetDeviceQueue(
429// XGL_DEVICE device,
430// XGL_QUEUE_TYPE queueType,
431// XGL_UINT queueIndex,
432// XGL_QUEUE* pQueue);
433 /*
434 * queue handles are retrieved from the device by calling
435 * xglGetDeviceQueue() with a queue type and a requested logical
436 * queue ID. The logical queue ID is a sequential number starting
437 * from zero and referencing up to the number of queues requested
438 * at device creation. Each queue type has its own sequence of IDs
439 * starting at zero.
440 */
441
Chia-I Wu3b78d312014-12-29 15:39:23 +0800442 for (que_idx = 0; que_idx < queue_props.queueCount; que_idx++) {
Courtney Goeltzenleuchtercc32aa92014-08-14 10:15:09 -0600443
444// typedef enum _XGL_QUEUE_FLAGS
445// {
446// XGL_QUEUE_GRAPHICS_BIT = 0x00000001, // Queue supports graphics operations
447// XGL_QUEUE_COMPUTE_BIT = 0x00000002, // Queue supports compute operations
448// XGL_QUEUE_DMA_BIT = 0x00000004, // Queue supports DMA operations
449// XGL_QUEUE_EXTENDED_BIT = 0x80000000 // Extended queue
450// } XGL_QUEUE_FLAGS;
451
452// typedef enum _XGL_QUEUE_TYPE
453// {
454// XGL_QUEUE_TYPE_GRAPHICS = 0x1,
455// XGL_QUEUE_TYPE_COMPUTE = 0x2,
456// XGL_QUEUE_TYPE_DMA = 0x3,
457// XGL_MAX_ENUM(_XGL_QUEUE_TYPE)
458// } XGL_QUEUE_TYPE;
459
Chia-I Wu3b78d312014-12-29 15:39:23 +0800460 if (queue_props.queueFlags & XGL_QUEUE_GRAPHICS_BIT) {
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600461 getQueue(m_device, XGL_QUEUE_TYPE_GRAPHICS, "Graphics");
Courtney Goeltzenleuchtercc32aa92014-08-14 10:15:09 -0600462 }
463
Chia-I Wu3b78d312014-12-29 15:39:23 +0800464 if (queue_props.queueFlags & XGL_QUEUE_COMPUTE_BIT) {
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600465 getQueue(m_device, XGL_QUEUE_TYPE_GRAPHICS, "Compute");
Courtney Goeltzenleuchtercc32aa92014-08-14 10:15:09 -0600466 }
467
Chia-I Wu3b78d312014-12-29 15:39:23 +0800468 if (queue_props.queueFlags & XGL_QUEUE_DMA_BIT) {
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600469 getQueue(m_device, XGL_QUEUE_TYPE_GRAPHICS, "DMA");
Courtney Goeltzenleuchtercc32aa92014-08-14 10:15:09 -0600470 }
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 Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600483void XglTest::CreateImageTest()
484{
485 XGL_RESULT err;
486 XGL_IMAGE image;
487 XGL_UINT w, h, mipCount;
488 XGL_SIZE size;
489 XGL_FORMAT fmt;
490 XGL_FORMAT_PROPERTIES image_fmt;
Chia-I Wu54ed0792014-12-27 14:14:50 +0800491 size_t data_size;
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600492
493 w =512;
494 h = 256;
495 mipCount = 0;
496
497 XGL_UINT _w = w;
498 XGL_UINT _h = h;
499 while( ( _w > 0 ) || ( _h > 0 ) )
500 {
501 _w >>= 1;
502 _h >>= 1;
503 mipCount++;
504 }
505
506 fmt.channelFormat = XGL_CH_FMT_R8G8B8A8;
507 fmt.numericFormat = XGL_NUM_FMT_UINT;
508 // TODO: Pick known good format rather than just expect common format
509 /*
510 * XXX: What should happen if given NULL HANDLE for the pData argument?
511 * We're not requesting XGL_INFO_TYPE_MEMORY_REQUIREMENTS so there is
512 * an expectation that pData is a valid pointer.
513 * However, why include a returned size value? That implies that the
514 * amount of data may vary and that doesn't work well for using a
515 * fixed structure.
516 */
517
Jon Ashburnb8e43892014-09-25 14:36:58 -0600518 size = sizeof(image_fmt);
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600519 err = xglGetFormatInfo(device(), fmt,
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600520 XGL_INFO_TYPE_FORMAT_PROPERTIES,
521 &size, &image_fmt);
522 ASSERT_XGL_SUCCESS(err);
523
524// typedef struct _XGL_IMAGE_CREATE_INFO
525// {
526// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO
527// const XGL_VOID* pNext; // Pointer to next structure.
528// XGL_IMAGE_TYPE imageType;
529// XGL_FORMAT format;
530// XGL_EXTENT3D extent;
531// XGL_UINT mipLevels;
532// XGL_UINT arraySize;
533// XGL_UINT samples;
534// XGL_IMAGE_TILING tiling;
535// XGL_FLAGS usage; // XGL_IMAGE_USAGE_FLAGS
536// XGL_FLAGS flags; // XGL_IMAGE_CREATE_FLAGS
537// } XGL_IMAGE_CREATE_INFO;
538
539
540 XGL_IMAGE_CREATE_INFO imageCreateInfo = {};
541 imageCreateInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
542 imageCreateInfo.imageType = XGL_IMAGE_2D;
543 imageCreateInfo.format = fmt;
544 imageCreateInfo.arraySize = 1;
545 imageCreateInfo.extent.width = w;
546 imageCreateInfo.extent.height = h;
547 imageCreateInfo.extent.depth = 1;
548 imageCreateInfo.mipLevels = mipCount;
549 imageCreateInfo.samples = 1;
550 imageCreateInfo.tiling = XGL_LINEAR_TILING;
551
552// Image usage flags
553// typedef enum _XGL_IMAGE_USAGE_FLAGS
554// {
555// XGL_IMAGE_USAGE_SHADER_ACCESS_READ_BIT = 0x00000001,
556// XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT = 0x00000002,
557// XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000004,
558// XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT = 0x00000008,
559// } XGL_IMAGE_USAGE_FLAGS;
560 imageCreateInfo.usage = XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT | XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
561
562// XGL_RESULT XGLAPI xglCreateImage(
563// XGL_DEVICE device,
564// const XGL_IMAGE_CREATE_INFO* pCreateInfo,
565// XGL_IMAGE* pImage);
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600566 err = xglCreateImage(device(), &imageCreateInfo, &image);
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600567 ASSERT_XGL_SUCCESS(err);
568
Courtney Goeltzenleuchterac3b73a2014-08-14 17:40:57 -0600569 // Verify image resources
570// XGL_RESULT XGLAPI xglGetImageSubresourceInfo(
571// XGL_IMAGE image,
572// const XGL_IMAGE_SUBRESOURCE* pSubresource,
573// XGL_SUBRESOURCE_INFO_TYPE infoType,
574// XGL_SIZE* pDataSize,
575// XGL_VOID* pData);
576// typedef struct _XGL_SUBRESOURCE_LAYOUT
577// {
578// XGL_GPU_SIZE offset; // Specified in bytes
579// XGL_GPU_SIZE size; // Specified in bytes
580// XGL_GPU_SIZE rowPitch; // Specified in bytes
581// XGL_GPU_SIZE depthPitch; // Specified in bytes
582// } XGL_SUBRESOURCE_LAYOUT;
583
584// typedef struct _XGL_IMAGE_SUBRESOURCE
585// {
586// XGL_IMAGE_ASPECT aspect;
587// XGL_UINT mipLevel;
588// XGL_UINT arraySlice;
589// } XGL_IMAGE_SUBRESOURCE;
590// typedef enum _XGL_SUBRESOURCE_INFO_TYPE
591// {
592// // Info type for xglGetImageSubresourceInfo()
593// XGL_INFO_TYPE_SUBRESOURCE_LAYOUT = 0x00000000,
594
595// XGL_MAX_ENUM(_XGL_SUBRESOURCE_INFO_TYPE)
596// } XGL_SUBRESOURCE_INFO_TYPE;
597 XGL_IMAGE_SUBRESOURCE subresource = {};
598 subresource.aspect = XGL_IMAGE_ASPECT_COLOR;
599 subresource.arraySlice = 0;
600
601 _w = w;
602 _h = h;
603 while( ( _w > 0 ) || ( _h > 0 ) )
604 {
605 XGL_SUBRESOURCE_LAYOUT layout = {};
Jon Ashburnb8e43892014-09-25 14:36:58 -0600606 data_size = sizeof(layout);
Courtney Goeltzenleuchterac3b73a2014-08-14 17:40:57 -0600607 err = xglGetImageSubresourceInfo(image, &subresource, XGL_INFO_TYPE_SUBRESOURCE_LAYOUT,
608 &data_size, &layout);
609 ASSERT_XGL_SUCCESS(err);
610 ASSERT_EQ(sizeof(XGL_SUBRESOURCE_LAYOUT), data_size) << "Invalid structure (XGL_SUBRESOURCE_LAYOUT) size";
611
612 // TODO: 4 should be replaced with pixel size for given format
613 EXPECT_LE(_w * 4, layout.rowPitch) << "Pitch does not match expected image pitch";
614 _w >>= 1;
615 _h >>= 1;
616
617 subresource.mipLevel++;
618 }
619
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600620 XGL_MEMORY_REQUIREMENTS mem_req;
Jon Ashburnb8e43892014-09-25 14:36:58 -0600621 data_size = sizeof(mem_req);
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600622 err = xglGetObjectInfo(image, XGL_INFO_TYPE_MEMORY_REQUIREMENTS,
623 &data_size, &mem_req);
624 ASSERT_XGL_SUCCESS(err);
625 ASSERT_EQ(data_size, sizeof(mem_req));
626 ASSERT_NE(0, mem_req.size) << "xglGetObjectInfo (Event): Failed - expect images to require memory";
627
628 // XGL_RESULT XGLAPI xglAllocMemory(
629 // XGL_DEVICE device,
630 // const XGL_MEMORY_ALLOC_INFO* pAllocInfo,
631 // XGL_GPU_MEMORY* pMem);
632 XGL_MEMORY_ALLOC_INFO mem_info;
633 XGL_GPU_MEMORY image_mem;
634
Tony Barbourfa6cac72015-01-16 14:27:35 -0700635 XGL_UINT heapInfo[mem_req.heapCount];
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600636 memset(&mem_info, 0, sizeof(mem_info));
637 mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
638 mem_info.allocationSize = mem_req.size;
639 mem_info.alignment = mem_req.alignment;
640 mem_info.heapCount = mem_req.heapCount;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700641 mem_info.pHeaps = heapInfo;
642 memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount);
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600643 mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
644 mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT;
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600645 err = xglAllocMemory(device(), &mem_info, &image_mem);
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600646 ASSERT_XGL_SUCCESS(err);
647
Jon Ashburned62b412015-01-15 10:39:19 -0700648 err = xglBindObjectMemory(image, 0, image_mem, 0);
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600649 ASSERT_XGL_SUCCESS(err);
650
651// typedef struct _XGL_IMAGE_VIEW_CREATE_INFO
652// {
653// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
654// const XGL_VOID* pNext; // Pointer to next structure
655// XGL_IMAGE image;
656// XGL_IMAGE_VIEW_TYPE viewType;
657// XGL_FORMAT format;
658// XGL_CHANNEL_MAPPING channels;
659// XGL_IMAGE_SUBRESOURCE_RANGE subresourceRange;
660// XGL_FLOAT minLod;
661// } XGL_IMAGE_VIEW_CREATE_INFO;
662 XGL_IMAGE_VIEW_CREATE_INFO viewInfo = {};
663 XGL_IMAGE_VIEW view;
664 viewInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
665 viewInfo.image = image;
666 viewInfo.viewType = XGL_IMAGE_VIEW_2D;
667 viewInfo.format = fmt;
668
669 viewInfo.channels.r = XGL_CHANNEL_SWIZZLE_R;
670 viewInfo.channels.g = XGL_CHANNEL_SWIZZLE_G;
671 viewInfo.channels.b = XGL_CHANNEL_SWIZZLE_B;
672 viewInfo.channels.a = XGL_CHANNEL_SWIZZLE_A;
673
674 viewInfo.subresourceRange.baseArraySlice = 0;
675 viewInfo.subresourceRange.arraySize = 1;
676 viewInfo.subresourceRange.baseMipLevel = 0;
677 viewInfo.subresourceRange.mipLevels = 1;
678 viewInfo.subresourceRange.aspect = XGL_IMAGE_ASPECT_COLOR;
679
680// XGL_RESULT XGLAPI xglCreateImageView(
681// XGL_DEVICE device,
682// const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo,
683// XGL_IMAGE_VIEW* pView);
684
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600685 err = xglCreateImageView(device(), &viewInfo, &view);
Courtney Goeltzenleuchterac3b73a2014-08-14 17:40:57 -0600686 ASSERT_XGL_SUCCESS(err) << "xglCreateImageView failed";
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600687
688 // TODO: Test image memory.
689
690 // All done with image memory, clean up
Jon Ashburned62b412015-01-15 10:39:19 -0700691 ASSERT_XGL_SUCCESS(xglBindObjectMemory(image, 0, XGL_NULL_HANDLE, 0));
Courtney Goeltzenleuchter9c3aad02014-08-13 17:55:12 -0600692
693 ASSERT_XGL_SUCCESS(xglFreeMemory(image_mem));
694
695 ASSERT_XGL_SUCCESS(xglDestroyObject(image));
696}
697
698TEST_F(XglTest, CreateImage) {
699 CreateImageTest();
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600700}
701
Courtney Goeltzenleuchter0842df72014-08-20 15:26:55 -0600702void XglTest::CreateCommandBufferTest()
703{
704 XGL_RESULT err;
705 XGL_CMD_BUFFER_CREATE_INFO info = {};
706 XGL_CMD_BUFFER cmdBuffer;
707
708// typedef struct _XGL_CMD_BUFFER_CREATE_INFO
709// {
710// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO
711// const XGL_VOID* pNext;
712// XGL_QUEUE_TYPE queueType;
713// XGL_FLAGS flags;
714// } XGL_CMD_BUFFER_CREATE_INFO;
715
716 info.sType = XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO;
717 info.queueType = XGL_QUEUE_TYPE_GRAPHICS;
718 err = xglCreateCommandBuffer(device(), &info, &cmdBuffer);
719 ASSERT_XGL_SUCCESS(err) << "xglCreateCommandBuffer failed";
720
721 ASSERT_XGL_SUCCESS(xglDestroyObject(cmdBuffer));
722}
723
724TEST_F(XglTest, TestComandBuffer) {
725 CreateCommandBufferTest();
726}
727
728void XglTest::CreateShader(XGL_SHADER *pshader)
729{
Courtney Goeltzenleuchtera693ed22014-08-19 13:34:28 -0600730 void *code;
731 uint32_t codeSize;
Chia-I Wu4115c892014-08-28 11:56:29 +0800732 struct icd_bil_header *pBIL;
Courtney Goeltzenleuchtera693ed22014-08-19 13:34:28 -0600733 XGL_RESULT err;
734
Chia-I Wu4115c892014-08-28 11:56:29 +0800735 codeSize = sizeof(struct icd_bil_header) + 100;
Courtney Goeltzenleuchtera693ed22014-08-19 13:34:28 -0600736 code = malloc(codeSize);
737 ASSERT_TRUE(NULL != code) << "malloc failed!";
738
739 memset(code, 0, codeSize);
740
741 // Indicate that this is BIL data.
Chia-I Wu4115c892014-08-28 11:56:29 +0800742 pBIL = (struct icd_bil_header *) code;
743 pBIL->magic = ICD_BIL_MAGIC;
744 pBIL->version = ICD_BIL_VERSION;
Courtney Goeltzenleuchtera693ed22014-08-19 13:34:28 -0600745
746// typedef struct _XGL_SHADER_CREATE_INFO
747// {
748// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO
749// const XGL_VOID* pNext; // Pointer to next structure
750// XGL_SIZE codeSize; // Specified in bytes
751// const XGL_VOID* pCode;
752// XGL_FLAGS flags; // Reserved
753// } XGL_SHADER_CREATE_INFO;
754
755 XGL_SHADER_CREATE_INFO createInfo;
756 XGL_SHADER shader;
757
758 createInfo.sType = XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO;
759 createInfo.pNext = NULL;
760 createInfo.pCode = code;
761 createInfo.codeSize = codeSize;
762 createInfo.flags = 0;
Courtney Goeltzenleuchterb85c5812014-08-19 18:35:50 -0600763 err = xglCreateShader(device(), &createInfo, &shader);
Courtney Goeltzenleuchtera693ed22014-08-19 13:34:28 -0600764 ASSERT_XGL_SUCCESS(err);
765
Courtney Goeltzenleuchter0842df72014-08-20 15:26:55 -0600766 *pshader = shader;
767}
768
Courtney Goeltzenleuchter6b814b32014-08-12 09:59:36 -0600769int main(int argc, char **argv) {
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600770 ::testing::InitGoogleTest(&argc, argv);
Chia-I Wu1c9869e2014-12-28 14:27:28 +0800771 xgl_testing::set_error_callback(test_error_callback);
Courtney Goeltzenleuchtered56abc2014-08-12 14:12:22 -0600772 return RUN_ALL_TESTS();
Courtney Goeltzenleuchter7087dde2014-08-11 18:19:35 -0600773}