mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-31 19:55:38 +00:00
GPUDevice: Fix binding deferred cleared textures
i.e. briefly flashing previous state after reset.
This commit is contained in:
parent
371c58dc72
commit
7e1276fbac
|
@ -940,7 +940,17 @@ void D3D11Device::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUTextu
|
||||||
|
|
||||||
void D3D11Device::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* sampler)
|
void D3D11Device::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* sampler)
|
||||||
{
|
{
|
||||||
ID3D11ShaderResourceView* T = texture ? static_cast<D3D11Texture*>(texture)->GetD3DSRV() : nullptr;
|
ID3D11ShaderResourceView* T;
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
static_cast<D3D11Texture*>(texture)->CommitClear(m_context.Get());
|
||||||
|
T = static_cast<D3D11Texture*>(texture)->GetD3DSRV();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
T = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
ID3D11SamplerState* S = sampler ? static_cast<D3D11Sampler*>(sampler)->GetSamplerState() : nullptr;
|
ID3D11SamplerState* S = sampler ? static_cast<D3D11Sampler*>(sampler)->GetSamplerState() : nullptr;
|
||||||
|
|
||||||
// Runtime will null these if we don't...
|
// Runtime will null these if we don't...
|
||||||
|
|
|
@ -1864,6 +1864,7 @@ void D3D12Device::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* s
|
||||||
|
|
||||||
if (T)
|
if (T)
|
||||||
{
|
{
|
||||||
|
T->CommitClear();
|
||||||
T->SetUseFenceValue(GetCurrentFenceValue());
|
T->SetUseFenceValue(GetCurrentFenceValue());
|
||||||
if (T->GetResourceState() != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
|
if (T->GetResourceState() != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1408,13 +1408,12 @@ void MetalDevice::InvalidateRenderTarget(GPUTexture* t)
|
||||||
|
|
||||||
void MetalDevice::CommitClear(MetalTexture* tex)
|
void MetalDevice::CommitClear(MetalTexture* tex)
|
||||||
{
|
{
|
||||||
if (tex->GetState() == GPUTexture::State::Dirty)
|
|
||||||
return;
|
|
||||||
|
|
||||||
DebugAssert(tex->IsRenderTargetOrDepthStencil());
|
DebugAssert(tex->IsRenderTargetOrDepthStencil());
|
||||||
|
|
||||||
if (tex->GetState() == GPUTexture::State::Cleared)
|
if (tex->GetState() == GPUTexture::State::Cleared)
|
||||||
{
|
{
|
||||||
|
tex->SetState(GPUTexture::State::Dirty);
|
||||||
|
|
||||||
// TODO: We could combine it with the current render pass.
|
// TODO: We could combine it with the current render pass.
|
||||||
if (InRenderPass())
|
if (InRenderPass())
|
||||||
EndRenderPass();
|
EndRenderPass();
|
||||||
|
@ -1655,7 +1654,10 @@ void MetalDevice::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* s
|
||||||
|
|
||||||
id<MTLTexture> T = texture ? static_cast<MetalTexture*>(texture)->GetMTLTexture() : nil;
|
id<MTLTexture> T = texture ? static_cast<MetalTexture*>(texture)->GetMTLTexture() : nil;
|
||||||
if (texture)
|
if (texture)
|
||||||
|
{
|
||||||
|
CommitClear(static_cast<MetalTexture*>(texture));
|
||||||
static_cast<MetalTexture*>(texture)->SetUseFenceCounter(m_current_fence_counter);
|
static_cast<MetalTexture*>(texture)->SetUseFenceCounter(m_current_fence_counter);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_current_textures[slot] != T)
|
if (m_current_textures[slot] != T)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1130,8 +1130,18 @@ void OpenGLDevice::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler*
|
||||||
DebugAssert(slot < MAX_TEXTURE_SAMPLERS);
|
DebugAssert(slot < MAX_TEXTURE_SAMPLERS);
|
||||||
auto& sslot = m_last_samplers[slot];
|
auto& sslot = m_last_samplers[slot];
|
||||||
|
|
||||||
const OpenGLTexture* T = static_cast<const OpenGLTexture*>(texture);
|
OpenGLTexture* T = static_cast<OpenGLTexture*>(texture);
|
||||||
const GLuint Tid = T ? T->GetGLId() : 0;
|
GLuint Tid;
|
||||||
|
if (T)
|
||||||
|
{
|
||||||
|
Tid = T->GetGLId();
|
||||||
|
CommitClear(T);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Tid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (sslot.first != Tid)
|
if (sslot.first != Tid)
|
||||||
{
|
{
|
||||||
sslot.first = Tid;
|
sslot.first = Tid;
|
||||||
|
|
|
@ -3250,6 +3250,7 @@ void VulkanDevice::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler*
|
||||||
|
|
||||||
if (T)
|
if (T)
|
||||||
{
|
{
|
||||||
|
T->CommitClear();
|
||||||
T->SetUseFenceCounter(GetCurrentFenceCounter());
|
T->SetUseFenceCounter(GetCurrentFenceCounter());
|
||||||
if (T->GetLayout() != VulkanTexture::Layout::ShaderReadOnly)
|
if (T->GetLayout() != VulkanTexture::Layout::ShaderReadOnly)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue