From 36f1d38e9d1d0b145e8c2b17f299b59dfec274b8 Mon Sep 17 00:00:00 2001 From: jerrywwl Date: Mon, 14 Jan 2019 15:51:12 +0800 Subject: [PATCH] add pass.update() to render pipeline --- cocos/gfx/webgl/webgl-buffer.ts | 4 +- cocos/gfx/webgl/webgl-command-buffer.ts | 108 ++++++++++++++---------- cocos/gfx/webgl/webgl-device.ts | 96 +++++++++++++++------ cocos/gfx/webgl/webgl-gpu-objects.ts | 19 ++++- cocos/pipeline/forward/forward-stage.ts | 2 - cocos/pipeline/render-pipeline.ts | 2 +- cocos/pipeline/render-queue.ts | 4 + cocos/renderer/scene/model.ts | 55 ++++++------ 8 files changed, 186 insertions(+), 104 deletions(-) diff --git a/cocos/gfx/webgl/webgl-buffer.ts b/cocos/gfx/webgl/webgl-buffer.ts index 04fe330f9a..b23c3a6663 100644 --- a/cocos/gfx/webgl/webgl-buffer.ts +++ b/cocos/gfx/webgl/webgl-buffer.ts @@ -1,5 +1,5 @@ -import { GFXBuffer, IGFXBufferInfo, GFXBufferSource } from '../buffer'; -import { GFXMemoryUsageBit, GFXStatus, GFXBufferUsageBit } from '../define'; +import { GFXBuffer, GFXBufferSource, IGFXBufferInfo } from '../buffer'; +import { GFXBufferUsageBit, GFXMemoryUsageBit, GFXStatus } from '../define'; import { GFXDevice } from '../device'; import { WebGLGFXDevice } from './webgl-device'; import { WebGLGPUBuffer } from './webgl-gpu-objects'; diff --git a/cocos/gfx/webgl/webgl-command-buffer.ts b/cocos/gfx/webgl/webgl-command-buffer.ts index 74486d1f12..1f64f68349 100644 --- a/cocos/gfx/webgl/webgl-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-command-buffer.ts @@ -1,7 +1,7 @@ import { GFXBindingLayout } from '../binding-layout'; import { GFXBuffer, GFXBufferSource } from '../buffer'; import { GFXCommandBuffer, IGFXCommandBufferInfo } from '../command-buffer'; -import { GFXBufferTextureCopy, GFXStatus, GFXTextureLayout, IGFXColor, IGFXRect, GFXBufferUsageBit } from '../define'; +import { GFXBufferTextureCopy, GFXBufferUsageBit, GFXStatus, GFXTextureLayout, IGFXColor, IGFXRect, GFXCommandBufferType } from '../define'; import { GFXDevice } from '../device'; import { GFXFramebuffer } from '../framebuffer'; import { GFXInputAssembler } from '../input-assembler'; @@ -29,6 +29,7 @@ import { WebGLGFXTexture } from './webgl-texture'; export class WebGLGFXCommandBuffer extends GFXCommandBuffer { public cmdPackage: WebGLCmdPackage = new WebGLCmdPackage(); + private _isInRenderPass: boolean = false; private _curGPUPipelineState: WebGLGPUPipelineState | null = null; private _curGPUBindingLayout: WebGLGPUBindingLayout | null = null; private _curGPUInputAssembler: WebGLGPUInputAssembler | null = null; @@ -68,6 +69,8 @@ export class WebGLGFXCommandBuffer extends GFXCommandBuffer { if (this._isStateInvalied) { this.bindStates(); } + + this._isInRenderPass = false; } public beginRenderPass ( @@ -88,9 +91,12 @@ export class WebGLGFXCommandBuffer extends GFXCommandBuffer { this.cmdPackage.cmds.push(WebGLCmd.BEGIN_RENDER_PASS); } + + this._isInRenderPass = true; } public endRenderPass () { + this._isInRenderPass = false; } public bindPipelineState (pipelineState: GFXPipelineState) { @@ -119,46 +125,55 @@ export class WebGLGFXCommandBuffer extends GFXCommandBuffer { public draw (inputAssembler: GFXInputAssembler) { - if (this._isStateInvalied) { - this.bindStates(); - } + if (this._type === GFXCommandBufferType.PRIMARY && this._isInRenderPass || + this._type === GFXCommandBufferType.SECONDARY) { + if (this._isStateInvalied) { + this.bindStates(); + } - const cmd = ( this._allocator as WebGLGFXCommandAllocator). - drawCmdPool.alloc(WebGLCmdDraw); - if (cmd) { - (inputAssembler as WebGLGFXInputAssembler).extractCmdDraw(cmd); - this.cmdPackage.drawCmds.push(cmd); + const cmd = ( this._allocator as WebGLGFXCommandAllocator). + drawCmdPool.alloc(WebGLCmdDraw); + if (cmd) { + (inputAssembler as WebGLGFXInputAssembler).extractCmdDraw(cmd); + this.cmdPackage.drawCmds.push(cmd); - this.cmdPackage.cmds.push(WebGLCmd.DRAW); + this.cmdPackage.cmds.push(WebGLCmd.DRAW); + } + } else { + console.error('Command \'draw\' must be recorded inside a render pass.'); } } public updateBuffer (buffer: GFXBuffer, data: GFXBufferSource, offset?: number, size?: number) { - const gpuBuffer = (buffer as WebGLGFXBuffer).gpuBuffer; - if (gpuBuffer) { - const cmd = (this._allocator as WebGLGFXCommandAllocator). - updateBufferCmdPool.alloc(WebGLCmdUpdateBuffer); - if (cmd) { + if (!this._isInRenderPass) { + const gpuBuffer = (buffer as WebGLGFXBuffer).gpuBuffer; + if (gpuBuffer) { + const cmd = (this._allocator as WebGLGFXCommandAllocator). + updateBufferCmdPool.alloc(WebGLCmdUpdateBuffer); + if (cmd) { - let buffSize; - if (size !== undefined ) { - buffSize = size; - } else if (buffer.usage & GFXBufferUsageBit.INDIRECT) { - buffSize = 0; - } else { - buffSize = (data as ArrayBuffer).byteLength; + let buffSize; + if (size !== undefined ) { + buffSize = size; + } else if (buffer.usage & GFXBufferUsageBit.INDIRECT) { + buffSize = 0; + } else { + buffSize = (data as ArrayBuffer).byteLength; + } + + const buff = data as ArrayBuffer; + + cmd.gpuBuffer = gpuBuffer; + cmd.buffer = buff.slice(0); + cmd.offset = (offset !== undefined ? offset : 0); + cmd.size = buffSize; + this.cmdPackage.updateBufferCmds.push(cmd); + + this.cmdPackage.cmds.push(WebGLCmd.UPDATE_BUFFER); } - - const buff = data as ArrayBuffer; - - cmd.gpuBuffer = gpuBuffer; - cmd.buffer = buff.slice(0); - cmd.offset = (offset !== undefined ? offset : 0); - cmd.size = buffSize; - this.cmdPackage.updateBufferCmds.push(cmd); - - this.cmdPackage.cmds.push(WebGLCmd.UPDATE_BUFFER); } + } else { + console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); } } @@ -167,20 +182,25 @@ export class WebGLGFXCommandBuffer extends GFXCommandBuffer { dstTex: GFXTexture, dstLayout: GFXTextureLayout, regions: GFXBufferTextureCopy[]) { - const gpuBuffer = ( srcBuff as WebGLGFXBuffer).gpuBuffer; - const gpuTexture = ( dstTex as WebGLGFXTexture).gpuTexture; - if (gpuBuffer && gpuTexture) { - const cmd = (this._allocator as WebGLGFXCommandAllocator). - copyBufferToTextureCmdPool.alloc(WebGLCmdCopyBufferToTexture); - if (cmd) { - cmd.gpuBuffer = gpuBuffer; - cmd.gpuTexture = gpuTexture; - cmd.dstLayout = dstLayout; - cmd.regions = regions; - this.cmdPackage.copyBufferToTextureCmds.push(cmd); - this.cmdPackage.cmds.push(WebGLCmd.COPY_BUFFER_TO_TEXTURE); + if (!this._isInRenderPass) { + const gpuBuffer = ( srcBuff as WebGLGFXBuffer).gpuBuffer; + const gpuTexture = ( dstTex as WebGLGFXTexture).gpuTexture; + if (gpuBuffer && gpuTexture) { + const cmd = (this._allocator as WebGLGFXCommandAllocator). + copyBufferToTextureCmdPool.alloc(WebGLCmdCopyBufferToTexture); + if (cmd) { + cmd.gpuBuffer = gpuBuffer; + cmd.gpuTexture = gpuTexture; + cmd.dstLayout = dstLayout; + cmd.regions = regions; + this.cmdPackage.copyBufferToTextureCmds.push(cmd); + + this.cmdPackage.cmds.push(WebGLCmd.COPY_BUFFER_TO_TEXTURE); + } } + } else { + console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); } } diff --git a/cocos/gfx/webgl/webgl-device.ts b/cocos/gfx/webgl/webgl-device.ts index 1fb69c7897..152f8c3bde 100644 --- a/cocos/gfx/webgl/webgl-device.ts +++ b/cocos/gfx/webgl/webgl-device.ts @@ -1,8 +1,20 @@ import { GFXBindingLayout, GFXBindingUnit, IGFXBindingLayoutInfo } from '../binding-layout'; -import { GFXBuffer, IGFXBufferInfo, GFXBufferSource } from '../buffer'; +import { GFXBuffer, GFXBufferSource, IGFXBufferInfo } from '../buffer'; import { GFXCommandAllocator, IGFXCommandAllocatorInfo } from '../command-allocator'; import { GFXCommandBuffer, IGFXCommandBufferInfo } from '../command-buffer'; -import { GFXBindingType, GFXBufferTextureCopy, GFXBufferUsageBit, GFXFilter, GFXFormat, GFXFormatInfos, GFXFormatSize, GFXQueueType, GFXTextureFlagBit, GFXTextureType, GFXTextureViewType } from '../define'; +import { + GFXBindingType, + GFXBufferTextureCopy, + GFXBufferUsageBit, + GFXFilter, + GFXFormat, + GFXFormatInfos, + GFXFormatSize, + GFXQueueType, + GFXTextureFlagBit, + GFXTextureType, + GFXTextureViewType, +} from '../define'; import { GFXDevice, IGFXDeviceInfo } from '../device'; import { GFXFramebuffer, IGFXFramebufferInfo } from '../framebuffer'; import { GFXInputAssembler, IGFXInputAssemblerInfo } from '../input-assembler'; @@ -19,9 +31,36 @@ import { WebGLGFXBindingLayout } from './webgl-binding-layout'; import { WebGLGFXBuffer } from './webgl-buffer'; import { WebGLGFXCommandAllocator } from './webgl-command-allocator'; import { WebGLGFXCommandBuffer } from './webgl-command-buffer'; -import { WebGLCmdFuncCopyBufferToTexture, WebGLCmdFuncCreateBuffer, WebGLCmdFuncCreateFramebuffer, WebGLCmdFuncCreateInputAssember, WebGLCmdFuncCreateShader, WebGLCmdFuncCreateTexture, WebGLCmdFuncDestroyBuffer, WebGLCmdFuncDestroyFramebuffer, WebGLCmdFuncDestroyShader, WebGLCmdFuncDestroyTexture, WebGLCmdFuncUpdateBuffer } from './webgl-commands'; +import { + WebGLCmdFuncCopyBufferToTexture, + WebGLCmdFuncCreateBuffer, + WebGLCmdFuncCreateFramebuffer, + WebGLCmdFuncCreateInputAssember, + WebGLCmdFuncCreateShader, + WebGLCmdFuncCreateTexture, + WebGLCmdFuncDestroyBuffer, + WebGLCmdFuncDestroyFramebuffer, + WebGLCmdFuncDestroyShader, + WebGLCmdFuncDestroyTexture, + WebGLCmdFuncUpdateBuffer, +} from './webgl-commands'; import { WebGLGFXFramebuffer } from './webgl-framebuffer'; -import { WebGLGPUBinding, WebGLGPUBindingLayout as WebGLGPUBindingLayout, WebGLGPUBuffer, WebGLGPUFramebuffer, WebGLGPUInputAssembler, WebGLGPUObjectType, WebGLGPUPipelineLayout, WebGLGPUPipelineState, WebGLGPURenderPass, WebGLGPUSampler, WebGLGPUShader, WebGLGPUShaderStage, WebGLGPUTexture, WebGLGPUTextureView } from './webgl-gpu-objects'; +import { + WebGLGPUBinding, + WebGLGPUBindingLayout, + WebGLGPUBuffer, + WebGLGPUFramebuffer, + WebGLGPUInputAssembler, + WebGLGPUObjectType, + WebGLGPUPipelineLayout, + WebGLGPUPipelineState, + WebGLGPURenderPass, + WebGLGPUSampler, + WebGLGPUShader, + WebGLGPUShaderStage, + WebGLGPUTexture, + WebGLGPUTextureView, +} from './webgl-gpu-objects'; import { WebGLGFXInputAssembler } from './webgl-input-assembler'; import { WebGLGFXPipelineLayout } from './webgl-pipeline-layout'; import { WebGLGFXPipelineState } from './webgl-pipeline-state'; @@ -475,7 +514,11 @@ export class WebGLGFXDevice extends GFXDevice { } } - public copyFramebufferToBuffer (srcFramebuffer: GFXFramebuffer, dstBuffer: ArrayBuffer, regions: GFXBufferTextureCopy[]) { + public copyFramebufferToBuffer ( + srcFramebuffer: GFXFramebuffer, + dstBuffer: ArrayBuffer, + regions: GFXBufferTextureCopy[]) { + const gl = this._webGLRC as WebGLRenderingContext; const gpuFramebuffer = (srcFramebuffer as WebGLGFXFramebuffer).gpuFramebuffer; @@ -497,7 +540,8 @@ export class WebGLGFXDevice extends GFXDevice { const memSize = GFXFormatSize(GFXFormat.RGBA8, w, h, 1); const data = view.subarray(buffOffset, buffOffset + memSize); - gl.readPixels(region.texOffset.x, region.texOffset.y, w, h, WebGLRenderingContext.RGBA, WebGLRenderingContext.UNSIGNED_BYTE, data); + gl.readPixels(region.texOffset.x, region.texOffset.y, w, h, + WebGLRenderingContext.RGBA, WebGLRenderingContext.UNSIGNED_BYTE, data); } if (this.stateCache.glFramebuffer !== curFBO) { @@ -955,37 +999,37 @@ export class WebGLGFXDevice extends GFXDevice { private initStates (gl: WebGLRenderingContext) { - gl.activeTexture(WebGLRenderingContext.TEXTURE0); - gl.pixelStorei(WebGLRenderingContext.PACK_ALIGNMENT, 1); - gl.pixelStorei(WebGLRenderingContext.UNPACK_ALIGNMENT, 1); + gl.activeTexture(gl.TEXTURE0); + gl.pixelStorei(gl.PACK_ALIGNMENT, 1); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); - gl.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER, null); + gl.bindFramebuffer(gl.FRAMEBUFFER, null); // rasteriazer state - gl.enable(WebGLRenderingContext.CULL_FACE); - gl.cullFace(WebGLRenderingContext.BACK); - gl.frontFace(WebGLRenderingContext.CCW); + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.BACK); + gl.frontFace(gl.CCW); gl.polygonOffset(0.0, 0.0); // depth stencil state - gl.enable(WebGLRenderingContext.DEPTH_TEST); + gl.enable(gl.DEPTH_TEST); gl.depthMask(true); - gl.depthFunc(WebGLRenderingContext.LESS); + gl.depthFunc(gl.LESS); - gl.stencilFuncSeparate(WebGLRenderingContext.FRONT, WebGLRenderingContext.ALWAYS, 1, 0xffffffff); - gl.stencilOpSeparate(WebGLRenderingContext.FRONT, WebGLRenderingContext.KEEP, WebGLRenderingContext.KEEP, WebGLRenderingContext.KEEP); - gl.stencilMaskSeparate(WebGLRenderingContext.FRONT, 0xffffffff); - gl.stencilFuncSeparate(WebGLRenderingContext.BACK, WebGLRenderingContext.ALWAYS, 1, 0xffffffff); - gl.stencilOpSeparate(WebGLRenderingContext.BACK, WebGLRenderingContext.KEEP, WebGLRenderingContext.KEEP, WebGLRenderingContext.KEEP); - gl.stencilMaskSeparate(WebGLRenderingContext.BACK, 0xffffffff); + gl.stencilFuncSeparate(gl.FRONT, gl.ALWAYS, 1, 0xffffffff); + gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.KEEP); + gl.stencilMaskSeparate(gl.FRONT, 0xffffffff); + gl.stencilFuncSeparate(gl.BACK, gl.ALWAYS, 1, 0xffffffff); + gl.stencilOpSeparate(gl.BACK, gl.KEEP, gl.KEEP, gl.KEEP); + gl.stencilMaskSeparate(gl.BACK, 0xffffffff); - gl.disable(WebGLRenderingContext.STENCIL_TEST); + gl.disable(gl.STENCIL_TEST); // blend state - gl.disable(WebGLRenderingContext.SAMPLE_ALPHA_TO_COVERAGE); - gl.disable(WebGLRenderingContext.BLEND); - gl.blendEquationSeparate(WebGLRenderingContext.FUNC_ADD, WebGLRenderingContext.FUNC_ADD); - gl.blendFuncSeparate(WebGLRenderingContext.ONE, WebGLRenderingContext.ZERO, WebGLRenderingContext.ONE, WebGLRenderingContext.ZERO); + 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); } diff --git a/cocos/gfx/webgl/webgl-gpu-objects.ts b/cocos/gfx/webgl/webgl-gpu-objects.ts index 0f4956c057..71dcabef9e 100644 --- a/cocos/gfx/webgl/webgl-gpu-objects.ts +++ b/cocos/gfx/webgl/webgl-gpu-objects.ts @@ -1,9 +1,24 @@ -import { GFXBindingType, GFXBufferUsage, GFXBufferUsageBit, GFXFormat, GFXMemoryUsage, GFXMemoryUsageBit, GFXShaderType, GFXTextureFlagBit, GFXTextureFlags, GFXTextureType, GFXTextureUsage, GFXTextureUsageBit, GFXTextureViewType, GFXType } from '../define'; +import { GFXBufferSource } from '../buffer'; +import { + GFXBindingType, + GFXBufferUsage, + GFXBufferUsageBit, + GFXFormat, + GFXMemoryUsage, + GFXMemoryUsageBit, + GFXShaderType, + GFXTextureFlagBit, + GFXTextureFlags, + GFXTextureType, + GFXTextureUsage, + GFXTextureUsageBit, + GFXTextureViewType, + GFXType, +} from '../define'; import { IGFXInputAttribute } from '../input-assembler'; import { GFXBlendState, GFXDepthStencilState, GFXRasterizerState } from '../pipeline-state'; import { GFXColorAttachment, GFXDepthStencilAttachment } from '../render-pass'; import { GFXUniformBlock, GFXUniformSampler, IGFXShaderMacro } from '../shader'; -import { GFXBufferSource } from '../buffer'; export enum WebGLGPUObjectType { UNKNOWN, diff --git a/cocos/pipeline/forward/forward-stage.ts b/cocos/pipeline/forward/forward-stage.ts index 65e427c81d..c0589212cd 100644 --- a/cocos/pipeline/forward/forward-stage.ts +++ b/cocos/pipeline/forward/forward-stage.ts @@ -52,12 +52,10 @@ export class ForwardStage extends RenderStage { [camera.clearColor], camera.clearDepth, camera.clearStencil); for (const item of queue.opaques) { - cmdBuff.updateBuffer(item.model.localUBO, item.model.localUniforms.view); cmdBuff.execute([item.cmdBuff]); } for (const item of queue.transparents) { - cmdBuff.updateBuffer(item.model.localUBO, item.model.localUniforms.view); cmdBuff.execute([item.cmdBuff]); } diff --git a/cocos/pipeline/render-pipeline.ts b/cocos/pipeline/render-pipeline.ts index e4efecb8db..94712630ce 100644 --- a/cocos/pipeline/render-pipeline.ts +++ b/cocos/pipeline/render-pipeline.ts @@ -363,7 +363,7 @@ export abstract class RenderPipeline { continue; } - model.updateRenderData(); + model.updateUBOs(); // add model pass to render queue this._queue.add(model, camera); diff --git a/cocos/pipeline/render-queue.ts b/cocos/pipeline/render-queue.ts index 8e75be0bb7..458f3b5ba8 100644 --- a/cocos/pipeline/render-queue.ts +++ b/cocos/pipeline/render-queue.ts @@ -54,6 +54,10 @@ export class RenderQueue { for (let i = 0; i < model.passes.length; ++i) { const pass = model.passes[i]; + + // update pass + pass.update(); + const cmdBuff = model.commandBuffers[i]; model.node.getWorldPosition(); diff --git a/cocos/renderer/scene/model.ts b/cocos/renderer/scene/model.ts index 23bec24317..daf815ad94 100644 --- a/cocos/renderer/scene/model.ts +++ b/cocos/renderer/scene/model.ts @@ -39,7 +39,7 @@ export class Model { private _modelBounds: aabb; private _material: Material | null; private _cmdBuffers: GFXCommandBuffer[]; - private _localUniforms: UBOLocal | null; + private _uboLocal: UBOLocal; private _localUBO: GFXBuffer | null; /** * Setup a default empty model @@ -62,12 +62,11 @@ export class Model { this._castShadow = false; this._material = null; this._cmdBuffers = new Array(); - this._localUniforms = null; + this._uboLocal = new UBOLocal(); this._localUBO = null; } public initialize () { - this._localUniforms = new UBOLocal(); this._localUBO = cc.director.root.device.createBuffer({ usage: GFXBufferUsageBit.UNIFORM | GFXBufferUsageBit.TRANSFER_DST, memUsage: GFXMemoryUsageBit.HOST, @@ -75,7 +74,7 @@ export class Model { stride: UBOLocal.SIZE, }); if (this._localUBO) { - this._localUBO.update(this._localUniforms.view); + this._localUBO.update(this._uboLocal.view); } } @@ -102,22 +101,20 @@ export class Model { this._node._rot, this._node._scale, this._worldBounds); } - public updateRenderData () { + public updateUBOs () { mat4.array(_temp_floatx16, this._node._mat); this._node._mat.invert(_temp_mat4); - if (this._localUniforms) { - this._localUniforms.view.set(_temp_floatx16, UBOLocal.MAT_WORLD_OFFSET); + if (this._uboLocal) { + this._uboLocal.view.set(_temp_floatx16, UBOLocal.MAT_WORLD_OFFSET); } mat4.array(_temp_floatx16, _temp_mat4); - if (this._localUniforms) { - this._localUniforms.view.set(_temp_floatx16, UBOLocal.MAT_WORLD_IT_OFFSET); + if (this._uboLocal) { + this._uboLocal.view.set(_temp_floatx16, UBOLocal.MAT_WORLD_IT_OFFSET); } - /* if (this._localUBO) { - this._localUBO.update(this._localUniforms.view); + this._localUBO.update(this._uboLocal.view); } - */ } /** @@ -211,23 +208,27 @@ export class Model { public recordCommandBuffer (index: number) { const pass = (this._material as Material).passes[index]; - const cmdBufferInfo = { - allocator: cc.director.root.device.commandAllocator, - type: GFXCommandBufferType.SECONDARY, - }; if (this._cmdBuffers[index] == null) { + const cmdBufferInfo = { + allocator: cc.director.root.device.commandAllocator, + type: GFXCommandBufferType.SECONDARY, + }; this._cmdBuffers[index] = cc.director.root.device.createCommandBuffer(cmdBufferInfo); } - if (this._localUBO) { - pass.bindingLayout.bindBuffer(UBOLocal.BLOCK.binding, this._localUBO); - } + + const localUBO = this._localUBO as GFXBuffer; + const subMesh = this._subMeshObject as IRenderingSubmesh; + + pass.bindingLayout.bindBuffer(UBOLocal.BLOCK.binding, localUBO); pass.update(); - this._cmdBuffers[index].begin(); - this._cmdBuffers[index].bindPipelineState(pass.pipelineState); - this._cmdBuffers[index].bindBindingLayout(pass.bindingLayout); - this._cmdBuffers[index].bindInputAssembler((this._subMeshObject as IRenderingSubmesh).inputAssembler); - this._cmdBuffers[index].draw((this._subMeshObject as IRenderingSubmesh).inputAssembler); - this._cmdBuffers[index].end(); + + const cmdBuff = this._cmdBuffers[index]; + cmdBuff.begin(); + cmdBuff.bindPipelineState(pass.pipelineState); + cmdBuff.bindBindingLayout(pass.bindingLayout); + cmdBuff.bindInputAssembler(subMesh.inputAssembler); + cmdBuff.draw(subMesh.inputAssembler); + cmdBuff.end(); } /** @@ -246,8 +247,8 @@ export class Model { return this._cmdBuffers; } - get localUniforms (): UBOLocal { - return this._localUniforms as UBOLocal; + get uboLocal (): UBOLocal { + return this._uboLocal; } get localUBO (): GFXBuffer {