mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-19 14: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)
|
||||
{
|
||||
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;
|
||||
|
||||
// Runtime will null these if we don't...
|
||||
|
|
|
@ -1864,6 +1864,7 @@ void D3D12Device::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* s
|
|||
|
||||
if (T)
|
||||
{
|
||||
T->CommitClear();
|
||||
T->SetUseFenceValue(GetCurrentFenceValue());
|
||||
if (T->GetResourceState() != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
|
||||
{
|
||||
|
|
|
@ -1408,13 +1408,12 @@ void MetalDevice::InvalidateRenderTarget(GPUTexture* t)
|
|||
|
||||
void MetalDevice::CommitClear(MetalTexture* tex)
|
||||
{
|
||||
if (tex->GetState() == GPUTexture::State::Dirty)
|
||||
return;
|
||||
|
||||
DebugAssert(tex->IsRenderTargetOrDepthStencil());
|
||||
|
||||
if (tex->GetState() == GPUTexture::State::Cleared)
|
||||
{
|
||||
tex->SetState(GPUTexture::State::Dirty);
|
||||
|
||||
// TODO: We could combine it with the current render pass.
|
||||
if (InRenderPass())
|
||||
EndRenderPass();
|
||||
|
@ -1655,7 +1654,10 @@ void MetalDevice::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* s
|
|||
|
||||
id<MTLTexture> T = texture ? static_cast<MetalTexture*>(texture)->GetMTLTexture() : nil;
|
||||
if (texture)
|
||||
{
|
||||
CommitClear(static_cast<MetalTexture*>(texture));
|
||||
static_cast<MetalTexture*>(texture)->SetUseFenceCounter(m_current_fence_counter);
|
||||
}
|
||||
|
||||
if (m_current_textures[slot] != T)
|
||||
{
|
||||
|
|
|
@ -1130,8 +1130,18 @@ void OpenGLDevice::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler*
|
|||
DebugAssert(slot < MAX_TEXTURE_SAMPLERS);
|
||||
auto& sslot = m_last_samplers[slot];
|
||||
|
||||
const OpenGLTexture* T = static_cast<const OpenGLTexture*>(texture);
|
||||
const GLuint Tid = T ? T->GetGLId() : 0;
|
||||
OpenGLTexture* T = static_cast<OpenGLTexture*>(texture);
|
||||
GLuint Tid;
|
||||
if (T)
|
||||
{
|
||||
Tid = T->GetGLId();
|
||||
CommitClear(T);
|
||||
}
|
||||
else
|
||||
{
|
||||
Tid = 0;
|
||||
}
|
||||
|
||||
if (sslot.first != Tid)
|
||||
{
|
||||
sslot.first = Tid;
|
||||
|
|
|
@ -3250,6 +3250,7 @@ void VulkanDevice::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler*
|
|||
|
||||
if (T)
|
||||
{
|
||||
T->CommitClear();
|
||||
T->SetUseFenceCounter(GetCurrentFenceCounter());
|
||||
if (T->GetLayout() != VulkanTexture::Layout::ShaderReadOnly)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue