mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-13 10:11:02 +00:00
Vk pixel history: unbound fragment shader
Add support for unbound fragment shader.
This commit is contained in:
committed by
Baldur Karlsson
parent
727ddfc672
commit
f8c5c2878b
@@ -49,12 +49,13 @@ enum
|
||||
TestEnabled_FragmentDiscard = 1 << 6,
|
||||
|
||||
Blending_Enabled = 1 << 7,
|
||||
TestMustFail_Culling = 1 << 8,
|
||||
TestMustFail_Scissor = 1 << 9,
|
||||
TestMustPass_Scissor = 1 << 10,
|
||||
TestMustFail_DepthTesting = 1 << 11,
|
||||
TestMustFail_StencilTesting = 1 << 12,
|
||||
TestMustFail_SampleMask = 1 << 13,
|
||||
UnboundFragmentShader = 1 << 8,
|
||||
TestMustFail_Culling = 1 << 9,
|
||||
TestMustFail_Scissor = 1 << 10,
|
||||
TestMustPass_Scissor = 1 << 11,
|
||||
TestMustFail_DepthTesting = 1 << 12,
|
||||
TestMustFail_StencilTesting = 1 << 13,
|
||||
TestMustFail_SampleMask = 1 << 14,
|
||||
};
|
||||
|
||||
struct CopyPixelParams
|
||||
@@ -1480,6 +1481,9 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if(p.shaders[StageIndex(VK_SHADER_STAGE_FRAGMENT_BIT)].module == ResourceId())
|
||||
flags |= UnboundFragmentShader;
|
||||
|
||||
// Samples
|
||||
{
|
||||
// TODO: figure out if we always need to check this.
|
||||
@@ -2139,14 +2143,27 @@ struct VulkanPixelHistoryPerFragmentCallback : VulkanPixelHistoryCallback
|
||||
}
|
||||
|
||||
// Output the primitive ID.
|
||||
VkPipelineShaderStageCreateInfo stageCI = {};
|
||||
stageCI.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
stageCI.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
stageCI.module = m_ShaderCache->GetPrimitiveIdShader(framebufferIndex);
|
||||
stageCI.pName = "main";
|
||||
bool fsFound = false;
|
||||
for(uint32_t i = 0; i < pipeCreateInfo.stageCount; i++)
|
||||
{
|
||||
if(stages[i].stage == VK_SHADER_STAGE_FRAGMENT_BIT)
|
||||
{
|
||||
stages[i].module = m_ShaderCache->GetPrimitiveIdShader(framebufferIndex);
|
||||
stages[i].pName = "main";
|
||||
stages[i] = stageCI;
|
||||
fsFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!fsFound)
|
||||
{
|
||||
stages.push_back(stageCI);
|
||||
pipeCreateInfo.stageCount = (uint32_t)stages.size();
|
||||
pipeCreateInfo.pStages = stages.data();
|
||||
}
|
||||
|
||||
vkr = m_pDriver->vkCreateGraphicsPipelines(m_pDriver->GetDev(), VK_NULL_HANDLE, 1,
|
||||
&pipeCreateInfo, NULL, &pipes.primitiveIdPipe);
|
||||
@@ -2831,6 +2848,8 @@ rdcarray<PixelModification> VulkanReplay::PixelHistory(rdcarray<EventUsage> even
|
||||
mod.scissorClipped = true;
|
||||
if(flags & TestMustFail_SampleMask)
|
||||
mod.sampleMasked = true;
|
||||
if(flags & UnboundFragmentShader)
|
||||
mod.unboundPS = true;
|
||||
|
||||
UpdateTestsFailed(tfCb, eventId, flags, mod);
|
||||
}
|
||||
|
||||
@@ -221,10 +221,12 @@ void main()
|
||||
vkh::vertexAttr(2, 0, DefaultA2V, uv),
|
||||
};
|
||||
|
||||
pipeCreateInfo.stages = {
|
||||
CompileShaderModule(common + vertex, ShaderLang::glsl, ShaderStage::vert, "main"),
|
||||
CompileShaderModule(common + pixel, ShaderLang::glsl, ShaderStage::frag, "main"),
|
||||
};
|
||||
VkPipelineShaderStageCreateInfo vertexShader =
|
||||
CompileShaderModule(common + vertex, ShaderLang::glsl, ShaderStage::vert, "main");
|
||||
VkPipelineShaderStageCreateInfo fragmentShader =
|
||||
CompileShaderModule(common + pixel, ShaderLang::glsl, ShaderStage::frag, "main");
|
||||
|
||||
pipeCreateInfo.stages = {vertexShader, fragmentShader};
|
||||
|
||||
pipeCreateInfo.rasterizationState.depthClampEnable = VK_FALSE;
|
||||
pipeCreateInfo.rasterizationState.cullMode = VK_CULL_MODE_BACK_BIT;
|
||||
@@ -249,6 +251,10 @@ void main()
|
||||
pipeCreateInfo.depthStencilState.stencilTestEnable = VK_FALSE;
|
||||
VkPipeline backgroundPipe = createGraphicsPipeline(pipeCreateInfo);
|
||||
|
||||
pipeCreateInfo.stages = {vertexShader};
|
||||
VkPipeline noFsPipe = createGraphicsPipeline(pipeCreateInfo);
|
||||
pipeCreateInfo.stages = {vertexShader, fragmentShader};
|
||||
|
||||
pipeCreateInfo.depthStencilState.stencilTestEnable = VK_TRUE;
|
||||
pipeCreateInfo.depthStencilState.front.compareOp = VK_COMPARE_OP_GREATER;
|
||||
VkPipeline pipe = createGraphicsPipeline(pipeCreateInfo);
|
||||
@@ -319,6 +325,10 @@ void main()
|
||||
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, depthWritePipe);
|
||||
vkCmdDraw(cmd, 3, 1, 0, 0);
|
||||
|
||||
setMarker(cmd, "Unbound Fragment Shader");
|
||||
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, noFsPipe);
|
||||
vkCmdDraw(cmd, 3, 1, 3, 0);
|
||||
|
||||
setMarker(cmd, "Stencil Write");
|
||||
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, stencilWritePipe);
|
||||
vkCmdDraw(cmd, 3, 1, 3, 0);
|
||||
|
||||
@@ -12,6 +12,7 @@ def shader_out_col(x): return value_selector(x.shaderOut.col)
|
||||
def pre_mod_col(x): return value_selector(x.preMod.col)
|
||||
def post_mod_col(x): return value_selector(x.postMod.col)
|
||||
def primitive_id(x): return x.primitiveID
|
||||
def unboundPS(x): return x.unboundPS
|
||||
|
||||
class VK_Pixel_History(rdtest.TestCase):
|
||||
demos_test_name = 'VK_Pixel_History_Test'
|
||||
@@ -47,6 +48,7 @@ class VK_Pixel_History(rdtest.TestCase):
|
||||
begin_renderpass_eid = self.find_draw("Begin RenderPass").next.eventId
|
||||
depth_write_eid = self.find_draw("Depth Write").next.eventId
|
||||
stencil_write_eid = self.find_draw("Stencil Write").next.eventId
|
||||
unbound_fs_eid = self.find_draw("Unbound Fragment Shader").next.eventId
|
||||
background_eid = self.find_draw("Background").next.eventId
|
||||
cull_eid = self.find_draw("Cull Front").next.eventId
|
||||
test_eid = self.find_draw("Test").next.eventId
|
||||
@@ -57,6 +59,7 @@ class VK_Pixel_History(rdtest.TestCase):
|
||||
modifs: List[rd.PixelModification] = self.controller.PixelHistory(tex, x, y, sub, rt.typeCast)
|
||||
events = [
|
||||
[[event_id, begin_renderpass_eid], [passed, True]],
|
||||
[[event_id, unbound_fs_eid], [passed, True], [unboundPS, True], [primitive_id, 0]],
|
||||
[[event_id, stencil_write_eid], [passed, True]],
|
||||
[[event_id, background_eid], [depth_test_failed, True], [post_mod_col, (1.0, 0.0, 0.0, 1.0)]],
|
||||
[[event_id, test_eid], [stencil_test_failed, True]],
|
||||
|
||||
Reference in New Issue
Block a user