From 5534fe115eadcac7a5a02bad60dad672943a9963 Mon Sep 17 00:00:00 2001 From: Cherser-s <29800876+Cherser-s@users.noreply.github.com> Date: Wed, 22 Sep 2021 18:08:08 +0300 Subject: [PATCH] amdilc, mantle: handle basic atomic counter buffer functionality Added support for APPEND_BUF_ALLOC, APPEND_BUF_CONSUME instructions, added support for grCmdInitAtomicCounters which is used by Battlefield 4. --- src/amdilc/amdilc.h | 1 + src/amdilc/amdilc_compiler.c | 69 ++++++++++ src/amdilc/amdilc_spirv.c | 28 +++++ src/amdilc/amdilc_spirv.h | 13 ++ src/mantle/mantle_cmd_buf.c | 216 ++++++++++++++++++++++++++++++-- src/mantle/mantle_cmd_buf_man.c | 6 + src/mantle/mantle_object.h | 4 + src/mantle/stub.c | 21 ---- 8 files changed, 328 insertions(+), 30 deletions(-) diff --git a/src/amdilc/amdilc.h b/src/amdilc/amdilc.h index f7705252..ff4ee8c4 100644 --- a/src/amdilc/amdilc.h +++ b/src/amdilc/amdilc.h @@ -8,6 +8,7 @@ // TODO get rid of this #define ILC_BASE_RESOURCE_ID (16) // Samplers use 0-15 +#define ILC_BASE_APPEND_COUNTER_RESOURCE_ID (0xFFFF) #define ILC_MAX_STRIDE_CONSTANTS (8) diff --git a/src/amdilc/amdilc_compiler.c b/src/amdilc/amdilc_compiler.c index ef4e56a2..c9935a31 100644 --- a/src/amdilc/amdilc_compiler.c +++ b/src/amdilc/amdilc_compiler.c @@ -23,6 +23,7 @@ typedef enum { RES_TYPE_GENERIC, RES_TYPE_LDS, + RES_TYPE_ATOMIC_BUFFER, } IlcResourceType; typedef enum { @@ -2494,6 +2495,70 @@ static void emitLdsStoreVec( } } +static void emitUavAppendBufAlloc( + IlcCompiler* compiler, + const Instruction* instr) +{ + uint8_t ilResourceId = GET_BITS(instr->control, 0, 14); + bool increment = instr->opcode == IL_OP_APPEND_BUF_ALLOC; + //ilResourceId is always 0 + const IlcResource* resource = findResource(compiler, RES_TYPE_ATOMIC_BUFFER, 0); + if (resource == NULL) { + IlcSpvId arrayId = ilcSpvPutRuntimeArrayType(compiler->module, compiler->uintId, true); + IlcSpvId structId = ilcSpvPutUniqueStructType(compiler->module, 1, &arrayId); + IlcSpvId pCounterId = ilcSpvPutPointerType(compiler->module, SpvStorageClassStorageBuffer, structId); + IlcSpvId resourceId = ilcSpvPutVariable(compiler->module, pCounterId, SpvStorageClassStorageBuffer); + + IlcSpvWord arrayStride = sizeof(unsigned); + IlcSpvWord memberOffset = 0; + ilcSpvPutDecoration(compiler->module, arrayId, SpvDecorationArrayStride, 1, &arrayStride); + ilcSpvPutDecoration(compiler->module, structId, SpvDecorationBlock, 0, NULL); + ilcSpvPutMemberDecoration(compiler->module, structId, 0, SpvDecorationOffset, 1, &memberOffset); + + const IlcResource resourceInfo = { + .resType = RES_TYPE_ATOMIC_BUFFER, + .id = resourceId, + .typeId = structId, + .texelTypeId = compiler->uintId, + .ilId = 0, + .ilType = IL_USAGE_PIXTEX_UNKNOWN, + .strideId = 0, + .structured = false, + }; + + emitBinding(compiler, resourceId, ILC_BASE_APPEND_COUNTER_RESOURCE_ID, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, + NO_STRIDE_INDEX); + + addResource(compiler, &resourceInfo); + resource = findResource(compiler, RES_TYPE_ATOMIC_BUFFER, 0); + if (resource == NULL) { + LOGE("failed to find counter resource after creation"); + return; + } + } + const Destination* dst = &instr->dsts[0]; + + IlcSpvId zeroId = ilcSpvPutConstant(compiler->module, compiler->uintId, ZERO_LITERAL); + IlcSpvId counterIndexId = ilcSpvPutConstant(compiler->module, compiler->uintId, ilResourceId); + IlcSpvId scopeId = ilcSpvPutConstant(compiler->module, compiler->intId, SpvScopeDevice); + + IlcSpvId ptrTypeId = ilcSpvPutPointerType(compiler->module, SpvStorageClassStorageBuffer, resource->texelTypeId); + + IlcSpvId indexIds[] = { zeroId, counterIndexId }; + IlcSpvId ptrId = ilcSpvPutAccessChain(compiler->module, ptrTypeId, resource->id, + 2, indexIds); + IlcSpvId semanticsId = ilcSpvPutConstant(compiler->module, compiler->intId, + SpvMemorySemanticsAcquireReleaseMask | + SpvMemorySemanticsUniformMemoryMask); + IlcSpvId readId = ilcSpvPutAtomicOpWithoutValue(compiler->module, increment ? SpvOpAtomicIIncrement : SpvOpAtomicIDecrement, + resource->texelTypeId, ptrId, scopeId, semanticsId); + + IlcSpvId constituents[4] = { readId, zeroId, zeroId, zeroId}; + IlcSpvId loadId = ilcSpvPutCompositeConstruct(compiler->module, compiler->uint4Id, + 4, constituents); + storeDestination(compiler, dst, loadId, compiler->uint4Id); +} + static void emitUavLoad( IlcCompiler* compiler, const Instruction* instr) @@ -3135,6 +3200,10 @@ static void emitInstr( case IL_OP_LDS_READ_UMAX: emitLdsAtomicOp(compiler, instr); break; + case IL_OP_APPEND_BUF_ALLOC: + case IL_OP_APPEND_BUF_CONSUME: + emitUavAppendBufAlloc(compiler, instr); + break; case IL_OP_DCL_RAW_SRV: case IL_OP_DCL_STRUCT_SRV: emitSrv(compiler, instr); diff --git a/src/amdilc/amdilc_spirv.c b/src/amdilc/amdilc_spirv.c index cf475813..198b88cb 100644 --- a/src/amdilc/amdilc_spirv.c +++ b/src/amdilc/amdilc_spirv.c @@ -419,6 +419,14 @@ IlcSpvId ilcSpvPutRuntimeArrayType( return putType(module, SpvOpTypeRuntimeArray, 1, &typeId, true, unique); } +IlcSpvId ilcSpvPutUniqueStructType( + IlcSpvModule* module, + unsigned memberTypeIdCount, + const IlcSpvId* memberTypeId) +{ + return putType(module, SpvOpTypeStruct, memberTypeIdCount, memberTypeId, true, true); +} + IlcSpvId ilcSpvPutStructType( IlcSpvModule* module, unsigned memberTypeIdCount, @@ -889,6 +897,26 @@ IlcSpvId ilcSpvPutOp4( return id; } +IlcSpvId ilcSpvPutAtomicOpWithoutValue( + IlcSpvModule* module, + SpvOp op, + IlcSpvId resultTypeId, + IlcSpvId pointerId, + IlcSpvWord memoryId, + IlcSpvWord semanticsId) +{ + IlcSpvBuffer* buffer = &module->buffer[ID_CODE]; + + IlcSpvId id = ilcSpvAllocId(module); + putInstr(buffer, op, 6); + putWord(buffer, resultTypeId); + putWord(buffer, id); + putWord(buffer, pointerId); + putWord(buffer, memoryId); + putWord(buffer, semanticsId); + return id; +} + IlcSpvId ilcSpvPutAtomicOp( IlcSpvModule* module, SpvOp op, diff --git a/src/amdilc/amdilc_spirv.h b/src/amdilc/amdilc_spirv.h index ce1a9544..42b261f1 100644 --- a/src/amdilc/amdilc_spirv.h +++ b/src/amdilc/amdilc_spirv.h @@ -128,6 +128,11 @@ IlcSpvId ilcSpvPutRuntimeArrayType( IlcSpvId typeId, bool unique); +IlcSpvId ilcSpvPutUniqueStructType( + IlcSpvModule* module, + unsigned memberTypeIdCount, + const IlcSpvId* memberTypeId); + IlcSpvId ilcSpvPutStructType( IlcSpvModule* module, unsigned memberTypeIdCount, @@ -318,6 +323,14 @@ IlcSpvId ilcSpvPutAtomicOp( IlcSpvWord semanticsId, IlcSpvId valueId); +IlcSpvId ilcSpvPutAtomicOpWithoutValue( + IlcSpvModule* module, + SpvOp op, + IlcSpvId resultTypeId, + IlcSpvId pointerId, + IlcSpvWord memoryId, + IlcSpvWord semanticsId); + IlcSpvId ilcSpvPutBitcast( IlcSpvModule* module, IlcSpvId resultTypeId, diff --git a/src/mantle/mantle_cmd_buf.c b/src/mantle/mantle_cmd_buf.c index abc027d8..1e36bd94 100644 --- a/src/mantle/mantle_cmd_buf.c +++ b/src/mantle/mantle_cmd_buf.c @@ -117,9 +117,60 @@ static const DescriptorSetSlot* getDescriptorSetSlot( return NULL; } +static void allocateAtomicCounterMemory( + const GrDevice* grDevice, + GrCmdBuffer* grCmdBuffer, + VkPipelineBindPoint bindPoint) +{ + LOGT("%p %p %d\n", grDevice, grCmdBuffer, bindPoint); + unsigned heapCount = 0; + grGetMemoryHeapCount((GR_DEVICE)grDevice, &heapCount); + + GR_MEMORY_HEAP_PROPERTIES heapProps = {}; + GR_SIZE heapPropsSize = sizeof(heapProps); + GR_UINT suitableHeap = 0; + + for (int i = 0; i < heapCount; i++) { + grGetMemoryHeapInfo((GR_DEVICE)grDevice, i, GR_INFO_TYPE_MEMORY_HEAP_PROPERTIES, &heapPropsSize, &heapProps); + + if (heapProps.heapMemoryType == GR_HEAP_MEMORY_LOCAL) { + suitableHeap = i; + break; + } + } + GR_RESULT heapResult = grGetMemoryHeapInfo((GR_DEVICE)grDevice, suitableHeap, GR_INFO_TYPE_MEMORY_HEAP_PROPERTIES, &heapPropsSize, &heapProps); + assert(heapResult == GR_SUCCESS); + + VkPhysicalDeviceProperties deviceProperties; + vki.vkGetPhysicalDeviceProperties(grDevice->physicalDevice, &deviceProperties); + GR_MEMORY_ALLOC_INFO allocInfo = {}; + //TODO: move this to grDevice init + unsigned stride = max(sizeof(int), deviceProperties.limits.minStorageBufferOffsetAlignment); + unsigned allocSize = MAX_UAV_COUNTERS * stride; + allocInfo.size = (1 + allocSize / heapProps.pageSize) * heapProps.pageSize; + allocInfo.alignment = 0; + allocInfo.memPriority = GR_MEMORY_PRIORITY_HIGH; + allocInfo.heapCount = 1; + allocInfo.heaps[0] = suitableHeap; + GR_RESULT allocResult = grAllocMemory((GR_DEVICE)grDevice, &allocInfo, &grCmdBuffer->bindPoints[bindPoint].atomicCounterMemory); + assert(allocResult == GR_SUCCESS); + GrGpuMemory* grGpuMemory = (GrGpuMemory*)grCmdBuffer->bindPoints[bindPoint].atomicCounterMemory; + grCmdBuffer->bindPoints[bindPoint].atomicCounterSlot = (DescriptorSetSlot) { + .type = SLOT_TYPE_MEMORY_VIEW, + .memoryView = { + .vkBuffer = grGpuMemory->buffer, + .offset = 0, + .range = allocSize, + .stride = stride, + }, + }; + +} + static void updateVkDescriptorSet( const GrDevice* grDevice, GrCmdBuffer* grCmdBuffer, + VkPipelineBindPoint bindPoint, VkDescriptorSet vkDescriptorSet, VkPipelineLayout vkPipelineLayout, unsigned slotOffset, @@ -144,10 +195,15 @@ static void updateVkDescriptorSet( for (unsigned i = 0; i < grShader->bindingCount; i++) { const IlcBinding* binding = &grShader->bindings[i]; const DescriptorSetSlot* slot; - if (dynamicMapping->slotObjectType != GR_SLOT_UNUSED && (binding->index == (ILC_BASE_RESOURCE_ID + dynamicMapping->shaderEntityIndex))) { slot = dynamicMemoryView; + } else if (binding->index == ILC_BASE_APPEND_COUNTER_RESOURCE_ID) { + if (grCmdBuffer->bindPoints[bindPoint].atomicCounterSlot.type == SLOT_TYPE_NONE) { + LOGT("allocating atomic buffer\n"); + allocateAtomicCounterMemory(grDevice, grCmdBuffer, bindPoint); + } + slot = &grCmdBuffer->bindPoints[bindPoint].atomicCounterSlot; } else { slot = getDescriptorSetSlot(grDescriptorSet, slotOffset, &shaderInfo->descriptorSetMapping[0], binding->index); @@ -337,9 +393,12 @@ static void grCmdBufferUpdateDescriptorSets( } for (unsigned i = 0; i < grPipeline->stageCount; i++) { - updateVkDescriptorSet(grDevice, grCmdBuffer, bindPoint->descriptorSets[i], - grPipeline->pipelineLayout, bindPoint->slotOffset, - &grPipeline->shaderInfos[i], bindPoint->grDescriptorSet, + updateVkDescriptorSet(grDevice, grCmdBuffer, vkBindPoint, + bindPoint->descriptorSets[i], + grPipeline->pipelineLayout, + bindPoint->slotOffset, + &grPipeline->shaderInfos[i], + bindPoint->grDescriptorSet, &bindPoint->dynamicMemoryView); } } @@ -434,8 +493,8 @@ GR_VOID GR_STDCALL grCmdBindPipeline( if (vkBindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) { bindPoint->dirtyFlags |= FLAG_DIRTY_DESCRIPTOR_SETS | - FLAG_DIRTY_FRAMEBUFFER | - FLAG_DIRTY_PIPELINE; + FLAG_DIRTY_FRAMEBUFFER | + FLAG_DIRTY_PIPELINE; } else { // Pipeline creation isn't deferred for compute, bind now VKD.vkCmdBindPipeline(grCmdBuffer->commandBuffer, vkBindPoint, @@ -588,8 +647,8 @@ GR_VOID GR_STDCALL grCmdBindDynamicMemoryView( // FIXME what is pMemView->state for? bool dirtySlot = grGpuMemory->buffer != dynamicMemoryView->memoryView.vkBuffer || - pMemView->range != dynamicMemoryView->memoryView.range || - pMemView->stride != dynamicMemoryView->memoryView.stride; + pMemView->range != dynamicMemoryView->memoryView.range || + pMemView->stride != dynamicMemoryView->memoryView.stride; bool dirtyOffset = pMemView->offset != dynamicMemoryView->memoryView.offset; if (!dirtySlot && !dirtyOffset) { @@ -608,7 +667,7 @@ GR_VOID GR_STDCALL grCmdBindDynamicMemoryView( }; bindPoint->dirtyFlags |= (dirtySlot ? FLAG_DIRTY_DESCRIPTOR_SETS : 0) | - (dirtyOffset ? FLAG_DIRTY_DYNAMIC_OFFSET : 0); + (dirtyOffset ? FLAG_DIRTY_DYNAMIC_OFFSET : 0); } GR_VOID GR_STDCALL grCmdBindIndexData( @@ -1316,3 +1375,142 @@ GR_VOID GR_STDCALL grCmdResetQueryPool( VKD.vkCmdResetQueryPool(grCmdBuffer->commandBuffer, grQueryPool->queryPool, startQuery, queryCount); } + +GR_VOID GR_STDCALL grCmdInitAtomicCounters( + GR_CMD_BUFFER cmdBuffer, + GR_ENUM pipelineBindPoint, + GR_UINT startCounter, + GR_UINT counterCount, + const GR_UINT32* pData) +{ + LOGT("%p %d %d %d %p\n", cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData); + GrCmdBuffer* grCmdBuffer = (GrCmdBuffer*)cmdBuffer; + const GrDevice* grDevice = GET_OBJ_DEVICE(grCmdBuffer); + + grCmdBufferEndRenderPass(grCmdBuffer); + + VkPipelineBindPoint vkBindPoint = getVkPipelineBindPoint(pipelineBindPoint); + if (grCmdBuffer->bindPoints[vkBindPoint].atomicCounterMemory == GR_NULL_HANDLE) { + allocateAtomicCounterMemory(grDevice, grCmdBuffer, vkBindPoint); + } + + unsigned offset = startCounter * grCmdBuffer->bindPoints[vkBindPoint].atomicCounterSlot.memoryView.stride; + unsigned size = counterCount * sizeof(GR_UINT32); + + VkBufferMemoryBarrier preTransferBarrier = { + .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, + .pNext = NULL, + .srcAccessMask = VK_ACCESS_UNIFORM_READ_BIT | + VK_ACCESS_SHADER_READ_BIT | + VK_ACCESS_SHADER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .buffer = grCmdBuffer->bindPoints[vkBindPoint].atomicCounterSlot.memoryView.vkBuffer, + .offset = offset, + .size = size, + }; + + VKD.vkCmdPipelineBarrier(grCmdBuffer->commandBuffer, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // TODO optimize + VK_PIPELINE_STAGE_TRANSFER_BIT, + 0, 0, NULL, 1, &preTransferBarrier, 0, NULL); + //TODO: handle strides which are more than 4 + grCmdUpdateMemory( + cmdBuffer, + grCmdBuffer->bindPoints[vkBindPoint].atomicCounterMemory, + offset, + size, + pData); + + VkBufferMemoryBarrier postTransferBarrier = { + .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, + .pNext = NULL, + .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT | + VK_ACCESS_SHADER_READ_BIT | + VK_ACCESS_SHADER_WRITE_BIT, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .buffer = grCmdBuffer->bindPoints[vkBindPoint].atomicCounterSlot.memoryView.vkBuffer, + .offset = offset, + .size = size, + }; + + VKD.vkCmdPipelineBarrier(grCmdBuffer->commandBuffer, + VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // TODO optimize + 0, 0, NULL, 1, &postTransferBarrier, 0, NULL); +} + +GR_VOID GR_STDCALL grCmdSaveAtomicCounters( + GR_CMD_BUFFER cmdBuffer, + GR_ENUM pipelineBindPoint, + GR_UINT startCounter, + GR_UINT counterCount, + GR_GPU_MEMORY destMem, + GR_GPU_SIZE destOffset) +{ + LOGT("%p %d %d %d %p %d\n", cmdBuffer, pipelineBindPoint, startCounter, counterCount, destMem, destOffset); + + GrCmdBuffer* grCmdBuffer = (GrCmdBuffer*)cmdBuffer; + const GrDevice* grDevice = GET_OBJ_DEVICE(grCmdBuffer); + + grCmdBufferEndRenderPass(grCmdBuffer); + + VkPipelineBindPoint vkBindPoint = getVkPipelineBindPoint(pipelineBindPoint); + + if (grCmdBuffer->bindPoints[vkBindPoint].atomicCounterMemory == GR_NULL_HANDLE) { + LOGW("trying to save atomic counters when no counters were initialized\n"); + allocateAtomicCounterMemory(grDevice, grCmdBuffer, vkBindPoint); + } + + GR_MEMORY_COPY copyRegion = { + .srcOffset = startCounter * grCmdBuffer->bindPoints[vkBindPoint].atomicCounterSlot.memoryView.stride, + .copySize = counterCount * sizeof(GR_UINT32), + .destOffset = destOffset, + }; + + VkBufferMemoryBarrier preTransferBarrier = { + .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, + .pNext = NULL, + .srcAccessMask = VK_ACCESS_UNIFORM_READ_BIT | + VK_ACCESS_SHADER_READ_BIT | + VK_ACCESS_SHADER_WRITE_BIT, + .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .buffer = grCmdBuffer->bindPoints[vkBindPoint].atomicCounterSlot.memoryView.vkBuffer, + .offset = copyRegion.srcOffset, + .size = copyRegion.copySize, + }; + + VKD.vkCmdPipelineBarrier(grCmdBuffer->commandBuffer, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // TODO optimize + VK_PIPELINE_STAGE_TRANSFER_BIT, + 0, 0, NULL, 1, &preTransferBarrier, 0, NULL); + + grCmdCopyMemory( + cmdBuffer, + grCmdBuffer->bindPoints[vkBindPoint].atomicCounterMemory, + destMem, + 1, ©Region); + + VkBufferMemoryBarrier postTransferBarrier = { + .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, + .pNext = NULL, + .srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT | + VK_ACCESS_SHADER_READ_BIT | + VK_ACCESS_SHADER_WRITE_BIT, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .buffer = grCmdBuffer->bindPoints[vkBindPoint].atomicCounterSlot.memoryView.vkBuffer, + .offset = copyRegion.srcOffset, + .size = copyRegion.copySize, + }; + VKD.vkCmdPipelineBarrier(grCmdBuffer->commandBuffer, + VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // TODO optimize + 0, 0, NULL, 1, &postTransferBarrier, 0, NULL); +} diff --git a/src/mantle/mantle_cmd_buf_man.c b/src/mantle/mantle_cmd_buf_man.c index 015c45d4..fc10c637 100644 --- a/src/mantle/mantle_cmd_buf_man.c +++ b/src/mantle/mantle_cmd_buf_man.c @@ -12,6 +12,12 @@ void grCmdBufferResetState( for (unsigned i = 0; i < grCmdBuffer->framebufferCount; i++) { VKD.vkDestroyFramebuffer(grDevice->device, grCmdBuffer->framebuffers[i], NULL); } + if (grCmdBuffer->bindPoints[0].atomicCounterMemory != GR_NULL_HANDLE) { + grFreeMemory(grCmdBuffer->bindPoints[0].atomicCounterMemory); + } + if (grCmdBuffer->bindPoints[1].atomicCounterMemory != GR_NULL_HANDLE) { + grFreeMemory(grCmdBuffer->bindPoints[1].atomicCounterMemory); + } free(grCmdBuffer->descriptorPools); free(grCmdBuffer->framebuffers); diff --git a/src/mantle/mantle_object.h b/src/mantle/mantle_object.h index 80401211..494526c5 100644 --- a/src/mantle/mantle_object.h +++ b/src/mantle/mantle_object.h @@ -11,6 +11,8 @@ #define MAX_STAGE_COUNT 5 // VS, HS, DS, GS, PS #define MSAA_LEVEL_COUNT 5 // 1, 2, 4, 8, 16x +#define MAX_UAV_COUNTERS 512 + #define GET_OBJ_TYPE(obj) \ (((GrBaseObject*)(obj))->grObjType) @@ -95,7 +97,9 @@ typedef struct _BindPoint GrPipeline* grPipeline; GrDescriptorSet* grDescriptorSet; unsigned slotOffset; + GR_GPU_MEMORY atomicCounterMemory; DescriptorSetSlot dynamicMemoryView; + DescriptorSetSlot atomicCounterSlot; VkDescriptorPool descriptorPool; VkDescriptorSet descriptorSets[MAX_STAGE_COUNT]; } BindPoint; diff --git a/src/mantle/stub.c b/src/mantle/stub.c index 1bb34b60..d17d4b77 100644 --- a/src/mantle/stub.c +++ b/src/mantle/stub.c @@ -138,16 +138,6 @@ GR_VOID GR_STDCALL grCmdWriteTimestamp( LOGW("STUB\n"); } -GR_VOID GR_STDCALL grCmdInitAtomicCounters( - GR_CMD_BUFFER cmdBuffer, - GR_ENUM pipelineBindPoint, - GR_UINT startCounter, - GR_UINT counterCount, - const GR_UINT32* pData) -{ - LOGW("STUB\n"); -} - GR_VOID GR_STDCALL grCmdLoadAtomicCounters( GR_CMD_BUFFER cmdBuffer, GR_ENUM pipelineBindPoint, @@ -159,17 +149,6 @@ GR_VOID GR_STDCALL grCmdLoadAtomicCounters( LOGW("STUB\n"); } -GR_VOID GR_STDCALL grCmdSaveAtomicCounters( - GR_CMD_BUFFER cmdBuffer, - GR_ENUM pipelineBindPoint, - GR_UINT startCounter, - GR_UINT counterCount, - GR_GPU_MEMORY destMem, - GR_GPU_SIZE destOffset) -{ - LOGW("STUB\n"); -} - // Debug Functions GR_RESULT GR_STDCALL grDbgSetValidationLevel(