mirror of https://github.com/PCSX2/pcsx2.git
GS/OpenGL: Fix texture uploads in big picture mode
This commit is contained in:
parent
e233f1dded
commit
f2ca07033c
|
@ -85,6 +85,9 @@ std::unique_ptr<HostDisplayTexture> OpenGLHostDisplay::CreateTexture(u32 width,
|
||||||
// clear error
|
// clear error
|
||||||
glGetError();
|
glGetError();
|
||||||
|
|
||||||
|
// don't worry, I'm planning on removing this eventually - we'll use GSTexture instead.
|
||||||
|
glActiveTexture(GL_TEXTURE7);
|
||||||
|
|
||||||
GLuint id;
|
GLuint id;
|
||||||
glGenTextures(1, &id);
|
glGenTextures(1, &id);
|
||||||
glBindTexture(GL_TEXTURE_2D, id);
|
glBindTexture(GL_TEXTURE_2D, id);
|
||||||
|
@ -100,6 +103,8 @@ std::unique_ptr<HostDisplayTexture> OpenGLHostDisplay::CreateTexture(u32 width,
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
GLenum error = glGetError();
|
GLenum error = glGetError();
|
||||||
if (error != GL_NO_ERROR)
|
if (error != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -115,30 +120,15 @@ void OpenGLHostDisplay::UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y,
|
||||||
{
|
{
|
||||||
OpenGLHostDisplayTexture* tex = static_cast<OpenGLHostDisplayTexture*>(texture);
|
OpenGLHostDisplayTexture* tex = static_cast<OpenGLHostDisplayTexture*>(texture);
|
||||||
|
|
||||||
GLint alignment;
|
glActiveTexture(GL_TEXTURE7);
|
||||||
if (texture_data_stride & 1)
|
|
||||||
alignment = 1;
|
|
||||||
else if (texture_data_stride & 2)
|
|
||||||
alignment = 2;
|
|
||||||
else
|
|
||||||
alignment = 4;
|
|
||||||
|
|
||||||
GLint old_texture_binding = 0, old_alignment = 0, old_row_length = 0;
|
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_texture_binding);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, tex->GetGLID());
|
|
||||||
|
|
||||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &old_alignment);
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
|
|
||||||
|
|
||||||
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &old_row_length);
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, texture_data_stride / sizeof(u32));
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, texture_data_stride / sizeof(u32));
|
||||||
|
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA8, GL_UNSIGNED_BYTE, texture_data);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA8, GL_UNSIGNED_BYTE, texture_data);
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, old_row_length);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, old_alignment);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, old_texture_binding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLHostDisplay::SetVSync(VsyncMode mode)
|
void OpenGLHostDisplay::SetVSync(VsyncMode mode)
|
||||||
|
@ -216,6 +206,9 @@ bool OpenGLHostDisplay::CreateDevice(const WindowInfo& wi, VsyncMode vsync)
|
||||||
|
|
||||||
bool OpenGLHostDisplay::SetupDevice()
|
bool OpenGLHostDisplay::SetupDevice()
|
||||||
{
|
{
|
||||||
|
// We do use 8-bit formats, and higher alignment for 32-bit formats won't hurt anything.
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
SetSwapInterval();
|
SetSwapInterval();
|
||||||
GL::Program::ResetLastProgram();
|
GL::Program::ResetLastProgram();
|
||||||
return true;
|
return true;
|
||||||
|
@ -363,11 +356,8 @@ bool OpenGLHostDisplay::BeginPresent(bool frame_skip)
|
||||||
|
|
||||||
void OpenGLHostDisplay::EndPresent()
|
void OpenGLHostDisplay::EndPresent()
|
||||||
{
|
{
|
||||||
// clear out pipeline bindings, since imgui doesn't use them
|
|
||||||
glBindProgramPipeline(0);
|
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
|
@ -477,13 +477,14 @@ bool GSDeviceOGL::Create()
|
||||||
// ****************************************************************
|
// ****************************************************************
|
||||||
if (!GLLoader::buggy_pbo)
|
if (!GLLoader::buggy_pbo)
|
||||||
{
|
{
|
||||||
// Mesa seems to use it to compute the row length. In our case, we are
|
|
||||||
// tightly packed so don't bother with this parameter and set it to the
|
|
||||||
// minimum alignment (1 byte)
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
|
|
||||||
s_texture_upload_buffer = GL::StreamBuffer::Create(GL_PIXEL_UNPACK_BUFFER, TEXTURE_UPLOAD_BUFFER_SIZE);
|
s_texture_upload_buffer = GL::StreamBuffer::Create(GL_PIXEL_UNPACK_BUFFER, TEXTURE_UPLOAD_BUFFER_SIZE);
|
||||||
if (!s_texture_upload_buffer)
|
if (s_texture_upload_buffer)
|
||||||
|
{
|
||||||
|
// Don't keep it bound, we'll re-bind when we need it.
|
||||||
|
// Otherwise non-PBO texture uploads break. Yay for global state.
|
||||||
|
s_texture_upload_buffer->Unbind();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Console.Error("Failed to create texture upload buffer. Using slow path.");
|
Console.Error("Failed to create texture upload buffer. Using slow path.");
|
||||||
GLLoader::buggy_pbo = true;
|
GLLoader::buggy_pbo = true;
|
||||||
|
@ -569,6 +570,7 @@ void GSDeviceOGL::ResetAPIState()
|
||||||
// clear out DSB
|
// clear out DSB
|
||||||
glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
|
glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceOGL::RestoreAPIState()
|
void GSDeviceOGL::RestoreAPIState()
|
||||||
|
|
|
@ -256,6 +256,8 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch, int
|
||||||
|
|
||||||
glTextureSubImage2D(m_texture_id, layer, r.x, r.y, r.width(), r.height(), m_int_format, m_int_type,
|
glTextureSubImage2D(m_texture_id, layer, r.x, r.y, r.width(), r.height(), m_int_format, m_int_type,
|
||||||
reinterpret_cast<void*>(static_cast<uintptr_t>(map.buffer_offset)));
|
reinterpret_cast<void*>(static_cast<uintptr_t>(map.buffer_offset)));
|
||||||
|
|
||||||
|
sb->Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_needs_mipmaps_generated = true;
|
m_needs_mipmaps_generated = true;
|
||||||
|
@ -316,6 +318,8 @@ void GSTextureOGL::Unmap()
|
||||||
glTextureSubImage2D(m_texture_id, m_layer, m_r_x, m_r_y, m_r_w, m_r_h, m_int_format, m_int_type,
|
glTextureSubImage2D(m_texture_id, m_layer, m_r_x, m_r_y, m_r_w, m_r_h, m_int_format, m_int_type,
|
||||||
reinterpret_cast<void*>(static_cast<uintptr_t>(m_map_offset)));
|
reinterpret_cast<void*>(static_cast<uintptr_t>(m_map_offset)));
|
||||||
|
|
||||||
|
sb->Unbind();
|
||||||
|
|
||||||
m_needs_mipmaps_generated = true;
|
m_needs_mipmaps_generated = true;
|
||||||
|
|
||||||
GL_POP(); // PUSH is in Map
|
GL_POP(); // PUSH is in Map
|
||||||
|
|
Loading…
Reference in New Issue