diff options
Diffstat (limited to 'src/video_core/guest_driver.cpp')
| -rw-r--r-- | src/video_core/guest_driver.cpp | 36 |
1 files changed, 36 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..6adef459e --- /dev/null +++ b/src/video_core/guest_driver.cpp | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <limits> | ||
| 7 | |||
| 8 | #include "video_core/guest_driver.h" | ||
| 9 | |||
| 10 | namespace VideoCore { | ||
| 11 | |||
| 12 | void GuestDriverProfile::DeduceTextureHandlerSize(std::vector<u32>&& bound_offsets) { | ||
| 13 | if (texture_handler_size_deduced) { | ||
| 14 | return; | ||
| 15 | } | ||
| 16 | const std::size_t size = bound_offsets.size(); | ||
| 17 | if (size < 2) { | ||
| 18 | return; | ||
| 19 | } | ||
| 20 | std::sort(bound_offsets.begin(), bound_offsets.end(), std::less{}); | ||
| 21 | u32 min_val = std::numeric_limits<u32>::max(); | ||
| 22 | for (std::size_t i = 1; i < size; ++i) { | ||
| 23 | if (bound_offsets[i] == bound_offsets[i - 1]) { | ||
| 24 | continue; | ||
| 25 | } | ||
| 26 | const u32 new_min = bound_offsets[i] - bound_offsets[i - 1]; | ||
| 27 | min_val = std::min(min_val, new_min); | ||
| 28 | } | ||
| 29 | if (min_val > 2) { | ||
| 30 | return; | ||
| 31 | } | ||
| 32 | texture_handler_size_deduced = true; | ||
| 33 | texture_handler_size = min_texture_handler_size * min_val; | ||
| 34 | } | ||
| 35 | |||
| 36 | } // namespace VideoCore | ||