mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-12 17:34:33 +00:00
GPUDevice: Ensure clear is committed in MakeReadyForSampling()
This commit is contained in:
@@ -687,14 +687,12 @@ void D3D12Texture::TransitionSubresourceToState(ID3D12GraphicsCommandList* cmdli
|
||||
|
||||
void D3D12Texture::MakeReadyForSampling()
|
||||
{
|
||||
if (m_resource_state == D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
|
||||
if (m_resource_state == D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE && m_state != State::Cleared)
|
||||
return;
|
||||
|
||||
D3D12Device& dev = D3D12Device::GetInstance();
|
||||
if (dev.InRenderPass())
|
||||
dev.EndRenderPass();
|
||||
|
||||
TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||
ID3D12GraphicsCommandList4* const cmdlist = GetCommandBufferForUpdate();
|
||||
CommitClear(cmdlist);
|
||||
TransitionToState(cmdlist, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||
}
|
||||
|
||||
D3D12Sampler::D3D12Sampler(D3D12DescriptorHandle descriptor) : m_descriptor(descriptor)
|
||||
|
||||
@@ -1053,11 +1053,13 @@ void MetalTexture::Unmap()
|
||||
void MetalTexture::MakeReadyForSampling()
|
||||
{
|
||||
MetalDevice& dev = MetalDevice::GetInstance();
|
||||
if (!dev.InRenderPass())
|
||||
return;
|
||||
if (dev.InRenderPass())
|
||||
{
|
||||
if (IsRenderTarget() ? dev.IsRenderTargetBound(this) : (dev.m_current_depth_target == this))
|
||||
dev.EndRenderPass();
|
||||
}
|
||||
|
||||
if (IsRenderTarget() ? dev.IsRenderTargetBound(this) : (dev.m_current_depth_target == this))
|
||||
dev.EndRenderPass();
|
||||
dev.CommitClear(this);
|
||||
}
|
||||
|
||||
void MetalTexture::GenerateMipmaps()
|
||||
@@ -1631,10 +1633,7 @@ void MetalDevice::CommitClear(MetalTexture* tex)
|
||||
tex->SetState(GPUTexture::State::Dirty);
|
||||
|
||||
// TODO: We could combine it with the current render pass.
|
||||
if (InRenderPass())
|
||||
EndRenderPass();
|
||||
else if (InComputePass())
|
||||
EndComputePass();
|
||||
EndAnyEncoding();
|
||||
|
||||
@autoreleasepool
|
||||
{
|
||||
|
||||
@@ -425,15 +425,12 @@ void VulkanTexture::CommitClear()
|
||||
if (m_state != GPUTexture::State::Cleared)
|
||||
return;
|
||||
|
||||
VulkanDevice& dev = VulkanDevice::GetInstance();
|
||||
if (dev.InRenderPass())
|
||||
dev.EndRenderPass();
|
||||
|
||||
CommitClear(dev.GetCurrentCommandBuffer());
|
||||
CommitClear(GetCommandBufferForUpdate());
|
||||
}
|
||||
|
||||
void VulkanTexture::CommitClear(VkCommandBuffer cmdbuf)
|
||||
{
|
||||
DebugAssert(m_state == State::Cleared);
|
||||
TransitionToLayout(cmdbuf, Layout::ClearDst);
|
||||
|
||||
if (IsDepthStencil())
|
||||
@@ -707,14 +704,14 @@ VkDescriptorSet VulkanTexture::GetDescriptorSetWithSampler(VkSampler sampler)
|
||||
|
||||
void VulkanTexture::MakeReadyForSampling()
|
||||
{
|
||||
if (m_layout == Layout::ShaderReadOnly)
|
||||
if (m_layout == Layout::ShaderReadOnly && m_state != State::Cleared)
|
||||
return;
|
||||
|
||||
VulkanDevice& dev = VulkanDevice::GetInstance();
|
||||
if (dev.InRenderPass())
|
||||
dev.EndRenderPass();
|
||||
const VkCommandBuffer cmdbuf = GetCommandBufferForUpdate();
|
||||
if (m_state == State::Cleared)
|
||||
CommitClear(cmdbuf);
|
||||
|
||||
TransitionToLayout(Layout::ShaderReadOnly);
|
||||
TransitionToLayout(cmdbuf, Layout::ShaderReadOnly);
|
||||
}
|
||||
|
||||
void VulkanTexture::GenerateMipmaps()
|
||||
|
||||
Reference in New Issue
Block a user