Merge pull request #11279 from tellowkrinkle/GlobalStateIsGreat
VideoBackends:OGL: Creating vertex formats shouldn't unbind anything
This commit is contained in:
commit
421af09b1e
|
@ -59,7 +59,6 @@ GLVertexFormat::GLVertexFormat(const PortableVertexDeclaration& vtx_decl)
|
||||||
|
|
||||||
glGenVertexArrays(1, &VAO);
|
glGenVertexArrays(1, &VAO);
|
||||||
glBindVertexArray(VAO);
|
glBindVertexArray(VAO);
|
||||||
ProgramShaderCache::BindVertexFormat(this);
|
|
||||||
|
|
||||||
// the element buffer is bound directly to the vao, so we must it set for every vao
|
// the element buffer is bound directly to the vao, so we must it set for every vao
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vm->GetIndexBufferHandle());
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vm->GetIndexBufferHandle());
|
||||||
|
@ -77,6 +76,9 @@ GLVertexFormat::GLVertexFormat(const PortableVertexDeclaration& vtx_decl)
|
||||||
SetPointer(ShaderAttrib::TexCoord0 + i, vertex_stride, vtx_decl.texcoords[i]);
|
SetPointer(ShaderAttrib::TexCoord0 + i, vertex_stride, vtx_decl.texcoords[i]);
|
||||||
|
|
||||||
SetPointer(ShaderAttrib::PositionMatrix, vertex_stride, vtx_decl.posmtx);
|
SetPointer(ShaderAttrib::PositionMatrix, vertex_stride, vtx_decl.posmtx);
|
||||||
|
|
||||||
|
// Other code shouldn't have to worry about its vertex formats being randomly unbound
|
||||||
|
ProgramShaderCache::ReBindVertexFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLVertexFormat::~GLVertexFormat()
|
GLVertexFormat::~GLVertexFormat()
|
||||||
|
|
|
@ -496,6 +496,12 @@ void ProgramShaderCache::BindVertexFormat(const GLVertexFormat* vertex_format)
|
||||||
s_last_VAO = new_VAO;
|
s_last_VAO = new_VAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgramShaderCache::ReBindVertexFormat()
|
||||||
|
{
|
||||||
|
if (s_last_VAO)
|
||||||
|
glBindVertexArray(s_last_VAO);
|
||||||
|
}
|
||||||
|
|
||||||
bool ProgramShaderCache::IsValidVertexFormatBound()
|
bool ProgramShaderCache::IsValidVertexFormatBound()
|
||||||
{
|
{
|
||||||
return s_last_VAO != 0 && s_last_VAO != s_attributeless_VAO;
|
return s_last_VAO != 0 && s_last_VAO != s_attributeless_VAO;
|
||||||
|
|
|
@ -69,6 +69,7 @@ class ProgramShaderCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void BindVertexFormat(const GLVertexFormat* vertex_format);
|
static void BindVertexFormat(const GLVertexFormat* vertex_format);
|
||||||
|
static void ReBindVertexFormat();
|
||||||
static bool IsValidVertexFormatBound();
|
static bool IsValidVertexFormatBound();
|
||||||
static void InvalidateVertexFormat();
|
static void InvalidateVertexFormat();
|
||||||
static void InvalidateVertexFormatIfBound(GLuint vao);
|
static void InvalidateVertexFormatIfBound(GLuint vao);
|
||||||
|
|
Loading…
Reference in New Issue