From 8931d968c0ea639e055440acd194d9397afc8e60 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 17 Jan 2014 16:08:29 -0800 Subject: [PATCH] Renderer uses a float as a key Instead of using a 64-bit int key with viewport, opaque and depth, it only uses a 32-bit float with only the depth. Saves time in: - No need to convert the 32-bit float into 24-bit int - keys are shorter --- CHANGELOG | 1 + cocos/2d/CCAtlasNode.cpp | 2 +- cocos/2d/CCClippingNode.cpp | 8 +-- cocos/2d/CCDrawNode.cpp | 2 +- cocos/2d/CCLabel.cpp | 2 +- cocos/2d/CCLayer.cpp | 2 +- cocos/2d/CCMotionStreak.cpp | 2 +- cocos/2d/CCNodeGrid.cpp | 6 +- cocos/2d/CCParticleBatchNode.cpp | 2 +- cocos/2d/CCParticleSystemQuad.cpp | 2 +- cocos/2d/CCProgressTimer.cpp | 2 +- cocos/2d/CCRenderTexture.cpp | 12 ++-- cocos/2d/CCSprite.cpp | 2 +- cocos/2d/CCSpriteBatchNode.cpp | 2 +- cocos/2d/CCTransitionPageTurn.cpp | 8 +-- cocos/2d/renderer/CCBatchCommand.cpp | 60 +------------------ cocos/2d/renderer/CCBatchCommand.h | 15 +---- cocos/2d/renderer/CCCustomCommand.cpp | 16 +---- cocos/2d/renderer/CCCustomCommand.h | 11 +--- cocos/2d/renderer/CCGroupCommand.cpp | 16 +---- cocos/2d/renderer/CCGroupCommand.h | 11 +--- cocos/2d/renderer/CCQuadCommand.cpp | 26 +++----- cocos/2d/renderer/CCQuadCommand.h | 16 +---- cocos/2d/renderer/CCRenderCommand.cpp | 8 +-- cocos/2d/renderer/CCRenderCommand.h | 14 +++-- cocos/2d/renderer/CCRenderer.cpp | 4 +- .../editor-support/cocostudio/CCBatchNode.cpp | 2 +- cocos/editor-support/cocostudio/CCSkin.cpp | 2 +- cocos/editor-support/spine/CCSkeleton.cpp | 2 +- cocos/gui/UILayout.cpp | 12 ++-- extensions/GUI/CCScrollView/CCScrollView.cpp | 4 +- .../Classes/ActionsTest/ActionsTest.cpp | 10 ++-- .../Classes/Box2DTestBed/Box2dView.cpp | 2 +- .../ClippingNodeTest/ClippingNodeTest.cpp | 8 +-- .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 2 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 4 +- .../TestCpp/Classes/LabelTest/LabelTest.cpp | 6 +- .../Classes/LabelTest/LabelTestNew.cpp | 4 +- .../Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp | 2 +- .../RenderTextureTest/RenderTextureTest.cpp | 10 ++-- .../TestCpp/Classes/ShaderTest/ShaderTest.cpp | 4 +- .../Classes/ShaderTest/ShaderTest2.cpp | 2 +- .../Classes/Texture2dTest/Texture2dTest.cpp | 4 +- .../Classes/TileMapTest/TileMapTest.cpp | 6 +- 44 files changed, 100 insertions(+), 238 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c4a8ea7282..5f24006cb3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ cocos2d-x-3.0final ?.? ? [FIX] Renderer: QuadCommand::init() does not copy the Quads, it only store a reference making the code faster [FIX] Renderer: Performance improved in Sprite and SpriteBatchNode (and subclasses) sprites in about 20% [FIX] Renderer: When note using VAO, call glBufferData() instead of glBufferSubData(). + [FIX] Renderer: Uses a float as key with only the depth. Viewport, opaque are not needed now [FIX] Sprite: removed _hasChildren optimization. It uses !_children.empty() now which is super fast as well [FIX] Tests: TestCpp works with CMake on Windows. [FIX] Tests: Sprites Performance Test has 4 new tests diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index f86c143d78..03eb16ba18 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -152,7 +152,7 @@ void AtlasNode::draw(void) auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - _quadCommand.init(0, + _quadCommand.init( _vertexZ, _textureAtlas->getTexture()->getName(), shader, diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index f5bc3bf95d..55be0ef5a8 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -210,12 +210,12 @@ void ClippingNode::visit() Renderer* renderer = Director::getInstance()->getRenderer(); - _groupCommand.init(0,_vertexZ); + _groupCommand.init(_vertexZ); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - _beforeVisitCmd.init(0,_vertexZ); + _beforeVisitCmd.init(_vertexZ); _beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this); renderer->addCommand(&_beforeVisitCmd); if (_alphaThreshold < 1) @@ -238,7 +238,7 @@ void ClippingNode::visit() } _stencil->visit(); - _afterDrawStencilCmd.init(0,_vertexZ); + _afterDrawStencilCmd.init(_vertexZ); _afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this); renderer->addCommand(&_afterDrawStencilCmd); @@ -268,7 +268,7 @@ void ClippingNode::visit() this->draw(); } - _afterVisitCmd.init(0,_vertexZ); + _afterVisitCmd.init(_vertexZ); _afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this); renderer->addCommand(&_afterVisitCmd); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 3432ad024f..0e28ee554f 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -241,7 +241,7 @@ void DrawNode::render() void DrawNode::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 52f817ef7c..c96678fc57 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -666,7 +666,7 @@ void Label::onDraw() void Label::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(Label::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 1b24c97f25..83629a50ec 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -565,7 +565,7 @@ void LayerColor::updateColor() void LayerColor::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index fdb0b70fb8..2dc1f49fbb 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -359,7 +359,7 @@ void MotionStreak::draw() if(_nuPoints <= 1) return; kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV); - _customCommand.init(0,_vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index 9c24500da0..9f359cf778 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -92,7 +92,7 @@ void NodeGrid::visit() Renderer* renderer = Director::getInstance()->getRenderer(); - _groupCommand.init(0,_vertexZ); + _groupCommand.init(_vertexZ); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); @@ -104,7 +104,7 @@ void NodeGrid::visit() _nodeGrid->set2DProjection(); } - _gridBeginCommand.init(0,_vertexZ); + _gridBeginCommand.init(_vertexZ); _gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this); renderer->addCommand(&_gridBeginCommand); @@ -152,7 +152,7 @@ void NodeGrid::visit() director->setProjection(beforeProjectionType); } - _gridEndCommand.init(0,_vertexZ); + _gridEndCommand.init(_vertexZ); _gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this); renderer->addCommand(&_gridEndCommand); diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index b291910422..d64d682ce3 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -382,7 +382,7 @@ void ParticleBatchNode::draw(void) return; } - _batchCommand.init(0, + _batchCommand.init( _vertexZ, _textureAtlas->getTexture()->getName(), _shaderProgram, diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 8495483116..cf3725e1a2 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -439,7 +439,7 @@ void ParticleSystemQuad::draw() auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - _quadCommand.init(0, _vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform); + _quadCommand.init(_vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform); Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index 37c754a0ee..b8332e0442 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -555,7 +555,7 @@ void ProgressTimer::draw() if( ! _vertexData || ! _sprite) return; - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index fcf00452ed..63bc1a596d 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -322,7 +322,7 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep this->begin(); //clear screen - _beginWithClearCommand.init(0, _vertexZ); + _beginWithClearCommand.init(_vertexZ); _beginWithClearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this); Director::getInstance()->getRenderer()->addCommand(&_beginWithClearCommand); } @@ -340,7 +340,7 @@ void RenderTexture::clearDepth(float depthValue) this->begin(); - _clearDepthCommand.init(0, _vertexZ); + _clearDepthCommand.init(_vertexZ); _clearDepthCommand.func = CC_CALLBACK_0(RenderTexture::onClearDepth, this); Director::getInstance()->getRenderer()->addCommand(&_clearDepthCommand); @@ -605,7 +605,7 @@ void RenderTexture::draw() begin(); //clear screen - _clearCommand.init(0, _vertexZ); + _clearCommand.init(_vertexZ); _clearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this); Director::getInstance()->getRenderer()->addCommand(&_clearCommand); @@ -648,13 +648,13 @@ void RenderTexture::begin() (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); kmGLMultMatrix(&orthoMatrix); - _groupCommand.init(0, _vertexZ); + _groupCommand.init(_vertexZ); Renderer *renderer = Director::getInstance()->getRenderer(); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - _beginCommand.init(0, _vertexZ); + _beginCommand.init(_vertexZ); _beginCommand.func = CC_CALLBACK_0(RenderTexture::onBegin, this); Director::getInstance()->getRenderer()->addCommand(&_beginCommand); @@ -662,7 +662,7 @@ void RenderTexture::begin() void RenderTexture::end() { - _endCommand.init(0, _vertexZ); + _endCommand.init(_vertexZ); _endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this); Renderer *renderer = Director::getInstance()->getRenderer(); diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index c66c811b1b..fafb509a6b 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -670,7 +670,7 @@ void Sprite::updateTransform(void) void Sprite::draw(void) { //TODO implement z order - _quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform); + _quadCommand.init(_vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform); // if(culling()) { diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index fde85639aa..6237f92b19 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -356,7 +356,7 @@ void SpriteBatchNode::draw() for(const auto &child: _children) child->updateTransform(); - _batchCommand.init(0, + _batchCommand.init( _vertexZ, _textureAtlas->getTexture()->getName(), _shaderProgram, diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index 7ade9878a4..c42bf6e9d2 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -98,23 +98,23 @@ void TransitionPageTurn::draw() if( _isInSceneOnTop ) { _outSceneProxy->visit(); - _enableOffsetCmd.init(0, _vertexZ); + _enableOffsetCmd.init(_vertexZ); _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd); _inSceneProxy->visit(); - _disableOffsetCmd.init(0, _vertexZ); + _disableOffsetCmd.init(_vertexZ); _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd); } else { _inSceneProxy->visit(); - _enableOffsetCmd.init(0, _vertexZ); + _enableOffsetCmd.init(_vertexZ); _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd); _outSceneProxy->visit(); - _disableOffsetCmd.init(0, _vertexZ); + _disableOffsetCmd.init(_vertexZ); _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd); } diff --git a/cocos/2d/renderer/CCBatchCommand.cpp b/cocos/2d/renderer/CCBatchCommand.cpp index de3fc511cd..817cfb421c 100644 --- a/cocos/2d/renderer/CCBatchCommand.cpp +++ b/cocos/2d/renderer/CCBatchCommand.cpp @@ -30,9 +30,7 @@ NS_CC_BEGIN BatchCommand::BatchCommand() -: _viewport(0) -, _depth(0) -, _textureID(0) +: _textureID(0) , _blendType(BlendFunc::DISABLE) , _textureAtlas(nullptr) { @@ -40,9 +38,8 @@ BatchCommand::BatchCommand() _shader = nullptr; } -void BatchCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform) +void BatchCommand::init(float depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform) { - _viewport = viewport; _depth = depth; _textureID = textureID; _blendType = blendType; @@ -57,59 +54,6 @@ BatchCommand::~BatchCommand() { } -int64_t BatchCommand::generateID() -{ - _id = 0; - - //Generate Material ID - //TODO fix shader ID generation - CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10"); - //TODO fix texture ID generation - CCASSERT(_textureID < pow(2,18), "TextureID is greater than 2^18"); - - //TODO fix blend id generation - int blendID = 0; - if(_blendType == BlendFunc::DISABLE) - { - blendID = 0; - } - else if(_blendType == BlendFunc::ALPHA_PREMULTIPLIED) - { - blendID = 1; - } - else if(_blendType == BlendFunc::ALPHA_NON_PREMULTIPLIED) - { - blendID = 2; - } - else if(_blendType == BlendFunc::ADDITIVE) - { - blendID = 3; - } - else - { - blendID = 4; - } - - //TODO Material ID should be part of the ID - // - // Temporal hack (later, these 32-bits should be packed in 24-bits - // - // +---------------------+-------------------+----------------------+ - // | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) | - // +---------------------+-------------------+----------------------+ - - _materialID = (int32_t)_shader->getProgram() << 22 - | (int32_t)blendID << 18 - | (int32_t)_textureID << 0; - - //Generate RenderCommandID - _id = (int64_t)_viewport << 61 - | (int64_t)1 << 60 //translucent - | (int64_t)_depth << 36; - - return _id; -} - void BatchCommand::execute() { // Set material diff --git a/cocos/2d/renderer/CCBatchCommand.h b/cocos/2d/renderer/CCBatchCommand.h index d3b2a5245e..9ac5b346ee 100644 --- a/cocos/2d/renderer/CCBatchCommand.h +++ b/cocos/2d/renderer/CCBatchCommand.h @@ -43,26 +43,13 @@ public: BatchCommand(); ~BatchCommand(); - void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform); - - // +----------+----------+-----+-----------------------------------+ - // | | | | | | - // | ViewPort | Transluc | | Depth | Material ID | - // | 3 bits | 1 bit | | 24 bits | 24 bit2 | - // +----------+----------+-----+----------------+------------------+ - virtual int64_t generateID(); + void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform); void execute(); protected: int32_t _materialID; - //Key Data - int _viewport; /// Which view port it belongs to - - //TODO use material to determine if it's translucent - int32_t _depth; - //Maternal GLuint _textureID; diff --git a/cocos/2d/renderer/CCCustomCommand.cpp b/cocos/2d/renderer/CCCustomCommand.cpp index 5bbf2032ea..10992393f7 100644 --- a/cocos/2d/renderer/CCCustomCommand.cpp +++ b/cocos/2d/renderer/CCCustomCommand.cpp @@ -28,15 +28,12 @@ NS_CC_BEGIN CustomCommand::CustomCommand() : func(nullptr) -, _viewport(0) -, _depth(0) { _type = RenderCommand::Type::CUSTOM_COMMAND; } -void CustomCommand::init(int viewport, int32_t depth) +void CustomCommand::init(float depth) { - _viewport = viewport; _depth = depth; } @@ -45,17 +42,6 @@ CustomCommand::~CustomCommand() } -int64_t CustomCommand::generateID() -{ - _id = 0; - - _id = (int64_t)_viewport << 61 - | (int64_t)1 << 60 // translucent - | (int64_t)_depth << 36; - - return _id; -} - void CustomCommand::execute() { if(func) diff --git a/cocos/2d/renderer/CCCustomCommand.h b/cocos/2d/renderer/CCCustomCommand.h index 7ff4c3e3ca..03fdead69a 100644 --- a/cocos/2d/renderer/CCCustomCommand.h +++ b/cocos/2d/renderer/CCCustomCommand.h @@ -39,14 +39,7 @@ public: public: - void init(int viewport, int32_t depth); - - // +----------+----------+-----+-----------------------------------+ - // | | | | | | - // | ViewPort | Transluc | | Depth | | - // | 3 bits | 1 bit | | 24 bits | | - // +----------+----------+-----+----------------+------------------+ - virtual int64_t generateID(); + void init(float depth); void execute(); @@ -54,8 +47,6 @@ public: std::function func; protected: - int _viewport; - int32_t _depth; }; NS_CC_END diff --git a/cocos/2d/renderer/CCGroupCommand.cpp b/cocos/2d/renderer/CCGroupCommand.cpp index 9c0e57eb92..70496b5d1d 100644 --- a/cocos/2d/renderer/CCGroupCommand.cpp +++ b/cocos/2d/renderer/CCGroupCommand.cpp @@ -86,16 +86,13 @@ void GroupCommandManager::releaseGroupID(int groupID) } GroupCommand::GroupCommand() -: _viewport(0) -, _depth(0) { _type = RenderCommand::Type::GROUP_COMMAND; _renderQueueID = GroupCommandManager::getInstance()->getGroupID(); } -void GroupCommand::init(int viewport, int32_t depth) +void GroupCommand::init(float depth) { - _viewport = viewport; _depth = depth; GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID); _renderQueueID = GroupCommandManager::getInstance()->getGroupID(); @@ -106,15 +103,4 @@ GroupCommand::~GroupCommand() GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID); } -int64_t GroupCommand::generateID() -{ - _id = 0; - - _id = (int64_t)_viewport << 61 - | (int64_t)1 << 60 // translucent - | (int64_t)_depth << 36; - - return _id; -} - NS_CC_END diff --git a/cocos/2d/renderer/CCGroupCommand.h b/cocos/2d/renderer/CCGroupCommand.h index 7a6b6e511c..02fe541fd0 100644 --- a/cocos/2d/renderer/CCGroupCommand.h +++ b/cocos/2d/renderer/CCGroupCommand.h @@ -58,21 +58,12 @@ public: public: - void init(int viewport, int32_t depth); - - // +----------+----------+-----+-----------------------------------+ - // | | | | | | - // | ViewPort | Transluc | | Depth | | - // | 3 bits | 1 bit | | 24 bits | | - // +----------+----------+-----+----------------+------------------+ - virtual int64_t generateID() override; + void init(float depth); inline bool isTranslucent() {return true;} inline int getRenderQueueID() {return _renderQueueID;} protected: - int _viewport; - int32_t _depth; int _renderQueueID; }; diff --git a/cocos/2d/renderer/CCQuadCommand.cpp b/cocos/2d/renderer/CCQuadCommand.cpp index a19e3f7053..0d602cee4e 100644 --- a/cocos/2d/renderer/CCQuadCommand.cpp +++ b/cocos/2d/renderer/CCQuadCommand.cpp @@ -29,9 +29,7 @@ NS_CC_BEGIN QuadCommand::QuadCommand() -:_viewport(0) -,_depth(0) -,_textureID(0) +:_textureID(0) ,_blendType(BlendFunc::DISABLE) ,_quadsCount(0) { @@ -40,9 +38,8 @@ QuadCommand::QuadCommand() _quads = nullptr; } -void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv) +void QuadCommand::init(float depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv) { - _viewport = viewport; _depth = depth; _textureID = textureID; _blendType = blendType; @@ -52,16 +49,16 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* _quads = quad; _mv = mv; + + generateMaterialID(); } QuadCommand::~QuadCommand() { } -int64_t QuadCommand::generateID() +void QuadCommand::generateMaterialID() { - _id = 0; - //Generate Material ID //TODO fix shader ID generation CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10"); @@ -99,16 +96,9 @@ int64_t QuadCommand::generateID() // | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) | // +---------------------+-------------------+----------------------+ - _materialID = (int32_t)_shader->getProgram() << 22 - | (int32_t)blendID << 18 - | (int32_t)_textureID << 0; - - //Generate RenderCommandID - _id = (int64_t)_viewport << 61 - | (int64_t)1 << 60 //translucent - | (int64_t)_depth << 36; - - return _id; + _materialID = (uint32_t)_shader->getProgram() << 22 + | (uint32_t)blendID << 18 + | (uint32_t)_textureID << 0; } void QuadCommand::useMaterial() diff --git a/cocos/2d/renderer/CCQuadCommand.h b/cocos/2d/renderer/CCQuadCommand.h index 1837919c8d..e6bb2059b3 100644 --- a/cocos/2d/renderer/CCQuadCommand.h +++ b/cocos/2d/renderer/CCQuadCommand.h @@ -41,21 +41,15 @@ public: QuadCommand(); ~QuadCommand(); - void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, + void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, const kmMat4& mv); - // +----------+----------+-----+-----------------------------------+ - // | | | | | | - // | ViewPort | Transluc | | Depth | Material ID | - // | 3 bits | 1 bit | | 24 bits | 24 bit2 | - // +----------+----------+-----+----------------+------------------+ - virtual int64_t generateID(); - void useMaterial(); //TODO use material to decide if it is translucent inline bool isTranslucent() const { return true; } + void generateMaterialID(); inline uint32_t getMaterialID() const { return _materialID; } inline GLuint getTextureID() const { return _textureID; } @@ -73,12 +67,6 @@ public: protected: uint32_t _materialID; - //Key Data - int _viewport; /// Which view port it belongs to - - //TODO use material to determine if it's translucent - int32_t _depth; - //Maternal GLuint _textureID; diff --git a/cocos/2d/renderer/CCRenderCommand.cpp b/cocos/2d/renderer/CCRenderCommand.cpp index 71fee4edb0..64157b4739 100644 --- a/cocos/2d/renderer/CCRenderCommand.cpp +++ b/cocos/2d/renderer/CCRenderCommand.cpp @@ -28,9 +28,9 @@ NS_CC_BEGIN RenderCommand::RenderCommand() +: _type(RenderCommand::Type::UNKNOWN_COMMAND) +, _depth(0) { - _id = 0; - _type = RenderCommand::Type::UNKNOWN_COMMAND; } RenderCommand::~RenderCommand() @@ -57,9 +57,7 @@ void printBits(ssize_t const size, void const * const ptr) void RenderCommand::printID() { - printf("CommandID: "); - printBits(sizeof(_id), &_id); - printf("\n"); + printf("Command Depth: %f\n", _depth); } NS_CC_END \ No newline at end of file diff --git a/cocos/2d/renderer/CCRenderCommand.h b/cocos/2d/renderer/CCRenderCommand.h index 57fa2e75ce..9035454bc2 100644 --- a/cocos/2d/renderer/CCRenderCommand.h +++ b/cocos/2d/renderer/CCRenderCommand.h @@ -33,7 +33,9 @@ NS_CC_BEGIN -//TODO make RenderCommand inherent from Object +/** Base class of the RenderCommand hierarchy. + The Renderer knows how to render RenderCommands. + */ class RenderCommand { public: @@ -47,10 +49,8 @@ public: GROUP_COMMAND, }; - virtual int64_t generateID() = 0; - /** Get Render Command Id */ - inline int64_t getID() { return _id; } + inline float getDepth() { return _depth; } /** Returns the Command type */ inline Type getType() { return _type; } @@ -61,9 +61,11 @@ protected: void printID(); - //Generated IDs - int64_t _id; /// used for sorting render commands + // Type used in order to avoid dynamic cast, faster Type _type; + + // commands are sort by depth + float _depth; }; NS_CC_END diff --git a/cocos/2d/renderer/CCRenderer.cpp b/cocos/2d/renderer/CCRenderer.cpp index df7d41473a..5b56fc80cd 100644 --- a/cocos/2d/renderer/CCRenderer.cpp +++ b/cocos/2d/renderer/CCRenderer.cpp @@ -185,8 +185,6 @@ void Renderer::addCommand(RenderCommand* command, int renderQueue) { CCASSERT(renderQueue >=0, "Invalid render queue"); CCASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type"); - - command->generateID(); _renderGroups[renderQueue].push_back(command); } @@ -209,7 +207,7 @@ int Renderer::createRenderQueue() bool compareRenderCommand(RenderCommand* a, RenderCommand* b) { - return a->getID() < b->getID(); + return a->getDepth() < b->getDepth(); } void Renderer::render() diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 634630ec64..20f034c35b 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -156,7 +156,7 @@ void BatchNode::draw() void BatchNode::generateGroupCommand() { Renderer* renderer = Director::getInstance()->getRenderer(); - _groupCommand->init(0,_vertexZ); + _groupCommand->init(_vertexZ); renderer->addCommand(_groupCommand); renderer->pushGroup(_groupCommand->getRenderQueueID()); diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index da98e5a736..1da40694f7 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -225,7 +225,7 @@ void Skin::draw() kmGLGetMatrix(KM_GL_MODELVIEW, &mv); //TODO implement z order - _quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); + _quadCommand.init(_vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index 9051679a98..c224e38d4e 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -131,7 +131,7 @@ void Skeleton::draw() kmGLMatrixMode(KM_GL_MODELVIEW); kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix); - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 38c73c5a65..691fb212a2 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -210,18 +210,18 @@ void Layout::stencilClippingVisit() Renderer* renderer = Director::getInstance()->getRenderer(); - _groupCommand.init(0,_vertexZ); + _groupCommand.init(_vertexZ); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - _beforeVisitCmdStencil.init(0,_vertexZ); + _beforeVisitCmdStencil.init(_vertexZ); _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this); renderer->addCommand(&_beforeVisitCmdStencil); _clippingStencil->visit(); - _afterDrawStencilCmd.init(0,_vertexZ); + _afterDrawStencilCmd.init(_vertexZ); _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this); renderer->addCommand(&_afterDrawStencilCmd); @@ -251,7 +251,7 @@ void Layout::stencilClippingVisit() this->draw(); } - _afterVisitCmdStencil.init(0,_vertexZ); + _afterVisitCmdStencil.init(_vertexZ); _afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this); renderer->addCommand(&_afterVisitCmdStencil); @@ -336,13 +336,13 @@ void Layout::scissorClippingVisit() { Renderer* renderer = Director::getInstance()->getRenderer(); - _beforeVisitCmdScissor.init(0, _vertexZ); + _beforeVisitCmdScissor.init(_vertexZ); _beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this); renderer->addCommand(&_beforeVisitCmdScissor); Node::visit(); - _afterVisitCmdScissor.init(0, _vertexZ); + _afterVisitCmdScissor.init(_vertexZ); _afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this); renderer->addCommand(&_afterVisitCmdScissor); } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index e1c21ce3a6..bf7e667cc2 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -494,7 +494,7 @@ void ScrollView::addChild(Node * child, int zOrder, int tag) void ScrollView::beforeDraw() { - _beforeDrawCommand.init(0, _vertexZ); + _beforeDrawCommand.init(_vertexZ); _beforeDrawCommand.func = CC_CALLBACK_0(ScrollView::onBeforeDraw, this); Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand); } @@ -529,7 +529,7 @@ void ScrollView::onBeforeDraw() void ScrollView::afterDraw() { - _afterDrawCommand.init(0, _vertexZ); + _afterDrawCommand.init(_vertexZ); _afterDrawCommand.func = CC_CALLBACK_0(ScrollView::onAfterDraw, this); Director::getInstance()->getRenderer()->addCommand(&_afterDrawCommand); } diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp index fa40b74f0a..1fea5ffa2a 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -1314,7 +1314,7 @@ void ActionFollow::onEnter() void ActionFollow::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); @@ -1630,7 +1630,7 @@ void ActionCatmullRomStacked::draw() kmGLPopMatrix(); kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2); - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -1745,7 +1745,7 @@ void ActionCardinalSplineStacked::draw() kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2); kmGLPopMatrix(); - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -2107,7 +2107,7 @@ void ActionCatmullRom::draw() kmGLPopMatrix(); kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2); - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -2207,7 +2207,7 @@ void ActionCardinalSpline::draw() kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2); kmGLPopMatrix(); - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp index dd8d3f8693..ed1e08da29 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp @@ -211,7 +211,7 @@ void Box2DView::draw() { Layer::draw(); - _customCmd.init(0, _vertexZ); + _customCmd.init(_vertexZ); _customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCmd); } diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 68a584d577..b73c205be3 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -611,7 +611,7 @@ void RawStencilBufferTest::draw() auto iter = _renderCmds.begin(); - iter->init(0, _vertexZ); + iter->init(_vertexZ); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this); renderer->addCommand(&(*iter)); ++iter; @@ -628,7 +628,7 @@ void RawStencilBufferTest::draw() spritePoint.y = 0; _sprites.at(i)->setPosition( spritePoint ); - iter->init(0, _vertexZ); + iter->init(_vertexZ); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint); renderer->addCommand(&(*iter)); ++iter; @@ -638,7 +638,7 @@ void RawStencilBufferTest::draw() _sprites.at(i)->visit(); kmGLPopMatrix(); - iter->init(0, _vertexZ); + iter->init(_vertexZ); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i, winPoint); renderer->addCommand(&(*iter)); ++iter; @@ -649,7 +649,7 @@ void RawStencilBufferTest::draw() kmGLPopMatrix(); } - iter->init(0, _vertexZ); + iter->init(_vertexZ); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this); renderer->addCommand(&(*iter)); diff --git a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 61aa2aa0b2..0e693d640a 100644 --- a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -116,7 +116,7 @@ DrawPrimitivesTest::DrawPrimitivesTest() void DrawPrimitivesTest::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index fdf76c80a0..8e2a0119e4 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -1067,7 +1067,7 @@ void TestColliderDetector::update(float delta) } void TestColliderDetector::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -1108,7 +1108,7 @@ std::string TestBoundingBox::title() const } void TestBoundingBox::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index d85049bc94..af89de176c 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -210,7 +210,7 @@ void Atlas1::draw() // GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // GL_TEXTURE_2D - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); @@ -526,7 +526,7 @@ Atlas4::Atlas4() void Atlas4::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -1612,7 +1612,7 @@ std::string LabelBMFontBounds::subtitle() const void LabelBMFontBounds::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp index 604ff0cb8b..91be90098d 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp @@ -302,7 +302,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() void LabelFNTSpriteActions::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_vertexZ); _renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); @@ -912,7 +912,7 @@ std::string LabelFNTBounds::subtitle() const void LabelFNTBounds::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_vertexZ); _renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); } diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp index 4d69c14542..a0c70d62b5 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp @@ -932,7 +932,7 @@ protected: void MySprite::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 9a18f256be..a90ce6aebc 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -470,19 +470,19 @@ RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil() void RenderTextureTestDepthStencil::draw() { - _renderCmds[0].init(0, _vertexZ); + _renderCmds[0].init(_vertexZ); _renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmds[0]); _rend->beginWithClear(0, 0, 0, 0, 0, 0); - _renderCmds[1].init(0, _vertexZ); + _renderCmds[1].init(_vertexZ); _renderCmds[1].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmds[1]); _spriteDS->visit(); - _renderCmds[2].init(0, _vertexZ); + _renderCmds[2].init(_vertexZ); _renderCmds[2].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmds[2]); @@ -490,7 +490,7 @@ void RenderTextureTestDepthStencil::draw() _rend->end(); - _renderCmds[3].init(0, _vertexZ); + _renderCmds[3].init(_vertexZ); _renderCmds[3].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmds[3]); @@ -638,7 +638,7 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea void SpriteRenderTextureBug::SimpleSprite::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp index ba6c1f01c1..087644545e 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -193,7 +193,7 @@ void ShaderNode::setPosition(const Point &newPosition) void ShaderNode::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -526,7 +526,7 @@ void SpriteBlur::initProgram() void SpriteBlur::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_vertexZ); _customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp index 569bef3915..1d76e56892 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp @@ -178,7 +178,7 @@ void ShaderSprite::initShader() void ShaderSprite::draw() { - _renderCommand.init(0, _vertexZ); + _renderCommand.init(_vertexZ); _renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCommand); diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index a3f4a7d564..3324802c9d 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -1794,7 +1794,7 @@ void TextureDrawAtPoint::draw() { TextureDemo::draw(); - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_vertexZ); _renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); @@ -1835,7 +1835,7 @@ void TextureDrawInRect::draw() { TextureDemo::draw(); - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_vertexZ); _renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); diff --git a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp index 75f0fd6eee..68f3cd5d59 100644 --- a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp @@ -599,7 +599,7 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest() void TMXOrthoObjectsTest::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_vertexZ); _renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); } @@ -672,7 +672,7 @@ TMXIsoObjectsTest::TMXIsoObjectsTest() void TMXIsoObjectsTest::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_vertexZ); _renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); } @@ -1504,7 +1504,7 @@ TMXGIDObjectsTest::TMXGIDObjectsTest() void TMXGIDObjectsTest::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_vertexZ); _renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); }