diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.cpp b/src/video_core/renderer_vulkan/vk_compute_pass.cpp index dded1301b2..fc03ea01f6 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pass.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pass.cpp @@ -1307,102 +1307,6 @@ void BlockLinearUnswizzle3DPass::UnswizzleChunk( }); } -MSAACopyPass::MSAACopyPass(const Device& device_, Scheduler& scheduler_, - DescriptorPool& descriptor_pool_, - StagingBufferPool& staging_buffer_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue_) - : ComputePass(device_, scheduler_, descriptor_pool_, MSAA_DESCRIPTOR_SET_BINDINGS, - MSAA_DESCRIPTOR_UPDATE_TEMPLATE, MSAA_BANK_INFO, {}, - CONVERT_NON_MSAA_TO_MSAA_COMP_SPV), - scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_}, - compute_pass_descriptor_queue{compute_pass_descriptor_queue_} { - const auto make_msaa_pipeline = [this](size_t i, std::span code) { - modules[i] = device.GetLogical().CreateShaderModule({ - .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .codeSize = static_cast(code.size_bytes()), - .pCode = code.data(), - }); - pipelines[i] = device.GetLogical().CreateComputePipeline(VkComputePipelineCreateInfo{ - .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .stage{ - .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .stage = VK_SHADER_STAGE_COMPUTE_BIT, - .module = *modules[i], - .pName = "main", - .pSpecializationInfo = nullptr, - }, - .layout = *layout, - .basePipelineHandle = {}, - .basePipelineIndex = 0, - }); - }; - make_msaa_pipeline(0, CONVERT_NON_MSAA_TO_MSAA_COMP_SPV); - make_msaa_pipeline(1, CONVERT_MSAA_TO_NON_MSAA_COMP_SPV); -} - -MSAACopyPass::~MSAACopyPass() = default; - -void MSAACopyPass::CopyImage(Image& dst_image, Image& src_image, - std::span copies, - bool msaa_to_non_msaa) { - const VkPipeline msaa_pipeline = *pipelines[msaa_to_non_msaa ? 1 : 0]; - scheduler.RequestOutsideRenderPassOperationContext(); - for (const VideoCommon::ImageCopy& copy : copies) { - ASSERT(copy.src_subresource.base_layer == 0); - ASSERT(copy.src_subresource.num_layers == 1); - ASSERT(copy.dst_subresource.base_layer == 0); - ASSERT(copy.dst_subresource.num_layers == 1); - - compute_pass_descriptor_queue.Acquire(scheduler, 2); - compute_pass_descriptor_queue.AddImage( - src_image.StorageImageView(copy.src_subresource.base_level)); - compute_pass_descriptor_queue.AddImage( - dst_image.StorageImageView(copy.dst_subresource.base_level)); - const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()}; - - const Common::Vec3 num_dispatches = { - Common::DivCeil(copy.extent.width, 8U), - Common::DivCeil(copy.extent.height, 8U), - copy.extent.depth, - }; - - scheduler.Record([this, dst = dst_image.Handle(), msaa_pipeline, num_dispatches, - descriptor_data](vk::CommandBuffer cmdbuf) { - const VkDescriptorSet set = descriptor_allocator.Commit(); - device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data); - cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, msaa_pipeline); - cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {}); - cmdbuf.Dispatch(num_dispatches.x, num_dispatches.y, num_dispatches.z); - const VkImageMemoryBarrier write_barrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_SHADER_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst, - .subresourceRange{ - .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, - }; - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, - VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, write_barrier); - }); - } -} - // I feel there was a better way to do this like a image.Clear or something but I couldn't find anything or am blind. // So enjoy this mess void BlockLinearUnswizzle3DPass::UnswizzleZeroChunk( @@ -1735,100 +1639,4 @@ void BlockLinearUnswizzle2DPass::Unswizzle( //scheduler.Finish(); } -MSAACopyPass::MSAACopyPass(const Device& device_, Scheduler& scheduler_, - DescriptorPool& descriptor_pool_, - StagingBufferPool& staging_buffer_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue_) - : ComputePass(device_, scheduler_, descriptor_pool_, MSAA_DESCRIPTOR_SET_BINDINGS, - MSAA_DESCRIPTOR_UPDATE_TEMPLATE, MSAA_BANK_INFO, {}, - CONVERT_NON_MSAA_TO_MSAA_COMP_SPV), - scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_}, - compute_pass_descriptor_queue{compute_pass_descriptor_queue_} { - const auto make_msaa_pipeline = [this](size_t i, std::span code) { - modules[i] = device.GetLogical().CreateShaderModule({ - .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .codeSize = static_cast(code.size_bytes()), - .pCode = code.data(), - }); - pipelines[i] = device.GetLogical().CreateComputePipeline(VkComputePipelineCreateInfo{ - .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .stage{ - .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, - .pNext = nullptr, - .flags = 0, - .stage = VK_SHADER_STAGE_COMPUTE_BIT, - .module = *modules[i], - .pName = "main", - .pSpecializationInfo = nullptr, - }, - .layout = *layout, - .basePipelineHandle = {}, - .basePipelineIndex = 0, - }); - }; - make_msaa_pipeline(0, CONVERT_NON_MSAA_TO_MSAA_COMP_SPV); - make_msaa_pipeline(1, CONVERT_MSAA_TO_NON_MSAA_COMP_SPV); -} - -MSAACopyPass::~MSAACopyPass() = default; - -void MSAACopyPass::CopyImage(Image& dst_image, Image& src_image, - std::span copies, - bool msaa_to_non_msaa) { - const VkPipeline msaa_pipeline = *pipelines[msaa_to_non_msaa ? 1 : 0]; - scheduler.RequestOutsideRenderPassOperationContext(); - for (const VideoCommon::ImageCopy& copy : copies) { - ASSERT(copy.src_subresource.base_layer == 0); - ASSERT(copy.src_subresource.num_layers == 1); - ASSERT(copy.dst_subresource.base_layer == 0); - ASSERT(copy.dst_subresource.num_layers == 1); - - compute_pass_descriptor_queue.Acquire(scheduler, 2); - compute_pass_descriptor_queue.AddImage( - src_image.StorageImageView(copy.src_subresource.base_level)); - compute_pass_descriptor_queue.AddImage( - dst_image.StorageImageView(copy.dst_subresource.base_level)); - const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()}; - - const Common::Vec3 num_dispatches = { - Common::DivCeil(copy.extent.width, 8U), - Common::DivCeil(copy.extent.height, 8U), - copy.extent.depth, - }; - - scheduler.Record([this, dst = dst_image.Handle(), msaa_pipeline, num_dispatches, - descriptor_data](vk::CommandBuffer cmdbuf) { - const VkDescriptorSet set = descriptor_allocator.Commit(); - device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data); - cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, msaa_pipeline); - cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {}); - cmdbuf.Dispatch(num_dispatches.x, num_dispatches.y, num_dispatches.z); - const VkImageMemoryBarrier write_barrier{ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = nullptr, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, - .dstAccessMask = VK_ACCESS_SHADER_READ_BIT, - .oldLayout = VK_IMAGE_LAYOUT_GENERAL, - .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = dst, - .subresourceRange{ - .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }, - }; - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, - VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, write_barrier); - }); - } -} - } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.h b/src/video_core/renderer_vulkan/vk_compute_pass.h index e7f344b467..33a74b584f 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pass.h +++ b/src/video_core/renderer_vulkan/vk_compute_pass.h @@ -173,25 +173,6 @@ private: ComputePassDescriptorQueue& compute_pass_descriptor_queue; }; - -class MSAACopyPass final : public ComputePass { -public: - explicit MSAACopyPass(const Device& device_, Scheduler& scheduler_, - DescriptorPool& descriptor_pool_, StagingBufferPool& staging_buffer_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue_); - ~MSAACopyPass(); - - void CopyImage(Image& dst_image, Image& src_image, - std::span copies, bool msaa_to_non_msaa); - -private: - Scheduler& scheduler; - StagingBufferPool& staging_buffer_pool; - ComputePassDescriptorQueue& compute_pass_descriptor_queue; - std::array modules; - std::array pipelines; -}; - class BlockLinearUnswizzle2DPass final : public ComputePass { public: explicit BlockLinearUnswizzle2DPass(const Device& device_, Scheduler& scheduler_, @@ -261,22 +242,4 @@ private: ComputePassDescriptorQueue& compute_pass_descriptor_queue; }; -class MSAACopyPass final : public ComputePass { -public: - explicit MSAACopyPass(const Device& device_, Scheduler& scheduler_, - DescriptorPool& descriptor_pool_, StagingBufferPool& staging_buffer_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue_); - ~MSAACopyPass(); - - void CopyImage(Image& dst_image, Image& src_image, - std::span copies, bool msaa_to_non_msaa); - -private: - Scheduler& scheduler; - StagingBufferPool& staging_buffer_pool; - ComputePassDescriptorQueue& compute_pass_descriptor_queue; - std::array modules; - std::array pipelines; -}; - } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index fd9c9cc45a..a2a14f3674 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1900,22 +1900,8 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu VAddr cpu_addr_) : VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime_.scheduler}, runtime{&runtime_}, - original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info, - WillUseWidenedAstcFormat(runtime_.device, info) - ? std::span{} - : runtime->ViewFormats(info.format), - WillUseWidenedAstcFormat(runtime_.device, info) - ? std::make_optional(VK_FORMAT_R32G32B32A32_SFLOAT) - : std::nullopt)), - WillUseWidenedAstcFormat(runtime_.device, info) - ? std::span{} - : std::span(BuildViewFormats( - info, runtime->ViewFormats(info.format))), - WillUseWidenedAstcFormat(runtime_.device, info) - ? std::make_optional(VK_FORMAT_R32G32B32A32_SFLOAT) - : std::nullopt)), - runtime->ViewFormats(info.format))), - aspect_mask(ImageAspectMask(info.format)) { + original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info, std::span(BuildViewFormats(info, runtime->ViewFormats(info.format))))), + aspect_mask(ImageAspectMask(info.format)) { if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) { switch (Settings::values.accelerate_astc.GetValue()) { case Settings::AstcDecodeMode::Gpu: @@ -2342,12 +2328,8 @@ VkImageView Image::StorageImageView(s32 level) noexcept { auto format_info = MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format); if (WillUseAcceleratedAstcDecode(runtime->device, info)) { - format_info.format = WillUseWidenedAstcFormat(runtime->device, info) - ? VK_FORMAT_R32G32B32A32_SFLOAT - : VK_FORMAT_A8B8G8R8_UNORM_PACK32; - format_info.format = WillUseWidenedAstcFormat(runtime->device, info) - ? VK_FORMAT_R32G32B32A32_SFLOAT - : VK_FORMAT_A8B8G8R8_UNORM_PACK32; + format_info.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32; + format_info.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32; } else if (const auto block_view_format = BlockTexelViewFormat(info.format)) { format_info.format = *block_view_format; format_info.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32; diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index a6112c5130..a95ca76729 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -161,12 +161,10 @@ public: std::optional astc_decoder_pass; std::optional bl3d_unswizzle_pass; - std::optional msaa_copy_pass; std::optional bl2d_unswizzle_pass; std::optional generic_2d_unswizzle_pass; std::optional generic_3d_unswizzle_pass; std::optional generic_linear_unswizzle_pass; - std::optional msaa_copy_pass; const Settings::ResolutionScalingInfo& resolution; std::array, VideoCore::Surface::MaxPixelFormat> view_formats; diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index ccc39a2f74..1d00811dd1 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -563,16 +563,15 @@ private: u64 frame_tick = 0; u64 last_sampler_gc_frame = (std::numeric_limits::max)(); - Common::ThreadWorker texture_decode_worker{1, "TextureDecoder"}; // I kinda don't want ASTC CPU async to flood your threads but eh, lets FAFO static u32 ComputeTextureDecodeWorkerCount() { const u32 hw = std::thread::hardware_concurrency(); return (std::max)(1u, hw > 2 ? hw - 1 : hw); } const u32 texture_decode_worker_count = ComputeTextureDecodeWorkerCount(); - Common::ThreadWorker texture_decode_worker{texture_decode_worker_count, "TextureDecoder"}; - Common::ThreadWorker texture_decode_worker{1, "TextureDecoder", {}, - Common::ThreadPlacement::Efficiency}; + Common::ThreadWorker texture_decode_worker{ + texture_decode_worker_count, "TextureDecoder", {},Common::ThreadPlacement::Efficiency + }; std::vector> async_decodes; std::deque unswizzle_queue;