Set a compatible renderpass on graphics pipeline creation

This commit is contained in:
baldurk
2015-10-23 11:04:41 +02:00
parent b03a1df2fe
commit 944bad84b9
4 changed files with 68 additions and 8 deletions
+57 -1
View File
@@ -211,6 +211,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev)
m_TexDisplayNextSet = 0;
m_TexDisplayPipeline = VK_NULL_HANDLE;
m_TexDisplayBlendPipeline = VK_NULL_HANDLE;
m_TexDisplayF32Pipeline = VK_NULL_HANDLE;
RDCEraseEl(m_TexDisplayUBO);
m_TextDescSetLayout = VK_NULL_HANDLE;
@@ -502,6 +503,43 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev)
VKMGR()->WrapResource(Unwrap(dev), shader[i]);
}
VkRenderPass RGBA32RP, RGBA8RP; // compatible render passes for creating pipelines, either RGBA F32 or RGBA8
{
VkAttachmentDescription attDesc = {
VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION, NULL,
VK_FORMAT_R8G8B8A8_UNORM, 1,
VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_STORE_OP_STORE,
VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
};
VkAttachmentReference attRef = { 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL };
VkSubpassDescription sub = {
VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION, NULL,
VK_PIPELINE_BIND_POINT_GRAPHICS, 0,
0, NULL, // inputs
1, &attRef, // color
NULL, // resolve
{ VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_UNDEFINED }, // depth-stencil
0, NULL, // preserve
};
VkRenderPassCreateInfo rpinfo = {
VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, NULL,
1, &attDesc,
1, &sub,
0, NULL, // dependencies
};
vt->CreateRenderPass(Unwrap(dev), &rpinfo, &RGBA8RP);
attDesc.format = VK_FORMAT_R32G32B32A32_SFLOAT;
vt->CreateRenderPass(Unwrap(dev), &rpinfo, &RGBA32RP);
}
VkPipelineShaderStageCreateInfo stages[2] = {
{ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, NULL, VK_SHADER_STAGE_VERTEX, VK_NULL_HANDLE, NULL },
{ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, NULL, VK_SHADER_STAGE_FRAGMENT, VK_NULL_HANDLE, NULL },
@@ -574,7 +612,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev)
&dyn,
0, // flags
Unwrap(m_CheckerboardPipeLayout),
VK_NULL_HANDLE, // render pass
RGBA8RP,
0, // sub pass
VK_NULL_HANDLE, // base pipeline handle
0, // base pipeline index
@@ -598,6 +636,15 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev)
VKMGR()->WrapResource(Unwrap(dev), m_TexDisplayPipeline);
pipeInfo.renderPass = RGBA32RP;
vkr = vt->CreateGraphicsPipelines(Unwrap(dev), VK_NULL_HANDLE, 1, &pipeInfo, &m_TexDisplayF32Pipeline);
RDCASSERT(vkr == VK_SUCCESS);
VKMGR()->WrapResource(Unwrap(dev), m_TexDisplayF32Pipeline);
pipeInfo.renderPass = RGBA8RP;
attState.blendEnable = true;
attState.srcBlendColor = VK_BLEND_SRC_ALPHA;
attState.destBlendColor = VK_BLEND_ONE_MINUS_SRC_ALPHA;
@@ -648,6 +695,9 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev)
VKMGR()->WrapResource(Unwrap(dev), m_GenericPipeline);
vt->DestroyRenderPass(Unwrap(dev), RGBA32RP);
vt->DestroyRenderPass(Unwrap(dev), RGBA8RP);
for(size_t i=0; i < ARRAY_COUNT(module); i++)
{
vt->DestroyShader(Unwrap(dev), Unwrap(shader[i]));
@@ -1039,6 +1089,12 @@ VulkanDebugManager::~VulkanDebugManager()
VKMGR()->ReleaseWrappedResource(m_TexDisplayBlendPipeline);
}
if(m_TexDisplayF32Pipeline != VK_NULL_HANDLE)
{
vt->DestroyPipeline(Unwrap(dev), Unwrap(m_TexDisplayF32Pipeline));
VKMGR()->ReleaseWrappedResource(m_TexDisplayF32Pipeline);
}
m_CheckerboardUBO.Destroy(vt, dev);
m_TexDisplayUBO.Destroy(vt, dev);
+1 -1
View File
@@ -95,7 +95,7 @@ class VulkanDebugManager
VkPipelineLayout m_TexDisplayPipeLayout;
VkDescriptorSet m_TexDisplayDescSet[16]; // ring buffered to allow multiple texture renders between flushes
uint32_t m_TexDisplayNextSet;
VkPipeline m_TexDisplayPipeline, m_TexDisplayBlendPipeline;
VkPipeline m_TexDisplayPipeline, m_TexDisplayBlendPipeline, m_TexDisplayF32Pipeline;
GPUBuffer m_TexDisplayUBO;
VkDescriptorSet GetTexDisplayDescSet()
+9 -5
View File
@@ -562,7 +562,7 @@ void VulkanReplay::PickPixel(ResourceId texture, uint32_t x, uint32_t y, uint32_
1, &clearval,
};
RenderTextureInternal(texDisplay, rpbegin, false);
RenderTextureInternal(texDisplay, rpbegin, true);
}
VkDevice dev = m_pDriver->GetDev();
@@ -660,10 +660,10 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
1, &clearval,
};
return RenderTextureInternal(cfg, rpbegin, true);
return RenderTextureInternal(cfg, rpbegin, false);
}
bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginInfo rpbegin, bool blendAlpha)
bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginInfo rpbegin, bool f32render)
{
VkDevice dev = m_pDriver->GetDev();
VkCmdBuffer cmd = m_pDriver->GetNextCmd();
@@ -823,9 +823,13 @@ bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginIn
{
vt->CmdBeginRenderPass(Unwrap(cmd), &rpbegin, VK_RENDER_PASS_CONTENTS_INLINE);
bool doblend = !cfg.rawoutput && blendAlpha && cfg.CustomShader == ResourceId();
VkPipeline pipe = GetDebugManager()->m_TexDisplayPipeline;
if(f32render)
pipe = GetDebugManager()->m_TexDisplayF32Pipeline;
else if(!cfg.rawoutput && cfg.CustomShader == ResourceId())
pipe = GetDebugManager()->m_TexDisplayBlendPipeline;
vt->CmdBindPipeline(Unwrap(cmd), VK_PIPELINE_BIND_POINT_GRAPHICS, doblend ? Unwrap(GetDebugManager()->m_TexDisplayBlendPipeline) : Unwrap(GetDebugManager()->m_TexDisplayPipeline));
vt->CmdBindPipeline(Unwrap(cmd), VK_PIPELINE_BIND_POINT_GRAPHICS, Unwrap(pipe));
vt->CmdBindDescriptorSets(Unwrap(cmd), VK_PIPELINE_BIND_POINT_GRAPHICS, Unwrap(GetDebugManager()->m_TexDisplayPipeLayout), 0, 1, UnwrapPtr(descset), 1, &uboOffs);
VkViewport viewport = { 0.0f, 0.0f, (float)m_DebugWidth, (float)m_DebugHeight, 0.0f, 1.0f };
+1 -1
View File
@@ -215,7 +215,7 @@ class VulkanReplay : public IReplayDriver
WrappedVulkan *m_pDriver;
bool RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginInfo rpbegin, bool blendAlpha);
bool RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginInfo rpbegin, bool f32render);
void FillCBufferVariables(rdctype::array<ShaderConstant>, vector<ShaderVariable> &outvars, const vector<byte> &data, size_t &offset);