Skip to content

Commit

Permalink
filter non default pass
Browse files Browse the repository at this point in the history
  • Loading branch information
star-e committed Oct 16, 2024
1 parent 408425c commit 734828d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions EngineErrorMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -3339,6 +3339,10 @@ Custom pipeline invalid render phase, program: %s. Please reimport all effects (

custom-pipeline module not available.

### 12110

MaterialPass passID in legacy pipeline is wrongly initialized.

### 13100

Incorrect CCON magic.
Expand Down
13 changes: 13 additions & 0 deletions cocos/render-scene/core/pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,19 @@ export class Pass {
errorID(12108, info.program);
return;
}
} else {
// Here we are in legacy-pipeline
// eslint-disable-next-line no-lonely-if
if (typeof info.phase === 'number') {
this._passID = (info as Pass)._passID;
} else if (info.pass && info.pass !== 'default') {
// In legacy pipeline, user might select invalid material,
// whose pass name is not 'default'.
// We should filter these passes.
// Here we set _passID to 0, if pass is not 'default'.
assertID(this._passID === 0xFFFFFFFF, 12110);
this._passID = 0;
}
}
this._phase = getPhaseID('default');
this._primitive = PrimitiveMode.TRIANGLE_LIST;
Expand Down
1 change: 1 addition & 0 deletions cocos/rendering/forward/forward-stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export class ForwardStage extends RenderStage {
for (p = 0; p < passes.length; ++p) {
const pass = passes[p];
if (pass.phase !== this._phaseID) continue;
if (pass.passID !== 0xFFFFFFFF) continue;
const batchingScheme = pass.batchingScheme;
if (batchingScheme === BatchingSchemes.INSTANCING) {
const instancedBuffer = pass.getInstancedBuffer();
Expand Down
1 change: 1 addition & 0 deletions native/cocos/renderer/pipeline/forward/ForwardStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void ForwardStage::dispenseRenderObject2Queues() {
for (uint32_t passIdx = 0; passIdx < passCount; ++passIdx) {
const auto &pass = passes[passIdx];
if (pass->getPhase() != _phaseID) continue;
if (pass->getPassID() != 0xFFFFFFFF) continue;
if (pass->getBatchingScheme() == scene::BatchingSchemes::INSTANCING) {
auto *instancedBuffer = pass->getInstancedBuffer();
instancedBuffer->merge(subModel, passIdx);
Expand Down
14 changes: 14 additions & 0 deletions native/cocos/scene/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,20 @@ void Pass::doInit(const IPassInfoFull &info, bool /*copyDefines*/ /* = false */)
CC_LOG_ERROR("Invalid phase ID");
return;
}
} else {
// Here we are in legacy-pipeline
if (info.phaseID != INVALID_ID) {
_passID = info.passID;
} else {
if (info.pass && *info.pass != "default") {
// In legacy pipeline, user might select invalid material,
// whose pass name is not 'default'.
// We should filter these passes.
// Here we set _passID to 0, if pass is not 'default'.
CC_ASSERT(_passID == INVALID_ID);
_passID = 0;
}
}
}
_phaseString = "default";
_phase = pipeline::getPhaseID(_phaseString);
Expand Down

0 comments on commit 734828d

Please sign in to comment.