mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
AbstractTexture: Move Bind() method to Renderer
This makes state tracking simpler, and enables easier porting to command lists later on.
This commit is contained in:
@ -19,9 +19,6 @@ namespace OGL
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::array<u32, 8> s_Textures;
|
||||
u32 s_ActiveTexture;
|
||||
|
||||
GLenum GetGLInternalFormatForTextureFormat(AbstractTextureFormat format, bool storage)
|
||||
{
|
||||
switch (format)
|
||||
@ -120,26 +117,15 @@ OGLTexture::OGLTexture(const TextureConfig& tex_config) : AbstractTexture(tex_co
|
||||
// method is in the base renderer class and can be called by VideoCommon.
|
||||
FramebufferManager::SetFramebuffer(0);
|
||||
}
|
||||
|
||||
SetStage();
|
||||
}
|
||||
|
||||
OGLTexture::~OGLTexture()
|
||||
{
|
||||
if (m_texId)
|
||||
{
|
||||
for (auto& gtex : s_Textures)
|
||||
if (gtex == m_texId)
|
||||
gtex = 0;
|
||||
glDeleteTextures(1, &m_texId);
|
||||
m_texId = 0;
|
||||
}
|
||||
|
||||
if (m_framebuffer)
|
||||
{
|
||||
glDeleteFramebuffers(1, &m_framebuffer);
|
||||
m_framebuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GLuint OGLTexture::GetRawTexIdentifier() const
|
||||
@ -152,21 +138,6 @@ GLuint OGLTexture::GetFramebuffer() const
|
||||
return m_framebuffer;
|
||||
}
|
||||
|
||||
void OGLTexture::Bind(unsigned int stage)
|
||||
{
|
||||
if (s_Textures[stage] != m_texId)
|
||||
{
|
||||
if (s_ActiveTexture != stage)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + stage);
|
||||
s_ActiveTexture = stage;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_texId);
|
||||
s_Textures[stage] = m_texId;
|
||||
}
|
||||
}
|
||||
|
||||
void OGLTexture::CopyRectangleFromTexture(const AbstractTexture* src,
|
||||
const MathUtil::Rectangle<int>& src_rect, u32 src_layer,
|
||||
u32 src_level, const MathUtil::Rectangle<int>& dst_rect,
|
||||
@ -300,19 +271,6 @@ void OGLTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8
|
||||
|
||||
if (row_length != width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
SetStage();
|
||||
}
|
||||
|
||||
void OGLTexture::DisableStage(unsigned int stage)
|
||||
{
|
||||
}
|
||||
|
||||
void OGLTexture::SetStage()
|
||||
{
|
||||
// -1 is the initial value as we don't know which texture should be bound
|
||||
if (s_ActiveTexture != (u32)-1)
|
||||
glActiveTexture(GL_TEXTURE0 + s_ActiveTexture);
|
||||
}
|
||||
|
||||
OGLStagingTexture::OGLStagingTexture(StagingTextureType type, const TextureConfig& config,
|
||||
@ -444,7 +402,6 @@ void OGLStagingTexture::CopyFromTexture(const AbstractTexture* src,
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, gltex->GetRawTexIdentifier());
|
||||
glGetTexImage(GL_TEXTURE_2D_ARRAY, src_level, GetGLFormatForTextureFormat(m_config.format),
|
||||
GetGLTypeForTextureFormat(m_config.format), nullptr);
|
||||
OGLTexture::SetStage();
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,7 +464,6 @@ void OGLStagingTexture::CopyToTexture(const MathUtil::Rectangle<int>& src_rect,
|
||||
dst_rect.GetWidth(), dst_rect.GetHeight(), 1,
|
||||
GetGLFormatForTextureFormat(m_config.format),
|
||||
GetGLTypeForTextureFormat(m_config.format), reinterpret_cast<void*>(src_offset));
|
||||
OGLTexture::SetStage();
|
||||
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
|
Reference in New Issue
Block a user