summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.h2
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp28
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_blit_screen.cpp6
-rw-r--r--src/video_core/renderer_vulkan/vk_blit_screen.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp6
-rw-r--r--src/video_core/texture_cache/texture_cache.h9
-rw-r--r--src/video_core/texture_cache/texture_cache_base.h4
10 files changed, 40 insertions, 31 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 050a74cca..b42fb110c 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -747,16 +747,20 @@ std::optional<FramebufferTextureInfo> RasterizerOpenGL::AccelerateDisplay(
747 MICROPROFILE_SCOPE(OpenGL_CacheManagement); 747 MICROPROFILE_SCOPE(OpenGL_CacheManagement);
748 748
749 std::scoped_lock lock{texture_cache.mutex}; 749 std::scoped_lock lock{texture_cache.mutex};
750 ImageView* const image_view{ 750 const auto [image_view, scaled] =
751 texture_cache.TryFindFramebufferImageView(config, framebuffer_addr)}; 751 texture_cache.TryFindFramebufferImageView(config, framebuffer_addr);
752 if (!image_view) { 752 if (!image_view) {
753 return {}; 753 return {};
754 } 754 }
755 755
756 const auto& resolution = Settings::values.resolution_info;
757
756 FramebufferTextureInfo info{}; 758 FramebufferTextureInfo info{};
757 info.display_texture = image_view->Handle(Shader::TextureType::Color2D); 759 info.display_texture = image_view->Handle(Shader::TextureType::Color2D);
758 info.width = image_view->size.width; 760 info.width = image_view->size.width;
759 info.height = image_view->size.height; 761 info.height = image_view->size.height;
762 info.scaled_width = scaled ? resolution.ScaleUp(info.width) : info.width;
763 info.scaled_height = scaled ? resolution.ScaleUp(info.height) : info.height;
760 return info; 764 return info;
761} 765}
762 766
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 66a5ca03e..be14494ca 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -1051,6 +1051,10 @@ void Image::Scale(bool up_scale) {
1051 state_tracker.NotifyScissor0(); 1051 state_tracker.NotifyScissor0();
1052} 1052}
1053 1053
1054bool Image::IsRescaled() const {
1055 return True(flags & ImageFlagBits::Rescaled);
1056}
1057
1054bool Image::ScaleUp(bool ignore) { 1058bool Image::ScaleUp(bool ignore) {
1055 const auto& resolution = runtime->resolution; 1059 const auto& resolution = runtime->resolution;
1056 if (!resolution.active) { 1060 if (!resolution.active) {
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h
index 34870c81f..3e54edcc2 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.h
+++ b/src/video_core/renderer_opengl/gl_texture_cache.h
@@ -217,6 +217,8 @@ public:
217 return gl_type; 217 return gl_type;
218 } 218 }
219 219
220 bool IsRescaled() const;
221
220 bool ScaleUp(bool ignore = false); 222 bool ScaleUp(bool ignore = false);
221 223
222 bool ScaleDown(bool ignore = false); 224 bool ScaleDown(bool ignore = false);
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index ea5ed3e2f..2b9ebff92 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -229,6 +229,8 @@ FramebufferTextureInfo RendererOpenGL::LoadFBToScreenInfo(
229 info.display_texture = framebuffer_texture.resource.handle; 229 info.display_texture = framebuffer_texture.resource.handle;
230 info.width = framebuffer.width; 230 info.width = framebuffer.width;
231 info.height = framebuffer.height; 231 info.height = framebuffer.height;
232 info.scaled_width = framebuffer.width;
233 info.scaled_height = framebuffer.height;
232 234
233 // TODO(Rodrigo): Read this from HLE 235 // TODO(Rodrigo): Read this from HLE
234 constexpr u32 block_height_log2 = 4; 236 constexpr u32 block_height_log2 = 4;
@@ -476,25 +478,13 @@ void RendererOpenGL::DrawScreen(const Tegra::FramebufferConfig& framebuffer,
476 478
477 if (anti_aliasing != Settings::AntiAliasing::None) { 479 if (anti_aliasing != Settings::AntiAliasing::None) {
478 glEnablei(GL_SCISSOR_TEST, 0); 480 glEnablei(GL_SCISSOR_TEST, 0);
479 auto viewport_width = info.width; 481 auto scissor_width = Settings::values.resolution_info.ScaleUp(framebuffer_texture.width);
480 auto scissor_width = static_cast<u32>(crop.GetWidth()); 482 auto viewport_width = static_cast<GLfloat>(scissor_width);
481 if (scissor_width <= 0) { 483 auto scissor_height = Settings::values.resolution_info.ScaleUp(framebuffer_texture.height);
482 scissor_width = viewport_width; 484 auto viewport_height = static_cast<GLfloat>(scissor_height);
483 }
484 auto viewport_height = info.height;
485 auto scissor_height = static_cast<u32>(crop.GetHeight());
486 if (scissor_height <= 0) {
487 scissor_height = viewport_height;
488 }
489
490 viewport_width = Settings::values.resolution_info.ScaleUp(viewport_width);
491 scissor_width = Settings::values.resolution_info.ScaleUp(scissor_width);
492 viewport_height = Settings::values.resolution_info.ScaleUp(viewport_height);
493 scissor_height = Settings::values.resolution_info.ScaleUp(scissor_height);
494 485
495 glScissorIndexed(0, 0, 0, scissor_width, scissor_height); 486 glScissorIndexed(0, 0, 0, scissor_width, scissor_height);
496 glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(viewport_width), 487 glViewportIndexedf(0, 0.0f, 0.0f, viewport_width, viewport_height);
497 static_cast<GLfloat>(viewport_height));
498 488
499 glBindSampler(0, present_sampler.handle); 489 glBindSampler(0, present_sampler.handle);
500 GLint old_read_fb; 490 GLint old_read_fb;
@@ -557,10 +547,8 @@ void RendererOpenGL::DrawScreen(const Tegra::FramebufferConfig& framebuffer,
557 fsr->InitBuffers(); 547 fsr->InitBuffers();
558 } 548 }
559 549
560 const auto fsr_input_width = Settings::values.resolution_info.ScaleUp(info.width);
561 const auto fsr_input_height = Settings::values.resolution_info.ScaleUp(info.height);
562 glBindSampler(0, present_sampler.handle); 550 glBindSampler(0, present_sampler.handle);
563 fsr->Draw(program_manager, layout.screen, fsr_input_width, fsr_input_height, crop); 551 fsr->Draw(program_manager, layout.screen, info.scaled_width, info.scaled_height, crop);
564 } else { 552 } else {
565 if (fsr->AreBuffersInitialized()) { 553 if (fsr->AreBuffersInitialized()) {
566 fsr->ReleaseBuffers(); 554 fsr->ReleaseBuffers();
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index cde8c5702..3a83a9b78 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -54,6 +54,8 @@ struct FramebufferTextureInfo {
54 GLuint display_texture{}; 54 GLuint display_texture{};
55 u32 width; 55 u32 width;
56 u32 height; 56 u32 height;
57 u32 scaled_width;
58 u32 scaled_height;
57}; 59};
58 60
59class RendererOpenGL final : public VideoCore::RendererBase { 61class RendererOpenGL final : public VideoCore::RendererBase {
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp
index c21a9c8fe..24781860b 100644
--- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp
+++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp
@@ -152,6 +152,8 @@ void BlitScreen::Draw(RasterizerVulkan& rasterizer, const Tegra::FramebufferConf
152 framebuffer, framebuffer.address + framebuffer.offset, framebuffer.stride); 152 framebuffer, framebuffer.address + framebuffer.offset, framebuffer.stride);
153 const u32 texture_width = texture_info ? texture_info->width : framebuffer.width; 153 const u32 texture_width = texture_info ? texture_info->width : framebuffer.width;
154 const u32 texture_height = texture_info ? texture_info->height : framebuffer.height; 154 const u32 texture_height = texture_info ? texture_info->height : framebuffer.height;
155 const u32 scaled_width = texture_info ? texture_info->scaled_width : texture_width;
156 const u32 scaled_height = texture_info ? texture_info->scaled_height : texture_height;
155 const bool use_accelerated = texture_info.has_value(); 157 const bool use_accelerated = texture_info.has_value();
156 158
157 RefreshResources(framebuffer); 159 RefreshResources(framebuffer);
@@ -363,8 +365,8 @@ void BlitScreen::Draw(RasterizerVulkan& rasterizer, const Tegra::FramebufferConf
363 if (fsr) { 365 if (fsr) {
364 const auto crop_rect = Tegra::NormalizeCrop(framebuffer, texture_width, texture_height); 366 const auto crop_rect = Tegra::NormalizeCrop(framebuffer, texture_width, texture_height);
365 const VkExtent2D fsr_input_size{ 367 const VkExtent2D fsr_input_size{
366 .width = Settings::values.resolution_info.ScaleUp(texture_width), 368 .width = scaled_width,
367 .height = Settings::values.resolution_info.ScaleUp(texture_height), 369 .height = scaled_height,
368 }; 370 };
369 VkImageView fsr_image_view = 371 VkImageView fsr_image_view =
370 fsr->Draw(scheduler, image_index, source_image_view, fsr_input_size, crop_rect); 372 fsr->Draw(scheduler, image_index, source_image_view, fsr_input_size, crop_rect);
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.h b/src/video_core/renderer_vulkan/vk_blit_screen.h
index 40338886a..56ac47f08 100644
--- a/src/video_core/renderer_vulkan/vk_blit_screen.h
+++ b/src/video_core/renderer_vulkan/vk_blit_screen.h
@@ -47,6 +47,8 @@ struct FramebufferTextureInfo {
47 VkImageView image_view{}; 47 VkImageView image_view{};
48 u32 width{}; 48 u32 width{};
49 u32 height{}; 49 u32 height{};
50 u32 scaled_width{};
51 u32 scaled_height{};
50}; 52};
51 53
52class BlitScreen { 54class BlitScreen {
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index e593d7225..aa0a027bb 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -788,18 +788,22 @@ std::optional<FramebufferTextureInfo> RasterizerVulkan::AccelerateDisplay(
788 return {}; 788 return {};
789 } 789 }
790 std::scoped_lock lock{texture_cache.mutex}; 790 std::scoped_lock lock{texture_cache.mutex};
791 ImageView* const image_view = 791 const auto [image_view, scaled] =
792 texture_cache.TryFindFramebufferImageView(config, framebuffer_addr); 792 texture_cache.TryFindFramebufferImageView(config, framebuffer_addr);
793 if (!image_view) { 793 if (!image_view) {
794 return {}; 794 return {};
795 } 795 }
796 query_cache.NotifySegment(false); 796 query_cache.NotifySegment(false);
797 797
798 const auto& resolution = Settings::values.resolution_info;
799
798 FramebufferTextureInfo info{}; 800 FramebufferTextureInfo info{};
799 info.image = image_view->ImageHandle(); 801 info.image = image_view->ImageHandle();
800 info.image_view = image_view->Handle(Shader::TextureType::Color2D); 802 info.image_view = image_view->Handle(Shader::TextureType::Color2D);
801 info.width = image_view->size.width; 803 info.width = image_view->size.width;
802 info.height = image_view->size.height; 804 info.height = image_view->size.height;
805 info.scaled_width = scaled ? resolution.ScaleUp(info.width) : info.width;
806 info.scaled_height = scaled ? resolution.ScaleUp(info.height) : info.height;
803 return info; 807 return info;
804} 808}
805 809
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index a7400adfa..a20c956ff 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -713,12 +713,12 @@ bool TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst,
713} 713}
714 714
715template <class P> 715template <class P>
716typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView( 716std::pair<typename P::ImageView*, bool> TextureCache<P>::TryFindFramebufferImageView(
717 const Tegra::FramebufferConfig& config, DAddr cpu_addr) { 717 const Tegra::FramebufferConfig& config, DAddr cpu_addr) {
718 // TODO: Properly implement this 718 // TODO: Properly implement this
719 const auto it = page_table.find(cpu_addr >> YUZU_PAGEBITS); 719 const auto it = page_table.find(cpu_addr >> YUZU_PAGEBITS);
720 if (it == page_table.end()) { 720 if (it == page_table.end()) {
721 return nullptr; 721 return {};
722 } 722 }
723 const auto& image_map_ids = it->second; 723 const auto& image_map_ids = it->second;
724 boost::container::small_vector<ImageId, 4> valid_image_ids; 724 boost::container::small_vector<ImageId, 4> valid_image_ids;
@@ -747,7 +747,8 @@ typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(
747 747
748 const auto GetImageViewForFramebuffer = [&](ImageId image_id) { 748 const auto GetImageViewForFramebuffer = [&](ImageId image_id) {
749 const ImageViewInfo info{ImageViewType::e2D, view_format}; 749 const ImageViewInfo info{ImageViewType::e2D, view_format};
750 return &slot_image_views[FindOrEmplaceImageView(image_id, info)]; 750 return std::make_pair(&slot_image_views[FindOrEmplaceImageView(image_id, info)],
751 slot_images[image_id].IsRescaled());
751 }; 752 };
752 753
753 if (valid_image_ids.size() == 1) [[likely]] { 754 if (valid_image_ids.size() == 1) [[likely]] {
@@ -761,7 +762,7 @@ typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(
761 return GetImageViewForFramebuffer(*most_recent); 762 return GetImageViewForFramebuffer(*most_recent);
762 } 763 }
763 764
764 return nullptr; 765 return {};
765} 766}
766 767
767template <class P> 768template <class P>
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h
index f9aebb293..e7b910121 100644
--- a/src/video_core/texture_cache/texture_cache_base.h
+++ b/src/video_core/texture_cache/texture_cache_base.h
@@ -212,8 +212,8 @@ public:
212 const Tegra::Engines::Fermi2D::Config& copy); 212 const Tegra::Engines::Fermi2D::Config& copy);
213 213
214 /// Try to find a cached image view in the given CPU address 214 /// Try to find a cached image view in the given CPU address
215 [[nodiscard]] ImageView* TryFindFramebufferImageView(const Tegra::FramebufferConfig& config, 215 [[nodiscard]] std::pair<ImageView*, bool> TryFindFramebufferImageView(
216 DAddr cpu_addr); 216 const Tegra::FramebufferConfig& config, DAddr cpu_addr);
217 217
218 /// Return true when there are uncommitted images to be downloaded 218 /// Return true when there are uncommitted images to be downloaded
219 [[nodiscard]] bool HasUncommittedFlushes() const noexcept; 219 [[nodiscard]] bool HasUncommittedFlushes() const noexcept;