diff options
Diffstat (limited to 'src/video_core')
23 files changed, 114 insertions, 124 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 6624919a4..98756e4da 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -96,12 +96,12 @@ void BufferCache<P>::TickFrame() { template <class P> void BufferCache<P>::WriteMemory(VAddr cpu_addr, u64 size) { - memory_tracker.MarkRegionAsCpuModified(cpu_addr, size); if (memory_tracker.IsRegionGpuModified(cpu_addr, size)) { const IntervalType subtract_interval{cpu_addr, cpu_addr + size}; ClearDownload(subtract_interval); common_ranges.subtract(subtract_interval); } + memory_tracker.MarkRegionAsCpuModified(cpu_addr, size); } template <class P> @@ -122,41 +122,24 @@ std::optional<VideoCore::RasterizerDownloadArea> BufferCache<P>::GetFlushArea(VA area->preemtive = true; return area; }; + area->preemtive = + !IsRegionGpuModified(cpu_addr_start_aligned, cpu_addr_end_aligned - cpu_addr_start_aligned); memory_tracker.MarkRegionAsPreflushable(cpu_addr_start_aligned, cpu_addr_end_aligned - cpu_addr_start_aligned); - area->preemtive = !IsRegionGpuModified(cpu_addr, size); return area; } template <class P> void BufferCache<P>::DownloadMemory(VAddr cpu_addr, u64 size) { - WaitOnAsyncFlushes(cpu_addr, size); ForEachBufferInRange(cpu_addr, size, [&](BufferId, Buffer& buffer) { DownloadBufferMemory(buffer, cpu_addr, size); }); } template <class P> -void BufferCache<P>::WaitOnAsyncFlushes(VAddr cpu_addr, u64 size) { - bool must_wait = false; - ForEachInOverlapCounter(async_downloads, cpu_addr, size, - [&](VAddr, VAddr, int) { must_wait = true; }); - bool must_release = false; - ForEachInRangeSet(pending_ranges, cpu_addr, size, [&](VAddr, VAddr) { must_release = true; }); - if (must_release) { - std::function<void()> tmp([]() {}); - rasterizer.SignalFence(std::move(tmp)); - } - if (must_wait || must_release) { - rasterizer.ReleaseFences(); - } -} - -template <class P> void BufferCache<P>::ClearDownload(IntervalType subtract_interval) { RemoveEachInOverlapCounter(async_downloads, subtract_interval, -1024); uncommitted_ranges.subtract(subtract_interval); - pending_ranges.subtract(subtract_interval); for (auto& interval_set : committed_ranges) { interval_set.subtract(subtract_interval); } @@ -176,7 +159,6 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am } const IntervalType subtract_interval{*cpu_dest_address, *cpu_dest_address + amount}; - WaitOnAsyncFlushes(*cpu_src_address, static_cast<u32>(amount)); ClearDownload(subtract_interval); BufferId buffer_a; @@ -204,7 +186,6 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am const IntervalType add_interval{new_base_address, new_base_address + size}; tmp_intervals.push_back(add_interval); uncommitted_ranges.add(add_interval); - pending_ranges.add(add_interval); }; ForEachInRangeSet(common_ranges, *cpu_src_address, amount, mirror); // This subtraction in this order is important for overlapping copies. @@ -491,7 +472,6 @@ void BufferCache<P>::CommitAsyncFlushesHigh() { } MICROPROFILE_SCOPE(GPU_DownloadMemory); - pending_ranges.clear(); auto it = committed_ranges.begin(); while (it != committed_ranges.end()) { auto& current_intervals = *it; @@ -1223,16 +1203,14 @@ void BufferCache<P>::UpdateComputeTextureBuffers() { template <class P> void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, VAddr cpu_addr, u32 size) { - memory_tracker.MarkRegionAsGpuModified(cpu_addr, size); - if (memory_tracker.IsRegionCpuModified(cpu_addr, size)) { SynchronizeBuffer(slot_buffers[buffer_id], cpu_addr, size); } + memory_tracker.MarkRegionAsGpuModified(cpu_addr, size); const IntervalType base_interval{cpu_addr, cpu_addr + size}; common_ranges.add(base_interval); uncommitted_ranges.add(base_interval); - pending_ranges.add(base_interval); } template <class P> @@ -1677,14 +1655,15 @@ typename BufferCache<P>::Binding BufferCache<P>::StorageBufferBinding(GPUVAddr s const bool is_nvn_cbuf = cbuf_index == 0; // The NVN driver buffer (index 0) is known to pack the SSBO address followed by its size. if (is_nvn_cbuf) { - return gpu_memory->Read<u32>(ssbo_addr + 8); + const u32 ssbo_size = gpu_memory->Read<u32>(ssbo_addr + 8); + if (ssbo_size != 0) { + return ssbo_size; + } } // Other titles (notably Doom Eternal) may use STG/LDG on buffer addresses in custom defined // cbufs, which do not store the sizes adjacent to the addresses, so use the fully // mapped buffer size for now. const u32 memory_layout_size = static_cast<u32>(gpu_memory->GetMemoryLayoutSize(gpu_addr)); - LOG_INFO(HW_GPU, "Binding storage buffer for cbuf index {}, MemoryLayoutSize 0x{:X}", - cbuf_index, memory_layout_size); return memory_layout_size; }(); const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); diff --git a/src/video_core/buffer_cache/buffer_cache_base.h b/src/video_core/buffer_cache/buffer_cache_base.h index 0445ec47f..ac00d4d9d 100644 --- a/src/video_core/buffer_cache/buffer_cache_base.h +++ b/src/video_core/buffer_cache/buffer_cache_base.h @@ -381,8 +381,6 @@ private: void RunGarbageCollector(); - void WaitOnAsyncFlushes(VAddr cpu_addr, u64 size); - void BindHostIndexBuffer(); void BindHostVertexBuffers(); @@ -547,7 +545,6 @@ private: IntervalSet uncommitted_ranges; IntervalSet common_ranges; IntervalSet cached_ranges; - IntervalSet pending_ranges; std::deque<IntervalSet> committed_ranges; // Async Buffers diff --git a/src/video_core/engines/sw_blitter/blitter.cpp b/src/video_core/engines/sw_blitter/blitter.cpp index 3c9f38559..ff88cd03d 100644 --- a/src/video_core/engines/sw_blitter/blitter.cpp +++ b/src/video_core/engines/sw_blitter/blitter.cpp @@ -5,6 +5,7 @@ #include <cmath> #include <vector> +#include "common/scratch_buffer.h" #include "video_core/engines/sw_blitter/blitter.h" #include "video_core/engines/sw_blitter/converter.h" #include "video_core/memory_manager.h" @@ -112,11 +113,11 @@ void Bilinear(std::span<const f32> input, std::span<f32> output, size_t src_widt } // namespace struct SoftwareBlitEngine::BlitEngineImpl { - std::vector<u8> tmp_buffer; - std::vector<u8> src_buffer; - std::vector<u8> dst_buffer; - std::vector<f32> intermediate_src; - std::vector<f32> intermediate_dst; + Common::ScratchBuffer<u8> tmp_buffer; + Common::ScratchBuffer<u8> src_buffer; + Common::ScratchBuffer<u8> dst_buffer; + Common::ScratchBuffer<f32> intermediate_src; + Common::ScratchBuffer<f32> intermediate_dst; ConverterFactory converter_factory; }; @@ -158,14 +159,14 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst, const auto src_bytes_per_pixel = BytesPerBlock(PixelFormatFromRenderTargetFormat(src.format)); const auto dst_bytes_per_pixel = BytesPerBlock(PixelFormatFromRenderTargetFormat(dst.format)); const size_t src_size = get_surface_size(src, src_bytes_per_pixel); - impl->tmp_buffer.resize(src_size); + impl->tmp_buffer.resize_destructive(src_size); memory_manager.ReadBlock(src.Address(), impl->tmp_buffer.data(), src_size); const size_t src_copy_size = src_extent_x * src_extent_y * src_bytes_per_pixel; const size_t dst_copy_size = dst_extent_x * dst_extent_y * dst_bytes_per_pixel; - impl->src_buffer.resize(src_copy_size); + impl->src_buffer.resize_destructive(src_copy_size); const bool no_passthrough = src.format != dst.format || src_extent_x != dst_extent_x || src_extent_y != dst_extent_y; @@ -177,8 +178,10 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst, const auto convertion_phase_ir = [&]() { auto* input_converter = impl->converter_factory.GetFormatConverter(src.format); - impl->intermediate_src.resize((src_copy_size / src_bytes_per_pixel) * ir_components); - impl->intermediate_dst.resize((dst_copy_size / dst_bytes_per_pixel) * ir_components); + impl->intermediate_src.resize_destructive((src_copy_size / src_bytes_per_pixel) * + ir_components); + impl->intermediate_dst.resize_destructive((dst_copy_size / dst_bytes_per_pixel) * + ir_components); input_converter->ConvertTo(impl->src_buffer, impl->intermediate_src); if (config.filter != Fermi2D::Filter::Bilinear) { @@ -195,7 +198,7 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst, // Do actual Blit - impl->dst_buffer.resize(dst_copy_size); + impl->dst_buffer.resize_destructive(dst_copy_size); if (src.linear == Fermi2D::MemoryLayout::BlockLinear) { UnswizzleSubrect(impl->src_buffer, impl->tmp_buffer, src_bytes_per_pixel, src.width, src.height, src.depth, config.src_x0, config.src_y0, src_extent_x, @@ -218,7 +221,7 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst, } const size_t dst_size = get_surface_size(dst, dst_bytes_per_pixel); - impl->tmp_buffer.resize(dst_size); + impl->tmp_buffer.resize_destructive(dst_size); memory_manager.ReadBlock(dst.Address(), impl->tmp_buffer.data(), dst_size); if (dst.linear == Fermi2D::MemoryLayout::BlockLinear) { diff --git a/src/video_core/host1x/codecs/h264.cpp b/src/video_core/host1x/codecs/h264.cpp index e87bd65fa..6ce179167 100644 --- a/src/video_core/host1x/codecs/h264.cpp +++ b/src/video_core/host1x/codecs/h264.cpp @@ -111,7 +111,7 @@ const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegist writer.WriteUe(0); writer.WriteBit(context.h264_parameter_set.entropy_coding_mode_flag != 0); - writer.WriteBit(false); + writer.WriteBit(context.h264_parameter_set.pic_order_present_flag != 0); writer.WriteUe(0); writer.WriteUe(context.h264_parameter_set.num_refidx_l0_default_active); writer.WriteUe(context.h264_parameter_set.num_refidx_l1_default_active); @@ -129,7 +129,7 @@ const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegist writer.WriteBit(context.h264_parameter_set.redundant_pic_cnt_present_flag != 0); writer.WriteBit(context.h264_parameter_set.transform_8x8_mode_flag != 0); - writer.WriteBit(true); + writer.WriteBit(true); // pic_scaling_matrix_present_flag for (s32 index = 0; index < 6; index++) { writer.WriteBit(true); diff --git a/src/video_core/renderer_vulkan/pipeline_helper.h b/src/video_core/renderer_vulkan/pipeline_helper.h index 28b893e25..983e1c2e1 100644 --- a/src/video_core/renderer_vulkan/pipeline_helper.h +++ b/src/video_core/renderer_vulkan/pipeline_helper.h @@ -176,7 +176,7 @@ public: }; inline void PushImageDescriptors(TextureCache& texture_cache, - UpdateDescriptorQueue& update_descriptor_queue, + GuestDescriptorQueue& guest_descriptor_queue, const Shader::Info& info, RescalingPushConstant& rescaling, const VkSampler*& samplers, const VideoCommon::ImageViewInOut*& views) { @@ -190,7 +190,7 @@ inline void PushImageDescriptors(TextureCache& texture_cache, const VkSampler sampler{*(samplers++)}; ImageView& image_view{texture_cache.GetImageView(image_view_id)}; const VkImageView vk_image_view{image_view.Handle(desc.type)}; - update_descriptor_queue.AddSampledImage(vk_image_view, sampler); + guest_descriptor_queue.AddSampledImage(vk_image_view, sampler); rescaling.PushTexture(texture_cache.IsRescaling(image_view)); } } @@ -201,7 +201,7 @@ inline void PushImageDescriptors(TextureCache& texture_cache, texture_cache.MarkModification(image_view.image_id); } const VkImageView vk_image_view{image_view.StorageView(desc.type, desc.format)}; - update_descriptor_queue.AddImage(vk_image_view); + guest_descriptor_queue.AddImage(vk_image_view); rescaling.PushImage(texture_cache.IsRescaling(image_view)); } } diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 510602e8e..9627eb129 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp @@ -298,12 +298,14 @@ private: BufferCacheRuntime::BufferCacheRuntime(const Device& device_, MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, - UpdateDescriptorQueue& update_descriptor_queue_, + GuestDescriptorQueue& guest_descriptor_queue_, + ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool) : device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, - staging_pool{staging_pool_}, update_descriptor_queue{update_descriptor_queue_}, - uint8_pass(device, scheduler, descriptor_pool, staging_pool, update_descriptor_queue), - quad_index_pass(device, scheduler, descriptor_pool, staging_pool, update_descriptor_queue) { + staging_pool{staging_pool_}, guest_descriptor_queue{guest_descriptor_queue_}, + uint8_pass(device, scheduler, descriptor_pool, staging_pool, compute_pass_descriptor_queue), + quad_index_pass(device, scheduler, descriptor_pool, staging_pool, + compute_pass_descriptor_queue) { quad_array_index_buffer = std::make_shared<QuadArrayIndexBuffer>(device_, memory_allocator_, scheduler_, staging_pool_); quad_strip_index_buffer = std::make_shared<QuadStripIndexBuffer>(device_, memory_allocator_, diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h index 879f1ed94..5e9602905 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.h +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h @@ -63,7 +63,8 @@ class BufferCacheRuntime { public: explicit BufferCacheRuntime(const Device& device_, MemoryAllocator& memory_manager_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, - UpdateDescriptorQueue& update_descriptor_queue_, + GuestDescriptorQueue& guest_descriptor_queue, + ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool); void Finish(); @@ -116,12 +117,12 @@ public: void BindTextureBuffer(Buffer& buffer, u32 offset, u32 size, VideoCore::Surface::PixelFormat format) { - update_descriptor_queue.AddTexelBuffer(buffer.View(offset, size, format)); + guest_descriptor_queue.AddTexelBuffer(buffer.View(offset, size, format)); } private: void BindBuffer(VkBuffer buffer, u32 offset, u32 size) { - update_descriptor_queue.AddBuffer(buffer, offset, size); + guest_descriptor_queue.AddBuffer(buffer, offset, size); } void ReserveNullBuffer(); @@ -130,7 +131,7 @@ private: MemoryAllocator& memory_allocator; Scheduler& scheduler; StagingBufferPool& staging_pool; - UpdateDescriptorQueue& update_descriptor_queue; + GuestDescriptorQueue& guest_descriptor_queue; std::shared_ptr<QuadArrayIndexBuffer> quad_array_index_buffer; std::shared_ptr<QuadStripIndexBuffer> quad_strip_index_buffer; diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.cpp b/src/video_core/renderer_vulkan/vk_compute_pass.cpp index 1a316b6eb..3bc8553e1 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pass.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pass.cpp @@ -200,12 +200,12 @@ ComputePass::~ComputePass() = default; Uint8Pass::Uint8Pass(const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool, StagingBufferPool& staging_buffer_pool_, - UpdateDescriptorQueue& update_descriptor_queue_) + ComputePassDescriptorQueue& compute_pass_descriptor_queue_) : ComputePass(device_, descriptor_pool, INPUT_OUTPUT_DESCRIPTOR_SET_BINDINGS, INPUT_OUTPUT_DESCRIPTOR_UPDATE_TEMPLATE, INPUT_OUTPUT_BANK_INFO, {}, VULKAN_UINT8_COMP_SPV), scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_}, - update_descriptor_queue{update_descriptor_queue_} {} + compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {} Uint8Pass::~Uint8Pass() = default; @@ -214,10 +214,10 @@ std::pair<VkBuffer, VkDeviceSize> Uint8Pass::Assemble(u32 num_vertices, VkBuffer const u32 staging_size = static_cast<u32>(num_vertices * sizeof(u16)); const auto staging = staging_buffer_pool.Request(staging_size, MemoryUsage::DeviceLocal); - update_descriptor_queue.Acquire(); - update_descriptor_queue.AddBuffer(src_buffer, src_offset, num_vertices); - update_descriptor_queue.AddBuffer(staging.buffer, staging.offset, staging_size); - const void* const descriptor_data{update_descriptor_queue.UpdateData()}; + compute_pass_descriptor_queue.Acquire(); + compute_pass_descriptor_queue.AddBuffer(src_buffer, src_offset, num_vertices); + compute_pass_descriptor_queue.AddBuffer(staging.buffer, staging.offset, staging_size); + const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()}; scheduler.RequestOutsideRenderPassOperationContext(); scheduler.Record([this, descriptor_data, num_vertices](vk::CommandBuffer cmdbuf) { @@ -242,12 +242,12 @@ std::pair<VkBuffer, VkDeviceSize> Uint8Pass::Assemble(u32 num_vertices, VkBuffer QuadIndexedPass::QuadIndexedPass(const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_, StagingBufferPool& staging_buffer_pool_, - UpdateDescriptorQueue& update_descriptor_queue_) + ComputePassDescriptorQueue& compute_pass_descriptor_queue_) : ComputePass(device_, descriptor_pool_, INPUT_OUTPUT_DESCRIPTOR_SET_BINDINGS, INPUT_OUTPUT_DESCRIPTOR_UPDATE_TEMPLATE, INPUT_OUTPUT_BANK_INFO, COMPUTE_PUSH_CONSTANT_RANGE<sizeof(u32) * 3>, VULKAN_QUAD_INDEXED_COMP_SPV), scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_}, - update_descriptor_queue{update_descriptor_queue_} {} + compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {} QuadIndexedPass::~QuadIndexedPass() = default; @@ -272,10 +272,10 @@ std::pair<VkBuffer, VkDeviceSize> QuadIndexedPass::Assemble( const std::size_t staging_size = num_tri_vertices * sizeof(u32); const auto staging = staging_buffer_pool.Request(staging_size, MemoryUsage::DeviceLocal); - update_descriptor_queue.Acquire(); - update_descriptor_queue.AddBuffer(src_buffer, src_offset, input_size); - update_descriptor_queue.AddBuffer(staging.buffer, staging.offset, staging_size); - const void* const descriptor_data{update_descriptor_queue.UpdateData()}; + compute_pass_descriptor_queue.Acquire(); + compute_pass_descriptor_queue.AddBuffer(src_buffer, src_offset, input_size); + compute_pass_descriptor_queue.AddBuffer(staging.buffer, staging.offset, staging_size); + const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()}; scheduler.RequestOutsideRenderPassOperationContext(); scheduler.Record([this, descriptor_data, num_tri_vertices, base_vertex, index_shift, @@ -304,13 +304,14 @@ std::pair<VkBuffer, VkDeviceSize> QuadIndexedPass::Assemble( ASTCDecoderPass::ASTCDecoderPass(const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_, StagingBufferPool& staging_buffer_pool_, - UpdateDescriptorQueue& update_descriptor_queue_, + ComputePassDescriptorQueue& compute_pass_descriptor_queue_, MemoryAllocator& memory_allocator_) : ComputePass(device_, descriptor_pool_, ASTC_DESCRIPTOR_SET_BINDINGS, ASTC_PASS_DESCRIPTOR_UPDATE_TEMPLATE_ENTRY, ASTC_BANK_INFO, COMPUTE_PUSH_CONSTANT_RANGE<sizeof(AstcPushConstants)>, ASTC_DECODER_COMP_SPV), scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_}, - update_descriptor_queue{update_descriptor_queue_}, memory_allocator{memory_allocator_} {} + compute_pass_descriptor_queue{compute_pass_descriptor_queue_}, memory_allocator{ + memory_allocator_} {} ASTCDecoderPass::~ASTCDecoderPass() = default; @@ -358,11 +359,11 @@ void ASTCDecoderPass::Assemble(Image& image, const StagingBufferRef& map, const u32 num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 8U); const u32 num_dispatches_z = image.info.resources.layers; - update_descriptor_queue.Acquire(); - update_descriptor_queue.AddBuffer(map.buffer, input_offset, - image.guest_size_bytes - swizzle.buffer_offset); - update_descriptor_queue.AddImage(image.StorageImageView(swizzle.level)); - const void* const descriptor_data{update_descriptor_queue.UpdateData()}; + compute_pass_descriptor_queue.Acquire(); + compute_pass_descriptor_queue.AddBuffer(map.buffer, input_offset, + image.guest_size_bytes - swizzle.buffer_offset); + compute_pass_descriptor_queue.AddImage(image.StorageImageView(swizzle.level)); + const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()}; // To unswizzle the ASTC data const auto params = MakeBlockLinearSwizzle2DParams(swizzle, image.info); diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.h b/src/video_core/renderer_vulkan/vk_compute_pass.h index c4c8fa081..dd3927376 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pass.h +++ b/src/video_core/renderer_vulkan/vk_compute_pass.h @@ -9,6 +9,7 @@ #include "common/common_types.h" #include "video_core/engines/maxwell_3d.h" #include "video_core/renderer_vulkan/vk_descriptor_pool.h" +#include "video_core/renderer_vulkan/vk_update_descriptor.h" #include "video_core/vulkan_common/vulkan_memory_allocator.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -21,7 +22,6 @@ namespace Vulkan { class Device; class StagingBufferPool; class Scheduler; -class UpdateDescriptorQueue; class Image; struct StagingBufferRef; @@ -50,7 +50,7 @@ class Uint8Pass final : public ComputePass { public: explicit Uint8Pass(const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_, StagingBufferPool& staging_buffer_pool_, - UpdateDescriptorQueue& update_descriptor_queue_); + ComputePassDescriptorQueue& compute_pass_descriptor_queue_); ~Uint8Pass(); /// Assemble uint8 indices into an uint16 index buffer @@ -61,7 +61,7 @@ public: private: Scheduler& scheduler; StagingBufferPool& staging_buffer_pool; - UpdateDescriptorQueue& update_descriptor_queue; + ComputePassDescriptorQueue& compute_pass_descriptor_queue; }; class QuadIndexedPass final : public ComputePass { @@ -69,7 +69,7 @@ public: explicit QuadIndexedPass(const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_, StagingBufferPool& staging_buffer_pool_, - UpdateDescriptorQueue& update_descriptor_queue_); + ComputePassDescriptorQueue& compute_pass_descriptor_queue_); ~QuadIndexedPass(); std::pair<VkBuffer, VkDeviceSize> Assemble( @@ -79,7 +79,7 @@ public: private: Scheduler& scheduler; StagingBufferPool& staging_buffer_pool; - UpdateDescriptorQueue& update_descriptor_queue; + ComputePassDescriptorQueue& compute_pass_descriptor_queue; }; class ASTCDecoderPass final : public ComputePass { @@ -87,7 +87,7 @@ public: explicit ASTCDecoderPass(const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_, StagingBufferPool& staging_buffer_pool_, - UpdateDescriptorQueue& update_descriptor_queue_, + ComputePassDescriptorQueue& compute_pass_descriptor_queue_, MemoryAllocator& memory_allocator_); ~ASTCDecoderPass(); @@ -97,7 +97,7 @@ public: private: Scheduler& scheduler; StagingBufferPool& staging_buffer_pool; - UpdateDescriptorQueue& update_descriptor_queue; + ComputePassDescriptorQueue& compute_pass_descriptor_queue; MemoryAllocator& memory_allocator; }; diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index 2a0f0dbf0..733e70d9d 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp @@ -26,13 +26,13 @@ using Tegra::Texture::TexturePair; ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipeline_cache_, DescriptorPool& descriptor_pool, - UpdateDescriptorQueue& update_descriptor_queue_, + GuestDescriptorQueue& guest_descriptor_queue_, Common::ThreadWorker* thread_worker, PipelineStatistics* pipeline_statistics, VideoCore::ShaderNotify* shader_notify, const Shader::Info& info_, vk::ShaderModule spv_module_) - : device{device_}, pipeline_cache(pipeline_cache_), - update_descriptor_queue{update_descriptor_queue_}, info{info_}, + : device{device_}, + pipeline_cache(pipeline_cache_), guest_descriptor_queue{guest_descriptor_queue_}, info{info_}, spv_module(std::move(spv_module_)) { if (shader_notify) { shader_notify->MarkShaderBuilding(); @@ -99,7 +99,7 @@ ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipel void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute, Tegra::MemoryManager& gpu_memory, Scheduler& scheduler, BufferCache& buffer_cache, TextureCache& texture_cache) { - update_descriptor_queue.Acquire(); + guest_descriptor_queue.Acquire(); buffer_cache.SetComputeUniformBufferState(info.constant_buffer_mask, &uniform_buffer_sizes); buffer_cache.UnbindComputeStorageBuffers(); @@ -194,7 +194,7 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute, RescalingPushConstant rescaling; const VkSampler* samplers_it{samplers.data()}; const VideoCommon::ImageViewInOut* views_it{views.data()}; - PushImageDescriptors(texture_cache, update_descriptor_queue, info, rescaling, samplers_it, + PushImageDescriptors(texture_cache, guest_descriptor_queue, info, rescaling, samplers_it, views_it); if (!is_built.load(std::memory_order::relaxed)) { @@ -204,7 +204,7 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute, build_condvar.wait(lock, [this] { return is_built.load(std::memory_order::relaxed); }); }); } - const void* const descriptor_data{update_descriptor_queue.UpdateData()}; + const void* const descriptor_data{guest_descriptor_queue.UpdateData()}; const bool is_rescaling = !info.texture_descriptors.empty() || !info.image_descriptors.empty(); scheduler.Record([this, descriptor_data, is_rescaling, rescaling_data = rescaling.Data()](vk::CommandBuffer cmdbuf) { diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.h b/src/video_core/renderer_vulkan/vk_compute_pipeline.h index 78d77027f..d1a1e2c46 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.h +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.h @@ -30,7 +30,7 @@ class ComputePipeline { public: explicit ComputePipeline(const Device& device, vk::PipelineCache& pipeline_cache, DescriptorPool& descriptor_pool, - UpdateDescriptorQueue& update_descriptor_queue, + GuestDescriptorQueue& guest_descriptor_queue, Common::ThreadWorker* thread_worker, PipelineStatistics* pipeline_statistics, VideoCore::ShaderNotify* shader_notify, const Shader::Info& info, @@ -48,7 +48,7 @@ public: private: const Device& device; vk::PipelineCache& pipeline_cache; - UpdateDescriptorQueue& update_descriptor_queue; + GuestDescriptorQueue& guest_descriptor_queue; Shader::Info info; VideoCommon::ComputeUniformBufferSizes uniform_buffer_sizes{}; diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index baedc4424..f1bcd5cd6 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -236,13 +236,13 @@ GraphicsPipeline::GraphicsPipeline( Scheduler& scheduler_, BufferCache& buffer_cache_, TextureCache& texture_cache_, vk::PipelineCache& pipeline_cache_, VideoCore::ShaderNotify* shader_notify, const Device& device_, DescriptorPool& descriptor_pool, - UpdateDescriptorQueue& update_descriptor_queue_, Common::ThreadWorker* worker_thread, + GuestDescriptorQueue& guest_descriptor_queue_, Common::ThreadWorker* worker_thread, PipelineStatistics* pipeline_statistics, RenderPassCache& render_pass_cache, const GraphicsPipelineCacheKey& key_, std::array<vk::ShaderModule, NUM_STAGES> stages, const std::array<const Shader::Info*, NUM_STAGES>& infos) : key{key_}, device{device_}, texture_cache{texture_cache_}, buffer_cache{buffer_cache_}, pipeline_cache(pipeline_cache_), scheduler{scheduler_}, - update_descriptor_queue{update_descriptor_queue_}, spv_modules{std::move(stages)} { + guest_descriptor_queue{guest_descriptor_queue_}, spv_modules{std::move(stages)} { if (shader_notify) { shader_notify->MarkShaderBuilding(); } @@ -449,7 +449,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { buffer_cache.UpdateGraphicsBuffers(is_indexed); buffer_cache.BindHostGeometryBuffers(is_indexed); - update_descriptor_queue.Acquire(); + guest_descriptor_queue.Acquire(); RescalingPushConstant rescaling; RenderAreaPushConstant render_area; @@ -457,7 +457,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { const VideoCommon::ImageViewInOut* views_it{views.data()}; const auto prepare_stage{[&](size_t stage) LAMBDA_FORCEINLINE { buffer_cache.BindHostStageBuffers(stage); - PushImageDescriptors(texture_cache, update_descriptor_queue, stage_infos[stage], rescaling, + PushImageDescriptors(texture_cache, guest_descriptor_queue, stage_infos[stage], rescaling, samplers_it, views_it); const auto& info{stage_infos[0]}; if (info.uses_render_area) { @@ -499,7 +499,7 @@ void GraphicsPipeline::ConfigureDraw(const RescalingPushConstant& rescaling, const bool is_rescaling{texture_cache.IsRescaling()}; const bool update_rescaling{scheduler.UpdateRescaling(is_rescaling)}; const bool bind_pipeline{scheduler.UpdateGraphicsPipeline(this)}; - const void* const descriptor_data{update_descriptor_queue.UpdateData()}; + const void* const descriptor_data{guest_descriptor_queue.UpdateData()}; scheduler.Record([this, descriptor_data, bind_pipeline, rescaling_data = rescaling.Data(), is_rescaling, update_rescaling, uses_render_area = render_area.uses_render_area, diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h index 67c657d0e..99e56e9ad 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h @@ -64,7 +64,6 @@ class RenderPassCache; class RescalingPushConstant; class RenderAreaPushConstant; class Scheduler; -class UpdateDescriptorQueue; class GraphicsPipeline { static constexpr size_t NUM_STAGES = Tegra::Engines::Maxwell3D::Regs::MaxShaderStage; @@ -74,7 +73,7 @@ public: Scheduler& scheduler, BufferCache& buffer_cache, TextureCache& texture_cache, vk::PipelineCache& pipeline_cache, VideoCore::ShaderNotify* shader_notify, const Device& device, DescriptorPool& descriptor_pool, - UpdateDescriptorQueue& update_descriptor_queue, Common::ThreadWorker* worker_thread, + GuestDescriptorQueue& guest_descriptor_queue, Common::ThreadWorker* worker_thread, PipelineStatistics* pipeline_statistics, RenderPassCache& render_pass_cache, const GraphicsPipelineCacheKey& key, std::array<vk::ShaderModule, NUM_STAGES> stages, const std::array<const Shader::Info*, NUM_STAGES>& infos); @@ -133,7 +132,7 @@ private: BufferCache& buffer_cache; vk::PipelineCache& pipeline_cache; Scheduler& scheduler; - UpdateDescriptorQueue& update_descriptor_queue; + GuestDescriptorQueue& guest_descriptor_queue; void (*configure_func)(GraphicsPipeline*, bool){}; diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index a318d643e..66dfe5733 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -277,11 +277,11 @@ bool GraphicsPipelineCacheKey::operator==(const GraphicsPipelineCacheKey& rhs) c PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_, - UpdateDescriptorQueue& update_descriptor_queue_, + GuestDescriptorQueue& guest_descriptor_queue_, RenderPassCache& render_pass_cache_, BufferCache& buffer_cache_, TextureCache& texture_cache_, VideoCore::ShaderNotify& shader_notify_) : VideoCommon::ShaderCache{rasterizer_}, device{device_}, scheduler{scheduler_}, - descriptor_pool{descriptor_pool_}, update_descriptor_queue{update_descriptor_queue_}, + descriptor_pool{descriptor_pool_}, guest_descriptor_queue{guest_descriptor_queue_}, render_pass_cache{render_pass_cache_}, buffer_cache{buffer_cache_}, texture_cache{texture_cache_}, shader_notify{shader_notify_}, use_asynchronous_shaders{Settings::values.use_asynchronous_shaders.GetValue()}, @@ -643,7 +643,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline( Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr}; return std::make_unique<GraphicsPipeline>( scheduler, buffer_cache, texture_cache, vulkan_pipeline_cache, &shader_notify, device, - descriptor_pool, update_descriptor_queue, thread_worker, statistics, render_pass_cache, key, + descriptor_pool, guest_descriptor_queue, thread_worker, statistics, render_pass_cache, key, std::move(modules), infos); } catch (const Shader::Exception& exception) { @@ -698,7 +698,8 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline( PipelineStatistics* statistics, bool build_in_parallel) try { // TODO: Remove this when Intel fixes their shader compiler. // https://github.com/IGCIT/Intel-GPU-Community-Issue-Tracker-IGCIT/issues/159 - if (device.GetDriverID() == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) { + if (device.GetDriverID() == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS && + !Settings::values.enable_compute_pipelines.GetValue()) { LOG_ERROR(Render_Vulkan, "Skipping 0x{:016x}", key.Hash()); return nullptr; } @@ -722,7 +723,7 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline( } Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr}; return std::make_unique<ComputePipeline>(device, vulkan_pipeline_cache, descriptor_pool, - update_descriptor_queue, thread_worker, statistics, + guest_descriptor_queue, thread_worker, statistics, &shader_notify, program.info, std::move(spv_module)); } catch (const Shader::Exception& exception) { diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index 5171912d7..15aa7e224 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h @@ -82,7 +82,6 @@ class PipelineStatistics; class RasterizerVulkan; class RenderPassCache; class Scheduler; -class UpdateDescriptorQueue; using VideoCommon::ShaderInfo; @@ -102,7 +101,7 @@ class PipelineCache : public VideoCommon::ShaderCache { public: explicit PipelineCache(RasterizerVulkan& rasterizer, const Device& device, Scheduler& scheduler, DescriptorPool& descriptor_pool, - UpdateDescriptorQueue& update_descriptor_queue, + GuestDescriptorQueue& guest_descriptor_queue, RenderPassCache& render_pass_cache, BufferCache& buffer_cache, TextureCache& texture_cache, VideoCore::ShaderNotify& shader_notify_); ~PipelineCache(); @@ -144,7 +143,7 @@ private: const Device& device; Scheduler& scheduler; DescriptorPool& descriptor_pool; - UpdateDescriptorQueue& update_descriptor_queue; + GuestDescriptorQueue& guest_descriptor_queue; RenderPassCache& render_pass_cache; BufferCache& buffer_cache; TextureCache& texture_cache; diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index cbf23552c..8d3a9736b 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -160,17 +160,16 @@ RasterizerVulkan::RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra : RasterizerAccelerated{cpu_memory_}, gpu{gpu_}, screen_info{screen_info_}, device{device_}, memory_allocator{memory_allocator_}, state_tracker{state_tracker_}, scheduler{scheduler_}, staging_pool(device, memory_allocator, scheduler), descriptor_pool(device, scheduler), - update_descriptor_queue(device, scheduler), - blit_image(device, scheduler, state_tracker, descriptor_pool), - render_pass_cache(device), texture_cache_runtime{device, scheduler, - memory_allocator, staging_pool, - blit_image, render_pass_cache, - descriptor_pool, update_descriptor_queue}, + guest_descriptor_queue(device, scheduler), compute_pass_descriptor_queue(device, scheduler), + blit_image(device, scheduler, state_tracker, descriptor_pool), render_pass_cache(device), + texture_cache_runtime{ + device, scheduler, memory_allocator, staging_pool, + blit_image, render_pass_cache, descriptor_pool, compute_pass_descriptor_queue}, texture_cache(texture_cache_runtime, *this), buffer_cache_runtime(device, memory_allocator, scheduler, staging_pool, - update_descriptor_queue, descriptor_pool), + guest_descriptor_queue, compute_pass_descriptor_queue, descriptor_pool), buffer_cache(*this, cpu_memory_, buffer_cache_runtime), - pipeline_cache(*this, device, scheduler, descriptor_pool, update_descriptor_queue, + pipeline_cache(*this, device, scheduler, descriptor_pool, guest_descriptor_queue, render_pass_cache, buffer_cache, texture_cache, gpu.ShaderNotify()), query_cache{*this, cpu_memory_, device, scheduler}, accelerate_dma(buffer_cache, texture_cache, scheduler), @@ -656,7 +655,8 @@ void RasterizerVulkan::FlushCommands() { void RasterizerVulkan::TickFrame() { draw_counter = 0; - update_descriptor_queue.TickFrame(); + guest_descriptor_queue.TickFrame(); + compute_pass_descriptor_queue.TickFrame(); fence_manager.TickFrame(); staging_pool.TickFrame(); { diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index 9bd422850..b39710b3c 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -184,7 +184,8 @@ private: StagingBufferPool staging_pool; DescriptorPool descriptor_pool; - UpdateDescriptorQueue update_descriptor_queue; + GuestDescriptorQueue guest_descriptor_queue; + ComputePassDescriptorQueue compute_pass_descriptor_queue; BlitImageHelper blit_image; RenderPassCache render_pass_cache; diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 9ca7751c5..4d0481f2a 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -798,13 +798,13 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched BlitImageHelper& blit_image_helper_, RenderPassCache& render_pass_cache_, DescriptorPool& descriptor_pool, - UpdateDescriptorQueue& update_descriptor_queue) + ComputePassDescriptorQueue& compute_pass_descriptor_queue) : device{device_}, scheduler{scheduler_}, memory_allocator{memory_allocator_}, staging_buffer_pool{staging_buffer_pool_}, blit_image_helper{blit_image_helper_}, render_pass_cache{render_pass_cache_}, resolution{Settings::values.resolution_info} { if (Settings::values.accelerate_astc) { astc_decoder_pass.emplace(device, scheduler, descriptor_pool, staging_buffer_pool, - update_descriptor_queue, memory_allocator); + compute_pass_descriptor_queue, memory_allocator); } } @@ -1864,6 +1864,7 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime, num_layers = std::max(num_layers, color_buffer->range.extent.layers); images[num_images] = color_buffer->ImageHandle(); image_ranges[num_images] = MakeSubresourceRange(color_buffer); + rt_map[index] = num_images; samples = color_buffer->Samples(); ++num_images; } diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 6f360177a..4166b3d20 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -34,7 +34,6 @@ class ImageView; class Framebuffer; class RenderPassCache; class StagingBufferPool; -class UpdateDescriptorQueue; class Scheduler; class TextureCacheRuntime { @@ -45,7 +44,7 @@ public: BlitImageHelper& blit_image_helper_, RenderPassCache& render_pass_cache_, DescriptorPool& descriptor_pool, - UpdateDescriptorQueue& update_descriptor_queue); + ComputePassDescriptorQueue& compute_pass_descriptor_queue); void Finish(); @@ -335,7 +334,7 @@ public: } [[nodiscard]] bool HasAspectColorBit(size_t index) const noexcept { - return (image_ranges.at(index).aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) != 0; + return (image_ranges.at(rt_map[index]).aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) != 0; } [[nodiscard]] bool HasAspectDepthBit() const noexcept { @@ -355,6 +354,7 @@ private: u32 num_images = 0; std::array<VkImage, 9> images{}; std::array<VkImageSubresourceRange, 9> image_ranges{}; + std::array<size_t, NUM_RT> rt_map{}; bool has_depth{}; bool has_stencil{}; }; diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index 1c1a7020b..310fb551a 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h @@ -32,7 +32,7 @@ class UpdateDescriptorQueue final { // This should be plenty for the vast majority of cases. Most desktop platforms only // provide up to 3 swapchain images. static constexpr size_t FRAMES_IN_FLIGHT = 5; - static constexpr size_t FRAME_PAYLOAD_SIZE = 0x10000; + static constexpr size_t FRAME_PAYLOAD_SIZE = 0x20000; static constexpr size_t PAYLOAD_SIZE = FRAME_PAYLOAD_SIZE * FRAMES_IN_FLIGHT; public: @@ -86,4 +86,8 @@ private: std::array<DescriptorUpdateEntry, PAYLOAD_SIZE> payload; }; +// TODO: should these be separate classes instead? +using GuestDescriptorQueue = UpdateDescriptorQueue; +using ComputePassDescriptorQueue = UpdateDescriptorQueue; + } // namespace Vulkan diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index e1198dcf8..b24086fce 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -1469,7 +1469,7 @@ std::optional<typename TextureCache<P>::BlitImages> TextureCache<P>::GetBlitImag if (!copy.must_accelerate) { do { if (!src_id && !dst_id) { - return std::nullopt; + break; } if (src_id && True(slot_images[src_id].flags & ImageFlagBits::GpuModified)) { break; diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 6ffca2af2..161f050b8 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -1009,6 +1009,8 @@ void Device::CollectPhysicalMemoryInfo() { device_access_memory += mem_properties.memoryHeaps[element].size; } if (!is_integrated) { + const u64 reserve_memory = std::min<u64>(device_access_memory / 8, 1_GiB); + device_access_memory -= reserve_memory; return; } const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage); diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp index 1732866e0..e28a556f8 100644 --- a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp +++ b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp @@ -147,7 +147,7 @@ public: /// Returns whether this allocation is compatible with the arguments. [[nodiscard]] bool IsCompatible(VkMemoryPropertyFlags flags, u32 type_mask) const { - return (flags & property_flags) == property_flags && (type_mask & shifted_memory_type) != 0; + return (flags & property_flags) == flags && (type_mask & shifted_memory_type) != 0; } private: |