diff --git a/.eslintrc.yaml b/.eslintrc.yaml index b4c45b3bc5..9eb97b5cfc 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -94,6 +94,7 @@ rules: one-var-declaration-per-line: off # auto-fix has order issues with `one-var` prefer-destructuring: off # auto-fix is not smart enough to merge different instances linebreak-style: off # we don't enforce this on everyone's dev environment for now + spaced-comment: off # for license declarations ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES ##### diff --git a/@types/webGL.extras.d.ts b/@types/webGL.extras.d.ts index 269d7966fe..77070521b3 100644 --- a/@types/webGL.extras.d.ts +++ b/@types/webGL.extras.d.ts @@ -1,3 +1,30 @@ +interface WEBGL_multi_draw { + multiDrawArraysWEBGL(mode: GLenum, + firstsList: GLint[] | Int32Array, firstsOffset: GLuint, + countsList: GLsizei[] | Int32Array, countsOffset: GLuint, + drawCount: GLsizei + ): void; + multiDrawElementsWEBGL(mode: GLenum, + countsList: GLint[] | Int32Array, countsOffset: GLuint, + type: GLenum, + offsetsList: GLsizei[] | Int32Array, OffsetsOffset: GLuint, + drawCount: GLsizei + ): void; + multiDrawArraysInstancedWEBGL(mode: GLenum, + firstsList: GLint[] | Int32Array, firstsOffset: GLuint, + countsList: GLsizei[] | Int32Array, countsOffset: GLuint, + instanceCountsList: GLsizei[] | Int32Array, instanceCountsOffset: GLuint, + drawCount: GLsizei + ): void; + multiDrawElementsInstancedWEBGL(mode: GLenum, + countsList: GLint[] | Int32Array, countsOffset: GLuint, + type: GLenum, + offsetsList: GLsizei[] | Int32Array, OffsetsOffset: GLuint, + instanceCountsList: GLsizei[] | Int32Array, instanceCountsOffset: GLuint, + drawCount: GLsizei + ): void; +} + interface EXT_color_buffer_half_float { readonly RGBA16F_EXT: GLenum; readonly RGB16F_EXT: GLenum; @@ -28,4 +55,4 @@ interface WEBGL_compressed_texture_pvrtc { readonly COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: GLenum; readonly COMPRESSED_RGB_PVRTC_2BPPV1_IMG: GLenum; readonly COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: GLenum; -} \ No newline at end of file +} diff --git a/cocos/2d/assets/sprite-frame.ts b/cocos/2d/assets/sprite-frame.ts index fcae04d471..b91199c50c 100644 --- a/cocos/2d/assets/sprite-frame.ts +++ b/cocos/2d/assets/sprite-frame.ts @@ -681,8 +681,8 @@ export class SpriteFrame extends Asset { * @en Gets the sampler hash of its texture * @zh 贴图资源的采样器哈希值 */ - public getSamplerHash () { - return this._texture.getSamplerHash(); + public getSamplerInfo () { + return this._texture.getSamplerInfo(); } /** diff --git a/cocos/2d/renderer/batcher-2d.ts b/cocos/2d/renderer/batcher-2d.ts index 50f02d243c..3d0d786382 100644 --- a/cocos/2d/renderer/batcher-2d.ts +++ b/cocos/2d/renderer/batcher-2d.ts @@ -31,7 +31,8 @@ import { Camera, Model } from 'cocos/core/renderer/scene'; import { UIStaticBatch } from '../components'; import { Material } from '../../core/assets/material'; import { RenderRoot2D, Renderable2D, UIComponent } from '../framework'; -import { Texture, Device, Attribute, Sampler, DescriptorSetInfo, Buffer, BufferInfo, BufferUsageBit, MemoryUsageBit, DescriptorSet } from '../../core/gfx'; +import { Texture, Device, Attribute, Sampler, DescriptorSetInfo, Buffer, + BufferInfo, BufferUsageBit, MemoryUsageBit, DescriptorSet } from '../../core/gfx'; import { Pool, RecyclePool } from '../../core/memop'; import { CachedArray } from '../../core/memop/cached-array'; import { RenderScene } from '../../core/renderer/scene/render-scene'; @@ -47,8 +48,6 @@ import { SpriteFrame } from '../assets'; import { TextureBase } from '../../core/assets/texture-base'; import { sys } from '../../core/platform/sys'; import { Mat4 } from '../../core/math'; -import { value } from '../../core/utils/js-typed'; -import { NativeDrawBatch2D } from '../../core/renderer/scene'; const _dsInfo = new DescriptorSetInfo(null!); const m4_1 = new Mat4(); @@ -150,7 +149,6 @@ export class Batcher2D { private _currComponent: Renderable2D | null = null; private _currTransform: Node | null = null; private _currTextureHash = 0; - private _currSamplerHash = 0; private _currBlendTargetHash = 0; private _currLayer = 0; private _currDepthStencilStateStage: any | null = null; @@ -375,12 +373,10 @@ export class Batcher2D { let texture; let samp; let textureHash = 0; - let samplerHash = 0; if (frame) { texture = frame.getGFXTexture(); samp = frame.getGFXSampler(); textureHash = frame.getHash(); - samplerHash = frame.getSamplerHash(); } else { texture = null; samp = null; @@ -395,7 +391,7 @@ export class Batcher2D { if (this._currScene !== renderScene || this._currLayer !== comp.node.layer || this._currMaterial !== mat || this._currBlendTargetHash !== blendTargetHash || this._currDepthStencilStateStage !== depthStencilStateStage - || this._currTextureHash !== textureHash || this._currSamplerHash !== samplerHash || this._currTransform !== transform) { + || this._currTextureHash !== textureHash || this._currSampler !== samp || this._currTransform !== transform) { this.autoMergeBatches(this._currComponent!); this._currScene = renderScene; this._currComponent = renderComp; @@ -404,7 +400,6 @@ export class Batcher2D { this._currTexture = texture; this._currSampler = samp; this._currTextureHash = textureHash; - this._currSamplerHash = samplerHash; this._currBlendTargetHash = blendTargetHash; this._currDepthStencilStateStage = depthStencilStateStage; this._currLayer = comp.node.layer; @@ -477,7 +472,6 @@ export class Batcher2D { this._currTexture = null; this._currSampler = null; this._currTextureHash = 0; - this._currSamplerHash = 0; this._currLayer = 0; } @@ -533,7 +527,6 @@ export class Batcher2D { curDrawBatch.inputAssembler = ia; curDrawBatch.useLocalData = this._currTransform; curDrawBatch.textureHash = this._currTextureHash; - curDrawBatch.samplerHash = this._currSamplerHash; curDrawBatch.fillPasses(mat, depthStencil, dssHash, blendState, bsHash, null); this._batches.push(curDrawBatch); @@ -567,10 +560,9 @@ export class Batcher2D { this._currTexture = frame.getGFXTexture(); this._currSampler = frame.getGFXSampler(); this._currTextureHash = frame.getHash(); - this._currSamplerHash = frame.getSamplerHash(); } else { this._currTexture = this._currSampler = null; - this._currTextureHash = this._currSamplerHash = 0; + this._currTextureHash = 0; } this._currLayer = renderComp.node.layer; this._currScene = renderComp._getRenderScene(); @@ -592,7 +584,6 @@ export class Batcher2D { this._currComponent = null; this._currTransform = null; this._currTextureHash = 0; - this._currSamplerHash = 0; this._currLayer = 0; } diff --git a/cocos/2d/renderer/draw-batch.ts b/cocos/2d/renderer/draw-batch.ts index 13532b2e40..38562e750e 100644 --- a/cocos/2d/renderer/draw-batch.ts +++ b/cocos/2d/renderer/draw-batch.ts @@ -94,7 +94,6 @@ export class DrawBatch2D { public useLocalData: Node | null = null; public isStatic = false; public textureHash = 0; - public samplerHash = 0; private _passes: Pass[] = []; private _shaders: Shader[] = []; private _visFlags: number = UI_VIS_FLAG; diff --git a/cocos/3d/assets/morph-rendering.ts b/cocos/3d/assets/morph-rendering.ts index 40f65c9568..12e1c5ff76 100644 --- a/cocos/3d/assets/morph-rendering.ts +++ b/cocos/3d/assets/morph-rendering.ts @@ -32,10 +32,9 @@ import { AttributeName, Buffer, BufferUsageBit, Device, Feature, MemoryUsageBit, import { Mesh } from './mesh'; import { Texture2D } from '../../core/assets/texture-2d'; import { ImageAsset } from '../../core/assets/image-asset'; -import { samplerLib } from '../../core/renderer/core/sampler-lib'; import { UBOMorph, UNIFORM_NORMAL_MORPH_TEXTURE_BINDING, UNIFORM_POSITION_MORPH_TEXTURE_BINDING, UNIFORM_TANGENT_MORPH_TEXTURE_BINDING } from '../../core/pipeline/define'; -import { warn, warnID } from '../../core/platform/debug'; +import { warn } from '../../core/platform/debug'; import { Morph, MorphRendering, MorphRenderingInstance, SubMeshMorph } from './morph'; import { assertIsNonNullable, assertIsTrue } from '../../core/data/utils/asserts'; import { log2, nextPow2 } from '../../core/math/bits'; @@ -517,7 +516,7 @@ function createVec4TextureFactory (gfxDevice: Device, vec4Capacity: number) { if (!textureAsset.getGFXTexture()) { warn('Unexpected: failed to create morph texture?'); } - const sampler = samplerLib.getSampler(gfxDevice, textureAsset.getSamplerHash()); + const sampler = gfxDevice.getSampler(textureAsset.getSamplerInfo()); return { /** * Gets the GFX texture. diff --git a/cocos/3d/models/baked-skinning-model.ts b/cocos/3d/models/baked-skinning-model.ts index b7dc82f476..dc7035b547 100644 --- a/cocos/3d/models/baked-skinning-model.ts +++ b/cocos/3d/models/baked-skinning-model.ts @@ -37,13 +37,12 @@ import { BufferUsageBit, MemoryUsageBit, Attribute, DescriptorSet, Buffer, Buffe import { INST_JOINT_ANIM_INFO, UBOSkinningAnimation, UBOSkinningTexture, UNIFORM_JOINT_TEXTURE_BINDING } from '../../core/pipeline/define'; import { Node } from '../../core/scene-graph'; import { IMacroPatch, Pass } from '../../core/renderer/core/pass'; -import { samplerLib } from '../../core/renderer/core/sampler-lib'; import { DataPoolManager } from '../skeletal-animation/data-pool-manager'; import { ModelType } from '../../core/renderer/scene/model'; -import { IAnimInfo, IJointTextureHandle, jointTextureSamplerHash } from '../skeletal-animation/skeletal-animation-utils'; +import { IAnimInfo, IJointTextureHandle, jointTextureSamplerInfo } from '../skeletal-animation/skeletal-animation-utils'; import { MorphModel } from './morph-model'; import { legacyCC } from '../../core/global-exports'; -import { NativeAABB, NativeBakedSkinningModel, NativeSkinningModel } from '../../core/renderer/scene/native-scene'; +import { NativeAABB, NativeBakedSkinningModel } from '../../core/renderer/scene/native-scene'; interface IJointsInfo { buffer: Buffer | null; @@ -111,7 +110,7 @@ export class BakedSkinningModel extends MorphModel { if (!this._jointsMedium.buffer) { this._jointsMedium.buffer = this._device.createBuffer(new BufferInfo( BufferUsageBit.UNIFORM | BufferUsageBit.TRANSFER_DST, - MemoryUsageBit.HOST | MemoryUsageBit.DEVICE, + MemoryUsageBit.DEVICE, UBOSkinningTexture.SIZE, UBOSkinningTexture.SIZE, )); @@ -224,7 +223,7 @@ export class BakedSkinningModel extends MorphModel { descriptorSet.bindBuffer(UBOSkinningTexture.BINDING, buffer!); descriptorSet.bindBuffer(UBOSkinningAnimation.BINDING, animInfo.buffer); if (texture) { - const sampler = samplerLib.getSampler(this._device, jointTextureSamplerHash); + const sampler = this._device.getSampler(jointTextureSamplerInfo); descriptorSet.bindTexture(UNIFORM_JOINT_TEXTURE_BINDING, texture.handle.texture); descriptorSet.bindSampler(UNIFORM_JOINT_TEXTURE_BINDING, sampler); } diff --git a/cocos/3d/skeletal-animation/skeletal-animation-utils.ts b/cocos/3d/skeletal-animation/skeletal-animation-utils.ts index 7662a48de9..43b050d278 100644 --- a/cocos/3d/skeletal-animation/skeletal-animation-utils.ts +++ b/cocos/3d/skeletal-animation/skeletal-animation-utils.ts @@ -36,11 +36,10 @@ import { Mesh } from '../assets/mesh'; import { Skeleton } from '../assets/skeleton'; import { AABB } from '../../core/geometry'; import { Address, BufferUsageBit, Filter, Format, FormatInfos, - MemoryUsageBit, Feature, Device, Buffer, BufferInfo } from '../../core/gfx'; + MemoryUsageBit, Feature, Device, Buffer, BufferInfo, Sampler, SamplerInfo } from '../../core/gfx'; import { Mat4, Quat, Vec3 } from '../../core/math'; import { UBOSkinningAnimation } from '../../core/pipeline/define'; import { Node } from '../../core/scene-graph'; -import { genSamplerHash } from '../../core/renderer/core/sampler-lib'; import { ITextureBufferHandle, TextureBufferPool } from '../../core/renderer/core/texture-buffer-pool'; // change here and cc-skinning.chunk to use other skinning algorithms @@ -103,14 +102,14 @@ function roundUpTextureSize (targetLength: number, formatSize: number) { return Math.ceil(Math.max(MINIMUM_JOINT_TEXTURE_SIZE * formatScale, targetLength) / 12) * 12; } -export const jointTextureSamplerHash = genSamplerHash([ +export const jointTextureSamplerInfo = new SamplerInfo( Filter.POINT, Filter.POINT, Filter.NONE, Address.CLAMP, Address.CLAMP, Address.CLAMP, -]); +); interface IInternalJointAnimInfo { downstream?: Mat4; // downstream default pose, if present diff --git a/cocos/core/animation/value-proxy-factories/uniform.ts b/cocos/core/animation/value-proxy-factories/uniform.ts index 20766c98b7..d9f2034505 100644 --- a/cocos/core/animation/value-proxy-factories/uniform.ts +++ b/cocos/core/animation/value-proxy-factories/uniform.ts @@ -35,8 +35,7 @@ import { SpriteFrame } from '../../../2d/assets/sprite-frame'; import { TextureBase } from '../../assets/texture-base'; import { Type } from '../../gfx'; import { Pass } from '../../renderer/core/pass'; -import { getDefaultFromType, PropertyType } from '../../renderer/core/pass-utils'; -import { samplerLib } from '../../renderer/core/sampler-lib'; +import { getDefaultFromType } from '../../renderer/core/pass-utils'; import { IValueProxy, IValueProxyFactory } from '../value-proxy'; import { warn } from '../../platform/debug'; import { legacyCC } from '../../global-exports'; @@ -87,8 +86,8 @@ export class UniformProxyFactory implements IValueProxyFactory { if (!handle) { throw new Error(`Material "${target.name}" has no uniform "${this.uniformName}"`); } - const propertyType = Pass.getPropertyTypeFromHandle(handle); - if (propertyType === PropertyType.BUFFER) { + const type = Pass.getTypeFromHandle(handle); + if (type < Type.SAMPLER1D) { const realHandle = this.channelIndex === undefined ? handle : pass.getHandle(this.uniformName, this.channelIndex, Type.FLOAT); if (!realHandle) { throw new Error(`Uniform "${this.uniformName} (in material ${target.name}) has no channel ${this.channelIndex!}"`); @@ -105,7 +104,7 @@ export class UniformProxyFactory implements IValueProxyFactory { pass.setUniform(realHandle, value); }, }; - } if (propertyType === PropertyType.TEXTURE) { + } else { const binding = Pass.getBindingFromHandle(handle); const prop = pass.properties[this.uniformName]; const texName = prop && prop.value ? `${prop.value as string}-texture` : getDefaultFromType(prop.type) as string; @@ -121,12 +120,11 @@ export class UniformProxyFactory implements IValueProxyFactory { if (!texture || !texture.width || !texture.height) { return; } pass.bindTexture(binding, texture); if (value instanceof TextureBase) { - pass.bindSampler(binding, samplerLib.getSampler(legacyCC.game._gfxDevice, value.getSamplerHash())); + pass.bindSampler(binding, legacyCC.game._gfxDevice.getSampler(value.getSamplerInfo())); } }, }; } - throw new Error(`Animations are not available for uniforms with property type ${propertyType}.`); } } diff --git a/cocos/core/assets/effect-asset.ts b/cocos/core/assets/effect-asset.ts index a73c91fb5d..01f3e0a7a6 100644 --- a/cocos/core/assets/effect-asset.ts +++ b/cocos/core/assets/effect-asset.ts @@ -32,91 +32,113 @@ import { ccclass, serializable, editable, editorOnly } from 'cc.decorator'; import { EDITOR } from 'internal:constants'; import { Root } from '../root'; import { BlendState, DepthStencilState, RasterizerState, DescriptorType, - DynamicStateFlags, PrimitiveMode, ShaderStageFlags, Type, IUniform, IAttribute } from '../gfx'; - + DynamicStateFlags, PrimitiveMode, ShaderStageFlags, Type, SamplerInfo, Uniform, Attribute, MemoryAccess } from '../gfx'; import { RenderPassStage } from '../pipeline/define'; import { MacroRecord } from '../renderer/core/pass-utils'; import { programLib } from '../renderer/core/program-lib'; import { Asset } from './asset'; import { legacyCC } from '../global-exports'; -export interface IPropertyInfo { - type: number; // auto-extracted from shader - handleInfo?: [string, number, number]; // auto-generated from 'target' - samplerHash?: number; // auto-generated from 'sampler' - value?: number[] | string; -} -// Pass instance itself are compliant to IPassStates too -export interface IPassStates { - priority?: number; - primitive?: PrimitiveMode; - stage?: RenderPassStage; - rasterizerState?: RasterizerState; - depthStencilState?: DepthStencilState; - blendState?: BlendState; - dynamicStates?: DynamicStateFlags; - phase?: string | number; -} -export interface IPassInfo extends IPassStates { - program: string; // auto-generated from 'vert' and 'frag' - embeddedMacros?: MacroRecord; - propertyIndex?: number; - switch?: string; - properties?: Record; -} -export interface ITechniqueInfo { - passes: IPassInfo[]; - name?: string; -} +export declare namespace EffectAsset { + export interface IPropertyInfo { + type: number; // auto-extracted from shader + handleInfo?: [string, number, number]; // auto-generated from 'target' + samplerHash?: number; // auto-generated from 'sampler' + value?: number[] | string; + } + // Pass instance itself are compliant to IPassStates too + export interface IPassStates { + priority?: number; + primitive?: PrimitiveMode; + stage?: RenderPassStage; + rasterizerState?: RasterizerState; + depthStencilState?: DepthStencilState; + blendState?: BlendState; + dynamicStates?: DynamicStateFlags; + phase?: string | number; + } + export interface IPassInfo extends IPassStates { + program: string; // auto-generated from 'vert' and 'frag' + embeddedMacros?: MacroRecord; + propertyIndex?: number; + switch?: string; + properties?: Record; + } + export interface ITechniqueInfo { + passes: IPassInfo[]; + name?: string; + } -export interface IBlockInfo { - binding: number; - name: string; - members: IUniform[]; - count: number; - stageFlags: ShaderStageFlags; - descriptorType?: DescriptorType; -} -export interface ISamplerTextureInfo { - binding: number; - name: string; - type: Type; - count: number; - stageFlags: ShaderStageFlags; - descriptorType?: DescriptorType; -} -export interface IAttributeInfo extends IAttribute { - defines: string[]; -} -export interface IDefineInfo { - name: string; - type: string; - range?: number[]; - options?: string[]; - default?: string; -} -export interface IBuiltin { - name: string; - defines: string[]; -} -export interface IBuiltinInfo { - blocks: IBuiltin[]; - samplerTextures: IBuiltin[]; -} -export interface IShaderInfo { - name: string; - hash: number; - glsl4: { vert: string, frag: string }; - glsl3: { vert: string, frag: string }; - glsl1: { vert: string, frag: string }; - builtins: { globals: IBuiltinInfo, locals: IBuiltinInfo, statistics: Record }; - defines: IDefineInfo[]; - blocks: IBlockInfo[]; - samplerTextures: ISamplerTextureInfo[]; - attributes: IAttributeInfo[]; -} -export interface IPreCompileInfo { - [name: string]: boolean[] | number[] | string[]; + export interface IBufferInfo { + binding: number; + name: string; + count: number; + stageFlags: ShaderStageFlags; + memoryAccess: MemoryAccess; + descriptorType?: DescriptorType; + } + export interface IBlockInfo { + binding: number; + name: string; + members: Uniform[]; + count: number; + stageFlags: ShaderStageFlags; + descriptorType?: DescriptorType; + } + export interface ISamplerTextureInfo { + binding: number; + name: string; + type: Type; + count: number; + stageFlags: ShaderStageFlags; + descriptorType?: DescriptorType; + } + export interface IImageInfo { + binding: number; + name: string; + type: Type; + count: number; + stageFlags: ShaderStageFlags; + memoryAccess: MemoryAccess; + descriptorType?: DescriptorType; + } + export interface IAttributeInfo extends Attribute { + defines: string[]; + } + export interface IDefineInfo { + name: string; + type: string; + range?: number[]; + options?: string[]; + default?: string; + } + export interface IBuiltin { + name: string; + defines: string[]; + } + export interface IBuiltinInfo { + buffers: IBuiltin[]; + blocks: IBuiltin[]; + samplerTextures: IBuiltin[]; + images: IBuiltin[]; + } + export interface IShaderInfo { + name: string; + hash: number; + glsl4: { vert: string, frag: string }; + glsl3: { vert: string, frag: string }; + glsl1: { vert: string, frag: string }; + builtins: { globals: IBuiltinInfo, locals: IBuiltinInfo, statistics: Record }; + defines: IDefineInfo[]; + buffers: IBufferInfo[]; + blocks: IBlockInfo[]; + samplerTextures: ISamplerTextureInfo[]; + images: IImageInfo[]; + attributes: IAttributeInfo[]; + } + export interface IPreCompileInfo { + [name: string]: boolean[] | number[] | string[]; + } } /** @@ -180,7 +202,7 @@ export class EffectAsset extends Asset { */ @serializable @editable - public techniques: ITechniqueInfo[] = []; + public techniques: EffectAsset.ITechniqueInfo[] = []; /** * @en The shaders used by the current effect. @@ -188,7 +210,7 @@ export class EffectAsset extends Asset { */ @serializable @editable - public shaders: IShaderInfo[] = []; + public shaders: EffectAsset.IShaderInfo[] = []; /** * @en The preprocess macro combinations for the shader @@ -196,7 +218,7 @@ export class EffectAsset extends Asset { */ @serializable @editable - public combinations: IPreCompileInfo[] = []; + public combinations: EffectAsset.IPreCompileInfo[] = []; @serializable @editorOnly diff --git a/cocos/core/assets/material.ts b/cocos/core/assets/material.ts index a47dfbbd46..b4a71a7f80 100644 --- a/cocos/core/assets/material.ts +++ b/cocos/core/assets/material.ts @@ -32,11 +32,11 @@ import { ccclass, serializable, type } from 'cc.decorator'; import { Asset } from './asset'; import { EffectAsset } from './effect-asset'; import { RenderableComponent } from '../components/renderable-component'; -import { Texture } from '../gfx'; +import { Texture, Type } from '../gfx'; import { TextureBase } from './texture-base'; import { legacyCC } from '../global-exports'; import { IPassInfoFull, Pass, PassOverrides } from '../renderer/core/pass'; -import { MacroRecord, MaterialProperty, PropertyType } from '../renderer/core/pass-utils'; +import { MacroRecord, MaterialProperty } from '../renderer/core/pass-utils'; import { Color } from '../math/color'; import { warnID } from '../platform/debug'; @@ -418,8 +418,8 @@ export class Material extends Asset { protected _uploadProperty (pass: Pass, name: string, val: MaterialPropertyFull | MaterialPropertyFull[]) { const handle = pass.getHandle(name); if (!handle) { return false; } - const propertyType = Pass.getPropertyTypeFromHandle(handle); - if (propertyType === PropertyType.BUFFER) { + const type = Pass.getTypeFromHandle(handle); + if (type < Type.SAMPLER1D) { if (Array.isArray(val)) { pass.setUniformArray(handle, val as MaterialProperty[]); } else if (val !== null) { @@ -427,16 +427,14 @@ export class Material extends Asset { } else { pass.resetUniform(name); } - } else if (propertyType === PropertyType.TEXTURE) { - if (Array.isArray(val)) { - for (let i = 0; i < val.length; i++) { - this._bindTexture(pass, handle, val[i], i); - } - } else if (val) { - this._bindTexture(pass, handle, val); - } else { - pass.resetTexture(name); + } else if (Array.isArray(val)) { + for (let i = 0; i < val.length; i++) { + this._bindTexture(pass, handle, val[i], i); } + } else if (val) { + this._bindTexture(pass, handle, val); + } else { + pass.resetTexture(name); } return true; } diff --git a/cocos/core/assets/render-texture.ts b/cocos/core/assets/render-texture.ts index d9e8cbc4d5..70c19ae0b7 100644 --- a/cocos/core/assets/render-texture.ts +++ b/cocos/core/assets/render-texture.ts @@ -29,17 +29,15 @@ */ import { ccclass, rangeMin, rangeMax, serializable } from 'cc.decorator'; -import { Texture, Sampler, ColorAttachment, DepthStencilAttachment, AccessType, RenderPassInfo } from '../gfx'; +import { Texture, Sampler, ColorAttachment, DepthStencilAttachment, AccessType, RenderPassInfo, SamplerInfo, Format } from '../gfx'; import { legacyCC } from '../global-exports'; import { RenderWindow, IRenderWindowInfo } from '../renderer/core/render-window'; - import { Root } from '../root'; import { TextureBase } from './texture-base'; -import { samplerLib, defaultSamplerHash } from '../renderer/core/sampler-lib'; import { IDGenerator } from '../utils/js'; -import { murmurhash2_32_gc } from '../utils/murmurhash2_gc'; const idGenerator = new IDGenerator('RenderTex'); +const defaultSamplerInfo = new SamplerInfo(); export interface IRenderTextureCreateInfo { name?: string; @@ -49,8 +47,11 @@ export interface IRenderTextureCreateInfo { } const _colorAttachment = new ColorAttachment(); +_colorAttachment.format = Format.RGBA8; +_colorAttachment.beginAccesses = [AccessType.FRAGMENT_SHADER_READ_TEXTURE]; _colorAttachment.endAccesses = [AccessType.FRAGMENT_SHADER_READ_TEXTURE]; const _depthStencilAttachment = new DepthStencilAttachment(); +_depthStencilAttachment.format = Format.DEPTH_STENCIL; const passInfo = new RenderPassInfo([_colorAttachment], _depthStencilAttachment); const _windowInfo: IRenderWindowInfo = { @@ -157,15 +158,15 @@ export class RenderTexture extends TextureBase { */ public getGFXSampler (): Sampler { const root = legacyCC.director.root as Root; - return samplerLib.getSampler(root.device, defaultSamplerHash); + return root.device.getSampler(defaultSamplerInfo); } /** * @en Gets the sampler hash for the render texture * @zh 获取渲染贴图的采样器哈希值 */ - public getSamplerHash () { - return defaultSamplerHash; + public getSamplerInfo () { + return defaultSamplerInfo; } public onLoaded () { diff --git a/cocos/core/assets/simple-texture.ts b/cocos/core/assets/simple-texture.ts index 0ac141a2ce..a8902fb3c9 100644 --- a/cocos/core/assets/simple-texture.ts +++ b/cocos/core/assets/simple-texture.ts @@ -231,7 +231,7 @@ export class SimpleTexture extends TextureBase { usage: TextureUsageBit.SAMPLED | TextureUsageBit.TRANSFER_DST, format: this._getGFXFormat(), levelCount: this._mipmapLevel, - flags: flags | TextureFlagBit.IMMUTABLE, + flags, }); if (!textureCreateInfo) { return; diff --git a/cocos/core/assets/texture-base.ts b/cocos/core/assets/texture-base.ts index 53aaad2920..d500de3267 100644 --- a/cocos/core/assets/texture-base.ts +++ b/cocos/core/assets/texture-base.ts @@ -32,11 +32,10 @@ // @ts-check import { EDITOR, TEST } from 'internal:constants'; import { ccclass, serializable } from 'cc.decorator'; -import { genSamplerHash, SamplerInfoIndex, samplerLib } from '../renderer/core/sampler-lib'; import IDGenerator from '../utils/id-generator'; import { Asset } from './asset'; import { Filter, PixelFormat, WrapMode } from './asset-enum'; -import { Sampler, Texture, Device, Format } from '../gfx'; +import { Sampler, Texture, Device, Format, SamplerInfo, Address, Filter as GFXFilter } from '../gfx'; import { legacyCC } from '../global-exports'; import { errorID } from '../platform/debug'; import { murmurhash2_32_gc } from '../utils/murmurhash2_gc'; @@ -92,25 +91,25 @@ export class TextureBase extends Asset { public static Filter = Filter; @serializable - protected _format: number = PixelFormat.RGBA8888; + protected _format = PixelFormat.RGBA8888; @serializable - protected _minFilter: number = Filter.LINEAR; + protected _minFilter = Filter.LINEAR; @serializable - protected _magFilter: number = Filter.LINEAR; + protected _magFilter = Filter.LINEAR; @serializable - protected _mipFilter: number = Filter.NONE; + protected _mipFilter = Filter.NONE; @serializable - protected _wrapS: number = WrapMode.REPEAT; + protected _wrapS = WrapMode.REPEAT; @serializable - protected _wrapT: number = WrapMode.REPEAT; + protected _wrapT = WrapMode.REPEAT; @serializable - protected _wrapR: number = WrapMode.REPEAT; + protected _wrapR = WrapMode.REPEAT; @serializable protected _anisotropy = 0; @@ -119,8 +118,7 @@ export class TextureBase extends Asset { protected _height = 1; private _id: string; - private _samplerInfo: (number | undefined)[] = []; - private _samplerHash = 0; + private _samplerInfo = new SamplerInfo(); private _gfxSampler: Sampler | null = null; private _gfxDevice: Device | null = null; @@ -173,18 +171,17 @@ export class TextureBase extends Asset { */ public setWrapMode (wrapS: WrapMode, wrapT: WrapMode, wrapR?: WrapMode) { this._wrapS = wrapS; - this._samplerInfo[SamplerInfoIndex.addressU] = wrapS; + this._samplerInfo.addressU = wrapS as unknown as Address; this._wrapT = wrapT; - this._samplerInfo[SamplerInfoIndex.addressV] = wrapT; + this._samplerInfo.addressV = wrapT as unknown as Address; + if (wrapR !== undefined) { this._wrapR = wrapR; - this._samplerInfo[SamplerInfoIndex.addressW] = wrapR; + this._samplerInfo.addressW = wrapR as unknown as Address; } - this._samplerHash = genSamplerHash(this._samplerInfo); - // for editor assetDB if (this._gfxDevice) { - this._gfxSampler = samplerLib.getSampler(this._gfxDevice, this._samplerHash); + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } } @@ -196,12 +193,12 @@ export class TextureBase extends Asset { */ public setFilters (minFilter: Filter, magFilter: Filter) { this._minFilter = minFilter; - this._samplerInfo[SamplerInfoIndex.minFilter] = minFilter; + this._samplerInfo.minFilter = minFilter as unknown as GFXFilter; this._magFilter = magFilter; - this._samplerInfo[SamplerInfoIndex.magFilter] = magFilter; - this._samplerHash = genSamplerHash(this._samplerInfo); + this._samplerInfo.magFilter = magFilter as unknown as GFXFilter; + if (this._gfxDevice) { - this._gfxSampler = samplerLib.getSampler(this._gfxDevice, this._samplerHash); + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } } @@ -212,10 +209,10 @@ export class TextureBase extends Asset { */ public setMipFilter (mipFilter: Filter) { this._mipFilter = mipFilter; - this._samplerInfo[SamplerInfoIndex.mipFilter] = mipFilter; - this._samplerHash = genSamplerHash(this._samplerInfo); + this._samplerInfo.mipFilter = mipFilter as unknown as GFXFilter; + if (this._gfxDevice) { - this._gfxSampler = samplerLib.getSampler(this._gfxDevice, this._samplerHash); + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } } @@ -226,10 +223,10 @@ export class TextureBase extends Asset { */ public setAnisotropy (anisotropy: number) { this._anisotropy = anisotropy; - this._samplerInfo[SamplerInfoIndex.maxAnisotropy] = anisotropy; - this._samplerHash = genSamplerHash(this._samplerInfo); + this._samplerInfo.maxAnisotropy = anisotropy; + if (this._gfxDevice) { - this._gfxSampler = samplerLib.getSampler(this._gfxDevice, this._samplerHash); + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } } @@ -266,8 +263,8 @@ export class TextureBase extends Asset { * @zh 获取此贴图内部使用的 GFX 采样器信息。 * @private */ - public getSamplerHash () { - return this._samplerHash; + public getSamplerInfo (): Readonly { + return this._samplerInfo; } /** @@ -277,7 +274,7 @@ export class TextureBase extends Asset { public getGFXSampler () { if (!this._gfxSampler) { if (this._gfxDevice) { - this._gfxSampler = samplerLib.getSampler(this._gfxDevice, this._samplerHash); + this._gfxSampler = this._gfxDevice.getSampler(this._samplerInfo); } else { errorID(9302); } @@ -334,7 +331,7 @@ export class TextureBase extends Asset { this._format = format === undefined ? PixelFormat.RGBA8888 : format; } - protected _getGFXPixelFormat (format) { + protected _getGFXPixelFormat (format: PixelFormat) { if (format === PixelFormat.RGBA_ETC1) { format = PixelFormat.RGB_ETC1; } else if (format === PixelFormat.RGB_A_PVRTC_4BPPV1) { @@ -342,7 +339,7 @@ export class TextureBase extends Asset { } else if (format === PixelFormat.RGB_A_PVRTC_2BPPV1) { format = PixelFormat.RGB_PVRTC_2BPPV1; } - return format as Format; + return format as unknown as Format; } } diff --git a/cocos/core/builtin/effects.ts b/cocos/core/builtin/effects.ts index 3f38ed21be..77c7fe661c 100644 --- a/cocos/core/builtin/effects.ts +++ b/cocos/core/builtin/effects.ts @@ -12,12 +12,13 @@ export const effects = [ "hash": 308883658, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 50, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 38 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "images": [] } }, "defines": [ { "name": "CC_USE_HDR", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ { "name": "mainTiling_Offset", "type": 16, "count": 1 }, @@ -34,10 +35,11 @@ export const effects = [ "samplerTextures": [ { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 3 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 1 }, - { "name": "a_color", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 2 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 }, + { "name": "a_color", "defines": [], "format": 44, "location": 2 } ] } ] @@ -53,14 +55,16 @@ export const effects = [ "hash": 3507038093, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 0, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, - "globals": { "blocks": [], "samplerTextures": [] }, - "locals": { "blocks": [], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [], "samplerTextures": [], "images": [] } }, "defines": [], + "buffers": [], "blocks": [], "samplerTextures": [], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 } ] } ] @@ -76,16 +80,18 @@ export const effects = [ "hash": 3113634185, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 46, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "images": [] } }, "defines": [], + "buffers": [], "blocks": [], "samplerTextures": [], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_color", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 1 }, - { "name": "a_dist", "type": 13, "count": 1, "defines": [], "stageFlags": 1, "format": 11, "location": 2 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_color", "defines": [], "format": 44, "location": 1 }, + { "name": "a_dist", "defines": [], "format": 11, "location": 2 } ] } ] @@ -101,8 +107,8 @@ export const effects = [ "hash": 3001336778, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 60, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 38 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "images": [] } }, "defines": [ { "name": "CC_RENDER_MODE", "type": "number", "range": [0, 4] }, @@ -115,6 +121,7 @@ export const effects = [ { "name": "CC_USE_WORLD_SPACE", "type": "boolean" }, { "name": "CC_USE_HDR", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ { "name": "mainTiling_Offset", "type": 16, "count": 1 }, @@ -161,17 +168,18 @@ export const effects = [ { "name": "texture_animation_tex0", "type": 28, "count": 1, "defines": ["TEXTURE_ANIMATION_MODULE_ENABLE"], "stageFlags": 1, "binding": 15 }, { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 16 } ], + "images": [], "attributes": [ - { "name": "a_position_starttime", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 0 }, - { "name": "a_size_uv", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 1 }, - { "name": "a_rotation_uv", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 2 }, - { "name": "a_color", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 3 }, - { "name": "a_dir_life", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 4 }, - { "name": "a_rndSeed", "type": 13, "count": 1, "defines": [], "stageFlags": 1, "format": 11, "location": 5 }, - { "name": "a_texCoord", "type": 15, "count": 1, "defines": ["CC_RENDER_MODE"], "stageFlags": 1, "format": 32, "location": 6 }, - { "name": "a_texCoord3", "type": 15, "count": 1, "defines": ["CC_RENDER_MODE"], "stageFlags": 1, "format": 32, "location": 7 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": ["CC_RENDER_MODE"], "stageFlags": 1, "format": 32, "location": 8 }, - { "name": "a_color1", "type": 16, "count": 1, "defines": ["CC_RENDER_MODE"], "stageFlags": 1, "format": 44, "location": 9 } + { "name": "a_position_starttime", "defines": [], "format": 44, "location": 0 }, + { "name": "a_size_uv", "defines": [], "format": 44, "location": 1 }, + { "name": "a_rotation_uv", "defines": [], "format": 44, "location": 2 }, + { "name": "a_color", "defines": [], "format": 44, "location": 3 }, + { "name": "a_dir_life", "defines": [], "format": 44, "location": 4 }, + { "name": "a_rndSeed", "defines": [], "format": 11, "location": 5 }, + { "name": "a_texCoord", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 6 }, + { "name": "a_texCoord3", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 7 }, + { "name": "a_normal", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 8 }, + { "name": "a_color1", "defines": ["CC_RENDER_MODE"], "format": 44, "location": 9 } ] } ] @@ -187,8 +195,8 @@ export const effects = [ "hash": 2637621064, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 49, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 38 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "images": [] } }, "defines": [ { "name": "CC_RENDER_MODE", "type": "number", "range": [0, 4] }, @@ -196,6 +204,7 @@ export const effects = [ { "name": "CC_USE_WORLD_SPACE", "type": "boolean" }, { "name": "CC_USE_HDR", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ { "name": "mainTiling_Offset", "type": 16, "count": 1 }, @@ -209,12 +218,13 @@ export const effects = [ "samplerTextures": [ { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_texCoord", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 1 }, - { "name": "a_texCoord1", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 2 }, - { "name": "a_texCoord2", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 3 }, - { "name": "a_color", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 4 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 44, "location": 1 }, + { "name": "a_texCoord1", "defines": [], "format": 32, "location": 2 }, + { "name": "a_texCoord2", "defines": [], "format": 32, "location": 3 }, + { "name": "a_color", "defines": [], "format": 44, "location": 4 } ] } ] @@ -230,14 +240,15 @@ export const effects = [ "hash": 1675533382, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 49, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 38 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "images": [] } }, "defines": [ { "name": "CC_RENDER_MODE", "type": "number", "range": [0, 4] }, { "name": "CC_USE_WORLD_SPACE", "type": "boolean" }, { "name": "CC_USE_HDR", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ { "name": "mainTiling_Offset", "type": 16, "count": 1 }, @@ -251,15 +262,16 @@ export const effects = [ "samplerTextures": [ { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_texCoord", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord1", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 2 }, - { "name": "a_texCoord2", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 3 }, - { "name": "a_color", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 4 }, - { "name": "a_color1", "type": 15, "count": 1, "defines": ["CC_RENDER_MODE"], "stageFlags": 1, "format": 32, "location": 8 }, - { "name": "a_texCoord3", "type": 15, "count": 1, "defines": ["CC_RENDER_MODE"], "stageFlags": 1, "format": 32, "location": 6 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": ["CC_RENDER_MODE"], "stageFlags": 1, "format": 32, "location": 7 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord1", "defines": [], "format": 32, "location": 2 }, + { "name": "a_texCoord2", "defines": [], "format": 32, "location": 3 }, + { "name": "a_color", "defines": [], "format": 44, "location": 4 }, + { "name": "a_color1", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 8 }, + { "name": "a_texCoord3", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 6 }, + { "name": "a_normal", "defines": ["CC_RENDER_MODE"], "format": 32, "location": 7 } ] } ] @@ -275,25 +287,27 @@ export const effects = [ "hash": 1867464226, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 46, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 1 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": ["USE_LOCAL"] }], "samplerTextures": [{ "name": "cc_spriteTexture", "defines": [] }] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": ["USE_LOCAL"] }], "samplerTextures": [{ "name": "cc_spriteTexture", "defines": [] }], "images": [] } }, "defines": [ { "name": "USE_LOCAL", "type": "boolean" }, { "name": "TWO_COLORED", "type": "boolean" }, { "name": "USE_ALPHA_TEST", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "ALPHA_TEST_DATA", "defines": ["USE_ALPHA_TEST"], "binding": 0, "stageFlags": 16, "members": [ { "name": "alphaThreshold", "type": 13, "count": 1 } ]} ], "samplerTextures": [], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 1 }, - { "name": "a_color", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 2 }, - { "name": "a_color2", "type": 16, "count": 1, "defines": ["TWO_COLORED"], "stageFlags": 1, "format": 44, "location": 3 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 }, + { "name": "a_color", "defines": [], "format": 44, "location": 2 }, + { "name": "a_color2", "defines": ["TWO_COLORED"], "format": 44, "location": 3 } ] } ] @@ -309,8 +323,8 @@ export const effects = [ "hash": 1559944983, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 46, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 1 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": ["USE_LOCAL"] }], "samplerTextures": [{ "name": "cc_spriteTexture", "defines": ["USE_TEXTURE"] }] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": ["USE_LOCAL"] }], "samplerTextures": [{ "name": "cc_spriteTexture", "defines": ["USE_TEXTURE"] }], "images": [] } }, "defines": [ { "name": "USE_LOCAL", "type": "boolean" }, @@ -321,16 +335,18 @@ export const effects = [ { "name": "USE_TEXTURE", "type": "boolean" }, { "name": "IS_GRAY", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "ALPHA_TEST_DATA", "defines": ["USE_ALPHA_TEST"], "binding": 0, "stageFlags": 16, "members": [ { "name": "alphaThreshold", "type": 13, "count": 1 } ]} ], "samplerTextures": [], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 1 }, - { "name": "a_color", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 2 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 }, + { "name": "a_color", "defines": [], "format": 44, "location": 2 } ] } ] @@ -338,7 +354,7 @@ export const effects = [ { "name": "standard", "techniques": [ - { "name": "opaque", "passes": [{ "program": "standard|standard-vs|standard-fs", "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "occlusion": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 0, 13] }, "roughness": { "value": [0.8], "type": 13, "handleInfo": ["pbrParams", 1, 13] }, "metallic": { "value": [0.6], "type": 13, "handleInfo": ["pbrParams", 2, 13] }, "SpecularIntensity": { "value": [0.5], "type": 13, "handleInfo": ["pbrParams", 3, 13] }, "normalStrenth": { "value": [1], "type": 13, "handleInfo": ["miscParams", 0, 13] }, "emissive": { "value": [0, 0, 0, 1], "type": 16 }, "emissiveScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["emissiveScaleParam", 0, 15] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "normalMap": { "value": "normal", "type": 28 }, "pbrMap": { "value": "grey", "type": 28 }, "metallicRoughnessMap": { "value": "grey", "type": 28 }, "occlusionMap": { "value": "white", "type": 28 }, "emissiveMap": { "value": "grey", "type": 28 }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "pbrParams": { "type": 16, "value": [1, 0.8, 0.6, 0.5] }, "miscParams": { "type": 16, "value": [1, 0, 0, 0] }, "emissiveScaleParam": { "type": 16, "value": [1, 1, 1, 0] }, "albedoMap": { "type": 28, "value": "grey" } } }, { "phase": "deferred", "propertyIndex": 0, "blendState": { "targets": [{ "blend": false }, { "blend": false }, { "blend": false }, { "blend": false }] }, "program": "standard|standard-vs|standard-fs", "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "occlusion": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 0, 13] }, "roughness": { "value": [0.8], "type": 13, "handleInfo": ["pbrParams", 1, 13] }, "metallic": { "value": [0.6], "type": 13, "handleInfo": ["pbrParams", 2, 13] }, "SpecularIntensity": { "value": [0.5], "type": 13, "handleInfo": ["pbrParams", 3, 13] }, "normalStrenth": { "value": [1], "type": 13, "handleInfo": ["miscParams", 0, 13] }, "emissive": { "value": [0, 0, 0, 1], "type": 16 }, "emissiveScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["emissiveScaleParam", 0, 15] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "normalMap": { "value": "normal", "type": 28 }, "pbrMap": { "value": "grey", "type": 28 }, "metallicRoughnessMap": { "value": "grey", "type": 28 }, "occlusionMap": { "value": "white", "type": 28 }, "emissiveMap": { "value": "grey", "type": 28 }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "pbrParams": { "type": 16, "value": [1, 0.8, 0.6, 0.5] }, "miscParams": { "type": 16, "value": [1, 0, 0, 0] }, "emissiveScaleParam": { "type": 16, "value": [1, 1, 1, 0] }, "albedoMap": { "type": 28, "value": "grey" } } }, { "phase": "forward-add", "propertyIndex": 0, "embeddedMacros": { "CC_FORWARD_ADD": true }, "blendState": { "targets": [{ "blend": true, "blendSrc": 1, "blendDst": 1, "blendSrcAlpha": 0, "blendDstAlpha": 1 }] }, "program": "standard|standard-vs|standard-fs", "depthStencilState": { "depthFunc": 2, "depthTest": true, "depthWrite": false }, "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "occlusion": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 0, 13] }, "roughness": { "value": [0.8], "type": 13, "handleInfo": ["pbrParams", 1, 13] }, "metallic": { "value": [0.6], "type": 13, "handleInfo": ["pbrParams", 2, 13] }, "SpecularIntensity": { "value": [0.5], "type": 13, "handleInfo": ["pbrParams", 3, 13] }, "normalStrenth": { "value": [1], "type": 13, "handleInfo": ["miscParams", 0, 13] }, "emissive": { "value": [0, 0, 0, 1], "type": 16 }, "emissiveScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["emissiveScaleParam", 0, 15] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "normalMap": { "value": "normal", "type": 28 }, "pbrMap": { "value": "grey", "type": 28 }, "metallicRoughnessMap": { "value": "grey", "type": 28 }, "occlusionMap": { "value": "white", "type": 28 }, "emissiveMap": { "value": "grey", "type": 28 }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "pbrParams": { "type": 16, "value": [1, 0.8, 0.6, 0.5] }, "miscParams": { "type": 16, "value": [1, 0, 0, 0] }, "emissiveScaleParam": { "type": 16, "value": [1, 1, 1, 0] }, "albedoMap": { "type": 28, "value": "grey" } } }, { "phase": "shadow-caster", "propertyIndex": 0, "rasterizerState": { "cullMode": 1 }, "program": "standard|shadow-caster-vs:vert|shadow-caster-fs:frag", "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "occlusion": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 0, 13] }, "roughness": { "value": [0.8], "type": 13, "handleInfo": ["pbrParams", 1, 13] }, "metallic": { "value": [0.6], "type": 13, "handleInfo": ["pbrParams", 2, 13] }, "normalStrenth": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 3, 13] }, "emissive": { "value": [0, 0, 0, 1], "type": 16 }, "emissiveScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["emissiveScaleParam", 0, 15] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "pbrParams": { "type": 16, "value": [1, 0.8, 0.6, 1] }, "emissiveScaleParam": { "type": 16, "value": [1, 1, 1, 0] }, "albedoMap": { "type": 28, "value": "grey" } } }] } + { "name": "opaque", "passes": [{ "program": "standard|standard-vs|standard-fs", "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "occlusion": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 0, 13] }, "roughness": { "value": [0.8], "type": 13, "handleInfo": ["pbrParams", 1, 13] }, "metallic": { "value": [0.6], "type": 13, "handleInfo": ["pbrParams", 2, 13] }, "SpecularIntensity": { "value": [0.5], "type": 13, "handleInfo": ["pbrParams", 3, 13] }, "normalStrenth": { "value": [1], "type": 13, "handleInfo": ["miscParams", 0, 13] }, "emissive": { "value": [0, 0, 0, 1], "type": 16 }, "emissiveScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["emissiveScaleParam", 0, 15] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "normalMap": { "value": "normal", "type": 28 }, "pbrMap": { "value": "grey", "type": 28 }, "metallicRoughnessMap": { "value": "grey", "type": 28 }, "occlusionMap": { "value": "white", "type": 28 }, "emissiveMap": { "value": "grey", "type": 28 }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "pbrParams": { "type": 16, "value": [1, 0.8, 0.6, 0.5] }, "miscParams": { "type": 16, "value": [1, 0, 0, 0] }, "emissiveScaleParam": { "type": 16, "value": [1, 1, 1, 0] }, "albedoMap": { "type": 28, "value": "grey" } } }, { "phase": "forward-add", "propertyIndex": 0, "embeddedMacros": { "CC_FORWARD_ADD": true }, "blendState": { "targets": [{ "blend": true, "blendSrc": 1, "blendDst": 1, "blendSrcAlpha": 0, "blendDstAlpha": 1 }] }, "program": "standard|standard-vs|standard-fs", "depthStencilState": { "depthFunc": 2, "depthTest": true, "depthWrite": false }, "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "occlusion": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 0, 13] }, "roughness": { "value": [0.8], "type": 13, "handleInfo": ["pbrParams", 1, 13] }, "metallic": { "value": [0.6], "type": 13, "handleInfo": ["pbrParams", 2, 13] }, "SpecularIntensity": { "value": [0.5], "type": 13, "handleInfo": ["pbrParams", 3, 13] }, "normalStrenth": { "value": [1], "type": 13, "handleInfo": ["miscParams", 0, 13] }, "emissive": { "value": [0, 0, 0, 1], "type": 16 }, "emissiveScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["emissiveScaleParam", 0, 15] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "normalMap": { "value": "normal", "type": 28 }, "pbrMap": { "value": "grey", "type": 28 }, "metallicRoughnessMap": { "value": "grey", "type": 28 }, "occlusionMap": { "value": "white", "type": 28 }, "emissiveMap": { "value": "grey", "type": 28 }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "pbrParams": { "type": 16, "value": [1, 0.8, 0.6, 0.5] }, "miscParams": { "type": 16, "value": [1, 0, 0, 0] }, "emissiveScaleParam": { "type": 16, "value": [1, 1, 1, 0] }, "albedoMap": { "type": 28, "value": "grey" } } }, { "phase": "shadow-caster", "propertyIndex": 0, "rasterizerState": { "cullMode": 1 }, "program": "standard|shadow-caster-vs:vert|shadow-caster-fs:frag", "properties": { "tilingOffset": { "value": [1, 1, 0, 0], "type": 16 }, "mainColor": { "value": [1, 1, 1, 1], "type": 16, "handleInfo": ["albedo", 0, 16] }, "albedoScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["albedoScaleAndCutoff", 0, 15] }, "alphaThreshold": { "value": [0.5], "type": 13, "handleInfo": ["albedoScaleAndCutoff", 3, 13] }, "occlusion": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 0, 13] }, "roughness": { "value": [0.8], "type": 13, "handleInfo": ["pbrParams", 1, 13] }, "metallic": { "value": [0.6], "type": 13, "handleInfo": ["pbrParams", 2, 13] }, "normalStrenth": { "value": [1], "type": 13, "handleInfo": ["pbrParams", 3, 13] }, "emissive": { "value": [0, 0, 0, 1], "type": 16 }, "emissiveScale": { "value": [1, 1, 1], "type": 15, "handleInfo": ["emissiveScaleParam", 0, 15] }, "mainTexture": { "value": "grey", "type": 28, "handleInfo": ["albedoMap", 0, 28] }, "albedo": { "type": 16, "value": [1, 1, 1, 1] }, "albedoScaleAndCutoff": { "type": 16, "value": [1, 1, 1, 0.5] }, "pbrParams": { "type": 16, "value": [1, 0.8, 0.6, 1] }, "emissiveScaleParam": { "type": 16, "value": [1, 1, 1, 0] }, "albedoMap": { "type": 28, "value": "grey" } } }] } ], "shaders": [ { @@ -346,8 +362,8 @@ export const effects = [ "hash": 4020165078, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 220, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 63 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }] }, - "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }, { "name": "CCForwardLight", "defines": ["CC_FORWARD_ADD"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "cc_lightingMap", "defines": ["USE_LIGHTMAP", "!USE_BATCHING", "!CC_FORWARD_ADD"] }] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }, { "name": "CCForwardLight", "defines": ["CC_FORWARD_ADD"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "cc_lightingMap", "defines": ["USE_LIGHTMAP", "!USE_BATCHING", "!CC_FORWARD_ADD"] }], "images": [] } }, "defines": [ { "name": "CC_USE_MORPH", "type": "boolean" }, @@ -384,6 +400,7 @@ export const effects = [ { "name": "CC_PIPELINE_TYPE", "type": "number", "range": [0, 1] }, { "name": "CC_STANDARD_TRANSPARENT", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 17, "members": [ { "name": "tilingOffset", "type": 16, "count": 1 }, @@ -403,22 +420,23 @@ export const effects = [ { "name": "occlusionMap", "type": 28, "count": 1, "defines": ["USE_OCCLUSION_MAP"], "stageFlags": 16, "binding": 5 }, { "name": "emissiveMap", "type": 28, "count": 1, "defines": ["USE_EMISSIVE_MAP"], "stageFlags": 16, "binding": 6 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 }, - { "name": "a_tangent", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 3 }, - { "name": "a_vertexId", "type": 13, "count": 1, "defines": ["CC_USE_MORPH"], "stageFlags": 1, "format": 11, "location": 6 }, - { "name": "a_joints", "type": "u32vec4", "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "location": 4 }, - { "name": "a_weights", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "format": 44, "location": 5 }, - { "name": "a_jointAnimInfo", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 7 }, - { "name": "a_matWorld0", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 8 }, - { "name": "a_matWorld1", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 9 }, - { "name": "a_matWorld2", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 10 }, - { "name": "a_lightingMapUVParam", "type": 16, "count": 1, "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 11 }, - { "name": "a_dyn_batch_id", "type": 13, "count": 1, "defines": ["!USE_INSTANCING", "USE_BATCHING"], "stageFlags": 1, "format": 11, "location": 12 }, - { "name": "a_color", "type": 16, "count": 1, "defines": ["USE_VERTEX_COLOR"], "stageFlags": 1, "format": 44, "location": 13 }, - { "name": "a_texCoord1", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 14 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 }, + { "name": "a_matWorld0", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 8 }, + { "name": "a_matWorld1", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 9 }, + { "name": "a_matWorld2", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 10 }, + { "name": "a_lightingMapUVParam", "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "format": 44, "isInstanced": true, "location": 11 }, + { "name": "a_dyn_batch_id", "defines": ["!USE_INSTANCING", "USE_BATCHING"], "format": 11, "location": 12 }, + { "name": "a_color", "defines": ["USE_VERTEX_COLOR"], "format": 44, "location": 13 }, + { "name": "a_texCoord1", "defines": [], "format": 21, "location": 14 } ] }, { @@ -426,8 +444,8 @@ export const effects = [ "hash": 1783225275, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 183, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 63 }, - "globals": { "blocks": [{ "name": "CCShadow", "defines": [] }, { "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }] }, - "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }] } + "globals": { "buffers": [], "blocks": [{ "name": "CCShadow", "defines": [] }, { "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "images": [] } }, "defines": [ { "name": "CC_USE_MORPH", "type": "boolean" }, @@ -448,6 +466,7 @@ export const effects = [ { "name": "USE_ALPHA_TEST", "type": "boolean" }, { "name": "ALPHA_TEST_CHANNEL", "type": "string", "options": ["a", "r"] } ], + "buffers": [], "blocks": [ {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 17, "members": [ { "name": "tilingOffset", "type": 16, "count": 1 }, @@ -462,21 +481,22 @@ export const effects = [ "samplerTextures": [ { "name": "albedoMap", "type": 28, "count": 1, "defines": ["USE_ALBEDO_MAP"], "stageFlags": 16, "binding": 1 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 }, - { "name": "a_tangent", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 3 }, - { "name": "a_vertexId", "type": 13, "count": 1, "defines": ["CC_USE_MORPH"], "stageFlags": 1, "format": 11, "location": 6 }, - { "name": "a_joints", "type": "u32vec4", "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "location": 4 }, - { "name": "a_weights", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "format": 44, "location": 5 }, - { "name": "a_jointAnimInfo", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 7 }, - { "name": "a_matWorld0", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 8 }, - { "name": "a_matWorld1", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 9 }, - { "name": "a_matWorld2", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 10 }, - { "name": "a_lightingMapUVParam", "type": 16, "count": 1, "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 11 }, - { "name": "a_dyn_batch_id", "type": 13, "count": 1, "defines": ["!USE_INSTANCING", "USE_BATCHING"], "stageFlags": 1, "format": 11, "location": 12 }, - { "name": "a_texCoord1", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 13 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 }, + { "name": "a_matWorld0", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 8 }, + { "name": "a_matWorld1", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 9 }, + { "name": "a_matWorld2", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 10 }, + { "name": "a_lightingMapUVParam", "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "format": 44, "isInstanced": true, "location": 11 }, + { "name": "a_dyn_batch_id", "defines": ["!USE_INSTANCING", "USE_BATCHING"], "format": 11, "location": 12 }, + { "name": "a_texCoord1", "defines": [], "format": 21, "location": 13 } ] } ] @@ -484,7 +504,7 @@ export const effects = [ { "name": "terrain", "techniques": [ - { "name": "opaque", "passes": [{ "program": "terrain|terrain-vs|terrain-fs", "properties": { "UVScale": { "value": [1, 1, 1, 1], "type": 16 }, "lightMapUVParam": { "value": [0, 0, 0, 0], "type": 16 }, "metallic": { "value": [0, 0, 0, 0], "type": 16 }, "roughness": { "value": [1, 1, 1, 1], "type": 16 }, "weightMap": { "value": "black", "type": 28 }, "detailMap0": { "value": "grey", "type": 28 }, "detailMap1": { "value": "grey", "type": 28 }, "detailMap2": { "value": "grey", "type": 28 }, "detailMap3": { "value": "grey", "type": 28 }, "normalMap0": { "value": "normal", "type": 28 }, "normalMap1": { "value": "normal", "type": 28 }, "normalMap2": { "value": "normal", "type": 28 }, "normalMap3": { "value": "normal", "type": 28 }, "lightMap": { "value": "grey", "type": 28 } } }, { "phase": "deferred", "propertyIndex": 0, "blendState": { "targets": [{ "blend": false }, { "blend": false }, { "blend": false }, { "blend": false }] }, "program": "terrain|terrain-vs|terrain-fs", "properties": { "UVScale": { "value": [1, 1, 1, 1], "type": 16 }, "lightMapUVParam": { "value": [0, 0, 0, 0], "type": 16 }, "metallic": { "value": [0, 0, 0, 0], "type": 16 }, "roughness": { "value": [1, 1, 1, 1], "type": 16 }, "weightMap": { "value": "black", "type": 28 }, "detailMap0": { "value": "grey", "type": 28 }, "detailMap1": { "value": "grey", "type": 28 }, "detailMap2": { "value": "grey", "type": 28 }, "detailMap3": { "value": "grey", "type": 28 }, "normalMap0": { "value": "normal", "type": 28 }, "normalMap1": { "value": "normal", "type": 28 }, "normalMap2": { "value": "normal", "type": 28 }, "normalMap3": { "value": "normal", "type": 28 }, "lightMap": { "value": "grey", "type": 28 } } }, { "phase": "forward-add", "propertyIndex": 0, "embeddedMacros": { "CC_FORWARD_ADD": true }, "blendState": { "targets": [{ "blend": true, "blendSrc": 1, "blendDst": 1, "blendSrcAlpha": 0, "blendDstAlpha": 1 }] }, "program": "terrain|terrain-vs|terrain-fs", "depthStencilState": { "depthFunc": 2, "depthTest": true, "depthWrite": false }, "properties": { "UVScale": { "value": [1, 1, 1, 1], "type": 16 }, "lightMapUVParam": { "value": [0, 0, 0, 0], "type": 16 }, "metallic": { "value": [0, 0, 0, 0], "type": 16 }, "roughness": { "value": [1, 1, 1, 1], "type": 16 }, "weightMap": { "value": "black", "type": 28 }, "detailMap0": { "value": "grey", "type": 28 }, "detailMap1": { "value": "grey", "type": 28 }, "detailMap2": { "value": "grey", "type": 28 }, "detailMap3": { "value": "grey", "type": 28 }, "normalMap0": { "value": "normal", "type": 28 }, "normalMap1": { "value": "normal", "type": 28 }, "normalMap2": { "value": "normal", "type": 28 }, "normalMap3": { "value": "normal", "type": 28 }, "lightMap": { "value": "grey", "type": 28 } } }, { "phase": "shadow-add", "propertyIndex": 0, "rasterizerState": { "cullMode": 2 }, "program": "terrain|shadow-caster-vs:vert|shadow-caster-fs:frag" }] } + { "name": "opaque", "passes": [{ "program": "terrain|terrain-vs|terrain-fs", "properties": { "UVScale": { "value": [1, 1, 1, 1], "type": 16 }, "lightMapUVParam": { "value": [0, 0, 0, 0], "type": 16 }, "metallic": { "value": [0, 0, 0, 0], "type": 16 }, "roughness": { "value": [1, 1, 1, 1], "type": 16 }, "weightMap": { "value": "black", "type": 28 }, "detailMap0": { "value": "grey", "type": 28 }, "detailMap1": { "value": "grey", "type": 28 }, "detailMap2": { "value": "grey", "type": 28 }, "detailMap3": { "value": "grey", "type": 28 }, "normalMap0": { "value": "normal", "type": 28 }, "normalMap1": { "value": "normal", "type": 28 }, "normalMap2": { "value": "normal", "type": 28 }, "normalMap3": { "value": "normal", "type": 28 }, "lightMap": { "value": "grey", "type": 28 } } }, { "phase": "forward-add", "propertyIndex": 0, "embeddedMacros": { "CC_FORWARD_ADD": true }, "blendState": { "targets": [{ "blend": true, "blendSrc": 1, "blendDst": 1, "blendSrcAlpha": 0, "blendDstAlpha": 1 }] }, "program": "terrain|terrain-vs|terrain-fs", "depthStencilState": { "depthFunc": 2, "depthTest": true, "depthWrite": false }, "properties": { "UVScale": { "value": [1, 1, 1, 1], "type": 16 }, "lightMapUVParam": { "value": [0, 0, 0, 0], "type": 16 }, "metallic": { "value": [0, 0, 0, 0], "type": 16 }, "roughness": { "value": [1, 1, 1, 1], "type": 16 }, "weightMap": { "value": "black", "type": 28 }, "detailMap0": { "value": "grey", "type": 28 }, "detailMap1": { "value": "grey", "type": 28 }, "detailMap2": { "value": "grey", "type": 28 }, "detailMap3": { "value": "grey", "type": 28 }, "normalMap0": { "value": "normal", "type": 28 }, "normalMap1": { "value": "normal", "type": 28 }, "normalMap2": { "value": "normal", "type": 28 }, "normalMap3": { "value": "normal", "type": 28 }, "lightMap": { "value": "grey", "type": 28 } } }, { "phase": "shadow-add", "propertyIndex": 0, "rasterizerState": { "cullMode": 2 }, "program": "terrain|shadow-caster-vs:vert|shadow-caster-fs:frag" }] } ], "shaders": [ { @@ -492,8 +512,8 @@ export const effects = [ "hash": 271165681, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 67, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 58 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }, { "name": "CCForwardLight", "defines": ["CC_FORWARD_ADD"] }], "samplerTextures": [{ "name": "cc_lightingMap", "defines": ["USE_LIGHTMAP", "!USE_BATCHING", "!CC_FORWARD_ADD"] }] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": [] }, { "name": "CCForwardLight", "defines": ["CC_FORWARD_ADD"] }], "samplerTextures": [{ "name": "cc_lightingMap", "defines": ["USE_LIGHTMAP", "!USE_BATCHING", "!CC_FORWARD_ADD"] }], "images": [] } }, "defines": [ { "name": "CC_USE_FOG", "type": "number", "range": [0, 4] }, @@ -509,6 +529,7 @@ export const effects = [ { "name": "CC_PIPELINE_TYPE", "type": "number", "range": [0, 1] }, { "name": "CC_STANDARD_TRANSPARENT", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "TexCoords", "defines": [], "binding": 0, "stageFlags": 1, "members": [ { "name": "UVScale", "type": 16, "count": 1 }, @@ -531,10 +552,11 @@ export const effects = [ { "name": "normalMap3", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 10 }, { "name": "lightMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 11 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 } ] }, { @@ -542,16 +564,18 @@ export const effects = [ "hash": 3278422876, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 65, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCLocal", "defines": [] }], "samplerTextures": [], "images": [] } }, "defines": [], + "buffers": [], "blocks": [], "samplerTextures": [], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 } ] } ] @@ -567,8 +591,8 @@ export const effects = [ "hash": 1017648509, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 195, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 39 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "images": [] } }, "defines": [ { "name": "CC_USE_MORPH", "type": "boolean" }, @@ -591,6 +615,7 @@ export const effects = [ { "name": "USE_ALPHA_TEST", "type": "boolean" }, { "name": "ALPHA_TEST_CHANNEL", "type": "string", "options": ["a", "r", "g", "b"] } ], + "buffers": [], "blocks": [ {"name": "TexCoords", "defines": ["USE_TEXTURE"], "binding": 0, "stageFlags": 1, "members": [ { "name": "tilingOffset", "type": 16, "count": 1 } @@ -603,21 +628,22 @@ export const effects = [ "samplerTextures": [ { "name": "mainTexture", "type": 28, "count": 1, "defines": ["USE_TEXTURE"], "stageFlags": 16, "binding": 2 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 }, - { "name": "a_tangent", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 3 }, - { "name": "a_vertexId", "type": 13, "count": 1, "defines": ["CC_USE_MORPH"], "stageFlags": 1, "format": 11, "location": 6 }, - { "name": "a_joints", "type": "u32vec4", "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "location": 4 }, - { "name": "a_weights", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "format": 44, "location": 5 }, - { "name": "a_jointAnimInfo", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 7 }, - { "name": "a_matWorld0", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 8 }, - { "name": "a_matWorld1", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 9 }, - { "name": "a_matWorld2", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 10 }, - { "name": "a_lightingMapUVParam", "type": 16, "count": 1, "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 11 }, - { "name": "a_dyn_batch_id", "type": 13, "count": 1, "defines": ["!USE_INSTANCING", "USE_BATCHING"], "stageFlags": 1, "format": 11, "location": 12 }, - { "name": "a_color", "type": 16, "count": 1, "defines": ["USE_VERTEX_COLOR"], "stageFlags": 1, "format": 44, "location": 13 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 }, + { "name": "a_matWorld0", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 8 }, + { "name": "a_matWorld1", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 9 }, + { "name": "a_matWorld2", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 10 }, + { "name": "a_lightingMapUVParam", "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "format": 44, "isInstanced": true, "location": 11 }, + { "name": "a_dyn_batch_id", "defines": ["!USE_INSTANCING", "USE_BATCHING"], "format": 11, "location": 12 }, + { "name": "a_color", "defines": ["USE_VERTEX_COLOR"], "format": 44, "location": 13 } ] } ] @@ -630,11 +656,11 @@ export const effects = [ "shaders": [ { "name": "deferred-lighting|lighting-vs|lighting-fs", - "hash": 2563484864, + "hash": 1125786565, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 37, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 56 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }, { "name": "cc_gbuffer_albedoMap", "defines": [] }, { "name": "cc_gbuffer_positionMap", "defines": [] }, { "name": "cc_gbuffer_normalMap", "defines": [] }, { "name": "cc_gbuffer_emissiveMap", "defines": [] }] }, - "locals": { "blocks": [{ "name": "CCForwardLight", "defines": [] }], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [{ "name": "cc_shadowMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_spotLightingMap", "defines": ["CC_RECEIVE_SHADOW"] }, { "name": "cc_environment", "defines": ["CC_USE_IBL"] }], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCForwardLight", "defines": [] }], "samplerTextures": [], "images": [] } }, "defines": [ { "name": "CC_RECEIVE_SHADOW", "type": "boolean" }, @@ -647,13 +673,20 @@ export const effects = [ { "name": "CC_STANDARD_TRANSPARENT", "type": "boolean" }, { "name": "CC_USE_FOG", "type": "number", "range": [0, 4] } ], + "buffers": [], "blocks": [], - "samplerTextures": [], + "samplerTextures": [ + { "name": "gbuffer_albedoMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 0 }, + { "name": "gbuffer_positionMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 1 }, + { "name": "gbuffer_normalMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 }, + { "name": "gbuffer_emissiveMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 3 } + ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 }, - { "name": "a_tangent", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 3 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 } ] } ] @@ -669,8 +702,8 @@ export const effects = [ "hash": 1115292548, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 213, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 56 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }, { "name": "CCShadow", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }, { "name": "CCLocalBatched", "defines": ["!USE_INSTANCING", "USE_BATCHING"] }, { "name": "CCLocal", "defines": ["!USE_INSTANCING", "!USE_BATCHING"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "images": [] } }, "defines": [ { "name": "CC_USE_MORPH", "type": "boolean" }, @@ -686,22 +719,24 @@ export const effects = [ { "name": "USE_LIGHTMAP", "type": "boolean" }, { "name": "CC_USE_HDR", "type": "boolean" } ], + "buffers": [], "blocks": [], "samplerTextures": [], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 }, - { "name": "a_tangent", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 3 }, - { "name": "a_vertexId", "type": 13, "count": 1, "defines": ["CC_USE_MORPH"], "stageFlags": 1, "format": 11, "location": 6 }, - { "name": "a_joints", "type": "u32vec4", "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "location": 4 }, - { "name": "a_weights", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "format": 44, "location": 5 }, - { "name": "a_jointAnimInfo", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 7 }, - { "name": "a_matWorld0", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 8 }, - { "name": "a_matWorld1", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 9 }, - { "name": "a_matWorld2", "type": 16, "count": 1, "defines": ["USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 10 }, - { "name": "a_lightingMapUVParam", "type": 16, "count": 1, "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 11 }, - { "name": "a_dyn_batch_id", "type": 13, "count": 1, "defines": ["!USE_INSTANCING", "USE_BATCHING"], "stageFlags": 1, "format": 11, "location": 12 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 }, + { "name": "a_matWorld0", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 8 }, + { "name": "a_matWorld1", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 9 }, + { "name": "a_matWorld2", "defines": ["USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 10 }, + { "name": "a_lightingMapUVParam", "defines": ["USE_INSTANCING", "USE_LIGHTMAP"], "format": 44, "isInstanced": true, "location": 11 }, + { "name": "a_dyn_batch_id", "defines": ["!USE_INSTANCING", "USE_BATCHING"], "format": 11, "location": 12 } ] } ] @@ -714,11 +749,11 @@ export const effects = [ "shaders": [ { "name": "post-process|post-process-vs|post-process-fs", - "hash": 1780456825, + "hash": 1551345262, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 145, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 37 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [{ "name": "cc_lighting_resultMap", "defines": [] }] }, - "locals": { "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [{ "name": "CCMorph", "defines": ["CC_USE_MORPH"] }, { "name": "CCSkinningTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinningAnimation", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }, { "name": "CCSkinning", "defines": ["CC_USE_SKINNING", "!CC_USE_BAKED_ANIMATION"] }], "samplerTextures": [{ "name": "cc_PositionDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_POSITION"] }, { "name": "cc_NormalDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_NORMAL"] }, { "name": "cc_TangentDisplacements", "defines": ["CC_USE_MORPH", "CC_MORPH_TARGET_HAS_TANGENT"] }, { "name": "cc_jointTexture", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION"] }], "images": [] } }, "defines": [ { "name": "CC_USE_MORPH", "type": "boolean" }, @@ -731,17 +766,21 @@ export const effects = [ { "name": "CC_USE_BAKED_ANIMATION", "type": "boolean" }, { "name": "USE_INSTANCING", "type": "boolean" } ], + "buffers": [], "blocks": [], - "samplerTextures": [], + "samplerTextures": [ + { "name": "lighting_resultMap", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 0 } + ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 }, - { "name": "a_tangent", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 3 }, - { "name": "a_vertexId", "type": 13, "count": 1, "defines": ["CC_USE_MORPH"], "stageFlags": 1, "format": 11, "location": 6 }, - { "name": "a_joints", "type": "u32vec4", "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "location": 4 }, - { "name": "a_weights", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING"], "stageFlags": 1, "format": 44, "location": 5 }, - { "name": "a_jointAnimInfo", "type": 16, "count": 1, "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "stageFlags": 1, "format": 44, "isInstanced": true, "location": 7 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 }, + { "name": "a_vertexId", "defines": ["CC_USE_MORPH"], "format": 11, "location": 6 }, + { "name": "a_joints", "defines": ["CC_USE_SKINNING"], "location": 4 }, + { "name": "a_weights", "defines": ["CC_USE_SKINNING"], "format": 44, "location": 5 }, + { "name": "a_jointAnimInfo", "defines": ["CC_USE_SKINNING", "CC_USE_BAKED_ANIMATION", "USE_INSTANCING"], "format": 44, "isInstanced": true, "location": 7 } ] } ] @@ -757,21 +796,23 @@ export const effects = [ "hash": 3169038185, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 37, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 37 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [{ "name": "cc_environment", "defines": [] }] }, - "locals": { "blocks": [], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [{ "name": "cc_environment", "defines": [] }], "images": [] }, + "locals": { "buffers": [], "blocks": [], "samplerTextures": [], "images": [] } }, "defines": [ { "name": "CC_USE_IBL", "type": "number", "range": [0, 2] }, { "name": "CC_USE_HDR", "type": "boolean" }, { "name": "USE_RGBE_CUBEMAP", "type": "boolean" } ], + "buffers": [], "blocks": [], "samplerTextures": [], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_normal", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 1 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 2 }, - { "name": "a_tangent", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 3 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_normal", "defines": [], "format": 32, "location": 1 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 2 }, + { "name": "a_tangent", "defines": [], "format": 44, "location": 3 } ] } ] @@ -779,20 +820,21 @@ export const effects = [ { "name": "profiler", "techniques": [ - { "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "rasterizerState": { "cullMode": 0 }, "program": "profiler|profiler-vs:vert|profiler-fs:frag", "depthStencilState": { "depthTest": false, "depthWrite": false } }] } + { "passes": [{ "blendState": { "targets": [{ "blend": true, "blendSrc": 2, "blendDst": 4, "blendDstAlpha": 4 }] }, "rasterizerState": { "cullMode": 0 }, "program": "profiler|profiler-vs:vert|profiler-fs:frag", "priority": 255, "depthStencilState": { "depthTest": false, "depthWrite": false } }] } ], "shaders": [ { "name": "profiler|profiler-vs:vert|profiler-fs:frag", - "hash": 3552712539, + "hash": 4249741501, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 58, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 37 }, - "globals": { "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [] }, - "locals": { "blocks": [], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [{ "name": "CCGlobal", "defines": [] }, { "name": "CCCamera", "defines": [] }], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [], "samplerTextures": [], "images": [] } }, "defines": [ { "name": "CC_USE_HDR", "type": "boolean" } ], + "buffers": [], "blocks": [ {"name": "Constants", "defines": [], "binding": 0, "stageFlags": 1, "members": [ { "name": "offset", "type": 16, "count": 1 } @@ -804,9 +846,10 @@ export const effects = [ "samplerTextures": [ { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 2 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 15, "count": 1, "defines": [], "stageFlags": 1, "format": 32, "location": 0 }, - { "name": "a_color", "type": 16, "count": 1, "defines": [], "stageFlags": 1, "format": 44, "location": 1 } + { "name": "a_position", "defines": [], "format": 32, "location": 0 }, + { "name": "a_color", "defines": [], "format": 44, "location": 1 } ] } ] @@ -822,10 +865,11 @@ export const effects = [ "hash": 1349506124, "builtins": { "statistics": { "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 6, "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 0 }, - "globals": { "blocks": [], "samplerTextures": [] }, - "locals": { "blocks": [], "samplerTextures": [] } + "globals": { "buffers": [], "blocks": [], "samplerTextures": [], "images": [] }, + "locals": { "buffers": [], "blocks": [], "samplerTextures": [], "images": [] } }, "defines": [], + "buffers": [], "blocks": [ {"name": "Constant", "defines": [], "binding": 0, "stageFlags": 1, "members": [ { "name": "u_buffer0", "type": 16, "count": 1 }, @@ -836,9 +880,10 @@ export const effects = [ "samplerTextures": [ { "name": "mainTexture", "type": 28, "count": 1, "defines": [], "stageFlags": 16, "binding": 1 } ], + "images": [], "attributes": [ - { "name": "a_position", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 0 }, - { "name": "a_texCoord", "type": 14, "count": 1, "defines": [], "stageFlags": 1, "format": 21, "location": 1 } + { "name": "a_position", "defines": [], "format": 21, "location": 0 }, + { "name": "a_texCoord", "defines": [], "format": 21, "location": 1 } ] } ] diff --git a/cocos/core/builtin/shader-sources/glsl1.ts b/cocos/core/builtin/shader-sources/glsl1.ts index faabb8d334..18b294c179 100644 --- a/cocos/core/builtin/shader-sources/glsl1.ts +++ b/cocos/core/builtin/shader-sources/glsl1.ts @@ -77,7 +77,7 @@ export const glsl1 = [ [ { "vert": "\nprecision highp float;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition.xy = cc_cameraPos.w == 0.0 ? vec2(position.xy.x, -position.xy.y) : position.xy;\ngl_Position = vec4(position.x, position.y, 1.0, 1.0);\nv_uv = a_texCoord;\n}", - "frag": "\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_exposure;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp mat4 cc_matLightViewProj;\nuniform highp vec4 cc_shadowInvProjDepthInfo;\nuniform highp vec4 cc_shadowProjDepthInfo;\nuniform highp vec4 cc_shadowProjInfo;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowWHPBInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newshadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewshadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newshadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n} else {\nfloat closestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\n}\n}\nreturn shadow / 9.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn texture2DLodEXT(tex, coord, lod);\n#else\nreturn texture2D(tex, coord, lod);\n#endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn textureCubeLodEXT(tex, coord, lod);\n#else\nreturn textureCube(tex, coord, lod);\n#endif\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse) * s.occlusion;\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nuniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\nuniform vec4 cc_lightColor[LIGHTS_PER_PASS];\nuniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nuniform vec4 cc_lightDir[LIGHTS_PER_PASS];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvarying vec2 v_uv;\nuniform sampler2D cc_gbuffer_albedoMap;\nuniform sampler2D cc_gbuffer_positionMap;\nuniform sampler2D cc_gbuffer_normalMap;\nuniform sampler2D cc_gbuffer_emissiveMap;\nvoid main () {\nStandardSurface s;\nvec4 albedoMap = texture2D(cc_gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture2D(cc_gbuffer_positionMap,v_uv);\nvec4 normalMap = texture2D(cc_gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture2D(cc_gbuffer_emissiveMap,v_uv);\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\n#if CC_USE_FOG == 0\nfogFactor = LinearFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 1\nfogFactor = ExpFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 2\nfogFactor = ExpSquaredFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 3\nfogFactor = LayeredFog(vec4(s.position, 1));\n#else\nfogFactor = 1.0;\n#endif\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\nCCStandardShadingAdditive(s, shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, fogFactor), color.a);\ngl_FragColor = CCFragOutput(color);\n}", + "frag": "\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_exposure;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp mat4 cc_matLightViewProj;\nuniform highp vec4 cc_shadowInvProjDepthInfo;\nuniform highp vec4 cc_shadowProjDepthInfo;\nuniform highp vec4 cc_shadowProjInfo;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowWHPBInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newshadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewshadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newshadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n} else {\nfloat closestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\n}\n}\nreturn shadow / 9.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn texture2DLodEXT(tex, coord, lod);\n#else\nreturn texture2D(tex, coord, lod);\n#endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn textureCubeLodEXT(tex, coord, lod);\n#else\nreturn textureCube(tex, coord, lod);\n#endif\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse) * s.occlusion;\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nuniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\nuniform vec4 cc_lightColor[LIGHTS_PER_PASS];\nuniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nuniform vec4 cc_lightDir[LIGHTS_PER_PASS];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvarying vec2 v_uv;\nuniform sampler2D gbuffer_albedoMap;\nuniform sampler2D gbuffer_positionMap;\nuniform sampler2D gbuffer_normalMap;\nuniform sampler2D gbuffer_emissiveMap;\nvoid main () {\nStandardSurface s;\nvec4 albedoMap = texture2D(gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture2D(gbuffer_positionMap,v_uv);\nvec4 normalMap = texture2D(gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture2D(gbuffer_emissiveMap,v_uv);\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\n#if CC_USE_FOG == 0\nfogFactor = LinearFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 1\nfogFactor = ExpFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 2\nfogFactor = ExpSquaredFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 3\nfogFactor = LayeredFog(vec4(s.position, 1));\n#else\nfogFactor = 1.0;\n#endif\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\nCCStandardShadingAdditive(s, shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, fogFactor), color.a);\ngl_FragColor = CCFragOutput(color);\n}", } ], [ @@ -89,7 +89,7 @@ export const glsl1 = [ [ { "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", - "frag": "\nprecision highp float;\nuniform mediump vec4 cc_screenSize;\nvarying vec2 v_uv;\nuniform sampler2D cc_lighting_resultMap;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\nvec4 texColor = texture2D(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\ngl_FragColor = fxaa(cc_lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}", + "frag": "\nprecision highp float;\nuniform mediump vec4 cc_screenSize;\nvarying vec2 v_uv;\nuniform sampler2D lighting_resultMap;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\nvec4 texColor = texture2D(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\ngl_FragColor = fxaa(lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}", } ], [ @@ -100,7 +100,7 @@ export const glsl1 = [ ], [ { - "vert": "\nprecision mediump float;\nuniform highp mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec2 v_uv;\nuniform vec4 offset;\nuniform vec4 digits[20];\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nvec4 position = cc_matViewProj * vec4(a_position, 1.0);\nposition.xy += offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "vert": "\nprecision mediump float;\nuniform highp mat4 cc_matProj;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec2 v_uv;\nuniform vec4 offset;\nuniform vec4 digits[20];\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nmat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);\nproj /= abs(proj[1].x + proj[1].y);\nvec2 position = proj * a_position.xy + offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn vec4(position, 0.0, 1.0);\n}\nvoid main() { gl_Position = vert(); }", "frag": "\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\nreturn CCFragOutput(texture2D(mainTexture, v_uv));\n}\nvoid main() { gl_FragColor = frag(); }", } ], diff --git a/cocos/core/builtin/shader-sources/glsl3.ts b/cocos/core/builtin/shader-sources/glsl3.ts index c987da7840..22249e6b56 100644 --- a/cocos/core/builtin/shader-sources/glsl3.ts +++ b/cocos/core/builtin/shader-sources/glsl3.ts @@ -77,7 +77,7 @@ export const glsl3 = [ [ { "vert": "\nprecision highp float;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nout vec2 v_uv;\nvoid main () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition.xy = cc_cameraPos.w == 0.0 ? vec2(position.xy.x, -position.xy.y) : position.xy;\ngl_Position = vec4(position.x, position.y, 1.0, 1.0);\nv_uv = a_texCoord;\n}", - "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newshadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewshadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newshadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n} else {\nfloat closestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\n}\n}\nreturn shadow / 9.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse) * s.occlusion;\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nlayout(std140) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nin vec2 v_uv;\nuniform sampler2D cc_gbuffer_albedoMap;\nuniform sampler2D cc_gbuffer_positionMap;\nuniform sampler2D cc_gbuffer_normalMap;\nuniform sampler2D cc_gbuffer_emissiveMap;\nlayout(location = 0) out vec4 fragColor;\nvoid main () {\nStandardSurface s;\nvec4 albedoMap = texture(cc_gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture(cc_gbuffer_positionMap,v_uv);\nvec4 normalMap = texture(cc_gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture(cc_gbuffer_emissiveMap,v_uv);\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\n#if CC_USE_FOG == 0\nfogFactor = LinearFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 1\nfogFactor = ExpFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 2\nfogFactor = ExpSquaredFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 3\nfogFactor = LayeredFog(vec4(s.position, 1));\n#else\nfogFactor = 1.0;\n#endif\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\nCCStandardShadingAdditive(s, shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, fogFactor), color.a);\nfragColor = CCFragOutput(color);\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newshadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewshadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newshadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n} else {\nfloat closestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\n}\n}\nreturn shadow / 9.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse) * s.occlusion;\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nlayout(std140) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nin vec2 v_uv;\nuniform sampler2D gbuffer_albedoMap;\nuniform sampler2D gbuffer_positionMap;\nuniform sampler2D gbuffer_normalMap;\nuniform sampler2D gbuffer_emissiveMap;\nlayout(location = 0) out vec4 fragColor;\nvoid main () {\nStandardSurface s;\nvec4 albedoMap = texture(gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture(gbuffer_positionMap,v_uv);\nvec4 normalMap = texture(gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture(gbuffer_emissiveMap,v_uv);\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\n#if CC_USE_FOG == 0\nfogFactor = LinearFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 1\nfogFactor = ExpFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 2\nfogFactor = ExpSquaredFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 3\nfogFactor = LayeredFog(vec4(s.position, 1));\n#else\nfogFactor = 1.0;\n#endif\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\nCCStandardShadingAdditive(s, shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, fogFactor), color.a);\nfragColor = CCFragOutput(color);\n}", } ], [ @@ -89,7 +89,7 @@ export const glsl3 = [ [ { "vert": "\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nout vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", - "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nin vec2 v_uv;\nuniform sampler2D cc_lighting_resultMap;\nlayout(location = 0) out vec4 fragColor;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture(tex, v_rgbSE).xyz;\nvec4 texColor = texture(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\nfragColor = fxaa(cc_lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}", + "frag": "\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nin vec2 v_uv;\nuniform sampler2D lighting_resultMap;\nlayout(location = 0) out vec4 fragColor;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture(tex, v_rgbSE).xyz;\nvec4 texColor = texture(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\nfragColor = fxaa(lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}", } ], [ @@ -100,7 +100,7 @@ export const glsl3 = [ ], [ { - "vert": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec2 v_uv;\nlayout(std140) uniform Constants {\nvec4 offset;\n};\nlayout(std140) uniform PerFrameInfo {\nvec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nvec4 position = cc_matViewProj * vec4(a_position, 1.0);\nposition.xy += offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "vert": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec2 v_uv;\nlayout(std140) uniform Constants {\nvec4 offset;\n};\nlayout(std140) uniform PerFrameInfo {\nvec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nmat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);\nproj /= abs(proj[1].x + proj[1].y);\nvec2 position = proj * a_position.xy + offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn vec4(position, 0.0, 1.0);\n}\nvoid main() { gl_Position = vert(); }", "frag": "\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\nreturn CCFragOutput(texture(mainTexture, v_uv));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", } ], diff --git a/cocos/core/builtin/shader-sources/glsl4.ts b/cocos/core/builtin/shader-sources/glsl4.ts index 8e1b66dcc2..bff6e872e4 100644 --- a/cocos/core/builtin/shader-sources/glsl4.ts +++ b/cocos/core/builtin/shader-sources/glsl4.ts @@ -77,7 +77,7 @@ export const glsl4 = [ [ { "vert": "\nprecision highp float;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(location = 0) out vec2 v_uv;\nvoid main () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition.xy = cc_cameraPos.w == 0.0 ? vec2(position.xy.x, -position.xy.y) : position.xy;\ngl_Position = vec4(position.x, position.y, 1.0, 1.0);\nv_uv = a_texCoord;\n}", - "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\n#if CC_RECEIVE_SHADOW\nlayout(set = 0, binding = 3) uniform sampler2D cc_shadowMap;\nlayout(set = 0, binding = 5) uniform sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newshadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewshadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newshadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n} else {\nfloat closestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\n}\n}\nreturn shadow / 9.0;\n}\n#endif\n#if CC_USE_IBL\nlayout(set = 0, binding = 4) uniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse) * s.occlusion;\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nlayout(set = 2, binding = 1) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nlayout(location = 0) in vec2 v_uv;\nlayout (set = 0, binding = 6) uniform sampler2D cc_gbuffer_albedoMap;\nlayout (set = 0, binding = 7) uniform sampler2D cc_gbuffer_positionMap;\nlayout (set = 0, binding = 8) uniform sampler2D cc_gbuffer_normalMap;\nlayout (set = 0, binding = 9) uniform sampler2D cc_gbuffer_emissiveMap;\nlayout(location = 0) out vec4 fragColor;\nvoid main () {\nStandardSurface s;\nvec4 albedoMap = texture(cc_gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture(cc_gbuffer_positionMap,v_uv);\nvec4 normalMap = texture(cc_gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture(cc_gbuffer_emissiveMap,v_uv);\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\n#if CC_USE_FOG == 0\nfogFactor = LinearFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 1\nfogFactor = ExpFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 2\nfogFactor = ExpSquaredFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 3\nfogFactor = LayeredFog(vec4(s.position, 1));\n#else\nfogFactor = 1.0;\n#endif\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\nCCStandardShadingAdditive(s, shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, fogFactor), color.a);\nfragColor = CCFragOutput(color);\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(set = 0, binding = 2) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\n#if CC_RECEIVE_SHADOW\nlayout(set = 0, binding = 3) uniform sampler2D cc_shadowMap;\nlayout(set = 0, binding = 5) uniform sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newshadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewshadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newshadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n} else {\nfloat closestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(offsetDepth, closestDepth);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = clipPos.z;\nfloat offsetDepth = depth;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\nshadow += step(offsetDepth, closestDepth);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(offsetDepth, closestDepth);\n}\n}\n}\nreturn shadow / 9.0;\n}\n#endif\n#if CC_USE_IBL\nlayout(set = 0, binding = 4) uniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.0);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse) * s.occlusion;\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nlayout(set = 2, binding = 1) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.0);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, s.position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, s.position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, s.position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 0) uniform sampler2D gbuffer_albedoMap;\nlayout(set = 1, binding = 1) uniform sampler2D gbuffer_positionMap;\nlayout(set = 1, binding = 2) uniform sampler2D gbuffer_normalMap;\nlayout(set = 1, binding = 3) uniform sampler2D gbuffer_emissiveMap;\nlayout(location = 0) out vec4 fragColor;\nvoid main () {\nStandardSurface s;\nvec4 albedoMap = texture(gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture(gbuffer_positionMap,v_uv);\nvec4 normalMap = texture(gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture(gbuffer_emissiveMap,v_uv);\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\n#if CC_USE_FOG == 0\nfogFactor = LinearFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 1\nfogFactor = ExpFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 2\nfogFactor = ExpSquaredFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 3\nfogFactor = LayeredFog(vec4(s.position, 1));\n#else\nfogFactor = 1.0;\n#endif\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\nCCStandardShadingAdditive(s, shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, fogFactor), color.a);\nfragColor = CCFragOutput(color);\n}", } ], [ @@ -89,7 +89,7 @@ export const glsl4 = [ [ { "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\nlayout(location = 3) in vec4 a_tangent;\n#if CC_USE_MORPH\nint getVertexId() {\nreturn gl_VertexIndex;\n}\nlayout(set = 2, binding = 4) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nlayout(set = 2, binding = 6) uniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nlayout(set = 2, binding = 7) uniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nlayout(set = 2, binding = 8) uniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nlayout(location = 4) in u32vec4 a_joints;\nlayout(location = 5) in vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nlayout(location = 7) in highp vec4 a_jointAnimInfo;\n#endif\nlayout(set = 2, binding = 3) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(set = 2, binding = 2) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nlayout(set = 2, binding = 5) uniform highp sampler2D cc_jointTexture;\n#else\nlayout(set = 2, binding = 3) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#else\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\n#else\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n}\n#endif\nmat4 skinMatrix () {\nvec4 joints = vec4(a_joints);\nreturn getJointMatrix(joints.x) * a_weights.x\n+ getJointMatrix(joints.y) * a_weights.y\n+ getJointMatrix(joints.z) * a_weights.z\n+ getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(location = 0) out vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}", - "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(location = 0) in vec2 v_uv;\nlayout (set = 0, binding = 10) uniform sampler2D cc_lighting_resultMap;\nlayout(location = 0) out vec4 fragColor;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture(tex, v_rgbSE).xyz;\nvec4 texColor = texture(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\nfragColor = fxaa(cc_lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}", + "frag": "\nprecision highp float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 0) uniform sampler2D lighting_resultMap;\nlayout(location = 0) out vec4 fragColor;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture(tex, v_rgbSE).xyz;\nvec4 texColor = texture(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\nfragColor = fxaa(lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}", } ], [ @@ -100,7 +100,7 @@ export const glsl4 = [ ], [ { - "vert": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec4 a_color;\nlayout(location = 0) out vec2 v_uv;\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 offset;\n};\nlayout(set = 1, binding = 1) uniform PerFrameInfo {\nvec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nvec4 position = cc_matViewProj * vec4(a_position, 1.0);\nposition.xy += offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn position;\n}\nvoid main() { gl_Position = vert(); }", + "vert": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec4 a_color;\nlayout(location = 0) out vec2 v_uv;\nlayout(set = 1, binding = 0) uniform Constants {\nvec4 offset;\n};\nlayout(set = 1, binding = 1) uniform PerFrameInfo {\nvec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nmat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);\nproj /= abs(proj[1].x + proj[1].y);\nvec2 position = proj * a_position.xy + offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn vec4(position, 0.0, 1.0);\n}\nvoid main() { gl_Position = vert(); }", "frag": "\nprecision mediump float;\nlayout(set = 0, binding = 0) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nlayout(location = 0) in vec2 v_uv;\nlayout(set = 1, binding = 2) uniform sampler2D mainTexture;\nvec4 frag () {\nreturn CCFragOutput(texture(mainTexture, v_uv));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }", } ], diff --git a/cocos/core/director.ts b/cocos/core/director.ts index a46bbbee11..2b6503a347 100644 --- a/cocos/core/director.ts +++ b/cocos/core/director.ts @@ -793,8 +793,7 @@ export class Director extends EventTarget { private _init () { // The test environment does not currently support the renderer if (TEST) return Promise.resolve(); - // @ts-expect-error internal api usage - this._root = new Root(game._gfxDevice); + this._root = new Root(game._gfxDevice!); const rootInfo = {}; return this._root.initialize(rootInfo).catch((error) => { errorID(1217); diff --git a/cocos/core/game.ts b/cocos/core/game.ts index d64338878b..75e83c1bc2 100644 --- a/cocos/core/game.ts +++ b/cocos/core/game.ts @@ -34,7 +34,7 @@ import { IAssetManagerOptions } from './asset-manager/asset-manager'; import { EventTarget } from './event/event-target'; import * as debug from './platform/debug'; import inputManager from './platform/event-manager/input-manager'; -import { Device, DeviceInfo } from './gfx'; +import { Device, DeviceInfo, SampleCount, Swapchain, SwapchainInfo } from './gfx'; import { sys } from './platform/sys'; import { macro } from './platform/macro'; import { ICustomJointTextureLayout } from '../3d/skeletal-animation/skeletal-animation-utils'; @@ -366,7 +366,8 @@ export class Game extends EventTarget { public _persistRootNodes = {}; - private _gfxDevice: Device | null = null; + public _gfxDevice: Device | null = null; + public _swapchain: Swapchain | null = null; // states public _configLoaded = false; // whether config loaded public _isCloning = false; // deserializing or instantiating @@ -825,18 +826,10 @@ export class Game extends EventTarget { if (this.renderType === Game.RENDER_TYPE_WEBGL) { const ctors: Constructor[] = []; - const opts = new DeviceInfo( - this.canvas as HTMLCanvasElement, - EDITOR || macro.ENABLE_WEBGL_ANTIALIAS, - false, - window.devicePixelRatio, - sys.windowPixelResolution.width, - sys.windowPixelResolution.height, - bindingMappingInfo, - ); + const deviceInfo = new DeviceInfo(bindingMappingInfo); if (JSB && window.gfx) { - this._gfxDevice = gfx.DeviceManager.create(opts); + this._gfxDevice = gfx.DeviceManager.create(deviceInfo); } else { let useWebGL2 = (!!window.WebGL2RenderingContext); const userAgent = window.navigator.userAgent.toLowerCase(); @@ -851,10 +844,13 @@ export class Game extends EventTarget { if (legacyCC.WebGLDevice) { ctors.push(legacyCC.WebGLDevice); } + if (legacyCC.EmptyDevice) { + ctors.push(legacyCC.EmptyDevice); + } for (let i = 0; i < ctors.length; i++) { this._gfxDevice = new ctors[i](); - if (this._gfxDevice.initialize(opts)) { break; } + if (this._gfxDevice.initialize(deviceInfo)) { break; } } } } @@ -866,6 +862,11 @@ export class Game extends EventTarget { return; } + const swapchainInfo = new SwapchainInfo(this.canvas!); + swapchainInfo.width = sys.windowPixelResolution.width; + swapchainInfo.height = sys.windowPixelResolution.height; + this._swapchain = this._gfxDevice.createSwapchain(swapchainInfo); + this.canvas!.oncontextmenu = () => false; } diff --git a/cocos/core/gfx/base/buffer.ts b/cocos/core/gfx/base/buffer.ts index 1b7167f3b2..ae52e49876 100644 --- a/cocos/core/gfx/base/buffer.ts +++ b/cocos/core/gfx/base/buffer.ts @@ -28,7 +28,6 @@ * @module gfx */ -import { Device } from './device'; import { BufferFlagBit, BufferFlags, @@ -36,9 +35,8 @@ import { BufferUsageBit, MemoryUsage, MemoryUsageBit, - Obj, + GFXObject, ObjectType, - IndirectBuffer, BufferInfo, BufferViewInfo, BufferSource, @@ -48,7 +46,7 @@ import { * @en GFX buffer. * @zh GFX 缓冲。 */ -export abstract class Buffer extends Obj { +export abstract class Buffer extends GFXObject { /** * @en Usage type of the buffer. * @zh 缓冲使用方式。 @@ -93,22 +91,19 @@ export abstract class Buffer extends Obj { return this._flags; } - protected _device: Device; protected _usage: BufferUsage = BufferUsageBit.NONE; protected _memUsage: MemoryUsage = MemoryUsageBit.NONE; protected _size = 0; protected _stride = 1; protected _count = 0; protected _flags: BufferFlags = BufferFlagBit.NONE; - protected _indirectBuffer: IndirectBuffer | null = null; protected _isBufferView = false; - constructor (device: Device) { + constructor () { super(ObjectType.BUFFER); - this._device = device; } - public abstract initialize (info: BufferInfo | BufferViewInfo): boolean; + public abstract initialize (info: BufferInfo | BufferViewInfo): void; public abstract destroy (): void; diff --git a/cocos/core/gfx/base/command-buffer.ts b/cocos/core/gfx/base/command-buffer.ts index e402e55e92..17774281ed 100644 --- a/cocos/core/gfx/base/command-buffer.ts +++ b/cocos/core/gfx/base/command-buffer.ts @@ -30,7 +30,6 @@ import { Buffer } from './buffer'; import { DescriptorSet } from './descriptor-set'; -import { Device } from './device'; import { Framebuffer } from './framebuffer'; import { InputAssembler } from './input-assembler'; import { PipelineState } from './pipeline-state'; @@ -38,22 +37,22 @@ import { Queue } from './queue'; import { RenderPass } from './render-pass'; import { Texture } from './texture'; import { - Obj, + GFXObject, ObjectType, StencilFace, CommandBufferType, CommandBufferInfo, BufferTextureCopy, Color, Rect, Viewport, DrawInfo, } from './define'; -import { GlobalBarrier } from './global-barrier'; -import { TextureBarrier } from './texture-barrier'; +import { GlobalBarrier } from './states/global-barrier'; +import { TextureBarrier } from './states/texture-barrier'; /** * @en GFX command buffer. * @zh GFX 命令缓冲。 */ -export abstract class CommandBuffer extends Obj { +export abstract class CommandBuffer extends GFXObject { /** * @en Type of the command buffer. * @zh 命令缓冲类型。 @@ -94,24 +93,17 @@ export abstract class CommandBuffer extends Obj { return this._numTris; } - protected _device: Device; - protected _queue: Queue | null = null; - protected _type: CommandBufferType = CommandBufferType.PRIMARY; - protected _numDrawCalls = 0; - protected _numInstances = 0; - protected _numTris = 0; - constructor (device: Device) { + constructor () { super(ObjectType.COMMAND_BUFFER); - this._device = device; } - public abstract initialize (info: CommandBufferInfo): boolean; + public abstract initialize (info: CommandBufferInfo): void; public abstract destroy (): void; @@ -238,9 +230,9 @@ export abstract class CommandBuffer extends Obj { /** * @en Draw the specified primitives. * @zh 绘制。 - * @param info The draw call information. + * @param infoOrAssembler The draw call information. */ - public abstract draw (info: DrawInfo | InputAssembler): void; + public abstract draw (infoOrAssembler: DrawInfo | InputAssembler): void; /** * @en Update buffer. @@ -275,5 +267,5 @@ export abstract class CommandBuffer extends Obj { * @param globalBarrier The global memory barrier to apply. * @param textureBarriers The texture memory barriers to apply. */ - public abstract pipelineBarrier (globalBarrier: GlobalBarrier, textureBarriers: TextureBarrier[] | null): void; + public abstract pipelineBarrier (globalBarrier: GlobalBarrier | null, textureBarriers?: TextureBarrier[], textures?: Texture[]): void; } diff --git a/cocos/core/gfx/base/define.ts b/cocos/core/gfx/base/define.ts index b9eb543383..e234591455 100644 --- a/cocos/core/gfx/base/define.ts +++ b/cocos/core/gfx/base/define.ts @@ -28,11 +28,13 @@ * @module gfx */ +import { ccenum } from '../../value-types/enum'; import { Buffer } from './buffer'; import { DescriptorSetLayout } from './descriptor-set-layout'; import { Queue } from './queue'; import { RenderPass } from './render-pass'; -import { Sampler } from './sampler'; +import { Sampler } from './states/sampler'; +import { Swapchain } from './swapchain'; import { Texture } from './texture'; interface ICopyable { copy(info: ICopyable): ICopyable; } @@ -55,6 +57,7 @@ const deepCopy = (target: T[], source: T[], Ctor: Construct export enum ObjectType { UNKNOWN, + SWAPCHAIN, BUFFER, TEXTURE, RENDER_PASS, @@ -71,6 +74,7 @@ export enum ObjectType { GLOBAL_BARRIER, TEXTURE_BARRIER, BUFFER_BARRIER, + COUNT, } export enum Status { @@ -185,12 +189,8 @@ export enum Format { RGB9E5, // Depth-Stencil Format - D16, - D16S8, - D24, - D24S8, - D32F, - D32F_S8, + DEPTH, + DEPTH_STENCIL, // Compressed Format @@ -367,8 +367,8 @@ export enum MemoryAccessBit { export enum MemoryUsageBit { NONE = 0, - DEVICE = 0x1, - HOST = 0x2, + DEVICE = 0x1, // for rarely-updated resources, use MemoryUsageBit::DEVICE + HOST = 0x2, // for frequently-updated resources, use MemoryUsageBit::DEVICE | MemoryUsageBit::HOST } export enum TextureType { @@ -393,19 +393,40 @@ export enum TextureUsageBit { export enum TextureFlagBit { NONE = 0, - GEN_MIPMAP = 0x1, - IMMUTABLE = 0x2, - GENERAL_LAYOUT = 0x4, + GEN_MIPMAP = 0x1, // Generate mipmaps using bilinear filter + RESIZABLE = 0x2, // Make the texture resizable, should be avoided whenever possible + GENERAL_LAYOUT = 0x4, // For inout framebuffer attachments } export enum SampleCount { - X1 = 0x1, - X2 = 0x2, - X4 = 0x4, - X8 = 0x8, - X16 = 0x10, - X32 = 0x20, - X64 = 0x40, + ONE, // Single sample + MULTIPLE_PERFORMANCE, // Multiple samples prioritizing performance over quality + MULTIPLE_BALANCE, // Multiple samples leveraging both quality and performance + MULTIPLE_QUALITY, // Multiple samples prioritizing quality over performance +} + +export enum VsyncMode { + // The application does not synchronizes with the vertical sync. + // If application renders faster than the display refreshes, frames are wasted and tearing may be observed. + // FPS is uncapped. Maximum power consumption. If unsupported, "ON" value will be used instead. Minimum latency. + OFF, + // The application is always synchronized with the vertical sync. Tearing does not happen. + // FPS is capped to the display's refresh rate. For fast applications, battery life is improved. Always supported. + ON, + // The application synchronizes with the vertical sync, but only if the application rendering speed is greater than refresh rate. + // Compared to OFF, there is no tearing. Compared to ON, the FPS will be improved for "slower" applications. + // If unsupported, "ON" value will be used instead. Recommended for most applications. Default if supported. + RELAXED, + // The presentation engine will always use the latest fully rendered image. + // Compared to OFF, no tearing will be observed. + // Compared to ON, battery power will be worse, especially for faster applications. + // If unsupported, "OFF" will be attempted next. + MAILBOX, + // The application is capped to using half the vertical sync time. + // FPS artificially capped to Half the display speed (usually 30fps) to maintain battery. + // Best possible battery savings. Worst possible performance. + // Recommended for specific applications where battery saving is critical. + HALF, } export enum Filter { @@ -655,7 +676,7 @@ export class Size { public z: number = 0, ) {} - public copy (info: Size) { + public copy (info: Readonly) { this.x = info.x; this.y = info.y; this.z = info.z; @@ -680,8 +701,6 @@ export class DeviceCaps { public maxUniformBlockSize: number = 0, public maxTextureSize: number = 0, public maxCubeMapTextureSize: number = 0, - public depthBits: number = 0, - public stencilBits: number = 0, public uboOffsetAlignment: number = 1, public maxComputeSharedMemorySize: number = 0, public maxComputeWorkGroupInvocations: number = 0, @@ -692,7 +711,7 @@ export class DeviceCaps { public clipSpaceSignY: number = 1, ) {} - public copy (info: DeviceCaps) { + public copy (info: Readonly) { this.maxVertexAttributes = info.maxVertexAttributes; this.maxVertexUniformVectors = info.maxVertexUniformVectors; this.maxFragmentUniformVectors = info.maxFragmentUniformVectors; @@ -706,8 +725,6 @@ export class DeviceCaps { this.maxUniformBlockSize = info.maxUniformBlockSize; this.maxTextureSize = info.maxTextureSize; this.maxCubeMapTextureSize = info.maxCubeMapTextureSize; - this.depthBits = info.depthBits; - this.stencilBits = info.stencilBits; this.uboOffsetAlignment = info.uboOffsetAlignment; this.maxComputeSharedMemorySize = info.maxComputeSharedMemorySize; this.maxComputeWorkGroupInvocations = info.maxComputeWorkGroupInvocations; @@ -729,7 +746,7 @@ export class Offset { public z: number = 0, ) {} - public copy (info: Offset) { + public copy (info: Readonly) { this.x = info.x; this.y = info.y; this.z = info.z; @@ -747,7 +764,7 @@ export class Rect { public height: number = 0, ) {} - public copy (info: Rect) { + public copy (info: Readonly) { this.x = info.x; this.y = info.y; this.width = info.width; @@ -765,7 +782,7 @@ export class Extent { public depth: number = 1, ) {} - public copy (info: Extent) { + public copy (info: Readonly) { this.width = info.width; this.height = info.height; this.depth = info.depth; @@ -782,7 +799,7 @@ export class TextureSubresLayers { public layerCount: number = 1, ) {} - public copy (info: TextureSubresLayers) { + public copy (info: Readonly) { this.mipLevel = info.mipLevel; this.baseArrayLayer = info.baseArrayLayer; this.layerCount = info.layerCount; @@ -800,7 +817,7 @@ export class TextureSubresRange { public layerCount: number = 1, ) {} - public copy (info: TextureSubresRange) { + public copy (info: Readonly) { this.baseMipLevel = info.baseMipLevel; this.levelCount = info.levelCount; this.baseArrayLayer = info.baseArrayLayer; @@ -820,7 +837,7 @@ export class TextureCopy { public extent: Extent = new Extent(), ) {} - public copy (info: TextureCopy) { + public copy (info: Readonly) { this.srcSubres.copy(info.srcSubres); this.srcOffset.copy(info.srcOffset); this.dstSubres.copy(info.dstSubres); @@ -842,7 +859,7 @@ export class TextureBlit { public dstExtent: Extent = new Extent(), ) {} - public copy (info: TextureBlit) { + public copy (info: Readonly) { this.srcSubres.copy(info.srcSubres); this.srcOffset.copy(info.srcOffset); this.srcExtent.copy(info.srcExtent); @@ -864,7 +881,7 @@ export class BufferTextureCopy { public texSubres: TextureSubresLayers = new TextureSubresLayers(), ) {} - public copy (info: BufferTextureCopy) { + public copy (info: Readonly) { this.buffStride = info.buffStride; this.buffTexHeight = info.buffTexHeight; this.texOffset.copy(info.texOffset); @@ -886,7 +903,7 @@ export class Viewport { public maxDepth: number = 1, ) {} - public copy (info: Viewport) { + public copy (info: Readonly) { this.left = info.left; this.top = info.top; this.width = info.width; @@ -907,7 +924,7 @@ export class Color { public w: number = 0, ) {} - public copy (info: Color) { + public copy (info: Readonly) { this.x = info.x; this.y = info.y; this.z = info.z; @@ -925,7 +942,7 @@ export class BindingMappingInfo { public flexibleSet: number = 0, ) {} - public copy (info: BindingMappingInfo) { + public copy (info: Readonly) { this.bufferOffsets = info.bufferOffsets.slice(); this.samplerOffsets = info.samplerOffsets.slice(); this.flexibleSet = info.flexibleSet; @@ -933,6 +950,38 @@ export class BindingMappingInfo { } } +export class SwapchainInfo { + declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object + + constructor ( + public windowHandle: HTMLCanvasElement = null!, + public vsyncMode: VsyncMode = VsyncMode.RELAXED, + public width: number = 0, + public height: number = 0, + ) {} + + public copy (info: Readonly) { + this.windowHandle = info.windowHandle; + this.vsyncMode = info.vsyncMode; + this.width = info.width; + this.height = info.height; + return this; + } +} + +export class DeviceInfo { + declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object + + constructor ( + public bindingMappingInfo: BindingMappingInfo = new BindingMappingInfo(), + ) {} + + public copy (info: Readonly) { + this.bindingMappingInfo.copy(info.bindingMappingInfo); + return this; + } +} + export class BufferInfo { declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object @@ -944,7 +993,7 @@ export class BufferInfo { public flags: BufferFlags = BufferFlagBit.NONE, ) {} - public copy (info: BufferInfo) { + public copy (info: Readonly) { this.usage = info.usage; this.memUsage = info.memUsage; this.size = info.size; @@ -963,7 +1012,7 @@ export class BufferViewInfo { public range: number = 0, ) {} - public copy (info: BufferViewInfo) { + public copy (info: Readonly) { this.buffer = info.buffer; this.offset = info.offset; this.range = info.range; @@ -984,7 +1033,7 @@ export class DrawInfo { public firstInstance: number = 0, ) {} - public copy (info: DrawInfo) { + public copy (info: Readonly) { this.vertexCount = info.vertexCount; this.firstVertex = info.firstVertex; this.indexCount = info.indexCount; @@ -1007,7 +1056,7 @@ export class DispatchInfo { public indirectOffset: number = 0, ) {} - public copy (info: DispatchInfo) { + public copy (info: Readonly) { this.groupCountX = info.groupCountX; this.groupCountY = info.groupCountY; this.groupCountZ = info.groupCountZ; @@ -1024,7 +1073,7 @@ export class IndirectBuffer { public drawInfos: DrawInfo[] = [], ) {} - public copy (info: IndirectBuffer) { + public copy (info: Readonly) { deepCopy(this.drawInfos, info.drawInfos, DrawInfo); return this; } @@ -1042,11 +1091,12 @@ export class TextureInfo { public flags: TextureFlags = TextureFlagBit.NONE, public layerCount: number = 1, public levelCount: number = 1, - public samples: SampleCount = SampleCount.X1, + public samples: SampleCount = SampleCount.ONE, public depth: number = 1, + public externalRes: number = 0, ) {} - public copy (info: TextureInfo) { + public copy (info: Readonly) { this.type = info.type; this.usage = info.usage; this.format = info.format; @@ -1057,6 +1107,7 @@ export class TextureInfo { this.levelCount = info.levelCount; this.samples = info.samples; this.depth = info.depth; + this.externalRes = info.externalRes; return this; } } @@ -1074,7 +1125,7 @@ export class TextureViewInfo { public layerCount: number = 1, ) {} - public copy (info: TextureViewInfo) { + public copy (info: Readonly) { this.texture = info.texture; this.type = info.type; this.format = info.format; @@ -1098,11 +1149,9 @@ export class SamplerInfo { public addressW: Address = Address.WRAP, public maxAnisotropy: number = 0, public cmpFunc: ComparisonFunc = ComparisonFunc.ALWAYS, - public borderColor: Color = new Color(), - public mipLODBias: number = 0, ) {} - public copy (info: SamplerInfo) { + public copy (info: Readonly) { this.minFilter = info.minFilter; this.magFilter = info.magFilter; this.mipFilter = info.mipFilter; @@ -1111,8 +1160,6 @@ export class SamplerInfo { this.addressW = info.addressW; this.maxAnisotropy = info.maxAnisotropy; this.cmpFunc = info.cmpFunc; - this.borderColor.copy(info.borderColor); - this.mipLODBias = info.mipLODBias; return this; } } @@ -1126,7 +1173,7 @@ export class Uniform { public count: number = 0, ) {} - public copy (info: Uniform) { + public copy (info: Readonly) { this.name = info.name; this.type = info.type; this.count = info.count; @@ -1145,7 +1192,7 @@ export class UniformBlock { public count: number = 0, ) {} - public copy (info: UniformBlock) { + public copy (info: Readonly) { this.set = info.set; this.binding = info.binding; this.name = info.name; @@ -1166,7 +1213,7 @@ export class UniformSamplerTexture { public count: number = 0, ) {} - public copy (info: UniformSamplerTexture) { + public copy (info: Readonly) { this.set = info.set; this.binding = info.binding; this.name = info.name; @@ -1186,7 +1233,7 @@ export class UniformSampler { public count: number = 0, ) {} - public copy (info: UniformSampler) { + public copy (info: Readonly) { this.set = info.set; this.binding = info.binding; this.name = info.name; @@ -1206,7 +1253,7 @@ export class UniformTexture { public count: number = 0, ) {} - public copy (info: UniformTexture) { + public copy (info: Readonly) { this.set = info.set; this.binding = info.binding; this.name = info.name; @@ -1228,7 +1275,7 @@ export class UniformStorageImage { public memoryAccess: MemoryAccess = MemoryAccessBit.READ_WRITE, ) {} - public copy (info: UniformStorageImage) { + public copy (info: Readonly) { this.set = info.set; this.binding = info.binding; this.name = info.name; @@ -1250,7 +1297,7 @@ export class UniformStorageBuffer { public memoryAccess: MemoryAccess = MemoryAccessBit.READ_WRITE, ) {} - public copy (info: UniformStorageBuffer) { + public copy (info: Readonly) { this.set = info.set; this.binding = info.binding; this.name = info.name; @@ -1270,7 +1317,7 @@ export class UniformInputAttachment { public count: number = 0, ) {} - public copy (info: UniformInputAttachment) { + public copy (info: Readonly) { this.set = info.set; this.binding = info.binding; this.name = info.name; @@ -1287,7 +1334,7 @@ export class ShaderStage { public source: string = '', ) {} - public copy (info: ShaderStage) { + public copy (info: Readonly) { this.stage = info.stage; this.source = info.source; return this; @@ -1306,7 +1353,7 @@ export class Attribute { public location: number = 0, ) {} - public copy (info: Attribute) { + public copy (info: Readonly) { this.name = info.name; this.format = info.format; this.isNormalized = info.isNormalized; @@ -1333,7 +1380,7 @@ export class ShaderInfo { public subpassInputs: UniformInputAttachment[] = [], ) {} - public copy (info: ShaderInfo) { + public copy (info: Readonly) { this.name = info.name; deepCopy(this.stages, info.stages, ShaderStage); deepCopy(this.attributes, info.attributes, Attribute); @@ -1358,7 +1405,7 @@ export class InputAssemblerInfo { public indirectBuffer: Buffer | null = null, ) {} - public copy (info: InputAssemblerInfo) { + public copy (info: Readonly) { deepCopy(this.attributes, info.attributes, Attribute); this.vertexBuffers = info.vertexBuffers.slice(); this.indexBuffer = info.indexBuffer; @@ -1372,15 +1419,15 @@ export class ColorAttachment { constructor ( public format: Format = Format.UNKNOWN, - public sampleCount: SampleCount = SampleCount.X1, + public sampleCount: SampleCount = SampleCount.ONE, public loadOp: LoadOp = LoadOp.CLEAR, public storeOp: StoreOp = StoreOp.STORE, public beginAccesses: AccessType[] = [], - public endAccesses: AccessType[] = [AccessType.PRESENT], + public endAccesses: AccessType[] = [AccessType.COLOR_ATTACHMENT_WRITE], public isGeneralLayout: boolean = false, ) {} - public copy (info: ColorAttachment) { + public copy (info: Readonly) { this.format = info.format; this.sampleCount = info.sampleCount; this.loadOp = info.loadOp; @@ -1397,7 +1444,7 @@ export class DepthStencilAttachment { constructor ( public format: Format = Format.UNKNOWN, - public sampleCount: SampleCount = SampleCount.X1, + public sampleCount: SampleCount = SampleCount.ONE, public depthLoadOp: LoadOp = LoadOp.CLEAR, public depthStoreOp: StoreOp = StoreOp.STORE, public stencilLoadOp: LoadOp = LoadOp.CLEAR, @@ -1407,7 +1454,7 @@ export class DepthStencilAttachment { public isGeneralLayout: boolean = false, ) {} - public copy (info: DepthStencilAttachment) { + public copy (info: Readonly) { this.format = info.format; this.sampleCount = info.sampleCount; this.depthLoadOp = info.depthLoadOp; @@ -1435,7 +1482,7 @@ export class SubpassInfo { public stencilResolveMode: ResolveMode = ResolveMode.NONE, ) {} - public copy (info: SubpassInfo) { + public copy (info: Readonly) { this.inputs = info.inputs.slice(); this.colors = info.colors.slice(); this.resolves = info.resolves.slice(); @@ -1458,7 +1505,7 @@ export class SubpassDependency { public dstAccesses: AccessType[] = [], ) {} - public copy (info: SubpassDependency) { + public copy (info: Readonly) { this.srcSubpass = info.srcSubpass; this.dstSubpass = info.dstSubpass; this.srcAccesses = info.srcAccesses.slice(); @@ -1477,7 +1524,7 @@ export class RenderPassInfo { public dependencies: SubpassDependency[] = [], ) {} - public copy (info: RenderPassInfo) { + public copy (info: Readonly) { deepCopy(this.colorAttachments, info.colorAttachments, ColorAttachment); this.depthStencilAttachment.copy(info.depthStencilAttachment); deepCopy(this.subpasses, info.subpasses, SubpassInfo); @@ -1494,7 +1541,7 @@ export class GlobalBarrierInfo { public nextAccesses: AccessType[] = [], ) {} - public copy (info: GlobalBarrierInfo) { + public copy (info: Readonly) { this.prevAccesses = info.prevAccesses.slice(); this.nextAccesses = info.nextAccesses.slice(); return this; @@ -1512,7 +1559,7 @@ export class TextureBarrierInfo { public dstQueue: Queue | null = null, ) {} - public copy (info: TextureBarrierInfo) { + public copy (info: Readonly) { this.prevAccesses = info.prevAccesses.slice(); this.nextAccesses = info.nextAccesses.slice(); this.discardContents = info.discardContents; @@ -1527,11 +1574,11 @@ export class FramebufferInfo { constructor ( public renderPass: RenderPass = null!, - public colorTextures: (Texture | null)[] = [], + public colorTextures: Texture[] = [], public depthStencilTexture: Texture | null = null, ) {} - public copy (info: FramebufferInfo) { + public copy (info: Readonly) { this.renderPass = info.renderPass; this.colorTextures = info.colorTextures.slice(); this.depthStencilTexture = info.depthStencilTexture; @@ -1550,7 +1597,7 @@ export class DescriptorSetLayoutBinding { public immutableSamplers: Sampler[] = [], ) {} - public copy (info: DescriptorSetLayoutBinding) { + public copy (info: Readonly) { this.binding = info.binding; this.descriptorType = info.descriptorType; this.count = info.count; @@ -1567,7 +1614,7 @@ export class DescriptorSetLayoutInfo { public bindings: DescriptorSetLayoutBinding[] = [], ) {} - public copy (info: DescriptorSetLayoutInfo) { + public copy (info: Readonly) { deepCopy(this.bindings, info.bindings, DescriptorSetLayoutBinding); return this; } @@ -1580,7 +1627,7 @@ export class DescriptorSetInfo { public layout: DescriptorSetLayout = null!, ) {} - public copy (info: DescriptorSetInfo) { + public copy (info: Readonly) { this.layout = info.layout; return this; } @@ -1593,7 +1640,7 @@ export class PipelineLayoutInfo { public setLayouts: DescriptorSetLayout[] = [], ) {} - public copy (info: PipelineLayoutInfo) { + public copy (info: Readonly) { this.setLayouts = info.setLayouts.slice(); return this; } @@ -1606,7 +1653,7 @@ export class InputState { public attributes: Attribute[] = [], ) {} - public copy (info: InputState) { + public copy (info: Readonly) { deepCopy(this.attributes, info.attributes, Attribute); return this; } @@ -1620,7 +1667,7 @@ export class CommandBufferInfo { public type: CommandBufferType = CommandBufferType.PRIMARY, ) {} - public copy (info: CommandBufferInfo) { + public copy (info: Readonly) { this.queue = info.queue; this.type = info.type; return this; @@ -1634,7 +1681,7 @@ export class QueueInfo { public type: QueueType = QueueType.GRAPHICS, ) {} - public copy (info: QueueInfo) { + public copy (info: Readonly) { this.type = info.type; return this; } @@ -1663,7 +1710,7 @@ export class MemoryStatus { public textureSize: number = 0, ) {} - public copy (info: MemoryStatus) { + public copy (info: Readonly) { this.bufferSize = info.bufferSize; this.textureSize = info.textureSize; return this; @@ -1679,7 +1726,7 @@ export class DynamicStencilStates { public reference: number = 0, ) {} - public copy (info: DynamicStencilStates) { + public copy (info: Readonly) { this.writeMask = info.writeMask; this.compareMask = info.compareMask; this.reference = info.reference; @@ -1704,7 +1751,7 @@ export class DynamicStates { public stencilStatesBack: DynamicStencilStates = new DynamicStencilStates(), ) {} - public copy (info: DynamicStates) { + public copy (info: Readonly) { this.viewport.copy(info.viewport); this.scissor.copy(info.scissor); this.blendConstant.copy(info.blendConstant); @@ -1728,65 +1775,43 @@ export class DynamicStates { * ========================= !DO NOT CHANGE THE ABOVE SECTION MANUALLY! ========================= */ +ccenum(Format); + /** * @en GFX base object. * @zh GFX 基类对象。 */ -export class Obj { - public get gfxType (): ObjectType { - return this._gfxType; +export class GFXObject { + public get objectType (): ObjectType { + return this._objectType; } - protected _gfxType = ObjectType.UNKNOWN; + public get objectID (): number { + return this._objectID; + } - constructor (gfxType: ObjectType) { - this._gfxType = gfxType; + public get typedID (): number { + return this._typedID; + } + + protected _objectType = ObjectType.UNKNOWN; + protected _objectID = 0; + protected _typedID = 0; + + private static _idTable = Array(ObjectType.COUNT).fill(1 << 16); + + constructor (objectType: ObjectType) { + this._objectType = objectType; + this._objectID = GFXObject._idTable[ObjectType.UNKNOWN]++; + this._typedID = GFXObject._idTable[objectType]++; } } -export class DeviceInfo { - declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object - - constructor ( - public canvasElm: HTMLElement, - public isAntialias: boolean = true, - public isPremultipliedAlpha: boolean = true, - public devicePixelRatio: number = 1, - public width: number = 1, - public height: number = 1, - /** - * For non-vulkan backends, to maintain compatibility and maximize - * descriptor cache-locality, descriptor-set-based binding numbers need - * to be mapped to backend-specific bindings based on the maximum limit - * of available descriptor slots in each set. - * - * The GFX layer assumes the binding numbers for each descriptor type inside each set - * are guaranteed to be consecutive, so the mapping procedure is reduced - * to a simple shifting operation. This data structure specifies the - * offsets for each descriptor type in each set. - */ - public bindingMappingInfo = new BindingMappingInfo(), - ) {} -} - -export interface IUniform { - name: string; - type: Type; - count: number; -} - -export interface IShaderStage { - stage: ShaderStageFlagBit; - source: string; -} - -export interface IAttribute { - name: string; +export interface ISwapchainTextureInfo { + swapchain: Swapchain; format: Format; - isNormalized: boolean; - stream: number; - isInstanced: boolean; - location: number; + width: number; + height: number; } export enum AttributeName { @@ -1875,12 +1900,8 @@ export const FormatInfos = Object.freeze([ new FormatInfo('RGB10A2UI', 2, 4, FormatType.UINT, true, false, false, false), new FormatInfo('RGB9E5', 2, 4, FormatType.FLOAT, true, false, false, false), - new FormatInfo('D16', 2, 1, FormatType.UINT, false, true, false, false), - new FormatInfo('D16S8', 3, 2, FormatType.UINT, false, true, true, false), - new FormatInfo('D24', 3, 1, FormatType.UINT, false, true, false, false), - new FormatInfo('D24S8', 4, 2, FormatType.UINT, false, true, true, false), - new FormatInfo('D32F', 4, 1, FormatType.FLOAT, false, true, false, false), - new FormatInfo('D32FS8', 5, 2, FormatType.FLOAT, false, true, true, false), + new FormatInfo('DEPTH', 4, 1, FormatType.FLOAT, false, true, false, false), + new FormatInfo('DEPTH_STENCIL', 5, 2, FormatType.FLOAT, false, true, true, false), new FormatInfo('BC1', 1, 3, FormatType.UNORM, false, false, false, true), new FormatInfo('BC1_ALPHA', 1, 4, FormatType.UNORM, true, false, false, true), diff --git a/cocos/core/gfx/base/descriptor-set-layout.ts b/cocos/core/gfx/base/descriptor-set-layout.ts index da585b606f..47cd85d715 100644 --- a/cocos/core/gfx/base/descriptor-set-layout.ts +++ b/cocos/core/gfx/base/descriptor-set-layout.ts @@ -28,14 +28,13 @@ * @module gfx */ -import { Device } from './device'; -import { Obj, ObjectType, DescriptorSetLayoutBinding, DescriptorSetLayoutInfo } from './define'; +import { GFXObject, ObjectType, DescriptorSetLayoutBinding, DescriptorSetLayoutInfo } from './define'; /** * @en GFX descriptor sets layout. * @zh GFX 描述符集布局。 */ -export abstract class DescriptorSetLayout extends Obj { +export abstract class DescriptorSetLayout extends GFXObject { get bindings () { return this._bindings; } @@ -48,20 +47,15 @@ export abstract class DescriptorSetLayout extends Obj { return this._descriptorIndices; } - protected _device: Device; - protected _bindings: DescriptorSetLayoutBinding[] = []; - protected _bindingIndices: number[] = []; - protected _descriptorIndices: number[] = []; - constructor (device: Device) { + constructor () { super(ObjectType.DESCRIPTOR_SET_LAYOUT); - this._device = device; } - public abstract initialize (info: DescriptorSetLayoutInfo): boolean; + public abstract initialize (info: DescriptorSetLayoutInfo): void; public abstract destroy (): void; } diff --git a/cocos/core/gfx/base/descriptor-set.ts b/cocos/core/gfx/base/descriptor-set.ts index c5012f2739..02d0598e82 100644 --- a/cocos/core/gfx/base/descriptor-set.ts +++ b/cocos/core/gfx/base/descriptor-set.ts @@ -30,22 +30,19 @@ import { Buffer } from './buffer'; import { DescriptorSetLayout } from './descriptor-set-layout'; -import { Device } from './device'; -import { Sampler } from './sampler'; +import { Sampler } from './states/sampler'; import { Texture } from './texture'; -import { Obj, ObjectType, DescriptorSetInfo, DESCRIPTOR_BUFFER_TYPE, DESCRIPTOR_SAMPLER_TYPE } from './define'; +import { GFXObject, ObjectType, DescriptorSetInfo, DESCRIPTOR_BUFFER_TYPE, DESCRIPTOR_SAMPLER_TYPE } from './define'; /** * @en GFX descriptor sets. * @zh GFX 描述符集组。 */ -export abstract class DescriptorSet extends Obj { +export abstract class DescriptorSet extends GFXObject { get layout () { return this._layout!; } - protected _device: Device; - protected _layout: DescriptorSetLayout | null = null; protected _buffers: Buffer[] = []; protected _textures: Texture[] = []; @@ -53,12 +50,11 @@ export abstract class DescriptorSet extends Obj { protected _isDirty = false; - constructor (device: Device) { + constructor () { super(ObjectType.DESCRIPTOR_SET); - this._device = device; } - public abstract initialize (info: DescriptorSetInfo): boolean; + public abstract initialize (info: DescriptorSetInfo): void; public abstract destroy (): void; diff --git a/cocos/core/gfx/base/device.ts b/cocos/core/gfx/base/device.ts index b05f7d77a5..90c2f35a5d 100644 --- a/cocos/core/gfx/base/device.ts +++ b/cocos/core/gfx/base/device.ts @@ -28,12 +28,11 @@ * @module gfx */ -import { ccenum } from '../../value-types/enum'; import { - API, Feature, Filter, Format, MemoryStatus, SurfaceTransform, Rect, + API, Feature, MemoryStatus, CommandBufferInfo, BufferInfo, BufferViewInfo, TextureInfo, TextureViewInfo, SamplerInfo, DescriptorSetInfo, ShaderInfo, InputAssemblerInfo, RenderPassInfo, FramebufferInfo, DescriptorSetLayoutInfo, PipelineLayoutInfo, - QueueInfo, BufferTextureCopy, DeviceInfo, DeviceCaps, GlobalBarrierInfo, TextureBarrierInfo, + QueueInfo, BufferTextureCopy, DeviceInfo, DeviceCaps, GlobalBarrierInfo, TextureBarrierInfo, SwapchainInfo, BindingMappingInfo, } from './define'; import { Buffer } from './buffer'; import { CommandBuffer } from './command-buffer'; @@ -45,35 +44,18 @@ import { InputAssembler } from './input-assembler'; import { PipelineState, PipelineStateInfo } from './pipeline-state'; import { Queue } from './queue'; import { RenderPass } from './render-pass'; -import { Sampler } from './sampler'; +import { Sampler } from './states/sampler'; import { Shader } from './shader'; import { Texture } from './texture'; -import { GlobalBarrier } from './global-barrier'; -import { TextureBarrier } from './texture-barrier'; - -ccenum(Format); +import { GlobalBarrier } from './states/global-barrier'; +import { TextureBarrier } from './states/texture-barrier'; +import { Swapchain } from './swapchain'; /** * @en GFX Device. * @zh GFX 设备。 */ export abstract class Device { - /** - * @en The HTML canvas element. - * @zh HTML 画布。 - */ - get canvas (): HTMLCanvasElement { - return this._canvas as HTMLCanvasElement; - } - - /** - * @en The HTML canvas element for 2D rendering. - * @zh 用于 2D 绘制的 HTML 画布。 - */ - get canvas2D (): HTMLCanvasElement { - return this._canvas2D as HTMLCanvasElement; - } - /** * @en Current rendering API. * @zh 当前 GFX 使用的渲染 API。 @@ -98,30 +80,6 @@ export abstract class Device { return this._cmdBuff as CommandBuffer; } - /** - * @en Device pixel ratio. - * @zh DPR 设备像素比。 - */ - get devicePixelRatio (): number { - return this._devicePixelRatio; - } - - /** - * @en Device pixel width. - * @zh 设备像素宽度。 - */ - get width (): number { - return this._width; - } - - /** - * @en Device pixel height. - * @zh 设备像素高度。 - */ - get height (): number { - return this._height; - } - /** * @en Renderer description. * @zh 渲染器描述。 @@ -138,22 +96,6 @@ export abstract class Device { return this._vendor; } - /** - * @en Device color format. - * @zh 颜色格式。 - */ - get colorFormat (): Format { - return this._colorFmt; - } - - /** - * @en Device depth stencil format. - * @zh 深度模板格式。 - */ - get depthStencilFormat (): Format { - return this._depthStencilFmt; - } - /** * @en Number of draw calls currently recorded. * @zh 绘制调用次数。 @@ -188,59 +130,45 @@ export abstract class Device { /** * @en Current device capabilities. - * @zh 当前设备能立数据。 + * @zh 当前设备能力数据。 */ get capabilities (): DeviceCaps { return this._caps; } /** - * @en The surface transform to be applied in projection matrices. - * @zh 需要在投影矩阵中应用的表面变换。 + * @en Current device binding mappings. + * @zh 当前设备的绑定槽位映射关系。 */ - get surfaceTransform () { - return this._transform; + get bindingMappingInfo () { + return this._bindingMappingInfo; } - protected _canvas: HTMLCanvasElement | null = null; - protected _canvas2D: HTMLCanvasElement | null = null; protected _gfxAPI = API.UNKNOWN; - protected _transform = SurfaceTransform.IDENTITY; - protected _deviceName = ''; protected _renderer = ''; protected _vendor = ''; - protected _version = ''; protected _features = new Array(Feature.COUNT); protected _queue: Queue | null = null; protected _cmdBuff: CommandBuffer | null = null; - protected _devicePixelRatio = 1.0; - protected _width = 0; - protected _height = 0; - protected _colorFmt = Format.UNKNOWN; - protected _depthStencilFmt = Format.UNKNOWN; protected _numDrawCalls = 0; protected _numInstances = 0; protected _numTris = 0; protected _memoryStatus = new MemoryStatus(); protected _caps = new DeviceCaps(); + protected _bindingMappingInfo: BindingMappingInfo = new BindingMappingInfo(); + protected _samplers = new Map(); + protected _globalBarriers = new Map(); + protected _textureBarriers = new Map(); - public abstract initialize (info: DeviceInfo): boolean; + public abstract initialize (info: Readonly): boolean; public abstract destroy (): void; - /** - * @en Resize the device. - * @zh 重置设备大小。 - * @param width The device width. - * @param height The device height. - */ - public abstract resize (width: number, height: number): void; - /** * @en Acquire next swapchain image. * @zh 获取下一个交换链缓冲。 */ - public abstract acquire (): void; + public abstract acquire (swapchains: Swapchain[]): void; /** * @en Present current swapchain image. @@ -259,105 +187,112 @@ export abstract class Device { * @zh 创建命令缓冲。 * @param info GFX command buffer description info. */ - public abstract createCommandBuffer (info: CommandBufferInfo): CommandBuffer; + public abstract createCommandBuffer (info: Readonly): CommandBuffer; + + /** + * @en Create swapchain. + * @zh 创建交换链。 + * @param info GFX swapchain description info. + */ + public abstract createSwapchain (info: Readonly): Swapchain; /** * @en Create buffer. * @zh 创建缓冲。 * @param info GFX buffer description info. */ - public abstract createBuffer (info: BufferInfo | BufferViewInfo): Buffer; + public abstract createBuffer (info: Readonly | BufferViewInfo): Buffer; /** * @en Create texture. * @zh 创建纹理。 * @param info GFX texture description info. */ - public abstract createTexture (info: TextureInfo | TextureViewInfo): Texture; - - /** - * @en Create sampler. - * @zh 创建采样器。 - * @param info GFX sampler description info. - */ - public abstract createSampler (info: SamplerInfo): Sampler; + public abstract createTexture (info: Readonly | TextureViewInfo): Texture; /** * @en Create descriptor sets. * @zh 创建描述符集组。 * @param info GFX descriptor sets description info. */ - public abstract createDescriptorSet (info: DescriptorSetInfo): DescriptorSet; + public abstract createDescriptorSet (info: Readonly): DescriptorSet; /** * @en Create shader. * @zh 创建着色器。 * @param info GFX shader description info. */ - public abstract createShader (info: ShaderInfo): Shader; + public abstract createShader (info: Readonly): Shader; /** * @en Create input assembler. * @zh 创建纹理。 * @param info GFX input assembler description info. */ - public abstract createInputAssembler (info: InputAssemblerInfo): InputAssembler; + public abstract createInputAssembler (info: Readonly): InputAssembler; /** * @en Create render pass. * @zh 创建渲染过程。 * @param info GFX render pass description info. */ - public abstract createRenderPass (info: RenderPassInfo): RenderPass; + public abstract createRenderPass (info: Readonly): RenderPass; /** * @en Create frame buffer. * @zh 创建帧缓冲。 * @param info GFX frame buffer description info. */ - public abstract createFramebuffer (info: FramebufferInfo): Framebuffer; + public abstract createFramebuffer (info: Readonly): Framebuffer; /** * @en Create descriptor set layout. * @zh 创建描述符集布局。 * @param info GFX descriptor set layout description info. */ - public abstract createDescriptorSetLayout (info: DescriptorSetLayoutInfo): DescriptorSetLayout; + public abstract createDescriptorSetLayout (info: Readonly): DescriptorSetLayout; /** * @en Create pipeline layout. * @zh 创建管线布局。 * @param info GFX pipeline layout description info. */ - public abstract createPipelineLayout (info: PipelineLayoutInfo): PipelineLayout; + public abstract createPipelineLayout (info: Readonly): PipelineLayout; /** * @en Create pipeline state. * @zh 创建管线状态。 * @param info GFX pipeline state description info. */ - public abstract createPipelineState (info: PipelineStateInfo): PipelineState; + public abstract createPipelineState (info: Readonly): PipelineState; /** * @en Create queue. * @zh 创建队列。 * @param info GFX queue description info. */ - public abstract createQueue (info: QueueInfo): Queue; + public abstract createQueue (info: Readonly): Queue; + + /** + * @en Create sampler. + * @zh 创建采样器。 + * @param info GFX sampler description info. + */ + public abstract getSampler (info: Readonly): Sampler; /** * @en Create global barrier. * @zh 创建全局内存屏障。 * @param info GFX global barrier description info. */ - public abstract createGlobalBarrier (info: GlobalBarrierInfo): GlobalBarrier; + public abstract getGlobalBarrier (info: Readonly): GlobalBarrier; /** * @en Create texture barrier. * @zh 创建贴图内存屏障。 * @param info GFX texture barrier description info. */ - public abstract createTextureBarrier (info: TextureBarrierInfo): TextureBarrier; + public abstract getTextureBarrier (info: Readonly): TextureBarrier; /** * @en Copy buffers to texture. @@ -366,10 +301,9 @@ export abstract class Device { * @param texture The texture to copy to. * @param regions The region descriptions. */ - public abstract copyBuffersToTexture (buffers: ArrayBufferView[], texture: Texture, regions: BufferTextureCopy[]): void; + public abstract copyBuffersToTexture (buffers: Readonly, texture: Texture, regions: BufferTextureCopy[]): void; /** - * * @en Copy texture to buffers * @zh 拷贝纹理到缓冲 * @param texture The texture to be copied. @@ -387,15 +321,6 @@ export abstract class Device { */ public abstract copyTexImagesToTexture (texImages: TexImageSource[], texture: Texture, regions: BufferTextureCopy[]): void; - /** - * @en Copy frame buffer to buffer. - * @zh 拷贝帧缓冲到缓冲。 - * @param srcFramebuffer The frame buffer to be copied. - * @param dstBuffer The buffer to copy to. - * @param regions The region descriptions. - */ - public abstract copyFramebufferToBuffer (srcFramebuffer: Framebuffer, dstBuffer: ArrayBuffer, regions: BufferTextureCopy[]): void; - /** * @en Whether the device has specific feature. * @zh 是否具备特性。 diff --git a/cocos/core/gfx/base/framebuffer.ts b/cocos/core/gfx/base/framebuffer.ts index f39dcbf978..9e6a5f6d02 100644 --- a/cocos/core/gfx/base/framebuffer.ts +++ b/cocos/core/gfx/base/framebuffer.ts @@ -28,16 +28,15 @@ * @module gfx */ -import { Device } from './device'; import { RenderPass } from './render-pass'; import { Texture } from './texture'; -import { Obj, ObjectType, FramebufferInfo } from './define'; +import { GFXObject, ObjectType, FramebufferInfo } from './define'; /** * @en GFX frame buffer. * @zh GFX 帧缓冲。 */ -export abstract class Framebuffer extends Obj { +export abstract class Framebuffer extends GFXObject { /** * @en Get current render pass. * @zh GFX 渲染过程。 @@ -62,20 +61,15 @@ export abstract class Framebuffer extends Obj { return this._depthStencilTexture; } - protected _device: Device; - protected _renderPass: RenderPass | null = null; - protected _colorTextures: (Texture | null)[] = []; - protected _depthStencilTexture: Texture | null = null; - constructor (device: Device) { + constructor () { super(ObjectType.FRAMEBUFFER); - this._device = device; } - public abstract initialize (info: FramebufferInfo): boolean; + public abstract initialize (info: FramebufferInfo): void; public abstract destroy (): void; } diff --git a/cocos/core/gfx/base/input-assembler.ts b/cocos/core/gfx/base/input-assembler.ts index cc4867b482..d4cb058747 100644 --- a/cocos/core/gfx/base/input-assembler.ts +++ b/cocos/core/gfx/base/input-assembler.ts @@ -29,15 +29,22 @@ */ import { Buffer } from './buffer'; -import { Device } from './device'; import { murmurhash2_32_gc } from '../../utils/murmurhash2_gc'; -import { Attribute, Obj, ObjectType, InputAssemblerInfo } from './define'; +import { Attribute, GFXObject, ObjectType, InputAssemblerInfo, DrawInfo } from './define'; /** * @en GFX input assembler. * @zh GFX 输入汇集器。 */ -export abstract class InputAssembler extends Obj { +export abstract class InputAssembler extends GFXObject { + /** + * @en Get current attributes. + * @zh 顶点属性数组。 + */ + get attributes (): Attribute[] { + return this._attributes; + } + /** * @en Get current vertex buffers. * @zh 顶点缓冲数组。 @@ -55,11 +62,11 @@ export abstract class InputAssembler extends Obj { } /** - * @en Get current attributes. - * @zh 顶点属性数组。 + * @en Get the indirect buffer, if present. + * @zh 间接绘制缓冲。 */ - get attributes (): Attribute[] { - return this._attributes; + get indirectBuffer (): Buffer | null { + return this._indirectBuffer; } /** @@ -74,123 +81,73 @@ export abstract class InputAssembler extends Obj { * @en Get current vertex count. * @zh 顶点数量。 */ - get vertexCount (): number { - return this._vertexCount; - } - set vertexCount (count: number) { - this._vertexCount = count; + this._drawInfo.vertexCount = count; } /** * @en Get starting vertex. * @zh 起始顶点。 */ - get firstVertex (): number { - return this._firstVertex; - } - set firstVertex (first: number) { - this._firstVertex = first; + this._drawInfo.firstVertex = first; } /** * @en Get current index count. * @zh 索引数量。 */ - get indexCount (): number { - return this._indexCount; - } - set indexCount (count: number) { - this._indexCount = count; + this._drawInfo.indexCount = count; } /** * @en Get starting index. * @zh 起始索引。 */ - get firstIndex (): number { - return this._firstIndex; - } - set firstIndex (first: number) { - this._firstIndex = first; + this._drawInfo.firstIndex = first; } /** * @en Get current vertex offset. * @zh 顶点偏移量。 */ - get vertexOffset (): number { - return this._vertexOffset; - } - set vertexOffset (offset: number) { - this._vertexOffset = offset; + this._drawInfo.vertexOffset = offset; } /** * @en Get current instance count. * @zh 实例数量。 */ - get instanceCount (): number { - return this._instanceCount; - } - set instanceCount (count: number) { - this._instanceCount = count; + this._drawInfo.instanceCount = count; } /** * @en Get starting instance. * @zh 起始实例。 */ - get firstInstance (): number { - return this._firstInstance; - } - set firstInstance (first: number) { - this._firstInstance = first; + this._drawInfo.firstInstance = first; } - /** - * @en Get the indirect buffer, if present. - * @zh 间接绘制缓冲。 - */ - get indirectBuffer (): Buffer | null { - return this._indirectBuffer; + get drawInfo (): Readonly { + return this._drawInfo; } - protected _device: Device; - protected _attributes: Attribute[] = []; - - protected _vertexBuffers: Buffer[] = []; - - protected _indexBuffer: Buffer | null = null; - - protected _vertexCount = 0; - - protected _firstVertex = 0; - - protected _indexCount = 0; - - protected _firstIndex = 0; - - protected _vertexOffset = 0; - - protected _instanceCount = 0; - - protected _firstInstance = 0; - protected _attributesHash = 0; + protected _vertexBuffers: Buffer[] = []; + protected _indexBuffer: Buffer | null = null; protected _indirectBuffer: Buffer | null = null; - constructor (device: Device) { + protected _drawInfo = new DrawInfo(); + + constructor () { super(ObjectType.INPUT_ASSEMBLER); - this._device = device; } /** @@ -215,6 +172,6 @@ export abstract class InputAssembler extends Obj { return murmurhash2_32_gc(res, 666); } - public abstract initialize (info: InputAssemblerInfo): boolean; + public abstract initialize (info: InputAssemblerInfo): void; public abstract destroy (): void; } diff --git a/cocos/core/gfx/base/pipeline-layout.ts b/cocos/core/gfx/base/pipeline-layout.ts index 87e814dde6..36f6625305 100644 --- a/cocos/core/gfx/base/pipeline-layout.ts +++ b/cocos/core/gfx/base/pipeline-layout.ts @@ -29,28 +29,24 @@ */ import { DescriptorSetLayout } from './descriptor-set-layout'; -import { Device } from './device'; -import { Obj, ObjectType, PipelineLayoutInfo } from './define'; +import { GFXObject, ObjectType, PipelineLayoutInfo } from './define'; /** * @en GFX pipeline layout. * @zh GFX 管线布局。 */ -export abstract class PipelineLayout extends Obj { +export abstract class PipelineLayout extends GFXObject { get setLayouts () { return this._setLayouts; } - protected _device: Device; - protected _setLayouts: DescriptorSetLayout[] = []; - constructor (device: Device) { + constructor () { super(ObjectType.PIPELINE_LAYOUT); - this._device = device; } - public abstract initialize (info: PipelineLayoutInfo): boolean; + public abstract initialize (info: PipelineLayoutInfo): void; public abstract destroy (): void; } diff --git a/cocos/core/gfx/base/pipeline-state.ts b/cocos/core/gfx/base/pipeline-state.ts index 66d62763f1..7fa8cb0bb5 100644 --- a/cocos/core/gfx/base/pipeline-state.ts +++ b/cocos/core/gfx/base/pipeline-state.ts @@ -28,7 +28,6 @@ * @module gfx */ -import { Device } from './device'; import { PipelineLayout } from './pipeline-layout'; import { RenderPass } from './render-pass'; import { Shader } from './shader'; @@ -40,7 +39,7 @@ import { CullMode, DynamicStateFlagBit, DynamicStateFlags, - Obj, + GFXObject, ObjectType, PolygonMode, PrimitiveMode, @@ -265,7 +264,7 @@ export class PipelineStateInfo { * @en GFX pipeline state. * @zh GFX 管线状态。 */ -export abstract class PipelineState extends Obj { +export abstract class PipelineState extends GFXObject { /** * @en Get current shader. * @zh GFX 着色器。 @@ -338,32 +337,21 @@ export abstract class PipelineState extends Obj { return this._renderPass as RenderPass; } - protected _device: Device; - protected _shader: Shader | null = null; - protected _pipelineLayout: PipelineLayout | null = null; - protected _primitive: PrimitiveMode = PrimitiveMode.TRIANGLE_LIST; - protected _is: InputState | null = null; - protected _rs: RasterizerState = new RasterizerState(); - protected _dss: DepthStencilState = new DepthStencilState(); - protected _bs: BlendState = new BlendState(); - protected _dynamicStates: DynamicStateFlags = DynamicStateFlagBit.NONE; - protected _renderPass: RenderPass | null = null; - constructor (device: Device) { + constructor () { super(ObjectType.PIPELINE_STATE); - this._device = device; } - public abstract initialize (info: PipelineStateInfo): boolean; + public abstract initialize (info: PipelineStateInfo): void; public abstract destroy (): void; } diff --git a/cocos/core/gfx/base/queue.ts b/cocos/core/gfx/base/queue.ts index 56a0113e2e..228cb9e2f2 100644 --- a/cocos/core/gfx/base/queue.ts +++ b/cocos/core/gfx/base/queue.ts @@ -29,14 +29,13 @@ */ import { CommandBuffer } from './command-buffer'; -import { Device } from './device'; -import { Obj, ObjectType, QueueType, QueueInfo } from './define'; +import { GFXObject, ObjectType, QueueType, QueueInfo } from './define'; /** * @en GFX Queue. * @zh GFX 队列。 */ -export abstract class Queue extends Obj { +export abstract class Queue extends GFXObject { /** * @en Get current type. * @zh 队列类型。 @@ -45,20 +44,13 @@ export abstract class Queue extends Obj { return this._type; } - protected _device: Device; - protected _type: QueueType = QueueType.GRAPHICS; - protected _isAsync = false; - - constructor (device: Device) { + constructor () { super(ObjectType.QUEUE); - this._device = device; } - public isAsync () { return this._isAsync; } - - public abstract initialize (info: QueueInfo): boolean; + public abstract initialize (info: QueueInfo): void; public abstract destroy (): void; diff --git a/cocos/core/gfx/base/render-pass.ts b/cocos/core/gfx/base/render-pass.ts index f8e1bbb935..12d390d324 100644 --- a/cocos/core/gfx/base/render-pass.ts +++ b/cocos/core/gfx/base/render-pass.ts @@ -28,10 +28,9 @@ * @module gfx */ -import { Device } from './device'; import { murmurhash2_32_gc } from '../../utils/murmurhash2_gc'; import { - Obj, + GFXObject, ObjectType, ColorAttachment, DepthStencilAttachment, @@ -43,15 +42,10 @@ import { * @en GFX render pass. * @zh GFX 渲染过程。 */ -export abstract class RenderPass extends Obj { - protected _device: Device; - +export abstract class RenderPass extends GFXObject { protected _colorInfos: ColorAttachment[] = []; - protected _depthStencilInfo: DepthStencilAttachment | null = null; - protected _subpasses: SubpassInfo[] = []; - protected _hash = 0; get colorAttachments () { return this._colorInfos; } @@ -59,9 +53,8 @@ export abstract class RenderPass extends Obj { get subPasses () { return this._subpasses; } get hash () { return this._hash; } - constructor (device: Device) { + constructor () { super(ObjectType.RENDER_PASS); - this._device = device; } // Based on render pass compatibility @@ -104,7 +97,7 @@ export abstract class RenderPass extends Obj { return murmurhash2_32_gc(res, 666); } - public abstract initialize (info: RenderPassInfo): boolean; + public abstract initialize (info: RenderPassInfo): void; public abstract destroy (): void; } diff --git a/cocos/core/gfx/base/shader.ts b/cocos/core/gfx/base/shader.ts index c0bb63d7ed..ebf6bd1557 100644 --- a/cocos/core/gfx/base/shader.ts +++ b/cocos/core/gfx/base/shader.ts @@ -28,65 +28,40 @@ * @module gfx */ -import { Device } from './device'; -import { Obj, ObjectType, ShaderInfo, ShaderStage, UniformBlock, UniformSampler, Attribute } from './define'; +import { GFXObject, ObjectType, ShaderInfo, ShaderStage, UniformBlock, UniformSampler, Attribute } from './define'; /** * @en GFX shader. * @zh GFX 着色器。 */ -export abstract class Shader extends Obj { - private static _shaderIdGen = 0; - - /** - * @en Get current shader id. - * @zh 着色器 id。 - */ - public get id (): number { - return this._id; - } - - /** - * @en Get current shader name. - * @zh 着色器名称。 - */ - public get name (): string { +export abstract class Shader extends GFXObject { + get name (): string { return this._name; } - public get attributes () { + get attributes () { return this._attributes; } - public get blocks () { + get blocks () { return this._blocks; } - public get samplers () { + get samplers () { return this._samplers; } - protected _device: Device; - - protected _id: number; - protected _name = ''; - protected _stages: ShaderStage[] = []; - protected _attributes: Attribute[] = []; - protected _blocks: UniformBlock[] = []; - protected _samplers: UniformSampler[] = []; - constructor (device: Device) { + constructor () { super(ObjectType.SHADER); - this._device = device; - this._id = Shader._shaderIdGen++; } - public abstract initialize (info: ShaderInfo): boolean; + public abstract initialize (info: ShaderInfo): void; public abstract destroy (): void; } diff --git a/cocos/core/gfx/base/states/global-barrier.ts b/cocos/core/gfx/base/states/global-barrier.ts new file mode 100644 index 0000000000..9f4566b962 --- /dev/null +++ b/cocos/core/gfx/base/states/global-barrier.ts @@ -0,0 +1,60 @@ +/* + 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. + */ + +/** + * @packageDocumentation + * @module gfx + */ + +import { murmurhash2_32_gc } from '../../../utils/murmurhash2_gc'; +import { GFXObject, ObjectType, GlobalBarrierInfo } from '../define'; + +/** + * @en GFX global barrier. + * @zh GFX 全局内存屏障。 + */ +export class GlobalBarrier extends GFXObject { + get info (): Readonly { return this._info; } + + protected _info: GlobalBarrierInfo = new GlobalBarrierInfo(); + + constructor (info: GlobalBarrierInfo) { + super(ObjectType.GLOBAL_BARRIER); + this._info.copy(info); + } + + static computeHash (info: GlobalBarrierInfo) { + let res = 'prev:'; + for (let i = 0; i < info.prevAccesses.length; ++i) { + res += ` ${info.prevAccesses[i]}`; + } + res += 'next:'; + for (let i = 0; i < info.nextAccesses.length; ++i) { + res += ` ${info.nextAccesses[i]}`; + } + + return murmurhash2_32_gc(res, 666); + } +} diff --git a/cocos/core/gfx/base/sampler.ts b/cocos/core/gfx/base/states/sampler.ts similarity index 50% rename from cocos/core/gfx/base/sampler.ts rename to cocos/core/gfx/base/states/sampler.ts index ed0e13d6b9..faa2753ab3 100644 --- a/cocos/core/gfx/base/sampler.ts +++ b/cocos/core/gfx/base/states/sampler.ts @@ -28,44 +28,44 @@ * @module gfx */ -import { Device } from './device'; -import { Color, Address, ComparisonFunc, Filter, Obj, ObjectType, SamplerInfo } from './define'; +import { GFXObject, ObjectType, SamplerInfo } from '../define'; /** * @en GFX sampler. * @zh GFX 采样器。 */ -export abstract class Sampler extends Obj { - get minFilter () { return this._minFilter; } - get magFilter () { return this._magFilter; } - get mipFilter () { return this._mipFilter; } - get addressU () { return this._addressU; } - get addressV () { return this._addressV; } - get addressW () { return this._addressW; } - get maxAnisotropy () { return this._maxAnisotropy; } - get cmpFunc () { return this._cmpFunc; } - get borderColor () { return this._borderColor; } - get mipLODBias () { return this._mipLODBias; } +export class Sampler extends GFXObject { + get info (): Readonly { return this._info; } - protected _device: Device; + protected _info: SamplerInfo = new SamplerInfo(); - protected _minFilter: Filter = Filter.LINEAR; - protected _magFilter: Filter = Filter.LINEAR; - protected _mipFilter: Filter = Filter.NONE; - protected _addressU: Address = Address.WRAP; - protected _addressV: Address = Address.WRAP; - protected _addressW: Address = Address.WRAP; - protected _maxAnisotropy = 16; - protected _cmpFunc: ComparisonFunc = ComparisonFunc.NEVER; - protected _borderColor: Color = new Color(); - protected _mipLODBias = 0.0; - - constructor (device: Device) { + constructor (info: SamplerInfo) { super(ObjectType.SAMPLER); - this._device = device; + this._info.copy(info); } - public abstract initialize (info: SamplerInfo): boolean; + static computeHash (info: SamplerInfo) { + let hash = info.minFilter; + hash |= (info.magFilter << 2); + hash |= (info.mipFilter << 4); + hash |= (info.addressU << 6); + hash |= (info.addressV << 8); + hash |= (info.addressW << 10); + hash |= (info.maxAnisotropy << 12); + hash |= (info.cmpFunc << 16); + return hash; + } - public abstract destroy (): void; + static unpackFromHash (hash: number) { + const info = new SamplerInfo(); + info.minFilter = (hash & ((1 << 2) - 1)) >> 0; + info.magFilter = (hash & ((1 << 2) - 1)) >> 2; + info.mipFilter = (hash & ((1 << 2) - 1)) >> 4; + info.addressU = (hash & ((1 << 2) - 1)) >> 6; + info.addressV = (hash & ((1 << 2) - 1)) >> 8; + info.addressW = (hash & ((1 << 2) - 1)) >> 10; + info.maxAnisotropy = (hash & ((1 << 4) - 1)) >> 12; + info.cmpFunc = (hash & ((1 << 3) - 1)) >> 16; + return info; + } } diff --git a/cocos/core/gfx/base/states/texture-barrier.ts b/cocos/core/gfx/base/states/texture-barrier.ts new file mode 100644 index 0000000000..4b0afc6a43 --- /dev/null +++ b/cocos/core/gfx/base/states/texture-barrier.ts @@ -0,0 +1,63 @@ +/* + 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. + */ + +/** + * @packageDocumentation + * @module gfx + */ + +import { murmurhash2_32_gc } from '../../../utils/murmurhash2_gc'; +import { GFXObject, ObjectType, TextureBarrierInfo } from '../define'; + +/** + * @en GFX texture barrier. + * @zh GFX 贴图内存屏障。 + */ +export class TextureBarrier extends GFXObject { + get info (): Readonly { return this._info; } + + protected _info: TextureBarrierInfo = new TextureBarrierInfo(); + + constructor (info: TextureBarrierInfo) { + super(ObjectType.TEXTURE_BARRIER); + this._info.copy(info); + } + + static computeHash (info: TextureBarrierInfo) { + let res = 'prev:'; + for (let i = 0; i < info.prevAccesses.length; ++i) { + res += ` ${info.prevAccesses[i]}`; + } + res += 'next:'; + for (let i = 0; i < info.nextAccesses.length; ++i) { + res += ` ${info.nextAccesses[i]}`; + } + res += info.discardContents; + res += info.srcQueue ? info.srcQueue.type : 0; + res += info.dstQueue ? info.dstQueue.type : 0; + + return murmurhash2_32_gc(res, 666); + } +} diff --git a/cocos/core/gfx/base/swapchain.ts b/cocos/core/gfx/base/swapchain.ts new file mode 100644 index 0000000000..8339b23e09 --- /dev/null +++ b/cocos/core/gfx/base/swapchain.ts @@ -0,0 +1,82 @@ +/* + 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. + */ + +/** + * @packageDocumentation + * @module gfx + */ + +import { GFXObject, ObjectType, SurfaceTransform, SwapchainInfo } from './define'; +import { Texture } from './texture'; + +/** + * @en GFX Swapchain. + * @zh GFX 交换链。 + */ +export abstract class Swapchain extends GFXObject { + /** + * @en The color texture of this swapchain. + * @zh 当前交换链的颜色缓冲。 + */ + get colorTexture () { + return this._colorTexture; + } + + /** + * @en The depth stencil texture of this swapchain. + * @zh 当前交换链的深度模板缓冲。 + */ + get depthStencilTexture () { + return this._depthStencilTexture; + } + + /** + * @en The surface transform to be applied in projection matrices. + * @zh 需要在投影矩阵中应用的表面变换。 + */ + get surfaceTransform () { + return this._transform; + } + + get width () { + return this._colorTexture.width; + } + + get height () { + return this._colorTexture.height; + } + + protected _transform = SurfaceTransform.IDENTITY; + protected _colorTexture: Texture = null!; + protected _depthStencilTexture: Texture = null!; + + constructor () { + super(ObjectType.SWAPCHAIN); + } + + public abstract initialize (info: SwapchainInfo): void; + public abstract resize (width: number, height: number): void; + public abstract destroy (): void; +} diff --git a/cocos/core/gfx/base/texture.ts b/cocos/core/gfx/base/texture.ts index 8145cc8c44..bc75e861b4 100644 --- a/cocos/core/gfx/base/texture.ts +++ b/cocos/core/gfx/base/texture.ts @@ -28,10 +28,9 @@ * @module gfx */ -import { Device } from './device'; import { Format, - Obj, + GFXObject, ObjectType, SampleCount, TextureFlagBit, @@ -41,13 +40,14 @@ import { TextureUsageBit, TextureInfo, TextureViewInfo, + ISwapchainTextureInfo, } from './define'; /** * @en GFX texture. * @zh GFX 纹理。 */ -export abstract class Texture extends Obj { +export abstract class Texture extends GFXObject { /** * @en Get texture type. * @zh 纹理类型。 @@ -136,8 +136,6 @@ export abstract class Texture extends Obj { return this._size; } - protected _device: Device; - protected _type: TextureType = TextureType.TEX2D; protected _usage: TextureUsage = TextureUsageBit.NONE; protected _format: Format = Format.UNKNOWN; @@ -146,17 +144,16 @@ export abstract class Texture extends Obj { protected _depth = 1; protected _layerCount = 1; protected _levelCount = 1; - protected _samples: SampleCount = SampleCount.X1; + protected _samples: SampleCount = SampleCount.ONE; protected _flags: TextureFlags = TextureFlagBit.NONE; protected _isPowerOf2 = false; protected _size = 0; - constructor (device: Device) { + constructor () { super(ObjectType.TEXTURE); - this._device = device; } - public abstract initialize (info: TextureInfo | TextureViewInfo): boolean; + public abstract initialize (info: TextureInfo | TextureViewInfo): void; public abstract destroy (): void; @@ -167,4 +164,6 @@ export abstract class Texture extends Obj { * @param height The new height. */ public abstract resize (width: number, height: number): void; + + protected abstract initAsSwapchainTexture (info: ISwapchainTextureInfo): void; } diff --git a/cocos/core/gfx/empty/empty-buffer.ts b/cocos/core/gfx/empty/empty-buffer.ts new file mode 100644 index 0000000000..704017b0bd --- /dev/null +++ b/cocos/core/gfx/empty/empty-buffer.ts @@ -0,0 +1,53 @@ +/* + 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 { BufferSource, BufferInfo, BufferViewInfo } from '../base/define'; +import { Buffer } from '../base/buffer'; + +export class EmptyBuffer extends Buffer { + public initialize (info: BufferInfo | BufferViewInfo) { + if ('buffer' in info) { // buffer view + this._isBufferView = true; + + const buffer = info.buffer as EmptyBuffer; + + this._usage = buffer.usage; + this._memUsage = buffer.memUsage; + this._size = this._stride = info.range; + this._count = 1; + this._flags = buffer.flags; + } else { // native buffer + this._usage = info.usage; + this._memUsage = info.memUsage; + this._size = info.size; + this._stride = Math.max(info.stride || this._size, 1); + this._count = this._size / this._stride; + this._flags = info.flags; + } + } + public destroy () {} + public resize (size: number) {} + public update (buffer: BufferSource, size?: number) {} +} diff --git a/cocos/core/gfx/empty/empty-command-buffer.ts b/cocos/core/gfx/empty/empty-command-buffer.ts new file mode 100644 index 0000000000..939c4540bb --- /dev/null +++ b/cocos/core/gfx/empty/empty-command-buffer.ts @@ -0,0 +1,65 @@ +/* + 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 { DescriptorSet } from '../base/descriptor-set'; +import { Buffer } from '../base/buffer'; +import { CommandBuffer } from '../base/command-buffer'; +import { Framebuffer } from '../base/framebuffer'; +import { InputAssembler } from '../base/input-assembler'; +import { PipelineState } from '../base/pipeline-state'; +import { Texture } from '../base/texture'; +import { RenderPass } from '../base/render-pass'; +import { GlobalBarrier } from '../base/states/global-barrier'; +import { TextureBarrier } from '../base/states/texture-barrier'; +import { StencilFace, BufferSource, CommandBufferInfo, BufferTextureCopy, Color, Rect, Viewport, DrawInfo } from '../base/define'; + +export class EmptyCommandBuffer extends CommandBuffer { + public initialize (info: CommandBufferInfo) { + this._type = info.type; + this._queue = info.queue; + } + public destroy () {} + public begin (renderPass?: RenderPass, subpass = 0, frameBuffer?: Framebuffer) {} + public end () {} + public beginRenderPass (renderPass: RenderPass, framebuffer: Framebuffer, renderArea: Rect, + clearColors: Color[], clearDepth: number, clearStencil: number) {} + public endRenderPass () {} + public bindPipelineState (pipelineState: PipelineState) {} + public bindDescriptorSet (set: number, descriptorSet: DescriptorSet, dynamicOffsets?: number[]) {} + public bindInputAssembler (inputAssembler: InputAssembler) {} + public setViewport (viewport: Viewport) {} + public setScissor (scissor: Rect) {} + public setLineWidth (lineWidth: number) {} + public setDepthBias (depthBiasConstantFactor: number, depthBiasClamp: number, depthBiasSlopeFactor: number) {} + public setBlendConstants (blendConstants: Color) {} + public setDepthBound (minDepthBounds: number, maxDepthBounds: number) {} + public setStencilWriteMask (face: StencilFace, writeMask: number) {} + public setStencilCompareMask (face: StencilFace, reference: number, compareMask: number) {} + public draw (infoOrAssembler: DrawInfo | InputAssembler) {} + public updateBuffer (buffer: Buffer, data: BufferSource, size?: number) {} + public copyBuffersToTexture (buffers: ArrayBufferView[], texture: Texture, regions: BufferTextureCopy[]) {} + public execute (cmdBuffs: CommandBuffer[], count: number) {} + public pipelineBarrier (globalBarrier: GlobalBarrier, textureBarriers: TextureBarrier[]) {} +} diff --git a/cocos/core/gfx/base/texture-barrier.ts b/cocos/core/gfx/empty/empty-descriptor-set-layout.ts similarity index 68% rename from cocos/core/gfx/base/texture-barrier.ts rename to cocos/core/gfx/empty/empty-descriptor-set-layout.ts index 77a28c3707..43c8f30406 100644 --- a/cocos/core/gfx/base/texture-barrier.ts +++ b/cocos/core/gfx/empty/empty-descriptor-set-layout.ts @@ -23,29 +23,12 @@ THE SOFTWARE. */ -/** - * @packageDocumentation - * @module gfx - */ +import { DescriptorSetLayoutInfo } from '../base/define'; +import { DescriptorSetLayout } from '../base/descriptor-set-layout'; -import { Device } from './device'; -import { Obj, ObjectType, TextureBarrierInfo } from './define'; - -/** - * @en GFX shader. - * @zh GFX 着色器。 - */ -export class TextureBarrier extends Obj { - protected _device: Device; - protected _info: TextureBarrierInfo = new TextureBarrierInfo(); - - constructor (device: Device) { - super(ObjectType.TEXTURE_BARRIER); - this._device = device; - } - - public initialize (info: TextureBarrierInfo): boolean { - this._info.copy(info); - return true; +export class EmptyDescriptorSetLayout extends DescriptorSetLayout { + public initialize (info: DescriptorSetLayoutInfo) { + Array.prototype.push.apply(this._bindings, info.bindings); } + public destroy () {} } diff --git a/cocos/core/gfx/empty/empty-descriptor-set.ts b/cocos/core/gfx/empty/empty-descriptor-set.ts new file mode 100644 index 0000000000..01cddc336b --- /dev/null +++ b/cocos/core/gfx/empty/empty-descriptor-set.ts @@ -0,0 +1,35 @@ +/* + 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 { DescriptorSet } from '../base/descriptor-set'; +import { DescriptorSetInfo } from '../base/define'; + +export class EmptyDescriptorSet extends DescriptorSet { + public initialize (info: DescriptorSetInfo) { + this._layout = info.layout; + } + public destroy () {} + public update () {} +} diff --git a/cocos/core/gfx/empty/empty-device.ts b/cocos/core/gfx/empty/empty-device.ts new file mode 100644 index 0000000000..7817562aea --- /dev/null +++ b/cocos/core/gfx/empty/empty-device.ts @@ -0,0 +1,201 @@ +/* + 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 { debug } from '../../platform/debug'; +import { DescriptorSet } from '../base/descriptor-set'; +import { DescriptorSetLayout } from '../base/descriptor-set-layout'; +import { PipelineLayout } from '../base/pipeline-layout'; +import { Buffer } from '../base/buffer'; +import { CommandBuffer } from '../base/command-buffer'; +import { Device } from '../base/device'; +import { Framebuffer } from '../base/framebuffer'; +import { InputAssembler } from '../base/input-assembler'; +import { PipelineState, PipelineStateInfo } from '../base/pipeline-state'; +import { Queue } from '../base/queue'; +import { RenderPass } from '../base/render-pass'; +import { Sampler } from '../base/states/sampler'; +import { Shader } from '../base/shader'; +import { Texture } from '../base/texture'; +import { + ShaderInfo, + QueueInfo, CommandBufferInfo, DescriptorSetInfo, DescriptorSetLayoutInfo, FramebufferInfo, InputAssemblerInfo, PipelineLayoutInfo, + RenderPassInfo, SamplerInfo, TextureInfo, TextureViewInfo, BufferInfo, BufferViewInfo, DeviceInfo, TextureBarrierInfo, GlobalBarrierInfo, + QueueType, API, BufferTextureCopy, SwapchainInfo, +} from '../base/define'; +import { GlobalBarrier } from '../base/states/global-barrier'; +import { TextureBarrier } from '../base/states/texture-barrier'; +import { Swapchain } from '../base/swapchain'; +import { EmptyDescriptorSet } from './empty-descriptor-set'; +import { EmptyBuffer } from './empty-buffer'; +import { EmptyCommandBuffer } from './empty-command-buffer'; +import { EmptyFramebuffer } from './empty-framebuffer'; +import { EmptyInputAssembler } from './empty-input-assembler'; +import { EmptyDescriptorSetLayout } from './empty-descriptor-set-layout'; +import { EmptyPipelineLayout } from './empty-pipeline-layout'; +import { EmptyPipelineState } from './empty-pipeline-state'; +import { EmptyQueue } from './empty-queue'; +import { EmptyRenderPass } from './empty-render-pass'; +import { EmptyShader } from './empty-shader'; +import { EmptySwapchain } from './empty-swapchain'; +import { EmptyTexture } from './empty-texture'; + +export class EmptyDevice extends Device { + public initialize (info: DeviceInfo): boolean { + this._gfxAPI = API.UNKNOWN; + + this._bindingMappingInfo = info.bindingMappingInfo; + if (!this._bindingMappingInfo.bufferOffsets.length) this._bindingMappingInfo.bufferOffsets.push(0); + if (!this._bindingMappingInfo.samplerOffsets.length) this._bindingMappingInfo.samplerOffsets.push(0); + + this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); + + debug('Empty device initialized.'); + + return true; + } + + public destroy (): void { + if (this._queue) { + this._queue.destroy(); + this._queue = null; + } + + if (this._cmdBuff) { + this._cmdBuff.destroy(); + this._cmdBuff = null; + } + } + + public flushCommands (cmdBuffs: CommandBuffer[]) {} + public acquire (swapchains: Swapchain[]) {} + public present () {} + + public createCommandBuffer (info: CommandBufferInfo): CommandBuffer { + const cmdBuff = new EmptyCommandBuffer(); + cmdBuff.initialize(info); + return cmdBuff; + } + + public createSwapchain (info: SwapchainInfo): Swapchain { + const swapchain = new EmptySwapchain(); + swapchain.initialize(info); + return swapchain; + } + + public createBuffer (info: BufferInfo | BufferViewInfo): Buffer { + const buffer = new EmptyBuffer(); + buffer.initialize(info); + return buffer; + } + + public createTexture (info: TextureInfo | TextureViewInfo): Texture { + const texture = new EmptyTexture(); + texture.initialize(info); + return texture; + } + + public createDescriptorSet (info: DescriptorSetInfo): DescriptorSet { + const descriptorSet = new EmptyDescriptorSet(); + descriptorSet.initialize(info); + return descriptorSet; + } + + public createShader (info: ShaderInfo): Shader { + const shader = new EmptyShader(); + shader.initialize(info); + return shader; + } + + public createInputAssembler (info: InputAssemblerInfo): InputAssembler { + const inputAssembler = new EmptyInputAssembler(); + inputAssembler.initialize(info); + return inputAssembler; + } + + public createRenderPass (info: RenderPassInfo): RenderPass { + const renderPass = new EmptyRenderPass(); + renderPass.initialize(info); + return renderPass; + } + + public createFramebuffer (info: FramebufferInfo): Framebuffer { + const framebuffer = new EmptyFramebuffer(); + framebuffer.initialize(info); + return framebuffer; + } + + public createDescriptorSetLayout (info: DescriptorSetLayoutInfo): DescriptorSetLayout { + const descriptorSetLayout = new EmptyDescriptorSetLayout(); + descriptorSetLayout.initialize(info); + return descriptorSetLayout; + } + + public createPipelineLayout (info: PipelineLayoutInfo): PipelineLayout { + const pipelineLayout = new EmptyPipelineLayout(); + pipelineLayout.initialize(info); + return pipelineLayout; + } + + public createPipelineState (info: PipelineStateInfo): PipelineState { + const pipelineState = new EmptyPipelineState(); + pipelineState.initialize(info); + return pipelineState; + } + + public createQueue (info: QueueInfo): Queue { + const queue = new EmptyQueue(); + queue.initialize(info); + return queue; + } + + public getSampler (info: SamplerInfo): Sampler { + const hash = Sampler.computeHash(info); + if (!this._samplers.has(hash)) { + this._samplers.set(hash, new Sampler(info)); + } + return this._samplers.get(hash)!; + } + + public getGlobalBarrier (info: GlobalBarrierInfo) { + const hash = GlobalBarrier.computeHash(info); + if (!this._globalBarriers.has(hash)) { + this._globalBarriers.set(hash, new GlobalBarrier(info)); + } + return this._globalBarriers.get(hash)!; + } + + public getTextureBarrier (info: TextureBarrierInfo) { + const hash = TextureBarrier.computeHash(info); + if (!this._textureBarriers.has(hash)) { + this._textureBarriers.set(hash, new TextureBarrier(info)); + } + return this._textureBarriers.get(hash)!; + } + + public copyBuffersToTexture (buffers: ArrayBufferView[], texture: Texture, regions: BufferTextureCopy[]) {} + public copyTextureToBuffers (texture: Texture, buffers: ArrayBufferView[], regions: BufferTextureCopy[]) {} + public copyTexImagesToTexture (texImages: TexImageSource[], texture: Texture, regions: BufferTextureCopy[]) {} +} diff --git a/cocos/core/gfx/empty/empty-framebuffer.ts b/cocos/core/gfx/empty/empty-framebuffer.ts new file mode 100644 index 0000000000..57a8a0b0f7 --- /dev/null +++ b/cocos/core/gfx/empty/empty-framebuffer.ts @@ -0,0 +1,36 @@ +/* + 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 { FramebufferInfo } from '../base/define'; +import { Framebuffer } from '../base/framebuffer'; + +export class EmptyFramebuffer extends Framebuffer { + public initialize (info: FramebufferInfo) { + this._renderPass = info.renderPass; + this._colorTextures = info.colorTextures || []; + this._depthStencilTexture = info.depthStencilTexture || null; + } + public destroy () {} +} diff --git a/cocos/core/gfx/empty/empty-input-assembler.ts b/cocos/core/gfx/empty/empty-input-assembler.ts new file mode 100644 index 0000000000..a26a62b2a2 --- /dev/null +++ b/cocos/core/gfx/empty/empty-input-assembler.ts @@ -0,0 +1,47 @@ +/* + 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 { InputAssemblerInfo } from '../base/define'; +import { InputAssembler } from '../base/input-assembler'; + +export class EmptyInputAssembler extends InputAssembler { + public initialize (info: InputAssemblerInfo) { + this._attributes = info.attributes; + this._attributesHash = this.computeAttributesHash(); + this._vertexBuffers = info.vertexBuffers; + + if (info.indexBuffer) { + this._indexBuffer = info.indexBuffer; + this._drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; + this._drawInfo.firstIndex = 0; + } else { + const vertBuff = this._vertexBuffers[0]; + this._drawInfo.vertexCount = vertBuff.size / vertBuff.stride; + this._drawInfo.firstVertex = 0; + this._drawInfo.vertexOffset = 0; + } + } + public destroy () {} +} diff --git a/cocos/core/gfx/empty/empty-pipeline-layout.ts b/cocos/core/gfx/empty/empty-pipeline-layout.ts new file mode 100644 index 0000000000..cc06e63713 --- /dev/null +++ b/cocos/core/gfx/empty/empty-pipeline-layout.ts @@ -0,0 +1,34 @@ +/* + 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 { PipelineLayout } from '../base/pipeline-layout'; +import { PipelineLayoutInfo } from '../base/define'; + +export class EmptyPipelineLayout extends PipelineLayout { + public initialize (info: PipelineLayoutInfo) { + Array.prototype.push.apply(this._setLayouts, info.setLayouts); + } + public destroy () {} +} diff --git a/cocos/core/gfx/empty/empty-pipeline-state.ts b/cocos/core/gfx/empty/empty-pipeline-state.ts new file mode 100644 index 0000000000..2db9bd91be --- /dev/null +++ b/cocos/core/gfx/empty/empty-pipeline-state.ts @@ -0,0 +1,54 @@ +/* + 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 { PipelineState, PipelineStateInfo } from '../base/pipeline-state'; + +export class EmptyPipelineState extends PipelineState { + public initialize (info: PipelineStateInfo) { + this._primitive = info.primitive; + this._shader = info.shader; + this._pipelineLayout = info.pipelineLayout; + const bs = this._bs; + if (info.blendState) { + const bsInfo = info.blendState; + const { targets } = bsInfo; + if (targets) { + targets.forEach((t, i) => { + bs.setTarget(i, t); + }); + } + + if (bsInfo.isA2C !== undefined) { bs.isA2C = bsInfo.isA2C; } + if (bsInfo.isIndepend !== undefined) { bs.isIndepend = bsInfo.isIndepend; } + if (bsInfo.blendColor !== undefined) { bs.blendColor = bsInfo.blendColor; } + } + Object.assign(this._rs, info.rasterizerState); + Object.assign(this._dss, info.depthStencilState); + this._is = info.inputState; + this._renderPass = info.renderPass; + this._dynamicStates = info.dynamicStates; + } + public destroy () {} +} diff --git a/cocos/core/gfx/empty/empty-queue.ts b/cocos/core/gfx/empty/empty-queue.ts new file mode 100644 index 0000000000..99cfd010a3 --- /dev/null +++ b/cocos/core/gfx/empty/empty-queue.ts @@ -0,0 +1,36 @@ +/* + 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 { QueueInfo } from '../base/define'; +import { CommandBuffer } from '../base/command-buffer'; +import { Queue } from '../base/queue'; + +export class EmptyQueue extends Queue { + public initialize (info: QueueInfo) { + this._type = info.type; + } + public destroy () {} + public submit (cmdBuffs: CommandBuffer[]) {} +} diff --git a/cocos/core/gfx/empty/empty-render-pass.ts b/cocos/core/gfx/empty/empty-render-pass.ts new file mode 100644 index 0000000000..1873a9b928 --- /dev/null +++ b/cocos/core/gfx/empty/empty-render-pass.ts @@ -0,0 +1,37 @@ +/* + 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 { RenderPassInfo } from '../base/define'; +import { RenderPass } from '../base/render-pass'; + +export class EmptyRenderPass extends RenderPass { + public initialize (info: RenderPassInfo) { + this._colorInfos = info.colorAttachments; + this._depthStencilInfo = info.depthStencilAttachment; + this._subpasses = info.subpasses; + this._hash = this.computeHash(); + } + public destroy () {} +} diff --git a/cocos/core/gfx/empty/empty-shader.ts b/cocos/core/gfx/empty/empty-shader.ts new file mode 100644 index 0000000000..2a3ec122fc --- /dev/null +++ b/cocos/core/gfx/empty/empty-shader.ts @@ -0,0 +1,35 @@ +/* + 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 { debug } from '../../platform'; +import { ShaderInfo } from '../base/define'; +import { Shader } from '../base/shader'; + +export class EmptyShader extends Shader { + public initialize (info: ShaderInfo) { + debug(`Shader '${info.name}' compilation succeeded.`); + } + public destroy () {} +} diff --git a/cocos/core/gfx/empty/empty-swapchain.ts b/cocos/core/gfx/empty/empty-swapchain.ts new file mode 100644 index 0000000000..e83e643fa2 --- /dev/null +++ b/cocos/core/gfx/empty/empty-swapchain.ts @@ -0,0 +1,52 @@ +/* + 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 { Format, SwapchainInfo } from '../base/define'; +import { Swapchain } from '../base/swapchain'; +import { EmptyTexture } from './empty-texture'; + +export class EmptySwapchain extends Swapchain { + public initialize (info: SwapchainInfo) { + this._colorTexture = new EmptyTexture(); + // @ts-expect-error(2445) private initializer + this._colorTexture.initAsSwapchainTexture({ + swapchain: this, + format: Format.RGBA8, + width: info.width, + height: info.height, + }); + + this._depthStencilTexture = new EmptyTexture(); + // @ts-expect-error(2445) private initializer + this._depthStencilTexture.initAsSwapchainTexture({ + swapchain: this, + format: Format.DEPTH_STENCIL, + width: info.width, + height: info.height, + }); + } + public destroy (): void {} + public resize (width: number, height: number) {} +} diff --git a/cocos/core/gfx/empty/empty-texture.ts b/cocos/core/gfx/empty/empty-texture.ts new file mode 100644 index 0000000000..b37e6ec676 --- /dev/null +++ b/cocos/core/gfx/empty/empty-texture.ts @@ -0,0 +1,61 @@ +/* + 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 { TextureInfo, TextureViewInfo, ISwapchainTextureInfo, FormatSurfaceSize, IsPowerOf2 } from '../base/define'; +import { Texture } from '../base/texture'; + +export class EmptyTexture extends Texture { + public initialize (info: TextureInfo | TextureViewInfo, isSwapchainTexture?: boolean) { + if ('texture' in info) { + this._type = info.type; + this._format = info.format; + this._layerCount = info.layerCount; + this._levelCount = info.levelCount; + this._usage = info.texture.usage; + this._width = info.texture.width; + this._height = info.texture.height; + this._depth = info.texture.depth; + this._samples = info.texture.samples; + this._flags = info.texture.flags; + } else { + this._type = info.type; + this._usage = info.usage; + this._format = info.format; + this._width = info.width; + this._height = info.height; + this._depth = info.depth; + this._layerCount = info.layerCount; + this._levelCount = info.levelCount; + this._samples = info.samples; + this._flags = info.flags; + this._isPowerOf2 = IsPowerOf2(this._width) && IsPowerOf2(this._height); + this._size = FormatSurfaceSize(this._format, this.width, this.height, + this.depth, this._levelCount) * this._layerCount; + } + } + public destroy () {} + public resize (width: number, height: number) {} + protected initAsSwapchainTexture (info: ISwapchainTextureInfo) {} +} diff --git a/cocos/core/gfx/index.jsb.ts b/cocos/core/gfx/index.jsb.ts index 52deb7df2e..5d3d76aec8 100644 --- a/cocos/core/gfx/index.jsb.ts +++ b/cocos/core/gfx/index.jsb.ts @@ -39,20 +39,22 @@ export * from './base/buffer'; export * from './base/command-buffer'; export * from './base/define'; export * from './base/device'; +export * from './base/swapchain'; export * from './base/framebuffer'; export * from './base/input-assembler'; export * from './base/descriptor-set-layout'; export * from './base/pipeline-layout'; export * from './base/queue'; export * from './base/render-pass'; -export * from './base/sampler'; export * from './base/shader'; export * from './base/texture'; -export * from './base/global-barrier'; -export * from './base/texture-barrier'; +export * from './base/states/sampler'; +export * from './base/states/global-barrier'; +export * from './base/states/texture-barrier'; const polyfillCC: Record = Object.assign({}, defines); polyfillCC.Device = gfx.Device; +polyfillCC.Swapchain = gfx.Swapchain; polyfillCC.Buffer = gfx.Buffer; polyfillCC.Texture = gfx.Texture; polyfillCC.Sampler = gfx.Sampler; diff --git a/cocos/core/gfx/index.ts b/cocos/core/gfx/index.ts index 76135fbaea..cddd490376 100644 --- a/cocos/core/gfx/index.ts +++ b/cocos/core/gfx/index.ts @@ -36,6 +36,7 @@ export * from './base/buffer'; export * from './base/command-buffer'; export * from './base/define'; export * from './base/device'; +export * from './base/swapchain'; export * from './base/framebuffer'; export * from './base/input-assembler'; export * from './base/descriptor-set-layout'; @@ -43,8 +44,8 @@ export * from './base/pipeline-layout'; export * from './base/pipeline-state'; export * from './base/queue'; export * from './base/render-pass'; -export * from './base/sampler'; +export * from './base/states/sampler'; export * from './base/shader'; export * from './base/texture'; -export * from './base/global-barrier'; -export * from './base/texture-barrier'; +export * from './base/states/global-barrier'; +export * from './base/states/texture-barrier'; diff --git a/cocos/core/gfx/polyfill-legacy-cc.ts b/cocos/core/gfx/polyfill-legacy-cc.ts index 7691bfb033..1eacdae2af 100644 --- a/cocos/core/gfx/polyfill-legacy-cc.ts +++ b/cocos/core/gfx/polyfill-legacy-cc.ts @@ -31,6 +31,7 @@ import { Buffer } from './base/buffer'; import { CommandBuffer } from './base/command-buffer'; import { Device } from './base/device'; +import { Swapchain } from './base/swapchain'; import { Framebuffer } from './base/framebuffer'; import { InputAssembler } from './base/input-assembler'; import { DescriptorSet } from './base/descriptor-set'; @@ -39,16 +40,17 @@ import { PipelineLayout } from './base/pipeline-layout'; import { PipelineState, PipelineStateInfo, RasterizerState, BlendState, BlendTarget, DepthStencilState } from './base/pipeline-state'; import { Queue } from './base/queue'; import { RenderPass } from './base/render-pass'; -import { Sampler } from './base/sampler'; +import { Sampler } from './base/states/sampler'; import { Shader } from './base/shader'; import { Texture } from './base/texture'; -import { GlobalBarrier } from './base/global-barrier'; -import { TextureBarrier } from './base/texture-barrier'; +import { GlobalBarrier } from './base/states/global-barrier'; +import { TextureBarrier } from './base/states/texture-barrier'; import { legacyCC } from '../global-exports'; import * as defines from './base/define'; const polyfills: Record = { Device, + Swapchain, Buffer, Texture, Sampler, diff --git a/cocos/core/gfx/webgl/webgl-sampler.ts b/cocos/core/gfx/webgl/states/webgl-sampler.ts similarity index 75% rename from cocos/core/gfx/webgl/webgl-sampler.ts rename to cocos/core/gfx/webgl/states/webgl-sampler.ts index 5869484021..ae51b79d4b 100644 --- a/cocos/core/gfx/webgl/webgl-sampler.ts +++ b/cocos/core/gfx/webgl/states/webgl-sampler.ts @@ -23,9 +23,9 @@ THE SOFTWARE. */ -import { Filter, SamplerInfo } from '../base/define'; -import { Sampler } from '../base/sampler'; -import { IWebGLGPUSampler } from './webgl-gpu-objects'; +import { Filter, SamplerInfo } from '../../base/define'; +import { Sampler } from '../../base/states/sampler'; +import { IWebGLGPUSampler } from '../webgl-gpu-objects'; const WebGLWraps: GLenum[] = [ 0x2901, // WebGLRenderingContext.REPEAT, @@ -41,24 +41,15 @@ export class WebGLSampler extends Sampler { private _gpuSampler: IWebGLGPUSampler | null = null; - public initialize (info: SamplerInfo): boolean { - this._minFilter = info.minFilter; - this._magFilter = info.magFilter; - this._mipFilter = info.mipFilter; - this._addressU = info.addressU; - this._addressV = info.addressV; - this._addressW = info.addressW; - this._maxAnisotropy = info.maxAnisotropy; - this._cmpFunc = info.cmpFunc; - this._borderColor = info.borderColor; - this._mipLODBias = info.mipLODBias; + constructor (info: SamplerInfo) { + super(info); let glMinFilter = 0; let glMagFilter = 0; - const minFilter = this._minFilter; - const magFilter = this._magFilter; - const mipFilter = this._mipFilter; + const minFilter = this._info.minFilter; + const magFilter = this._info.magFilter; + const mipFilter = this._info.mipFilter; if (minFilter === Filter.LINEAR || minFilter === Filter.ANISOTROPIC) { if (mipFilter === Filter.LINEAR || mipFilter === Filter.ANISOTROPIC) { @@ -82,9 +73,9 @@ export class WebGLSampler extends Sampler { glMagFilter = 0x2600; // WebGLRenderingContext.NEAREST; } - const glWrapS = WebGLWraps[this._addressU]; - const glWrapT = WebGLWraps[this._addressV]; - const glWrapR = WebGLWraps[this._addressW]; + const glWrapS = WebGLWraps[this._info.addressU]; + const glWrapT = WebGLWraps[this._info.addressV]; + const glWrapR = WebGLWraps[this._info.addressW]; this._gpuSampler = { glMinFilter, @@ -93,11 +84,5 @@ export class WebGLSampler extends Sampler { glWrapT, glWrapR, }; - - return true; - } - - public destroy () { - this._gpuSampler = null; } } diff --git a/cocos/core/gfx/webgl/webgl-buffer.ts b/cocos/core/gfx/webgl/webgl-buffer.ts index 0a3fb0598c..1cabcb393f 100644 --- a/cocos/core/gfx/webgl/webgl-buffer.ts +++ b/cocos/core/gfx/webgl/webgl-buffer.ts @@ -23,7 +23,7 @@ THE SOFTWARE. */ -import { BufferSource, BufferInfo, BufferViewInfo, IndirectBuffer, BufferUsageBit } from '../base/define'; +import { BufferSource, BufferInfo, BufferViewInfo, BufferUsageBit } from '../base/define'; import { Buffer } from '../base/buffer'; import { @@ -32,8 +32,8 @@ import { WebGLCmdFuncResizeBuffer, WebGLCmdFuncUpdateBuffer, } from './webgl-commands'; -import { WebGLDevice } from './webgl-device'; -import { IWebGLGPUBuffer, IWebGLGPUBufferView } from './webgl-gpu-objects'; +import { IWebGLGPUBuffer, IWebGLGPUBufferView, WebGLIndirectDrawInfos } from './webgl-gpu-objects'; +import { WebGLDeviceManager } from './webgl-define'; export class WebGLBuffer extends Buffer { get gpuBuffer (): IWebGLGPUBuffer { @@ -48,7 +48,7 @@ export class WebGLBuffer extends Buffer { private _gpuBufferView: IWebGLGPUBufferView | null = null; private _uniformBuffer: Uint8Array | null = null; - public initialize (info: BufferInfo | BufferViewInfo): boolean { + public initialize (info: BufferInfo | BufferViewInfo) { if ('buffer' in info) { // buffer view this._isBufferView = true; @@ -73,10 +73,6 @@ export class WebGLBuffer extends Buffer { this._count = this._size / this._stride; this._flags = info.flags; - if (this._usage & BufferUsageBit.INDIRECT) { - this._indirectBuffer = new IndirectBuffer(); - } - if ((this._usage & BufferUsageBit.UNIFORM) && this._size > 0) { this._uniformBuffer = new Uint8Array(this._size); } @@ -88,31 +84,25 @@ export class WebGLBuffer extends Buffer { stride: this._stride, buffer: null, vf32: null, - indirects: [], + indirects: new WebGLIndirectDrawInfos(), glTarget: 0, glBuffer: null, }; - if (info.usage & BufferUsageBit.INDIRECT) { - this._gpuBuffer.indirects = this._indirectBuffer!.drawInfos; - } - if (this._usage & BufferUsageBit.UNIFORM) { this._gpuBuffer.buffer = this._uniformBuffer; } - WebGLCmdFuncCreateBuffer(this._device as WebGLDevice, this._gpuBuffer); + WebGLCmdFuncCreateBuffer(WebGLDeviceManager.instance, this._gpuBuffer); - this._device.memoryStatus.bufferSize += this._size; + WebGLDeviceManager.instance.memoryStatus.bufferSize += this._size; } - - return true; } public destroy () { if (this._gpuBuffer) { - WebGLCmdFuncDestroyBuffer(this._device as WebGLDevice, this._gpuBuffer); - this._device.memoryStatus.bufferSize -= this._size; + WebGLCmdFuncDestroyBuffer(WebGLDeviceManager.instance, this._gpuBuffer); + WebGLDeviceManager.instance.memoryStatus.bufferSize -= this._size; this._gpuBuffer = null; } @@ -144,9 +134,9 @@ export class WebGLBuffer extends Buffer { this._gpuBuffer.size = size; if (size > 0) { - WebGLCmdFuncResizeBuffer(this._device as WebGLDevice, this._gpuBuffer); - this._device.memoryStatus.bufferSize -= oldSize; - this._device.memoryStatus.bufferSize += size; + WebGLCmdFuncResizeBuffer(WebGLDeviceManager.instance, this._gpuBuffer); + WebGLDeviceManager.instance.memoryStatus.bufferSize -= oldSize; + WebGLDeviceManager.instance.memoryStatus.bufferSize += size; } } } @@ -167,7 +157,7 @@ export class WebGLBuffer extends Buffer { } WebGLCmdFuncUpdateBuffer( - this._device as WebGLDevice, + WebGLDeviceManager.instance, this._gpuBuffer!, buffer, 0, diff --git a/cocos/core/gfx/webgl/webgl-command-buffer.ts b/cocos/core/gfx/webgl/webgl-command-buffer.ts index 4017ad2007..7b5687fea8 100644 --- a/cocos/core/gfx/webgl/webgl-command-buffer.ts +++ b/cocos/core/gfx/webgl/webgl-command-buffer.ts @@ -33,7 +33,6 @@ import { Texture } from '../base/texture'; import { WebGLDescriptorSet } from './webgl-descriptor-set'; import { WebGLBuffer } from './webgl-buffer'; import { WebGLCommandAllocator } from './webgl-command-allocator'; -import { WebGLDevice } from './webgl-device'; import { WebGLFramebuffer } from './webgl-framebuffer'; import { IWebGLGPUInputAssembler, IWebGLGPUDescriptorSet, IWebGLGPUPipelineState } from './webgl-gpu-objects'; import { WebGLInputAssembler } from './webgl-input-assembler'; @@ -45,12 +44,14 @@ import { BufferUsageBit, CommandBufferType, StencilFace, BufferSource, CommandBufferInfo, BufferTextureCopy, Color, Rect, Viewport, DrawInfo, DynamicStates } from '../base/define'; import { WebGLCmd, WebGLCmdBeginRenderPass, WebGLCmdBindStates, WebGLCmdCopyBufferToTexture, WebGLCmdDraw, WebGLCmdPackage, WebGLCmdUpdateBuffer } from './webgl-commands'; -import { GlobalBarrier } from '../base/global-barrier'; -import { TextureBarrier } from '../base/texture-barrier'; +import { GlobalBarrier } from '../base/states/global-barrier'; +import { TextureBarrier } from '../base/states/texture-barrier'; +import { WebGLDeviceManager } from './webgl-define'; export class WebGLCommandBuffer extends CommandBuffer { public cmdPackage: WebGLCmdPackage = new WebGLCmdPackage(); - protected _webGLAllocator: WebGLCommandAllocator | null = null; + + protected _cmdAllocator: WebGLCommandAllocator = new WebGLCommandAllocator(); protected _isInRenderPass = false; protected _curGPUPipelineState: IWebGLGPUPipelineState | null = null; protected _curGPUInputAssembler: IWebGLGPUInputAssembler | null = null; @@ -59,29 +60,22 @@ export class WebGLCommandBuffer extends CommandBuffer { protected _curDynamicStates: DynamicStates = new DynamicStates(); protected _isStateInvalied = false; - public initialize (info: CommandBufferInfo): boolean { + public initialize (info: CommandBufferInfo) { this._type = info.type; this._queue = info.queue; - this._webGLAllocator = (this._device as WebGLDevice).cmdAllocator; - - const setCount = (this._device as WebGLDevice).bindingMappingInfo.bufferOffsets.length; + const setCount = WebGLDeviceManager.instance.bindingMappingInfo.bufferOffsets.length; for (let i = 0; i < setCount; i++) { this._curGPUDescriptorSets.push(null!); } - - return true; } public destroy () { - if (this._webGLAllocator) { - this._webGLAllocator.clearCmds(this.cmdPackage); - this._webGLAllocator = null; - } + this._cmdAllocator.clearCmds(this.cmdPackage); } public begin (renderPass?: RenderPass, subpass = 0, frameBuffer?: Framebuffer) { - this._webGLAllocator!.clearCmds(this.cmdPackage); + this._cmdAllocator.clearCmds(this.cmdPackage); this._curGPUPipelineState = null; this._curGPUInputAssembler = null; this._curGPUDescriptorSets.length = 0; @@ -106,7 +100,7 @@ export class WebGLCommandBuffer extends CommandBuffer { clearDepth: number, clearStencil: number, ) { - const cmd = this._webGLAllocator!.beginRenderPassCmdPool.alloc(WebGLCmdBeginRenderPass); + const cmd = this._cmdAllocator.beginRenderPassCmdPool.alloc(WebGLCmdBeginRenderPass); cmd.gpuRenderPass = (renderPass as WebGLRenderPass).gpuRenderPass; cmd.gpuFramebuffer = (framebuffer as WebGLFramebuffer).gpuFramebuffer; cmd.renderArea = renderArea; @@ -268,22 +262,16 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public draw (info: DrawInfo | InputAssembler) { + public draw (infoOrAssembler: DrawInfo | InputAssembler) { if (this._type === CommandBufferType.PRIMARY && this._isInRenderPass || this._type === CommandBufferType.SECONDARY) { if (this._isStateInvalied) { this.bindStates(); } + const info = 'drawInfo' in infoOrAssembler ? infoOrAssembler.drawInfo : infoOrAssembler; - const cmd = this._webGLAllocator!.drawCmdPool.alloc(WebGLCmdDraw); - // cmd.drawInfo = inputAssembler; - cmd.drawInfo.vertexCount = info.vertexCount; - cmd.drawInfo.firstVertex = info.firstVertex; - cmd.drawInfo.indexCount = info.indexCount; - cmd.drawInfo.firstIndex = info.firstIndex; - cmd.drawInfo.vertexOffset = info.vertexOffset; - cmd.drawInfo.instanceCount = info.instanceCount; - cmd.drawInfo.firstInstance = info.firstInstance; + const cmd = this._cmdAllocator.drawCmdPool.alloc(WebGLCmdDraw); + cmd.drawInfo.copy(info); this.cmdPackage.drawCmds.push(cmd); this.cmdPackage.cmds.push(WebGLCmd.DRAW); @@ -316,7 +304,7 @@ export class WebGLCommandBuffer extends CommandBuffer { || this._type === CommandBufferType.SECONDARY) { const gpuBuffer = (buffer as WebGLBuffer).gpuBuffer; if (gpuBuffer) { - const cmd = this._webGLAllocator!.updateBufferCmdPool.alloc(WebGLCmdUpdateBuffer); + const cmd = this._cmdAllocator.updateBufferCmdPool.alloc(WebGLCmdUpdateBuffer); let buffSize = 0; let buff: BufferSource | null = null; @@ -352,7 +340,7 @@ export class WebGLCommandBuffer extends CommandBuffer { || this._type === CommandBufferType.SECONDARY) { const gpuTexture = (texture as WebGLTexture).gpuTexture; if (gpuTexture) { - const cmd = this._webGLAllocator!.copyBufferToTextureCmdPool.alloc(WebGLCmdCopyBufferToTexture); + const cmd = this._cmdAllocator.copyBufferToTextureCmdPool.alloc(WebGLCmdCopyBufferToTexture); if (cmd) { cmd.gpuTexture = gpuTexture; cmd.regions = regions; @@ -411,15 +399,10 @@ export class WebGLCommandBuffer extends CommandBuffer { } } - public pipelineBarrier (globalBarrier: GlobalBarrier, textureBarriers: TextureBarrier[]) { - } - - public get webGLDevice (): WebGLDevice { - return this._device as WebGLDevice; - } + public pipelineBarrier (globalBarrier: GlobalBarrier | null, textureBarriers?: TextureBarrier[], textures?: Texture[]) {} protected bindStates () { - const bindStatesCmd = this._webGLAllocator!.bindStatesCmdPool.alloc(WebGLCmdBindStates); + const bindStatesCmd = this._cmdAllocator.bindStatesCmdPool.alloc(WebGLCmdBindStates); if (bindStatesCmd) { bindStatesCmd.gpuPipelineState = this._curGPUPipelineState; diff --git a/cocos/core/gfx/webgl/webgl-commands.ts b/cocos/core/gfx/webgl/webgl-commands.ts index 4f312d6968..fb1c05ce19 100644 --- a/cocos/core/gfx/webgl/webgl-commands.ts +++ b/cocos/core/gfx/webgl/webgl-commands.ts @@ -95,12 +95,8 @@ export function GFXFormatToWebGLType (format: Format, gl: WebGLRenderingContext) case Format.RGB10A2UI: return gl.UNSIGNED_INT; case Format.RGB9E5: return gl.UNSIGNED_BYTE; - case Format.D16: return gl.UNSIGNED_SHORT; - case Format.D16S8: return WebGLEXT.UNSIGNED_INT_24_8_WEBGL; // not supported, fallback - case Format.D24: return gl.UNSIGNED_INT; - case Format.D24S8: return WebGLEXT.UNSIGNED_INT_24_8_WEBGL; - case Format.D32F: return gl.UNSIGNED_INT; // not supported, fallback - case Format.D32F_S8: return WebGLEXT.UNSIGNED_INT_24_8_WEBGL; // not supported, fallback + case Format.DEPTH: return gl.UNSIGNED_INT; + case Format.DEPTH_STENCIL: return WebGLEXT.UNSIGNED_INT_24_8_WEBGL; // not supported, fallback case Format.BC1: return gl.UNSIGNED_BYTE; case Format.BC1_SRGB: return gl.UNSIGNED_BYTE; @@ -178,12 +174,8 @@ export function GFXFormatToWebGLInternalFormat (format: Format, gl: WebGLRenderi case Format.RGBA16F: return WebGLEXT.RGBA16F_EXT; case Format.RGBA32F: return WebGLEXT.RGBA32F_EXT; case Format.SRGB8_A8: return WebGLEXT.SRGB8_ALPHA8_EXT; - case Format.D16: return gl.DEPTH_COMPONENT16; - case Format.D16S8: return gl.DEPTH_STENCIL; - case Format.D24: return gl.DEPTH_COMPONENT16; - case Format.D24S8: return gl.DEPTH_STENCIL; - case Format.D32F: return gl.DEPTH_COMPONENT16; - case Format.D32F_S8: return gl.DEPTH_STENCIL; + case Format.DEPTH: return gl.DEPTH_COMPONENT16; + case Format.DEPTH_STENCIL: return gl.DEPTH_STENCIL; default: { console.error('Unsupported Format, convert to WebGL internal format failed.'); @@ -208,12 +200,8 @@ export function GFXFormatToWebGLFormat (format: Format, gl: WebGLRenderingContex case Format.R5G6B5: return gl.RGB; case Format.RGB5A1: return gl.RGBA; case Format.RGBA4: return gl.RGBA; - case Format.D16: return gl.DEPTH_COMPONENT; - case Format.D16S8: return gl.DEPTH_STENCIL; - case Format.D24: return gl.DEPTH_COMPONENT; - case Format.D24S8: return gl.DEPTH_STENCIL; - case Format.D32F: return gl.DEPTH_COMPONENT; - case Format.D32F_S8: return gl.DEPTH_STENCIL; + case Format.DEPTH: return gl.DEPTH_COMPONENT; + case Format.DEPTH_STENCIL: return gl.DEPTH_STENCIL; case Format.BC1: return WebGLEXT.COMPRESSED_RGB_S3TC_DXT1_EXT; case Format.BC1_ALPHA: return WebGLEXT.COMPRESSED_RGBA_S3TC_DXT1_EXT; @@ -596,9 +584,9 @@ export function WebGLCmdFuncCreateBuffer (device: WebGLDevice, gpuBuffer: IWebGL if (glBuffer) { gpuBuffer.glBuffer = glBuffer; if (gpuBuffer.size > 0) { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { - device.OES_vertex_array_object!.bindVertexArrayOES(null); + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; } } @@ -620,9 +608,9 @@ export function WebGLCmdFuncCreateBuffer (device: WebGLDevice, gpuBuffer: IWebGL if (glBuffer) { gpuBuffer.glBuffer = glBuffer; if (gpuBuffer.size > 0) { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { - device.OES_vertex_array_object!.bindVertexArrayOES(null); + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; } } @@ -638,7 +626,6 @@ export function WebGLCmdFuncCreateBuffer (device: WebGLDevice, gpuBuffer: IWebGL } } } else if (gpuBuffer.usage & BufferUsageBit.UNIFORM) { - // console.error("WebGL 1.0 doesn't support uniform buffer."); gpuBuffer.glTarget = gl.NONE; if (gpuBuffer.buffer) { @@ -669,9 +656,9 @@ export function WebGLCmdFuncResizeBuffer (device: WebGLDevice, gpuBuffer: IWebGL const glUsage: GLenum = gpuBuffer.memUsage & MemoryUsageBit.HOST ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW; if (gpuBuffer.usage & BufferUsageBit.VERTEX) { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { - device.OES_vertex_array_object!.bindVertexArrayOES(null); + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; } } @@ -688,9 +675,9 @@ export function WebGLCmdFuncResizeBuffer (device: WebGLDevice, gpuBuffer: IWebGL gl.bindBuffer(gl.ARRAY_BUFFER, null); device.stateCache.glArrayBuffer = null; } else if (gpuBuffer.usage & BufferUsageBit.INDEX) { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { - device.OES_vertex_array_object!.bindVertexArrayOES(null); + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; } } @@ -707,7 +694,6 @@ export function WebGLCmdFuncResizeBuffer (device: WebGLDevice, gpuBuffer: IWebGL gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); device.stateCache.glElementArrayBuffer = null; } else if (gpuBuffer.usage & BufferUsageBit.UNIFORM) { - // console.error("WebGL 1.0 doesn't support uniform buffer."); if (gpuBuffer.buffer) { gpuBuffer.vf32 = new Float32Array(gpuBuffer.buffer.buffer); } @@ -729,8 +715,11 @@ export function WebGLCmdFuncUpdateBuffer (device: WebGLDevice, gpuBuffer: IWebGL gpuBuffer.vf32!.set(new Float32Array(buffer as ArrayBuffer), offset / Float32Array.BYTES_PER_ELEMENT); } } else if (gpuBuffer.usage & BufferUsageBit.INDIRECT) { - gpuBuffer.indirects.length = offset; - Array.prototype.push.apply(gpuBuffer.indirects, (buffer as IndirectBuffer).drawInfos); + gpuBuffer.indirects.clearDraws(); + const drawInfos = (buffer as IndirectBuffer).drawInfos; + for (let i = 0; i < drawInfos.length; ++i) { + gpuBuffer.indirects.setDrawInfo(offset + i, drawInfos[i]); + } } else { const buff = buffer as ArrayBuffer; const { gl } = device; @@ -738,9 +727,9 @@ export function WebGLCmdFuncUpdateBuffer (device: WebGLDevice, gpuBuffer: IWebGL switch (gpuBuffer.glTarget) { case gl.ARRAY_BUFFER: { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { - device.OES_vertex_array_object!.bindVertexArrayOES(null); + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; } } @@ -752,9 +741,9 @@ export function WebGLCmdFuncUpdateBuffer (device: WebGLDevice, gpuBuffer: IWebGL break; } case gl.ELEMENT_ARRAY_BUFFER: { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { - device.OES_vertex_array_object!.bindVertexArrayOES(null); + device.extensions.OES_vertex_array_object!.bindVertexArrayOES(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; } } @@ -791,13 +780,14 @@ export function WebGLCmdFuncCreateTexture (device: WebGLDevice, gpuTexture: IWeb switch (gpuTexture.type) { case TextureType.TEX2D: { gpuTexture.glTarget = gl.TEXTURE_2D; + if (gpuTexture.isSwapchainTexture) break; const maxSize = Math.max(w, h); if (maxSize > device.capabilities.maxTextureSize) { errorID(9100, maxSize, device.capabilities.maxTextureSize); } - if (!device.WEBGL_depth_texture && FormatInfos[gpuTexture.format].hasDepth) { + if (!device.extensions.WEBGL_depth_texture && FormatInfos[gpuTexture.format].hasDepth) { gpuTexture.glInternalFmt = GFXFormatToWebGLInternalFormat(gpuTexture.format, gl); const glRenderbuffer = gl.createRenderbuffer(); if (glRenderbuffer && gpuTexture.size > 0) { @@ -1046,7 +1036,12 @@ export function WebGLCmdFuncResizeTexture (device: WebGLDevice, gpuTexture: IWeb } export function WebGLCmdFuncCreateFramebuffer (device: WebGLDevice, gpuFramebuffer: IWebGLGPUFramebuffer) { - if (!gpuFramebuffer.gpuColorTextures.length && !gpuFramebuffer.gpuDepthStencilTexture) { return; } // onscreen fbo + let isOnscreen = false; + for (let i = 0; i < gpuFramebuffer.gpuColorTextures.length; ++i) { + if (!gpuFramebuffer.gpuColorTextures[i].glTexture) isOnscreen = true; + } + if (gpuFramebuffer.gpuDepthStencilTexture && !gpuFramebuffer.gpuDepthStencilTexture.glTexture) isOnscreen = true; + if (isOnscreen) return; const { gl } = device; const attachments: GLenum[] = []; @@ -1104,8 +1099,8 @@ export function WebGLCmdFuncCreateFramebuffer (device: WebGLDevice, gpuFramebuff } } - if (device.WEBGL_draw_buffers) { - device.WEBGL_draw_buffers.drawBuffersWEBGL(attachments); + if (device.extensions.WEBGL_draw_buffers) { + device.extensions.WEBGL_draw_buffers.drawBuffersWEBGL(attachments); } const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER); @@ -1210,7 +1205,7 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL gl.linkProgram(gpuShader.glProgram); // detach & delete immediately - if (device.destroyShadersImmediately) { + if (device.extensions.destroyShadersImmediately) { for (let k = 0; k < gpuShader.gpuStages.length; k++) { const gpuStage = gpuShader.gpuStages[k]; if (gpuStage.glShader) { @@ -1333,8 +1328,8 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL if (!isSampler) { const glLoc = gl.getUniformLocation(gpuShader.glProgram, uniformInfo.name); - // Note: getUniformLocation return Object on wechat platform. - if (glLoc !== null && (typeof glLoc === 'number' || (glLoc as any).id !== -1)) { + // Note: wEcHAT just returns { id: -1 } for non-existing names /eyerolling + if (glLoc && (glLoc as any).id !== -1) { let varName: string; const nameOffset = uniformInfo.name.indexOf('['); if (nameOffset !== -1) { @@ -1394,8 +1389,8 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL for (let i = 0; i < gpuShader.samplerTextures.length; ++i) { const sampler = gpuShader.samplerTextures[i]; const glLoc = gl.getUniformLocation(gpuShader.glProgram, sampler.name); - // Note: getUniformLocation return Object on wechat platform. - if (glLoc !== null && (typeof glLoc === 'number' || (glLoc as any).id !== -1)) { + // Note: wEcHAT just returns { id: -1 } for non-existing names /eyerolling + if (glLoc && (glLoc as any).id !== -1) { glActiveSamplers.push(gpuShader.glSamplerTextures[i]); glActiveSamplerLocations.push(glLoc); } @@ -1476,7 +1471,7 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL export function WebGLCmdFuncDestroyShader (device: WebGLDevice, gpuShader: IWebGLGPUShader) { if (gpuShader.glProgram) { const { gl } = device; - if (!device.destroyShadersImmediately) { + if (!device.extensions.destroyShadersImmediately) { for (let k = 0; k < gpuShader.gpuStages.length; k++) { const gpuStage = gpuShader.gpuStages[k]; if (gpuStage.glShader) { @@ -1529,7 +1524,7 @@ export function WebGLCmdFuncDestroyInputAssembler (device: WebGLDevice, gpuInput const it = gpuInputAssembler.glVAOs.values(); let res = it.next(); while (!res.done) { - device.OES_vertex_array_object!.deleteVertexArrayOES(res.value); + device.extensions.OES_vertex_array_object!.deleteVertexArrayOES(res.value); res = it.next(); } gpuInputAssembler.glVAOs.clear(); @@ -1592,7 +1587,7 @@ export function WebGLCmdFuncBeginRenderPass ( // const invalidateAttachments: GLenum[] = []; let clearCount = clearColors.length; - if (!device.WEBGL_draw_buffers) { + if (!device.extensions.WEBGL_draw_buffers) { clearCount = 1; } @@ -2182,7 +2177,7 @@ export function WebGLCmdFuncBindStates ( if (gpuTexture.glTexture) { gl.bindTexture(gpuTexture.glTarget, gpuTexture.glTexture); } else { - gl.bindTexture(gpuTexture.glTarget, device.nullTex2D!.gpuTexture.glTexture); + gl.bindTexture(gpuTexture.glTarget, device.nullTex2D.gpuTexture.glTexture); } glTexUnit.glTexture = gpuTexture.glTexture; } @@ -2258,10 +2253,10 @@ export function WebGLCmdFuncBindStates ( if (gpuInputAssembler && gpuShader && (isShaderChanged || gfxStateCache.gpuInputAssembler !== gpuInputAssembler)) { gfxStateCache.gpuInputAssembler = gpuInputAssembler; - const ia = device.ANGLE_instanced_arrays; + const ia = device.extensions.ANGLE_instanced_arrays; - if (device.useVAO) { - const vao = device.OES_vertex_array_object!; + if (device.extensions.useVAO) { + const vao = device.extensions.OES_vertex_array_object!; // check vao let glVAO = gpuInputAssembler.glVAOs.get(gpuShader.glProgram!); @@ -2482,56 +2477,83 @@ export function WebGLCmdFuncBindStates ( } // update dynamic states } -export function WebGLCmdFuncDraw (device: WebGLDevice, drawInfo: DrawInfo) { +export function WebGLCmdFuncDraw (device: WebGLDevice, drawInfo: Readonly) { const { gl } = device; - const ia = device.ANGLE_instanced_arrays; + const { ANGLE_instanced_arrays: ia, WEBGL_multi_draw: md } = device.extensions; const { gpuInputAssembler, glPrimitive } = gfxStateCache; if (gpuInputAssembler) { + const indexBuffer = gpuInputAssembler.gpuIndexBuffer; if (gpuInputAssembler.gpuIndirectBuffer) { - const diLen = gpuInputAssembler.gpuIndirectBuffer.indirects.length; - for (let j = 0; j < diLen; j++) { - const subDrawInfo = gpuInputAssembler.gpuIndirectBuffer.indirects[j]; - const gpuBuffer = gpuInputAssembler.gpuIndexBuffer; - if (subDrawInfo.instanceCount && ia) { - if (gpuBuffer) { - if (subDrawInfo.indexCount > 0) { - const offset = subDrawInfo.firstIndex * gpuBuffer.stride; - ia.drawElementsInstancedANGLE(glPrimitive, subDrawInfo.indexCount, - gpuInputAssembler.glIndexType, offset, subDrawInfo.instanceCount); + const indirects = gpuInputAssembler.gpuIndirectBuffer.indirects; + if (indirects.drawByIndex) { + for (let j = 0; j < indirects.drawCount; j++) { + indirects.byteOffsets[j] = indirects.offsets[j] * indexBuffer!.stride; + } + if (md) { + if (indirects.instancedDraw) { + md.multiDrawElementsInstancedWEBGL(glPrimitive, + indirects.counts, 0, + gpuInputAssembler.glIndexType, + indirects.byteOffsets, 0, + indirects.instances, 0, + indirects.drawCount); + } else { + md.multiDrawElementsWEBGL(glPrimitive, + indirects.counts, 0, + gpuInputAssembler.glIndexType, + indirects.byteOffsets, 0, + indirects.drawCount); + } + } else { + for (let j = 0; j < indirects.drawCount; j++) { + if (indirects.instances[j] > 1 && ia) { + ia.drawElementsInstancedANGLE(glPrimitive, indirects.counts[j], + gpuInputAssembler.glIndexType, indirects.byteOffsets[j], indirects.instances[j]); + } else { + gl.drawElements(glPrimitive, indirects.counts[j], gpuInputAssembler.glIndexType, indirects.byteOffsets[j]); } - } else if (subDrawInfo.vertexCount > 0) { - ia.drawArraysInstancedANGLE(glPrimitive, subDrawInfo.firstVertex, subDrawInfo.vertexCount, subDrawInfo.instanceCount); } - } else if (gpuBuffer) { - if (subDrawInfo.indexCount > 0) { - const offset = subDrawInfo.firstIndex * gpuBuffer.stride; - gl.drawElements(glPrimitive, subDrawInfo.indexCount, gpuInputAssembler.glIndexType, offset); + } + } else if (md) { + if (indirects.instancedDraw) { + md.multiDrawArraysInstancedWEBGL(glPrimitive, + indirects.offsets, 0, + indirects.counts, 0, + indirects.instances, 0, + indirects.drawCount); + } else { + md.multiDrawArraysWEBGL(glPrimitive, + indirects.offsets, 0, + indirects.counts, 0, + indirects.drawCount); + } + } else { + for (let j = 0; j < indirects.drawCount; j++) { + if (indirects.instances[j] > 1 && ia) { + ia.drawArraysInstancedANGLE(glPrimitive, indirects.offsets[j], indirects.counts[j], indirects.instances[j]); + } else { + gl.drawArrays(glPrimitive, indirects.offsets[j], indirects.counts[j]); } - } else if (subDrawInfo.vertexCount > 0) { - gl.drawArrays(glPrimitive, subDrawInfo.firstVertex, subDrawInfo.vertexCount); } } - } else { - const gpuBuffer = gpuInputAssembler.gpuIndexBuffer; - if (drawInfo.instanceCount && ia) { - if (gpuBuffer) { - if (drawInfo.indexCount > 0) { - const offset = drawInfo.firstIndex * gpuBuffer.stride; - ia.drawElementsInstancedANGLE(glPrimitive, drawInfo.indexCount, - gpuInputAssembler.glIndexType, offset, drawInfo.instanceCount); - } - } else if (drawInfo.vertexCount > 0) { - ia.drawArraysInstancedANGLE(glPrimitive, drawInfo.firstVertex, drawInfo.vertexCount, drawInfo.instanceCount); - } - } else if (gpuBuffer) { + } else if (drawInfo.instanceCount > 1 && ia) { + if (indexBuffer) { if (drawInfo.indexCount > 0) { - const offset = drawInfo.firstIndex * gpuBuffer.stride; - gl.drawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler.glIndexType, offset); + const offset = drawInfo.firstIndex * indexBuffer.stride; + ia.drawElementsInstancedANGLE(glPrimitive, drawInfo.indexCount, + gpuInputAssembler.glIndexType, offset, drawInfo.instanceCount); } } else if (drawInfo.vertexCount > 0) { - gl.drawArrays(glPrimitive, drawInfo.firstVertex, drawInfo.vertexCount); + ia.drawArraysInstancedANGLE(glPrimitive, drawInfo.firstVertex, drawInfo.vertexCount, drawInfo.instanceCount); } + } else if (indexBuffer) { + if (drawInfo.indexCount > 0) { + const offset = drawInfo.firstIndex * indexBuffer.stride; + gl.drawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler.glIndexType, offset); + } + } else if (drawInfo.vertexCount > 0) { + gl.drawArrays(glPrimitive, drawInfo.firstVertex, drawInfo.vertexCount); } } } @@ -2668,7 +2690,7 @@ export function WebGLCmdFuncCopyBuffersToTexture ( gl.texSubImage2D(gl.TEXTURE_2D, region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, w, h, gpuTexture.glFormat, gpuTexture.glType, pixels); - } else if (gpuTexture.glInternalFmt === WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL || device.noCompressedTexSubImage2D) { + } else if (gpuTexture.glInternalFmt === WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL || device.extensions.noCompressedTexSubImage2D) { gl.compressedTexImage2D(gl.TEXTURE_2D, region.texSubres.mipLevel, gpuTexture.glInternalFmt, w, h, 0, pixels); } else { @@ -2694,7 +2716,7 @@ export function WebGLCmdFuncCopyBuffersToTexture ( gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, w, h, gpuTexture.glFormat, gpuTexture.glType, pixels); - } else if (gpuTexture.glInternalFmt === WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL || device.noCompressedTexSubImage2D) { + } else if (gpuTexture.glInternalFmt === WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL || device.extensions.noCompressedTexSubImage2D) { gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, region.texSubres.mipLevel, gpuTexture.glInternalFmt, w, h, 0, pixels); } else { diff --git a/cocos/core/gfx/webgl/webgl-define.ts b/cocos/core/gfx/webgl/webgl-define.ts index 028df42829..ac963365c1 100644 --- a/cocos/core/gfx/webgl/webgl-define.ts +++ b/cocos/core/gfx/webgl/webgl-define.ts @@ -23,6 +23,8 @@ THE SOFTWARE. */ +import { WebGLDevice } from './webgl-device'; + // Extensions export enum WebGLEXT { RGBA16F_EXT = 0x881A, @@ -95,3 +97,47 @@ export enum WebGLEXT { COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC, COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD, } + +export interface IWebGLExtensions { + EXT_texture_filter_anisotropic: EXT_texture_filter_anisotropic | null; + EXT_blend_minmax: EXT_blend_minmax | null; + EXT_frag_depth: EXT_frag_depth | null; + EXT_shader_texture_lod: EXT_shader_texture_lod | null; + EXT_sRGB: EXT_sRGB | null; + OES_vertex_array_object: OES_vertex_array_object | null; + EXT_color_buffer_half_float: EXT_color_buffer_half_float | null; + WEBGL_multi_draw: WEBGL_multi_draw | null; + WEBGL_color_buffer_float: WEBGL_color_buffer_float | null; + WEBGL_compressed_texture_etc1: WEBGL_compressed_texture_etc1 | null; + WEBGL_compressed_texture_etc: WEBGL_compressed_texture_etc | null; + WEBGL_compressed_texture_pvrtc: WEBGL_compressed_texture_pvrtc | null; + WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null; + WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null; + WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null; + WEBGL_debug_shaders: WEBGL_debug_shaders | null; + WEBGL_draw_buffers: WEBGL_draw_buffers | null; + WEBGL_lose_context: WEBGL_lose_context | null; + WEBGL_depth_texture: WEBGL_depth_texture | null; + WEBGL_debug_renderer_info: WEBGL_debug_renderer_info | null; + OES_texture_half_float: OES_texture_half_float | null; + OES_texture_half_float_linear: OES_texture_half_float_linear | null; + OES_texture_float: OES_texture_float | null; + OES_texture_float_linear: OES_texture_float_linear | null; + OES_standard_derivatives: OES_standard_derivatives | null; + OES_element_index_uint: OES_element_index_uint | null; + ANGLE_instanced_arrays: ANGLE_instanced_arrays | null; + destroyShadersImmediately: boolean; + noCompressedTexSubImage2D: boolean; + useVAO: boolean; +} + +// put the global instance here so that we won't have circular dependencies +export class WebGLDeviceManager { + static get instance () { + return WebGLDeviceManager._instance!; + } + static setInstance (instance: WebGLDevice) { + WebGLDeviceManager._instance = instance; + } + private static _instance: WebGLDevice | null = null; +} diff --git a/cocos/core/gfx/webgl/webgl-descriptor-set-layout.ts b/cocos/core/gfx/webgl/webgl-descriptor-set-layout.ts index 255c851590..16ac8d0c8c 100644 --- a/cocos/core/gfx/webgl/webgl-descriptor-set-layout.ts +++ b/cocos/core/gfx/webgl/webgl-descriptor-set-layout.ts @@ -68,8 +68,6 @@ export class WebGLDescriptorSetLayout extends DescriptorSetLayout { descriptorIndices, descriptorCount, }; - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl/webgl-descriptor-set.ts b/cocos/core/gfx/webgl/webgl-descriptor-set.ts index f27335a422..c8f8d1e46d 100644 --- a/cocos/core/gfx/webgl/webgl-descriptor-set.ts +++ b/cocos/core/gfx/webgl/webgl-descriptor-set.ts @@ -26,7 +26,7 @@ import { DescriptorSet } from '../base/descriptor-set'; import { WebGLBuffer } from './webgl-buffer'; import { IWebGLGPUDescriptorSet, IWebGLGPUDescriptor } from './webgl-gpu-objects'; -import { WebGLSampler } from './webgl-sampler'; +import { WebGLSampler } from './states/webgl-sampler'; import { WebGLTexture } from './webgl-texture'; import { WebGLDescriptorSetLayout } from './webgl-descriptor-set-layout'; import { DescriptorSetInfo, DESCRIPTOR_SAMPLER_TYPE, DESCRIPTOR_BUFFER_TYPE } from '../base/define'; @@ -38,7 +38,7 @@ export class WebGLDescriptorSet extends DescriptorSet { private _gpuDescriptorSet: IWebGLGPUDescriptorSet | null = null; - public initialize (info: DescriptorSetInfo): boolean { + public initialize (info: DescriptorSetInfo) { this._layout = info.layout; const { bindings, descriptorIndices, descriptorCount } = (info.layout as WebGLDescriptorSetLayout).gpuDescriptorSetLayout; @@ -60,8 +60,6 @@ export class WebGLDescriptorSet extends DescriptorSet { }); } } - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl/webgl-device.ts b/cocos/core/gfx/webgl/webgl-device.ts index cd287cfec6..1f6c937870 100644 --- a/cocos/core/gfx/webgl/webgl-device.ts +++ b/cocos/core/gfx/webgl/webgl-device.ts @@ -23,9 +23,6 @@ THE SOFTWARE. */ -import { ALIPAY, RUNTIME_BASED, BYTEDANCE, WECHAT, LINKSURE, QTT, COCOSPLAY, HUAWEI } from 'internal:constants'; -import { macro, warnID, warn } from '../../platform'; -import { sys } from '../../platform/sys'; import { DescriptorSet } from '../base/descriptor-set'; import { DescriptorSetLayout } from '../base/descriptor-set-layout'; import { PipelineLayout } from '../base/pipeline-layout'; @@ -37,12 +34,11 @@ import { InputAssembler } from '../base/input-assembler'; import { PipelineState, PipelineStateInfo } from '../base/pipeline-state'; import { Queue } from '../base/queue'; import { RenderPass } from '../base/render-pass'; -import { Sampler } from '../base/sampler'; +import { Sampler } from '../base/states/sampler'; import { Shader } from '../base/shader'; import { Texture } from '../base/texture'; import { WebGLDescriptorSet } from './webgl-descriptor-set'; import { WebGLBuffer } from './webgl-buffer'; -import { WebGLCommandAllocator } from './webgl-command-allocator'; import { WebGLCommandBuffer } from './webgl-command-buffer'; import { WebGLFramebuffer } from './webgl-framebuffer'; import { WebGLInputAssembler } from './webgl-input-assembler'; @@ -52,251 +48,71 @@ import { WebGLPipelineState } from './webgl-pipeline-state'; import { WebGLPrimaryCommandBuffer } from './webgl-primary-command-buffer'; import { WebGLQueue } from './webgl-queue'; import { WebGLRenderPass } from './webgl-render-pass'; -import { WebGLSampler } from './webgl-sampler'; +import { WebGLSampler } from './states/webgl-sampler'; import { WebGLShader } from './webgl-shader'; -import { WebGLStateCache } from './webgl-state-cache'; +import { getExtensions, WebGLSwapchain } from './webgl-swapchain'; import { WebGLTexture } from './webgl-texture'; import { - getTypedArrayConstructor, CommandBufferType, Filter, Format, FormatInfos, BindingMappingInfo, ShaderInfo, + CommandBufferType, ShaderInfo, QueueInfo, CommandBufferInfo, DescriptorSetInfo, DescriptorSetLayoutInfo, FramebufferInfo, InputAssemblerInfo, PipelineLayoutInfo, RenderPassInfo, SamplerInfo, TextureInfo, TextureViewInfo, BufferInfo, BufferViewInfo, DeviceInfo, TextureBarrierInfo, GlobalBarrierInfo, - QueueType, TextureFlagBit, TextureType, TextureUsageBit, API, Feature, BufferTextureCopy, Rect, + QueueType, API, Feature, BufferTextureCopy, SwapchainInfo, } from '../base/define'; -import { - GFXFormatToWebGLFormat, GFXFormatToWebGLType, WebGLCmdFuncCopyBuffersToTexture, WebGLCmdFuncCopyTextureToBuffers, - WebGLCmdFuncCopyTexImagesToTexture, -} from './webgl-commands'; -import { GlobalBarrier } from '../base/global-barrier'; -import { TextureBarrier } from '../base/texture-barrier'; -import { BrowserType, OS } from '../../../../pal/system-info/enum-type'; +import { WebGLCmdFuncCopyBuffersToTexture, WebGLCmdFuncCopyTextureToBuffers, WebGLCmdFuncCopyTexImagesToTexture } from './webgl-commands'; +import { GlobalBarrier } from '../base/states/global-barrier'; +import { TextureBarrier } from '../base/states/texture-barrier'; import { debug } from '../../platform/debug'; - -const eventWebGLContextLost = 'webglcontextlost'; +import { Swapchain } from '../base/swapchain'; +import { WebGLDeviceManager } from './webgl-define'; export class WebGLDevice extends Device { get gl () { - return this._webGLRC as WebGLRenderingContext; + return this._swapchain!.gl; } - get webGLQueue () { - return this._queue as WebGLQueue; + get extensions () { + return this._swapchain!.extensions; } - get isAntialias () { - return this._isAntialias; + get stateCache () { + return this._swapchain!.stateCache; } - get isPremultipliedAlpha () { - return this._isPremultipliedAlpha; + get nullTex2D () { + return this._swapchain!.nullTex2D; } - get useVAO () { - return this._useVAO; + get nullTexCube () { + return this._swapchain!.nullTexCube; } - get destroyShadersImmediately () { - return this._destroyShadersImmediately; - } - - get noCompressedTexSubImage2D () { - return this._noCompressedTexSubImage2D; - } - - get bindingMappingInfo () { - return this._bindingMappingInfo; - } - - get EXT_texture_filter_anisotropic () { - return this._EXT_texture_filter_anisotropic; - } - - get EXT_blend_minmax () { - return this._EXT_blend_minmax; - } - - get EXT_frag_depth () { - return this._EXT_frag_depth; - } - - get EXT_shader_texture_lod () { - return this._EXT_shader_texture_lod; - } - - get EXT_sRGB () { - return this._EXT_sRGB; - } - - get OES_vertex_array_object () { - return this._OES_vertex_array_object; - } - - get WEBGL_color_buffer_float () { - return this._WEBGL_color_buffer_float; - } - - get WEBGL_compressed_texture_etc1 () { - return this._WEBGL_compressed_texture_etc1; - } - - get WEBGL_compressed_texture_pvrtc () { - return this._WEBGL_compressed_texture_pvrtc; - } - - get WEBGL_compressed_texture_astc () { - return this._WEBGL_compressed_texture_astc; - } - - get WEBGL_compressed_texture_s3tc () { - return this._WEBGL_compressed_texture_s3tc; - } - - get WEBGL_compressed_texture_s3tc_srgb () { - return this._WEBGL_compressed_texture_s3tc_srgb; - } - - get WEBGL_debug_shaders () { - return this._WEBGL_debug_shaders; - } - - get WEBGL_draw_buffers () { - return this._WEBGL_draw_buffers; - } - - get WEBGL_lose_context () { - return this._WEBGL_lose_context; - } - - get WEBGL_depth_texture () { - return this._WEBGL_depth_texture; - } - - get WEBGL_debug_renderer_info () { - return this._WEBGL_debug_renderer_info; - } - - get OES_texture_half_float () { - return this._OES_texture_half_float; - } - - get OES_texture_half_float_linear () { - return this._OES_texture_half_float_linear; - } - - get OES_texture_float () { - return this._OES_texture_float; - } - - get OES_standard_derivatives () { - return this._OES_standard_derivatives; - } - - get OES_element_index_uint () { - return this._OES_element_index_uint; - } - - get ANGLE_instanced_arrays () { - return this._ANGLE_instanced_arrays; - } - - public stateCache: WebGLStateCache = new WebGLStateCache(); - public cmdAllocator: WebGLCommandAllocator = new WebGLCommandAllocator(); - public nullTex2D: WebGLTexture | null = null; - public nullTexCube: WebGLTexture | null = null; - - private _webGLRC: WebGLRenderingContext | null = null; - private _isAntialias = true; - private _isPremultipliedAlpha = true; - private _useVAO = false; - private _destroyShadersImmediately = true; - private _noCompressedTexSubImage2D = false; - private _bindingMappingInfo: BindingMappingInfo = new BindingMappingInfo(); - private _webGLContextLostHandler: null | ((event: Event) => void) = null; - - private _extensions: string[] | null = null; - private _EXT_texture_filter_anisotropic: EXT_texture_filter_anisotropic | null = null; - private _EXT_blend_minmax: EXT_blend_minmax | null = null; - private _EXT_frag_depth: EXT_frag_depth | null = null; - private _EXT_shader_texture_lod: EXT_shader_texture_lod | null = null; - private _EXT_sRGB: EXT_sRGB | null = null; - private _OES_vertex_array_object: OES_vertex_array_object | null = null; - private _EXT_color_buffer_half_float: EXT_color_buffer_half_float | null = null; - private _WEBGL_color_buffer_float: WEBGL_color_buffer_float | null = null; - private _WEBGL_compressed_texture_etc1: WEBGL_compressed_texture_etc1 | null = null; - private _WEBGL_compressed_texture_etc: WEBGL_compressed_texture_etc | null = null; - private _WEBGL_compressed_texture_pvrtc: WEBGL_compressed_texture_pvrtc | null = null; - private _WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null = null; - private _WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null = null; - private _WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null = null; - private _WEBGL_debug_shaders: WEBGL_debug_shaders | null = null; - private _WEBGL_draw_buffers: WEBGL_draw_buffers | null = null; - private _WEBGL_lose_context: WEBGL_lose_context | null = null; - private _WEBGL_depth_texture: WEBGL_depth_texture | null = null; - private _WEBGL_debug_renderer_info: WEBGL_debug_renderer_info | null = null; - private _OES_texture_half_float: OES_texture_half_float | null = null; - private _OES_texture_half_float_linear: OES_texture_half_float_linear | null = null; - private _OES_texture_float: OES_texture_float | null = null; - private _OES_texture_float_linear: OES_texture_float_linear | null = null; - private _OES_standard_derivatives: OES_standard_derivatives | null = null; - private _OES_element_index_uint: OES_element_index_uint | null = null; - private _ANGLE_instanced_arrays: ANGLE_instanced_arrays | null = null; + private _swapchain: WebGLSwapchain | null = null; public initialize (info: DeviceInfo): boolean { - this._canvas = info.canvasElm as HTMLCanvasElement; - this._isAntialias = info.isAntialias; - this._isPremultipliedAlpha = info.isPremultipliedAlpha; + WebGLDeviceManager.setInstance(this); + this._gfxAPI = API.WEBGL; + this._bindingMappingInfo = info.bindingMappingInfo; if (!this._bindingMappingInfo.bufferOffsets.length) this._bindingMappingInfo.bufferOffsets.push(0); if (!this._bindingMappingInfo.samplerOffsets.length) this._bindingMappingInfo.samplerOffsets.push(0); + let gl: WebGLRenderingContext | null = null; + try { - const webGLCtxAttribs: WebGLContextAttributes = { - alpha: macro.ENABLE_TRANSPARENT_CANVAS, - antialias: this._isAntialias, - depth: true, - stencil: true, - premultipliedAlpha: this._isPremultipliedAlpha, - preserveDrawingBuffer: false, - powerPreference: 'default', - failIfMajorPerformanceCaveat: false, - }; - - /* - if (WECHAT) { - webGLCtxAttribs.preserveDrawingBuffer = true; - } - */ - - this._webGLRC = this._canvas.getContext('webgl', webGLCtxAttribs); + gl = document.createElement('canvas').getContext('webgl'); } catch (err) { console.error(err); - return false; } - if (!this._webGLRC) { + if (!gl) { console.error('This device does not support WebGL.'); return false; } - this._webGLContextLostHandler = this._onWebGLContextLost.bind(this); - this._canvas.addEventListener(eventWebGLContextLost, this._onWebGLContextLost); + // create queue + this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); - this._canvas2D = document.createElement('canvas'); - console.info('WebGL device initialized.'); - - this._gfxAPI = API.WEBGL; - this._deviceName = 'WebGL'; - const gl = this._webGLRC; - - this._WEBGL_debug_renderer_info = this.getExtension('WEBGL_debug_renderer_info'); - if (this._WEBGL_debug_renderer_info) { - this._renderer = gl.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); - this._vendor = gl.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL); - } else { - this._renderer = gl.getParameter(gl.RENDERER); - this._vendor = gl.getParameter(gl.VENDOR); - } - - this._version = gl.getParameter(gl.VERSION); this._caps.maxVertexAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); this._caps.maxVertexUniformVectors = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS); this._caps.maxFragmentUniformVectors = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS); @@ -304,264 +120,113 @@ export class WebGLDevice extends Device { this._caps.maxVertexTextureUnits = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS); this._caps.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); this._caps.maxCubeMapTextureSize = gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE); - this._caps.depthBits = gl.getParameter(gl.DEPTH_BITS); - this._caps.stencilBits = gl.getParameter(gl.STENCIL_BITS); - this.stateCache.initialize(this._caps.maxTextureUnits, this._caps.maxVertexAttributes); - - if (ALIPAY) { - this._caps.depthBits = 24; + const extensions = gl.getSupportedExtensions(); + let extStr = ''; + if (extensions) { + for (const ext of extensions) { + extStr += `${ext} `; + } } - this._devicePixelRatio = info.devicePixelRatio || 1.0; - this._width = info.width; - this._height = info.height; + const exts = getExtensions(gl); - this._colorFmt = Format.RGBA8; - - if (this._caps.depthBits === 24) { - if (this._caps.stencilBits === 8) { - this._depthStencilFmt = Format.D24S8; - } else { - this._depthStencilFmt = Format.D24; - } - } else if (this._caps.stencilBits === 8) { - this._depthStencilFmt = Format.D16S8; + if (exts.WEBGL_debug_renderer_info) { + this._renderer = gl.getParameter(exts.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); + this._vendor = gl.getParameter(exts.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL); } else { - this._depthStencilFmt = Format.D16; + this._renderer = gl.getParameter(gl.RENDERER); + this._vendor = gl.getParameter(gl.VENDOR); } - this._extensions = gl.getSupportedExtensions(); - let extensions = ''; - if (this._extensions) { - for (const ext of this._extensions) { - extensions += `${ext} `; - } - - debug(`EXTENSIONS: ${extensions}`); - } - - this._EXT_texture_filter_anisotropic = this.getExtension('EXT_texture_filter_anisotropic'); - this._EXT_blend_minmax = this.getExtension('EXT_blend_minmax'); - this._EXT_frag_depth = this.getExtension('EXT_frag_depth'); - this._EXT_shader_texture_lod = this.getExtension('EXT_shader_texture_lod'); - this._EXT_sRGB = this.getExtension('EXT_sRGB'); - this._OES_vertex_array_object = this.getExtension('OES_vertex_array_object'); - this._EXT_color_buffer_half_float = this.getExtension('EXT_color_buffer_half_float'); - this._WEBGL_color_buffer_float = this.getExtension('WEBGL_color_buffer_float'); - this._WEBGL_compressed_texture_etc1 = this.getExtension('WEBGL_compressed_texture_etc1'); - this._WEBGL_compressed_texture_etc = this.getExtension('WEBGL_compressed_texture_etc'); - this._WEBGL_compressed_texture_pvrtc = this.getExtension('WEBGL_compressed_texture_pvrtc'); - this._WEBGL_compressed_texture_s3tc = this.getExtension('WEBGL_compressed_texture_s3tc'); - this._WEBGL_compressed_texture_s3tc_srgb = this.getExtension('WEBGL_compressed_texture_s3tc_srgb'); - this._WEBGL_debug_shaders = this.getExtension('WEBGL_debug_shaders'); - this._WEBGL_draw_buffers = this.getExtension('WEBGL_draw_buffers'); - this._WEBGL_lose_context = this.getExtension('WEBGL_lose_context'); - this._WEBGL_depth_texture = this.getExtension('WEBGL_depth_texture'); - this._OES_texture_half_float = this.getExtension('OES_texture_half_float'); - this._OES_texture_half_float_linear = this.getExtension('OES_texture_half_float_linear'); - this._OES_texture_float = this.getExtension('OES_texture_float'); - this._OES_texture_float_linear = this.getExtension('OES_texture_float_linear'); - this._OES_standard_derivatives = this.getExtension('OES_standard_derivatives'); - this._OES_element_index_uint = this.getExtension('OES_element_index_uint'); - this._ANGLE_instanced_arrays = this.getExtension('ANGLE_instanced_arrays'); - - // platform-specific hacks - // eslint-disable-next-line no-lone-blocks - { - // iOS 14 browsers crash on getExtension('WEBGL_compressed_texture_astc') - if (sys.os !== OS.IOS || sys.osMainVersion !== 14 || !sys.isBrowser) { - this._WEBGL_compressed_texture_astc = this.getExtension('WEBGL_compressed_texture_astc'); - } - - // UC browser instancing implementation doesn't work - if (sys.browserType === BrowserType.UC) { - this._ANGLE_instanced_arrays = null; - } - - // bytedance ios depth texture implementation doesn't work - if (BYTEDANCE && sys.os === OS.IOS) { - this._WEBGL_depth_texture = null; - } - - if (RUNTIME_BASED) { - // VAO implementations doesn't work well on some runtime platforms - if (LINKSURE || QTT || COCOSPLAY || HUAWEI) { - this._OES_vertex_array_object = null; - } - } - - // some earlier version of iOS and android wechat implement gl.detachShader incorrectly - if ((sys.os === OS.IOS && sys.osMainVersion <= 10) - || (WECHAT && sys.os === OS.ANDROID)) { - this._destroyShadersImmediately = false; - } - - // compressedTexSubImage2D has always been problematic because the parameters differs slightly from GLES - if (WECHAT) { // and MANY platforms get it wrong - this._noCompressedTexSubImage2D = true; - } - } + const version: string = gl.getParameter(gl.VERSION); this._features.fill(false); - if (this._EXT_sRGB) { + if (exts.EXT_sRGB) { this._features[Feature.FORMAT_SRGB] = true; } - if (this._EXT_blend_minmax) { + if (exts.EXT_blend_minmax) { this._features[Feature.BLEND_MINMAX] = true; } - if (this._WEBGL_color_buffer_float) { + if (exts.WEBGL_color_buffer_float) { this._features[Feature.COLOR_FLOAT] = true; } - if (this._EXT_color_buffer_half_float) { + if (exts.EXT_color_buffer_half_float) { this._features[Feature.COLOR_HALF_FLOAT] = true; } - if (this._OES_texture_float) { + if (exts.OES_texture_float) { this._features[Feature.TEXTURE_FLOAT] = true; } - if (this._OES_texture_half_float) { + if (exts.OES_texture_half_float) { this._features[Feature.TEXTURE_HALF_FLOAT] = true; } - if (this._OES_texture_float_linear) { + if (exts.OES_texture_float_linear) { this._features[Feature.TEXTURE_FLOAT_LINEAR] = true; } - if (this._OES_texture_half_float_linear) { + if (exts.OES_texture_half_float_linear) { this._features[Feature.TEXTURE_HALF_FLOAT_LINEAR] = true; } this._features[Feature.FORMAT_RGB8] = true; - if (this._OES_element_index_uint) { + if (exts.OES_element_index_uint) { this._features[Feature.ELEMENT_INDEX_UINT] = true; } - if (this._ANGLE_instanced_arrays) { + if (exts.ANGLE_instanced_arrays) { this._features[Feature.INSTANCED_ARRAYS] = true; } - if (this._WEBGL_draw_buffers) { + if (exts.WEBGL_draw_buffers) { this._features[Feature.MULTIPLE_RENDER_TARGETS] = true; } let compressedFormat = ''; - if (this._WEBGL_compressed_texture_etc1) { + if (exts.WEBGL_compressed_texture_etc1) { this._features[Feature.FORMAT_ETC1] = true; compressedFormat += 'etc1 '; } - if (this._WEBGL_compressed_texture_etc) { + if (exts.WEBGL_compressed_texture_etc) { this._features[Feature.FORMAT_ETC2] = true; compressedFormat += 'etc2 '; } - if (this._WEBGL_compressed_texture_s3tc) { + if (exts.WEBGL_compressed_texture_s3tc) { this._features[Feature.FORMAT_DXT] = true; compressedFormat += 'dxt '; } - if (this._WEBGL_compressed_texture_pvrtc) { + if (exts.WEBGL_compressed_texture_pvrtc) { this._features[Feature.FORMAT_PVRTC] = true; compressedFormat += 'pvrtc '; } - if (this._WEBGL_compressed_texture_astc) { + if (exts.WEBGL_compressed_texture_astc) { this._features[Feature.FORMAT_ASTC] = true; compressedFormat += 'astc '; } - if (this._OES_vertex_array_object) { - this._useVAO = true; - } - + debug('WebGL device initialized.'); debug(`RENDERER: ${this._renderer}`); debug(`VENDOR: ${this._vendor}`); - debug(`VERSION: ${this._version}`); - debug(`DPR: ${this._devicePixelRatio}`); - debug(`SCREEN_SIZE: ${this._width} x ${this._height}`); - // debug('COLOR_FORMAT: ' + FormatInfos[this._colorFmt].name); - // debug('DEPTH_STENCIL_FORMAT: ' + FormatInfos[this._depthStencilFmt].name); - // debug('MAX_VERTEX_ATTRIBS: ' + this._maxVertexAttributes); - debug(`MAX_VERTEX_UNIFORM_VECTORS: ${this._caps.maxVertexUniformVectors}`); - // debug('MAX_FRAGMENT_UNIFORM_VECTORS: ' + this._maxFragmentUniformVectors); - // debug('MAX_TEXTURE_IMAGE_UNITS: ' + this._maxTextureUnits); - // debug('MAX_VERTEX_TEXTURE_IMAGE_UNITS: ' + this._maxVertexTextureUnits); - debug(`DEPTH_BITS: ${this._caps.depthBits}`); - debug(`STENCIL_BITS: ${this._caps.stencilBits}`); - if (this._EXT_texture_filter_anisotropic) { - debug(`MAX_TEXTURE_MAX_ANISOTROPY_EXT: ${this._EXT_texture_filter_anisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT}`); - } - debug(`USE_VAO: ${this._useVAO}`); + debug(`VERSION: ${version}`); debug(`COMPRESSED_FORMAT: ${compressedFormat}`); - - // init states - this.initStates(gl); - - // create queue - this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); - this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); - - // create default null texture - this.nullTex2D = this.createTexture(new TextureInfo( - TextureType.TEX2D, - TextureUsageBit.SAMPLED, - Format.RGBA8, - 2, - 2, - TextureFlagBit.GEN_MIPMAP, - )) as WebGLTexture; - - this.nullTexCube = this.createTexture(new TextureInfo( - TextureType.CUBE, - TextureUsageBit.SAMPLED, - Format.RGBA8, - 2, - 2, - TextureFlagBit.GEN_MIPMAP, - 6, - )) as WebGLTexture; - - const nullTexRegion = new BufferTextureCopy(); - nullTexRegion.texExtent.width = 2; - nullTexRegion.texExtent.height = 2; - - const nullTexBuff = new Uint8Array(this.nullTex2D.size); - nullTexBuff.fill(0); - this.copyBuffersToTexture([nullTexBuff], this.nullTex2D, [nullTexRegion]); - - nullTexRegion.texSubres.layerCount = 6; - this.copyBuffersToTexture( - [nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff], - this.nullTexCube, [nullTexRegion], - ); + debug(`EXTENSIONS: ${extStr}`); return true; } public destroy (): void { - if (this._canvas && this._webGLContextLostHandler) { - this._canvas.removeEventListener(eventWebGLContextLost, this._webGLContextLostHandler); - this._webGLContextLostHandler = null; - } - - if (this.nullTex2D) { - this.nullTex2D.destroy(); - this.nullTex2D = null; - } - - if (this.nullTexCube) { - this.nullTexCube.destroy(); - this.nullTexCube = null; - } - if (this._queue) { this._queue.destroy(); this._queue = null; @@ -571,27 +236,11 @@ export class WebGLDevice extends Device { this._cmdBuff.destroy(); this._cmdBuff = null; } - - this._extensions = null; - - this._webGLRC = null; - } - - public resize (width: number, height: number) { - if (this._width !== width || this._height !== height) { - debug(`Resizing device: ${width}x${height}`); - this._canvas!.width = width; - this._canvas!.height = height; - this._width = width; - this._height = height; - } } public flushCommands (cmdBuffs: CommandBuffer[]) {} - public acquire () { - this.cmdAllocator.releaseCmds(); - } + public acquire (swapchains: Swapchain[]) {} public present () { const queue = (this._queue as WebGLQueue); @@ -604,123 +253,106 @@ export class WebGLDevice extends Device { public createCommandBuffer (info: CommandBufferInfo): CommandBuffer { // const Ctor = WebGLCommandBuffer; // opt to instant invocation const Ctor = info.type === CommandBufferType.PRIMARY ? WebGLPrimaryCommandBuffer : WebGLCommandBuffer; - const cmdBuff = new Ctor(this); - if (cmdBuff.initialize(info)) { - return cmdBuff; - } - return null!; + const cmdBuff = new Ctor(); + cmdBuff.initialize(info); + return cmdBuff; + } + + public createSwapchain (info: SwapchainInfo): Swapchain { + const swapchain = new WebGLSwapchain(); + this._swapchain = swapchain; + swapchain.initialize(info); + return swapchain; } public createBuffer (info: BufferInfo | BufferViewInfo): Buffer { - const buffer = new WebGLBuffer(this); - if (buffer.initialize(info)) { - return buffer; - } - return null!; + const buffer = new WebGLBuffer(); + buffer.initialize(info); + return buffer; } public createTexture (info: TextureInfo | TextureViewInfo): Texture { - const texture = new WebGLTexture(this); - if (texture.initialize(info)) { - return texture; - } - return null!; - } - - public createSampler (info: SamplerInfo): Sampler { - const sampler = new WebGLSampler(this); - if (sampler.initialize(info)) { - return sampler; - } - return null!; + const texture = new WebGLTexture(); + texture.initialize(info); + return texture; } public createDescriptorSet (info: DescriptorSetInfo): DescriptorSet { - const descriptorSet = new WebGLDescriptorSet(this); - if (descriptorSet.initialize(info)) { - return descriptorSet; - } - return null!; + const descriptorSet = new WebGLDescriptorSet(); + descriptorSet.initialize(info); + return descriptorSet; } public createShader (info: ShaderInfo): Shader { - const shader = new WebGLShader(this); - if (shader.initialize(info)) { - return shader; - } - return null!; + const shader = new WebGLShader(); + shader.initialize(info); + return shader; } public createInputAssembler (info: InputAssemblerInfo): InputAssembler { - const inputAssembler = new WebGLInputAssembler(this); - if (inputAssembler.initialize(info)) { - return inputAssembler; - } - return null!; + const inputAssembler = new WebGLInputAssembler(); + inputAssembler.initialize(info); + return inputAssembler; } public createRenderPass (info: RenderPassInfo): RenderPass { - const renderPass = new WebGLRenderPass(this); - if (renderPass.initialize(info)) { - return renderPass; - } - return null!; + const renderPass = new WebGLRenderPass(); + renderPass.initialize(info); + return renderPass; } public createFramebuffer (info: FramebufferInfo): Framebuffer { - const framebuffer = new WebGLFramebuffer(this); - if (framebuffer.initialize(info)) { - return framebuffer; - } - return null!; + const framebuffer = new WebGLFramebuffer(); + framebuffer.initialize(info); + return framebuffer; } public createDescriptorSetLayout (info: DescriptorSetLayoutInfo): DescriptorSetLayout { - const descriptorSetLayout = new WebGLDescriptorSetLayout(this); - if (descriptorSetLayout.initialize(info)) { - return descriptorSetLayout; - } - return null!; + const descriptorSetLayout = new WebGLDescriptorSetLayout(); + descriptorSetLayout.initialize(info); + return descriptorSetLayout; } public createPipelineLayout (info: PipelineLayoutInfo): PipelineLayout { - const pipelineLayout = new WebGLPipelineLayout(this); - if (pipelineLayout.initialize(info)) { - return pipelineLayout; - } - return null!; + const pipelineLayout = new WebGLPipelineLayout(); + pipelineLayout.initialize(info); + return pipelineLayout; } public createPipelineState (info: PipelineStateInfo): PipelineState { - const pipelineState = new WebGLPipelineState(this); - if (pipelineState.initialize(info)) { - return pipelineState; - } - return null!; + const pipelineState = new WebGLPipelineState(); + pipelineState.initialize(info); + return pipelineState; } public createQueue (info: QueueInfo): Queue { - const queue = new WebGLQueue(this); - if (queue.initialize(info)) { - return queue; - } - return null!; + const queue = new WebGLQueue(); + queue.initialize(info); + return queue; } - public createGlobalBarrier (info: GlobalBarrierInfo) { - const barrier = new GlobalBarrier(this); - if (barrier.initialize(info)) { - return barrier; + public getSampler (info: SamplerInfo): Sampler { + const hash = Sampler.computeHash(info); + if (!this._samplers.has(hash)) { + this._samplers.set(hash, new WebGLSampler(info)); } - return null!; + return this._samplers.get(hash)!; } - public createTextureBarrier (info: TextureBarrierInfo) { - const barrier = new TextureBarrier(this); - if (barrier.initialize(info)) { - return barrier; + public getGlobalBarrier (info: GlobalBarrierInfo) { + const hash = GlobalBarrier.computeHash(info); + if (!this._globalBarriers.has(hash)) { + this._globalBarriers.set(hash, new GlobalBarrier(info)); } - return null!; + return this._globalBarriers.get(hash)!; + } + + public getTextureBarrier (info: TextureBarrierInfo) { + const hash = TextureBarrier.computeHash(info); + if (!this._textureBarriers.has(hash)) { + this._textureBarriers.set(hash, new TextureBarrier(info)); + } + return this._textureBarriers.get(hash)!; } public copyBuffersToTexture (buffers: ArrayBufferView[], texture: Texture, regions: BufferTextureCopy[]) { @@ -753,100 +385,4 @@ export class WebGLDevice extends Device { regions, ); } - - public copyFramebufferToBuffer ( - srcFramebuffer: Framebuffer, - dstBuffer: ArrayBuffer, - regions: BufferTextureCopy[], - ) { - const gl = this._webGLRC as WebGLRenderingContext; - const gpuFramebuffer = (srcFramebuffer as WebGLFramebuffer).gpuFramebuffer; - const format = gpuFramebuffer.gpuColorTextures[0].format; - const glFormat = GFXFormatToWebGLFormat(format, gl); - const glType = GFXFormatToWebGLType(format, gl); - const Ctor = getTypedArrayConstructor(FormatInfos[format]); - - const curFBO = this.stateCache.glFramebuffer; - - if (this.stateCache.glFramebuffer !== gpuFramebuffer.glFramebuffer) { - gl.bindFramebuffer(gl.FRAMEBUFFER, gpuFramebuffer.glFramebuffer); - this.stateCache.glFramebuffer = gpuFramebuffer.glFramebuffer; - } - - const view = new Ctor(dstBuffer); - - for (const region of regions) { - const w = region.texExtent.width; - const h = region.texExtent.height; - - gl.readPixels(region.texOffset.x, region.texOffset.y, w, h, glFormat, glType, view); - } - - if (this.stateCache.glFramebuffer !== curFBO) { - gl.bindFramebuffer(gl.FRAMEBUFFER, curFBO); - this.stateCache.glFramebuffer = curFBO; - } - } - - public blitFramebuffer (src: Framebuffer, dst: Framebuffer, srcRect: Rect, dstRect: Rect, filter: Filter) { - } - - private getExtension (ext: string): any { - const prefixes = ['', 'WEBKIT_', 'MOZ_']; - for (let i = 0; i < prefixes.length; ++i) { - const _ext = this.gl.getExtension(prefixes[i] + ext); - if (_ext) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return _ext; - } - } - return null; - } - - private initStates (gl: WebGLRenderingContext) { - gl.activeTexture(gl.TEXTURE0); - gl.pixelStorei(gl.PACK_ALIGNMENT, 1); - gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); - - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - - // rasterizer state - gl.enable(gl.SCISSOR_TEST); - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.BACK); - gl.frontFace(gl.CCW); - gl.disable(gl.POLYGON_OFFSET_FILL); - gl.polygonOffset(0.0, 0.0); - - // depth stencil state - gl.enable(gl.DEPTH_TEST); - gl.depthMask(true); - gl.depthFunc(gl.LESS); - gl.depthRange(0.0, 1.0); - - gl.stencilFuncSeparate(gl.FRONT, gl.ALWAYS, 1, 0xffff); - gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.KEEP); - gl.stencilMaskSeparate(gl.FRONT, 0xffff); - gl.stencilFuncSeparate(gl.BACK, gl.ALWAYS, 1, 0xffff); - gl.stencilOpSeparate(gl.BACK, gl.KEEP, gl.KEEP, gl.KEEP); - gl.stencilMaskSeparate(gl.BACK, 0xffff); - - gl.disable(gl.STENCIL_TEST); - - // blend state - gl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE); - gl.disable(gl.BLEND); - gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD); - gl.blendFuncSeparate(gl.ONE, gl.ZERO, gl.ONE, gl.ZERO); - gl.colorMask(true, true, true, true); - gl.blendColor(0.0, 0.0, 0.0, 0.0); - } - - private _onWebGLContextLost (event: Event) { - warnID(11000); - warn(event); - // 2020.9.3: `preventDefault` is not available on some platforms - // event.preventDefault(); - } } diff --git a/cocos/core/gfx/webgl/webgl-framebuffer.ts b/cocos/core/gfx/webgl/webgl-framebuffer.ts index 2de0c40194..dd90c3a477 100644 --- a/cocos/core/gfx/webgl/webgl-framebuffer.ts +++ b/cocos/core/gfx/webgl/webgl-framebuffer.ts @@ -26,7 +26,7 @@ import { FramebufferInfo } from '../base/define'; import { Framebuffer } from '../base/framebuffer'; import { WebGLCmdFuncCreateFramebuffer, WebGLCmdFuncDestroyFramebuffer } from './webgl-commands'; -import { WebGLDevice } from './webgl-device'; +import { WebGLDeviceManager } from './webgl-define'; import { IWebGLGPUFramebuffer, IWebGLGPUTexture } from './webgl-gpu-objects'; import { WebGLRenderPass } from './webgl-render-pass'; @@ -39,7 +39,7 @@ export class WebGLFramebuffer extends Framebuffer { private _gpuFramebuffer: IWebGLGPUFramebuffer | null = null; - public initialize (info: FramebufferInfo): boolean { + public initialize (info: FramebufferInfo) { this._renderPass = info.renderPass; this._colorTextures = info.colorTextures || []; this._depthStencilTexture = info.depthStencilTexture || null; @@ -64,14 +64,12 @@ export class WebGLFramebuffer extends Framebuffer { glFramebuffer: null, }; - WebGLCmdFuncCreateFramebuffer(this._device as WebGLDevice, this._gpuFramebuffer); - - return true; + WebGLCmdFuncCreateFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer); } public destroy () { if (this._gpuFramebuffer) { - WebGLCmdFuncDestroyFramebuffer(this._device as WebGLDevice, this._gpuFramebuffer); + WebGLCmdFuncDestroyFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer); this._gpuFramebuffer = null; } } diff --git a/cocos/core/gfx/webgl/webgl-gpu-objects.ts b/cocos/core/gfx/webgl/webgl-gpu-objects.ts index 4947e730d4..db82c00693 100644 --- a/cocos/core/gfx/webgl/webgl-gpu-objects.ts +++ b/cocos/core/gfx/webgl/webgl-gpu-objects.ts @@ -23,14 +23,76 @@ THE SOFTWARE. */ +import { nextPow2 } from '../../math/bits'; import { DescriptorType, BufferUsage, Format, MemoryUsage, SampleCount, DynamicStateFlagBit, ShaderStageFlagBit, TextureFlags, TextureType, TextureUsage, Type, - DrawInfo, Attribute, ColorAttachment, DepthStencilAttachment, - UniformBlock, UniformSamplerTexture, DescriptorSetLayoutBinding, + Attribute, ColorAttachment, DepthStencilAttachment, + UniformBlock, UniformSamplerTexture, DescriptorSetLayoutBinding, DrawInfo, } from '../base/define'; import { BlendState, DepthStencilState, RasterizerState } from '../base/pipeline-state'; +export class WebGLIndirectDrawInfos { + public counts: Int32Array; + public offsets: Int32Array; + public instances: Int32Array; + public drawCount = 0; + public drawByIndex = false; + public instancedDraw = false; + + // staging buffer + public byteOffsets: Int32Array; + + private _capacity = 4; + + constructor () { + this.counts = new Int32Array(this._capacity); + this.offsets = new Int32Array(this._capacity); + this.instances = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); + } + + public clearDraws () { + this.drawCount = 0; + this.drawByIndex = false; + this.instancedDraw = false; + } + + public setDrawInfo (idx: number, info: DrawInfo) { + this._ensureCapacity(idx); + this.drawByIndex = info.indexCount > 0; + this.instancedDraw = info.instanceCount > 1; + this.drawCount = Math.max(idx + 1, this.drawCount); + + if (this.drawByIndex) { + this.counts[idx] = info.indexCount; + this.offsets[idx] = info.firstIndex; + } else { + this.counts[idx] = info.vertexCount; + this.offsets[idx] = info.firstVertex; + } + this.instances[idx] = Math.max(1, info.instanceCount); + } + + private _ensureCapacity (target: number) { + if (this._capacity > target) return; + this._capacity = nextPow2(target); + + const counts = new Int32Array(this._capacity); + const offsets = new Int32Array(this._capacity); + const instances = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); + + counts.set(this.counts); + offsets.set(this.offsets); + instances.set(this.instances); + + this.counts = counts; + this.offsets = offsets; + this.instances = instances; + } +} + export interface IWebGLGPUUniformInfo { name: string; type: Type; @@ -57,7 +119,7 @@ export interface IWebGLGPUBuffer { buffer: ArrayBufferView | null; vf32: Float32Array | null; - indirects: DrawInfo[]; + indirects: WebGLIndirectDrawInfos; } export interface IWebGLGPUTexture { @@ -85,6 +147,8 @@ export interface IWebGLGPUTexture { glWrapT: GLenum; glMinFilter: GLenum; glMagFilter: GLenum; + + isSwapchainTexture: boolean; } export interface IWebGLGPURenderPass { diff --git a/cocos/core/gfx/webgl/webgl-input-assembler.ts b/cocos/core/gfx/webgl/webgl-input-assembler.ts index 7477f18710..663ba7cd1d 100644 --- a/cocos/core/gfx/webgl/webgl-input-assembler.ts +++ b/cocos/core/gfx/webgl/webgl-input-assembler.ts @@ -27,7 +27,7 @@ import { InputAssemblerInfo } from '../base/define'; import { InputAssembler } from '../base/input-assembler'; import { WebGLBuffer } from './webgl-buffer'; import { WebGLCmdFuncCreateInputAssember, WebGLCmdFuncDestroyInputAssembler } from './webgl-commands'; -import { WebGLDevice } from './webgl-device'; +import { WebGLDeviceManager } from './webgl-define'; import { IWebGLGPUInputAssembler, IWebGLGPUBuffer } from './webgl-gpu-objects'; export class WebGLInputAssembler extends InputAssembler { @@ -37,10 +37,10 @@ export class WebGLInputAssembler extends InputAssembler { private _gpuInputAssembler: IWebGLGPUInputAssembler | null = null; - public initialize (info: InputAssemblerInfo): boolean { + public initialize (info: InputAssemblerInfo) { if (info.vertexBuffers.length === 0) { console.error('InputAssemblerInfo.vertexBuffers is null.'); - return false; + return; } this._attributes = info.attributes; @@ -49,16 +49,16 @@ export class WebGLInputAssembler extends InputAssembler { if (info.indexBuffer) { this._indexBuffer = info.indexBuffer; - this._indexCount = this._indexBuffer.size / this._indexBuffer.stride; - this._firstIndex = 0; + this._drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; + this._drawInfo.firstIndex = 0; } else { const vertBuff = this._vertexBuffers[0]; - this._vertexCount = vertBuff.size / vertBuff.stride; - this._firstVertex = 0; - this._vertexOffset = 0; + this._drawInfo.vertexCount = vertBuff.size / vertBuff.stride; + this._drawInfo.firstVertex = 0; + this._drawInfo.vertexOffset = 0; } - this._instanceCount = 0; - this._firstInstance = 0; + this._drawInfo.instanceCount = 0; + this._drawInfo.firstInstance = 0; this._indirectBuffer = info.indirectBuffer || null; @@ -102,15 +102,13 @@ export class WebGLInputAssembler extends InputAssembler { glVAOs: new Map(), }; - WebGLCmdFuncCreateInputAssember(this._device as WebGLDevice, this._gpuInputAssembler); - - return true; + WebGLCmdFuncCreateInputAssember(WebGLDeviceManager.instance, this._gpuInputAssembler); } public destroy () { - const webglDev = this._device as WebGLDevice; - if (this._gpuInputAssembler && webglDev.useVAO) { - WebGLCmdFuncDestroyInputAssembler(webglDev, this._gpuInputAssembler); + const device = WebGLDeviceManager.instance; + if (this._gpuInputAssembler && device.extensions.useVAO) { + WebGLCmdFuncDestroyInputAssembler(device, this._gpuInputAssembler); } this._gpuInputAssembler = null; } diff --git a/cocos/core/gfx/webgl/webgl-pipeline-layout.ts b/cocos/core/gfx/webgl/webgl-pipeline-layout.ts index 4e1ca9c230..0d29908e14 100644 --- a/cocos/core/gfx/webgl/webgl-pipeline-layout.ts +++ b/cocos/core/gfx/webgl/webgl-pipeline-layout.ts @@ -62,8 +62,6 @@ export class WebGLPipelineLayout extends PipelineLayout { dynamicOffsetCount, dynamicOffsetOffsets, }; - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl/webgl-pipeline-state.ts b/cocos/core/gfx/webgl/webgl-pipeline-state.ts index f3a85d513e..f869feb62b 100644 --- a/cocos/core/gfx/webgl/webgl-pipeline-state.ts +++ b/cocos/core/gfx/webgl/webgl-pipeline-state.ts @@ -54,7 +54,7 @@ export class WebGLPipelineState extends PipelineState { private _gpuPipelineState: IWebGLGPUPipelineState | null = null; - public initialize (info: PipelineStateInfo): boolean { + public initialize (info: PipelineStateInfo) { this._primitive = info.primitive; this._shader = info.shader; this._pipelineLayout = info.pipelineLayout; @@ -95,8 +95,6 @@ export class WebGLPipelineState extends PipelineState { gpuRenderPass: (info.renderPass as WebGLRenderPass).gpuRenderPass, dynamicStates, }; - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl/webgl-primary-command-buffer.ts b/cocos/core/gfx/webgl/webgl-primary-command-buffer.ts index fc829655f5..e0982ab407 100644 --- a/cocos/core/gfx/webgl/webgl-primary-command-buffer.ts +++ b/cocos/core/gfx/webgl/webgl-primary-command-buffer.ts @@ -34,11 +34,11 @@ import { WebGLCommandBuffer } from './webgl-command-buffer'; import { WebGLCmdFuncBeginRenderPass, WebGLCmdFuncBindStates, WebGLCmdFuncCopyBuffersToTexture, WebGLCmdFuncDraw, WebGLCmdFuncExecuteCmds, WebGLCmdFuncUpdateBuffer } from './webgl-commands'; -import { WebGLDevice } from './webgl-device'; import { WebGLFramebuffer } from './webgl-framebuffer'; import { WebGLTexture } from './webgl-texture'; import { RenderPass } from '../base/render-pass'; import { WebGLRenderPass } from './webgl-render-pass'; +import { WebGLDeviceManager } from './webgl-define'; export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { public beginRenderPass ( @@ -50,7 +50,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { clearStencil: number, ) { WebGLCmdFuncBeginRenderPass( - this._device as WebGLDevice, + WebGLDeviceManager.instance, (renderPass as WebGLRenderPass).gpuRenderPass, (framebuffer as WebGLFramebuffer).gpuFramebuffer, renderArea, clearColors, clearDepth, clearStencil, @@ -58,13 +58,15 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { this._isInRenderPass = true; } - public draw (info: DrawInfo | InputAssembler) { + public draw (infoOrAssembler: DrawInfo | InputAssembler) { if (this._isInRenderPass) { if (this._isStateInvalied) { this.bindStates(); } - WebGLCmdFuncDraw(this._device as WebGLDevice, info as DrawInfo); + const info = 'drawInfo' in infoOrAssembler ? infoOrAssembler.drawInfo : infoOrAssembler; + + WebGLCmdFuncDraw(WebGLDeviceManager.instance, info as DrawInfo); ++this._numDrawCalls; this._numInstances += info.instanceCount; @@ -102,7 +104,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { buffSize = (data as ArrayBuffer).byteLength; } - WebGLCmdFuncUpdateBuffer(this._device as WebGLDevice, gpuBuffer, data as ArrayBuffer, 0, buffSize); + WebGLCmdFuncUpdateBuffer(WebGLDeviceManager.instance, gpuBuffer, data as ArrayBuffer, 0, buffSize); } } else { console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); @@ -113,7 +115,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { if (!this._isInRenderPass) { const gpuTexture = (texture as WebGLTexture).gpuTexture; if (gpuTexture) { - WebGLCmdFuncCopyBuffersToTexture(this._device as WebGLDevice, buffers, gpuTexture, regions); + WebGLCmdFuncCopyBuffersToTexture(WebGLDeviceManager.instance, buffers, gpuTexture, regions); } } else { console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); @@ -124,7 +126,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { for (let i = 0; i < count; ++i) { // actually they are secondary buffers, the cast here is only for type checking const webGLCmdBuff = cmdBuffs[i] as WebGLPrimaryCommandBuffer; - WebGLCmdFuncExecuteCmds(this._device as WebGLDevice, webGLCmdBuff.cmdPackage); + WebGLCmdFuncExecuteCmds(WebGLDeviceManager.instance, webGLCmdBuff.cmdPackage); this._numDrawCalls += webGLCmdBuff._numDrawCalls; this._numInstances += webGLCmdBuff._numInstances; this._numTris += webGLCmdBuff._numTris; @@ -132,7 +134,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { } protected bindStates () { - WebGLCmdFuncBindStates(this._device as WebGLDevice, this._curGPUPipelineState, this._curGPUInputAssembler, + WebGLCmdFuncBindStates(WebGLDeviceManager.instance, this._curGPUPipelineState, this._curGPUInputAssembler, this._curGPUDescriptorSets, this._curDynamicOffsets, this._curDynamicStates); this._isStateInvalied = false; } diff --git a/cocos/core/gfx/webgl/webgl-queue.ts b/cocos/core/gfx/webgl/webgl-queue.ts index b6b7f9b26e..5459c86f4a 100644 --- a/cocos/core/gfx/webgl/webgl-queue.ts +++ b/cocos/core/gfx/webgl/webgl-queue.ts @@ -32,25 +32,21 @@ export class WebGLQueue extends Queue { public numInstances = 0; public numTris = 0; - public initialize (info: QueueInfo): boolean { + public initialize (info: QueueInfo) { this._type = info.type; - - return true; } public destroy () { } public submit (cmdBuffs: CommandBuffer[]) { - if (!this._isAsync) { - const len = cmdBuffs.length; - for (let i = 0; i < len; i++) { - const cmdBuff = cmdBuffs[i]; - // WebGLCmdFuncExecuteCmds( this._device as WebGLDevice, (cmdBuff as WebGLCommandBuffer).cmdPackage); // opted out - this.numDrawCalls += cmdBuff.numDrawCalls; - this.numInstances += cmdBuff.numInstances; - this.numTris += cmdBuff.numTris; - } + const len = cmdBuffs.length; + for (let i = 0; i < len; i++) { + const cmdBuff = cmdBuffs[i]; + // WebGLCmdFuncExecuteCmds( this._device as WebGLDevice, (cmdBuff as WebGLCommandBuffer).cmdPackage); // opted out + this.numDrawCalls += cmdBuff.numDrawCalls; + this.numInstances += cmdBuff.numInstances; + this.numTris += cmdBuff.numTris; } } diff --git a/cocos/core/gfx/webgl/webgl-render-pass.ts b/cocos/core/gfx/webgl/webgl-render-pass.ts index dd4903b15b..ff16f42c88 100644 --- a/cocos/core/gfx/webgl/webgl-render-pass.ts +++ b/cocos/core/gfx/webgl/webgl-render-pass.ts @@ -34,12 +34,10 @@ export class WebGLRenderPass extends RenderPass { private _gpuRenderPass: IWebGLGPURenderPass | null = null; - public initialize (info: RenderPassInfo): boolean { + public initialize (info: RenderPassInfo) { this._colorInfos = info.colorAttachments; this._depthStencilInfo = info.depthStencilAttachment; - if (info.subpasses) { - this._subpasses = info.subpasses; - } + this._subpasses = info.subpasses; this._gpuRenderPass = { colorAttachments: this._colorInfos, @@ -47,8 +45,6 @@ export class WebGLRenderPass extends RenderPass { }; this._hash = this.computeHash(); - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl/webgl-shader.ts b/cocos/core/gfx/webgl/webgl-shader.ts index 4c22cffeb3..6c808c0654 100644 --- a/cocos/core/gfx/webgl/webgl-shader.ts +++ b/cocos/core/gfx/webgl/webgl-shader.ts @@ -26,7 +26,7 @@ import { ShaderInfo } from '../base/define'; import { Shader } from '../base/shader'; import { WebGLCmdFuncCreateShader, WebGLCmdFuncDestroyShader } from './webgl-commands'; -import { WebGLDevice } from './webgl-device'; +import { WebGLDeviceManager } from './webgl-define'; import { IWebGLGPUShader, IWebGLGPUShaderStage } from './webgl-gpu-objects'; export class WebGLShader extends Shader { @@ -36,7 +36,7 @@ export class WebGLShader extends Shader { private _gpuShader: IWebGLGPUShader | null = null; - public initialize (info: ShaderInfo): boolean { + public initialize (info: ShaderInfo) { this._name = info.name; this._stages = info.stages; this._attributes = info.attributes; @@ -65,14 +65,12 @@ export class WebGLShader extends Shader { }; } - WebGLCmdFuncCreateShader(this._device as WebGLDevice, this._gpuShader); - - return true; + WebGLCmdFuncCreateShader(WebGLDeviceManager.instance, this._gpuShader); } public destroy () { if (this._gpuShader) { - WebGLCmdFuncDestroyShader(this._device as WebGLDevice, this._gpuShader); + WebGLCmdFuncDestroyShader(WebGLDeviceManager.instance, this._gpuShader); this._gpuShader = null; } } diff --git a/cocos/core/gfx/webgl/webgl-swapchain.ts b/cocos/core/gfx/webgl/webgl-swapchain.ts new file mode 100644 index 0000000000..1355d61f23 --- /dev/null +++ b/cocos/core/gfx/webgl/webgl-swapchain.ts @@ -0,0 +1,328 @@ +/* + 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 { ALIPAY, RUNTIME_BASED, BYTEDANCE, WECHAT, LINKSURE, QTT, COCOSPLAY, HUAWEI, EDITOR } from 'internal:constants'; +import { macro, warnID, warn, debug } from '../../platform'; +import { sys } from '../../platform/sys'; +import { WebGLCommandAllocator } from './webgl-command-allocator'; +import { WebGLStateCache } from './webgl-state-cache'; +import { WebGLTexture } from './webgl-texture'; +import { Format, TextureInfo, TextureFlagBit, TextureType, TextureUsageBit, BufferTextureCopy, SwapchainInfo } from '../base/define'; +import { BrowserType, OS } from '../../../../pal/system-info/enum-type'; +import { Swapchain } from '../base/swapchain'; +import { IWebGLExtensions, WebGLDeviceManager } from './webgl-define'; + +const eventWebGLContextLost = 'webglcontextlost'; + +function initStates (gl: WebGLRenderingContext) { + gl.activeTexture(gl.TEXTURE0); + gl.pixelStorei(gl.PACK_ALIGNMENT, 1); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); + + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + + // rasterizer state + gl.enable(gl.SCISSOR_TEST); + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.BACK); + gl.frontFace(gl.CCW); + gl.disable(gl.POLYGON_OFFSET_FILL); + gl.polygonOffset(0.0, 0.0); + + // depth stencil state + gl.enable(gl.DEPTH_TEST); + gl.depthMask(true); + gl.depthFunc(gl.LESS); + gl.depthRange(0.0, 1.0); + + gl.stencilFuncSeparate(gl.FRONT, gl.ALWAYS, 1, 0xffff); + gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.KEEP); + gl.stencilMaskSeparate(gl.FRONT, 0xffff); + gl.stencilFuncSeparate(gl.BACK, gl.ALWAYS, 1, 0xffff); + gl.stencilOpSeparate(gl.BACK, gl.KEEP, gl.KEEP, gl.KEEP); + gl.stencilMaskSeparate(gl.BACK, 0xffff); + + gl.disable(gl.STENCIL_TEST); + + // blend state + gl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE); + gl.disable(gl.BLEND); + gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD); + gl.blendFuncSeparate(gl.ONE, gl.ZERO, gl.ONE, gl.ZERO); + gl.colorMask(true, true, true, true); + gl.blendColor(0.0, 0.0, 0.0, 0.0); +} + +function getExtension (gl: WebGLRenderingContext, ext: string): any { + const prefixes = ['', 'WEBKIT_', 'MOZ_']; + for (let i = 0; i < prefixes.length; ++i) { + const _ext = gl.getExtension(prefixes[i] + ext); + if (_ext) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return _ext; + } + } + return null; +} + +export function getExtensions (gl: WebGLRenderingContext) { + const res: IWebGLExtensions = { + EXT_texture_filter_anisotropic: getExtension(gl, 'EXT_texture_filter_anisotropic'), + EXT_blend_minmax: getExtension(gl, 'EXT_blend_minmax'), + EXT_frag_depth: getExtension(gl, 'EXT_frag_depth'), + EXT_shader_texture_lod: getExtension(gl, 'EXT_shader_texture_lod'), + EXT_sRGB: getExtension(gl, 'EXT_sRGB'), + OES_vertex_array_object: getExtension(gl, 'OES_vertex_array_object'), + EXT_color_buffer_half_float: getExtension(gl, 'EXT_color_buffer_half_float'), + WEBGL_multi_draw: getExtension(gl, 'WEBGL_multi_draw'), + WEBGL_color_buffer_float: getExtension(gl, 'WEBGL_color_buffer_float'), + WEBGL_compressed_texture_etc1: getExtension(gl, 'WEBGL_compressed_texture_etc1'), + WEBGL_compressed_texture_etc: getExtension(gl, 'WEBGL_compressed_texture_etc'), + WEBGL_compressed_texture_pvrtc: getExtension(gl, 'WEBGL_compressed_texture_pvrtc'), + WEBGL_compressed_texture_s3tc: getExtension(gl, 'WEBGL_compressed_texture_s3tc'), + WEBGL_compressed_texture_s3tc_srgb: getExtension(gl, 'WEBGL_compressed_texture_s3tc_srgb'), + WEBGL_debug_shaders: getExtension(gl, 'WEBGL_debug_shaders'), + WEBGL_draw_buffers: getExtension(gl, 'WEBGL_draw_buffers'), + WEBGL_lose_context: getExtension(gl, 'WEBGL_lose_context'), + WEBGL_depth_texture: getExtension(gl, 'WEBGL_depth_texture'), + OES_texture_half_float: getExtension(gl, 'OES_texture_half_float'), + OES_texture_half_float_linear: getExtension(gl, 'OES_texture_half_float_linear'), + OES_texture_float: getExtension(gl, 'OES_texture_float'), + OES_texture_float_linear: getExtension(gl, 'OES_texture_float_linear'), + OES_standard_derivatives: getExtension(gl, 'OES_standard_derivatives'), + OES_element_index_uint: getExtension(gl, 'OES_element_index_uint'), + ANGLE_instanced_arrays: getExtension(gl, 'ANGLE_instanced_arrays'), + WEBGL_debug_renderer_info: getExtension(gl, 'WEBGL_debug_renderer_info'), + WEBGL_compressed_texture_astc: null, + destroyShadersImmediately: true, + noCompressedTexSubImage2D: false, + useVAO: false, + }; + + // platform-specific extension hacks + // eslint-disable-next-line no-lone-blocks + { + // iOS 14 browsers crash on getExtension('WEBGL_compressed_texture_astc') + if (sys.os !== OS.IOS || sys.osMainVersion !== 14 || !sys.isBrowser) { + res.WEBGL_compressed_texture_astc = getExtension(gl, 'WEBGL_compressed_texture_astc'); + } + + // UC browser instancing implementation doesn't work + if (sys.browserType === BrowserType.UC) { + res.ANGLE_instanced_arrays = null; + } + + // bytedance ios depth texture implementation doesn't work + if (BYTEDANCE && sys.os === OS.IOS) { + res.WEBGL_depth_texture = null; + } + + if (RUNTIME_BASED) { + // VAO implementations doesn't work well on some runtime platforms + if (LINKSURE || QTT || COCOSPLAY || HUAWEI) { + res.OES_vertex_array_object = null; + } + } + + // some earlier version of iOS and android wechat implement gl.detachShader incorrectly + if ((sys.os === OS.IOS && sys.osMainVersion <= 10) + || (WECHAT && sys.os === OS.ANDROID)) { + res.destroyShadersImmediately = false; + } + + // compressedTexSubImage2D has always been problematic because the parameters differs slightly from GLES + if (WECHAT) { // and MANY platforms get it wrong + res.noCompressedTexSubImage2D = true; + } + + if (res.OES_vertex_array_object) { + res.useVAO = true; + } + } + + return res; +} + +export class WebGLSwapchain extends Swapchain { + get gl () { + return this._webGLRC as WebGLRenderingContext; + } + + get extensions () { + return this._extensions as IWebGLExtensions; + } + + public stateCache: WebGLStateCache = new WebGLStateCache(); + public cmdAllocator: WebGLCommandAllocator = new WebGLCommandAllocator(); + public nullTex2D: WebGLTexture = null!; + public nullTexCube: WebGLTexture = null!; + + private _canvas: HTMLCanvasElement | null = null; + private _webGLRC: WebGLRenderingContext | null = null; + private _webGLContextLostHandler: ((event: Event) => void) | null = null; + private _extensions: IWebGLExtensions | null = null; + + public initialize (info: SwapchainInfo) { + this._canvas = info.windowHandle; + + try { + const webGLCtxAttribs: WebGLContextAttributes = { + alpha: macro.ENABLE_TRANSPARENT_CANVAS, + antialias: EDITOR || macro.ENABLE_WEBGL_ANTIALIAS, + depth: true, + stencil: true, + premultipliedAlpha: false, + preserveDrawingBuffer: false, + powerPreference: 'default', + failIfMajorPerformanceCaveat: false, + }; + + this._webGLRC = this._canvas.getContext('webgl', webGLCtxAttribs); + } catch (err) { + return; + } + + if (!this._webGLRC) { + return; + } + + this._webGLContextLostHandler = this._onWebGLContextLost.bind(this); + this._canvas.addEventListener(eventWebGLContextLost, this._onWebGLContextLost); + + const gl = this.gl; + + this.stateCache.initialize( + WebGLDeviceManager.instance.capabilities.maxTextureUnits, + WebGLDeviceManager.instance.capabilities.maxVertexAttributes, + ); + + this._extensions = getExtensions(gl); + + // init states + initStates(gl); + + const colorFmt = Format.RGBA8; + let depthStencilFmt = Format.UNKNOWN; + + let depthBits = gl.getParameter(gl.DEPTH_BITS); + const stencilBits = gl.getParameter(gl.STENCIL_BITS); + + if (ALIPAY) { + depthBits = 24; + } + + if (depthBits && stencilBits) depthStencilFmt = Format.DEPTH_STENCIL; + else if (depthBits) depthStencilFmt = Format.DEPTH; + + this._colorTexture = new WebGLTexture(); + // @ts-expect-error(2445) private initializer + this._colorTexture.initAsSwapchainTexture({ + swapchain: this, + format: colorFmt, + width: info.width, + height: info.height, + }); + + this._depthStencilTexture = new WebGLTexture(); + // @ts-expect-error(2445) private initializer + this._depthStencilTexture.initAsSwapchainTexture({ + swapchain: this, + format: depthStencilFmt, + width: info.width, + height: info.height, + }); + + // create default null texture + this.nullTex2D = WebGLDeviceManager.instance.createTexture(new TextureInfo( + TextureType.TEX2D, + TextureUsageBit.SAMPLED, + Format.RGBA8, + 2, + 2, + TextureFlagBit.GEN_MIPMAP, + )) as WebGLTexture; + + this.nullTexCube = WebGLDeviceManager.instance.createTexture(new TextureInfo( + TextureType.CUBE, + TextureUsageBit.SAMPLED, + Format.RGBA8, + 2, + 2, + TextureFlagBit.GEN_MIPMAP, + 6, + )) as WebGLTexture; + + const nullTexRegion = new BufferTextureCopy(); + nullTexRegion.texExtent.width = 2; + nullTexRegion.texExtent.height = 2; + + const nullTexBuff = new Uint8Array(this.nullTex2D.size); + nullTexBuff.fill(0); + WebGLDeviceManager.instance.copyBuffersToTexture([nullTexBuff], this.nullTex2D, [nullTexRegion]); + + nullTexRegion.texSubres.layerCount = 6; + WebGLDeviceManager.instance.copyBuffersToTexture( + [nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff], + this.nullTexCube, [nullTexRegion], + ); + } + + public destroy (): void { + if (this._canvas && this._webGLContextLostHandler) { + this._canvas.removeEventListener(eventWebGLContextLost, this._webGLContextLostHandler); + this._webGLContextLostHandler = null; + } + + if (this.nullTex2D) { + this.nullTex2D.destroy(); + this.nullTex2D = null!; + } + + if (this.nullTexCube) { + this.nullTexCube.destroy(); + this.nullTexCube = null!; + } + + this._extensions = null; + this._webGLRC = null; + this._canvas = null; + } + + public resize (width: number, height: number) { + if (this._canvas!.width !== width || this._canvas!.height !== height) { + debug(`Resizing swapchain: ${width}x${height}`); + this._canvas!.width = width; + this._canvas!.height = height; + } + } + + private _onWebGLContextLost (event: Event) { + warnID(11000); + warn(event); + // 2020.9.3: `preventDefault` is not available on some platforms + // event.preventDefault(); + } +} diff --git a/cocos/core/gfx/webgl/webgl-texture.ts b/cocos/core/gfx/webgl/webgl-texture.ts index 0a1fe006eb..ab638a6115 100644 --- a/cocos/core/gfx/webgl/webgl-texture.ts +++ b/cocos/core/gfx/webgl/webgl-texture.ts @@ -23,10 +23,10 @@ THE SOFTWARE. */ -import { TextureFlagBit, FormatSurfaceSize, TextureInfo, TextureViewInfo, IsPowerOf2 } from '../base/define'; +import { FormatSurfaceSize, TextureInfo, TextureViewInfo, IsPowerOf2, ISwapchainTextureInfo, TextureUsageBit, FormatInfos } from '../base/define'; import { Texture } from '../base/texture'; import { WebGLCmdFuncCreateTexture, WebGLCmdFuncDestroyTexture, WebGLCmdFuncResizeTexture } from './webgl-commands'; -import { WebGLDevice } from './webgl-device'; +import { WebGLDeviceManager } from './webgl-define'; import { IWebGLGPUTexture } from './webgl-gpu-objects'; export class WebGLTexture extends Texture { @@ -36,10 +36,10 @@ export class WebGLTexture extends Texture { private _gpuTexture: IWebGLGPUTexture | null = null; - public initialize (info: TextureInfo | TextureViewInfo): boolean { + public initialize (info: TextureInfo | TextureViewInfo, isSwapchainTexture?: boolean) { if ('texture' in info) { console.log('WebGL does not support texture view.'); - return false; + return; } this._type = info.type; @@ -81,19 +81,19 @@ export class WebGLTexture extends Texture { glWrapT: 0, glMinFilter: 0, glMagFilter: 0, + + isSwapchainTexture: isSwapchainTexture || false, }; - WebGLCmdFuncCreateTexture(this._device as WebGLDevice, this._gpuTexture); + WebGLCmdFuncCreateTexture(WebGLDeviceManager.instance, this._gpuTexture); - this._device.memoryStatus.textureSize += this._size; - - return true; + WebGLDeviceManager.instance.memoryStatus.textureSize += this._size; } public destroy () { if (this._gpuTexture) { - WebGLCmdFuncDestroyTexture(this._device as WebGLDevice, this._gpuTexture); - this._device.memoryStatus.textureSize -= this._size; + WebGLCmdFuncDestroyTexture(WebGLDeviceManager.instance, this._gpuTexture); + WebGLDeviceManager.instance.memoryStatus.textureSize -= this._size; this._gpuTexture = null; } } @@ -109,9 +109,20 @@ export class WebGLTexture extends Texture { this._gpuTexture.width = width; this._gpuTexture.height = height; this._gpuTexture.size = this._size; - WebGLCmdFuncResizeTexture(this._device as WebGLDevice, this._gpuTexture); - this._device.memoryStatus.textureSize -= oldSize; - this._device.memoryStatus.textureSize += this._size; + WebGLCmdFuncResizeTexture(WebGLDeviceManager.instance, this._gpuTexture); + WebGLDeviceManager.instance.memoryStatus.textureSize -= oldSize; + WebGLDeviceManager.instance.memoryStatus.textureSize += this._size; } } + + // ======================= Swapchain Specific ======================= // + + protected initAsSwapchainTexture (info: ISwapchainTextureInfo) { + const texInfo = new TextureInfo(); + texInfo.format = info.format; + texInfo.usage = FormatInfos[info.format].hasDepth ? TextureUsageBit.DEPTH_STENCIL_ATTACHMENT : TextureUsageBit.COLOR_ATTACHMENT; + texInfo.width = info.width; + texInfo.height = info.height; + this.initialize(texInfo, true); + } } diff --git a/cocos/core/gfx/webgl2/webgl2-sampler.ts b/cocos/core/gfx/webgl2/states/webgl2-sampler.ts similarity index 61% rename from cocos/core/gfx/webgl2/webgl2-sampler.ts rename to cocos/core/gfx/webgl2/states/webgl2-sampler.ts index 34996751d9..079411b672 100644 --- a/cocos/core/gfx/webgl2/webgl2-sampler.ts +++ b/cocos/core/gfx/webgl2/states/webgl2-sampler.ts @@ -23,11 +23,11 @@ THE SOFTWARE. */ -import { SamplerInfo } from '../base/define'; -import { Sampler } from '../base/sampler'; -import { WebGL2CmdFuncCreateSampler, WebGL2CmdFuncDestroySampler } from './webgl2-commands'; -import { WebGL2Device } from './webgl2-device'; -import { IWebGL2GPUSampler } from './webgl2-gpu-objects'; +import { SamplerInfo } from '../../base/define'; +import { Sampler } from '../../base/states/sampler'; +import { WebGL2CmdFuncCreateSampler, WebGL2CmdFuncDestroySampler } from '../webgl2-commands'; +import { WebGL2DeviceManager } from '../webgl2-define'; +import { IWebGL2GPUSampler } from '../webgl2-gpu-objects'; export class WebGL2Sampler extends Sampler { public get gpuSampler (): IWebGL2GPUSampler { @@ -36,26 +36,17 @@ export class WebGL2Sampler extends Sampler { private _gpuSampler: IWebGL2GPUSampler | null = null; - public initialize (info: SamplerInfo): boolean { - this._minFilter = info.minFilter; - this._magFilter = info.magFilter; - this._mipFilter = info.mipFilter; - this._addressU = info.addressU; - this._addressV = info.addressV; - this._addressW = info.addressW; - this._maxAnisotropy = info.maxAnisotropy; - this._cmpFunc = info.cmpFunc; - this._borderColor = info.borderColor; - this._mipLODBias = info.mipLODBias; + constructor (info: SamplerInfo) { + super(info); this._gpuSampler = { glSampler: null, - minFilter: this._minFilter, - magFilter: this._magFilter, - mipFilter: this._mipFilter, - addressU: this._addressU, - addressV: this._addressV, - addressW: this._addressW, + minFilter: this._info.minFilter, + magFilter: this._info.magFilter, + mipFilter: this._info.mipFilter, + addressU: this._info.addressU, + addressV: this._info.addressV, + addressW: this._info.addressW, glMinFilter: 0, glMagFilter: 0, @@ -64,14 +55,12 @@ export class WebGL2Sampler extends Sampler { glWrapR: 0, }; - WebGL2CmdFuncCreateSampler(this._device as WebGL2Device, this._gpuSampler); - - return true; + WebGL2CmdFuncCreateSampler(WebGL2DeviceManager.instance, this._gpuSampler); } - public destroy () { + destroy () { if (this._gpuSampler) { - WebGL2CmdFuncDestroySampler(this._device as WebGL2Device, this._gpuSampler); + WebGL2CmdFuncDestroySampler(WebGL2DeviceManager.instance, this._gpuSampler); this._gpuSampler = null; } } diff --git a/cocos/core/gfx/webgl2/webgl2-buffer.ts b/cocos/core/gfx/webgl2/webgl2-buffer.ts index b01d2c3b37..7cfede0088 100644 --- a/cocos/core/gfx/webgl2/webgl2-buffer.ts +++ b/cocos/core/gfx/webgl2/webgl2-buffer.ts @@ -24,15 +24,15 @@ */ import { Buffer } from '../base/buffer'; -import { BufferUsageBit, BufferSource, BufferInfo, BufferViewInfo, IndirectBuffer } from '../base/define'; +import { BufferUsageBit, BufferSource, BufferInfo, BufferViewInfo } from '../base/define'; import { WebGL2CmdFuncCreateBuffer, WebGL2CmdFuncDestroyBuffer, WebGL2CmdFuncResizeBuffer, WebGL2CmdFuncUpdateBuffer, } from './webgl2-commands'; -import { WebGL2Device } from './webgl2-device'; -import { IWebGL2GPUBuffer } from './webgl2-gpu-objects'; +import { WebGL2DeviceManager } from './webgl2-define'; +import { IWebGL2GPUBuffer, WebGL2IndirectDrawInfos } from './webgl2-gpu-objects'; export class WebGL2Buffer extends Buffer { get gpuBuffer (): IWebGL2GPUBuffer { @@ -41,7 +41,7 @@ export class WebGL2Buffer extends Buffer { private _gpuBuffer: IWebGL2GPUBuffer | null = null; - public initialize (info: BufferInfo | BufferViewInfo): boolean { + public initialize (info: BufferInfo | BufferViewInfo) { if ('buffer' in info) { // buffer view this._isBufferView = true; @@ -72,39 +72,29 @@ export class WebGL2Buffer extends Buffer { this._count = this._size / this._stride; this._flags = info.flags; - if (this._usage & BufferUsageBit.INDIRECT) { - this._indirectBuffer = new IndirectBuffer(); - } - this._gpuBuffer = { usage: this._usage, memUsage: this._memUsage, size: this._size, stride: this._stride, buffer: null, - indirects: [], + indirects: new WebGL2IndirectDrawInfos(), glTarget: 0, glBuffer: null, glOffset: 0, }; - if (info.usage & BufferUsageBit.INDIRECT) { - this._gpuBuffer.indirects = this._indirectBuffer!.drawInfos; - } + WebGL2CmdFuncCreateBuffer(WebGL2DeviceManager.instance, this._gpuBuffer); - WebGL2CmdFuncCreateBuffer(this._device as WebGL2Device, this._gpuBuffer); - - this._device.memoryStatus.bufferSize += this._size; + WebGL2DeviceManager.instance.memoryStatus.bufferSize += this._size; } - - return true; } public destroy () { if (this._gpuBuffer) { if (!this._isBufferView) { - WebGL2CmdFuncDestroyBuffer(this._device as WebGL2Device, this._gpuBuffer); - this._device.memoryStatus.bufferSize -= this._size; + WebGL2CmdFuncDestroyBuffer(WebGL2DeviceManager.instance, this._gpuBuffer); + WebGL2DeviceManager.instance.memoryStatus.bufferSize -= this._size; } this._gpuBuffer = null; } @@ -125,9 +115,9 @@ export class WebGL2Buffer extends Buffer { if (this._gpuBuffer) { this._gpuBuffer.size = size; if (size > 0) { - WebGL2CmdFuncResizeBuffer(this._device as WebGL2Device, this._gpuBuffer); - this._device.memoryStatus.bufferSize -= oldSize; - this._device.memoryStatus.bufferSize += size; + WebGL2CmdFuncResizeBuffer(WebGL2DeviceManager.instance, this._gpuBuffer); + WebGL2DeviceManager.instance.memoryStatus.bufferSize -= oldSize; + WebGL2DeviceManager.instance.memoryStatus.bufferSize += size; } } } @@ -148,7 +138,7 @@ export class WebGL2Buffer extends Buffer { } WebGL2CmdFuncUpdateBuffer( - this._device as WebGL2Device, + WebGL2DeviceManager.instance, this._gpuBuffer!, buffer, 0, diff --git a/cocos/core/gfx/webgl2/webgl2-command-buffer.ts b/cocos/core/gfx/webgl2/webgl2-command-buffer.ts index ecf1d00551..e8cf7949e1 100644 --- a/cocos/core/gfx/webgl2/webgl2-command-buffer.ts +++ b/cocos/core/gfx/webgl2/webgl2-command-buffer.ts @@ -49,7 +49,6 @@ import { WebGL2CmdPackage, WebGL2CmdUpdateBuffer, } from './webgl2-commands'; -import { WebGL2Device } from './webgl2-device'; import { WebGL2Framebuffer } from './webgl2-framebuffer'; import { IWebGL2GPUInputAssembler, IWebGL2GPUDescriptorSet, IWebGL2GPUPipelineState } from './webgl2-gpu-objects'; import { WebGL2InputAssembler } from './webgl2-input-assembler'; @@ -57,12 +56,14 @@ import { WebGL2PipelineState } from './webgl2-pipeline-state'; import { WebGL2Texture } from './webgl2-texture'; import { RenderPass } from '../base/render-pass'; import { WebGL2RenderPass } from './webgl2-render-pass'; -import { GlobalBarrier } from '../base/global-barrier'; -import { TextureBarrier } from '../base/texture-barrier'; +import { GlobalBarrier } from '../base/states/global-barrier'; +import { TextureBarrier } from '../base/states/texture-barrier'; +import { WebGL2DeviceManager } from './webgl2-define'; export class WebGL2CommandBuffer extends CommandBuffer { public cmdPackage: WebGL2CmdPackage = new WebGL2CmdPackage(); - protected _webGLAllocator: WebGL2CommandAllocator | null = null; + + protected _cmdAllocator: WebGL2CommandAllocator = new WebGL2CommandAllocator(); protected _isInRenderPass = false; protected _curGPUPipelineState: IWebGL2GPUPipelineState | null = null; protected _curGPUDescriptorSets: IWebGL2GPUDescriptorSet[] = []; @@ -71,29 +72,22 @@ export class WebGL2CommandBuffer extends CommandBuffer { protected _curDynamicStates: DynamicStates = new DynamicStates(); protected _isStateInvalied = false; - public initialize (info: CommandBufferInfo): boolean { + public initialize (info: CommandBufferInfo) { this._type = info.type; this._queue = info.queue; - this._webGLAllocator = (this._device as WebGL2Device).cmdAllocator; - - const setCount = (this._device as WebGL2Device).bindingMappingInfo.bufferOffsets.length; + const setCount = WebGL2DeviceManager.instance.bindingMappingInfo.bufferOffsets.length; for (let i = 0; i < setCount; i++) { this._curGPUDescriptorSets.push(null!); } - - return true; } public destroy () { - if (this._webGLAllocator) { - this._webGLAllocator.clearCmds(this.cmdPackage); - this._webGLAllocator = null; - } + this._cmdAllocator.clearCmds(this.cmdPackage); } public begin (renderPass?: RenderPass, subpass = 0, frameBuffer?: Framebuffer) { - this._webGLAllocator!.clearCmds(this.cmdPackage); + this._cmdAllocator.clearCmds(this.cmdPackage); this._curGPUPipelineState = null; this._curGPUInputAssembler = null; this._curGPUDescriptorSets.length = 0; @@ -118,7 +112,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { clearDepth: number, clearStencil: number, ) { - const cmd = this._webGLAllocator!.beginRenderPassCmdPool.alloc(WebGL2CmdBeginRenderPass); + const cmd = this._cmdAllocator.beginRenderPassCmdPool.alloc(WebGL2CmdBeginRenderPass); cmd.gpuRenderPass = (renderPass as WebGL2RenderPass).gpuRenderPass; cmd.gpuFramebuffer = (framebuffer as WebGL2Framebuffer).gpuFramebuffer; cmd.renderArea = renderArea; @@ -279,22 +273,16 @@ export class WebGL2CommandBuffer extends CommandBuffer { } } - public draw (info: DrawInfo | InputAssembler) { + public draw (infoOrAssembler: DrawInfo | InputAssembler) { if (this._type === CommandBufferType.PRIMARY && this._isInRenderPass || this._type === CommandBufferType.SECONDARY) { if (this._isStateInvalied) { this.bindStates(); } + const info = 'drawInfo' in infoOrAssembler ? infoOrAssembler.drawInfo : infoOrAssembler; - const cmd = this._webGLAllocator!.drawCmdPool.alloc(WebGL2CmdDraw); - // cmd.drawInfo = inputAssembler; - cmd.drawInfo.vertexCount = info.vertexCount; - cmd.drawInfo.firstVertex = info.firstVertex; - cmd.drawInfo.indexCount = info.indexCount; - cmd.drawInfo.firstIndex = info.firstIndex; - cmd.drawInfo.vertexOffset = info.vertexOffset; - cmd.drawInfo.instanceCount = info.instanceCount; - cmd.drawInfo.firstInstance = info.firstInstance; + const cmd = this._cmdAllocator.drawCmdPool.alloc(WebGL2CmdDraw); + cmd.drawInfo.copy(info); this.cmdPackage.drawCmds.push(cmd); this.cmdPackage.cmds.push(WebGL2Cmd.DRAW); @@ -327,7 +315,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { || this._type === CommandBufferType.SECONDARY) { const gpuBuffer = (buffer as WebGL2Buffer).gpuBuffer; if (gpuBuffer) { - const cmd = this._webGLAllocator!.updateBufferCmdPool.alloc(WebGL2CmdUpdateBuffer); + const cmd = this._cmdAllocator.updateBufferCmdPool.alloc(WebGL2CmdUpdateBuffer); let buffSize = 0; let buff: BufferSource | null = null; @@ -362,7 +350,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { || this._type === CommandBufferType.SECONDARY) { const gpuTexture = (texture as WebGL2Texture).gpuTexture; if (gpuTexture) { - const cmd = this._webGLAllocator!.copyBufferToTextureCmdPool.alloc(WebGL2CmdCopyBufferToTexture); + const cmd = this._cmdAllocator.copyBufferToTextureCmdPool.alloc(WebGL2CmdCopyBufferToTexture); cmd.gpuTexture = gpuTexture; cmd.regions = regions; // TODO: Have to copy to staging buffer first to make this work for the execution is deferred. @@ -419,15 +407,10 @@ export class WebGL2CommandBuffer extends CommandBuffer { } } - public pipelineBarrier (globalBarrier: GlobalBarrier, textureBarriers: TextureBarrier[]) { - } - - public get webGLDevice (): WebGL2Device { - return this._device as WebGL2Device; - } + public pipelineBarrier (globalBarrier: GlobalBarrier | null, textureBarriers?: TextureBarrier[], textures?: Texture[]) {} protected bindStates () { - const bindStatesCmd = this._webGLAllocator!.bindStatesCmdPool.alloc(WebGL2CmdBindStates); + const bindStatesCmd = this._cmdAllocator.bindStatesCmdPool.alloc(WebGL2CmdBindStates); bindStatesCmd.gpuPipelineState = this._curGPUPipelineState; Array.prototype.push.apply(bindStatesCmd.gpuDescriptorSets, this._curGPUDescriptorSets); Array.prototype.push.apply(bindStatesCmd.dynamicOffsets, this._curDynamicOffsets); diff --git a/cocos/core/gfx/webgl2/webgl2-commands.ts b/cocos/core/gfx/webgl2/webgl2-commands.ts index 755aa7672d..aa934afff9 100644 --- a/cocos/core/gfx/webgl2/webgl2-commands.ts +++ b/cocos/core/gfx/webgl2/webgl2-commands.ts @@ -31,7 +31,7 @@ import { FormatInfos, FormatSize, LoadOp, MemoryUsageBit, SampleCount, ShaderStageFlagBit, TextureFlagBit, Color, Rect, BufferTextureCopy, BufferSource, DrawInfo, IndirectBuffer, UniformBlock, DynamicStates, } from '../base/define'; -import { WebGLEXT } from '../webgl/webgl-define'; +import { WebGL2EXT } from './webgl2-define'; import { WebGL2CommandAllocator } from './webgl2-command-allocator'; import { WebGL2Device } from './webgl2-device'; import { @@ -121,12 +121,8 @@ export function GFXFormatToWebGLType (format: Format, gl: WebGL2RenderingContext case Format.RGB10A2UI: return gl.UNSIGNED_INT_2_10_10_10_REV; case Format.RGB9E5: return gl.FLOAT; - case Format.D16: return gl.UNSIGNED_SHORT; - case Format.D16S8: return gl.UNSIGNED_INT_24_8; // no D16S8 support - case Format.D24: return gl.UNSIGNED_INT; - case Format.D24S8: return gl.UNSIGNED_INT_24_8; - case Format.D32F: return gl.FLOAT; - case Format.D32F_S8: return gl.FLOAT_32_UNSIGNED_INT_24_8_REV; + case Format.DEPTH: return gl.FLOAT; + case Format.DEPTH_STENCIL: return gl.FLOAT_32_UNSIGNED_INT_24_8_REV; case Format.BC1: return gl.UNSIGNED_BYTE; case Format.BC1_SRGB: return gl.UNSIGNED_BYTE; @@ -250,68 +246,64 @@ export function GFXFormatToWebGLInternalFormat (format: Format, gl: WebGL2Render case Format.RGB10A2: return gl.RGB10_A2; case Format.RGB10A2UI: return gl.RGB10_A2UI; case Format.R11G11B10F: return gl.R11F_G11F_B10F; - case Format.D16: return gl.DEPTH_COMPONENT16; - case Format.D16S8: return gl.DEPTH24_STENCIL8; // no D16S8 support - case Format.D24: return gl.DEPTH_COMPONENT24; - case Format.D24S8: return gl.DEPTH24_STENCIL8; - case Format.D32F: return gl.DEPTH_COMPONENT32F; - case Format.D32F_S8: return gl.DEPTH32F_STENCIL8; + case Format.DEPTH: return gl.DEPTH_COMPONENT32F; + case Format.DEPTH_STENCIL: return gl.DEPTH32F_STENCIL8; - case Format.BC1: return WebGLEXT.COMPRESSED_RGB_S3TC_DXT1_EXT; - case Format.BC1_ALPHA: return WebGLEXT.COMPRESSED_RGBA_S3TC_DXT1_EXT; - case Format.BC1_SRGB: return WebGLEXT.COMPRESSED_SRGB_S3TC_DXT1_EXT; - case Format.BC1_SRGB_ALPHA: return WebGLEXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; - case Format.BC2: return WebGLEXT.COMPRESSED_RGBA_S3TC_DXT3_EXT; - case Format.BC2_SRGB: return WebGLEXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; - case Format.BC3: return WebGLEXT.COMPRESSED_RGBA_S3TC_DXT5_EXT; - case Format.BC3_SRGB: return WebGLEXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + case Format.BC1: return WebGL2EXT.COMPRESSED_RGB_S3TC_DXT1_EXT; + case Format.BC1_ALPHA: return WebGL2EXT.COMPRESSED_RGBA_S3TC_DXT1_EXT; + case Format.BC1_SRGB: return WebGL2EXT.COMPRESSED_SRGB_S3TC_DXT1_EXT; + case Format.BC1_SRGB_ALPHA: return WebGL2EXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + case Format.BC2: return WebGL2EXT.COMPRESSED_RGBA_S3TC_DXT3_EXT; + case Format.BC2_SRGB: return WebGL2EXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + case Format.BC3: return WebGL2EXT.COMPRESSED_RGBA_S3TC_DXT5_EXT; + case Format.BC3_SRGB: return WebGL2EXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; - case Format.ETC_RGB8: return WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL; - case Format.ETC2_RGB8: return WebGLEXT.COMPRESSED_RGB8_ETC2; - case Format.ETC2_SRGB8: return WebGLEXT.COMPRESSED_SRGB8_ETC2; - case Format.ETC2_RGB8_A1: return WebGLEXT.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; - case Format.ETC2_SRGB8_A1: return WebGLEXT.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; - case Format.ETC2_RGBA8: return WebGLEXT.COMPRESSED_RGBA8_ETC2_EAC; - case Format.ETC2_SRGB8_A8: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; - case Format.EAC_R11: return WebGLEXT.COMPRESSED_R11_EAC; - case Format.EAC_R11SN: return WebGLEXT.COMPRESSED_SIGNED_R11_EAC; - case Format.EAC_RG11: return WebGLEXT.COMPRESSED_RG11_EAC; - case Format.EAC_RG11SN: return WebGLEXT.COMPRESSED_SIGNED_RG11_EAC; + case Format.ETC_RGB8: return WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL; + case Format.ETC2_RGB8: return WebGL2EXT.COMPRESSED_RGB8_ETC2; + case Format.ETC2_SRGB8: return WebGL2EXT.COMPRESSED_SRGB8_ETC2; + case Format.ETC2_RGB8_A1: return WebGL2EXT.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + case Format.ETC2_SRGB8_A1: return WebGL2EXT.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; + case Format.ETC2_RGBA8: return WebGL2EXT.COMPRESSED_RGBA8_ETC2_EAC; + case Format.ETC2_SRGB8_A8: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; + case Format.EAC_R11: return WebGL2EXT.COMPRESSED_R11_EAC; + case Format.EAC_R11SN: return WebGL2EXT.COMPRESSED_SIGNED_R11_EAC; + case Format.EAC_RG11: return WebGL2EXT.COMPRESSED_RG11_EAC; + case Format.EAC_RG11SN: return WebGL2EXT.COMPRESSED_SIGNED_RG11_EAC; - case Format.PVRTC_RGB2: return WebGLEXT.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - case Format.PVRTC_RGBA2: return WebGLEXT.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - case Format.PVRTC_RGB4: return WebGLEXT.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - case Format.PVRTC_RGBA4: return WebGLEXT.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + case Format.PVRTC_RGB2: return WebGL2EXT.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + case Format.PVRTC_RGBA2: return WebGL2EXT.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + case Format.PVRTC_RGB4: return WebGL2EXT.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + case Format.PVRTC_RGBA4: return WebGL2EXT.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - case Format.ASTC_RGBA_4X4: return WebGLEXT.COMPRESSED_RGBA_ASTC_4x4_KHR; - case Format.ASTC_RGBA_5X4: return WebGLEXT.COMPRESSED_RGBA_ASTC_5x4_KHR; - case Format.ASTC_RGBA_5X5: return WebGLEXT.COMPRESSED_RGBA_ASTC_5x5_KHR; - case Format.ASTC_RGBA_6X5: return WebGLEXT.COMPRESSED_RGBA_ASTC_6x5_KHR; - case Format.ASTC_RGBA_6X6: return WebGLEXT.COMPRESSED_RGBA_ASTC_6x6_KHR; - case Format.ASTC_RGBA_8X5: return WebGLEXT.COMPRESSED_RGBA_ASTC_8x5_KHR; - case Format.ASTC_RGBA_8X6: return WebGLEXT.COMPRESSED_RGBA_ASTC_8x6_KHR; - case Format.ASTC_RGBA_8X8: return WebGLEXT.COMPRESSED_RGBA_ASTC_8x8_KHR; - case Format.ASTC_RGBA_10X5: return WebGLEXT.COMPRESSED_RGBA_ASTC_10x5_KHR; - case Format.ASTC_RGBA_10X6: return WebGLEXT.COMPRESSED_RGBA_ASTC_10x6_KHR; - case Format.ASTC_RGBA_10X8: return WebGLEXT.COMPRESSED_RGBA_ASTC_10x8_KHR; - case Format.ASTC_RGBA_10X10: return WebGLEXT.COMPRESSED_RGBA_ASTC_10x10_KHR; - case Format.ASTC_RGBA_12X10: return WebGLEXT.COMPRESSED_RGBA_ASTC_12x10_KHR; - case Format.ASTC_RGBA_12X12: return WebGLEXT.COMPRESSED_RGBA_ASTC_12x12_KHR; + case Format.ASTC_RGBA_4X4: return WebGL2EXT.COMPRESSED_RGBA_ASTC_4x4_KHR; + case Format.ASTC_RGBA_5X4: return WebGL2EXT.COMPRESSED_RGBA_ASTC_5x4_KHR; + case Format.ASTC_RGBA_5X5: return WebGL2EXT.COMPRESSED_RGBA_ASTC_5x5_KHR; + case Format.ASTC_RGBA_6X5: return WebGL2EXT.COMPRESSED_RGBA_ASTC_6x5_KHR; + case Format.ASTC_RGBA_6X6: return WebGL2EXT.COMPRESSED_RGBA_ASTC_6x6_KHR; + case Format.ASTC_RGBA_8X5: return WebGL2EXT.COMPRESSED_RGBA_ASTC_8x5_KHR; + case Format.ASTC_RGBA_8X6: return WebGL2EXT.COMPRESSED_RGBA_ASTC_8x6_KHR; + case Format.ASTC_RGBA_8X8: return WebGL2EXT.COMPRESSED_RGBA_ASTC_8x8_KHR; + case Format.ASTC_RGBA_10X5: return WebGL2EXT.COMPRESSED_RGBA_ASTC_10x5_KHR; + case Format.ASTC_RGBA_10X6: return WebGL2EXT.COMPRESSED_RGBA_ASTC_10x6_KHR; + case Format.ASTC_RGBA_10X8: return WebGL2EXT.COMPRESSED_RGBA_ASTC_10x8_KHR; + case Format.ASTC_RGBA_10X10: return WebGL2EXT.COMPRESSED_RGBA_ASTC_10x10_KHR; + case Format.ASTC_RGBA_12X10: return WebGL2EXT.COMPRESSED_RGBA_ASTC_12x10_KHR; + case Format.ASTC_RGBA_12X12: return WebGL2EXT.COMPRESSED_RGBA_ASTC_12x12_KHR; - case Format.ASTC_SRGBA_4X4: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; - case Format.ASTC_SRGBA_5X4: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; - case Format.ASTC_SRGBA_5X5: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; - case Format.ASTC_SRGBA_6X5: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; - case Format.ASTC_SRGBA_6X6: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; - case Format.ASTC_SRGBA_8X5: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; - case Format.ASTC_SRGBA_8X6: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; - case Format.ASTC_SRGBA_8X8: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; - case Format.ASTC_SRGBA_10X5: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; - case Format.ASTC_SRGBA_10X6: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; - case Format.ASTC_SRGBA_10X8: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; - case Format.ASTC_SRGBA_10X10: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; - case Format.ASTC_SRGBA_12X10: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; - case Format.ASTC_SRGBA_12X12: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; + case Format.ASTC_SRGBA_4X4: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; + case Format.ASTC_SRGBA_5X4: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; + case Format.ASTC_SRGBA_5X5: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; + case Format.ASTC_SRGBA_6X5: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; + case Format.ASTC_SRGBA_6X6: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; + case Format.ASTC_SRGBA_8X5: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; + case Format.ASTC_SRGBA_8X6: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; + case Format.ASTC_SRGBA_8X8: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; + case Format.ASTC_SRGBA_10X5: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; + case Format.ASTC_SRGBA_10X6: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; + case Format.ASTC_SRGBA_10X8: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; + case Format.ASTC_SRGBA_10X10: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; + case Format.ASTC_SRGBA_12X10: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; + case Format.ASTC_SRGBA_12X12: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; default: { console.error('Unsupported Format, convert to WebGL internal format failed.'); @@ -373,68 +365,64 @@ export function GFXFormatToWebGLFormat (format: Format, gl: WebGL2RenderingConte case Format.RGBA4: return gl.RGBA; case Format.SRGB8: return gl.RGB; case Format.SRGB8_A8: return gl.RGBA; - case Format.D16: return gl.DEPTH_COMPONENT; - case Format.D16S8: return gl.DEPTH_STENCIL; - case Format.D24: return gl.DEPTH_COMPONENT; - case Format.D24S8: return gl.DEPTH_STENCIL; - case Format.D32F: return gl.DEPTH_COMPONENT; - case Format.D32F_S8: return gl.DEPTH_STENCIL; + case Format.DEPTH: return gl.DEPTH_COMPONENT; + case Format.DEPTH_STENCIL: return gl.DEPTH_STENCIL; - case Format.BC1: return WebGLEXT.COMPRESSED_RGB_S3TC_DXT1_EXT; - case Format.BC1_ALPHA: return WebGLEXT.COMPRESSED_RGBA_S3TC_DXT1_EXT; - case Format.BC1_SRGB: return WebGLEXT.COMPRESSED_SRGB_S3TC_DXT1_EXT; - case Format.BC1_SRGB_ALPHA: return WebGLEXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; - case Format.BC2: return WebGLEXT.COMPRESSED_RGBA_S3TC_DXT3_EXT; - case Format.BC2_SRGB: return WebGLEXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; - case Format.BC3: return WebGLEXT.COMPRESSED_RGBA_S3TC_DXT5_EXT; - case Format.BC3_SRGB: return WebGLEXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + case Format.BC1: return WebGL2EXT.COMPRESSED_RGB_S3TC_DXT1_EXT; + case Format.BC1_ALPHA: return WebGL2EXT.COMPRESSED_RGBA_S3TC_DXT1_EXT; + case Format.BC1_SRGB: return WebGL2EXT.COMPRESSED_SRGB_S3TC_DXT1_EXT; + case Format.BC1_SRGB_ALPHA: return WebGL2EXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + case Format.BC2: return WebGL2EXT.COMPRESSED_RGBA_S3TC_DXT3_EXT; + case Format.BC2_SRGB: return WebGL2EXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + case Format.BC3: return WebGL2EXT.COMPRESSED_RGBA_S3TC_DXT5_EXT; + case Format.BC3_SRGB: return WebGL2EXT.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; - case Format.ETC_RGB8: return WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL; - case Format.ETC2_RGB8: return WebGLEXT.COMPRESSED_RGB8_ETC2; - case Format.ETC2_SRGB8: return WebGLEXT.COMPRESSED_SRGB8_ETC2; - case Format.ETC2_RGB8_A1: return WebGLEXT.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; - case Format.ETC2_SRGB8_A1: return WebGLEXT.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; - case Format.ETC2_RGBA8: return WebGLEXT.COMPRESSED_RGBA8_ETC2_EAC; - case Format.ETC2_SRGB8_A8: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; - case Format.EAC_R11: return WebGLEXT.COMPRESSED_R11_EAC; - case Format.EAC_R11SN: return WebGLEXT.COMPRESSED_SIGNED_R11_EAC; - case Format.EAC_RG11: return WebGLEXT.COMPRESSED_RG11_EAC; - case Format.EAC_RG11SN: return WebGLEXT.COMPRESSED_SIGNED_RG11_EAC; + case Format.ETC_RGB8: return WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL; + case Format.ETC2_RGB8: return WebGL2EXT.COMPRESSED_RGB8_ETC2; + case Format.ETC2_SRGB8: return WebGL2EXT.COMPRESSED_SRGB8_ETC2; + case Format.ETC2_RGB8_A1: return WebGL2EXT.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + case Format.ETC2_SRGB8_A1: return WebGL2EXT.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; + case Format.ETC2_RGBA8: return WebGL2EXT.COMPRESSED_RGBA8_ETC2_EAC; + case Format.ETC2_SRGB8_A8: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; + case Format.EAC_R11: return WebGL2EXT.COMPRESSED_R11_EAC; + case Format.EAC_R11SN: return WebGL2EXT.COMPRESSED_SIGNED_R11_EAC; + case Format.EAC_RG11: return WebGL2EXT.COMPRESSED_RG11_EAC; + case Format.EAC_RG11SN: return WebGL2EXT.COMPRESSED_SIGNED_RG11_EAC; - case Format.PVRTC_RGB2: return WebGLEXT.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - case Format.PVRTC_RGBA2: return WebGLEXT.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - case Format.PVRTC_RGB4: return WebGLEXT.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - case Format.PVRTC_RGBA4: return WebGLEXT.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + case Format.PVRTC_RGB2: return WebGL2EXT.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + case Format.PVRTC_RGBA2: return WebGL2EXT.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + case Format.PVRTC_RGB4: return WebGL2EXT.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + case Format.PVRTC_RGBA4: return WebGL2EXT.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - case Format.ASTC_RGBA_4X4: return WebGLEXT.COMPRESSED_RGBA_ASTC_4x4_KHR; - case Format.ASTC_RGBA_5X4: return WebGLEXT.COMPRESSED_RGBA_ASTC_5x4_KHR; - case Format.ASTC_RGBA_5X5: return WebGLEXT.COMPRESSED_RGBA_ASTC_5x5_KHR; - case Format.ASTC_RGBA_6X5: return WebGLEXT.COMPRESSED_RGBA_ASTC_6x5_KHR; - case Format.ASTC_RGBA_6X6: return WebGLEXT.COMPRESSED_RGBA_ASTC_6x6_KHR; - case Format.ASTC_RGBA_8X5: return WebGLEXT.COMPRESSED_RGBA_ASTC_8x5_KHR; - case Format.ASTC_RGBA_8X6: return WebGLEXT.COMPRESSED_RGBA_ASTC_8x6_KHR; - case Format.ASTC_RGBA_8X8: return WebGLEXT.COMPRESSED_RGBA_ASTC_8x8_KHR; - case Format.ASTC_RGBA_10X5: return WebGLEXT.COMPRESSED_RGBA_ASTC_10x5_KHR; - case Format.ASTC_RGBA_10X6: return WebGLEXT.COMPRESSED_RGBA_ASTC_10x6_KHR; - case Format.ASTC_RGBA_10X8: return WebGLEXT.COMPRESSED_RGBA_ASTC_10x8_KHR; - case Format.ASTC_RGBA_10X10: return WebGLEXT.COMPRESSED_RGBA_ASTC_10x10_KHR; - case Format.ASTC_RGBA_12X10: return WebGLEXT.COMPRESSED_RGBA_ASTC_12x10_KHR; - case Format.ASTC_RGBA_12X12: return WebGLEXT.COMPRESSED_RGBA_ASTC_12x12_KHR; + case Format.ASTC_RGBA_4X4: return WebGL2EXT.COMPRESSED_RGBA_ASTC_4x4_KHR; + case Format.ASTC_RGBA_5X4: return WebGL2EXT.COMPRESSED_RGBA_ASTC_5x4_KHR; + case Format.ASTC_RGBA_5X5: return WebGL2EXT.COMPRESSED_RGBA_ASTC_5x5_KHR; + case Format.ASTC_RGBA_6X5: return WebGL2EXT.COMPRESSED_RGBA_ASTC_6x5_KHR; + case Format.ASTC_RGBA_6X6: return WebGL2EXT.COMPRESSED_RGBA_ASTC_6x6_KHR; + case Format.ASTC_RGBA_8X5: return WebGL2EXT.COMPRESSED_RGBA_ASTC_8x5_KHR; + case Format.ASTC_RGBA_8X6: return WebGL2EXT.COMPRESSED_RGBA_ASTC_8x6_KHR; + case Format.ASTC_RGBA_8X8: return WebGL2EXT.COMPRESSED_RGBA_ASTC_8x8_KHR; + case Format.ASTC_RGBA_10X5: return WebGL2EXT.COMPRESSED_RGBA_ASTC_10x5_KHR; + case Format.ASTC_RGBA_10X6: return WebGL2EXT.COMPRESSED_RGBA_ASTC_10x6_KHR; + case Format.ASTC_RGBA_10X8: return WebGL2EXT.COMPRESSED_RGBA_ASTC_10x8_KHR; + case Format.ASTC_RGBA_10X10: return WebGL2EXT.COMPRESSED_RGBA_ASTC_10x10_KHR; + case Format.ASTC_RGBA_12X10: return WebGL2EXT.COMPRESSED_RGBA_ASTC_12x10_KHR; + case Format.ASTC_RGBA_12X12: return WebGL2EXT.COMPRESSED_RGBA_ASTC_12x12_KHR; - case Format.ASTC_SRGBA_4X4: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; - case Format.ASTC_SRGBA_5X4: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; - case Format.ASTC_SRGBA_5X5: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; - case Format.ASTC_SRGBA_6X5: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; - case Format.ASTC_SRGBA_6X6: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; - case Format.ASTC_SRGBA_8X5: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; - case Format.ASTC_SRGBA_8X6: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; - case Format.ASTC_SRGBA_8X8: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; - case Format.ASTC_SRGBA_10X5: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; - case Format.ASTC_SRGBA_10X6: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; - case Format.ASTC_SRGBA_10X8: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; - case Format.ASTC_SRGBA_10X10: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; - case Format.ASTC_SRGBA_12X10: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; - case Format.ASTC_SRGBA_12X12: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; + case Format.ASTC_SRGBA_4X4: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; + case Format.ASTC_SRGBA_5X4: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; + case Format.ASTC_SRGBA_5X5: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; + case Format.ASTC_SRGBA_6X5: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; + case Format.ASTC_SRGBA_6X6: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; + case Format.ASTC_SRGBA_8X5: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; + case Format.ASTC_SRGBA_8X6: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; + case Format.ASTC_SRGBA_8X8: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; + case Format.ASTC_SRGBA_10X5: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; + case Format.ASTC_SRGBA_10X6: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; + case Format.ASTC_SRGBA_10X8: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; + case Format.ASTC_SRGBA_10X10: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; + case Format.ASTC_SRGBA_12X10: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; + case Format.ASTC_SRGBA_12X12: return WebGL2EXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; default: { console.error('Unsupported Format, convert to WebGL format failed.'); @@ -779,7 +767,7 @@ export function WebGL2CmdFuncCreateBuffer (device: WebGL2Device, gpuBuffer: IWeb if (glBuffer) { gpuBuffer.glBuffer = glBuffer; if (gpuBuffer.size > 0) { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { gl.bindVertexArray(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; @@ -803,7 +791,7 @@ export function WebGL2CmdFuncCreateBuffer (device: WebGL2Device, gpuBuffer: IWeb if (glBuffer) { gpuBuffer.glBuffer = glBuffer; if (gpuBuffer.size > 0) { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { gl.bindVertexArray(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; @@ -855,7 +843,7 @@ export function WebGL2CmdFuncDestroyBuffer (device: WebGL2Device, gpuBuffer: IWe // can be reproduced in the static batching scene at https://github.com/cocos-creator/test-cases-3d switch (gpuBuffer.glTarget) { case gl.ARRAY_BUFFER: - if (device.useVAO && device.stateCache.glVAO) { + if (device.extensions.useVAO && device.stateCache.glVAO) { gl.bindVertexArray(null); device.stateCache.glVAO = gfxStateCache.gpuInputAssembler = null; } @@ -863,7 +851,7 @@ export function WebGL2CmdFuncDestroyBuffer (device: WebGL2Device, gpuBuffer: IWe device.stateCache.glArrayBuffer = null; break; case gl.ELEMENT_ARRAY_BUFFER: - if (device.useVAO && device.stateCache.glVAO) { + if (device.extensions.useVAO && device.stateCache.glVAO) { gl.bindVertexArray(null); device.stateCache.glVAO = gfxStateCache.gpuInputAssembler = null; } @@ -888,7 +876,7 @@ export function WebGL2CmdFuncResizeBuffer (device: WebGL2Device, gpuBuffer: IWeb const glUsage: GLenum = gpuBuffer.memUsage & MemoryUsageBit.HOST ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW; if (gpuBuffer.usage & BufferUsageBit.VERTEX) { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { gl.bindVertexArray(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; @@ -907,7 +895,7 @@ export function WebGL2CmdFuncResizeBuffer (device: WebGL2Device, gpuBuffer: IWeb gl.bindBuffer(gl.ARRAY_BUFFER, null); cache.glArrayBuffer = null; } else if (gpuBuffer.usage & BufferUsageBit.INDEX) { - if (device.useVAO) { + if (device.extensions.useVAO) { if (cache.glVAO) { gl.bindVertexArray(null); cache.glVAO = gfxStateCache.gpuInputAssembler = null; @@ -945,8 +933,11 @@ export function WebGL2CmdFuncResizeBuffer (device: WebGL2Device, gpuBuffer: IWeb export function WebGL2CmdFuncUpdateBuffer (device: WebGL2Device, gpuBuffer: IWebGL2GPUBuffer, buffer: BufferSource, offset: number, size: number) { if (gpuBuffer.usage & BufferUsageBit.INDIRECT) { - gpuBuffer.indirects.length = offset; - Array.prototype.push.apply(gpuBuffer.indirects, (buffer as IndirectBuffer).drawInfos); + gpuBuffer.indirects.clearDraws(); + const drawInfos = (buffer as IndirectBuffer).drawInfos; + for (let i = 0; i < drawInfos.length; ++i) { + gpuBuffer.indirects.setDrawInfo(offset + i, drawInfos[i]); + } } else { const buff = buffer as ArrayBuffer; const { gl } = device; @@ -1022,13 +1013,14 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW switch (gpuTexture.type) { case TextureType.TEX2D: { gpuTexture.glTarget = gl.TEXTURE_2D; + if (gpuTexture.isSwapchainTexture) break; const maxSize = Math.max(w, h); if (maxSize > device.capabilities.maxTextureSize) { errorID(9100, maxSize, device.capabilities.maxTextureSize); } - if (gpuTexture.samples === SampleCount.X1) { + if (gpuTexture.samples === SampleCount.ONE) { const glTexture = gl.createTexture(); if (glTexture && gpuTexture.size > 0) { gpuTexture.glTexture = glTexture; @@ -1039,20 +1031,12 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW glTexUnit.glTexture = gpuTexture.glTexture; } - if (gpuTexture.glInternalFmt === WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) { + if (gpuTexture.glInternalFmt === WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL) { // init 2 x 2 texture const imgSize = FormatSize(gpuTexture.format, 2, 2, 1); const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gpuTexture.glInternalFmt, 2, 2, 0, view); - } else if (gpuTexture.flags & TextureFlagBit.IMMUTABLE) { - gl.texStorage2D(gl.TEXTURE_2D, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h); - } else if (!FormatInfos[gpuTexture.format].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel; ++i) { - gl.texImage2D(gl.TEXTURE_2D, i, gpuTexture.glInternalFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null); - w = Math.max(1, w >> 1); - h = Math.max(1, h >> 1); - } - } else { + } else if (FormatInfos[gpuTexture.format].isCompressed) { for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); @@ -1060,6 +1044,14 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); } + } else if (!(gpuTexture.flags & TextureFlagBit.RESIZABLE)) { + gl.texStorage2D(gl.TEXTURE_2D, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h); + } else { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + gl.texImage2D(gl.TEXTURE_2D, i, gpuTexture.glInternalFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null); + w = Math.max(1, w >> 1); + h = Math.max(1, h >> 1); + } } } else { gl.deleteTexture(glTexture); @@ -1097,24 +1089,13 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW glTexUnit.glTexture = gpuTexture.glTexture; } - if (gpuTexture.glInternalFmt === WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) { + if (gpuTexture.glInternalFmt === WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL) { for (let f = 0; f < 6; ++f) { const imgSize = FormatSize(gpuTexture.format, 2, 2, 1); const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, 0, gpuTexture.glInternalFmt, 2, 2, 0, view); } - } else if (gpuTexture.flags & TextureFlagBit.IMMUTABLE) { - gl.texStorage2D(gl.TEXTURE_CUBE_MAP, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h); - } else if (!FormatInfos[gpuTexture.format].isCompressed) { - for (let i = 0; i < gpuTexture.mipLevel; ++i) { - for (let f = 0; f < 6; ++f) { - gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, - gpuTexture.glInternalFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null); - } - w = Math.max(1, w >> 1); - h = Math.max(1, h >> 1); - } - } else { + } else if (FormatInfos[gpuTexture.format].isCompressed) { for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); @@ -1124,6 +1105,17 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); } + } else if (!(gpuTexture.flags & TextureFlagBit.RESIZABLE)) { + gl.texStorage2D(gl.TEXTURE_CUBE_MAP, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h); + } else { + for (let i = 0; i < gpuTexture.mipLevel; ++i) { + for (let f = 0; f < 6; ++f) { + gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, + gpuTexture.glInternalFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null); + } + w = Math.max(1, w >> 1); + h = Math.max(1, h >> 1); + } } } break; @@ -1163,7 +1155,7 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2Device, gpuTexture: IW errorID(9100, maxSize, device.capabilities.maxTextureSize); } - if (gpuTexture.samples === SampleCount.X1) { + if (gpuTexture.samples === SampleCount.ONE) { const glTexUnit = device.stateCache.glTexUnits[device.stateCache.texUnit]; if (glTexUnit.glTexture !== gpuTexture.glTexture) { @@ -1177,7 +1169,7 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2Device, gpuTexture: IW w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); } - } else if (gpuTexture.glInternalFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) { + } else if (gpuTexture.glInternalFmt !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL) { for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = FormatSize(gpuTexture.format, w, h, 1); const view: Uint8Array = new Uint8Array(imgSize); @@ -1224,7 +1216,7 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2Device, gpuTexture: IW h = Math.max(1, h >> 1); } } - } else if (gpuTexture.glInternalFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) { + } else if (gpuTexture.glInternalFmt !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL) { for (let f = 0; f < 6; ++f) { w = gpuTexture.width; h = gpuTexture.height; @@ -1296,7 +1288,12 @@ export function WebGL2CmdFuncDestroySampler (device: WebGL2Device, gpuSampler: I } export function WebGL2CmdFuncCreateFramebuffer (device: WebGL2Device, gpuFramebuffer: IWebGL2GPUFramebuffer) { - if (!gpuFramebuffer.gpuColorTextures.length && !gpuFramebuffer.gpuDepthStencilTexture) { return; } // onscreen fbo + let isOnscreen = false; + for (let i = 0; i < gpuFramebuffer.gpuColorTextures.length; ++i) { + if (!gpuFramebuffer.gpuColorTextures[i].glTexture) isOnscreen = true; + } + if (gpuFramebuffer.gpuDepthStencilTexture && !gpuFramebuffer.gpuDepthStencilTexture.glTexture) isOnscreen = true; + if (isOnscreen) return; const { gl } = device; const attachments: GLenum[] = []; @@ -1591,8 +1588,8 @@ export function WebGL2CmdFuncCreateShader (device: WebGL2Device, gpuShader: IWeb for (let i = 0; i < gpuShader.samplerTextures.length; ++i) { const sampler = gpuShader.samplerTextures[i]; const glLoc = gl.getUniformLocation(gpuShader.glProgram, sampler.name); - // Note: getUniformLocation return Object on wechat platform. - if (glLoc !== null && (typeof glLoc === 'number' || (glLoc as any).id !== -1)) { + // wEcHAT just returns { id: -1 } for non-existing names /eyerolling + if (glLoc && (glLoc as any).id !== -1) { glActiveSamplers.push(gpuShader.glSamplerTextures[i]); glActiveSamplerLocations.push(glLoc); } @@ -2205,7 +2202,7 @@ export function WebGL2CmdFuncBindStates ( if (gpuTexture.glTexture) { gl.bindTexture(gpuTexture.glTarget, gpuTexture.glTexture); } else { - gl.bindTexture(gpuTexture.glTarget, device.nullTex2D!.gpuTexture.glTexture); + gl.bindTexture(gpuTexture.glTarget, device.nullTex2D.gpuTexture.glTexture); } glTexUnit.glTexture = gpuTexture.glTexture; } @@ -2227,7 +2224,7 @@ export function WebGL2CmdFuncBindStates ( && (isShaderChanged || gfxStateCache.gpuInputAssembler !== gpuInputAssembler)) { gfxStateCache.gpuInputAssembler = gpuInputAssembler; - if (device.useVAO) { + if (device.extensions.useVAO) { // check vao let glVAO = gpuInputAssembler.glVAOs.get(gpuShader.glProgram!); if (!glVAO) { @@ -2446,45 +2443,76 @@ export function WebGL2CmdFuncBindStates ( export function WebGL2CmdFuncDraw (device: WebGL2Device, drawInfo: DrawInfo) { const { gl } = device; const { gpuInputAssembler, glPrimitive } = gfxStateCache; + const md = device.extensions.WEBGL_multi_draw; if (gpuInputAssembler) { + const indexBuffer = gpuInputAssembler.gpuIndexBuffer; if (gpuInputAssembler.gpuIndirectBuffer) { const { indirects } = gpuInputAssembler.gpuIndirectBuffer; - for (let k = 0; k < indirects.length; k++) { - const subDrawInfo = indirects[k]; - const gpuBuffer = gpuInputAssembler.gpuIndexBuffer; - if (subDrawInfo.instanceCount) { - if (gpuBuffer) { - if (subDrawInfo.indexCount > 0) { - const offset = subDrawInfo.firstIndex * gpuBuffer.stride; - gl.drawElementsInstanced(glPrimitive, subDrawInfo.indexCount, - gpuInputAssembler.glIndexType, offset, subDrawInfo.instanceCount); + if (indirects.drawByIndex) { + for (let j = 0; j < indirects.drawCount; j++) { + indirects.byteOffsets[j] = indirects.offsets[j] * indexBuffer!.stride; + } + if (md) { + if (indirects.instancedDraw) { + md.multiDrawElementsInstancedWEBGL(glPrimitive, + indirects.counts, 0, + gpuInputAssembler.glIndexType, + indirects.byteOffsets, 0, + indirects.instances, 0, + indirects.drawCount); + } else { + md.multiDrawElementsWEBGL(glPrimitive, + indirects.counts, 0, + gpuInputAssembler.glIndexType, + indirects.byteOffsets, 0, + indirects.drawCount); + } + } else { + for (let j = 0; j < indirects.drawCount; j++) { + if (indirects.instances[j] > 1) { + gl.drawElementsInstanced(glPrimitive, indirects.counts[j], + gpuInputAssembler.glIndexType, indirects.byteOffsets[j], indirects.instances[j]); + } else { + gl.drawElements(glPrimitive, indirects.counts[j], gpuInputAssembler.glIndexType, indirects.byteOffsets[j]); } - } else if (subDrawInfo.vertexCount > 0) { - gl.drawArraysInstanced(glPrimitive, subDrawInfo.firstVertex, subDrawInfo.vertexCount, subDrawInfo.instanceCount); } - } else if (gpuBuffer) { - if (subDrawInfo.indexCount > 0) { - const offset = subDrawInfo.firstIndex * gpuBuffer.stride; - gl.drawElements(glPrimitive, subDrawInfo.indexCount, gpuInputAssembler.glIndexType, offset); + } + } else if (md) { + if (indirects.instancedDraw) { + md.multiDrawArraysInstancedWEBGL(glPrimitive, + indirects.offsets, 0, + indirects.counts, 0, + indirects.instances, 0, + indirects.drawCount); + } else { + md.multiDrawArraysWEBGL(glPrimitive, + indirects.offsets, 0, + indirects.counts, 0, + indirects.drawCount); + } + } else { + for (let j = 0; j < indirects.drawCount; j++) { + if (indirects.instances[j] > 1) { + gl.drawArraysInstanced(glPrimitive, indirects.offsets[j], indirects.counts[j], indirects.instances[j]); + } else { + gl.drawArrays(glPrimitive, indirects.offsets[j], indirects.counts[j]); } - } else if (subDrawInfo.vertexCount > 0) { - gl.drawArrays(glPrimitive, subDrawInfo.firstVertex, subDrawInfo.vertexCount); } } } else if (drawInfo.instanceCount) { - if (gpuInputAssembler.gpuIndexBuffer) { + if (indexBuffer) { if (drawInfo.indexCount > 0) { - const offset = drawInfo.firstIndex * gpuInputAssembler.gpuIndexBuffer.stride; + const offset = drawInfo.firstIndex * indexBuffer.stride; gl.drawElementsInstanced(glPrimitive, drawInfo.indexCount, gpuInputAssembler.glIndexType, offset, drawInfo.instanceCount); } } else if (drawInfo.vertexCount > 0) { gl.drawArraysInstanced(glPrimitive, drawInfo.firstVertex, drawInfo.vertexCount, drawInfo.instanceCount); } - } else if (gpuInputAssembler.gpuIndexBuffer) { + } else if (indexBuffer) { if (drawInfo.indexCount > 0) { - const offset = drawInfo.firstIndex * gpuInputAssembler.gpuIndexBuffer.stride; + const offset = drawInfo.firstIndex * indexBuffer.stride; gl.drawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler.glIndexType, offset); } } else if (drawInfo.vertexCount > 0) { @@ -2620,7 +2648,7 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( gl.texSubImage2D(gl.TEXTURE_2D, region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, w, h, gpuTexture.glFormat, gpuTexture.glType, pixels); - } else if (gpuTexture.glInternalFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) { + } else if (gpuTexture.glInternalFmt !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL) { gl.compressedTexSubImage2D(gl.TEXTURE_2D, region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, w, h, gpuTexture.glFormat, pixels); @@ -2645,7 +2673,7 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, w, h, gpuTexture.glFormat, gpuTexture.glType, pixels); - } else if (gpuTexture.glInternalFmt !== WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL) { + } else if (gpuTexture.glInternalFmt !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL) { gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, w, h, gpuTexture.glFormat, pixels); diff --git a/cocos/core/gfx/webgl2/webgl2-define.ts b/cocos/core/gfx/webgl2/webgl2-define.ts new file mode 100644 index 0000000000..92553146d5 --- /dev/null +++ b/cocos/core/gfx/webgl2/webgl2-define.ts @@ -0,0 +1,117 @@ +/* + 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 { WebGL2Device } from './webgl2-device'; + +// Extensions +export enum WebGL2EXT { + COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0, + COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1, + COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2, + COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3, + + COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C, + COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8C4D, + COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E, + COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F, + + COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00, + COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01, + COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02, + COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03, + + COMPRESSED_RGB_ETC1_WEBGL = 0x8D64, + + COMPRESSED_R11_EAC = 0x9270, + COMPRESSED_SIGNED_R11_EAC = 0x9271, + COMPRESSED_RG11_EAC = 0x9272, + COMPRESSED_SIGNED_RG11_EAC = 0x9273, + COMPRESSED_RGB8_ETC2 = 0x9274, + COMPRESSED_SRGB8_ETC2 = 0x9275, + COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276, + COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277, + COMPRESSED_RGBA8_ETC2_EAC = 0x9278, + COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279, + + COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0, + COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1, + COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2, + COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3, + COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4, + COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5, + COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6, + COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7, + COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8, + COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9, + COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA, + COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB, + COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC, + COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD, + + COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0, + COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1, + COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2, + COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3, + COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4, + COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5, + COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6, + COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7, + COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8, + COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9, + COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA, + COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB, + COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC, + COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD, +} + +export interface IWebGL2Extensions { + EXT_texture_filter_anisotropic: EXT_texture_filter_anisotropic | null; + EXT_color_buffer_half_float: EXT_color_buffer_half_float | null; + EXT_color_buffer_float: EXT_color_buffer_float | null; + WEBGL_multi_draw: WEBGL_multi_draw | null; + WEBGL_compressed_texture_etc1: WEBGL_compressed_texture_etc1 | null; + WEBGL_compressed_texture_etc: WEBGL_compressed_texture_etc | null; + WEBGL_compressed_texture_pvrtc: WEBGL_compressed_texture_pvrtc | null; + WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null; + WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null; + WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null; + WEBGL_debug_shaders: WEBGL_debug_shaders | null; + WEBGL_lose_context: WEBGL_lose_context | null; + WEBGL_debug_renderer_info: WEBGL_debug_renderer_info | null; + OES_texture_half_float_linear: OES_texture_half_float_linear | null; + OES_texture_float_linear: OES_texture_float_linear | null; + useVAO: boolean; +} + +// put the global instance here so that we won't have circular dependencies +export class WebGL2DeviceManager { + static get instance () { + return WebGL2DeviceManager._instance!; + } + static setInstance (instance: WebGL2Device) { + WebGL2DeviceManager._instance = instance; + } + private static _instance: WebGL2Device | null = null; +} diff --git a/cocos/core/gfx/webgl2/webgl2-descriptor-set-layout.ts b/cocos/core/gfx/webgl2/webgl2-descriptor-set-layout.ts index 95ddd41475..efd863be98 100644 --- a/cocos/core/gfx/webgl2/webgl2-descriptor-set-layout.ts +++ b/cocos/core/gfx/webgl2/webgl2-descriptor-set-layout.ts @@ -68,8 +68,6 @@ export class WebGL2DescriptorSetLayout extends DescriptorSetLayout { descriptorIndices, descriptorCount, }; - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl2/webgl2-descriptor-set.ts b/cocos/core/gfx/webgl2/webgl2-descriptor-set.ts index 20339df6a9..128ac7b44a 100644 --- a/cocos/core/gfx/webgl2/webgl2-descriptor-set.ts +++ b/cocos/core/gfx/webgl2/webgl2-descriptor-set.ts @@ -26,7 +26,7 @@ import { DescriptorSet } from '../base/descriptor-set'; import { WebGL2Buffer } from './webgl2-buffer'; import { IWebGL2GPUDescriptorSet, IWebGL2GPUDescriptor } from './webgl2-gpu-objects'; -import { WebGL2Sampler } from './webgl2-sampler'; +import { WebGL2Sampler } from './states/webgl2-sampler'; import { WebGL2Texture } from './webgl2-texture'; import { WebGL2DescriptorSetLayout } from './webgl2-descriptor-set-layout'; import { DescriptorSetInfo, DESCRIPTOR_BUFFER_TYPE, DESCRIPTOR_SAMPLER_TYPE } from '../base/define'; @@ -38,7 +38,7 @@ export class WebGL2DescriptorSet extends DescriptorSet { private _gpuDescriptorSet: IWebGL2GPUDescriptorSet | null = null; - public initialize (info: DescriptorSetInfo): boolean { + public initialize (info: DescriptorSetInfo) { this._layout = info.layout; const { bindings, descriptorIndices, descriptorCount } = (info.layout as WebGL2DescriptorSetLayout).gpuDescriptorSetLayout; @@ -60,8 +60,6 @@ export class WebGL2DescriptorSet extends DescriptorSet { }); } } - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl2/webgl2-device.ts b/cocos/core/gfx/webgl2/webgl2-device.ts index e028e40a97..97713d9f15 100644 --- a/cocos/core/gfx/webgl2/webgl2-device.ts +++ b/cocos/core/gfx/webgl2/webgl2-device.ts @@ -23,7 +23,6 @@ THE SOFTWARE. */ -import { macro, warnID, warn } from '../../platform'; import { DescriptorSet } from '../base/descriptor-set'; import { DescriptorSetLayout } from '../base/descriptor-set-layout'; import { PipelineLayout } from '../base/pipeline-layout'; @@ -35,12 +34,11 @@ import { InputAssembler } from '../base/input-assembler'; import { PipelineState, PipelineStateInfo } from '../base/pipeline-state'; import { Queue } from '../base/queue'; import { RenderPass } from '../base/render-pass'; -import { Sampler } from '../base/sampler'; +import { Sampler } from '../base/states/sampler'; import { Shader } from '../base/shader'; import { Texture } from '../base/texture'; import { WebGL2DescriptorSet } from './webgl2-descriptor-set'; import { WebGL2Buffer } from './webgl2-buffer'; -import { WebGL2CommandAllocator } from './webgl2-command-allocator'; import { WebGL2CommandBuffer } from './webgl2-command-buffer'; import { WebGL2Framebuffer } from './webgl2-framebuffer'; import { WebGL2InputAssembler } from './webgl2-input-assembler'; @@ -50,176 +48,71 @@ import { WebGL2PipelineState } from './webgl2-pipeline-state'; import { WebGL2PrimaryCommandBuffer } from './webgl2-primary-command-buffer'; import { WebGL2Queue } from './webgl2-queue'; import { WebGL2RenderPass } from './webgl2-render-pass'; -import { WebGL2Sampler } from './webgl2-sampler'; +import { WebGL2Sampler } from './states/webgl2-sampler'; import { WebGL2Shader } from './webgl2-shader'; -import { WebGL2StateCache } from './webgl2-state-cache'; +import { WebGL2Swapchain, getExtensions } from './webgl2-swapchain'; import { WebGL2Texture } from './webgl2-texture'; import { - getTypedArrayConstructor, CommandBufferType, Filter, Format, FormatInfos, DescriptorSetLayoutInfo, DescriptorSetInfo, - PipelineLayoutInfo, BufferViewInfo, CommandBufferInfo, BufferInfo, BindingMappingInfo, FramebufferInfo, InputAssemblerInfo, - QueueInfo, RenderPassInfo, SamplerInfo, ShaderInfo, TextureInfo, TextureViewInfo, DeviceInfo, Rect, GlobalBarrierInfo, TextureBarrierInfo, - QueueType, TextureFlagBit, TextureType, TextureUsageBit, API, Feature, BufferTextureCopy, + CommandBufferType, DescriptorSetLayoutInfo, DescriptorSetInfo, + PipelineLayoutInfo, BufferViewInfo, CommandBufferInfo, BufferInfo, FramebufferInfo, InputAssemblerInfo, + QueueInfo, RenderPassInfo, SamplerInfo, ShaderInfo, TextureInfo, TextureViewInfo, DeviceInfo, GlobalBarrierInfo, TextureBarrierInfo, + QueueType, API, Feature, BufferTextureCopy, SwapchainInfo, } from '../base/define'; -import { - GFXFormatToWebGLFormat, GFXFormatToWebGLType, WebGL2CmdFuncBlitFramebuffer, WebGL2CmdFuncCopyTextureToBuffers, - WebGL2CmdFuncCopyBuffersToTexture, WebGL2CmdFuncCopyTexImagesToTexture, -} from './webgl2-commands'; -import { GlobalBarrier } from '../base/global-barrier'; -import { TextureBarrier } from '../base/texture-barrier'; +import { WebGL2CmdFuncCopyTextureToBuffers, WebGL2CmdFuncCopyBuffersToTexture, WebGL2CmdFuncCopyTexImagesToTexture } from './webgl2-commands'; +import { GlobalBarrier } from '../base/states/global-barrier'; +import { TextureBarrier } from '../base/states/texture-barrier'; import { debug } from '../../platform/debug'; - -const eventWebGLContextLost = 'webglcontextlost'; +import { Swapchain } from '../base/swapchain'; +import { WebGL2DeviceManager } from './webgl2-define'; export class WebGL2Device extends Device { get gl () { - return this._webGL2RC as WebGL2RenderingContext; + return this._swapchain!.gl; } - get isAntialias () { - return this._isAntialias; + get extensions () { + return this._swapchain!.extensions; } - get isPremultipliedAlpha () { - return this._isPremultipliedAlpha; + get stateCache () { + return this._swapchain!.stateCache; } - get useVAO () { - return this._useVAO; + get nullTex2D () { + return this._swapchain!.nullTex2D; } - get bindingMappingInfo () { - return this._bindingMappingInfo; + get nullTexCube () { + return this._swapchain!.nullTexCube; } - get EXT_texture_filter_anisotropic () { - return this._EXT_texture_filter_anisotropic; - } - - get OES_texture_float_linear () { - return this._OES_texture_float_linear; - } - - get EXT_color_buffer_float () { - return this._EXT_color_buffer_float; - } - - get EXT_disjoint_timer_query_webgl2 () { - return this._EXT_disjoint_timer_query_webgl2; - } - - get WEBGL_compressed_texture_etc1 () { - return this._WEBGL_compressed_texture_etc1; - } - - get WEBGL_compressed_texture_etc () { - return this._WEBGL_compressed_texture_etc; - } - - get WEBGL_compressed_texture_pvrtc () { - return this._WEBGL_compressed_texture_pvrtc; - } - - get WEBGL_compressed_texture_s3tc () { - return this._WEBGL_compressed_texture_s3tc; - } - - get WEBGL_compressed_texture_s3tc_srgb () { - return this._WEBGL_compressed_texture_s3tc_srgb; - } - - get WEBGL_texture_storage_multisample () { - return this._WEBGL_texture_storage_multisample; - } - - get WEBGL_debug_shaders () { - return this._WEBGL_debug_shaders; - } - - get WEBGL_lose_context () { - return this._WEBGL_lose_context; - } - - public stateCache: WebGL2StateCache = new WebGL2StateCache(); - public cmdAllocator: WebGL2CommandAllocator = new WebGL2CommandAllocator(); - public nullTex2D: WebGL2Texture | null = null; - public nullTexCube: WebGL2Texture | null = null; - - private _webGL2RC: WebGL2RenderingContext | null = null; - private _isAntialias = true; - private _isPremultipliedAlpha = true; - private _useVAO = true; - private _bindingMappingInfo: BindingMappingInfo = new BindingMappingInfo(); - private _webGLContextLostHandler: null | ((event: Event) => void) = null; - - private _extensions: string[] | null = null; - private _EXT_texture_filter_anisotropic: EXT_texture_filter_anisotropic | null = null; - private _OES_texture_float_linear: OES_texture_float_linear | null = null; - private _OES_texture_half_float_linear: OES_texture_half_float_linear | null = null; - private _EXT_color_buffer_float: EXT_color_buffer_float | null = null; - private _EXT_disjoint_timer_query_webgl2: EXT_disjoint_timer_query_webgl2 | null = null; - private _WEBGL_compressed_texture_etc1: WEBGL_compressed_texture_etc1 | null = null; - private _WEBGL_compressed_texture_etc: WEBGL_compressed_texture_etc | null = null; - private _WEBGL_compressed_texture_pvrtc: WEBGL_compressed_texture_pvrtc | null = null; - private _WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null = null; - private _WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null = null; - private _WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null = null; - private _WEBGL_debug_renderer_info: WEBGL_debug_renderer_info | null = null; - private _WEBGL_texture_storage_multisample: WEBGL_texture_storage_multisample | null = null; - private _WEBGL_debug_shaders: WEBGL_debug_shaders | null = null; - private _WEBGL_lose_context: WEBGL_lose_context | null = null; + private _swapchain: WebGL2Swapchain | null = null; public initialize (info: DeviceInfo): boolean { - this._canvas = info.canvasElm as HTMLCanvasElement; - this._isAntialias = info.isAntialias; - this._isPremultipliedAlpha = info.isPremultipliedAlpha; + WebGL2DeviceManager.setInstance(this); + this._gfxAPI = API.WEBGL2; + this._bindingMappingInfo = info.bindingMappingInfo; if (!this._bindingMappingInfo.bufferOffsets.length) this._bindingMappingInfo.bufferOffsets.push(0); if (!this._bindingMappingInfo.samplerOffsets.length) this._bindingMappingInfo.samplerOffsets.push(0); + let gl: WebGL2RenderingContext | null = null; + try { - const webGLCtxAttribs: WebGLContextAttributes = { - alpha: macro.ENABLE_TRANSPARENT_CANVAS, - antialias: this._isAntialias, - depth: true, - stencil: true, - premultipliedAlpha: this._isPremultipliedAlpha, - preserveDrawingBuffer: false, - powerPreference: 'default', - failIfMajorPerformanceCaveat: false, - }; - - this._webGL2RC = this._canvas.getContext('webgl2', webGLCtxAttribs); + gl = document.createElement('canvas').getContext('webgl2'); } catch (err) { - console.warn(err); + console.error(err); + } + + if (!gl) { + console.error('This device does not support WebGL.'); return false; } - if (!this._webGL2RC) { - console.warn('This device does not support WebGL2.'); - return false; - } + // create queue + this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); + this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); - this._webGLContextLostHandler = this._onWebGLContextLost.bind(this); - this._canvas.addEventListener(eventWebGLContextLost, this._onWebGLContextLost); - - this._canvas2D = document.createElement('canvas'); - - console.info('WebGL2 device initialized.'); - - this._gfxAPI = API.WEBGL2; - this._deviceName = 'WebGL2'; - const gl = this._webGL2RC; - - this._WEBGL_debug_renderer_info = this.getExtension('WEBGL_debug_renderer_info'); - if (this._WEBGL_debug_renderer_info) { - this._renderer = gl.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); - this._vendor = gl.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL); - } else { - this._renderer = gl.getParameter(gl.RENDERER); - this._vendor = gl.getParameter(gl.VENDOR); - } - - this._version = gl.getParameter(gl.VERSION); this._caps.maxVertexAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); this._caps.maxVertexUniformVectors = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS); this._caps.maxFragmentUniformVectors = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS); @@ -230,61 +123,26 @@ export class WebGL2Device extends Device { this._caps.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); this._caps.maxCubeMapTextureSize = gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE); this._caps.uboOffsetAlignment = gl.getParameter(gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT); - this._caps.depthBits = gl.getParameter(gl.DEPTH_BITS); - this._caps.stencilBits = gl.getParameter(gl.STENCIL_BITS); - // let maxVertexUniformBlocks = gl.getParameter(gl.MAX_VERTEX_UNIFORM_BLOCKS); - // let maxFragmentUniformBlocks = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_BLOCKS); - this.stateCache.initialize(this._caps.maxTextureUnits, this._caps.maxUniformBufferBindings, this._caps.maxVertexAttributes); - - this._devicePixelRatio = info.devicePixelRatio || 1.0; - this._width = info.width; - this._height = info.height; - - this._colorFmt = Format.RGBA8; - - if (this._caps.depthBits === 32) { - if (this._caps.stencilBits === 8) { - this._depthStencilFmt = Format.D32F_S8; - } else { - this._depthStencilFmt = Format.D32F; + const extensions = gl.getSupportedExtensions(); + let extStr = ''; + if (extensions) { + for (const ext of extensions) { + extStr += `${ext} `; } - } else if (this._caps.depthBits === 24) { - if (this._caps.stencilBits === 8) { - this._depthStencilFmt = Format.D24S8; - } else { - this._depthStencilFmt = Format.D24; - } - } else if (this._caps.stencilBits === 8) { - this._depthStencilFmt = Format.D16S8; + } + + const exts = getExtensions(gl); + + if (exts.WEBGL_debug_renderer_info) { + this._renderer = gl.getParameter(exts.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); + this._vendor = gl.getParameter(exts.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL); } else { - this._depthStencilFmt = Format.D16; + this._renderer = gl.getParameter(gl.RENDERER); + this._vendor = gl.getParameter(gl.VENDOR); } - this._extensions = gl.getSupportedExtensions(); - let extensions = ''; - if (this._extensions) { - for (const ext of this._extensions) { - extensions += `${ext} `; - } - - debug(`EXTENSIONS: ${extensions}`); - } - - this._EXT_texture_filter_anisotropic = this.getExtension('EXT_texture_filter_anisotropic'); - this._EXT_color_buffer_float = this.getExtension('EXT_color_buffer_float'); - this._EXT_disjoint_timer_query_webgl2 = this.getExtension('EXT_disjoint_timer_query_webgl2'); - this._OES_texture_float_linear = this.getExtension('OES_texture_float_linear'); - this._OES_texture_half_float_linear = this.getExtension('OES_texture_half_float_linear'); - this._WEBGL_compressed_texture_etc1 = this.getExtension('WEBGL_compressed_texture_etc1'); - this._WEBGL_compressed_texture_etc = this.getExtension('WEBGL_compressed_texture_etc'); - this._WEBGL_compressed_texture_pvrtc = this.getExtension('WEBGL_compressed_texture_pvrtc'); - this._WEBGL_compressed_texture_astc = this.getExtension('WEBGL_compressed_texture_astc'); - this._WEBGL_compressed_texture_s3tc = this.getExtension('WEBGL_compressed_texture_s3tc'); - this._WEBGL_compressed_texture_s3tc_srgb = this.getExtension('WEBGL_compressed_texture_s3tc_srgb'); - this._WEBGL_texture_storage_multisample = this.getExtension('WEBGL_texture_storage_multisample'); - this._WEBGL_debug_shaders = this.getExtension('WEBGL_debug_shaders'); - this._WEBGL_lose_context = this.getExtension('WEBGL_lose_context'); + const version: string = gl.getParameter(gl.VERSION); this._features.fill(false); this._features[Feature.TEXTURE_FLOAT] = true; @@ -297,138 +155,57 @@ export class WebGL2Device extends Device { this._features[Feature.MULTIPLE_RENDER_TARGETS] = true; this._features[Feature.BLEND_MINMAX] = true; - if (this._EXT_color_buffer_float) { + if (exts.EXT_color_buffer_float) { this._features[Feature.COLOR_FLOAT] = true; this._features[Feature.COLOR_HALF_FLOAT] = true; } - if (this._OES_texture_float_linear) { + if (exts.OES_texture_float_linear) { this._features[Feature.TEXTURE_FLOAT_LINEAR] = true; } - if (this._OES_texture_half_float_linear) { + if (exts.OES_texture_half_float_linear) { this._features[Feature.TEXTURE_HALF_FLOAT_LINEAR] = true; } let compressedFormat = ''; - if (this._WEBGL_compressed_texture_etc1) { + if (exts.WEBGL_compressed_texture_etc1) { this._features[Feature.FORMAT_ETC1] = true; compressedFormat += 'etc1 '; } - if (this._WEBGL_compressed_texture_etc) { + if (exts.WEBGL_compressed_texture_etc) { this._features[Feature.FORMAT_ETC2] = true; compressedFormat += 'etc2 '; } - if (this._WEBGL_compressed_texture_s3tc) { + if (exts.WEBGL_compressed_texture_s3tc) { this._features[Feature.FORMAT_DXT] = true; compressedFormat += 'dxt '; } - if (this._WEBGL_compressed_texture_pvrtc) { + if (exts.WEBGL_compressed_texture_pvrtc) { this._features[Feature.FORMAT_PVRTC] = true; compressedFormat += 'pvrtc '; } - if (this._WEBGL_compressed_texture_astc) { + if (exts.WEBGL_compressed_texture_astc) { this._features[Feature.FORMAT_ASTC] = true; compressedFormat += 'astc '; } + debug('WebGL2 device initialized.'); debug(`RENDERER: ${this._renderer}`); debug(`VENDOR: ${this._vendor}`); - debug(`VERSION: ${this._version}`); - debug(`DPR: ${this._devicePixelRatio}`); - debug(`SCREEN_SIZE: ${this._width} x ${this._height}`); - debug(`MAX_VERTEX_ATTRIBS: ${this._caps.maxVertexAttributes}`); - debug(`MAX_VERTEX_UNIFORM_VECTORS: ${this._caps.maxVertexUniformVectors}`); - debug(`MAX_FRAGMENT_UNIFORM_VECTORS: ${this._caps.maxFragmentUniformVectors}`); - debug(`MAX_TEXTURE_IMAGE_UNITS: ${this._caps.maxTextureUnits}`); - debug(`MAX_VERTEX_TEXTURE_IMAGE_UNITS: ${this._caps.maxVertexTextureUnits}`); - debug(`MAX_UNIFORM_BUFFER_BINDINGS: ${this._caps.maxUniformBufferBindings}`); - debug(`MAX_UNIFORM_BLOCK_SIZE: ${this._caps.maxUniformBlockSize}`); - debug(`DEPTH_BITS: ${this._caps.depthBits}`); - debug(`STENCIL_BITS: ${this._caps.stencilBits}`); - debug(`UNIFORM_BUFFER_OFFSET_ALIGNMENT: ${this._caps.uboOffsetAlignment}`); - if (this._EXT_texture_filter_anisotropic) { - debug(`MAX_TEXTURE_MAX_ANISOTROPY_EXT: ${this._EXT_texture_filter_anisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT}`); - } - debug(`USE_VAO: ${this._useVAO}`); + debug(`VERSION: ${version}`); debug(`COMPRESSED_FORMAT: ${compressedFormat}`); - - // init states - this.initStates(gl); - - // create queue - this._queue = this.createQueue(new QueueInfo(QueueType.GRAPHICS)); - this._cmdBuff = this.createCommandBuffer(new CommandBufferInfo(this._queue)); - - // create default null texture - this.nullTex2D = this.createTexture(new TextureInfo( - TextureType.TEX2D, - TextureUsageBit.SAMPLED, - Format.RGBA8, - 2, - 2, - TextureFlagBit.GEN_MIPMAP, - )) as WebGL2Texture; - - this.nullTexCube = new WebGL2Texture(this); - this.nullTexCube.initialize(new TextureInfo( - TextureType.CUBE, - TextureUsageBit.SAMPLED, - Format.RGBA8, - 2, - 2, - TextureFlagBit.GEN_MIPMAP, - 6, - )); - - const nullTexRegion = new BufferTextureCopy(); - nullTexRegion.texExtent.width = 2; - nullTexRegion.texExtent.height = 2; - - const nullTexBuff = new Uint8Array(this.nullTex2D.size); - nullTexBuff.fill(0); - this.copyBuffersToTexture([nullTexBuff], this.nullTex2D, [nullTexRegion]); - - nullTexRegion.texSubres.layerCount = 6; - this.copyBuffersToTexture( - [nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff], - this.nullTexCube, [nullTexRegion], - ); + debug(`EXTENSIONS: ${extStr}`); return true; } public destroy (): void { - if (this._canvas && this._webGLContextLostHandler) { - this._canvas.removeEventListener(eventWebGLContextLost, this._webGLContextLostHandler); - this._webGLContextLostHandler = null; - } - - if (this.nullTex2D) { - this.nullTex2D.destroy(); - this.nullTex2D = null; - } - - if (this.nullTexCube) { - this.nullTexCube.destroy(); - this.nullTexCube = null; - } - - // for (let i = 0; i < this._primaries.length; i++) { - // this._primaries[i].destroy(); - // } - // this._nextPrimary = this._primaries.length = 0; - - // for (let i = 0; i < this._secondaries.length; i++) { - // this._secondaries[i].destroy(); - // } - // this._nextSecondary = this._secondaries.length = 0; - if (this._queue) { this._queue.destroy(); this._queue = null; @@ -439,26 +216,19 @@ export class WebGL2Device extends Device { this._cmdBuff = null; } - this._extensions = null; - - this._webGL2RC = null; - } - - public resize (width: number, height: number) { - if (this._width !== width || this._height !== height) { - debug(`Resizing device: ${width}x${height}`); - this._canvas!.width = width; - this._canvas!.height = height; - this._width = width; - this._height = height; + const it = this._samplers.values(); + let res = it.next(); + while (!res.done) { + (res.value as WebGL2Sampler).destroy(); + res = it.next(); } + + this._swapchain = null; } public flushCommands (cmdBuffs: CommandBuffer[]) {} - public acquire () { - this.cmdAllocator.releaseCmds(); - } + public acquire (swapchains: Swapchain[]) {} public present () { const queue = (this._queue as WebGL2Queue); @@ -471,123 +241,106 @@ export class WebGL2Device extends Device { public createCommandBuffer (info: CommandBufferInfo): CommandBuffer { // const Ctor = WebGLCommandBuffer; // opt to instant invocation const Ctor = info.type === CommandBufferType.PRIMARY ? WebGL2PrimaryCommandBuffer : WebGL2CommandBuffer; - const cmdBuff = new Ctor(this); - if (cmdBuff.initialize(info)) { - return cmdBuff; - } - return null!; + const cmdBuff = new Ctor(); + cmdBuff.initialize(info); + return cmdBuff; + } + + public createSwapchain (info: SwapchainInfo): Swapchain { + const swapchain = new WebGL2Swapchain(); + this._swapchain = swapchain; + swapchain.initialize(info); + return swapchain; } public createBuffer (info: BufferInfo | BufferViewInfo): Buffer { - const buffer = new WebGL2Buffer(this); - if (buffer.initialize(info)) { - return buffer; - } - return null!; + const buffer = new WebGL2Buffer(); + buffer.initialize(info); + return buffer; } public createTexture (info: TextureInfo | TextureViewInfo): Texture { - const texture = new WebGL2Texture(this); - if (texture.initialize(info)) { - return texture; - } - return null!; - } - - public createSampler (info: SamplerInfo): Sampler { - const sampler = new WebGL2Sampler(this); - if (sampler.initialize(info)) { - return sampler; - } - return null!; + const texture = new WebGL2Texture(); + texture.initialize(info); + return texture; } public createDescriptorSet (info: DescriptorSetInfo): DescriptorSet { - const descriptorSet = new WebGL2DescriptorSet(this); - if (descriptorSet.initialize(info)) { - return descriptorSet; - } - return null!; + const descriptorSet = new WebGL2DescriptorSet(); + descriptorSet.initialize(info); + return descriptorSet; } public createShader (info: ShaderInfo): Shader { - const shader = new WebGL2Shader(this); - if (shader.initialize(info)) { - return shader; - } - return null!; + const shader = new WebGL2Shader(); + shader.initialize(info); + return shader; } public createInputAssembler (info: InputAssemblerInfo): InputAssembler { - const inputAssembler = new WebGL2InputAssembler(this); - if (inputAssembler.initialize(info)) { - return inputAssembler; - } - return null!; + const inputAssembler = new WebGL2InputAssembler(); + inputAssembler.initialize(info); + return inputAssembler; } public createRenderPass (info: RenderPassInfo): RenderPass { - const renderPass = new WebGL2RenderPass(this); - if (renderPass.initialize(info)) { - return renderPass; - } - return null!; + const renderPass = new WebGL2RenderPass(); + renderPass.initialize(info); + return renderPass; } public createFramebuffer (info: FramebufferInfo): Framebuffer { - const framebuffer = new WebGL2Framebuffer(this); - if (framebuffer.initialize(info)) { - return framebuffer; - } - return null!; + const framebuffer = new WebGL2Framebuffer(); + framebuffer.initialize(info); + return framebuffer; } public createDescriptorSetLayout (info: DescriptorSetLayoutInfo): DescriptorSetLayout { - const descriptorSetLayout = new WebGL2DescriptorSetLayout(this); - if (descriptorSetLayout.initialize(info)) { - return descriptorSetLayout; - } - return null!; + const descriptorSetLayout = new WebGL2DescriptorSetLayout(); + descriptorSetLayout.initialize(info); + return descriptorSetLayout; } public createPipelineLayout (info: PipelineLayoutInfo): PipelineLayout { - const pipelineLayout = new WebGL2PipelineLayout(this); - if (pipelineLayout.initialize(info)) { - return pipelineLayout; - } - return null!; + const pipelineLayout = new WebGL2PipelineLayout(); + pipelineLayout.initialize(info); + return pipelineLayout; } public createPipelineState (info: PipelineStateInfo): PipelineState { - const pipelineState = new WebGL2PipelineState(this); - if (pipelineState.initialize(info)) { - return pipelineState; - } - return null!; + const pipelineState = new WebGL2PipelineState(); + pipelineState.initialize(info); + return pipelineState; } public createQueue (info: QueueInfo): Queue { - const queue = new WebGL2Queue(this); - if (queue.initialize(info)) { - return queue; - } - return null!; + const queue = new WebGL2Queue(); + queue.initialize(info); + return queue; } - public createGlobalBarrier (info: GlobalBarrierInfo) { - const barrier = new GlobalBarrier(this); - if (barrier.initialize(info)) { - return barrier; + public getSampler (info: SamplerInfo): Sampler { + const hash = Sampler.computeHash(info); + if (!this._samplers.has(hash)) { + this._samplers.set(hash, new WebGL2Sampler(info)); } - return null!; + return this._samplers.get(hash)!; } - public createTextureBarrier (info: TextureBarrierInfo) { - const barrier = new TextureBarrier(this); - if (barrier.initialize(info)) { - return barrier; + public getGlobalBarrier (info: GlobalBarrierInfo) { + const hash = GlobalBarrier.computeHash(info); + if (!this._globalBarriers.has(hash)) { + this._globalBarriers.set(hash, new GlobalBarrier(info)); } - return null!; + return this._globalBarriers.get(hash)!; + } + + public getTextureBarrier (info: TextureBarrierInfo) { + const hash = TextureBarrier.computeHash(info); + if (!this._textureBarriers.has(hash)) { + this._textureBarriers.set(hash, new TextureBarrier(info)); + } + return this._textureBarriers.get(hash)!; } public copyBuffersToTexture (buffers: ArrayBufferView[], texture: Texture, regions: BufferTextureCopy[]) { @@ -620,109 +373,4 @@ export class WebGL2Device extends Device { regions, ); } - - public copyFramebufferToBuffer ( - srcFramebuffer: Framebuffer, - dstBuffer: ArrayBuffer, - regions: BufferTextureCopy[], - ) { - const gl = this._webGL2RC as WebGL2RenderingContext; - const gpuFramebuffer = (srcFramebuffer as WebGL2Framebuffer).gpuFramebuffer; - const format = gpuFramebuffer.gpuColorTextures[0].format; - const glFormat = GFXFormatToWebGLFormat(format, gl); - const glType = GFXFormatToWebGLType(format, gl); - const Ctor = getTypedArrayConstructor(FormatInfos[format]); - - const curFBO = this.stateCache.glFramebuffer; - - if (this.stateCache.glFramebuffer !== gpuFramebuffer.glFramebuffer) { - gl.bindFramebuffer(gl.FRAMEBUFFER, gpuFramebuffer.glFramebuffer); - this.stateCache.glFramebuffer = gpuFramebuffer.glFramebuffer; - } - - const view = new Ctor(dstBuffer); - - for (const region of regions) { - const w = region.texExtent.width; - const h = region.texExtent.height; - - gl.readPixels(region.texOffset.x, region.texOffset.y, w, h, glFormat, glType, view); - } - - if (this.stateCache.glFramebuffer !== curFBO) { - gl.bindFramebuffer(gl.FRAMEBUFFER, curFBO); - this.stateCache.glFramebuffer = curFBO; - } - } - - public blitFramebuffer (src: Framebuffer, dst: Framebuffer, srcRect: Rect, dstRect: Rect, filter: Filter) { - const srcFBO = (src as WebGL2Framebuffer).gpuFramebuffer; - const dstFBO = (dst as WebGL2Framebuffer).gpuFramebuffer; - - WebGL2CmdFuncBlitFramebuffer( - this, - srcFBO, - dstFBO, - srcRect, - dstRect, - filter, - ); - } - - private getExtension (ext: string): any { - const prefixes = ['', 'WEBKIT_', 'MOZ_']; - for (let i = 0; i < prefixes.length; ++i) { - const _ext = this.gl.getExtension(prefixes[i] + ext); - if (_ext) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return _ext; - } - } - return null; - } - - private initStates (gl: WebGL2RenderingContext) { - gl.activeTexture(gl.TEXTURE0); - gl.pixelStorei(gl.PACK_ALIGNMENT, 1); - gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); - - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - - // rasterizer state - gl.enable(gl.SCISSOR_TEST); - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.BACK); - gl.frontFace(gl.CCW); - gl.polygonOffset(0.0, 0.0); - - // depth stencil state - gl.enable(gl.DEPTH_TEST); - gl.depthMask(true); - gl.depthFunc(gl.LESS); - - gl.stencilFuncSeparate(gl.FRONT, gl.ALWAYS, 1, 0xffff); - gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.KEEP); - gl.stencilMaskSeparate(gl.FRONT, 0xffff); - gl.stencilFuncSeparate(gl.BACK, gl.ALWAYS, 1, 0xffff); - gl.stencilOpSeparate(gl.BACK, gl.KEEP, gl.KEEP, gl.KEEP); - gl.stencilMaskSeparate(gl.BACK, 0xffff); - - gl.disable(gl.STENCIL_TEST); - - // blend state - gl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE); - gl.disable(gl.BLEND); - gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD); - gl.blendFuncSeparate(gl.ONE, gl.ZERO, gl.ONE, gl.ZERO); - gl.colorMask(true, true, true, true); - gl.blendColor(0.0, 0.0, 0.0, 0.0); - } - - private _onWebGLContextLost (event: Event) { - warnID(11000); - warn(event); - // 2020.9.3: `preventDefault` is not available on some platforms - // event.preventDefault(); - } } diff --git a/cocos/core/gfx/webgl2/webgl2-framebuffer.ts b/cocos/core/gfx/webgl2/webgl2-framebuffer.ts index 0246033b04..19836bb3e9 100644 --- a/cocos/core/gfx/webgl2/webgl2-framebuffer.ts +++ b/cocos/core/gfx/webgl2/webgl2-framebuffer.ts @@ -26,7 +26,7 @@ import { FramebufferInfo } from '../base/define'; import { Framebuffer } from '../base/framebuffer'; import { WebGL2CmdFuncCreateFramebuffer, WebGL2CmdFuncDestroyFramebuffer } from './webgl2-commands'; -import { WebGL2Device } from './webgl2-device'; +import { WebGL2DeviceManager } from './webgl2-define'; import { IWebGL2GPUFramebuffer, IWebGL2GPUTexture } from './webgl2-gpu-objects'; import { WebGL2RenderPass } from './webgl2-render-pass'; import { WebGL2Texture } from './webgl2-texture'; @@ -38,7 +38,7 @@ export class WebGL2Framebuffer extends Framebuffer { private _gpuFramebuffer: IWebGL2GPUFramebuffer | null = null; - public initialize (info: FramebufferInfo): boolean { + public initialize (info: FramebufferInfo) { this._renderPass = info.renderPass; this._colorTextures = info.colorTextures || []; this._depthStencilTexture = info.depthStencilTexture || null; @@ -63,14 +63,12 @@ export class WebGL2Framebuffer extends Framebuffer { glFramebuffer: null, }; - WebGL2CmdFuncCreateFramebuffer(this._device as WebGL2Device, this._gpuFramebuffer); - - return true; + WebGL2CmdFuncCreateFramebuffer(WebGL2DeviceManager.instance, this._gpuFramebuffer); } public destroy () { if (this._gpuFramebuffer) { - WebGL2CmdFuncDestroyFramebuffer(this._device as WebGL2Device, this._gpuFramebuffer); + WebGL2CmdFuncDestroyFramebuffer(WebGL2DeviceManager.instance, this._gpuFramebuffer); this._gpuFramebuffer = null; } } diff --git a/cocos/core/gfx/webgl2/webgl2-gpu-objects.ts b/cocos/core/gfx/webgl2/webgl2-gpu-objects.ts index 1c35014c10..cb6213770c 100644 --- a/cocos/core/gfx/webgl2/webgl2-gpu-objects.ts +++ b/cocos/core/gfx/webgl2/webgl2-gpu-objects.ts @@ -23,6 +23,7 @@ THE SOFTWARE. */ +import { nextPow2 } from '../../math/bits'; import { Address, DescriptorType, BufferUsage, Filter, Format, MemoryUsage, SampleCount, ShaderStageFlagBit, TextureFlags, TextureType, TextureUsage, Type, DynamicStateFlagBit, DrawInfo, Attribute, @@ -30,6 +31,67 @@ import { } from '../base/define'; import { BlendState, DepthStencilState, RasterizerState } from '../base/pipeline-state'; +export class WebGL2IndirectDrawInfos { + public counts: Int32Array; + public offsets: Int32Array; + public instances: Int32Array; + public drawCount = 0; + public drawByIndex = false; + public instancedDraw = false; + + // staging buffer + public byteOffsets: Int32Array; + + private _capacity = 4; + + constructor () { + this.counts = new Int32Array(this._capacity); + this.offsets = new Int32Array(this._capacity); + this.instances = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); + } + + public clearDraws () { + this.drawCount = 0; + this.drawByIndex = false; + this.instancedDraw = false; + } + + public setDrawInfo (idx: number, info: DrawInfo) { + this._ensureCapacity(idx); + this.drawByIndex = info.indexCount > 0; + this.instancedDraw = info.instanceCount > 1; + this.drawCount = Math.max(idx + 1, this.drawCount); + + if (this.drawByIndex) { + this.counts[idx] = info.indexCount; + this.offsets[idx] = info.firstIndex; + } else { + this.counts[idx] = info.vertexCount; + this.offsets[idx] = info.firstVertex; + } + this.instances[idx] = Math.max(1, info.instanceCount); + } + + private _ensureCapacity (target: number) { + if (this._capacity > target) return; + this._capacity = nextPow2(target); + + const counts = new Int32Array(this._capacity); + const offsets = new Int32Array(this._capacity); + const instances = new Int32Array(this._capacity); + this.byteOffsets = new Int32Array(this._capacity); + + counts.set(this.counts); + offsets.set(this.offsets); + instances.set(this.instances); + + this.counts = counts; + this.offsets = offsets; + this.instances = instances; + } +} + export interface IWebGL2GPUUniformInfo { name: string; type: Type; @@ -50,7 +112,7 @@ export interface IWebGL2GPUBuffer { glOffset: number; buffer: ArrayBufferView | null; - indirects: DrawInfo[]; + indirects: WebGL2IndirectDrawInfos; } export interface IWebGL2GPUTexture { @@ -78,6 +140,8 @@ export interface IWebGL2GPUTexture { glWrapT: GLenum; glMinFilter: GLenum; glMagFilter: GLenum; + + isSwapchainTexture: boolean; } export interface IWebGL2GPURenderPass { diff --git a/cocos/core/gfx/webgl2/webgl2-input-assembler.ts b/cocos/core/gfx/webgl2/webgl2-input-assembler.ts index ad596d332c..1eb8ffe851 100644 --- a/cocos/core/gfx/webgl2/webgl2-input-assembler.ts +++ b/cocos/core/gfx/webgl2/webgl2-input-assembler.ts @@ -27,7 +27,7 @@ import { InputAssemblerInfo } from '../base/define'; import { InputAssembler } from '../base/input-assembler'; import { WebGL2Buffer } from './webgl2-buffer'; import { WebGL2CmdFuncCreateInputAssember, WebGL2CmdFuncDestroyInputAssembler } from './webgl2-commands'; -import { WebGL2Device } from './webgl2-device'; +import { WebGL2DeviceManager } from './webgl2-define'; import { IWebGL2GPUInputAssembler, IWebGL2GPUBuffer } from './webgl2-gpu-objects'; export class WebGL2InputAssembler extends InputAssembler { @@ -37,10 +37,10 @@ export class WebGL2InputAssembler extends InputAssembler { private _gpuInputAssembler: IWebGL2GPUInputAssembler | null = null; - public initialize (info: InputAssemblerInfo): boolean { + public initialize (info: InputAssemblerInfo) { if (info.vertexBuffers.length === 0) { console.error('InputAssemblerInfo.vertexBuffers is null.'); - return false; + return; } this._attributes = info.attributes; @@ -49,16 +49,16 @@ export class WebGL2InputAssembler extends InputAssembler { if (info.indexBuffer) { this._indexBuffer = info.indexBuffer; - this._indexCount = this._indexBuffer.size / this._indexBuffer.stride; - this._firstIndex = 0; + this._drawInfo.indexCount = this._indexBuffer.size / this._indexBuffer.stride; + this._drawInfo.firstIndex = 0; } else { const vertBuff = this._vertexBuffers[0]; - this._vertexCount = vertBuff.size / vertBuff.stride; - this._firstVertex = 0; - this._vertexOffset = 0; + this._drawInfo.vertexCount = vertBuff.size / vertBuff.stride; + this._drawInfo.firstVertex = 0; + this._drawInfo.vertexOffset = 0; } - this._instanceCount = 0; - this._firstInstance = 0; + this._drawInfo.instanceCount = 0; + this._drawInfo.firstInstance = 0; this._indirectBuffer = info.indirectBuffer || null; @@ -102,15 +102,13 @@ export class WebGL2InputAssembler extends InputAssembler { glVAOs: new Map(), }; - WebGL2CmdFuncCreateInputAssember(this._device as WebGL2Device, this._gpuInputAssembler); - - return true; + WebGL2CmdFuncCreateInputAssember(WebGL2DeviceManager.instance, this._gpuInputAssembler); } public destroy () { - const webgl2Dev = this._device as WebGL2Device; - if (this._gpuInputAssembler && webgl2Dev.useVAO) { - WebGL2CmdFuncDestroyInputAssembler(webgl2Dev, this._gpuInputAssembler); + const device = WebGL2DeviceManager.instance; + if (this._gpuInputAssembler && device.extensions.useVAO) { + WebGL2CmdFuncDestroyInputAssembler(device, this._gpuInputAssembler); } this._gpuInputAssembler = null; } diff --git a/cocos/core/gfx/webgl2/webgl2-pipeline-layout.ts b/cocos/core/gfx/webgl2/webgl2-pipeline-layout.ts index 73fa325cf7..b2b73fef7f 100644 --- a/cocos/core/gfx/webgl2/webgl2-pipeline-layout.ts +++ b/cocos/core/gfx/webgl2/webgl2-pipeline-layout.ts @@ -62,8 +62,6 @@ export class WebGL2PipelineLayout extends PipelineLayout { dynamicOffsetCount, dynamicOffsetOffsets, }; - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl2/webgl2-pipeline-state.ts b/cocos/core/gfx/webgl2/webgl2-pipeline-state.ts index b6479a53d5..d045df52fa 100644 --- a/cocos/core/gfx/webgl2/webgl2-pipeline-state.ts +++ b/cocos/core/gfx/webgl2/webgl2-pipeline-state.ts @@ -54,7 +54,7 @@ export class WebGL2PipelineState extends PipelineState { private _gpuPipelineState: IWebGL2GPUPipelineState | null = null; - public initialize (info: PipelineStateInfo): boolean { + public initialize (info: PipelineStateInfo) { this._primitive = info.primitive; this._shader = info.shader; this._pipelineLayout = info.pipelineLayout; @@ -95,8 +95,6 @@ export class WebGL2PipelineState extends PipelineState { gpuRenderPass: (info.renderPass as WebGL2RenderPass).gpuRenderPass, dynamicStates, }; - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl2/webgl2-primary-command-buffer.ts b/cocos/core/gfx/webgl2/webgl2-primary-command-buffer.ts index 084f937000..29aebe5d65 100644 --- a/cocos/core/gfx/webgl2/webgl2-primary-command-buffer.ts +++ b/cocos/core/gfx/webgl2/webgl2-primary-command-buffer.ts @@ -34,11 +34,11 @@ import { WebGL2CommandBuffer } from './webgl2-command-buffer'; import { WebGL2CmdFuncBeginRenderPass, WebGL2CmdFuncBindStates, WebGL2CmdFuncCopyBuffersToTexture, WebGL2CmdFuncDraw, WebGL2CmdFuncExecuteCmds, WebGL2CmdFuncUpdateBuffer } from './webgl2-commands'; -import { WebGL2Device } from './webgl2-device'; import { WebGL2Framebuffer } from './webgl2-framebuffer'; import { WebGL2Texture } from './webgl2-texture'; import { RenderPass } from '../base/render-pass'; import { WebGL2RenderPass } from './webgl2-render-pass'; +import { WebGL2DeviceManager } from './webgl2-define'; export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { public beginRenderPass ( @@ -50,7 +50,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { clearStencil: number, ) { WebGL2CmdFuncBeginRenderPass( - this._device as WebGL2Device, + WebGL2DeviceManager.instance, (renderPass as WebGL2RenderPass).gpuRenderPass, (framebuffer as WebGL2Framebuffer).gpuFramebuffer, renderArea, clearColors, clearDepth, clearStencil, @@ -58,13 +58,15 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { this._isInRenderPass = true; } - public draw (info: DrawInfo | InputAssembler) { + public draw (infoOrAssembler: DrawInfo | InputAssembler) { if (this._isInRenderPass) { if (this._isStateInvalied) { this.bindStates(); } - WebGL2CmdFuncDraw(this._device as WebGL2Device, info as DrawInfo); + const info = 'drawInfo' in infoOrAssembler ? infoOrAssembler.drawInfo : infoOrAssembler; + + WebGL2CmdFuncDraw(WebGL2DeviceManager.instance, info as DrawInfo); ++this._numDrawCalls; this._numInstances += info.instanceCount; @@ -102,7 +104,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { buffSize = (data as ArrayBuffer).byteLength; } - WebGL2CmdFuncUpdateBuffer(this._device as WebGL2Device, gpuBuffer, data as ArrayBuffer, 0, buffSize); + WebGL2CmdFuncUpdateBuffer(WebGL2DeviceManager.instance, gpuBuffer, data as ArrayBuffer, 0, buffSize); } } else { console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); @@ -113,7 +115,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { if (!this._isInRenderPass) { const gpuTexture = (texture as WebGL2Texture).gpuTexture; if (gpuTexture) { - WebGL2CmdFuncCopyBuffersToTexture(this._device as WebGL2Device, buffers, gpuTexture, regions); + WebGL2CmdFuncCopyBuffersToTexture(WebGL2DeviceManager.instance, buffers, gpuTexture, regions); } } else { console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); @@ -124,7 +126,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { for (let i = 0; i < count; ++i) { // actually they are secondary buffers, the cast here is only for type checking const webGL2CmdBuff = cmdBuffs[i] as WebGL2PrimaryCommandBuffer; - WebGL2CmdFuncExecuteCmds(this._device as WebGL2Device, webGL2CmdBuff.cmdPackage); + WebGL2CmdFuncExecuteCmds(WebGL2DeviceManager.instance, webGL2CmdBuff.cmdPackage); this._numDrawCalls += webGL2CmdBuff._numDrawCalls; this._numInstances += webGL2CmdBuff._numInstances; this._numTris += webGL2CmdBuff._numTris; @@ -132,7 +134,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { } protected bindStates () { - WebGL2CmdFuncBindStates(this._device as WebGL2Device, this._curGPUPipelineState, this._curGPUInputAssembler, + WebGL2CmdFuncBindStates(WebGL2DeviceManager.instance, this._curGPUPipelineState, this._curGPUInputAssembler, this._curGPUDescriptorSets, this._curDynamicOffsets, this._curDynamicStates); this._isStateInvalied = false; } diff --git a/cocos/core/gfx/webgl2/webgl2-queue.ts b/cocos/core/gfx/webgl2/webgl2-queue.ts index a1bed026e7..41db5dd27b 100644 --- a/cocos/core/gfx/webgl2/webgl2-queue.ts +++ b/cocos/core/gfx/webgl2/webgl2-queue.ts @@ -33,25 +33,20 @@ export class WebGL2Queue extends Queue { public numInstances = 0; public numTris = 0; - public initialize (info: QueueInfo): boolean { + public initialize (info: QueueInfo) { this._type = info.type; - - return true; } public destroy () { } public submit (cmdBuffs: CommandBuffer[]) { - // TODO: Async - if (!this._isAsync) { - for (let i = 0; i < cmdBuffs.length; i++) { - const cmdBuff = cmdBuffs[i] as WebGL2CommandBuffer; - // WebGL2CmdFuncExecuteCmds(this._device as WebGL2Device, cmdBuff.cmdPackage); // opted out - this.numDrawCalls += cmdBuff.numDrawCalls; - this.numInstances += cmdBuff.numInstances; - this.numTris += cmdBuff.numTris; - } + for (let i = 0; i < cmdBuffs.length; i++) { + const cmdBuff = cmdBuffs[i] as WebGL2CommandBuffer; + // WebGL2CmdFuncExecuteCmds(this._device as WebGL2Device, cmdBuff.cmdPackage); // opted out + this.numDrawCalls += cmdBuff.numDrawCalls; + this.numInstances += cmdBuff.numInstances; + this.numTris += cmdBuff.numTris; } } diff --git a/cocos/core/gfx/webgl2/webgl2-render-pass.ts b/cocos/core/gfx/webgl2/webgl2-render-pass.ts index 9b145ad4de..ce55acb833 100644 --- a/cocos/core/gfx/webgl2/webgl2-render-pass.ts +++ b/cocos/core/gfx/webgl2/webgl2-render-pass.ts @@ -34,12 +34,10 @@ export class WebGL2RenderPass extends RenderPass { private _gpuRenderPass: IWebGL2GPURenderPass | null = null; - public initialize (info: RenderPassInfo): boolean { + public initialize (info: RenderPassInfo) { this._colorInfos = info.colorAttachments; this._depthStencilInfo = info.depthStencilAttachment; - if (info.subpasses) { - this._subpasses = info.subpasses; - } + this._subpasses = info.subpasses; this._gpuRenderPass = { colorAttachments: this._colorInfos, @@ -47,8 +45,6 @@ export class WebGL2RenderPass extends RenderPass { }; this._hash = this.computeHash(); - - return true; } public destroy () { diff --git a/cocos/core/gfx/webgl2/webgl2-shader.ts b/cocos/core/gfx/webgl2/webgl2-shader.ts index 873ed096d9..57d793b8b8 100644 --- a/cocos/core/gfx/webgl2/webgl2-shader.ts +++ b/cocos/core/gfx/webgl2/webgl2-shader.ts @@ -26,7 +26,7 @@ import { ShaderInfo } from '../base/define'; import { Shader } from '../base/shader'; import { WebGL2CmdFuncCreateShader, WebGL2CmdFuncDestroyShader } from './webgl2-commands'; -import { WebGL2Device } from './webgl2-device'; +import { WebGL2DeviceManager } from './webgl2-define'; import { IWebGL2GPUShader, IWebGL2GPUShaderStage } from './webgl2-gpu-objects'; export class WebGL2Shader extends Shader { @@ -36,7 +36,7 @@ export class WebGL2Shader extends Shader { private _gpuShader: IWebGL2GPUShader | null = null; - public initialize (info: ShaderInfo): boolean { + public initialize (info: ShaderInfo) { this._name = info.name; this._stages = info.stages; this._attributes = info.attributes; @@ -65,14 +65,12 @@ export class WebGL2Shader extends Shader { }; } - WebGL2CmdFuncCreateShader(this._device as WebGL2Device, this._gpuShader); - - return true; + WebGL2CmdFuncCreateShader(WebGL2DeviceManager.instance, this._gpuShader); } public destroy () { if (this._gpuShader) { - WebGL2CmdFuncDestroyShader(this._device as WebGL2Device, this._gpuShader); + WebGL2CmdFuncDestroyShader(WebGL2DeviceManager.instance, this._gpuShader); this._gpuShader = null; } } diff --git a/cocos/core/gfx/webgl2/webgl2-swapchain.ts b/cocos/core/gfx/webgl2/webgl2-swapchain.ts new file mode 100644 index 0000000000..9c4c3fe08e --- /dev/null +++ b/cocos/core/gfx/webgl2/webgl2-swapchain.ts @@ -0,0 +1,264 @@ +/* + 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 { EDITOR } from 'internal:constants'; +import { macro, warnID, warn, debug } from '../../platform'; +import { WebGL2StateCache } from './webgl2-state-cache'; +import { WebGL2Texture } from './webgl2-texture'; +import { Format, TextureInfo, TextureFlagBit, TextureType, TextureUsageBit, BufferTextureCopy, SwapchainInfo } from '../base/define'; +import { Swapchain } from '../base/swapchain'; +import { IWebGL2Extensions, WebGL2DeviceManager } from './webgl2-define'; + +const eventWebGLContextLost = 'webglcontextlost'; + +function initStates (gl: WebGL2RenderingContext) { + gl.activeTexture(gl.TEXTURE0); + gl.pixelStorei(gl.PACK_ALIGNMENT, 1); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); + + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + + // rasterizer state + gl.enable(gl.SCISSOR_TEST); + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.BACK); + gl.frontFace(gl.CCW); + gl.polygonOffset(0.0, 0.0); + + // depth stencil state + gl.enable(gl.DEPTH_TEST); + gl.depthMask(true); + gl.depthFunc(gl.LESS); + + gl.stencilFuncSeparate(gl.FRONT, gl.ALWAYS, 1, 0xffff); + gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.KEEP); + gl.stencilMaskSeparate(gl.FRONT, 0xffff); + gl.stencilFuncSeparate(gl.BACK, gl.ALWAYS, 1, 0xffff); + gl.stencilOpSeparate(gl.BACK, gl.KEEP, gl.KEEP, gl.KEEP); + gl.stencilMaskSeparate(gl.BACK, 0xffff); + + gl.disable(gl.STENCIL_TEST); + + // blend state + gl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE); + gl.disable(gl.BLEND); + gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD); + gl.blendFuncSeparate(gl.ONE, gl.ZERO, gl.ONE, gl.ZERO); + gl.colorMask(true, true, true, true); + gl.blendColor(0.0, 0.0, 0.0, 0.0); +} + +function getExtension (gl: WebGL2RenderingContext, ext: string): any { + const prefixes = ['', 'WEBKIT_', 'MOZ_']; + for (let i = 0; i < prefixes.length; ++i) { + const _ext = gl.getExtension(prefixes[i] + ext); + if (_ext) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return _ext; + } + } + return null; +} + +export function getExtensions (gl: WebGL2RenderingContext) { + const res: IWebGL2Extensions = { + EXT_texture_filter_anisotropic: getExtension(gl, 'EXT_texture_filter_anisotropic'), + EXT_color_buffer_half_float: getExtension(gl, 'EXT_color_buffer_half_float'), + EXT_color_buffer_float: getExtension(gl, 'EXT_color_buffer_float'), + WEBGL_multi_draw: getExtension(gl, 'WEBGL_multi_draw'), + WEBGL_compressed_texture_etc1: getExtension(gl, 'WEBGL_compressed_texture_etc1'), + WEBGL_compressed_texture_etc: getExtension(gl, 'WEBGL_compressed_texture_etc'), + WEBGL_compressed_texture_pvrtc: getExtension(gl, 'WEBGL_compressed_texture_pvrtc'), + WEBGL_compressed_texture_astc: getExtension(gl, 'WEBGL_compressed_texture_astc'), + WEBGL_compressed_texture_s3tc: getExtension(gl, 'WEBGL_compressed_texture_s3tc'), + WEBGL_compressed_texture_s3tc_srgb: getExtension(gl, 'WEBGL_compressed_texture_s3tc_srgb'), + WEBGL_debug_shaders: getExtension(gl, 'WEBGL_debug_shaders'), + WEBGL_lose_context: getExtension(gl, 'WEBGL_lose_context'), + WEBGL_debug_renderer_info: getExtension(gl, 'WEBGL_debug_renderer_info'), + OES_texture_half_float_linear: getExtension(gl, 'OES_texture_half_float_linear'), + OES_texture_float_linear: getExtension(gl, 'OES_texture_float_linear'), + useVAO: true, + }; + + return res; +} + +export class WebGL2Swapchain extends Swapchain { + get gl () { + return this._webGL2RC as WebGL2RenderingContext; + } + + get extensions () { + return this._extensions as IWebGL2Extensions; + } + + public stateCache: WebGL2StateCache = new WebGL2StateCache(); + public nullTex2D: WebGL2Texture = null!; + public nullTexCube: WebGL2Texture = null!; + + private _canvas: HTMLCanvasElement | null = null; + private _webGL2RC: WebGL2RenderingContext | null = null; + private _webGL2ContextLostHandler: ((event: Event) => void) | null = null; + private _extensions: IWebGL2Extensions | null = null; + + public initialize (info: SwapchainInfo) { + this._canvas = info.windowHandle; + + try { + const webGLCtxAttribs: WebGLContextAttributes = { + alpha: macro.ENABLE_TRANSPARENT_CANVAS, + antialias: EDITOR || macro.ENABLE_WEBGL_ANTIALIAS, + depth: true, + stencil: true, + premultipliedAlpha: false, + preserveDrawingBuffer: false, + powerPreference: 'default', + failIfMajorPerformanceCaveat: false, + }; + + this._webGL2RC = this._canvas.getContext('webgl2', webGLCtxAttribs); + } catch (err) { + return; + } + + if (!this._webGL2RC) { + return; + } + + this._webGL2ContextLostHandler = this._onWebGLContextLost.bind(this); + this._canvas.addEventListener(eventWebGLContextLost, this._onWebGLContextLost); + + const gl = this.gl; + + this.stateCache.initialize( + WebGL2DeviceManager.instance.capabilities.maxTextureUnits, + WebGL2DeviceManager.instance.capabilities.maxUniformBufferBindings, + WebGL2DeviceManager.instance.capabilities.maxVertexAttributes, + ); + + this._extensions = getExtensions(gl); + + // init states + initStates(gl); + + const colorFmt = Format.RGBA8; + let depthStencilFmt = Format.UNKNOWN; + + const depthBits = gl.getParameter(gl.DEPTH_BITS); + const stencilBits = gl.getParameter(gl.STENCIL_BITS); + + if (depthBits && stencilBits) depthStencilFmt = Format.DEPTH_STENCIL; + else if (depthBits) depthStencilFmt = Format.DEPTH; + + this._colorTexture = new WebGL2Texture(); + // @ts-expect-error(2445) private initializer + this._colorTexture.initAsSwapchainTexture({ + swapchain: this, + format: colorFmt, + width: info.width, + height: info.height, + }); + + this._depthStencilTexture = new WebGL2Texture(); + // @ts-expect-error(2445) private initializer + this._depthStencilTexture.initAsSwapchainTexture({ + swapchain: this, + format: depthStencilFmt, + width: info.width, + height: info.height, + }); + + // create default null texture + this.nullTex2D = WebGL2DeviceManager.instance.createTexture(new TextureInfo( + TextureType.TEX2D, + TextureUsageBit.SAMPLED, + Format.RGBA8, + 2, + 2, + TextureFlagBit.GEN_MIPMAP, + )) as WebGL2Texture; + + this.nullTexCube = WebGL2DeviceManager.instance.createTexture(new TextureInfo( + TextureType.CUBE, + TextureUsageBit.SAMPLED, + Format.RGBA8, + 2, + 2, + TextureFlagBit.GEN_MIPMAP, + 6, + )) as WebGL2Texture; + + const nullTexRegion = new BufferTextureCopy(); + nullTexRegion.texExtent.width = 2; + nullTexRegion.texExtent.height = 2; + + const nullTexBuff = new Uint8Array(this.nullTex2D.size); + nullTexBuff.fill(0); + WebGL2DeviceManager.instance.copyBuffersToTexture([nullTexBuff], this.nullTex2D, [nullTexRegion]); + + nullTexRegion.texSubres.layerCount = 6; + WebGL2DeviceManager.instance.copyBuffersToTexture( + [nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff, nullTexBuff], + this.nullTexCube, [nullTexRegion], + ); + } + + public destroy (): void { + if (this._canvas && this._webGL2ContextLostHandler) { + this._canvas.removeEventListener(eventWebGLContextLost, this._webGL2ContextLostHandler); + this._webGL2ContextLostHandler = null; + } + + if (this.nullTex2D) { + this.nullTex2D.destroy(); + this.nullTex2D = null!; + } + + if (this.nullTexCube) { + this.nullTexCube.destroy(); + this.nullTexCube = null!; + } + + this._extensions = null; + this._webGL2RC = null; + this._canvas = null; + } + + public resize (width: number, height: number) { + if (this._canvas!.width !== width || this._canvas!.height !== height) { + debug(`Resizing swapchain: ${width}x${height}`); + this._canvas!.width = width; + this._canvas!.height = height; + } + } + + private _onWebGLContextLost (event: Event) { + warnID(11000); + warn(event); + // 2020.9.3: `preventDefault` is not available on some platforms + // event.preventDefault(); + } +} diff --git a/cocos/core/gfx/webgl2/webgl2-texture.ts b/cocos/core/gfx/webgl2/webgl2-texture.ts index d7b9c89dac..ec50d5540b 100644 --- a/cocos/core/gfx/webgl2/webgl2-texture.ts +++ b/cocos/core/gfx/webgl2/webgl2-texture.ts @@ -23,10 +23,11 @@ THE SOFTWARE. */ -import { TextureFlagBit, FormatSurfaceSize, TextureInfo, IsPowerOf2, TextureViewInfo } from '../base/define'; +import { FormatSurfaceSize, TextureInfo, IsPowerOf2, TextureViewInfo, ISwapchainTextureInfo, + FormatInfos, TextureUsageBit, TextureFlagBit } from '../base/define'; import { Texture } from '../base/texture'; import { WebGL2CmdFuncCreateTexture, WebGL2CmdFuncDestroyTexture, WebGL2CmdFuncResizeTexture } from './webgl2-commands'; -import { WebGL2Device } from './webgl2-device'; +import { WebGL2DeviceManager } from './webgl2-define'; import { IWebGL2GPUTexture } from './webgl2-gpu-objects'; export class WebGL2Texture extends Texture { @@ -36,10 +37,10 @@ export class WebGL2Texture extends Texture { private _gpuTexture: IWebGL2GPUTexture | null = null; - public initialize (info: TextureInfo | TextureViewInfo): boolean { + public initialize (info: TextureInfo | TextureViewInfo, isSwapchainTexture?: boolean) { if ('texture' in info) { console.log('WebGL2 does not support texture view.'); - return false; + return; } this._type = info.type; @@ -81,24 +82,28 @@ export class WebGL2Texture extends Texture { glWrapT: 0, glMinFilter: 0, glMagFilter: 0, + + isSwapchainTexture: isSwapchainTexture || false, }; - WebGL2CmdFuncCreateTexture(this._device as WebGL2Device, this._gpuTexture); + WebGL2CmdFuncCreateTexture(WebGL2DeviceManager.instance, this._gpuTexture); - this._device.memoryStatus.textureSize += this._size; - - return true; + WebGL2DeviceManager.instance.memoryStatus.textureSize += this._size; } public destroy () { if (this._gpuTexture) { - WebGL2CmdFuncDestroyTexture(this._device as WebGL2Device, this._gpuTexture); - this._device.memoryStatus.textureSize -= this._size; + WebGL2CmdFuncDestroyTexture(WebGL2DeviceManager.instance, this._gpuTexture); + WebGL2DeviceManager.instance.memoryStatus.textureSize -= this._size; this._gpuTexture = null; } } public resize (width: number, height: number) { + if (!(this._flags & TextureFlagBit.RESIZABLE)) { + console.error('Cannot resize immutable textures'); + } + const oldSize = this._size; this._width = width; this._height = height; @@ -109,9 +114,20 @@ export class WebGL2Texture extends Texture { this._gpuTexture.width = width; this._gpuTexture.height = height; this._gpuTexture.size = this._size; - WebGL2CmdFuncResizeTexture(this._device as WebGL2Device, this._gpuTexture); - this._device.memoryStatus.textureSize -= oldSize; - this._device.memoryStatus.textureSize += this._size; + WebGL2CmdFuncResizeTexture(WebGL2DeviceManager.instance, this._gpuTexture); + WebGL2DeviceManager.instance.memoryStatus.textureSize -= oldSize; + WebGL2DeviceManager.instance.memoryStatus.textureSize += this._size; } } + + // ======================= Swapchain Specific ======================= // + + protected initAsSwapchainTexture (info: ISwapchainTextureInfo) { + const texInfo = new TextureInfo(); + texInfo.format = info.format; + texInfo.usage = FormatInfos[info.format].hasDepth ? TextureUsageBit.DEPTH_STENCIL_ATTACHMENT : TextureUsageBit.COLOR_ATTACHMENT; + texInfo.width = info.width; + texInfo.height = info.height; + this.initialize(texInfo, true); + } } diff --git a/cocos/core/math/bits.ts b/cocos/core/math/bits.ts index 99048844d0..4b76fd9202 100644 --- a/cocos/core/math/bits.ts +++ b/cocos/core/math/bits.ts @@ -139,7 +139,6 @@ export function countTrailingZeros (v: number) { * @zh 计算大于等于v的最小的二的整数次幂的数字。 */ export function nextPow2 (v: number) { - v += ((v === 0) as unknown as number); --v; v |= v >>> 1; v |= v >>> 2; diff --git a/cocos/core/pipeline/deferred/deferred-pipeline.ts b/cocos/core/pipeline/deferred/deferred-pipeline.ts index 09611dc263..d0858925c7 100644 --- a/cocos/core/pipeline/deferred/deferred-pipeline.ts +++ b/cocos/core/pipeline/deferred/deferred-pipeline.ts @@ -29,7 +29,6 @@ import { ccclass, displayOrder, type, serializable } from 'cc.decorator'; import { EDITOR } from 'internal:constants'; -import { genSamplerHash, samplerLib } from '../../renderer/core/sampler-lib'; import { builtinResMgr } from '../../builtin/builtin-res-mgr'; import { Texture2D } from '../../assets/texture-2d'; import { RenderPipeline, IRenderPipelineInfo } from '../render-pipeline'; @@ -39,27 +38,25 @@ import { ShadowFlow } from '../shadow/shadow-flow'; import { BufferUsageBit, Format, MemoryUsageBit, ClearFlagBit, ClearFlags, StoreOp, Filter, Address, SurfaceTransform, ColorAttachment, DepthStencilAttachment, RenderPass, LoadOp, RenderPassInfo, BufferInfo, Texture, InputAssembler, InputAssemblerInfo, Attribute, Buffer, AccessType, Framebuffer, - TextureInfo, TextureType, TextureUsageBit, FramebufferInfo, Rect } from '../../gfx'; -import { UBOGlobal, UBOCamera, UBOShadow, UNIFORM_SHADOWMAP_BINDING, UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING, UNIFORM_GBUFFER_ALBEDOMAP_BINDING, - UNIFORM_GBUFFER_POSITIONMAP_BINDING, UNIFORM_GBUFFER_NORMALMAP_BINDING, UNIFORM_GBUFFER_EMISSIVEMAP_BINDING, UNIFORM_LIGHTING_RESULTMAP_BINDING } from '../define'; + TextureInfo, TextureType, TextureUsageBit, FramebufferInfo, Rect, Swapchain, SamplerInfo, Sampler } from '../../gfx'; +import { UBOGlobal, UBOCamera, UBOShadow, UNIFORM_SHADOWMAP_BINDING, UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING } from '../define'; import { SKYBOX_FLAG } from '../../renderer/scene/camera'; import { Camera } from '../../renderer/scene'; import { errorID } from '../../platform/debug'; import { sceneCulling } from '../scene-culling'; import { DeferredPipelineSceneData } from './deferred-pipeline-scene-data'; +import { RenderWindow } from '../../renderer/core/render-window'; const PIPELINE_TYPE = 1; -const _samplerInfo = [ +const _samplerInfo = new SamplerInfo( Filter.POINT, Filter.POINT, Filter.NONE, Address.CLAMP, Address.CLAMP, Address.CLAMP, -]; - -const samplerHash = genSamplerHash(_samplerInfo); +); class InputAssemblerData { quadIB: Buffer|null = null; @@ -68,11 +65,12 @@ class InputAssemblerData { } export class DeferredRenderData { - gbufferFrameBuffer: Framebuffer | null = null; + gbufferFrameBuffer: Framebuffer = null!; gbufferRenderTargets: Texture[] = []; - lightingFrameBuffer: Framebuffer | null = null; + lightingFrameBuffer: Framebuffer = null!; lightingRenderTargets: Texture[] = []; - depthTex: Texture | null = null; + depthTex: Texture = null!; + sampler: Sampler = null!; } /** @@ -127,17 +125,20 @@ export class DeferredPipeline extends RenderPipeline { return true; } - public activate (): boolean { - if (EDITOR) { console.info('Deferred render pipeline initialized. Note that non-transparent materials with no lighting will not be rendered, such as builtin-unlit.'); } + public activate (swapchain: Swapchain): boolean { + if (EDITOR) { + console.info('Deferred render pipeline initialized. ' + + 'Note that non-transparent materials with no lighting will not be rendered, such as builtin-unlit.'); + } this._macros = { CC_PIPELINE_TYPE: PIPELINE_TYPE }; this._pipelineSceneData = new DeferredPipelineSceneData(); - if (!super.activate()) { + if (!super.activate(swapchain)) { return false; } - if (!this._activeRenderer()) { + if (!this._activeRenderer(swapchain)) { errorID(2402); return false; } @@ -151,7 +152,7 @@ export class DeferredPipeline extends RenderPipeline { } this._commandBuffers[0].begin(); - this._pipelineUBO.updateGlobalUBO(); + this._pipelineUBO.updateGlobalUBO(cameras[0].window!); // TODO: window size is also camera-specific for (let i = 0; i < cameras.length; i++) { const camera = cameras[i]; if (camera.scene) { @@ -166,15 +167,15 @@ export class DeferredPipeline extends RenderPipeline { this._device.queue.submit(this._commandBuffers); } - public getRenderPass (clearFlags: ClearFlags): RenderPass { + public getRenderPass (clearFlags: ClearFlags, swapchain: Swapchain): RenderPass { let renderPass = this._renderPasses.get(clearFlags); if (renderPass) { return renderPass; } - const device = this.device; + const device = this._device; const colorAttachment = new ColorAttachment(); const depthStencilAttachment = new DepthStencilAttachment(); - colorAttachment.format = device.colorFormat; - depthStencilAttachment.format = device.depthStencilFormat; + colorAttachment.format = swapchain.colorTexture.format; + depthStencilAttachment.format = swapchain.depthStencilTexture.format; depthStencilAttachment.stencilStoreOp = StoreOp.DISCARD; depthStencilAttachment.depthStoreOp = StoreOp.DISCARD; @@ -183,15 +184,15 @@ export class DeferredPipeline extends RenderPipeline { colorAttachment.loadOp = LoadOp.DISCARD; } else { colorAttachment.loadOp = LoadOp.LOAD; - colorAttachment.beginAccesses = [AccessType.PRESENT]; + colorAttachment.beginAccesses = [AccessType.COLOR_ATTACHMENT_WRITE]; } } if ((clearFlags & ClearFlagBit.DEPTH_STENCIL) !== ClearFlagBit.DEPTH_STENCIL) { if (!(clearFlags & ClearFlagBit.DEPTH)) depthStencilAttachment.depthLoadOp = LoadOp.LOAD; if (!(clearFlags & ClearFlagBit.STENCIL)) depthStencilAttachment.stencilLoadOp = LoadOp.LOAD; - depthStencilAttachment.beginAccesses = [AccessType.DEPTH_STENCIL_ATTACHMENT_WRITE]; } + depthStencilAttachment.beginAccesses = [AccessType.DEPTH_STENCIL_ATTACHMENT_WRITE]; const renderPassInfo = new RenderPassInfo([colorAttachment], depthStencilAttachment); renderPass = device.createRenderPass(renderPassInfo); @@ -200,7 +201,7 @@ export class DeferredPipeline extends RenderPipeline { return renderPass; } - public getDeferredRenderData (camera): DeferredRenderData { + public getDeferredRenderData (): DeferredRenderData { if (!this._deferredRenderData) { this._generateDeferredRenderData(); } @@ -208,12 +209,12 @@ export class DeferredPipeline extends RenderPipeline { return this._deferredRenderData!; } - private _activeRenderer () { + private _activeRenderer (swapchain: Swapchain) { const device = this.device; this._commandBuffers.push(device.commandBuffer); - const sampler = samplerLib.getSampler(device, samplerHash); + const sampler = device.getSampler(_samplerInfo); this._descriptorSet.bindSampler(UNIFORM_SHADOWMAP_BINDING, sampler); this._descriptorSet.bindTexture(UNIFORM_SHADOWMAP_BINDING, builtinResMgr.get('default-texture').getGFXTexture()!); this._descriptorSet.bindSampler(UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING, sampler); @@ -221,7 +222,7 @@ export class DeferredPipeline extends RenderPipeline { this._descriptorSet.update(); let inputAssemblerDataOffscreen = new InputAssemblerData(); - inputAssemblerDataOffscreen = this.createQuadInputAssembler(SurfaceTransform.IDENTITY); + inputAssemblerDataOffscreen = this.createQuadInputAssembler(); if (!inputAssemblerDataOffscreen.quadIB || !inputAssemblerDataOffscreen.quadVB || !inputAssemblerDataOffscreen.quadIA) { return false; } @@ -229,7 +230,7 @@ export class DeferredPipeline extends RenderPipeline { this._quadVBOffscreen = inputAssemblerDataOffscreen.quadVB; this._quadIAOffscreen = inputAssemblerDataOffscreen.quadIA; - const inputAssemblerDataOnscreen = this.createQuadInputAssembler(device.surfaceTransform); + const inputAssemblerDataOnscreen = this.createQuadInputAssembler(); if (!inputAssemblerDataOnscreen.quadIB || !inputAssemblerDataOnscreen.quadVB || !inputAssemblerDataOnscreen.quadIA) { return false; } @@ -258,13 +259,15 @@ export class DeferredPipeline extends RenderPipeline { colorAttachment3.storeOp = StoreOp.STORE; const depthStencilAttachment = new DepthStencilAttachment(); - depthStencilAttachment.format = device.depthStencilFormat; + depthStencilAttachment.format = Format.DEPTH_STENCIL; depthStencilAttachment.depthLoadOp = LoadOp.CLEAR; depthStencilAttachment.depthStoreOp = StoreOp.STORE; depthStencilAttachment.stencilLoadOp = LoadOp.CLEAR; depthStencilAttachment.stencilStoreOp = StoreOp.STORE; - const renderPassInfo = new RenderPassInfo([colorAttachment0, colorAttachment1, colorAttachment2, colorAttachment3], - depthStencilAttachment); + const renderPassInfo = new RenderPassInfo( + [colorAttachment0, colorAttachment1, colorAttachment2, colorAttachment3], + depthStencilAttachment, + ); this._gbufferRenderPass = device.createRenderPass(renderPassInfo); } @@ -276,7 +279,7 @@ export class DeferredPipeline extends RenderPipeline { colorAttachment.endAccesses = [AccessType.COLOR_ATTACHMENT_WRITE]; const depthStencilAttachment = new DepthStencilAttachment(); - depthStencilAttachment.format = device.depthStencilFormat; + depthStencilAttachment.format = Format.DEPTH_STENCIL; depthStencilAttachment.depthLoadOp = LoadOp.LOAD; depthStencilAttachment.depthStoreOp = StoreOp.DISCARD; depthStencilAttachment.stencilLoadOp = LoadOp.LOAD; @@ -288,8 +291,8 @@ export class DeferredPipeline extends RenderPipeline { this._lightingRenderPass = device.createRenderPass(renderPassInfo); } - this._width = device.width; - this._height = device.height; + this._width = swapchain.width; + this._height = swapchain.height; this._generateDeferredRenderData(); return true; @@ -300,8 +303,6 @@ export class DeferredPipeline extends RenderPipeline { this._descriptorSet.getBuffer(UBOGlobal.BINDING).destroy(); this._descriptorSet.getBuffer(UBOShadow.BINDING).destroy(); this._descriptorSet.getBuffer(UBOCamera.BINDING).destroy(); - this._descriptorSet.getSampler(UNIFORM_SHADOWMAP_BINDING).destroy(); - this._descriptorSet.getSampler(UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING).destroy(); this._descriptorSet.getTexture(UNIFORM_SHADOWMAP_BINDING).destroy(); this._descriptorSet.getTexture(UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING).destroy(); } @@ -359,7 +360,7 @@ export class DeferredPipeline extends RenderPipeline { * @zh * 创建四边形输入汇集器。 */ - protected createQuadInputAssembler (surfaceTransform: SurfaceTransform): InputAssemblerData { + protected createQuadInputAssembler (): InputAssemblerData { // create vertex buffer const inputAssemblerData = new InputAssemblerData(); @@ -416,26 +417,26 @@ export class DeferredPipeline extends RenderPipeline { return inputAssemblerData; } - public updateQuadVertexData (renderArea: Rect) { + public updateQuadVertexData (renderArea: Rect, window: RenderWindow) { if (this._lastUsedRenderArea === renderArea) { return; } this._lastUsedRenderArea = renderArea; - const offData = this.genQuadVertexData(SurfaceTransform.IDENTITY, renderArea); + const offData = this.genQuadVertexData(SurfaceTransform.IDENTITY, renderArea, window); this._quadVBOffscreen!.update(offData); - const onData = this.genQuadVertexData(this.device.surfaceTransform, renderArea); + const onData = this.genQuadVertexData(window.swapchain && window.swapchain.surfaceTransform || SurfaceTransform.IDENTITY, renderArea, window); this._quadVBOnscreen!.update(onData); } - protected genQuadVertexData (surfaceTransform: SurfaceTransform, renderArea: Rect) : Float32Array { + protected genQuadVertexData (surfaceTransform: SurfaceTransform, renderArea: Rect, window: RenderWindow) : Float32Array { const vbData = new Float32Array(4 * 4); - const minX = renderArea.x / this.device.width; - const maxX = (renderArea.x + renderArea.width) / this.device.width; - let minY = renderArea.y / this.device.height; - let maxY = (renderArea.y + renderArea.height) / this.device.height; + const minX = renderArea.x / window.width; + const maxX = (renderArea.x + renderArea.width) / window.width; + let minY = renderArea.y / window.height; + let maxY = (renderArea.y + renderArea.height) / window.height; if (this.device.capabilities.screenSpaceSignY > 0) { const temp = maxY; maxY = minY; @@ -514,41 +515,19 @@ export class DeferredPipeline extends RenderPipeline { const data: DeferredRenderData = this._deferredRenderData = new DeferredRenderData(); - data.gbufferRenderTargets.push(device.createTexture(new TextureInfo( - TextureType.TEX2D, - TextureUsageBit.COLOR_ATTACHMENT | TextureUsageBit.SAMPLED, - Format.RGBA16F, - this._width, - this._height, - ))); - - data.gbufferRenderTargets.push(device.createTexture(new TextureInfo( - TextureType.TEX2D, - TextureUsageBit.COLOR_ATTACHMENT | TextureUsageBit.SAMPLED, - Format.RGBA16F, - this._width, - this._height, - ))); - - data.gbufferRenderTargets.push(device.createTexture(new TextureInfo( - TextureType.TEX2D, - TextureUsageBit.COLOR_ATTACHMENT | TextureUsageBit.SAMPLED, - Format.RGBA16F, - this._width, - this._height, - ))); - data.gbufferRenderTargets.push(device.createTexture(new TextureInfo( - TextureType.TEX2D, - TextureUsageBit.COLOR_ATTACHMENT | TextureUsageBit.SAMPLED, - Format.RGBA16F, - this._width, - this._height, - ))); - + for (let i = 0; i < 4; ++i) { + data.gbufferRenderTargets.push(device.createTexture(new TextureInfo( + TextureType.TEX2D, + TextureUsageBit.COLOR_ATTACHMENT | TextureUsageBit.SAMPLED, + i % 3 ? Format.RGBA16F : Format.RGBA8, // positions & normals need more precision + this._width, + this._height, + ))); + } data.depthTex = device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.DEPTH_STENCIL_ATTACHMENT, - device.depthStencilFormat, + Format.DEPTH_STENCIL, this._width, this._height, )); @@ -573,17 +552,6 @@ export class DeferredPipeline extends RenderPipeline { data.depthTex, )); - this._descriptorSet.bindTexture(UNIFORM_GBUFFER_ALBEDOMAP_BINDING, data.gbufferFrameBuffer.colorTextures[0]!); - this._descriptorSet.bindTexture(UNIFORM_GBUFFER_POSITIONMAP_BINDING, data.gbufferFrameBuffer.colorTextures[1]!); - this._descriptorSet.bindTexture(UNIFORM_GBUFFER_NORMALMAP_BINDING, data.gbufferFrameBuffer.colorTextures[2]!); - this._descriptorSet.bindTexture(UNIFORM_GBUFFER_EMISSIVEMAP_BINDING, data.gbufferFrameBuffer.colorTextures[3]!); - this._descriptorSet.bindTexture(UNIFORM_LIGHTING_RESULTMAP_BINDING, data.lightingFrameBuffer.colorTextures[0]!); - - const sampler = samplerLib.getSampler(device, samplerHash); - this._descriptorSet.bindSampler(UNIFORM_GBUFFER_ALBEDOMAP_BINDING, sampler); - this._descriptorSet.bindSampler(UNIFORM_GBUFFER_POSITIONMAP_BINDING, sampler); - this._descriptorSet.bindSampler(UNIFORM_GBUFFER_NORMALMAP_BINDING, sampler); - this._descriptorSet.bindSampler(UNIFORM_GBUFFER_EMISSIVEMAP_BINDING, sampler); - this._descriptorSet.bindSampler(UNIFORM_LIGHTING_RESULTMAP_BINDING, sampler); + data.sampler = device.getSampler(_samplerInfo); } } diff --git a/cocos/core/pipeline/deferred/gbuffer-stage.ts b/cocos/core/pipeline/deferred/gbuffer-stage.ts index 33b96d18cd..8401d26925 100644 --- a/cocos/core/pipeline/deferred/gbuffer-stage.ts +++ b/cocos/core/pipeline/deferred/gbuffer-stage.ts @@ -80,7 +80,7 @@ export class GbufferStage extends RenderStage { private _renderArea = new Rect(); private _batchedQueue: RenderBatchedQueue; private _instancedQueue: RenderInstancedQueue; - private _phaseID = getPhaseID('deferred'); + private _phaseID = getPhaseID('default'); constructor () { super(); @@ -152,7 +152,7 @@ export class GbufferStage extends RenderStage { this._instancedQueue.uploadBuffers(cmdBuff); this._batchedQueue.uploadBuffers(cmdBuff); this._renderArea = pipeline.generateRenderArea(camera); - pipeline.updateQuadVertexData(this._renderArea); + pipeline.updateQuadVertexData(this._renderArea, camera.window!); if (camera.clearFlag & ClearFlagBit.COLOR) { if (pipeline.pipelineSceneData.isHDR) { @@ -170,8 +170,8 @@ export class GbufferStage extends RenderStage { colors[0].w = camera.clearColor.w; - const deferredData = pipeline.getDeferredRenderData(camera); - const framebuffer = deferredData.gbufferFrameBuffer!; + const deferredData = pipeline.getDeferredRenderData(); + const framebuffer = deferredData.gbufferFrameBuffer; const renderPass = framebuffer.renderPass; cmdBuff.beginRenderPass(renderPass, framebuffer, this._renderArea, diff --git a/cocos/core/pipeline/deferred/lighting-stage.ts b/cocos/core/pipeline/deferred/lighting-stage.ts index 8ebda06d75..743fdef9cc 100644 --- a/cocos/core/pipeline/deferred/lighting-stage.ts +++ b/cocos/core/pipeline/deferred/lighting-stage.ts @@ -44,7 +44,6 @@ import { intersect, Sphere } from '../../geometry'; import { Vec3, Vec4 } from '../../math'; import { SRGBToLinear } from '../pipeline-funcs'; import { DeferredPipelineSceneData } from './deferred-pipeline-scene-data'; -import { Pass } from '../../renderer/core/pass'; import { renderQueueClearFunc, RenderQueue, convertRenderQueue, renderQueueSortFunc } from '../render-queue'; import { RenderQueueDesc } from '../pipeline-serialization'; @@ -75,7 +74,6 @@ export class LightingStage extends RenderStage { @displayOrder(2) private renderQueues: RenderQueueDesc[] = []; private _phaseID = getPhaseID('default'); - private _defPhaseID = getPhaseID('deferred'); private _renderQueues: RenderQueue[] = []; public static initInfo: IRenderStageInfo = { @@ -253,8 +251,8 @@ export class LightingStage extends RenderStage { } colors[0].w = 0; - const deferredData = pipeline.getDeferredRenderData(camera); - const framebuffer = deferredData.lightingFrameBuffer!; + const deferredData = pipeline.getDeferredRenderData(); + const framebuffer = deferredData.lightingFrameBuffer; const renderPass = framebuffer.renderPass; cmdBuff.beginRenderPass(renderPass, framebuffer, this._renderArea, @@ -266,6 +264,13 @@ export class LightingStage extends RenderStage { const lightingMat = (sceneData as DeferredPipelineSceneData).deferredLightingMaterial; const pass = lightingMat.passes[0]; const shader = pass.getShaderVariant(); + + for (let i = 0; i < 4; ++i) { + pass.descriptorSet.bindTexture(i, deferredData.gbufferRenderTargets[i]); + pass.descriptorSet.bindSampler(i, deferredData.sampler); + } + pass.descriptorSet.update(); + cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, pass.descriptorSet); const inputAssembler = pipeline.quadIAOffscreen; @@ -292,8 +297,7 @@ export class LightingStage extends RenderStage { const passes = subModel.passes; for (p = 0; p < passes.length; ++p) { const pass = passes[p]; - // TODO: need fallback of ulit and gizmo material. - if (pass.phase !== this._phaseID && pass.phase !== this._defPhaseID) continue; + if (pass.phase !== this._phaseID) continue; for (k = 0; k < this._renderQueues.length; k++) { this._renderQueues[k].insertRenderPass(ro, m, p); } diff --git a/cocos/core/pipeline/deferred/postprocess-stage.ts b/cocos/core/pipeline/deferred/postprocess-stage.ts index 1f54fd94f6..2725e03149 100644 --- a/cocos/core/pipeline/deferred/postprocess-stage.ts +++ b/cocos/core/pipeline/deferred/postprocess-stage.ts @@ -38,9 +38,7 @@ import { Material } from '../../assets/material'; import { PipelineStateManager } from '../pipeline-state-manager'; import { UIPhase } from '../forward/ui-phase'; import { MainFlow } from './main-flow'; -import { opaqueCompareFn, RenderQueue, transparentCompareFn } from '../render-queue'; -import { RenderQueueDesc, RenderQueueSortMode } from '../pipeline-serialization'; -import { getPhaseID } from '../pass-phase'; +import { RenderQueueDesc } from '../pipeline-serialization'; import { DeferredPipelineSceneData } from './deferred-pipeline-scene-data'; const colors: Color[] = [new Color(0, 0, 0, 1)]; @@ -104,7 +102,8 @@ export class PostprocessStage extends RenderStage { this._renderArea.height = vp.height * camera.height * sceneData.shadingScale; const framebuffer = camera.window!.framebuffer; - const renderPass = framebuffer.colorTextures[0] ? framebuffer.renderPass : pipeline.getRenderPass(camera.clearFlag); + const swapchain = camera.window!.swapchain; + const renderPass = swapchain ? pipeline.getRenderPass(camera.clearFlag, swapchain) : framebuffer.renderPass; if (camera.clearFlag & ClearFlagBit.COLOR) { colors[0].x = camera.clearColor.x; @@ -113,6 +112,7 @@ export class PostprocessStage extends RenderStage { } colors[0].w = camera.clearColor.w; + const deferredData = pipeline.getDeferredRenderData(); cmdBuff.beginRenderPass(renderPass, framebuffer, this._renderArea, colors, camera.clearDepth, camera.clearStencil); @@ -123,9 +123,14 @@ export class PostprocessStage extends RenderStage { const builtinPostProcess = (sceneData as DeferredPipelineSceneData).deferredPostMaterial; const pass = builtinPostProcess.passes[0]; const shader = pass.getShaderVariant(); + + pass.descriptorSet.bindTexture(0, deferredData.lightingRenderTargets[0]); + pass.descriptorSet.bindSampler(0, deferredData.sampler); + pass.descriptorSet.update(); + cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, pass.descriptorSet); - const inputAssembler = camera.window!.hasOffScreenAttachments ? pipeline.quadIAOffscreen : pipeline.quadIAOnscreen; + const inputAssembler = camera.window!.swapchain ? pipeline.quadIAOnscreen : pipeline.quadIAOffscreen; let pso:PipelineState|null = null; if (pass != null && shader != null && inputAssembler != null) { pso = PipelineStateManager.getOrCreatePipelineState(device, pass, shader, renderPass, inputAssembler); diff --git a/cocos/core/pipeline/define.ts b/cocos/core/pipeline/define.ts index 74118fe037..440da12524 100644 --- a/cocos/core/pipeline/define.ts +++ b/cocos/core/pipeline/define.ts @@ -121,11 +121,6 @@ export enum PipelineGlobalBindings { SAMPLER_SHADOWMAP, SAMPLER_ENVIRONMENT, // don't put this as the first sampler binding due to Mac GL driver issues: cubemap at texture unit 0 causes rendering issues SAMPLER_SPOT_LIGHTING_MAP, - SAMPLER_GBUFFER_ALBEDOMAP, - SAMPLER_GBUFFER_POSITIONMAP, - SAMPLER_GBUFFER_NORMALMAP, - SAMPLER_GBUFFER_EMISSIVEMAP, - SAMPLER_LIGHTING_RESULTMAP, COUNT, } @@ -285,41 +280,6 @@ const UNIFORM_SHADOWMAP_LAYOUT = new UniformSamplerTexture(SetIndex.GLOBAL, UNIF globalDescriptorSetLayout.layouts[UNIFORM_SHADOWMAP_NAME] = UNIFORM_SHADOWMAP_LAYOUT; globalDescriptorSetLayout.bindings[UNIFORM_SHADOWMAP_BINDING] = UNIFORM_SHADOWMAP_DESCRIPTOR; -const UNIFORM_GBUFFER_ALBEDOMAP_NAME = 'cc_gbuffer_albedoMap'; -export const UNIFORM_GBUFFER_ALBEDOMAP_BINDING = PipelineGlobalBindings.SAMPLER_GBUFFER_ALBEDOMAP; -const UNIFORM_GBUFFER_ALBEDOMAP_DESCRIPTOR = new DescriptorSetLayoutBinding(UNIFORM_GBUFFER_ALBEDOMAP_BINDING, DescriptorType.SAMPLER_TEXTURE, 1, ShaderStageFlagBit.FRAGMENT); -const UNIFORM_GBUFFER_ALBEDOMAP_LAYOUT = new UniformSamplerTexture(SetIndex.GLOBAL, UNIFORM_GBUFFER_ALBEDOMAP_BINDING, UNIFORM_GBUFFER_ALBEDOMAP_NAME, Type.SAMPLER2D, 1); -globalDescriptorSetLayout.layouts[UNIFORM_GBUFFER_ALBEDOMAP_NAME] = UNIFORM_GBUFFER_ALBEDOMAP_LAYOUT; -globalDescriptorSetLayout.bindings[UNIFORM_GBUFFER_ALBEDOMAP_BINDING] = UNIFORM_GBUFFER_ALBEDOMAP_DESCRIPTOR; - -const UNIFORM_GBUFFER_POSITIONMAP_NAME = 'cc_gbuffer_positionMap'; -export const UNIFORM_GBUFFER_POSITIONMAP_BINDING = PipelineGlobalBindings.SAMPLER_GBUFFER_POSITIONMAP; -const UNIFORM_GBUFFER_POSITIONMAP_DESCRIPTOR = new DescriptorSetLayoutBinding(UNIFORM_GBUFFER_POSITIONMAP_BINDING, DescriptorType.SAMPLER_TEXTURE, 1, ShaderStageFlagBit.FRAGMENT); -const UNIFORM_GBUFFER_POSITIONMAP_LAYOUT = new UniformSamplerTexture(SetIndex.GLOBAL, UNIFORM_GBUFFER_POSITIONMAP_BINDING, UNIFORM_GBUFFER_POSITIONMAP_NAME, Type.SAMPLER2D, 1); -globalDescriptorSetLayout.layouts[UNIFORM_GBUFFER_POSITIONMAP_NAME] = UNIFORM_GBUFFER_POSITIONMAP_LAYOUT; -globalDescriptorSetLayout.bindings[UNIFORM_GBUFFER_POSITIONMAP_BINDING] = UNIFORM_GBUFFER_POSITIONMAP_DESCRIPTOR; - -const UNIFORM_GBUFFER_NORMALMAP_NAME = 'cc_gbuffer_normalMap'; -export const UNIFORM_GBUFFER_NORMALMAP_BINDING = PipelineGlobalBindings.SAMPLER_GBUFFER_NORMALMAP; -const UNIFORM_GBUFFER_NORMALMAP_DESCRIPTOR = new DescriptorSetLayoutBinding(UNIFORM_GBUFFER_NORMALMAP_BINDING, DescriptorType.SAMPLER_TEXTURE, 1, ShaderStageFlagBit.FRAGMENT); -const UNIFORM_GBUFFER_NORMALMAP_LAYOUT = new UniformSamplerTexture(SetIndex.GLOBAL, UNIFORM_GBUFFER_NORMALMAP_BINDING, UNIFORM_GBUFFER_NORMALMAP_NAME, Type.SAMPLER2D, 1); -globalDescriptorSetLayout.layouts[UNIFORM_GBUFFER_NORMALMAP_NAME] = UNIFORM_GBUFFER_NORMALMAP_LAYOUT; -globalDescriptorSetLayout.bindings[UNIFORM_GBUFFER_NORMALMAP_BINDING] = UNIFORM_GBUFFER_NORMALMAP_DESCRIPTOR; - -const UNIFORM_LIGHTING_RESULTMAP_NAME = 'cc_lighting_resultMap'; -export const UNIFORM_LIGHTING_RESULTMAP_BINDING = PipelineGlobalBindings.SAMPLER_LIGHTING_RESULTMAP; -const UNIFORM_LIGHTING_RESULTMAP_DESCRIPTOR = new DescriptorSetLayoutBinding(UNIFORM_LIGHTING_RESULTMAP_BINDING, DescriptorType.SAMPLER_TEXTURE, 1, ShaderStageFlagBit.FRAGMENT); -const UNIFORM_LIGHTING_RESULTMAP_LAYOUT = new UniformSamplerTexture(SetIndex.GLOBAL, UNIFORM_LIGHTING_RESULTMAP_BINDING, UNIFORM_LIGHTING_RESULTMAP_NAME, Type.SAMPLER2D, 1); -globalDescriptorSetLayout.layouts[UNIFORM_LIGHTING_RESULTMAP_NAME] = UNIFORM_LIGHTING_RESULTMAP_LAYOUT; -globalDescriptorSetLayout.bindings[UNIFORM_LIGHTING_RESULTMAP_BINDING] = UNIFORM_LIGHTING_RESULTMAP_DESCRIPTOR; - -const UNIFORM_GBUFFER_EMISSIVEMAP_NAME = 'cc_gbuffer_emissiveMap'; -export const UNIFORM_GBUFFER_EMISSIVEMAP_BINDING = PipelineGlobalBindings.SAMPLER_GBUFFER_EMISSIVEMAP; -const UNIFORM_GBUFFER_EMISSIVEMAP_DESCRIPTOR = new DescriptorSetLayoutBinding(UNIFORM_GBUFFER_EMISSIVEMAP_BINDING, DescriptorType.SAMPLER_TEXTURE, 1, ShaderStageFlagBit.FRAGMENT); -const UNIFORM_GBUFFER_EMISSIVEMAP_LAYOUT = new UniformSamplerTexture(SetIndex.GLOBAL, UNIFORM_GBUFFER_EMISSIVEMAP_BINDING, UNIFORM_GBUFFER_EMISSIVEMAP_NAME, Type.SAMPLER2D, 1); -globalDescriptorSetLayout.layouts[UNIFORM_GBUFFER_EMISSIVEMAP_NAME] = UNIFORM_GBUFFER_EMISSIVEMAP_LAYOUT; -globalDescriptorSetLayout.bindings[UNIFORM_GBUFFER_EMISSIVEMAP_BINDING] = UNIFORM_GBUFFER_EMISSIVEMAP_DESCRIPTOR; - const UNIFORM_ENVIRONMENT_NAME = 'cc_environment'; export const UNIFORM_ENVIRONMENT_BINDING = PipelineGlobalBindings.SAMPLER_ENVIRONMENT; const UNIFORM_ENVIRONMENT_DESCRIPTOR = new DescriptorSetLayoutBinding(UNIFORM_ENVIRONMENT_BINDING, DescriptorType.SAMPLER_TEXTURE, 1, ShaderStageFlagBit.FRAGMENT); diff --git a/cocos/core/pipeline/forward/forward-pipeline.ts b/cocos/core/pipeline/forward/forward-pipeline.ts index b25afedc71..a2f776e959 100644 --- a/cocos/core/pipeline/forward/forward-pipeline.ts +++ b/cocos/core/pipeline/forward/forward-pipeline.ts @@ -36,26 +36,25 @@ import { RenderTextureConfig } from '../pipeline-serialization'; import { ShadowFlow } from '../shadow/shadow-flow'; import { UBOGlobal, UBOShadow, UBOCamera, UNIFORM_SHADOWMAP_BINDING, UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING } from '../define'; import { ColorAttachment, DepthStencilAttachment, RenderPass, LoadOp, - RenderPassInfo, ClearFlagBit, ClearFlags, Filter, Address, StoreOp, AccessType } from '../../gfx'; + RenderPassInfo, ClearFlagBit, ClearFlags, Filter, Address, StoreOp, AccessType, Swapchain, SamplerInfo } from '../../gfx'; import { SKYBOX_FLAG } from '../../renderer/scene/camera'; -import { genSamplerHash, samplerLib } from '../../renderer/core/sampler-lib'; import { builtinResMgr } from '../../builtin'; import { Texture2D } from '../../assets/texture-2d'; import { Camera } from '../../renderer/scene'; -import { errorID, warnID } from '../../platform/debug'; +import { errorID } from '../../platform/debug'; import { sceneCulling } from '../scene-culling'; import { PipelineSceneData } from '../pipeline-scene-data'; const PIPELINE_TYPE = 0; -const _samplerInfo = [ +const _samplerInfo = new SamplerInfo( Filter.POINT, Filter.POINT, Filter.NONE, Address.CLAMP, Address.CLAMP, Address.CLAMP, -]; +); /** * @en The forward render pipeline @@ -86,13 +85,13 @@ export class ForwardPipeline extends RenderPipeline { return true; } - public activate (): boolean { + public activate (swapchain: Swapchain): boolean { if (EDITOR) { console.info('Forward render pipeline initialized.'); } this._macros = { CC_PIPELINE_TYPE: PIPELINE_TYPE }; this._pipelineSceneData = new PipelineSceneData(); - if (!super.activate()) { + if (!super.activate(swapchain)) { return false; } @@ -106,7 +105,7 @@ export class ForwardPipeline extends RenderPipeline { public render (cameras: Camera[]) { this._commandBuffers[0].begin(); - this._pipelineUBO.updateGlobalUBO(); + this._pipelineUBO.updateGlobalUBO(cameras[0].window!); for (let i = 0; i < cameras.length; i++) { const camera = cameras[i]; if (camera.scene) { @@ -122,15 +121,15 @@ export class ForwardPipeline extends RenderPipeline { this._device.queue.submit(this._commandBuffers); } - public getRenderPass (clearFlags: ClearFlags): RenderPass { + public getRenderPass (clearFlags: ClearFlags, swapchain: Swapchain): RenderPass { let renderPass = this._renderPasses.get(clearFlags); if (renderPass) { return renderPass; } - const device = this.device; + const device = this._device; const colorAttachment = new ColorAttachment(); const depthStencilAttachment = new DepthStencilAttachment(); - colorAttachment.format = device.colorFormat; - depthStencilAttachment.format = device.depthStencilFormat; + colorAttachment.format = swapchain.colorTexture.format; + depthStencilAttachment.format = swapchain.depthStencilTexture.format; depthStencilAttachment.stencilStoreOp = StoreOp.DISCARD; depthStencilAttachment.depthStoreOp = StoreOp.DISCARD; @@ -139,15 +138,15 @@ export class ForwardPipeline extends RenderPipeline { colorAttachment.loadOp = LoadOp.DISCARD; } else { colorAttachment.loadOp = LoadOp.LOAD; - colorAttachment.beginAccesses = [AccessType.PRESENT]; + colorAttachment.beginAccesses = [AccessType.COLOR_ATTACHMENT_WRITE]; } } if ((clearFlags & ClearFlagBit.DEPTH_STENCIL) !== ClearFlagBit.DEPTH_STENCIL) { if (!(clearFlags & ClearFlagBit.DEPTH)) depthStencilAttachment.depthLoadOp = LoadOp.LOAD; if (!(clearFlags & ClearFlagBit.STENCIL)) depthStencilAttachment.stencilLoadOp = LoadOp.LOAD; - depthStencilAttachment.beginAccesses = [AccessType.DEPTH_STENCIL_ATTACHMENT_WRITE]; } + depthStencilAttachment.beginAccesses = [AccessType.DEPTH_STENCIL_ATTACHMENT_WRITE]; const renderPassInfo = new RenderPassInfo([colorAttachment], depthStencilAttachment); renderPass = device.createRenderPass(renderPassInfo); @@ -161,8 +160,7 @@ export class ForwardPipeline extends RenderPipeline { this._commandBuffers.push(device.commandBuffer); - const shadowMapSamplerHash = genSamplerHash(_samplerInfo); - const shadowMapSampler = samplerLib.getSampler(device, shadowMapSamplerHash); + const shadowMapSampler = device.getSampler(_samplerInfo); this._descriptorSet.bindSampler(UNIFORM_SHADOWMAP_BINDING, shadowMapSampler); this._descriptorSet.bindTexture(UNIFORM_SHADOWMAP_BINDING, builtinResMgr.get('default-texture').getGFXTexture()!); this._descriptorSet.bindSampler(UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING, shadowMapSampler); @@ -177,8 +175,6 @@ export class ForwardPipeline extends RenderPipeline { this._descriptorSet.getBuffer(UBOGlobal.BINDING).destroy(); this._descriptorSet.getBuffer(UBOShadow.BINDING).destroy(); this._descriptorSet.getBuffer(UBOCamera.BINDING).destroy(); - this._descriptorSet.getSampler(UNIFORM_SHADOWMAP_BINDING).destroy(); - this._descriptorSet.getSampler(UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING).destroy(); this._descriptorSet.getTexture(UNIFORM_SHADOWMAP_BINDING).destroy(); this._descriptorSet.getTexture(UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING).destroy(); } diff --git a/cocos/core/pipeline/forward/forward-stage.ts b/cocos/core/pipeline/forward/forward-stage.ts index f5b2c612ec..a3232443de 100644 --- a/cocos/core/pipeline/forward/forward-stage.ts +++ b/cocos/core/pipeline/forward/forward-stage.ts @@ -183,7 +183,8 @@ export class ForwardStage extends RenderStage { colors[0].w = camera.clearColor.w; const framebuffer = camera.window!.framebuffer; - const renderPass = framebuffer.colorTextures[0] ? framebuffer.renderPass : pipeline.getRenderPass(camera.clearFlag & this._clearFlag); + const swapchain = camera.window!.swapchain; + const renderPass = swapchain ? pipeline.getRenderPass(camera.clearFlag & this._clearFlag, swapchain) : framebuffer.renderPass; cmdBuff.beginRenderPass(renderPass, framebuffer, this._renderArea, colors, camera.clearDepth, camera.clearStencil); diff --git a/cocos/core/pipeline/forward/ui-phase.ts b/cocos/core/pipeline/forward/ui-phase.ts index 156aad77bb..cb6f082323 100644 --- a/cocos/core/pipeline/forward/ui-phase.ts +++ b/cocos/core/pipeline/forward/ui-phase.ts @@ -40,7 +40,7 @@ export class UIPhase { } public render (camera: Camera, renderPass: RenderPass) { - const pipeline = this._pipeline as ForwardPipeline; + const pipeline = this._pipeline; const device = pipeline.device; const cmdBuff = pipeline.commandBuffers[0]; const scene = camera.scene!; @@ -69,5 +69,15 @@ export class UIPhase { cmdBuff.draw(inputAssembler!); } } + + if (pipeline.profiler && pipeline.profiler.enabled && camera.window!.swapchain) { + const { inputAssembler, passes, shaders, descriptorSet } = pipeline.profiler.subModels[0]; + const pso = PipelineStateManager.getOrCreatePipelineState(device, passes[0], shaders[0], renderPass, inputAssembler); + cmdBuff.bindPipelineState(pso); + cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, passes[0].descriptorSet); + cmdBuff.bindDescriptorSet(SetIndex.LOCAL, descriptorSet); + cmdBuff.bindInputAssembler(inputAssembler); + cmdBuff.draw(inputAssembler); + } } } diff --git a/cocos/core/pipeline/global-descriptor-set-manager.ts b/cocos/core/pipeline/global-descriptor-set-manager.ts index 56a5c16035..bccc05bc84 100644 --- a/cocos/core/pipeline/global-descriptor-set-manager.ts +++ b/cocos/core/pipeline/global-descriptor-set-manager.ts @@ -30,27 +30,26 @@ import { RenderPipeline } from './render-pipeline'; import { Device, BufferUsageBit, MemoryUsageBit, BufferInfo, Filter, Address, Sampler, DescriptorSet, - DescriptorSetInfo, Buffer, Texture, DescriptorSetLayoutInfo, DescriptorSetLayout } from '../gfx'; + DescriptorSetInfo, Buffer, Texture, DescriptorSetLayoutInfo, DescriptorSetLayout, SamplerInfo } from '../gfx'; import { UBOShadow, globalDescriptorSetLayout, PipelineGlobalBindings } from './define'; -import { genSamplerHash, samplerLib } from '../renderer/core/sampler-lib'; -const _samplerLinearInfo = [ +const _samplerLinearInfo = new SamplerInfo( Filter.LINEAR, Filter.LINEAR, Filter.NONE, Address.CLAMP, Address.CLAMP, Address.CLAMP, -]; +); -const _samplerPointInfo = [ +const _samplerPointInfo = new SamplerInfo( Filter.POINT, Filter.POINT, Filter.NONE, Address.CLAMP, Address.CLAMP, Address.CLAMP, -]; +); export class GlobalDSManager { private _device: Device; @@ -85,11 +84,8 @@ export class GlobalDSManager { constructor (pipeline: RenderPipeline) { this._device = pipeline.device; - const linearSamplerHash = genSamplerHash(_samplerLinearInfo); - this._linearSampler = samplerLib.getSampler(this._device, linearSamplerHash); - - const pointSamplerHash = genSamplerHash(_samplerPointInfo); - this._pointSampler = samplerLib.getSampler(this._device, pointSamplerHash); + this._linearSampler = this._device.getSampler(_samplerLinearInfo); + this._pointSampler = this._device.getSampler(_samplerPointInfo); const layoutInfo = new DescriptorSetLayoutInfo(globalDescriptorSetLayout.bindings); this._descriptorSetLayout = this._device.createDescriptorSetLayout(layoutInfo); @@ -201,7 +197,5 @@ export class GlobalDSManager { public destroy () { this._descriptorSetLayout.destroy(); - this._linearSampler.destroy(); - this._pointSampler.destroy(); } } diff --git a/cocos/core/pipeline/index.jsb.ts b/cocos/core/pipeline/index.jsb.ts index 36736cf8f0..fec64e9f65 100644 --- a/cocos/core/pipeline/index.jsb.ts +++ b/cocos/core/pipeline/index.jsb.ts @@ -32,6 +32,8 @@ import { PipelineSceneData } from './pipeline-scene-data'; import { DeferredPipelineSceneData } from './deferred/deferred-pipeline-scene-data'; import { legacyCC } from '../../core/global-exports'; import { Asset } from '../assets/asset'; +import { Swapchain } from '../gfx'; +import { Model } from '../renderer/scene'; nr.getPhaseID = getPhaseID; @@ -76,8 +78,8 @@ export class ForwardPipeline extends nr.ForwardPipeline { this.initialize(info); } - public activate () { - return super.activate() && this.pipelineSceneData.activate(legacyCC.director.root.device, this as any); + public activate (swapchain: Swapchain) { + return super.activate(swapchain) && this.pipelineSceneData.activate(legacyCC.director.root.device, this as any); } public render (cameras) { @@ -88,6 +90,10 @@ export class ForwardPipeline extends nr.ForwardPipeline { super.render(nativeObjs); } + set profiler (value: Model) { + this.setProfiler(value.native); + } + public destroy () { this.pipelineSceneData.destroy(); super.destroy(); @@ -204,8 +210,8 @@ export class DeferredPipeline extends nr.DeferredPipeline { this.initialize(info); } - public activate () { - return super.activate() && this.pipelineSceneData.activate(legacyCC.director.root.device, this as any); + public activate (swapchain: Swapchain) { + return super.activate(swapchain) && this.pipelineSceneData.activate(legacyCC.director.root.device, this as any); } public render (cameras) { @@ -216,6 +222,10 @@ export class DeferredPipeline extends nr.DeferredPipeline { super.render(nativeObjs); } + set profiler (value: Model) { + this.setProfiler(value.native); + } + destroy () { this.fog.destroy(); this.ambient.destroy(); diff --git a/cocos/core/pipeline/pipeline-serialization.ts b/cocos/core/pipeline/pipeline-serialization.ts index f655a78035..81ca22cc00 100644 --- a/cocos/core/pipeline/pipeline-serialization.ts +++ b/cocos/core/pipeline/pipeline-serialization.ts @@ -121,7 +121,7 @@ export class ColorDesc { @type([AccessType]) public beginAccesses: AccessType[] = []; @type([AccessType]) - public endAccesses: AccessType[] = [AccessType.PRESENT]; + public endAccesses: AccessType[] = [AccessType.COLOR_ATTACHMENT_WRITE]; } @ccclass('DepthStencilDesc') diff --git a/cocos/core/pipeline/pipeline-state-manager.ts b/cocos/core/pipeline/pipeline-state-manager.ts index d3b624e647..f3149a9e8e 100644 --- a/cocos/core/pipeline/pipeline-state-manager.ts +++ b/cocos/core/pipeline/pipeline-state-manager.ts @@ -39,7 +39,7 @@ export class PipelineStateManager { const hash1 = pass.hash; const hash2 = renderPass.hash; const hash3 = ia.attributesHash; - const hash4 = shader.id; + const hash4 = shader.typedID; const newHash = hash1 ^ hash2 ^ hash3 ^ hash4; let pso = this._PSOHashMap.get(newHash); diff --git a/cocos/core/pipeline/pipeline-ubo.ts b/cocos/core/pipeline/pipeline-ubo.ts index f4676c9a2b..608116aa57 100644 --- a/cocos/core/pipeline/pipeline-ubo.ts +++ b/cocos/core/pipeline/pipeline-ubo.ts @@ -24,7 +24,7 @@ */ import { UBOGlobal, UBOShadow, UBOCamera, UNIFORM_SHADOWMAP_BINDING, supportsHalfFloatTexture } from './define'; -import { Device, BufferInfo, BufferUsageBit, MemoryUsageBit, Feature } from '../gfx'; +import { Device, BufferInfo, BufferUsageBit, MemoryUsageBit, Feature, Swapchain } from '../gfx'; import { Camera } from '../renderer/scene/camera'; import { Mat4, Vec3, Vec4, Color } from '../math'; import { RenderPipeline } from './render-pipeline'; @@ -33,6 +33,7 @@ import { PCFType, Shadows, ShadowType } from '../renderer/scene/shadows'; import { getShadowWorldMatrix, updatePlanarPROJ } from './scene-culling'; import { Light, LightType } from '../renderer/scene/light'; import { SpotLight } from '../renderer/scene'; +import { RenderWindow } from '../renderer/core/render-window'; const matShadowView = new Mat4(); const matShadowViewProj = new Mat4(); @@ -40,23 +41,22 @@ const vec3_center = new Vec3(); const vec4ShadowInfo = new Vec4(); export class PipelineUBO { - public static updateGlobalUBOView (pipeline: RenderPipeline, bufferView: Float32Array) { - const device = pipeline.device; + public static updateGlobalUBOView (window: RenderWindow, bufferView: Float32Array) { const root = legacyCC.director.root; const fv = bufferView; - const shadingWidth = Math.floor(device.width); - const shadingHeight = Math.floor(device.height); + const shadingWidth = Math.floor(window.width); + const shadingHeight = Math.floor(window.height); // update UBOGlobal fv[UBOGlobal.TIME_OFFSET] = root.cumulativeTime; fv[UBOGlobal.TIME_OFFSET + 1] = root.frameTime; fv[UBOGlobal.TIME_OFFSET + 2] = legacyCC.director.getTotalFrames(); - fv[UBOGlobal.SCREEN_SIZE_OFFSET] = device.width; - fv[UBOGlobal.SCREEN_SIZE_OFFSET + 1] = device.height; - fv[UBOGlobal.SCREEN_SIZE_OFFSET + 2] = 1.0 / device.width; - fv[UBOGlobal.SCREEN_SIZE_OFFSET + 3] = 1.0 / device.height; + fv[UBOGlobal.SCREEN_SIZE_OFFSET] = shadingWidth; + fv[UBOGlobal.SCREEN_SIZE_OFFSET + 1] = shadingHeight; + fv[UBOGlobal.SCREEN_SIZE_OFFSET + 2] = 1.0 / shadingWidth; + fv[UBOGlobal.SCREEN_SIZE_OFFSET + 3] = 1.0 / shadingHeight; fv[UBOGlobal.NATIVE_SIZE_OFFSET] = shadingWidth; fv[UBOGlobal.NATIVE_SIZE_OFFSET + 1] = shadingHeight; @@ -66,14 +66,14 @@ export class PipelineUBO { public static updateCameraUBOView (pipeline: RenderPipeline, bufferView: Float32Array, camera: Camera) { - const device = pipeline.device; + const root = legacyCC.director.root; const scene = camera.scene ? camera.scene : legacyCC.director.getScene().renderScene; const mainLight = scene.mainLight; const sceneData = pipeline.pipelineSceneData; const ambient = sceneData.ambient; const fog = sceneData.fog; - const shadingWidth = Math.floor(device.width); - const shadingHeight = Math.floor(device.height); + const shadingWidth = Math.floor(root.mainWindow.width); + const shadingHeight = Math.floor(root.mainWindow.height); const cv = bufferView; const exposure = camera.exposure; const isHDR = sceneData.isHDR; @@ -348,12 +348,12 @@ export class PipelineUBO { * @en Update all UBOs * @zh 更新全部 UBO。 */ - public updateGlobalUBO () { + public updateGlobalUBO (window: RenderWindow) { const globalDSManager = this._pipeline.globalDSManager; const ds = this._pipeline.descriptorSet; const cmdBuffer = this._pipeline.commandBuffers; ds.update(); - PipelineUBO.updateGlobalUBOView(this._pipeline, this._globalUBO); + PipelineUBO.updateGlobalUBOView(window, this._globalUBO); cmdBuffer[0].updateBuffer(ds.getBuffer(UBOGlobal.BINDING), this._globalUBO); globalDSManager.bindBuffer(UBOGlobal.BINDING, ds.getBuffer(UBOGlobal.BINDING)); diff --git a/cocos/core/pipeline/render-additive-light-queue.ts b/cocos/core/pipeline/render-additive-light-queue.ts index 3046ebe154..4a6d13cb39 100644 --- a/cocos/core/pipeline/render-additive-light-queue.ts +++ b/cocos/core/pipeline/render-additive-light-queue.ts @@ -162,8 +162,6 @@ export class RenderAdditiveLightQueue { const descriptorSet = descriptorSetMap.get(key)!; if (descriptorSet) { descriptorSet.getBuffer(UBOShadow.BINDING).destroy(); - descriptorSet.getSampler(UNIFORM_SHADOWMAP_BINDING).destroy(); - descriptorSet.getSampler(UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING).destroy(); descriptorSet.getTexture(UNIFORM_SHADOWMAP_BINDING).destroy(); descriptorSet.getTexture(UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING).destroy(); descriptorSet.destroy(); diff --git a/cocos/core/pipeline/render-pipeline.ts b/cocos/core/pipeline/render-pipeline.ts index 3de198b256..ab5bbafb93 100644 --- a/cocos/core/pipeline/render-pipeline.ts +++ b/cocos/core/pipeline/render-pipeline.ts @@ -33,11 +33,13 @@ import { legacyCC } from '../global-exports'; import { Asset } from '../assets/asset'; import { RenderFlow } from './render-flow'; import { MacroRecord } from '../renderer/core/pass-utils'; -import { Device, DescriptorSet, CommandBuffer, Feature, Rect } from '../gfx'; +import { Device, DescriptorSet, CommandBuffer, Feature, Rect, Swapchain } from '../gfx'; import { Camera } from '../renderer/scene/camera'; import { PipelineUBO } from './pipeline-ubo'; import { PipelineSceneData } from './pipeline-scene-data'; import { GlobalDSManager } from './global-descriptor-set-manager'; +import { Root } from '../root'; +import { Model } from '../renderer/scene/model'; /** * @en Render pipeline information descriptor @@ -145,6 +147,14 @@ export abstract class RenderPipeline extends Asset { return this._pipelineSceneData; } + set profiler (value) { + this._profiler = value; + } + + get profiler () { + return this._profiler; + } + protected _device!: Device; protected _globalDSManager!: GlobalDSManager; protected _descriptorSet!: DescriptorSet; @@ -152,6 +162,7 @@ export abstract class RenderPipeline extends Asset { protected _pipelineUBO = new PipelineUBO(); protected _macros: MacroRecord = {}; protected _constantMacros = ''; + protected _profiler: Model | null = null; protected declare _pipelineSceneData: PipelineSceneData; /** @@ -176,8 +187,9 @@ export abstract class RenderPipeline extends Asset { const vp = camera.viewport; const sceneData = this.pipelineSceneData; // render area is not oriented - const w = camera.window!.hasOnScreenAttachments && this.device.surfaceTransform % 2 ? camera.height : camera.width; - const h = camera.window!.hasOnScreenAttachments && this.device.surfaceTransform % 2 ? camera.width : camera.height; + const swapchain = camera.window!.swapchain; + const w = swapchain && swapchain.surfaceTransform % 2 ? camera.height : camera.width; + const h = swapchain && swapchain.surfaceTransform % 2 ? camera.width : camera.height; res.x = vp.x * w; res.y = vp.y * h; res.width = vp.width * w * sceneData.shadingScale; @@ -188,9 +200,12 @@ export abstract class RenderPipeline extends Asset { /** * @en Activate the render pipeline after loaded, it mainly activate the flows * @zh 当渲染管线资源加载完成后,启用管线,主要是启用管线内的 flow + * TODO: remove swapchain dependency at this stage + * after deferred pipeline can handle multiple swapchains */ - public activate (): boolean { - this._device = legacyCC.director.root.device; + public activate (swapchain: Swapchain): boolean { + const root = legacyCC.director.root as Root; + this._device = root.device; this._globalDSManager = new GlobalDSManager(this); this._descriptorSet = this._globalDSManager.globalDescriptorSet; this._pipelineUBO.activate(this._device, this); diff --git a/cocos/core/pipeline/render-queue.ts b/cocos/core/pipeline/render-queue.ts index 3c7707a51c..b1e7c4fe0c 100644 --- a/cocos/core/pipeline/render-queue.ts +++ b/cocos/core/pipeline/render-queue.ts @@ -112,7 +112,7 @@ export class RenderQueue { const rp = this._passPool.add(); rp.hash = hash; rp.depth = renderObj.depth || 0; - rp.shaderId = shader.id; + rp.shaderId = shader.typedID; rp.subModel = subModel; rp.passIdx = passIdx; this.queue.push(rp); diff --git a/cocos/core/pipeline/scene-culling.ts b/cocos/core/pipeline/scene-culling.ts index 9e6d644377..14677b8c99 100644 --- a/cocos/core/pipeline/scene-culling.ts +++ b/cocos/core/pipeline/scene-culling.ts @@ -37,6 +37,7 @@ import { Pool } from '../memop'; import { IRenderObject, UBOShadow } from './define'; import { ShadowType, Shadows } from '../renderer/scene/shadows'; import { SphereLight, DirectionalLight, Light } from '../renderer/scene'; +import { Layers } from '../scene-graph'; const _tempVec3 = new Vec3(); const _dir_negate = new Vec3(); diff --git a/cocos/core/pipeline/shadow/shadow-flow.ts b/cocos/core/pipeline/shadow/shadow-flow.ts index 6400f6c5c4..83d01f65e2 100644 --- a/cocos/core/pipeline/shadow/shadow-flow.ts +++ b/cocos/core/pipeline/shadow/shadow-flow.ts @@ -35,7 +35,7 @@ import { ForwardFlowPriority } from '../forward/enum'; import { ShadowStage } from './shadow-stage'; import { RenderPass, LoadOp, StoreOp, Format, Texture, TextureType, TextureUsageBit, ColorAttachment, - DepthStencilAttachment, RenderPassInfo, TextureInfo, FramebufferInfo, Feature } from '../../gfx'; + DepthStencilAttachment, RenderPassInfo, TextureInfo, FramebufferInfo, Swapchain } from '../../gfx'; import { RenderFlowTag } from '../pipeline-serialization'; import { ForwardPipeline } from '../forward/forward-pipeline'; import { RenderPipeline } from '..'; @@ -94,7 +94,7 @@ export class ShadowFlow extends RenderFlow { const light = validLights[l]; if (!shadowFrameBufferMap.has(light)) { - this._initShadowFrameBuffer(pipeline, light); + this._initShadowFrameBuffer(pipeline, light, camera.window!.swapchain); } const shadowFrameBuffer = shadowFrameBufferMap.get(light); @@ -138,8 +138,8 @@ export class ShadowFlow extends RenderFlow { if (this._shadowRenderPass) { this._shadowRenderPass.destroy(); } } - public _initShadowFrameBuffer (pipeline: RenderPipeline, light: Light) { - const device = pipeline.device; + public _initShadowFrameBuffer (pipeline: RenderPipeline, light: Light, swapchain: Swapchain) { + const { device } = pipeline; const shadows = pipeline.pipelineSceneData.shadows; const shadowMapSize = shadows.size; const shadowFrameBufferMap = pipeline.pipelineSceneData.shadowFrameBufferMap; @@ -153,7 +153,7 @@ export class ShadowFlow extends RenderFlow { colorAttachment.sampleCount = 1; const depthStencilAttachment = new DepthStencilAttachment(); - depthStencilAttachment.format = device.depthStencilFormat; + depthStencilAttachment.format = Format.DEPTH_STENCIL; depthStencilAttachment.depthLoadOp = LoadOp.CLEAR; depthStencilAttachment.depthStoreOp = StoreOp.DISCARD; depthStencilAttachment.stencilLoadOp = LoadOp.CLEAR; @@ -176,7 +176,7 @@ export class ShadowFlow extends RenderFlow { const depth = device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.DEPTH_STENCIL_ATTACHMENT, - device.depthStencilFormat, + Format.DEPTH_STENCIL, shadowMapSize.x, shadowMapSize.y, )); diff --git a/cocos/core/renderer/core/pass-instance.ts b/cocos/core/renderer/core/pass-instance.ts index c325702e97..245da15bd0 100644 --- a/cocos/core/renderer/core/pass-instance.ts +++ b/cocos/core/renderer/core/pass-instance.ts @@ -28,7 +28,7 @@ * @module material */ -import { IPassInfo } from '../../assets/effect-asset'; +import { EffectAsset } from '../../assets/effect-asset'; import { MaterialInstance } from './material-instance'; import { BatchingSchemes, Pass, PassOverrides } from './pass'; import { overrideMacros, MacroRecord } from './pass-utils'; @@ -82,7 +82,7 @@ export class PassInstance extends Pass { * @param original The original pass info * @param value The override pipeline state info */ - public overridePipelineStates (original: IPassInfo, overrides: PassOverrides): void { + public overridePipelineStates (original: EffectAsset.IPassInfo, overrides: PassOverrides): void { this._bs.reset(); this._rs.reset(); this._dss.reset(); diff --git a/cocos/core/renderer/core/pass-utils.ts b/cocos/core/renderer/core/pass-utils.ts index d3a861e97a..9b872650c1 100644 --- a/cocos/core/renderer/core/pass-utils.ts +++ b/cocos/core/renderer/core/pass-utils.ts @@ -31,35 +31,18 @@ import { Type } from '../../gfx'; import { Color, Mat3, Mat4, Vec2, Vec3, Vec4, Quat, IVec2Like, IVec3Like, IVec4Like, IMat3Like, IMat4Like } from '../../math'; -const dtMask = 0xf0000000; // 4 bits => 16 property types -const typeMask = 0x0fc00000; // 6 bits => 64 types -const setMask = 0x00300000; // 2 bits => 4 sets -const bindingMask = 0x000fc000; // 6 bits => 64 bindings -const offsetMask = 0x00003fff; // 14 bits => 4096 vectors +const typeMask = 0xfc000000; // 6 bits => 64 types +const bindingMask = 0x03f00000; // 6 bits => 64 bindings +const countMask = 0x000ff000; // 8 bits => 256 vectors +const offsetMask = 0x00000fff; // 12 bits => 1024 vectors -/** - * @en The type enums of the property - * @zh Uniform 的绑定类型(UBO 或贴图等) - */ -export enum PropertyType { - /** - * Uniform buffer object - */ - BUFFER, - /** - * Texture sampler - */ - TEXTURE, -} - -export const genHandle = (pt: PropertyType, set: number, binding: number, type: Type, offset = 0): number => ((pt << 28) & dtMask) - | ((type << 22) & typeMask) | ((set << 20) & setMask) | ((binding << 14) & bindingMask) | (offset & offsetMask); -export const getPropertyTypeFromHandle = (handle: number): number => (handle & dtMask) >>> 28; -export const getTypeFromHandle = (handle: number): number => (handle & typeMask) >>> 22; -export const getSetIndexFromHandle = (handle: number): number => (handle & setMask) >>> 20; -export const getBindingFromHandle = (handle: number): number => (handle & bindingMask) >>> 14; +export const genHandle = (binding: number, type: Type, count: number, offset = 0): number => ((type << 26) & typeMask) + | ((binding << 20) & bindingMask) | (count << 12) & countMask | (offset & offsetMask); +export const getTypeFromHandle = (handle: number): number => (handle & typeMask) >>> 26; +export const getBindingFromHandle = (handle: number): number => (handle & bindingMask) >>> 20; +export const getCountFromHandle = (handle: number): number => (handle & countMask) >>> 12; export const getOffsetFromHandle = (handle: number): number => (handle & offsetMask); -export const customizeType = (handle: number, type: Type): number => (handle & ~typeMask) | ((type << 22) & typeMask); +export const customizeType = (handle: number, type: Type): number => (handle & ~typeMask) | ((type << 26) & typeMask); /** * @en Vector type uniforms diff --git a/cocos/core/renderer/core/pass.ts b/cocos/core/renderer/core/pass.ts index 5b4acf3cbc..0afee72fdf 100644 --- a/cocos/core/renderer/core/pass.ts +++ b/cocos/core/renderer/core/pass.ts @@ -34,30 +34,27 @@ import { TextureBase } from '../../assets/texture-base'; import { builtinResMgr } from '../../builtin/builtin-res-mgr'; import { getPhaseID } from '../../pipeline/pass-phase'; import { murmurhash2_32_gc } from '../../utils/murmurhash2_gc'; -import { samplerLib } from './sampler-lib'; -import { - BufferUsageBit, DynamicStateFlagBit, DynamicStateFlags, Feature, GetTypeSize, MemoryUsageBit, PrimitiveMode, Type, Color, +import { BufferUsageBit, DynamicStateFlagBit, DynamicStateFlags, Feature, GetTypeSize, MemoryUsageBit, PrimitiveMode, Type, Color, BlendState, BlendTarget, Buffer, BufferInfo, BufferViewInfo, DepthStencilState, DescriptorSet, - DescriptorSetInfo, DescriptorSetLayout, Device, RasterizerState, Sampler, Texture, Shader, PipelineLayout, DynamicStates, + DescriptorSetInfo, DescriptorSetLayout, Device, RasterizerState, Sampler, Texture, Shader, PipelineLayout, } from '../../gfx'; -import { IPassInfo, IPassStates, IPropertyInfo } from '../../assets/effect-asset'; +import { EffectAsset } from '../../assets/effect-asset'; import { IProgramInfo, programLib } from './program-lib'; -import { - MacroRecord, MaterialProperty, PropertyType, customizeType, - getBindingFromHandle, getDefaultFromType, getOffsetFromHandle, getPropertyTypeFromHandle, getTypeFromHandle, type2reader, type2writer, +import { MacroRecord, MaterialProperty, customizeType, getBindingFromHandle, getDefaultFromType, + getOffsetFromHandle, getTypeFromHandle, type2reader, type2writer, getCountFromHandle, } from './pass-utils'; import { RenderPassStage, RenderPriority } from '../../pipeline/define'; import { NativePass } from '../scene/native-scene'; import { errorID } from '../../platform/debug'; import { PassHandle, PassView, NULL_HANDLE, PassPool } from './memory-pools'; -export interface IPassInfoFull extends IPassInfo { +export interface IPassInfoFull extends EffectAsset.IPassInfo { // generated part passIndex: number; defines: MacroRecord; stateOverrides?: PassOverrides; } -export type PassOverrides = RecursivePartial; +export type PassOverrides = RecursivePartial; export interface IMacroPatch { name: string; @@ -73,7 +70,7 @@ interface IPassDynamics { const _bufferInfo = new BufferInfo( BufferUsageBit.UNIFORM | BufferUsageBit.TRANSFER_DST, - MemoryUsageBit.HOST | MemoryUsageBit.DEVICE, + MemoryUsageBit.DEVICE, ); const _bufferViewInfo = new BufferViewInfo(null!); @@ -87,13 +84,11 @@ export enum BatchingSchemes { } export declare namespace Pass { - export type getPropertyTypeFromHandle = typeof getPropertyTypeFromHandle; - export type getTypeFromHandle = typeof getTypeFromHandle; - export type getBindingFromHandle = typeof getBindingFromHandle; + export type getTypeFromHandle = typeof Pass.getTypeFromHandle; + export type getBindingFromHandle = typeof Pass.getBindingFromHandle; export type fillPipelineInfo = typeof Pass.fillPipelineInfo; export type getPassHash = typeof Pass.getPassHash; - export type getOffsetFromHandle = typeof getOffsetFromHandle; - export type PropertyType = typeof PropertyType; + export type getCountFromHandle = typeof Pass.getCountFromHandle; } /** @@ -102,29 +97,23 @@ export declare namespace Pass { */ export class Pass { /** - * @en The binding type enums of the property - * @zh Uniform 的绑定类型(UBO 或贴图等) - */ - public static PropertyType = PropertyType; - - /** - * @en Gets the binding type of the property with handle - * @zh 根据 handle 获取 uniform 的绑定类型(UBO 或贴图等)。 - */ - public static getPropertyTypeFromHandle = getPropertyTypeFromHandle; - - /** - * @en Gets the type of member in uniform buffer object with the handle - * @zh 根据 handle 获取 UBO member 的具体类型。 + * @en Get the type of member in uniform buffer object with the handle + * @zh 根据 handle 获取 uniform 的具体类型。 */ public static getTypeFromHandle = getTypeFromHandle; /** - * @en Gets the binding with handle + * @en Get the binding with handle * @zh 根据 handle 获取 binding。 */ public static getBindingFromHandle = getBindingFromHandle; + /** + * @en Get the array length with handle + * @zh 根据 handle 获取数组长度。 + */ + public static getCountFromHandle = getCountFromHandle; + protected static getOffsetFromHandle = getOffsetFromHandle; /** @@ -188,7 +177,7 @@ export class Pass { protected _blocks: Float32Array[] = []; protected _shaderInfo: IProgramInfo = null!; protected _defines: MacroRecord = {}; - protected _properties: Record = {}; + protected _properties: Record = {}; protected _shader: Shader | null = null protected _bs: BlendState = new BlendState(); protected _dss: DepthStencilState = new DepthStencilState(); @@ -361,7 +350,7 @@ export class Pass { * @param original The original pass info * @param value The override pipeline state info */ - public overridePipelineStates (original: IPassInfo, overrides: PassOverrides): void { + public overridePipelineStates (original: EffectAsset.IPassInfo, overrides: PassOverrides): void { console.warn('base pass cannot override states, please use pass instance instead.'); } @@ -452,10 +441,13 @@ export class Pass { const type = Pass.getTypeFromHandle(handle); const binding = Pass.getBindingFromHandle(handle); const ofs = Pass.getOffsetFromHandle(handle); + const count = Pass.getCountFromHandle(handle); const block = this._blocks[binding]; const info = this._properties[name]; - const value = (info && info.value) || getDefaultFromType(type); - type2writer[type](block, value, ofs); + const givenDefault = info && info.value; + const value = (givenDefault || getDefaultFromType(type)) as number[]; + const size = (GetTypeSize(type) >> 2) * count; + for (let k = 0; k + value.length <= size; k += value.length) { block.set(value, ofs + k); } this._setRootBufferDirty(true); } @@ -473,8 +465,9 @@ export class Pass { const texName = value ? `${value as string}-texture` : getDefaultFromType(type) as string; const textureBase = builtinResMgr.get(texName); const texture = textureBase && textureBase.getGFXTexture()!; - const samplerHash = info && (info.samplerHash !== undefined) ? info.samplerHash : textureBase && textureBase.getSamplerHash(); - const sampler = samplerLib.getSampler(this._device, samplerHash); + const samplerInfo = info && info.samplerHash !== undefined + ? Sampler.unpackFromHash(info.samplerHash) : textureBase && textureBase.getSamplerInfo(); + const sampler = this._device.getSampler(samplerInfo); this._descriptorSet.bindSampler(binding, sampler, index); this._descriptorSet.bindTexture(binding, texture, index); } @@ -766,15 +759,13 @@ export class Pass { this._setHash(target._hash ^ hashFactor); } - /* eslint-disable max-len */ - // infos get root (): Root { return this._root; } get device (): Device { return this._device; } get shaderInfo (): IProgramInfo { return this._shaderInfo; } get localSetLayout (): DescriptorSetLayout { return programLib.getDescriptorSetLayout(this._device, this._programName, true); } get program (): string { return this._programName; } - get properties (): Record { return this._properties; } + get properties (): Record { return this._properties; } get defines (): Record { return this._defines; } get passIndex (): number { return this._passIndex; } get propertyIndex (): number { return this._propertyIndex; } diff --git a/cocos/core/renderer/core/program-lib.ts b/cocos/core/renderer/core/program-lib.ts index 94ad64bc03..0f33796191 100644 --- a/cocos/core/renderer/core/program-lib.ts +++ b/cocos/core/renderer/core/program-lib.ts @@ -28,10 +28,10 @@ * @module material */ -import { EffectAsset, IBlockInfo, IBuiltinInfo, IDefineInfo, IShaderInfo } from '../../assets/effect-asset'; +import { EffectAsset } from '../../assets/effect-asset'; import { SetIndex, IDescriptorSetLayoutInfo, globalDescriptorSetLayout, localDescriptorSetLayout } from '../../pipeline/define'; import { RenderPipeline } from '../../pipeline/render-pipeline'; -import { genHandle, MacroRecord, PropertyType } from './pass-utils'; +import { genHandle, MacroRecord } from './pass-utils'; import { legacyCC } from '../../global-exports'; import { PipelineLayoutInfo, Device, Attribute, UniformBlock, ShaderInfo, Uniform, ShaderStage, DESCRIPTOR_SAMPLER_TYPE, DESCRIPTOR_BUFFER_TYPE, @@ -41,7 +41,7 @@ import { debug } from '../../platform/debug'; const _dsLayoutInfo = new DescriptorSetLayoutInfo(); -interface IDefineRecord extends IDefineInfo { +interface IDefineRecord extends EffectAsset.IDefineInfo { _map: (value: any) => number; _offset: number; } @@ -59,7 +59,7 @@ export interface ITemplateInfo { samplerStartBinding: number; } -export interface IProgramInfo extends IShaderInfo { +export interface IProgramInfo extends EffectAsset.IShaderInfo { effectName: string; defines: IDefineRecord[]; constantMacros: string; @@ -76,7 +76,7 @@ function getBitCount (cnt: number) { return Math.ceil(Math.log2(Math.max(cnt, 2))); } -function mapDefine (info: IDefineInfo, def: number | string | boolean) { +function mapDefine (info: EffectAsset.IDefineInfo, def: number | string | boolean) { switch (info.type) { case 'boolean': return typeof def === 'number' ? def.toString() : (def ? '1' : '0'); case 'string': return def !== undefined ? def as string : info.options![0]; @@ -87,7 +87,7 @@ function mapDefine (info: IDefineInfo, def: number | string | boolean) { } } -function prepareDefines (defs: MacroRecord, tDefs: IDefineInfo[]) { +function prepareDefines (defs: MacroRecord, tDefs: EffectAsset.IDefineInfo[]) { const macros: IMacroInfo[] = []; for (let i = 0; i < tDefs.length; i++) { const tmpl = tDefs[i]; @@ -106,9 +106,9 @@ function getShaderInstanceName (name: string, macros: IMacroInfo[]) { function insertBuiltinBindings ( tmpl: IProgramInfo, tmplInfo: ITemplateInfo, source: IDescriptorSetLayoutInfo, - type: string, outBindings?: DescriptorSetLayoutBinding[], + type: 'locals' | 'globals', outBindings?: DescriptorSetLayoutBinding[], ) { - const target = tmpl.builtins[type] as IBuiltinInfo; + const target = tmpl.builtins[type]; const tempBlocks: UniformBlock[] = []; for (let i = 0; i < target.blocks.length; i++) { const b = target.blocks[i]; @@ -138,7 +138,7 @@ function insertBuiltinBindings ( if (outBindings) outBindings.sort((a, b) => a.binding - b.binding); } -function getSize (block: IBlockInfo) { +function getSize (block: EffectAsset.IBlockInfo) { return block.members.reduce((s, m) => s + GetTypeSize(m.type) * m.count, 0); } @@ -151,14 +151,14 @@ function genHandles (tmpl: IProgramInfo) { let offset = 0; for (let j = 0; j < members.length; j++) { const uniform = members[j]; - handleMap[uniform.name] = genHandle(PropertyType.BUFFER, SetIndex.MATERIAL, block.binding, uniform.type, offset); - offset += (GetTypeSize(uniform.type) >> 2) * uniform.count; + handleMap[uniform.name] = genHandle(block.binding, uniform.type, uniform.count, offset); + offset += (GetTypeSize(uniform.type) >> 2) * uniform.count; // assumes no implicit padding, which is guaranteed by effect compiler } } // samplerTexture handles for (let i = 0; i < tmpl.samplerTextures.length; i++) { const samplerTexture = tmpl.samplerTextures[i]; - handleMap[samplerTexture.name] = genHandle(PropertyType.TEXTURE, SetIndex.MATERIAL, samplerTexture.binding, samplerTexture.type); + handleMap[samplerTexture.name] = genHandle(samplerTexture.binding, samplerTexture.type, samplerTexture.count); } return handleMap; } @@ -205,7 +205,7 @@ class ProgramLib { * @en Register the shader template with the given info * @zh 注册 shader 模板。 */ - public define (shader: IShaderInfo) { + public define (shader: EffectAsset.IShaderInfo) { const curTmpl = this._templates[shader.name]; if (curTmpl && curTmpl.hash === shader.hash) { return curTmpl; } const tmpl = ({ ...shader }) as IProgramInfo; diff --git a/cocos/core/renderer/core/render-window.ts b/cocos/core/renderer/core/render-window.ts index 5164faf93f..c30b5ce299 100644 --- a/cocos/core/renderer/core/render-window.ts +++ b/cocos/core/renderer/core/render-window.ts @@ -25,7 +25,7 @@ import { JSB } from 'internal:constants'; import { TextureType, TextureUsageBit, Format, RenderPass, Texture, Framebuffer, - RenderPassInfo, Device, TextureInfo, FramebufferInfo, + RenderPassInfo, Device, TextureInfo, FramebufferInfo, Swapchain, TextureFlagBit, } from '../../gfx'; import { Root } from '../../root'; import { Camera, NativeRenderWindow } from '../scene'; @@ -35,8 +35,7 @@ export interface IRenderWindowInfo { width: number; height: number; renderPassInfo: RenderPassInfo; - swapchainBufferIndices?: number; - shouldSyncSizeWithSwapchain?: boolean; + swapchain?: Swapchain; } /** @@ -60,6 +59,14 @@ export class RenderWindow { return this._height; } + /** + * @en Get the swapchain for this window, if there is one + * @zh 如果存在的话,获取此窗口的交换链 + */ + get swapchain () { + return this._swapchain; + } + /** * @en Get window frame buffer. * @zh 帧缓冲对象。 @@ -68,26 +75,6 @@ export class RenderWindow { return this._framebuffer!; } - get shouldSyncSizeWithSwapchain () { - return this._shouldSyncSizeWithSwapchain; - } - - /** - * @en Whether it has on screen attachments - * @zh 这个渲染窗口是否指向在屏缓冲 - */ - get hasOnScreenAttachments () { - return this._hasOnScreenAttachments; - } - - /** - * @en Whether it has off screen attachments - * @zh 这个渲染窗口是否指向离屏缓冲 - */ - get hasOffScreenAttachments () { - return this._hasOffScreenAttachments; - } - get cameras () { return this._cameras; } @@ -102,11 +89,10 @@ export class RenderWindow { protected _title = ''; protected _width = 1; protected _height = 1; + protected _swapchain: Swapchain = null!; protected _renderPass: RenderPass | null = null; - protected _colorTextures: (Texture | null)[] = []; + protected _colorTextures: Texture[] = []; protected _depthStencilTexture: Texture | null = null; - protected _swapchainBufferIndices = 0; - protected _shouldSyncSizeWithSwapchain = false; protected _cameras: Camera[] = []; protected _hasOnScreenAttachments = false; protected _hasOffScreenAttachments = false; @@ -117,114 +103,65 @@ export class RenderWindow { return this._nativeObj; } - private constructor (root: Root) { - } - - private _setHasOffScreenAttachments (val) { - this._hasOffScreenAttachments = val; - if (JSB) { - this._nativeObj!.hasOffScreenAttachments = val; - } - } - - private _setHasOnScreenAttachments (val) { - this._hasOnScreenAttachments = val; - if (JSB) { - this._nativeObj!.hasOnScreenAttachments = val; - } - } - - private _createFrameBuffer (device: Device, renderPass) { - this._framebuffer = device.createFramebuffer(new FramebufferInfo( - renderPass, - this._colorTextures, - this._depthStencilTexture, - )); - if (JSB) { - this._nativeObj!.frameBuffer = this._framebuffer; - } - } - - protected _init () { - if (JSB) { - this._nativeObj = new NativeRenderWindow(); - } - } + private constructor (root: Root) {} public initialize (device: Device, info: IRenderWindowInfo): boolean { this._init(); + if (info.title !== undefined) { this._title = info.title; } - if (info.swapchainBufferIndices !== undefined) { - this._swapchainBufferIndices = info.swapchainBufferIndices; - } - - if (info.shouldSyncSizeWithSwapchain !== undefined) { - this._shouldSyncSizeWithSwapchain = info.shouldSyncSizeWithSwapchain; + if (info.swapchain !== undefined) { + this._swapchain = info.swapchain; } this._width = info.width; this._height = info.height; - - const { colorAttachments, depthStencilAttachment } = info.renderPassInfo; - for (let i = 0; i < colorAttachments.length; i++) { - if (colorAttachments[i].format === Format.UNKNOWN) { - colorAttachments[i].format = device.colorFormat; - } - } - if (depthStencilAttachment && depthStencilAttachment.format === Format.UNKNOWN) { - depthStencilAttachment.format = device.depthStencilFormat; - } - this._renderPass = device.createRenderPass(info.renderPassInfo); - for (let i = 0; i < colorAttachments.length; i++) { - let colorTex: Texture | null = null; - if (!(this._swapchainBufferIndices & (1 << i))) { - colorTex = device.createTexture(new TextureInfo( + if (info.swapchain) { + this._setSwapchain(info.swapchain); + this._colorTextures.push(info.swapchain.colorTexture); + this._depthStencilTexture = info.swapchain.depthStencilTexture; + } else { + for (let i = 0; i < info.renderPassInfo.colorAttachments.length; i++) { + this._colorTextures.push(device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.COLOR_ATTACHMENT | TextureUsageBit.SAMPLED, - colorAttachments[i].format, + info.renderPassInfo.colorAttachments[i].format, this._width, this._height, - )); - this._setHasOffScreenAttachments(true); - } else { - this._setHasOnScreenAttachments(true); + ))); } - this._colorTextures.push(colorTex); - } - - // Use the sign bit to indicate depth attachment - if (depthStencilAttachment) { - if (this._swapchainBufferIndices >= 0) { + if (info.renderPassInfo.depthStencilAttachment.format !== Format.UNKNOWN) { this._depthStencilTexture = device.createTexture(new TextureInfo( TextureType.TEX2D, TextureUsageBit.DEPTH_STENCIL_ATTACHMENT | TextureUsageBit.SAMPLED, - depthStencilAttachment.format, + info.renderPassInfo.depthStencilAttachment.format, this._width, this._height, )); - this._setHasOffScreenAttachments(true); } - } else { - this._setHasOnScreenAttachments(true); } - this._createFrameBuffer(device, this._renderPass); - return true; - } - protected _destroy () { - this.framebuffer.destroy(); - if (JSB) { - this._nativeObj = null; - } + this._setFrameBuffer(device.createFramebuffer(new FramebufferInfo( + this._renderPass, + this._colorTextures, + this._depthStencilTexture, + ))); + + return true; } public destroy () { this.clearCameras(); + + if (this._framebuffer) { + this._framebuffer.destroy(); + this._framebuffer = null; + } + if (this._depthStencilTexture) { this._depthStencilTexture.destroy(); this._depthStencilTexture = null; @@ -237,6 +174,7 @@ export class RenderWindow { } } this._colorTextures.length = 0; + this._destroy(); } @@ -250,25 +188,38 @@ export class RenderWindow { this._width = width; this._height = height; - let needRebuild = false; + if (this._swapchain) { + this._swapchain.resize(width, height); + } else { + if (this._depthStencilTexture) { + this._depthStencilTexture.destroy(); + this._depthStencilTexture.initialize(new TextureInfo( + TextureType.TEX2D, + TextureUsageBit.DEPTH_STENCIL_ATTACHMENT | TextureUsageBit.SAMPLED, + this._renderPass!.depthStencilAttachment!.format, + this._width, + this._height, + )); + } - if (this._depthStencilTexture) { - this._depthStencilTexture.resize(width, height); - needRebuild = true; - } - - for (let i = 0; i < this._colorTextures.length; i++) { - const colorTex = this._colorTextures[i]; - if (colorTex) { - colorTex.resize(width, height); - needRebuild = true; + for (let i = 0; i < this._colorTextures.length; i++) { + const colorTex = this._colorTextures[i]; + if (colorTex) { + colorTex.destroy(); + colorTex.initialize(new TextureInfo( + TextureType.TEX2D, + TextureUsageBit.COLOR_ATTACHMENT | TextureUsageBit.SAMPLED, + this._renderPass!.colorAttachments[i].format, + this._width, + this._height, + )); + } } } - const framebuffer = this.framebuffer; - if (needRebuild && framebuffer) { - framebuffer.destroy(); - framebuffer.initialize(new FramebufferInfo( + if (this.framebuffer) { + this.framebuffer.destroy(); + this.framebuffer.initialize(new FramebufferInfo( this._renderPass!, this._colorTextures, this._depthStencilTexture, @@ -332,4 +283,32 @@ export class RenderWindow { public sortCameras () { this._cameras.sort((a: Camera, b: Camera) => a.priority - b.priority); } + + // ====================== Native Specific ====================== // + + private _init () { + if (JSB) { + this._nativeObj = new NativeRenderWindow(); + } + } + + private _destroy () { + if (JSB) { + this._nativeObj = null; + } + } + + private _setSwapchain (val: Swapchain) { + this._swapchain = val; + if (JSB) { + this._nativeObj!.swapchain = val; + } + } + + private _setFrameBuffer (val: Framebuffer) { + this._framebuffer = val; + if (JSB) { + this._nativeObj!.frameBuffer = val; + } + } } diff --git a/cocos/core/renderer/core/sampler-lib.ts b/cocos/core/renderer/core/sampler-lib.ts deleted file mode 100644 index a658f2af77..0000000000 --- a/cocos/core/renderer/core/sampler-lib.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* - Copyright (c) 2017-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. -*/ - -/** - * @packageDocumentation - * @hidden - */ - -import { Address, ComparisonFunc, Filter, Device, Sampler, SamplerInfo, Color } from '../../gfx'; -import { legacyCC } from '../../global-exports'; - -export enum SamplerInfoIndex { - minFilter, - magFilter, - mipFilter, - addressU, - addressV, - addressW, - maxAnisotropy, - cmpFunc, - mipLODBias, - total, -} - -const defaultInfo = [ - Filter.LINEAR, - Filter.LINEAR, - Filter.NONE, - Address.WRAP, - Address.WRAP, - Address.WRAP, - 0, - ComparisonFunc.NEVER, - 0, -]; -export const defaultSamplerHash = genSamplerHash(defaultInfo); - -const borderColor = new Color(); - -const _samplerInfo = new SamplerInfo(); - -export function genSamplerHash (info: (number | undefined)[]): number { - let value = 0; - let hash = 0; - for (let i = 0; i < defaultInfo.length; i++) { - value = (info[i] || defaultInfo[i]); - switch (i) { - case SamplerInfoIndex.minFilter: hash |= value; break; - case SamplerInfoIndex.magFilter: hash |= (value << 2); break; - case SamplerInfoIndex.mipFilter: hash |= (value << 4); break; - case SamplerInfoIndex.addressU: hash |= (value << 6); break; - case SamplerInfoIndex.addressV: hash |= (value << 8); break; - case SamplerInfoIndex.addressW: hash |= (value << 10); break; - case SamplerInfoIndex.maxAnisotropy: hash |= (value << 12); break; - case SamplerInfoIndex.cmpFunc: hash |= (value << 16); break; - case SamplerInfoIndex.mipLODBias: hash |= (value << 28); break; - default: - } - } - return hash; -} - -/** - * @zh - * 维护 sampler 资源实例的全局管理器。 - */ -class SamplerLib { - protected _cache: Record = {}; - - /** - * @zh - * 获取指定属性的 sampler 资源。 - * @param device 渲染设备 GFX [[Device]] - * @param info 目标 sampler 属性 - */ - public getSampler (device: Device, hash: number) { - if (!hash) { hash = defaultSamplerHash; } - const cache = this._cache[hash]; - if (cache) { return cache; } - - _samplerInfo.minFilter = (hash & 3); - _samplerInfo.magFilter = ((hash >> 2) & 3); - _samplerInfo.mipFilter = ((hash >> 4) & 3); - _samplerInfo.addressU = ((hash >> 6) & 3); - _samplerInfo.addressV = ((hash >> 8) & 3); - _samplerInfo.addressW = ((hash >> 10) & 3); - _samplerInfo.maxAnisotropy = ((hash >> 12) & 15); - _samplerInfo.cmpFunc = ((hash >> 16) & 15); - _samplerInfo.mipLODBias = ((hash >> 28) & 15); - _samplerInfo.borderColor = borderColor; - - const sampler = this._cache[hash] = device.createSampler(_samplerInfo); - return sampler; - } -} - -export const samplerLib = new SamplerLib(); -legacyCC.samplerLib = samplerLib; diff --git a/cocos/core/renderer/core/texture-buffer-pool.ts b/cocos/core/renderer/core/texture-buffer-pool.ts index 5edf08246d..ed08459ecd 100644 --- a/cocos/core/renderer/core/texture-buffer-pool.ts +++ b/cocos/core/renderer/core/texture-buffer-pool.ts @@ -175,7 +175,6 @@ export class TextureBufferPool { this._format, length, length, - TextureFlagBit.IMMUTABLE, )); const chunk: ITextureBuffer = { diff --git a/cocos/core/renderer/index.ts b/cocos/core/renderer/index.ts index e7dedb19d5..fbe9744874 100644 --- a/cocos/core/renderer/index.ts +++ b/cocos/core/renderer/index.ts @@ -38,7 +38,6 @@ export * from './core/constants'; export * from './core/pass-utils'; export * from './core/pass'; export * from './core/program-lib'; -export * from './core/sampler-lib'; export * from './core/texture-buffer-pool'; export * from './core/material-instance'; export * from './core/pass-instance'; diff --git a/cocos/core/renderer/scene/camera.ts b/cocos/core/renderer/scene/camera.ts index 88d10ae189..78c813221c 100644 --- a/cocos/core/renderer/scene/camera.ts +++ b/cocos/core/renderer/scene/camera.ts @@ -25,7 +25,7 @@ import { JSB } from 'internal:constants'; import { Frustum, Ray } from '../../geometry'; -import { SurfaceTransform, ClearFlagBit, Device, Color, ClearFlags } from '../../gfx'; +import { SurfaceTransform, ClearFlagBit, Device, Color, ClearFlags, Swapchain } from '../../gfx'; import { lerp, Mat4, Rect, toRadian, Vec3, IVec4Like, } from '../../math'; @@ -288,14 +288,12 @@ export class Camera { } // projection matrix - let orientation = this._device.surfaceTransform; + const swapchain = this.window?.swapchain; + const orientation = swapchain && swapchain.surfaceTransform || SurfaceTransform.IDENTITY; if (this._isProjDirty || this._curTransform !== orientation) { this._curTransform = orientation; const projectionSignY = this._device.capabilities.clipSpaceSignY; // Only for rendertexture processing - if (this.window?.hasOffScreenAttachments) { - orientation = SurfaceTransform.IDENTITY; - } if (this._proj === CameraProjection.PERSPECTIVE) { Mat4.perspective(this._matProj, this._fov, this._aspect, this._nearClip, this._farClip, this._fovAxis === CameraFOVAxis.VERTICAL, this._device.capabilities.clipSpaceMinZ, projectionSignY, orientation); @@ -422,7 +420,10 @@ export class Camera { const { x, width, height } = val; const y = this._device.capabilities.clipSpaceSignY < 0 ? 1 - val.y - height : val.y; - switch (this._device.surfaceTransform) { + const swapchain = this.window?.swapchain; + const orientation = swapchain && swapchain.surfaceTransform || SurfaceTransform.IDENTITY; + + switch (orientation) { case SurfaceTransform.ROTATE_90: this._viewport.x = 1 - y - height; this._viewport.y = x; diff --git a/cocos/core/renderer/scene/model.ts b/cocos/core/renderer/scene/model.ts index b414b93b11..cb76048166 100644 --- a/cocos/core/renderer/scene/model.ts +++ b/cocos/core/renderer/scene/model.ts @@ -37,19 +37,15 @@ import { SubModel } from './submodel'; import { Pass, IMacroPatch, BatchingSchemes } from '../core/pass'; import { legacyCC } from '../../global-exports'; import { InstancedBuffer } from '../../pipeline/instanced-buffer'; - import { Mat4, Vec3, Vec4 } from '../../math'; -import { genSamplerHash, samplerLib } from '../core/sampler-lib'; import { Attribute, DescriptorSet, Device, Buffer, BufferInfo, getTypedArrayConstructor, - BufferUsageBit, FormatInfos, MemoryUsageBit, Filter, Address, Feature } from '../../gfx'; + BufferUsageBit, FormatInfos, MemoryUsageBit, Filter, Address, Feature, SamplerInfo } from '../../gfx'; import { INST_MAT_WORLD, UBOLocal, UNIFORM_LIGHTMAP_TEXTURE_BINDING } from '../../pipeline/define'; import { NativeBakedSkinningModel, NativeModel, NativeSkinningModel } from './native-scene'; import { Pool } from '../../memop/pool'; const m4_1 = new Mat4(); -const _subModelPool = new Pool(() => new SubModel(), 32); - const shadowMapPatches: IMacroPatch[] = [ { name: 'CC_RECEIVE_SHADOW', value: true }, ]; @@ -75,23 +71,23 @@ function uploadMat4AsVec4x3 (mat: Mat4, v1: ArrayBufferView, v2: ArrayBufferView v3[0] = mat.m08; v3[1] = mat.m09; v3[2] = mat.m10; v3[3] = mat.m14; } -const lightmapSamplerHash = genSamplerHash([ +const lightmapSamplerHash = new SamplerInfo( Filter.LINEAR, Filter.LINEAR, Filter.NONE, Address.CLAMP, Address.CLAMP, Address.CLAMP, -]); +); -const lightmapSamplerWithMipHash = genSamplerHash([ +const lightmapSamplerWithMipHash = new SamplerInfo( Filter.LINEAR, Filter.LINEAR, Filter.LINEAR, Address.CLAMP, Address.CLAMP, Address.CLAMP, -]); +); /** * A representation of a model @@ -448,7 +444,7 @@ export class Model { const gfxTexture = texture.getGFXTexture(); if (gfxTexture) { - const sampler = samplerLib.getSampler(this._device, texture.mipmaps.length > 1 ? lightmapSamplerWithMipHash : lightmapSamplerHash); + const sampler = this._device.getSampler(texture.mipmaps.length > 1 ? lightmapSamplerWithMipHash : lightmapSamplerHash); const subModels = this._subModels; for (let i = 0; i < subModels.length; i++) { const { descriptorSet } = subModels[i]; @@ -538,7 +534,7 @@ export class Model { if (!this._localBuffer) { this._localBuffer = this._device.createBuffer(new BufferInfo( BufferUsageBit.UNIFORM | BufferUsageBit.TRANSFER_DST, - MemoryUsageBit.HOST | MemoryUsageBit.DEVICE, + MemoryUsageBit.DEVICE, UBOLocal.SIZE, UBOLocal.SIZE, )); diff --git a/cocos/core/renderer/scene/native-scene.ts b/cocos/core/renderer/scene/native-scene.ts index 097e3c4e17..7ab1645e7d 100644 --- a/cocos/core/renderer/scene/native-scene.ts +++ b/cocos/core/renderer/scene/native-scene.ts @@ -1,7 +1,7 @@ import { IFlatBuffer } from '../../assets/rendering-sub-mesh'; import { Frustum } from '../../geometry'; -import { Attribute, Buffer, ClearFlags, Color as GFXColor, DescriptorSet, Framebuffer, InputAssembler, Shader, - BlendState, DepthStencilState, RasterizerState } from '../../gfx'; +import { Attribute, BlendState, Buffer, ClearFlags, Color as GFXColor, DepthStencilState, + DescriptorSet, Framebuffer, InputAssembler, RasterizerState, Shader, Swapchain } from '../../gfx'; import { Color, Mat4, Rect, Vec2 } from '../../math'; import { RenderPriority } from '../../pipeline/define'; import { LightType } from './light'; @@ -152,8 +152,7 @@ export const NativeFog: Constructor<{ export type NativeFog = InstanceType; export const NativeRenderWindow: Constructor<{ - hasOffScreenAttachments: boolean; - hasOnScreenAttachments: boolean; + swapchain: Swapchain; frameBuffer: Framebuffer; }> = null!; export type NativeRenderWindow = InstanceType; diff --git a/cocos/core/renderer/scene/skybox.ts b/cocos/core/renderer/scene/skybox.ts index 7224cdee09..e76ba60b4a 100644 --- a/cocos/core/renderer/scene/skybox.ts +++ b/cocos/core/renderer/scene/skybox.ts @@ -30,14 +30,13 @@ import { Mesh } from '../../../3d/assets/mesh'; import { TextureCube } from '../../assets/texture-cube'; import { UNIFORM_ENVIRONMENT_BINDING } from '../../pipeline/define'; import { MaterialInstance } from '../core/material-instance'; -import { samplerLib } from '../core/sampler-lib'; import { Model } from './model'; import { legacyCC } from '../../global-exports'; -import { DescriptorSet } from '../../gfx'; import { SkyboxInfo } from '../../scene-graph/scene-globals'; import { Root } from '../../root'; import { NaitveSkybox } from './native-scene'; import { GlobalDSManager } from '../../pipeline/global-descriptor-set-manager'; +import { Device } from '../../gfx'; let skybox_mesh: Mesh | null = null; let skybox_material: Material | null = null; @@ -204,7 +203,8 @@ export class Skybox { protected _updateGlobalBinding () { const texture = this.envmap!.getGFXTexture()!; - const sampler = samplerLib.getSampler(legacyCC.director._device, this.envmap!.getSamplerHash()); + const device = legacyCC.director.root.device as Device; + const sampler = device.getSampler(this.envmap!.getSamplerInfo()); this._globalDSManager!.bindSampler(UNIFORM_ENVIRONMENT_BINDING, sampler); this._globalDSManager!.bindTexture(UNIFORM_ENVIRONMENT_BINDING, texture); this._globalDSManager!.update(); diff --git a/cocos/core/renderer/scene/submodel.ts b/cocos/core/renderer/scene/submodel.ts index 420fefcb00..6e17750169 100644 --- a/cocos/core/renderer/scene/submodel.ts +++ b/cocos/core/renderer/scene/submodel.ts @@ -28,14 +28,14 @@ import { RenderingSubMesh } from '../../assets/rendering-sub-mesh'; import { RenderPriority, UNIFORM_REFLECTION_TEXTURE_BINDING, UNIFORM_REFLECTION_STORAGE_BINDING } from '../../pipeline/define'; import { BatchingSchemes, IMacroPatch, Pass } from '../core/pass'; import { DescriptorSet, DescriptorSetInfo, Device, InputAssembler, InputAssemblerInfo, Texture, TextureType, TextureUsageBit, TextureInfo, - Format, Sampler, Filter, Address, TextureFlagBit, Shader } from '../../gfx'; + Format, Sampler, Filter, Address, Shader, SamplerInfo } from '../../gfx'; import { legacyCC } from '../../global-exports'; import { ForwardPipeline } from '../../pipeline'; import { errorID } from '../../platform/debug'; import { Shadows } from './shadows'; import { NativePass, NativeSubModel } from './native-scene'; import { getPhaseID } from '../../pipeline/pass-phase'; -import { genSamplerHash, samplerLib } from '../core/sampler-lib'; +import { Root } from '../../root'; const _dsInfo = new DescriptorSetInfo(null!); const MAX_PASS_COUNT = 8; @@ -169,7 +169,8 @@ export class SubModel { } public initialize (subMesh: RenderingSubMesh, passes: Pass[], patches: IMacroPatch[] | null = null): void { - this._device = legacyCC.director.root.device as Device; + const root = legacyCC.director.root as Root; + this._device = root.device; _dsInfo.layout = passes[0].localSetLayout; this._init(); this._setInputAssembler(subMesh.iaInfo); @@ -185,8 +186,8 @@ export class SubModel { // initialize resources for reflection material if (passes[0].phase === getPhaseID('reflection')) { - let texWidth = this._device.width; - let texHeight = this._device.height; + let texWidth = root.mainWindow!.width; + let texHeight = root.mainWindow!.height; const minSize = 512; if (texHeight < texWidth) { @@ -203,22 +204,18 @@ export class SubModel { Format.RGBA8, texWidth, texHeight, - TextureFlagBit.IMMUTABLE, )); this.descriptorSet.bindTexture(UNIFORM_REFLECTION_TEXTURE_BINDING, this._reflectionTex); - const samplerInfo = [ + this._reflectionSampler = this._device.getSampler(new SamplerInfo( Filter.LINEAR, Filter.LINEAR, Filter.NONE, Address.CLAMP, Address.CLAMP, Address.CLAMP, - ]; - - const samplerHash = genSamplerHash(samplerInfo); - this._reflectionSampler = samplerLib.getSampler(this._device, samplerHash); + )); this.descriptorSet.bindSampler(UNIFORM_REFLECTION_TEXTURE_BINDING, this._reflectionSampler); this.descriptorSet.bindTexture(UNIFORM_REFLECTION_STORAGE_BINDING, this._reflectionTex); } @@ -273,7 +270,6 @@ export class SubModel { if (this._reflectionTex) this._reflectionTex.destroy(); this._reflectionTex = null; - if (this._reflectionSampler) this._reflectionSampler.destroy(); this._reflectionSampler = null; this._destroy(); diff --git a/cocos/core/root.ts b/cocos/core/root.ts index d0071d3b2c..8776645cc1 100644 --- a/cocos/core/root.ts +++ b/cocos/core/root.ts @@ -41,7 +41,7 @@ import { SpotLight } from './renderer/scene/spot-light'; import { Batcher2D } from '../2d/renderer/batcher-2d'; import { legacyCC } from './global-exports'; import { RenderWindow, IRenderWindowInfo } from './renderer/core/render-window'; -import { ColorAttachment, DepthStencilAttachment, RenderPassInfo, StoreOp, Device } from './gfx'; +import { ColorAttachment, DepthStencilAttachment, RenderPassInfo, StoreOp, Device, Swapchain } from './gfx'; import { warnID } from './platform/debug'; /** @@ -268,17 +268,22 @@ export class Root { public initialize (info: IRootInfo): Promise { this._init(); + const swapchain: Swapchain = legacyCC.game._swapchain; + const colorAttachment = new ColorAttachment(); + colorAttachment.format = swapchain.colorTexture.format; const depthStencilAttachment = new DepthStencilAttachment(); + depthStencilAttachment.format = swapchain.depthStencilTexture.format; depthStencilAttachment.depthStoreOp = StoreOp.DISCARD; depthStencilAttachment.stencilStoreOp = StoreOp.DISCARD; const renderPassInfo = new RenderPassInfo([colorAttachment], depthStencilAttachment); + this._mainWindow = this.createWindow({ title: 'rootMainWindow', - width: this._device.width, - height: this._device.height, + width: swapchain.width, + height: swapchain.height, renderPassInfo, - swapchainBufferIndices: -1, // always on screen + swapchain, }); this._curWindow = this._mainWindow; @@ -321,12 +326,10 @@ export class Root { // const w = width / cc.view._devicePixelRatio; // const h = height / cc.view._devicePixelRatio; - this._device.resize(width, height); - this._mainWindow!.resize(width, height); for (const window of this._windows) { - if (window.shouldSyncSizeWithSwapchain) { + if (window.swapchain) { window.resize(width, height); } } @@ -348,7 +351,7 @@ export class Root { } this._pipeline = rppl; - if (!this._pipeline.activate()) { + if (!this._pipeline.activate(this._mainWindow!.swapchain)) { if (isCreateDefaultPipeline) { this._pipeline.destroy(); } @@ -439,7 +442,7 @@ export class Root { } if (this._pipeline && cameraList.length > 0) { - this._device.acquire(); + this._device.acquire([legacyCC.game._swapchain]); const scenes = this._scenes; const stamp = legacyCC.director.getTotalFrames(); if (this._batcher) this._batcher.uploadBuffers(); diff --git a/cocos/core/splash-screen.ts b/cocos/core/splash-screen.ts index ce701c16fc..60153752c7 100644 --- a/cocos/core/splash-screen.ts +++ b/cocos/core/splash-screen.ts @@ -36,7 +36,7 @@ import { clamp01 } from './math/utils'; import { Sampler, SamplerInfo, Shader, Texture, TextureInfo, Device, InputAssembler, InputAssemblerInfo, Attribute, Buffer, BufferInfo, Rect, Color, BufferTextureCopy, Framebuffer, CommandBuffer, BufferUsageBit, Format, - MemoryUsageBit, TextureType, TextureUsageBit, Address, SurfaceTransform, + MemoryUsageBit, TextureType, TextureUsageBit, Address, SurfaceTransform, Swapchain, } from './gfx'; import { PipelineStateManager } from './pipeline'; import { legacyCC } from './global-exports'; @@ -77,8 +77,8 @@ export class SplashScreen { private _loadFinish = false; private _directCall = false; - private root!: Root; private device!: Device; + private swapchain!: Swapchain; private shader!: Shader; private sampler!: Sampler; private cmdBuff!: CommandBuffer; @@ -136,8 +136,9 @@ export class SplashScreen { } else { legacyCC.view.setDesignResolutionSize(960, 640, 4); } - this.root = root; this.device = root.device; + this.swapchain = root.mainWindow!.swapchain; + this.framebuffer = root.mainWindow!.framebuffer; legacyCC.game.once(legacyCC.Game.EVENT_GAME_INITED, () => { legacyCC.director._lateUpdate = performance.now(); }, legacyCC.director); @@ -178,9 +179,8 @@ export class SplashScreen { // Color manually, or will have problem on native. const clearColor = this.settings.clearColor; this.clearColors = [new Color(clearColor.x, clearColor.y, clearColor.z, clearColor.w)]; - const device = this.device; - this.renderArea = new Rect(0, 0, device.width, device.height); - this.framebuffer = this.root.mainWindow!.framebuffer; + const { device, swapchain } = this; + this.renderArea = new Rect(0, 0, swapchain.width, swapchain.height); this.cmdBuff = device.commandBuffer; // create input assembler @@ -190,7 +190,7 @@ export class SplashScreen { const vbSize = vbStride * 4; this.vertexBuffers = device.createBuffer(new BufferInfo( BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST, - MemoryUsageBit.HOST | MemoryUsageBit.DEVICE, vbSize, vbStride, + MemoryUsageBit.DEVICE, vbSize, vbStride, )); this.vertexBuffers.update(verts); @@ -200,7 +200,7 @@ export class SplashScreen { const ibSize = ibStride * 6; this.indicesBuffers = device.createBuffer(new BufferInfo( BufferUsageBit.INDEX | BufferUsageBit.TRANSFER_DST, - MemoryUsageBit.HOST | MemoryUsageBit.DEVICE, ibSize, ibStride, + MemoryUsageBit.DEVICE, ibSize, ibStride, )); this.indicesBuffers.update(indices); @@ -213,7 +213,7 @@ export class SplashScreen { this.projection = new Mat4(); Mat4.ortho(this.projection, -1, 1, -1, 1, -1, 1, device.capabilities.clipSpaceMinZ, - device.capabilities.clipSpaceSignY, device.surfaceTransform); + device.capabilities.clipSpaceSignY, swapchain.surfaceTransform); } private init () { @@ -222,10 +222,10 @@ export class SplashScreen { const animate = (time: number) => { if (this.cancelAnimate) return; const settings = this.settings; - const device = this.device; + const { device, swapchain } = this; Mat4.ortho(this.projection, -1, 1, -1, 1, -1, 1, device.capabilities.clipSpaceMinZ, - device.capabilities.clipSpaceSignY, device.surfaceTransform); - const dw = device.width; const dh = device.height; + device.capabilities.clipSpaceSignY, swapchain.surfaceTransform); + const dw = swapchain.width; const dh = swapchain.height; const refW = dw < dh ? dw : dh; // update logo uniform if (this.startTime < 0) this.startTime = time; @@ -237,8 +237,8 @@ export class SplashScreen { const logoW = refW * settings.displayRatio; let scaleX = logoW * logoTW / logoTH; let scaleY = logoW; - if (device.surfaceTransform === SurfaceTransform.ROTATE_90 - || device.surfaceTransform === SurfaceTransform.ROTATE_270) { + if (swapchain.surfaceTransform === SurfaceTransform.ROTATE_90 + || swapchain.surfaceTransform === SurfaceTransform.ROTATE_270) { scaleX = logoW * dw / dh; scaleY = logoW * logoTH / logoTW * dh / dw; } @@ -255,8 +255,8 @@ export class SplashScreen { const wartermarkTW = this.watermarkTexture.width; const wartermarkTH = this.watermarkTexture.height; let scaleX = wartermarkW; let scaleY = wartermarkW * wartermarkTH / wartermarkTW; - if (device.surfaceTransform === SurfaceTransform.ROTATE_90 - || device.surfaceTransform === SurfaceTransform.ROTATE_270) { + if (swapchain.surfaceTransform === SurfaceTransform.ROTATE_90 + || swapchain.surfaceTransform === SurfaceTransform.ROTATE_270) { scaleX = wartermarkW * 0.5; scaleY = wartermarkW * dw / dh * 0.5; } @@ -293,7 +293,7 @@ export class SplashScreen { samplerInfo.addressU = Address.CLAMP; samplerInfo.addressV = Address.CLAMP; samplerInfo.addressW = Address.CLAMP; - this.sampler = device.createSampler(samplerInfo); + this.sampler = device.getSampler(samplerInfo); this.logoTexture = device.createTexture(new TextureInfo( TextureType.TEX2D, @@ -348,15 +348,15 @@ export class SplashScreen { } private frame () { - const device = this.device; - device.acquire(); + const { device, swapchain } = this; + device.acquire([swapchain]); // record command const cmdBuff = this.cmdBuff; const framebuffer = this.framebuffer; const renderArea = this.renderArea; - renderArea.width = device.width; - renderArea.height = device.height; + renderArea.width = swapchain.width; + renderArea.height = swapchain.height; cmdBuff.begin(); cmdBuff.beginRenderPass(framebuffer.renderPass, framebuffer, renderArea, this.clearColors, 1.0, 0); @@ -387,8 +387,8 @@ export class SplashScreen { private destroy () { this.callBack = null; - this.root = null!; this.device = null!; + this.swapchain = null!; this.clearColors = null!; if ((this.logoImage as any).destroy) (this.logoImage as any).destroy(); this.logoImage = null!; @@ -406,7 +406,6 @@ export class SplashScreen { this.vertexBuffers = null!; this.indicesBuffers.destroy(); this.indicesBuffers = null!; - this.sampler.destroy(); this.sampler = null!; /** text */ diff --git a/cocos/profiler/profiler.ts b/cocos/profiler/profiler.ts index d1f9122a78..ff58fa90ac 100644 --- a/cocos/profiler/profiler.ts +++ b/cocos/profiler/profiler.ts @@ -26,10 +26,9 @@ import { TEST, EDITOR } from 'internal:constants'; import { MeshRenderer } from '../3d/framework/mesh-renderer'; -import { Camera } from '../core/components/camera-component'; import { createMesh } from '../3d/misc'; import { Material } from '../core/assets/material'; -import { ClearFlagBit, Format, TextureType, TextureUsageBit, Texture, TextureInfo, Device, BufferTextureCopy } from '../core/gfx'; +import { Format, TextureType, TextureUsageBit, Texture, TextureInfo, Device, BufferTextureCopy, Swapchain } from '../core/gfx'; import { Layers } from '../core/scene-graph'; import { Node } from '../core/scene-graph/node'; import { ICounterOption } from './counter'; @@ -37,6 +36,8 @@ import { PerfCounter } from './perf-counter'; import { legacyCC } from '../core/global-exports'; import { Pass } from '../core/renderer'; import { preTransforms } from '../core/math/mat4'; +import { Root } from '../core/root'; +import { RenderPipeline } from '../core'; const _characters = '0123456789. '; @@ -98,6 +99,9 @@ export class Profiler { private _rootNode: Node | null = null; private _device: Device | null = null; + private _swapchain: Swapchain | null = null; + private _pipeline: RenderPipeline = null!; + private _meshRenderer: MeshRenderer = null!; private readonly _canvas: HTMLCanvasElement | null = null; private readonly _ctx: CanvasRenderingContext2D | null = null; private _texture: Texture | null = null; @@ -151,7 +155,12 @@ export class Profiler { public showStats () { if (!this._showFPS) { - if (!this._device) { this._device = legacyCC.director.root.device; } + if (!this._device) { + const root = legacyCC.director.root as Root; + this._device = root.device; + this._swapchain = root.mainWindow!.swapchain; + this._pipeline = root.pipeline; + } if (!EDITOR) { this.generateCanvas(); } @@ -254,18 +263,6 @@ export class Profiler { this._rootNode = new Node('PROFILER_NODE'); legacyCC.game.addPersistRootNode(this._rootNode); - const cameraNode = new Node('Profiler_Camera'); - cameraNode.setPosition(0, 0, 1.5); - cameraNode.parent = this._rootNode; - const camera = cameraNode.addComponent('cc.Camera') as Camera; - camera.projection = Camera.ProjectionType.ORTHO; - camera.orthoHeight = 1; - camera.near = 1; - camera.far = 2; - camera.visibility = Layers.BitMask.PROFILER; - camera.clearFlags = ClearFlagBit.NONE; - camera.priority = 0xffffffff; // after everything else - const managerNode = new Node('Profiler_Root'); managerNode.parent = this._rootNode; @@ -275,10 +272,10 @@ export class Profiler { const scale = rowHeight / _constants.fontSize; const columnWidth = this._eachNumWidth * this._canvas!.width * scale; const vertexPos: number[] = [ - 0, height, 0, // top-left + 0, height, 0, // top-left lWidth, height, 0, // top-right lWidth, 0, 0, // bottom-right - 0, 0, 0, // bottom-left + 0, 0, 0, // bottom-left ]; const vertexindices: number[] = [ 0, 2, 1, @@ -309,8 +306,8 @@ export class Profiler { } } - const modelCom = managerNode.addComponent(MeshRenderer); - modelCom.mesh = createMesh({ + this._meshRenderer = managerNode.addComponent(MeshRenderer); + this._meshRenderer.mesh = createMesh({ positions: vertexPos, indices: vertexindices, colors: vertexUV, // pack all the necessary info in a_color: { x: u, y: v, z: id.x, w: id.y } @@ -328,8 +325,9 @@ export class Profiler { this.offsetData = pass.blocks[bOffset]; this.offsetData[3] = -1; // ensure init on the first frame - modelCom.material = _material; - modelCom.node.layer = Layers.Enum.PROFILER; + this._meshRenderer.material = _material; + this._meshRenderer.node.layer = Layers.Enum.PROFILER; + this._inited = true; } @@ -380,7 +378,7 @@ export class Profiler { } if (!EDITOR) { - const surfaceTransform = this._device!.surfaceTransform; + const surfaceTransform = this._swapchain!.surfaceTransform; const clipSpaceSignY = this._device!.capabilities.clipSpaceSignY; if (surfaceTransform !== this.offsetData[3]) { const preTransform = preTransforms[surfaceTransform]; @@ -395,6 +393,8 @@ export class Profiler { this.pass._setRootBufferDirty(true); } + if (this._meshRenderer.model) this._pipeline.profiler = this._meshRenderer.model; + const now = performance.now(); (this._stats.render.counter as PerfCounter).start(now); } diff --git a/editor/assets/default_prefab/3d/Capsule.prefab b/editor/assets/default_prefab/3d/Capsule.prefab index ea61865084..1fbcad266d 100644 --- a/editor/assets/default_prefab/3d/Capsule.prefab +++ b/editor/assets/default_prefab/3d/Capsule.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_receiveShadows": false, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "79dw5Ftk1ApLmqTwrc+k7C" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "da90XzlDpMAYZdnNEoKl+n" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "79dw5Ftk1ApLmqTwrc+k7C" } ] diff --git a/editor/assets/default_prefab/3d/Capsule.prefab.meta b/editor/assets/default_prefab/3d/Capsule.prefab.meta index c39a9161cf..7b26184156 100644 --- a/editor/assets/default_prefab/3d/Capsule.prefab.meta +++ b/editor/assets/default_prefab/3d/Capsule.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "73ce1f7f-d1f4-4942-ad93-66ca3b3041ab", diff --git a/editor/assets/default_prefab/3d/Cone.prefab b/editor/assets/default_prefab/3d/Cone.prefab index b6bca5c8a5..01be6d8b84 100644 --- a/editor/assets/default_prefab/3d/Cone.prefab +++ b/editor/assets/default_prefab/3d/Cone.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_receiveShadows": false, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f1ipRw5aRJRZ9C2iZg62pq" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "71iiGASwNCApxqLqH+wIbn" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "f1ipRw5aRJRZ9C2iZg62pq" } ] diff --git a/editor/assets/default_prefab/3d/Cone.prefab.meta b/editor/assets/default_prefab/3d/Cone.prefab.meta index 23cedea6e3..838a4f81fe 100644 --- a/editor/assets/default_prefab/3d/Cone.prefab.meta +++ b/editor/assets/default_prefab/3d/Cone.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "6350d660-e888-4acf-a552-f3b719ae9110", diff --git a/editor/assets/default_prefab/3d/Cube.prefab b/editor/assets/default_prefab/3d/Cube.prefab index 44ad4bbd1c..c5201d7ce2 100644 --- a/editor/assets/default_prefab/3d/Cube.prefab +++ b/editor/assets/default_prefab/3d/Cube.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_receiveShadows": false, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e8DOT5UJ1F/ZgplWYyCxRs" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "18p7R2TC1PDpDQlq3lim9E" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "e8DOT5UJ1F/ZgplWYyCxRs" } ] diff --git a/editor/assets/default_prefab/3d/Cube.prefab.meta b/editor/assets/default_prefab/3d/Cube.prefab.meta index ee789e9235..58e73ad4f1 100644 --- a/editor/assets/default_prefab/3d/Cube.prefab.meta +++ b/editor/assets/default_prefab/3d/Cube.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "30da77a1-f02d-4ede-aa56-403452ee7fde", diff --git a/editor/assets/default_prefab/3d/Cylinder.prefab b/editor/assets/default_prefab/3d/Cylinder.prefab index 1c40854f80..68342ca09d 100644 --- a/editor/assets/default_prefab/3d/Cylinder.prefab +++ b/editor/assets/default_prefab/3d/Cylinder.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_receiveShadows": false, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b8R46AvAVAcJdQNHs3AvR2" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "33oEQpEV9OVK/ZqTytUy5k" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "b8R46AvAVAcJdQNHs3AvR2" } ] diff --git a/editor/assets/default_prefab/3d/Cylinder.prefab.meta b/editor/assets/default_prefab/3d/Cylinder.prefab.meta index 6391a68468..423a3e6e09 100644 --- a/editor/assets/default_prefab/3d/Cylinder.prefab.meta +++ b/editor/assets/default_prefab/3d/Cylinder.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "ab3e16f9-671e-48a7-90b7-d0884d9cbb85", diff --git a/editor/assets/default_prefab/3d/Plane.prefab b/editor/assets/default_prefab/3d/Plane.prefab index 0b3c17f5d7..c26148d8d4 100644 --- a/editor/assets/default_prefab/3d/Plane.prefab +++ b/editor/assets/default_prefab/3d/Plane.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_receiveShadows": false, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e0uHCYkZ1D1I9glcT6oLf2" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "a4McGKwcFCoYngMEkhGE/8" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "e0uHCYkZ1D1I9glcT6oLf2" } ] diff --git a/editor/assets/default_prefab/3d/Plane.prefab.meta b/editor/assets/default_prefab/3d/Plane.prefab.meta index af841ec2e8..846280d311 100644 --- a/editor/assets/default_prefab/3d/Plane.prefab.meta +++ b/editor/assets/default_prefab/3d/Plane.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "40563723-f8fc-4216-99ea-a81636435c10", diff --git a/editor/assets/default_prefab/3d/Quad.prefab b/editor/assets/default_prefab/3d/Quad.prefab index e3a5923a76..c85db2ee2d 100644 --- a/editor/assets/default_prefab/3d/Quad.prefab +++ b/editor/assets/default_prefab/3d/Quad.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_receiveShadows": false, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "cf0e2Ddb1LaZRmljaFideC" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "f7nu3miDhBqIw9jKCaQ84w" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "cf0e2Ddb1LaZRmljaFideC" } ] diff --git a/editor/assets/default_prefab/3d/Quad.prefab.meta b/editor/assets/default_prefab/3d/Quad.prefab.meta index f1d3fa9e63..6f3bf187a5 100644 --- a/editor/assets/default_prefab/3d/Quad.prefab.meta +++ b/editor/assets/default_prefab/3d/Quad.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "34a07346-9f62-4a84-90ae-cb83f7a426c1", diff --git a/editor/assets/default_prefab/3d/Sphere.prefab b/editor/assets/default_prefab/3d/Sphere.prefab index ed79cd15aa..e27967effa 100644 --- a/editor/assets/default_prefab/3d/Sphere.prefab +++ b/editor/assets/default_prefab/3d/Sphere.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_receiveShadows": false, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "492SVdw3ZPdre+amT+eLU6" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "a0eltv8s1AU6XwR/2b0+3P" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "492SVdw3ZPdre+amT+eLU6" } ] diff --git a/editor/assets/default_prefab/3d/Sphere.prefab.meta b/editor/assets/default_prefab/3d/Sphere.prefab.meta index 9f90d8f355..4be5bb097f 100644 --- a/editor/assets/default_prefab/3d/Sphere.prefab.meta +++ b/editor/assets/default_prefab/3d/Sphere.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "655c9519-1a37-472b-bae6-29fefac0b550", diff --git a/editor/assets/default_prefab/3d/Torus.prefab b/editor/assets/default_prefab/3d/Torus.prefab index f01271a558..9e3a29d2af 100644 --- a/editor/assets/default_prefab/3d/Torus.prefab +++ b/editor/assets/default_prefab/3d/Torus.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_receiveShadows": false, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f5ai5YKCpGMp+t5Pa+yXBj" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "3eSHLLgglMw5XPGA//qFqs" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "f5ai5YKCpGMp+t5Pa+yXBj" } ] diff --git a/editor/assets/default_prefab/3d/Torus.prefab.meta b/editor/assets/default_prefab/3d/Torus.prefab.meta index 9cfabe6e82..ee3d61fe71 100644 --- a/editor/assets/default_prefab/3d/Torus.prefab.meta +++ b/editor/assets/default_prefab/3d/Torus.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "d47f5d5e-c931-4ff4-987b-cc818a728b82", diff --git a/editor/assets/default_prefab/Camera.prefab b/editor/assets/default_prefab/Camera.prefab index 94399b3dab..700bb00ee5 100644 --- a/editor/assets/default_prefab/Camera.prefab +++ b/editor/assets/default_prefab/Camera.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -89,9 +89,13 @@ "_id": "", "_visibility": 1822425087, "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "dbCiGR9T1E0oZwxclTRFEj" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -101,9 +105,5 @@ "__id__": 0 }, "fileId": "f8Nyw5r0hH9Zz+WrOqK1x/" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "dbCiGR9T1E0oZwxclTRFEj" } ] diff --git a/editor/assets/default_prefab/Camera.prefab.meta b/editor/assets/default_prefab/Camera.prefab.meta index 2f3eea2f67..7e21cd5202 100644 --- a/editor/assets/default_prefab/Camera.prefab.meta +++ b/editor/assets/default_prefab/Camera.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "bb0a6472-cd67-4afb-a031-94fca8f4cc92", diff --git a/editor/assets/default_prefab/Terrain.prefab.meta b/editor/assets/default_prefab/Terrain.prefab.meta index adc7e61157..5650b0a165 100644 --- a/editor/assets/default_prefab/Terrain.prefab.meta +++ b/editor/assets/default_prefab/Terrain.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "90e8b0d4-12dc-412d-9156-ea1fdb18c15b", diff --git a/editor/assets/default_prefab/effects/Particle System.prefab b/editor/assets/default_prefab/effects/Particle System.prefab index b8d5a8d6f7..eb4778af16 100644 --- a/editor/assets/default_prefab/effects/Particle System.prefab +++ b/editor/assets/default_prefab/effects/Particle System.prefab @@ -23,7 +23,7 @@ } ], "_prefab": { - "__id__": 52 + "__id__": 53 }, "_lpos": { "__type__": "cc.Vec3", @@ -156,7 +156,7 @@ "_simulationSpace": 1, "_id": "", "__prefab": { - "__id__": 53 + "__id__": 52 } }, { @@ -605,6 +605,10 @@ }, "_useGPU": false }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "0b7a7v3FVOCpzmec7amMlB" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -614,9 +618,5 @@ "__id__": 0 }, "fileId": "d8TRONhORDRpCXbQBSi+LM" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "0b7a7v3FVOCpzmec7amMlB" } ] diff --git a/editor/assets/default_prefab/effects/Particle System.prefab.meta b/editor/assets/default_prefab/effects/Particle System.prefab.meta index 5337fa0394..a985056467 100644 --- a/editor/assets/default_prefab/effects/Particle System.prefab.meta +++ b/editor/assets/default_prefab/effects/Particle System.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "f09a0597-10e6-49e5-8759-a148b5e85395", diff --git a/editor/assets/default_prefab/light/Directional Light.prefab b/editor/assets/default_prefab/light/Directional Light.prefab index fc90ed3541..9ee3cd0341 100644 --- a/editor/assets/default_prefab/light/Directional Light.prefab +++ b/editor/assets/default_prefab/light/Directional Light.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -74,9 +74,13 @@ "_intensity": 65000, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "1fmNgOipdOha90C8NNkXEN" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -86,9 +90,5 @@ "__id__": 0 }, "fileId": "aeyMch0nJBEbV/mk9CXYkW" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "1fmNgOipdOha90C8NNkXEN" } ] diff --git a/editor/assets/default_prefab/light/Directional Light.prefab.meta b/editor/assets/default_prefab/light/Directional Light.prefab.meta index 41eb208375..ecb2f7c270 100644 --- a/editor/assets/default_prefab/light/Directional Light.prefab.meta +++ b/editor/assets/default_prefab/light/Directional Light.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "a0e9756d-9128-4f49-8097-e041c8b733b8", diff --git a/editor/assets/default_prefab/light/Sphere Light.prefab b/editor/assets/default_prefab/light/Sphere Light.prefab index 3c9f572eed..eb7df41e9d 100644 --- a/editor/assets/default_prefab/light/Sphere Light.prefab +++ b/editor/assets/default_prefab/light/Sphere Light.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -76,9 +76,13 @@ "_range": 2, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "5b6a86+adN0IKor4mk41YN" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -88,9 +92,5 @@ "__id__": 0 }, "fileId": "59eikBZx5K9aR06hUuVC37" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "5b6a86+adN0IKor4mk41YN" } ] diff --git a/editor/assets/default_prefab/light/Sphere Light.prefab.meta b/editor/assets/default_prefab/light/Sphere Light.prefab.meta index 3dbf2a003b..ce7bf37c29 100644 --- a/editor/assets/default_prefab/light/Sphere Light.prefab.meta +++ b/editor/assets/default_prefab/light/Sphere Light.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "4182ee46-ffa0-4de2-b66b-c93cc6c7e9b8", diff --git a/editor/assets/default_prefab/light/Spot Light.prefab b/editor/assets/default_prefab/light/Spot Light.prefab index b2f5ea1197..aeec84b0eb 100644 --- a/editor/assets/default_prefab/light/Spot Light.prefab +++ b/editor/assets/default_prefab/light/Spot Light.prefab @@ -24,7 +24,7 @@ } ], "_prefab": { - "__id__": 3 + "__id__": 4 }, "_lpos": { "__type__": "cc.Vec3", @@ -77,9 +77,13 @@ "_spotAngle": 30, "_id": "", "__prefab": { - "__id__": 4 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "42FuKkPeBOSLyZuICQqfaf" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -89,9 +93,5 @@ "__id__": 0 }, "fileId": "35C2xAi5dG/btOADE1TC8p" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "42FuKkPeBOSLyZuICQqfaf" } ] diff --git a/editor/assets/default_prefab/light/Spot Light.prefab.meta b/editor/assets/default_prefab/light/Spot Light.prefab.meta index 3812316437..f4f911ddd3 100644 --- a/editor/assets/default_prefab/light/Spot Light.prefab.meta +++ b/editor/assets/default_prefab/light/Spot Light.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "7a49aa24-bd7a-40a8-b31a-b2a9da85abcd", diff --git a/editor/assets/default_prefab/ui/Button.prefab.meta b/editor/assets/default_prefab/ui/Button.prefab.meta index bf35c4cbbb..f9e9caebaf 100644 --- a/editor/assets/default_prefab/ui/Button.prefab.meta +++ b/editor/assets/default_prefab/ui/Button.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "90bdd2a9-2838-4888-b66c-e94c8b7a5169", diff --git a/editor/assets/default_prefab/ui/Canvas.prefab b/editor/assets/default_prefab/ui/Canvas.prefab index 1b123e3b7f..e1ae69c2cc 100644 --- a/editor/assets/default_prefab/ui/Canvas.prefab +++ b/editor/assets/default_prefab/ui/Canvas.prefab @@ -26,14 +26,14 @@ "__id__": 4 }, { - "__id__": 5 + "__id__": 6 }, { - "__id__": 6 + "__id__": 8 } ], "_prefab": { - "__id__": 7 + "__id__": 10 }, "_lpos": { "__type__": "cc.Vec3", @@ -156,7 +156,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 8 + "__id__": 5 }, "_priority": 0, "_contentSize": { @@ -171,6 +171,10 @@ }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "0dngp/9gNO34wUQjZfN/CX" + }, { "__type__": "cc.Canvas", "_name": "", @@ -180,7 +184,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 9 + "__id__": 7 }, "_cameraComponent": { "__id__": 3 @@ -188,6 +192,10 @@ "_alignCanvasWithScreen": true, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3f2oTdCepERZdpmIfLsrhd" + }, { "__type__": "cc.Widget", "_name": "", @@ -197,7 +205,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 10 + "__id__": 9 }, "_alignFlags": 45, "_target": null, @@ -219,6 +227,10 @@ "_lockFlags": 0, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e8a+bU/8dPDbbJguUzLdoF" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -228,17 +240,5 @@ "__uuid__": "f773db21-62b8-4540-956a-29bacf5ddbf5" }, "fileId": "5f6AJl30pDQId35UqIfQJ/" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "0dngp/9gNO34wUQjZfN/CX" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "3f2oTdCepERZdpmIfLsrhd" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "e8a+bU/8dPDbbJguUzLdoF" } ] diff --git a/editor/assets/default_prefab/ui/Canvas.prefab.meta b/editor/assets/default_prefab/ui/Canvas.prefab.meta index 5cab875b93..78676f8d54 100644 --- a/editor/assets/default_prefab/ui/Canvas.prefab.meta +++ b/editor/assets/default_prefab/ui/Canvas.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "f773db21-62b8-4540-956a-29bacf5ddbf5", diff --git a/editor/assets/default_prefab/ui/EditBox.prefab b/editor/assets/default_prefab/ui/EditBox.prefab index 1404812ee8..59f6a25b01 100644 --- a/editor/assets/default_prefab/ui/EditBox.prefab +++ b/editor/assets/default_prefab/ui/EditBox.prefab @@ -20,24 +20,24 @@ "__id__": 2 }, { - "__id__": 6 + "__id__": 8 } ], "_active": true, "_level": 2, "_components": [ { - "__id__": 10 + "__id__": 14 }, { - "__id__": 11 + "__id__": 16 }, { - "__id__": 12 + "__id__": 18 } ], "_prefab": { - "__id__": 13 + "__id__": 20 }, "_lpos": { "__type__": "cc.Vec3", @@ -82,11 +82,11 @@ "__id__": 3 }, { - "__id__": 4 + "__id__": 5 } ], "_prefab": { - "__id__": 5 + "__id__": 7 }, "_lpos": { "__type__": "cc.Vec3", @@ -137,9 +137,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 14 + "__id__": 4 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "779kAXGTtMZKXfYlOg0Tfd" + }, { "__type__": "cc.Label", "_name": "", @@ -176,9 +180,13 @@ "_cacheMode": 0, "_id": "", "__prefab": { - "__id__": 15 + "__id__": 6 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ddIY+NJvlDTIQAg7PLVrGo" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -201,14 +209,14 @@ "_level": 2, "_components": [ { - "__id__": 7 + "__id__": 9 }, { - "__id__": 8 + "__id__": 11 } ], "_prefab": { - "__id__": 9 + "__id__": 13 }, "_lpos": { "__type__": "cc.Vec3", @@ -243,7 +251,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 6 + "__id__": 8 }, "_enabled": true, "_contentSize": { @@ -259,15 +267,19 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 16 + "__id__": 10 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "d07wQj4whCUqYGJH1lEpVp" + }, { "__type__": "cc.Label", "_name": "", "_objFlags": 0, "node": { - "__id__": 6 + "__id__": 8 }, "_enabled": true, "_srcBlendFactor": 2, @@ -298,9 +310,13 @@ "_cacheMode": 0, "_id": "", "__prefab": { - "__id__": 17 + "__id__": 12 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "8fhi7qRLFJbK0abIJuXmCW" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -332,9 +348,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 18 + "__id__": 15 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "1fhJOVuOVAGYSYZoiE25Uz" + }, { "__type__": "cc.Sprite", "_name": "", @@ -370,9 +390,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 19 + "__id__": 17 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "43qH95z3VGeYelCElKd6FW" + }, { "__type__": "cc.EditBox", "_name": "", @@ -416,9 +440,13 @@ "_stayOnTop": false, "_id": "", "__prefab": { - "__id__": 20 + "__id__": 19 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "1bCHrwPGZOPrbmPh93kwpe" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -428,33 +456,5 @@ "__id__": 0 }, "fileId": "028Ule0PtAPqB/Osb42WnZ" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "779kAXGTtMZKXfYlOg0Tfd" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "ddIY+NJvlDTIQAg7PLVrGo" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "d07wQj4whCUqYGJH1lEpVp" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "8fhi7qRLFJbK0abIJuXmCW" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "1fhJOVuOVAGYSYZoiE25Uz" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "43qH95z3VGeYelCElKd6FW" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "1bCHrwPGZOPrbmPh93kwpe" } ] diff --git a/editor/assets/default_prefab/ui/EditBox.prefab.meta b/editor/assets/default_prefab/ui/EditBox.prefab.meta index 441fa05e02..dcde03efad 100644 --- a/editor/assets/default_prefab/ui/EditBox.prefab.meta +++ b/editor/assets/default_prefab/ui/EditBox.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "05e79121-8675-4551-9ad7-1b901a4025db", diff --git a/editor/assets/default_prefab/ui/Graphics.prefab b/editor/assets/default_prefab/ui/Graphics.prefab index 21b926654e..1b2dd5d0b3 100644 --- a/editor/assets/default_prefab/ui/Graphics.prefab +++ b/editor/assets/default_prefab/ui/Graphics.prefab @@ -22,11 +22,11 @@ "__id__": 2 }, { - "__id__": 3 + "__id__": 4 } ], "_prefab": { - "__id__": 4 + "__id__": 6 }, "_lpos": { "__type__": "cc.Vec3", @@ -65,7 +65,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 5 + "__id__": 3 }, "_priority": 0, "_contentSize": { @@ -80,6 +80,10 @@ }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c3dMMH5KBHA7aaNq/gxfrr" + }, { "__type__": "cc.Graphics", "_name": "", @@ -89,7 +93,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 6 + "__id__": 5 }, "_visFlags": 0, "_customMaterial": null, @@ -122,6 +126,10 @@ "_miterLimit": 10, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b72j61fNtG9IH3vOo7HXe7" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -131,13 +139,5 @@ "__id__": 0 }, "fileId": "ecuOmM2MBGcJr6Soj9eWHR" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "c3dMMH5KBHA7aaNq/gxfrr" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "b72j61fNtG9IH3vOo7HXe7" } ] diff --git a/editor/assets/default_prefab/ui/Graphics.prefab.meta b/editor/assets/default_prefab/ui/Graphics.prefab.meta index e7c91e3e85..c3029ab026 100644 --- a/editor/assets/default_prefab/ui/Graphics.prefab.meta +++ b/editor/assets/default_prefab/ui/Graphics.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "c96e159e-43ea-4a16-8279-05bc39119d1a", diff --git a/editor/assets/default_prefab/ui/Label.prefab b/editor/assets/default_prefab/ui/Label.prefab index aff1c566bb..45835cb745 100644 --- a/editor/assets/default_prefab/ui/Label.prefab +++ b/editor/assets/default_prefab/ui/Label.prefab @@ -22,11 +22,11 @@ "__id__": 2 }, { - "__id__": 3 + "__id__": 4 } ], "_prefab": { - "__id__": 4 + "__id__": 6 }, "_lpos": { "__type__": "cc.Vec3", @@ -77,9 +77,13 @@ }, "_id": "", "__prefab": { - "__id__": 5 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "c68UOAlNhN171Umca6yVvF" + }, { "__type__": "cc.Label", "_name": "", @@ -116,9 +120,13 @@ "_cacheMode": 0, "_id": "", "__prefab": { - "__id__": 6 + "__id__": 5 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2frm37uaJHQr0AEEaYyM82" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -128,13 +136,5 @@ "__id__": 0 }, "fileId": "85tZs04QNDoJ8Zw+ovirTw" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "c68UOAlNhN171Umca6yVvF" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "2frm37uaJHQr0AEEaYyM82" } ] diff --git a/editor/assets/default_prefab/ui/Label.prefab.meta b/editor/assets/default_prefab/ui/Label.prefab.meta index 539d295ece..ba07ee727d 100644 --- a/editor/assets/default_prefab/ui/Label.prefab.meta +++ b/editor/assets/default_prefab/ui/Label.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "36008810-7ad3-47c0-8112-e30aee089e45", diff --git a/editor/assets/default_prefab/ui/Layout.prefab b/editor/assets/default_prefab/ui/Layout.prefab index bee6c9a7fa..29c8711c09 100644 --- a/editor/assets/default_prefab/ui/Layout.prefab +++ b/editor/assets/default_prefab/ui/Layout.prefab @@ -23,11 +23,11 @@ "__id__": 2 }, { - "__id__": 3 + "__id__": 4 } ], "_prefab": { - "__id__": 4 + "__id__": 6 }, "_lpos": { "__type__": "cc.Vec3", @@ -77,9 +77,13 @@ }, "_id": "", "__prefab": { - "__id__": 5 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "71F9vsVsZH7ZFd+PpN0azA" + }, { "__type__": "cc.Layout", "_name": "", @@ -107,9 +111,13 @@ "_id": "", "_layoutType": 0, "__prefab": { - "__id__": 6 + "__id__": 5 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "eaGEkmlCpANK+GS6CImtZa" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -119,13 +127,5 @@ "__id__": 0 }, "fileId": "708rGaUe1FubBlr3fE3DYE" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "71F9vsVsZH7ZFd+PpN0azA" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "eaGEkmlCpANK+GS6CImtZa" } ] diff --git a/editor/assets/default_prefab/ui/Layout.prefab.meta b/editor/assets/default_prefab/ui/Layout.prefab.meta index 7fdb39d9e6..0eef3f46b8 100644 --- a/editor/assets/default_prefab/ui/Layout.prefab.meta +++ b/editor/assets/default_prefab/ui/Layout.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "a9ef7dfc-ea8b-4cf8-918e-36da948c4de0", diff --git a/editor/assets/default_prefab/ui/Mask.prefab b/editor/assets/default_prefab/ui/Mask.prefab index 5bb340b81b..dc7c8ee962 100644 --- a/editor/assets/default_prefab/ui/Mask.prefab +++ b/editor/assets/default_prefab/ui/Mask.prefab @@ -23,11 +23,11 @@ "__id__": 2 }, { - "__id__": 3 + "__id__": 4 } ], "_prefab": { - "__id__": 4 + "__id__": 6 }, "_lpos": { "__type__": "cc.Vec3", @@ -78,9 +78,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 5 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "85Rkr8igNOB6QSD/HtnhgH" + }, { "__type__": "cc.Mask", "_name": "", @@ -103,9 +107,13 @@ "_segments": 64, "_id": "", "__prefab": { - "__id__": 6 + "__id__": 5 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "90TR3hptxAq7K974GgvafO" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -115,13 +123,5 @@ "__uuid__": "7fa63aed-f3e2-46a5-8a7c-c1a1adf6cea6" }, "fileId": "dcqbd5AqtAAa0hfeX2B3/Y" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "85Rkr8igNOB6QSD/HtnhgH" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "90TR3hptxAq7K974GgvafO" } ] diff --git a/editor/assets/default_prefab/ui/Mask.prefab.meta b/editor/assets/default_prefab/ui/Mask.prefab.meta index 45a56dc4c0..173bb5daa3 100644 --- a/editor/assets/default_prefab/ui/Mask.prefab.meta +++ b/editor/assets/default_prefab/ui/Mask.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "7fa63aed-f3e2-46a5-8a7c-c1a1adf6cea6", diff --git a/editor/assets/default_prefab/ui/ParticleSystem2D.prefab.meta b/editor/assets/default_prefab/ui/ParticleSystem2D.prefab.meta index 3c243c3e4a..874273cc70 100644 --- a/editor/assets/default_prefab/ui/ParticleSystem2D.prefab.meta +++ b/editor/assets/default_prefab/ui/ParticleSystem2D.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "f396261e-3e06-41ec-bdd6-9a8b6d99026f", diff --git a/editor/assets/default_prefab/ui/ProgressBar.prefab b/editor/assets/default_prefab/ui/ProgressBar.prefab index 10b55398e3..30c2019a87 100644 --- a/editor/assets/default_prefab/ui/ProgressBar.prefab +++ b/editor/assets/default_prefab/ui/ProgressBar.prefab @@ -23,18 +23,18 @@ "_active": true, "_level": 2, "_components": [ - { - "__id__": 6 - }, - { - "__id__": 7 - }, { "__id__": 8 + }, + { + "__id__": 10 + }, + { + "__id__": 12 } ], "_prefab": { - "__id__": 9 + "__id__": 14 }, "_lpos": { "__type__": "cc.Vec3", @@ -79,11 +79,11 @@ "__id__": 3 }, { - "__id__": 4 + "__id__": 5 } ], "_prefab": { - "__id__": 5 + "__id__": 7 }, "_lpos": { "__type__": "cc.Vec3", @@ -134,9 +134,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 10 + "__id__": 4 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "80SdIywIVFupwJOwCni0ux" + }, { "__type__": "cc.Sprite", "_name": "", @@ -172,9 +176,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 11 + "__id__": 6 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e00niSjJdHzqQfr6Uq+1as" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -206,9 +214,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 12 + "__id__": 9 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "0a4TUb2bBHBa3wO6MCw2d2" + }, { "__type__": "cc.Sprite", "_name": "", @@ -244,9 +256,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 13 + "__id__": 11 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e3LBidlN9MdpNxB8lzYZv7" + }, { "__type__": "cc.ProgressBar", "_name": "", @@ -256,7 +272,7 @@ }, "_enabled": true, "_barSprite": { - "__id__": 4 + "__id__": 5 }, "_mode": 0, "_totalLength": 300, @@ -264,9 +280,13 @@ "_reverse": false, "_id": "", "__prefab": { - "__id__": 14 + "__id__": 13 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3f/uAXDzRCkYMASuN3GC61" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -276,25 +296,5 @@ "__id__": 0 }, "fileId": "57OgHuVgZMi7YjfxaBX7ok" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "80SdIywIVFupwJOwCni0ux" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "e00niSjJdHzqQfr6Uq+1as" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "0a4TUb2bBHBa3wO6MCw2d2" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "e3LBidlN9MdpNxB8lzYZv7" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "3f/uAXDzRCkYMASuN3GC61" } ] diff --git a/editor/assets/default_prefab/ui/ProgressBar.prefab.meta b/editor/assets/default_prefab/ui/ProgressBar.prefab.meta index d2ed195f14..7c813e398a 100644 --- a/editor/assets/default_prefab/ui/ProgressBar.prefab.meta +++ b/editor/assets/default_prefab/ui/ProgressBar.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "0d9353c4-6fb9-49bb-bc62-77f1750078c2", diff --git a/editor/assets/default_prefab/ui/RichText.prefab.meta b/editor/assets/default_prefab/ui/RichText.prefab.meta index ea37ece242..2082066213 100644 --- a/editor/assets/default_prefab/ui/RichText.prefab.meta +++ b/editor/assets/default_prefab/ui/RichText.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "fc6bfcfa-8086-4326-809b-0ba1226bac7d", diff --git a/editor/assets/default_prefab/ui/ScrollView.prefab b/editor/assets/default_prefab/ui/ScrollView.prefab index a72233e6ca..2bd14fa258 100644 --- a/editor/assets/default_prefab/ui/ScrollView.prefab +++ b/editor/assets/default_prefab/ui/ScrollView.prefab @@ -20,23 +20,23 @@ "__id__": 2 }, { - "__id__": 13 + "__id__": 20 } ], "_active": true, "_components": [ { - "__id__": 24 + "__id__": 36 }, { - "__id__": 25 + "__id__": 38 }, { - "__id__": 11 + "__id__": 17 } ], "_prefab": { - "__id__": 26 + "__id__": 40 }, "_lpos": { "__type__": "cc.Vec3", @@ -80,21 +80,21 @@ ], "_active": true, "_components": [ - { - "__id__": 7 - }, - { - "__id__": 8 - }, { "__id__": 9 }, { - "__id__": 10 + "__id__": 11 + }, + { + "__id__": 13 + }, + { + "__id__": 15 } ], "_prefab": { - "__id__": 23 + "__id__": 35 }, "_lpos": { "__type__": "cc.Vec3", @@ -138,11 +138,11 @@ "__id__": 4 }, { - "__id__": 5 + "__id__": 6 } ], "_prefab": { - "__id__": 6 + "__id__": 8 }, "_lpos": { "__type__": "cc.Vec3", @@ -181,7 +181,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 27 + "__id__": 5 }, "_priority": 0, "_contentSize": { @@ -196,6 +196,10 @@ }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "95oWyE8aJJxJ5UvVmOXyZU" + }, { "__type__": "cc.Sprite", "_name": "", @@ -206,7 +210,7 @@ "_enabled": true, "_materials": [], "__prefab": { - "__id__": 28 + "__id__": 7 }, "_visFlags": 0, "_srcBlendFactor": 2, @@ -236,6 +240,10 @@ "_atlas": null, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "02Vchn8fFF/77B+7pVCQuQ" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -255,7 +263,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 29 + "__id__": 10 }, "_priority": 0, "_contentSize": { @@ -270,6 +278,10 @@ }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "17lQPXOPpO0b6Z/3qQRAz3" + }, { "__type__": "cc.Sprite", "_name": "", @@ -280,7 +292,7 @@ "_enabled": true, "_materials": [], "__prefab": { - "__id__": 30 + "__id__": 12 }, "_visFlags": 0, "_srcBlendFactor": 2, @@ -310,6 +322,10 @@ "_atlas": null, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "9dLJe/n0BKVoGauB1wT/Tc" + }, { "__type__": "cc.Widget", "_name": "", @@ -319,7 +335,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 31 + "__id__": 14 }, "_alignFlags": 37, "_target": null, @@ -341,6 +357,10 @@ "_lockFlags": 0, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "88/VBmjEBOMLWb2cOiN0kU" + }, { "__type__": "cc.ScrollBar", "_name": "", @@ -350,19 +370,23 @@ }, "_enabled": true, "__prefab": { - "__id__": 32 + "__id__": 16 }, "_scrollView": { - "__id__": 11 + "__id__": 17 }, "_handle": { - "__id__": 5 + "__id__": 6 }, "_direction": 1, "_enableAutoHide": false, "_autoHideTime": 1, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f4i77UV0dH4pcD0KQOXx7c" + }, { "__type__": "cc.ScrollView", "_name": "", @@ -372,7 +396,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 33 + "__id__": 18 }, "bounceDuration": 0.23, "brake": 0.75, @@ -383,34 +407,38 @@ "cancelInnerEvents": true, "scrollEvents": [], "_content": { - "__id__": 12 + "__id__": 19 }, "_horizontalScrollBar": null, "_verticalScrollBar": { - "__id__": 10 + "__id__": 15 }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a8UaPDxYhIX5MrqvKGMJdR" + }, { "__type__": "cc.Node", "_name": "content", "_objFlags": 0, "_parent": { - "__id__": 13 + "__id__": 20 }, "_children": [ { - "__id__": 17 + "__id__": 26 } ], "_active": true, "_components": [ { - "__id__": 21 + "__id__": 32 } ], "_prefab": { - "__id__": 22 + "__id__": 34 }, "_lpos": { "__type__": "cc.Vec3", @@ -449,20 +477,20 @@ }, "_children": [ { - "__id__": 12 + "__id__": 19 } ], "_active": true, "_components": [ { - "__id__": 14 + "__id__": 21 }, { - "__id__": 15 + "__id__": 23 } ], "_prefab": { - "__id__": 16 + "__id__": 25 }, "_lpos": { "__type__": "cc.Vec3", @@ -497,11 +525,11 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 13 + "__id__": 20 }, "_enabled": true, "__prefab": { - "__id__": 34 + "__id__": 22 }, "_priority": 0, "_contentSize": { @@ -516,17 +544,21 @@ }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "adVJjE6iNG9YcIKwDKe/zq" + }, { "__type__": "cc.Mask", "_name": "", "_objFlags": 0, "node": { - "__id__": 13 + "__id__": 20 }, "_enabled": true, "_materials": [], "__prefab": { - "__id__": 35 + "__id__": 24 }, "_visFlags": 0, "_srcBlendFactor": 2, @@ -543,6 +575,10 @@ "_segments": 64, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "4eIg29oQZFVLk+NZnwDdlk" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -558,20 +594,20 @@ "_name": "item", "_objFlags": 0, "_parent": { - "__id__": 12 + "__id__": 19 }, "_children": [], "_active": true, "_components": [ { - "__id__": 18 + "__id__": 27 }, { - "__id__": 19 + "__id__": 29 } ], "_prefab": { - "__id__": 20 + "__id__": 31 }, "_lpos": { "__type__": "cc.Vec3", @@ -606,11 +642,11 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 17 + "__id__": 26 }, "_enabled": true, "__prefab": { - "__id__": 36 + "__id__": 28 }, "_priority": 0, "_contentSize": { @@ -625,17 +661,21 @@ }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3d8stlV6pL/KRLrvrUs0F9" + }, { "__type__": "cc.Label", "_name": "", "_objFlags": 0, "node": { - "__id__": 17 + "__id__": 26 }, "_enabled": true, "_materials": [], "__prefab": { - "__id__": 37 + "__id__": 30 }, "_visFlags": 0, "_srcBlendFactor": 2, @@ -665,6 +705,10 @@ "_cacheMode": 0, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "17Ae0SAyNCRLoyUTsE6naB" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -680,11 +724,11 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 12 + "__id__": 19 }, "_enabled": true, "__prefab": { - "__id__": 38 + "__id__": 33 }, "_priority": 0, "_contentSize": { @@ -699,6 +743,10 @@ }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "99yn0cfL9MmZYfJbPmK9qL" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -728,7 +776,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 39 + "__id__": 37 }, "_priority": 0, "_contentSize": { @@ -743,6 +791,10 @@ }, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "71kmounFRG/K27WWBbH2RB" + }, { "__type__": "cc.Sprite", "_name": "", @@ -753,7 +805,7 @@ "_enabled": true, "_materials": [], "__prefab": { - "__id__": 40 + "__id__": 39 }, "_visFlags": 0, "_srcBlendFactor": 2, @@ -783,6 +835,10 @@ "_atlas": null, "_id": "" }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "8ce2Xg/B9GhY0DNafD/vxa" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -792,61 +848,5 @@ "__id__": 0 }, "fileId": "ddcO5JFkdFA4VJz3MwozPj" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "95oWyE8aJJxJ5UvVmOXyZU" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "02Vchn8fFF/77B+7pVCQuQ" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "17lQPXOPpO0b6Z/3qQRAz3" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "9dLJe/n0BKVoGauB1wT/Tc" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "88/VBmjEBOMLWb2cOiN0kU" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "f4i77UV0dH4pcD0KQOXx7c" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "a8UaPDxYhIX5MrqvKGMJdR" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "adVJjE6iNG9YcIKwDKe/zq" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "4eIg29oQZFVLk+NZnwDdlk" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "3d8stlV6pL/KRLrvrUs0F9" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "17Ae0SAyNCRLoyUTsE6naB" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "99yn0cfL9MmZYfJbPmK9qL" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "71kmounFRG/K27WWBbH2RB" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "8ce2Xg/B9GhY0DNafD/vxa" } ] diff --git a/editor/assets/default_prefab/ui/ScrollView.prefab.meta b/editor/assets/default_prefab/ui/ScrollView.prefab.meta index b8d8b5ce8d..34ca536635 100644 --- a/editor/assets/default_prefab/ui/ScrollView.prefab.meta +++ b/editor/assets/default_prefab/ui/ScrollView.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "c1baa707-78d6-4b89-8d5d-0b7fdf0c39bc", diff --git a/editor/assets/default_prefab/ui/Slider.prefab b/editor/assets/default_prefab/ui/Slider.prefab index 25309bb215..b49d04c728 100644 --- a/editor/assets/default_prefab/ui/Slider.prefab +++ b/editor/assets/default_prefab/ui/Slider.prefab @@ -24,17 +24,17 @@ "_level": 2, "_components": [ { - "__id__": 7 + "__id__": 10 }, { - "__id__": 8 + "__id__": 12 }, { - "__id__": 9 + "__id__": 14 } ], "_prefab": { - "__id__": 10 + "__id__": 16 }, "_lpos": { "__type__": "cc.Vec3", @@ -79,14 +79,14 @@ "__id__": 3 }, { - "__id__": 4 + "__id__": 5 }, { - "__id__": 5 + "__id__": 7 } ], "_prefab": { - "__id__": 6 + "__id__": 9 }, "_lpos": { "__type__": "cc.Vec3", @@ -137,9 +137,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 11 + "__id__": 4 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "13QJLCXqxP1Il0fUQIF50F" + }, { "__type__": "cc.Sprite", "_name": "", @@ -177,9 +181,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 12 + "__id__": 6 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "70944AM5hNwKBMkwzEOckA" + }, { "__type__": "cc.Button", "_name": "", @@ -232,9 +240,13 @@ "_clickEvents": [], "_id": "", "__prefab": { - "__id__": 13 + "__id__": 8 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "9eUkB/MkNDvohDk817OV44" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -266,9 +278,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 14 + "__id__": 11 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "07sDRP1gxKtb3urHSdnuDY" + }, { "__type__": "cc.Sprite", "_name": "", @@ -306,9 +322,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 15 + "__id__": 13 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "36Am8fYc5AZodP1DolQQ0j" + }, { "__type__": "cc.Slider", "_name": "", @@ -318,16 +338,20 @@ }, "_enabled": true, "_handle": { - "__id__": 4 + "__id__": 5 }, "_direction": 0, "_progress": 0.1, "_slideEvents": [], "_id": "", "__prefab": { - "__id__": 16 + "__id__": 15 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "d072tlidJJc4WAM3bGih0d" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -337,29 +361,5 @@ "__id__": 0 }, "fileId": "338FzIbp1AD445tFsve9M7" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "13QJLCXqxP1Il0fUQIF50F" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "70944AM5hNwKBMkwzEOckA" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "9eUkB/MkNDvohDk817OV44" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "07sDRP1gxKtb3urHSdnuDY" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "36Am8fYc5AZodP1DolQQ0j" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "d072tlidJJc4WAM3bGih0d" } ] diff --git a/editor/assets/default_prefab/ui/Slider.prefab.meta b/editor/assets/default_prefab/ui/Slider.prefab.meta index aa0c237f45..56534228df 100644 --- a/editor/assets/default_prefab/ui/Slider.prefab.meta +++ b/editor/assets/default_prefab/ui/Slider.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "2bd7e5b6-cd8c-41a1-8136-ddb8efbf6326", diff --git a/editor/assets/default_prefab/ui/Sprite.prefab b/editor/assets/default_prefab/ui/Sprite.prefab index dd1378e3b0..e9180e626f 100644 --- a/editor/assets/default_prefab/ui/Sprite.prefab +++ b/editor/assets/default_prefab/ui/Sprite.prefab @@ -22,11 +22,11 @@ "__id__": 2 }, { - "__id__": 3 + "__id__": 4 } ], "_prefab": { - "__id__": 4 + "__id__": 6 }, "_lpos": { "__type__": "cc.Vec3", @@ -77,9 +77,13 @@ }, "_id": "", "__prefab": { - "__id__": 5 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f7NISe7HdAD68SLfhnddy8" + }, { "__type__": "cc.Sprite", "_name": "", @@ -116,9 +120,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 6 + "__id__": 5 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e71ctEmpxFC4KlSYRZNz/a" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -128,13 +136,5 @@ "__id__": 0 }, "fileId": "aaJ6tvsWNHC4pk5TDYmpFa" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "f7NISe7HdAD68SLfhnddy8" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "e71ctEmpxFC4KlSYRZNz/a" } ] diff --git a/editor/assets/default_prefab/ui/Sprite.prefab.meta b/editor/assets/default_prefab/ui/Sprite.prefab.meta index 6efeae6330..2d8d7d3964 100644 --- a/editor/assets/default_prefab/ui/Sprite.prefab.meta +++ b/editor/assets/default_prefab/ui/Sprite.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "9db8cd0b-cbe4-42e7-96a9-a239620c0a9d", diff --git a/editor/assets/default_prefab/ui/SpriteSplash.prefab b/editor/assets/default_prefab/ui/SpriteSplash.prefab index 6c02c502e7..cebac4d991 100644 --- a/editor/assets/default_prefab/ui/SpriteSplash.prefab +++ b/editor/assets/default_prefab/ui/SpriteSplash.prefab @@ -65,7 +65,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 7 + "__id__": 3 }, "_priority": 0, "_contentSize": { @@ -82,7 +82,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "94Ki8oOf5BApUAVjddk12n" + "fileId": "55pCbtzR5GbojKMArZkfim" }, { "__type__": "cc.Sprite", @@ -93,7 +93,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 8 + "__id__": 5 }, "_visFlags": 0, "_customMaterial": null, @@ -126,7 +126,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "62gb5XootOJqH7yKP7GfB0" + "fileId": "20UGQn4U9GUoln0NJQTkbG" }, { "__type__": "cc.PrefabInfo", @@ -137,13 +137,5 @@ "__id__": 0 }, "fileId": "2auWFC5gdLdawQHv2TQRjx" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "55pCbtzR5GbojKMArZkfim" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "20UGQn4U9GUoln0NJQTkbG" } ] diff --git a/editor/assets/default_prefab/ui/SpriteSplash.prefab.meta b/editor/assets/default_prefab/ui/SpriteSplash.prefab.meta index d3a75503ef..45ae9a884f 100644 --- a/editor/assets/default_prefab/ui/SpriteSplash.prefab.meta +++ b/editor/assets/default_prefab/ui/SpriteSplash.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "e5f21aad-3a69-4011-ac62-b74352ac025e", diff --git a/editor/assets/default_prefab/ui/TiledMap.prefab.meta b/editor/assets/default_prefab/ui/TiledMap.prefab.meta index deb39c596e..531cc915d0 100644 --- a/editor/assets/default_prefab/ui/TiledMap.prefab.meta +++ b/editor/assets/default_prefab/ui/TiledMap.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "3139fa4f-8c42-4ce6-98be-15e848d9734c", diff --git a/editor/assets/default_prefab/ui/Toggle.prefab b/editor/assets/default_prefab/ui/Toggle.prefab index bdf89c8bfd..ff22ae766c 100644 --- a/editor/assets/default_prefab/ui/Toggle.prefab +++ b/editor/assets/default_prefab/ui/Toggle.prefab @@ -22,18 +22,18 @@ ], "_active": true, "_components": [ - { - "__id__": 6 - }, - { - "__id__": 7 - }, { "__id__": 8 + }, + { + "__id__": 10 + }, + { + "__id__": 12 } ], "_prefab": { - "__id__": 9 + "__id__": 14 }, "_lpos": { "__type__": "cc.Vec3", @@ -77,11 +77,11 @@ "__id__": 3 }, { - "__id__": 4 + "__id__": 5 } ], "_prefab": { - "__id__": 5 + "__id__": 7 }, "_lpos": { "__type__": "cc.Vec3", @@ -132,9 +132,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 10 + "__id__": 4 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "e4k6OSwohL75lyfsntvPC5" + }, { "__type__": "cc.Sprite", "_name": "", @@ -171,9 +175,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 11 + "__id__": 6 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "25nHiyhlVLhbUiFI4JJ9Sn" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -205,9 +213,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 12 + "__id__": 9 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "a7yxb8GDhNnIT24rnD3lO4" + }, { "__type__": "cc.Sprite", "_name": "", @@ -244,9 +256,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 13 + "__id__": 11 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3a4GKzsKZCNLuWHErVRJ1B" + }, { "__type__": "cc.Toggle", "_name": "", @@ -301,13 +317,17 @@ "_isChecked": true, "_toggleGroup": null, "_checkMark": { - "__id__": 4 + "__id__": 5 }, "_id": "", "__prefab": { - "__id__": 14 + "__id__": 13 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "58GFHdMmJFBa4quSrrbzsk" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -317,25 +337,5 @@ "__id__": 0 }, "fileId": "eaBmd9z1dGd5Mi/sTp4eCJ" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "e4k6OSwohL75lyfsntvPC5" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "25nHiyhlVLhbUiFI4JJ9Sn" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "a7yxb8GDhNnIT24rnD3lO4" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "3a4GKzsKZCNLuWHErVRJ1B" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "58GFHdMmJFBa4quSrrbzsk" } ] diff --git a/editor/assets/default_prefab/ui/Toggle.prefab.meta b/editor/assets/default_prefab/ui/Toggle.prefab.meta index 7dd3d05f6a..ed494baff1 100644 --- a/editor/assets/default_prefab/ui/Toggle.prefab.meta +++ b/editor/assets/default_prefab/ui/Toggle.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "0e89afe7-56de-4f99-96a1-cba8a75bedd2", diff --git a/editor/assets/default_prefab/ui/ToggleContainer.prefab b/editor/assets/default_prefab/ui/ToggleContainer.prefab index 70482e7577..44db913f01 100644 --- a/editor/assets/default_prefab/ui/ToggleContainer.prefab +++ b/editor/assets/default_prefab/ui/ToggleContainer.prefab @@ -20,21 +20,21 @@ "__id__": 2 }, { - "__id__": 12 + "__id__": 18 }, { - "__id__": 21 + "__id__": 32 } ], "_active": true, "_level": 2, "_components": [ { - "__id__": 10 + "__id__": 14 } ], "_prefab": { - "__id__": 30 + "__id__": 46 }, "_lpos": { "__type__": "cc.Vec3", @@ -79,18 +79,18 @@ "_active": true, "_level": 2, "_components": [ - { - "__id__": 7 - }, - { - "__id__": 8 - }, { "__id__": 9 + }, + { + "__id__": 11 + }, + { + "__id__": 13 } ], "_prefab": { - "__id__": 11 + "__id__": 17 }, "_lpos": { "__type__": "cc.Vec3", @@ -135,11 +135,11 @@ "__id__": 4 }, { - "__id__": 5 + "__id__": 6 } ], "_prefab": { - "__id__": 6 + "__id__": 8 }, "_lpos": { "__type__": "cc.Vec3", @@ -190,9 +190,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 31 + "__id__": 5 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "769r8PnWVBcKxoQ/tBgxxJ" + }, { "__type__": "cc.Sprite", "_name": "", @@ -228,9 +232,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 32 + "__id__": 7 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "feLMgPl9lI7psUYhi9QZnd" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -262,9 +270,13 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 33 + "__id__": 10 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "7eWgLqN4BJYKFxZT9fh0Dg" + }, { "__type__": "cc.Sprite", "_name": "", @@ -300,9 +312,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 34 + "__id__": 12 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "05YCOqjrpMLJpWYS4SFuRX" + }, { "__type__": "cc.Toggle", "_name": "", @@ -356,14 +372,14 @@ "checkEvents": [], "_isChecked": true, "_toggleGroup": { - "__id__": 10 + "__id__": 14 }, "_checkMark": { - "__id__": 5 + "__id__": 6 }, "_id": "", "__prefab": { - "__id__": 35 + "__id__": 16 } }, { @@ -378,9 +394,17 @@ "_allowSwitchOff": false, "_id": "", "__prefab": { - "__id__": 36 + "__id__": 15 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "352Lg0yJ1CEY+vaR56K/O8" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "9b8IW1c0BB3rLtFXFfDwtM" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -400,24 +424,24 @@ }, "_children": [ { - "__id__": 13 + "__id__": 19 } ], "_active": true, "_level": 2, "_components": [ { - "__id__": 17 + "__id__": 25 }, { - "__id__": 18 + "__id__": 27 }, { - "__id__": 19 + "__id__": 29 } ], "_prefab": { - "__id__": 20 + "__id__": 31 }, "_lpos": { "__type__": "cc.Vec3", @@ -452,21 +476,21 @@ "_name": "Checkmark", "_objFlags": 0, "_parent": { - "__id__": 12 + "__id__": 18 }, "_children": [], "_active": false, "_level": 3, "_components": [ { - "__id__": 14 + "__id__": 20 }, { - "__id__": 15 + "__id__": 22 } ], "_prefab": { - "__id__": 16 + "__id__": 24 }, "_lpos": { "__type__": "cc.Vec3", @@ -501,7 +525,7 @@ "_name": "Checkmark", "_objFlags": 0, "node": { - "__id__": 13 + "__id__": 19 }, "_enabled": true, "_contentSize": { @@ -517,15 +541,19 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 37 + "__id__": 21 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "689DN305dFGJTCMmQOfwAD" + }, { "__type__": "cc.Sprite", "_name": "Checkmark", "_objFlags": 0, "node": { - "__id__": 13 + "__id__": 19 }, "_enabled": true, "_srcBlendFactor": 2, @@ -555,9 +583,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 38 + "__id__": 23 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "faDtNLU2xM7aWAk+Ipet86" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -573,7 +605,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 12 + "__id__": 18 }, "_enabled": true, "_contentSize": { @@ -589,15 +621,19 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 39 + "__id__": 26 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2408xx9KlDjpgL7oVDU/d8" + }, { "__type__": "cc.Sprite", "_name": "", "_objFlags": 0, "node": { - "__id__": 12 + "__id__": 18 }, "_enabled": true, "_srcBlendFactor": 2, @@ -627,15 +663,19 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 40 + "__id__": 28 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f5MaVV0MdBMIwcasBnu/Ri" + }, { "__type__": "cc.Toggle", "_name": "", "_objFlags": 0, "node": { - "__id__": 12 + "__id__": 18 }, "_enabled": true, "clickEvents": [], @@ -678,21 +718,25 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 12 + "__id__": 18 }, "checkEvents": [], "_isChecked": false, "_toggleGroup": { - "__id__": 10 + "__id__": 14 }, "_checkMark": { - "__id__": 15 + "__id__": 22 }, "_id": "", "__prefab": { - "__id__": 41 + "__id__": 30 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "62dIBI9rRNWoWNm6Z4N1Xu" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -712,24 +756,24 @@ }, "_children": [ { - "__id__": 22 + "__id__": 33 } ], "_active": true, "_level": 2, "_components": [ { - "__id__": 26 + "__id__": 39 }, { - "__id__": 27 + "__id__": 41 }, { - "__id__": 28 + "__id__": 43 } ], "_prefab": { - "__id__": 29 + "__id__": 45 }, "_lpos": { "__type__": "cc.Vec3", @@ -764,21 +808,21 @@ "_name": "Checkmark", "_objFlags": 0, "_parent": { - "__id__": 21 + "__id__": 32 }, "_children": [], "_active": false, "_level": 3, "_components": [ { - "__id__": 23 + "__id__": 34 }, { - "__id__": 24 + "__id__": 36 } ], "_prefab": { - "__id__": 25 + "__id__": 38 }, "_lpos": { "__type__": "cc.Vec3", @@ -813,7 +857,7 @@ "_name": "Checkmark", "_objFlags": 0, "node": { - "__id__": 22 + "__id__": 33 }, "_enabled": true, "_contentSize": { @@ -829,15 +873,19 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 42 + "__id__": 35 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "eeq2vO+dJBn5KOb1dAA5F3" + }, { "__type__": "cc.Sprite", "_name": "Checkmark", "_objFlags": 0, "node": { - "__id__": 22 + "__id__": 33 }, "_enabled": true, "_srcBlendFactor": 2, @@ -867,9 +915,13 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 43 + "__id__": 37 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "70FX1MVxdNeLTwMFd50cKW" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -885,7 +937,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 21 + "__id__": 32 }, "_enabled": true, "_contentSize": { @@ -901,15 +953,19 @@ "_id": "", "_priority": 0, "__prefab": { - "__id__": 44 + "__id__": 40 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "32AvB2MYZMpaTyU7uqXecV" + }, { "__type__": "cc.Sprite", "_name": "", "_objFlags": 0, "node": { - "__id__": 21 + "__id__": 32 }, "_enabled": true, "_srcBlendFactor": 2, @@ -939,15 +995,19 @@ "_atlas": null, "_id": "", "__prefab": { - "__id__": 45 + "__id__": 42 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "1abJcRoRFGWLtnvEy6fR2T" + }, { "__type__": "cc.Toggle", "_name": "", "_objFlags": 0, "node": { - "__id__": 21 + "__id__": 32 }, "_enabled": true, "clickEvents": [], @@ -990,21 +1050,25 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 21 + "__id__": 32 }, "checkEvents": [], "_isChecked": false, "_toggleGroup": { - "__id__": 10 + "__id__": 14 }, "_checkMark": { - "__id__": 24 + "__id__": 36 }, "_id": "", "__prefab": { - "__id__": 46 + "__id__": 44 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "dbO+2TKn5Ku4d/ME4S+Grh" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -1024,69 +1088,5 @@ "__uuid__": "2af73429-41d1-4346-9062-7798e42945dd" }, "fileId": "0abpGdRJZFr6tOhit0x6yB" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "769r8PnWVBcKxoQ/tBgxxJ" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "feLMgPl9lI7psUYhi9QZnd" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "7eWgLqN4BJYKFxZT9fh0Dg" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "05YCOqjrpMLJpWYS4SFuRX" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "9b8IW1c0BB3rLtFXFfDwtM" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "352Lg0yJ1CEY+vaR56K/O8" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "689DN305dFGJTCMmQOfwAD" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "faDtNLU2xM7aWAk+Ipet86" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "2408xx9KlDjpgL7oVDU/d8" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "f5MaVV0MdBMIwcasBnu/Ri" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "62dIBI9rRNWoWNm6Z4N1Xu" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "eeq2vO+dJBn5KOb1dAA5F3" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "70FX1MVxdNeLTwMFd50cKW" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "32AvB2MYZMpaTyU7uqXecV" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "1abJcRoRFGWLtnvEy6fR2T" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "dbO+2TKn5Ku4d/ME4S+Grh" } ] diff --git a/editor/assets/default_prefab/ui/ToggleContainer.prefab.meta b/editor/assets/default_prefab/ui/ToggleContainer.prefab.meta index b84fc90f10..be874bf547 100644 --- a/editor/assets/default_prefab/ui/ToggleContainer.prefab.meta +++ b/editor/assets/default_prefab/ui/ToggleContainer.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "2af73429-41d1-4346-9062-7798e42945dd", diff --git a/editor/assets/default_prefab/ui/VideoPlayer.prefab.meta b/editor/assets/default_prefab/ui/VideoPlayer.prefab.meta index 35c2f75d45..14cd3924cb 100644 --- a/editor/assets/default_prefab/ui/VideoPlayer.prefab.meta +++ b/editor/assets/default_prefab/ui/VideoPlayer.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "7e089eaf-fa97-40d7-8a20-741a152585df", diff --git a/editor/assets/default_prefab/ui/WebView.prefab.meta b/editor/assets/default_prefab/ui/WebView.prefab.meta index 749c78fa64..1953608395 100644 --- a/editor/assets/default_prefab/ui/WebView.prefab.meta +++ b/editor/assets/default_prefab/ui/WebView.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "9c541fa2-1dc8-4d8b-813a-aec89133f5b1", diff --git a/editor/assets/default_prefab/ui/Widget.prefab b/editor/assets/default_prefab/ui/Widget.prefab index e2093668f2..a6f1ea0f38 100644 --- a/editor/assets/default_prefab/ui/Widget.prefab +++ b/editor/assets/default_prefab/ui/Widget.prefab @@ -23,11 +23,11 @@ "__id__": 2 }, { - "__id__": 3 + "__id__": 4 } ], "_prefab": { - "__id__": 4 + "__id__": 6 }, "_lpos": { "__type__": "cc.Vec3", @@ -77,9 +77,13 @@ }, "_id": "", "__prefab": { - "__id__": 5 + "__id__": 3 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "15MbuX4VNHPLpqzglWCixn" + }, { "__type__": "cc.Widget", "_name": "", @@ -106,9 +110,13 @@ "_alignMode": 2, "_id": "", "__prefab": { - "__id__": 6 + "__id__": 5 } }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2ac45cT6BHwqitY1b17iCp" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -118,13 +126,5 @@ "__id__": 0 }, "fileId": "578WJabBZMg7E4k78zGTBW" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "15MbuX4VNHPLpqzglWCixn" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "2ac45cT6BHwqitY1b17iCp" } ] diff --git a/editor/assets/default_prefab/ui/Widget.prefab.meta b/editor/assets/default_prefab/ui/Widget.prefab.meta index 37b671fb7f..1616f133ec 100644 --- a/editor/assets/default_prefab/ui/Widget.prefab.meta +++ b/editor/assets/default_prefab/ui/Widget.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "36ed4422-3542-4cc4-bf02-dc4bfc590836", diff --git a/editor/assets/default_prefab/ui/pageView.prefab.meta b/editor/assets/default_prefab/ui/pageView.prefab.meta index 0e2f116d7e..7cc9148f73 100644 --- a/editor/assets/default_prefab/ui/pageView.prefab.meta +++ b/editor/assets/default_prefab/ui/pageView.prefab.meta @@ -1,5 +1,5 @@ { - "ver": "1.1.30", + "ver": "1.1.31", "importer": "prefab", "imported": true, "uuid": "20a5d8cb-ccad-4543-a937-fccd98c9f3de", diff --git a/editor/assets/default_renderpipeline/builtin-deferred.rpp b/editor/assets/default_renderpipeline/builtin-deferred.rpp index 88b479e654..ea7564ba60 100644 --- a/editor/assets/default_renderpipeline/builtin-deferred.rpp +++ b/editor/assets/default_renderpipeline/builtin-deferred.rpp @@ -65,7 +65,7 @@ "isTransparent": false, "sortMode": 0, "stages": [ - "deferred" + "default" ] }, { @@ -73,20 +73,19 @@ "_name": "LightingStage", "_priority": 0, "_tag": 0, + "_deferredMaterial": null, "renderQueues": [ { "__id__": 7 } - ], - "_deferredMaterial": null + ] }, { "__type__": "RenderQueueDesc", "isTransparent": true, "sortMode": 1, "stages": [ - "default", - "deferred" + "default" ] }, { @@ -94,6 +93,7 @@ "_name": "PostprocessStage", "_priority": 0, "_tag": 0, - "_postProcessMaterial": null + "_postProcessMaterial": null, + "renderQueues": [] } ] \ No newline at end of file diff --git a/editor/assets/effects/builtin-standard.effect b/editor/assets/effects/builtin-standard.effect index 197dfe5ae1..9f12f009d7 100644 --- a/editor/assets/effects/builtin-standard.effect +++ b/editor/assets/effects/builtin-standard.effect @@ -27,18 +27,6 @@ CCEffect %{ migrations: properties: pbrParams: { removeImmediately: true } - - &deferred - vert: standard-vs - frag: standard-fs - phase: deferred - propertyIndex: 0 - blendState: - targets: - - blend: false - - blend: false - - blend: false - - blend: false - properties: *props - &forward-add vert: standard-vs frag: standard-fs @@ -380,7 +368,7 @@ CCProgram shadow-caster-fs %{ if (cc_shadowLPNNInfo.y > 0.000001) { return packDepthToRGBA(v_clip_depth); } - + return vec4(v_clip_depth, 1.0, 1.0, 1.0); } }% diff --git a/editor/assets/effects/builtin-terrain.effect b/editor/assets/effects/builtin-terrain.effect index e133100b26..345bc4e049 100644 --- a/editor/assets/effects/builtin-terrain.effect +++ b/editor/assets/effects/builtin-terrain.effect @@ -20,17 +20,6 @@ CCEffect %{ normalMap2: { value: normal } normalMap3: { value: normal } lightMap: { value: grey } - - vert: terrain-vs - frag: terrain-fs - phase: deferred - propertyIndex: 0 - blendState: - targets: - - blend: false - - blend: false - - blend: false - - blend: false - properties: *props - vert: terrain-vs frag: terrain-fs phase: forward-add diff --git a/editor/assets/effects/editor/light.effect b/editor/assets/effects/editor/light.effect index 86e8121afb..0ad95f064f 100644 --- a/editor/assets/effects/editor/light.effect +++ b/editor/assets/effects/editor/light.effect @@ -37,7 +37,7 @@ CCProgram light-vs %{ CCProgram light-fs %{ precision mediump float; #include - + uniform Constant { vec4 mainColor; vec4 intensitySize; // x: intensity, y: glow diff --git a/editor/assets/effects/pipeline/deferred-lighting.effect b/editor/assets/effects/pipeline/deferred-lighting.effect index 29c2d218ea..2e3adad244 100644 --- a/editor/assets/effects/pipeline/deferred-lighting.effect +++ b/editor/assets/effects/pipeline/deferred-lighting.effect @@ -39,24 +39,20 @@ CCProgram lighting-fs %{ in vec2 v_uv; - #pragma builtin(global) - layout (set = 0, binding = 6) uniform sampler2D cc_gbuffer_albedoMap; - #pragma builtin(global) - layout (set = 0, binding = 7) uniform sampler2D cc_gbuffer_positionMap; - #pragma builtin(global) - layout (set = 0, binding = 8) uniform sampler2D cc_gbuffer_normalMap; - #pragma builtin(global) - layout (set = 0, binding = 9) uniform sampler2D cc_gbuffer_emissiveMap; + layout(binding = 0) uniform sampler2D gbuffer_albedoMap; + layout(binding = 1) uniform sampler2D gbuffer_positionMap; + layout(binding = 2) uniform sampler2D gbuffer_normalMap; + layout(binding = 3) uniform sampler2D gbuffer_emissiveMap; layout(location = 0) out vec4 fragColor; void main () { StandardSurface s; - vec4 albedoMap = texture(cc_gbuffer_albedoMap,v_uv); - vec4 positionMap = texture(cc_gbuffer_positionMap,v_uv); - vec4 normalMap = texture(cc_gbuffer_normalMap,v_uv); - vec4 emissiveMap = texture(cc_gbuffer_emissiveMap,v_uv); + vec4 albedoMap = texture(gbuffer_albedoMap,v_uv); + vec4 positionMap = texture(gbuffer_positionMap,v_uv); + vec4 normalMap = texture(gbuffer_normalMap,v_uv); + vec4 emissiveMap = texture(gbuffer_emissiveMap,v_uv); s.albedo = albedoMap; s.position = positionMap.xyz; diff --git a/editor/assets/effects/pipeline/post-process.effect b/editor/assets/effects/pipeline/post-process.effect index 0f4e959bac..d4255b8831 100644 --- a/editor/assets/effects/pipeline/post-process.effect +++ b/editor/assets/effects/pipeline/post-process.effect @@ -42,8 +42,7 @@ CCProgram post-process-fs %{ in vec2 v_uv; - #pragma builtin(global) - layout (set = 0, binding = 10) uniform sampler2D cc_lighting_resultMap; + layout(binding = 0) uniform sampler2D lighting_resultMap; layout(location = 0) out vec4 fragColor; @@ -124,6 +123,6 @@ vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution, vec2 fragCoord = v_uv * resolution; texcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); - fragColor = fxaa(cc_lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); + fragColor = fxaa(lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); } }% diff --git a/editor/assets/effects/util/profiler.effect b/editor/assets/effects/util/profiler.effect index c7ccf5a91d..abd1a8b72e 100644 --- a/editor/assets/effects/util/profiler.effect +++ b/editor/assets/effects/util/profiler.effect @@ -4,6 +4,7 @@ CCEffect %{ - passes: - vert: profiler-vs:vert frag: profiler-fs:frag + priority: max depthStencilState: depthTest: false depthWrite: false @@ -45,8 +46,9 @@ CCProgram profiler-vs %{ } vec4 vert () { - vec4 position = cc_matViewProj * vec4(a_position, 1.0); - position.xy += offset.xy; + mat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy); + proj /= abs(proj[1].x + proj[1].y); + vec2 position = proj * a_position.xy + offset.xy; v_uv = a_color.xy; @@ -55,7 +57,7 @@ CCProgram profiler-vs %{ v_uv += vec2(offset.z * n, 0.0); } - return position; + return vec4(position, 0.0, 1.0); } }% diff --git a/editor/exports/offline-mappings.ts b/editor/exports/offline-mappings.ts index 550f5b29d2..748980bde7 100644 --- a/editor/exports/offline-mappings.ts +++ b/editor/exports/offline-mappings.ts @@ -1,13 +1,13 @@ +/* eslint-disable camelcase */ import { Address, BlendFactor, BlendOp, ColorMask, ComparisonFunc, CullMode, DynamicStateFlagBit, Filter, Format, FormatInfos, FormatType, GetTypeSize, PolygonMode, PrimitiveMode, - ShadeModel, ShaderStageFlagBit, StencilOp, Type, DescriptorType, + ShadeModel, ShaderStageFlagBit, StencilOp, Type, DescriptorType, SamplerInfo, } from '../../cocos/core/gfx/base/define'; -import { RenderQueue } from '../../cocos/core/renderer/core/constants'; import { RenderPassStage, RenderPriority, SetIndex } from '../../cocos/core/pipeline/define'; import { murmurhash2_32_gc } from '../../cocos/core/utils/murmurhash2_gc'; -import { SamplerInfoIndex, genSamplerHash } from '../../cocos/core/renderer/core/sampler-lib'; +import { Sampler } from '../../cocos/core/gfx/base/states/sampler'; const typeMap: Record = {}; typeMap[typeMap.bool = Type.BOOL] = 'bool'; @@ -275,8 +275,8 @@ const effectStructure = { export { murmurhash2_32_gc, - SamplerInfoIndex, - genSamplerHash, + Sampler, + SamplerInfo, effectStructure, isSampler, typeMap, @@ -287,7 +287,6 @@ export { isNormalized, isPaddedMatrix, passParams, - RenderQueue, SetIndex, RenderPriority, GetTypeSize, diff --git a/cocos/core/gfx/base/global-barrier.ts b/exports/gfx-empty.ts similarity index 70% rename from cocos/core/gfx/base/global-barrier.ts rename to exports/gfx-empty.ts index 42eedc1c7d..8035e50379 100644 --- a/cocos/core/gfx/base/global-barrier.ts +++ b/exports/gfx-empty.ts @@ -25,27 +25,11 @@ /** * @packageDocumentation - * @module gfx + * @hidden */ -import { Device } from './device'; -import { Obj, ObjectType, GlobalBarrierInfo } from './define'; +import { EmptyDevice } from '../cocos/core/gfx/empty/empty-device'; +import { legacyCC } from '../cocos/core/global-exports'; -/** - * @en GFX shader. - * @zh GFX 着色器。 - */ -export class GlobalBarrier extends Obj { - protected _device: Device; - protected _info: GlobalBarrierInfo = new GlobalBarrierInfo(); - - constructor (device: Device) { - super(ObjectType.GLOBAL_BARRIER); - this._device = device; - } - - public initialize (info: GlobalBarrierInfo): boolean { - this._info.copy(info); - return true; - } -} +export { EmptyDevice }; +legacyCC.EmptyDevice = EmptyDevice; diff --git a/exports/gfx-webgl.ts b/exports/gfx-webgl.ts index 1ab79b91d4..078fc419a3 100644 --- a/exports/gfx-webgl.ts +++ b/exports/gfx-webgl.ts @@ -30,5 +30,6 @@ import { WebGLDevice } from '../cocos/core/gfx/webgl/webgl-device'; import { legacyCC } from '../cocos/core/global-exports'; + export { WebGLDevice }; legacyCC.WebGLDevice = WebGLDevice; diff --git a/exports/gfx-webgl2.ts b/exports/gfx-webgl2.ts index 51d2eed1c4..0f43311276 100644 --- a/exports/gfx-webgl2.ts +++ b/exports/gfx-webgl2.ts @@ -30,5 +30,6 @@ import { WebGL2Device } from '../cocos/core/gfx/webgl2/webgl2-device'; import { legacyCC } from '../cocos/core/global-exports'; + export { WebGL2Device }; legacyCC.WebGL2Device = WebGL2Device; diff --git a/package-lock.json b/package-lock.json index 27d39fd067..7ead8f9838 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cocos-creator", - "version": "3.3.0", + "version": "3.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1719,7 +1719,7 @@ }, "@cocos/babel-plugin-dynamic-import-vars": { "version": "1.0.2", - "resolved": "https://registry.npm.taobao.org/@cocos/babel-plugin-dynamic-import-vars/download/@cocos/babel-plugin-dynamic-import-vars-1.0.2.tgz?cache=0&sync_timestamp=1604048375532&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40cocos%2Fbabel-plugin-dynamic-import-vars%2Fdownload%2F%40cocos%2Fbabel-plugin-dynamic-import-vars-1.0.2.tgz", + "resolved": "https://registry.npm.taobao.org/@cocos/babel-plugin-dynamic-import-vars/download/@cocos/babel-plugin-dynamic-import-vars-1.0.2.tgz", "integrity": "sha1-chaboK/r3jjHTS02cU95rWZBT5g=", "dev": true, "requires": { @@ -1841,7 +1841,7 @@ }, "fs-extra": { "version": "8.1.0", - "resolved": "https://registry.nlark.com/fs-extra/download/fs-extra-8.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz?cache=0&sync_timestamp=1611075413359&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffs-extra%2Fdownload%2Ffs-extra-8.1.0.tgz", "integrity": "sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA=", "dev": true, "requires": { @@ -1974,7 +1974,7 @@ }, "yargs": { "version": "15.4.1", - "resolved": "https://registry.nlark.com/yargs/download/yargs-15.4.1.tgz?cache=0&sync_timestamp=1620086465147&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fyargs%2Fdownload%2Fyargs-15.4.1.tgz", + "resolved": "https://registry.nlark.com/yargs/download/yargs-15.4.1.tgz", "integrity": "sha1-DYehbeAa7p2L7Cv7909nhRcw9Pg=", "dev": true, "requires": { @@ -2074,6 +2074,63 @@ } } }, + "@eslint/eslintrc": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", + "integrity": "sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.1.1", + "espree": "^7.3.0", + "globals": "^13.9.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "globals": { + "version": "13.11.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", + "integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + } + } + }, + "@humanwhocodes/config-array": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", + "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", + "dev": true, + "requires": { + "@humanwhocodes/object-schema": "^1.2.0", + "debug": "^4.1.1", + "minimatch": "^3.0.4" + } + }, + "@humanwhocodes/object-schema": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", + "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "dev": true + }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npm.taobao.org/@istanbuljs/load-nyc-config/download/@istanbuljs/load-nyc-config-1.1.0.tgz", @@ -3249,7 +3306,7 @@ }, "@rollup/plugin-json": { "version": "4.1.0", - "resolved": "https://registry.npm.taobao.org/@rollup/plugin-json/download/@rollup/plugin-json-4.1.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40rollup%2Fplugin-json%2Fdownload%2F%40rollup%2Fplugin-json-4.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/@rollup/plugin-json/download/@rollup/plugin-json-4.1.0.tgz", "integrity": "sha1-VOCYZ65pY8WThE2L16nHGClElvM=", "dev": true, "requires": { @@ -3271,7 +3328,7 @@ }, "@rollup/plugin-node-resolve": { "version": "7.1.3", - "resolved": "https://registry.npm.taobao.org/@rollup/plugin-node-resolve/download/@rollup/plugin-node-resolve-7.1.3.tgz?cache=0&sync_timestamp=1603765888985&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40rollup%2Fplugin-node-resolve%2Fdownload%2F%40rollup%2Fplugin-node-resolve-7.1.3.tgz", + "resolved": "https://registry.npm.taobao.org/@rollup/plugin-node-resolve/download/@rollup/plugin-node-resolve-7.1.3.tgz", "integrity": "sha1-gN44Tt+9e/yRARZJEPhgeBUaPso=", "dev": true, "requires": { @@ -3437,15 +3494,9 @@ } }, "@types/json-schema": { - "version": "7.0.4", - "resolved": "https://registry.npm.taobao.org/@types/json-schema/download/@types/json-schema-7.0.4.tgz", - "integrity": "sha1-OP1z3f2bVaux4bLtV4y1W9e30zk=", - "dev": true - }, - "@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", + "version": "7.0.9", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", + "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", "dev": true }, "@types/minimatch": { @@ -3474,7 +3525,7 @@ }, "@types/resolve": { "version": "0.0.8", - "resolved": "https://registry.npm.taobao.org/@types/resolve/download/@types/resolve-0.0.8.tgz?cache=0&sync_timestamp=1596840738717&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fresolve%2Fdownload%2F%40types%2Fresolve-0.0.8.tgz", + "resolved": "https://registry.npm.taobao.org/@types/resolve/download/@types/resolve-0.0.8.tgz?cache=0&sync_timestamp=1613671200787&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fresolve%2Fdownload%2F%40types%2Fresolve-0.0.8.tgz", "integrity": "sha1-8mB00jjgJlnjI84aE9BB7uKA4ZQ=", "dev": true, "requires": { @@ -3505,126 +3556,150 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.6.1.tgz", - "integrity": "sha512-SNZyflefTMK2JyrPfFFzzoy2asLmZvZJ6+/L5cIqg4HfKGiW2Gr1Go1OyEVqne/U4QwmoasuMwppoBHWBWF2nA==", + "version": "4.29.3", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.29.3.tgz", + "integrity": "sha512-tBgfA3K/3TsZY46ROGvoRxQr1wBkclbVqRQep97MjVHJzcRBURRY3sNFqLk0/Xr//BY5hM9H2p/kp+6qim85SA==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.6.1", - "@typescript-eslint/scope-manager": "4.6.1", - "debug": "^4.1.1", + "@typescript-eslint/experimental-utils": "4.29.3", + "@typescript-eslint/scope-manager": "4.29.3", + "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", - "regexpp": "^3.0.0", - "semver": "^7.3.2", - "tsutils": "^3.17.1" + "regexpp": "^3.1.0", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "dependencies": { - "@typescript-eslint/experimental-utils": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.6.1.tgz", - "integrity": "sha512-qyPqCFWlHZXkEBoV56UxHSoXW2qnTr4JrWVXOh3soBP3q0o7p4pUEMfInDwIa0dB/ypdtm7gLOS0hg0a73ijfg==", + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", "dev": true, "requires": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.6.1", - "@typescript-eslint/types": "4.6.1", - "@typescript-eslint/typescript-estree": "4.6.1", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" - } - }, - "@typescript-eslint/typescript-estree": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.6.1.tgz", - "integrity": "sha512-/J/kxiyjQQKqEr5kuKLNQ1Finpfb8gf/NpbwqFFYEBjxOsZ621r9AqwS9UDRA1Rrr/eneX/YsbPAIhU2rFLjXQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "4.6.1", - "@typescript-eslint/visitor-keys": "4.6.1", - "debug": "^4.1.1", - "globby": "^11.0.1", - "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^7.3.2", - "tsutils": "^3.17.1" + "ms": "2.1.2" } }, "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } } } }, - "@typescript-eslint/parser": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.6.1.tgz", - "integrity": "sha512-lScKRPt1wM9UwyKkGKyQDqf0bh6jm8DQ5iN37urRIXDm16GEv+HGEmum2Fc423xlk5NUOkOpfTnKZc/tqKZkDQ==", + "@typescript-eslint/experimental-utils": { + "version": "4.29.3", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.29.3.tgz", + "integrity": "sha512-ffIvbytTVWz+3keg+Sy94FG1QeOvmV9dP2YSdLFHw/ieLXWCa3U1TYu8IRCOpMv2/SPS8XqhM1+ou1YHsdzKrg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.6.1", - "@typescript-eslint/types": "4.6.1", - "@typescript-eslint/typescript-estree": "4.6.1", - "debug": "^4.1.1" + "@types/json-schema": "^7.0.7", + "@typescript-eslint/scope-manager": "4.29.3", + "@typescript-eslint/types": "4.29.3", + "@typescript-eslint/typescript-estree": "4.29.3", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + } + }, + "@typescript-eslint/parser": { + "version": "4.29.3", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.3.tgz", + "integrity": "sha512-jrHOV5g2u8ROghmspKoW7pN8T/qUzk0+DITun0MELptvngtMrwUJ1tv5zMI04CYVEUsSrN4jV7AKSv+I0y0EfQ==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "4.29.3", + "@typescript-eslint/types": "4.29.3", + "@typescript-eslint/typescript-estree": "4.29.3", + "debug": "^4.3.1" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + } } }, "@typescript-eslint/scope-manager": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.6.1.tgz", - "integrity": "sha512-f95+80r6VdINYscJY1KDUEDcxZ3prAWHulL4qRDfNVD0I5QAVSGqFkwHERDoLYJJWmEAkUMdQVvx7/c2Hp+Bjg==", + "version": "4.29.3", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.3.tgz", + "integrity": "sha512-x+w8BLXO7iWPkG5mEy9bA1iFRnk36p/goVlYobVWHyDw69YmaH9q6eA+Fgl7kYHmFvWlebUTUfhtIg4zbbl8PA==", "dev": true, "requires": { - "@typescript-eslint/types": "4.6.1", - "@typescript-eslint/visitor-keys": "4.6.1" + "@typescript-eslint/types": "4.29.3", + "@typescript-eslint/visitor-keys": "4.29.3" } }, "@typescript-eslint/types": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.6.1.tgz", - "integrity": "sha512-k2ZCHhJ96YZyPIsykickez+OMHkz06xppVLfJ+DY90i532/Cx2Z+HiRMH8YZQo7a4zVd/TwNBuRCdXlGK4yo8w==", + "version": "4.29.3", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.3.tgz", + "integrity": "sha512-s1eV1lKNgoIYLAl1JUba8NhULmf+jOmmeFO1G5MN/RBCyyzg4TIOfIOICVNC06lor+Xmy4FypIIhFiJXOknhIg==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.6.1.tgz", - "integrity": "sha512-/J/kxiyjQQKqEr5kuKLNQ1Finpfb8gf/NpbwqFFYEBjxOsZ621r9AqwS9UDRA1Rrr/eneX/YsbPAIhU2rFLjXQ==", + "version": "4.29.3", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.3.tgz", + "integrity": "sha512-45oQJA0bxna4O5TMwz55/TpgjX1YrAPOI/rb6kPgmdnemRZx/dB0rsx+Ku8jpDvqTxcE1C/qEbVHbS3h0hflag==", "dev": true, "requires": { - "@typescript-eslint/types": "4.6.1", - "@typescript-eslint/visitor-keys": "4.6.1", - "debug": "^4.1.1", - "globby": "^11.0.1", + "@typescript-eslint/types": "4.29.3", + "@typescript-eslint/visitor-keys": "4.29.3", + "debug": "^4.3.1", + "globby": "^11.0.3", "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^7.3.2", - "tsutils": "^3.17.1" + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "globby": { + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz", + "integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==", + "dev": true, + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.1.1", + "ignore": "^5.1.4", + "merge2": "^1.3.0", + "slash": "^3.0.0" + } + }, "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } } } }, "@typescript-eslint/visitor-keys": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.6.1.tgz", - "integrity": "sha512-owABze4toX7QXwOLT3/D5a8NecZEjEWU1srqxENTfqsY3bwVnl3YYbOh6s1rp2wQKO9RTHFGjKes08FgE7SVMw==", + "version": "4.29.3", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.3.tgz", + "integrity": "sha512-MGGfJvXT4asUTeVs0Q2m+sY63UsfnA+C/FDgBKV3itLBmM9H0u+URcneePtkd0at1YELmZK6HSolCqM4Fzs6yA==", "dev": true, "requires": { - "@typescript-eslint/types": "4.6.1", + "@typescript-eslint/types": "4.29.3", "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", - "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", - "dev": true - } } }, "abab": { @@ -3650,9 +3725,9 @@ } }, "acorn-jsx": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", - "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true }, "acorn-walk": { @@ -3672,12 +3747,12 @@ } }, "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npm.taobao.org/ajv/download/ajv-6.10.2.tgz", - "integrity": "sha1-086gTWsBeyiUrWkED+yLYj60vVI=", + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "requires": { - "fast-deep-equal": "^2.0.1", + "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" @@ -3816,78 +3891,38 @@ "dev": true }, "array-includes": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz", - "integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.3.tgz", + "integrity": "sha512-gcem1KlBU7c9rB+Rq8/3PPKsK2kjqeEBa3bD5kkQo4nYlOHQCJqIJFqBXDEfwaRuYTT4E+FxA9xez7Gf/e3Q7A==", "dev": true, "requires": { + "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.17.0", + "es-abstract": "^1.18.0-next.2", + "get-intrinsic": "^1.1.1", "is-string": "^1.0.5" }, "dependencies": { - "es-abstract": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", - "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", "dev": true, "requires": { - "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "is-callable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", - "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", - "dev": true - }, - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { "has-symbols": "^1.0.1" } - }, - "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } } } }, @@ -3964,78 +3999,14 @@ "dev": true }, "array.prototype.flat": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz", - "integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.4.tgz", + "integrity": "sha512-4470Xi3GAPAjZqFcljX2xzckv1qeKPizoNkiS0+O4IoPR2ZNpcjE0pkhdihlDouK+x6QOast26B4Q/O9DJnwSg==", "dev": true, "requires": { + "call-bind": "^1.0.0", "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1" - }, - "dependencies": { - "es-abstract": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", - "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "is-callable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", - "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", - "dev": true - }, - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - }, - "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } - } + "es-abstract": "^1.18.0-next.1" } }, "asn1": { @@ -4060,9 +4031,9 @@ "dev": true }, "astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npm.taobao.org/astral-regex/download/astral-regex-1.0.0.tgz", - "integrity": "sha1-bIw/uCfdQ+45GPJ7gngqt2WKb9k=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, "async": { @@ -4596,12 +4567,6 @@ "integrity": "sha1-10Q1giYhf5ge1Y9Hmx1rzClUXc8=", "dev": true }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true - }, "child_process": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz", @@ -4707,21 +4672,6 @@ "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", "dev": true }, - "cli-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", - "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", - "dev": true, - "requires": { - "restore-cursor": "^3.1.0" - } - }, - "cli-width": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", - "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", - "dev": true - }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npm.taobao.org/cliui/download/cliui-3.2.0.tgz?cache=0&sync_timestamp=1573943292170&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcliui%2Fdownload%2Fcliui-3.2.0.tgz", @@ -4885,12 +4835,6 @@ "integrity": "sha512-gNld/3lySHwuhaVluJUKLePYirM3QNCKzVxqAdhJII9/WXKVX5PURzMVJspS1jTslSqjeuG4KMVTSouit5YPHA==", "dev": true }, - "contains-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", - "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", - "dev": true - }, "convert-source-map": { "version": "1.7.0", "resolved": "https://registry.npm.taobao.org/convert-source-map/download/convert-source-map-1.7.0.tgz?cache=0&sync_timestamp=1573003637425&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fconvert-source-map%2Fdownload%2Fconvert-source-map-1.7.0.tgz", @@ -5292,6 +5236,23 @@ "once": "^1.4.0" } }, + "enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.1" + }, + "dependencies": { + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + } + } + }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npm.taobao.org/error-ex/download/error-ex-1.3.2.tgz", @@ -5301,6 +5262,89 @@ "is-arrayish": "^0.2.1" } }, + "es-abstract": { + "version": "1.18.5", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.5.tgz", + "integrity": "sha512-DDggyJLoS91CkJjgauM5c0yZMjiD1uK3KcaCeAmffGwZ+ODWzOkPN4QwRbsK5DOFf06fywmyLci3ZD8jLGhVYA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "get-intrinsic": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.2", + "internal-slot": "^1.0.3", + "is-callable": "^1.2.3", + "is-negative-zero": "^2.0.1", + "is-regex": "^1.1.3", + "is-string": "^1.0.6", + "object-inspect": "^1.11.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.2", + "string.prototype.trimend": "^1.0.4", + "string.prototype.trimstart": "^1.0.4", + "unbox-primitive": "^1.0.1" + }, + "dependencies": { + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + }, + "object-inspect": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.0.tgz", + "integrity": "sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg==", + "dev": true + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" + } + } + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, "es5-ext": { "version": "0.10.53", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", @@ -5386,36 +5430,40 @@ } }, "eslint": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.2.0.tgz", - "integrity": "sha512-B3BtEyaDKC5MlfDa2Ha8/D6DsS4fju95zs0hjS3HdGazw+LNayai38A25qMppK37wWGWNYSPOR6oYzlz5MHsRQ==", + "version": "7.32.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.32.0.tgz", + "integrity": "sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", + "@babel/code-frame": "7.12.11", + "@eslint/eslintrc": "^0.4.3", + "@humanwhocodes/config-array": "^0.5.0", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^5.1.0", - "eslint-utils": "^2.0.0", - "eslint-visitor-keys": "^1.2.0", - "espree": "^7.1.0", - "esquery": "^1.2.0", + "enquirer": "^2.3.5", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^2.0.0", + "espree": "^7.3.1", + "esquery": "^1.4.0", "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^12.1.0", + "glob-parent": "^5.1.2", + "globals": "^13.6.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", - "lodash": "^4.17.14", + "lodash.merge": "^4.6.2", "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", @@ -5424,34 +5472,90 @@ "semver": "^7.2.1", "strip-ansi": "^6.0.0", "strip-json-comments": "^3.1.0", - "table": "^5.2.3", + "table": "^6.0.9", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { + "@babel/code-frame": { + "version": "7.12.11", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", + "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.4" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.14.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.9.tgz", + "integrity": "sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g==", + "dev": true + }, + "@babel/highlight": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", + "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.14.5", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + } + } + }, "ansi-regex": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "color-convert": { @@ -5480,46 +5584,45 @@ "which": "^2.0.1" } }, - "eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - } - }, - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, - "esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "eslint-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", "dev": true, "requires": { - "estraverse": "^5.2.0" + "eslint-visitor-keys": "^1.1.0" }, "dependencies": { - "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", "dev": true } } }, - "globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "13.11.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", + "integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" } }, "has-flag": { @@ -5528,6 +5631,12 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, "levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -5565,10 +5674,13 @@ "dev": true }, "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } }, "shebang-command": { "version": "2.0.0", @@ -5594,15 +5706,6 @@ "ansi-regex": "^5.0.0" } }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -5612,6 +5715,12 @@ "prelude-ls": "^1.2.1" } }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -5649,49 +5758,53 @@ } }, "eslint-import-resolver-node": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz", - "integrity": "sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA==", + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", + "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", "dev": true, "requires": { - "debug": "^2.6.9", - "resolve": "^1.13.1" + "debug": "^3.2.7", + "resolve": "^1.20.0" }, "dependencies": { "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } } } }, "eslint-module-utils": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", - "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.2.tgz", + "integrity": "sha512-QG8pcgThYOuqxupd06oYTZoNOGaUdTY1PqK+oS6ElF6vs4pBdk/aYxFVQQXzcrAqp9m7cl7lb2ubazX+g16k2Q==", "dev": true, "requires": { - "debug": "^2.6.9", + "debug": "^3.2.7", "pkg-dir": "^2.0.0" }, "dependencies": { "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "find-up": { @@ -5713,12 +5826,6 @@ "path-exists": "^3.0.0" } }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -5743,12 +5850,6 @@ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - }, "pkg-dir": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", @@ -5761,24 +5862,26 @@ } }, "eslint-plugin-import": { - "version": "2.22.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz", - "integrity": "sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==", + "version": "2.24.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.24.1.tgz", + "integrity": "sha512-KSFWhNxPH8OGJwpRJJs+Z7I0a13E2iFQZJIvSnCu6KUs4qmgAm3xN9GYBCSoiGWmwA7gERZPXqYQjcoCROnYhQ==", "dev": true, "requires": { - "array-includes": "^3.1.1", - "array.prototype.flat": "^1.2.3", - "contains-path": "^0.1.0", + "array-includes": "^3.1.3", + "array.prototype.flat": "^1.2.4", "debug": "^2.6.9", - "doctrine": "1.5.0", - "eslint-import-resolver-node": "^0.3.4", - "eslint-module-utils": "^2.6.0", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.6", + "eslint-module-utils": "^2.6.2", + "find-up": "^2.0.0", "has": "^1.0.3", + "is-core-module": "^2.6.0", "minimatch": "^3.0.4", - "object.values": "^1.1.1", - "read-pkg-up": "^2.0.0", - "resolve": "^1.17.0", - "tsconfig-paths": "^3.9.0" + "object.values": "^1.1.4", + "pkg-up": "^2.0.0", + "read-pkg-up": "^3.0.0", + "resolve": "^1.20.0", + "tsconfig-paths": "^3.10.1" }, "dependencies": { "debug": { @@ -5791,13 +5894,12 @@ } }, "doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { - "esutils": "^2.0.2", - "isarray": "^1.0.0" + "esutils": "^2.0.2" } }, "find-up": { @@ -5810,14 +5912,14 @@ } }, "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", "dev": true, "requires": { "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", + "parse-json": "^4.0.0", + "pify": "^3.0.0", "strip-bom": "^3.0.0" } }, @@ -5861,49 +5963,59 @@ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - }, - "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", "dev": true, "requires": { - "pify": "^2.0.0" + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" } }, - "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", "dev": true, "requires": { - "load-json-file": "^2.0.0", + "pify": "^3.0.0" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "dev": true, + "requires": { + "load-json-file": "^4.0.0", "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "path-type": "^3.0.0" } }, "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", + "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", "dev": true, "requires": { "find-up": "^2.0.0", - "read-pkg": "^2.0.0" + "read-pkg": "^3.0.0" } }, "resolve": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.18.1.tgz", - "integrity": "sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", "dev": true, "requires": { - "is-core-module": "^2.0.0", + "is-core-module": "^2.2.0", "path-parse": "^1.0.6" } }, @@ -5916,38 +6028,38 @@ } }, "eslint-scope": { - "version": "5.0.0", - "resolved": "https://registry.npm.taobao.org/eslint-scope/download/eslint-scope-5.0.0.tgz", - "integrity": "sha1-6HyIh8c+jR7ITxylkWRcNYv8j7k=", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, "requires": { - "esrecurse": "^4.1.0", + "esrecurse": "^4.3.0", "estraverse": "^4.1.1" } }, "eslint-utils": { - "version": "2.0.0", - "resolved": "https://registry.npm.taobao.org/eslint-utils/download/eslint-utils-2.0.0.tgz", - "integrity": "sha1-e+HMcPJ6cqds0UqmmLyr7WiQ4c0=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", "dev": true, "requires": { - "eslint-visitor-keys": "^1.1.0" + "eslint-visitor-keys": "^2.0.0" } }, "eslint-visitor-keys": { - "version": "1.1.0", - "resolved": "https://registry.npm.taobao.org/eslint-visitor-keys/download/eslint-visitor-keys-1.1.0.tgz", - "integrity": "sha1-4qgs6oT/JGrW+1f5veW0ZiFFnsI=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", "dev": true }, "espree": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz", - "integrity": "sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", + "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", "dev": true, "requires": { "acorn": "^7.4.0", - "acorn-jsx": "^5.2.0", + "acorn-jsx": "^5.3.1", "eslint-visitor-keys": "^1.3.0" }, "dependencies": { @@ -5966,9 +6078,9 @@ "dev": true }, "esquery": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", - "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -5983,23 +6095,31 @@ } }, "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npm.taobao.org/esrecurse/download/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "requires": { - "estraverse": "^4.1.0" + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } } }, "estraverse": { "version": "4.3.0", - "resolved": "https://registry.npm.taobao.org/estraverse/download/estraverse-4.3.0.tgz?cache=0&sync_timestamp=1565734335990&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Festraverse%2Fdownload%2Festraverse-4.3.0.tgz", - "integrity": "sha1-OYrT88WiSUi+dyXoPRGn3ijNvR0=", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, "estree-walker": { "version": "1.0.1", - "resolved": "https://registry.npm.taobao.org/estree-walker/download/estree-walker-1.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/estree-walker/download/estree-walker-1.0.1.tgz?cache=0&sync_timestamp=1611956983677&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Festree-walker%2Fdownload%2Festree-walker-1.0.1.tgz", "integrity": "sha1-MbxdYSyWtwQQa0d+bdXYqhOMtwA=", "dev": true }, @@ -6247,17 +6367,6 @@ } } }, - "external-editor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", - "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", - "dev": true, - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, "extglob": { "version": "2.0.4", "resolved": "https://registry.npm.taobao.org/extglob/download/extglob-2.0.4.tgz", @@ -6342,9 +6451,9 @@ } }, "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, "fast-glob": { @@ -6436,22 +6545,13 @@ "bser": "2.1.1" } }, - "figures": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", - "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, "file-entry-cache": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "requires": { - "flat-cache": "^2.0.1" + "flat-cache": "^3.0.4" } }, "fill-range": { @@ -6479,7 +6579,7 @@ }, "find-up": { "version": "3.0.0", - "resolved": "https://registry.npm.taobao.org/find-up/download/find-up-3.0.0.tgz?cache=0&sync_timestamp=1597169872380&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffind-up%2Fdownload%2Ffind-up-3.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/find-up/download/find-up-3.0.0.tgz", "integrity": "sha1-SRafHXmTQwZG2mHsxa41XCHJe3M=", "dev": true, "requires": { @@ -6529,31 +6629,19 @@ "dev": true }, "flat-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", "dev": true, "requires": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" - }, - "dependencies": { - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } + "flatted": "^3.1.0", + "rimraf": "^3.0.2" } }, "flatted": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", - "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.2.tgz", + "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==", "dev": true }, "flush-write-stream": { @@ -7268,7 +7356,7 @@ }, "functional-red-black-tree": { "version": "1.0.1", - "resolved": "https://registry.npm.taobao.org/functional-red-black-tree/download/functional-red-black-tree-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, @@ -7663,6 +7751,12 @@ "function-bind": "^1.1.1" } }, + "has-bigints": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", + "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "dev": true + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz", @@ -7675,6 +7769,23 @@ "integrity": "sha1-n1IUdYpEGWxAbZvXbOv4HsLdMeg=", "dev": true }, + "has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + }, + "dependencies": { + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + } + } + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npm.taobao.org/has-value/download/has-value-1.0.0.tgz", @@ -7805,15 +7916,15 @@ } }, "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", "dev": true }, "import-fresh": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.2.tgz", - "integrity": "sha512-cTPNrlvJT6twpYy+YmKUKrTSjWFs3bjYjAhCwm+z4EOCubZxAuO+hHpRN64TqjEaYSHs7tJAE0w1CKMGmsG/lw==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -7864,134 +7975,27 @@ "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", "dev": true }, - "inquirer": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", - "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", + "internal-slot": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz", + "integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==", "dev": true, "requires": { - "ansi-escapes": "^4.2.1", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-width": "^3.0.0", - "external-editor": "^3.0.3", - "figures": "^3.0.0", - "lodash": "^4.17.19", - "mute-stream": "0.0.8", - "run-async": "^2.4.0", - "rxjs": "^6.6.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6" + "get-intrinsic": "^1.1.0", + "has": "^1.0.3", + "side-channel": "^1.0.4" }, "dependencies": { - "ansi-escapes": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", - "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", "dev": true, "requires": { - "type-fest": "^0.11.0" + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" } - }, - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, - "string-width": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", - "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "type-fest": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", - "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", - "dev": true } } }, @@ -8052,6 +8056,15 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, + "is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "requires": { + "has-bigints": "^1.0.1" + } + }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npm.taobao.org/is-binary-path/download/is-binary-path-1.0.1.tgz", @@ -8061,12 +8074,51 @@ "binary-extensions": "^1.0.0" } }, + "is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "dependencies": { + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + } + } + }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz", "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", "dev": true }, + "is-callable": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", + "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", + "dev": true + }, "is-ci": { "version": "2.0.0", "resolved": "https://registry.npm.taobao.org/is-ci/download/is-ci-2.0.0.tgz", @@ -8077,9 +8129,9 @@ } }, "is-core-module": { - "version": "2.0.0", - "resolved": "https://registry.npm.taobao.org/is-core-module/download/is-core-module-2.0.0.tgz?cache=0&sync_timestamp=1603133391687&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-core-module%2Fdownload%2Fis-core-module-2.0.0.tgz", - "integrity": "sha1-WFMbcK7R23wOjU6xoKLR3dZL0S0=", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", + "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", "dev": true, "requires": { "has": "^1.0.3" @@ -8106,10 +8158,13 @@ } }, "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npm.taobao.org/is-date-object/download/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", - "dev": true + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } }, "is-descriptor": { "version": "0.1.6", @@ -8183,9 +8238,9 @@ "dev": true }, "is-negative-zero": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.0.tgz", - "integrity": "sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", + "integrity": "sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==", "dev": true }, "is-number": { @@ -8208,6 +8263,15 @@ } } }, + "is-number-object": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.6.tgz", + "integrity": "sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } + }, "is-path-cwd": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", @@ -8244,6 +8308,39 @@ "@types/estree": "*" } }, + "is-regex": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "dependencies": { + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + } + } + }, "is-relative": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", @@ -8260,18 +8357,29 @@ "dev": true }, "is-string": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", - "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", - "dev": true - }, - "is-symbol": { - "version": "1.0.2", - "resolved": "https://registry.npm.taobao.org/is-symbol/download/is-symbol-1.0.2.tgz", - "integrity": "sha1-oFX2rlcZLK7jKeeoYBGLSXqVDzg=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", "dev": true, "requires": { - "has-symbols": "^1.0.0" + "has-tostringtag": "^1.0.0" + } + }, + "is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + }, + "dependencies": { + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + } } }, "is-typedarray": { @@ -11711,6 +11819,12 @@ "integrity": "sha1-gFZNLkg9rPbo7yCWUKZ98/DCg6Q=", "dev": true }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, "json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npm.taobao.org/json-parse-even-better-errors/download/json-parse-even-better-errors-2.3.1.tgz", @@ -11902,6 +12016,24 @@ "integrity": "sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg=", "dev": true }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "lodash.truncate": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", + "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "dev": true + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npm.taobao.org/loose-envify/download/loose-envify-1.4.0.tgz", @@ -11928,7 +12060,7 @@ }, "magic-string": { "version": "0.25.7", - "resolved": "https://registry.npm.taobao.org/magic-string/download/magic-string-0.25.7.tgz?cache=0&sync_timestamp=1583500518436&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmagic-string%2Fdownload%2Fmagic-string-0.25.7.tgz", + "resolved": "https://registry.npm.taobao.org/magic-string/download/magic-string-0.25.7.tgz", "integrity": "sha1-P0l9b9NMZpxnmNy4IfLvMfVEUFE=", "dev": true, "requires": { @@ -12156,23 +12288,6 @@ } } }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npm.taobao.org/mkdirp/download/mkdirp-0.5.1.tgz?cache=0&sync_timestamp=1579899671093&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmkdirp%2Fdownload%2Fmkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npm.taobao.org/minimist/download/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } - } - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npm.taobao.org/ms/download/ms-2.1.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.1.2.tgz", @@ -12185,12 +12300,6 @@ "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==", "dev": true }, - "mute-stream": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", - "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", - "dev": true - }, "nan": { "version": "2.14.0", "resolved": "https://registry.npm.taobao.org/nan/download/nan-2.14.0.tgz", @@ -12431,78 +12540,36 @@ } }, "object.entries": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.2.tgz", - "integrity": "sha512-BQdB9qKmb/HyNdMNWVr7O3+z5MUIx3aiegEIJqjMBbBf0YT9RRxTJSim4mzFqtyr7PDAHigq0N9dO0m0tRakQA==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.4.tgz", + "integrity": "sha512-h4LWKWE+wKQGhtMjZEBud7uLGhqyLwj8fpHOarZhD2uY3C9cRtk57VQ89ke3moByLXMedqs3XCHzyb4AmA2DjA==", "dev": true, "requires": { + "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.17.5", - "has": "^1.0.3" + "es-abstract": "^1.18.2" }, "dependencies": { - "es-abstract": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", - "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", "dev": true, "requires": { - "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "is-callable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", - "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", - "dev": true - }, - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { "has-symbols": "^1.0.1" } - }, - "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } } } }, @@ -12536,79 +12603,36 @@ } }, "object.values": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz", - "integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.4.tgz", + "integrity": "sha512-TnGo7j4XSnKQoK3MfvkzqKCi0nVe/D9I9IjwTNYdb/fxYHpjrluHVOgw0AF6jrRFGMPHdfuidR09tIDiIvnaSg==", "dev": true, "requires": { + "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1", - "function-bind": "^1.1.1", - "has": "^1.0.3" + "es-abstract": "^1.18.2" }, "dependencies": { - "es-abstract": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", - "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", "dev": true, "requires": { - "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "is-callable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", - "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", - "dev": true - }, - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { "has-symbols": "^1.0.1" } - }, - "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } } } }, @@ -12632,7 +12656,7 @@ }, "open": { "version": "7.4.2", - "resolved": "https://registry.npm.taobao.org/open/download/open-7.4.2.tgz?cache=0&sync_timestamp=1614759218873&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fopen%2Fdownload%2Fopen-7.4.2.tgz", + "resolved": "https://registry.npm.taobao.org/open/download/open-7.4.2.tgz?cache=0&sync_timestamp=1618549241971&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fopen%2Fdownload%2Fopen-7.4.2.tgz", "integrity": "sha1-uBR+Jtzz5CYxbHMAif1x7dKcIyE=", "dev": true, "optional": true, @@ -12679,12 +12703,6 @@ "lcid": "^1.0.0" } }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npm.taobao.org/os-tmpdir/download/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, "p-defer": { "version": "1.0.0", "resolved": "https://registry.npm.taobao.org/p-defer/download/p-defer-1.0.0.tgz", @@ -12948,6 +12966,60 @@ } } }, + "pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-2.0.0.tgz", + "integrity": "sha1-yBmscoBZpGHKscOImivjxJoATX8=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + } + } + }, "portfinder": { "version": "1.0.28", "resolved": "https://registry.npm.taobao.org/portfinder/download/portfinder-1.0.28.tgz", @@ -13261,9 +13333,9 @@ } }, "regexpp": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", - "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, "regexpu-core": { @@ -13457,6 +13529,12 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "require-main-filename": { "version": "1.0.1", "resolved": "https://registry.npm.taobao.org/require-main-filename/download/require-main-filename-1.0.1.tgz", @@ -13526,16 +13604,6 @@ "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "dev": true }, - "restore-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", - "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", - "dev": true, - "requires": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - } - }, "ret": { "version": "0.1.15", "resolved": "https://registry.npm.taobao.org/ret/download/ret-0.1.15.tgz", @@ -13626,7 +13694,7 @@ }, "rollup-plugin-visualizer": { "version": "4.2.2", - "resolved": "https://registry.npm.taobao.org/rollup-plugin-visualizer/download/rollup-plugin-visualizer-4.2.2.tgz?cache=0&sync_timestamp=1617262822404&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Frollup-plugin-visualizer%2Fdownload%2Frollup-plugin-visualizer-4.2.2.tgz", + "resolved": "https://registry.nlark.com/rollup-plugin-visualizer/download/rollup-plugin-visualizer-4.2.2.tgz", "integrity": "sha1-7euLP8b0mzyV9sxmj066V8YRIJk=", "dev": true, "optional": true, @@ -13639,14 +13707,14 @@ "dependencies": { "ansi-regex": { "version": "5.0.0", - "resolved": "https://registry.npm.taobao.org/ansi-regex/download/ansi-regex-5.0.0.tgz?cache=0&sync_timestamp=1570188663907&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-regex%2Fdownload%2Fansi-regex-5.0.0.tgz", + "resolved": "https://registry.nlark.com/ansi-regex/download/ansi-regex-5.0.0.tgz", "integrity": "sha1-OIU59VF5vzkznIGvMKZU1p+Hy3U=", "dev": true, "optional": true }, "ansi-styles": { "version": "4.3.0", - "resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-4.3.0.tgz?cache=0&sync_timestamp=1601839226460&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-4.3.0.tgz", + "resolved": "https://registry.nlark.com/ansi-styles/download/ansi-styles-4.3.0.tgz", "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", "dev": true, "optional": true, @@ -13685,7 +13753,7 @@ }, "emoji-regex": { "version": "8.0.0", - "resolved": "https://registry.npm.taobao.org/emoji-regex/download/emoji-regex-8.0.0.tgz?cache=0&sync_timestamp=1603212180491&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Femoji-regex%2Fdownload%2Femoji-regex-8.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/emoji-regex/download/emoji-regex-8.0.0.tgz?cache=0&sync_timestamp=1614682725186&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Femoji-regex%2Fdownload%2Femoji-regex-8.0.0.tgz", "integrity": "sha1-6Bj9ac5cz8tARZT4QpY79TFkzDc=", "dev": true, "optional": true @@ -13699,21 +13767,21 @@ }, "is-fullwidth-code-point": { "version": "3.0.0", - "resolved": "https://registry.npm.taobao.org/is-fullwidth-code-point/download/is-fullwidth-code-point-3.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/is-fullwidth-code-point/download/is-fullwidth-code-point-3.0.0.tgz?cache=0&sync_timestamp=1618552489864&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-fullwidth-code-point%2Fdownload%2Fis-fullwidth-code-point-3.0.0.tgz", "integrity": "sha1-8Rb4Bk/pCz94RKOJl8C3UFEmnx0=", "dev": true, "optional": true }, "source-map": { "version": "0.7.3", - "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.7.3.tgz?cache=0&sync_timestamp=1571657176668&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsource-map%2Fdownload%2Fsource-map-0.7.3.tgz", + "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.7.3.tgz", "integrity": "sha1-UwL4FpAxc1ImVECS5kmB91F1A4M=", "dev": true, "optional": true }, "string-width": { "version": "4.2.2", - "resolved": "https://registry.npm.taobao.org/string-width/download/string-width-4.2.2.tgz?cache=0&sync_timestamp=1614522241573&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstring-width%2Fdownload%2Fstring-width-4.2.2.tgz", + "resolved": "https://registry.nlark.com/string-width/download/string-width-4.2.2.tgz", "integrity": "sha1-2v1PlVmnWFz7pSnGoKT3NIjr1MU=", "dev": true, "optional": true, @@ -13725,7 +13793,7 @@ }, "strip-ansi": { "version": "6.0.0", - "resolved": "https://registry.npm.taobao.org/strip-ansi/download/strip-ansi-6.0.0.tgz?cache=0&sync_timestamp=1573280518303&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstrip-ansi%2Fdownload%2Fstrip-ansi-6.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/strip-ansi/download/strip-ansi-6.0.0.tgz?cache=0&sync_timestamp=1618553320591&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstrip-ansi%2Fdownload%2Fstrip-ansi-6.0.0.tgz", "integrity": "sha1-CxVx3XZpzNTz4G4U7x7tJiJa5TI=", "dev": true, "optional": true, @@ -13747,7 +13815,7 @@ }, "yargs": { "version": "16.2.0", - "resolved": "https://registry.npm.taobao.org/yargs/download/yargs-16.2.0.tgz?cache=0&sync_timestamp=1607207963779&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs%2Fdownload%2Fyargs-16.2.0.tgz", + "resolved": "https://registry.nlark.com/yargs/download/yargs-16.2.0.tgz", "integrity": "sha1-HIK/D2tqZur85+8w43b0mhJHf2Y=", "dev": true, "optional": true, @@ -13776,27 +13844,12 @@ "integrity": "sha1-yPFVMR0Wf2jyHhaN9x7FsIMRNzQ=", "dev": true }, - "run-async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", - "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", - "dev": true - }, "run-parallel": { "version": "1.1.10", "resolved": "https://registry.npm.taobao.org/run-parallel/download/run-parallel-1.1.10.tgz?cache=0&sync_timestamp=1603768238747&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Frun-parallel%2Fdownload%2Frun-parallel-1.1.10.tgz", "integrity": "sha1-YKUbKug2Y2yBN33xbLEHNRvNE+8=", "dev": true }, - "rxjs": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.3.tgz", - "integrity": "sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz", @@ -13867,7 +13920,7 @@ }, "serialize-javascript": { "version": "4.0.0", - "resolved": "https://registry.npm.taobao.org/serialize-javascript/download/serialize-javascript-4.0.0.tgz?cache=0&sync_timestamp=1599740689479&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fserialize-javascript%2Fdownload%2Fserialize-javascript-4.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/serialize-javascript/download/serialize-javascript-4.0.0.tgz?cache=0&sync_timestamp=1599740650381&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fserialize-javascript%2Fdownload%2Fserialize-javascript-4.0.0.tgz", "integrity": "sha1-tSXhI4SJpez8Qq+sw/6Z5mb0sao=", "dev": true, "requires": { @@ -13979,14 +14032,46 @@ "dev": true }, "slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", "dev": true, "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + } } }, "snapdragon": { @@ -14354,154 +14439,68 @@ } }, "string.prototype.trimend": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.2.tgz", - "integrity": "sha512-8oAG/hi14Z4nOVP0z6mdiVZ/wqjDtWSLygMigTzAb+7aPEDTleeFf+WrF+alzecxIRkckkJVn+dTlwzJXORATw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", + "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", "dev": true, "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.1" + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" }, "dependencies": { - "es-abstract": { - "version": "1.18.0-next.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz", - "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==", + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", "dev": true, "requires": { - "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-negative-zero": "^2.0.0", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "is-callable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", - "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", - "dev": true - }, - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { "has-symbols": "^1.0.1" } - }, - "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } } } }, "string.prototype.trimstart": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.2.tgz", - "integrity": "sha512-7F6CdBTl5zyu30BJFdzSTlSlLPwODC23Od+iLoVH8X6+3fvDPPuBVVj9iaB1GOsSTSIgVfsfm27R2FGrAPznWg==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", + "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", "dev": true, "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.1" + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" }, "dependencies": { - "es-abstract": { - "version": "1.18.0-next.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz", - "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==", + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", "dev": true, "requires": { - "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-negative-zero": "^2.0.0", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "is-callable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", - "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", - "dev": true - }, - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { "has-symbols": "^1.0.1" } - }, - "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } } } }, @@ -14594,41 +14593,73 @@ "dev": true }, "table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz", + "integrity": "sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg==", "dev": true, "requires": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" + "ajv": "^8.0.1", + "lodash.clonedeep": "^4.5.0", + "lodash.truncate": "^4.4.2", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0" }, "dependencies": { + "ajv": { + "version": "8.6.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.2.tgz", + "integrity": "sha512-9807RlWAgT564wT+DjeyU5OFMPjmzxVobvDFmNAhY+5zD6A2ly3jDp6sgnfyDtlIQ+7H97oc/DGCzzfu9rjw9w==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true }, "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", "dev": true, "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" } }, "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "ansi-regex": "^4.1.0" + "ansi-regex": "^5.0.0" } } } @@ -14675,7 +14706,7 @@ }, "text-table": { "version": "0.2.0", - "resolved": "https://registry.npm.taobao.org/text-table/download/text-table-0.2.0.tgz", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, @@ -14692,7 +14723,7 @@ "dependencies": { "ansi-regex": { "version": "4.1.0", - "resolved": "https://registry.npm.taobao.org/ansi-regex/download/ansi-regex-4.1.0.tgz", + "resolved": "https://registry.nlark.com/ansi-regex/download/ansi-regex-4.1.0.tgz", "integrity": "sha1-i5+PCM8ay4Q3Vqg5yox+MWjFGZc=", "dev": true }, @@ -14721,7 +14752,7 @@ }, "string-width": { "version": "3.1.0", - "resolved": "https://registry.npm.taobao.org/string-width/download/string-width-3.1.0.tgz?cache=0&sync_timestamp=1614522241573&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstring-width%2Fdownload%2Fstring-width-3.1.0.tgz", + "resolved": "https://registry.nlark.com/string-width/download/string-width-3.1.0.tgz", "integrity": "sha1-InZ74htirxCBV0MG9prFG2IgOWE=", "dev": true, "requires": { @@ -14732,7 +14763,7 @@ }, "strip-ansi": { "version": "5.2.0", - "resolved": "https://registry.npm.taobao.org/strip-ansi/download/strip-ansi-5.2.0.tgz", + "resolved": "https://registry.npm.taobao.org/strip-ansi/download/strip-ansi-5.2.0.tgz?cache=0&sync_timestamp=1618553320591&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstrip-ansi%2Fdownload%2Fstrip-ansi-5.2.0.tgz", "integrity": "sha1-jJpTb+tq/JYr36WxBKUJHBrZwK4=", "dev": true, "requires": { @@ -14764,7 +14795,7 @@ }, "yargs": { "version": "13.3.2", - "resolved": "https://registry.npm.taobao.org/yargs/download/yargs-13.3.2.tgz?cache=0&sync_timestamp=1618115316688&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs%2Fdownload%2Fyargs-13.3.2.tgz", + "resolved": "https://registry.nlark.com/yargs/download/yargs-13.3.2.tgz", "integrity": "sha1-rX/+/sGqWVZayRX4Lcyzipwxot0=", "dev": true, "requires": { @@ -14798,12 +14829,6 @@ "integrity": "sha1-xRmSNYA6rRh1SmZ9ZZtecs4Wdks=", "dev": true }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npm.taobao.org/through/download/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, "through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", @@ -14830,15 +14855,6 @@ "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", "dev": true }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "~1.0.2" - } - }, "tmpl": { "version": "1.0.4", "resolved": "https://registry.npm.taobao.org/tmpl/download/tmpl-1.0.4.tgz", @@ -14974,24 +14990,23 @@ } }, "tsconfig-paths": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", - "integrity": "sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.10.1.tgz", + "integrity": "sha512-rETidPDgCpltxF7MjBZlAFPUHv5aHH2MymyPvh+vEyWAED4Eb/WeMbsnD/JDr4OKPOA1TssDHgIcpTN5Kh0p6Q==", "dev": true, "requires": { - "@types/json5": "^0.0.29", - "json5": "^1.0.1", + "json5": "^2.2.0", "minimist": "^1.2.0", "strip-bom": "^3.0.0" }, "dependencies": { "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", "dev": true, "requires": { - "minimist": "^1.2.0" + "minimist": "^1.2.5" } }, "strip-bom": { @@ -15003,15 +15018,15 @@ } }, "tslib": { - "version": "1.10.0", - "resolved": "https://registry.npm.taobao.org/tslib/download/tslib-1.10.0.tgz", - "integrity": "sha1-w8GflZc/sKYpc/sJ2Q2WHuQ+XIo=", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, "tsutils": { - "version": "3.17.1", - "resolved": "https://registry.npm.taobao.org/tsutils/download/tsutils-3.17.1.tgz", - "integrity": "sha1-7XGZF/EcoN7lhicrKsSeAVot11k=", + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -15192,6 +15207,26 @@ } } }, + "unbox-primitive": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", + "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has-bigints": "^1.0.1", + "has-symbols": "^1.0.2", + "which-boxed-primitive": "^1.0.2" + }, + "dependencies": { + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + } + } + }, "unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npm.taobao.org/unc-path-regex/download/unc-path-regex-0.1.2.tgz", @@ -15410,9 +15445,9 @@ "optional": true }, "v8-compile-cache": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz", - "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, "v8-to-istanbul": { @@ -15616,6 +15651,19 @@ "isexe": "^2.0.0" } }, + "which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "requires": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + } + }, "which-module": { "version": "1.0.0", "resolved": "https://registry.npm.taobao.org/which-module/download/which-module-1.0.0.tgz", @@ -15650,15 +15698,6 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "write": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } - }, "write-file-atomic": { "version": "3.0.3", "resolved": "https://registry.npm.taobao.org/write-file-atomic/download/write-file-atomic-3.0.3.tgz", diff --git a/package.json b/package.json index 98a8ebe3ae..9fc610fcbe 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ ], "module": "index.js", "scripts": { - "server": "http-server . -p 8002 -o http://127.0.0.1:8002/playground/index.html", + "server": "http-server . -p 8002 -o playground/index.html", "postinstall": "gulp build-debug-infos && gulp build-declarations && npm run fetch-ral", "build": "gulp build", "build:dev": "gulp build-h5-source", @@ -36,15 +36,15 @@ "@types/fs-extra": "^5.0.4", "@types/jest": "^24.9.1", "@types/yargs": "^12.0.14", - "@typescript-eslint/eslint-plugin": "^4.6.1", - "@typescript-eslint/parser": "^4.6.1", + "@typescript-eslint/eslint-plugin": "^4.29.3", + "@typescript-eslint/parser": "^4.29.3", "child_process": "^1.0.2", "commander": "^2.20.3", "dat.gui": "^0.7.5", "del": "^6.0.0", - "eslint": "^7.2.0", + "eslint": "^7.32.0", "eslint-config-airbnb-base": "^14.2.1", - "eslint-plugin-import": "^2.22.1", + "eslint-plugin-import": "^2.24.1", "fs": "^0.0.1-security", "fs-extra": "^7.0.1", "gulp": "^4.0.2", diff --git a/platforms/.eslintrc.yaml b/platforms/.eslintrc.yaml new file mode 100644 index 0000000000..bb9f03c008 --- /dev/null +++ b/platforms/.eslintrc.yaml @@ -0,0 +1,77 @@ +root: true + +extends: + - eslint:recommended + - airbnb-base + +env: + browser: true + node: true + es6: true + jest: true + +globals: + cc: readonly + +rules: + # https://eslint.org/docs/rules/ + # https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin + + # !!!!!!!!!!!!!!!!!!!!!!!!! + # BEFORE ADDING ANY RULES + # PLEASE EXPLAIN THE REASON IN THE COMMENT. + + ##### RECOMMENDED RULE OVERRIDES ##### + + camelcase: off # underscores may come in handy in some cases + eqeqeq: warn # important check missing from recommended + keyword-spacing: warn # we require this explicitly + no-multi-spaces: off # useful for manually align some expression across lines + prefer-rest-params: off # we need ES5 to be fast too + prefer-spread: off # we need ES5 to be fast too + space-before-function-paren: [warn, always] # we require this explicitly + radix: off # we sometimes do not need to pass a second parameter + # allow underscores, we still widely use pre-dangle naming in our naming convention + # e.g. private properties, private functions, module scope shared variables etc. + no-underscore-dangle: off + quotes: [warn, single, { allowTemplateLiterals: true }] # force single, but allow template literal + no-else-return: off # else-return is a common pattern which clearly expresses the control flow + no-unused-expressions: off # taken over by '@typescript-eslint/no-unused-expressions' + + ##### AIRBNB-SPECIFIC RULE OVERRIDES ##### + + class-methods-use-this: off # so empty functions could work + guard-for-in: off # for-in is a efficient choice for plain objects + import/export: off # so export declare namespace could work + import/extensions: off # typescript doesn't support this + import/no-unresolved: off # TODO: fix internal modules + import/prefer-default-export: off # prefer named exports + indent: off # use @typescript-eslint/indent instead for better compatibility + + lines-between-class-members: off # be more lenient on member declarations + max-classes-per-file: off # helper classes are common + max-len: [warn, 150] # more lenient on max length per line + no-console: off # this is just too much work, cc.warn is still too much pain to use + no-plusplus: off # allow increment/decrement operators + no-continue: off # allow unlabeled continues + no-mixed-operators: off # this is just cumbersome + no-multi-assign: off # it is handy sometimes + no-nested-ternary: off # it is handy sometimes + no-param-reassign: off # the output object is passed as parameters all the time + no-restricted-syntax: off # for-in is a efficient choice for plain objects + no-return-assign: off # it is handy sometimes + no-shadow: off # TODO: this throws false-positives? + no-sequences: off # it is handy sometimes + no-bitwise: off # we use this extensively + no-use-before-define: off # just too much work + no-useless-constructor: off # gives false-positives for empty constructor with parameter properties + object-curly-newline: off # we want manual control over this + one-var-declaration-per-line: off # auto-fix has order issues with `one-var` + prefer-destructuring: off # auto-fix is not smart enough to merge different instances + linebreak-style: off # we don't enforce this on everyone's dev environment for now + spaced-comment: off # for license declarations + + ##### JS SPECIFIC OVERRIDES ##### + + global-require: off # may require different files based on global environment + func-names: off # overriding existing functions are common diff --git a/platforms/native/engine/index.js b/platforms/native/engine/index.js index 3105c14ca4..82f3b0995b 100644 --- a/platforms/native/engine/index.js +++ b/platforms/native/engine/index.js @@ -32,9 +32,8 @@ require('./jsb-loader.js'); require('./jsb-videoplayer.js'); require('./jsb-webview.js'); require('./jsb-editbox.js'); -require('./jsb-editor-support.js') -require('./jsb-spine-skeleton.js') -require('./jsb-dragonbones.js') +require('./jsb-editor-support.js'); +require('./jsb-spine-skeleton.js'); +require('./jsb-dragonbones.js'); -if (cc.physics && cc.physics.PhysicsSystem.PHYSICS_PHYSX) - require('./jsb-physics.js'); \ No newline at end of file +if (cc.physics && cc.physics.PhysicsSystem.PHYSICS_PHYSX) { require('./jsb-physics.js'); } diff --git a/platforms/native/engine/jsb-gfx.js b/platforms/native/engine/jsb-gfx.js index 730ec24649..d7ef8fb74f 100644 --- a/platforms/native/engine/jsb-gfx.js +++ b/platforms/native/engine/jsb-gfx.js @@ -23,170 +23,57 @@ THE SOFTWARE. ****************************************************************************/ -// Converters for converting js objects to jsb struct objects -let _converters = { - texImagesToBuffers: function (texImages) { - if (texImages) { - let buffers = []; - for (let i = 0; i < texImages.length; ++i) { - let texImage = texImages[i]; - if (texImage instanceof HTMLCanvasElement) { - // Refer to HTMLCanvasElement and ImageData implementation - buffers.push(texImage._data.data); - } - else if (texImage instanceof HTMLImageElement) { - // Refer to HTMLImageElement implementation - buffers.push(texImage._data); - } - else { - console.log('copyTexImagesToTexture: Convert texImages to data buffers failed'); - return null; - } +/* global gfx */ + +const deviceProto = gfx.Device.prototype; +const swapchainProto = gfx.Swapchain.prototype; +const bufferProto = gfx.Buffer.prototype; +const textureProto = gfx.Texture.prototype; +const descriptorSetProto = gfx.DescriptorSet.prototype; + +///////////////////////////// handle different paradigms ///////////////////////////// + +const oldCopyTexImagesToTextureFunc = deviceProto.copyTexImagesToTexture; +deviceProto.copyTexImagesToTexture = function (texImages, texture, regions) { + const images = []; + if (texImages) { + for (let i = 0; i < texImages.length; ++i) { + const texImage = texImages[i]; + if (texImage instanceof HTMLCanvasElement) { + // Refer to HTMLCanvasElement and ImageData implementation + images.push(texImage._data.data); + } else if (texImage instanceof HTMLImageElement) { + // Refer to HTMLImageElement implementation + images.push(texImage._data); + } else { + console.log('copyTexImagesToTexture: Convert texImages to data buffers failed'); + return; } - return buffers; } - }, - DeviceInfo: function (info) { - let handler = window.windowHandler; - return new gfx.DeviceInfo(info.isAntialias, handler, info.width, info.height, info.devicePixelRatio, info.bindingMappingInfo); } + oldCopyTexImagesToTextureFunc.call(this, images, texture, regions); }; -// Helper functions to convert the original jsb function to a wrapper function -function replaceFunction (jsbFunc, ...converters) { - let l = converters.length; - // Validation - for (let i = 0; i < l; ++i) { - if (!converters[i]) { - return null; - } - } - if (l === 1) { - return function (param0) { - // Convert parameters one by one - let _jsbParam0 = converters[0](param0); - return this[jsbFunc](_jsbParam0); - } - } - else if (l === 2) { - return function (param0, param1) { - // Convert parameters one by one - let _jsbParam0 = converters[0](param0); - let _jsbParam1 = converters[1](param1); - return this[jsbFunc](_jsbParam0, _jsbParam1); - } - } - else if (l === 3) { - return function (param0, param1, param2) { - // Convert parameters one by one - let _jsbParam0 = converters[0](param0); - let _jsbParam1 = converters[1](param1); - let _jsbParam2 = converters[2](param2); - return this[jsbFunc](_jsbParam0, _jsbParam1, _jsbParam2); - } - } - else { - return function (...params) { - if (l !== params.length) { - throw new Error(jsbFunc + ': The parameters length don\'t match the converters length'); - } - let jsbParams = new Array(l); - for (let i = 0; i < l; ++i) { - jsbParams[i] = converters[i](params[i]); - } - return this[jsbFunc].apply(this, jsbParams); - } - }; -} +const oldDeviceCreateSwapchainFunc = deviceProto.createSwapchain; +deviceProto.createSwapchain = function (info) { + info.windowHandle = window.windowHandler; + return oldDeviceCreateSwapchainFunc.call(this, info); +}; -// Replace all given functions to the wrapper function provided -function replace (proto, replacements) { - for (let func in replacements) { - let oldFunc = proto[func]; - let newFunc = replacements[func]; - if (oldFunc && newFunc) { - let jsbFunc = '_' + func; - proto[jsbFunc] = oldFunc; - proto[func] = newFunc; - } - } -} +const oldSwapchainInitializeFunc = swapchainProto.initialize; +swapchainProto.initialize = function (info) { + info.windowHandle = window.windowHandler; + oldSwapchainInitializeFunc.call(this, info); +}; -// Cache dirty to avoid invoking gfx.DescriptorSet.update(). -let descriptorSetProto = gfx.DescriptorSet.prototype; -descriptorSetProto.bindBuffer = function (binding, buffer, index) { - this.dirtyJSB = descriptorSetProto.bindBufferJSB.call(this, binding, buffer, index || 0); -} -descriptorSetProto.bindSampler = function (binding, sampler, index) { - this.dirtyJSB = descriptorSetProto.bindSamplerJSB.call(this, binding, sampler, index || 0); -} -descriptorSetProto.bindTexture = function (bindding, texture, index) { - this.dirtyJSB = descriptorSetProto.bindTextureJSB.call(this, bindding, texture, index || 0); -} -let oldDSUpdate = descriptorSetProto.update; -descriptorSetProto.update = function () { - if (!this.dirtyJSB) return; - oldDSUpdate.call(this); - this.dirtyJSB = false; -} - -replace(gfx.DeviceManager, { - create: replaceFunction('_create', _converters.DeviceInfo), -}); - -let deviceProto = gfx.Device.prototype; - -let oldCopyTexImagesToTextureFunc = deviceProto.copyTexImagesToTexture; -deviceProto.copyTexImagesToTexture = function (texImages, texture, regions) { - let images = _converters.texImagesToBuffers(texImages); - oldCopyTexImagesToTextureFunc.call(this, images, texture, regions); -} - -let oldDeviceCreatBufferFun = deviceProto.createBuffer; -deviceProto.createBuffer = function (info) { - let buffer; - if (info.buffer) { - buffer = oldDeviceCreatBufferFun.call(this, info, true); - } else { - buffer = oldDeviceCreatBufferFun.call(this, info, false); - } - buffer.cachedUsage = info.usage; - return buffer; -} - -let oldDeviceCreatTextureFun = deviceProto.createTexture; -deviceProto.createTexture = function (info) { - if (info.texture) { - return oldDeviceCreatTextureFun.call(this, info, true); - } else { - return oldDeviceCreatTextureFun.call(this, info, false); - } -} - -Object.defineProperty(deviceProto, 'uboOffsetAlignment', { - get () { - if (this.cachedUboOffsetAlignment === undefined) { - this.cachedUboOffsetAlignment = this.getUboOffsetAlignment(); - } - return this.cachedUboOffsetAlignment; - } -}) - -let shaderProto = gfx.Shader.prototype; -cc.js.get(shaderProto, 'id', function () { - return this.shaderID; -}); - -let bufferProto = gfx.Buffer.prototype; - -let oldUpdate = bufferProto.update; +const oldUpdate = bufferProto.update; bufferProto.update = function (buffer, size) { if (buffer.byteLength === 0) return; let buffSize; if (this.cachedUsage & 0x40) { // BufferUsageBit.INDIRECT // It is a IIndirectBuffer object. - let drawInfos = buffer.drawInfos; + const { drawInfos } = buffer; buffer = new Uint32Array(drawInfos.length * 7); let baseIndex = 0; let drawInfo; @@ -210,23 +97,70 @@ bufferProto.update = function (buffer, size) { } oldUpdate.call(this, buffer, buffSize); -} +}; -let oldBufferInitializeFunc = bufferProto.initialize; +const oldDeviceCreateBufferFun = deviceProto.createBuffer; +deviceProto.createBuffer = function (info) { + let buffer; + if (info.buffer) { + buffer = oldDeviceCreateBufferFun.call(this, info, true); + } else { + buffer = oldDeviceCreateBufferFun.call(this, info, false); + } + buffer.cachedUsage = info.usage; + return buffer; +}; + +const oldBufferInitializeFunc = bufferProto.initialize; bufferProto.initialize = function (info) { if (info.buffer) { oldBufferInitializeFunc.call(this, info, true); } else { oldBufferInitializeFunc.call(this, info, false); } -} +}; -let textureProto = gfx.Texture.prototype; -let oldTextureInitializeFunc = textureProto.initialize; +const oldDeviceCreateTextureFun = deviceProto.createTexture; +deviceProto.createTexture = function (info) { + if (info.texture) { + return oldDeviceCreateTextureFun.call(this, info, true); + } + return oldDeviceCreateTextureFun.call(this, info, false); +}; + +const oldTextureInitializeFunc = textureProto.initialize; textureProto.initialize = function (info) { if (info.texture) { oldTextureInitializeFunc.call(this, info, true); } else { oldTextureInitializeFunc.call(this, info, false); } -} +}; + +///////////////////////////// optimizations ///////////////////////////// + +// Cache dirty to avoid invoking gfx.DescriptorSet.update(). +descriptorSetProto.bindBuffer = function (binding, buffer, index) { + this.dirtyJSB = descriptorSetProto.bindBufferJSB.call(this, binding, buffer, index || 0); +}; +descriptorSetProto.bindSampler = function (binding, sampler, index) { + this.dirtyJSB = descriptorSetProto.bindSamplerJSB.call(this, binding, sampler, index || 0); +}; +descriptorSetProto.bindTexture = function (bindding, texture, index) { + this.dirtyJSB = descriptorSetProto.bindTextureJSB.call(this, bindding, texture, index || 0); +}; +const oldDSUpdate = descriptorSetProto.update; +descriptorSetProto.update = function () { + if (!this.dirtyJSB) return; + oldDSUpdate.call(this); + this.dirtyJSB = false; +}; + +Object.defineProperty(deviceProto, 'uboOffsetAlignment', { + get () { + if (this.cachedUboOffsetAlignment === undefined) { + this.cachedUboOffsetAlignment = this.getUboOffsetAlignment(); + } + return this.cachedUboOffsetAlignment; + }, +}); diff --git a/playground/.eslintrc.yaml b/playground/.eslintrc.yaml new file mode 100644 index 0000000000..bb9f03c008 --- /dev/null +++ b/playground/.eslintrc.yaml @@ -0,0 +1,77 @@ +root: true + +extends: + - eslint:recommended + - airbnb-base + +env: + browser: true + node: true + es6: true + jest: true + +globals: + cc: readonly + +rules: + # https://eslint.org/docs/rules/ + # https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin + + # !!!!!!!!!!!!!!!!!!!!!!!!! + # BEFORE ADDING ANY RULES + # PLEASE EXPLAIN THE REASON IN THE COMMENT. + + ##### RECOMMENDED RULE OVERRIDES ##### + + camelcase: off # underscores may come in handy in some cases + eqeqeq: warn # important check missing from recommended + keyword-spacing: warn # we require this explicitly + no-multi-spaces: off # useful for manually align some expression across lines + prefer-rest-params: off # we need ES5 to be fast too + prefer-spread: off # we need ES5 to be fast too + space-before-function-paren: [warn, always] # we require this explicitly + radix: off # we sometimes do not need to pass a second parameter + # allow underscores, we still widely use pre-dangle naming in our naming convention + # e.g. private properties, private functions, module scope shared variables etc. + no-underscore-dangle: off + quotes: [warn, single, { allowTemplateLiterals: true }] # force single, but allow template literal + no-else-return: off # else-return is a common pattern which clearly expresses the control flow + no-unused-expressions: off # taken over by '@typescript-eslint/no-unused-expressions' + + ##### AIRBNB-SPECIFIC RULE OVERRIDES ##### + + class-methods-use-this: off # so empty functions could work + guard-for-in: off # for-in is a efficient choice for plain objects + import/export: off # so export declare namespace could work + import/extensions: off # typescript doesn't support this + import/no-unresolved: off # TODO: fix internal modules + import/prefer-default-export: off # prefer named exports + indent: off # use @typescript-eslint/indent instead for better compatibility + + lines-between-class-members: off # be more lenient on member declarations + max-classes-per-file: off # helper classes are common + max-len: [warn, 150] # more lenient on max length per line + no-console: off # this is just too much work, cc.warn is still too much pain to use + no-plusplus: off # allow increment/decrement operators + no-continue: off # allow unlabeled continues + no-mixed-operators: off # this is just cumbersome + no-multi-assign: off # it is handy sometimes + no-nested-ternary: off # it is handy sometimes + no-param-reassign: off # the output object is passed as parameters all the time + no-restricted-syntax: off # for-in is a efficient choice for plain objects + no-return-assign: off # it is handy sometimes + no-shadow: off # TODO: this throws false-positives? + no-sequences: off # it is handy sometimes + no-bitwise: off # we use this extensively + no-use-before-define: off # just too much work + no-useless-constructor: off # gives false-positives for empty constructor with parameter properties + object-curly-newline: off # we want manual control over this + one-var-declaration-per-line: off # auto-fix has order issues with `one-var` + prefer-destructuring: off # auto-fix is not smart enough to merge different instances + linebreak-style: off # we don't enforce this on everyone's dev environment for now + spaced-comment: off # for license declarations + + ##### JS SPECIFIC OVERRIDES ##### + + global-require: off # may require different files based on global environment + func-names: off # overriding existing functions are common diff --git a/playground/common/camera.js b/playground/common/camera.js index d3f6c2ddfa..90f2f6c0aa 100644 --- a/playground/common/camera.js +++ b/playground/common/camera.js @@ -1,117 +1,143 @@ -const { Quat, Vec2, Vec3 } = cc.math; +document.addEventListener('readystatechange', () => { + if (document.readyState !== 'complete') return; -const v2_1 = new Vec2(); -const v2_2 = new Vec2(); -const v3_1 = new Vec3(); -const qt_1 = new Quat(); -const id_forward = new Vec3(0, 0, 1); -const KEYCODE = { - W: 'W'.charCodeAt(0), - S: 'S'.charCodeAt(0), - A: 'A'.charCodeAt(0), - D: 'D'.charCodeAt(0), - Q: 'Q'.charCodeAt(0), - E: 'E'.charCodeAt(0), - SHIFT: cc.macro.KEY.shift, -}; + window.FirstPersonCamera = (() => { + const { Quat, Vec2, Vec3 } = cc.math; -const FirstPersonCamera = cc.Class({ - extends: cc.Component, - properties: { - moveSpeed: 1, - moveSpeedShiftScale: 5, - damp: 0.2, - rotateSpeed: 1, - }, + const v2_1 = new Vec2(); + const v2_2 = new Vec2(); + const v3_1 = new Vec3(); + const qt_1 = new Quat(); + const KEYCODE = { + W: 'W'.charCodeAt(0), + S: 'S'.charCodeAt(0), + A: 'A'.charCodeAt(0), + D: 'D'.charCodeAt(0), + Q: 'Q'.charCodeAt(0), + E: 'E'.charCodeAt(0), + SHIFT: cc.macro.KEY.shift, + }; - onLoad () { - this._euler = new Vec3(); - this._velocity = new Vec3(); - this._position = new Vec3(); - this._speedScale = 1; - cc.systemEvent.on(cc.SystemEvent.EventType.MOUSE_WHEEL, this.onMouseWheel, this); - cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this); - cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this); - cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_START, this.onTouchStart, this); - cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_MOVE, this.onTouchMove, this); - cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_END, this.onTouchEnd, this); - Vec3.copy(this._euler, this.node.eulerAngles); - Vec3.copy(this._position, this.node.position); - }, + class FirstPersonCamera extends cc.Component { + constructor () { + super(); + this.moveSpeed = 1; + this.moveSpeedShiftScale = 5; + this.damp = 0.2; + this.rotateSpeed = 1; + } - onDestroy () { - cc.systemEvent.off(cc.SystemEvent.EventType.MOUSE_WHEEL, this.onMouseWheel, this); - cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this); - cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this); - cc.systemEvent.off(cc.SystemEvent.EventType.TOUCH_START, this.onTouchStart, this); - cc.systemEvent.off(cc.SystemEvent.EventType.TOUCH_MOVE, this.onTouchMove, this); - cc.systemEvent.off(cc.SystemEvent.EventType.TOUCH_END, this.onTouchEnd, this); - }, + onLoad () { + this._euler = new Vec3(); + this._velocity = new Vec3(); + this._position = new Vec3(); + this._speedScale = 1; + cc.systemEvent.on(cc.SystemEvent.EventType.MOUSE_WHEEL, this.onMouseWheel, this); + cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this); + cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this); + cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_START, this.onTouchStart, this); + cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_MOVE, this.onTouchMove, this); + cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_END, this.onTouchEnd, this); + Vec3.copy(this._euler, this.node.eulerAngles); + Vec3.copy(this._position, this.node.position); + } - update (dt) { - // position - Vec3.transformQuat(v3_1, this._velocity, this.node.rotation); - Vec3.scaleAndAdd(this._position, this._position, v3_1, this.moveSpeed * this._speedScale); - Vec3.lerp(v3_1, this.node.position, this._position, dt / this.damp); - this.node.setPosition(v3_1); - // rotation - Quat.fromEuler(qt_1, this._euler.x, this._euler.y, this._euler.z); - Quat.slerp(qt_1, this.node.rotation, qt_1, dt / this.damp); - this.node.setRotation(qt_1); - }, + onDestroy () { + cc.systemEvent.off(cc.SystemEvent.EventType.MOUSE_WHEEL, this.onMouseWheel, this); + cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this); + cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this); + cc.systemEvent.off(cc.SystemEvent.EventType.TOUCH_START, this.onTouchStart, this); + cc.systemEvent.off(cc.SystemEvent.EventType.TOUCH_MOVE, this.onTouchMove, this); + cc.systemEvent.off(cc.SystemEvent.EventType.TOUCH_END, this.onTouchEnd, this); + } - onMouseWheel (e) { - const delta = -e.getScrollY() * this.moveSpeed * 0.1; // delta is positive when scroll down - Vec3.transformQuat(v3_1, Vec3.UNIT_Z, this.node.rotation); - Vec3.scaleAndAdd(this._position, this.node.position, v3_1, delta); - }, + update (dt) { + // position + Vec3.transformQuat(v3_1, this._velocity, this.node.rotation); + Vec3.scaleAndAdd(this._position, this._position, v3_1, this.moveSpeed * this._speedScale); + Vec3.lerp(v3_1, this.node.position, this._position, dt / this.damp); + this.node.setPosition(v3_1); + // rotation + Quat.fromEuler(qt_1, this._euler.x, this._euler.y, this._euler.z); + Quat.slerp(qt_1, this.node.rotation, qt_1, dt / this.damp); + this.node.setRotation(qt_1); + } - onKeyDown (e) { - const v = this._velocity; - if (e.keyCode === KEYCODE.SHIFT) { this._speedScale = this.moveSpeedShiftScale; } - else if (e.keyCode === KEYCODE.W) { if (v.z === 0) { v.z = -1; } } - else if (e.keyCode === KEYCODE.S) { if (v.z === 0) { v.z = 1; } } - else if (e.keyCode === KEYCODE.A) { if (v.x === 0) { v.x = -1; } } - else if (e.keyCode === KEYCODE.D) { if (v.x === 0) { v.x = 1; } } - else if (e.keyCode === KEYCODE.Q) { if (v.y === 0) { v.y = -1; } } - else if (e.keyCode === KEYCODE.E) { if (v.y === 0) { v.y = 1; } } - }, + onMouseWheel (e) { + const delta = -e.getScrollY() * this.moveSpeed * 0.1; // delta is positive when scroll down + Vec3.transformQuat(v3_1, Vec3.UNIT_Z, this.node.rotation); + Vec3.scaleAndAdd(this._position, this.node.position, v3_1, delta); + } - onKeyUp (e) { - const v = this._velocity; - if (e.keyCode === KEYCODE.SHIFT) { this._speedScale = 1; } - else if (e.keyCode === KEYCODE.W) { if (v.z < 0) { v.z = 0; } } - else if (e.keyCode === KEYCODE.S) { if (v.z > 0) { v.z = 0; } } - else if (e.keyCode === KEYCODE.A) { if (v.x < 0) { v.x = 0; } } - else if (e.keyCode === KEYCODE.D) { if (v.x > 0) { v.x = 0; } } - else if (e.keyCode === KEYCODE.Q) { if (v.y < 0) { v.y = 0; } } - else if (e.keyCode === KEYCODE.E) { if (v.y > 0) { v.y = 0; } } - }, + onKeyDown (e) { + const v = this._velocity; + if (e.keyCode === KEYCODE.SHIFT) { + this._speedScale = this.moveSpeedShiftScale; + } else if (e.keyCode === KEYCODE.W) { + if (v.z === 0) { v.z = -1; } + } else if (e.keyCode === KEYCODE.S) { + if (v.z === 0) { v.z = 1; } + } else if (e.keyCode === KEYCODE.A) { + if (v.x === 0) { v.x = -1; } + } else if (e.keyCode === KEYCODE.D) { + if (v.x === 0) { v.x = 1; } + } else if (e.keyCode === KEYCODE.Q) { + if (v.y === 0) { v.y = -1; } + } else if (e.keyCode === KEYCODE.E) { + if (v.y === 0) { v.y = 1; } + } + } - onTouchStart (e) { - if (cc.game.canvas.requestPointerLock) cc.game.canvas.requestPointerLock(); - }, + onKeyUp (e) { + const v = this._velocity; + if (e.keyCode === KEYCODE.SHIFT) { + this._speedScale = 1; + } else if (e.keyCode === KEYCODE.W) { + if (v.z < 0) { v.z = 0; } + } else if (e.keyCode === KEYCODE.S) { + if (v.z > 0) { v.z = 0; } + } else if (e.keyCode === KEYCODE.A) { + if (v.x < 0) { v.x = 0; } + } else if (e.keyCode === KEYCODE.D) { + if (v.x > 0) { v.x = 0; } + } else if (e.keyCode === KEYCODE.Q) { + if (v.y < 0) { v.y = 0; } + } else if (e.keyCode === KEYCODE.E) { + if (v.y > 0) { v.y = 0; } + } + } - onTouchMove (e) { - e.getStartLocation(v2_1); - if (v2_1.x > cc.winSize.width * 0.4) { // rotation - e.getDelta(v2_2); - this._euler.y -= v2_2.x * this.rotateSpeed * 0.1; - this._euler.x += v2_2.y * this.rotateSpeed * 0.1; - } else { // position - e.getLocation(v2_2); - Vec3.subtract(v2_2, v2_2, v2_1); - this._velocity.x = v2_2.x * 0.01; - this._velocity.z = -v2_2.y * 0.01; + onTouchStart () { + if (cc.game.canvas.requestPointerLock) cc.game.canvas.requestPointerLock(); + } + + onTouchMove (e) { + e.getStartLocation(v2_1); + if (v2_1.x > cc.winSize.width * 0.4) { // rotation + e.getDelta(v2_2); + this._euler.y -= v2_2.x * this.rotateSpeed * 0.1; + this._euler.x += v2_2.y * this.rotateSpeed * 0.1; + } else { // position + e.getLocation(v2_2); + Vec3.subtract(v2_2, v2_2, v2_1); + this._velocity.x = v2_2.x * 0.01; + this._velocity.z = -v2_2.y * 0.01; + } + } + + onTouchEnd (e) { + if (document.exitPointerLock) document.exitPointerLock(); + e.getStartLocation(v2_1); + if (v2_1.x < cc.winSize.width * 0.4) { // position + this._velocity.x = 0; + this._velocity.z = 0; + } + } } - }, - onTouchEnd (e) { - if (document.exitPointerLock) document.exitPointerLock(); - e.getStartLocation(v2_1); - if (v2_1.x < cc.winSize.width * 0.4) { // position - this._velocity.x = 0; - this._velocity.z = 0; - } - }, + return cc.Class({ + name: 'FirstPersonCamera', + ctor: FirstPersonCamera, + }); + })(); }); diff --git a/playground/index.html b/playground/index.html index 3467662bae..7913aadbc0 100644 --- a/playground/index.html +++ b/playground/index.html @@ -66,13 +66,17 @@ + + -
+
+ > +
diff --git a/playground/shell.js b/playground/shell.js index d711036890..f4c58c0539 100644 --- a/playground/shell.js +++ b/playground/shell.js @@ -1,21 +1,19 @@ -'use strict'; - (() => { - function loadPromise(url) { + function loadPromise (url) { return new Promise((resolve, reject) => { const xhr = new window.XMLHttpRequest(); - xhr.open('GET', url + '?_=' + new Date().getTime(), true); // force no cache + xhr.open('GET', `${url}?_=${new Date().getTime()}`, true); // force no cache xhr.onreadystatechange = onreadystatechange; xhr.send(null); - function onreadystatechange(e) { + function onreadystatechange (e) { if (xhr.readyState !== 4) { return; } // Testing harness file:/// results in 0. if ([0, 200, 304].indexOf(xhr.status) === -1) { - reject(`While loading from url ${url} server responded with a status of ${xhr.status}`); + reject(new Error(`While loading from url ${url} server responded with a status of ${xhr.status}`)); } else { resolve(e.target.response); } @@ -23,16 +21,15 @@ }); } - function _load(url) { - loadPromise(url).then(result => { - + function _load (url) { + loadPromise(url).then((result) => { if (window.dgui) { window.dgui.destroy(); window.dgui = null; } cc.director.off(cc.Director.EVENT_BEFORE_UPDATE); - // cc.director.off(cc.Director.EVENT_AFTER_UPDATE); // should uncomment these after UI manager move to global + // cc.director.off(cc.Director.EVENT_AFTER_UPDATE); // cc.director.off(cc.Director.EVENT_BEFORE_DRAW); // cc.director.off(cc.Director.EVENT_AFTER_DRAW); cc.systemEvent.off(cc.SystemEvent.EventType.MOUSE_WHEEL); @@ -44,28 +41,28 @@ // init dgui if (window.dat) { - const dgui = new dat.GUI({ width: 270 }); + const dgui = new window.dat.GUI({ width: 270 }); dgui.domElement.classList.add('dgui'); window.dgui = dgui; } - const getCurAbsPath = () => { + const curAbsPath = (() => { const scripts = document.getElementsByTagName('script'); - const lastScriptPath = scripts[scripts.length -1].src; + const lastScriptPath = scripts[scripts.length - 1].src; const segs = lastScriptPath.split('/'); if (segs.length >= 1) { segs.pop(); } - const path = segs.join('/') + '/'; + const path = `${segs.join('/')}/`; return path; - }; + })(); - eval(`(() => {\n${result}\n})();\n\n//# sourceURL=${getCurAbsPath() + url}`); + // eslint-disable-next-line no-eval + eval(`(() => {\n${result}\n})();\n\n//# sourceURL=${curAbsPath + url}`); window.cc.director.on(cc.Director.EVENT_BEFORE_UPDATE, () => { window.stats.update(); }); - - }).catch(err => { + }).catch((err) => { console.error(err); }); } @@ -84,7 +81,7 @@ enableSpector.checked = localStorage.getItem('engine.enableSpector') === 'true'; enableVConsole.checked = localStorage.getItem('engine.enableVConsole') === 'true'; let exampleIndex = parseInt(localStorage.getItem('engine.exampleIndex')); - if (isNaN(exampleIndex) || exampleIndex >= exampleList.childElementCount) exampleIndex = 0; + if (Number.isNaN(exampleIndex) || exampleIndex >= exampleList.childElementCount) exampleIndex = 0; exampleList.selectedIndex = exampleIndex; // init stats @@ -94,7 +91,7 @@ stats.dom.style.display = showFPS.checked ? 'block' : 'none'; document.body.appendChild(stats.dom); window.stats = stats; - showFPS.addEventListener('click', event => { + showFPS.addEventListener('click', (event) => { localStorage.setItem('engine.showFPS', event.target.checked); stats.dom.style.display = event.target.checked ? 'block' : 'none'; }); @@ -102,13 +99,14 @@ // init spector const url = '../node_modules/spectorjs/dist/spector.bundle.js'; - loadPromise(url).then(result => { + loadPromise(url).then((result) => { + // eslint-disable-next-line no-eval eval(`${result}\n//# sourceURL=${url}`); if (enableSpector.checked) { window.spector = new window.SPECTOR.Spector(); window.spector.displayUI(); } - enableSpector.addEventListener('click', event => { + enableSpector.addEventListener('click', () => { // localStorage.setItem('engine.enableSpector', event.target.checked); if (enableSpector.checked) { window.spector = new window.SPECTOR.Spector(); @@ -120,7 +118,7 @@ // init vconsole if (window.VConsole) { if (enableVConsole.checked) window.vconsole = new window.VConsole(); - enableVConsole.addEventListener('click', event => { + enableVConsole.addEventListener('click', () => { // localStorage.setItem('engine.enableVConsole', event.target.checked); if (enableVConsole.checked) window.vconsole = new window.VConsole(); }); @@ -128,23 +126,26 @@ // create canvas const bcr = view.getBoundingClientRect(); - const canvas = document.createElement('canvas'); + const canvas = document.getElementById('GameCanvas'); canvas.classList.add('fit'); canvas.tabIndex = -1; - canvas.id = 'canvas'; canvas.width = bcr.width; canvas.height = bcr.height; - view.appendChild(canvas); // init engine - window.cc.game.init({ id: canvas.id }); + window.cc.game.init({ + adapter: { canvas, container: canvas.parentNode, frame: canvas.parentNode.parentNode }, + customJointTextureLayouts: [], + }); window.cc.game.run(() => { _load(exampleList.value); window.addEventListener('resize', () => { const bcr = view.getBoundingClientRect(); cc.director.root.resize(bcr.width, bcr.height); }); - exampleList.addEventListener('change', event => { + const bcr = view.getBoundingClientRect(); + cc.director.root.resize(bcr.width, bcr.height); + exampleList.addEventListener('change', (event) => { localStorage.setItem('engine.exampleIndex', event.target.selectedIndex); _load(exampleList.value); }); diff --git a/playground/src/collision-detection.js b/playground/src/collision-detection.js index 302e19224c..d637b12d91 100644 --- a/playground/src/collision-detection.js +++ b/playground/src/collision-detection.js @@ -1,9 +1,7 @@ - const { cc, dgui } = window; -const { Camera, Component, DirectionalLight, Scene, - SphereCollider, Material, MeshRenderer, Node } = cc; +const { Camera, Scene, Material, Node } = cc; const { BlendFactor } = cc.gfx; -const { Color, randomRange, toRadian, Vec3, Vec4 } = cc.math; +const { Color, randomRange, toRadian, Vec3 } = cc.math; const { sphere, capsule } = cc.primitives; const { createMesh } = cc.utils; @@ -17,17 +15,17 @@ const dobj = { }, stop: () => { dobj.playing = false; - emitters.forEach(e => { + emitters.forEach((e) => { e.reapAll(); }); }, step: () => { dobj.playing = true; - emitters.forEach(e => { + emitters.forEach((e) => { e.update(); }); dobj.playing = false; - } + }, }; const scene = new Scene(); @@ -54,7 +52,7 @@ class Element { // annihilate after collision, if satisfying filter condition class Emitter { constructor (group, mask, pos, minAngle, maxAngle, color) { - this.node = new Node('emitter_' + group); + this.node = new Node(`emitter_${group}`); this.node.parent = scene; this.node.setPosition(pos); this.group = group; @@ -67,9 +65,9 @@ class Emitter { this._elements = []; // emitter hint const hint = new Node('hint'); - const hintModel = hint.addComponent(MeshRenderer); + const hintModel = hint.addComponent('cc.MeshRenderer'); const hintMat = new Material(); - hintMat.initialize({ effectName: 'builtin-standard' }); + hintMat.initialize({ effectName: 'standard' }); hintMat.setProperty('albedo', this.color); hintMat.setProperty('metallic', 0.1); hintModel.material = hintMat; @@ -84,19 +82,21 @@ class Emitter { ele.node = node; ele.color.set(this.color); // model - const model = node.addComponent(MeshRenderer); + const model = node.addComponent('cc.MeshRenderer'); const mat = new Material(); mat.initialize({ - effectName: 'builtin-standard', - states: { - blendState: { targets: [{ + effectName: 'standard', + states: { + blendState: { + targets: [{ blend: true, blendSrc: BlendFactor.SRC_ALPHA, blendDst: BlendFactor.ONE_MINUS_SRC_ALPHA, blendDstAlpha: BlendFactor.ONE_MINUS_SRC_ALPHA, - }] }, - depthStencilState: { depthTest: false }, - } + }], + }, + depthStencilState: { depthTest: false }, + }, }); mat.setProperty('metallic', 0.1); ele.pass = mat.passes[0]; @@ -105,7 +105,7 @@ class Emitter { model.material = mat; model.mesh = sphereMesh; // collider - const col = node.addComponent(SphereCollider); + const col = node.addComponent('cc.SphereCollider'); col.radius = 1; col.isTrigger = true; col.setGroup(this.group); col.setMask(this.mask); @@ -167,7 +167,7 @@ class Emitter { Math.cos(phi) * speed, Math.sin(theta) * Math.sin(phi) * speed); ele.color.a = this.color.a; ele.collided = false; ele.pass.setUniform(ele.hColor, ele.color); - const col = ele.node.getComponent(SphereCollider); + const col = ele.node.getComponent('cc.SphereCollider'); col.setGroup(this.group); col.setMask(this.mask); ele.node.setPosition(0, 0, 0); this._livepool.push(ele); @@ -181,13 +181,13 @@ cameraNode.parent = scene; cameraNode.setPosition(-20, 50, 12); cameraNode.lookAt(Vec3.ZERO); cameraNode.addComponent(Camera); -cameraNode.addComponent(FirstPersonCamera); +cameraNode.addComponent(window.FirstPersonCamera); // light const light = new Node('light'); light.parent = scene; light.setRotationFromEuler(-80, 20, -40); -light.addComponent(DirectionalLight); +light.addComponent('cc.DirectionalLight'); cc.director.on(cc.Director.EVENT_BEFORE_UPDATE, () => { for (let i = 0; i < emitters.length; i++) { @@ -204,7 +204,7 @@ cc.director.runSceneImmediate(scene); // have to run the scene before set collid // set the stage const emitters = []; // a particle does not collide with those come from the same group -emitters.push(new Emitter(1, ~1, new Vec3(-10, 0, 10), 0, -90, new Color(204, 178, 128, 51))); -emitters.push(new Emitter(2, ~2, new Vec3( 10, 0, -10), 90, 180, new Color( 51, 76, 128, 51))); -emitters.push(new Emitter(4, ~4, new Vec3(-10, 0, -10), 0, 90, new Color(204, 76, 128, 51))); -emitters.push(new Emitter(8, ~8, new Vec3( 10, 0, 10), -90, -180, new Color( 51, 178, 128, 51))); +emitters.push(new Emitter(1, ~1, new Vec3(-10, 0, 10), 0, -90, new Color(204, 178, 128, 51))); +emitters.push(new Emitter(2, ~2, new Vec3(10, 0, -10), 90, 180, new Color(51, 76, 128, 51))); +emitters.push(new Emitter(4, ~4, new Vec3(-10, 0, -10), 0, 90, new Color(204, 76, 128, 51))); +emitters.push(new Emitter(8, ~8, new Vec3(10, 0, 10), -90, -180, new Color(51, 178, 128, 51))); diff --git a/playground/src/custom-effect.js b/playground/src/custom-effect.js index 15193c024c..7bdad453f1 100644 --- a/playground/src/custom-effect.js +++ b/playground/src/custom-effect.js @@ -1,13 +1,12 @@ - cc.AssetLibrary.init({ libraryPath: 'library', rawAssetsBase: 'library', rawAssets: { assets: { - // https://github.com/cocos-creator/example-3d/blob/master/demo02/assets/effects/test.effect - "97051ce4-0cc9-4ae0-a584-d73943d7c11a": ["test", "cc.EffectAsset"] - } - } + // https://github.com/cocos-creator/example-3d/blob/master/show-cases/assets/effects/test.effect + '97051ce4-0cc9-4ae0-a584-d73943d7c11a': ['test', 'cc.EffectAsset'], + }, + }, }); const scene = new cc.Scene(); @@ -17,7 +16,7 @@ cameraNode.parent = scene; cameraNode.setPosition(6, 0, 2); cameraNode.setRotationFromEuler(0, 70, 0); cameraNode.addComponent(cc.Camera); -cameraNode.addComponent(FirstPersonCamera); +cameraNode.addComponent(window.FirstPersonCamera); const modelNode = new cc.Node('test'); modelNode.parent = scene; diff --git a/playground/src/gizmo.js b/playground/src/gizmo.js index a0626bc3ee..e48c0bedc9 100644 --- a/playground/src/gizmo.js +++ b/playground/src/gizmo.js @@ -1,29 +1,28 @@ - const scene = new cc.Scene('scene'); const cameraNode = new cc.Node('camera'); cameraNode.parent = scene; cameraNode.setPosition(20, 20, 20); cameraNode.lookAt(cc.v3()); -cameraNode.addComponent(FirstPersonCamera); +cameraNode.addComponent(window.FirstPersonCamera); cameraNode.addComponent(cc.Camera); const material = new cc.Material(); material.initialize({ - effectName: 'builtin-unlit', + effectName: 'unlit', defines: { USE_COLOR: true }, }); const material2 = new cc.Material(); material2.initialize({ - effectName: 'builtin-unlit', + effectName: 'unlit', defines: { USE_COLOR: true }, states: { depthStencilState: { depthTest: false, depthWrite: false }, rasterizerState: { cullMode: cc.gfx.CullMode.NONE }, blendState: { targets: [ - { blend: true, blendDst: cc.gfx.BlendFactor.ONE_MINUS_SRC_ALPHA, blendDstAlpha: cc.gfx.BlendFactor.ONE_MINUS_SRC_ALPHA } - ] } - } + { blend: true, blendDst: cc.gfx.BlendFactor.ONE_MINUS_SRC_ALPHA, blendDstAlpha: cc.gfx.BlendFactor.ONE_MINUS_SRC_ALPHA }, + ] }, + }, }); const createArrow = (color, rotation) => { @@ -32,13 +31,13 @@ const createArrow = (color, rotation) => { const arrowHead = new cc.Node('arrowHead'); arrowHead.parent = arrow; arrowHead.setPosition(0, 10, 0); - const headModel = arrowHead.addComponent(cc.MeshRenderer); + const headModel = arrowHead.addComponent('cc.MeshRenderer'); headModel.mesh = cc.utils.createMesh(cc.primitives.cone()); headModel.material = material; headModel.material.setProperty('color', color); const arrowBody = new cc.Node('arrowBody'); arrowBody.parent = arrow; - const bodyModel = arrowBody.addComponent(cc.MeshRenderer); + const bodyModel = arrowBody.addComponent('cc.MeshRenderer'); bodyModel.mesh = cc.utils.createMesh({ positions: [0, 0, 0, 0, 10, 0], indices: [0, 1], @@ -56,9 +55,9 @@ const createBorderPlane = (color, position, rotation) => { borderPlane.setRotation(rotation); const plane = new cc.Node('plane'); plane.parent = borderPlane; - const planeModel = plane.addComponent(cc.MeshRenderer); + const planeModel = plane.addComponent('cc.MeshRenderer'); const mesh = planeModel.mesh = cc.utils.createMesh(cc.primitives.quad()); - const submesh = mesh.renderingMesh.getSubmesh(0); + const submesh = mesh.renderingSubMeshes[0]; const vbInfo = mesh.struct.vertexBundles[0].view; submesh.vbuffer = mesh.data.buffer.slice(vbInfo.offset, vbInfo.offset + vbInfo.length); @@ -69,7 +68,7 @@ const createBorderPlane = (color, position, rotation) => { planeModel.material.setProperty('color', cc.color(0, 0, 0, 0).lerp(color, 0.5)); const border = new cc.Node('border'); border.parent = borderPlane; - const borderModel = border.addComponent(cc.MeshRenderer); + const borderModel = border.addComponent('cc.MeshRenderer'); borderModel.mesh = cc.utils.createMesh({ positions: [0.5, 0.5, 0, 0, 0.5, 0, 0.5, 0, 0], indices: [0, 1, 0, 2], @@ -90,7 +89,7 @@ createBorderPlane(cc.Color.RED, cc.v3(0.5, 0.5, 0), cc.Quat.fromEuler(new cc.Qua createBorderPlane(cc.Color.GREEN, cc.v3(0.5, 0, 0.5), cc.Quat.fromEuler(new cc.Quat(), -90, -90, 0)).parent = moveTool; createBorderPlane(cc.Color.BLUE, cc.v3(0, 0.5, 0.5), cc.Quat.fromEuler(new cc.Quat(), 90, 0, 90)).parent = moveTool; -const vel = cc.v3(), speed = 0.1, keys = 'IKJLOUR'; +const vel = cc.v3(); const speed = 0.1; const keys = 'IKJLOUR'; const KEYCODE = new Array(keys.length).fill(0).reduce((acc, _, i) => (acc[keys[i]] = keys.charCodeAt(i), acc), {}); cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, (e) => { if (e.keyCode === KEYCODE.I) vel.z = speed; diff --git a/playground/src/planar-shadow.js b/playground/src/planar-shadow.js index ffaee72edf..7cdfd67e71 100644 --- a/playground/src/planar-shadow.js +++ b/playground/src/planar-shadow.js @@ -1,4 +1,3 @@ - const scene = new cc.Scene(); const root = new cc.Node(); root.parent = scene; @@ -10,16 +9,16 @@ cameraNode.parent = root; cameraNode.setPosition(-16, 2, 16); cameraNode.setRotationFromEuler(-12, -63, 0); cameraNode.addComponent(cc.Camera); -cameraNode.addComponent(FirstPersonCamera); +cameraNode.addComponent(window.FirstPersonCamera); const lightNode = new cc.Node('Light'); lightNode.parent = root; lightNode.setPosition(-10, 10, -10); lightNode.setRotationFromEuler(-50, 0, 0); -const lightComp = lightNode.addComponent(cc.DirectionalLight); +lightNode.addComponent('cc.DirectionalLight'); const material = new cc.Material(); -material.initialize({ effectName: 'builtin-standard' }); +material.initialize({ effectName: 'standard' }); const manifest = [ { name: 'box', pos: cc.v3(0, 1, 10) }, @@ -36,7 +35,7 @@ for (const info of manifest) { const modelComp = modelNode.addComponent('cc.MeshRenderer'); modelComp.material = info.mat || material; modelComp.mesh = cc.utils.createMesh(cc.primitives[info.name](info.param)); - if (info.name !== 'plane') modelComp.shadowCastingMode = cc.MeshRenderer.ShadowCastingMode.ON; + if (info.name !== 'plane') modelComp.shadowCastingMode = cc.ModelComponent.ShadowCastingMode.ON; modelNode.setPosition(info.pos); models[info.name] = modelComp; } diff --git a/playground/src/save-primitive-objs.js b/playground/src/save-primitive-objs.js index 49b0a45501..05c018ab7f 100644 --- a/playground/src/save-primitive-objs.js +++ b/playground/src/save-primitive-objs.js @@ -1,4 +1,3 @@ - function write (name) { const text = cc.primitives.toWavefrontOBJ(cc.primitives[name](), 100); const blob = new Blob([text], { type: 'text/plain' }); diff --git a/playground/src/simple.js b/playground/src/simple.js index 65a89480d4..c3ceb77099 100644 --- a/playground/src/simple.js +++ b/playground/src/simple.js @@ -1,4 +1,3 @@ - const geomList = ['box', 'sphere', 'cylinder', 'cone', 'torus', 'capsule']; const scene = new cc.Scene(); @@ -6,7 +5,7 @@ const cameraNode = new cc.Node('Camera'); cameraNode.parent = scene; cameraNode.setPosition(-2.2, 3.6, -5.3); cameraNode.setRotationFromEuler(-13.6, -165.5, 0); -cameraNode.addComponent(FirstPersonCamera); +cameraNode.addComponent(window.FirstPersonCamera); const camComp = cameraNode.addComponent(cc.Camera); const skybox = scene.globals.skybox; @@ -16,21 +15,21 @@ camComp.clearFlags = cc.Camera.CameraClearFlag.SKYBOX; const lightNode = new cc.Node('Light'); lightNode.parent = scene; lightNode.setRotationFromEuler(-40, 0, 0); -lightNode.addComponent(cc.DirectionalLight); +lightNode.addComponent(cc.DirectionalLightComponent); // parsed effect file is embedded in cocos/3d/builtin/effects.js const material = new cc.Material(); material.initialize({ /* * - effectName: 'builtin-standard', + effectName: 'standard', /* */ - effectName: 'builtin-unlit', + effectName: 'unlit', defines: { USE_COLOR: true }, /* */ }); const len = 50; -const models = [], passes = []; +const models = []; const passes = []; const color = cc.color(); for (let i = 0; i < len; i++) { const modelNode = new cc.Node(`${i}`); @@ -49,26 +48,26 @@ const canvasNode = new cc.Node('Canvas'); canvasNode.parent = scene; canvasNode.addComponent(cc.Canvas); -const spriteNode = new cc.Node('test-sprite'); -spriteNode.parent = canvasNode; -const spriteComp = spriteNode.addComponent('cc.Sprite'); -spriteComp.sizeMode = cc.Sprite.SizeMode.CUSTOM; -spriteNode.getComponent('cc.UITransform').contentSize = cc.size(64, 64); -const widgetComp = spriteNode.addComponent(cc.Widget); -widgetComp.isAlignBottom = widgetComp.isAlignLeft = true; -widgetComp.bottom = widgetComp.left = 10; +// const spriteNode = new cc.Node('test-sprite'); +// spriteNode.parent = canvasNode; +// const spriteComp = spriteNode.addComponent('cc.Sprite'); +// spriteComp.sizeMode = cc.SpriteComponent.SizeMode.CUSTOM; +// spriteNode.getComponent('cc.UITransform').contentSize = cc.size(64, 64); +// const widgetComp = spriteNode.addComponent(cc.WidgetComponent); +// widgetComp.isAlignBottom = widgetComp.isAlignLeft = true; +// widgetComp.bottom = widgetComp.left = 10; const img = document.createElement('img'); img.src = './common/texture.png'; img.onload = () => { const textureCube = new cc.TextureCube(); textureCube.image = { - right: new cc.ImageAsset(img), - left: new cc.ImageAsset(img), - top: new cc.ImageAsset(img), + right: new cc.ImageAsset(img), + left: new cc.ImageAsset(img), + top: new cc.ImageAsset(img), bottom: new cc.ImageAsset(img), - front: new cc.ImageAsset(img), - back: new cc.ImageAsset(img), + front: new cc.ImageAsset(img), + back: new cc.ImageAsset(img), }; skybox.envmap = textureCube; const texture = new cc.Texture2D(); @@ -77,11 +76,11 @@ img.onload = () => { const rect = cc.rect(0, 0, img.width, img.height); const spriteFrame = new cc.SpriteFrame(); spriteFrame.reset({ texture, originalSize, rect }); - spriteComp.spriteFrame = spriteFrame; + // spriteComp.spriteFrame = spriteFrame; }; const material2 = new cc.Material(); -material2.initialize({ effectName: 'builtin-standard' }); +material2.initialize({ effectName: 'standard' }); const modelNode2 = new cc.Node('test2'); modelNode2.parent = scene; const modelCom2 = modelNode2.addComponent('cc.MeshRenderer'); @@ -89,23 +88,15 @@ modelCom2.material = material2; const shape2 = cc.primitives.sphere(); modelCom2.mesh = cc.utils.createMesh(shape2); -let buttonDown = false, pos = cc.v2(); -cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_START, (e) => buttonDown = true); -cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_END, (e) => buttonDown = false); +const pos = cc.v2(); cc.systemEvent.on(cc.SystemEvent.EventType.TOUCH_MOVE, (e) => e.getLocation(pos)); cc.director.on(cc.Director.EVENT_BEFORE_UPDATE, () => { - if (buttonDown) { - const ray = camComp.screenPointToRay(pos.x, pos.y); - const scene = cc.director.getScene().renderScene; - const res = scene.raycastAllModels(ray); - if (res) scene.rayResultModels.forEach((r) => console.log(r.node.name, r.distance)); - } models.forEach((m, i) => { - const dt = cc.director._deltaTime; - const t = cc.director._totalFrames / (60); + const dt = cc.director.getDeltaTime(); + const t = cc.director.getTotalFrames() / 60; const rad = i * Math.PI * 8 / len; - const x = Math.cos(rad + t), y = Math.sin(rad + t); + const x = Math.cos(rad + t); const y = Math.sin(rad + t); let z = m.position.z + dt; if (z > len * 2) z = 0; m.setPosition(x * 2, y * 2, z); color.fromHSV((x + 1) * 0.5, 0.5, 1); diff --git a/tests/general/sealed-global-variables.json b/tests/general/sealed-global-variables.json index b2888b0e08..3e64dd4162 100644 --- a/tests/general/sealed-global-variables.json +++ b/tests/general/sealed-global-variables.json @@ -1,6 +1,6 @@ { "thisFile": { - "stamp": "2021-07-05T09:43:28.305Z" + "stamp": "2021-08-24T10:14:20.085Z" }, "variables": [ "cc.AffineTransform", @@ -54,6 +54,7 @@ "cc.ENGINE_VERSION", "cc.EditBoxComponent", "cc.EffectAsset", + "cc.EmptyDevice", "cc.Enum", "cc.Event", "cc.EventListener", @@ -113,6 +114,7 @@ "cc.GFXFormatType", "cc.GFXFramebuffer", "cc.GFXFramebufferInfo", + "cc.GFXGFXObject", "cc.GFXGetTypeSize", "cc.GFXGlobalBarrier", "cc.GFXGlobalBarrierInfo", @@ -125,7 +127,6 @@ "cc.GFXMemoryAccessBit", "cc.GFXMemoryStatus", "cc.GFXMemoryUsageBit", - "cc.GFXObject", "cc.GFXObjectType", "cc.GFXOffset", "cc.GFXPipelineBindPoint", @@ -159,6 +160,8 @@ "cc.GFXSubpassDependency", "cc.GFXSubpassInfo", "cc.GFXSurfaceTransform", + "cc.GFXSwapchain", + "cc.GFXSwapchainInfo", "cc.GFXTexture", "cc.GFXTextureBarrier", "cc.GFXTextureBarrierInfo", @@ -181,6 +184,7 @@ "cc.GFXUniformStorageImage", "cc.GFXUniformTexture", "cc.GFXViewport", + "cc.GFXVsyncMode", "cc.GFX_DRAW_INFO_SIZE", "cc.Game", "cc.GraphicsComponent", @@ -342,7 +346,6 @@ "cc.renderer", "cc.resources", "cc.sampleAnimationCurve", - "cc.samplerLib", "cc.screen", "cc.size", "cc.sys", diff --git a/tsconfig.json b/tsconfig.json index 66f11ed1fd..4691129744 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,47 +1,47 @@ { - "compilerOptions": { - "target": "es6", - "lib": ["es2015", "es2017", "dom"], - "module": "commonjs", - "sourceMap": true, - "outDir": "./bin/.ts", - "rootDir": "./", - "noEmit": true, - "strict": true, - "noImplicitAny": false, - "downlevelIteration": true, - "esModuleInterop": true, - "experimentalDecorators": true, - "isolatedModules": true, - "baseUrl": "./", - "paths": { - "cc.decorator": [ - "cocos/core/data/decorators/index.ts" - ] - }, - "types": [ - "./@types/globals", - "./@types/consts", - "./@types/jsb", - "./@types/editor-extends", - "./@types/webGL.extras", - "./@types/webGL2.extras", - "./node_modules/@cocos/cannon/CANNON", - "./node_modules/@cocos/ammo/Ammo", - "./node_modules/@cocos/physx/PhysX", - "./node_modules/@types/jest/index", - - // pal - "./@types/pal/system-info", - "./@types/pal/screen-adapter", - "./@types/pal/minigame", - "./@types/pal/audio", - "./@types/pal/input" - ] + "compilerOptions": { + "target": "es6", + "lib": ["es2015", "es2017", "dom"], + "module": "commonjs", + "sourceMap": true, + "outDir": "./bin/.ts", + "rootDir": "./", + "noEmit": true, + "strict": true, + "noImplicitAny": false, + "downlevelIteration": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "isolatedModules": true, + "baseUrl": "./", + "paths": { + "cc.decorator": [ + "cocos/core/data/decorators/index.ts" + ] }, - "include": [ - "exports/**/*.ts", - "index.ts", - "pal/**/*.ts" + "types": [ + "./@types/globals", + "./@types/consts", + "./@types/jsb", + "./@types/editor-extends", + "./@types/webGL.extras", + "./@types/webGL2.extras", + "./node_modules/@cocos/cannon/CANNON", + "./node_modules/@cocos/ammo/Ammo", + "./node_modules/@cocos/physx/PhysX", + "./node_modules/@types/jest/index", + + // pal + "./@types/pal/system-info", + "./@types/pal/screen-adapter", + "./@types/pal/minigame", + "./@types/pal/audio", + "./@types/pal/input" ] - } + }, + "include": [ + "exports/**/*.ts", + "index.ts", + "pal/**/*.ts" + ] +}