mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55:38 +00:00
OpenGLDevice: Set unpack row length on create
This commit is contained in:
parent
2067b660f6
commit
6d18863d65
|
@ -267,9 +267,15 @@ public:
|
||||||
DebugAssert((m_position + used_size) <= m_size);
|
DebugAssert((m_position + used_size) <= m_size);
|
||||||
if (!m_coherent)
|
if (!m_coherent)
|
||||||
{
|
{
|
||||||
// TODO: shouldn't be needed anymore
|
if (GLAD_GL_VERSION_4_5 || GLAD_GL_ARB_direct_state_access)
|
||||||
Bind();
|
{
|
||||||
glFlushMappedBufferRange(m_target, m_position, used_size);
|
glFlushMappedNamedBufferRange(m_buffer_id, m_position, used_size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bind();
|
||||||
|
glFlushMappedBufferRange(m_target, m_position, used_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 prev_position = m_position;
|
const u32 prev_position = m_position;
|
||||||
|
|
|
@ -120,15 +120,22 @@ bool OpenGLTexture::Create(u32 width, u32 height, u32 layers, u32 levels, u32 sa
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, data_pitch / GetPixelSize(format));
|
||||||
|
|
||||||
// TODO: Fix data for mipmaps here.
|
// TODO: Fix data for mipmaps here.
|
||||||
if (layers > 1)
|
if (layers > 1)
|
||||||
glTexSubImage3D(target, 0, 0, 0, 0, width, height, layers, gl_format, gl_type, data);
|
glTexSubImage3D(target, 0, 0, 0, 0, width, height, layers, gl_format, gl_type, data);
|
||||||
else
|
else
|
||||||
glTexSubImage2D(target, 0, 0, 0, width, height, gl_format, gl_type, data);
|
glTexSubImage2D(target, 0, 0, 0, width, height, gl_format, gl_type, data);
|
||||||
|
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (data)
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, data_pitch / GetPixelSize(format));
|
||||||
|
|
||||||
for (u32 i = 0; i < levels; i++)
|
for (u32 i = 0; i < levels; i++)
|
||||||
{
|
{
|
||||||
// TODO: Fix data pointer here.
|
// TODO: Fix data pointer here.
|
||||||
|
@ -138,6 +145,9 @@ bool OpenGLTexture::Create(u32 width, u32 height, u32 layers, u32 levels, u32 sa
|
||||||
glTexImage2D(target, i, gl_internal_format, width, height, 0, gl_format, gl_type, data);
|
glTexImage2D(target, i, gl_internal_format, width, height, 0, gl_format, gl_type, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data)
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0);
|
glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0);
|
||||||
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels);
|
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels);
|
||||||
}
|
}
|
||||||
|
@ -206,6 +216,7 @@ bool OpenGLTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data
|
||||||
GL_INS_FMT("Not using PBO for map size {}", map_size);
|
GL_INS_FMT("Not using PBO for map size {}", map_size);
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize());
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize());
|
||||||
glTexSubImage2D(target, layer, x, y, width, height, gl_format, gl_type, data);
|
glTexSubImage2D(target, layer, x, y, width, height, gl_format, gl_type, data);
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -217,6 +228,7 @@ bool OpenGLTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, preferred_pitch / GetPixelSize());
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, preferred_pitch / GetPixelSize());
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, layer, x, y, width, height, gl_format, gl_type,
|
glTexSubImage2D(GL_TEXTURE_2D, layer, x, y, width, height, gl_format, gl_type,
|
||||||
reinterpret_cast<void*>(static_cast<uintptr_t>(map.buffer_offset)));
|
reinterpret_cast<void*>(static_cast<uintptr_t>(map.buffer_offset)));
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
sb->Unbind();
|
sb->Unbind();
|
||||||
}
|
}
|
||||||
|
@ -261,13 +273,13 @@ void OpenGLTexture::Unmap()
|
||||||
sb->Unmap(upload_size);
|
sb->Unmap(upload_size);
|
||||||
sb->Bind();
|
sb->Bind();
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize());
|
|
||||||
|
|
||||||
OpenGLDevice::BindUpdateTextureUnit();
|
OpenGLDevice::BindUpdateTextureUnit();
|
||||||
|
|
||||||
const GLenum target = GetGLTarget();
|
const GLenum target = GetGLTarget();
|
||||||
glBindTexture(target, m_id);
|
glBindTexture(target, m_id);
|
||||||
|
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize());
|
||||||
|
|
||||||
const auto [gl_internal_format, gl_format, gl_type] = GetPixelFormatMapping(m_format);
|
const auto [gl_internal_format, gl_format, gl_type] = GetPixelFormatMapping(m_format);
|
||||||
if (IsTextureArray())
|
if (IsTextureArray())
|
||||||
{
|
{
|
||||||
|
@ -282,9 +294,9 @@ void OpenGLTexture::Unmap()
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
sb->Unbind();
|
|
||||||
|
|
||||||
glBindTexture(target, 0);
|
glBindTexture(target, 0);
|
||||||
|
|
||||||
|
sb->Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLTexture::SetDebugName(const std::string_view& name)
|
void OpenGLTexture::SetDebugName(const std::string_view& name)
|
||||||
|
|
Loading…
Reference in a new issue