Skip to content
Permalink
Browse files
Merge pull request #6010 from lioncash/vertex
OGL/VertexManager: Make vertex and index buffer handles private
  • Loading branch information
delroth committed Sep 3, 2017
2 parents 632cb35 + 2237a6a commit ab27f0f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
@@ -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->GetIndexBufferHandle());
glBindBuffer(GL_ARRAY_BUFFER, vm->GetVertexBufferHandle());

SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, _vtx_decl.position);

@@ -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->GetVertexBufferHandle());

OGLTexture::SetStage();
}
@@ -61,6 +61,16 @@ void VertexManager::DestroyDeviceObjects()
s_indexBuffer.reset();
}

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

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

void VertexManager::PrepareDrawBuffers(u32 stride)
{
u32 vertex_data_size = IndexGenerator::GetNumVerts() * stride;
@@ -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 GetVertexBufferHandle() const;
GLuint GetIndexBufferHandle() const;

protected:
void ResetBuffer(u32 stride) override;
@@ -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;

0 comments on commit ab27f0f

Please sign in to comment.