[Vulkan] Do not set any blend attachments with depth blits
This commit is contained in:
parent
554d333299
commit
8d7b8c2f82
|
@ -265,7 +265,8 @@ void Blitter::BlitTexture2D(VkCommandBuffer command_buffer, VkFence fence,
|
||||||
|
|
||||||
// Acquire a pipeline.
|
// Acquire a pipeline.
|
||||||
auto pipeline =
|
auto pipeline =
|
||||||
GetPipeline(render_pass, color_or_depth ? blit_color_ : blit_depth_);
|
GetPipeline(render_pass, color_or_depth ? blit_color_ : blit_depth_,
|
||||||
|
color_or_depth);
|
||||||
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
pipeline);
|
pipeline);
|
||||||
|
|
||||||
|
@ -354,14 +355,16 @@ VkRenderPass Blitter::GetRenderPass(VkFormat format, bool color_or_depth) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline Blitter::GetPipeline(VkRenderPass render_pass,
|
VkPipeline Blitter::GetPipeline(VkRenderPass render_pass,
|
||||||
VkShaderModule frag_shader) {
|
VkShaderModule frag_shader,
|
||||||
|
bool color_or_depth) {
|
||||||
auto it = pipelines_.find(std::make_pair(render_pass, frag_shader));
|
auto it = pipelines_.find(std::make_pair(render_pass, frag_shader));
|
||||||
if (it != pipelines_.end()) {
|
if (it != pipelines_.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and cache the pipeline.
|
// Create and cache the pipeline.
|
||||||
VkPipeline pipeline = CreatePipeline(render_pass, frag_shader);
|
VkPipeline pipeline =
|
||||||
|
CreatePipeline(render_pass, frag_shader, color_or_depth);
|
||||||
if (pipeline) {
|
if (pipeline) {
|
||||||
pipelines_[std::make_pair(render_pass, frag_shader)] = pipeline;
|
pipelines_[std::make_pair(render_pass, frag_shader)] = pipeline;
|
||||||
}
|
}
|
||||||
|
@ -378,12 +381,14 @@ VkRenderPass Blitter::CreateRenderPass(VkFormat output_format,
|
||||||
attachments[0].flags = 0;
|
attachments[0].flags = 0;
|
||||||
attachments[0].format = output_format;
|
attachments[0].format = output_format;
|
||||||
attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
|
attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
attachments[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
attachments[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
attachments[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
|
attachments[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
attachments[0].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
attachments[0].initialLayout =
|
||||||
attachments[0].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
color_or_depth ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
||||||
|
: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||||
|
attachments[0].finalLayout = attachments[0].initialLayout;
|
||||||
|
|
||||||
VkAttachmentReference attach_refs[1];
|
VkAttachmentReference attach_refs[1];
|
||||||
attach_refs[0].attachment = 0;
|
attach_refs[0].attachment = 0;
|
||||||
|
@ -426,7 +431,8 @@ VkRenderPass Blitter::CreateRenderPass(VkFormat output_format,
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline Blitter::CreatePipeline(VkRenderPass render_pass,
|
VkPipeline Blitter::CreatePipeline(VkRenderPass render_pass,
|
||||||
VkShaderModule frag_shader) {
|
VkShaderModule frag_shader,
|
||||||
|
bool color_or_depth) {
|
||||||
VkResult result = VK_SUCCESS;
|
VkResult result = VK_SUCCESS;
|
||||||
|
|
||||||
// Pipeline
|
// Pipeline
|
||||||
|
@ -530,7 +536,9 @@ VkPipeline Blitter::CreatePipeline(VkRenderPass render_pass,
|
||||||
blend_info.flags = 0;
|
blend_info.flags = 0;
|
||||||
blend_info.logicOpEnable = VK_FALSE;
|
blend_info.logicOpEnable = VK_FALSE;
|
||||||
blend_info.logicOp = VK_LOGIC_OP_NO_OP;
|
blend_info.logicOp = VK_LOGIC_OP_NO_OP;
|
||||||
|
|
||||||
VkPipelineColorBlendAttachmentState blend_attachments[1];
|
VkPipelineColorBlendAttachmentState blend_attachments[1];
|
||||||
|
if (color_or_depth) {
|
||||||
blend_attachments[0].blendEnable = VK_FALSE;
|
blend_attachments[0].blendEnable = VK_FALSE;
|
||||||
blend_attachments[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
blend_attachments[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
||||||
blend_attachments[0].dstColorBlendFactor = VK_BLEND_FACTOR_ZERO;
|
blend_attachments[0].dstColorBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||||
|
@ -539,9 +547,15 @@ VkPipeline Blitter::CreatePipeline(VkRenderPass render_pass,
|
||||||
blend_attachments[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
blend_attachments[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||||
blend_attachments[0].alphaBlendOp = VK_BLEND_OP_ADD;
|
blend_attachments[0].alphaBlendOp = VK_BLEND_OP_ADD;
|
||||||
blend_attachments[0].colorWriteMask = 0xF;
|
blend_attachments[0].colorWriteMask = 0xF;
|
||||||
|
|
||||||
blend_info.attachmentCount =
|
blend_info.attachmentCount =
|
||||||
static_cast<uint32_t>(xe::countof(blend_attachments));
|
static_cast<uint32_t>(xe::countof(blend_attachments));
|
||||||
blend_info.pAttachments = blend_attachments;
|
blend_info.pAttachments = blend_attachments;
|
||||||
|
} else {
|
||||||
|
blend_info.attachmentCount = 0;
|
||||||
|
blend_info.pAttachments = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::memset(blend_info.blendConstants, 0, sizeof(blend_info.blendConstants));
|
std::memset(blend_info.blendConstants, 0, sizeof(blend_info.blendConstants));
|
||||||
pipeline_info.pColorBlendState = &blend_info;
|
pipeline_info.pColorBlendState = &blend_info;
|
||||||
VkPipelineDynamicStateCreateInfo dynamic_state_info;
|
VkPipelineDynamicStateCreateInfo dynamic_state_info;
|
||||||
|
|
|
@ -63,10 +63,11 @@ class Blitter {
|
||||||
int swap; // 0x1C
|
int swap; // 0x1C
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPipeline GetPipeline(VkRenderPass render_pass, VkShaderModule frag_shader);
|
VkPipeline GetPipeline(VkRenderPass render_pass, VkShaderModule frag_shader,
|
||||||
|
bool color_or_depth);
|
||||||
VkRenderPass CreateRenderPass(VkFormat output_format, bool color_or_depth);
|
VkRenderPass CreateRenderPass(VkFormat output_format, bool color_or_depth);
|
||||||
VkPipeline CreatePipeline(VkRenderPass render_pass,
|
VkPipeline CreatePipeline(VkRenderPass render_pass,
|
||||||
VkShaderModule frag_shader);
|
VkShaderModule frag_shader, bool color_or_depth);
|
||||||
|
|
||||||
std::unique_ptr<DescriptorPool> descriptor_pool_ = nullptr;
|
std::unique_ptr<DescriptorPool> descriptor_pool_ = nullptr;
|
||||||
VulkanDevice* device_ = nullptr;
|
VulkanDevice* device_ = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue