diff options
| author | 2021-07-20 19:36:38 +0200 | |
|---|---|---|
| committer | 2021-11-16 22:11:27 +0100 | |
| commit | 778700ff9d6eca96945deebcd4415e70d58330d9 (patch) | |
| tree | 413adfbca91e85dd3bdcae718786d2ceba549f81 /src/video_core/texture_cache | |
| parent | Settings: eliminate rescaling_factor. (diff) | |
| download | yuzu-778700ff9d6eca96945deebcd4415e70d58330d9.tar.gz yuzu-778700ff9d6eca96945deebcd4415e70d58330d9.tar.xz yuzu-778700ff9d6eca96945deebcd4415e70d58330d9.zip | |
TextureCache: Modify Viewports/Scissors according to Rescale.
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 25 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 3 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index b7d1ae92d..4e5031acc 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <unordered_set> | 7 | #include <unordered_set> |
| 8 | 8 | ||
| 9 | #include "common/alignment.h" | 9 | #include "common/alignment.h" |
| 10 | #include "common/settings.h" | ||
| 10 | #include "video_core/dirty_flags.h" | 11 | #include "video_core/dirty_flags.h" |
| 11 | #include "video_core/engines/kepler_compute.h" | 12 | #include "video_core/engines/kepler_compute.h" |
| 12 | #include "video_core/texture_cache/image_view_base.h" | 13 | #include "video_core/texture_cache/image_view_base.h" |
| @@ -205,6 +206,7 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 205 | return; | 206 | return; |
| 206 | } | 207 | } |
| 207 | 208 | ||
| 209 | bool rescaled; | ||
| 208 | do { | 210 | do { |
| 209 | flags[Dirty::RenderTargets] = false; | 211 | flags[Dirty::RenderTargets] = false; |
| 210 | 212 | ||
| @@ -243,6 +245,7 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 243 | check_rescale(render_targets.depth_buffer_id, tmp_depth_image); | 245 | check_rescale(render_targets.depth_buffer_id, tmp_depth_image); |
| 244 | 246 | ||
| 245 | if (can_rescale) { | 247 | if (can_rescale) { |
| 248 | rescaled = true; | ||
| 246 | const auto scale_up = [this](ImageId image_id) { | 249 | const auto scale_up = [this](ImageId image_id) { |
| 247 | if (image_id != CORRUPT_ID) { | 250 | if (image_id != CORRUPT_ID) { |
| 248 | Image& image = slot_images[image_id]; | 251 | Image& image = slot_images[image_id]; |
| @@ -254,6 +257,7 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 254 | } | 257 | } |
| 255 | scale_up(tmp_depth_image); | 258 | scale_up(tmp_depth_image); |
| 256 | } else { | 259 | } else { |
| 260 | rescaled = false; | ||
| 257 | const auto scale_down = [this](ImageId image_id) { | 261 | const auto scale_down = [this](ImageId image_id) { |
| 258 | if (image_id != CORRUPT_ID) { | 262 | if (image_id != CORRUPT_ID) { |
| 259 | Image& image = slot_images[image_id]; | 263 | Image& image = slot_images[image_id]; |
| @@ -268,6 +272,12 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 268 | } while (has_deleted_images); | 272 | } while (has_deleted_images); |
| 269 | // Rescale End | 273 | // Rescale End |
| 270 | 274 | ||
| 275 | if (is_rescaling != rescaled) { | ||
| 276 | flags[Dirty::RescaleViewports] = true; | ||
| 277 | flags[Dirty::RescaleScissors] = true; | ||
| 278 | is_rescaling = rescaled; | ||
| 279 | } | ||
| 280 | |||
| 271 | for (size_t index = 0; index < NUM_RT; ++index) { | 281 | for (size_t index = 0; index < NUM_RT; ++index) { |
| 272 | ImageViewId& color_buffer_id = render_targets.color_buffer_ids[index]; | 282 | ImageViewId& color_buffer_id = render_targets.color_buffer_ids[index]; |
| 273 | PrepareImageView(color_buffer_id, true, is_clear && IsFullClear(color_buffer_id)); | 283 | PrepareImageView(color_buffer_id, true, is_clear && IsFullClear(color_buffer_id)); |
| @@ -279,9 +289,15 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 279 | for (size_t index = 0; index < NUM_RT; ++index) { | 289 | for (size_t index = 0; index < NUM_RT; ++index) { |
| 280 | render_targets.draw_buffers[index] = static_cast<u8>(maxwell3d.regs.rt_control.Map(index)); | 290 | render_targets.draw_buffers[index] = static_cast<u8>(maxwell3d.regs.rt_control.Map(index)); |
| 281 | } | 291 | } |
| 292 | u32 up_scale = 1; | ||
| 293 | u32 down_shift = 0; | ||
| 294 | if (is_rescaling) { | ||
| 295 | up_scale = Settings::values.resolution_info.up_scale; | ||
| 296 | down_shift = Settings::values.resolution_info.down_shift; | ||
| 297 | } | ||
| 282 | render_targets.size = Extent2D{ | 298 | render_targets.size = Extent2D{ |
| 283 | maxwell3d.regs.render_area.width, | 299 | (maxwell3d.regs.render_area.width * up_scale) >> down_shift, |
| 284 | maxwell3d.regs.render_area.height, | 300 | (maxwell3d.regs.render_area.height * up_scale) >> down_shift, |
| 285 | }; | 301 | }; |
| 286 | 302 | ||
| 287 | flags[Dirty::DepthBiasGlobal] = true; | 303 | flags[Dirty::DepthBiasGlobal] = true; |
| @@ -539,6 +555,11 @@ void TextureCache<P>::PopAsyncFlushes() { | |||
| 539 | } | 555 | } |
| 540 | 556 | ||
| 541 | template <class P> | 557 | template <class P> |
| 558 | bool TextureCache<P>::IsRescaling() { | ||
| 559 | return is_rescaling; | ||
| 560 | } | ||
| 561 | |||
| 562 | template <class P> | ||
| 542 | bool TextureCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { | 563 | bool TextureCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { |
| 543 | bool is_modified = false; | 564 | bool is_modified = false; |
| 544 | ForEachImageInRegion(addr, size, [&is_modified](ImageId, ImageBase& image) { | 565 | ForEachImageInRegion(addr, size, [&is_modified](ImageId, ImageBase& image) { |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index cdd99242b..1f51fcee8 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -168,6 +168,8 @@ public: | |||
| 168 | /// Return true when a CPU region is modified from the GPU | 168 | /// Return true when a CPU region is modified from the GPU |
| 169 | [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); | 169 | [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); |
| 170 | 170 | ||
| 171 | [[nodiscard]] bool IsRescaling(); | ||
| 172 | |||
| 171 | std::mutex mutex; | 173 | std::mutex mutex; |
| 172 | 174 | ||
| 173 | private: | 175 | private: |
| @@ -362,6 +364,7 @@ private: | |||
| 362 | VAddr virtual_invalid_space{}; | 364 | VAddr virtual_invalid_space{}; |
| 363 | 365 | ||
| 364 | bool has_deleted_images = false; | 366 | bool has_deleted_images = false; |
| 367 | bool is_rescaling = false; | ||
| 365 | u64 total_used_memory = 0; | 368 | u64 total_used_memory = 0; |
| 366 | u64 minimum_memory; | 369 | u64 minimum_memory; |
| 367 | u64 expected_memory; | 370 | u64 expected_memory; |