diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/video_core/rasterizer_interface.h | 61 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 269 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 162 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 1 |
5 files changed, 495 insertions, 1 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index df4368f52..e56253c4c 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -11,8 +11,11 @@ add_library(video_core STATIC | |||
| 11 | gpu.h | 11 | gpu.h |
| 12 | memory_manager.cpp | 12 | memory_manager.cpp |
| 13 | memory_manager.h | 13 | memory_manager.h |
| 14 | rasterizer_interface.h | ||
| 14 | renderer_base.cpp | 15 | renderer_base.cpp |
| 15 | renderer_base.h | 16 | renderer_base.h |
| 17 | renderer_opengl/gl_rasterizer.cpp | ||
| 18 | renderer_opengl/gl_rasterizer.h | ||
| 16 | renderer_opengl/gl_rasterizer_cache.cpp | 19 | renderer_opengl/gl_rasterizer_cache.cpp |
| 17 | renderer_opengl/gl_rasterizer_cache.h | 20 | renderer_opengl/gl_rasterizer_cache.h |
| 18 | renderer_opengl/gl_resource_manager.h | 21 | renderer_opengl/gl_resource_manager.h |
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h new file mode 100644 index 000000000..6c7bd0826 --- /dev/null +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | struct ScreenInfo; | ||
| 10 | |||
| 11 | namespace VideoCore { | ||
| 12 | |||
| 13 | class RasterizerInterface { | ||
| 14 | public: | ||
| 15 | virtual ~RasterizerInterface() {} | ||
| 16 | |||
| 17 | /// Draw the current batch of triangles | ||
| 18 | virtual void DrawTriangles() = 0; | ||
| 19 | |||
| 20 | /// Notify rasterizer that the specified Maxwell register has been changed | ||
| 21 | virtual void NotifyMaxwellRegisterChanged(u32 id) = 0; | ||
| 22 | |||
| 23 | /// Notify rasterizer that all caches should be flushed to 3DS memory | ||
| 24 | virtual void FlushAll() = 0; | ||
| 25 | |||
| 26 | /// Notify rasterizer that any caches of the specified region should be flushed to 3DS memory | ||
| 27 | virtual void FlushRegion(PAddr addr, u32 size) = 0; | ||
| 28 | |||
| 29 | /// Notify rasterizer that any caches of the specified region should be invalidated | ||
| 30 | virtual void InvalidateRegion(PAddr addr, u32 size) = 0; | ||
| 31 | |||
| 32 | /// Notify rasterizer that any caches of the specified region should be flushed to 3DS memory | ||
| 33 | /// and invalidated | ||
| 34 | virtual void FlushAndInvalidateRegion(PAddr addr, u32 size) = 0; | ||
| 35 | |||
| 36 | /// Attempt to use a faster method to perform a display transfer with is_texture_copy = 0 | ||
| 37 | virtual bool AccelerateDisplayTransfer(const void* config) { | ||
| 38 | return false; | ||
| 39 | } | ||
| 40 | |||
| 41 | /// Attempt to use a faster method to perform a display transfer with is_texture_copy = 1 | ||
| 42 | virtual bool AccelerateTextureCopy(const void* config) { | ||
| 43 | return false; | ||
| 44 | } | ||
| 45 | |||
| 46 | /// Attempt to use a faster method to fill a region | ||
| 47 | virtual bool AccelerateFill(const void* config) { | ||
| 48 | return false; | ||
| 49 | } | ||
| 50 | |||
| 51 | /// Attempt to use a faster method to display the framebuffer to screen | ||
| 52 | virtual bool AccelerateDisplay(const void* config, PAddr framebuffer_addr, u32 pixel_stride, | ||
| 53 | ScreenInfo& screen_info) { | ||
| 54 | return false; | ||
| 55 | } | ||
| 56 | |||
| 57 | virtual bool AccelerateDrawBatch(bool is_indexed) { | ||
| 58 | return false; | ||
| 59 | } | ||
| 60 | }; | ||
| 61 | } // namespace VideoCore | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp new file mode 100644 index 000000000..24cfff229 --- /dev/null +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -0,0 +1,269 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <memory> | ||
| 6 | #include <string> | ||
| 7 | #include <tuple> | ||
| 8 | #include <utility> | ||
| 9 | #include <glad/glad.h> | ||
| 10 | #include "common/alignment.h" | ||
| 11 | #include "common/assert.h" | ||
| 12 | #include "common/logging/log.h" | ||
| 13 | #include "common/math_util.h" | ||
| 14 | #include "common/microprofile.h" | ||
| 15 | #include "common/scope_exit.h" | ||
| 16 | #include "common/vector_math.h" | ||
| 17 | #include "core/settings.h" | ||
| 18 | #include "video_core/renderer_opengl/gl_rasterizer.h" | ||
| 19 | #include "video_core/renderer_opengl/gl_shader_gen.h" | ||
| 20 | #include "video_core/renderer_opengl/renderer_opengl.h" | ||
| 21 | |||
| 22 | using PixelFormat = SurfaceParams::PixelFormat; | ||
| 23 | using SurfaceType = SurfaceParams::SurfaceType; | ||
| 24 | |||
| 25 | MICROPROFILE_DEFINE(OpenGL_VAO, "OpenGL", "Vertex Array Setup", MP_RGB(128, 128, 192)); | ||
| 26 | MICROPROFILE_DEFINE(OpenGL_VS, "OpenGL", "Vertex Shader Setup", MP_RGB(128, 128, 192)); | ||
| 27 | MICROPROFILE_DEFINE(OpenGL_FS, "OpenGL", "Fragment Shader Setup", MP_RGB(128, 128, 192)); | ||
| 28 | MICROPROFILE_DEFINE(OpenGL_Drawing, "OpenGL", "Drawing", MP_RGB(128, 128, 192)); | ||
| 29 | MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255)); | ||
| 30 | MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); | ||
| 31 | |||
| 32 | enum class UniformBindings : GLuint { Common, VS, FS }; | ||
| 33 | |||
| 34 | static void SetShaderUniformBlockBinding(GLuint shader, const char* name, UniformBindings binding, | ||
| 35 | size_t expected_size) { | ||
| 36 | GLuint ub_index = glGetUniformBlockIndex(shader, name); | ||
| 37 | if (ub_index != GL_INVALID_INDEX) { | ||
| 38 | GLint ub_size = 0; | ||
| 39 | glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size); | ||
| 40 | ASSERT_MSG(ub_size == expected_size, | ||
| 41 | "Uniform block size did not match! Got %d, expected %zu", | ||
| 42 | static_cast<int>(ub_size), expected_size); | ||
| 43 | glUniformBlockBinding(shader, ub_index, static_cast<GLuint>(binding)); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | static void SetShaderUniformBlockBindings(GLuint shader) { | ||
| 48 | SetShaderUniformBlockBinding(shader, "shader_data", UniformBindings::Common, | ||
| 49 | sizeof(RasterizerOpenGL::UniformData)); | ||
| 50 | SetShaderUniformBlockBinding(shader, "vs_config", UniformBindings::VS, | ||
| 51 | sizeof(RasterizerOpenGL::VSUniformData)); | ||
| 52 | SetShaderUniformBlockBinding(shader, "fs_config", UniformBindings::FS, | ||
| 53 | sizeof(RasterizerOpenGL::FSUniformData)); | ||
| 54 | } | ||
| 55 | |||
| 56 | RasterizerOpenGL::RasterizerOpenGL() { | ||
| 57 | has_ARB_buffer_storage = false; | ||
| 58 | has_ARB_direct_state_access = false; | ||
| 59 | has_ARB_separate_shader_objects = false; | ||
| 60 | has_ARB_vertex_attrib_binding = false; | ||
| 61 | |||
| 62 | GLint ext_num; | ||
| 63 | glGetIntegerv(GL_NUM_EXTENSIONS, &ext_num); | ||
| 64 | for (GLint i = 0; i < ext_num; i++) { | ||
| 65 | std::string extension{reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i))}; | ||
| 66 | |||
| 67 | if (extension == "GL_ARB_buffer_storage") { | ||
| 68 | has_ARB_buffer_storage = true; | ||
| 69 | } else if (extension == "GL_ARB_direct_state_access") { | ||
| 70 | has_ARB_direct_state_access = true; | ||
| 71 | } else if (extension == "GL_ARB_separate_shader_objects") { | ||
| 72 | has_ARB_separate_shader_objects = true; | ||
| 73 | } else if (extension == "GL_ARB_vertex_attrib_binding") { | ||
| 74 | has_ARB_vertex_attrib_binding = true; | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | // Clipping plane 0 is always enabled for PICA fixed clip plane z <= 0 | ||
| 79 | state.clip_distance[0] = true; | ||
| 80 | |||
| 81 | // Generate VBO, VAO and UBO | ||
| 82 | vertex_buffer = OGLStreamBuffer::MakeBuffer(GLAD_GL_ARB_buffer_storage, GL_ARRAY_BUFFER); | ||
| 83 | vertex_buffer->Create(VERTEX_BUFFER_SIZE, VERTEX_BUFFER_SIZE / 2); | ||
| 84 | sw_vao.Create(); | ||
| 85 | uniform_buffer.Create(); | ||
| 86 | |||
| 87 | state.draw.vertex_array = sw_vao.handle; | ||
| 88 | state.draw.vertex_buffer = vertex_buffer->GetHandle(); | ||
| 89 | state.draw.uniform_buffer = uniform_buffer.handle; | ||
| 90 | state.Apply(); | ||
| 91 | |||
| 92 | glBufferData(GL_UNIFORM_BUFFER, sizeof(UniformData), nullptr, GL_STATIC_DRAW); | ||
| 93 | glBindBufferBase(GL_UNIFORM_BUFFER, 0, uniform_buffer.handle); | ||
| 94 | |||
| 95 | uniform_block_data.dirty = true; | ||
| 96 | |||
| 97 | // Create render framebuffer | ||
| 98 | framebuffer.Create(); | ||
| 99 | |||
| 100 | if (has_ARB_separate_shader_objects) { | ||
| 101 | hw_vao.Create(); | ||
| 102 | hw_vao_enabled_attributes.fill(false); | ||
| 103 | |||
| 104 | stream_buffer = OGLStreamBuffer::MakeBuffer(has_ARB_buffer_storage, GL_ARRAY_BUFFER); | ||
| 105 | stream_buffer->Create(STREAM_BUFFER_SIZE, STREAM_BUFFER_SIZE / 2); | ||
| 106 | state.draw.vertex_buffer = stream_buffer->GetHandle(); | ||
| 107 | |||
| 108 | pipeline.Create(); | ||
| 109 | vs_input_index_min = 0; | ||
| 110 | vs_input_index_max = 0; | ||
| 111 | state.draw.program_pipeline = pipeline.handle; | ||
| 112 | state.draw.shader_program = 0; | ||
| 113 | state.draw.vertex_array = hw_vao.handle; | ||
| 114 | state.Apply(); | ||
| 115 | |||
| 116 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, stream_buffer->GetHandle()); | ||
| 117 | |||
| 118 | vs_uniform_buffer.Create(); | ||
| 119 | glBindBuffer(GL_UNIFORM_BUFFER, vs_uniform_buffer.handle); | ||
| 120 | glBufferData(GL_UNIFORM_BUFFER, sizeof(VSUniformData), nullptr, GL_STREAM_COPY); | ||
| 121 | glBindBufferBase(GL_UNIFORM_BUFFER, 1, vs_uniform_buffer.handle); | ||
| 122 | } else { | ||
| 123 | UNIMPLEMENTED(); | ||
| 124 | } | ||
| 125 | |||
| 126 | accelerate_draw = AccelDraw::Disabled; | ||
| 127 | |||
| 128 | glEnable(GL_BLEND); | ||
| 129 | |||
| 130 | // Sync fixed function OpenGL state | ||
| 131 | SyncClipEnabled(); | ||
| 132 | SyncClipCoef(); | ||
| 133 | SyncCullMode(); | ||
| 134 | SyncBlendEnabled(); | ||
| 135 | SyncBlendFuncs(); | ||
| 136 | SyncBlendColor(); | ||
| 137 | } | ||
| 138 | |||
| 139 | RasterizerOpenGL::~RasterizerOpenGL() { | ||
| 140 | if (stream_buffer != nullptr) { | ||
| 141 | state.draw.vertex_buffer = stream_buffer->GetHandle(); | ||
| 142 | state.Apply(); | ||
| 143 | stream_buffer->Release(); | ||
| 144 | } | ||
| 145 | } | ||
| 146 | |||
| 147 | static constexpr std::array<GLenum, 4> vs_attrib_types{ | ||
| 148 | GL_BYTE, // VertexAttributeFormat::BYTE | ||
| 149 | GL_UNSIGNED_BYTE, // VertexAttributeFormat::UBYTE | ||
| 150 | GL_SHORT, // VertexAttributeFormat::SHORT | ||
| 151 | GL_FLOAT // VertexAttributeFormat::FLOAT | ||
| 152 | }; | ||
| 153 | |||
| 154 | void RasterizerOpenGL::AnalyzeVertexArray(bool is_indexed) { | ||
| 155 | UNIMPLEMENTED(); | ||
| 156 | } | ||
| 157 | |||
| 158 | void RasterizerOpenGL::SetupVertexArray(u8* array_ptr, GLintptr buffer_offset) { | ||
| 159 | MICROPROFILE_SCOPE(OpenGL_VAO); | ||
| 160 | UNIMPLEMENTED(); | ||
| 161 | } | ||
| 162 | |||
| 163 | void RasterizerOpenGL::SetupVertexShader(VSUniformData* ub_ptr, GLintptr buffer_offset) { | ||
| 164 | MICROPROFILE_SCOPE(OpenGL_VS); | ||
| 165 | UNIMPLEMENTED(); | ||
| 166 | } | ||
| 167 | |||
| 168 | void RasterizerOpenGL::SetupFragmentShader(FSUniformData* ub_ptr, GLintptr buffer_offset) { | ||
| 169 | MICROPROFILE_SCOPE(OpenGL_FS); | ||
| 170 | UNIMPLEMENTED(); | ||
| 171 | } | ||
| 172 | |||
| 173 | bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) { | ||
| 174 | if (!has_ARB_separate_shader_objects) { | ||
| 175 | UNIMPLEMENTED(); | ||
| 176 | return false; | ||
| 177 | } | ||
| 178 | |||
| 179 | accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; | ||
| 180 | DrawTriangles(); | ||
| 181 | |||
| 182 | return true; | ||
| 183 | } | ||
| 184 | |||
| 185 | void RasterizerOpenGL::DrawTriangles() { | ||
| 186 | MICROPROFILE_SCOPE(OpenGL_Drawing); | ||
| 187 | UNIMPLEMENTED(); | ||
| 188 | } | ||
| 189 | |||
| 190 | void RasterizerOpenGL::NotifyMaxwellRegisterChanged(u32 id) {} | ||
| 191 | |||
| 192 | void RasterizerOpenGL::FlushAll() { | ||
| 193 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); | ||
| 194 | res_cache.FlushAll(); | ||
| 195 | } | ||
| 196 | |||
| 197 | void RasterizerOpenGL::FlushRegion(PAddr addr, u32 size) { | ||
| 198 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); | ||
| 199 | res_cache.FlushRegion(addr, size); | ||
| 200 | } | ||
| 201 | |||
| 202 | void RasterizerOpenGL::InvalidateRegion(PAddr addr, u32 size) { | ||
| 203 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); | ||
| 204 | res_cache.InvalidateRegion(addr, size, nullptr); | ||
| 205 | } | ||
| 206 | |||
| 207 | void RasterizerOpenGL::FlushAndInvalidateRegion(PAddr addr, u32 size) { | ||
| 208 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); | ||
| 209 | res_cache.FlushRegion(addr, size); | ||
| 210 | res_cache.InvalidateRegion(addr, size, nullptr); | ||
| 211 | } | ||
| 212 | |||
| 213 | bool RasterizerOpenGL::AccelerateDisplayTransfer(const void* config) { | ||
| 214 | MICROPROFILE_SCOPE(OpenGL_Blits); | ||
| 215 | UNIMPLEMENTED(); | ||
| 216 | return true; | ||
| 217 | } | ||
| 218 | |||
| 219 | bool RasterizerOpenGL::AccelerateTextureCopy(const void* config) { | ||
| 220 | UNIMPLEMENTED(); | ||
| 221 | return true; | ||
| 222 | } | ||
| 223 | |||
| 224 | bool RasterizerOpenGL::AccelerateFill(const void* config) { | ||
| 225 | UNIMPLEMENTED(); | ||
| 226 | return true; | ||
| 227 | } | ||
| 228 | |||
| 229 | bool RasterizerOpenGL::AccelerateDisplay(const void* config, PAddr framebuffer_addr, | ||
| 230 | u32 pixel_stride, ScreenInfo& screen_info) { | ||
| 231 | UNIMPLEMENTED(); | ||
| 232 | return true; | ||
| 233 | } | ||
| 234 | |||
| 235 | void RasterizerOpenGL::SetShader() { | ||
| 236 | UNIMPLEMENTED(); | ||
| 237 | } | ||
| 238 | |||
| 239 | void RasterizerOpenGL::SyncClipEnabled() { | ||
| 240 | UNIMPLEMENTED(); | ||
| 241 | } | ||
| 242 | |||
| 243 | void RasterizerOpenGL::SyncClipCoef() { | ||
| 244 | UNIMPLEMENTED(); | ||
| 245 | } | ||
| 246 | |||
| 247 | void RasterizerOpenGL::SyncCullMode() { | ||
| 248 | UNIMPLEMENTED(); | ||
| 249 | } | ||
| 250 | |||
| 251 | void RasterizerOpenGL::SyncDepthScale() { | ||
| 252 | UNIMPLEMENTED(); | ||
| 253 | } | ||
| 254 | |||
| 255 | void RasterizerOpenGL::SyncDepthOffset() { | ||
| 256 | UNIMPLEMENTED(); | ||
| 257 | } | ||
| 258 | |||
| 259 | void RasterizerOpenGL::SyncBlendEnabled() { | ||
| 260 | UNIMPLEMENTED(); | ||
| 261 | } | ||
| 262 | |||
| 263 | void RasterizerOpenGL::SyncBlendFuncs() { | ||
| 264 | UNIMPLEMENTED(); | ||
| 265 | } | ||
| 266 | |||
| 267 | void RasterizerOpenGL::SyncBlendColor() { | ||
| 268 | UNIMPLEMENTED(); | ||
| 269 | } | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h new file mode 100644 index 000000000..893fc530f --- /dev/null +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -0,0 +1,162 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include <cstddef> | ||
| 9 | #include <cstring> | ||
| 10 | #include <memory> | ||
| 11 | #include <unordered_map> | ||
| 12 | #include <vector> | ||
| 13 | #include <glad/glad.h> | ||
| 14 | #include "common/bit_field.h" | ||
| 15 | #include "common/common_types.h" | ||
| 16 | #include "common/hash.h" | ||
| 17 | #include "common/vector_math.h" | ||
| 18 | #include "video_core/rasterizer_interface.h" | ||
| 19 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" | ||
| 20 | #include "video_core/renderer_opengl/gl_resource_manager.h" | ||
| 21 | #include "video_core/renderer_opengl/gl_shader_gen.h" | ||
| 22 | #include "video_core/renderer_opengl/gl_state.h" | ||
| 23 | #include "video_core/renderer_opengl/gl_stream_buffer.h" | ||
| 24 | |||
| 25 | struct ScreenInfo; | ||
| 26 | |||
| 27 | class RasterizerOpenGL : public VideoCore::RasterizerInterface { | ||
| 28 | public: | ||
| 29 | RasterizerOpenGL(); | ||
| 30 | ~RasterizerOpenGL() override; | ||
| 31 | |||
| 32 | void DrawTriangles() override; | ||
| 33 | void NotifyMaxwellRegisterChanged(u32 id) override; | ||
| 34 | void FlushAll() override; | ||
| 35 | void FlushRegion(PAddr addr, u32 size) override; | ||
| 36 | void InvalidateRegion(PAddr addr, u32 size) override; | ||
| 37 | void FlushAndInvalidateRegion(PAddr addr, u32 size) override; | ||
| 38 | bool AccelerateDisplayTransfer(const void* config) override; | ||
| 39 | bool AccelerateTextureCopy(const void* config) override; | ||
| 40 | bool AccelerateFill(const void* config) override; | ||
| 41 | bool AccelerateDisplay(const void* config, PAddr framebuffer_addr, u32 pixel_stride, | ||
| 42 | ScreenInfo& screen_info) override; | ||
| 43 | bool AccelerateDrawBatch(bool is_indexed) override; | ||
| 44 | |||
| 45 | struct VertexShader { | ||
| 46 | OGLShader shader; | ||
| 47 | }; | ||
| 48 | |||
| 49 | struct FragmentShader { | ||
| 50 | OGLShader shader; | ||
| 51 | }; | ||
| 52 | |||
| 53 | /// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned | ||
| 54 | // NOTE: Always keep a vec4 at the end. The GL spec is not clear wether the alignment at | ||
| 55 | // the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not. | ||
| 56 | // Not following that rule will cause problems on some AMD drivers. | ||
| 57 | struct UniformData {}; | ||
| 58 | |||
| 59 | // static_assert( | ||
| 60 | // sizeof(UniformData) == 0x460, | ||
| 61 | // "The size of the UniformData structure has changed, update the structure in the shader"); | ||
| 62 | static_assert(sizeof(UniformData) < 16384, | ||
| 63 | "UniformData structure must be less than 16kb as per the OpenGL spec"); | ||
| 64 | |||
| 65 | struct VSUniformData {}; | ||
| 66 | // static_assert( | ||
| 67 | // sizeof(VSUniformData) == 1856, | ||
| 68 | // "The size of the VSUniformData structure has changed, update the structure in the | ||
| 69 | // shader"); | ||
| 70 | static_assert(sizeof(VSUniformData) < 16384, | ||
| 71 | "VSUniformData structure must be less than 16kb as per the OpenGL spec"); | ||
| 72 | |||
| 73 | struct FSUniformData {}; | ||
| 74 | // static_assert( | ||
| 75 | // sizeof(FSUniformData) == 1856, | ||
| 76 | // "The size of the FSUniformData structure has changed, update the structure in the | ||
| 77 | // shader"); | ||
| 78 | static_assert(sizeof(FSUniformData) < 16384, | ||
| 79 | "FSUniformData structure must be less than 16kb as per the OpenGL spec"); | ||
| 80 | |||
| 81 | private: | ||
| 82 | struct SamplerInfo {}; | ||
| 83 | |||
| 84 | /// Syncs the clip enabled status to match the guest state | ||
| 85 | void SyncClipEnabled(); | ||
| 86 | |||
| 87 | /// Syncs the clip coefficients to match the guest state | ||
| 88 | void SyncClipCoef(); | ||
| 89 | |||
| 90 | /// Sets the OpenGL shader in accordance with the current guest state | ||
| 91 | void SetShader(); | ||
| 92 | |||
| 93 | /// Syncs the cull mode to match the guest state | ||
| 94 | void SyncCullMode(); | ||
| 95 | |||
| 96 | /// Syncs the depth scale to match the guest state | ||
| 97 | void SyncDepthScale(); | ||
| 98 | |||
| 99 | /// Syncs the depth offset to match the guest state | ||
| 100 | void SyncDepthOffset(); | ||
| 101 | |||
| 102 | /// Syncs the blend enabled status to match the guest state | ||
| 103 | void SyncBlendEnabled(); | ||
| 104 | |||
| 105 | /// Syncs the blend functions to match the guest state | ||
| 106 | void SyncBlendFuncs(); | ||
| 107 | |||
| 108 | /// Syncs the blend color to match the guest state | ||
| 109 | void SyncBlendColor(); | ||
| 110 | |||
| 111 | bool has_ARB_buffer_storage; | ||
| 112 | bool has_ARB_direct_state_access; | ||
| 113 | bool has_ARB_separate_shader_objects; | ||
| 114 | bool has_ARB_vertex_attrib_binding; | ||
| 115 | |||
| 116 | OpenGLState state; | ||
| 117 | |||
| 118 | RasterizerCacheOpenGL res_cache; | ||
| 119 | |||
| 120 | struct { | ||
| 121 | UniformData data; | ||
| 122 | bool dirty; | ||
| 123 | } uniform_block_data = {}; | ||
| 124 | |||
| 125 | OGLPipeline pipeline; | ||
| 126 | OGLVertexArray sw_vao; | ||
| 127 | OGLVertexArray hw_vao; | ||
| 128 | std::array<bool, 16> hw_vao_enabled_attributes; | ||
| 129 | |||
| 130 | std::array<SamplerInfo, 3> texture_samplers; | ||
| 131 | static constexpr size_t VERTEX_BUFFER_SIZE = 128 * 1024 * 1024; | ||
| 132 | std::unique_ptr<OGLStreamBuffer> vertex_buffer; | ||
| 133 | OGLBuffer uniform_buffer; | ||
| 134 | OGLFramebuffer framebuffer; | ||
| 135 | |||
| 136 | static constexpr size_t STREAM_BUFFER_SIZE = 4 * 1024 * 1024; | ||
| 137 | std::unique_ptr<OGLStreamBuffer> stream_buffer; | ||
| 138 | |||
| 139 | GLint vs_input_index_min; | ||
| 140 | GLint vs_input_index_max; | ||
| 141 | GLsizeiptr vs_input_size; | ||
| 142 | |||
| 143 | void AnalyzeVertexArray(bool is_indexed); | ||
| 144 | void SetupVertexArray(u8* array_ptr, GLintptr buffer_offset); | ||
| 145 | |||
| 146 | OGLBuffer vs_uniform_buffer; | ||
| 147 | std::unordered_map<GLShader::MaxwellVSConfig, VertexShader*> vs_shader_map; | ||
| 148 | std::unordered_map<std::string, VertexShader> vs_shader_cache; | ||
| 149 | OGLShader vs_default_shader; | ||
| 150 | |||
| 151 | void SetupVertexShader(VSUniformData* ub_ptr, GLintptr buffer_offset); | ||
| 152 | |||
| 153 | OGLBuffer fs_uniform_buffer; | ||
| 154 | std::unordered_map<GLShader::MaxwellFSConfig, FragmentShader*> fs_shader_map; | ||
| 155 | std::unordered_map<std::string, FragmentShader> fs_shader_cache; | ||
| 156 | OGLShader fs_default_shader; | ||
| 157 | |||
| 158 | void SetupFragmentShader(FSUniformData* ub_ptr, GLintptr buffer_offset); | ||
| 159 | |||
| 160 | enum class AccelDraw { Disabled, Arrays, Indexed }; | ||
| 161 | AccelDraw accelerate_draw; | ||
| 162 | }; | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index e481139af..884637ca5 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -26,7 +26,6 @@ | |||
| 26 | #include "core/settings.h" | 26 | #include "core/settings.h" |
| 27 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" | 27 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" |
| 28 | #include "video_core/renderer_opengl/gl_state.h" | 28 | #include "video_core/renderer_opengl/gl_state.h" |
| 29 | #include "video_core/texture/texture_decode.h" | ||
| 30 | #include "video_core/utils.h" | 29 | #include "video_core/utils.h" |
| 31 | #include "video_core/video_core.h" | 30 | #include "video_core/video_core.h" |
| 32 | 31 | ||