diff options
| -rw-r--r-- | src/video_core/guest_driver.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/shader/const_buffer_locker.h | 2 | ||||
| -rw-r--r-- | src/video_core/shader/decode.cpp | 31 | ||||
| -rw-r--r-- | src/video_core/shader/decode/texture.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/shader/node.h | 14 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.h | 2 | ||||
| -rw-r--r-- | src/video_core/shader/track.cpp | 9 |
10 files changed, 40 insertions, 36 deletions
diff --git a/src/video_core/guest_driver.h b/src/video_core/guest_driver.h index 0a9a826b6..fc1917347 100644 --- a/src/video_core/guest_driver.h +++ b/src/video_core/guest_driver.h | |||
| @@ -33,6 +33,7 @@ private: | |||
| 33 | // This goes with Vulkan and OpenGL standards but Nvidia GPUs can easily | 33 | // This goes with Vulkan and OpenGL standards but Nvidia GPUs can easily |
| 34 | // use 4 bytes instead. Thus, certain drivers may squish the size. | 34 | // use 4 bytes instead. Thus, certain drivers may squish the size. |
| 35 | static constexpr u32 default_texture_handler_size = 8; | 35 | static constexpr u32 default_texture_handler_size = 8; |
| 36 | |||
| 36 | u32 texture_handler_size = default_texture_handler_size; | 37 | u32 texture_handler_size = default_texture_handler_size; |
| 37 | bool texture_handler_size_deduced = false; | 38 | bool texture_handler_size_deduced = false; |
| 38 | }; | 39 | }; |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 2f2bb07a4..cb1a5f35c 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -505,11 +505,11 @@ private: | |||
| 505 | } | 505 | } |
| 506 | 506 | ||
| 507 | void DeclareCustomVariables() { | 507 | void DeclareCustomVariables() { |
| 508 | const u32 cv_num = ir.GetCustomVariablesAmount(); | 508 | const u32 num_custom_variables = ir.GetNumCustomVariables(); |
| 509 | for (u32 i = 0; i < cv_num; ++i) { | 509 | for (u32 i = 0; i < num_custom_variables; ++i) { |
| 510 | code.AddLine("float {} = 0.0f;", GetCustomVariable(i)); | 510 | code.AddLine("float {} = 0.0f;", GetCustomVariable(i)); |
| 511 | } | 511 | } |
| 512 | if (cv_num > 0) { | 512 | if (num_custom_variables > 0) { |
| 513 | code.AddNewLine(); | 513 | code.AddNewLine(); |
| 514 | } | 514 | } |
| 515 | } | 515 | } |
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 130060369..36d928fab 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | |||
| @@ -589,8 +589,8 @@ private: | |||
| 589 | } | 589 | } |
| 590 | 590 | ||
| 591 | void DeclareCustomVariables() { | 591 | void DeclareCustomVariables() { |
| 592 | const u32 cv_num = ir.GetCustomVariablesAmount(); | 592 | const u32 num_custom_variables = ir.GetNumCustomVariables(); |
| 593 | for (u32 i = 0; i < cv_num; ++i) { | 593 | for (u32 i = 0; i < num_custom_variables; ++i) { |
| 594 | const Id id = OpVariable(t_prv_float, spv::StorageClass::Private, v_float_zero); | 594 | const Id id = OpVariable(t_prv_float, spv::StorageClass::Private, v_float_zero); |
| 595 | Name(id, fmt::format("custom_var_{}", i)); | 595 | Name(id, fmt::format("custom_var_{}", i)); |
| 596 | custom_variables.emplace(i, AddGlobalVariable(id)); | 596 | custom_variables.emplace(i, AddGlobalVariable(id)); |
| @@ -1363,6 +1363,7 @@ private: | |||
| 1363 | 1363 | ||
| 1364 | } else if (const auto cv = std::get_if<CustomVarNode>(&*dest)) { | 1364 | } else if (const auto cv = std::get_if<CustomVarNode>(&*dest)) { |
| 1365 | target = {custom_variables.at(cv->GetIndex()), Type::Float}; | 1365 | target = {custom_variables.at(cv->GetIndex()), Type::Float}; |
| 1366 | |||
| 1366 | } else { | 1367 | } else { |
| 1367 | UNIMPLEMENTED(); | 1368 | UNIMPLEMENTED(); |
| 1368 | } | 1369 | } |
diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/const_buffer_locker.h index fd1bb476a..d3ea11087 100644 --- a/src/video_core/shader/const_buffer_locker.h +++ b/src/video_core/shader/const_buffer_locker.h | |||
| @@ -77,10 +77,12 @@ public: | |||
| 77 | return bindless_samplers; | 77 | return bindless_samplers; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | /// Gets bound buffer used on this shader | ||
| 80 | u32 GetBoundBuffer() const { | 81 | u32 GetBoundBuffer() const { |
| 81 | return bound_buffer; | 82 | return bound_buffer; |
| 82 | } | 83 | } |
| 83 | 84 | ||
| 85 | /// Obtains access to the guest driver's profile. | ||
| 84 | VideoCore::GuestDriverProfile* AccessGuestDriverProfile() const { | 86 | VideoCore::GuestDriverProfile* AccessGuestDriverProfile() const { |
| 85 | if (engine) { | 87 | if (engine) { |
| 86 | return &engine->AccessGuestDriverProfile(); | 88 | return &engine->AccessGuestDriverProfile(); |
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp index d4a10eee5..6b697ed5d 100644 --- a/src/video_core/shader/decode.cpp +++ b/src/video_core/shader/decode.cpp | |||
| @@ -35,9 +35,9 @@ constexpr bool IsSchedInstruction(u32 offset, u32 main_offset) { | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver, | 37 | void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver, |
| 38 | std::list<Sampler>& used_samplers) { | 38 | const std::list<Sampler>& used_samplers) { |
| 39 | if (gpu_driver == nullptr) { | 39 | if (gpu_driver == nullptr) { |
| 40 | LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet"); | 40 | LOG_CRITICAL(HW_GPU, "GPU driver profile has not been created yet"); |
| 41 | return; | 41 | return; |
| 42 | } | 42 | } |
| 43 | if (gpu_driver->TextureHandlerSizeKnown() || used_samplers.size() <= 1) { | 43 | if (gpu_driver->TextureHandlerSizeKnown() || used_samplers.size() <= 1) { |
| @@ -57,9 +57,9 @@ void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver, | |||
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | std::optional<u32> TryDeduceSamplerSize(Sampler& sampler_to_deduce, | 60 | std::optional<u32> TryDeduceSamplerSize(const Sampler& sampler_to_deduce, |
| 61 | VideoCore::GuestDriverProfile* gpu_driver, | 61 | VideoCore::GuestDriverProfile* gpu_driver, |
| 62 | std::list<Sampler>& used_samplers) { | 62 | const std::list<Sampler>& used_samplers) { |
| 63 | if (gpu_driver == nullptr) { | 63 | if (gpu_driver == nullptr) { |
| 64 | LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet"); | 64 | LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet"); |
| 65 | return std::nullopt; | 65 | return std::nullopt; |
| @@ -367,17 +367,18 @@ void ShaderIR::PostDecode() { | |||
| 367 | auto gpu_driver = locker.AccessGuestDriverProfile(); | 367 | auto gpu_driver = locker.AccessGuestDriverProfile(); |
| 368 | DeduceTextureHandlerSize(gpu_driver, used_samplers); | 368 | DeduceTextureHandlerSize(gpu_driver, used_samplers); |
| 369 | // Deduce Indexed Samplers | 369 | // Deduce Indexed Samplers |
| 370 | if (uses_indexed_samplers) { | 370 | if (!uses_indexed_samplers) { |
| 371 | for (auto& sampler : used_samplers) { | 371 | return; |
| 372 | if (sampler.IsIndexed()) { | 372 | } |
| 373 | auto size = TryDeduceSamplerSize(sampler, gpu_driver, used_samplers); | 373 | for (auto& sampler : used_samplers) { |
| 374 | if (size) { | 374 | if (!sampler.IsIndexed()) { |
| 375 | sampler.SetSize(*size); | 375 | continue; |
| 376 | } else { | 376 | } |
| 377 | LOG_CRITICAL(HW_GPU, "Failed to deduce size of indexed sampler"); | 377 | if (const auto size = TryDeduceSamplerSize(sampler, gpu_driver, used_samplers)) { |
| 378 | sampler.SetSize(1); | 378 | sampler.SetSize(*size); |
| 379 | } | 379 | } else { |
| 380 | } | 380 | LOG_CRITICAL(HW_GPU, "Failed to deduce size of indexed sampler"); |
| 381 | sampler.SetSize(1); | ||
| 381 | } | 382 | } |
| 382 | } | 383 | } |
| 383 | } | 384 | } |
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 6da9668fe..d980535b1 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp | |||
| @@ -201,7 +201,8 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { | |||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | for (u32 element = 0; element < values.size(); ++element) { | 203 | for (u32 element = 0; element < values.size(); ++element) { |
| 204 | MetaTexture meta{*sampler, array_node, {}, {}, {}, derivates, {}, {}, {}, element, index_var}; | 204 | MetaTexture meta{*sampler, array_node, {}, {}, {}, derivates, |
| 205 | {}, {}, {}, element, index_var}; | ||
| 205 | values[element] = Operation(OperationCode::TextureGradient, std::move(meta), coords); | 206 | values[element] = Operation(OperationCode::TextureGradient, std::move(meta), coords); |
| 206 | } | 207 | } |
| 207 | 208 | ||
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index d75453458..53a551d27 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h | |||
| @@ -291,7 +291,7 @@ public: | |||
| 291 | return size; | 291 | return size; |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | void SetSize(u32 new_size) { | 294 | constexpr void SetSize(u32 new_size) { |
| 295 | size = new_size; | 295 | size = new_size; |
| 296 | } | 296 | } |
| 297 | 297 | ||
| @@ -315,15 +315,15 @@ public: | |||
| 315 | explicit ArraySamplerNode(u32 index, u32 base_offset, u32 bindless_var) | 315 | explicit ArraySamplerNode(u32 index, u32 base_offset, u32 bindless_var) |
| 316 | : index{index}, base_offset{base_offset}, bindless_var{bindless_var} {} | 316 | : index{index}, base_offset{base_offset}, bindless_var{bindless_var} {} |
| 317 | 317 | ||
| 318 | u32 GetIndex() const { | 318 | constexpr u32 GetIndex() const { |
| 319 | return index; | 319 | return index; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | u32 GetBaseOffset() const { | 322 | constexpr u32 GetBaseOffset() const { |
| 323 | return base_offset; | 323 | return base_offset; |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | u32 GetIndexVar() const { | 326 | constexpr u32 GetIndexVar() const { |
| 327 | return bindless_var; | 327 | return bindless_var; |
| 328 | } | 328 | } |
| 329 | 329 | ||
| @@ -338,11 +338,11 @@ class BindlessSamplerNode final { | |||
| 338 | public: | 338 | public: |
| 339 | explicit BindlessSamplerNode(u32 index, u32 offset) : index{index}, offset{offset} {} | 339 | explicit BindlessSamplerNode(u32 index, u32 offset) : index{index}, offset{offset} {} |
| 340 | 340 | ||
| 341 | u32 GetIndex() const { | 341 | constexpr u32 GetIndex() const { |
| 342 | return index; | 342 | return index; |
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | u32 GetOffset() const { | 345 | constexpr u32 GetOffset() const { |
| 346 | return offset; | 346 | return offset; |
| 347 | } | 347 | } |
| 348 | 348 | ||
| @@ -557,7 +557,7 @@ class CustomVarNode final { | |||
| 557 | public: | 557 | public: |
| 558 | explicit constexpr CustomVarNode(u32 index) : index{index} {} | 558 | explicit constexpr CustomVarNode(u32 index) : index{index} {} |
| 559 | 559 | ||
| 560 | u32 GetIndex() const { | 560 | constexpr u32 GetIndex() const { |
| 561 | return index; | 561 | return index; |
| 562 | } | 562 | } |
| 563 | 563 | ||
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index 94972d57f..3a5d280a9 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp | |||
| @@ -458,8 +458,7 @@ std::size_t ShaderIR::DeclareAmend(Node new_amend) { | |||
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | u32 ShaderIR::NewCustomVariable() { | 460 | u32 ShaderIR::NewCustomVariable() { |
| 461 | const u32 id = num_custom_variables++; | 461 | return num_custom_variables++; |
| 462 | return id; | ||
| 463 | } | 462 | } |
| 464 | 463 | ||
| 465 | } // namespace VideoCommon::Shader | 464 | } // namespace VideoCommon::Shader |
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 43672b41c..b0851c3be 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h | |||
| @@ -180,7 +180,7 @@ public: | |||
| 180 | return amend_code[index]; | 180 | return amend_code[index]; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | u32 GetCustomVariablesAmount() const { | 183 | u32 GetNumCustomVariables() const { |
| 184 | return num_custom_variables; | 184 | return num_custom_variables; |
| 185 | } | 185 | } |
| 186 | 186 | ||
diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index 4db721f69..ea39bca54 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp | |||
| @@ -36,7 +36,6 @@ std::pair<Node, s64> FindOperation(const NodeBlock& code, s64 cursor, | |||
| 36 | } | 36 | } |
| 37 | return {}; | 37 | return {}; |
| 38 | } | 38 | } |
| 39 | } // Anonymous namespace | ||
| 40 | 39 | ||
| 41 | std::optional<std::pair<Node, Node>> DecoupleIndirectRead(const OperationNode& operation) { | 40 | std::optional<std::pair<Node, Node>> DecoupleIndirectRead(const OperationNode& operation) { |
| 42 | if (operation.GetCode() != OperationCode::UAdd) { | 41 | if (operation.GetCode() != OperationCode::UAdd) { |
| @@ -44,9 +43,7 @@ std::optional<std::pair<Node, Node>> DecoupleIndirectRead(const OperationNode& o | |||
| 44 | } | 43 | } |
| 45 | Node gpr{}; | 44 | Node gpr{}; |
| 46 | Node offset{}; | 45 | Node offset{}; |
| 47 | if (operation.GetOperandsCount() != 2) { | 46 | ASSERT(operation.GetOperandsCount() == 2); |
| 48 | return std::nullopt; | ||
| 49 | } | ||
| 50 | for (std::size_t i = 0; i < operation.GetOperandsCount(); i++) { | 47 | for (std::size_t i = 0; i < operation.GetOperandsCount(); i++) { |
| 51 | Node operand = operation[i]; | 48 | Node operand = operation[i]; |
| 52 | if (std::holds_alternative<ImmediateNode>(*operand)) { | 49 | if (std::holds_alternative<ImmediateNode>(*operand)) { |
| @@ -56,7 +53,7 @@ std::optional<std::pair<Node, Node>> DecoupleIndirectRead(const OperationNode& o | |||
| 56 | } | 53 | } |
| 57 | } | 54 | } |
| 58 | if (offset && gpr) { | 55 | if (offset && gpr) { |
| 59 | return {std::make_pair(gpr, offset)}; | 56 | return std::make_pair(gpr, offset); |
| 60 | } | 57 | } |
| 61 | return std::nullopt; | 58 | return std::nullopt; |
| 62 | } | 59 | } |
| @@ -72,6 +69,8 @@ bool AmendNodeCv(std::size_t amend_index, Node node) { | |||
| 72 | return false; | 69 | return false; |
| 73 | } | 70 | } |
| 74 | 71 | ||
| 72 | } // Anonymous namespace | ||
| 73 | |||
| 75 | std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, const NodeBlock& code, | 74 | std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, const NodeBlock& code, |
| 76 | s64 cursor) { | 75 | s64 cursor) { |
| 77 | if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) { | 76 | if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) { |