GPUDevice: Fix binding deferred cleared textures

i.e. briefly flashing previous state after reset.
This commit is contained in:
Stenzek 2023-12-14 14:47:15 +10:00
parent 371c58dc72
commit 7e1276fbac
No known key found for this signature in database
5 changed files with 30 additions and 6 deletions

View file

@ -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...

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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;

View file

@ -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)
{