diff --git a/filament/backend/src/vulkan/VulkanBlitter.cpp b/filament/backend/src/vulkan/VulkanBlitter.cpp index 22960d9ddea..e9e4062ac6e 100644 --- a/filament/backend/src/vulkan/VulkanBlitter.cpp +++ b/filament/backend/src/vulkan/VulkanBlitter.cpp @@ -147,7 +147,7 @@ void VulkanBlitter::blitColor(BlitArgs args) { } #endif VulkanCommandBuffer& commands = mCommands->get(); - VkCommandBuffer const cmdbuffer = commands.cmdbuffer; + VkCommandBuffer const cmdbuffer = commands.buffer(); commands.acquire(src.texture); commands.acquire(dst.texture); @@ -184,7 +184,7 @@ void VulkanBlitter::blitDepth(BlitArgs args) { } VulkanCommandBuffer& commands = mCommands->get(); - VkCommandBuffer const cmdbuffer = commands.cmdbuffer; + VkCommandBuffer const cmdbuffer = commands.buffer(); commands.acquire(src.texture); commands.acquire(dst.texture); blitFast(cmdbuffer, aspect, args.filter, args.srcTarget->getExtent(), src, dst, args.srcRectPair, @@ -197,13 +197,11 @@ void VulkanBlitter::terminate() noexcept { mDepthResolveProgram = nullptr; if (mTriangleBuffer) { - mTriangleBuffer->terminate(); delete mTriangleBuffer; mTriangleBuffer = nullptr; } if (mParamsBuffer) { - mParamsBuffer->terminate(); delete mParamsBuffer; mParamsBuffer = nullptr; } @@ -257,7 +255,7 @@ void VulkanBlitter::lazyInit() noexcept { }; VulkanCommandBuffer& commands = mCommands->get(); - VkCommandBuffer const cmdbuffer = commands.cmdbuffer; + VkCommandBuffer const cmdbuffer = commands.buffer(); mTriangleBuffer = new VulkanBuffer(mAllocator, mStagePool, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, sizeof(kTriangleVertices)); @@ -278,7 +276,7 @@ void VulkanBlitter::blitSlowDepth(VkFilter filter, const VkExtent2D srcExtent, V lazyInit(); VulkanCommandBuffer* commands = &mCommands->get(); - VkCommandBuffer const cmdbuffer = commands->cmdbuffer; + VkCommandBuffer const cmdbuffer = commands->buffer(); commands->acquire(src.texture); commands->acquire(dst.texture); diff --git a/filament/backend/src/vulkan/VulkanBuffer.cpp b/filament/backend/src/vulkan/VulkanBuffer.cpp index d09e2ae16d8..1b5f59eafd6 100644 --- a/filament/backend/src/vulkan/VulkanBuffer.cpp +++ b/filament/backend/src/vulkan/VulkanBuffer.cpp @@ -45,14 +45,7 @@ VulkanBuffer::VulkanBuffer(VmaAllocator allocator, VulkanStagePool& stagePool, } VulkanBuffer::~VulkanBuffer() { - assert_invariant(mGpuMemory == VK_NULL_HANDLE); - assert_invariant(mGpuBuffer == VK_NULL_HANDLE); -} - -void VulkanBuffer::terminate() { vmaDestroyBuffer(mAllocator, mGpuBuffer, mGpuMemory); - mGpuMemory = VK_NULL_HANDLE; - mGpuBuffer = VK_NULL_HANDLE; } void VulkanBuffer::loadFromCpu(VkCommandBuffer cmdbuf, const void* cpuData, uint32_t byteOffset, diff --git a/filament/backend/src/vulkan/VulkanBuffer.h b/filament/backend/src/vulkan/VulkanBuffer.h index f9f3c7e3b6e..d9a87962cef 100644 --- a/filament/backend/src/vulkan/VulkanBuffer.h +++ b/filament/backend/src/vulkan/VulkanBuffer.h @@ -28,7 +28,6 @@ class VulkanBuffer { VulkanBuffer(VmaAllocator allocator, VulkanStagePool& stagePool, VkBufferUsageFlags usage, uint32_t numBytes); ~VulkanBuffer(); - void terminate(); void loadFromCpu(VkCommandBuffer cmdbuf, const void* cpuData, uint32_t byteOffset, uint32_t numBytes) const; VkBuffer getGpuBuffer() const { diff --git a/filament/backend/src/vulkan/VulkanCommands.cpp b/filament/backend/src/vulkan/VulkanCommands.cpp index dfbb3747faf..66a7c915a7a 100644 --- a/filament/backend/src/vulkan/VulkanCommands.cpp +++ b/filament/backend/src/vulkan/VulkanCommands.cpp @@ -52,6 +52,23 @@ VulkanCmdFence::~VulkanCmdFence() { vkDestroyFence(device, fence, VKALLOC); } +VulkanCommandBuffer::VulkanCommandBuffer(VulkanResourceAllocator* allocator, VkDevice device, + VkCommandPool pool) + : mResourceManager(allocator) { + // Create the low-level command buffer. + const VkCommandBufferAllocateInfo allocateInfo{ + .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, + .commandPool = pool, + .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY, + .commandBufferCount = 1, + }; + + // The buffer allocated here will be implicitly reset when vkBeginCommandBuffer is called. + vkAllocateCommandBuffers(device, &allocateInfo, &mBuffer); + + // We don't need to deallocate since destroying the pool will free all of the buffers. +} + CommandBufferObserver::~CommandBufferObserver() {} static VkCommandPool createPool(VkDevice device, uint32_t queueFamilyIndex) { @@ -130,7 +147,7 @@ VulkanCommands::VulkanCommands(VkDevice device, VkQueue queue, uint32_t queueFam } for (size_t i = 0; i < CAPACITY; ++i) { - mStorage[i] = std::make_unique(allocator); + mStorage[i] = std::make_unique(allocator, mDevice, mPool); } } @@ -151,7 +168,7 @@ VulkanCommandBuffer& VulkanCommands::get() { // If we ran out of available command buffers, stall until one finishes. This is very rare. // It occurs only when Filament invokes commit() or endFrame() a large number of times without // presenting the swap chain or waiting on a fence. - while (mAvailableCount == 0) { + while (mAvailableBufferCount == 0) { #if VK_REPORT_STALLS slog.i << "VulkanCommands has stalled. " << "If this occurs frequently, consider increasing VK_MAX_COMMAND_BUFFERS." @@ -165,7 +182,7 @@ VulkanCommandBuffer& VulkanCommands::get() { // Find an available slot. for (size_t i = 0; i < CAPACITY; ++i) { auto wrapper = mStorage[i].get(); - if (wrapper->cmdbuffer == VK_NULL_HANDLE) { + if (wrapper->buffer() == VK_NULL_HANDLE) { mCurrentCommandBufferIndex = static_cast(i); currentbuf = wrapper; break; @@ -173,16 +190,7 @@ VulkanCommandBuffer& VulkanCommands::get() { } assert_invariant(currentbuf); - --mAvailableCount; - - // Create the low-level command buffer. - const VkCommandBufferAllocateInfo allocateInfo { - .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, - .commandPool = mPool, - .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY, - .commandBufferCount = 1 - }; - vkAllocateCommandBuffers(mDevice, &allocateInfo, ¤tbuf->cmdbuffer); + mAvailableBufferCount--; // Note that the fence wrapper uses shared_ptr because a DriverAPI fence can also have ownership // over it. The destruction of the low-level fence occurs either in VulkanCommands::gc(), or in @@ -194,7 +202,7 @@ VulkanCommandBuffer& VulkanCommands::get() { .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, }; - vkBeginCommandBuffer(currentbuf->cmdbuffer, &binfo); + vkBeginCommandBuffer(currentbuf->buffer(), &binfo); // Notify the observer that a new command buffer has been activated. if (mObserver) { @@ -235,7 +243,7 @@ bool VulkanCommands::flush() { VulkanCommandBuffer const* currentbuf = mStorage[index].get(); VkSemaphore const renderingFinished = mSubmissionSignals[index]; - vkEndCommandBuffer(currentbuf->cmdbuffer); + vkEndCommandBuffer(currentbuf->buffer()); // If the injected semaphore is an "image available" semaphore that has not yet been signaled, // it is sometimes fine to start executing commands anyway, as along as we stall the GPU at the @@ -253,13 +261,15 @@ bool VulkanCommands::flush() { VK_NULL_HANDLE, }; + VkCommandBuffer const cmdbuffer = currentbuf->buffer(); + VkSubmitInfo submitInfo { .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .waitSemaphoreCount = 0, .pWaitSemaphores = signals, .pWaitDstStageMask = waitDestStageMasks, .commandBufferCount = 1, - .pCommandBuffers = ¤tbuf->cmdbuffer, + .pCommandBuffers = &cmdbuffer, .signalSemaphoreCount = 1u, .pSignalSemaphores = &renderingFinished, }; @@ -278,7 +288,7 @@ bool VulkanCommands::flush() { } #if FILAMENT_VULKAN_VERBOSE - slog.i << "Submitting cmdbuffer=" << currentbuf->cmdbuffer + slog.i << "Submitting cmdbuffer=" << cmdbuffer << " wait=(" << signals[0] << ", " << signals[1] << ") " << " signal=" << renderingFinished << io::endl; @@ -326,7 +336,7 @@ void VulkanCommands::wait() { size_t count = 0; for (size_t i = 0; i < CAPACITY; i++) { auto wrapper = mStorage[i].get(); - if (wrapper->cmdbuffer != VK_NULL_HANDLE + if (wrapper->buffer() != VK_NULL_HANDLE && mCurrentCommandBufferIndex != static_cast(i)) { fences[count++] = wrapper->fence->fence; } @@ -337,33 +347,25 @@ void VulkanCommands::wait() { } void VulkanCommands::gc() { - VkCommandBuffer buffers[CAPACITY]; - size_t count = 0; for (size_t i = 0; i < CAPACITY; i++) { auto wrapper = mStorage[i].get(); - if (wrapper->cmdbuffer == VK_NULL_HANDLE) { + if (wrapper->buffer() == VK_NULL_HANDLE) { continue; } VkResult const result = vkWaitForFences(mDevice, 1, &wrapper->fence->fence, VK_TRUE, 0); if (result != VK_SUCCESS) { continue; } - buffers[count++] = wrapper->cmdbuffer; - wrapper->cmdbuffer = VK_NULL_HANDLE; wrapper->fence->status.store(VK_SUCCESS); - wrapper->fence.reset(); - wrapper->clearResources(); - ++mAvailableCount; - } - if (count > 0) { - vkFreeCommandBuffers(mDevice, mPool, count, buffers); + wrapper->reset(); + mAvailableBufferCount++; } } void VulkanCommands::updateFences() { for (size_t i = 0; i < CAPACITY; i++) { auto wrapper = mStorage[i].get(); - if (wrapper->cmdbuffer != VK_NULL_HANDLE) { + if (wrapper->buffer() != VK_NULL_HANDLE) { VulkanCmdFence* fence = wrapper->fence.get(); if (fence) { VkResult status = vkGetFenceStatus(mDevice, fence->fence); @@ -384,7 +386,7 @@ void VulkanCommands::pushGroupMarker(char const* str, VulkanGroupMarkers::Timest #endif // TODO: Add group marker color to the Driver API - const VkCommandBuffer cmdbuffer = get().cmdbuffer; + VkCommandBuffer const cmdbuffer = get().buffer(); if (!mGroupMarkers) { mGroupMarkers = std::make_unique(); @@ -412,7 +414,7 @@ void VulkanCommands::popGroupMarker() { assert_invariant(mGroupMarkers); if (!mGroupMarkers->empty()) { - const VkCommandBuffer cmdbuffer = get().cmdbuffer; + VkCommandBuffer const cmdbuffer = get().buffer(); #if FILAMENT_VULKAN_VERBOSE auto const [marker, startTime] = mGroupMarkers->pop(); auto const endTime = std::chrono::high_resolution_clock::now(); @@ -437,7 +439,7 @@ void VulkanCommands::popGroupMarker() { } void VulkanCommands::insertEventMarker(char const* string, uint32_t len) { - VkCommandBuffer const cmdbuffer = get().cmdbuffer; + VkCommandBuffer const cmdbuffer = get().buffer(); if (mContext->isDebugUtilsSupported()) { VkDebugUtilsLabelEXT labelInfo = { .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, diff --git a/filament/backend/src/vulkan/VulkanCommands.h b/filament/backend/src/vulkan/VulkanCommands.h index f2c358fa36e..8038ae2724b 100644 --- a/filament/backend/src/vulkan/VulkanCommands.h +++ b/filament/backend/src/vulkan/VulkanCommands.h @@ -71,13 +71,10 @@ struct VulkanCmdFence { // DriverApi fence object and should not be destroyed until both the DriverApi object is freed and // we're done waiting on the most recent submission of the given command buffer. struct VulkanCommandBuffer { - VulkanCommandBuffer(VulkanResourceAllocator* allocator) - : mResourceManager(allocator) {} + VulkanCommandBuffer(VulkanResourceAllocator* allocator, VkDevice device, VkCommandPool pool); VulkanCommandBuffer(VulkanCommandBuffer const&) = delete; VulkanCommandBuffer& operator=(VulkanCommandBuffer const&) = delete; - VkCommandBuffer cmdbuffer = VK_NULL_HANDLE; - std::shared_ptr fence; inline void acquire(VulkanResource* resource) { mResourceManager.acquire(resource); @@ -87,12 +84,23 @@ struct VulkanCommandBuffer { mResourceManager.acquire(srcResources); } - inline void clearResources() { + inline void reset() { + fence.reset(); mResourceManager.clear(); } + inline VkCommandBuffer buffer() const { + if (fence) { + return mBuffer; + } + return VK_NULL_HANDLE; + } + + std::shared_ptr fence; + private: VulkanAcquireOnlyResourceManager mResourceManager; + VkCommandBuffer mBuffer; }; // Allows classes to be notified after a new command buffer has been activated. @@ -185,7 +193,7 @@ class VulkanCommands { VkSemaphore mInjectedSignal = {}; utils::FixedCapacityVector> mStorage; VkSemaphore mSubmissionSignals[CAPACITY] = {}; - size_t mAvailableCount = CAPACITY; + uint8_t mAvailableBufferCount = CAPACITY; CommandBufferObserver* mObserver = nullptr; std::unique_ptr mGroupMarkers; diff --git a/filament/backend/src/vulkan/VulkanContext.cpp b/filament/backend/src/vulkan/VulkanContext.cpp index b2c14cfe3c3..f8a4e496d22 100644 --- a/filament/backend/src/vulkan/VulkanContext.cpp +++ b/filament/backend/src/vulkan/VulkanContext.cpp @@ -117,8 +117,9 @@ void VulkanTimestamps::beginQuery(VulkanCommandBuffer const* commands, VulkanTimerQuery* query) { uint32_t const index = query->getStartingQueryIndex(); - vkCmdResetQueryPool(commands->cmdbuffer, mPool, index, 2); - vkCmdWriteTimestamp(commands->cmdbuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, mPool, index); + auto const cmdbuffer = commands->buffer(); + vkCmdResetQueryPool(cmdbuffer, mPool, index, 2); + vkCmdWriteTimestamp(cmdbuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, mPool, index); // We stash this because getResult might come before the query is actually processed. query->setFence(commands->fence); @@ -127,7 +128,7 @@ void VulkanTimestamps::beginQuery(VulkanCommandBuffer const* commands, void VulkanTimestamps::endQuery(VulkanCommandBuffer const* commands, VulkanTimerQuery const* query) { uint32_t const index = query->getStoppingQueryIndex(); - vkCmdWriteTimestamp(commands->cmdbuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, mPool, index); + vkCmdWriteTimestamp(commands->buffer(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, mPool, index); } VulkanTimestamps::QueryResult VulkanTimestamps::getResult(VulkanTimerQuery const* query) { diff --git a/filament/backend/src/vulkan/VulkanDriver.cpp b/filament/backend/src/vulkan/VulkanDriver.cpp index 875a5837362..85bf6c17ef6 100644 --- a/filament/backend/src/vulkan/VulkanDriver.cpp +++ b/filament/backend/src/vulkan/VulkanDriver.cpp @@ -873,7 +873,7 @@ void VulkanDriver::updateIndexBuffer(Handle ibh, BufferDescriptor VulkanCommandBuffer& commands = mCommands->get(); auto ib = mResourceAllocator.handle_cast(ibh); commands.acquire(ib); - ib->buffer.loadFromCpu(commands.cmdbuffer, p.buffer, byteOffset, p.size); + ib->buffer.loadFromCpu(commands.buffer(), p.buffer, byteOffset, p.size); scheduleDestroy(std::move(p)); } @@ -884,7 +884,7 @@ void VulkanDriver::updateBufferObject(Handle boh, BufferDescript auto bo = mResourceAllocator.handle_cast(boh); commands.acquire(bo); - bo->buffer.loadFromCpu(commands.cmdbuffer, bd.buffer, byteOffset, bd.size); + bo->buffer.loadFromCpu(commands.buffer(), bd.buffer, byteOffset, bd.size); scheduleDestroy(std::move(bd)); } @@ -895,7 +895,7 @@ void VulkanDriver::updateBufferObjectUnsynchronized(Handle boh, auto bo = mResourceAllocator.handle_cast(boh); commands.acquire(bo); // TODO: implement unsynchronized version - bo->buffer.loadFromCpu(commands.cmdbuffer, bd.buffer, byteOffset, bd.size); + bo->buffer.loadFromCpu(commands.buffer(), bd.buffer, byteOffset, bd.size); mResourceManager.acquire(bo); scheduleDestroy(std::move(bd)); } @@ -1021,7 +1021,7 @@ void VulkanDriver::beginRenderPass(Handle rth, const RenderPassP // the non-sampling case. bool samplingDepthAttachment = false; VulkanCommandBuffer& commands = mCommands->get(); - VkCommandBuffer const cmdbuffer = commands.cmdbuffer; + VkCommandBuffer const cmdbuffer = commands.buffer(); UTILS_NOUNROLL for (uint8_t samplerGroupIdx = 0; samplerGroupIdx < Program::SAMPLER_BINDING_COUNT; @@ -1247,7 +1247,7 @@ void VulkanDriver::beginRenderPass(Handle rth, const RenderPassP void VulkanDriver::endRenderPass(int) { VulkanCommandBuffer& commands = mCommands->get(); - VkCommandBuffer cmdbuffer = commands.cmdbuffer; + VkCommandBuffer cmdbuffer = commands.buffer(); vkCmdEndRenderPass(cmdbuffer); VulkanRenderTarget* rt = mCurrentRenderPass.renderTarget; @@ -1299,7 +1299,7 @@ void VulkanDriver::nextSubpass(int) { assert_invariant(renderTarget); assert_invariant(mCurrentRenderPass.params.subpassMask); - vkCmdNextSubpass(mCommands->get().cmdbuffer, VK_SUBPASS_CONTENTS_INLINE); + vkCmdNextSubpass(mCommands->get().buffer(), VK_SUBPASS_CONTENTS_INLINE); mPipelineCache.bindRenderPass(mCurrentRenderPass.renderPass, ++mCurrentRenderPass.currentSubpass); @@ -1484,7 +1484,7 @@ void VulkanDriver::blit(TargetBufferFlags buffers, Handle dst, V void VulkanDriver::draw(PipelineState pipelineState, Handle rph, const uint32_t instanceCount) { VulkanCommandBuffer* commands = &mCommands->get(); - VkCommandBuffer cmdbuffer = commands->cmdbuffer; + VkCommandBuffer cmdbuffer = commands->buffer(); const VulkanRenderPrimitive& prim = *mResourceAllocator.handle_cast(rph); Handle programHandle = pipelineState.program; diff --git a/filament/backend/src/vulkan/VulkanHandles.h b/filament/backend/src/vulkan/VulkanHandles.h index 6e9db5040a5..276f2ab8196 100644 --- a/filament/backend/src/vulkan/VulkanHandles.h +++ b/filament/backend/src/vulkan/VulkanHandles.h @@ -96,10 +96,6 @@ struct VulkanVertexBuffer : public HwVertexBuffer, VulkanResource { void setBuffer(VulkanBufferObject* bufferObject, uint32_t index); - inline void terminate() { - mResources.clear(); - } - utils::FixedCapacityVector buffers; private: @@ -114,9 +110,6 @@ struct VulkanIndexBuffer : public HwIndexBuffer, VulkanResource { buffer(allocator, stagePool, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, elementSize * indexCount), indexType(elementSize == 2 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32) {} - void terminate() { - buffer.terminate(); - } VulkanBuffer buffer; const VkIndexType indexType; }; @@ -124,9 +117,7 @@ struct VulkanIndexBuffer : public HwIndexBuffer, VulkanResource { struct VulkanBufferObject : public HwBufferObject, VulkanResource { VulkanBufferObject(VmaAllocator allocator, VulkanStagePool& stagePool, uint32_t byteCount, BufferObjectBinding bindingType, BufferUsage usage); - void terminate() { - buffer.terminate(); - } + VulkanBuffer buffer; const BufferObjectBinding bindingType; }; diff --git a/filament/backend/src/vulkan/VulkanPipelineCache.cpp b/filament/backend/src/vulkan/VulkanPipelineCache.cpp index 0d74637bc75..e69cfae9a53 100644 --- a/filament/backend/src/vulkan/VulkanPipelineCache.cpp +++ b/filament/backend/src/vulkan/VulkanPipelineCache.cpp @@ -166,7 +166,7 @@ bool VulkanPipelineCache::bindDescriptors(VkCommandBuffer cmdbuffer) noexcept { } bool VulkanPipelineCache::bindPipeline(VulkanCommandBuffer* commands) noexcept { - VkCommandBuffer const cmdbuffer = commands->cmdbuffer; + VkCommandBuffer const cmdbuffer = commands->buffer(); PipelineMap::iterator pipelineIter = mPipelines.find(mPipelineRequirements); @@ -678,7 +678,7 @@ void VulkanPipelineCache::terminate() noexcept { mDummyMemory = VK_NULL_HANDLE; } -void VulkanPipelineCache::onCommandBuffer(const VulkanCommandBuffer& cmdbuffer) { +void VulkanPipelineCache::onCommandBuffer(const VulkanCommandBuffer& commands) { // The timestamp associated with a given cache entry represents "time" as a count of flush // events since the cache was constructed. If any cache entry was most recently used over // VK_MAX_PIPELINE_AGE flush events in the past, then we can be sure that it is no longer diff --git a/filament/backend/src/vulkan/VulkanResourceAllocator.h b/filament/backend/src/vulkan/VulkanResourceAllocator.h index ab68865724e..222c7be9360 100644 --- a/filament/backend/src/vulkan/VulkanResourceAllocator.h +++ b/filament/backend/src/vulkan/VulkanResourceAllocator.h @@ -101,10 +101,6 @@ class VulkanResourceAllocator { template inline void destruct(Handle handle) noexcept { auto obj = handle_cast(handle); - if constexpr (std::is_base_of_v - || std::is_base_of_v) { - obj->terminate(); - } TRACK_DECREMENT(); mHandleAllocatorImpl.deallocate(handle, obj); } diff --git a/filament/backend/src/vulkan/VulkanResources.h b/filament/backend/src/vulkan/VulkanResources.h index 61e039941ff..538b07a82a4 100644 --- a/filament/backend/src/vulkan/VulkanResources.h +++ b/filament/backend/src/vulkan/VulkanResources.h @@ -164,6 +164,10 @@ class FixedCapacityResourceSet { public: using const_iterator = FixedSizeArray::const_iterator; + inline ~FixedCapacityResourceSet() { + clear(); + } + inline const_iterator begin() { if (mInd == 0) { return mArray.cend(); diff --git a/filament/backend/src/vulkan/VulkanStagePool.cpp b/filament/backend/src/vulkan/VulkanStagePool.cpp index cb0f79b7e73..a8934d242b4 100644 --- a/filament/backend/src/vulkan/VulkanStagePool.cpp +++ b/filament/backend/src/vulkan/VulkanStagePool.cpp @@ -111,7 +111,7 @@ VulkanStageImage const* VulkanStagePool::acquireImage(PixelDataFormat format, Pi assert_invariant(result == VK_SUCCESS); VkImageAspectFlags const aspectFlags = getImageAspect(vkformat); - const VkCommandBuffer cmdbuffer = mCommands->get().cmdbuffer; + VkCommandBuffer const cmdbuffer = mCommands->get().buffer(); // We use VK_IMAGE_LAYOUT_GENERAL here because the spec says: // "Host access to image memory is only well-defined for linear images and for image diff --git a/filament/backend/src/vulkan/VulkanSwapChain.cpp b/filament/backend/src/vulkan/VulkanSwapChain.cpp index 286499f78be..d6c43b62f63 100644 --- a/filament/backend/src/vulkan/VulkanSwapChain.cpp +++ b/filament/backend/src/vulkan/VulkanSwapChain.cpp @@ -79,7 +79,7 @@ void VulkanSwapChain::update() { void VulkanSwapChain::present() { if (!mHeadless) { - VkCommandBuffer const cmdbuf = mCommands->get().cmdbuffer; + VkCommandBuffer const cmdbuf = mCommands->get().buffer(); VkImageSubresourceRange const subresources{ .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .baseMipLevel = 0, diff --git a/filament/backend/src/vulkan/VulkanTexture.cpp b/filament/backend/src/vulkan/VulkanTexture.cpp index 1a58d6f9dcf..140c697f87d 100644 --- a/filament/backend/src/vulkan/VulkanTexture.cpp +++ b/filament/backend/src/vulkan/VulkanTexture.cpp @@ -227,7 +227,7 @@ VulkanTexture::VulkanTexture(VkDevice device, VkPhysicalDevice physicalDevice, VkImageSubresourceRange range = { getImageAspect(), 0, levels, 0, layers }; VulkanCommandBuffer& commands = mCommands->get(); - VkCommandBuffer const cmdbuf = commands.cmdbuffer; + VkCommandBuffer const cmdbuf = commands.buffer(); commands.acquire(this); transitionLayout(cmdbuf, range, ImgUtil::getDefaultLayout(imageInfo.usage)); @@ -280,7 +280,7 @@ void VulkanTexture::updateImage(const PixelBufferDescriptor& data, uint32_t widt vmaFlushAllocation(mAllocator, stage->memory, 0, hostData->size); VulkanCommandBuffer& commands = mCommands->get(); - VkCommandBuffer const cmdbuf = commands.cmdbuffer; + VkCommandBuffer const cmdbuf = commands.buffer(); commands.acquire(this); VkBufferImageCopy copyRegion = { @@ -343,7 +343,7 @@ void VulkanTexture::updateImageWithBlit(const PixelBufferDescriptor& hostData, u vmaFlushAllocation(mAllocator, stage->memory, 0, hostData.size); VulkanCommandBuffer& commands = mCommands->get(); - VkCommandBuffer const cmdbuf = commands.cmdbuffer; + VkCommandBuffer const cmdbuf = commands.buffer(); commands.acquire(this); // TODO: support blit-based format conversion for 3D images and cubemaps.