1
0
forked from 0ad/0ad

Invalidates CDeviceCommandContext texture bind cache properly.

Tested By: Langbart
Differential Revision: https://code.wildfiregames.com/D4553
This was SVN commit r26664.
This commit is contained in:
Vladislav Belov 2022-03-17 18:17:11 +00:00
parent ce3a47e49a
commit 2ed2e9de0c
4 changed files with 13 additions and 0 deletions

View File

@ -693,6 +693,8 @@ void CSceneRenderer::RenderSilhouettes(
// inverted depth test so any behind an occluder will get drawn in a constant
// color.
deviceCommandContext->SetGraphicsPipelineState(
Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc());
deviceCommandContext->ClearFramebuffer(false, true, true);
// Render occluders:

View File

@ -390,6 +390,14 @@ void CDeviceCommandContext::BindBuffer(const CBuffer::Type type, CBuffer* buffer
glBindBufferARB(BufferTypeToGLTarget(type), buffer ? buffer->GetHandle() : 0);
}
void CDeviceCommandContext::OnTextureDestroy(CTexture* texture)
{
ENSURE(texture);
for (size_t index = 0; index < m_BoundTextures.size(); ++index)
if (m_BoundTextures[index].second == texture->GetHandle())
BindTexture(index, GL_TEXTURE_2D, 0);
}
void CDeviceCommandContext::Flush()
{
ResetStates();

View File

@ -105,6 +105,8 @@ public:
// TODO: remove direct binding after moving shaders.
void BindTexture(const uint32_t unit, const GLenum target, const GLuint handle);
void BindBuffer(const CBuffer::Type type, CBuffer* buffer);
// We need to know when to invalidate our texture bind cache.
void OnTextureDestroy(CTexture* texture);
void Flush();

View File

@ -293,6 +293,7 @@ CTexture::CTexture() = default;
CTexture::~CTexture()
{
m_Device->GetActiveCommandContext()->OnTextureDestroy(this);
if (m_Handle)
glDeleteTextures(1, &m_Handle);
}