Skip to content

Commit

Permalink
Revert "Fix the display of WebGPU under the new pipeline with CSM, re…
Browse files Browse the repository at this point in the history
…solve the conflict between binding and render attachment, and optimize the memory pool. (cocos#17562)"

This reverts commit 3dfdc02.
  • Loading branch information
star-e committed Aug 21, 2024
1 parent 3dfdc02 commit 2fb742a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
4 changes: 2 additions & 2 deletions cocos/rendering/custom/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export function updatePerPassUBO (layout: string, sceneId: number, user: RenderD
const bindId = getDescBinding(key, descriptorSetData);
if (bindId === -1) { continue; }
const tex = descriptorSet.getTexture(bindId);
if (tex !== value
if (!tex || value !== webPip.defaultShadowTexture
// @ts-ignore
|| (!tex.gpuTexture && !(tex.gpuTextureView && tex.gpuTextureView.gpuTexture))) {
bindGlobalDesc(descriptorSet, bindId, value);
Expand All @@ -654,7 +654,7 @@ export function updatePerPassUBO (layout: string, sceneId: number, user: RenderD
const bindId = getDescBinding(key, descriptorSetData);
if (bindId === -1) { continue; }
const sampler = descriptorSet.getSampler(bindId);
if (sampler !== value) {
if (!sampler || value !== webPip.defaultSampler) {
bindGlobalDesc(descriptorSet, bindId, value);
}
}
Expand Down
45 changes: 21 additions & 24 deletions cocos/rendering/custom/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,10 @@ class RenderPassLayoutInfo {
protected _layoutID = 0;
protected _vertID = -1;
protected _stage: RenderStageData | null = null;
protected _layout!: PipelineLayoutData;
protected _inputName!: string;
protected _layout: PipelineLayoutData;
protected _inputName: string;
protected _descriptorSet: DescriptorSet | null = null;
init (layoutId: number, vertId: number, input: [string, ComputeView[]]): void {
constructor (layoutId: number, vertId: number, input: [string, ComputeView[]]) {
this._inputName = input[0];
this._layoutID = layoutId;
this._vertID = vertId;
Expand Down Expand Up @@ -820,6 +820,13 @@ class DeviceRenderPass implements RecordingInterface {
let depthTex: Texture | null = null;
let swapchain: Swapchain | null = null;
let framebuffer: Framebuffer | null = null;
for (const cv of passInfo.pass.computeViews) {
this._applyRenderLayout(cv);
}
// update the layout descriptorSet
if (this.renderLayout && this.renderLayout.descriptorSet) {
this.renderLayout.descriptorSet.update();
}
for (const [resName, rasterV] of passInfo.pass.rasterViews) {
let resTex = context.deviceTextures.get(resName);
if (!resTex) {
Expand Down Expand Up @@ -913,15 +920,6 @@ class DeviceRenderPass implements RecordingInterface {
get deviceQueues (): Map<number, DeviceRenderQueue> { return this._deviceQueues; }
get rasterPassInfo (): RasterPassInfo { return this._rasterInfo; }
get viewport (): Viewport | null { return this._viewport; }
setRenderLayoutView (): void {
for (const cv of this.rasterPassInfo.pass.computeViews) {
this._applyRenderLayout(cv);
}
// update the layout descriptorSet
if (this.renderLayout && this.renderLayout.descriptorSet) {
this.renderLayout.descriptorSet.update();
}
}
visitResource (resName: string): void {
const resourceGraph = context.resourceGraph;
const vertId = resourceGraph.vertex(resName);
Expand All @@ -940,8 +938,7 @@ class DeviceRenderPass implements RecordingInterface {
const layoutGraph = context.layoutGraph;
const stageId = layoutGraph.locateChild(layoutGraph.N, stageName);
if (stageId !== 0xFFFFFFFF) {
this._layout = context.pools.addRenderPassLayout();
this._layout.init(stageId, this.rasterPassInfo.id, input);
this._layout = new RenderPassLayoutInfo(stageId, this.rasterPassInfo.id, input);
}
}
}
Expand Down Expand Up @@ -1048,6 +1045,14 @@ class DeviceRenderPass implements RecordingInterface {
const currFramebuffer = this._framebuffer;
const currFBDepthTex = currFramebuffer.depthStencilTexture;
let depTexture = currFramebuffer ? currFBDepthTex : null;
for (const cv of this._rasterInfo.pass.computeViews) {
this._applyRenderLayout(cv);
}
// update the layout descriptorSet
if (this.renderLayout && this.renderLayout.descriptorSet) {
this.renderLayout.descriptorSet.update();
}

const resGraph = context.resourceGraph;
const currentWidth = currFramebuffer ? currFramebuffer.width : 0;
const currentHeight = currFramebuffer ? currFramebuffer.height : 0;
Expand Down Expand Up @@ -1203,8 +1208,7 @@ class DeviceComputePass implements RecordingInterface {
const layoutGraph = context.layoutGraph;
const stageId = layoutGraph.locateChild(layoutGraph.N, stageName);
if (stageId !== 0xFFFFFFFF) {
this._layout = context.pools.addRenderPassLayout();
this._layout.init(stageId, this._computeInfo.id, input);
this._layout = new RenderPassLayoutInfo(stageId, this._computeInfo.id, input);
}
}
}
Expand Down Expand Up @@ -1327,7 +1331,7 @@ class DeviceRenderScene implements RecordingInterface {
const queueId = this._currentQueue.queueId;
const queueRenderData = context.renderGraph.getData(queueId)!;
this._updateGlobal(queueRenderData, this.graphScene.sceneID);
devicePass.setRenderLayoutView();

this._currentQueue.isUpdateUBO = true;

const batches = this.camera!.scene!.batches;
Expand Down Expand Up @@ -1405,7 +1409,6 @@ class DeviceRenderScene implements RecordingInterface {
this._updateGlobal(queueRenderData, sceneId);
const sceneRenderData = context.renderGraph.getData(sceneId)!;
if (sceneRenderData) this._updateGlobal(sceneRenderData, sceneId);
devicePass.setRenderLayoutView();
this._currentQueue.isUpdateUBO = true;
}

Expand Down Expand Up @@ -1464,7 +1467,6 @@ class ExecutorPools {
this.deviceScenePool = new RecyclePool<DeviceRenderScene>((): DeviceRenderScene => new DeviceRenderScene(), 16);
this.computeQueuePool = new RecyclePool<DeviceComputeQueue>((): DeviceComputeQueue => new DeviceComputeQueue(), 16);
this.graphScenePool = new RecyclePool<GraphScene>((): GraphScene => new GraphScene(), 16);
this.renderPassLayoutPool = new RecyclePool<RenderPassLayoutInfo>((): RenderPassLayoutInfo => new RenderPassLayoutInfo(), 16);
this.rasterPassInfoPool = new RecyclePool<RasterPassInfo>((): RasterPassInfo => new RasterPassInfo(), 16);
this.computePassInfoPool = new RecyclePool<ComputePassInfo>((): ComputePassInfo => new ComputePassInfo(), 16);
this.passPool = new RecyclePool<IRenderPass>((): { priority: number; hash: number; depth: number; shaderId: number; subModel: any; passIdx: number; } => ({
Expand All @@ -1476,9 +1478,6 @@ class ExecutorPools {
passIdx: 0,
}), 64);
}
addRenderPassLayout (): RenderPassLayoutInfo {
return this.renderPassLayoutPool.add();
}
addDeviceQueue (): DeviceRenderQueue {
return this.deviceQueuePool.add();
}
Expand All @@ -1503,7 +1502,6 @@ class ExecutorPools {
this.graphScenePool.reset();
this.computePassInfoPool.reset();
this.deviceScenePool.reset();
this.renderPassLayoutPool.reset();
}
readonly deviceQueuePool: RecyclePool<DeviceRenderQueue>;
readonly computeQueuePool: RecyclePool<DeviceComputeQueue>;
Expand All @@ -1512,7 +1510,6 @@ class ExecutorPools {
readonly rasterPassInfoPool: RecyclePool<RasterPassInfo>;
readonly computePassInfoPool: RecyclePool<ComputePassInfo>;
readonly deviceScenePool: RecyclePool<DeviceRenderScene>;
readonly renderPassLayoutPool: RecyclePool<RenderPassLayoutInfo>;
}

const vbData = new Float32Array(4 * 4);
Expand Down

0 comments on commit 2fb742a

Please sign in to comment.