mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 21:30:53 +00:00
Pass back buffers and buffer information
This commit is contained in:
@@ -278,6 +278,7 @@ void VulkanCreationInfo::Memory::Init(VulkanResourceManager *resourceMan, const
|
||||
|
||||
void VulkanCreationInfo::Buffer::Init(VulkanResourceManager *resourceMan, const VkBufferCreateInfo* pCreateInfo)
|
||||
{
|
||||
usage = pCreateInfo->usage;
|
||||
size = pCreateInfo->size;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,6 +207,7 @@ struct VulkanCreationInfo
|
||||
{
|
||||
void Init(VulkanResourceManager *resourceMan, const VkBufferCreateInfo* pCreateInfo);
|
||||
|
||||
VkBufferUsageFlags usage;
|
||||
uint64_t size;
|
||||
};
|
||||
map<ResourceId, Buffer> m_Buffer;
|
||||
|
||||
@@ -530,8 +530,158 @@ vector<ResourceId> VulkanReplay::GetTextures()
|
||||
|
||||
vector<ResourceId> VulkanReplay::GetBuffers()
|
||||
{
|
||||
VULKANNOTIMP("GetBuffers");
|
||||
return vector<ResourceId>();
|
||||
vector<ResourceId> bufs;
|
||||
|
||||
for(auto it = m_pDriver->m_CreationInfo.m_Buffer.begin(); it != m_pDriver->m_CreationInfo.m_Buffer.end(); ++it)
|
||||
{
|
||||
// skip textures that aren't from the capture
|
||||
if(m_pDriver->GetResourceManager()->GetOriginalID(it->first) == it->first)
|
||||
continue;
|
||||
|
||||
bufs.push_back(it->first);
|
||||
}
|
||||
|
||||
return bufs;
|
||||
}
|
||||
|
||||
FetchTexture VulkanReplay::GetTexture(ResourceId id)
|
||||
{
|
||||
VulkanCreationInfo::Image &iminfo = m_pDriver->m_CreationInfo.m_Image[id];
|
||||
|
||||
FetchTexture ret;
|
||||
ret.ID = m_pDriver->GetResourceManager()->GetOriginalID(id);
|
||||
ret.arraysize = iminfo.arraySize;
|
||||
ret.creationFlags = iminfo.creationFlags;
|
||||
ret.cubemap = iminfo.cube;
|
||||
ret.width = iminfo.extent.width;
|
||||
ret.height = iminfo.extent.height;
|
||||
ret.depth = iminfo.extent.depth;
|
||||
ret.mips = iminfo.mipLevels;
|
||||
ret.numSubresources = ret.mips*ret.arraysize;
|
||||
|
||||
ret.byteSize = 0;
|
||||
for(uint32_t s=0; s < ret.mips; s++)
|
||||
ret.byteSize += GetByteSize(ret.width, ret.height, ret.depth, iminfo.format, s);
|
||||
ret.byteSize *= ret.arraysize;
|
||||
|
||||
ret.msQual = 0;
|
||||
ret.msSamp = iminfo.samples;
|
||||
|
||||
ret.format = MakeResourceFormat(iminfo.format);
|
||||
|
||||
switch(iminfo.type)
|
||||
{
|
||||
case VK_IMAGE_TYPE_1D:
|
||||
ret.resType = iminfo.arraySize > 1 ? eResType_Texture1DArray : eResType_Texture1D;
|
||||
ret.dimension = 1;
|
||||
break;
|
||||
case VK_IMAGE_TYPE_2D:
|
||||
if(ret.msSamp > 1) ret.resType = iminfo.arraySize > 1 ? eResType_Texture2DMSArray : eResType_Texture2DMS;
|
||||
else if(ret.cubemap) ret.resType = iminfo.arraySize > 6 ? eResType_TextureCubeArray : eResType_TextureCube;
|
||||
else ret.resType = iminfo.arraySize > 1 ? eResType_Texture2DArray : eResType_Texture2D;
|
||||
ret.dimension = 2;
|
||||
break;
|
||||
case VK_IMAGE_TYPE_3D:
|
||||
ret.resType = eResType_Texture3D;
|
||||
ret.dimension = 3;
|
||||
break;
|
||||
default:
|
||||
RDCERR("Unexpected image type");
|
||||
break;
|
||||
}
|
||||
|
||||
ret.customName = true;
|
||||
ret.name = m_pDriver->m_CreationInfo.m_Names[id];
|
||||
if(ret.name.count == 0)
|
||||
{
|
||||
ret.customName = false;
|
||||
|
||||
const char *suffix = "";
|
||||
const char *ms = "";
|
||||
|
||||
if(ret.msSamp > 1)
|
||||
ms = "MS";
|
||||
|
||||
if(ret.creationFlags & eTextureCreate_RTV)
|
||||
suffix = " RTV";
|
||||
if(ret.creationFlags & eTextureCreate_DSV)
|
||||
suffix = " DSV";
|
||||
|
||||
if(ret.cubemap)
|
||||
{
|
||||
if(ret.arraysize > 6)
|
||||
ret.name = StringFormat::Fmt("TextureCube%sArray%s %llu", ms, suffix, ret.ID);
|
||||
else
|
||||
ret.name = StringFormat::Fmt("TextureCube%s%s %llu", ms, suffix, ret.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ret.arraysize > 1)
|
||||
ret.name = StringFormat::Fmt("Texture%dD%sArray%s %llu", ret.dimension, ms, suffix, ret.ID);
|
||||
else
|
||||
ret.name = StringFormat::Fmt("Texture%dD%s%s %llu", ret.dimension, ms, suffix, ret.ID);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FetchBuffer VulkanReplay::GetBuffer(ResourceId id)
|
||||
{
|
||||
VulkanCreationInfo::Buffer &bufinfo = m_pDriver->m_CreationInfo.m_Buffer[id];
|
||||
|
||||
FetchBuffer ret;
|
||||
ret.ID = m_pDriver->GetResourceManager()->GetOriginalID(id);
|
||||
ret.byteSize = bufinfo.size;
|
||||
ret.structureSize = 0;
|
||||
ret.length = (uint32_t)ret.byteSize;
|
||||
|
||||
ret.creationFlags = 0;
|
||||
|
||||
if(bufinfo.usage & (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT|VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT))
|
||||
ret.creationFlags |= eBufferCreate_UAV;
|
||||
if(bufinfo.usage & (VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT|VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT))
|
||||
ret.creationFlags |= eBufferCreate_CB;
|
||||
if(bufinfo.usage & (VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT))
|
||||
ret.creationFlags |= eBufferCreate_Indirect;
|
||||
if(bufinfo.usage & (VK_BUFFER_USAGE_INDEX_BUFFER_BIT))
|
||||
ret.creationFlags |= eBufferCreate_IB;
|
||||
if(bufinfo.usage & (VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))
|
||||
ret.creationFlags |= eBufferCreate_IB;
|
||||
|
||||
ret.customName = true;
|
||||
ret.name = m_pDriver->m_CreationInfo.m_Names[id];
|
||||
if(ret.name.count == 0)
|
||||
{
|
||||
ret.customName = false;
|
||||
ret.name = StringFormat::Fmt("Buffer %llu", ret.ID);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ShaderReflection *VulkanReplay::GetShader(ResourceId id)
|
||||
{
|
||||
auto shad = m_pDriver->m_CreationInfo.m_Shader.find(id);
|
||||
|
||||
if(shad == m_pDriver->m_CreationInfo.m_Shader.end())
|
||||
{
|
||||
RDCERR("Can't get shader details");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// disassemble lazily on demand
|
||||
if(shad->second.refl.Disassembly.count == 0)
|
||||
{
|
||||
auto &shadmod = m_pDriver->m_CreationInfo.m_ShaderModule[shad->second.module];
|
||||
|
||||
if(shadmod.spirv.m_Disassembly.empty())
|
||||
shadmod.spirv.Disassemble();
|
||||
|
||||
shad->second.refl.Disassembly = shadmod.spirv.m_Disassembly;
|
||||
}
|
||||
|
||||
return &shad->second.refl;
|
||||
}
|
||||
|
||||
void VulkanReplay::PickPixel(ResourceId texture, uint32_t x, uint32_t y, uint32_t sliceFace, uint32_t mip, uint32_t sample, float pixel[4])
|
||||
@@ -1324,122 +1474,8 @@ void VulkanReplay::FileChanged()
|
||||
{
|
||||
}
|
||||
|
||||
FetchTexture VulkanReplay::GetTexture(ResourceId id)
|
||||
{
|
||||
VulkanCreationInfo::Image &iminfo = m_pDriver->m_CreationInfo.m_Image[id];
|
||||
|
||||
FetchTexture ret;
|
||||
ret.ID = m_pDriver->GetResourceManager()->GetOriginalID(id);
|
||||
ret.arraysize = iminfo.arraySize;
|
||||
ret.creationFlags = iminfo.creationFlags;
|
||||
ret.cubemap = iminfo.cube;
|
||||
ret.width = iminfo.extent.width;
|
||||
ret.height = iminfo.extent.height;
|
||||
ret.depth = iminfo.extent.depth;
|
||||
ret.mips = iminfo.mipLevels;
|
||||
ret.numSubresources = ret.mips*ret.arraysize;
|
||||
|
||||
ret.byteSize = 0;
|
||||
for(uint32_t s=0; s < ret.mips; s++)
|
||||
ret.byteSize += GetByteSize(ret.width, ret.height, ret.depth, iminfo.format, s);
|
||||
ret.byteSize *= ret.arraysize;
|
||||
|
||||
ret.msQual = 0;
|
||||
ret.msSamp = iminfo.samples;
|
||||
|
||||
ret.format = MakeResourceFormat(iminfo.format);
|
||||
|
||||
switch(iminfo.type)
|
||||
{
|
||||
case VK_IMAGE_TYPE_1D:
|
||||
ret.resType = iminfo.arraySize > 1 ? eResType_Texture1DArray : eResType_Texture1D;
|
||||
ret.dimension = 1;
|
||||
break;
|
||||
case VK_IMAGE_TYPE_2D:
|
||||
if(ret.msSamp > 1) ret.resType = iminfo.arraySize > 1 ? eResType_Texture2DMSArray : eResType_Texture2DMS;
|
||||
else if(ret.cubemap) ret.resType = iminfo.arraySize > 6 ? eResType_TextureCubeArray : eResType_TextureCube;
|
||||
else ret.resType = iminfo.arraySize > 1 ? eResType_Texture2DArray : eResType_Texture2D;
|
||||
ret.dimension = 2;
|
||||
break;
|
||||
case VK_IMAGE_TYPE_3D:
|
||||
ret.resType = eResType_Texture3D;
|
||||
ret.dimension = 3;
|
||||
break;
|
||||
default:
|
||||
RDCERR("Unexpected image type");
|
||||
break;
|
||||
}
|
||||
|
||||
ret.customName = true;
|
||||
ret.name = m_pDriver->m_CreationInfo.m_Names[id];
|
||||
if(ret.name.count == 0)
|
||||
{
|
||||
ret.customName = false;
|
||||
|
||||
const char *suffix = "";
|
||||
const char *ms = "";
|
||||
|
||||
if(ret.msSamp > 1)
|
||||
ms = "MS";
|
||||
|
||||
if(ret.creationFlags & eTextureCreate_RTV)
|
||||
suffix = " RTV";
|
||||
if(ret.creationFlags & eTextureCreate_DSV)
|
||||
suffix = " DSV";
|
||||
|
||||
if(ret.cubemap)
|
||||
{
|
||||
if(ret.arraysize > 6)
|
||||
ret.name = StringFormat::Fmt("TextureCube%sArray%s %llu", ms, suffix, ret.ID);
|
||||
else
|
||||
ret.name = StringFormat::Fmt("TextureCube%s%s %llu", ms, suffix, ret.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ret.arraysize > 1)
|
||||
ret.name = StringFormat::Fmt("Texture%dD%sArray%s %llu", ret.dimension, ms, suffix, ret.ID);
|
||||
else
|
||||
ret.name = StringFormat::Fmt("Texture%dD%s%s %llu", ret.dimension, ms, suffix, ret.ID);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FetchBuffer VulkanReplay::GetBuffer(ResourceId id)
|
||||
{
|
||||
RDCUNIMPLEMENTED("GetBuffer");
|
||||
return FetchBuffer();
|
||||
}
|
||||
|
||||
ShaderReflection *VulkanReplay::GetShader(ResourceId id)
|
||||
{
|
||||
auto shad = m_pDriver->m_CreationInfo.m_Shader.find(id);
|
||||
|
||||
if(shad == m_pDriver->m_CreationInfo.m_Shader.end())
|
||||
{
|
||||
RDCERR("Can't get shader details");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// disassemble lazily on demand
|
||||
if(shad->second.refl.Disassembly.count == 0)
|
||||
{
|
||||
auto &shadmod = m_pDriver->m_CreationInfo.m_ShaderModule[shad->second.module];
|
||||
|
||||
if(shadmod.spirv.m_Disassembly.empty())
|
||||
shadmod.spirv.Disassemble();
|
||||
|
||||
shad->second.refl.Disassembly = shadmod.spirv.m_Disassembly;
|
||||
}
|
||||
|
||||
return &shad->second.refl;
|
||||
}
|
||||
|
||||
void VulkanReplay::SavePipelineState()
|
||||
{
|
||||
VULKANNOTIMP("SavePipelineState");
|
||||
|
||||
{
|
||||
const WrappedVulkan::PartialReplayData::StateVector &state = m_pDriver->m_PartialReplayData.state;
|
||||
VulkanCreationInfo &c = m_pDriver->m_CreationInfo;
|
||||
|
||||
Reference in New Issue
Block a user