|
@@ -16,8 +16,14 @@
|
|
|
|
|
|
|
|
namespace bs
|
|
namespace bs
|
|
|
{
|
|
{
|
|
|
|
|
+ VulkanPipeline::VulkanPipeline(VulkanResourceManager* owner, VkPipeline pipeline,
|
|
|
|
|
+ const std::array<bool, BS_MAX_MULTIPLE_RENDER_TARGETS>& colorReadOnly, bool depthStencilReadOnly)
|
|
|
|
|
+ : VulkanResource(owner, true), mPipeline(pipeline), mReadOnlyColor(colorReadOnly)
|
|
|
|
|
+ , mReadOnlyDepthStencil(depthStencilReadOnly)
|
|
|
|
|
+ { }
|
|
|
|
|
+
|
|
|
VulkanPipeline::VulkanPipeline(VulkanResourceManager* owner, VkPipeline pipeline)
|
|
VulkanPipeline::VulkanPipeline(VulkanResourceManager* owner, VkPipeline pipeline)
|
|
|
- :VulkanResource(owner, true), mPipeline(pipeline)
|
|
|
|
|
|
|
+ : VulkanResource(owner, true), mPipeline(pipeline), mReadOnlyColor(), mReadOnlyDepthStencil(false)
|
|
|
{ }
|
|
{ }
|
|
|
|
|
|
|
|
VulkanPipeline::~VulkanPipeline()
|
|
VulkanPipeline::~VulkanPipeline()
|
|
@@ -396,16 +402,41 @@ namespace bs
|
|
|
mPipelineInfo.layout = mPerDeviceData[deviceIdx].pipelineLayout;
|
|
mPipelineInfo.layout = mPerDeviceData[deviceIdx].pipelineLayout;
|
|
|
mPipelineInfo.pVertexInputState = vertexInput->getCreateInfo();
|
|
mPipelineInfo.pVertexInputState = vertexInput->getCreateInfo();
|
|
|
|
|
|
|
|
|
|
+ bool depthStencilReadOnly;
|
|
|
if (framebuffer->hasDepthAttachment())
|
|
if (framebuffer->hasDepthAttachment())
|
|
|
|
|
+ {
|
|
|
mPipelineInfo.pDepthStencilState = &mDepthStencilInfo;
|
|
mPipelineInfo.pDepthStencilState = &mDepthStencilInfo;
|
|
|
|
|
+
|
|
|
|
|
+ depthStencilReadOnly = !enableDepthWrites;
|
|
|
|
|
+ }
|
|
|
else
|
|
else
|
|
|
|
|
+ {
|
|
|
mPipelineInfo.pDepthStencilState = nullptr;
|
|
mPipelineInfo.pDepthStencilState = nullptr;
|
|
|
|
|
+ depthStencilReadOnly = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ std::array<bool, BS_MAX_MULTIPLE_RENDER_TARGETS> colorReadOnly;
|
|
|
if (framebuffer->getNumColorAttachments() > 0)
|
|
if (framebuffer->getNumColorAttachments() > 0)
|
|
|
|
|
+ {
|
|
|
mPipelineInfo.pColorBlendState = &mColorBlendStateInfo;
|
|
mPipelineInfo.pColorBlendState = &mColorBlendStateInfo;
|
|
|
|
|
+
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ VkPipelineColorBlendAttachmentState& blendState = mAttachmentBlendStates[i];
|
|
|
|
|
+ colorReadOnly[i] = blendState.colorWriteMask == 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
else
|
|
else
|
|
|
|
|
+ {
|
|
|
mPipelineInfo.pColorBlendState = nullptr;
|
|
mPipelineInfo.pColorBlendState = nullptr;
|
|
|
|
|
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ VkPipelineColorBlendAttachmentState& blendState = mAttachmentBlendStates[i];
|
|
|
|
|
+ colorReadOnly[i] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
std::pair<VkShaderStageFlagBits, GpuProgramCore*> stages[] =
|
|
std::pair<VkShaderStageFlagBits, GpuProgramCore*> stages[] =
|
|
|
{
|
|
{
|
|
|
{ VK_SHADER_STAGE_VERTEX_BIT, mData.vertexProgram.get() },
|
|
{ VK_SHADER_STAGE_VERTEX_BIT, mData.vertexProgram.get() },
|
|
@@ -451,7 +482,7 @@ namespace bs
|
|
|
mDepthStencilInfo.back.failOp = oldBackFailOp;
|
|
mDepthStencilInfo.back.failOp = oldBackFailOp;
|
|
|
mDepthStencilInfo.back.depthFailOp = oldBackZFailOp;
|
|
mDepthStencilInfo.back.depthFailOp = oldBackZFailOp;
|
|
|
|
|
|
|
|
- return device->getResourceManager().create<VulkanPipeline>(pipeline);
|
|
|
|
|
|
|
+ return device->getResourceManager().create<VulkanPipeline>(pipeline, colorReadOnly, depthStencilReadOnly);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
VulkanComputePipelineStateCore::VulkanComputePipelineStateCore(const SPtr<GpuProgramCore>& program,
|
|
VulkanComputePipelineStateCore::VulkanComputePipelineStateCore(const SPtr<GpuProgramCore>& program,
|