aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan/present/layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/renderer_vulkan/present/layer.cpp')
-rw-r--r--src/video_core/renderer_vulkan/present/layer.cpp71
1 files changed, 35 insertions, 36 deletions
diff --git a/src/video_core/renderer_vulkan/present/layer.cpp b/src/video_core/renderer_vulkan/present/layer.cpp
index e20473d2af..14935f92bb 100644
--- a/src/video_core/renderer_vulkan/present/layer.cpp
+++ b/src/video_core/renderer_vulkan/present/layer.cpp
@@ -56,13 +56,15 @@ VkFormat GetFormat(const Tegra::FramebufferConfig& framebuffer) {
} // Anonymous namespace
-Layer::Layer(const Device& device_, MemoryAllocator& memory_allocator_, Scheduler& scheduler_,
- Tegra::MaxwellDeviceMemoryManager& device_memory_, size_t image_count_,
- VkExtent2D output_size, VkDescriptorSetLayout layout, const PresentFilters& filters_)
- : device(device_), memory_allocator(memory_allocator_), scheduler(scheduler_),
- device_memory(device_memory_), filters(filters_), image_count(image_count_) {
- CreateDescriptorPool();
- CreateDescriptorSets(layout);
+Layer::Layer(const Device& device, MemoryAllocator& memory_allocator_, Scheduler& scheduler_, Tegra::MaxwellDeviceMemoryManager& device_memory_, size_t image_count_, VkExtent2D output_size, VkDescriptorSetLayout layout, const PresentFilters& filters_)
+ : memory_allocator(memory_allocator_)
+ , scheduler(scheduler_)
+ , device_memory(device_memory_)
+ , filters(filters_)
+ , image_count(image_count_)
+{
+ CreateDescriptorPool(device);
+ CreateDescriptorSets(device, layout);
if (filters.get_scaling_filter() == Settings::ScalingFilter::Fsr) {
sr_filter.emplace<FSR>(device, memory_allocator, image_count, output_size);
} else if (filters.get_scaling_filter() == Settings::ScalingFilter::Sgsr) {
@@ -76,7 +78,7 @@ Layer::~Layer() {
ReleaseRawImages();
}
-void Layer::ConfigureDraw(PresentPushConstants* out_push_constants,
+void Layer::ConfigureDraw(const Device& device, PresentPushConstants* out_push_constants,
VkDescriptorSet* out_descriptor_set, RasterizerVulkan& rasterizer,
VkSampler sampler, size_t image_index,
const Tegra::FramebufferConfig& framebuffer,
@@ -89,8 +91,8 @@ void Layer::ConfigureDraw(PresentPushConstants* out_push_constants,
const u32 scaled_height = texture_info ? texture_info->scaled_height : texture_height;
const bool use_accelerated = texture_info.has_value();
- RefreshResources(framebuffer);
- SetAntiAliasPass();
+ RefreshResources(device, framebuffer);
+ SetAntiAliasPass(device);
// Finish any pending renderpass
scheduler.RequestOutsideRenderPassOperationContext();
@@ -108,9 +110,9 @@ void Layer::ConfigureDraw(PresentPushConstants* out_push_constants,
texture_info ? texture_info->image_view : *raw_image_views[image_index];
if (auto* fxaa = std::get_if<FXAA>(&anti_alias)) {
- fxaa->Draw(scheduler, image_index, &source_image, &source_image_view);
+ fxaa->Draw(device, scheduler, image_index, &source_image, &source_image_view);
} else if (auto* smaa = std::get_if<SMAA>(&anti_alias)) {
- smaa->Draw(scheduler, image_index, &source_image, &source_image_view);
+ smaa->Draw(device, scheduler, image_index, &source_image, &source_image_view);
}
auto crop_rect = Tegra::NormalizeCrop(framebuffer, texture_width, texture_height);
@@ -120,30 +122,30 @@ void Layer::ConfigureDraw(PresentPushConstants* out_push_constants,
};
if (auto* fsr = std::get_if<FSR>(&sr_filter)) {
- source_image_view = fsr->Draw(scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
+ source_image_view = fsr->Draw(device, scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
crop_rect = {0, 0, 1, 1};
} else if (auto* sgsr = std::get_if<SGSR>(&sr_filter)) {
- source_image_view = sgsr->Draw(scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
+ source_image_view = sgsr->Draw(device, scheduler, image_index, source_image, source_image_view, render_extent, crop_rect);
crop_rect = {0, 0, 1, 1};
}
- SetMatrixData(*out_push_constants, layout);
- SetVertexData(*out_push_constants, layout, crop_rect);
+ SetMatrixData(device, *out_push_constants, layout);
+ SetVertexData(device, *out_push_constants, layout, crop_rect);
- UpdateDescriptorSet(source_image_view, sampler, image_index);
+ UpdateDescriptorSet(device, source_image_view, sampler, image_index);
*out_descriptor_set = descriptor_sets[image_index];
}
-void Layer::CreateDescriptorPool() {
+void Layer::CreateDescriptorPool(const Device& device) {
descriptor_pool = CreateWrappedDescriptorPool(device, image_count, image_count);
}
-void Layer::CreateDescriptorSets(VkDescriptorSetLayout layout) {
+void Layer::CreateDescriptorSets(const Device& device, VkDescriptorSetLayout layout) {
const std::vector layouts(image_count, layout);
descriptor_sets = CreateWrappedDescriptorSets(descriptor_pool, layouts);
}
-void Layer::CreateStagingBuffer(const Tegra::FramebufferConfig& framebuffer) {
+void Layer::CreateStagingBuffer(const Device& device, const Tegra::FramebufferConfig& framebuffer) {
const VkBufferCreateInfo ci{
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
@@ -159,7 +161,7 @@ void Layer::CreateStagingBuffer(const Tegra::FramebufferConfig& framebuffer) {
buffer = memory_allocator.CreateBuffer(ci, MemoryUsage::Upload);
}
-void Layer::CreateRawImages(const Tegra::FramebufferConfig& framebuffer) {
+void Layer::CreateRawImages(const Device& device, const Tegra::FramebufferConfig& framebuffer) {
const auto format = GetFormat(framebuffer);
resource_ticks.resize(image_count);
raw_images.resize(image_count);
@@ -172,7 +174,7 @@ void Layer::CreateRawImages(const Tegra::FramebufferConfig& framebuffer) {
}
}
-void Layer::RefreshResources(const Tegra::FramebufferConfig& framebuffer) {
+void Layer::RefreshResources(const Device& device, const Tegra::FramebufferConfig& framebuffer) {
if (framebuffer.width == raw_width && framebuffer.height == raw_height &&
framebuffer.pixel_format == pixel_format && !raw_images.empty()) {
return;
@@ -184,11 +186,11 @@ void Layer::RefreshResources(const Tegra::FramebufferConfig& framebuffer) {
anti_alias.emplace<std::monostate>();
ReleaseRawImages();
- CreateStagingBuffer(framebuffer);
- CreateRawImages(framebuffer);
+ CreateStagingBuffer(device, framebuffer);
+ CreateRawImages(device, framebuffer);
}
-void Layer::SetAntiAliasPass() {
+void Layer::SetAntiAliasPass(const Device& device) {
if (!std::holds_alternative<std::monostate>(anti_alias) && anti_alias_setting == filters.get_anti_aliasing())
return;
@@ -229,20 +231,17 @@ u64 Layer::GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer,
return GetSizeInBytes(framebuffer) * image_index;
}
-void Layer::SetMatrixData(PresentPushConstants& data,
- const Layout::FramebufferLayout& layout) const {
- data.modelview_matrix =
- MakeOrthographicMatrix(static_cast<f32>(layout.width), static_cast<f32>(layout.height));
+void Layer::SetMatrixData(const Device& device, PresentPushConstants& data, const Layout::FramebufferLayout& layout) const {
+ data.modelview_matrix = MakeOrthographicMatrix(f32(layout.width), static_cast<f32>(layout.height));
}
-void Layer::SetVertexData(PresentPushConstants& data, const Layout::FramebufferLayout& layout,
- const Common::Rectangle<f32>& crop) const {
+void Layer::SetVertexData(const Device& device, PresentPushConstants& data, const Layout::FramebufferLayout& layout, const Common::Rectangle<f32>& crop) const {
// Map the coordinates to the screen.
const auto& screen = layout.screen;
- const auto x = static_cast<f32>(screen.left);
- const auto y = static_cast<f32>(screen.top);
- const auto w = static_cast<f32>(screen.GetWidth());
- const auto h = static_cast<f32>(screen.GetHeight());
+ const auto x = f32(screen.left);
+ const auto y = f32(screen.top);
+ const auto w = f32(screen.GetWidth());
+ const auto h = f32(screen.GetHeight());
data.vertices[0] = ScreenRectVertex(x, y, crop.left, crop.top);
data.vertices[1] = ScreenRectVertex(x + w, y, crop.right, crop.top);
@@ -250,7 +249,7 @@ void Layer::SetVertexData(PresentPushConstants& data, const Layout::FramebufferL
data.vertices[3] = ScreenRectVertex(x + w, y + h, crop.right, crop.bottom);
}
-void Layer::UpdateDescriptorSet(VkImageView image_view, VkSampler sampler, size_t image_index) {
+void Layer::UpdateDescriptorSet(const Device& device, VkImageView image_view, VkSampler sampler, size_t image_index) {
const VkDescriptorImageInfo image_info{
.sampler = sampler,
.imageView = image_view,