Merge pull request #1650 from unknownbrackets/attributeless-fix
OGL: Unbind the active VAO before attributeless rendering
This commit is contained in:
commit
15f7e63cc2
|
@ -373,6 +373,8 @@ void FramebufferManager::ReinterpretPixelData(unsigned int convtype)
|
|||
{
|
||||
g_renderer->ResetAPIState();
|
||||
|
||||
OpenGL_BindAttributelessVAO();
|
||||
|
||||
GLuint src_texture = 0;
|
||||
|
||||
// We aren't allowed to render and sample the same texture in one draw call,
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
cInterfaceBase *GLInterface;
|
||||
static GLuint attributelessVAO = 0;
|
||||
static GLuint attributelessVBO = 0;
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
|
@ -113,3 +115,38 @@ GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShade
|
|||
return programID;
|
||||
}
|
||||
|
||||
void OpenGL_CreateAttributelessVAO()
|
||||
{
|
||||
glGenVertexArrays(1, &attributelessVAO);
|
||||
_dbg_assert_msg_(VIDEO, attributelessVAO != 0, "Attributeless VAO should have been created successfully.")
|
||||
|
||||
// In a compatibility context, we require a valid, bound array buffer.
|
||||
glGenBuffers(1, &attributelessVBO);
|
||||
_dbg_assert_msg_(VIDEO, attributelessVBO != 0, "Attributeless VBO should have been created successfully.")
|
||||
|
||||
// Initialize the buffer with nothing.
|
||||
glBindBuffer(GL_ARRAY_BUFFER, attributelessVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat), nullptr, GL_STATIC_DRAW);
|
||||
|
||||
// We must also define vertex attribute 0.
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
|
||||
}
|
||||
|
||||
void OpenGL_BindAttributelessVAO()
|
||||
{
|
||||
_dbg_assert_msg_(VIDEO, attributelessVAO != 0, "Attributeless VAO should have already been created.")
|
||||
glBindVertexArray(attributelessVAO);
|
||||
}
|
||||
|
||||
void OpenGL_DeleteAttributelessVAO()
|
||||
{
|
||||
_dbg_assert_msg_(VIDEO, attributelessVAO != 0, "Attributeless VAO should have already been created.")
|
||||
if (attributelessVAO != 0)
|
||||
{
|
||||
glDeleteVertexArrays(1, &attributelessVAO);
|
||||
glDeleteBuffers(1, &attributelessVBO);
|
||||
|
||||
attributelessVAO = 0;
|
||||
attributelessVBO = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,14 @@ void InitInterface();
|
|||
// Helpers
|
||||
GLuint OpenGL_CompileProgram(const char *vertexShader, const char *fragmentShader);
|
||||
|
||||
// Creates and deletes a VAO and VBO suitable for attributeless rendering.
|
||||
// Called by the Renderer.
|
||||
void OpenGL_CreateAttributelessVAO();
|
||||
void OpenGL_DeleteAttributelessVAO();
|
||||
|
||||
// Binds the VAO suitable for attributeless rendering.
|
||||
void OpenGL_BindAttributelessVAO();
|
||||
|
||||
// this should be removed in future, but as long as glsl is unstable, we should really read this messages
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#define DEBUG_GLSL 1
|
||||
|
|
|
@ -72,6 +72,8 @@ void OpenGLPostProcessing::BlitFromTexture(TargetRectangle src, TargetRectangle
|
|||
|
||||
if (m_attribute_workaround)
|
||||
glBindVertexArray(m_attribute_vao);
|
||||
else
|
||||
OpenGL_BindAttributelessVAO();
|
||||
|
||||
m_shader.Bind();
|
||||
|
||||
|
|
|
@ -691,6 +691,8 @@ void Renderer::Shutdown()
|
|||
|
||||
delete m_post_processor;
|
||||
m_post_processor = nullptr;
|
||||
|
||||
OpenGL_DeleteAttributelessVAO();
|
||||
}
|
||||
|
||||
void Renderer::Init()
|
||||
|
@ -717,6 +719,8 @@ void Renderer::Init()
|
|||
" ocol0 = c;\n"
|
||||
"}\n");
|
||||
|
||||
OpenGL_CreateAttributelessVAO();
|
||||
|
||||
// creating buffers
|
||||
glGenBuffers(1, &s_ShowEFBCopyRegions_VBO);
|
||||
glGenVertexArrays(1, &s_ShowEFBCopyRegions_VAO);
|
||||
|
|
|
@ -249,6 +249,8 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
|
|||
{
|
||||
FramebufferManager::SetFramebuffer(framebuffer);
|
||||
|
||||
OpenGL_BindAttributelessVAO();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0+9);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, read_texture);
|
||||
|
||||
|
|
|
@ -222,6 +222,8 @@ static void EncodeToRamUsingShader(GLuint srcTexture,
|
|||
// attach render buffer as color destination
|
||||
FramebufferManager::SetFramebuffer(s_texConvFrameBuffer[0]);
|
||||
|
||||
OpenGL_BindAttributelessVAO();
|
||||
|
||||
// set source texture
|
||||
glActiveTexture(GL_TEXTURE0+9);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, srcTexture);
|
||||
|
@ -362,6 +364,8 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
|
|||
|
||||
g_renderer->ResetAPIState(); // reset any game specific settings
|
||||
|
||||
OpenGL_BindAttributelessVAO();
|
||||
|
||||
// switch to texture converter frame buffer
|
||||
// attach destTexture as color destination
|
||||
FramebufferManager::SetFramebuffer(s_texConvFrameBuffer[1]);
|
||||
|
|
Loading…
Reference in New Issue