diff --git a/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp b/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp index ecc60b35b70..ddd087f4211 100644 --- a/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp +++ b/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp @@ -593,6 +593,7 @@ gfx::DescriptorSet* initDescriptorSet( gfx::DescriptorSet* updatePerPassDescriptorSet( gfx::CommandBuffer* cmdBuff, + ResourceGraph& resg, const LayoutGraphData& lg, const DescriptorSetData& set, const RenderData& user, @@ -677,7 +678,15 @@ gfx::DescriptorSet* updatePerPassDescriptorSet( for (const auto& d : block.descriptors) { bool found = false; CC_EXPECTS(d.count == 1); - if (auto iter = user.buffers.find(d.descriptorID.value); + if (auto iter = user.bufferNames.find(d.descriptorID.value); + iter != user.bufferNames.end()) { + const auto resID = findVertex(iter->second, resg); + CC_ENSURES(resID != ResourceGraph::null_vertex()); + auto* buffer = resg.getBuffer(resID); + CC_ENSURES(buffer); + newSet->bindBuffer(bindID, buffer); + found = true; + } else if (auto iter = user.buffers.find(d.descriptorID.value); iter != user.buffers.end()) { newSet->bindBuffer(bindID, iter->second.get()); found = true; @@ -732,7 +741,7 @@ gfx::DescriptorSet* updateCameraUniformBufferAndDescriptorSet( auto& set = iter->second; auto& node = ctx.context.layoutGraphResources.at(passLayoutID); const auto& user = get(RenderGraph::DataTag{}, ctx.g, sceneID); // notice: sceneID - perPassSet = updatePerPassDescriptorSet(ctx.cmdBuff, ctx.lg, set, user, node); + perPassSet = updatePerPassDescriptorSet(ctx.cmdBuff, ctx.resourceGraph, ctx.lg, set, user, node); } return perPassSet; } diff --git a/native/cocos/renderer/pipeline/custom/NativeRenderGraph.cpp b/native/cocos/renderer/pipeline/custom/NativeRenderGraph.cpp index cc6e2c863f1..c05f83c0258 100644 --- a/native/cocos/renderer/pipeline/custom/NativeRenderGraph.cpp +++ b/native/cocos/renderer/pipeline/custom/NativeRenderGraph.cpp @@ -760,6 +760,7 @@ void NativeRenderQueueBuilder::addGpuDrivenResource(const scene::Camera *camera, } if (any(sceneFlags & SceneFlags::GPU_DRIVEN)) { + auto &data = get(RenderGraph::DataTag{}, *renderGraph, rgSceneID); const auto passID = renderGraph->getPassID(nodeID); const auto &sceneCulling = dynamic_cast(pipelineRuntime)->nativeContext.sceneCulling; const auto sceneID = sceneCulling.sceneIDs.at(scene); @@ -772,6 +773,12 @@ void NativeRenderQueueBuilder::addGpuDrivenResource(const scene::Camera *camera, ccstd::pmr::string drawInstanceBuffer("CCDrawInstanceBuffer"); drawInstanceBuffer.append(std::to_string(cullingID)); + const auto objectNameID = layoutGraph->attributeIndex.at("CCObjectBuffer"); + data.bufferNames[objectNameID.value] = objectBuffer; + + const auto instanceNameID = layoutGraph->attributeIndex.at("CCDrawInstanceBuffer"); + data.bufferNames[instanceNameID.value] = drawInstanceBuffer; + auto &rasterPass = get(RasterPassTag{}, passID, *renderGraph); if (rasterPass.computeViews.find(objectBuffer) == rasterPass.computeViews.end()) { auto res = rasterPass.computeViews.emplace( diff --git a/native/cocos/renderer/pipeline/custom/NativeRenderQueue.cpp b/native/cocos/renderer/pipeline/custom/NativeRenderQueue.cpp index b7520244b09..d90e4b48e0c 100644 --- a/native/cocos/renderer/pipeline/custom/NativeRenderQueue.cpp +++ b/native/cocos/renderer/pipeline/custom/NativeRenderQueue.cpp @@ -204,11 +204,6 @@ void GPUDrivenQueue::recordCommandBuffer( auto indirectResID = findVertex(indirectName, resg); const auto &indirectBuffer = get(ManagedBufferTag{}, indirectResID, resg).buffer.get(); - ccstd::pmr::string instanceName("CCDrawInstanceBuffer", get_allocator()); - instanceName.append(std::to_string(cullingID)); - auto instanceResID = findVertex(instanceName, resg); - const auto &instanceBuffer = get(ManagedBufferTag{}, instanceResID, resg).buffer.get(); - // Draw visible instances const auto supportFirstInstance = device->getCapabilities().supportFirstInstance; auto *batchPool = gpuScene->getBatchPool(); diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphTypes.cpp b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.cpp index 6627c262ebc..3ca5123978e 100644 --- a/native/cocos/renderer/pipeline/custom/RenderGraphTypes.cpp +++ b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.cpp @@ -392,6 +392,7 @@ RenderData::RenderData(const allocator_type& alloc) noexcept buffers(alloc), textures(alloc), samplers(alloc), + bufferNames(alloc), custom(alloc) {} RenderData::RenderData(RenderData&& rhs, const allocator_type& alloc) @@ -399,6 +400,7 @@ RenderData::RenderData(RenderData&& rhs, const allocator_type& alloc) buffers(std::move(rhs.buffers), alloc), textures(std::move(rhs.textures), alloc), samplers(std::move(rhs.samplers), alloc), + bufferNames(std::move(rhs.bufferNames), alloc), custom(std::move(rhs.custom), alloc) {} RenderGraph::RenderGraph(const allocator_type& alloc) noexcept diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h index 1cccc271dbf..0cbe0752bc2 100644 --- a/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h +++ b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h @@ -911,6 +911,7 @@ struct RenderData { PmrUnorderedMap> buffers; PmrUnorderedMap> textures; PmrUnorderedMap samplers; + PmrUnorderedMap bufferNames; ccstd::pmr::string custom; };