diff options
| author | 2020-02-28 20:53:10 -0300 | |
|---|---|---|
| committer | 2020-03-09 18:40:06 -0300 | |
| commit | e8efd5a90100a86899e31a4de0137e915e0e0366 (patch) | |
| tree | 586964f8bf2036517d7fb40c2f93b9e7e1bb058b | |
| parent | gl_shader_cache: Rework shader cache and remove post-specializations (diff) | |
| download | yuzu-e8efd5a90100a86899e31a4de0137e915e0e0366.tar.gz yuzu-e8efd5a90100a86899e31a4de0137e915e0e0366.tar.xz yuzu-e8efd5a90100a86899e31a4de0137e915e0e0366.zip | |
video_core: Rename "const buffer locker" to "registry"
| -rw-r--r-- | CMakeModules/GenerateSCMRev.cmake | 4 | ||||
| -rw-r--r-- | src/common/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/video_core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 65 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.h | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.h | 4 | ||||
| -rw-r--r-- | src/video_core/shader/control_flow.cpp | 13 | ||||
| -rw-r--r-- | src/video_core/shader/control_flow.h | 3 | ||||
| -rw-r--r-- | src/video_core/shader/decode.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/shader/decode/texture.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/shader/registry.cpp (renamed from src/video_core/shader/const_buffer_locker.cpp) | 34 | ||||
| -rw-r--r-- | src/video_core/shader/registry.h (renamed from src/video_core/shader/const_buffer_locker.h) | 30 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.h | 6 | ||||
| -rw-r--r-- | src/video_core/shader/track.cpp | 4 |
17 files changed, 102 insertions, 97 deletions
diff --git a/CMakeModules/GenerateSCMRev.cmake b/CMakeModules/GenerateSCMRev.cmake index 6c2f201eb..8c13a94fb 100644 --- a/CMakeModules/GenerateSCMRev.cmake +++ b/CMakeModules/GenerateSCMRev.cmake | |||
| @@ -89,8 +89,6 @@ set(HASH_FILES | |||
| 89 | "${VIDEO_CORE}/shader/ast.h" | 89 | "${VIDEO_CORE}/shader/ast.h" |
| 90 | "${VIDEO_CORE}/shader/compiler_settings.cpp" | 90 | "${VIDEO_CORE}/shader/compiler_settings.cpp" |
| 91 | "${VIDEO_CORE}/shader/compiler_settings.h" | 91 | "${VIDEO_CORE}/shader/compiler_settings.h" |
| 92 | "${VIDEO_CORE}/shader/const_buffer_locker.cpp" | ||
| 93 | "${VIDEO_CORE}/shader/const_buffer_locker.h" | ||
| 94 | "${VIDEO_CORE}/shader/control_flow.cpp" | 92 | "${VIDEO_CORE}/shader/control_flow.cpp" |
| 95 | "${VIDEO_CORE}/shader/control_flow.h" | 93 | "${VIDEO_CORE}/shader/control_flow.h" |
| 96 | "${VIDEO_CORE}/shader/decode.cpp" | 94 | "${VIDEO_CORE}/shader/decode.cpp" |
| @@ -99,6 +97,8 @@ set(HASH_FILES | |||
| 99 | "${VIDEO_CORE}/shader/node.h" | 97 | "${VIDEO_CORE}/shader/node.h" |
| 100 | "${VIDEO_CORE}/shader/node_helper.cpp" | 98 | "${VIDEO_CORE}/shader/node_helper.cpp" |
| 101 | "${VIDEO_CORE}/shader/node_helper.h" | 99 | "${VIDEO_CORE}/shader/node_helper.h" |
| 100 | "${VIDEO_CORE}/shader/registry.cpp" | ||
| 101 | "${VIDEO_CORE}/shader/registry.h" | ||
| 102 | "${VIDEO_CORE}/shader/shader_ir.cpp" | 102 | "${VIDEO_CORE}/shader/shader_ir.cpp" |
| 103 | "${VIDEO_CORE}/shader/shader_ir.h" | 103 | "${VIDEO_CORE}/shader/shader_ir.h" |
| 104 | "${VIDEO_CORE}/shader/track.cpp" | 104 | "${VIDEO_CORE}/shader/track.cpp" |
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 274e4ec79..1f621fb1f 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -70,8 +70,6 @@ add_custom_command(OUTPUT scm_rev.cpp | |||
| 70 | "${VIDEO_CORE}/shader/ast.h" | 70 | "${VIDEO_CORE}/shader/ast.h" |
| 71 | "${VIDEO_CORE}/shader/compiler_settings.cpp" | 71 | "${VIDEO_CORE}/shader/compiler_settings.cpp" |
| 72 | "${VIDEO_CORE}/shader/compiler_settings.h" | 72 | "${VIDEO_CORE}/shader/compiler_settings.h" |
| 73 | "${VIDEO_CORE}/shader/const_buffer_locker.cpp" | ||
| 74 | "${VIDEO_CORE}/shader/const_buffer_locker.h" | ||
| 75 | "${VIDEO_CORE}/shader/control_flow.cpp" | 73 | "${VIDEO_CORE}/shader/control_flow.cpp" |
| 76 | "${VIDEO_CORE}/shader/control_flow.h" | 74 | "${VIDEO_CORE}/shader/control_flow.h" |
| 77 | "${VIDEO_CORE}/shader/decode.cpp" | 75 | "${VIDEO_CORE}/shader/decode.cpp" |
| @@ -80,6 +78,8 @@ add_custom_command(OUTPUT scm_rev.cpp | |||
| 80 | "${VIDEO_CORE}/shader/node.h" | 78 | "${VIDEO_CORE}/shader/node.h" |
| 81 | "${VIDEO_CORE}/shader/node_helper.cpp" | 79 | "${VIDEO_CORE}/shader/node_helper.cpp" |
| 82 | "${VIDEO_CORE}/shader/node_helper.h" | 80 | "${VIDEO_CORE}/shader/node_helper.h" |
| 81 | "${VIDEO_CORE}/shader/registry.cpp" | ||
| 82 | "${VIDEO_CORE}/shader/registry.h" | ||
| 83 | "${VIDEO_CORE}/shader/shader_ir.cpp" | 83 | "${VIDEO_CORE}/shader/shader_ir.cpp" |
| 84 | "${VIDEO_CORE}/shader/shader_ir.h" | 84 | "${VIDEO_CORE}/shader/shader_ir.h" |
| 85 | "${VIDEO_CORE}/shader/track.cpp" | 85 | "${VIDEO_CORE}/shader/track.cpp" |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 3d93c07fb..0101e5f0e 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -116,8 +116,6 @@ add_library(video_core STATIC | |||
| 116 | shader/ast.h | 116 | shader/ast.h |
| 117 | shader/compiler_settings.cpp | 117 | shader/compiler_settings.cpp |
| 118 | shader/compiler_settings.h | 118 | shader/compiler_settings.h |
| 119 | shader/const_buffer_locker.cpp | ||
| 120 | shader/const_buffer_locker.h | ||
| 121 | shader/control_flow.cpp | 119 | shader/control_flow.cpp |
| 122 | shader/control_flow.h | 120 | shader/control_flow.h |
| 123 | shader/decode.cpp | 121 | shader/decode.cpp |
| @@ -126,6 +124,8 @@ add_library(video_core STATIC | |||
| 126 | shader/node_helper.cpp | 124 | shader/node_helper.cpp |
| 127 | shader/node_helper.h | 125 | shader/node_helper.h |
| 128 | shader/node.h | 126 | shader/node.h |
| 127 | shader/registry.cpp | ||
| 128 | shader/registry.h | ||
| 129 | shader/shader_ir.cpp | 129 | shader/shader_ir.cpp |
| 130 | shader/shader_ir.h | 130 | shader/shader_ir.h |
| 131 | shader/track.cpp | 131 | shader/track.cpp |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index e3a1d5a5f..87d25b5a5 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -28,13 +28,14 @@ | |||
| 28 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" | 28 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" |
| 29 | #include "video_core/renderer_opengl/gl_state_tracker.h" | 29 | #include "video_core/renderer_opengl/gl_state_tracker.h" |
| 30 | #include "video_core/renderer_opengl/utils.h" | 30 | #include "video_core/renderer_opengl/utils.h" |
| 31 | #include "video_core/shader/registry.h" | ||
| 31 | #include "video_core/shader/shader_ir.h" | 32 | #include "video_core/shader/shader_ir.h" |
| 32 | 33 | ||
| 33 | namespace OpenGL { | 34 | namespace OpenGL { |
| 34 | 35 | ||
| 35 | using Tegra::Engines::ShaderType; | 36 | using Tegra::Engines::ShaderType; |
| 36 | using VideoCommon::Shader::ConstBufferLocker; | ||
| 37 | using VideoCommon::Shader::ProgramCode; | 37 | using VideoCommon::Shader::ProgramCode; |
| 38 | using VideoCommon::Shader::Registry; | ||
| 38 | using VideoCommon::Shader::ShaderIR; | 39 | using VideoCommon::Shader::ShaderIR; |
| 39 | 40 | ||
| 40 | namespace { | 41 | namespace { |
| @@ -163,22 +164,22 @@ std::string MakeShaderID(u64 unique_identifier, ShaderType shader_type) { | |||
| 163 | return fmt::format("{}{:016X}", GetShaderTypeName(shader_type), unique_identifier); | 164 | return fmt::format("{}{:016X}", GetShaderTypeName(shader_type), unique_identifier); |
| 164 | } | 165 | } |
| 165 | 166 | ||
| 166 | std::shared_ptr<ConstBufferLocker> MakeLocker(const ShaderDiskCacheEntry& entry) { | 167 | std::shared_ptr<Registry> MakeRegistry(const ShaderDiskCacheEntry& entry) { |
| 167 | const VideoCore::GuestDriverProfile guest_profile{entry.texture_handler_size}; | 168 | const VideoCore::GuestDriverProfile guest_profile{entry.texture_handler_size}; |
| 168 | auto locker = std::make_shared<ConstBufferLocker>(entry.type, guest_profile); | 169 | auto registry = std::make_shared<Registry>(entry.type, guest_profile); |
| 169 | locker->SetBoundBuffer(entry.bound_buffer); | 170 | registry->SetBoundBuffer(entry.bound_buffer); |
| 170 | for (const auto& [address, value] : entry.keys) { | 171 | for (const auto& [address, value] : entry.keys) { |
| 171 | const auto [buffer, offset] = address; | 172 | const auto [buffer, offset] = address; |
| 172 | locker->InsertKey(buffer, offset, value); | 173 | registry->InsertKey(buffer, offset, value); |
| 173 | } | 174 | } |
| 174 | for (const auto& [offset, sampler] : entry.bound_samplers) { | 175 | for (const auto& [offset, sampler] : entry.bound_samplers) { |
| 175 | locker->InsertBoundSampler(offset, sampler); | 176 | registry->InsertBoundSampler(offset, sampler); |
| 176 | } | 177 | } |
| 177 | for (const auto& [key, sampler] : entry.bindless_samplers) { | 178 | for (const auto& [key, sampler] : entry.bindless_samplers) { |
| 178 | const auto [buffer, offset] = key; | 179 | const auto [buffer, offset] = key; |
| 179 | locker->InsertBindlessSampler(buffer, offset, sampler); | 180 | registry->InsertBindlessSampler(buffer, offset, sampler); |
| 180 | } | 181 | } |
| 181 | return locker; | 182 | return registry; |
| 182 | } | 183 | } |
| 183 | 184 | ||
| 184 | std::shared_ptr<OGLProgram> BuildShader(const Device& device, ShaderType shader_type, | 185 | std::shared_ptr<OGLProgram> BuildShader(const Device& device, ShaderType shader_type, |
| @@ -211,15 +212,15 @@ std::unordered_set<GLenum> GetSupportedFormats() { | |||
| 211 | } // Anonymous namespace | 212 | } // Anonymous namespace |
| 212 | 213 | ||
| 213 | CachedShader::CachedShader(const u8* host_ptr, VAddr cpu_addr, std::size_t size_in_bytes, | 214 | CachedShader::CachedShader(const u8* host_ptr, VAddr cpu_addr, std::size_t size_in_bytes, |
| 214 | std::shared_ptr<VideoCommon::Shader::ConstBufferLocker> locker, | 215 | std::shared_ptr<VideoCommon::Shader::Registry> registry, |
| 215 | ShaderEntries entries, std::shared_ptr<OGLProgram> program) | 216 | ShaderEntries entries, std::shared_ptr<OGLProgram> program) |
| 216 | : RasterizerCacheObject{host_ptr}, locker{std::move(locker)}, entries{std::move(entries)}, | 217 | : RasterizerCacheObject{host_ptr}, registry{std::move(registry)}, entries{std::move(entries)}, |
| 217 | cpu_addr{cpu_addr}, size_in_bytes{size_in_bytes}, program{std::move(program)} {} | 218 | cpu_addr{cpu_addr}, size_in_bytes{size_in_bytes}, program{std::move(program)} {} |
| 218 | 219 | ||
| 219 | CachedShader::~CachedShader() = default; | 220 | CachedShader::~CachedShader() = default; |
| 220 | 221 | ||
| 221 | GLuint CachedShader::GetHandle() const { | 222 | GLuint CachedShader::GetHandle() const { |
| 222 | if (!locker->IsConsistent()) { | 223 | if (!registry->IsConsistent()) { |
| 223 | std::abort(); | 224 | std::abort(); |
| 224 | } | 225 | } |
| 225 | return program->handle; | 226 | return program->handle; |
| @@ -231,8 +232,8 @@ Shader CachedShader::CreateStageFromMemory(const ShaderParameters& params, | |||
| 231 | const auto shader_type = GetShaderType(program_type); | 232 | const auto shader_type = GetShaderType(program_type); |
| 232 | const std::size_t size_in_bytes = code.size() * sizeof(u64); | 233 | const std::size_t size_in_bytes = code.size() * sizeof(u64); |
| 233 | 234 | ||
| 234 | auto locker = std::make_shared<ConstBufferLocker>(shader_type, params.system.GPU().Maxwell3D()); | 235 | auto registry = std::make_shared<Registry>(shader_type, params.system.GPU().Maxwell3D()); |
| 235 | const ShaderIR ir(code, STAGE_MAIN_OFFSET, COMPILER_SETTINGS, *locker); | 236 | const ShaderIR ir(code, STAGE_MAIN_OFFSET, COMPILER_SETTINGS, *registry); |
| 236 | // TODO(Rodrigo): Handle VertexA shaders | 237 | // TODO(Rodrigo): Handle VertexA shaders |
| 237 | // std::optional<ShaderIR> ir_b; | 238 | // std::optional<ShaderIR> ir_b; |
| 238 | // if (!code_b.empty()) { | 239 | // if (!code_b.empty()) { |
| @@ -245,46 +246,46 @@ Shader CachedShader::CreateStageFromMemory(const ShaderParameters& params, | |||
| 245 | entry.code = std::move(code); | 246 | entry.code = std::move(code); |
| 246 | entry.code_b = std::move(code_b); | 247 | entry.code_b = std::move(code_b); |
| 247 | entry.unique_identifier = params.unique_identifier; | 248 | entry.unique_identifier = params.unique_identifier; |
| 248 | entry.bound_buffer = locker->GetBoundBuffer(); | 249 | entry.bound_buffer = registry->GetBoundBuffer(); |
| 249 | entry.keys = locker->GetKeys(); | 250 | entry.keys = registry->GetKeys(); |
| 250 | entry.bound_samplers = locker->GetBoundSamplers(); | 251 | entry.bound_samplers = registry->GetBoundSamplers(); |
| 251 | entry.bindless_samplers = locker->GetBindlessSamplers(); | 252 | entry.bindless_samplers = registry->GetBindlessSamplers(); |
| 252 | params.disk_cache.SaveEntry(std::move(entry)); | 253 | params.disk_cache.SaveEntry(std::move(entry)); |
| 253 | 254 | ||
| 254 | return std::shared_ptr<CachedShader>(new CachedShader(params.host_ptr, params.cpu_addr, | 255 | return std::shared_ptr<CachedShader>(new CachedShader(params.host_ptr, params.cpu_addr, |
| 255 | size_in_bytes, std::move(locker), | 256 | size_in_bytes, std::move(registry), |
| 256 | MakeEntries(ir), std::move(program))); | 257 | MakeEntries(ir), std::move(program))); |
| 257 | } | 258 | } |
| 258 | 259 | ||
| 259 | Shader CachedShader::CreateKernelFromMemory(const ShaderParameters& params, ProgramCode code) { | 260 | Shader CachedShader::CreateKernelFromMemory(const ShaderParameters& params, ProgramCode code) { |
| 260 | const std::size_t size_in_bytes = code.size() * sizeof(u64); | 261 | const std::size_t size_in_bytes = code.size() * sizeof(u64); |
| 261 | 262 | ||
| 262 | auto locker = std::make_shared<ConstBufferLocker>(Tegra::Engines::ShaderType::Compute, | 263 | auto registry = |
| 263 | params.system.GPU().KeplerCompute()); | 264 | std::make_shared<Registry>(ShaderType::Compute, params.system.GPU().KeplerCompute()); |
| 264 | const ShaderIR ir(code, KERNEL_MAIN_OFFSET, COMPILER_SETTINGS, *locker); | 265 | const ShaderIR ir(code, KERNEL_MAIN_OFFSET, COMPILER_SETTINGS, *registry); |
| 265 | auto program = BuildShader(params.device, ShaderType::Compute, params.unique_identifier, ir); | 266 | auto program = BuildShader(params.device, ShaderType::Compute, params.unique_identifier, ir); |
| 266 | 267 | ||
| 267 | ShaderDiskCacheEntry entry; | 268 | ShaderDiskCacheEntry entry; |
| 268 | entry.type = ShaderType::Compute; | 269 | entry.type = ShaderType::Compute; |
| 269 | entry.code = std::move(code); | 270 | entry.code = std::move(code); |
| 270 | entry.unique_identifier = params.unique_identifier; | 271 | entry.unique_identifier = params.unique_identifier; |
| 271 | entry.bound_buffer = locker->GetBoundBuffer(); | 272 | entry.bound_buffer = registry->GetBoundBuffer(); |
| 272 | entry.keys = locker->GetKeys(); | 273 | entry.keys = registry->GetKeys(); |
| 273 | entry.bound_samplers = locker->GetBoundSamplers(); | 274 | entry.bound_samplers = registry->GetBoundSamplers(); |
| 274 | entry.bindless_samplers = locker->GetBindlessSamplers(); | 275 | entry.bindless_samplers = registry->GetBindlessSamplers(); |
| 275 | params.disk_cache.SaveEntry(std::move(entry)); | 276 | params.disk_cache.SaveEntry(std::move(entry)); |
| 276 | 277 | ||
| 277 | return std::shared_ptr<CachedShader>(new CachedShader(params.host_ptr, params.cpu_addr, | 278 | return std::shared_ptr<CachedShader>(new CachedShader(params.host_ptr, params.cpu_addr, |
| 278 | size_in_bytes, std::move(locker), | 279 | size_in_bytes, std::move(registry), |
| 279 | MakeEntries(ir), std::move(program))); | 280 | MakeEntries(ir), std::move(program))); |
| 280 | } | 281 | } |
| 281 | 282 | ||
| 282 | Shader CachedShader::CreateFromCache(const ShaderParameters& params, | 283 | Shader CachedShader::CreateFromCache(const ShaderParameters& params, |
| 283 | const PrecompiledShader& precompiled_shader, | 284 | const PrecompiledShader& precompiled_shader, |
| 284 | std::size_t size_in_bytes) { | 285 | std::size_t size_in_bytes) { |
| 285 | return std::shared_ptr<CachedShader>( | 286 | return std::shared_ptr<CachedShader>(new CachedShader( |
| 286 | new CachedShader(params.host_ptr, params.cpu_addr, size_in_bytes, precompiled_shader.locker, | 287 | params.host_ptr, params.cpu_addr, size_in_bytes, precompiled_shader.registry, |
| 287 | precompiled_shader.entries, precompiled_shader.program)); | 288 | precompiled_shader.entries, precompiled_shader.program)); |
| 288 | } | 289 | } |
| 289 | 290 | ||
| 290 | ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system, | 291 | ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system, |
| @@ -336,8 +337,8 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, | |||
| 336 | 337 | ||
| 337 | const bool is_compute = entry.type == ShaderType::Compute; | 338 | const bool is_compute = entry.type == ShaderType::Compute; |
| 338 | const u32 main_offset = is_compute ? KERNEL_MAIN_OFFSET : STAGE_MAIN_OFFSET; | 339 | const u32 main_offset = is_compute ? KERNEL_MAIN_OFFSET : STAGE_MAIN_OFFSET; |
| 339 | auto locker = MakeLocker(entry); | 340 | auto registry = MakeRegistry(entry); |
| 340 | const ShaderIR ir(entry.code, main_offset, COMPILER_SETTINGS, *locker); | 341 | const ShaderIR ir(entry.code, main_offset, COMPILER_SETTINGS, *registry); |
| 341 | 342 | ||
| 342 | std::shared_ptr<OGLProgram> program; | 343 | std::shared_ptr<OGLProgram> program; |
| 343 | if (precompiled_entry) { | 344 | if (precompiled_entry) { |
| @@ -354,7 +355,7 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, | |||
| 354 | 355 | ||
| 355 | PrecompiledShader shader; | 356 | PrecompiledShader shader; |
| 356 | shader.program = std::move(program); | 357 | shader.program = std::move(program); |
| 357 | shader.locker = std::move(locker); | 358 | shader.registry = std::move(registry); |
| 358 | shader.entries = MakeEntries(ir); | 359 | shader.entries = MakeEntries(ir); |
| 359 | 360 | ||
| 360 | std::scoped_lock lock{mutex}; | 361 | std::scoped_lock lock{mutex}; |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index 03d7a2b3f..4935019fc 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 22 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 23 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" | 23 | #include "video_core/renderer_opengl/gl_shader_decompiler.h" |
| 24 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" | 24 | #include "video_core/renderer_opengl/gl_shader_disk_cache.h" |
| 25 | #include "video_core/shader/const_buffer_locker.h" | 25 | #include "video_core/shader/registry.h" |
| 26 | #include "video_core/shader/shader_ir.h" | 26 | #include "video_core/shader/shader_ir.h" |
| 27 | 27 | ||
| 28 | namespace Core { | 28 | namespace Core { |
| @@ -45,7 +45,7 @@ using Maxwell = Tegra::Engines::Maxwell3D::Regs; | |||
| 45 | 45 | ||
| 46 | struct PrecompiledShader { | 46 | struct PrecompiledShader { |
| 47 | std::shared_ptr<OGLProgram> program; | 47 | std::shared_ptr<OGLProgram> program; |
| 48 | std::shared_ptr<VideoCommon::Shader::ConstBufferLocker> locker; | 48 | std::shared_ptr<VideoCommon::Shader::Registry> registry; |
| 49 | ShaderEntries entries; | 49 | ShaderEntries entries; |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| @@ -91,10 +91,10 @@ public: | |||
| 91 | 91 | ||
| 92 | private: | 92 | private: |
| 93 | explicit CachedShader(const u8* host_ptr, VAddr cpu_addr, std::size_t size_in_bytes, | 93 | explicit CachedShader(const u8* host_ptr, VAddr cpu_addr, std::size_t size_in_bytes, |
| 94 | std::shared_ptr<VideoCommon::Shader::ConstBufferLocker> locker, | 94 | std::shared_ptr<VideoCommon::Shader::Registry> registry, |
| 95 | ShaderEntries entries, std::shared_ptr<OGLProgram> program); | 95 | ShaderEntries entries, std::shared_ptr<OGLProgram> program); |
| 96 | 96 | ||
| 97 | std::shared_ptr<VideoCommon::Shader::ConstBufferLocker> locker; | 97 | std::shared_ptr<VideoCommon::Shader::Registry> registry; |
| 98 | ShaderEntries entries; | 98 | ShaderEntries entries; |
| 99 | VAddr cpu_addr = 0; | 99 | VAddr cpu_addr = 0; |
| 100 | std::size_t size_in_bytes = 0; | 100 | std::size_t size_in_bytes = 0; |
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.h b/src/video_core/renderer_opengl/gl_shader_disk_cache.h index 0ce0ea3f8..7f2ab36be 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | #include "common/common_types.h" | 19 | #include "common/common_types.h" |
| 20 | #include "core/file_sys/vfs_vector.h" | 20 | #include "core/file_sys/vfs_vector.h" |
| 21 | #include "video_core/engines/shader_type.h" | 21 | #include "video_core/engines/shader_type.h" |
| 22 | #include "video_core/shader/const_buffer_locker.h" | 22 | #include "video_core/shader/registry.h" |
| 23 | 23 | ||
| 24 | namespace Core { | 24 | namespace Core { |
| 25 | class System; | 25 | class System; |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 144e1e007..ebf85f311 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -161,8 +161,8 @@ CachedShader::CachedShader(Core::System& system, Tegra::Engines::ShaderType stag | |||
| 161 | GPUVAddr gpu_addr, VAddr cpu_addr, u8* host_ptr, | 161 | GPUVAddr gpu_addr, VAddr cpu_addr, u8* host_ptr, |
| 162 | ProgramCode program_code, u32 main_offset) | 162 | ProgramCode program_code, u32 main_offset) |
| 163 | : RasterizerCacheObject{host_ptr}, gpu_addr{gpu_addr}, cpu_addr{cpu_addr}, | 163 | : RasterizerCacheObject{host_ptr}, gpu_addr{gpu_addr}, cpu_addr{cpu_addr}, |
| 164 | program_code{std::move(program_code)}, locker{stage, GetEngine(system, stage)}, | 164 | program_code{std::move(program_code)}, registry{stage, GetEngine(system, stage)}, |
| 165 | shader_ir{this->program_code, main_offset, compiler_settings, locker}, | 165 | shader_ir{this->program_code, main_offset, compiler_settings, registry}, |
| 166 | entries{GenerateShaderEntries(shader_ir)} {} | 166 | entries{GenerateShaderEntries(shader_ir)} {} |
| 167 | 167 | ||
| 168 | CachedShader::~CachedShader() = default; | 168 | CachedShader::~CachedShader() = default; |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index 92a670cc7..e292526bb 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | #include "video_core/renderer_vulkan/vk_renderpass_cache.h" | 25 | #include "video_core/renderer_vulkan/vk_renderpass_cache.h" |
| 26 | #include "video_core/renderer_vulkan/vk_resource_manager.h" | 26 | #include "video_core/renderer_vulkan/vk_resource_manager.h" |
| 27 | #include "video_core/renderer_vulkan/vk_shader_decompiler.h" | 27 | #include "video_core/renderer_vulkan/vk_shader_decompiler.h" |
| 28 | #include "video_core/shader/const_buffer_locker.h" | 28 | #include "video_core/shader/registry.h" |
| 29 | #include "video_core/shader/shader_ir.h" | 29 | #include "video_core/shader/shader_ir.h" |
| 30 | #include "video_core/surface.h" | 30 | #include "video_core/surface.h" |
| 31 | 31 | ||
| @@ -147,7 +147,7 @@ private: | |||
| 147 | GPUVAddr gpu_addr{}; | 147 | GPUVAddr gpu_addr{}; |
| 148 | VAddr cpu_addr{}; | 148 | VAddr cpu_addr{}; |
| 149 | ProgramCode program_code; | 149 | ProgramCode program_code; |
| 150 | VideoCommon::Shader::ConstBufferLocker locker; | 150 | VideoCommon::Shader::Registry registry; |
| 151 | VideoCommon::Shader::ShaderIR shader_ir; | 151 | VideoCommon::Shader::ShaderIR shader_ir; |
| 152 | ShaderEntries entries; | 152 | ShaderEntries entries; |
| 153 | }; | 153 | }; |
diff --git a/src/video_core/shader/control_flow.cpp b/src/video_core/shader/control_flow.cpp index 0229733b6..2e2711350 100644 --- a/src/video_core/shader/control_flow.cpp +++ b/src/video_core/shader/control_flow.cpp | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "video_core/shader/ast.h" | 14 | #include "video_core/shader/ast.h" |
| 15 | #include "video_core/shader/control_flow.h" | 15 | #include "video_core/shader/control_flow.h" |
| 16 | #include "video_core/shader/registry.h" | ||
| 16 | #include "video_core/shader/shader_ir.h" | 17 | #include "video_core/shader/shader_ir.h" |
| 17 | 18 | ||
| 18 | namespace VideoCommon::Shader { | 19 | namespace VideoCommon::Shader { |
| @@ -64,11 +65,11 @@ struct BlockInfo { | |||
| 64 | }; | 65 | }; |
| 65 | 66 | ||
| 66 | struct CFGRebuildState { | 67 | struct CFGRebuildState { |
| 67 | explicit CFGRebuildState(const ProgramCode& program_code, u32 start, ConstBufferLocker& locker) | 68 | explicit CFGRebuildState(const ProgramCode& program_code, u32 start, Registry& registry) |
| 68 | : program_code{program_code}, locker{locker}, start{start} {} | 69 | : program_code{program_code}, registry{registry}, start{start} {} |
| 69 | 70 | ||
| 70 | const ProgramCode& program_code; | 71 | const ProgramCode& program_code; |
| 71 | ConstBufferLocker& locker; | 72 | Registry& registry; |
| 72 | u32 start{}; | 73 | u32 start{}; |
| 73 | std::vector<BlockInfo> block_info; | 74 | std::vector<BlockInfo> block_info; |
| 74 | std::list<u32> inspect_queries; | 75 | std::list<u32> inspect_queries; |
| @@ -438,7 +439,7 @@ std::pair<ParseResult, ParseInfo> ParseCode(CFGRebuildState& state, u32 address) | |||
| 438 | const s32 pc_target = offset + result.relative_position; | 439 | const s32 pc_target = offset + result.relative_position; |
| 439 | std::vector<CaseBranch> branches; | 440 | std::vector<CaseBranch> branches; |
| 440 | for (u32 i = 0; i < result.entries; i++) { | 441 | for (u32 i = 0; i < result.entries; i++) { |
| 441 | auto key = state.locker.ObtainKey(result.buffer, result.offset + i * 4); | 442 | auto key = state.registry.ObtainKey(result.buffer, result.offset + i * 4); |
| 442 | if (!key) { | 443 | if (!key) { |
| 443 | return {ParseResult::AbnormalFlow, parse_info}; | 444 | return {ParseResult::AbnormalFlow, parse_info}; |
| 444 | } | 445 | } |
| @@ -656,14 +657,14 @@ void DecompileShader(CFGRebuildState& state) { | |||
| 656 | 657 | ||
| 657 | std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code, u32 start_address, | 658 | std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code, u32 start_address, |
| 658 | const CompilerSettings& settings, | 659 | const CompilerSettings& settings, |
| 659 | ConstBufferLocker& locker) { | 660 | Registry& registry) { |
| 660 | auto result_out = std::make_unique<ShaderCharacteristics>(); | 661 | auto result_out = std::make_unique<ShaderCharacteristics>(); |
| 661 | if (settings.depth == CompileDepth::BruteForce) { | 662 | if (settings.depth == CompileDepth::BruteForce) { |
| 662 | result_out->settings.depth = CompileDepth::BruteForce; | 663 | result_out->settings.depth = CompileDepth::BruteForce; |
| 663 | return result_out; | 664 | return result_out; |
| 664 | } | 665 | } |
| 665 | 666 | ||
| 666 | CFGRebuildState state{program_code, start_address, locker}; | 667 | CFGRebuildState state{program_code, start_address, registry}; |
| 667 | // Inspect Code and generate blocks | 668 | // Inspect Code and generate blocks |
| 668 | state.labels.clear(); | 669 | state.labels.clear(); |
| 669 | state.labels.emplace(start_address); | 670 | state.labels.emplace(start_address); |
diff --git a/src/video_core/shader/control_flow.h b/src/video_core/shader/control_flow.h index 5304998b9..62a3510d8 100644 --- a/src/video_core/shader/control_flow.h +++ b/src/video_core/shader/control_flow.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "video_core/engines/shader_bytecode.h" | 12 | #include "video_core/engines/shader_bytecode.h" |
| 13 | #include "video_core/shader/ast.h" | 13 | #include "video_core/shader/ast.h" |
| 14 | #include "video_core/shader/compiler_settings.h" | 14 | #include "video_core/shader/compiler_settings.h" |
| 15 | #include "video_core/shader/registry.h" | ||
| 15 | #include "video_core/shader/shader_ir.h" | 16 | #include "video_core/shader/shader_ir.h" |
| 16 | 17 | ||
| 17 | namespace VideoCommon::Shader { | 18 | namespace VideoCommon::Shader { |
| @@ -111,6 +112,6 @@ struct ShaderCharacteristics { | |||
| 111 | 112 | ||
| 112 | std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code, u32 start_address, | 113 | std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code, u32 start_address, |
| 113 | const CompilerSettings& settings, | 114 | const CompilerSettings& settings, |
| 114 | ConstBufferLocker& locker); | 115 | Registry& registry); |
| 115 | 116 | ||
| 116 | } // namespace VideoCommon::Shader | 117 | } // namespace VideoCommon::Shader |
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp index af4490d66..87ac9ac6c 100644 --- a/src/video_core/shader/decode.cpp +++ b/src/video_core/shader/decode.cpp | |||
| @@ -141,7 +141,7 @@ void ShaderIR::Decode() { | |||
| 141 | std::memcpy(&header, program_code.data(), sizeof(Tegra::Shader::Header)); | 141 | std::memcpy(&header, program_code.data(), sizeof(Tegra::Shader::Header)); |
| 142 | 142 | ||
| 143 | decompiled = false; | 143 | decompiled = false; |
| 144 | auto info = ScanFlow(program_code, main_offset, settings, locker); | 144 | auto info = ScanFlow(program_code, main_offset, settings, registry); |
| 145 | auto& shader_info = *info; | 145 | auto& shader_info = *info; |
| 146 | coverage_begin = shader_info.start; | 146 | coverage_begin = shader_info.start; |
| 147 | coverage_end = shader_info.end; | 147 | coverage_end = shader_info.end; |
| @@ -356,7 +356,7 @@ u32 ShaderIR::DecodeInstr(NodeBlock& bb, u32 pc) { | |||
| 356 | 356 | ||
| 357 | void ShaderIR::PostDecode() { | 357 | void ShaderIR::PostDecode() { |
| 358 | // Deduce texture handler size if needed | 358 | // Deduce texture handler size if needed |
| 359 | auto gpu_driver = locker.AccessGuestDriverProfile(); | 359 | auto gpu_driver = registry.AccessGuestDriverProfile(); |
| 360 | DeduceTextureHandlerSize(gpu_driver, used_samplers); | 360 | DeduceTextureHandlerSize(gpu_driver, used_samplers); |
| 361 | // Deduce Indexed Samplers | 361 | // Deduce Indexed Samplers |
| 362 | if (!uses_indexed_samplers) { | 362 | if (!uses_indexed_samplers) { |
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index bee7d8cad..48350e042 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 13 | #include "video_core/engines/shader_bytecode.h" | 13 | #include "video_core/engines/shader_bytecode.h" |
| 14 | #include "video_core/shader/node_helper.h" | 14 | #include "video_core/shader/node_helper.h" |
| 15 | #include "video_core/shader/registry.h" | ||
| 15 | #include "video_core/shader/shader_ir.h" | 16 | #include "video_core/shader/shader_ir.h" |
| 16 | 17 | ||
| 17 | namespace VideoCommon::Shader { | 18 | namespace VideoCommon::Shader { |
| @@ -359,8 +360,8 @@ ShaderIR::SamplerInfo ShaderIR::GetSamplerInfo(std::optional<SamplerInfo> sample | |||
| 359 | if (sampler_info) { | 360 | if (sampler_info) { |
| 360 | return *sampler_info; | 361 | return *sampler_info; |
| 361 | } | 362 | } |
| 362 | const auto sampler = | 363 | const auto sampler = buffer ? registry.ObtainBindlessSampler(*buffer, offset) |
| 363 | buffer ? locker.ObtainBindlessSampler(*buffer, offset) : locker.ObtainBoundSampler(offset); | 364 | : registry.ObtainBoundSampler(offset); |
| 364 | if (!sampler) { | 365 | if (!sampler) { |
| 365 | LOG_WARNING(HW_GPU, "Unknown sampler info"); | 366 | LOG_WARNING(HW_GPU, "Unknown sampler info"); |
| 366 | return SamplerInfo{TextureType::Texture2D, false, false, false}; | 367 | return SamplerInfo{TextureType::Texture2D, false, false, false}; |
diff --git a/src/video_core/shader/const_buffer_locker.cpp b/src/video_core/shader/registry.cpp index c859dd7ca..7126caf98 100644 --- a/src/video_core/shader/const_buffer_locker.cpp +++ b/src/video_core/shader/registry.cpp | |||
| @@ -8,23 +8,23 @@ | |||
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "video_core/engines/maxwell_3d.h" | 9 | #include "video_core/engines/maxwell_3d.h" |
| 10 | #include "video_core/engines/shader_type.h" | 10 | #include "video_core/engines/shader_type.h" |
| 11 | #include "video_core/shader/const_buffer_locker.h" | 11 | #include "video_core/shader/registry.h" |
| 12 | 12 | ||
| 13 | namespace VideoCommon::Shader { | 13 | namespace VideoCommon::Shader { |
| 14 | 14 | ||
| 15 | using Tegra::Engines::SamplerDescriptor; | 15 | using Tegra::Engines::SamplerDescriptor; |
| 16 | 16 | ||
| 17 | ConstBufferLocker::ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, | 17 | Registry::Registry(Tegra::Engines::ShaderType shader_stage, |
| 18 | VideoCore::GuestDriverProfile stored_guest_driver_profile) | 18 | VideoCore::GuestDriverProfile stored_guest_driver_profile) |
| 19 | : stage{shader_stage}, stored_guest_driver_profile{stored_guest_driver_profile} {} | 19 | : stage{shader_stage}, stored_guest_driver_profile{stored_guest_driver_profile} {} |
| 20 | 20 | ||
| 21 | ConstBufferLocker::ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, | 21 | Registry::Registry(Tegra::Engines::ShaderType shader_stage, |
| 22 | Tegra::Engines::ConstBufferEngineInterface& engine) | 22 | Tegra::Engines::ConstBufferEngineInterface& engine) |
| 23 | : stage{shader_stage}, engine{&engine} {} | 23 | : stage{shader_stage}, engine{&engine} {} |
| 24 | 24 | ||
| 25 | ConstBufferLocker::~ConstBufferLocker() = default; | 25 | Registry::~Registry() = default; |
| 26 | 26 | ||
| 27 | std::optional<u32> ConstBufferLocker::ObtainKey(u32 buffer, u32 offset) { | 27 | std::optional<u32> Registry::ObtainKey(u32 buffer, u32 offset) { |
| 28 | const std::pair<u32, u32> key = {buffer, offset}; | 28 | const std::pair<u32, u32> key = {buffer, offset}; |
| 29 | const auto iter = keys.find(key); | 29 | const auto iter = keys.find(key); |
| 30 | if (iter != keys.end()) { | 30 | if (iter != keys.end()) { |
| @@ -38,7 +38,7 @@ std::optional<u32> ConstBufferLocker::ObtainKey(u32 buffer, u32 offset) { | |||
| 38 | return value; | 38 | return value; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | std::optional<SamplerDescriptor> ConstBufferLocker::ObtainBoundSampler(u32 offset) { | 41 | std::optional<SamplerDescriptor> Registry::ObtainBoundSampler(u32 offset) { |
| 42 | const u32 key = offset; | 42 | const u32 key = offset; |
| 43 | const auto iter = bound_samplers.find(key); | 43 | const auto iter = bound_samplers.find(key); |
| 44 | if (iter != bound_samplers.end()) { | 44 | if (iter != bound_samplers.end()) { |
| @@ -52,8 +52,8 @@ std::optional<SamplerDescriptor> ConstBufferLocker::ObtainBoundSampler(u32 offse | |||
| 52 | return value; | 52 | return value; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | std::optional<Tegra::Engines::SamplerDescriptor> ConstBufferLocker::ObtainBindlessSampler( | 55 | std::optional<Tegra::Engines::SamplerDescriptor> Registry::ObtainBindlessSampler(u32 buffer, |
| 56 | u32 buffer, u32 offset) { | 56 | u32 offset) { |
| 57 | const std::pair key = {buffer, offset}; | 57 | const std::pair key = {buffer, offset}; |
| 58 | const auto iter = bindless_samplers.find(key); | 58 | const auto iter = bindless_samplers.find(key); |
| 59 | if (iter != bindless_samplers.end()) { | 59 | if (iter != bindless_samplers.end()) { |
| @@ -67,7 +67,7 @@ std::optional<Tegra::Engines::SamplerDescriptor> ConstBufferLocker::ObtainBindle | |||
| 67 | return value; | 67 | return value; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | std::optional<u32> ConstBufferLocker::ObtainBoundBuffer() { | 70 | std::optional<u32> Registry::ObtainBoundBuffer() { |
| 71 | if (bound_buffer_saved) { | 71 | if (bound_buffer_saved) { |
| 72 | return bound_buffer; | 72 | return bound_buffer; |
| 73 | } | 73 | } |
| @@ -79,24 +79,24 @@ std::optional<u32> ConstBufferLocker::ObtainBoundBuffer() { | |||
| 79 | return bound_buffer; | 79 | return bound_buffer; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | void ConstBufferLocker::InsertKey(u32 buffer, u32 offset, u32 value) { | 82 | void Registry::InsertKey(u32 buffer, u32 offset, u32 value) { |
| 83 | keys.insert_or_assign({buffer, offset}, value); | 83 | keys.insert_or_assign({buffer, offset}, value); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | void ConstBufferLocker::InsertBoundSampler(u32 offset, SamplerDescriptor sampler) { | 86 | void Registry::InsertBoundSampler(u32 offset, SamplerDescriptor sampler) { |
| 87 | bound_samplers.insert_or_assign(offset, sampler); | 87 | bound_samplers.insert_or_assign(offset, sampler); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | void ConstBufferLocker::InsertBindlessSampler(u32 buffer, u32 offset, SamplerDescriptor sampler) { | 90 | void Registry::InsertBindlessSampler(u32 buffer, u32 offset, SamplerDescriptor sampler) { |
| 91 | bindless_samplers.insert_or_assign({buffer, offset}, sampler); | 91 | bindless_samplers.insert_or_assign({buffer, offset}, sampler); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | void ConstBufferLocker::SetBoundBuffer(u32 buffer) { | 94 | void Registry::SetBoundBuffer(u32 buffer) { |
| 95 | bound_buffer_saved = true; | 95 | bound_buffer_saved = true; |
| 96 | bound_buffer = buffer; | 96 | bound_buffer = buffer; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | bool ConstBufferLocker::IsConsistent() const { | 99 | bool Registry::IsConsistent() const { |
| 100 | if (!engine) { | 100 | if (!engine) { |
| 101 | return true; | 101 | return true; |
| 102 | } | 102 | } |
| @@ -119,7 +119,7 @@ bool ConstBufferLocker::IsConsistent() const { | |||
| 119 | }); | 119 | }); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | bool ConstBufferLocker::HasEqualKeys(const ConstBufferLocker& rhs) const { | 122 | bool Registry::HasEqualKeys(const Registry& rhs) const { |
| 123 | return std::tie(keys, bound_samplers, bindless_samplers) == | 123 | return std::tie(keys, bound_samplers, bindless_samplers) == |
| 124 | std::tie(rhs.keys, rhs.bound_samplers, rhs.bindless_samplers); | 124 | std::tie(rhs.keys, rhs.bound_samplers, rhs.bindless_samplers); |
| 125 | } | 125 | } |
diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/registry.h index 7c6f7bbdd..a5487e1d7 100644 --- a/src/video_core/shader/const_buffer_locker.h +++ b/src/video_core/shader/registry.h | |||
| @@ -20,21 +20,21 @@ using BindlessSamplerMap = | |||
| 20 | std::unordered_map<std::pair<u32, u32>, Tegra::Engines::SamplerDescriptor, Common::PairHash>; | 20 | std::unordered_map<std::pair<u32, u32>, Tegra::Engines::SamplerDescriptor, Common::PairHash>; |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * The ConstBufferLocker is a class use to interface the 3D and compute engines with the shader | 23 | * The Registry is a class use to interface the 3D and compute engines with the shader compiler. |
| 24 | * compiler. with it, the shader can obtain required data from GPU state and store it for disk | 24 | * With it, the shader can obtain required data from GPU state and store it for disk shader |
| 25 | * shader compilation. | 25 | * compilation. |
| 26 | */ | 26 | */ |
| 27 | class ConstBufferLocker { | 27 | class Registry { |
| 28 | public: | 28 | public: |
| 29 | explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, | 29 | explicit Registry(Tegra::Engines::ShaderType shader_stage, |
| 30 | VideoCore::GuestDriverProfile stored_guest_driver_profile); | 30 | VideoCore::GuestDriverProfile stored_guest_driver_profile); |
| 31 | 31 | ||
| 32 | explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, | 32 | explicit Registry(Tegra::Engines::ShaderType shader_stage, |
| 33 | Tegra::Engines::ConstBufferEngineInterface& engine); | 33 | Tegra::Engines::ConstBufferEngineInterface& engine); |
| 34 | 34 | ||
| 35 | ~ConstBufferLocker(); | 35 | ~Registry(); |
| 36 | 36 | ||
| 37 | /// Retrieves a key from the locker, if it's registered, it will give the registered value, if | 37 | /// Retrieves a key from the registry, if it's registered, it will give the registered value, if |
| 38 | /// not it will obtain it from maxwell3d and register it. | 38 | /// not it will obtain it from maxwell3d and register it. |
| 39 | std::optional<u32> ObtainKey(u32 buffer, u32 offset); | 39 | std::optional<u32> ObtainKey(u32 buffer, u32 offset); |
| 40 | 40 | ||
| @@ -53,15 +53,15 @@ public: | |||
| 53 | /// Inserts a bindless sampler key. | 53 | /// Inserts a bindless sampler key. |
| 54 | void InsertBindlessSampler(u32 buffer, u32 offset, Tegra::Engines::SamplerDescriptor sampler); | 54 | void InsertBindlessSampler(u32 buffer, u32 offset, Tegra::Engines::SamplerDescriptor sampler); |
| 55 | 55 | ||
| 56 | /// Set the bound buffer for this locker. | 56 | /// Set the bound buffer for this registry. |
| 57 | void SetBoundBuffer(u32 buffer); | 57 | void SetBoundBuffer(u32 buffer); |
| 58 | 58 | ||
| 59 | /// Checks keys and samplers against engine's current const buffers. Returns true if they are | 59 | /// Checks keys and samplers against engine's current const buffers. |
| 60 | /// the same value, false otherwise; | 60 | /// Returns true if they are the same value, false otherwise. |
| 61 | bool IsConsistent() const; | 61 | bool IsConsistent() const; |
| 62 | 62 | ||
| 63 | /// Returns true if the keys are equal to the other ones in the locker. | 63 | /// Returns true if the keys are equal to the other ones in the registry. |
| 64 | bool HasEqualKeys(const ConstBufferLocker& rhs) const; | 64 | bool HasEqualKeys(const Registry& rhs) const; |
| 65 | 65 | ||
| 66 | /// Gives an getter to the const buffer keys in the database. | 66 | /// Gives an getter to the const buffer keys in the database. |
| 67 | const KeyMap& GetKeys() const { | 67 | const KeyMap& GetKeys() const { |
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index 3a5d280a9..425927777 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "video_core/engines/shader_bytecode.h" | 12 | #include "video_core/engines/shader_bytecode.h" |
| 13 | #include "video_core/shader/node_helper.h" | 13 | #include "video_core/shader/node_helper.h" |
| 14 | #include "video_core/shader/registry.h" | ||
| 14 | #include "video_core/shader/shader_ir.h" | 15 | #include "video_core/shader/shader_ir.h" |
| 15 | 16 | ||
| 16 | namespace VideoCommon::Shader { | 17 | namespace VideoCommon::Shader { |
| @@ -24,8 +25,8 @@ using Tegra::Shader::PredOperation; | |||
| 24 | using Tegra::Shader::Register; | 25 | using Tegra::Shader::Register; |
| 25 | 26 | ||
| 26 | ShaderIR::ShaderIR(const ProgramCode& program_code, u32 main_offset, CompilerSettings settings, | 27 | ShaderIR::ShaderIR(const ProgramCode& program_code, u32 main_offset, CompilerSettings settings, |
| 27 | ConstBufferLocker& locker) | 28 | Registry& registry) |
| 28 | : program_code{program_code}, main_offset{main_offset}, settings{settings}, locker{locker} { | 29 | : program_code{program_code}, main_offset{main_offset}, settings{settings}, registry{registry} { |
| 29 | Decode(); | 30 | Decode(); |
| 30 | PostDecode(); | 31 | PostDecode(); |
| 31 | } | 32 | } |
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index b0851c3be..dde036b40 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h | |||
| @@ -18,8 +18,8 @@ | |||
| 18 | #include "video_core/engines/shader_header.h" | 18 | #include "video_core/engines/shader_header.h" |
| 19 | #include "video_core/shader/ast.h" | 19 | #include "video_core/shader/ast.h" |
| 20 | #include "video_core/shader/compiler_settings.h" | 20 | #include "video_core/shader/compiler_settings.h" |
| 21 | #include "video_core/shader/const_buffer_locker.h" | ||
| 22 | #include "video_core/shader/node.h" | 21 | #include "video_core/shader/node.h" |
| 22 | #include "video_core/shader/registry.h" | ||
| 23 | 23 | ||
| 24 | namespace VideoCommon::Shader { | 24 | namespace VideoCommon::Shader { |
| 25 | 25 | ||
| @@ -69,7 +69,7 @@ struct GlobalMemoryUsage { | |||
| 69 | class ShaderIR final { | 69 | class ShaderIR final { |
| 70 | public: | 70 | public: |
| 71 | explicit ShaderIR(const ProgramCode& program_code, u32 main_offset, CompilerSettings settings, | 71 | explicit ShaderIR(const ProgramCode& program_code, u32 main_offset, CompilerSettings settings, |
| 72 | ConstBufferLocker& locker); | 72 | Registry& registry); |
| 73 | ~ShaderIR(); | 73 | ~ShaderIR(); |
| 74 | 74 | ||
| 75 | const std::map<u32, NodeBlock>& GetBasicBlocks() const { | 75 | const std::map<u32, NodeBlock>& GetBasicBlocks() const { |
| @@ -414,7 +414,7 @@ private: | |||
| 414 | const ProgramCode& program_code; | 414 | const ProgramCode& program_code; |
| 415 | const u32 main_offset; | 415 | const u32 main_offset; |
| 416 | const CompilerSettings settings; | 416 | const CompilerSettings settings; |
| 417 | ConstBufferLocker& locker; | 417 | Registry& registry; |
| 418 | 418 | ||
| 419 | bool decompiled{}; | 419 | bool decompiled{}; |
| 420 | bool disable_flow_stack{}; | 420 | bool disable_flow_stack{}; |
diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index b1a0aa00c..831219841 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp | |||
| @@ -81,7 +81,7 @@ std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, cons | |||
| 81 | MakeTrackSampler<BindlessSamplerNode>(cbuf->GetIndex(), immediate->GetValue()); | 81 | MakeTrackSampler<BindlessSamplerNode>(cbuf->GetIndex(), immediate->GetValue()); |
| 82 | return {tracked, track}; | 82 | return {tracked, track}; |
| 83 | } else if (const auto operation = std::get_if<OperationNode>(&*offset)) { | 83 | } else if (const auto operation = std::get_if<OperationNode>(&*offset)) { |
| 84 | auto bound_buffer = locker.ObtainBoundBuffer(); | 84 | const auto bound_buffer = registry.ObtainBoundBuffer(); |
| 85 | if (!bound_buffer) { | 85 | if (!bound_buffer) { |
| 86 | return {}; | 86 | return {}; |
| 87 | } | 87 | } |
| @@ -94,7 +94,7 @@ std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, cons | |||
| 94 | } | 94 | } |
| 95 | auto [gpr, base_offset] = *pair; | 95 | auto [gpr, base_offset] = *pair; |
| 96 | const auto offset_inm = std::get_if<ImmediateNode>(&*base_offset); | 96 | const auto offset_inm = std::get_if<ImmediateNode>(&*base_offset); |
| 97 | const auto& gpu_driver = locker.AccessGuestDriverProfile(); | 97 | const auto& gpu_driver = registry.AccessGuestDriverProfile(); |
| 98 | const u32 bindless_cv = NewCustomVariable(); | 98 | const u32 bindless_cv = NewCustomVariable(); |
| 99 | const Node op = | 99 | const Node op = |
| 100 | Operation(OperationCode::UDiv, gpr, Immediate(gpu_driver.GetTextureHandlerSize())); | 100 | Operation(OperationCode::UDiv, gpr, Immediate(gpu_driver.GetTextureHandlerSize())); |