本文整理汇总了C++中VkResourceRecord类的典型用法代码示例。如果您正苦于以下问题:C++ VkResourceRecord类的具体用法?C++ VkResourceRecord怎么用?C++ VkResourceRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VkResourceRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRecord
VkResult WrappedVulkan::vkBindBufferMemory(
VkDevice device,
VkBuffer buffer,
VkDeviceMemory mem,
VkDeviceSize memOffset)
{
VkResourceRecord *record = GetRecord(buffer);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(BIND_BUFFER_MEM);
Serialise_vkBindBufferMemory(localSerialiser, device, buffer, mem, memOffset);
chunk = scope.Get();
}
// memory object bindings are immutable and must happen before creation or use,
// so this can always go into the record, even if a resource is created and bound
// to memory mid-frame
record->AddChunk(chunk);
record->AddParent(GetRecord(mem));
record->baseResource = GetResID(mem);
}
return ObjDisp(device)->BindBufferMemory(Unwrap(device), Unwrap(buffer), Unwrap(mem), memOffset);
}
示例2: ObjDisp
VkResult WrappedVulkan::vkCreateBuffer(
VkDevice device,
const VkBufferCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkBuffer* pBuffer)
{
VkResult ret = ObjDisp(device)->CreateBuffer(Unwrap(device), pCreateInfo, pAllocator, pBuffer);
// SHARING: pCreateInfo sharingMode, queueFamilyCount, pQueueFamilyIndices
if(ret == VK_SUCCESS)
{
ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pBuffer);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CREATE_BUFFER);
Serialise_vkCreateBuffer(localSerialiser, device, pCreateInfo, NULL, pBuffer);
chunk = scope.Get();
}
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pBuffer);
record->AddChunk(chunk);
if(pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_BINDING_BIT|VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT))
{
record->sparseInfo = new SparseMapping();
// buffers are always bound opaquely and in arbitrary divisions, sparse residency
// only means not all the buffer needs to be bound, which is not that interesting for
// our purposes
{
SCOPED_LOCK(m_CapTransitionLock);
if(m_State != WRITING_CAPFRAME)
GetResourceManager()->MarkDirtyResource(id);
else
GetResourceManager()->MarkPendingDirty(id);
}
}
}
else
{
GetResourceManager()->AddLiveResource(id, *pBuffer);
m_CreationInfo.m_Buffer[id].Init(GetResourceManager(), m_CreationInfo, pCreateInfo);
}
}
return ret;
}
示例3: Unwrap
VkResult WrappedVulkan::vkCreatePipelineLayout(VkDevice device,
const VkPipelineLayoutCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkPipelineLayout *pPipelineLayout)
{
VkDescriptorSetLayout *unwrapped = GetTempArray<VkDescriptorSetLayout>(pCreateInfo->setLayoutCount);
for(uint32_t i = 0; i < pCreateInfo->setLayoutCount; i++)
unwrapped[i] = Unwrap(pCreateInfo->pSetLayouts[i]);
VkPipelineLayoutCreateInfo unwrappedInfo = *pCreateInfo;
unwrappedInfo.pSetLayouts = unwrapped;
VkResult ret = ObjDisp(device)->CreatePipelineLayout(Unwrap(device), &unwrappedInfo, pAllocator,
pPipelineLayout);
if(ret == VK_SUCCESS)
{
ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pPipelineLayout);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CREATE_PIPE_LAYOUT);
Serialise_vkCreatePipelineLayout(localSerialiser, device, pCreateInfo, NULL, pPipelineLayout);
chunk = scope.Get();
}
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pPipelineLayout);
record->AddChunk(chunk);
for(uint32_t i = 0; i < pCreateInfo->setLayoutCount; i++)
{
VkResourceRecord *layoutrecord = GetRecord(pCreateInfo->pSetLayouts[i]);
record->AddParent(layoutrecord);
}
}
else
{
GetResourceManager()->AddLiveResource(id, *pPipelineLayout);
m_CreationInfo.m_PipelineLayout[id].Init(GetResourceManager(), m_CreationInfo, &unwrappedInfo);
}
}
return ret;
}
示例4: Unwrap
VkResult WrappedVulkan::vkCreateImageView(
VkDevice device,
const VkImageViewCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkImageView* pView)
{
VkImageViewCreateInfo unwrappedInfo = *pCreateInfo;
unwrappedInfo.image = Unwrap(unwrappedInfo.image);
VkResult ret = ObjDisp(device)->CreateImageView(Unwrap(device), &unwrappedInfo, pAllocator, pView);
if(ret == VK_SUCCESS)
{
ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pView);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CREATE_IMAGE_VIEW);
Serialise_vkCreateImageView(localSerialiser, device, pCreateInfo, NULL, pView);
chunk = scope.Get();
}
VkResourceRecord *imageRecord = GetRecord(pCreateInfo->image);
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pView);
record->AddChunk(chunk);
record->AddParent(imageRecord);
// store the base resource. Note images have a baseResource pointing
// to their memory, which we will also need so we store that separately
record->baseResource = imageRecord->GetResourceID();
record->baseResourceMem = imageRecord->baseResource;
record->sparseInfo = imageRecord->sparseInfo;
}
else
{
GetResourceManager()->AddLiveResource(id, *pView);
m_CreationInfo.m_ImageView[id].Init(GetResourceManager(), m_CreationInfo, &unwrappedInfo);
}
}
return ret;
}
示例5: RDCWARN
VkResult WrappedVulkan::vkCreatePipelineCache(VkDevice device,
const VkPipelineCacheCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkPipelineCache *pPipelineCache)
{
// pretend the user didn't provide any cache data
VkPipelineCacheCreateInfo createInfo = *pCreateInfo;
createInfo.initialDataSize = 0;
createInfo.pInitialData = NULL;
if(pCreateInfo->initialDataSize > 0)
{
RDCWARN(
"Application provided pipeline cache data! This is invalid, as RenderDoc reports "
"incompatibility with previous caches");
}
VkResult ret =
ObjDisp(device)->CreatePipelineCache(Unwrap(device), &createInfo, pAllocator, pPipelineCache);
if(ret == VK_SUCCESS)
{
ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pPipelineCache);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CREATE_PIPE_CACHE);
Serialise_vkCreatePipelineCache(localSerialiser, device, &createInfo, NULL, pPipelineCache);
chunk = scope.Get();
}
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pPipelineCache);
record->AddChunk(chunk);
}
else
{
GetResourceManager()->AddLiveResource(id, *pPipelineCache);
}
}
return ret;
}
示例6: SCOPED_DBG_SINK
void WrappedVulkan::vkCmdSetBlendConstants(VkCommandBuffer cmdBuffer, const float *blendConst)
{
SCOPED_DBG_SINK();
ObjDisp(cmdBuffer)->CmdSetBlendConstants(Unwrap(cmdBuffer), blendConst);
if(m_State >= WRITING)
{
VkResourceRecord *record = GetRecord(cmdBuffer);
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(SET_BLEND_CONST);
Serialise_vkCmdSetBlendConstants(localSerialiser, cmdBuffer, blendConst);
record->AddChunk(scope.Get());
}
}
示例7: SCOPED_DBG_SINK
void WrappedVulkan::vkCmdResetEvent(
VkCommandBuffer cmdBuffer,
VkEvent event,
VkPipelineStageFlags stageMask)
{
SCOPED_DBG_SINK();
ObjDisp(cmdBuffer)->CmdResetEvent(Unwrap(cmdBuffer), Unwrap(event), stageMask);
if(m_State >= WRITING)
{
VkResourceRecord *record = GetRecord(cmdBuffer);
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CMD_RESET_EVENT);
Serialise_vkCmdResetEvent(localSerialiser, cmdBuffer, event, stageMask);
record->AddChunk(scope.Get());
record->MarkResourceFrameReferenced(GetResID(event), eFrameRef_Read);
}
}
示例8: ObjDisp
VkResult WrappedVulkan::vkCreateSampler(
VkDevice device,
const VkSamplerCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSampler* pSampler)
{
VkResult ret = ObjDisp(device)->CreateSampler(Unwrap(device), pCreateInfo, pAllocator, pSampler);
if(ret == VK_SUCCESS)
{
ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pSampler);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CREATE_SAMPLER);
Serialise_vkCreateSampler(localSerialiser, device, pCreateInfo, NULL, pSampler);
chunk = scope.Get();
}
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pSampler);
record->AddChunk(chunk);
}
else
{
GetResourceManager()->AddLiveResource(id, *pSampler);
m_CreationInfo.m_Sampler[id].Init(GetResourceManager(), m_CreationInfo, pCreateInfo);
}
}
return ret;
}
示例9: ObjDisp
VkResult WrappedVulkan::vkCreateDescriptorPool(
VkDevice device,
const VkDescriptorPoolCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkDescriptorPool* pDescriptorPool)
{
VkResult ret = ObjDisp(device)->CreateDescriptorPool(Unwrap(device), pCreateInfo, pAllocator, pDescriptorPool);
if(ret == VK_SUCCESS)
{
ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pDescriptorPool);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CREATE_DESCRIPTOR_POOL);
Serialise_vkCreateDescriptorPool(localSerialiser, device, pCreateInfo, NULL, pDescriptorPool);
chunk = scope.Get();
}
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pDescriptorPool);
record->AddChunk(chunk);
}
else
{
GetResourceManager()->AddLiveResource(id, *pDescriptorPool);
}
}
return ret;
}
示例10: GetResID
void WrappedVulkan::vkUnmapMemory(
VkDevice device,
VkDeviceMemory mem)
{
if(m_State >= WRITING)
{
ResourceId id = GetResID(mem);
VkResourceRecord *memrecord = GetRecord(mem);
RDCASSERT(memrecord->memMapState);
MemMapState &state = *memrecord->memMapState;
{
// decide atomically if this chunk should be in-frame or not
// so that we're not in the else branch but haven't marked
// dirty when capframe starts, then we mark dirty while in-frame
bool capframe = false;
{
SCOPED_LOCK(m_CapTransitionLock);
capframe = (m_State == WRITING_CAPFRAME);
if(!capframe)
GetResourceManager()->MarkDirtyResource(id);
}
if(capframe)
{
// coherent maps must always serialise all data on unmap, even if a flush was seen, because
// unflushed data is *also* visible. This is a bit redundant since data is serialised here
// and in any flushes, but that's the app's fault - the spec calls out flushing coherent maps
// as inefficient
// if the memory is not coherent, we must have a flush for every region written while it is
// mapped, there is no implicit flush on unmap, so we follow the spec strictly on this.
if(state.mapCoherent)
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(UNMAP_MEM);
Serialise_vkUnmapMemory(localSerialiser, device, mem);
VkResourceRecord *record = GetRecord(mem);
if(m_State == WRITING_IDLE)
{
record->AddChunk(scope.Get());
}
else
{
m_FrameCaptureRecord->AddChunk(scope.Get());
GetResourceManager()->MarkResourceFrameReferenced(id, eFrameRef_Write);
}
}
}
state.mappedPtr = NULL;
}
Serialiser::FreeAlignedBuffer(state.refData);
if(state.mapCoherent)
{
SCOPED_LOCK(m_CoherentMapsLock);
auto it = std::find(m_CoherentMaps.begin(), m_CoherentMaps.end(), memrecord);
if(it == m_CoherentMaps.end())
RDCERR("vkUnmapMemory for memory handle that's not currently mapped");
m_CoherentMaps.erase(it);
}
}
ObjDisp(device)->UnmapMemory(Unwrap(device), Unwrap(mem));
}
示例11: ObjDisp
//.........这里部分代码省略.........
// use instead of SetDispatchTableOverMagicNumber
if(layerCreateInfo)
{
RDCASSERT(m_SetDeviceLoaderData == layerCreateInfo->u.pfnSetDeviceLoaderData || m_SetDeviceLoaderData == NULL,
m_SetDeviceLoaderData, layerCreateInfo->u.pfnSetDeviceLoaderData);
m_SetDeviceLoaderData = layerCreateInfo->u.pfnSetDeviceLoaderData;
}
VkResult ret = createFunc(Unwrap(physicalDevice), &createInfo, pAllocator, pDevice);
// don't serialise out any of the pNext stuff for layer initialisation
// (note that we asserted above that there was nothing else in the chain)
createInfo.pNext = NULL;
if(ret == VK_SUCCESS)
{
InitDeviceTable(*pDevice, gdpa);
ResourceId id = GetResourceManager()->WrapResource(*pDevice, *pDevice);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CREATE_DEVICE);
Serialise_vkCreateDevice(localSerialiser, physicalDevice, &createInfo, NULL, pDevice);
chunk = scope.Get();
}
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pDevice);
RDCASSERT(record);
record->AddChunk(chunk);
record->memIdxMap = GetRecord(physicalDevice)->memIdxMap;
record->instDevInfo = new InstanceDeviceInfo();
#undef CheckExt
#define CheckExt(name) record->instDevInfo->name = GetRecord(m_Instance)->instDevInfo->name;
// inherit extension enablement from instance, that way GetDeviceProcAddress can check
// for enabled extensions for instance functions
CheckInstanceExts();
#undef CheckExt
#define CheckExt(name) if(!strcmp(createInfo.ppEnabledExtensionNames[i], STRINGIZE(name))) { record->instDevInfo->name = true; }
for(uint32_t i=0; i < createInfo.enabledExtensionCount; i++)
{
CheckDeviceExts();
}
InitDeviceExtensionTables(*pDevice);
GetRecord(m_Instance)->AddParent(record);
}
else
{
GetResourceManager()->AddLiveResource(id, *pDevice);
}
示例12: ObjDisp
void WrappedVulkan::vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex,
uint32_t queueIndex, VkQueue *pQueue)
{
ObjDisp(device)->GetDeviceQueue(Unwrap(device), queueFamilyIndex, queueIndex, pQueue);
if(m_SetDeviceLoaderData)
m_SetDeviceLoaderData(m_Device, *pQueue);
else
SetDispatchTableOverMagicNumber(device, *pQueue);
RDCASSERT(m_State >= WRITING);
{
// it's perfectly valid for enumerate type functions to return the same handle
// each time. If that happens, we will already have a wrapper created so just
// return the wrapped object to the user and do nothing else
if(m_QueueFamilies[queueFamilyIndex][queueIndex] != VK_NULL_HANDLE)
{
*pQueue = m_QueueFamilies[queueFamilyIndex][queueIndex];
}
else
{
ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pQueue);
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(GET_DEVICE_QUEUE);
Serialise_vkGetDeviceQueue(localSerialiser, device, queueFamilyIndex, queueIndex, pQueue);
chunk = scope.Get();
}
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pQueue);
RDCASSERT(record);
VkResourceRecord *instrecord = GetRecord(m_Instance);
// treat queues as pool members of the instance (ie. freed when the instance dies)
{
instrecord->LockChunks();
instrecord->pooledChildren.push_back(record);
instrecord->UnlockChunks();
}
record->AddChunk(chunk);
}
m_QueueFamilies[queueFamilyIndex][queueIndex] = *pQueue;
if(queueFamilyIndex == m_QueueFamilyIdx)
{
m_Queue = *pQueue;
// we can now submit any cmds that were queued (e.g. from creating debug
// manager on vkCreateDevice)
SubmitCmds();
}
}
}
}
示例13: SCOPED_DBG_SINK
VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
const VkSubmitInfo *pSubmits, VkFence fence)
{
SCOPED_DBG_SINK();
size_t tempmemSize = sizeof(VkSubmitInfo) * submitCount;
// need to count how many semaphore and command buffer arrays to allocate for
for(uint32_t i = 0; i < submitCount; i++)
{
tempmemSize += pSubmits[i].commandBufferCount * sizeof(VkCommandBuffer);
tempmemSize += pSubmits[i].signalSemaphoreCount * sizeof(VkSemaphore);
tempmemSize += pSubmits[i].waitSemaphoreCount * sizeof(VkSemaphore);
}
byte *memory = GetTempMemory(tempmemSize);
VkSubmitInfo *unwrappedSubmits = (VkSubmitInfo *)memory;
VkSemaphore *unwrappedWaitSems = (VkSemaphore *)(unwrappedSubmits + submitCount);
for(uint32_t i = 0; i < submitCount; i++)
{
RDCASSERT(pSubmits[i].sType == VK_STRUCTURE_TYPE_SUBMIT_INFO && pSubmits[i].pNext == NULL);
unwrappedSubmits[i] = pSubmits[i];
unwrappedSubmits[i].pWaitSemaphores =
unwrappedSubmits[i].waitSemaphoreCount ? unwrappedWaitSems : NULL;
for(uint32_t o = 0; o < unwrappedSubmits[i].waitSemaphoreCount; o++)
unwrappedWaitSems[o] = Unwrap(pSubmits[i].pWaitSemaphores[o]);
unwrappedWaitSems += unwrappedSubmits[i].waitSemaphoreCount;
VkCommandBuffer *unwrappedCommandBuffers = (VkCommandBuffer *)unwrappedWaitSems;
unwrappedSubmits[i].pCommandBuffers =
unwrappedSubmits[i].commandBufferCount ? unwrappedCommandBuffers : NULL;
for(uint32_t o = 0; o < unwrappedSubmits[i].commandBufferCount; o++)
unwrappedCommandBuffers[o] = Unwrap(pSubmits[i].pCommandBuffers[o]);
unwrappedCommandBuffers += unwrappedSubmits[i].commandBufferCount;
VkSemaphore *unwrappedSignalSems = (VkSemaphore *)unwrappedCommandBuffers;
unwrappedSubmits[i].pSignalSemaphores =
unwrappedSubmits[i].signalSemaphoreCount ? unwrappedSignalSems : NULL;
for(uint32_t o = 0; o < unwrappedSubmits[i].signalSemaphoreCount; o++)
unwrappedSignalSems[o] = Unwrap(pSubmits[i].pSignalSemaphores[o]);
}
VkResult ret =
ObjDisp(queue)->QueueSubmit(Unwrap(queue), submitCount, unwrappedSubmits, Unwrap(fence));
bool capframe = false;
set<ResourceId> refdIDs;
for(uint32_t s = 0; s < submitCount; s++)
{
for(uint32_t i = 0; i < pSubmits[s].commandBufferCount; i++)
{
ResourceId cmd = GetResID(pSubmits[s].pCommandBuffers[i]);
VkResourceRecord *record = GetRecord(pSubmits[s].pCommandBuffers[i]);
{
SCOPED_LOCK(m_ImageLayoutsLock);
GetResourceManager()->ApplyBarriers(record->bakedCommands->cmdInfo->imgbarriers,
m_ImageLayouts);
}
// need to lock the whole section of code, not just the check on
// m_State, as we also need to make sure we don't check the state,
// start marking dirty resources then while we're doing so the
// state becomes capframe.
// the next sections where we mark resources referenced and add
// the submit chunk to the frame record don't have to be protected.
// Only the decision of whether we're inframe or not, and marking
// dirty.
{
SCOPED_LOCK(m_CapTransitionLock);
if(m_State == WRITING_CAPFRAME)
{
for(auto it = record->bakedCommands->cmdInfo->dirtied.begin();
it != record->bakedCommands->cmdInfo->dirtied.end(); ++it)
GetResourceManager()->MarkPendingDirty(*it);
capframe = true;
}
else
{
for(auto it = record->bakedCommands->cmdInfo->dirtied.begin();
it != record->bakedCommands->cmdInfo->dirtied.end(); ++it)
GetResourceManager()->MarkDirtyResource(*it);
}
}
if(capframe)
{
// for each bound descriptor set, mark it referenced as well as all resources currently
// bound to it
for(auto it = record->bakedCommands->cmdInfo->boundDescSets.begin();
it != record->bakedCommands->cmdInfo->boundDescSets.end(); ++it)
{
//.........这里部分代码省略.........
示例14: sizeof
VkResult WrappedVulkan::vkAllocateDescriptorSets(
VkDevice device,
const VkDescriptorSetAllocateInfo* pAllocateInfo,
VkDescriptorSet* pDescriptorSets)
{
size_t tempmemSize = sizeof(VkDescriptorSetAllocateInfo) + sizeof(VkDescriptorSetLayout)*pAllocateInfo->descriptorSetCount;
byte *memory = GetTempMemory(tempmemSize);
VkDescriptorSetAllocateInfo *unwrapped = (VkDescriptorSetAllocateInfo *)memory;
VkDescriptorSetLayout *layouts = (VkDescriptorSetLayout *)(unwrapped + 1);
*unwrapped = *pAllocateInfo;
unwrapped->pSetLayouts = layouts;
unwrapped->descriptorPool = Unwrap(unwrapped->descriptorPool);
for(uint32_t i=0; i < pAllocateInfo->descriptorSetCount; i++)
layouts[i] = Unwrap(pAllocateInfo->pSetLayouts[i]);
VkResult ret = ObjDisp(device)->AllocateDescriptorSets(Unwrap(device), unwrapped, pDescriptorSets);
if(ret != VK_SUCCESS) return ret;
for(uint32_t i=0; i < pAllocateInfo->descriptorSetCount; i++)
{
ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), pDescriptorSets[i]);
if(m_State >= WRITING)
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
VkDescriptorSetAllocateInfo info = *pAllocateInfo;
info.descriptorSetCount = 1;
info.pSetLayouts += i;
SCOPED_SERIALISE_CONTEXT(ALLOC_DESC_SET);
Serialise_vkAllocateDescriptorSets(localSerialiser, device, &info, &pDescriptorSets[i]);
chunk = scope.Get();
}
VkResourceRecord *record = GetResourceManager()->AddResourceRecord(pDescriptorSets[i]);
record->AddChunk(chunk);
ResourceId layoutID = GetResID(pAllocateInfo->pSetLayouts[i]);
VkResourceRecord *layoutRecord = GetRecord(pAllocateInfo->pSetLayouts[i]);
VkResourceRecord *poolrecord = GetRecord(pAllocateInfo->descriptorPool);
{
poolrecord->LockChunks();
poolrecord->pooledChildren.push_back(record);
poolrecord->UnlockChunks();
}
record->pool = poolrecord;
record->AddParent(poolrecord);
record->AddParent(GetResourceManager()->GetResourceRecord(layoutID));
// just always treat descriptor sets as dirty
{
SCOPED_LOCK(m_CapTransitionLock);
if(m_State != WRITING_CAPFRAME)
GetResourceManager()->MarkDirtyResource(id);
else
GetResourceManager()->MarkPendingDirty(id);
}
record->descInfo = new DescriptorSetData();
record->descInfo->layout = layoutRecord->descInfo->layout;
record->descInfo->layout->CreateBindingsArray(record->descInfo->descBindings);
}
else
{
GetResourceManager()->AddLiveResource(id, pDescriptorSets[i]);
}
}
return ret;
}
示例15: GetTempMemory
void WrappedVulkan::vkCmdWaitEvents(
VkCommandBuffer cmdBuffer,
uint32_t eventCount,
const VkEvent* pEvents,
VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
uint32_t memoryBarrierCount,
const VkMemoryBarrier* pMemoryBarriers,
uint32_t bufferMemoryBarrierCount,
const VkBufferMemoryBarrier* pBufferMemoryBarriers,
uint32_t imageMemoryBarrierCount,
const VkImageMemoryBarrier* pImageMemoryBarriers)
{
{
byte *memory = GetTempMemory( sizeof(VkEvent)*eventCount +
sizeof(VkBufferMemoryBarrier)*bufferMemoryBarrierCount +
sizeof(VkImageMemoryBarrier)*imageMemoryBarrierCount);
VkEvent *ev = (VkEvent *)memory;
VkImageMemoryBarrier *im = (VkImageMemoryBarrier *)(ev + eventCount);
VkBufferMemoryBarrier *buf = (VkBufferMemoryBarrier *)(im + imageMemoryBarrierCount);
for(uint32_t i=0; i < eventCount; i++)
ev[i] = Unwrap(pEvents[i]);
for(uint32_t i=0; i < bufferMemoryBarrierCount; i++)
{
buf[i] = pBufferMemoryBarriers[i];
buf[i].buffer = Unwrap(buf[i].buffer);
}
for(uint32_t i=0; i < imageMemoryBarrierCount; i++)
{
im[i] = pImageMemoryBarriers[i];
im[i].image = Unwrap(im[i].image);
}
ObjDisp(cmdBuffer)->CmdWaitEvents(Unwrap(cmdBuffer), eventCount, ev, srcStageMask, dstStageMask,
memoryBarrierCount, pMemoryBarriers,
bufferMemoryBarrierCount, buf,
imageMemoryBarrierCount, im);
}
if(m_State >= WRITING)
{
VkResourceRecord *record = GetRecord(cmdBuffer);
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CONTEXT(CMD_WAIT_EVENTS);
Serialise_vkCmdWaitEvents(localSerialiser, cmdBuffer, eventCount, pEvents, srcStageMask, dstStageMask,
memoryBarrierCount, pMemoryBarriers,
bufferMemoryBarrierCount, pBufferMemoryBarriers,
imageMemoryBarrierCount, pImageMemoryBarriers);
if(imageMemoryBarrierCount > 0)
{
SCOPED_LOCK(m_ImageLayoutsLock);
GetResourceManager()->RecordBarriers(GetRecord(cmdBuffer)->cmdInfo->imgbarriers, m_ImageLayouts, imageMemoryBarrierCount, pImageMemoryBarriers);
}
record->AddChunk(scope.Get());
for(uint32_t i=0; i < eventCount; i++)
record->MarkResourceFrameReferenced(GetResID(pEvents[i]), eFrameRef_Read);
}
}