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

Fix the issue where the "Custom" pipeline cannot use post-processing in WebGL 1.0. #17600

Merged
merged 1 commit into from
Sep 4, 2024
Merged
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
57 changes: 40 additions & 17 deletions cocos/rendering/custom/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,18 +486,6 @@ class DescBuffManager {

const buffsMap: Map<string, DescBuffManager> = new Map();
const currBindBuffs: Map<string, number> = new Map();
function updateGlobalDescBuffer (blockId: number, sceneId: number, idxRD: number, vals: number[], setData: DescriptorSetData): void {
const bindId = getDescBinding(blockId, setData);
if (bindId === -1) { return; }
const descKey = `${blockId}${bindId}${idxRD}${sceneId}`;
currBindBuffs.set(descKey, bindId);
let currDescBuff = buffsMap.get(descKey);
if (!currDescBuff) {
buffsMap.set(descKey, new DescBuffManager(vals.length * 4, 2));
currDescBuff = buffsMap.get(descKey);
}
currDescBuff!.updateData(vals);
}

const layouts: Map<string, DescriptorSetData> = new Map();
export function getDescriptorSetDataFromLayout (layoutName: string): DescriptorSetData | undefined {
Expand Down Expand Up @@ -591,6 +579,43 @@ function addConstantBuffer (block: string, layout: string): number[] | null {
uniformBlockMap.set(block, buffers);
return buffers;
}

function updateGlobalDescBuffer (descKey: string, vals: number[]): void {
let currDescBuff = buffsMap.get(descKey);
if (!currDescBuff) {
buffsMap.set(descKey, new DescBuffManager(vals.length * 4, 2));
currDescBuff = buffsMap.get(descKey);
}
currDescBuff!.updateData(vals);
}

function updateConstantBlock (
constantBuff: ConstantBlockInfo,
data: number[],
descriptorSetData: DescriptorSetData,
sceneId: number,
idxRD: number,
): void {
const blockId = constantBuff.blockId;
const buffer = constantBuff.buffer;
const isImparity = copyToConstantBuffer(buffer, data, constantBuff.offset);
const bindId = getDescBinding(blockId, descriptorSetData);
const desc = descriptorSetData.descriptorSet!;
if (isImparity || !desc.getBuffer(bindId) && bindId !== -1) {
const descKey = `${blockId}${bindId}${idxRD}${sceneId}`;
currBindBuffs.set(descKey, bindId);
updateGlobalDescBuffer(descKey, buffer);
}
}

function updateDefaultConstantBlock (blockId: number, sceneId: number, idxRD: number, vals: number[], setData: DescriptorSetData): void {
const bindId = getDescBinding(blockId, setData);
if (bindId === -1) { return; }
const descKey = `${blockId}${bindId}${idxRD}${sceneId}`;
currBindBuffs.set(descKey, bindId);
updateGlobalDescBuffer(descKey, vals);
}

export function updatePerPassUBO (layout: string, sceneId: number, idxRD: number, user: RenderData): void {
const constantMap = user.constants;
const samplers = user.samplers;
Expand All @@ -612,20 +637,18 @@ export function updatePerPassUBO (layout: string, sceneId: number, idxRD: number
if (offset === -1) {
// Although the current uniformMem does not belong to the current uniform block,
// it does not mean that it should not be bound to the corresponding descriptor.
updateGlobalDescBuffer(blockId, sceneId, idxRD, constantBuff, descriptorSetData);
updateDefaultConstantBlock(blockId, sceneId, idxRD, constantBuff, descriptorSetData);
continue;
}
constantBlockMap.set(key, new ConstantBlockInfo());
constantBlock = constantBlockMap.get(key)!;
constantBlock.buffer = constantBuff;
constantBlock.blockId = blockId;
constantBlock.offset = offset;
const isImparity = copyToConstantBuffer(constantBuff, data, offset);
if (isImparity) updateGlobalDescBuffer(blockId, sceneId, idxRD, constantBuff, descriptorSetData);
updateConstantBlock(constantBlock, data, descriptorSetData, sceneId, idxRD);
}
} else {
const isImparity = copyToConstantBuffer(constantBlock.buffer, data, constantBlock.offset);
if (isImparity) updateGlobalDescBuffer(constantBlock.blockId, sceneId, idxRD, constantBlock.buffer, descriptorSetData);
updateConstantBlock(constantBlock, data, descriptorSetData, sceneId, idxRD);
}
}

Expand Down
Loading