summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-07-28 02:47:06 -0300
committerGravatar Fernando Sahmkow2021-11-16 22:11:28 +0100
commit56ccda1d9952368d0c1e29d7c4b486c547de9549 (patch)
treeb2064ced92ef5ee0f4a67169df10462414664db9 /src/video_core/renderer_vulkan
parentVulkan: Fix downscaling Blit. (diff)
downloadyuzu-56ccda1d9952368d0c1e29d7c4b486c547de9549.tar.gz
yuzu-56ccda1d9952368d0c1e29d7c4b486c547de9549.tar.xz
yuzu-56ccda1d9952368d0c1e29d7c4b486c547de9549.zip
texture_cache: Simplify image view queries and blacklisting
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/pipeline_helper.h19
-rw-r--r--src/video_core/renderer_vulkan/vk_compute_pipeline.cpp60
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp54
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp22
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.h41
5 files changed, 82 insertions, 114 deletions
diff --git a/src/video_core/renderer_vulkan/pipeline_helper.h b/src/video_core/renderer_vulkan/pipeline_helper.h
index 7ba6078df..bf18b34d1 100644
--- a/src/video_core/renderer_vulkan/pipeline_helper.h
+++ b/src/video_core/renderer_vulkan/pipeline_helper.h
@@ -156,28 +156,27 @@ private:
156 u32 texture_bit{1u}; 156 u32 texture_bit{1u};
157}; 157};
158 158
159inline void PushImageDescriptors(const Shader::Info& info, const VkSampler*& samplers, 159inline void PushImageDescriptors(TextureCache& texture_cache,
160 const ImageId*& image_view_ids, TextureCache& texture_cache,
161 VKUpdateDescriptorQueue& update_descriptor_queue, 160 VKUpdateDescriptorQueue& update_descriptor_queue,
162 RescalingPushConstant& rescaling) { 161 const Shader::Info& info, RescalingPushConstant& rescaling,
163 static constexpr VideoCommon::ImageViewId NULL_IMAGE_VIEW_ID{0}; 162 const VkSampler*& samplers,
164 image_view_ids += Shader::NumDescriptors(info.texture_buffer_descriptors); 163 const VideoCommon::ImageViewInOut*& views) {
165 image_view_ids += Shader::NumDescriptors(info.image_buffer_descriptors); 164 views += Shader::NumDescriptors(info.texture_buffer_descriptors);
165 views += Shader::NumDescriptors(info.image_buffer_descriptors);
166 for (const auto& desc : info.texture_descriptors) { 166 for (const auto& desc : info.texture_descriptors) {
167 for (u32 index = 0; index < desc.count; ++index) { 167 for (u32 index = 0; index < desc.count; ++index) {
168 const VideoCommon::ImageViewId image_view_id{*(image_view_ids++)}; 168 const VideoCommon::ImageViewId image_view_id{(views++)->id};
169 const VkSampler sampler{*(samplers++)}; 169 const VkSampler sampler{*(samplers++)};
170 ImageView& image_view{texture_cache.GetImageView(image_view_id)}; 170 ImageView& image_view{texture_cache.GetImageView(image_view_id)};
171 const Image& image{texture_cache.GetImage(image_view.image_id)}; 171 const Image& image{texture_cache.GetImage(image_view.image_id)};
172 const VkImageView vk_image_view{image_view.Handle(desc.type)}; 172 const VkImageView vk_image_view{image_view.Handle(desc.type)};
173 update_descriptor_queue.AddSampledImage(vk_image_view, sampler); 173 update_descriptor_queue.AddSampledImage(vk_image_view, sampler);
174 rescaling.PushTexture(image_view_id != NULL_IMAGE_VIEW_ID && 174 rescaling.PushTexture(True(image.flags & VideoCommon::ImageFlagBits::Rescaled));
175 True(image.flags & VideoCommon::ImageFlagBits::Rescaled));
176 } 175 }
177 } 176 }
178 for (const auto& desc : info.image_descriptors) { 177 for (const auto& desc : info.image_descriptors) {
179 for (u32 index = 0; index < desc.count; ++index) { 178 for (u32 index = 0; index < desc.count; ++index) {
180 ImageView& image_view{texture_cache.GetImageView(*(image_view_ids++))}; 179 ImageView& image_view{texture_cache.GetImageView((views++)->id)};
181 if (desc.is_written) { 180 if (desc.is_written) {
182 texture_cache.MarkModification(image_view.image_id); 181 texture_cache.MarkModification(image_view.image_id);
183 } 182 }
diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
index 5c591e345..f89b84c6e 100644
--- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
@@ -108,10 +108,8 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
108 texture_cache.SynchronizeComputeDescriptors(); 108 texture_cache.SynchronizeComputeDescriptors();
109 109
110 static constexpr size_t max_elements = 64; 110 static constexpr size_t max_elements = 64;
111 std::array<ImageId, max_elements> image_view_ids; 111 boost::container::static_vector<VideoCommon::ImageViewInOut, max_elements> views;
112 boost::container::static_vector<u32, max_elements> image_view_indices;
113 boost::container::static_vector<VkSampler, max_elements> samplers; 112 boost::container::static_vector<VkSampler, max_elements> samplers;
114 boost::container::static_vector<bool, max_elements> image_view_blacklist;
115 113
116 const auto& qmd{kepler_compute.launch_description}; 114 const auto& qmd{kepler_compute.launch_description};
117 const auto& cbufs{qmd.const_buffer_config}; 115 const auto& cbufs{qmd.const_buffer_config};
@@ -135,54 +133,37 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
135 } 133 }
136 return TexturePair(gpu_memory.Read<u32>(addr), via_header_index); 134 return TexturePair(gpu_memory.Read<u32>(addr), via_header_index);
137 }}; 135 }};
138 const auto add_image{[&](const auto& desc) { 136 const auto add_image{[&](const auto& desc, bool blacklist) {
139 for (u32 index = 0; index < desc.count; ++index) { 137 for (u32 index = 0; index < desc.count; ++index) {
140 const auto handle{read_handle(desc, index)}; 138 const auto handle{read_handle(desc, index)};
141 image_view_indices.push_back(handle.first); 139 views.push_back({
140 .index = handle.first,
141 .blacklist = blacklist,
142 .id = {},
143 });
142 } 144 }
143 }}; 145 }};
144 std::ranges::for_each(info.texture_buffer_descriptors, add_image); 146 for (const auto& desc : info.texture_buffer_descriptors) {
145 std::ranges::for_each(info.image_buffer_descriptors, add_image); 147 add_image(desc, false);
148 }
149 for (const auto& desc : info.image_buffer_descriptors) {
150 add_image(desc, false);
151 }
146 for (const auto& desc : info.texture_descriptors) { 152 for (const auto& desc : info.texture_descriptors) {
147 for (u32 index = 0; index < desc.count; ++index) { 153 for (u32 index = 0; index < desc.count; ++index) {
148 const auto handle{read_handle(desc, index)}; 154 const auto handle{read_handle(desc, index)};
149 image_view_indices.push_back(handle.first); 155 views.push_back({handle.first});
150 156
151 Sampler* const sampler = texture_cache.GetComputeSampler(handle.second); 157 Sampler* const sampler = texture_cache.GetComputeSampler(handle.second);
152 samplers.push_back(sampler->Handle()); 158 samplers.push_back(sampler->Handle());
153 } 159 }
154 } 160 }
155 const u32 black_list_base = image_view_indices.size();
156 bool atleast_one_blacklisted = false;
157 for (const auto& desc : info.image_descriptors) { 161 for (const auto& desc : info.image_descriptors) {
158 const bool is_black_listed = 162 add_image(desc, true);
159 desc.is_written && (desc.type == Shader::TextureType::Color2D ||
160 desc.type == Shader::TextureType::ColorArray2D);
161 for (u32 index = 0; index < desc.count; ++index) {
162 image_view_blacklist.push_back(is_black_listed);
163 }
164 atleast_one_blacklisted |= is_black_listed;
165 add_image(desc);
166 } 163 }
167 164 texture_cache.FillComputeImageViews(std::span(views.data(), views.size()));
168 const std::span indices_span(image_view_indices.data(), image_view_indices.size());
169 bool has_listed_stuffs;
170 do {
171 has_listed_stuffs = false;
172 texture_cache.FillComputeImageViews(indices_span, image_view_ids);
173 if (atleast_one_blacklisted) {
174 for (u32 index = 0; index < image_view_blacklist.size(); index++) {
175 if (image_view_blacklist[index]) {
176 ImageView& image_view{
177 texture_cache.GetImageView(image_view_ids[index + black_list_base])};
178 has_listed_stuffs |= texture_cache.BlackListImage(image_view.image_id);
179 }
180 }
181 }
182 } while (has_listed_stuffs);
183 165
184 buffer_cache.UnbindComputeTextureBuffers(); 166 buffer_cache.UnbindComputeTextureBuffers();
185 ImageId* texture_buffer_ids{image_view_ids.data()};
186 size_t index{}; 167 size_t index{};
187 const auto add_buffer{[&](const auto& desc) { 168 const auto add_buffer{[&](const auto& desc) {
188 constexpr bool is_image = std::is_same_v<decltype(desc), const ImageBufferDescriptor&>; 169 constexpr bool is_image = std::is_same_v<decltype(desc), const ImageBufferDescriptor&>;
@@ -191,11 +172,10 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
191 if constexpr (is_image) { 172 if constexpr (is_image) {
192 is_written = desc.is_written; 173 is_written = desc.is_written;
193 } 174 }
194 ImageView& image_view = texture_cache.GetImageView(*texture_buffer_ids); 175 ImageView& image_view = texture_cache.GetImageView(views[index].id);
195 buffer_cache.BindComputeTextureBuffer(index, image_view.GpuAddr(), 176 buffer_cache.BindComputeTextureBuffer(index, image_view.GpuAddr(),
196 image_view.BufferSize(), image_view.format, 177 image_view.BufferSize(), image_view.format,
197 is_written, is_image); 178 is_written, is_image);
198 ++texture_buffer_ids;
199 ++index; 179 ++index;
200 } 180 }
201 }}; 181 }};
@@ -207,9 +187,9 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
207 187
208 RescalingPushConstant rescaling(num_textures); 188 RescalingPushConstant rescaling(num_textures);
209 const VkSampler* samplers_it{samplers.data()}; 189 const VkSampler* samplers_it{samplers.data()};
210 const ImageId* views_it{image_view_ids.data()}; 190 const VideoCommon::ImageViewInOut* views_it{views.data()};
211 PushImageDescriptors(info, samplers_it, views_it, texture_cache, update_descriptor_queue, 191 PushImageDescriptors(texture_cache, update_descriptor_queue, info, rescaling, samplers_it,
212 rescaling); 192 views_it);
213 193
214 if (!is_built.load(std::memory_order::relaxed)) { 194 if (!is_built.load(std::memory_order::relaxed)) {
215 // Wait for the pipeline to be built 195 // Wait for the pipeline to be built
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
index 4d966ee4b..4efb5d735 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
@@ -278,12 +278,10 @@ void GraphicsPipeline::AddTransition(GraphicsPipeline* transition) {
278 278
279template <typename Spec> 279template <typename Spec>
280void GraphicsPipeline::ConfigureImpl(bool is_indexed) { 280void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
281 std::array<ImageId, MAX_IMAGE_ELEMENTS> image_view_ids; 281 std::array<VideoCommon::ImageViewInOut, MAX_IMAGE_ELEMENTS> views;
282 std::array<u32, MAX_IMAGE_ELEMENTS> image_view_indices;
283 std::array<bool, MAX_IMAGE_ELEMENTS> image_view_blacklist;
284 std::array<VkSampler, MAX_IMAGE_ELEMENTS> samplers; 282 std::array<VkSampler, MAX_IMAGE_ELEMENTS> samplers;
285 size_t sampler_index{}; 283 size_t sampler_index{};
286 size_t image_index{}; 284 size_t view_index{};
287 285
288 texture_cache.SynchronizeGraphicsDescriptors(); 286 texture_cache.SynchronizeGraphicsDescriptors();
289 287
@@ -291,8 +289,6 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
291 289
292 const auto& regs{maxwell3d.regs}; 290 const auto& regs{maxwell3d.regs};
293 const bool via_header_index{regs.sampler_index == Maxwell::SamplerIndex::ViaHeaderIndex}; 291 const bool via_header_index{regs.sampler_index == Maxwell::SamplerIndex::ViaHeaderIndex};
294 u32 start_black_list = std::numeric_limits<u32>::max();
295 u32 end_black_list = 0;
296 const auto config_stage{[&](size_t stage) LAMBDA_FORCEINLINE { 292 const auto config_stage{[&](size_t stage) LAMBDA_FORCEINLINE {
297 const Shader::Info& info{stage_infos[stage]}; 293 const Shader::Info& info{stage_infos[stage]};
298 buffer_cache.UnbindGraphicsStorageBuffers(stage); 294 buffer_cache.UnbindGraphicsStorageBuffers(stage);
@@ -329,7 +325,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
329 const auto add_image{[&](const auto& desc) { 325 const auto add_image{[&](const auto& desc) {
330 for (u32 index = 0; index < desc.count; ++index) { 326 for (u32 index = 0; index < desc.count; ++index) {
331 const auto handle{read_handle(desc, index)}; 327 const auto handle{read_handle(desc, index)};
332 image_view_indices[image_index++] = handle.first; 328 views[view_index++] = {handle.first};
333 } 329 }
334 }}; 330 }};
335 if constexpr (Spec::has_texture_buffers) { 331 if constexpr (Spec::has_texture_buffers) {
@@ -345,7 +341,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
345 for (const auto& desc : info.texture_descriptors) { 341 for (const auto& desc : info.texture_descriptors) {
346 for (u32 index = 0; index < desc.count; ++index) { 342 for (u32 index = 0; index < desc.count; ++index) {
347 const auto handle{read_handle(desc, index)}; 343 const auto handle{read_handle(desc, index)};
348 image_view_indices[image_index++] = handle.first; 344 views[view_index++] = {handle.first};
349 345
350 Sampler* const sampler{texture_cache.GetGraphicsSampler(handle.second)}; 346 Sampler* const sampler{texture_cache.GetGraphicsSampler(handle.second)};
351 samplers[sampler_index++] = sampler->Handle(); 347 samplers[sampler_index++] = sampler->Handle();
@@ -353,15 +349,6 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
353 } 349 }
354 if constexpr (Spec::has_images) { 350 if constexpr (Spec::has_images) {
355 for (const auto& desc : info.image_descriptors) { 351 for (const auto& desc : info.image_descriptors) {
356 if (desc.is_written && (desc.type == Shader::TextureType::Color2D ||
357 desc.type == Shader::TextureType::ColorArray2D)) {
358 auto index_copy = image_index;
359 for (u32 index = 0; index < desc.count; ++index) {
360 start_black_list = std::min<u32>(start_black_list, index_copy);
361 image_view_blacklist[index_copy++] = true;
362 end_black_list = std::max<u32>(end_black_list, index_copy);
363 }
364 }
365 add_image(desc); 352 add_image(desc);
366 } 353 }
367 } 354 }
@@ -381,24 +368,9 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
381 if constexpr (Spec::enabled_stages[4]) { 368 if constexpr (Spec::enabled_stages[4]) {
382 config_stage(4); 369 config_stage(4);
383 } 370 }
384 const std::span indices_span(image_view_indices.data(), image_index); 371 texture_cache.FillGraphicsImageViews<Spec::has_images>(std::span(views.data(), view_index));
385 bool has_listed_stuffs;
386 do {
387 has_listed_stuffs = false;
388 texture_cache.FillGraphicsImageViews(indices_span, image_view_ids);
389 if constexpr (Spec::has_images) {
390 if (start_black_list < end_black_list) {
391 for (u32 index = start_black_list; index < end_black_list; index++) {
392 if (image_view_blacklist[index]) {
393 ImageView& image_view{texture_cache.GetImageView(image_view_ids[index])};
394 has_listed_stuffs |= texture_cache.BlackListImage(image_view.image_id);
395 }
396 }
397 }
398 }
399 } while (has_listed_stuffs);
400 372
401 ImageId* texture_buffer_index{image_view_ids.data()}; 373 VideoCommon::ImageViewInOut* texture_buffer_it{views.data()};
402 const auto bind_stage_info{[&](size_t stage) LAMBDA_FORCEINLINE { 374 const auto bind_stage_info{[&](size_t stage) LAMBDA_FORCEINLINE {
403 size_t index{}; 375 size_t index{};
404 const auto add_buffer{[&](const auto& desc) { 376 const auto add_buffer{[&](const auto& desc) {
@@ -408,12 +380,12 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
408 if constexpr (is_image) { 380 if constexpr (is_image) {
409 is_written = desc.is_written; 381 is_written = desc.is_written;
410 } 382 }
411 ImageView& image_view{texture_cache.GetImageView(*texture_buffer_index)}; 383 ImageView& image_view{texture_cache.GetImageView(texture_buffer_it->id)};
412 buffer_cache.BindGraphicsTextureBuffer(stage, index, image_view.GpuAddr(), 384 buffer_cache.BindGraphicsTextureBuffer(stage, index, image_view.GpuAddr(),
413 image_view.BufferSize(), image_view.format, 385 image_view.BufferSize(), image_view.format,
414 is_written, is_image); 386 is_written, is_image);
415 ++index; 387 ++index;
416 ++texture_buffer_index; 388 ++texture_buffer_it;
417 } 389 }
418 }}; 390 }};
419 buffer_cache.UnbindGraphicsTextureBuffers(stage); 391 buffer_cache.UnbindGraphicsTextureBuffers(stage);
@@ -429,9 +401,9 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
429 add_buffer(desc); 401 add_buffer(desc);
430 } 402 }
431 } 403 }
432 texture_buffer_index += Shader::NumDescriptors(info.texture_descriptors); 404 texture_buffer_it += Shader::NumDescriptors(info.texture_descriptors);
433 if constexpr (Spec::has_images) { 405 if constexpr (Spec::has_images) {
434 texture_buffer_index += Shader::NumDescriptors(info.image_descriptors); 406 texture_buffer_it += Shader::NumDescriptors(info.image_descriptors);
435 } 407 }
436 }}; 408 }};
437 if constexpr (Spec::enabled_stages[0]) { 409 if constexpr (Spec::enabled_stages[0]) {
@@ -457,11 +429,11 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
457 429
458 RescalingPushConstant rescaling(num_textures); 430 RescalingPushConstant rescaling(num_textures);
459 const VkSampler* samplers_it{samplers.data()}; 431 const VkSampler* samplers_it{samplers.data()};
460 const ImageId* views_it{image_view_ids.data()}; 432 const VideoCommon::ImageViewInOut* views_it{views.data()};
461 const auto prepare_stage{[&](size_t stage) LAMBDA_FORCEINLINE { 433 const auto prepare_stage{[&](size_t stage) LAMBDA_FORCEINLINE {
462 buffer_cache.BindHostStageBuffers(stage); 434 buffer_cache.BindHostStageBuffers(stage);
463 PushImageDescriptors(stage_infos[stage], samplers_it, views_it, texture_cache, 435 PushImageDescriptors(texture_cache, update_descriptor_queue, stage_infos[stage], rescaling,
464 update_descriptor_queue, rescaling); 436 samplers_it, views_it);
465 }}; 437 }};
466 if constexpr (Spec::enabled_stages[0]) { 438 if constexpr (Spec::enabled_stages[0]) {
467 prepare_stage(0); 439 prepare_stage(0);
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
index b21992fce..3400066a6 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -730,10 +730,17 @@ void BlitScale(VKScheduler& scheduler, VkImage src_image, VkImage dst_image, con
730} 730}
731} // Anonymous namespace 731} // Anonymous namespace
732 732
733void TextureCacheRuntime::Init() { 733TextureCacheRuntime::TextureCacheRuntime(const Device& device_, VKScheduler& scheduler_,
734 resolution = Settings::values.resolution_info; 734 MemoryAllocator& memory_allocator_,
735 is_rescaling_on = resolution.up_scale != 1 || resolution.down_shift != 0; 735 StagingBufferPool& staging_buffer_pool_,
736} 736 BlitImageHelper& blit_image_helper_,
737 ASTCDecoderPass& astc_decoder_pass_,
738 RenderPassCache& render_pass_cache_)
739 : device{device_}, scheduler{scheduler_}, memory_allocator{memory_allocator_},
740 staging_buffer_pool{staging_buffer_pool_}, blit_image_helper{blit_image_helper_},
741 astc_decoder_pass{astc_decoder_pass_}, render_pass_cache{render_pass_cache_},
742 resolution{Settings::values.resolution_info},
743 is_rescaling_on(resolution.up_scale != 1 || resolution.down_shift != 0) {}
737 744
738void TextureCacheRuntime::Finish() { 745void TextureCacheRuntime::Finish() {
739 scheduler.Finish(); 746 scheduler.Finish();
@@ -1040,6 +1047,8 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
1040 } 1047 }
1041} 1048}
1042 1049
1050Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBase{params} {}
1051
1043Image::~Image() = default; 1052Image::~Image() = default;
1044 1053
1045void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { 1054void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) {
@@ -1187,8 +1196,7 @@ bool Image::ScaleDown(bool save_as_backup) {
1187 }*/ 1196 }*/
1188 1197
1189 const auto& resolution = runtime->resolution; 1198 const auto& resolution = runtime->resolution;
1190 vk::Image downscaled_image = 1199 vk::Image downscaled_image = MakeImage(runtime->device, info);
1191 MakeImage(runtime->device, info);
1192 MemoryCommit new_commit( 1200 MemoryCommit new_commit(
1193 runtime->memory_allocator.Commit(downscaled_image, MemoryUsage::DeviceLocal)); 1201 runtime->memory_allocator.Commit(downscaled_image, MemoryUsage::DeviceLocal));
1194 1202
@@ -1301,7 +1309,7 @@ ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo& info,
1301 : VideoCommon::ImageViewBase{info, view_info}, gpu_addr{gpu_addr_}, 1309 : VideoCommon::ImageViewBase{info, view_info}, gpu_addr{gpu_addr_},
1302 buffer_size{VideoCommon::CalculateGuestSizeInBytes(info)} {} 1310 buffer_size{VideoCommon::CalculateGuestSizeInBytes(info)} {}
1303 1311
1304ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::NullImageParams& params) 1312ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::NullImageViewParams& params)
1305 : VideoCommon::ImageViewBase{params} {} 1313 : VideoCommon::ImageViewBase{params} {}
1306 1314
1307VkImageView ImageView::DepthView() { 1315VkImageView ImageView::DepthView() {
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h
index 958a64651..9c39a6d99 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.h
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.h
@@ -34,21 +34,16 @@ class RenderPassCache;
34class StagingBufferPool; 34class StagingBufferPool;
35class VKScheduler; 35class VKScheduler;
36 36
37struct TextureCacheRuntime { 37class TextureCacheRuntime {
38 const Device& device; 38public:
39 VKScheduler& scheduler;
40 MemoryAllocator& memory_allocator;
41 StagingBufferPool& staging_buffer_pool;
42 BlitImageHelper& blit_image_helper;
43 ASTCDecoderPass& astc_decoder_pass;
44 RenderPassCache& render_pass_cache;
45 static constexpr size_t TICKS_TO_DESTROY = 6; 39 static constexpr size_t TICKS_TO_DESTROY = 6;
46 DelayedDestructionRing<vk::Image, TICKS_TO_DESTROY> prescaled_images;
47 DelayedDestructionRing<MemoryCommit, TICKS_TO_DESTROY> prescaled_commits;
48 Settings::ResolutionScalingInfo resolution;
49 bool is_rescaling_on{};
50 40
51 void Init(); 41 explicit TextureCacheRuntime(const Device& device_, VKScheduler& scheduler_,
42 MemoryAllocator& memory_allocator_,
43 StagingBufferPool& staging_buffer_pool_,
44 BlitImageHelper& blit_image_helper_,
45 ASTCDecoderPass& astc_decoder_pass_,
46 RenderPassCache& render_pass_cache_);
52 47
53 void Finish(); 48 void Finish();
54 49
@@ -56,6 +51,10 @@ struct TextureCacheRuntime {
56 51
57 StagingBufferRef DownloadStagingBuffer(size_t size); 52 StagingBufferRef DownloadStagingBuffer(size_t size);
58 53
54 void TickFrame();
55
56 u64 GetDeviceLocalMemory() const;
57
59 void BlitImage(Framebuffer* dst_framebuffer, ImageView& dst, ImageView& src, 58 void BlitImage(Framebuffer* dst_framebuffer, ImageView& dst, ImageView& src,
60 const Region2D& dst_region, const Region2D& src_region, 59 const Region2D& dst_region, const Region2D& src_region,
61 Tegra::Engines::Fermi2D::Filter filter, 60 Tegra::Engines::Fermi2D::Filter filter,
@@ -84,15 +83,25 @@ struct TextureCacheRuntime {
84 return true; 83 return true;
85 } 84 }
86 85
87 void TickFrame(); 86 const Device& device;
87 VKScheduler& scheduler;
88 MemoryAllocator& memory_allocator;
89 StagingBufferPool& staging_buffer_pool;
90 BlitImageHelper& blit_image_helper;
91 ASTCDecoderPass& astc_decoder_pass;
92 RenderPassCache& render_pass_cache;
88 93
89 u64 GetDeviceLocalMemory() const; 94 DelayedDestructionRing<vk::Image, TICKS_TO_DESTROY> prescaled_images;
95 DelayedDestructionRing<MemoryCommit, TICKS_TO_DESTROY> prescaled_commits;
96 Settings::ResolutionScalingInfo resolution;
97 bool is_rescaling_on{};
90}; 98};
91 99
92class Image : public VideoCommon::ImageBase { 100class Image : public VideoCommon::ImageBase {
93public: 101public:
94 explicit Image(TextureCacheRuntime&, const VideoCommon::ImageInfo& info, GPUVAddr gpu_addr, 102 explicit Image(TextureCacheRuntime&, const VideoCommon::ImageInfo& info, GPUVAddr gpu_addr,
95 VAddr cpu_addr); 103 VAddr cpu_addr);
104 explicit Image(const VideoCommon::NullImageParams&);
96 105
97 ~Image(); 106 ~Image();
98 107
@@ -151,7 +160,7 @@ public:
151 explicit ImageView(TextureCacheRuntime&, const VideoCommon::ImageViewInfo&, ImageId, Image&); 160 explicit ImageView(TextureCacheRuntime&, const VideoCommon::ImageViewInfo&, ImageId, Image&);
152 explicit ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo&, 161 explicit ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo&,
153 const VideoCommon::ImageViewInfo&, GPUVAddr); 162 const VideoCommon::ImageViewInfo&, GPUVAddr);
154 explicit ImageView(TextureCacheRuntime&, const VideoCommon::NullImageParams&); 163 explicit ImageView(TextureCacheRuntime&, const VideoCommon::NullImageViewParams&);
155 164
156 [[nodiscard]] VkImageView DepthView(); 165 [[nodiscard]] VkImageView DepthView();
157 166