mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Fix pass hash when blend change (#12294)
Co-authored-by: ChiaNing <sun.clooud.mo@gmail.com>
This commit is contained in:
@@ -489,7 +489,10 @@ export class UIRenderer extends Renderer {
|
||||
target.blendDstAlpha = BlendFactor.ONE_MINUS_SRC_ALPHA;
|
||||
target.blendDst = this._dstBlendFactor;
|
||||
target.blendSrc = this._srcBlendFactor;
|
||||
this.getMaterialInstance(0)!.passes[0].blendState.setTarget(0, target);
|
||||
const targetPass = this.getMaterialInstance(0)!.passes[0];
|
||||
targetPass.blendState.setTarget(0, target);
|
||||
// @ts-expect-error hack for UI use pass object
|
||||
targetPass._updatePassHash();
|
||||
this._dstBlendFactorCache = this._dstBlendFactor;
|
||||
this._srcBlendFactorCache = this._srcBlendFactor;
|
||||
}
|
||||
|
||||
@@ -656,6 +656,11 @@ export class Pass {
|
||||
this._hash = target._hash ^ hashFactor;
|
||||
}
|
||||
|
||||
// Only for UI
|
||||
private _updatePassHash () {
|
||||
this._hash = Pass.getPassHash(this);
|
||||
}
|
||||
|
||||
// infos
|
||||
get root (): Root { return this._root; }
|
||||
get device (): Device { return this._device; }
|
||||
|
||||
@@ -656,6 +656,10 @@ void Pass::initPassFromTarget(Pass *target, const gfx::DepthStencilState &dss, c
|
||||
_hash = target->_hash ^ hashFactor;
|
||||
}
|
||||
|
||||
void Pass::updatePassHash() {
|
||||
_hash = Pass::getPassHash(this);
|
||||
}
|
||||
|
||||
gfx::DescriptorSetLayout *Pass::getLocalSetLayout() const {
|
||||
return ProgramLib::getInstance()->getDescriptorSetLayout(_device, _programName, true);
|
||||
}
|
||||
|
||||
@@ -298,6 +298,7 @@ public:
|
||||
|
||||
// Only for UI
|
||||
void initPassFromTarget(Pass *target, const gfx::DepthStencilState &dss, ccstd::hash_t hashFactor);
|
||||
void updatePassHash();
|
||||
|
||||
// internal use
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,7 @@ rename_functions = Root::[initialize=_initialize],
|
||||
ProgramLib::[registerEffect=register],
|
||||
Model::[initLocalDescriptors=_initLocalDescriptors updateLocalDescriptors=_updateLocalDescriptors updateInstancedAttributes=_updateInstancedAttributes getInstancedAttributeIndex=_getInstancedAttributeIndex],
|
||||
Scene::[load=_load activate=_activate],
|
||||
Pass::[initPassFromTarget=_initPassFromTarget]
|
||||
Pass::[initPassFromTarget=_initPassFromTarget updatePassHash=_updatePassHash]
|
||||
|
||||
getter_setter = Root::[device:_device mainWindow curWindow tempWindow windows scenes cumulativeTime frameTime frameCount fps fixedFPS useDeferredPipeline/isUsingDeferredPipeline usesCustomPipeline/usesCustomPipeline pipeline customPipeline],
|
||||
RenderWindow::[width height framebuffer cameras swapchain],
|
||||
|
||||
Reference in New Issue
Block a user