mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 05:45: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);
|
||||
if (!m_coherent)
|
||||
{
|
||||
// TODO: shouldn't be needed anymore
|
||||
Bind();
|
||||
glFlushMappedBufferRange(m_target, m_position, used_size);
|
||||
if (GLAD_GL_VERSION_4_5 || GLAD_GL_ARB_direct_state_access)
|
||||
{
|
||||
glFlushMappedNamedBufferRange(m_buffer_id, m_position, used_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
Bind();
|
||||
glFlushMappedBufferRange(m_target, m_position, used_size);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, data_pitch / GetPixelSize(format));
|
||||
|
||||
// TODO: Fix data for mipmaps here.
|
||||
if (layers > 1)
|
||||
glTexSubImage3D(target, 0, 0, 0, 0, width, height, layers, gl_format, gl_type, data);
|
||||
else
|
||||
glTexSubImage2D(target, 0, 0, 0, width, height, gl_format, gl_type, data);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, data_pitch / GetPixelSize(format));
|
||||
|
||||
for (u32 i = 0; i < levels; i++)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (data)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
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);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize());
|
||||
glTexSubImage2D(target, layer, x, y, width, height, gl_format, gl_type, data);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
}
|
||||
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());
|
||||
glTexSubImage2D(GL_TEXTURE_2D, layer, x, y, width, height, gl_format, gl_type,
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(map.buffer_offset)));
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
sb->Unbind();
|
||||
}
|
||||
|
@ -261,13 +273,13 @@ void OpenGLTexture::Unmap()
|
|||
sb->Unmap(upload_size);
|
||||
sb->Bind();
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize());
|
||||
|
||||
OpenGLDevice::BindUpdateTextureUnit();
|
||||
|
||||
const GLenum target = GetGLTarget();
|
||||
glBindTexture(target, m_id);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize());
|
||||
|
||||
const auto [gl_internal_format, gl_format, gl_type] = GetPixelFormatMapping(m_format);
|
||||
if (IsTextureArray())
|
||||
{
|
||||
|
@ -282,9 +294,9 @@ void OpenGLTexture::Unmap()
|
|||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
sb->Unbind();
|
||||
|
||||
glBindTexture(target, 0);
|
||||
|
||||
sb->Unbind();
|
||||
}
|
||||
|
||||
void OpenGLTexture::SetDebugName(const std::string_view& name)
|
||||
|
|
Loading…
Reference in a new issue