tests: Remove old tests that have been ported to gtest

This commit is contained in:
Courtney Goeltzenleuchter 2014-08-14 10:17:56 -06:00
parent b9e3d1fa39
commit 1d319a7a08
6 changed files with 0 additions and 760 deletions

View File

@ -10,11 +10,6 @@ include_directories("${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include")
add_executable(xglinfo xglinfo.c ${COMMON})
add_executable(xglAllocMemory xglAllocMemory.c ${COMMON})
add_executable(xglFence xglFence.c ${COMMON})
add_executable(xglQueue xglQueue.c ${COMMON})
add_executable(xglEvent xglEvent.c ${COMMON})
add_executable(xglQuery xglQuery.c ${COMMON})
add_executable(xglbase init.cpp ${COMMON_CPP})
set_target_properties(xglbase
PROPERTIES
@ -22,10 +17,5 @@ set_target_properties(xglbase
target_link_libraries(xglbase XGL gtest gtest_main)
target_link_libraries(xglinfo XGL)
target_link_libraries(xglAllocMemory XGL)
target_link_libraries(xglFence XGL)
target_link_libraries(xglQueue XGL)
target_link_libraries(xglEvent XGL)
target_link_libraries(xglQuery XGL)
add_subdirectory(gtest-1.7.0)

View File

@ -1,146 +0,0 @@
/*
* XGL
*
* Copyright (C) 2014 LunarG, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "common.h"
#include "debug.h"
int main(int argc, char **argv)
{
static const XGL_APPLICATION_INFO app_info = {
.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = NULL,
.pAppName = (const XGL_CHAR *) "xglCreateDevice",
.appVersion = 1,
.pEngineName = (const XGL_CHAR *) "xglCreateDevice",
.engineVersion = 1,
.apiVersion = XGL_MAKE_VERSION(0, 22, 0),
};
struct app_gpu gpus[MAX_GPUS];
XGL_PHYSICAL_GPU objs[MAX_GPUS];
XGL_UINT gpu_count, i, gpu_idx;
XGL_RESULT err;
XGL_MEMORY_ALLOC_INFO alloc_info;
XGL_GPU_MEMORY gpu_mem;
XGL_UINT8 *pData;
err = xglInitAndEnumerateGpus(&app_info, NULL,
MAX_GPUS, &gpu_count, objs);
if (err)
ERR_EXIT(err);
if (gpu_count <= 0) {
ERR_MSG_EXIT("No GPU avialable");
}
for (i = 0; i < gpu_count; i++) {
app_gpu_init(&gpus[i], i, objs[i]);
}
for (gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) {
if (gpus[gpu_idx].dev.heap_count > 0) {
memset(&alloc_info, 0, sizeof(alloc_info));
// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO
alloc_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
// XGL_VOID* pNext; // Pointer to next structure
// XGL_GPU_SIZE allocationSize; // Size of memory allocation
// XGL_GPU_SIZE alignment;
// XGL_FLAGS flags; // XGL_MEMORY_ALLOC_FLAGS
// XGL_UINT heapCount;
// XGL_UINT heaps[XGL_MAX_MEMORY_HEAPS];
alloc_info.allocationSize = 1024 * 1024; // 1MB
alloc_info.alignment = 0;
alloc_info.heapCount = 1;
alloc_info.heaps[0] = 0; // TODO: Reference other heaps
// XGL_MEMORY_ALLOC_FLAGS
// XGL_MEMORY_HEAP_CPU_VISIBLE_BIT = 0x00000001,
// XGL_MEMORY_HEAP_CPU_GPU_COHERENT_BIT = 0x00000002,
// XGL_MEMORY_HEAP_CPU_UNCACHED_BIT = 0x00000004,
// XGL_MEMORY_HEAP_CPU_WRITE_COMBINED_BIT = 0x00000008,
// XGL_MEMORY_HEAP_HOLDS_PINNED_BIT = 0x00000010,
// XGL_MEMORY_HEAP_SHAREABLE_BIT = 0x00000020,
// TODO: Pick heap properties indicated by heap info
alloc_info.flags = XGL_MEMORY_HEAP_CPU_VISIBLE_BIT;
// XGL_MEMORY_PRIORITY
// XGL_MEMORY_PRIORITY_UNUSED = 0x0,
// XGL_MEMORY_PRIORITY_VERY_LOW = 0x1,
// XGL_MEMORY_PRIORITY_LOW = 0x2,
// XGL_MEMORY_PRIORITY_NORMAL = 0x3,
// XGL_MEMORY_PRIORITY_HIGH = 0x4,
// XGL_MEMORY_PRIORITY_VERY_HIGH = 0x5,
// XGL_MEMORY_PRIORITY_BEGIN_RANGE = XGL_MEMORY_PRIORITY_UNUSED,
// XGL_MEMORY_PRIORITY_END_RANGE = XGL_MEMORY_PRIORITY_VERY_HIGH,
// XGL_NUM_MEMORY_PRIORITY = (XGL_MEMORY_PRIORITY_END_RANGE - XGL_MEMORY_PRIORITY_BEGIN_RANGE + 1),
// TODO: Try variety of memory priorities
alloc_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
err = xglAllocMemory(gpus[gpu_idx].dev.obj, &alloc_info, &gpu_mem);
if (err)
ERR_EXIT(err);
printf("xglAllocMemory: Passed\n");
// XGL_RESULT XGLAPI xglMapMemory(
// XGL_GPU_MEMORY mem,
// XGL_FLAGS flags, // Reserved
// XGL_VOID** ppData);
err = xglMapMemory(gpu_mem, 0, (XGL_VOID *) &pData);
if (err)
ERR_EXIT(err);
printf("xglMapMemory: Passed\n");
memset(pData, 0x55, alloc_info.allocationSize);
if (pData[0] == 0x55) {
printf("xglMapMemory: Successfully wrote data\n");
}
err = xglUnmapMemory(gpu_mem);
if (err)
ERR_EXIT(err);
printf("xglUnmapMemory: Passed\n");
err = xglFreeMemory(gpu_mem);
if (err)
ERR_EXIT(err);
printf("xglFreeMemory: Passed\n");
} else {
debug_printf("No heaps available for GPU #%d: %s", gpu_idx, gpus[gpu_idx].props.gpuName);
}
}
for (i = 0; i < gpu_count; i++)
app_gpu_destroy(&gpus[i]);
return 0;
}

View File

@ -1,158 +0,0 @@
/*
* XGL
*
* Copyright (C) 2014 LunarG, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "common.h"
#include "debug.h"
int main(int argc, char **argv)
{
static const XGL_APPLICATION_INFO app_info = {
.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = NULL,
.pAppName = (const XGL_CHAR *) "xglEvent",
.appVersion = 1,
.pEngineName = (const XGL_CHAR *) "xglEvent",
.engineVersion = 1,
.apiVersion = XGL_MAKE_VERSION(0, 22, 0),
};
struct app_gpu gpus[MAX_GPUS];
struct app_gpu *gpu;
XGL_PHYSICAL_GPU objs[MAX_GPUS];
XGL_UINT gpu_count, i, gpu_idx;
XGL_EVENT_CREATE_INFO event_info;
XGL_EVENT event;
XGL_UINT data_size;
XGL_MEMORY_REQUIREMENTS mem_req;
XGL_RESULT err;
err = xglInitAndEnumerateGpus(&app_info, NULL,
MAX_GPUS, &gpu_count, objs);
if (err)
ERR_EXIT(err);
if (gpu_count <= 0) {
ERR_MSG_EXIT("No GPU avialable");
}
for (i = 0; i < gpu_count; i++) {
app_gpu_init(&gpus[i], i, objs[i]);
app_dev_init_queue(&gpus[i].dev, XGL_QUEUE_TYPE_GRAPHICS);
}
for (gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) {
gpu = &gpus[gpu_idx];
// typedef struct _XGL_EVENT_CREATE_INFO
// {
// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO
// const XGL_VOID* pNext; // Pointer to next structure
// XGL_FLAGS flags; // Reserved
// } XGL_EVENT_CREATE_INFO;
memset(&event_info, 0, sizeof(event_info));
event_info.sType = XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO;
err = xglCreateEvent(gpu->dev.obj, &event_info, &event);
if (err)
ERR_EXIT(err);
printf("xglCreateEvent: Passed");
err = xglGetObjectInfo(event, XGL_INFO_TYPE_MEMORY_REQUIREMENTS,
&data_size, &mem_req);
// XGL_RESULT XGLAPI xglAllocMemory(
// XGL_DEVICE device,
// const XGL_MEMORY_ALLOC_INFO* pAllocInfo,
// XGL_GPU_MEMORY* pMem);
XGL_MEMORY_ALLOC_INFO mem_info;
XGL_GPU_MEMORY event_mem;
if (mem_req.size == 0) {
ERR_MSG_EXIT("xglGetObjectInfo (Event): Failed - expect events to require memory");
}
memset(&mem_info, 0, sizeof(mem_info));
mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
mem_info.allocationSize = mem_req.size;
mem_info.alignment = mem_req.alignment;
mem_info.heapCount = mem_req.heapCount;
memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS);
mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT;
err = xglAllocMemory(gpu->dev.obj, &mem_info, &event_mem);
if (err)
ERR_EXIT(err);
printf("xglAllocMemory (Event): Passed\n");
err = xglBindObjectMemory(event, event_mem, 0);
if (err)
ERR_EXIT(err);
printf("xglBindObjectMemory (Event): Passed\n");
err = xglResetEvent(event);
if (err)
ERR_EXIT(err);
printf("xglResetEvent: Passed\n");
err = xglGetEventStatus(event);
if (err != XGL_EVENT_RESET)
ERR_EXIT(err);
printf("xglGetEventStatus (reset): Passed\n");
err = xglSetEvent(event);
if (err)
ERR_EXIT(err);
printf("xglSetEvent: Passed\n");
err = xglGetEventStatus(event);
if (err != XGL_EVENT_SET)
ERR_EXIT(err);
printf("xglGetEventStatus (set): Passed\n");
// TODO: Test actual synchronization with command buffer event.
// All done with event memory, clean up
err = xglBindObjectMemory(event, XGL_NULL_HANDLE, 0);
if (err)
ERR_EXIT(err);
printf("xglBindObjectMemory (Unbind memory): Passed\n");
err = xglDestroyObject(event);
if (err)
ERR_EXIT(err);
printf("xglDestroyObject (Event): Passed\n");
}
for (i = 0; i < gpu_count; i++)
app_gpu_destroy(&gpus[i]);
return 0;
}

View File

@ -1,116 +0,0 @@
/*
* XGL
*
* Copyright (C) 2014 LunarG, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "common.h"
#include "debug.h"
int main(int argc, char **argv)
{
static const XGL_APPLICATION_INFO app_info = {
.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = NULL,
.pAppName = (const XGL_CHAR *) "xglCreateDevice",
.appVersion = 1,
.pEngineName = (const XGL_CHAR *) "xglCreateDevice",
.engineVersion = 1,
.apiVersion = XGL_MAKE_VERSION(0, 22, 0),
};
struct app_gpu gpus[MAX_GPUS];
XGL_PHYSICAL_GPU objs[MAX_GPUS];
struct app_gpu *gpu;
XGL_UINT gpu_count, i, gpu_idx;
XGL_RESULT err;
XGL_FENCE_CREATE_INFO fence_info;
XGL_FENCE fence;
err = xglInitAndEnumerateGpus(&app_info, NULL,
MAX_GPUS, &gpu_count, objs);
if (err)
ERR_EXIT(err);
if (gpu_count <= 0) {
ERR_MSG_EXIT("No GPU avialable");
}
for (i = 0; i < gpu_count; i++) {
app_gpu_init(&gpus[i], i, objs[i]);
}
for (gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) {
gpu = &gpus[gpu_idx];
if (gpu->dev.heap_count == 0) {
debug_printf("No heaps available for GPU #%d: %s", gpu_idx, gpu->props.gpuName);
continue;
}
memset(&fence_info, 0, sizeof(fence_info));
// typedef struct _XGL_FENCE_CREATE_INFO
// {
// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO
// const XGL_VOID* pNext; // Pointer to next structure
// XGL_FLAGS flags; // Reserved
fence_info.sType = XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO;
err = xglCreateFence(gpu->dev.obj, &fence_info, &fence);
if (err)
ERR_EXIT(err);
printf("xglCreateFence: Passed\n");
err = xglGetFenceStatus(fence);
// We've not submitted this fence on a command buffer so should get
// XGL_ERROR_UNAVAILABLE
if (err != XGL_ERROR_UNAVAILABLE) {
ERR_EXIT(err);
}
// Test glxWaitForFences
// XGL_RESULT XGLAPI xglWaitForFences(
// XGL_DEVICE device,
// XGL_UINT fenceCount,
// const XGL_FENCE* pFences,
// XGL_BOOL waitAll,
// XGL_UINT64 timeout);
err = xglWaitForFences(gpu->dev.obj, 1, &fence, XGL_TRUE, 0);
if (err != XGL_ERROR_UNAVAILABLE)
ERR_EXIT(err);
printf("xglWaitForFences(UNAVAILABLE): Passed\n");
// TODO: Attached to command buffer and test GetFenceStatus
// TODO: Add some commands and submit the command buffer
err = xglDestroyObject(fence);
if (err)
ERR_EXIT(err);
printf("xglDestoryObject(fence): Passed\n");
}
for (i = 0; i < gpu_count; i++)
app_gpu_destroy(&gpus[i]);
return 0;
}

View File

@ -1,187 +0,0 @@
/*
* XGL
*
* Copyright (C) 2014 LunarG, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "common.h"
#include "debug.h"
#define MAX_QUERY_SLOTS 10
int main(int argc, char **argv)
{
static const XGL_APPLICATION_INFO app_info = {
.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = NULL,
.pAppName = (const XGL_CHAR *) "xglQuery",
.appVersion = 1,
.pEngineName = (const XGL_CHAR *) "xglQuery",
.engineVersion = 1,
.apiVersion = XGL_MAKE_VERSION(0, 22, 0),
};
struct app_gpu gpus[MAX_GPUS];
struct app_gpu *gpu;
XGL_PHYSICAL_GPU objs[MAX_GPUS];
XGL_UINT gpu_count, i, gpu_idx;
XGL_QUERY_POOL_CREATE_INFO query_info;
XGL_QUERY_POOL query_pool;
XGL_UINT data_size;
XGL_MEMORY_REQUIREMENTS mem_req;
XGL_UINT query_result_size;
XGL_UINT *query_result_data;
XGL_RESULT err;
err = xglInitAndEnumerateGpus(&app_info, NULL,
MAX_GPUS, &gpu_count, objs);
if (err)
ERR_EXIT(err);
if (gpu_count <= 0) {
ERR_MSG_EXIT("No GPU avialable");
}
for (i = 0; i < gpu_count; i++) {
app_gpu_init(&gpus[i], i, objs[i]);
app_dev_init_queue(&gpus[i].dev, XGL_QUEUE_TYPE_GRAPHICS);
}
for (gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) {
gpu = &gpus[gpu_idx];
// typedef enum _XGL_QUERY_TYPE
// {
// XGL_QUERY_OCCLUSION = 0x00000000,
// XGL_QUERY_PIPELINE_STATISTICS = 0x00000001,
// XGL_QUERY_TYPE_BEGIN_RANGE = XGL_QUERY_OCCLUSION,
// XGL_QUERY_TYPE_END_RANGE = XGL_QUERY_PIPELINE_STATISTICS,
// XGL_NUM_QUERY_TYPE = (XGL_QUERY_TYPE_END_RANGE - XGL_QUERY_TYPE_BEGIN_RANGE + 1),
// XGL_MAX_ENUM(_XGL_QUERY_TYPE)
// } XGL_QUERY_TYPE;
// typedef struct _XGL_QUERY_POOL_CREATE_INFO
// {
// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO
// const XGL_VOID* pNext; // Pointer to next structure
// XGL_QUERY_TYPE queryType;
// XGL_UINT slots;
// } XGL_QUERY_POOL_CREATE_INFO;
memset(&query_info, 0, sizeof(query_info));
query_info.sType = XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
query_info.queryType = XGL_QUERY_OCCLUSION;
query_info.slots = MAX_QUERY_SLOTS;
// XGL_RESULT XGLAPI xglCreateQueryPool(
// XGL_DEVICE device,
// const XGL_QUERY_POOL_CREATE_INFO* pCreateInfo,
// XGL_QUERY_POOL* pQueryPool);
err = xglCreateQueryPool(gpu->dev.obj, &query_info, &query_pool);
if (err)
ERR_EXIT(err);
printf("xglCreateQueryPool: Passed");
err = xglGetObjectInfo(query_pool, XGL_INFO_TYPE_MEMORY_REQUIREMENTS,
&data_size, &mem_req);
// XGL_RESULT XGLAPI xglAllocMemory(
// XGL_DEVICE device,
// const XGL_MEMORY_ALLOC_INFO* pAllocInfo,
// XGL_GPU_MEMORY* pMem);
XGL_MEMORY_ALLOC_INFO mem_info;
XGL_GPU_MEMORY query_mem;
if (data_size == 0) {
ERR_MSG_EXIT("xglGetObjectInfo (Event): Failed - expect events to require memory");
}
memset(&mem_info, 0, sizeof(mem_info));
mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
// TODO: Is a simple multiple all that's needed here?
mem_info.allocationSize = mem_req.size * MAX_QUERY_SLOTS;
mem_info.alignment = mem_req.alignment;
mem_info.heapCount = mem_req.heapCount;
memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS);
mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
// TODO: are the flags right?
// TODO: Should this be pinned? Or maybe a separate test with pinned.
mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT;
err = xglAllocMemory(gpu->dev.obj, &mem_info, &query_mem);
if (err)
ERR_EXIT(err);
printf("xglAllocMemory (QueryPool): Passed\n");
err = xglBindObjectMemory(query_pool, query_mem, 0);
if (err)
ERR_EXIT(err);
printf("xglBindObjectMemory (QueryPool): Passed\n");
// TODO: Test actual synchronization with command buffer event.
// TODO: Create command buffer
// TODO: xglCmdResetQueryPool
// TODO: xglCmdBeginQuery
// TODO: commands
// TOOD: xglCmdEndQuery
err = xglGetQueryPoolResults(query_pool, 0, MAX_QUERY_SLOTS,
&query_result_size, XGL_NULL_HANDLE);
if (err)
ERR_EXIT(err);
printf("xglGetQueryPoolResults: Passed (size = %d)\n", query_result_size);
if (query_result_size > 0) {
query_result_data = malloc(query_result_size);
err = xglGetQueryPoolResults(query_pool, 0, MAX_QUERY_SLOTS,
&query_result_size, query_result_data);
if (err)
ERR_EXIT(err);
// TODO: Test Query result data.
printf("xglGetQueryPoolResults: Passed\n");
}
// All done with QueryPool memory, clean up
err = xglBindObjectMemory(query_pool, XGL_NULL_HANDLE, 0);
if (err)
ERR_EXIT(err);
printf("xglBindObjectMemory (Unbind memory): Passed\n");
err = xglDestroyObject(query_pool);
if (err)
ERR_EXIT(err);
printf("xglDestroyObject (QueryPool): Passed\n");
}
for (i = 0; i < gpu_count; i++)
app_gpu_destroy(&gpus[i]);
return 0;
}

View File

@ -1,143 +0,0 @@
/*
* XGL
*
* Copyright (C) 2014 LunarG, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "common.h"
#include "debug.h"
XGL_RESULT getQueue(struct app_gpu *gpu, XGL_QUEUE_TYPE qtype, const char *qname)
{
int que_idx;
XGL_RESULT err = XGL_SUCCESS;
XGL_QUEUE queue;
for (que_idx = 0; que_idx < gpu->queue_props->queueCount; que_idx++) {
err = xglGetDeviceQueue(gpu->dev.obj, qtype, que_idx, &queue);
if (err) {
printf("xglGetDeviceQueue: %s queue #%d: Failed\n", qname, que_idx);
ERR_EXIT(err);
}
printf("xglGetDeviceQueue: %s queue #%d: Passed\n", qname, que_idx);
}
return err;
}
int main(int argc, char **argv)
{
static const XGL_APPLICATION_INFO app_info = {
.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = NULL,
.pAppName = (const XGL_CHAR *) "xglCreateDevice",
.appVersion = 1,
.pEngineName = (const XGL_CHAR *) "xglCreateDevice",
.engineVersion = 1,
.apiVersion = XGL_MAKE_VERSION(0, 22, 0),
};
struct app_gpu gpus[MAX_GPUS];
struct app_gpu *gpu;
XGL_PHYSICAL_GPU objs[MAX_GPUS];
XGL_UINT gpu_count, i, gpu_idx, que_idx;
XGL_RESULT err;
err = xglInitAndEnumerateGpus(&app_info, NULL,
MAX_GPUS, &gpu_count, objs);
if (err)
ERR_EXIT(err);
if (gpu_count <= 0) {
ERR_MSG_EXIT("No GPU avialable");
}
for (i = 0; i < gpu_count; i++) {
app_gpu_init(&gpus[i], i, objs[i]);
}
for (gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) {
gpu = &gpus[gpu_idx];
if (gpu->queue_props->queueCount == 0) {
debug_printf("No heaps available for GPU #%d: %s", gpu_idx, gpu->props.gpuName);
continue;
} else {
// XGL_RESULT XGLAPI xglGetDeviceQueue(
// XGL_DEVICE device,
// XGL_QUEUE_TYPE queueType,
// XGL_UINT queueIndex,
// XGL_QUEUE* pQueue);
/*
* queue handles are retrieved from the device by calling
* xglGetDeviceQueue() with a queue type and a requested logical
* queue ID. The logical queue ID is a sequential number starting
* from zero and referencing up to the number of queues requested
* at device creation. Each queue type has its own sequence of IDs
* starting at zero.
*/
for (que_idx = 0; que_idx < gpu->queue_props->queueCount; que_idx++) {
// typedef enum _XGL_QUEUE_FLAGS
// {
// XGL_QUEUE_GRAPHICS_BIT = 0x00000001, // Queue supports graphics operations
// XGL_QUEUE_COMPUTE_BIT = 0x00000002, // Queue supports compute operations
// XGL_QUEUE_DMA_BIT = 0x00000004, // Queue supports DMA operations
// XGL_QUEUE_EXTENDED_BIT = 0x80000000 // Extended queue
// } XGL_QUEUE_FLAGS;
// typedef enum _XGL_QUEUE_TYPE
// {
// XGL_QUEUE_TYPE_GRAPHICS = 0x1,
// XGL_QUEUE_TYPE_COMPUTE = 0x2,
// XGL_QUEUE_TYPE_DMA = 0x3,
// XGL_MAX_ENUM(_XGL_QUEUE_TYPE)
// } XGL_QUEUE_TYPE;
if (gpu->queue_props->queueFlags & XGL_QUEUE_GRAPHICS_BIT) {
getQueue(gpu, XGL_QUEUE_TYPE_GRAPHICS, "Graphics");
}
if (gpu->queue_props->queueFlags & XGL_QUEUE_COMPUTE_BIT) {
getQueue(gpu, XGL_QUEUE_TYPE_GRAPHICS, "Compute");
}
if (gpu->queue_props->queueFlags & XGL_QUEUE_DMA_BIT) {
getQueue(gpu, XGL_QUEUE_TYPE_GRAPHICS, "DMA");
}
// TODO: What do we do about EXTENDED_BIT?
/* Guide: pg 34:
* The queue objects cannot be destroyed explicitly by an application
* and are automatically destroyed when the associated device is destroyed.
* Once the device is destroyed, attempting to use a queue results in
* undefined behavior.
*/
}
}
}
for (i = 0; i < gpu_count; i++)
app_gpu_destroy(&gpus[i]);
return 0;
}