diff options
| author | 2020-01-03 16:16:29 -0400 | |
|---|---|---|
| committer | 2020-01-24 16:43:29 -0400 | |
| commit | c921e496eb47de49a4d6ce62527581b966dca259 (patch) | |
| tree | 788c71599f0abf53b479bd3f2f3ea730fc9c35c4 /src/video_core/guest_driver.cpp | |
| parent | Merge pull request #3273 from FernandoS27/txd-array (diff) | |
| download | yuzu-c921e496eb47de49a4d6ce62527581b966dca259.tar.gz yuzu-c921e496eb47de49a4d6ce62527581b966dca259.tar.xz yuzu-c921e496eb47de49a4d6ce62527581b966dca259.zip | |
GPU: Implement guest driver profile and deduce texture handler sizes.
Diffstat (limited to 'src/video_core/guest_driver.cpp')
| -rw-r--r-- | src/video_core/guest_driver.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/video_core/guest_driver.cpp b/src/video_core/guest_driver.cpp new file mode 100644 index 000000000..b1ac254ff --- /dev/null +++ b/src/video_core/guest_driver.cpp | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "video_core/guest_driver.h" | ||
| 6 | |||
| 7 | namespace VideoCore { | ||
| 8 | |||
| 9 | void GuestDriverProfile::DeduceTextureHandlerSize(std::vector<u32>&& bound_offsets) { | ||
| 10 | if (texture_handler_size_deduced) { | ||
| 11 | return; | ||
| 12 | } | ||
| 13 | std::size_t size = bound_offsets.size(); | ||
| 14 | if (size < 2) { | ||
| 15 | return; | ||
| 16 | } | ||
| 17 | std::sort(bound_offsets.begin(), bound_offsets.end(), | ||
| 18 | [](const u32& a, const u32& b) { return a < b; }); | ||
| 19 | u32 min_val = 0xFFFFFFFF; // set to highest possible 32 bit integer; | ||
| 20 | for (std::size_t i = 1; i < size; i++) { | ||
| 21 | if (bound_offsets[i] == bound_offsets[i - 1]) { | ||
| 22 | continue; | ||
| 23 | } | ||
| 24 | const u32 new_min = bound_offsets[i] - bound_offsets[i - 1]; | ||
| 25 | min_val = std::min(min_val, new_min); | ||
| 26 | } | ||
| 27 | if (min_val > 2) { | ||
| 28 | return; | ||
| 29 | } | ||
| 30 | texture_handler_size_deduced = true; | ||
| 31 | texture_handler_size = sizeof(u32) * min_val; | ||
| 32 | } | ||
| 33 | |||
| 34 | } // namespace VideoCore | ||