From 04913be779cf30a37196863bd92d9c701ee6137d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 29 Nov 2017 20:13:38 +0100 Subject: [PATCH] Move pushbuffer map/unmap to the .cpp file to avoid inlining (for stack traces) --- Common/Vulkan/VulkanMemory.cpp | 21 +++++++++++++++++++++ Common/Vulkan/VulkanMemory.h | 21 ++------------------- GPU/Vulkan/PipelineManagerVulkan.cpp | 3 +-- ext/native/thin3d/thin3d_vulkan.cpp | 1 - 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Common/Vulkan/VulkanMemory.cpp b/Common/Vulkan/VulkanMemory.cpp index 67d300dc44..c46195db30 100644 --- a/Common/Vulkan/VulkanMemory.cpp +++ b/Common/Vulkan/VulkanMemory.cpp @@ -134,6 +134,27 @@ size_t VulkanPushBuffer::GetTotalSize() const { return sum; } +void VulkanPushBuffer::Map() { + assert(!writePtr_); + VkResult res = vkMapMemory(device_, buffers_[buf_].deviceMemory, 0, size_, 0, (void **)(&writePtr_)); + assert(writePtr_); + assert(VK_SUCCESS == res); +} + +void VulkanPushBuffer::Unmap() { + assert(writePtr_); + /* + // Should not need this since we use coherent memory. + VkMappedMemoryRange range = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE }; + range.offset = 0; + range.size = offset_; + range.memory = buffers_[buf_].deviceMemory; + vkFlushMappedMemoryRanges(device_, 1, &range); + */ + vkUnmapMemory(device_, buffers_[buf_].deviceMemory); + writePtr_ = nullptr; +} + VulkanDeviceAllocator::VulkanDeviceAllocator(VulkanContext *vulkan, size_t minSlabSize, size_t maxSlabSize) : vulkan_(vulkan), lastSlab_(0), minSlabSize_(minSlabSize), maxSlabSize_(maxSlabSize), memoryTypeIndex_(UNDEFINED_MEMORY_TYPE), destroyed_(false) { assert((minSlabSize_ & (SLAB_GRAIN_SIZE - 1)) == 0); diff --git a/Common/Vulkan/VulkanMemory.h b/Common/Vulkan/VulkanMemory.h index 96f5833340..15f09d1265 100644 --- a/Common/Vulkan/VulkanMemory.h +++ b/Common/Vulkan/VulkanMemory.h @@ -46,26 +46,9 @@ public: Unmap(); } - void Map() { - assert(!writePtr_); - VkResult res = vkMapMemory(device_, buffers_[buf_].deviceMemory, 0, size_, 0, (void **)(&writePtr_)); - assert(writePtr_); - assert(VK_SUCCESS == res); - } + void Map(); - void Unmap() { - assert(writePtr_); - /* - // Should not need this since we use coherent memory. - VkMappedMemoryRange range = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE }; - range.offset = 0; - range.size = offset_; - range.memory = buffers_[buf_].deviceMemory; - vkFlushMappedMemoryRanges(device_, 1, &range); - */ - vkUnmapMemory(device_, buffers_[buf_].deviceMemory); - writePtr_ = nullptr; - } + void Unmap(); // When using the returned memory, make sure to bind the returned vkbuf. // This will later allow for handling overflow correctly. diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 1b27f135b4..dbf3e1e130 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -301,8 +301,7 @@ static VulkanPipeline *CreateVulkanPipeline(VkDevice device, VkPipelineCache pip VulkanPipeline *PipelineManagerVulkan::GetOrCreatePipeline(VkPipelineLayout layout, VkRenderPass renderPass, const VulkanPipelineRasterStateKey &rasterKey, const DecVtxFormat *decFmt, VulkanVertexShader *vs, VulkanFragmentShader *fs, bool useHwTransform) { VulkanPipelineKey key{}; - if (!renderPass) - Crash(); + _assert_msg_(G3D, renderPass, "Can't create a pipeline with a null renderpass"); key.raster = rasterKey; key.renderPass = renderPass; diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 0044b3f234..8e38776b6d 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -1298,7 +1298,6 @@ uint32_t VKContext::GetDataFormatSupport(DataFormat fmt) const { // use this frame's init command buffer. class VKFramebuffer : public Framebuffer { public: - // Inherits ownership so no AddRef. VKFramebuffer(VKRFramebuffer *fb) : buf_(fb) {} ~VKFramebuffer() { buf_->vulkan_->Delete().QueueCallback([](void *fb) {