Skip to content

Commit

Permalink
OGL/VertexManager: Make vertex and index buffer names private
Browse files Browse the repository at this point in the history
These are only ever read, but not written to outside of the VertexManager class.
  • Loading branch information
lioncash committed Sep 2, 2017
1 parent 657195f commit 1dc46d7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ GLVertexFormat::GLVertexFormat(const PortableVertexDeclaration& _vtx_decl)
ProgramShaderCache::BindVertexFormat(this);

// the element buffer is bound directly to the vao, so we must it set for every vao
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vm->m_index_buffers);
glBindBuffer(GL_ARRAY_BUFFER, vm->m_vertex_buffers);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vm->GetIndexBufferName());
glBindBuffer(GL_ARRAY_BUFFER, vm->GetVertexBufferName());

SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, _vtx_decl.position);

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ void Renderer::RestoreAPIState()

ProgramShaderCache::BindLastVertexFormat();
const VertexManager* const vm = static_cast<VertexManager*>(g_vertex_manager.get());
glBindBuffer(GL_ARRAY_BUFFER, vm->m_vertex_buffers);
glBindBuffer(GL_ARRAY_BUFFER, vm->GetVertexBufferName());

OGLTexture::SetStage();
}
Expand Down
10 changes: 10 additions & 0 deletions Source/Core/VideoBackends/OGL/VertexManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ void VertexManager::DestroyDeviceObjects()
s_indexBuffer.reset();
}

GLuint VertexManager::GetVertexBufferName() const
{
return m_vertex_buffers;
}

GLuint VertexManager::GetIndexBufferName() const
{
return m_index_buffers;
}

void VertexManager::PrepareDrawBuffers(u32 stride)
{
u32 vertex_data_size = IndexGenerator::GetNumVerts() * stride;
Expand Down
8 changes: 5 additions & 3 deletions Source/Core/VideoBackends/OGL/VertexManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ class VertexManager : public VertexManagerBase
void CreateDeviceObjects() override;
void DestroyDeviceObjects() override;

// NativeVertexFormat use this
GLuint m_vertex_buffers;
GLuint m_index_buffers;
GLuint GetVertexBufferName() const;
GLuint GetIndexBufferName() const;

protected:
void ResetBuffer(u32 stride) override;
Expand All @@ -49,6 +48,9 @@ class VertexManager : public VertexManagerBase
void vFlush() override;
void PrepareDrawBuffers(u32 stride);

GLuint m_vertex_buffers;
GLuint m_index_buffers;

// Alternative buffers in CPU memory for primatives we are going to discard.
std::vector<u8> m_cpu_v_buffer;
std::vector<u16> m_cpu_i_buffer;
Expand Down

0 comments on commit 1dc46d7

Please sign in to comment.