mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-05 11:02:40 +08:00
70ef983a41
move cocos/core/easing, cocos/core/utils/aotob and cocos/core/utils/murmurhash2_gc to cocos/core/algorithm
99 lines
3.7 KiB
TypeScript
99 lines
3.7 KiB
TypeScript
/*
|
|
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
|
|
|
|
https://www.cocos.com/
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated engine source code (the "Software"), a limited,
|
|
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
|
to use Cocos Creator solely to develop games on your target platforms. You shall
|
|
not use Cocos Creator software for developing other software or tools that's
|
|
used for developing games. You are not granted to publish, distribute,
|
|
sublicense, and/or sell copies of Cocos Creator.
|
|
|
|
The software or tools in this License Agreement are licensed, not sold.
|
|
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
*/
|
|
|
|
import { murmurhash2_32_gc } from '../../core/algorithm/murmurhash2_gc';
|
|
import {
|
|
GFXObject,
|
|
ObjectType,
|
|
ColorAttachment,
|
|
DepthStencilAttachment,
|
|
SubpassInfo,
|
|
RenderPassInfo,
|
|
} from './define';
|
|
|
|
/**
|
|
* @en GFX render pass.
|
|
* @zh GFX 渲染过程。
|
|
*/
|
|
export abstract class RenderPass extends GFXObject {
|
|
protected _colorInfos: ColorAttachment[] = [];
|
|
protected _depthStencilInfo: DepthStencilAttachment | null = null;
|
|
protected _subpasses: SubpassInfo[] = [];
|
|
protected _hash = 0;
|
|
|
|
get colorAttachments () : Readonly<ColorAttachment[]> { return this._colorInfos; }
|
|
get depthStencilAttachment () : Readonly<DepthStencilAttachment> | null { return this._depthStencilInfo; }
|
|
get subPasses () : Readonly<SubpassInfo[]> { return this._subpasses; }
|
|
get hash () { return this._hash; }
|
|
|
|
constructor () {
|
|
super(ObjectType.RENDER_PASS);
|
|
}
|
|
|
|
// Based on render pass compatibility
|
|
protected computeHash (): number {
|
|
let res = '';
|
|
if (this._subpasses.length) {
|
|
for (let i = 0; i < this._subpasses.length; ++i) {
|
|
const subpass = this._subpasses[i];
|
|
if (subpass.inputs.length) {
|
|
res += 'ia';
|
|
for (let j = 0; j < subpass.inputs.length; ++j) {
|
|
const ia = this._colorInfos[subpass.inputs[j]];
|
|
res += `,${ia.format},${ia.sampleCount}`;
|
|
}
|
|
}
|
|
if (subpass.colors.length) {
|
|
res += 'ca';
|
|
for (let j = 0; j < subpass.inputs.length; ++j) {
|
|
const ca = this._colorInfos[subpass.inputs[j]];
|
|
res += `,${ca.format},${ca.sampleCount}`;
|
|
}
|
|
}
|
|
if (subpass.depthStencil >= 0) {
|
|
const ds = this._colorInfos[subpass.depthStencil];
|
|
res += `ds,${ds.format},${ds.sampleCount}`;
|
|
}
|
|
}
|
|
} else {
|
|
res += 'ca';
|
|
for (let i = 0; i < this._colorInfos.length; ++i) {
|
|
const ca = this._colorInfos[i];
|
|
res += `,${ca.format},${ca.sampleCount}`;
|
|
}
|
|
const ds = this._depthStencilInfo;
|
|
if (ds) {
|
|
res += `ds,${ds.format},${ds.sampleCount}`;
|
|
}
|
|
}
|
|
|
|
return murmurhash2_32_gc(res, 666);
|
|
}
|
|
|
|
public abstract initialize (info: Readonly<RenderPassInfo>): void;
|
|
|
|
public abstract destroy (): void;
|
|
}
|