Add ClearUA to GPUContext to clear texture with float values

This commit is contained in:
Wojciech Figat
2022-02-08 18:06:02 +01:00
committed by Wojtek Figat
parent bac8058aa8
commit afed5a30bc
7 changed files with 45 additions and 0 deletions

View File

@@ -874,6 +874,23 @@ void GPUContextVulkan::ClearUA(GPUTexture* texture, const uint32 value[4])
}
}
void GPUContextVulkan::ClearUA(GPUTexture* texture, const Vector4& value)
{
const auto texVulkan = static_cast<GPUTextureVulkan*>(texture);
if (texVulkan)
{
auto rtVulkan = ((GPUTextureViewVulkan*)(texVulkan->IsVolume() ? texVulkan->ViewVolume() : texVulkan->View(0)));
const auto cmdBuffer = _cmdBufferManager->GetCmdBuffer();
if (cmdBuffer->IsInsideRenderPass())
EndRenderPass();
AddImageBarrier(rtVulkan, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
FlushBarriers();
vkCmdClearColorImage(cmdBuffer->GetHandle(), rtVulkan->Image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (const VkClearColorValue*)value.Raw, 1, &rtVulkan->Info.subresourceRange);
}
}
void GPUContextVulkan::ResetRenderTarget()
{
if (_rtDepth || _rtCount != 0)

View File

@@ -176,6 +176,7 @@ public:
void ClearUA(GPUBuffer* buf, const Vector4& value) override;
void ClearUA(GPUBuffer* buf, const uint32 value[4]) override;
void ClearUA(GPUTexture* texture, const uint32 value[4]) override;
void ClearUA(GPUTexture* texture, const Vector4& value) override;
void ResetRenderTarget() override;
void SetRenderTarget(GPUTextureView* rt) override;
void SetRenderTarget(GPUTextureView* depthBuffer, GPUTextureView* rt) override;