Optimize Vulkan Framebuffer when not using color blending
This commit is contained in:
@@ -338,6 +338,7 @@ void GPUContextVulkan::BeginRenderPass()
|
|||||||
framebufferKey.AttachmentCount = _rtCount;
|
framebufferKey.AttachmentCount = _rtCount;
|
||||||
RenderTargetLayoutVulkan layout;
|
RenderTargetLayoutVulkan layout;
|
||||||
layout.RTsCount = _rtCount;
|
layout.RTsCount = _rtCount;
|
||||||
|
layout.BlendEnable = _currentState && _currentState->BlendEnable;
|
||||||
layout.DepthFormat = _rtDepth ? _rtDepth->GetFormat() : PixelFormat::Unknown;
|
layout.DepthFormat = _rtDepth ? _rtDepth->GetFormat() : PixelFormat::Unknown;
|
||||||
for (int32 i = 0; i < GPU_MAX_RT_BINDED; i++)
|
for (int32 i = 0; i < GPU_MAX_RT_BINDED; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -427,6 +427,7 @@ uint32 GetHash(const RenderTargetLayoutVulkan& key)
|
|||||||
uint32 hash = (int32)key.MSAA * 11;
|
uint32 hash = (int32)key.MSAA * 11;
|
||||||
CombineHash(hash, (uint32)key.ReadDepth);
|
CombineHash(hash, (uint32)key.ReadDepth);
|
||||||
CombineHash(hash, (uint32)key.WriteDepth);
|
CombineHash(hash, (uint32)key.WriteDepth);
|
||||||
|
CombineHash(hash, (uint32)key.BlendEnable);
|
||||||
CombineHash(hash, (uint32)key.DepthFormat * 93473262);
|
CombineHash(hash, (uint32)key.DepthFormat * 93473262);
|
||||||
CombineHash(hash, key.RTsCount * 136);
|
CombineHash(hash, key.RTsCount * 136);
|
||||||
CombineHash(hash, key.Extent.width);
|
CombineHash(hash, key.Extent.width);
|
||||||
@@ -505,8 +506,7 @@ RenderPassVulkan::RenderPassVulkan(GPUDeviceVulkan* device, const RenderTargetLa
|
|||||||
attachment.flags = 0;
|
attachment.flags = 0;
|
||||||
attachment.format = RenderToolsVulkan::ToVulkanFormat(layout.RTVsFormats[i]);
|
attachment.format = RenderToolsVulkan::ToVulkanFormat(layout.RTVsFormats[i]);
|
||||||
attachment.samples = (VkSampleCountFlagBits)layout.MSAA;
|
attachment.samples = (VkSampleCountFlagBits)layout.MSAA;
|
||||||
//attachment.loadOp = currentBlendDesc->BlendEnable ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_DONT_CARE; // TODO: Only if any destination blend?
|
attachment.loadOp = layout.BlendEnable ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
attachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; // TODO: only load when using blend mode
|
|
||||||
attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ public:
|
|||||||
MSAALevel MSAA;
|
MSAALevel MSAA;
|
||||||
bool ReadDepth;
|
bool ReadDepth;
|
||||||
bool WriteDepth;
|
bool WriteDepth;
|
||||||
|
bool BlendEnable;
|
||||||
PixelFormat DepthFormat;
|
PixelFormat DepthFormat;
|
||||||
PixelFormat RTVsFormats[GPU_MAX_RT_BINDED];
|
PixelFormat RTVsFormats[GPU_MAX_RT_BINDED];
|
||||||
VkExtent2D Extent;
|
VkExtent2D Extent;
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ bool GPUPipelineStateVulkan::Init(const Description& desc)
|
|||||||
_desc.pRasterizationState = &_descRasterization;
|
_desc.pRasterizationState = &_descRasterization;
|
||||||
|
|
||||||
// Color Blend State
|
// Color Blend State
|
||||||
|
BlendEnable = desc.BlendMode.BlendEnable;
|
||||||
RenderToolsVulkan::ZeroStruct(_descColorBlend, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO);
|
RenderToolsVulkan::ZeroStruct(_descColorBlend, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO);
|
||||||
{
|
{
|
||||||
auto& blend = _descColorBlendAttachments[0];
|
auto& blend = _descColorBlendAttachments[0];
|
||||||
@@ -321,9 +322,7 @@ bool GPUPipelineStateVulkan::Init(const Description& desc)
|
|||||||
blend.colorWriteMask = (VkColorComponentFlags)desc.BlendMode.RenderTargetWriteMask;
|
blend.colorWriteMask = (VkColorComponentFlags)desc.BlendMode.RenderTargetWriteMask;
|
||||||
}
|
}
|
||||||
for (int32 i = 1; i < GPU_MAX_RT_BINDED; i++)
|
for (int32 i = 1; i < GPU_MAX_RT_BINDED; i++)
|
||||||
{
|
|
||||||
_descColorBlendAttachments[i] = _descColorBlendAttachments[i - 1];
|
_descColorBlendAttachments[i] = _descColorBlendAttachments[i - 1];
|
||||||
}
|
|
||||||
_descColorBlend.pAttachments = _descColorBlendAttachments;
|
_descColorBlend.pAttachments = _descColorBlendAttachments;
|
||||||
_descColorBlend.blendConstants[0] = 0.0f;
|
_descColorBlend.blendConstants[0] = 0.0f;
|
||||||
_descColorBlend.blendConstants[1] = 0.0f;
|
_descColorBlend.blendConstants[1] = 0.0f;
|
||||||
|
|||||||
@@ -135,6 +135,8 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
uint32 UsedStagesMask;
|
uint32 UsedStagesMask;
|
||||||
|
|
||||||
|
bool BlendEnable;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The bitmask of stages that have descriptors.
|
/// The bitmask of stages that have descriptors.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user