summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/Render.cpp
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2018-11-27 17:16:53 +1000
committerStenzek <stenzek@gmail.com>2018-12-04 17:37:25 +1000
commit7afd5cc2fb7e45f2c497e5aed007a017b8461335 (patch)
tree17f445fc7a686cd28859e6c46fb1a32d64a56123 /Source/Core/VideoBackends/OGL/Render.cpp
parent5ca18ff04e6dd69e09a5675db8f9474a51bdfcc0 (diff)
Use main buffers for utility draws
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp69
1 files changed, 21 insertions, 48 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index c43bb0ac87..55de5ec0dc 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -1184,6 +1184,27 @@ void Renderer::SetViewport(float x, float y, float width, float height, float ne
glDepthRangef(near_depth, far_depth);
}
+void Renderer::Draw(u32 base_vertex, u32 num_vertices)
+{
+ glDrawArrays(static_cast<const OGLPipeline*>(m_graphics_pipeline)->GetGLPrimitive(), base_vertex,
+ num_vertices);
+}
+
+void Renderer::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex)
+{
+ if (g_ogl_config.bSupportsGLBaseVertex)
+ {
+ glDrawElementsBaseVertex(static_cast<const OGLPipeline*>(m_graphics_pipeline)->GetGLPrimitive(),
+ num_indices, GL_UNSIGNED_SHORT,
+ static_cast<u16*>(nullptr) + base_index, base_vertex);
+ }
+ else
+ {
+ glDrawElements(static_cast<const OGLPipeline*>(m_graphics_pipeline)->GetGLPrimitive(),
+ num_indices, GL_UNSIGNED_SHORT, static_cast<u16*>(nullptr) + base_index);
+ }
+}
+
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
u32 color, u32 z)
{
@@ -1675,54 +1696,6 @@ void Renderer::SetInterlacingMode()
// TODO
}
-void Renderer::DrawUtilityPipeline(const void* uniforms, u32 uniforms_size, const void* vertices,
- u32 vertex_stride, u32 num_vertices)
-{
- // Copy in uniforms.
- if (uniforms_size > 0)
- UploadUtilityUniforms(uniforms, uniforms_size);
-
- // Draw from base index if there is vertex data.
- if (vertices)
- {
- StreamBuffer* vbuf = static_cast<VertexManager*>(g_vertex_manager.get())->GetVertexBuffer();
- auto buf = vbuf->Map(vertex_stride * num_vertices, vertex_stride);
- std::memcpy(buf.first, vertices, vertex_stride * num_vertices);
- vbuf->Unmap(vertex_stride * num_vertices);
- glDrawArrays(m_graphics_pipeline->GetGLPrimitive(), buf.second / vertex_stride, num_vertices);
- }
- else
- {
- glDrawArrays(m_graphics_pipeline->GetGLPrimitive(), 0, num_vertices);
- }
-}
-
-void Renderer::UploadUtilityUniforms(const void* uniforms, u32 uniforms_size)
-{
- DEBUG_ASSERT(uniforms_size > 0);
-
- auto buf = ProgramShaderCache::GetUniformBuffer()->Map(
- uniforms_size, ProgramShaderCache::GetUniformBufferAlignment());
- std::memcpy(buf.first, uniforms, uniforms_size);
- ProgramShaderCache::GetUniformBuffer()->Unmap(uniforms_size);
- glBindBufferRange(GL_UNIFORM_BUFFER, 1, ProgramShaderCache::GetUniformBuffer()->m_buffer,
- buf.second, uniforms_size);
-
- // This is rather horrible, but because of how the UBOs are bound, this forces it to rebind.
- ProgramShaderCache::InvalidateConstants();
-}
-
-void Renderer::DispatchComputeShader(const AbstractShader* shader, const void* uniforms,
- u32 uniforms_size, u32 groups_x, u32 groups_y, u32 groups_z)
-{
- glUseProgram(static_cast<const OGLShader*>(shader)->GetGLComputeProgramID());
- if (uniforms_size > 0)
- UploadUtilityUniforms(uniforms, uniforms_size);
-
- glDispatchCompute(groups_x, groups_y, groups_z);
- ProgramShaderCache::InvalidateLastProgram();
-}
-
std::unique_ptr<VideoCommon::AsyncShaderCompiler> Renderer::CreateAsyncShaderCompiler()
{
return std::make_unique<SharedContextAsyncShaderCompiler>();