diff options
| author | 2020-08-24 01:15:48 -0400 | |
|---|---|---|
| committer | 2020-08-24 01:15:50 -0400 | |
| commit | bafef3d1c98240085eb6ab8ed934221451c66c68 (patch) | |
| tree | 5fa0b4532611efd8e0e9cd32200bc237eaffd4d5 /src | |
| parent | Merge pull request #4573 from lioncash/label (diff) | |
| download | yuzu-bafef3d1c98240085eb6ab8ed934221451c66c68.tar.gz yuzu-bafef3d1c98240085eb6ab8ed934221451c66c68.tar.xz yuzu-bafef3d1c98240085eb6ab8ed934221451c66c68.zip | |
async_shaders: Mark getters as const member functions
While we're at it, we can also mark them as nodiscard.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/shader/async_shaders.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/shader/async_shaders.h | 26 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/video_core/shader/async_shaders.cpp b/src/video_core/shader/async_shaders.cpp index f815584f7..aabd62c5c 100644 --- a/src/video_core/shader/async_shaders.cpp +++ b/src/video_core/shader/async_shaders.cpp | |||
| @@ -73,11 +73,11 @@ void AsyncShaders::KillWorkers() { | |||
| 73 | worker_threads.clear(); | 73 | worker_threads.clear(); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | bool AsyncShaders::HasWorkQueued() { | 76 | bool AsyncShaders::HasWorkQueued() const { |
| 77 | return !pending_queue.empty(); | 77 | return !pending_queue.empty(); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | bool AsyncShaders::HasCompletedWork() { | 80 | bool AsyncShaders::HasCompletedWork() const { |
| 81 | std::shared_lock lock{completed_mutex}; | 81 | std::shared_lock lock{completed_mutex}; |
| 82 | return !finished_work.empty(); | 82 | return !finished_work.empty(); |
| 83 | } | 83 | } |
| @@ -102,7 +102,7 @@ bool AsyncShaders::IsShaderAsync(const Tegra::GPU& gpu) const { | |||
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | std::vector<AsyncShaders::Result> AsyncShaders::GetCompletedWork() { | 104 | std::vector<AsyncShaders::Result> AsyncShaders::GetCompletedWork() { |
| 105 | std::vector<AsyncShaders::Result> results; | 105 | std::vector<Result> results; |
| 106 | { | 106 | { |
| 107 | std::unique_lock lock{completed_mutex}; | 107 | std::unique_lock lock{completed_mutex}; |
| 108 | results.assign(std::make_move_iterator(finished_work.begin()), | 108 | results.assign(std::make_move_iterator(finished_work.begin()), |
diff --git a/src/video_core/shader/async_shaders.h b/src/video_core/shader/async_shaders.h index d5ae814d5..7cf8d994c 100644 --- a/src/video_core/shader/async_shaders.h +++ b/src/video_core/shader/async_shaders.h | |||
| @@ -5,11 +5,10 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <condition_variable> | 7 | #include <condition_variable> |
| 8 | #include <deque> | ||
| 9 | #include <memory> | 8 | #include <memory> |
| 10 | #include <shared_mutex> | 9 | #include <shared_mutex> |
| 11 | #include <thread> | 10 | #include <thread> |
| 12 | #include "common/bit_field.h" | 11 | |
| 13 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 14 | #include "video_core/renderer_opengl/gl_device.h" | 13 | #include "video_core/renderer_opengl/gl_device.h" |
| 15 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 14 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| @@ -17,7 +16,6 @@ | |||
| 17 | #include "video_core/renderer_vulkan/vk_device.h" | 16 | #include "video_core/renderer_vulkan/vk_device.h" |
| 18 | #include "video_core/renderer_vulkan/vk_pipeline_cache.h" | 17 | #include "video_core/renderer_vulkan/vk_pipeline_cache.h" |
| 19 | #include "video_core/renderer_vulkan/vk_scheduler.h" | 18 | #include "video_core/renderer_vulkan/vk_scheduler.h" |
| 20 | #include "video_core/renderer_vulkan/vk_update_descriptor.h" | ||
| 21 | 19 | ||
| 22 | namespace Core::Frontend { | 20 | namespace Core::Frontend { |
| 23 | class EmuWindow; | 21 | class EmuWindow; |
| @@ -70,20 +68,20 @@ public: | |||
| 70 | void KillWorkers(); | 68 | void KillWorkers(); |
| 71 | 69 | ||
| 72 | /// Check to see if any shaders have actually been compiled | 70 | /// Check to see if any shaders have actually been compiled |
| 73 | bool HasCompletedWork(); | 71 | [[nodiscard]] bool HasCompletedWork() const; |
| 74 | 72 | ||
| 75 | /// Deduce if a shader can be build on another thread of MUST be built in sync. We cannot build | 73 | /// Deduce if a shader can be build on another thread of MUST be built in sync. We cannot build |
| 76 | /// every shader async as some shaders are only built and executed once. We try to "guess" which | 74 | /// every shader async as some shaders are only built and executed once. We try to "guess" which |
| 77 | /// shader would be used only once | 75 | /// shader would be used only once |
| 78 | bool IsShaderAsync(const Tegra::GPU& gpu) const; | 76 | [[nodiscard]] bool IsShaderAsync(const Tegra::GPU& gpu) const; |
| 79 | 77 | ||
| 80 | /// Pulls completed compiled shaders | 78 | /// Pulls completed compiled shaders |
| 81 | std::vector<Result> GetCompletedWork(); | 79 | [[nodiscard]] std::vector<Result> GetCompletedWork(); |
| 82 | 80 | ||
| 83 | void QueueOpenGLShader(const OpenGL::Device& device, Tegra::Engines::ShaderType shader_type, | 81 | void QueueOpenGLShader(const OpenGL::Device& device, Tegra::Engines::ShaderType shader_type, |
| 84 | u64 uid, std::vector<u64> code, std::vector<u64> code_b, u32 main_offset, | 82 | u64 uid, std::vector<u64> code, std::vector<u64> code_b, u32 main_offset, |
| 85 | VideoCommon::Shader::CompilerSettings compiler_settings, | 83 | CompilerSettings compiler_settings, const Registry& registry, |
| 86 | const VideoCommon::Shader::Registry& registry, VAddr cpu_addr); | 84 | VAddr cpu_addr); |
| 87 | 85 | ||
| 88 | void QueueVulkanShader(Vulkan::VKPipelineCache* pp_cache, const Vulkan::VKDevice& device, | 86 | void QueueVulkanShader(Vulkan::VKPipelineCache* pp_cache, const Vulkan::VKDevice& device, |
| 89 | Vulkan::VKScheduler& scheduler, | 87 | Vulkan::VKScheduler& scheduler, |
| @@ -97,7 +95,7 @@ private: | |||
| 97 | void ShaderCompilerThread(Core::Frontend::GraphicsContext* context); | 95 | void ShaderCompilerThread(Core::Frontend::GraphicsContext* context); |
| 98 | 96 | ||
| 99 | /// Check our worker queue to see if we have any work queued already | 97 | /// Check our worker queue to see if we have any work queued already |
| 100 | bool HasWorkQueued(); | 98 | [[nodiscard]] bool HasWorkQueued() const; |
| 101 | 99 | ||
| 102 | struct WorkerParams { | 100 | struct WorkerParams { |
| 103 | Backend backend; | 101 | Backend backend; |
| @@ -108,8 +106,8 @@ private: | |||
| 108 | std::vector<u64> code; | 106 | std::vector<u64> code; |
| 109 | std::vector<u64> code_b; | 107 | std::vector<u64> code_b; |
| 110 | u32 main_offset; | 108 | u32 main_offset; |
| 111 | VideoCommon::Shader::CompilerSettings compiler_settings; | 109 | CompilerSettings compiler_settings; |
| 112 | std::optional<VideoCommon::Shader::Registry> registry; | 110 | std::optional<Registry> registry; |
| 113 | VAddr cpu_address; | 111 | VAddr cpu_address; |
| 114 | 112 | ||
| 115 | // For Vulkan | 113 | // For Vulkan |
| @@ -125,13 +123,13 @@ private: | |||
| 125 | }; | 123 | }; |
| 126 | 124 | ||
| 127 | std::condition_variable cv; | 125 | std::condition_variable cv; |
| 128 | std::mutex queue_mutex; | 126 | mutable std::mutex queue_mutex; |
| 129 | std::shared_mutex completed_mutex; | 127 | mutable std::shared_mutex completed_mutex; |
| 130 | std::atomic<bool> is_thread_exiting{}; | 128 | std::atomic<bool> is_thread_exiting{}; |
| 131 | std::vector<std::unique_ptr<Core::Frontend::GraphicsContext>> context_list; | 129 | std::vector<std::unique_ptr<Core::Frontend::GraphicsContext>> context_list; |
| 132 | std::vector<std::thread> worker_threads; | 130 | std::vector<std::thread> worker_threads; |
| 133 | std::queue<WorkerParams> pending_queue; | 131 | std::queue<WorkerParams> pending_queue; |
| 134 | std::vector<AsyncShaders::Result> finished_work; | 132 | std::vector<Result> finished_work; |
| 135 | Core::Frontend::EmuWindow& emu_window; | 133 | Core::Frontend::EmuWindow& emu_window; |
| 136 | }; | 134 | }; |
| 137 | 135 | ||