Skip to content
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
5 changes: 4 additions & 1 deletion cocos/2d/renderer/batcher-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,10 @@ class DescriptorSetCache {
if (this._descriptorSetCache.has(hash)) {
return this._descriptorSetCache.get(hash)!;
} else {
_dsInfo.layout = batch.passes[0].localSetLayout;
const ly = batch.passes[0].localSetLayout;
if (ly) {
_dsInfo.layout = ly;
}
const descriptorSet = root.device.createDescriptorSet(_dsInfo) as DescriptorSet;
const binding = ModelLocalBindings.SAMPLER_SPRITE;
descriptorSet.bindTexture(binding, batch.texture!);
Expand Down
5 changes: 4 additions & 1 deletion cocos/core/pipeline/deferred/lighting-stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ export class LightingStage extends RenderStage {
const deferredLitsBufView = device.createBuffer(new BufferViewInfo(this._deferredLitsBufs, 0, totalSize));
this._lightBufferData = new Float32Array(totalSize / Float32Array.BYTES_PER_ELEMENT);

this._descriptorSet = device.createDescriptorSet(new DescriptorSetInfo(pass.localSetLayout));
const ly = pass.localSetLayout;
if (ly) {
this._descriptorSet = device.createDescriptorSet(new DescriptorSetInfo(ly));
}
this._descriptorSet.bindBuffer(UBOForwardLight.BINDING, deferredLitsBufView);

const _localUBO = device.createBuffer(new BufferInfo(
Expand Down
5 changes: 4 additions & 1 deletion cocos/core/pipeline/deferred/postprocess-stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ export class PostProcessStage extends RenderStage {
const renderObjects = pipeline.pipelineSceneData.renderObjects;
if (pso != null && renderObjects.length > 0) {
if (!this._stageDesc) {
this._stageDesc = device.createDescriptorSet(new DescriptorSetInfo(pass.localSetLayout));
const ly = pass.localSetLayout;
if (ly) {
this._stageDesc = device.createDescriptorSet(new DescriptorSetInfo(ly));
}
this._localUBO = device.createBuffer(new BufferInfo(
BufferUsageBit.UNIFORM | BufferUsageBit.TRANSFER_DST,
MemoryUsageBit.DEVICE,
Expand Down
7 changes: 5 additions & 2 deletions cocos/core/renderer/core/pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,10 @@ export class Pass {
if (director.root.usesCustomPipeline) {
const root = legacyCC.director.root;
const ppl: Pipeline = root.customPipeline;
_dsInfo.layout = ppl.getDescriptorSetLayout(info.program, UpdateFrequency.PER_BATCH);
const ds = ppl.getDescriptorSetLayout(info.program, UpdateFrequency.PER_BATCH);
if (ds) {
_dsInfo.layout = ds;
}
} else {
_dsInfo.layout = programLib.getDescriptorSetLayout(this._device, info.program);
}
Expand Down Expand Up @@ -670,7 +673,7 @@ export class Pass {
get root (): Root { return this._root; }
get device (): Device { return this._device; }
get shaderInfo (): IProgramInfo { return this._shaderInfo; }
get localSetLayout (): DescriptorSetLayout {
get localSetLayout (): DescriptorSetLayout | null {
const director = legacyCC.director;
if (director.root.usesCustomPipeline) {
const root = legacyCC.director.root;
Expand Down
15 changes: 12 additions & 3 deletions cocos/core/renderer/scene/submodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export class SubModel {
// DS layout might change too
if (this._descriptorSet) {
this._descriptorSet.destroy();
_dsInfo.layout = passes[0].localSetLayout;
const ly = passes[0].localSetLayout;
if (ly) {
_dsInfo.layout = ly;
}
this._descriptorSet = this._device!.createDescriptorSet(_dsInfo);
}
}
Expand Down Expand Up @@ -187,15 +190,21 @@ export class SubModel {
public initialize (subMesh: RenderingSubMesh, passes: Pass[], patches: IMacroPatch[] | null = null): void {
const root = legacyCC.director.root as Root;
this._device = root.device;
_dsInfo.layout = passes[0].localSetLayout;
const ly = passes[0].localSetLayout;
if (ly) {
_dsInfo.layout = ly;
}

this._inputAssembler = this._device.createInputAssembler(subMesh.iaInfo);
this._descriptorSet = this._device.createDescriptorSet(_dsInfo);

const pipeline = (legacyCC.director.root as Root).pipeline;
const occlusionPass = pipeline.pipelineSceneData.getOcclusionQueryPass()!;
const occlusionDSInfo = new DescriptorSetInfo(null!);
occlusionDSInfo.layout = occlusionPass.localSetLayout;
const oly = occlusionPass.localSetLayout;
if (oly) {
occlusionDSInfo.layout = oly;
}
this._worldBoundDescriptorSet = this._device.createDescriptorSet(occlusionDSInfo);
this._subMesh = subMesh;
this._patches = patches;
Expand Down