From 38e0b6e2ab53374e7335fee94209bb90cb3e9ed2 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 21 Jan 2018 23:13:25 +1000 Subject: AbstractTexture: Move Bind() method to Renderer This makes state tracking simpler, and enables easier porting to command lists later on. --- Source/Core/VideoBackends/OGL/Render.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoBackends/OGL/Render.cpp') diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 9ee96bb724..d3cfa4136d 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1571,8 +1571,6 @@ void Renderer::RestoreAPIState() ProgramShaderCache::BindLastVertexFormat(); const VertexManager* const vm = static_cast(g_vertex_manager.get()); glBindBuffer(GL_ARRAY_BUFFER, vm->GetVertexBufferHandle()); - - OGLTexture::SetStage(); } void Renderer::SetRasterizationState(const RasterizationState& state) @@ -1611,11 +1609,34 @@ void Renderer::SetDepthState(const DepthState& state) } } +void Renderer::SetTexture(u32 index, const AbstractTexture* texture) +{ + if (m_bound_textures[index] == texture) + return; + + glActiveTexture(GL_TEXTURE0 + index); + glBindTexture(GL_TEXTURE_2D_ARRAY, + texture ? static_cast(texture)->GetRawTexIdentifier() : 0); + m_bound_textures[index] = texture; +} + void Renderer::SetSamplerState(u32 index, const SamplerState& state) { g_sampler_cache->SetSamplerState(index, state); } +void Renderer::UnbindTexture(const AbstractTexture* texture) +{ + for (size_t i = 0; i < m_bound_textures.size(); i++) + { + if (m_bound_textures[i] != texture) + continue; + + glActiveTexture(static_cast(GL_TEXTURE0 + i)); + glBindTexture(GL_TEXTURE_2D_ARRAY, 0); + } +} + void Renderer::SetInterlacingMode() { // TODO -- cgit v1.2.3