Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add queue passName #17309

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions cocos/rendering/custom/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,13 @@ export interface BasicRenderPassBuilder extends Setter {
*
* @param hint @en Usage hint of the queue @zh 用途的提示
* @param phaseName @en The name of the phase declared in the effect. Default value is 'default' @zh effect中相位(phase)的名字,缺省为'default'。
* @param passName @en The name of the pass declared in the effect. It is used to override the pass name in the parent pass/subpass. @zh effect中通道(pass)的名字,会覆盖(override)父(通道/子通道)中已设置的pass名字。
* @returns @en render queue builder @zh 渲染队列
*/
addQueue (hint?: QueueHint, phaseName?: string): RenderQueueBuilder;
addQueue (
hint?: QueueHint,
phaseName?: string,
passName?: string): RenderQueueBuilder;
/**
* @en Set rendering viewport.
* @zh 设置渲染视口
Expand Down Expand Up @@ -1160,9 +1164,13 @@ export interface RenderSubpassBuilder extends Setter {
*
* @param hint @en Usage hint of the queue @zh 用途的提示
* @param phaseName @en The name of the phase declared in the effect. Default value is 'default' @zh effect中相位(phase)的名字,缺省为'default'。
* @param passName @en The name of the pass declared in the effect. It is used to override the pass name in the parent pass/subpass. @zh effect中通道(pass)的名字,会覆盖(override)父(通道/子通道)中已设置的pass名字。
* @returns @en render queue builder @zh 渲染队列
*/
addQueue (hint?: QueueHint, phaseName?: string): RenderQueueBuilder;
addQueue (
hint?: QueueHint,
phaseName?: string,
passName?: string): RenderQueueBuilder;
/**
* @en Show statistics on screen
* @zh 在屏幕上渲染统计数据
Expand Down Expand Up @@ -1298,9 +1306,10 @@ export interface ComputeSubpassBuilder extends Setter {
*
* @param hint @en Usage hint of the queue @zh 用途的提示
* @param phaseName @en The name of the phase declared in the effect. Default value is 'default' @zh effect中相位(phase)的名字,缺省为'default'。
* @param passName @en The name of the pass declared in the effect. It is used to override the pass name in the parent pass/subpass. @zh effect中通道(pass)的名字,会覆盖(override)父(通道/子通道)中已设置的pass名字。
* @returns @en compute queue builder @zh 计算队列
*/
addQueue (phaseName?: string): ComputeQueueBuilder;
addQueue (phaseName?: string, passName?: string): ComputeQueueBuilder;
/**
* @experimental
*/
Expand Down Expand Up @@ -1476,9 +1485,10 @@ export interface ComputePassBuilder extends Setter {
*
* @param hint @en Usage hint of the queue @zh 用途的提示
* @param phaseName @en The name of the phase declared in the effect. Default value is 'default' @zh effect中相位(phase)的名字,缺省为'default'。
* @param passName @en The name of the pass declared in the effect. It is used to override the pass name in the parent pass/subpass. @zh effect中通道(pass)的名字,会覆盖(override)父(通道/子通道)中已设置的pass名字。
* @returns @en compute queue builder @zh 计算队列
*/
addQueue (phaseName?: string): ComputeQueueBuilder;
addQueue (phaseName?: string, passName?: string): ComputeQueueBuilder;
/**
* @experimental
*/
Expand Down
10 changes: 7 additions & 3 deletions cocos/rendering/custom/render-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1505,17 +1505,20 @@ export class ClearView {
}

export class RenderQueue {
constructor (hint: QueueHint = QueueHint.RENDER_OPAQUE, phaseID = 0xFFFFFFFF) {
constructor (hint: QueueHint = QueueHint.RENDER_OPAQUE, phaseID = 0xFFFFFFFF, passLayoutID = 0xFFFFFFFF) {
this.hint = hint;
this.phaseID = phaseID;
this.passLayoutID = passLayoutID;
}
reset (hint: QueueHint = QueueHint.RENDER_OPAQUE, phaseID = 0xFFFFFFFF): void {
reset (hint: QueueHint = QueueHint.RENDER_OPAQUE, phaseID = 0xFFFFFFFF, passLayoutID = 0xFFFFFFFF): void {
this.hint = hint;
this.phaseID = phaseID;
this.passLayoutID = passLayoutID;
this.viewport = null;
}
hint: QueueHint;
phaseID: number;
passLayoutID: number;
viewport: Viewport | null = null;
}

Expand Down Expand Up @@ -2840,9 +2843,10 @@ export class RenderGraphObjectPool {
createRenderQueue (
hint: QueueHint = QueueHint.RENDER_OPAQUE,
phaseID = 0xFFFFFFFF,
passLayoutID = 0xFFFFFFFF,
): RenderQueue {
const v = this._renderQueue.add();
v.reset(hint, phaseID);
v.reset(hint, phaseID, passLayoutID);
return v;
}
createSceneData (
Expand Down
6 changes: 3 additions & 3 deletions cocos/rendering/custom/web-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ export class WebRenderSubpassBuilder extends WebSetter implements RenderSubpassB
setViewport (viewport: Viewport): void {
throw new Error('Method not implemented.');
}
addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, layoutName = 'default'): RenderQueueBuilder {
addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, layoutName = 'default', passName = ''): RenderQueueBuilder {
const layoutId = this._lg.locateChild(this._layoutID, layoutName);
if (DEBUG) {
assert(layoutId !== 0xFFFFFFFF);
Expand Down Expand Up @@ -604,7 +604,7 @@ export class WebRenderPassBuilder extends WebSetter implements BasicMultisampleR
result.update(data, this._renderGraph, this._lg, vertID, subpass, this._pipeline);
return result;
}
addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, layoutName = 'default'): WebRenderQueueBuilder {
addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, layoutName = 'default', passName = ''): WebRenderQueueBuilder {
const layoutId = this._lg.locateChild(this._layoutID, layoutName);
if (DEBUG) {
assert(layoutId !== 0xFFFFFFFF);
Expand Down Expand Up @@ -776,7 +776,7 @@ export class WebComputePassBuilder extends WebSetter implements ComputePassBuild
addMaterialTexture (resourceName: string, flags?: ShaderStageFlagBit | undefined): void {
throw new Error('Method not implemented.');
}
addQueue (layoutName = 'default'): WebComputeQueueBuilder {
addQueue (layoutName = 'default', passName = ''): WebComputeQueueBuilder {
const layoutId = this._lg.locateChild(this._layoutID, layoutName);
if (DEBUG) {
assert(layoutId !== 0xFFFFFFFF);
Expand Down
18 changes: 9 additions & 9 deletions native/cocos/renderer/pipeline/custom/NativePipelineTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class NativeRenderSubpassBuilderImpl : public NativeSetter {
void addStorageBuffer(const ccstd::string &name, AccessType accessType, const ccstd::string &slotName) /*implements*/;
void addStorageImage(const ccstd::string &name, AccessType accessType, const ccstd::string &slotName) /*implements*/;
void setViewport(const gfx::Viewport &viewport) /*implements*/;
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName) /*implements*/;
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName, const ccstd::string &passName) /*implements*/;
bool getShowStatistics() const /*implements*/;
void setShowStatistics(bool enable) /*implements*/;
void setCustomShaderStages(const ccstd::string &name, gfx::ShaderStageFlagBit stageFlags) /*implements*/;
Expand Down Expand Up @@ -400,8 +400,8 @@ class NativeRenderSubpassBuilder final : public RenderSubpassBuilder, public Nat
void setViewport(const gfx::Viewport &viewport) override {
NativeRenderSubpassBuilderImpl::setViewport(viewport);
}
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName) override {
return NativeRenderSubpassBuilderImpl::addQueue(hint, phaseName);
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName, const ccstd::string &passName) override {
return NativeRenderSubpassBuilderImpl::addQueue(hint, phaseName, passName);
}
bool getShowStatistics() const override {
return NativeRenderSubpassBuilderImpl::getShowStatistics();
Expand Down Expand Up @@ -511,8 +511,8 @@ class NativeMultisampleRenderSubpassBuilder final : public MultisampleRenderSubp
void setViewport(const gfx::Viewport &viewport) override {
NativeRenderSubpassBuilderImpl::setViewport(viewport);
}
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName) override {
return NativeRenderSubpassBuilderImpl::addQueue(hint, phaseName);
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName, const ccstd::string &passName) override {
return NativeRenderSubpassBuilderImpl::addQueue(hint, phaseName, passName);
}
bool getShowStatistics() const override {
return NativeRenderSubpassBuilderImpl::getShowStatistics();
Expand Down Expand Up @@ -611,7 +611,7 @@ class NativeComputeSubpassBuilder final : public ComputeSubpassBuilder, public N
void addTexture(const ccstd::string &name, const ccstd::string &slotName, gfx::Sampler *sampler, uint32_t plane) override;
void addStorageBuffer(const ccstd::string &name, AccessType accessType, const ccstd::string &slotName) override;
void addStorageImage(const ccstd::string &name, AccessType accessType, const ccstd::string &slotName) override;
ComputeQueueBuilder *addQueue(const ccstd::string &phaseName) override;
ComputeQueueBuilder *addQueue(const ccstd::string &phaseName, const ccstd::string &passName) override;
void setCustomShaderStages(const ccstd::string &name, gfx::ShaderStageFlagBit stageFlags) override;
};

Expand Down Expand Up @@ -697,7 +697,7 @@ class NativeRenderPassBuilder final : public RenderPassBuilder, public NativeSet
void addRenderTarget(const ccstd::string &name, gfx::LoadOp loadOp, gfx::StoreOp storeOp, const gfx::Color &color) override;
void addDepthStencil(const ccstd::string &name, gfx::LoadOp loadOp, gfx::StoreOp storeOp, float depth, uint8_t stencil, gfx::ClearFlagBit clearFlags) override;
void addTexture(const ccstd::string &name, const ccstd::string &slotName, gfx::Sampler *sampler, uint32_t plane) override;
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName) override;
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName, const ccstd::string &passName) override;
void setViewport(const gfx::Viewport &viewport) override;
void setVersion(const ccstd::string &name, uint64_t version) override;
bool getShowStatistics() const override;
Expand Down Expand Up @@ -796,7 +796,7 @@ class NativeMultisampleRenderPassBuilder final : public MultisampleRenderPassBui
void addRenderTarget(const ccstd::string &name, gfx::LoadOp loadOp, gfx::StoreOp storeOp, const gfx::Color &color) override;
void addDepthStencil(const ccstd::string &name, gfx::LoadOp loadOp, gfx::StoreOp storeOp, float depth, uint8_t stencil, gfx::ClearFlagBit clearFlags) override;
void addTexture(const ccstd::string &name, const ccstd::string &slotName, gfx::Sampler *sampler, uint32_t plane) override;
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName) override;
RenderQueueBuilder *addQueue(QueueHint hint, const ccstd::string &phaseName, const ccstd::string &passName) override;
void setViewport(const gfx::Viewport &viewport) override;
void setVersion(const ccstd::string &name, uint64_t version) override;
bool getShowStatistics() const override;
Expand Down Expand Up @@ -977,7 +977,7 @@ class NativeComputePassBuilder final : public ComputePassBuilder, public NativeS
void addStorageBuffer(const ccstd::string &name, AccessType accessType, const ccstd::string &slotName) override;
void addStorageImage(const ccstd::string &name, AccessType accessType, const ccstd::string &slotName) override;
void addMaterialTexture(const ccstd::string &resourceName, gfx::ShaderStageFlagBit flags) override;
ComputeQueueBuilder *addQueue(const ccstd::string &phaseName) override;
ComputeQueueBuilder *addQueue(const ccstd::string &phaseName, const ccstd::string &passName) override;
void setCustomShaderStages(const ccstd::string &name, gfx::ShaderStageFlagBit stageFlags) override;
};

Expand Down
62 changes: 47 additions & 15 deletions native/cocos/renderer/pipeline/custom/NativeRenderGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,17 @@ void NativeRenderSubpassBuilderImpl::setViewport(const gfx::Viewport &viewport)
}

RenderQueueBuilder *NativeRenderSubpassBuilderImpl::addQueue(
QueueHint hint, const ccstd::string &phaseName) {
QueueHint hint, const ccstd::string &phaseName, const ccstd::string &passName) {
CC_EXPECTS(!phaseName.empty());
CC_EXPECTS(layoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(layoutID, phaseName, *layoutGraph);
const auto passLayoutID =
passName.empty()
? layoutID
: locate(LayoutGraphData::null_vertex(), passName, *layoutGraph);
CC_ENSURES(passLayoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(passLayoutID, phaseName, *layoutGraph);
CC_ENSURES(phaseLayoutID != LayoutGraphData::null_vertex());

auto queueID = addVertex2(
Expand All @@ -530,7 +536,7 @@ RenderQueueBuilder *NativeRenderSubpassBuilderImpl::addQueue(
std::forward_as_tuple(phaseName),
std::forward_as_tuple(),
std::forward_as_tuple(),
std::forward_as_tuple(hint, phaseLayoutID),
std::forward_as_tuple(hint, phaseLayoutID, passLayoutID),
*renderGraph, nodeID);

return new NativeRenderQueueBuilder(pipelineRuntime, renderGraph, queueID, layoutGraph, phaseLayoutID);
Expand Down Expand Up @@ -671,11 +677,18 @@ void NativeComputeSubpassBuilder::setCustomShaderStages(
setSubpassResourceShaderStages<ComputeSubpassTag>(*renderGraph, nodeID, name, stageFlags);
}

ComputeQueueBuilder *NativeComputeSubpassBuilder::addQueue(const ccstd::string &phaseName) {
ComputeQueueBuilder *NativeComputeSubpassBuilder::addQueue(
const ccstd::string &phaseName, const ccstd::string &passName) {
CC_EXPECTS(!phaseName.empty());
CC_EXPECTS(layoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(layoutID, phaseName, *layoutGraph);
const auto passLayoutID =
passName.empty()
? layoutID
: locate(LayoutGraphData::null_vertex(), passName, *layoutGraph);
CC_ENSURES(passLayoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(passLayoutID, phaseName, *layoutGraph);
CC_ENSURES(phaseLayoutID != LayoutGraphData::null_vertex());

auto queueID = addVertex2(
Expand All @@ -684,7 +697,7 @@ ComputeQueueBuilder *NativeComputeSubpassBuilder::addQueue(const ccstd::string &
std::forward_as_tuple(phaseName),
std::forward_as_tuple(),
std::forward_as_tuple(),
std::forward_as_tuple(phaseLayoutID),
std::forward_as_tuple(phaseLayoutID, passLayoutID),
*renderGraph, nodeID);

return new NativeComputeQueueBuilder(pipelineRuntime, renderGraph, queueID, layoutGraph, phaseLayoutID);
Expand Down Expand Up @@ -991,11 +1004,17 @@ void NativeRenderQueueBuilder::addCustomCommand(std::string_view customBehavior)
}

RenderQueueBuilder *NativeRenderPassBuilder::addQueue(
QueueHint hint, const ccstd::string &phaseName) {
QueueHint hint, const ccstd::string &phaseName, const ccstd::string &passName) {
CC_EXPECTS(!phaseName.empty());
CC_EXPECTS(layoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(layoutID, phaseName, *layoutGraph);
const auto passLayoutID =
passName.empty()
? layoutID
: locate(LayoutGraphData::null_vertex(), passName, *layoutGraph);
CC_ENSURES(passLayoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(passLayoutID, phaseName, *layoutGraph);
CC_ENSURES(phaseLayoutID != LayoutGraphData::null_vertex());

auto queueID = addVertex2(
Expand All @@ -1004,7 +1023,7 @@ RenderQueueBuilder *NativeRenderPassBuilder::addQueue(
std::forward_as_tuple(phaseName),
std::forward_as_tuple(),
std::forward_as_tuple(),
std::forward_as_tuple(hint, phaseLayoutID),
std::forward_as_tuple(hint, phaseLayoutID, passLayoutID),
*renderGraph, nodeID);

return new NativeRenderQueueBuilder(pipelineRuntime, renderGraph, queueID, layoutGraph, phaseLayoutID);
Expand Down Expand Up @@ -1187,12 +1206,18 @@ void NativeMultisampleRenderPassBuilder::addStorageImage(
}

RenderQueueBuilder *NativeMultisampleRenderPassBuilder::addQueue(
QueueHint hint, const ccstd::string &phaseName) {
QueueHint hint, const ccstd::string &phaseName, const ccstd::string &passName) {
CC_EXPECTS(!phaseName.empty());
CC_EXPECTS(subpassLayoutID == layoutID);
CC_EXPECTS(subpassLayoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(subpassLayoutID, phaseName, *layoutGraph);
const auto passLayoutID =
passName.empty()
? layoutID
: locate(LayoutGraphData::null_vertex(), passName, *layoutGraph);
CC_ENSURES(passLayoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(passLayoutID, phaseName, *layoutGraph);
CC_ENSURES(phaseLayoutID != LayoutGraphData::null_vertex());

auto queueID = addVertex2(
Expand All @@ -1201,7 +1226,7 @@ RenderQueueBuilder *NativeMultisampleRenderPassBuilder::addQueue(
std::forward_as_tuple(phaseName),
std::forward_as_tuple(),
std::forward_as_tuple(),
std::forward_as_tuple(hint, phaseLayoutID),
std::forward_as_tuple(hint, phaseLayoutID, passLayoutID),
*renderGraph, subpassID);

return new NativeRenderQueueBuilder(pipelineRuntime, renderGraph, queueID, layoutGraph, phaseLayoutID);
Expand Down Expand Up @@ -1368,11 +1393,18 @@ void NativeComputePassBuilder::setCustomShaderStages(
}
}

ComputeQueueBuilder *NativeComputePassBuilder::addQueue(const ccstd::string &phaseName) {
ComputeQueueBuilder *NativeComputePassBuilder::addQueue(
const ccstd::string &phaseName, const ccstd::string &passName) {
CC_EXPECTS(!phaseName.empty());
CC_EXPECTS(layoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(layoutID, phaseName, *layoutGraph);
const auto passLayoutID =
passName.empty()
? layoutID
: locate(LayoutGraphData::null_vertex(), passName, *layoutGraph);
CC_ENSURES(passLayoutID != LayoutGraphData::null_vertex());

const auto phaseLayoutID = locate(passLayoutID, phaseName, *layoutGraph);
CC_ENSURES(phaseLayoutID != LayoutGraphData::null_vertex());

auto queueID = addVertex2(
Expand All @@ -1381,7 +1413,7 @@ ComputeQueueBuilder *NativeComputePassBuilder::addQueue(const ccstd::string &pha
std::forward_as_tuple(phaseName),
std::forward_as_tuple(),
std::forward_as_tuple(),
std::forward_as_tuple(QueueHint::NONE, phaseLayoutID),
std::forward_as_tuple(QueueHint::NONE, phaseLayoutID, passLayoutID),
*renderGraph, nodeID);

return new NativeComputeQueueBuilder(pipelineRuntime, renderGraph, queueID, layoutGraph, phaseLayoutID);
Expand Down
11 changes: 7 additions & 4 deletions native/cocos/renderer/pipeline/custom/RenderGraphTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -857,14 +857,17 @@ struct ClearView {

struct RenderQueue {
RenderQueue() = default;
RenderQueue(QueueHint hintIn, uint32_t phaseIDIn) noexcept
RenderQueue(QueueHint hintIn, uint32_t phaseIDIn, uint32_t passLayoutIDIn) noexcept // NOLINT
: hint(hintIn),
phaseID(phaseIDIn) {}
RenderQueue(uint32_t phaseIDIn) noexcept // NOLINT
: phaseID(phaseIDIn) {}
phaseID(phaseIDIn),
passLayoutID(passLayoutIDIn) {}
RenderQueue(uint32_t phaseIDIn, uint32_t passLayoutIDIn) noexcept
: phaseID(phaseIDIn),
passLayoutID(passLayoutIDIn) {}

QueueHint hint{QueueHint::RENDER_OPAQUE};
uint32_t phaseID{0xFFFFFFFF};
uint32_t passLayoutID{0xFFFFFFFF};
gfx::Viewport viewport;
};

Expand Down
Loading
Loading