diff --git a/cocos/3d/assets/material.ts b/cocos/3d/assets/material.ts index 2e7aca848c..949c037baa 100644 --- a/cocos/3d/assets/material.ts +++ b/cocos/3d/assets/material.ts @@ -95,15 +95,15 @@ export class Material extends Asset { this._props[passIdx][name] = val; const pass = this._passes[passIdx]; const handle = pass.getHandleFromName(name); - pass.setUniformMember(handle, val); + pass.setUniform(handle, val); } public setTexture(name: string, val: TextureBase, passIdx = 0) { console.assert(passIdx < this._passes.length, 'illegal pass index.'); this._textures[passIdx][name] = val; const pass = this._passes[passIdx]; - const handle = pass.getHandleFromName(name); - pass.setTextureView(handle, val._texView); + const binding = pass.getBindingFromName(name); + pass.bindTextureView(binding, val._texView); } public copy(mat: Material) { @@ -146,13 +146,13 @@ export class Material extends Asset { if (!props) { props = this._props[i] = {}; } for (const p of Object.keys(props)) { const handle = pass.getHandleFromName(p); - pass.setUniformMember(handle, props[p]); + pass.setUniform(handle, props[p]); } let textures = this._textures[i]; if (!textures) { textures = this._textures[i] = {}; } for (const t of Object.keys(textures)) { - const handle = pass.getHandleFromName(t); - pass.setTextureView(handle, textures[t]._texView); + const binding = pass.getBindingFromName(t); + pass.bindTextureView(binding, textures[t]._texView); } }); } else { diff --git a/cocos/assets/asset.d.ts b/cocos/assets/asset.d.ts index 07c9afee5c..9055813b31 100644 --- a/cocos/assets/asset.d.ts +++ b/cocos/assets/asset.d.ts @@ -26,5 +26,18 @@ import { RawAsset } from "./raw-asset"; export class Asset extends RawAsset { + protected _native: string; + protected loaded: boolean; + public _nativeAsset: any; + public nativeUrl: string; + + static preventDeferredLoadDependents: boolean; + static preventPreloadNativeObject: boolean; + static deserialize(data: string): object; + + public createNode: (err: string, node: object) => void | null; + public toString(): string; + public serialize(): string; + protected _setRawAsset(filename: string, inLibrary: boolean): void; } diff --git a/cocos/assets/raw-asset.d.ts b/cocos/assets/raw-asset.d.ts index 186076cde8..4c5fcf5fb0 100644 --- a/cocos/assets/raw-asset.d.ts +++ b/cocos/assets/raw-asset.d.ts @@ -28,4 +28,5 @@ import { CCObject } from '../core/data/object'; export class RawAsset extends CCObject { _uuid: string; + static isRawAssetType(ctor: Function): boolean; } diff --git a/cocos/core/data/object.d.ts b/cocos/core/data/object.d.ts index e24850f93b..a14ac9e6f0 100644 --- a/cocos/core/data/object.d.ts +++ b/cocos/core/data/object.d.ts @@ -24,6 +24,24 @@ ****************************************************************************/ export class CCObject { - _name: string; - name: string; + protected _name: string; + protected _objFlags: number; + + static _deferredDestroy(): void; + + public name: string; + public isValid: boolean; + public isRealValid: boolean; + + public destroy(): boolean; + public realDestroyInEditor(): void; + public _clearDeferredDestroyTimer(): void; + + protected _destruct(): void; + protected _destroyImmediate(): void; + + protected _serialize: (exporting: boolean) => object | null; + protected _deserialize: (data: object, ctx: object) => object | null; + protected _onPreDestroy: () => void | null; + protected Flags: object; } diff --git a/cocos/pipeline/forward/test-material-stage.ts b/cocos/pipeline/forward/test-material-stage.ts index 28c8bb5975..4b3b0a75c8 100644 --- a/cocos/pipeline/forward/test-material-stage.ts +++ b/cocos/pipeline/forward/test-material-stage.ts @@ -74,10 +74,10 @@ export class TestMaterialStage extends RenderStage { // material this._material.effectName = 'test'; // parsed-effect file is embedded in cocos/3d/builtin/effects.js const pass = this._material.passes[0]; - const handle1 = pass.getHandleFromName('u_sampler'); - pass.setTextureView(handle1, this._texView); - const handle2 = pass.getHandleFromName('u_color'); - pass.setUniformMember(handle2, cc.color('#ffffff')); + const texBinding = pass.getBindingFromName('u_sampler'); + pass.bindTextureView(texBinding, this._texView); + const colorHandle = pass.getHandleFromName('u_color'); + pass.setUniform(colorHandle, cc.color('#ffffff')); pass.update(); this._material.inited = true; } diff --git a/cocos/renderer/core/pass.ts b/cocos/renderer/core/pass.ts index 9b4c797e05..98f35c97e7 100644 --- a/cocos/renderer/core/pass.ts +++ b/cocos/renderer/core/pass.ts @@ -156,7 +156,11 @@ export class Pass { return this._handleMap[name]; } - public setUniformMember(handle: number, value: any) { + public getBindingFromName(name: string) { + return parseHandle(this.getHandleFromName(name))[0]; + } + + public setUniform(handle: number, value: any) { const [ binding, idx ] = parseHandle(handle); const block = this._blocks[binding]; const type = this._typeMap[handle]; @@ -164,8 +168,7 @@ export class Pass { block.dirty = true; } - public setTextureView(handle: number, value: GFXTextureView) { - const [ binding ] = parseHandle(handle); + public bindTextureView(binding: number, value: GFXTextureView) { const bl = this._bindingLayout; if (bl && bl.getBindingUnit(binding).texView !== value) { bl.bindTextureView(binding, value); @@ -173,6 +176,14 @@ export class Pass { } } + public bindSampler(binding: number, value: GFXSampler) { + const bl = this._bindingLayout; + if (bl && bl.getBindingUnit(binding).sampler !== value) { + bl.bindSampler(binding, value); + this._layoutDirty = true; + } + } + public setStates(info: PassInfoBase) { if (this._pipelineState) { this._pipelineState.destroy(); } this.createPipelineState(info); @@ -192,10 +203,12 @@ export class Pass { const block = this._blocks[i]; if (block.dirty) { this._buffers[i].update(block.buffer); + block.dirty = false; } } if (this._bindingLayout && this._layoutDirty) { this._bindingLayout.update(); + this._layoutDirty = false; } }