From 4dd9eeaf3c3ce5824ac83074e9672b502d509107 Mon Sep 17 00:00:00 2001 From: jerrywwl Date: Wed, 3 Apr 2019 10:33:20 +0800 Subject: [PATCH] ban webgl2 --- cocos/core/game.js | 2 +- cocos/core/platform/CCView.js | 4 ++-- cocos/gfx/webgl/webgl-command-buffer.ts | 27 +++++++++++++++++++++---- cocos/pipeline/render-pipeline.ts | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/cocos/core/game.js b/cocos/core/game.js index 750ac8316f..7c91fcd2dc 100644 --- a/cocos/core/game.js +++ b/cocos/core/game.js @@ -691,7 +691,7 @@ class Game extends EventTarget { } } - // useWebGL2 = false; + useWebGL2 = false; if (useWebGL2) { this._gfxDevice = new cc.WebGL2GFXDevice(); } else { diff --git a/cocos/core/platform/CCView.js b/cocos/core/platform/CCView.js index f94bd48ed3..70ed300bbc 100644 --- a/cocos/core/platform/CCView.js +++ b/cocos/core/platform/CCView.js @@ -556,8 +556,8 @@ class View extends EventTarget { var canvas = cc.game.canvas; var container = cc.game.container; - canvas.width = width * this._devicePixelRatio; - canvas.height = height * this._devicePixelRatio; + // canvas.width = width * this._devicePixelRatio; + // canvas.height = height * this._devicePixelRatio; canvas.style.width = width + 'px'; canvas.style.height = height + 'px'; diff --git a/cocos/gfx/webgl/webgl-command-buffer.ts b/cocos/gfx/webgl/webgl-command-buffer.ts index cef2a45098..bbe4fb1869 100644 --- a/cocos/gfx/webgl/webgl-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-command-buffer.ts @@ -117,6 +117,8 @@ export class WebGLGFXCommandBuffer extends GFXCommandBuffer { this._curDepthBounds = null; this._curStencilWriteMask = null; this._curStencilCompareMask = null; + this._numDrawCalls = 0; + this._numTris = 0; } public end () { @@ -341,11 +343,25 @@ export class WebGLGFXCommandBuffer extends GFXCommandBuffer { const cmd = ( this._allocator as WebGLGFXCommandAllocator). drawCmdPool.alloc(WebGLCmdDraw); - if (cmd) { - (inputAssembler as WebGLGFXInputAssembler).extractCmdDraw(cmd); - this.cmdPackage.drawCmds.push(cmd); + (inputAssembler as WebGLGFXInputAssembler).extractCmdDraw(cmd); + this.cmdPackage.drawCmds.push(cmd); - this.cmdPackage.cmds.push(WebGLCmd.DRAW); + this.cmdPackage.cmds.push(WebGLCmd.DRAW); + + ++this._numDrawCalls; + if (this._curGPUPipelineState) { + const glPrimitive = this._curGPUPipelineState.glPrimitive; + switch (glPrimitive) { + case WebGL2RenderingContext.TRIANGLES: { + this._numTris += inputAssembler.indexCount / 3 * inputAssembler.instanceCount; + break; + } + case WebGL2RenderingContext.TRIANGLE_STRIP: + case WebGL2RenderingContext.TRIANGLE_FAN: { + this._numTris += (inputAssembler.indexCount - 2) * inputAssembler.instanceCount; + break; + } + } } } else { console.error('Command \'draw\' must be recorded inside a render pass.'); @@ -449,6 +465,9 @@ export class WebGLGFXCommandBuffer extends GFXCommandBuffer { } this.cmdPackage.cmds.concat(webGLCmdBuff.cmdPackage.cmds); + + this._numDrawCalls += webGLCmdBuff._numDrawCalls; + this._numTris += webGLCmdBuff._numTris; } } diff --git a/cocos/pipeline/render-pipeline.ts b/cocos/pipeline/render-pipeline.ts index 029a1f01d7..f72a964d6d 100644 --- a/cocos/pipeline/render-pipeline.ts +++ b/cocos/pipeline/render-pipeline.ts @@ -365,7 +365,7 @@ export abstract class RenderPipeline { console.info('USE_SMAA: ' + this._useSMAA); console.info('CC_USE_HDR: ' + this._isHDR); console.info('SHADING_SIZE: ' + this._shadingWidth + ' x ' + this._shadingHeight); - console.info('SCREEN_SCALE: ' + this._shadingScale.toFixed(2)); + console.info('SHADING_SCALE: ' + this._shadingScale.toFixed(2)); console.info('SHADING_COLOR_FORMAT: ' + GFXFormatInfos[this._colorFmt].name); console.info('SHADING_DEPTH_FORMAT: ' + GFXFormatInfos[this._depthStencilFmt].name);