diff --git a/cocos/renderer/gfx/gfx-device.ts b/cocos/renderer/gfx/gfx-device.ts index b91eee2266..fef0883783 100644 --- a/cocos/renderer/gfx/gfx-device.ts +++ b/cocos/renderer/gfx/gfx-device.ts @@ -12,6 +12,7 @@ import { GFXInputAssemblerInfo, GFXInputAssembler } from './gfx-input-assembler' import { GFXCommandBufferInfo, GFXCommandBuffer } from './gfx-command-buffer'; import { GFXCommandAllocatorInfo, GFXCommandAllocator } from './gfx-command-allocator'; import { GFXWindowInfo, GFXWindow } from './gfx-window'; +import { GFXBindingLayoutInfo, GFXBindingLayout } from './gfx-binding-layout'; export enum GFXFeature { }; @@ -30,6 +31,7 @@ export abstract class GFXDevice { public abstract createTexture(info: GFXTextureInfo) : GFXTexture | null; public abstract createTextureView(info: GFXTextureViewInfo) : GFXTextureView | null; public abstract createSampler(info: GFXSamplerInfo) : GFXSampler | null; + public abstract createBindingLayout(info: GFXBindingLayoutInfo) : GFXBindingLayout | null; public abstract createShader(info: GFXShaderInfo) : GFXShader | null; public abstract createInputAssembler(info: GFXInputAssemblerInfo) : GFXInputAssembler | null; public abstract createRenderPass(info: GFXRenderPassInfo) : GFXRenderPass | null; @@ -51,8 +53,7 @@ export abstract class GFXDevice { protected _deviceName : string = ""; protected _queue : GFXQueue | null = null; - protected _primaryWindow : GFXWindow | null = null; - protected _windows : GFXWindow[] = []; + protected _curWindow : GFXWindow | null = null; protected _maxVertexAttributes : number = 0; }; diff --git a/cocos/renderer/gfx/webgl/webgl-commands.ts b/cocos/renderer/gfx/webgl/webgl-commands.ts index 988869172c..e3fd4097f9 100644 --- a/cocos/renderer/gfx/webgl/webgl-commands.ts +++ b/cocos/renderer/gfx/webgl/webgl-commands.ts @@ -1505,7 +1505,6 @@ export function WebGLCmdFuncExecuteCmds(device: WebGLGFXDevice, cmdPackage: WebG switch (glUniform.glType) { case WebGLRenderingContext.BOOL: case WebGLRenderingContext.INT: { - let offset = glUniform.offset; for (let m = 0; m < glUniform.count; ++m) { if (glBlock.bufferView.getInt32(offset) !== glUniform.bufferView[m]) { @@ -1514,6 +1513,7 @@ export function WebGLCmdFuncExecuteCmds(device: WebGLGFXDevice, cmdPackage: WebG } offset += 4; } + break; } case WebGLRenderingContext.BOOL_VEC2: case WebGLRenderingContext.INT_VEC2: { @@ -1532,7 +1532,6 @@ export function WebGLCmdFuncExecuteCmds(device: WebGLGFXDevice, cmdPackage: WebG } case WebGLRenderingContext.BOOL_VEC3: case WebGLRenderingContext.INT_VEC3: { - let offset = glUniform.offset; for (let m = 0; m < glUniform.count; ++m) { let idx = 3*m; @@ -1590,7 +1589,6 @@ export function WebGLCmdFuncExecuteCmds(device: WebGLGFXDevice, cmdPackage: WebG break; } case WebGLRenderingContext.FLOAT_VEC3: { - let offset = glUniform.offset; for (let m = 0; m < glUniform.count; ++m) { let idx = 3*m; @@ -1605,7 +1603,6 @@ export function WebGLCmdFuncExecuteCmds(device: WebGLGFXDevice, cmdPackage: WebG break; } case WebGLRenderingContext.FLOAT_VEC4: { - let offset = glUniform.offset; for (let m = 0; m < glUniform.count; ++m) { let idx = 4*m; @@ -1621,7 +1618,6 @@ export function WebGLCmdFuncExecuteCmds(device: WebGLGFXDevice, cmdPackage: WebG break; } case WebGLRenderingContext.FLOAT_MAT2: { - let offset = glUniform.offset; for (let m = 0; m < glUniform.count; ++m) { let idx = 4*m; @@ -1634,11 +1630,9 @@ export function WebGLCmdFuncExecuteCmds(device: WebGLGFXDevice, cmdPackage: WebG } offset += 16; } - break; } case WebGLRenderingContext.FLOAT_MAT3: { - let offset = glUniform.offset; for (let m = 0; m < glUniform.count; ++m) { let idx = 9*m; @@ -1656,11 +1650,9 @@ export function WebGLCmdFuncExecuteCmds(device: WebGLGFXDevice, cmdPackage: WebG } offset += 36; } - break; } case WebGLRenderingContext.FLOAT_MAT4: { - let offset = glUniform.offset; for (let m = 0; m < glUniform.count; ++m) { let idx = 16*m; diff --git a/cocos/renderer/gfx/webgl/webgl-gfx-device.ts b/cocos/renderer/gfx/webgl/webgl-gfx-device.ts index 4e135ad191..7d8965e3a9 100644 --- a/cocos/renderer/gfx/webgl/webgl-gfx-device.ts +++ b/cocos/renderer/gfx/webgl/webgl-gfx-device.ts @@ -20,7 +20,7 @@ import { WebGLGFXShader } from './webgl-gfx-shader'; import { GFXCommandAllocator, GFXCommandAllocatorInfo } from '../gfx-command-allocator'; import { GFXPipelineStateInfo, GFXPipelineState } from '../gfx-pipeline-state'; import { WebGLGFXPipelineLayout } from './webgl-gfx-pipeline-layout'; -import { GFXBindingLayoutInfo, GFXBindingUnit, GFXBindingType } from '../gfx-binding-layout'; +import { GFXBindingLayoutInfo, GFXBindingUnit, GFXBindingType, GFXBindingLayout } from '../gfx-binding-layout'; import { WebGLGFXSampler } from './webgl-gfx-sampler'; import { GFXCommandBufferInfo, GFXCommandBuffer } from '../gfx-command-buffer'; import { GFXQueueInfo, GFXQueue } from '../gfx-queue'; @@ -32,6 +32,7 @@ import { WebGLGFXInputAssembler } from './webgl-gfx-input-assembler'; import { GFXWindowInfo, GFXWindow } from '../gfx-window'; import { WebGLGFXWindow } from './webgl-gfx-window'; import { BufferView } from '../gfx-define'; +import { WebGLGFXBindingLayout } from './webgl-gfx-binding-layout'; const WebGLPrimitives: GLenum[] = [ WebGLRenderingContext.POINTS, @@ -148,7 +149,7 @@ export class WebGLGFXDevice extends GFXDevice { this._ANGLE_instanced_arrays = this._webGLRC.getExtension("ANGLE_instanced_arrays"); // create primary window - this._primaryWindow = this.createWindow({ + this._curWindow = this.createWindow({ title: this._webGLRC.canvas.title, left: this._webGLRC.canvas.offsetLeft, top: this._webGLRC.canvas.offsetTop, @@ -161,9 +162,9 @@ export class WebGLGFXDevice extends GFXDevice { public destroy(): void { - if (this._primaryWindow) { - this._primaryWindow.destroy(); - this._primaryWindow = null; + if (this._curWindow) { + this._curWindow.destroy(); + this._curWindow = null; } this._webGLRC = null; @@ -209,6 +210,16 @@ export class WebGLGFXDevice extends GFXDevice { } } + public createBindingLayout(info: GFXBindingLayoutInfo): GFXBindingLayout | null { + let bindingLayout = new WebGLGFXBindingLayout(this); + if (bindingLayout.initialize(info)) { + return bindingLayout; + } else { + bindingLayout.destroy(); + return null; + } + } + public createShader(info: GFXShaderInfo): GFXShader | null { let shader = new WebGLGFXShader(this); if (shader.initialize(info)) { @@ -302,7 +313,6 @@ export class WebGLGFXDevice extends GFXDevice { public createWindow(info: GFXWindowInfo): GFXWindow | null { let window = new WebGLGFXWindow(this); if (window.initialize(info)) { - this._windows.push(window); return window; } else { window.destroy();