diff options
| author | 2020-01-08 11:46:36 -0400 | |
|---|---|---|
| committer | 2020-01-24 16:43:30 -0400 | |
| commit | 64496f24569ecc23ebbb816725f27142867b1468 (patch) | |
| tree | e7dd660d9bdf3afc7a90a35314c18b29792e119a /src | |
| parent | Shader_IR: Allow constant access of guest driver. (diff) | |
| download | yuzu-64496f24569ecc23ebbb816725f27142867b1468.tar.gz yuzu-64496f24569ecc23ebbb816725f27142867b1468.tar.xz yuzu-64496f24569ecc23ebbb816725f27142867b1468.zip | |
Shader_IR: Address Feedback
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/guest_driver.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/guest_driver.h | 11 | ||||
| -rw-r--r-- | src/video_core/rasterizer_interface.h | 2 | ||||
| -rw-r--r-- | src/video_core/shader/const_buffer_locker.h | 2 | ||||
| -rw-r--r-- | src/video_core/shader/decode.cpp | 48 |
5 files changed, 37 insertions, 35 deletions
diff --git a/src/video_core/guest_driver.cpp b/src/video_core/guest_driver.cpp index 1ded52905..6adef459e 100644 --- a/src/video_core/guest_driver.cpp +++ b/src/video_core/guest_driver.cpp | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <climits> | 6 | #include <limits> |
| 7 | 7 | ||
| 8 | #include "video_core/guest_driver.h" | 8 | #include "video_core/guest_driver.h" |
| 9 | 9 | ||
| @@ -17,10 +17,9 @@ void GuestDriverProfile::DeduceTextureHandlerSize(std::vector<u32>&& bound_offse | |||
| 17 | if (size < 2) { | 17 | if (size < 2) { |
| 18 | return; | 18 | return; |
| 19 | } | 19 | } |
| 20 | std::sort(bound_offsets.begin(), bound_offsets.end(), | 20 | std::sort(bound_offsets.begin(), bound_offsets.end(), std::less{}); |
| 21 | [](const u32& a, const u32& b) { return a < b; }); | 21 | u32 min_val = std::numeric_limits<u32>::max(); |
| 22 | u32 min_val = UINT_MAX; | 22 | for (std::size_t i = 1; i < size; ++i) { |
| 23 | for (std::size_t i = 1; i < size; i++) { | ||
| 24 | if (bound_offsets[i] == bound_offsets[i - 1]) { | 23 | if (bound_offsets[i] == bound_offsets[i - 1]) { |
| 25 | continue; | 24 | continue; |
| 26 | } | 25 | } |
diff --git a/src/video_core/guest_driver.h b/src/video_core/guest_driver.h index e08588ee9..0a9a826b6 100644 --- a/src/video_core/guest_driver.h +++ b/src/video_core/guest_driver.h | |||
| @@ -12,10 +12,13 @@ namespace VideoCore { | |||
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * The GuestDriverProfile class is used to learn about the GPU drivers behavior and collect | 14 | * The GuestDriverProfile class is used to learn about the GPU drivers behavior and collect |
| 15 | * information necessary for impossible to avoid HLE methods like shader tracks. | 15 | * information necessary for impossible to avoid HLE methods like shader tracks as they are |
| 16 | * Entscheidungsproblems. | ||
| 16 | */ | 17 | */ |
| 17 | class GuestDriverProfile { | 18 | class GuestDriverProfile { |
| 18 | public: | 19 | public: |
| 20 | void DeduceTextureHandlerSize(std::vector<u32>&& bound_offsets); | ||
| 21 | |||
| 19 | u32 GetTextureHandlerSize() const { | 22 | u32 GetTextureHandlerSize() const { |
| 20 | return texture_handler_size; | 23 | return texture_handler_size; |
| 21 | } | 24 | } |
| @@ -24,16 +27,14 @@ public: | |||
| 24 | return texture_handler_size_deduced; | 27 | return texture_handler_size_deduced; |
| 25 | } | 28 | } |
| 26 | 29 | ||
| 27 | void DeduceTextureHandlerSize(std::vector<u32>&& bound_offsets); | ||
| 28 | |||
| 29 | private: | 30 | private: |
| 30 | // Minimum size of texture handler any driver can use. | 31 | // Minimum size of texture handler any driver can use. |
| 31 | static constexpr u32 min_texture_handler_size = 4; | 32 | static constexpr u32 min_texture_handler_size = 4; |
| 32 | // 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 |
| 33 | // use 4 bytes instead. Thus, certain drivers may squish the size. | 34 | // use 4 bytes instead. Thus, certain drivers may squish the size. |
| 34 | static constexpr u32 default_texture_handler_size = 8; | 35 | static constexpr u32 default_texture_handler_size = 8; |
| 35 | u32 texture_handler_size{default_texture_handler_size}; | 36 | u32 texture_handler_size = default_texture_handler_size; |
| 36 | bool texture_handler_size_deduced{}; | 37 | bool texture_handler_size_deduced = false; |
| 37 | }; | 38 | }; |
| 38 | 39 | ||
| 39 | } // namespace VideoCore | 40 | } // namespace VideoCore |
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index 1b0cc56f1..c586cd6fe 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -80,10 +80,12 @@ public: | |||
| 80 | virtual void LoadDiskResources(const std::atomic_bool& stop_loading = false, | 80 | virtual void LoadDiskResources(const std::atomic_bool& stop_loading = false, |
| 81 | const DiskResourceLoadCallback& callback = {}) {} | 81 | const DiskResourceLoadCallback& callback = {}) {} |
| 82 | 82 | ||
| 83 | /// Grant access to the Guest Driver Profile for recording/obtaining info on the guest driver. | ||
| 83 | GuestDriverProfile& AccessGuestDriverProfile() { | 84 | GuestDriverProfile& AccessGuestDriverProfile() { |
| 84 | return guest_driver_profile; | 85 | return guest_driver_profile; |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 88 | /// Grant access to the Guest Driver Profile for recording/obtaining info on the guest driver. | ||
| 87 | const GuestDriverProfile& AccessGuestDriverProfile() const { | 89 | const GuestDriverProfile& AccessGuestDriverProfile() const { |
| 88 | return guest_driver_profile; | 90 | return guest_driver_profile; |
| 89 | } | 91 | } |
diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/const_buffer_locker.h index f5655ac64..fd1bb476a 100644 --- a/src/video_core/shader/const_buffer_locker.h +++ b/src/video_core/shader/const_buffer_locker.h | |||
| @@ -83,7 +83,7 @@ public: | |||
| 83 | 83 | ||
| 84 | VideoCore::GuestDriverProfile* AccessGuestDriverProfile() const { | 84 | VideoCore::GuestDriverProfile* AccessGuestDriverProfile() const { |
| 85 | if (engine) { | 85 | if (engine) { |
| 86 | return &(engine->AccessGuestDriverProfile()); | 86 | return &engine->AccessGuestDriverProfile(); |
| 87 | } | 87 | } |
| 88 | return nullptr; | 88 | return nullptr; |
| 89 | } | 89 | } |
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp index c702c7629..507614d59 100644 --- a/src/video_core/shader/decode.cpp +++ b/src/video_core/shader/decode.cpp | |||
| @@ -33,6 +33,29 @@ constexpr bool IsSchedInstruction(u32 offset, u32 main_offset) { | |||
| 33 | return (absolute_offset % SchedPeriod) == 0; | 33 | return (absolute_offset % SchedPeriod) == 0; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver, | ||
| 37 | std::list<Sampler>& used_samplers) { | ||
| 38 | if (gpu_driver == nullptr) { | ||
| 39 | LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet"); | ||
| 40 | return; | ||
| 41 | } | ||
| 42 | if (gpu_driver->TextureHandlerSizeKnown() || used_samplers.size() <= 1) { | ||
| 43 | return; | ||
| 44 | } | ||
| 45 | u32 count{}; | ||
| 46 | std::vector<u32> bound_offsets; | ||
| 47 | for (const auto& sampler : used_samplers) { | ||
| 48 | if (sampler.IsBindless()) { | ||
| 49 | continue; | ||
| 50 | } | ||
| 51 | ++count; | ||
| 52 | bound_offsets.emplace_back(sampler.GetOffset()); | ||
| 53 | } | ||
| 54 | if (count > 1) { | ||
| 55 | gpu_driver->DeduceTextureHandlerSize(std::move(bound_offsets)); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 36 | } // Anonymous namespace | 59 | } // Anonymous namespace |
| 37 | 60 | ||
| 38 | class ASTDecoder { | 61 | class ASTDecoder { |
| @@ -315,32 +338,9 @@ u32 ShaderIR::DecodeInstr(NodeBlock& bb, u32 pc) { | |||
| 315 | return pc + 1; | 338 | return pc + 1; |
| 316 | } | 339 | } |
| 317 | 340 | ||
| 318 | void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver, | ||
| 319 | std::list<Sampler>& used_samplers) { | ||
| 320 | if (gpu_driver == nullptr) { | ||
| 321 | LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet"); | ||
| 322 | return; | ||
| 323 | } | ||
| 324 | if (gpu_driver->TextureHandlerSizeKnown() || used_samplers.size() <= 1) { | ||
| 325 | return; | ||
| 326 | } | ||
| 327 | u32 count{}; | ||
| 328 | std::vector<u32> bound_offsets; | ||
| 329 | for (const auto& sampler : used_samplers) { | ||
| 330 | if (sampler.IsBindless()) { | ||
| 331 | continue; | ||
| 332 | } | ||
| 333 | count++; | ||
| 334 | bound_offsets.emplace_back(sampler.GetOffset()); | ||
| 335 | } | ||
| 336 | if (count > 1) { | ||
| 337 | gpu_driver->DeduceTextureHandlerSize(std::move(bound_offsets)); | ||
| 338 | } | ||
| 339 | } | ||
| 340 | |||
| 341 | void ShaderIR::PostDecode() { | 341 | void ShaderIR::PostDecode() { |
| 342 | // Deduce texture handler size if needed | 342 | // Deduce texture handler size if needed |
| 343 | auto* gpu_driver = locker.AccessGuestDriverProfile(); | 343 | auto gpu_driver = locker.AccessGuestDriverProfile(); |
| 344 | DeduceTextureHandlerSize(gpu_driver, used_samplers); | 344 | DeduceTextureHandlerSize(gpu_driver, used_samplers); |
| 345 | } | 345 | } |
| 346 | 346 | ||