mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
OGL: Use a fixed VAO for attributeless rendering.
Instead of abusing whatever VAO is previously bound, which might have enabled arrays. Only used in one instance currently, which fixes a crash with older NVIDIA drivers.
This commit is contained in:
parent
f7a16eca84
commit
b19cff8a08
@ -16,6 +16,8 @@
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
cInterfaceBase *GLInterface;
|
||||
static GLuint attributelessVAO = 0;
|
||||
static GLuint attributelessVBO = 0;
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
@ -113,3 +115,32 @@ GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShade
|
||||
return programID;
|
||||
}
|
||||
|
||||
static void CreateAttributelessVAO()
|
||||
{
|
||||
glGenVertexArrays(1, &attributelessVAO);
|
||||
|
||||
// In a compatibility context, we require a valid, bound array buffer.
|
||||
glGenBuffers(1, &attributelessVBO);
|
||||
|
||||
// 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()
|
||||
{
|
||||
if (attributelessVAO == 0)
|
||||
CreateAttributelessVAO();
|
||||
|
||||
glBindVertexArray(attributelessVAO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, attributelessVBO);
|
||||
}
|
||||
|
||||
void OpenGL_DeleteAttributelessVAO()
|
||||
{
|
||||
glDeleteVertexArrays(1, &attributelessVAO);
|
||||
glDeleteBuffers(1, &attributelessVBO);
|
||||
}
|
||||
|
@ -18,6 +18,11 @@ void InitInterface();
|
||||
// Helpers
|
||||
GLuint OpenGL_CompileProgram(const char *vertexShader, const char *fragmentShader);
|
||||
|
||||
// Binds (and creates, if necessary) a VAO and VBO suitable for attributeless rendering.
|
||||
void OpenGL_BindAttributelessVAO();
|
||||
// Deletes any existing VAO / VBO that has been created.
|
||||
void OpenGL_DeleteAttributelessVAO();
|
||||
|
||||
// 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();
|
||||
|
||||
|
@ -686,6 +686,8 @@ void Renderer::Shutdown()
|
||||
|
||||
delete m_post_processor;
|
||||
m_post_processor = nullptr;
|
||||
|
||||
OpenGL_DeleteAttributelessVAO();
|
||||
}
|
||||
|
||||
void Renderer::Init()
|
||||
|
Loading…
Reference in New Issue
Block a user