From c9bbcf905fd5ecd814183fe6deb15ac34be41f0f Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 30 Sep 2020 17:25:20 +0800 Subject: [PATCH] GFXInputState GFXPipelineStateInfo use jsb binded class (#7473) --- cc.config.json | 1 - cocos/core/gfx/index.jsb.ts | 14 +++-- cocos/core/gfx/pipeline-state.jsb.ts | 5 -- cocos/core/pipeline/pipeline-state-manager.ts | 3 +- port/native/engine/jsb-gfx.js | 52 ------------------- 5 files changed, 10 insertions(+), 65 deletions(-) delete mode 100644 cocos/core/gfx/pipeline-state.jsb.ts diff --git a/cc.config.json b/cc.config.json index ed94203fbc..145367abb4 100644 --- a/cc.config.json +++ b/cc.config.json @@ -4,7 +4,6 @@ "moduleOverrides": { "cocos/core/pipeline/index.ts": "cocos/core/pipeline/index.jsb.ts", "cocos/core/renderer/core/native-pools.ts": "cocos/core/renderer/core/native-pools.jsb.ts", - "cocos/core/gfx/pipeline-state.ts": "cocos/core/gfx/pipeline-state.jsb.ts", "cocos/core/gfx/index.ts": "cocos/core/gfx/index.jsb.ts" } } diff --git a/cocos/core/gfx/index.jsb.ts b/cocos/core/gfx/index.jsb.ts index 00026cdbb9..8ff9b52178 100644 --- a/cocos/core/gfx/index.jsb.ts +++ b/cocos/core/gfx/index.jsb.ts @@ -1,6 +1,4 @@ -/** - * @category gfx - */ +declare const gfx: any; import { GFXBuffer } from './buffer'; import { GFXCommandBuffer } from './command-buffer'; @@ -30,8 +28,14 @@ export * from './render-pass'; export * from './sampler'; export * from './shader'; export * from './texture'; -export * from './pipeline-state.jsb'; +export const GFXRasterizerState = gfx.RasterizerState; +export const GFXDepthStencilState = gfx.DepthStencilState; +export const GFXBlendTarget = gfx.BlendTarget; +export const GFXBlendState = gfx.BlendState; +export const GFXPipelineState = gfx.PipelineState; +export const GFXPipelineStateInfo = gfx.PipelineStateInfo; +export const GFXInputState = gfx.InputState; legacyCC.GFXDevice = GFXDevice; legacyCC.GFXBuffer = GFXBuffer; @@ -41,7 +45,7 @@ legacyCC.GFXShader = GFXShader; legacyCC.GFXInputAssembler = GFXInputAssembler; legacyCC.GFXRenderPass = GFXRenderPass; legacyCC.GFXFramebuffer = GFXFramebuffer; -legacyCC.GFXPipelineState = gfx.PipelineState; +legacyCC.GFXPipelineState = GFXPipelineState; legacyCC.GFXCommandBuffer = GFXCommandBuffer; legacyCC.GFXQueue = GFXQueue; diff --git a/cocos/core/gfx/pipeline-state.jsb.ts b/cocos/core/gfx/pipeline-state.jsb.ts deleted file mode 100644 index 621954b408..0000000000 --- a/cocos/core/gfx/pipeline-state.jsb.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const GFXRasterizerState = gfx.RasterizerState; -export const GFXDepthStencilState = gfx.DepthStencilState; -export const GFXBlendTarget = gfx.BlendTarget; -export const GFXBlendState = gfx.BlendState; -export const GFXPipelineState = gfx.PipelineState; diff --git a/cocos/core/pipeline/pipeline-state-manager.ts b/cocos/core/pipeline/pipeline-state-manager.ts index 796db772e3..142ac811fa 100644 --- a/cocos/core/pipeline/pipeline-state-manager.ts +++ b/cocos/core/pipeline/pipeline-state-manager.ts @@ -19,8 +19,7 @@ export class PipelineStateManager { let pso = this._PSOHashMap.get(newHash); if (!pso) { const pipelineLayout = PipelineLayoutPool.get(PassPool.get(hPass, PassView.PIPELINE_LAYOUT)); - const inputState = new GFXInputState(); - inputState.attributes = ia.attributes; + const inputState = new GFXInputState(ia.attributes); const psoInfo = new GFXPipelineStateInfo( shader, pipelineLayout, renderPass, inputState, RasterizerStatePool.get(PassPool.get(hPass, PassView.RASTERIZER_STATE)), diff --git a/port/native/engine/jsb-gfx.js b/port/native/engine/jsb-gfx.js index 7504d819af..8e8e06ba3e 100644 --- a/port/native/engine/jsb-gfx.js +++ b/port/native/engine/jsb-gfx.js @@ -251,52 +251,6 @@ let _converters = { PushConstantRange: function (range) { return new gfx.PushConstantRange(range.shaderType, range.offset, range.count); }, - InputState: function (info) { - let attrs = info.attributes; - let jsbAttrs; - if (attrs) { - jsbAttrs = []; - for (let i = 0; i < attrs.length; ++i) { - jsbAttrs.push(_converters.Attribute(attrs[i])); - } - } - return new gfx.InputState(jsbAttrs); - }, - RasterizerState: function (info) { - return new gfx.RasterizerState(info); - }, - DepthStencilState: function (info) { - return new gfx.DepthStencilState(info); - }, - BlendTarget: function (info) { - return new gfx.BlendTarget(info); - }, - BlendState: function (state) { - let targets = state.targets; - let jsbTargets; - if (targets) { - jsbTargets = []; - for (let i = 0; i < targets.length; ++i) { - jsbTargets.push(_converters.BlendTarget(targets[i])); - } - } - let color = _converters.Color(state.blendColor); - return new gfx.BlendState(state.isA2c, state.isIndepend, color, jsbTargets); - }, - PipelineStateInfo: function (info) { - let jsbInfo = { - primitive: info.primitive, - shader: info.shader, - inputState: _converters.InputState(info.inputState), - rasterizerState: _converters.RasterizerState(info.rasterizerState), - depthStencilState: _converters.DepthStencilState(info.depthStencilState), - blendState: _converters.BlendState(info.blendState), - dynamicStates: info.dynamicStates, - renderPass: info.renderPass, - pipelineLayout: info.pipelineLayout, - } - return new gfx.PipelineStateInfo(jsbInfo); - }, CommandBufferInfo: function (info) { return new gfx.CommandBufferInfo(info); }, @@ -388,7 +342,6 @@ deviceProtos.forEach(function(item, index) { createDescriptorSet: replaceFunction('_createDescriptorSet', _converters.DescriptorSetInfo), createDescriptorSetLayout: replaceFunction('_createDescriptorSetLayout', _converters.DescriptorSetLayoutInfo), createPipelineLayout: replaceFunction('_createPipelineLayout', _converters.PipelineLayoutInfo), - createPipelineState: replaceFunction('_createPipelineState', _converters.PipelineStateInfo), copyBuffersToTexture: replaceFunction('_copyBuffersToTexture', _converters.origin, _converters.origin, _converters.BufferTextureCopyList), copyTexImagesToTexture: replaceFunction('_copyTexImagesToTexture', _converters.texImagesToBuffers, _converters.origin, _converters.BufferTextureCopyList), }); @@ -453,11 +406,6 @@ replace(pipelineLayoutProto, { initialize: replaceFunction('_initialize', _converters.PipelineLayoutInfo), }); -let pipelineStateProto = gfx.PipelineState.prototype; -replace(pipelineStateProto, { - initialize: replaceFunction('_initialize', _converters.PipelineStateInfo), -}); - let queueProto = gfx.Queue.prototype; replace(queueProto, { initialize: replaceFunction('_initialize', _converters.QueueInfo),