From ed667a540d22881cbf4c2e02a21083a19f64f183 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Thu, 5 Mar 2015 18:09:39 -0700 Subject: [PATCH] xgl: Impossible to expose multi-function queues Bug: 13363 header version: r29597 (0.51.0) included review feedback. --- demos/cube.c | 28 +++++++++++++++++++++++++--- demos/tri.c | 28 +++++++++++++++++++++++++--- icd/nulldrv/nulldrv.c | 2 +- include/xgl.h | 20 ++++---------------- layers/draw_state.c | 6 +++--- layers/draw_state.cpp | 6 +++--- layers/draw_state.h | 2 +- layers/glave_snapshot.c | 4 ++-- layers/mem_tracker.cpp | 4 ++-- xgl.py | 2 +- 10 files changed, 67 insertions(+), 35 deletions(-) diff --git a/demos/cube.c b/demos/cube.c index 6553962..601d1de 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -204,6 +204,8 @@ struct demo { XGL_PHYSICAL_GPU gpu; XGL_DEVICE device; XGL_QUEUE queue; + uint32_t graphics_queue_node_index; + XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *queue_props; int width, height; XGL_FORMAT format; @@ -892,7 +894,7 @@ static void demo_prepare_textures(struct demo *demo) XGL_CMD_BUFFER_CREATE_INFO cmd_buf_create_info = { .sType = XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO, .pNext = NULL, - .queueType = XGL_QUEUE_TYPE_GRAPHICS, + .queueNodeIndex = demo->graphics_queue_node_index, .flags = 0 }; @@ -1517,7 +1519,7 @@ static void demo_prepare(struct demo *demo) const XGL_CMD_BUFFER_CREATE_INFO cmd = { .sType = XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO, .pNext = NULL, - .queueType = XGL_QUEUE_TYPE_GRAPHICS, + .queueNodeIndex = demo->graphics_queue_node_index, .flags = 0, }; XGL_RESULT err; @@ -1687,6 +1689,8 @@ static void demo_init_xgl(struct demo *demo) XGL_RESULT err; uint32_t gpu_count; uint32_t i; + size_t data_size; + uint32_t queue_count; err = xglCreateInstance(&app, NULL, &demo->inst); if (err == XGL_ERROR_INCOMPATIBLE_DRIVER) { @@ -1711,7 +1715,25 @@ static void demo_init_xgl(struct demo *demo) err = xglCreateDevice(demo->gpu, &device, &demo->device); assert(!err); - err = xglGetDeviceQueue(demo->device, XGL_QUEUE_TYPE_GRAPHICS, + err = xglGetGpuInfo(demo->gpu, XGL_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES, + &data_size, NULL); + assert(!err); + + demo->queue_props = (XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *) malloc(data_size); + err = xglGetGpuInfo(demo->gpu, XGL_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES, + &data_size, demo->queue_props); + assert(!err); + queue_count = data_size / sizeof(XGL_PHYSICAL_GPU_QUEUE_PROPERTIES); + assert(queue_count >= 1); + + for (i = 0; i < queue_count; i++) { + if (demo->queue_props[i].queueFlags & XGL_QUEUE_GRAPHICS_BIT) + break; + } + assert(i < queue_count); + demo->graphics_queue_node_index = i; + + err = xglGetDeviceQueue(demo->device, demo->graphics_queue_node_index, 0, &demo->queue); assert(!err); } diff --git a/demos/tri.c b/demos/tri.c index d0fa438..d42719f 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -38,6 +38,8 @@ struct demo { XGL_PHYSICAL_GPU gpu; XGL_DEVICE device; XGL_QUEUE queue; + XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *queue_props; + uint32_t graphics_queue_node_index; int width, height; XGL_FORMAT format; @@ -539,7 +541,7 @@ static void demo_prepare_textures(struct demo *demo) XGL_CMD_BUFFER_CREATE_INFO cmd_buf_create_info = { .sType = XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO, .pNext = NULL, - .queueType = XGL_QUEUE_TYPE_GRAPHICS, + .queueNodeIndex = demo->graphics_queue_node_index, .flags = 0 }; @@ -1071,7 +1073,7 @@ static void demo_prepare(struct demo *demo) const XGL_CMD_BUFFER_CREATE_INFO cmd = { .sType = XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO, .pNext = NULL, - .queueType = XGL_QUEUE_TYPE_GRAPHICS, + .queueNodeIndex = demo->graphics_queue_node_index, .flags = 0, }; XGL_RESULT err; @@ -1208,6 +1210,8 @@ static void demo_init_xgl(struct demo *demo) XGL_RESULT err; uint32_t gpu_count; uint32_t i; + size_t data_size; + uint32_t queue_count; err = xglCreateInstance(&app, NULL, &demo->inst); if (err == XGL_ERROR_INCOMPATIBLE_DRIVER) { @@ -1232,7 +1236,25 @@ static void demo_init_xgl(struct demo *demo) err = xglCreateDevice(demo->gpu, &device, &demo->device); assert(!err); - err = xglGetDeviceQueue(demo->device, XGL_QUEUE_TYPE_GRAPHICS, + err = xglGetGpuInfo(demo->gpu, XGL_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES, + &data_size, NULL); + assert(!err); + + demo->queue_props = (XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *) malloc(data_size); + err = xglGetGpuInfo(demo->gpu, XGL_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES, + &data_size, demo->queue_props); + assert(!err); + queue_count = data_size / sizeof(XGL_PHYSICAL_GPU_QUEUE_PROPERTIES); + assert(queue_count >= 1); + + for (i = 0; i < queue_count; i++) { + if (demo->queue_props[i].queueFlags & XGL_QUEUE_GRAPHICS_BIT) + break; + } + assert(i < queue_count); + demo->graphics_queue_node_index = i; + + err = xglGetDeviceQueue(demo->device, demo->graphics_queue_node_index, 0, &demo->queue); assert(!err); } diff --git a/icd/nulldrv/nulldrv.c b/icd/nulldrv/nulldrv.c index e9db89c..dd5061e 100644 --- a/icd/nulldrv/nulldrv.c +++ b/icd/nulldrv/nulldrv.c @@ -1198,7 +1198,7 @@ ICD_EXPORT XGL_RESULT XGLAPI xglDestroyDevice( ICD_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue( XGL_DEVICE device, - XGL_QUEUE_TYPE queueType, + uint32_t queueNodeIndex, uint32_t queueIndex, XGL_QUEUE* pQueue) { diff --git a/include/xgl.h b/include/xgl.h index ec71157..6ec7ed5 100644 --- a/include/xgl.h +++ b/include/xgl.h @@ -33,7 +33,7 @@ #include "xglPlatform.h" // XGL API version supported by this file -#define XGL_API_VERSION XGL_MAKE_VERSION(0, 50, 1) +#define XGL_API_VERSION XGL_MAKE_VERSION(0, 51, 0) #ifdef __cplusplus extern "C" @@ -108,18 +108,6 @@ XGL_DEFINE_SUBCLASS_HANDLE(XGL_RENDER_PASS, XGL_OBJECT) // Enumerations -typedef enum _XGL_QUEUE_TYPE -{ - XGL_QUEUE_TYPE_GRAPHICS = 0x1, - XGL_QUEUE_TYPE_COMPUTE = 0x2, - XGL_QUEUE_TYPE_DMA = 0x3, - - XGL_QUEUE_TYPE_BEGIN_RANGE = XGL_QUEUE_TYPE_GRAPHICS, - XGL_QUEUE_TYPE_END_RANGE = XGL_QUEUE_TYPE_DMA, - XGL_NUM_QUEUE_TYPE = (XGL_QUEUE_TYPE_END_RANGE - XGL_QUEUE_TYPE_BEGIN_RANGE + 1), - XGL_MAX_ENUM(_XGL_QUEUE_TYPE) -} XGL_QUEUE_TYPE; - typedef enum _XGL_MEMORY_PRIORITY { XGL_MEMORY_PRIORITY_UNUSED = 0x0, @@ -2071,7 +2059,7 @@ typedef struct _XGL_CMD_BUFFER_CREATE_INFO { XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO const void* pNext; // Pointer to next structure - XGL_QUEUE_TYPE queueType; + uint32_t queueNodeIndex; XGL_FLAGS flags; } XGL_CMD_BUFFER_CREATE_INFO; @@ -2231,7 +2219,7 @@ typedef XGL_RESULT (XGLAPI *xglCreateDeviceType)(XGL_PHYSICAL_GPU gpu, const XGL typedef XGL_RESULT (XGLAPI *xglDestroyDeviceType)(XGL_DEVICE device); typedef XGL_RESULT (XGLAPI *xglGetExtensionSupportType)(XGL_PHYSICAL_GPU gpu, const char* pExtName); typedef XGL_RESULT (XGLAPI *xglEnumerateLayersType)(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved); -typedef XGL_RESULT (XGLAPI *xglGetDeviceQueueType)(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, uint32_t queueIndex, XGL_QUEUE* pQueue); +typedef XGL_RESULT (XGLAPI *xglGetDeviceQueueType)(XGL_DEVICE device, uint32_t queueNodeIndex, uint32_t queueIndex, XGL_QUEUE* pQueue); typedef XGL_RESULT (XGLAPI *xglQueueSubmitType)(XGL_QUEUE queue, uint32_t cmdBufferCount, const XGL_CMD_BUFFER* pCmdBuffers, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs, XGL_FENCE fence); typedef XGL_RESULT (XGLAPI *xglQueueSetGlobalMemReferencesType)(XGL_QUEUE queue, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs); typedef XGL_RESULT (XGLAPI *xglQueueWaitIdleType)(XGL_QUEUE queue); @@ -2394,7 +2382,7 @@ XGL_RESULT XGLAPI xglEnumerateLayers( XGL_RESULT XGLAPI xglGetDeviceQueue( XGL_DEVICE device, - XGL_QUEUE_TYPE queueType, + uint32_t queueNodeIndex, uint32_t queueIndex, XGL_QUEUE* pQueue); diff --git a/layers/draw_state.c b/layers/draw_state.c index 07cb1b5..b79a015 100644 --- a/layers/draw_state.c +++ b/layers/draw_state.c @@ -1116,11 +1116,11 @@ static void resetCB(const XGL_CMD_BUFFER cb) // Reset CB state GLOBAL_CB_NODE* pSaveNext = pCB->pNextGlobalCBNode; XGL_FLAGS saveFlags = pCB->flags; - XGL_QUEUE_TYPE saveQT = pCB->queueType; + uint32_t saveQueueNodeIndex = pCB->queueNodeIndex; memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); pCB->cmdBuffer = cb; pCB->flags = saveFlags; - pCB->queueType = saveQT; + pCB->queueNodeIndex = saveQueueNodeIndex; pCB->pNextGlobalCBNode = pSaveNext; pCB->lastVtxBinding = MAX_BINDING; } @@ -2022,7 +2022,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, con g_pCmdBufferHead = pCB; pCB->cmdBuffer = *pCmdBuffer; pCB->flags = pCreateInfo->flags; - pCB->queueType = pCreateInfo->queueType; + pCB->queueNodeIndex = pCreateInfo->queueNodeIndex; pCB->lastVtxBinding = MAX_BINDING; loader_platform_thread_unlock_mutex(&globalLock); updateCBTracking(*pCmdBuffer); diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index 9dbabae..97e31fe 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -1032,11 +1032,11 @@ static void resetCB(const XGL_CMD_BUFFER cb) } // Reset CB state XGL_FLAGS saveFlags = pCB->flags; - XGL_QUEUE_TYPE saveQT = pCB->queueType; + uint32_t saveQueueNodeIndex = pCB->queueNodeIndex; memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); pCB->cmdBuffer = cb; pCB->flags = saveFlags; - pCB->queueType = saveQT; + pCB->queueNodeIndex = saveQueueNodeIndex; pCB->lastVtxBinding = MAX_BINDING; } } @@ -1873,7 +1873,7 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, con memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); pCB->cmdBuffer = *pCmdBuffer; pCB->flags = pCreateInfo->flags; - pCB->queueType = pCreateInfo->queueType; + pCB->queueNodeIndex = pCreateInfo->queueNodeIndex; pCB->lastVtxBinding = MAX_BINDING; cmdBufferMap[*pCmdBuffer] = pCB; loader_platform_thread_unlock_mutex(&globalLock); diff --git a/layers/draw_state.h b/layers/draw_state.h index f5230f8..cb71b34 100644 --- a/layers/draw_state.h +++ b/layers/draw_state.h @@ -222,7 +222,7 @@ typedef enum _CB_STATE // Cmd Buffer Wrapper Struct typedef struct _GLOBAL_CB_NODE { XGL_CMD_BUFFER cmdBuffer; - XGL_QUEUE_TYPE queueType; + uint32_t queueNodeIndex; XGL_FLAGS flags; XGL_FENCE fence; // fence tracking this cmd buffer uint64_t numCmds; // number of cmds in this CB diff --git a/layers/glave_snapshot.c b/layers/glave_snapshot.c index b652706..2f645a5 100644 --- a/layers/glave_snapshot.c +++ b/layers/glave_snapshot.c @@ -587,12 +587,12 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size } } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, uint32_t queueIndex, XGL_QUEUE* pQueue) +XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, uint32_t queueNodeIndex, uint32_t queueIndex, XGL_QUEUE* pQueue) { loader_platform_thread_lock_mutex(&objLock); ll_increment_use_count((void*)device, XGL_OBJECT_TYPE_DEVICE); loader_platform_thread_unlock_mutex(&objLock); - XGL_RESULT result = nextTable.GetDeviceQueue(device, queueType, queueIndex, pQueue); + XGL_RESULT result = nextTable.GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); return result; } diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp index 914b510..9b75d50 100644 --- a/layers/mem_tracker.cpp +++ b/layers/mem_tracker.cpp @@ -859,9 +859,9 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size } } -XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, uint32_t queueIndex, XGL_QUEUE* pQueue) +XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, uint32_t queueNodeIndex, uint32_t queueIndex, XGL_QUEUE* pQueue) { - XGL_RESULT result = nextTable.GetDeviceQueue(device, queueType, queueIndex, pQueue); + XGL_RESULT result = nextTable.GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); addQueueInfo(*pQueue); return result; } diff --git a/xgl.py b/xgl.py index c29cb8b..c183fa6 100644 --- a/xgl.py +++ b/xgl.py @@ -263,7 +263,7 @@ core = Extension( Proto("XGL_RESULT", "GetDeviceQueue", [Param("XGL_DEVICE", "device"), - Param("XGL_QUEUE_TYPE", "queueType"), + Param("uint32_t", "queueNodeIndex"), Param("uint32_t", "queueIndex"), Param("XGL_QUEUE*", "pQueue")]), -- 2.7.4