summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-05-22 00:21:57 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-05-30 18:21:01 +0200
commitdf509486c48dd1da9e9e69d9e94a065e0fffbd20 (patch)
tree32f2961fbd05787eee715fccb83934264335ef9e /src/video_core/renderer_opengl
parentrasterizer_opengl: Remove OpenGL core profile (diff)
downloadyuzu-df509486c48dd1da9e9e69d9e94a065e0fffbd20.tar
yuzu-df509486c48dd1da9e9e69d9e94a065e0fffbd20.tar.gz
yuzu-df509486c48dd1da9e9e69d9e94a065e0fffbd20.tar.bz2
yuzu-df509486c48dd1da9e9e69d9e94a065e0fffbd20.tar.lz
yuzu-df509486c48dd1da9e9e69d9e94a065e0fffbd20.tar.xz
yuzu-df509486c48dd1da9e9e69d9e94a065e0fffbd20.tar.zst
yuzu-df509486c48dd1da9e9e69d9e94a065e0fffbd20.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_primitive_assembler.cpp63
-rw-r--r--src/video_core/renderer_opengl/gl_primitive_assembler.h31
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp37
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h2
-rw-r--r--src/video_core/renderer_opengl/maxwell_to_gl.h2
5 files changed, 5 insertions, 130 deletions
diff --git a/src/video_core/renderer_opengl/gl_primitive_assembler.cpp b/src/video_core/renderer_opengl/gl_primitive_assembler.cpp
deleted file mode 100644
index c3e94d917..000000000
--- a/src/video_core/renderer_opengl/gl_primitive_assembler.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include <algorithm>
-#include <array>
-#include "common/assert.h"
-#include "common/common_types.h"
-#include "core/core.h"
-#include "video_core/memory_manager.h"
-#include "video_core/renderer_opengl/gl_buffer_cache.h"
-#include "video_core/renderer_opengl/gl_primitive_assembler.h"
-
-namespace OpenGL {
-
-constexpr u32 TRIANGLES_PER_QUAD = 6;
-constexpr std::array<u32, TRIANGLES_PER_QUAD> QUAD_MAP = {0, 1, 2, 0, 2, 3};
-
-PrimitiveAssembler::PrimitiveAssembler(OGLBufferCache& buffer_cache) : buffer_cache(buffer_cache) {}
-
-PrimitiveAssembler::~PrimitiveAssembler() = default;
-
-std::size_t PrimitiveAssembler::CalculateQuadSize(u32 count) const {
- ASSERT_MSG(count % 4 == 0, "Quad count is expected to be a multiple of 4");
- return (count / 4) * TRIANGLES_PER_QUAD * sizeof(GLuint);
-}
-
-GLintptr PrimitiveAssembler::MakeQuadArray(u32 first, u32 count) {
- const std::size_t size{CalculateQuadSize(count)};
- auto [dst_pointer, index_offset] = buffer_cache.ReserveMemory(size);
-
- for (u32 primitive = 0; primitive < count / 4; ++primitive) {
- for (u32 i = 0; i < TRIANGLES_PER_QUAD; ++i) {
- const u32 index = first + primitive * 4 + QUAD_MAP[i];
- std::memcpy(dst_pointer, &index, sizeof(index));
- dst_pointer += sizeof(index);
- }
- }
-
- return index_offset;
-}
-
-GLintptr PrimitiveAssembler::MakeQuadIndexed(GPUVAddr gpu_addr, std::size_t index_size, u32 count) {
- const std::size_t map_size{CalculateQuadSize(count)};
- auto [dst_pointer, index_offset] = buffer_cache.ReserveMemory(map_size);
-
- auto& memory_manager = Core::System::GetInstance().GPU().MemoryManager();
- const u8* source{memory_manager.GetPointer(gpu_addr)};
-
- for (u32 primitive = 0; primitive < count / 4; ++primitive) {
- for (std::size_t i = 0; i < TRIANGLES_PER_QUAD; ++i) {
- const u32 index = primitive * 4 + QUAD_MAP[i];
- const u8* src_offset = source + (index * index_size);
-
- std::memcpy(dst_pointer, src_offset, index_size);
- dst_pointer += index_size;
- }
- }
-
- return index_offset;
-}
-
-} // namespace OpenGL
diff --git a/src/video_core/renderer_opengl/gl_primitive_assembler.h b/src/video_core/renderer_opengl/gl_primitive_assembler.h
deleted file mode 100644
index 4e87ce4d6..000000000
--- a/src/video_core/renderer_opengl/gl_primitive_assembler.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#pragma once
-
-#include <glad/glad.h>
-
-#include "common/common_types.h"
-
-namespace OpenGL {
-
-class OGLBufferCache;
-
-class PrimitiveAssembler {
-public:
- explicit PrimitiveAssembler(OGLBufferCache& buffer_cache);
- ~PrimitiveAssembler();
-
- /// Calculates the size required by MakeQuadArray and MakeQuadIndexed.
- std::size_t CalculateQuadSize(u32 count) const;
-
- GLintptr MakeQuadArray(u32 first, u32 count);
-
- GLintptr MakeQuadIndexed(GPUVAddr gpu_addr, std::size_t index_size, u32 count);
-
-private:
- OGLBufferCache& buffer_cache;
-};
-
-} // namespace OpenGL \ No newline at end of file
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index f9b6dfeea..5087d9406 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -246,29 +246,6 @@ DrawParameters RasterizerOpenGL::SetupDraw() {
DrawParameters params{};
params.current_instance = gpu.state.current_instance;
- if (regs.draw.topology == Maxwell::PrimitiveTopology::Quads) {
- MICROPROFILE_SCOPE(OpenGL_PrimitiveAssembly);
-
- params.use_indexed = true;
- params.primitive_mode = GL_TRIANGLES;
-
- if (is_indexed) {
- params.index_format = MaxwellToGL::IndexFormat(regs.index_array.format);
- params.count = (regs.index_array.count / 4) * 6;
- params.index_buffer_offset = primitive_assembler.MakeQuadIndexed(
- regs.index_array.IndexStart(), regs.index_array.FormatSizeInBytes(),
- regs.index_array.count);
- params.base_vertex = static_cast<GLint>(regs.vb_element_base);
- } else {
- // MakeQuadArray always generates u32 indexes
- params.index_format = GL_UNSIGNED_INT;
- params.count = (regs.vertex_buffer.count / 4) * 6;
- params.index_buffer_offset = primitive_assembler.MakeQuadArray(
- regs.vertex_buffer.first, regs.vertex_buffer.count);
- }
- return params;
- }
-
params.use_indexed = is_indexed;
params.primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology);
@@ -699,17 +676,9 @@ void RasterizerOpenGL::DrawArrays() {
std::size_t buffer_size = CalculateVertexArraysSize();
- // Add space for index buffer (keeping in mind non-core primitives)
- switch (regs.draw.topology) {
- case Maxwell::PrimitiveTopology::Quads:
- buffer_size = Common::AlignUp(buffer_size, 4) +
- primitive_assembler.CalculateQuadSize(regs.vertex_buffer.count);
- break;
- default:
- if (is_indexed) {
- buffer_size = Common::AlignUp(buffer_size, 4) + CalculateIndexBufferSize();
- }
- break;
+ // Add space for index buffer
+ if (is_indexed) {
+ buffer_size = Common::AlignUp(buffer_size, 4) + CalculateIndexBufferSize();
}
// Uniform space for the 5 shader stages
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index d78094138..f2643f26f 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -23,7 +23,6 @@
#include "video_core/renderer_opengl/gl_buffer_cache.h"
#include "video_core/renderer_opengl/gl_device.h"
#include "video_core/renderer_opengl/gl_global_cache.h"
-#include "video_core/renderer_opengl/gl_primitive_assembler.h"
#include "video_core/renderer_opengl/gl_rasterizer_cache.h"
#include "video_core/renderer_opengl/gl_resource_manager.h"
#include "video_core/renderer_opengl/gl_sampler_cache.h"
@@ -197,7 +196,6 @@ private:
static constexpr std::size_t STREAM_BUFFER_SIZE = 128 * 1024 * 1024;
OGLBufferCache buffer_cache;
- PrimitiveAssembler primitive_assembler{buffer_cache};
BindBuffersRangePushBuffer bind_ubo_pushbuffer{GL_UNIFORM_BUFFER};
BindBuffersRangePushBuffer bind_ssbo_pushbuffer{GL_SHADER_STORAGE_BUFFER};
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h
index ed7b5cff0..e3cabded3 100644
--- a/src/video_core/renderer_opengl/maxwell_to_gl.h
+++ b/src/video_core/renderer_opengl/maxwell_to_gl.h
@@ -128,6 +128,8 @@ inline GLenum PrimitiveTopology(Maxwell::PrimitiveTopology topology) {
return GL_TRIANGLE_STRIP;
case Maxwell::PrimitiveTopology::TriangleFan:
return GL_TRIANGLE_FAN;
+ case Maxwell::PrimitiveTopology::Quads:
+ return GL_QUADS;
default:
LOG_CRITICAL(Render_OpenGL, "Unimplemented topology={}", static_cast<u32>(topology));
UNREACHABLE();