mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 12:35:27 +00:00
OpenGL: Stream vertices + indices
This commit is contained in:
parent
52feed04db
commit
ff002320a5
@ -1653,7 +1653,7 @@ void Renderer::RestoreAPIState()
|
||||
|
||||
VertexManager *vm = (OGL::VertexManager*)g_vertex_manager;
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vm->m_vertex_buffers);
|
||||
vm->m_last_vao = 0;
|
||||
glBindVertexArray(vm->m_last_vao);
|
||||
|
||||
TextureCache::SetStage();
|
||||
}
|
||||
|
@ -85,20 +85,25 @@ void VertexManager::PrepareDrawBuffers(u32 stride)
|
||||
u32 vertex_data_size = IndexGenerator::GetNumVerts() * stride;
|
||||
u32 index_data_size = IndexGenerator::GetIndexLen() * sizeof(u16);
|
||||
|
||||
auto buffer = s_vertexBuffer->Map(vertex_data_size, stride);
|
||||
memcpy(buffer.first, GetVertexBuffer(), vertex_data_size);
|
||||
s_vertexBuffer->Unmap(vertex_data_size);
|
||||
s_baseVertex = buffer.second / stride;
|
||||
|
||||
buffer = s_indexBuffer->Map(index_data_size);
|
||||
memcpy(buffer.first, GetIndexBuffer(), index_data_size);
|
||||
s_indexBuffer->Unmap(index_data_size);
|
||||
s_index_offset = buffer.second;
|
||||
|
||||
ADDSTAT(stats.thisFrame.bytesVertexStreamed, vertex_data_size);
|
||||
ADDSTAT(stats.thisFrame.bytesIndexStreamed, index_data_size);
|
||||
}
|
||||
|
||||
void VertexManager::ResetBuffer(u32 stride)
|
||||
{
|
||||
auto buffer = s_vertexBuffer->Map(MAXVBUFFERSIZE, stride);
|
||||
s_pCurBufferPointer = s_pBaseBufferPointer = buffer.first;
|
||||
s_pEndBufferPointer = buffer.first + MAXVBUFFERSIZE;
|
||||
s_baseVertex = buffer.second / stride;
|
||||
|
||||
buffer = s_indexBuffer->Map(MAXIBUFFERSIZE * sizeof(u16));
|
||||
IndexGenerator::Start((u16*)buffer.first);
|
||||
s_index_offset = buffer.second;
|
||||
}
|
||||
|
||||
void VertexManager::Draw(u32 stride)
|
||||
{
|
||||
u32 index_size = IndexGenerator::GetIndexLen();
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
GLuint m_vertex_buffers;
|
||||
GLuint m_index_buffers;
|
||||
GLuint m_last_vao;
|
||||
protected:
|
||||
virtual void ResetBuffer(u32 stride);
|
||||
private:
|
||||
void Draw(u32 stride);
|
||||
void vFlush() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user