diff options
| author | 2019-01-08 16:44:53 -0500 | |
|---|---|---|
| committer | 2019-01-08 16:44:53 -0500 | |
| commit | 912f2a520a77f478a33bbfb426b0aebf3148e5f7 (patch) | |
| tree | 502fdead6b453ad85c816b14c38b34ce8c8b83a8 /src | |
| parent | Merge pull request #1999 from ReinUsesLisp/dirty-shader (diff) | |
| parent | gl_global_cache: Add dummy global cache manager (diff) | |
| download | yuzu-912f2a520a77f478a33bbfb426b0aebf3148e5f7.tar.gz yuzu-912f2a520a77f478a33bbfb426b0aebf3148e5f7.tar.xz yuzu-912f2a520a77f478a33bbfb426b0aebf3148e5f7.zip | |
Merge pull request #2010 from ReinUsesLisp/gmem
gl_global_cache: Add dummy global cache manager
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_global_cache.cpp | 24 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_global_cache.h | 60 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 10 |
5 files changed, 96 insertions, 3 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 0406fbcd9..327db68a5 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -30,6 +30,8 @@ add_library(video_core STATIC | |||
| 30 | renderer_base.h | 30 | renderer_base.h |
| 31 | renderer_opengl/gl_buffer_cache.cpp | 31 | renderer_opengl/gl_buffer_cache.cpp |
| 32 | renderer_opengl/gl_buffer_cache.h | 32 | renderer_opengl/gl_buffer_cache.h |
| 33 | renderer_opengl/gl_global_cache.cpp | ||
| 34 | renderer_opengl/gl_global_cache.h | ||
| 33 | renderer_opengl/gl_primitive_assembler.cpp | 35 | renderer_opengl/gl_primitive_assembler.cpp |
| 34 | renderer_opengl/gl_primitive_assembler.h | 36 | renderer_opengl/gl_primitive_assembler.h |
| 35 | renderer_opengl/gl_rasterizer.cpp | 37 | renderer_opengl/gl_rasterizer.cpp |
diff --git a/src/video_core/renderer_opengl/gl_global_cache.cpp b/src/video_core/renderer_opengl/gl_global_cache.cpp new file mode 100644 index 000000000..7992b82c4 --- /dev/null +++ b/src/video_core/renderer_opengl/gl_global_cache.cpp | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <glad/glad.h> | ||
| 6 | |||
| 7 | #include "video_core/renderer_opengl/gl_global_cache.h" | ||
| 8 | #include "video_core/renderer_opengl/gl_rasterizer.h" | ||
| 9 | #include "video_core/renderer_opengl/utils.h" | ||
| 10 | |||
| 11 | namespace OpenGL { | ||
| 12 | |||
| 13 | CachedGlobalRegion::CachedGlobalRegion(VAddr addr, u32 size) : addr{addr}, size{size} { | ||
| 14 | buffer.Create(); | ||
| 15 | // Bind and unbind the buffer so it gets allocated by the driver | ||
| 16 | glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer.handle); | ||
| 17 | glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); | ||
| 18 | LabelGLObject(GL_BUFFER, buffer.handle, addr, "GlobalMemory"); | ||
| 19 | } | ||
| 20 | |||
| 21 | GlobalRegionCacheOpenGL::GlobalRegionCacheOpenGL(RasterizerOpenGL& rasterizer) | ||
| 22 | : RasterizerCache{rasterizer} {} | ||
| 23 | |||
| 24 | } // namespace OpenGL | ||
diff --git a/src/video_core/renderer_opengl/gl_global_cache.h b/src/video_core/renderer_opengl/gl_global_cache.h new file mode 100644 index 000000000..406a735bc --- /dev/null +++ b/src/video_core/renderer_opengl/gl_global_cache.h | |||
| @@ -0,0 +1,60 @@ | |||
| 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 <memory> | ||
| 8 | #include <glad/glad.h> | ||
| 9 | |||
| 10 | #include "common/common_types.h" | ||
| 11 | #include "video_core/rasterizer_cache.h" | ||
| 12 | #include "video_core/renderer_opengl/gl_resource_manager.h" | ||
| 13 | |||
| 14 | namespace OpenGL { | ||
| 15 | |||
| 16 | namespace GLShader { | ||
| 17 | class GlobalMemoryEntry; | ||
| 18 | } // namespace GLShader | ||
| 19 | |||
| 20 | class RasterizerOpenGL; | ||
| 21 | class CachedGlobalRegion; | ||
| 22 | using GlobalRegion = std::shared_ptr<CachedGlobalRegion>; | ||
| 23 | |||
| 24 | class CachedGlobalRegion final : public RasterizerCacheObject { | ||
| 25 | public: | ||
| 26 | explicit CachedGlobalRegion(VAddr addr, u32 size); | ||
| 27 | |||
| 28 | /// Gets the address of the shader in guest memory, required for cache management | ||
| 29 | VAddr GetAddr() const { | ||
| 30 | return addr; | ||
| 31 | } | ||
| 32 | |||
| 33 | /// Gets the size of the shader in guest memory, required for cache management | ||
| 34 | std::size_t GetSizeInBytes() const { | ||
| 35 | return size; | ||
| 36 | } | ||
| 37 | |||
| 38 | /// Gets the GL program handle for the buffer | ||
| 39 | GLuint GetBufferHandle() const { | ||
| 40 | return buffer.handle; | ||
| 41 | } | ||
| 42 | |||
| 43 | // TODO(Rodrigo): When global memory is written (STG), implement flushing | ||
| 44 | void Flush() override { | ||
| 45 | UNIMPLEMENTED(); | ||
| 46 | } | ||
| 47 | |||
| 48 | private: | ||
| 49 | VAddr addr{}; | ||
| 50 | u32 size{}; | ||
| 51 | |||
| 52 | OGLBuffer buffer; | ||
| 53 | }; | ||
| 54 | |||
| 55 | class GlobalRegionCacheOpenGL final : public RasterizerCache<GlobalRegion> { | ||
| 56 | public: | ||
| 57 | explicit GlobalRegionCacheOpenGL(RasterizerOpenGL& rasterizer); | ||
| 58 | }; | ||
| 59 | |||
| 60 | } // namespace OpenGL | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 37f01d4f7..73567eb8c 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -101,7 +101,7 @@ struct FramebufferCacheKey { | |||
| 101 | 101 | ||
| 102 | RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo& info) | 102 | RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo& info) |
| 103 | : res_cache{*this}, shader_cache{*this}, emu_window{window}, screen_info{info}, | 103 | : res_cache{*this}, shader_cache{*this}, emu_window{window}, screen_info{info}, |
| 104 | buffer_cache(*this, STREAM_BUFFER_SIZE) { | 104 | buffer_cache(*this, STREAM_BUFFER_SIZE), global_cache{*this} { |
| 105 | // Create sampler objects | 105 | // Create sampler objects |
| 106 | for (std::size_t i = 0; i < texture_samplers.size(); ++i) { | 106 | for (std::size_t i = 0; i < texture_samplers.size(); ++i) { |
| 107 | texture_samplers[i].Create(); | 107 | texture_samplers[i].Create(); |
| @@ -763,6 +763,7 @@ void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size) { | |||
| 763 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); | 763 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); |
| 764 | res_cache.InvalidateRegion(addr, size); | 764 | res_cache.InvalidateRegion(addr, size); |
| 765 | shader_cache.InvalidateRegion(addr, size); | 765 | shader_cache.InvalidateRegion(addr, size); |
| 766 | global_cache.InvalidateRegion(addr, size); | ||
| 766 | buffer_cache.InvalidateRegion(addr, size); | 767 | buffer_cache.InvalidateRegion(addr, size); |
| 767 | } | 768 | } |
| 768 | 769 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 8a891ffc7..a53edee6d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include "video_core/rasterizer_cache.h" | 23 | #include "video_core/rasterizer_cache.h" |
| 24 | #include "video_core/rasterizer_interface.h" | 24 | #include "video_core/rasterizer_interface.h" |
| 25 | #include "video_core/renderer_opengl/gl_buffer_cache.h" | 25 | #include "video_core/renderer_opengl/gl_buffer_cache.h" |
| 26 | #include "video_core/renderer_opengl/gl_global_cache.h" | ||
| 26 | #include "video_core/renderer_opengl/gl_primitive_assembler.h" | 27 | #include "video_core/renderer_opengl/gl_primitive_assembler.h" |
| 27 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" | 28 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" |
| 28 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 29 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| @@ -66,6 +67,10 @@ public: | |||
| 66 | static_assert(MaxConstbufferSize % sizeof(GLvec4) == 0, | 67 | static_assert(MaxConstbufferSize % sizeof(GLvec4) == 0, |
| 67 | "The maximum size of a constbuffer must be a multiple of the size of GLvec4"); | 68 | "The maximum size of a constbuffer must be a multiple of the size of GLvec4"); |
| 68 | 69 | ||
| 70 | static constexpr std::size_t MaxGlobalMemorySize = 0x10000; | ||
| 71 | static_assert(MaxGlobalMemorySize % sizeof(float) == 0, | ||
| 72 | "The maximum size of a global memory must be a multiple of the size of float"); | ||
| 73 | |||
| 69 | private: | 74 | private: |
| 70 | class SamplerInfo { | 75 | class SamplerInfo { |
| 71 | public: | 76 | public: |
| @@ -105,7 +110,7 @@ private: | |||
| 105 | bool using_depth_fb = true, bool preserve_contents = true, | 110 | bool using_depth_fb = true, bool preserve_contents = true, |
| 106 | std::optional<std::size_t> single_color_target = {}); | 111 | std::optional<std::size_t> single_color_target = {}); |
| 107 | 112 | ||
| 108 | /* | 113 | /** |
| 109 | * Configures the current constbuffers to use for the draw command. | 114 | * Configures the current constbuffers to use for the draw command. |
| 110 | * @param stage The shader stage to configure buffers for. | 115 | * @param stage The shader stage to configure buffers for. |
| 111 | * @param shader The shader object that contains the specified stage. | 116 | * @param shader The shader object that contains the specified stage. |
| @@ -115,7 +120,7 @@ private: | |||
| 115 | u32 SetupConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, Shader& shader, | 120 | u32 SetupConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, Shader& shader, |
| 116 | GLenum primitive_mode, u32 current_bindpoint); | 121 | GLenum primitive_mode, u32 current_bindpoint); |
| 117 | 122 | ||
| 118 | /* | 123 | /** |
| 119 | * Configures the current textures to use for the draw command. | 124 | * Configures the current textures to use for the draw command. |
| 120 | * @param stage The shader stage to configure textures for. | 125 | * @param stage The shader stage to configure textures for. |
| 121 | * @param shader The shader object that contains the specified stage. | 126 | * @param shader The shader object that contains the specified stage. |
| @@ -185,6 +190,7 @@ private: | |||
| 185 | 190 | ||
| 186 | RasterizerCacheOpenGL res_cache; | 191 | RasterizerCacheOpenGL res_cache; |
| 187 | ShaderCacheOpenGL shader_cache; | 192 | ShaderCacheOpenGL shader_cache; |
| 193 | GlobalRegionCacheOpenGL global_cache; | ||
| 188 | 194 | ||
| 189 | Core::Frontend::EmuWindow& emu_window; | 195 | Core::Frontend::EmuWindow& emu_window; |
| 190 | 196 | ||