Fix pass hash when blend change (#12294)

Co-authored-by: ChiaNing <sun.clooud.mo@gmail.com>
This commit is contained in:
ChiaNing
2022-08-02 16:05:24 +08:00
committed by GitHub
parent 88d059ae44
commit 985f4fd94c
5 changed files with 15 additions and 2 deletions
+4 -1
View File
@@ -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;
}
+5
View File
@@ -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; }
+4
View File
@@ -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);
}
+1
View File
@@ -298,6 +298,7 @@ public:
// Only for UI
void initPassFromTarget(Pass *target, const gfx::DepthStencilState &dss, ccstd::hash_t hashFactor);
void updatePassHash();
// internal use
/**
+1 -1
View File
@@ -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],