diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/video_core/rasterizer_cache.h | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.h | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_global_cache.h | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 25 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 28 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.h | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_buffer_cache.h | 7 |
8 files changed, 58 insertions, 34 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c7be31db..04018233f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt | |||
| @@ -51,7 +51,10 @@ if (MSVC) | |||
| 51 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE) | 51 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE) |
| 52 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) | 52 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) |
| 53 | else() | 53 | else() |
| 54 | add_compile_options("-Wno-attributes") | 54 | add_compile_options( |
| 55 | -Wall | ||
| 56 | -Wno-attributes | ||
| 57 | ) | ||
| 55 | 58 | ||
| 56 | if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) | 59 | if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) |
| 57 | add_compile_options("-stdlib=libc++") | 60 | add_compile_options("-stdlib=libc++") |
diff --git a/src/video_core/rasterizer_cache.h b/src/video_core/rasterizer_cache.h index 291772186..f820f3ed9 100644 --- a/src/video_core/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache.h | |||
| @@ -37,9 +37,6 @@ public: | |||
| 37 | /// Gets the size of the shader in guest memory, required for cache management | 37 | /// Gets the size of the shader in guest memory, required for cache management |
| 38 | virtual std::size_t GetSizeInBytes() const = 0; | 38 | virtual std::size_t GetSizeInBytes() const = 0; |
| 39 | 39 | ||
| 40 | /// Wriets any cached resources back to memory | ||
| 41 | virtual void Flush() = 0; | ||
| 42 | |||
| 43 | /// Sets whether the cached object should be considered registered | 40 | /// Sets whether the cached object should be considered registered |
| 44 | void SetIsRegistered(bool registered) { | 41 | void SetIsRegistered(bool registered) { |
| 45 | is_registered = registered; | 42 | is_registered = registered; |
| @@ -158,6 +155,8 @@ protected: | |||
| 158 | return ++modified_ticks; | 155 | return ++modified_ticks; |
| 159 | } | 156 | } |
| 160 | 157 | ||
| 158 | virtual void FlushObjectInner(const T& object) = 0; | ||
| 159 | |||
| 161 | /// Flushes the specified object, updating appropriate cache state as needed | 160 | /// Flushes the specified object, updating appropriate cache state as needed |
| 162 | void FlushObject(const T& object) { | 161 | void FlushObject(const T& object) { |
| 163 | std::lock_guard lock{mutex}; | 162 | std::lock_guard lock{mutex}; |
| @@ -165,7 +164,7 @@ protected: | |||
| 165 | if (!object->IsDirty()) { | 164 | if (!object->IsDirty()) { |
| 166 | return; | 165 | return; |
| 167 | } | 166 | } |
| 168 | object->Flush(); | 167 | FlushObjectInner(object); |
| 169 | object->MarkAsModified(false, *this); | 168 | object->MarkAsModified(false, *this); |
| 170 | } | 169 | } |
| 171 | 170 | ||
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h index fc33aa433..f9247a40e 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.h +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h | |||
| @@ -42,9 +42,6 @@ public: | |||
| 42 | return alignment; | 42 | return alignment; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | // We do not have to flush this cache as things in it are never modified by us. | ||
| 46 | void Flush() override {} | ||
| 47 | |||
| 48 | private: | 45 | private: |
| 49 | VAddr cpu_addr{}; | 46 | VAddr cpu_addr{}; |
| 50 | std::size_t size{}; | 47 | std::size_t size{}; |
| @@ -75,6 +72,9 @@ public: | |||
| 75 | protected: | 72 | protected: |
| 76 | void AlignBuffer(std::size_t alignment); | 73 | void AlignBuffer(std::size_t alignment); |
| 77 | 74 | ||
| 75 | // We do not have to flush this cache as things in it are never modified by us. | ||
| 76 | void FlushObjectInner(const std::shared_ptr<CachedBufferEntry>& object) override {} | ||
| 77 | |||
| 78 | private: | 78 | private: |
| 79 | OGLStreamBuffer stream_buffer; | 79 | OGLStreamBuffer stream_buffer; |
| 80 | 80 | ||
diff --git a/src/video_core/renderer_opengl/gl_global_cache.h b/src/video_core/renderer_opengl/gl_global_cache.h index 196e6e278..2d467a240 100644 --- a/src/video_core/renderer_opengl/gl_global_cache.h +++ b/src/video_core/renderer_opengl/gl_global_cache.h | |||
| @@ -46,7 +46,7 @@ public: | |||
| 46 | /// Reloads the global region from guest memory | 46 | /// Reloads the global region from guest memory |
| 47 | void Reload(u32 size_); | 47 | void Reload(u32 size_); |
| 48 | 48 | ||
| 49 | void Flush() override; | 49 | void Flush(); |
| 50 | 50 | ||
| 51 | private: | 51 | private: |
| 52 | VAddr cpu_addr{}; | 52 | VAddr cpu_addr{}; |
| @@ -65,6 +65,11 @@ public: | |||
| 65 | GlobalRegion GetGlobalRegion(const GLShader::GlobalMemoryEntry& descriptor, | 65 | GlobalRegion GetGlobalRegion(const GLShader::GlobalMemoryEntry& descriptor, |
| 66 | Tegra::Engines::Maxwell3D::Regs::ShaderStage stage); | 66 | Tegra::Engines::Maxwell3D::Regs::ShaderStage stage); |
| 67 | 67 | ||
| 68 | protected: | ||
| 69 | void FlushObjectInner(const GlobalRegion& object) override { | ||
| 70 | object->Flush(); | ||
| 71 | } | ||
| 72 | |||
| 68 | private: | 73 | private: |
| 69 | GlobalRegion TryGetReservedGlobalRegion(CacheAddr addr, u32 size) const; | 74 | GlobalRegion TryGetReservedGlobalRegion(CacheAddr addr, u32 size) const; |
| 70 | GlobalRegion GetUncachedGlobalRegion(GPUVAddr addr, u8* host_ptr, u32 size); | 75 | GlobalRegion GetUncachedGlobalRegion(GPUVAddr addr, u8* host_ptr, u32 size); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 5a25f5b37..7d8fb670e 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -628,9 +628,11 @@ CachedSurface::CachedSurface(const SurfaceParams& params) | |||
| 628 | } | 628 | } |
| 629 | 629 | ||
| 630 | MICROPROFILE_DEFINE(OpenGL_SurfaceLoad, "OpenGL", "Surface Load", MP_RGB(128, 192, 64)); | 630 | MICROPROFILE_DEFINE(OpenGL_SurfaceLoad, "OpenGL", "Surface Load", MP_RGB(128, 192, 64)); |
| 631 | void CachedSurface::LoadGLBuffer() { | 631 | void CachedSurface::LoadGLBuffer(RasterizerTemporaryMemory& res_cache_tmp_mem) { |
| 632 | MICROPROFILE_SCOPE(OpenGL_SurfaceLoad); | 632 | MICROPROFILE_SCOPE(OpenGL_SurfaceLoad); |
| 633 | gl_buffer.resize(params.max_mip_level); | 633 | auto& gl_buffer = res_cache_tmp_mem.gl_buffer; |
| 634 | if (gl_buffer.size() < params.max_mip_level) | ||
| 635 | gl_buffer.resize(params.max_mip_level); | ||
| 634 | for (u32 i = 0; i < params.max_mip_level; i++) | 636 | for (u32 i = 0; i < params.max_mip_level; i++) |
| 635 | gl_buffer[i].resize(params.GetMipmapSizeGL(i)); | 637 | gl_buffer[i].resize(params.GetMipmapSizeGL(i)); |
| 636 | if (params.is_tiled) { | 638 | if (params.is_tiled) { |
| @@ -671,13 +673,13 @@ void CachedSurface::LoadGLBuffer() { | |||
| 671 | } | 673 | } |
| 672 | 674 | ||
| 673 | MICROPROFILE_DEFINE(OpenGL_SurfaceFlush, "OpenGL", "Surface Flush", MP_RGB(128, 192, 64)); | 675 | MICROPROFILE_DEFINE(OpenGL_SurfaceFlush, "OpenGL", "Surface Flush", MP_RGB(128, 192, 64)); |
| 674 | void CachedSurface::FlushGLBuffer() { | 676 | void CachedSurface::FlushGLBuffer(RasterizerTemporaryMemory& res_cache_tmp_mem) { |
| 675 | MICROPROFILE_SCOPE(OpenGL_SurfaceFlush); | 677 | MICROPROFILE_SCOPE(OpenGL_SurfaceFlush); |
| 676 | 678 | ||
| 677 | ASSERT_MSG(!IsPixelFormatASTC(params.pixel_format), "Unimplemented"); | 679 | ASSERT_MSG(!IsPixelFormatASTC(params.pixel_format), "Unimplemented"); |
| 678 | 680 | ||
| 681 | auto& gl_buffer = res_cache_tmp_mem.gl_buffer; | ||
| 679 | // OpenGL temporary buffer needs to be big enough to store raw texture size | 682 | // OpenGL temporary buffer needs to be big enough to store raw texture size |
| 680 | gl_buffer.resize(1); | ||
| 681 | gl_buffer[0].resize(GetSizeInBytes()); | 683 | gl_buffer[0].resize(GetSizeInBytes()); |
| 682 | 684 | ||
| 683 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); | 685 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); |
| @@ -713,10 +715,12 @@ void CachedSurface::FlushGLBuffer() { | |||
| 713 | } | 715 | } |
| 714 | } | 716 | } |
| 715 | 717 | ||
| 716 | void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, | 718 | void CachedSurface::UploadGLMipmapTexture(RasterizerTemporaryMemory& res_cache_tmp_mem, u32 mip_map, |
| 717 | GLuint draw_fb_handle) { | 719 | GLuint read_fb_handle, GLuint draw_fb_handle) { |
| 718 | const auto& rect{params.GetRect(mip_map)}; | 720 | const auto& rect{params.GetRect(mip_map)}; |
| 719 | 721 | ||
| 722 | auto& gl_buffer = res_cache_tmp_mem.gl_buffer; | ||
| 723 | |||
| 720 | // Load data from memory to the surface | 724 | // Load data from memory to the surface |
| 721 | const auto x0 = static_cast<GLint>(rect.left); | 725 | const auto x0 = static_cast<GLint>(rect.left); |
| 722 | const auto y0 = static_cast<GLint>(rect.bottom); | 726 | const auto y0 = static_cast<GLint>(rect.bottom); |
| @@ -845,11 +849,12 @@ void CachedSurface::EnsureTextureDiscrepantView() { | |||
| 845 | } | 849 | } |
| 846 | 850 | ||
| 847 | MICROPROFILE_DEFINE(OpenGL_TextureUL, "OpenGL", "Texture Upload", MP_RGB(128, 192, 64)); | 851 | MICROPROFILE_DEFINE(OpenGL_TextureUL, "OpenGL", "Texture Upload", MP_RGB(128, 192, 64)); |
| 848 | void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle) { | 852 | void CachedSurface::UploadGLTexture(RasterizerTemporaryMemory& res_cache_tmp_mem, |
| 853 | GLuint read_fb_handle, GLuint draw_fb_handle) { | ||
| 849 | MICROPROFILE_SCOPE(OpenGL_TextureUL); | 854 | MICROPROFILE_SCOPE(OpenGL_TextureUL); |
| 850 | 855 | ||
| 851 | for (u32 i = 0; i < params.max_mip_level; i++) | 856 | for (u32 i = 0; i < params.max_mip_level; i++) |
| 852 | UploadGLMipmapTexture(i, read_fb_handle, draw_fb_handle); | 857 | UploadGLMipmapTexture(res_cache_tmp_mem, i, read_fb_handle, draw_fb_handle); |
| 853 | } | 858 | } |
| 854 | 859 | ||
| 855 | void CachedSurface::UpdateSwizzle(Tegra::Texture::SwizzleSource swizzle_x, | 860 | void CachedSurface::UpdateSwizzle(Tegra::Texture::SwizzleSource swizzle_x, |
| @@ -929,8 +934,8 @@ Surface RasterizerCacheOpenGL::GetColorBufferSurface(std::size_t index, bool pre | |||
| 929 | } | 934 | } |
| 930 | 935 | ||
| 931 | void RasterizerCacheOpenGL::LoadSurface(const Surface& surface) { | 936 | void RasterizerCacheOpenGL::LoadSurface(const Surface& surface) { |
| 932 | surface->LoadGLBuffer(); | 937 | surface->LoadGLBuffer(temporal_memory); |
| 933 | surface->UploadGLTexture(read_framebuffer.handle, draw_framebuffer.handle); | 938 | surface->UploadGLTexture(temporal_memory, read_framebuffer.handle, draw_framebuffer.handle); |
| 934 | surface->MarkAsModified(false, *this); | 939 | surface->MarkAsModified(false, *this); |
| 935 | surface->MarkForReload(false); | 940 | surface->MarkForReload(false); |
| 936 | } | 941 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index db280dbb3..6263ef3e7 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -355,6 +355,12 @@ namespace OpenGL { | |||
| 355 | 355 | ||
| 356 | class RasterizerOpenGL; | 356 | class RasterizerOpenGL; |
| 357 | 357 | ||
| 358 | // This is used to store temporary big buffers, | ||
| 359 | // instead of creating/destroying all the time | ||
| 360 | struct RasterizerTemporaryMemory { | ||
| 361 | std::vector<std::vector<u8>> gl_buffer; | ||
| 362 | }; | ||
| 363 | |||
| 358 | class CachedSurface final : public RasterizerCacheObject { | 364 | class CachedSurface final : public RasterizerCacheObject { |
| 359 | public: | 365 | public: |
| 360 | explicit CachedSurface(const SurfaceParams& params); | 366 | explicit CachedSurface(const SurfaceParams& params); |
| @@ -371,10 +377,6 @@ public: | |||
| 371 | return memory_size; | 377 | return memory_size; |
| 372 | } | 378 | } |
| 373 | 379 | ||
| 374 | void Flush() override { | ||
| 375 | FlushGLBuffer(); | ||
| 376 | } | ||
| 377 | |||
| 378 | const OGLTexture& Texture() const { | 380 | const OGLTexture& Texture() const { |
| 379 | return texture; | 381 | return texture; |
| 380 | } | 382 | } |
| @@ -397,11 +399,12 @@ public: | |||
| 397 | } | 399 | } |
| 398 | 400 | ||
| 399 | // Read/Write data in Switch memory to/from gl_buffer | 401 | // Read/Write data in Switch memory to/from gl_buffer |
| 400 | void LoadGLBuffer(); | 402 | void LoadGLBuffer(RasterizerTemporaryMemory& res_cache_tmp_mem); |
| 401 | void FlushGLBuffer(); | 403 | void FlushGLBuffer(RasterizerTemporaryMemory& res_cache_tmp_mem); |
| 402 | 404 | ||
| 403 | // Upload data in gl_buffer to this surface's texture | 405 | // Upload data in gl_buffer to this surface's texture |
| 404 | void UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle); | 406 | void UploadGLTexture(RasterizerTemporaryMemory& res_cache_tmp_mem, GLuint read_fb_handle, |
| 407 | GLuint draw_fb_handle); | ||
| 405 | 408 | ||
| 406 | void UpdateSwizzle(Tegra::Texture::SwizzleSource swizzle_x, | 409 | void UpdateSwizzle(Tegra::Texture::SwizzleSource swizzle_x, |
| 407 | Tegra::Texture::SwizzleSource swizzle_y, | 410 | Tegra::Texture::SwizzleSource swizzle_y, |
| @@ -429,13 +432,13 @@ public: | |||
| 429 | } | 432 | } |
| 430 | 433 | ||
| 431 | private: | 434 | private: |
| 432 | void UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, GLuint draw_fb_handle); | 435 | void UploadGLMipmapTexture(RasterizerTemporaryMemory& res_cache_tmp_mem, u32 mip_map, |
| 436 | GLuint read_fb_handle, GLuint draw_fb_handle); | ||
| 433 | 437 | ||
| 434 | void EnsureTextureDiscrepantView(); | 438 | void EnsureTextureDiscrepantView(); |
| 435 | 439 | ||
| 436 | OGLTexture texture; | 440 | OGLTexture texture; |
| 437 | OGLTexture discrepant_view; | 441 | OGLTexture discrepant_view; |
| 438 | std::vector<std::vector<u8>> gl_buffer; | ||
| 439 | SurfaceParams params{}; | 442 | SurfaceParams params{}; |
| 440 | GLenum gl_target{}; | 443 | GLenum gl_target{}; |
| 441 | GLenum gl_internal_format{}; | 444 | GLenum gl_internal_format{}; |
| @@ -473,6 +476,11 @@ public: | |||
| 473 | void SignalPreDrawCall(); | 476 | void SignalPreDrawCall(); |
| 474 | void SignalPostDrawCall(); | 477 | void SignalPostDrawCall(); |
| 475 | 478 | ||
| 479 | protected: | ||
| 480 | void FlushObjectInner(const Surface& object) override { | ||
| 481 | object->FlushGLBuffer(temporal_memory); | ||
| 482 | } | ||
| 483 | |||
| 476 | private: | 484 | private: |
| 477 | void LoadSurface(const Surface& surface); | 485 | void LoadSurface(const Surface& surface); |
| 478 | Surface GetSurface(const SurfaceParams& params, bool preserve_contents = true); | 486 | Surface GetSurface(const SurfaceParams& params, bool preserve_contents = true); |
| @@ -519,6 +527,8 @@ private: | |||
| 519 | std::array<Surface, Maxwell::NumRenderTargets> current_color_buffers; | 527 | std::array<Surface, Maxwell::NumRenderTargets> current_color_buffers; |
| 520 | Surface last_depth_buffer; | 528 | Surface last_depth_buffer; |
| 521 | 529 | ||
| 530 | RasterizerTemporaryMemory temporal_memory; | ||
| 531 | |||
| 522 | using SurfaceIntervalCache = boost::icl::interval_map<CacheAddr, Surface>; | 532 | using SurfaceIntervalCache = boost::icl::interval_map<CacheAddr, Surface>; |
| 523 | using SurfaceInterval = typename SurfaceIntervalCache::interval_type; | 533 | using SurfaceInterval = typename SurfaceIntervalCache::interval_type; |
| 524 | 534 | ||
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index a332087f8..31b979987 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h | |||
| @@ -57,9 +57,6 @@ public: | |||
| 57 | return shader_length; | 57 | return shader_length; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | // We do not have to flush this cache as things in it are never modified by us. | ||
| 61 | void Flush() override {} | ||
| 62 | |||
| 63 | /// Gets the shader entries for the shader | 60 | /// Gets the shader entries for the shader |
| 64 | const GLShader::ShaderEntries& GetShaderEntries() const { | 61 | const GLShader::ShaderEntries& GetShaderEntries() const { |
| 65 | return entries; | 62 | return entries; |
| @@ -123,6 +120,10 @@ public: | |||
| 123 | /// Gets the current specified shader stage program | 120 | /// Gets the current specified shader stage program |
| 124 | Shader GetStageProgram(Maxwell::ShaderProgram program); | 121 | Shader GetStageProgram(Maxwell::ShaderProgram program); |
| 125 | 122 | ||
| 123 | protected: | ||
| 124 | // We do not have to flush this cache as things in it are never modified by us. | ||
| 125 | void FlushObjectInner(const Shader& object) override {} | ||
| 126 | |||
| 126 | private: | 127 | private: |
| 127 | std::unordered_map<u64, UnspecializedShader> GenerateUnspecializedShaders( | 128 | std::unordered_map<u64, UnspecializedShader> GenerateUnspecializedShaders( |
| 128 | const std::atomic_bool& stop_loading, const VideoCore::DiskResourceLoadCallback& callback, | 129 | const std::atomic_bool& stop_loading, const VideoCore::DiskResourceLoadCallback& callback, |
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h index 08b786aad..3edf460df 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.h +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h | |||
| @@ -49,9 +49,6 @@ public: | |||
| 49 | return alignment; | 49 | return alignment; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | // We do not have to flush this cache as things in it are never modified by us. | ||
| 53 | void Flush() override {} | ||
| 54 | |||
| 55 | private: | 52 | private: |
| 56 | VAddr cpu_addr{}; | 53 | VAddr cpu_addr{}; |
| 57 | std::size_t size{}; | 54 | std::size_t size{}; |
| @@ -87,6 +84,10 @@ public: | |||
| 87 | return buffer_handle; | 84 | return buffer_handle; |
| 88 | } | 85 | } |
| 89 | 86 | ||
| 87 | protected: | ||
| 88 | // We do not have to flush this cache as things in it are never modified by us. | ||
| 89 | void FlushObjectInner(const std::shared_ptr<CachedBufferEntry>& object) override {} | ||
| 90 | |||
| 90 | private: | 91 | private: |
| 91 | void AlignBuffer(std::size_t alignment); | 92 | void AlignBuffer(std::size_t alignment); |
| 92 | 93 | ||