summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-10-06 07:18:00 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2021-11-16 22:11:30 +0100
commit31478c6c1b841b9a820742830b136775fafe270f (patch)
treee8f5644dd6c570cf8ee08e5e23592983162a8ec4 /src/video_core/renderer_vulkan
parenttexture_cache: Refactor scaled image size calculation (diff)
downloadyuzu-31478c6c1b841b9a820742830b136775fafe270f.tar
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.gz
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.bz2
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.lz
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.xz
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.zst
yuzu-31478c6c1b841b9a820742830b136775fafe270f.zip
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_state_tracker.h10
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp31
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.h7
3 files changed, 29 insertions, 19 deletions
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h
index ac2bbebe0..40a149832 100644
--- a/src/video_core/renderer_vulkan/vk_state_tracker.h
+++ b/src/video_core/renderer_vulkan/vk_state_tracker.h
@@ -71,13 +71,15 @@ public:
}
bool TouchViewports() {
- return Exchange(Dirty::Viewports, false) ||
- Exchange(VideoCommon::Dirty::RescaleViewports, false);
+ const bool dirty_viewports = Exchange(Dirty::Viewports, false);
+ const bool rescale_viewports = Exchange(VideoCommon::Dirty::RescaleViewports, false);
+ return dirty_viewports || rescale_viewports;
}
bool TouchScissors() {
- return Exchange(Dirty::Scissors, false) ||
- Exchange(VideoCommon::Dirty::RescaleScissors, false);
+ const bool dirty_scissors = Exchange(Dirty::Scissors, false);
+ const bool rescale_scissors = Exchange(VideoCommon::Dirty::RescaleScissors, false);
+ return dirty_scissors || rescale_scissors;
}
bool TouchDepthBias() {
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
index 4f0bab274..930c7d569 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -125,8 +125,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
}
}
-[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info,
- u32 up, u32 down) {
+[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info) {
const PixelFormat format = StorageFormat(info.format);
const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format);
VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
@@ -137,9 +136,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
if (info.type == ImageType::e3D) {
flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT;
}
- const auto scale_up = [&](u32 value) { return std::max<u32>((value * up) >> down, 1U); };
const auto [samples_x, samples_y] = VideoCommon::SamplesLog2(info.num_samples);
- const bool is_2d = info.type == ImageType::e2D;
return VkImageCreateInfo{
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = nullptr,
@@ -147,8 +144,8 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
.imageType = ConvertImageType(info.type),
.format = format_info.format,
.extent{
- .width = scale_up(info.size.width) >> samples_x,
- .height = (is_2d ? scale_up(info.size.height) : info.size.height) >> samples_y,
+ .width = info.size.width >> samples_x,
+ .height = info.size.height >> samples_y,
.depth = info.size.depth,
},
.mipLevels = static_cast<u32>(info.resources.levels),
@@ -163,12 +160,11 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
};
}
-[[nodiscard]] vk::Image MakeImage(const Device& device, const ImageInfo& info, u32 up = 1,
- u32 down = 0) {
+[[nodiscard]] vk::Image MakeImage(const Device& device, const ImageInfo& info) {
if (info.type == ImageType::Buffer) {
return vk::Image{};
}
- return device.GetLogical().CreateImage(MakeImageCreateInfo(device, info, up, down));
+ return device.GetLogical().CreateImage(MakeImageCreateInfo(device, info));
}
[[nodiscard]] VkImageAspectFlags ImageAspectMask(PixelFormat format) {
@@ -860,10 +856,9 @@ void TextureCacheRuntime::BlitImage(Framebuffer* dst_framebuffer, ImageView& dst
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, nullptr, nullptr, read_barriers);
if (is_resolve) {
- VkImageResolve resolve_info =
- MakeImageResolve(dst_region, src_region, dst_layers, src_layers);
cmdbuf.ResolveImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image,
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, resolve_info);
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+ MakeImageResolve(dst_region, src_region, dst_layers, src_layers));
} else {
const bool is_linear = filter == Fermi2D::Filter::Bilinear;
const VkFilter vk_filter = is_linear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST;
@@ -1143,7 +1138,17 @@ bool Image::ScaleUp() {
}
const auto& device = runtime->device;
if (!scaled_image) {
- scaled_image = MakeImage(device, info, resolution.up_scale, resolution.down_shift);
+ const u32 up = resolution.up_scale;
+ const u32 down = resolution.down_shift;
+ const auto scale = [&](u32 value) { return std::max<u32>((value * up) >> down, 1U); };
+
+ const bool is_2d = info.type == ImageType::e2D;
+ const u32 scaled_width = scale(info.size.width);
+ const u32 scaled_height = is_2d ? scale(info.size.height) : info.size.height;
+ auto scaled_info = info;
+ scaled_info.size.width = scaled_width;
+ scaled_info.size.height = scaled_height;
+ scaled_image = MakeImage(device, scaled_info);
auto& allocator = runtime->memory_allocator;
scaled_commit = MemoryCommit(allocator.Commit(scaled_image, MemoryUsage::DeviceLocal));
}
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h
index e5060e3f1..5381343e9 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.h
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.h
@@ -6,7 +6,6 @@
#include <span>
-#include "common/settings.h"
#include "shader_recompiler/shader_info.h"
#include "video_core/renderer_vulkan/vk_staging_buffer_pool.h"
#include "video_core/texture_cache/image_view_base.h"
@@ -14,6 +13,10 @@
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"
+namespace Settings {
+struct ResolutionScalingInfo;
+}
+
namespace Vulkan {
using VideoCommon::ImageId;
@@ -86,7 +89,7 @@ public:
BlitImageHelper& blit_image_helper;
ASTCDecoderPass& astc_decoder_pass;
RenderPassCache& render_pass_cache;
- Settings::ResolutionScalingInfo resolution;
+ const Settings::ResolutionScalingInfo& resolution;
};
class Image : public VideoCommon::ImageBase {