From 7feb3f299fb559cc1e93c5add2618cd4edc0f583 Mon Sep 17 00:00:00 2001 From: coulsonwang Date: Mon, 31 Aug 2020 16:37:46 +0800 Subject: [PATCH 1/5] fix pipeline binding --- native/CMakeLists.txt | 2 + .../renderer/core/gfx/GFXDescriptorSet.cc | 9 + .../renderer/gfx-metal/MTLPipelineLayout.mm | 1 + native/cocos/renderer/gfx-metal/MTLSampler.mm | 2 +- native/cocos/renderer/pipeline/RenderView.cpp | 5 +- native/cocos/renderer/pipeline/RenderView.h | 4 +- .../pipeline/forward/ForwardPipeline.cpp | 7 +- .../renderer/pipeline/shadow/ShadowFlow.cpp | 1 + native/cocos/scripting/dop/jsb_dop.cpp | 5 +- .../js-bindings/auto/jsb_pipeline_auto.cpp | 7 +- .../manual/jsb_module_register.cpp | 59 +++---- .../manual/jsb_pipeline_manual.cpp | 157 ++++++++++++++++++ .../js-bindings/manual/jsb_pipeline_manual.h | 6 + 13 files changed, 219 insertions(+), 46 deletions(-) create mode 100644 native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp create mode 100644 native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.h diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index 73b4692046..89a3645a2c 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -828,6 +828,8 @@ cocos_source_files( cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.h cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.cpp cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.h + cocos/scripting/js-bindings/manual/jsb_pipeline_manual.h + cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp ) if(USE_SOCKET) diff --git a/native/cocos/renderer/core/gfx/GFXDescriptorSet.cc b/native/cocos/renderer/core/gfx/GFXDescriptorSet.cc index d65018f81b..0ab2ddb225 100644 --- a/native/cocos/renderer/core/gfx/GFXDescriptorSet.cc +++ b/native/cocos/renderer/core/gfx/GFXDescriptorSet.cc @@ -13,6 +13,9 @@ DescriptorSet::~DescriptorSet() { } void DescriptorSet::bindBuffer(uint binding, Buffer *buffer) { + if (!_layout->getBindings().size()) { + return;; + } const DescriptorSetLayoutBinding &descriptor = _layout->getBindings()[binding]; if ((uint)descriptor.descriptorType & DESCRIPTOR_BUFFER_TYPE) { if (_buffers[binding] != buffer) { @@ -25,6 +28,9 @@ void DescriptorSet::bindBuffer(uint binding, Buffer *buffer) { } void DescriptorSet::bindTexture(uint binding, Texture *texture) { + if (!_layout->getBindings().size()) { + return; + } const DescriptorSetLayoutBinding &descriptor = _layout->getBindings()[binding]; if ((uint)descriptor.descriptorType & DESCRIPTOR_SAMPLER_TYPE) { if (_textures[binding] != texture) { @@ -37,6 +43,9 @@ void DescriptorSet::bindTexture(uint binding, Texture *texture) { } void DescriptorSet::bindSampler(uint binding, Sampler *sampler) { + if(!_layout->getBindings().size()) { + return; + } const DescriptorSetLayoutBinding &descriptor = _layout->getBindings()[binding]; if ((uint)descriptor.descriptorType & DESCRIPTOR_SAMPLER_TYPE) { if (_samplers[binding] != sampler) { diff --git a/native/cocos/renderer/gfx-metal/MTLPipelineLayout.mm b/native/cocos/renderer/gfx-metal/MTLPipelineLayout.mm index 4b07bcd8ab..823ebf90ae 100644 --- a/native/cocos/renderer/gfx-metal/MTLPipelineLayout.mm +++ b/native/cocos/renderer/gfx-metal/MTLPipelineLayout.mm @@ -20,6 +20,7 @@ bool CCMTLPipelineLayout::initialize(const PipelineLayoutInfo &info) { uint i = 0; for (auto setLayout : _setLayouts) { + if(setLayout == nullptr) continue; auto gpuDescriptorSetLayout = static_cast(setLayout)->gpuDescriptorSetLayout(); auto dynamicCount = gpuDescriptorSetLayout->dynamicBindings.size(); auto bindingCount = gpuDescriptorSetLayout->bindings.size(); diff --git a/native/cocos/renderer/gfx-metal/MTLSampler.mm b/native/cocos/renderer/gfx-metal/MTLSampler.mm index 44ab71ac6f..21dfb14e60 100644 --- a/native/cocos/renderer/gfx-metal/MTLSampler.mm +++ b/native/cocos/renderer/gfx-metal/MTLSampler.mm @@ -35,7 +35,7 @@ bool CCMTLSampler::initialize(const SamplerInfo &info) { descriptor.minFilter = mu::toMTLSamplerMinMagFilter(_minFilter); descriptor.magFilter = mu::toMTLSamplerMinMagFilter(_magFilter); descriptor.mipFilter = mu::toMTLSamplerMipFilter(_mipFilter); - descriptor.maxAnisotropy = _maxAnisotropy; + descriptor.maxAnisotropy = _maxAnisotropy == 0 ? 1 : _maxAnisotropy; descriptor.compareFunction = mu::toMTLCompareFunction(_cmpFunc); descriptor.lodMinClamp = _minLOD; descriptor.lodMaxClamp = _maxLOD; diff --git a/native/cocos/renderer/pipeline/RenderView.cpp b/native/cocos/renderer/pipeline/RenderView.cpp index ce75b54d84..99ea312c8e 100644 --- a/native/cocos/renderer/pipeline/RenderView.cpp +++ b/native/cocos/renderer/pipeline/RenderView.cpp @@ -6,8 +6,7 @@ namespace cc { namespace pipeline { -RenderView::RenderView(uint cameraID) -: _camera(GET_CAMERA(cameraID)) { +RenderView::RenderView() { _pipeline = RenderPipeline::getInstance(); } @@ -16,9 +15,11 @@ RenderView::~RenderView() { } bool RenderView::initialize(const RenderViewInfo &info) { + _name = info.name; _priority = info.priority; setExecuteFlows(info.flows); + _camera = GET_CAMERA(info.cameraID); return true; } diff --git a/native/cocos/renderer/pipeline/RenderView.h b/native/cocos/renderer/pipeline/RenderView.h index 3a36ec62cf..277085ba65 100644 --- a/native/cocos/renderer/pipeline/RenderView.h +++ b/native/cocos/renderer/pipeline/RenderView.h @@ -18,7 +18,7 @@ struct CC_DLL RenderViewInfo { class CC_DLL RenderView : public Object { public: - RenderView(uint cameraID); + RenderView(); virtual ~RenderView(); void destroy(); @@ -42,7 +42,7 @@ public: // setWindow private: - RenderView() = default; +// RenderView() = default; private: RenderFlowList _flows; diff --git a/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp b/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp index dbb5008754..f2d264d55d 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp +++ b/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp @@ -72,9 +72,10 @@ bool ForwardPipeline::initialize(const RenderPipelineInfo &info) { RenderPipeline::initialize(info); if (_flows.size() == 0) { - auto shadowFlow = CC_NEW(ShadowFlow); - shadowFlow->initialize(ShadowFlow::getInitializeInfo()); - _flows.emplace_back(shadowFlow); + //TODO coulsonwang +// auto shadowFlow = CC_NEW(ShadowFlow); +// shadowFlow->initialize(ShadowFlow::getInitializeInfo()); +// _flows.emplace_back(shadowFlow); auto forwardFlow = CC_NEW(ForwardFlow); forwardFlow->initialize(ForwardFlow::getInitializeInfo()); diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp index 02768f567d..9d5e96c4c9 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp +++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp @@ -37,6 +37,7 @@ bool ShadowFlow::initialize(const RenderFlowInfo &info) { } void ShadowFlow::activate(RenderPipeline *pipeline) { + return; //TODO coulsonwang RenderFlow::activate(pipeline); auto device = gfx::Device::getInstance(); diff --git a/native/cocos/scripting/dop/jsb_dop.cpp b/native/cocos/scripting/dop/jsb_dop.cpp index d6af87c68e..c22e0da4ee 100644 --- a/native/cocos/scripting/dop/jsb_dop.cpp +++ b/native/cocos/scripting/dop/jsb_dop.cpp @@ -224,17 +224,16 @@ static bool jsb_ArrayPool_alloc(se::State &s) { s.rval().setObject(arrayPool->alloc(index)); return true; } - + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); return false; - } SE_BIND_FUNC(jsb_ArrayPool_alloc); static bool js_register_se_ArrayPool(se::Object *obj) { se::Class *cls = se::Class::create("NativeArrayPool", obj, nullptr, _SE(jsb_ArrayPool_constructor)); cls->defineFunction("resize", _SE(jsb_ArrayPool_resize)); - cls->defineFunction("getAlloc", _SE(jsb_ArrayPool_alloc)); + cls->defineFunction("alloc", _SE(jsb_ArrayPool_alloc)); cls->install(); JSBClassType::registerClass(cls); diff --git a/native/cocos/scripting/js-bindings/auto/jsb_pipeline_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_pipeline_auto.cpp index 15a73cc129..67d126164a 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_pipeline_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_pipeline_auto.cpp @@ -1851,12 +1851,7 @@ SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_RenderView_finalize) static bool js_pipeline_RenderView_constructor(se::State& s) { - CC_UNUSED bool ok = true; - const auto& args = s.args(); - unsigned int arg0 = 0; - ok &= seval_to_uint32(args[0], (uint32_t*)&arg0); - SE_PRECONDITION2(ok, false, "js_pipeline_RenderView_constructor : Error processing arguments"); - cc::pipeline::RenderView* cobj = JSB_ALLOC(cc::pipeline::RenderView, arg0); + cc::pipeline::RenderView* cobj = JSB_ALLOC(cc::pipeline::RenderView); s.thisObject()->setPrivateData(cobj); se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); return true; diff --git a/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp b/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp index 1bba9c8dd4..d560692006 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp @@ -25,63 +25,63 @@ #include "cocos2d.h" -#include "cocos/scripting/js-bindings/manual/jsb_module_register.h" #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" +#include "cocos/scripting/js-bindings/manual/jsb_module_register.h" #include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.h" -#include "cocos/scripting/js-bindings/manual/jsb_global.h" -#include "cocos/scripting/js-bindings/manual/jsb_conversions.h" -#include "cocos/scripting/js-bindings/manual/jsb_platform.h" -#include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.h" -#include "cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.h" -#include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.h" -#include "cocos/scripting/js-bindings/manual/jsb_gfx_manual.h" #include "cocos/scripting/dop/jsb_dop.h" -#include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.h" -#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.h" #include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.h" +#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.h" +#include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.h" #include "cocos/scripting/js-bindings/auto/jsb_pipeline_auto.h" +#include "cocos/scripting/js-bindings/auto/jsb_pipeline_manual.h" +#include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.h" +#include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.h" +#include "cocos/scripting/js-bindings/manual/jsb_conversions.h" +#include "cocos/scripting/js-bindings/manual/jsb_gfx_manual.h" +#include "cocos/scripting/js-bindings/manual/jsb_global.h" +#include "cocos/scripting/js-bindings/manual/jsb_platform.h" +#include "cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.h" #if USE_GFX_RENDERER #endif #if USE_SOCKET -#include "cocos/scripting/js-bindings/manual/jsb_websocket.h" -#include "cocos/scripting/js-bindings/manual/jsb_socketio.h" + #include "cocos/scripting/js-bindings/manual/jsb_socketio.h" + #include "cocos/scripting/js-bindings/manual/jsb_websocket.h" #endif // USE_SOCKET #if USE_AUDIO -#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.h" + #include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.h" #endif #if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_MAC_OSX) -#include "cocos/scripting/js-bindings/manual/JavaScriptObjCBridge.h" + #include "cocos/scripting/js-bindings/manual/JavaScriptObjCBridge.h" #endif #if (CC_PLATFORM == CC_PLATFORM_ANDROID) -#include "cocos/scripting/js-bindings/manual/JavaScriptJavaBridge.h" + #include "cocos/scripting/js-bindings/manual/JavaScriptJavaBridge.h" #endif #if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID) -#if USE_VIDEO -#include "cocos/scripting/js-bindings/auto/jsb_video_auto.h" -#endif + #if USE_VIDEO + #include "cocos/scripting/js-bindings/auto/jsb_video_auto.h" + #endif #endif // (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID) using namespace cc; -bool jsb_register_all_modules() -{ - se::ScriptEngine* se = se::ScriptEngine::getInstance(); +bool jsb_register_all_modules() { + se::ScriptEngine *se = se::ScriptEngine::getInstance(); - se->addBeforeInitHook([](){ + se->addBeforeInitHook([]() { JSBClassType::init(); }); - se->addBeforeCleanupHook([se](){ + se->addBeforeCleanupHook([se]() { se->garbageCollect(); PoolManager::getInstance()->getCurrentPool()->clear(); se->garbageCollect(); @@ -94,7 +94,7 @@ bool jsb_register_all_modules() se->addRegisterCallback(register_platform_bindings); se->addRegisterCallback(register_all_gfx); se->addRegisterCallback(register_all_gfx_manual); - + se->addRegisterCallback(register_all_network); se->addRegisterCallback(register_all_cocos2dx_network_manual); se->addRegisterCallback(register_all_xmlhttprequest); @@ -102,6 +102,7 @@ bool jsb_register_all_modules() se->addRegisterCallback(register_all_extension); se->addRegisterCallback(register_all_dop_bindings); se->addRegisterCallback(register_all_pipeline); + se->addRegisterCallback(register_all_pipeline_manual); #if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_MAC_OSX) se->addRegisterCallback(register_javascript_objc_bridge); @@ -114,7 +115,7 @@ bool jsb_register_all_modules() #if USE_AUDIO se->addRegisterCallback(register_all_audioengine); #endif - + #if USE_SOCKET se->addRegisterCallback(register_all_websocket); se->addRegisterCallback(register_all_socketio); @@ -122,13 +123,13 @@ bool jsb_register_all_modules() #if (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID) -#if USE_VIDEO -// se->addRegisterCallback(register_all_video); -#endif + #if USE_VIDEO + // se->addRegisterCallback(register_all_video); + #endif #endif // (CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_ANDROID) - se->addAfterCleanupHook([](){ + se->addAfterCleanupHook([]() { PoolManager::getInstance()->getCurrentPool()->clear(); JSBClassType::destroy(); }); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp new file mode 100644 index 0000000000..03ebf2521f --- /dev/null +++ b/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp @@ -0,0 +1,157 @@ +#include "jsb_gfx_manual.h" +#include "scripting/js-bindings/auto/jsb_pipeline_auto.h" +#include "scripting/js-bindings/jswrapper/SeApi.h" +#include "scripting/js-bindings/manual/jsb_conversions.h" +#include "scripting/js-bindings/manual/jsb_global.h" + +#include "renderer/pipeline/Define.h" +#include "renderer/pipeline/RenderFlow.h" +#include "renderer/pipeline/RenderPipeline.h" +#include "renderer/pipeline/RenderStage.h" +#include "renderer/pipeline/RenderView.h" +#include "renderer/pipeline/forward/ForwardFlow.h" +#include "renderer/pipeline/forward/ForwardPipeline.h" +#include "renderer/pipeline/forward/ForwardStage.h" +#include "renderer/pipeline/shadow/ShadowFlow.h" +#include "renderer/pipeline/shadow/ShadowStage.h" +#include "renderer/pipeline/ui/UIFlow.h" +#include "renderer/pipeline/ui/UIStage.h" +#include "scripting/js-bindings/manual/jsb_conversions.h" +#include "scripting/js-bindings/manual/jsb_global.h" + +se::Object *__jsb_cc_pipeline_RenderViewInfo_proto = nullptr; +se::Class *__jsb_cc_pipeline_RenderViewInfo_class = nullptr; + +SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_RenderViewInfo_finalize) + +static bool js_pipeline_RenderViewInfo_constructor(se::State &s) { + CC_UNUSED bool ok = true; + const auto &args = s.args(); + size_t argc = args.size(); + + if (argc == 0) { + cc::pipeline::RenderViewInfo *cobj = JSB_ALLOC(cc::pipeline::RenderViewInfo); + s.thisObject()->setPrivateData(cobj); + se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + return true; + } else if (argc == 1 && args[0].isObject()) { + se::Object *json = args[0].toObject(); + se::Value field; + + cc::pipeline::RenderViewInfo *cobj = JSB_ALLOC(cc::pipeline::RenderViewInfo); + unsigned int arg0 = 0; + json->getProperty("cameraID", &field); + if (!field.isUndefined()) { + ok &= seval_to_uint32(field, (uint32_t *)&arg0); + cobj->cameraID = arg0; + } + cc::String arg1; + json->getProperty("name", &field); + if (!field.isUndefined()) { + arg1 = field.toStringForce().c_str(); + cobj->name = arg1; + } + unsigned int arg2 = 0; + json->getProperty("priority", &field); + if (!field.isUndefined()) { + ok &= seval_to_uint32(field, (uint32_t *)&arg2); + cobj->priority = arg2; + } + std::vector arg3; + json->getProperty("flows", &field); + if (!field.isUndefined()) { + ok &= seval_to_std_vector_string(field, &arg3); + cobj->flows = arg3; + } + + if (!ok) { + JSB_FREE(cobj); + SE_REPORT_ERROR("argument convertion error"); + return false; + } + + s.thisObject()->setPrivateData(cobj); + se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + return true; + } else if (argc == 4) { + cc::pipeline::RenderViewInfo *cobj = JSB_ALLOC(cc::pipeline::RenderViewInfo); + unsigned int arg0 = 0; + if (!args[0].isUndefined()) { + ok &= seval_to_uint32(args[0], (uint32_t *)&arg0); + cobj->cameraID = arg0; + } + cc::String arg1; + if (!args[1].isUndefined()) { + arg1 = args[1].toStringForce().c_str(); + cobj->name = arg1; + } + unsigned int arg2 = 0; + if (!args[2].isUndefined()) { + ok &= seval_to_uint32(args[2], (uint32_t *)&arg2); + cobj->priority = arg2; + } + std::vector arg3; + if (!args[3].isUndefined()) { + ok &= seval_to_std_vector_string(args[3], &arg3); + cobj->flows = arg3; + } + + if (!ok) { + JSB_FREE(cobj); + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + + s.thisObject()->setPrivateData(cobj); + se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + return true; + } + + SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); + return false; +} +SE_BIND_CTOR(js_pipeline_RenderViewInfo_constructor, __jsb_cc_pipeline_RenderViewInfo_class, js_cc_pipeline_RenderViewInfo_finalize) + +static bool js_cc_pipeline_RenderViewInfo_finalize(se::State &s) { + auto iter = se::NonRefNativePtrCreatedByCtorMap::find(s.nativeThisObject()); + if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) { + se::NonRefNativePtrCreatedByCtorMap::erase(iter); + cc::pipeline::RenderViewInfo *cobj = (cc::pipeline::RenderViewInfo *)s.nativeThisObject(); + JSB_FREE(cobj); + } + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderViewInfo_finalize) + +bool js_register_pipeline_RenderViewInfo(se::Object *obj) { + auto cls = se::Class::create("RenderViewInfo", obj, nullptr, _SE(js_pipeline_RenderViewInfo_constructor)); + + // cls->defineProperty("cameraID", _SE(js_pipeline_RenderViewInfo_get_cameraID), _SE(js_pipeline_RenderViewInfo_set_cameraID)); + // cls->defineProperty("name", _SE(js_pipeline_RenderViewInfo_get_name), _SE(js_pipeline_RenderViewInfo_set_name)); + // cls->defineProperty("priority", _SE(js_pipeline_RenderViewInfo_get_priority), _SE(js_pipeline_RenderViewInfo_set_priority)); + // cls->defineProperty("flows", _SE(js_pipeline_RenderViewInfo_get_flows), _SE(js_pipeline_RenderViewInfo_set_flows)); + cls->defineFinalizeFunction(_SE(js_cc_pipeline_RenderViewInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_RenderViewInfo_proto = cls->getProto(); + __jsb_cc_pipeline_RenderViewInfo_class = cls; + + se::ScriptEngine::getInstance()->clearException(); + return true; +} + +bool register_all_pipeline_manual(se::Object *obj) { + // Get the ns + se::Value nsVal; + if (!obj->getProperty("nr", &nsVal)) { + se::HandleObject jsobj(se::Object::createPlainObject()); + nsVal.setObject(jsobj); + obj->setProperty("nr", nsVal); + } + se::Object *ns = nsVal.toObject(); + + js_register_pipeline_RenderViewInfo(ns); + + return true; +} diff --git a/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.h b/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.h new file mode 100644 index 0000000000..d122b7d5cb --- /dev/null +++ b/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.h @@ -0,0 +1,6 @@ +#pragma once + +namespace se { +class Object; +} +bool register_all_pipeline_manual(se::Object *obj); \ No newline at end of file From fc55b393118ae6b6684b4bf982e813fe4fab630a Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 31 Aug 2020 17:43:06 +0800 Subject: [PATCH 2/5] fix binding issue --- native/cocos/renderer/pipeline/helper/SharedMemory.h | 2 +- .../js-bindings/manual/jsb_module_register.cpp | 2 +- native/tools/tojs/cocos2dx_pipeline.ini | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/native/cocos/renderer/pipeline/helper/SharedMemory.h b/native/cocos/renderer/pipeline/helper/SharedMemory.h index 8b29dc9d7f..1ade7ca1bf 100644 --- a/native/cocos/renderer/pipeline/helper/SharedMemory.h +++ b/native/cocos/renderer/pipeline/helper/SharedMemory.h @@ -1,5 +1,5 @@ #pragma once -#include "core/CoreStd.h" +#include "renderer/core/CoreStd.h" #include "math/Vec2.h" #include "math/Vec3.h" #include "scripting/dop/ArrayPool.h" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp b/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp index d560692006..c61eda890e 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp @@ -35,7 +35,7 @@ #include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.h" #include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.h" #include "cocos/scripting/js-bindings/auto/jsb_pipeline_auto.h" -#include "cocos/scripting/js-bindings/auto/jsb_pipeline_manual.h" +#include "cocos/scripting/js-bindings/manual/jsb_pipeline_manual.h" #include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.h" #include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.h" #include "cocos/scripting/js-bindings/manual/jsb_conversions.h" diff --git a/native/tools/tojs/cocos2dx_pipeline.ini b/native/tools/tojs/cocos2dx_pipeline.ini index 19ff20353e..273fc1935d 100644 --- a/native/tools/tojs/cocos2dx_pipeline.ini +++ b/native/tools/tojs/cocos2dx_pipeline.ini @@ -16,7 +16,7 @@ android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILIT clang_headers = clang_flags = -nostdinc -x c++ -std=c++14 -fsigned-char -U__SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/ios/include/v8 cocos_flags = -DANDROID -DCC_PLATFORM=3 -DCC_PLATFORM_MAC_IOS=1 -DCC_PLATFORM_MAC_OSX=4 -DCC_PLATFORM_WINDOWS=2 -DCC_PLATFORM_ANDROID=3 @@ -26,11 +26,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardPipeline.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardFlow.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardStage.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowFlow.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowStage.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIFlow.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIStage.h %(cocosdir)s/cocos/renderer/pipeline/RenderPipeline.h %(cocosdir)s/cocos/renderer/pipeline/RenderFlow.h %(cocosdir)s/cocos/renderer/pipeline/RenderStage.h %(cocosdir)s/cocos/renderer/pipeline/Define.h %(cocosdir)s/cocos/renderer/pipeline/RenderView.h +headers = %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardPipeline.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardFlow.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardStage.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowFlow.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowStage.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIFlow.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIStage.h %(cocosdir)s/cocos/renderer/pipeline/RenderPipeline.h %(cocosdir)s/cocos/renderer/pipeline/RenderFlow.h %(cocosdir)s/cocos/renderer/pipeline/RenderStage.h %(cocosdir)s/cocos/renderer/pipeline/Define.h %(cocosdir)s/cocos/renderer/pipeline/RenderView.h %(cocosdir)s/cocos/renderer/pipeline/helper/SharedMemory.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = RenderPipeline ForwardPipeline ForwardFlow ForwardStage ShadowFlow ShadowStage UIFlow UIStage RenderView RenderPipelineInfo RenderFlowInfo RenderStageInfo RenderQueueDesc RenderFlow RenderStage +classes = RenderPipeline ForwardPipeline ForwardFlow ForwardStage ShadowFlow ShadowStage UIFlow UIStage RenderView RenderPipelineInfo RenderFlowInfo RenderStageInfo RenderQueueDesc RenderFlow RenderStage ShadowMap # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -38,7 +38,7 @@ classes = RenderPipeline ForwardPipeline ForwardFlow ForwardStage ShadowFlow Sha # add a single "*" as functions. See bellow for several examples. A special class name is "*", which # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = ForwardPipeline::[updateUBOs setHDR getOrCreateRenderPass getLightsUBO getValidLights getLightBuffers getLightIndexOffsets getLightIndices getRenderObjects getShadowObjects getCommandBuffers getShadingScale getFpScale isHDR setRenderObjcts setShadowObjects getShadowMap], +skip = ForwardPipeline::[updateUBOs setHDR getOrCreateRenderPass getLightsUBO getValidLights getLightBuffers getLightIndexOffsets getLightIndices getRenderObjects getShadowObjects getCommandBuffers getShadingScale getFpScale isHDR setRenderObjcts setShadowObjects], RenderPipeline::[getFlows getTag getGlobalBindings getMacro getDescriptorSet], RenderFlow::[render destroy getPriority getName], RenderStage::[render destroy getPriority getName], @@ -52,6 +52,8 @@ skip = ForwardPipeline::[updateUBOs setHDR getOrCreateRenderPass getLightsUBO ge rename_functions = +getter_setter=ForwardPipeline::[shadowMap] + rename_classes = # for all class names, should we remove something when registering in the target VM? From c0bb7138a9c61b4a746ef6767d24b680be21cb1f Mon Sep 17 00:00:00 2001 From: coulsonwang Date: Tue, 1 Sep 2020 11:24:02 +0800 Subject: [PATCH 3/5] remove shadowmap binding --- native/tools/tojs/cocos2dx_pipeline.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/tools/tojs/cocos2dx_pipeline.ini b/native/tools/tojs/cocos2dx_pipeline.ini index 273fc1935d..a63c91b23e 100644 --- a/native/tools/tojs/cocos2dx_pipeline.ini +++ b/native/tools/tojs/cocos2dx_pipeline.ini @@ -26,11 +26,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardPipeline.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardFlow.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardStage.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowFlow.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowStage.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIFlow.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIStage.h %(cocosdir)s/cocos/renderer/pipeline/RenderPipeline.h %(cocosdir)s/cocos/renderer/pipeline/RenderFlow.h %(cocosdir)s/cocos/renderer/pipeline/RenderStage.h %(cocosdir)s/cocos/renderer/pipeline/Define.h %(cocosdir)s/cocos/renderer/pipeline/RenderView.h %(cocosdir)s/cocos/renderer/pipeline/helper/SharedMemory.h +headers = %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardPipeline.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardFlow.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardStage.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowFlow.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowStage.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIFlow.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIStage.h %(cocosdir)s/cocos/renderer/pipeline/RenderPipeline.h %(cocosdir)s/cocos/renderer/pipeline/RenderFlow.h %(cocosdir)s/cocos/renderer/pipeline/RenderStage.h %(cocosdir)s/cocos/renderer/pipeline/Define.h %(cocosdir)s/cocos/renderer/pipeline/RenderView.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = RenderPipeline ForwardPipeline ForwardFlow ForwardStage ShadowFlow ShadowStage UIFlow UIStage RenderView RenderPipelineInfo RenderFlowInfo RenderStageInfo RenderQueueDesc RenderFlow RenderStage ShadowMap +classes = RenderPipeline ForwardPipeline ForwardFlow ForwardStage ShadowFlow ShadowStage UIFlow UIStage RenderView RenderPipelineInfo RenderFlowInfo RenderStageInfo RenderQueueDesc RenderFlow RenderStage # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -52,7 +52,7 @@ skip = ForwardPipeline::[updateUBOs setHDR getOrCreateRenderPass getLightsUBO ge rename_functions = -getter_setter=ForwardPipeline::[shadowMap] +getter_setter= rename_classes = From 20b9ce2eb121694b39fff8b12454c90dc42bd388 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 1 Sep 2020 17:18:13 +0800 Subject: [PATCH 4/5] fix buffer pool logic --- native/cocos/scripting/dop/BufferPool.cpp | 22 +++++++++------------- native/cocos/scripting/dop/BufferPool.h | 3 +-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/native/cocos/scripting/dop/BufferPool.cpp b/native/cocos/scripting/dop/BufferPool.cpp index f792df2dd1..f733e1e22c 100644 --- a/native/cocos/scripting/dop/BufferPool.cpp +++ b/native/cocos/scripting/dop/BufferPool.cpp @@ -31,7 +31,7 @@ using namespace se; cc::map BufferPool::_poolMap; BufferPool::BufferPool(PoolType type, uint entryBits, uint bytesPerEntry) -: _entryBits(entryBits), _bytesPerEntry(bytesPerEntry) { +: _entryBits(entryBits), _bytesPerEntry(bytesPerEntry), _type(type) { CCASSERT(BufferPool::_poolMap.count(type) == 0, "The type of pool is already exist"); _entriesPerChunk = 1 << entryBits; @@ -44,23 +44,19 @@ BufferPool::BufferPool(PoolType type, uint entryBits, uint bytesPerEntry) } BufferPool::~BufferPool() { - CCASSERT(_chunks.size() == _jsObjs.size(), "BufferPool: Page count doesn't match the number of javascript array buffer objects."); - for (auto element : _jsObjs) { - CC_FREE(element.first); - element.second->decRef(); - element.second->unroot(); - } - BufferPool::_poolMap.erase(_type); } Object *BufferPool::allocateNewChunk() { Chunk chunk = (uint8_t *)CC_MALLOC(_bytesPerChunk); - _chunks.push_back(chunk); - Object *jsObj = Object::createArrayBufferObject(chunk, _bytesPerChunk); - jsObj->root(); - jsObj->incRef(); - _jsObjs.emplace(chunk, jsObj); + + uint8_t *realPtr = nullptr; + size_t len = 0; + jsObj->getArrayBufferData(&realPtr, &len); + _chunks.push_back(realPtr); + + CC_FREE(chunk); + return jsObj; } diff --git a/native/cocos/scripting/dop/BufferPool.h b/native/cocos/scripting/dop/BufferPool.h index 067cb7bc54..fed1072df7 100644 --- a/native/cocos/scripting/dop/BufferPool.h +++ b/native/cocos/scripting/dop/BufferPool.h @@ -55,7 +55,7 @@ public: uint chunk = (_chunkMask & id) >> _entryBits; uint entry = _entryMask & id; CCASSERT(chunk < _chunks.size() && entry < _entriesPerChunk, "BufferPool: Invalid buffer pool entry id"); - return reinterpret_cast(_chunks[chunk][entry]); + return reinterpret_cast(_chunks[chunk] + (entry * _bytesPerEntry)); } Object *allocateNewChunk(); @@ -64,7 +64,6 @@ private: static cc::map _poolMap; cc::vector _chunks; - cc::map _jsObjs; const uint _poolFlag = 1 << 30; uint _entryBits = 1 << 8; uint _chunkMask = 0; From 1b091e3f55c2fd9b571fed9ca98c5894eaf357b3 Mon Sep 17 00:00:00 2001 From: coulsonwang Date: Tue, 1 Sep 2020 14:22:15 +0800 Subject: [PATCH 5/5] add get macros binding --- .../cocos/renderer/pipeline/RenderPipeline.h | 5 +- native/cocos/renderer/pipeline/RenderView.cpp | 3 + native/cocos/renderer/pipeline/RenderView.h | 8 +- .../renderer/pipeline/helper/DefineMap.h | 4 +- .../manual/jsb_pipeline_manual.cpp | 84 +++++++++++++++++-- native/tools/tojs/cocos2dx_pipeline.ini | 12 +-- 6 files changed, 96 insertions(+), 20 deletions(-) diff --git a/native/cocos/renderer/pipeline/RenderPipeline.h b/native/cocos/renderer/pipeline/RenderPipeline.h index efdabd09ef..b93cca5d70 100644 --- a/native/cocos/renderer/pipeline/RenderPipeline.h +++ b/native/cocos/renderer/pipeline/RenderPipeline.h @@ -34,7 +34,10 @@ public: CC_INLINE const RenderFlowList &getFlows() const { return _flows; } CC_INLINE uint getTag() const { return _tag; } CC_INLINE const map &getGlobalBindings() const { return _globalBindings; } - CC_INLINE const DefineMap &getMacro() const { return _macros; } + CC_INLINE const ValueMap &getMacros() const { return _macros.getValues(); } + template + ENABLE_IF_T3_RET(float, bool, String) + CC_INLINE setValue(const String &name, const T &value) { _macros.setValue(name, value);} CC_INLINE gfx::DescriptorSet *getDescriptorSet() const { return _descriptorSet; } protected: diff --git a/native/cocos/renderer/pipeline/RenderView.cpp b/native/cocos/renderer/pipeline/RenderView.cpp index 99ea312c8e..d22b205ade 100644 --- a/native/cocos/renderer/pipeline/RenderView.cpp +++ b/native/cocos/renderer/pipeline/RenderView.cpp @@ -8,6 +8,9 @@ namespace cc { namespace pipeline { RenderView::RenderView() { _pipeline = RenderPipeline::getInstance(); + + //TODO coulsong for test + _window = CC_NEW(RenderWindow); } RenderView::~RenderView() { diff --git a/native/cocos/renderer/pipeline/RenderView.h b/native/cocos/renderer/pipeline/RenderView.h index 277085ba65..9b579e0f2f 100644 --- a/native/cocos/renderer/pipeline/RenderView.h +++ b/native/cocos/renderer/pipeline/RenderView.h @@ -34,16 +34,10 @@ public: CC_INLINE void setVisibility(uint value) { _visibility = value; } CC_INLINE Camera *getCamera() const { return _camera; } CC_INLINE bool isEnabled() const { return _isEnabled; } - CC_INLINE void enable(bool value) { _isEnabled = value; } + CC_INLINE void setEnable(bool value) { _isEnabled = value; } CC_INLINE const RenderFlowList &getFlows() const { return _flows; } CC_INLINE RenderWindow *getWindow() const { return _window; } - // getWindow - // setWindow - -private: -// RenderView() = default; - private: RenderFlowList _flows; String _name; diff --git a/native/cocos/renderer/pipeline/helper/DefineMap.h b/native/cocos/renderer/pipeline/helper/DefineMap.h index 7a4edc528a..da2bbe4e91 100644 --- a/native/cocos/renderer/pipeline/helper/DefineMap.h +++ b/native/cocos/renderer/pipeline/helper/DefineMap.h @@ -25,9 +25,11 @@ public: setValue(const String &name, const T &value) { _values[name] = value; } + + const ValueMap &getValues() const { return _values; } private: - map _values; + ValueMap _values; }; } // namespace pipeline diff --git a/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp index 03ebf2521f..4d31aec0b1 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_pipeline_manual.cpp @@ -126,10 +126,6 @@ SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderViewInfo_finalize) bool js_register_pipeline_RenderViewInfo(se::Object *obj) { auto cls = se::Class::create("RenderViewInfo", obj, nullptr, _SE(js_pipeline_RenderViewInfo_constructor)); - // cls->defineProperty("cameraID", _SE(js_pipeline_RenderViewInfo_get_cameraID), _SE(js_pipeline_RenderViewInfo_set_cameraID)); - // cls->defineProperty("name", _SE(js_pipeline_RenderViewInfo_get_name), _SE(js_pipeline_RenderViewInfo_set_name)); - // cls->defineProperty("priority", _SE(js_pipeline_RenderViewInfo_get_priority), _SE(js_pipeline_RenderViewInfo_set_priority)); - // cls->defineProperty("flows", _SE(js_pipeline_RenderViewInfo_get_flows), _SE(js_pipeline_RenderViewInfo_set_flows)); cls->defineFinalizeFunction(_SE(js_cc_pipeline_RenderViewInfo_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -141,6 +137,81 @@ bool js_register_pipeline_RenderViewInfo(se::Object *obj) { return true; } +static bool js_pipeline_RenderPipeline_getMacros(se::State& s) +{ + cc::pipeline::RenderPipeline* cobj = (cc::pipeline::RenderPipeline*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_getMacros : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cc::ValueMap& result = cobj->getMacros(); + ok &= ccvaluemap_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_getMacros : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_PROP_GET(js_pipeline_RenderPipeline_getMacros) + +static bool js_pipeline_RenderPipeline_setMacros(se::State& s) +{ + cc::pipeline::RenderPipeline* cobj = (cc::pipeline::RenderPipeline*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_setMacros : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + cc::ValueMap arg0; + std::string arg1; + ok &= seval_to_ccvaluemap(args[0], &arg0); + ok &= seval_to_std_string(args[1], &arg1); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_setMacros : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_PROP_SET(js_pipeline_RenderPipeline_setMacros) + +static bool js_pipeline_RenderView_setEnabled(se::State& s) +{ + cc::pipeline::RenderView* cobj = (cc::pipeline::RenderView*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderView_setEnabled : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + bool arg0; + ok &= seval_to_boolean(args[0], &arg0); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderView_setEnabled : Error processing arguments"); + cobj->setEnable(arg0); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderView_setEnabled) + +static bool js_pipeline_RenderView_IsEnabled(se::State& s) +{ + cc::pipeline::RenderView* cobj = (cc::pipeline::RenderView*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_pipeline_RenderView_getIsEnable : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->isEnabled(); + ok &= boolean_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_pipeline_RenderView_getIsEnable : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_PROP_GET(js_pipeline_RenderView_IsEnabled) + bool register_all_pipeline_manual(se::Object *obj) { // Get the ns se::Value nsVal; @@ -152,6 +223,9 @@ bool register_all_pipeline_manual(se::Object *obj) { se::Object *ns = nsVal.toObject(); js_register_pipeline_RenderViewInfo(ns); - + + __jsb_cc_pipeline_RenderPipeline_proto->defineProperty("macros", _SE(js_pipeline_RenderPipeline_getMacros), _SE(js_pipeline_RenderPipeline_setMacros)); + __jsb_cc_pipeline_RenderView_proto->defineFunction("enable", _SE(js_pipeline_RenderView_setEnabled)); + __jsb_cc_pipeline_RenderView_proto->defineProperty("isEnable", _SE(js_pipeline_RenderView_IsEnabled), nullptr); return true; } diff --git a/native/tools/tojs/cocos2dx_pipeline.ini b/native/tools/tojs/cocos2dx_pipeline.ini index a63c91b23e..88b697cdea 100644 --- a/native/tools/tojs/cocos2dx_pipeline.ini +++ b/native/tools/tojs/cocos2dx_pipeline.ini @@ -26,11 +26,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardPipeline.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardFlow.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardStage.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowFlow.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowStage.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIFlow.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIStage.h %(cocosdir)s/cocos/renderer/pipeline/RenderPipeline.h %(cocosdir)s/cocos/renderer/pipeline/RenderFlow.h %(cocosdir)s/cocos/renderer/pipeline/RenderStage.h %(cocosdir)s/cocos/renderer/pipeline/Define.h %(cocosdir)s/cocos/renderer/pipeline/RenderView.h +headers = %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardPipeline.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardFlow.h %(cocosdir)s/cocos/renderer/pipeline/forward/ForwardStage.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowFlow.h %(cocosdir)s/cocos/renderer/pipeline/shadow/ShadowStage.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIFlow.h %(cocosdir)s/cocos/renderer/pipeline/ui/UIStage.h %(cocosdir)s/cocos/renderer/pipeline/RenderPipeline.h %(cocosdir)s/cocos/renderer/pipeline/RenderFlow.h %(cocosdir)s/cocos/renderer/pipeline/RenderStage.h %(cocosdir)s/cocos/renderer/pipeline/Define.h %(cocosdir)s/cocos/renderer/pipeline/RenderView.h %(cocosdir)s/cocos/renderer/pipeline/helper/SharedMemory.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = RenderPipeline ForwardPipeline ForwardFlow ForwardStage ShadowFlow ShadowStage UIFlow UIStage RenderView RenderPipelineInfo RenderFlowInfo RenderStageInfo RenderQueueDesc RenderFlow RenderStage +classes = RenderPipeline ForwardPipeline ForwardFlow ForwardStage ShadowFlow ShadowStage UIFlow UIStage RenderView RenderPipelineInfo RenderFlowInfo RenderStageInfo RenderQueueDesc RenderFlow RenderStage RenderWindow # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -38,8 +38,8 @@ classes = RenderPipeline ForwardPipeline ForwardFlow ForwardStage ShadowFlow Sha # add a single "*" as functions. See bellow for several examples. A special class name is "*", which # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = ForwardPipeline::[updateUBOs setHDR getOrCreateRenderPass getLightsUBO getValidLights getLightBuffers getLightIndexOffsets getLightIndices getRenderObjects getShadowObjects getCommandBuffers getShadingScale getFpScale isHDR setRenderObjcts setShadowObjects], - RenderPipeline::[getFlows getTag getGlobalBindings getMacro getDescriptorSet], +skip = ForwardPipeline::[updateUBOs setHDR getOrCreateRenderPass getLightsUBO getValidLights getLightBuffers getLightIndexOffsets getLightIndices getRenderObjects getShadowObjects getCommandBuffers getShadingScale getFpScale isHDR setRenderObjcts setShadowObjects getShadowMap], + RenderPipeline::[getFlows getTag getGlobalBindings getMacros getDescriptorSet], RenderFlow::[render destroy getPriority getName], RenderStage::[render destroy getPriority getName], ForwardFlow::[initialize activate destroy render], @@ -48,11 +48,11 @@ skip = ForwardPipeline::[updateUBOs setHDR getOrCreateRenderPass getLightsUBO ge ShadowStage::[initialize activate destroy render], UIFlow::[initialize activate destroy render], UIStage::[initialize activate destroy render], - RenderView::[getWindow getCamera] + RenderView::[getCamera isEnabled setEnable] rename_functions = -getter_setter= +getter_setter=RenderView::[name window] rename_classes =