Remove hardcoded display of backbuffer, instead display specified tex

* Currently will only work for 2D textures though
This commit is contained in:
baldurk
2015-09-23 17:59:41 +02:00
parent 26d99bf7bb
commit db74a097dd
5 changed files with 65 additions and 82 deletions
+1 -20
View File
@@ -659,28 +659,9 @@ void WrappedVulkan::ReadLogInitialisation()
m_PhysicalReplayData[m_SwapPhysDevice].cmd != VK_NULL_HANDLE &&
m_PhysicalReplayData[m_SwapPhysDevice].cmdpool != VK_NULL_HANDLE);
VkImageView fakeBBImView;
{
VkImageViewCreateInfo bbviewInfo = {
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, NULL,
Unwrap(m_FakeBBIm), VK_IMAGE_VIEW_TYPE_2D,
(VkFormat)m_FakeBBFmt.rawType,
{ VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, VK_CHANNEL_SWIZZLE_B, VK_CHANNEL_SWIZZLE_A },
{ VK_IMAGE_ASPECT_COLOR, 0, 1, 0, 1, }
};
// VKTODOMED used for texture display, but eventually will have to be created on the fly
// for whichever image we're viewing (and cached), not specifically created here.
VkResult vkr = ObjDisp(GetDev())->CreateImageView(Unwrap(GetDev()), &bbviewInfo, &fakeBBImView);
RDCASSERT(vkr == VK_SUCCESS);
GetResourceManager()->WrapResource(Unwrap(GetDev()), fakeBBImView);
}
// VKTODOLOW maybe better place to put this?
// VKTODOLOW leaking debug manager
m_PhysicalReplayData[m_SwapPhysDevice].debugMan = new VulkanDebugManager(this, GetDev(), fakeBBImView);
m_PhysicalReplayData[m_SwapPhysDevice].debugMan = new VulkanDebugManager(this, GetDev());
}
void WrappedVulkan::ContextReplayLog(LogState readType, uint32_t startEventID, uint32_t endEventID, bool partial)
+14 -34
View File
@@ -165,7 +165,7 @@ void VulkanDebugManager::UBO::Unmap(const VkLayerDispatchTable *vt, VkDevice dev
vt->UnmapMemory(Unwrap(dev), Unwrap(mem));
}
VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkImageView fakeBBView)
VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev)
{
// VKTODOLOW needs tidy up - isn't scalable. Needs more classes like UBO above.
@@ -176,8 +176,6 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm
m_LinearSampler = VK_NULL_HANDLE;
m_PointSampler = VK_NULL_HANDLE;
m_FakeBBImView = fakeBBView;
m_CheckerboardDescSetLayout = VK_NULL_HANDLE;
m_CheckerboardPipeLayout = VK_NULL_HANDLE;
m_CheckerboardDescSet = VK_NULL_HANDLE;
@@ -696,7 +694,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm
m_TextGlyphUBO.Unmap(vt, dev);
}
VkDescriptorInfo desc[7];
VkDescriptorInfo desc[6];
RDCEraseEl(desc);
// checkerboard
@@ -704,17 +702,15 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm
// tex display
desc[1].bufferView = Unwrap(m_TexDisplayUBO.view);
desc[2].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
desc[2].imageView = Unwrap(m_FakeBBImView);
desc[2].sampler = Unwrap(m_LinearSampler);
// image descriptor is updated right before rendering
// text
desc[3].bufferView = Unwrap(m_TextGeneralUBO.view);
desc[4].bufferView = Unwrap(m_TextGlyphUBO.view);
desc[5].bufferView = Unwrap(m_TextStringUBO.view);
desc[6].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
desc[6].imageView = Unwrap(m_TextAtlasView);
desc[6].sampler = Unwrap(m_LinearSampler);
desc[2].bufferView = Unwrap(m_TextGeneralUBO.view);
desc[3].bufferView = Unwrap(m_TextGlyphUBO.view);
desc[4].bufferView = Unwrap(m_TextStringUBO.view);
desc[5].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
desc[5].imageView = Unwrap(m_TextAtlasView);
desc[5].sampler = Unwrap(m_LinearSampler);
VkWriteDescriptorSet writeSet[] = {
{
@@ -727,32 +723,23 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm
},
{
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, NULL,
Unwrap(m_TextDescSet), 0, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &desc[3]
Unwrap(m_TextDescSet), 0, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &desc[2]
},
{
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, NULL,
Unwrap(m_TextDescSet), 1, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &desc[4]
Unwrap(m_TextDescSet), 1, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &desc[3]
},
{
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, NULL,
Unwrap(m_TextDescSet), 2, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &desc[5]
Unwrap(m_TextDescSet), 2, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &desc[4]
},
{
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, NULL,
Unwrap(m_TextDescSet), 3, 0, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &desc[6]
},
// this one is last so that we can skip it if we don't have m_FakeBBImView
{
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, NULL,
Unwrap(m_TexDisplayDescSet), 1, 0, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &desc[2]
Unwrap(m_TextDescSet), 3, 0, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &desc[5]
},
};
uint32_t writeCount = (uint32_t)ARRAY_COUNT(writeSet);
if(m_FakeBBImView == VK_NULL_HANDLE)
writeCount--;
vkr = vt->UpdateDescriptorSets(Unwrap(dev), writeCount, writeSet, 0, NULL);
vkr = vt->UpdateDescriptorSets(Unwrap(dev), ARRAY_COUNT(writeSet), writeSet, 0, NULL);
RDCASSERT(vkr == VK_SUCCESS);
}
@@ -805,13 +792,6 @@ VulkanDebugManager::~VulkanDebugManager()
VKMGR()->ReleaseWrappedResource(m_PointSampler);
}
if(m_FakeBBImView != VK_NULL_HANDLE)
{
vkr = vt->DestroyImageView(Unwrap(dev), Unwrap(m_FakeBBImView));
RDCASSERT(vkr == VK_SUCCESS);
VKMGR()->ReleaseWrappedResource(m_FakeBBImView);
}
if(m_CheckerboardDescSetLayout != VK_NULL_HANDLE)
{
vkr = vt->DestroyDescriptorSetLayout(Unwrap(dev), Unwrap(m_CheckerboardDescSetLayout));
+1 -3
View File
@@ -43,7 +43,7 @@ struct TextPrintState
class VulkanDebugManager
{
public:
VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkImageView fakeBBView);
VulkanDebugManager(WrappedVulkan *driver, VkDevice dev);
~VulkanDebugManager();
void RenderText(const TextPrintState &textstate, float x, float y, const char *fmt, ...);
@@ -69,8 +69,6 @@ class VulkanDebugManager
VkDynamicDepthStencilState m_DynamicDSStateDisabled;
VkSampler m_LinearSampler, m_PointSampler;
VkImageView m_FakeBBImView;
VkDescriptorSetLayout m_CheckerboardDescSetLayout;
VkPipelineLayout m_CheckerboardPipeLayout;
VkDescriptorSet m_CheckerboardDescSet;
+48 -24
View File
@@ -486,7 +486,7 @@ vector<ResourceId> VulkanReplay::GetTextures()
ResourceFormat fakeBBfmt;
m_pDriver->GetFakeBB(id, fakeBBIm, fakeBBext, fakeBBfmt);
texs.push_back(id);
texs.push_back(m_pDriver->GetResourceManager()->GetLiveID(id));
return texs;
}
@@ -632,17 +632,36 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
OutputWindow &outw = it->second;
ResourceId resid;
VkImage fakeBBIm = VK_NULL_HANDLE;
VkExtent3D fakeBBext;
ResourceFormat fakeBBfmt;
m_pDriver->GetFakeBB(resid, fakeBBIm, fakeBBext, fakeBBfmt);
VkDevice dev = m_pDriver->GetDev();
VkCmdBuffer cmd = m_pDriver->GetCmd();
VkQueue q = m_pDriver->GetQ();
const VkLayerDispatchTable *vt = ObjDisp(dev);
const ImgState &iminfo = m_pDriver->m_ImageInfo[cfg.texid];
VkImage liveIm = m_pDriver->GetResourceManager()->GetCurrentHandle<VkImage>(cfg.texid);
// VKTODOMED handle multiple subresources with different layouts etc
VkImageLayout origLayout = iminfo.subresourceStates[0].state;
VkImageView liveImView = VK_NULL_HANDLE;
// VKTODOLOW this view should be cached
{
VkImageViewCreateInfo viewInfo = {
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, NULL,
Unwrap(liveIm), VK_IMAGE_VIEW_TYPE_2D,
iminfo.format,
{ VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, VK_CHANNEL_SWIZZLE_B, VK_CHANNEL_SWIZZLE_A },
{ VK_IMAGE_ASPECT_COLOR, 0, 1, 0, 1, }
};
// VKTODOMED used for texture display, but eventually will have to be created on the fly
// for whichever image we're viewing (and cached), not specifically created here.
VkResult vkr = vt->CreateImageView(Unwrap(dev), &viewInfo, &liveImView);
RDCASSERT(vkr == VK_SUCCESS);
m_pDriver->GetResourceManager()->WrapResource(Unwrap(dev), liveImView);
}
// VKTODOHIGH once we stop doing DeviceWaitIdle/QueueWaitIdle all over, this
// needs to be ring-buffered
displayuniforms *data = (displayuniforms *)GetDebugManager()->m_TexDisplayUBO.Map(vt, dev);
@@ -657,10 +676,10 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
data->Scale = cfg.scale;
data->HDRMul = -1.0f;
int32_t tex_x = fakeBBext.width;
int32_t tex_y = fakeBBext.height;
int32_t tex_z = fakeBBext.depth;
int32_t tex_x = iminfo.extent.width;
int32_t tex_y = iminfo.extent.height;
int32_t tex_z = iminfo.extent.depth;
if(cfg.scale <= 0.0f)
{
float xscale = float(outw.width)/float(tex_x);
@@ -727,7 +746,7 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
VkDescriptorInfo desc = {0};
desc.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
desc.imageView = Unwrap(GetDebugManager()->m_FakeBBImView);
desc.imageView = Unwrap(liveImView);
desc.sampler = Unwrap(GetDebugManager()->m_PointSampler);
if(cfg.mip == 0 && cfg.scale < 1.0f)
desc.sampler = Unwrap(GetDebugManager()->m_LinearSampler);
@@ -740,11 +759,10 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
VkResult vkr = vt->UpdateDescriptorSets(Unwrap(dev), 1, &writeSet, 0, NULL);
RDCASSERT(vkr == VK_SUCCESS);
// VKTODOHIGH find out the actual current image state
VkImageMemoryBarrier fakeTrans = {
VkImageMemoryBarrier srcimTrans = {
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, NULL,
0, 0, VK_IMAGE_LAYOUT_PRESENT_SOURCE_WSI, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
0, 0, Unwrap(fakeBBIm),
0, 0, origLayout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
0, 0, Unwrap(liveIm),
{ VK_IMAGE_ASPECT_COLOR, 0, 1, 0, 1 } };
VkCmdBufferBeginInfo beginInfo = { VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO, NULL, VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT | VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT };
@@ -754,10 +772,10 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
vkr = vt->BeginCommandBuffer(Unwrap(cmd), &beginInfo);
RDCASSERT(vkr == VK_SUCCESS);
void *barrier = (void *)&fakeTrans;
void *barrier = (void *)&srcimTrans;
vt->CmdPipelineBarrier(Unwrap(cmd), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, false, 1, &barrier);
fakeTrans.oldLayout = fakeTrans.newLayout;
srcimTrans.oldLayout = srcimTrans.newLayout;
{
VkClearValue clearval = {0};
@@ -782,7 +800,7 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
vt->CmdEndRenderPass(Unwrap(cmd));
}
fakeTrans.newLayout = VK_IMAGE_LAYOUT_PRESENT_SOURCE_WSI;
srcimTrans.newLayout = origLayout;
vt->CmdPipelineBarrier(Unwrap(cmd), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, false, 1, &barrier);
vt->EndCommandBuffer(Unwrap(cmd));
@@ -794,6 +812,10 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
// ring-buffer style
vt->QueueWaitIdle(Unwrap(q));
vkr = vt->DestroyImageView(Unwrap(dev), Unwrap(liveImView));
RDCASSERT(vkr == VK_SUCCESS);
VKMGR()->ReleaseWrappedResource(liveImView);
return false;
}
@@ -1133,24 +1155,26 @@ FetchTexture VulkanReplay::GetTexture(ResourceId id)
VkExtent3D fakeBBext;
ResourceFormat fakeBBfmt;
m_pDriver->GetFakeBB(resid, fakeBBIm, fakeBBext, fakeBBfmt);
const ImgState &iminfo = m_pDriver->m_ImageInfo[id];
FetchTexture ret;
ret.arraysize = 1;
ret.byteSize = fakeBBext.width*fakeBBext.height*4;
ret.byteSize = iminfo.extent.width*iminfo.extent.height*4;
ret.creationFlags = eTextureCreate_SwapBuffer|eTextureCreate_SRV|eTextureCreate_RTV;
ret.cubemap = false;
ret.customName = false;
ret.depth = 1;
ret.width = fakeBBext.width;
ret.height = fakeBBext.height;
ret.width = iminfo.extent.width;
ret.height = iminfo.extent.height;
ret.dimension = 2;
ret.ID = id;
ret.ID = m_pDriver->GetResourceManager()->GetOriginalID(id);
ret.mips = 1;
ret.msQual = 0;
ret.msSamp = 1;
ret.name = "WSI Presentable Image";
ret.numSubresources = 1;
ret.format = fakeBBfmt;
ret.format = MakeResourceFormat(iminfo.format);
return ret;
}
@@ -456,7 +456,7 @@ VkResult WrappedVulkan::vkCreateDevice(
// not have this 'current swap chain device' thing.
m_SwapPhysDevice = (int)i;
m_PhysicalReplayData[i].debugMan = new VulkanDebugManager(this, *pDevice, VK_NULL_HANDLE);
m_PhysicalReplayData[i].debugMan = new VulkanDebugManager(this, *pDevice);
break;
}
}