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

[Fixed] sampler synchronization issues with compute view texture #16318

Merged
merged 1 commit into from
Sep 22, 2023
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
65 changes: 31 additions & 34 deletions cocos/rendering/custom/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,55 +584,52 @@ class SubmitInfo {

class RenderPassLayoutInfo {
protected _layoutID = 0;
protected _vertID = -1;
protected _stage: RenderStageData | null = null;
protected _layout: PipelineLayoutData;
protected _inputName: string;
protected _descriptorSet: DescriptorSet | null = null;
constructor (layoutId: number, input: [string, ComputeView[]]) {
constructor (layoutId: number, vertId: number, input: [string, ComputeView[]]) {
this._inputName = input[0];
this._layoutID = layoutId;
this._vertID = vertId;
const lg = context.layoutGraph;
this._stage = lg.getRenderStage(layoutId);
this._layout = lg.getLayout(layoutId);
const layoutData = this._layout.descriptorSets.get(UpdateFrequency.PER_PASS);
const globalDesc = context.pipeline.descriptorSet;
if (layoutData) {
// find resource
const deviceTex = context.deviceTextures.get(this._inputName);
const gfxTex = deviceTex?.texture;
const layoutDesc = layoutData.descriptorSet!;
if (!gfxTex) {
throw Error(`Could not find texture with resource name ${this._inputName}`);
}
const resId = context.resourceGraph.vertex(this._inputName);
const samplerInfo = context.resourceGraph.getSampler(resId);
// bind descriptors
for (const descriptor of input[1]) {
const descriptorName = descriptor.name;
const descriptorID = lg.attributeIndex.get(descriptorName);
// find descriptor binding
for (const block of layoutData.descriptorSetLayoutData.descriptorBlocks) {
for (let i = 0; i !== block.descriptors.length; ++i) {
// const buffer = layoutDesc.getBuffer(block.offset + i);
// const texture = layoutDesc.getTexture(block.offset + i);
if (descriptorID === block.descriptors[i].descriptorID) {
layoutDesc.bindTexture(block.offset + i, gfxTex);
layoutDesc.bindSampler(block.offset + i, context.device.getSampler(samplerInfo));
if (!this._descriptorSet) this._descriptorSet = layoutDesc;
continue;
}
// if (!buffer && !texture) {
// layoutDesc.bindBuffer(block.offset + i, globalDesc.getBuffer(block.offset + i));
// layoutDesc.bindTexture(block.offset + i, globalDesc.getTexture(block.offset + i));
// layoutDesc.bindSampler(block.offset + i, globalDesc.getSampler(block.offset + i));
// }
const layoutData = this._layout.descriptorSets.get(UpdateFrequency.PER_PASS);
if (!layoutData) {
return;
}
const layoutDesc = layoutData.descriptorSet!;
// find resource
const deviceTex = context.deviceTextures.get(this._inputName);
const gfxTex = deviceTex?.texture;
if (!gfxTex) {
throw Error(`Could not find texture with resource name ${this._inputName}`);
}
const resId = context.resourceGraph.vertex(this._inputName);
const samplerInfo = context.resourceGraph.getSampler(resId);
// bind descriptors
for (const descriptor of input[1]) {
const descriptorName = descriptor.name;
const descriptorID = lg.attributeIndex.get(descriptorName);
// find descriptor binding
for (const block of layoutData.descriptorSetLayoutData.descriptorBlocks) {
for (let i = 0; i !== block.descriptors.length; ++i) {
if (descriptorID === block.descriptors[i].descriptorID) {
layoutDesc.bindTexture(block.offset + i, gfxTex);
const renderData = context.renderGraph.getData(this._vertID);
layoutDesc.bindSampler(block.offset + i, renderData.samplers.get(descriptorID) || context.device.getSampler(samplerInfo));
if (!this._descriptorSet) this._descriptorSet = layoutDesc;
continue;
}
}
}
}
}
get descriptorSet (): DescriptorSet | null { return this._descriptorSet; }
get layoutID (): number { return this._layoutID; }
get vertID (): number { return this._vertID; }
get stage (): RenderStageData | null { return this._stage; }
get layout (): PipelineLayoutData { return this._layout; }
}
Expand Down Expand Up @@ -842,7 +839,7 @@ class DeviceRenderPass {
const layoutGraph = context.layoutGraph;
const stageId = layoutGraph.locateChild(layoutGraph.nullVertex(), stageName);
if (stageId !== 0xFFFFFFFF) {
this._layout = new RenderPassLayoutInfo(stageId, input);
this._layout = new RenderPassLayoutInfo(stageId, this.rasterPassInfo.id, input);
}
}
}
Expand Down