• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VkResourceRecord类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中VkResourceRecord的典型用法代码示例。如果您正苦于以下问题:C++ VkResourceRecord类的具体用法?C++ VkResourceRecord怎么用?C++ VkResourceRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了VkResourceRecord类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:281627166,项目名称:renderdoc,代码行数:32,代码来源:vk_resource_funcs.cpp


示例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;
}
开发者ID:281627166,项目名称:renderdoc,代码行数:57,代码来源:vk_resource_funcs.cpp


示例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;
}
开发者ID:AJ92,项目名称:renderdoc,代码行数:51,代码来源:vk_shader_funcs.cpp


示例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;
}
开发者ID:281627166,项目名称:renderdoc,代码行数:49,代码来源:vk_resource_funcs.cpp


示例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;
}
开发者ID:AJ92,项目名称:renderdoc,代码行数:49,代码来源:vk_shader_funcs.cpp


示例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());
  }
}
开发者ID:DrChat,项目名称:renderdoc,代码行数:18,代码来源:vk_dynamic_funcs.cpp


示例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);
	}
}
开发者ID:poppolopoppo,项目名称:renderdoc,代码行数:22,代码来源:vk_sync_funcs.cpp


示例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;
}
开发者ID:Althar93,项目名称:renderdoc,代码行数:38,代码来源:vk_misc_funcs.cpp


示例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;
}
开发者ID:Zorro666,项目名称:renderdoc,代码行数:36,代码来源:vk_descriptor_funcs.cpp


示例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));
}
开发者ID:281627166,项目名称:renderdoc,代码行数:75,代码来源:vk_resource_funcs.cpp


示例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);
		}
开发者ID:qqdiguo,项目名称:renderdoc,代码行数:66,代码来源:vk_device_funcs.cpp


示例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();
      }
    }
  }
}
开发者ID:Anteru,项目名称:renderdoc,代码行数:64,代码来源:vk_queue_funcs.cpp


示例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)
        {
//.........这里部分代码省略.........
开发者ID:Anteru,项目名称:renderdoc,代码行数:101,代码来源:vk_queue_funcs.cpp


示例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;
}
开发者ID:Zorro666,项目名称:renderdoc,代码行数:83,代码来源:vk_descriptor_funcs.cpp


示例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);
	}
}
开发者ID:poppolopoppo,项目名称:renderdoc,代码行数:66,代码来源:vk_sync_funcs.cpp


示例16: GetRecord

VkResult WrappedVulkan::vkAllocateMemory(
			VkDevice                                    device,
			const VkMemoryAllocateInfo*                 pAllocateInfo,
			const VkAllocationCallbacks*                pAllocator,
			VkDeviceMemory*                             pMemory)
{
	VkMemoryAllocateInfo info = *pAllocateInfo;
	if(m_State >= WRITING)
	{
		info.memoryTypeIndex = GetRecord(device)->memIdxMap[info.memoryTypeIndex];

		// we need to be able to allocate a buffer that covers the whole memory range. However
		// if the memory is e.g. 100 bytes (arbitrary example) and buffers have memory requirements
		// such that it must be bound to a multiple of 128 bytes, then we can't create a buffer
		// that entirely covers a 100 byte allocation.
		// To get around this, we create a buffer of the allocation's size with the properties we
		// want, check its required size, then bump up the allocation size to that as if the application
		// had requested more. We're assuming here no system will require something like "buffer of
		// size N must be bound to memory of size N+O for some value of O overhead bytes".
		//
		// this could be optimised as maybe we'll be creating buffers of multiple sizes, but allocation
		// in vulkan is already expensive and making it a little more expensive isn't a big deal.
	
		VkBufferCreateInfo bufInfo = {
			VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, NULL, 0,
			info.allocationSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT|VK_BUFFER_USAGE_TRANSFER_DST_BIT,
		};

		// since this is very short lived, it's not wrapped
		VkBuffer buf;

		VkResult vkr = ObjDisp(device)->CreateBuffer(Unwrap(device), &bufInfo, NULL, &buf);
		RDCASSERTEQUAL(vkr, VK_SUCCESS);

		if(vkr == VK_SUCCESS && buf != VK_NULL_HANDLE)
		{
			VkMemoryRequirements mrq = { 0 };
			ObjDisp(device)->GetBufferMemoryRequirements(Unwrap(device), buf, &mrq);

			RDCASSERTMSG("memory requirements less than desired size", mrq.size >= bufInfo.size, mrq.size, bufInfo.size);

			// round up allocation size to allow creation of buffers
			if(mrq.size >= bufInfo.size)
				info.allocationSize = mrq.size;
		}

		ObjDisp(device)->DestroyBuffer(Unwrap(device), buf, NULL);
	}

	VkResult ret = ObjDisp(device)->AllocateMemory(Unwrap(device), &info, pAllocator, pMemory);

	// restore the memoryTypeIndex to the original, as that's what we want to serialise,
	// but maintain any potential modifications we made to info.allocationSize
	info.memoryTypeIndex = pAllocateInfo->memoryTypeIndex;
	
	if(ret == VK_SUCCESS)
	{
		ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pMemory);

		if(m_State >= WRITING)
		{
			Chunk *chunk = NULL;

			{
				CACHE_THREAD_SERIALISER();
					
				SCOPED_SERIALISE_CONTEXT(ALLOC_MEM);
				Serialise_vkAllocateMemory(localSerialiser, device, &info, NULL, pMemory);

				chunk = scope.Get();
			}
			
			// create resource record for gpu memory
			VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pMemory);
			RDCASSERT(record);

			record->AddChunk(chunk);

			record->Length = info.allocationSize;

			uint32_t memProps = m_PhysicalDeviceData.fakeMemProps->memoryTypes[info.memoryTypeIndex].propertyFlags;

			// if memory is not host visible, so not mappable, don't create map state at all
			if((memProps & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
			{
				record->memMapState = new MemMapState();
				record->memMapState->mapCoherent = (memProps & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0;
				record->memMapState->refData = NULL;
			}
		}
		else
		{
			GetResourceManager()->AddLiveResource(id, *pMemory);

			m_CreationInfo.m_Memory[id].Init(GetResourceManager(), m_CreationInfo, &info);

			// create a buffer with the whole memory range bound, for copying to and from
			// conveniently (for initial state data)
			VkBuffer buf = VK_NULL_HANDLE;

//.........这里部分代码省略.........
开发者ID:qqdiguo,项目名称:renderdoc,代码行数:101,代码来源:vk_resource_funcs.cpp


示例17: GetTempMemory


//.........这里部分代码省略.........
            }

            // as long as descriptor sets are forced to have initial states, we don't have to mark them ref'd for
            // write here. The reason being that as long as we only mark them as ref'd when they're actually bound,
            // we can safely skip the ref here and it means any descriptor set updates of descriptor sets that are
            // never used in the frame can be ignored.
            //GetResourceManager()->MarkResourceFrameReferenced(GetResID(pDescriptorWrites[i].destSet), eFrameRef_Write);
        }

        for(uint32_t i=0; i < copyCount; i++)
        {
            {
                CACHE_THREAD_SERIALISER();

                SCOPED_SERIALISE_CONTEXT(UPDATE_DESC_SET);
                Serialise_vkUpdateDescriptorSets(localSerialiser, device, 0, NULL, 1, &pDescriptorCopies[i]);

                m_FrameCaptureRecord->AddChunk(scope.Get());
            }

            // Like writes we don't have to mark the written descriptor set as used because unless it's bound somewhere
            // we don't need it anyway. However we DO have to mark the source set as used because it doesn't have to
            // be bound to still be needed (think about if the dest set is bound somewhere after this copy - what refs
            // the source set?).
            // At the same time as ref'ing the source set, we must ref all of its resources (via the bindFrameRefs).
            // We just ref all rather than looking at only the copied sets to keep things simple.
            // This does mean a slightly conservative ref'ing if the dest set doesn't end up getting bound, but we only
            // do this during frame capture so it's not too bad.
            //GetResourceManager()->MarkResourceFrameReferenced(GetResID(pDescriptorCopies[i].destSet), eFrameRef_Write);

            {
                GetResourceManager()->MarkResourceFrameReferenced(GetResID(pDescriptorCopies[i].srcSet), eFrameRef_Read);

                VkResourceRecord *setrecord = GetRecord(pDescriptorCopies[i].srcSet);

                for(auto refit = setrecord->descInfo->bindFrameRefs.begin(); refit != setrecord->descInfo->bindFrameRefs.end(); ++refit)
                {
                    GetResourceManager()->MarkResourceFrameReferenced(refit->first, refit->second.second);

                    if(refit->second.first & DescriptorSetData::SPARSE_REF_BIT)
                    {
                        VkResourceRecord *record = GetResourceManager()->GetResourceRecord(refit->first);

                        GetResourceManager()->MarkSparseMapReferenced(record->sparseInfo);
                    }
                }
            }
        }
    }

    // need to track descriptor set contents whether capframing or idle
    if(m_State >= WRITING)
    {
        for(uint32_t i=0; i < writeCount; i++)
        {
            VkResourceRecord *record = GetRecord(pDescriptorWrites[i].dstSet);
            RDCASSERT(record->descInfo && record->descInfo->layout);
            const DescSetLayout &layout = *record->descInfo->layout;

            RDCASSERT(pDescriptorWrites[i].dstBinding < record->descInfo->descBindings.size());

            DescriptorSetSlot *binding = record->descInfo->descBindings[pDescriptorWrites[i].dstBinding];

            FrameRefType ref = eFrameRef_Write;

            switch(layout.bindings[pDescriptorWrites[i].dstBinding].descriptorType)
开发者ID:Zorro666,项目名称:renderdoc,代码行数:67,代码来源:vk_descriptor_funcs.cpp



注:本文中的VkResourceRecord类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VlcProc类代码示例发布时间:2022-05-31
下一篇:
C++ VkLayerDispatchTable类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap