mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
Merge branch 'v3.7.2' into develop
# Conflicts: # cocos/core/global-exports.ts # cocos/core/math/quat.ts # native/cocos/cocos-version.h # package.json
This commit is contained in:
@@ -1310,6 +1310,8 @@ cocos_source_files(
|
||||
cocos/renderer/pipeline/deferred/PostProcessStage.h
|
||||
cocos/renderer/pipeline/UIPhase.cpp
|
||||
cocos/renderer/pipeline/UIPhase.h
|
||||
cocos/renderer/pipeline/DebugView.cpp
|
||||
cocos/renderer/pipeline/DebugView.h
|
||||
cocos/renderer/pipeline/helper/Utils.h
|
||||
cocos/renderer/pipeline/helper/Utils.cpp
|
||||
cocos/renderer/pipeline/custom/BinaryArchive.h
|
||||
@@ -1341,18 +1343,20 @@ cocos_source_files(
|
||||
cocos/renderer/pipeline/custom/NativeExecutor.cpp
|
||||
cocos/renderer/pipeline/custom/NativeFactory.cpp
|
||||
cocos/renderer/pipeline/custom/NativeFwd.h
|
||||
cocos/renderer/pipeline/custom/NativeLayoutGraph.cpp
|
||||
cocos/renderer/pipeline/custom/NativePipeline.cpp
|
||||
cocos/renderer/pipeline/custom/NativePipelineFwd.h
|
||||
cocos/renderer/pipeline/custom/NativePipelineGraphs.h
|
||||
cocos/renderer/pipeline/custom/NativePipelineTypes.cpp
|
||||
cocos/renderer/pipeline/custom/NativePipelineTypes.h
|
||||
cocos/renderer/pipeline/custom/NativePools.cpp
|
||||
cocos/renderer/pipeline/custom/NativeProgramLibrary.cpp
|
||||
cocos/renderer/pipeline/custom/NativeRenderGraph.cpp
|
||||
cocos/renderer/pipeline/custom/NativeRenderQueue.cpp
|
||||
cocos/renderer/pipeline/custom/NativeRenderingModule.cpp
|
||||
cocos/renderer/pipeline/custom/NativeTypes.cpp
|
||||
cocos/renderer/pipeline/custom/NativeTypes.h
|
||||
cocos/renderer/pipeline/custom/NativeUtils.cpp
|
||||
cocos/renderer/pipeline/custom/NativeUtils.h
|
||||
cocos/renderer/pipeline/custom/PrivateFwd.h
|
||||
cocos/renderer/pipeline/custom/PrivateTypes.cpp
|
||||
cocos/renderer/pipeline/custom/PrivateTypes.h
|
||||
@@ -1370,6 +1374,7 @@ cocos_source_files(
|
||||
cocos/renderer/pipeline/custom/RenderInterfaceFwd.h
|
||||
cocos/renderer/pipeline/custom/RenderInterfaceTypes.cpp
|
||||
cocos/renderer/pipeline/custom/RenderInterfaceTypes.h
|
||||
cocos/renderer/pipeline/custom/RenderingModule.h
|
||||
)
|
||||
|
||||
if (USE_GEOMETRY_RENDERER)
|
||||
@@ -2775,19 +2780,12 @@ endif()
|
||||
##### ar module
|
||||
if(USE_AR_MODULE)
|
||||
cocos_source_files(
|
||||
cocos/xr/ar/ARModule.cpp
|
||||
cocos/xr/ar/ARModule.h
|
||||
cocos/xr/ar/IARAPI.h
|
||||
cocos/renderer/pipeline/xr/ar/ARStage.cpp
|
||||
cocos/renderer/pipeline/xr/ar/ARStage.h
|
||||
cocos/renderer/pipeline/xr/ar/ARBackground.cpp
|
||||
cocos/renderer/pipeline/xr/ar/ARBackground.h
|
||||
)
|
||||
if(ANDROID OR IOS)
|
||||
cocos_source_files(
|
||||
cocos/xr/ar/ARLib.h
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
##### extensions
|
||||
|
||||
@@ -231,7 +231,7 @@ CC_FORCE_INLINE void Batcher2d::handleModelDraw(RenderEntity* entity, RenderDraw
|
||||
|
||||
bool isMask = entity->getIsMask();
|
||||
if (isMask) {
|
||||
//Mask Comp
|
||||
// Mask Comp
|
||||
insertMaskBatch(entity);
|
||||
} else {
|
||||
entity->setEnumStencilStage(_stencilManager->getStencilStage());
|
||||
@@ -295,7 +295,7 @@ CC_FORCE_INLINE void Batcher2d::handleSubNode(RenderEntity* entity, RenderDrawIn
|
||||
}
|
||||
}
|
||||
|
||||
CC_FORCE_INLINE void Batcher2d::handleDrawInfo(RenderEntity* entity, RenderDrawInfo* drawInfo, Node* node) { //NOLINT(misc-no-recursion)
|
||||
CC_FORCE_INLINE void Batcher2d::handleDrawInfo(RenderEntity* entity, RenderDrawInfo* drawInfo, Node* node) { // NOLINT(misc-no-recursion)
|
||||
CC_ASSERT(entity);
|
||||
CC_ASSERT(drawInfo);
|
||||
RenderDrawInfoType drawInfoType = drawInfo->getEnumDrawInfoType();
|
||||
@@ -380,7 +380,7 @@ void Batcher2d::generateBatchForMiddleware(RenderEntity* entity, RenderDrawInfo*
|
||||
auto* texture = drawInfo->getTexture();
|
||||
auto* sampler = drawInfo->getSampler();
|
||||
auto* meshBuffer = drawInfo->getMeshBuffer();
|
||||
//set meshbuffer offset
|
||||
// set meshbuffer offset
|
||||
auto indexOffset = drawInfo->getIndexOffset();
|
||||
auto indexCount = drawInfo->getIbCount();
|
||||
indexOffset += indexCount;
|
||||
@@ -425,7 +425,7 @@ void Batcher2d::resetRenderStates() {
|
||||
_currDrawInfo = nullptr;
|
||||
}
|
||||
|
||||
gfx::DescriptorSet* Batcher2d::getDescriptorSet(gfx::Texture* texture, gfx::Sampler* sampler, gfx::DescriptorSetLayout* dsLayout) {
|
||||
gfx::DescriptorSet* Batcher2d::getDescriptorSet(gfx::Texture* texture, gfx::Sampler* sampler, const gfx::DescriptorSetLayout* dsLayout) {
|
||||
ccstd::hash_t hash = 2;
|
||||
size_t textureHash;
|
||||
if (texture != nullptr) {
|
||||
@@ -522,7 +522,7 @@ void Batcher2d::reset() {
|
||||
}
|
||||
}
|
||||
}
|
||||
//meshBuffer cannot clear because it is not transported at every frame.
|
||||
// meshBuffer cannot clear because it is not transported at every frame.
|
||||
|
||||
_currMeshBuffer = nullptr;
|
||||
_indexStart = 0;
|
||||
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
void insertMaskBatch(RenderEntity* entity);
|
||||
void createClearModel();
|
||||
|
||||
gfx::DescriptorSet* getDescriptorSet(gfx::Texture* texture, gfx::Sampler* sampler, gfx::DescriptorSetLayout* dsLayout);
|
||||
gfx::DescriptorSet* getDescriptorSet(gfx::Texture* texture, gfx::Sampler* sampler, const gfx::DescriptorSetLayout* dsLayout);
|
||||
|
||||
StencilManager* _stencilManager{nullptr};
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ gfx::InputAssembler* RenderDrawInfo::initIAInfo(gfx::Device* device) {
|
||||
return ia;
|
||||
}
|
||||
|
||||
void RenderDrawInfo::updateLocalDescriptorSet(Node* transform, gfx::DescriptorSetLayout* dsLayout) {
|
||||
void RenderDrawInfo::updateLocalDescriptorSet(Node* transform, const gfx::DescriptorSetLayout* dsLayout) {
|
||||
if (_localDSBF == nullptr) {
|
||||
_localDSBF = new LocalDSBF();
|
||||
auto* device = Root::getInstance()->getDevice();
|
||||
|
||||
@@ -218,7 +218,7 @@ public:
|
||||
void resetMeshIA();
|
||||
|
||||
inline gfx::DescriptorSet* getLocalDes() { return _localDSBF->ds; }
|
||||
void updateLocalDescriptorSet(Node* transform, gfx::DescriptorSetLayout* dsLayout);
|
||||
void updateLocalDescriptorSet(Node* transform, const gfx::DescriptorSetLayout* dsLayout);
|
||||
|
||||
inline void resetDrawInfo() {
|
||||
destroy();
|
||||
|
||||
@@ -87,7 +87,7 @@ void UIModelProxy::uploadData() {
|
||||
for (size_t i = 0; i < drawInfos.size(); i++) {
|
||||
auto* drawInfo = drawInfos[i];
|
||||
auto* ia = subModelList.at(i)->getInputAssembler();
|
||||
if (drawInfo->getVertexOffset() <= 0) continue;
|
||||
if (drawInfo->getVertexOffset() <= 0 || drawInfo->getIndexOffset() <= 0) continue;
|
||||
gfx::BufferList vBuffers = ia->getVertexBuffers();
|
||||
if (!vBuffers.empty()) {
|
||||
auto size = drawInfo->getVertexOffset() * _stride;
|
||||
|
||||
@@ -333,8 +333,8 @@ SNDFILE *sf_open_read(const char *path, SF_INFO *info, snd_callbacks *cb, void *
|
||||
return handle;
|
||||
|
||||
close:
|
||||
free(handle);
|
||||
handle->callback.close(stream);
|
||||
free(handle);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1287,7 +1287,7 @@ static bool js_cc_RenderDrawInfo_updateLocalDescriptorSet(se::State& s)
|
||||
|
||||
ok &= sevalue_to_native(args[1], &arg3, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
(arg1)->updateLocalDescriptorSet(arg2,arg3);
|
||||
(arg1)->updateLocalDescriptorSet(arg2,(cc::gfx::DescriptorSetLayout const *)arg3);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
@@ -109,22 +109,6 @@ static bool js_cc_ar_ARModule_get_static(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_get_static)
|
||||
|
||||
static bool js_new_cc_ar_ARModule(se::State& s) // NOLINT(readability-identifier-naming)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
cc::ar::ARModule *result;
|
||||
result = (cc::ar::ARModule *)new cc::ar::ARModule();
|
||||
|
||||
|
||||
auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result);
|
||||
s.thisObject()->setPrivateObject(ptr);
|
||||
return true;
|
||||
}
|
||||
SE_BIND_CTOR(js_new_cc_ar_ARModule, __jsb_cc_ar_ARModule_class, js_delete_cc_ar_ARModule)
|
||||
|
||||
static bool js_delete_cc_ar_ARModule(se::State& s)
|
||||
{
|
||||
return true;
|
||||
@@ -137,7 +121,7 @@ static bool js_cc_ar_ARModule_config(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
int arg2 ;
|
||||
uint32_t arg2 ;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
@@ -147,7 +131,8 @@ static bool js_cc_ar_ARModule_config(se::State& s)
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
(arg1)->config(arg2);
|
||||
|
||||
|
||||
@@ -161,7 +146,7 @@ static bool js_cc_ar_ARModule_getSupportMask(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
int result;
|
||||
uint32_t result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
@@ -169,7 +154,7 @@ static bool js_cc_ar_ARModule_getSupportMask(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (int)(arg1)->getSupportMask();
|
||||
result = ((cc::ar::ARModule const *)arg1)->getSupportMask();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
@@ -178,17 +163,12 @@ static bool js_cc_ar_ARModule_getSupportMask(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_getSupportMask)
|
||||
|
||||
static bool js_cc_ar_ARModule_start(se::State& s)
|
||||
static bool js_cc_ar_ARModule_start__SWIG_0(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->start();
|
||||
@@ -196,9 +176,52 @@ static bool js_cc_ar_ARModule_start(se::State& s)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool js_cc_ar_ARModule_start__SWIG_1(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
void *arg2 = (void *) NULL ;
|
||||
void *arg3 = (void *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
ok &= sevalue_to_native(args[0], &arg2);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
ok &= sevalue_to_native(args[1], &arg3);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
(arg1)->start(arg2,arg3);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool js_cc_ar_ARModule_start(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
|
||||
if (argc == 0) {
|
||||
ok = js_cc_ar_ARModule_start__SWIG_0(s);
|
||||
if (ok) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (argc == 2) {
|
||||
ok = js_cc_ar_ARModule_start__SWIG_1(s);
|
||||
if (ok) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_start)
|
||||
|
||||
static bool js_cc_ar_ARModule_onResume(se::State& s)
|
||||
static bool js_cc_ar_ARModule_stop(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
@@ -211,14 +234,72 @@ static bool js_cc_ar_ARModule_onResume(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->onResume();
|
||||
(arg1)->stop();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_onResume)
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_stop)
|
||||
|
||||
static bool js_cc_ar_ARModule_onPause(se::State& s)
|
||||
static bool js_cc_ar_ARModule_resume__SWIG_0(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->resume();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool js_cc_ar_ARModule_resume__SWIG_1(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
void *arg2 = (void *) NULL ;
|
||||
void *arg3 = (void *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
ok &= sevalue_to_native(args[0], &arg2);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
ok &= sevalue_to_native(args[1], &arg3);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
(arg1)->resume(arg2,arg3);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool js_cc_ar_ARModule_resume(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
|
||||
if (argc == 0) {
|
||||
ok = js_cc_ar_ARModule_resume__SWIG_0(s);
|
||||
if (ok) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (argc == 2) {
|
||||
ok = js_cc_ar_ARModule_resume__SWIG_1(s);
|
||||
if (ok) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_resume)
|
||||
|
||||
static bool js_cc_ar_ARModule_pause(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
@@ -231,12 +312,12 @@ static bool js_cc_ar_ARModule_onPause(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->onPause();
|
||||
(arg1)->pause();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_onPause)
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_pause)
|
||||
|
||||
static bool js_cc_ar_ARModule_update(se::State& s)
|
||||
{
|
||||
@@ -339,7 +420,7 @@ static bool js_cc_ar_ARModule_getCameraPose(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
Pose result;
|
||||
cc::ar::Pose result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
@@ -347,7 +428,7 @@ static bool js_cc_ar_ARModule_getCameraPose(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = ((cc::ar::ARModule const *)arg1)->getCameraPose();
|
||||
result = (arg1)->getCameraPose();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
@@ -365,7 +446,7 @@ static bool js_cc_ar_ARModule_getCameraViewMatrix(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
Matrix result;
|
||||
cc::ar::Matrix result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
@@ -373,7 +454,7 @@ static bool js_cc_ar_ARModule_getCameraViewMatrix(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = ((cc::ar::ARModule const *)arg1)->getCameraViewMatrix();
|
||||
result = (arg1)->getCameraViewMatrix();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
@@ -391,7 +472,7 @@ static bool js_cc_ar_ARModule_getCameraProjectionMatrix(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
Matrix result;
|
||||
cc::ar::Matrix result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
@@ -399,7 +480,7 @@ static bool js_cc_ar_ARModule_getCameraProjectionMatrix(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = ((cc::ar::ARModule const *)arg1)->getCameraProjectionMatrix();
|
||||
result = (arg1)->getCameraProjectionMatrix();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
@@ -417,7 +498,7 @@ static bool js_cc_ar_ARModule_getCameraTexCoords(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
TexCoords result;
|
||||
cc::ar::TexCoords result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
@@ -425,7 +506,7 @@ static bool js_cc_ar_ARModule_getCameraTexCoords(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = ((cc::ar::ARModule const *)arg1)->getCameraTexCoords();
|
||||
result = (arg1)->getCameraTexCoords();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
@@ -611,7 +692,7 @@ static bool js_cc_ar_ARModule_getCameraDepthBuffer(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (uint8_t *)((cc::ar::ARModule const *)arg1)->getCameraDepthBuffer();
|
||||
result = (uint8_t *)(arg1)->getCameraDepthBuffer();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
@@ -695,7 +776,7 @@ static bool js_cc_ar_ARModule_getMainLightDirection(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
LightVal result;
|
||||
cc::ar::LightVal result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
@@ -721,7 +802,7 @@ static bool js_cc_ar_ARModule_getMainLightIntensity(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
LightVal result;
|
||||
cc::ar::LightVal result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
@@ -775,7 +856,7 @@ static bool js_cc_ar_ARModule_getAnchorPose(se::State& s)
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
int arg2 ;
|
||||
Pose result;
|
||||
cc::ar::Pose result;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
@@ -786,7 +867,7 @@ static bool js_cc_ar_ARModule_getAnchorPose(se::State& s)
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
result = ((cc::ar::ARModule const *)arg1)->getAnchorPose(arg2);
|
||||
result = (arg1)->getAnchorPose(arg2);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
@@ -840,7 +921,7 @@ static bool js_cc_ar_ARModule_getHitResult(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
Pose result;
|
||||
cc::ar::Pose result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
@@ -848,7 +929,7 @@ static bool js_cc_ar_ARModule_getHitResult(se::State& s)
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = ((cc::ar::ARModule const *)arg1)->getHitResult();
|
||||
result = (arg1)->getHitResult();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
@@ -954,30 +1035,6 @@ static bool js_cc_ar_ARModule_setPlaneDetectionMode(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_setPlaneDetectionMode)
|
||||
|
||||
static bool js_cc_ar_ARModule_setPlaneMaxTrackingNumber(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
int arg2 ;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
((cc::ar::ARModule const *)arg1)->setPlaneMaxTrackingNumber(arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_setPlaneMaxTrackingNumber)
|
||||
|
||||
static bool js_cc_ar_ARModule_enableSceneMesh(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
@@ -1046,33 +1103,6 @@ static bool js_cc_ar_ARModule_enableImageTracking(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_enableImageTracking)
|
||||
|
||||
static bool js_cc_ar_ARModule_addImageToLib(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::ar::ARModule *arg1 = (cc::ar::ARModule *) NULL ;
|
||||
std::string *arg2 = 0 ;
|
||||
std::string temp2 ;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::ar::ARModule>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
((cc::ar::ARModule const *)arg1)->addImageToLib((std::string const &)*arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_addImageToLib)
|
||||
|
||||
static bool js_cc_ar_ARModule_addImageToLibWithSize(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
@@ -1203,6 +1233,22 @@ static bool js_cc_ar_ARModule_enableFaceTracking(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_ar_ARModule_enableFaceTracking)
|
||||
|
||||
static bool js_new_cc_ar_ARModule(se::State& s) // NOLINT(readability-identifier-naming)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
cc::ar::ARModule *result;
|
||||
result = (cc::ar::ARModule *)new cc::ar::ARModule();
|
||||
|
||||
|
||||
auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result);
|
||||
s.thisObject()->setPrivateObject(ptr);
|
||||
return true;
|
||||
}
|
||||
SE_BIND_CTOR(js_new_cc_ar_ARModule, __jsb_cc_ar_ARModule_class, js_delete_cc_ar_ARModule)
|
||||
|
||||
bool js_register_cc_ar_ARModule(se::Object* obj) {
|
||||
auto* cls = se::Class::create("ARModule", obj, nullptr, _SE(js_new_cc_ar_ARModule));
|
||||
|
||||
@@ -1211,8 +1257,9 @@ bool js_register_cc_ar_ARModule(se::Object* obj) {
|
||||
cls->defineFunction("config", _SE(js_cc_ar_ARModule_config));
|
||||
cls->defineFunction("getSupportMask", _SE(js_cc_ar_ARModule_getSupportMask));
|
||||
cls->defineFunction("start", _SE(js_cc_ar_ARModule_start));
|
||||
cls->defineFunction("onResume", _SE(js_cc_ar_ARModule_onResume));
|
||||
cls->defineFunction("onPause", _SE(js_cc_ar_ARModule_onPause));
|
||||
cls->defineFunction("stop", _SE(js_cc_ar_ARModule_stop));
|
||||
cls->defineFunction("resume", _SE(js_cc_ar_ARModule_resume));
|
||||
cls->defineFunction("pause", _SE(js_cc_ar_ARModule_pause));
|
||||
cls->defineFunction("update", _SE(js_cc_ar_ARModule_update));
|
||||
cls->defineFunction("getAPIState", _SE(js_cc_ar_ARModule_getAPIState));
|
||||
cls->defineFunction("setCameraId", _SE(js_cc_ar_ARModule_setCameraId));
|
||||
@@ -1241,11 +1288,9 @@ bool js_register_cc_ar_ARModule(se::Object* obj) {
|
||||
cls->defineFunction("getHitType", _SE(js_cc_ar_ARModule_getHitType));
|
||||
cls->defineFunction("enablePlane", _SE(js_cc_ar_ARModule_enablePlane));
|
||||
cls->defineFunction("setPlaneDetectionMode", _SE(js_cc_ar_ARModule_setPlaneDetectionMode));
|
||||
cls->defineFunction("setPlaneMaxTrackingNumber", _SE(js_cc_ar_ARModule_setPlaneMaxTrackingNumber));
|
||||
cls->defineFunction("enableSceneMesh", _SE(js_cc_ar_ARModule_enableSceneMesh));
|
||||
cls->defineFunction("endRequireSceneMesh", _SE(js_cc_ar_ARModule_endRequireSceneMesh));
|
||||
cls->defineFunction("enableImageTracking", _SE(js_cc_ar_ARModule_enableImageTracking));
|
||||
cls->defineFunction("addImageToLib", _SE(js_cc_ar_ARModule_addImageToLib));
|
||||
cls->defineFunction("addImageToLibWithSize", _SE(js_cc_ar_ARModule_addImageToLibWithSize));
|
||||
cls->defineFunction("setImageMaxTrackingNumber", _SE(js_cc_ar_ARModule_setImageMaxTrackingNumber));
|
||||
cls->defineFunction("enableObjectTracking", _SE(js_cc_ar_ARModule_enableObjectTracking));
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#pragma once
|
||||
#include "bindings/jswrapper/SeApi.h"
|
||||
#include "bindings/manual/jsb_conversions.h"
|
||||
#include "xr/ar/IARAPI.h"
|
||||
#include "xr/ar/ARModule.h"
|
||||
|
||||
|
||||
|
||||
@@ -16740,20 +16740,15 @@ static bool js_cc_IShaderInfo_descriptors_get(se::State& s)
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_IShaderInfo_descriptors_get)
|
||||
|
||||
static bool js_cc_IShaderInfo_getSource(se::State& s)
|
||||
static bool js_cc_IShaderInfo_getSource__SWIG_0(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::IShaderInfo *arg1 = (cc::IShaderInfo *) NULL ;
|
||||
ccstd::string *arg2 = 0 ;
|
||||
ccstd::string temp2 ;
|
||||
cc::IShaderSource *result = 0 ;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::IShaderInfo>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
@@ -16770,6 +16765,55 @@ static bool js_cc_IShaderInfo_getSource(se::State& s)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool js_cc_IShaderInfo_getSource__SWIG_1(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
cc::IShaderInfo *arg1 = (cc::IShaderInfo *) NULL ;
|
||||
ccstd::string *arg2 = 0 ;
|
||||
ccstd::string temp2 ;
|
||||
cc::IShaderSource *result = 0 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::IShaderInfo>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
result = (cc::IShaderSource *)(arg1)->getSource((ccstd::string const &)*arg2);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool js_cc_IShaderInfo_getSource(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
|
||||
if (argc == 1) {
|
||||
ok = js_cc_IShaderInfo_getSource__SWIG_0(s);
|
||||
if (ok) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (argc == 1) {
|
||||
ok = js_cc_IShaderInfo_getSource__SWIG_1(s);
|
||||
if (ok) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_IShaderInfo_getSource)
|
||||
|
||||
static bool js_new_cc_IShaderInfo(se::State& s) // NOLINT(readability-identifier-naming)
|
||||
|
||||
@@ -1413,6 +1413,29 @@ static bool js_cc_gi_LightProbesData_updateTetrahedrons(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_gi_LightProbesData_updateTetrahedrons)
|
||||
|
||||
static bool js_cc_gi_LightProbesData_hasCoefficients(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ;
|
||||
bool result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::gi::LightProbesData>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (bool)((cc::gi::LightProbesData const *)arg1)->hasCoefficients();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_gi_LightProbesData_hasCoefficients)
|
||||
|
||||
static bool js_cc_gi_LightProbesData_getInterpolationSHCoefficients(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
@@ -1672,6 +1695,7 @@ bool js_register_cc_gi_LightProbesData(se::Object* obj) {
|
||||
cls->defineFunction("reset", _SE(js_cc_gi_LightProbesData_reset));
|
||||
cls->defineFunction("updateProbes", _SE(js_cc_gi_LightProbesData_updateProbes));
|
||||
cls->defineFunction("updateTetrahedrons", _SE(js_cc_gi_LightProbesData_updateTetrahedrons));
|
||||
cls->defineFunction("hasCoefficients", _SE(js_cc_gi_LightProbesData_hasCoefficients));
|
||||
cls->defineFunction("getInterpolationSHCoefficients", _SE(js_cc_gi_LightProbesData_getInterpolationSHCoefficients));
|
||||
cls->defineFunction("getInterpolationWeights", _SE(js_cc_gi_LightProbesData_getInterpolationWeights));
|
||||
|
||||
@@ -2428,6 +2452,46 @@ static bool js_cc_gi_LightProbeInfo_activate(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_gi_LightProbeInfo_activate)
|
||||
|
||||
static bool js_cc_gi_LightProbeInfo_onProbeBakeFinished(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::gi::LightProbeInfo>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->onProbeBakeFinished();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_gi_LightProbeInfo_onProbeBakeFinished)
|
||||
|
||||
static bool js_cc_gi_LightProbeInfo_onProbeBakeCleared(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::gi::LightProbeInfo>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->onProbeBakeCleared();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_gi_LightProbeInfo_onProbeBakeCleared)
|
||||
|
||||
static bool js_cc_gi_LightProbeInfo_clearSHCoefficients(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
@@ -3204,6 +3268,8 @@ bool js_register_cc_gi_LightProbeInfo(se::Object* obj) {
|
||||
cls->defineProperty("data", _SE(js_cc_gi_LightProbeInfo_data_get), _SE(js_cc_gi_LightProbeInfo_data_set));
|
||||
|
||||
cls->defineFunction("activate", _SE(js_cc_gi_LightProbeInfo_activate));
|
||||
cls->defineFunction("onProbeBakeFinished", _SE(js_cc_gi_LightProbeInfo_onProbeBakeFinished));
|
||||
cls->defineFunction("onProbeBakeCleared", _SE(js_cc_gi_LightProbeInfo_onProbeBakeCleared));
|
||||
cls->defineFunction("clearSHCoefficients", _SE(js_cc_gi_LightProbeInfo_clearSHCoefficients));
|
||||
cls->defineFunction("isUniqueNode", _SE(js_cc_gi_LightProbeInfo_isUniqueNode));
|
||||
cls->defineFunction("addNode", _SE(js_cc_gi_LightProbeInfo_addNode));
|
||||
|
||||
@@ -130,6 +130,10 @@ using namespace cc;
|
||||
#define cc_pipeline_PipelineSceneData_lightProbes_get(self_) self_->getLightProbes()
|
||||
|
||||
|
||||
#define cc_pipeline_PipelineSceneData_validPunctualLights_get(self_) self_->getValidPunctualLights()
|
||||
#define cc_pipeline_PipelineSceneData_validPunctualLights_set(self_, val_) self_->setValidPunctualLights(val_)
|
||||
|
||||
|
||||
#define cc_pipeline_RenderStage__name_get(self_) self_->getName()
|
||||
#define cc_pipeline_RenderStage__name_set(self_, val_) self_->setName(val_)
|
||||
|
||||
@@ -170,6 +174,18 @@ using namespace cc;
|
||||
#define cc_pipeline_RenderFlow__stages_set(self_, val_) self_->setStages(val_)
|
||||
|
||||
|
||||
#define cc_pipeline_DebugView_singleMode_get(self_) self_->getSingleMode()
|
||||
#define cc_pipeline_DebugView_singleMode_set(self_, val_) self_->setSingleMode(val_)
|
||||
|
||||
|
||||
#define cc_pipeline_DebugView_lightingWithAlbedo_get(self_) self_->isLightingWithAlbedo()
|
||||
#define cc_pipeline_DebugView_lightingWithAlbedo_set(self_, val_) self_->setLightingWithAlbedo(val_)
|
||||
|
||||
|
||||
#define cc_pipeline_DebugView_csmLayerColoration_get(self_) self_->isCsmLayerColoration()
|
||||
#define cc_pipeline_DebugView_csmLayerColoration_set(self_, val_) self_->setCsmLayerColoration(val_)
|
||||
|
||||
|
||||
|
||||
se::Class* __jsb_cc_pipeline_SkinningJointCapacity_class = nullptr;
|
||||
se::Object* __jsb_cc_pipeline_SkinningJointCapacity_proto = nullptr;
|
||||
@@ -4379,6 +4395,7 @@ bool js_register_cc_pipeline_UBOGlobal(se::Object* obj) {
|
||||
cls->defineStaticProperty("DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET", nullptr, nullptr);
|
||||
cls->defineStaticProperty("DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET", nullptr, nullptr);
|
||||
cls->defineStaticProperty("DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET", nullptr, nullptr);
|
||||
cls->defineStaticProperty("DEBUG_VIEW_COMPOSITE_PACK_4_OFFSET", nullptr, nullptr);
|
||||
cls->defineStaticProperty("COUNT", nullptr, nullptr);
|
||||
cls->defineStaticProperty("SIZE", nullptr, nullptr);
|
||||
cls->defineStaticProperty("BINDING", nullptr, nullptr);
|
||||
@@ -7863,7 +7880,7 @@ static bool js_cc_pipeline_RenderPipeline_genQuadVertexData(se::State& s)
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::RenderPipeline *arg1 = (cc::pipeline::RenderPipeline *) NULL ;
|
||||
cc::Vec4 *arg2 = 0 ;
|
||||
float *arg3 = (float *) NULL ;
|
||||
float *arg3 ;
|
||||
cc::Vec4 temp2 ;
|
||||
|
||||
if(argc != 2) {
|
||||
@@ -9663,6 +9680,301 @@ bool js_register_cc_pipeline_RenderStage(se::Object* obj) {
|
||||
}
|
||||
|
||||
|
||||
se::Class* __jsb_cc_pipeline_DebugView_class = nullptr;
|
||||
se::Object* __jsb_cc_pipeline_DebugView_proto = nullptr;
|
||||
SE_DECLARE_FINALIZE_FUNC(js_delete_cc_pipeline_DebugView)
|
||||
|
||||
static bool js_new_cc_pipeline_DebugView(se::State& s) // NOLINT(readability-identifier-naming)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
cc::pipeline::DebugView *result;
|
||||
result = (cc::pipeline::DebugView *)new cc::pipeline::DebugView();
|
||||
|
||||
|
||||
auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result);
|
||||
s.thisObject()->setPrivateObject(ptr);
|
||||
return true;
|
||||
}
|
||||
SE_BIND_CTOR(js_new_cc_pipeline_DebugView, __jsb_cc_pipeline_DebugView_class, js_delete_cc_pipeline_DebugView)
|
||||
|
||||
static bool js_delete_cc_pipeline_DebugView(se::State& s)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FINALIZE_FUNC(js_delete_cc_pipeline_DebugView)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_isCompositeModeEnabled(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
uint32_t arg2 ;
|
||||
bool result;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
result = (bool)((cc::pipeline::DebugView const *)arg1)->isCompositeModeEnabled(arg2);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_pipeline_DebugView_isCompositeModeEnabled)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_enableCompositeMode(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
cc::pipeline::DebugViewCompositeType arg2 ;
|
||||
bool arg3 ;
|
||||
|
||||
if(argc != 2) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[1], &arg3);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
(arg1)->enableCompositeMode(arg2,arg3);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_pipeline_DebugView_enableCompositeMode)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_enableAllCompositeMode(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
bool arg2 ;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
(arg1)->enableAllCompositeMode(arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_pipeline_DebugView_enableAllCompositeMode)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_isEnabled(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
bool result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (bool)((cc::pipeline::DebugView const *)arg1)->isEnabled();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_pipeline_DebugView_isEnabled)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_reset(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->reset();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_pipeline_DebugView_reset)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_singleMode_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
cc::pipeline::DebugViewSingleType arg2 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
cc_pipeline_DebugView_singleMode_set(arg1,arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_pipeline_DebugView_singleMode_set)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_singleMode_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
cc::pipeline::DebugViewSingleType result;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (cc::pipeline::DebugViewSingleType)cc_pipeline_DebugView_singleMode_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_pipeline_DebugView_singleMode_get)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_lightingWithAlbedo_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
bool arg2 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
cc_pipeline_DebugView_lightingWithAlbedo_set(arg1,arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_pipeline_DebugView_lightingWithAlbedo_set)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_lightingWithAlbedo_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
bool result;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (bool)cc_pipeline_DebugView_lightingWithAlbedo_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_pipeline_DebugView_lightingWithAlbedo_get)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_csmLayerColoration_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
bool arg2 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
cc_pipeline_DebugView_csmLayerColoration_set(arg1,arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_pipeline_DebugView_csmLayerColoration_set)
|
||||
|
||||
static bool js_cc_pipeline_DebugView_csmLayerColoration_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::pipeline::DebugView *arg1 = (cc::pipeline::DebugView *) NULL ;
|
||||
bool result;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::DebugView>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (bool)cc_pipeline_DebugView_csmLayerColoration_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_pipeline_DebugView_csmLayerColoration_get)
|
||||
|
||||
bool js_register_cc_pipeline_DebugView(se::Object* obj) {
|
||||
auto* cls = se::Class::create("DebugView", obj, nullptr, _SE(js_new_cc_pipeline_DebugView));
|
||||
|
||||
cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE);
|
||||
cls->defineProperty("singleMode", _SE(js_cc_pipeline_DebugView_singleMode_get), _SE(js_cc_pipeline_DebugView_singleMode_set));
|
||||
cls->defineProperty("lightingWithAlbedo", _SE(js_cc_pipeline_DebugView_lightingWithAlbedo_get), _SE(js_cc_pipeline_DebugView_lightingWithAlbedo_set));
|
||||
cls->defineProperty("csmLayerColoration", _SE(js_cc_pipeline_DebugView_csmLayerColoration_get), _SE(js_cc_pipeline_DebugView_csmLayerColoration_set));
|
||||
|
||||
cls->defineFunction("isCompositeModeEnabled", _SE(js_cc_pipeline_DebugView_isCompositeModeEnabled));
|
||||
cls->defineFunction("enableCompositeMode", _SE(js_cc_pipeline_DebugView_enableCompositeMode));
|
||||
cls->defineFunction("enableAllCompositeMode", _SE(js_cc_pipeline_DebugView_enableAllCompositeMode));
|
||||
cls->defineFunction("isEnabled", _SE(js_cc_pipeline_DebugView_isEnabled));
|
||||
cls->defineFunction("reset", _SE(js_cc_pipeline_DebugView_reset));
|
||||
|
||||
|
||||
|
||||
|
||||
cls->defineFinalizeFunction(_SE(js_delete_cc_pipeline_DebugView));
|
||||
|
||||
|
||||
cls->install();
|
||||
JSBClassType::registerClass<cc::pipeline::DebugView>(cls);
|
||||
|
||||
__jsb_cc_pipeline_DebugView_proto = cls->getProto();
|
||||
__jsb_cc_pipeline_DebugView_class = cls;
|
||||
se::ScriptEngine::getInstance()->clearException();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
se::Class* __jsb_cc_pipeline_ForwardPipeline_class = nullptr;
|
||||
se::Object* __jsb_cc_pipeline_ForwardPipeline_proto = nullptr;
|
||||
SE_DECLARE_FINALIZE_FUNC(js_delete_cc_pipeline_ForwardPipeline)
|
||||
@@ -13550,31 +13862,6 @@ static bool js_cc_pipeline_PipelineSceneData_setShadowFramebuffer(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_pipeline_PipelineSceneData_setShadowFramebuffer)
|
||||
|
||||
static bool js_cc_pipeline_PipelineSceneData_getValidPunctualLights(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::PipelineSceneData *arg1 = (cc::pipeline::PipelineSceneData *) NULL ;
|
||||
ccstd::vector< cc::scene::Light const * > *result = 0 ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::PipelineSceneData>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (ccstd::vector< cc::scene::Light const * > *) &((cc::pipeline::PipelineSceneData const *)arg1)->getValidPunctualLights();
|
||||
|
||||
ok &= nativevalue_to_se(*result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_pipeline_PipelineSceneData_getValidPunctualLights)
|
||||
|
||||
static bool js_cc_pipeline_PipelineSceneData_getOctree(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
@@ -14060,6 +14347,47 @@ static bool js_cc_pipeline_PipelineSceneData_lightProbes_get(se::State& s)
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_pipeline_PipelineSceneData_lightProbes_get)
|
||||
|
||||
static bool js_cc_pipeline_PipelineSceneData_validPunctualLights_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::pipeline::PipelineSceneData *arg1 = (cc::pipeline::PipelineSceneData *) NULL ;
|
||||
ccstd::vector< cc::scene::Light const * > arg2 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::PipelineSceneData>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
cc_pipeline_PipelineSceneData_validPunctualLights_set(arg1,SWIG_STD_MOVE(arg2));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_pipeline_PipelineSceneData_validPunctualLights_set)
|
||||
|
||||
static bool js_cc_pipeline_PipelineSceneData_validPunctualLights_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::pipeline::PipelineSceneData *arg1 = (cc::pipeline::PipelineSceneData *) NULL ;
|
||||
ccstd::vector< cc::scene::Light const * > result;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::pipeline::PipelineSceneData>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = cc_pipeline_PipelineSceneData_validPunctualLights_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_pipeline_PipelineSceneData_validPunctualLights_get)
|
||||
|
||||
bool js_register_cc_pipeline_PipelineSceneData(se::Object* obj) {
|
||||
auto* cls = se::Class::create("PipelineSceneData", obj, nullptr, _SE(js_new_cc_pipeline_PipelineSceneData));
|
||||
|
||||
@@ -14071,12 +14399,12 @@ bool js_register_cc_pipeline_PipelineSceneData(se::Object* obj) {
|
||||
cls->defineProperty("skybox", _SE(js_cc_pipeline_PipelineSceneData_skybox_get), nullptr);
|
||||
cls->defineProperty("shadows", _SE(js_cc_pipeline_PipelineSceneData_shadows_get), nullptr);
|
||||
cls->defineProperty("lightProbes", _SE(js_cc_pipeline_PipelineSceneData_lightProbes_get), nullptr);
|
||||
cls->defineProperty("validPunctualLights", _SE(js_cc_pipeline_PipelineSceneData_validPunctualLights_get), _SE(js_cc_pipeline_PipelineSceneData_validPunctualLights_set));
|
||||
|
||||
cls->defineFunction("activate", _SE(js_cc_pipeline_PipelineSceneData_activate));
|
||||
cls->defineFunction("destroy", _SE(js_cc_pipeline_PipelineSceneData_destroy));
|
||||
cls->defineFunction("updatePipelineSceneData", _SE(js_cc_pipeline_PipelineSceneData_updatePipelineSceneData));
|
||||
cls->defineFunction("setShadowFramebuffer", _SE(js_cc_pipeline_PipelineSceneData_setShadowFramebuffer));
|
||||
cls->defineFunction("getValidPunctualLights", _SE(js_cc_pipeline_PipelineSceneData_getValidPunctualLights));
|
||||
cls->defineFunction("getOctree", _SE(js_cc_pipeline_PipelineSceneData_getOctree));
|
||||
cls->defineFunction("getOcclusionQueryInputAssembler", _SE(js_cc_pipeline_PipelineSceneData_getOcclusionQueryInputAssembler));
|
||||
cls->defineFunction("getOcclusionQueryPass", _SE(js_cc_pipeline_PipelineSceneData_getOcclusionQueryPass));
|
||||
@@ -21401,6 +21729,7 @@ bool register_all_pipeline(se::Object* obj) {
|
||||
js_register_cc_pipeline_RenderFlow(ns);
|
||||
js_register_cc_pipeline_RenderStageInfo(ns);
|
||||
js_register_cc_pipeline_RenderStage(ns);
|
||||
js_register_cc_pipeline_DebugView(ns);
|
||||
js_register_cc_pipeline_ForwardPipeline(ns);
|
||||
js_register_cc_pipeline_ForwardFlow(ns);
|
||||
js_register_cc_pipeline_ForwardStage(ns);
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "renderer/pipeline/PipelineSceneData.h"
|
||||
#include "renderer/pipeline/BatchedBuffer.h"
|
||||
#include "renderer/pipeline/GeometryRenderer.h"
|
||||
#include "renderer/pipeline/DebugView.h"
|
||||
#include "renderer/pipeline/reflection-probe/ReflectionProbeFlow.h"
|
||||
#include "renderer/pipeline/reflection-probe/ReflectionProbeStage.h"
|
||||
|
||||
@@ -472,6 +473,11 @@ extern se::Object *__jsb_cc_pipeline_RenderStage_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_pipeline_RenderStage_class; // NOLINT
|
||||
|
||||
|
||||
JSB_REGISTER_OBJECT_TYPE(cc::pipeline::DebugView);
|
||||
extern se::Object *__jsb_cc_pipeline_DebugView_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_pipeline_DebugView_class; // NOLINT
|
||||
|
||||
|
||||
JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardPipeline);
|
||||
extern se::Object *__jsb_cc_pipeline_ForwardPipeline_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_pipeline_ForwardPipeline_class; // NOLINT
|
||||
|
||||
@@ -106,15 +106,16 @@ using namespace cc::render;
|
||||
#define cc_render_RenderNode_name_set(self_, val_) self_->setName(val_)
|
||||
|
||||
|
||||
#define cc_render_RasterPassBuilder_showStatistics_get(self_) self_->getShowStatistics()
|
||||
#define cc_render_RasterPassBuilder_showStatistics_set(self_, val_) self_->setShowStatistics(val_)
|
||||
|
||||
|
||||
#define cc_render_SceneVisitor_pipelineSceneData_get(self_) self_->getPipelineSceneData()
|
||||
|
||||
|
||||
#define cc_render_SceneTask_taskType_get(self_) self_->getTaskType()
|
||||
|
||||
|
||||
#define cc_render_Pipeline_layoutGraphBuilder_get(self_) self_->getLayoutGraphBuilder()
|
||||
|
||||
|
||||
|
||||
se::Class* __jsb_cc_render_PipelineRuntime_class = nullptr;
|
||||
se::Object* __jsb_cc_render_PipelineRuntime_proto = nullptr;
|
||||
@@ -1710,6 +1711,7 @@ static bool js_cc_render_RasterPassBuilder_addQueue__SWIG_0(se::State& s)
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC();
|
||||
|
||||
|
||||
return true;
|
||||
@@ -1788,6 +1790,7 @@ static bool js_cc_render_RasterPassBuilder_addQueue__SWIG_1(se::State& s)
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC();
|
||||
|
||||
|
||||
return true;
|
||||
@@ -1817,6 +1820,43 @@ static bool js_cc_render_RasterPassBuilder_addQueue(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_RasterPassBuilder_addQueue)
|
||||
|
||||
static bool js_cc_render_RasterPassBuilder_showStatistics_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::RasterPassBuilder *arg1 = (cc::render::RasterPassBuilder *) NULL ;
|
||||
bool arg2 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::render::RasterPassBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
cc_render_RasterPassBuilder_showStatistics_set(arg1,arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_render_RasterPassBuilder_showStatistics_set)
|
||||
|
||||
static bool js_cc_render_RasterPassBuilder_showStatistics_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::render::RasterPassBuilder *arg1 = (cc::render::RasterPassBuilder *) NULL ;
|
||||
bool result;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::render::RasterPassBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (bool)cc_render_RasterPassBuilder_showStatistics_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_render_RasterPassBuilder_showStatistics_get)
|
||||
|
||||
static bool js_delete_cc_render_RasterPassBuilder(se::State& s)
|
||||
{
|
||||
return true;
|
||||
@@ -1827,6 +1867,7 @@ bool js_register_cc_render_RasterPassBuilder(se::Object* obj) {
|
||||
auto* cls = se::Class::create("RasterPassBuilder", obj, __jsb_cc_render_Setter_proto, nullptr);
|
||||
|
||||
cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE);
|
||||
cls->defineProperty("showStatistics", _SE(js_cc_render_RasterPassBuilder_showStatistics_get), _SE(js_cc_render_RasterPassBuilder_showStatistics_set));
|
||||
|
||||
cls->defineFunction("addRasterView", _SE(js_cc_render_RasterPassBuilder_addRasterView));
|
||||
cls->defineFunction("addComputeView", _SE(js_cc_render_RasterPassBuilder_addComputeView));
|
||||
@@ -2502,337 +2543,6 @@ bool js_register_cc_render_SceneTransversal(se::Object* obj) {
|
||||
}
|
||||
|
||||
|
||||
se::Class* __jsb_cc_render_LayoutGraphBuilder_class = nullptr;
|
||||
se::Object* __jsb_cc_render_LayoutGraphBuilder_proto = nullptr;
|
||||
SE_DECLARE_FINALIZE_FUNC(js_delete_cc_render_LayoutGraphBuilder)
|
||||
|
||||
static bool js_delete_cc_render_LayoutGraphBuilder(se::State& s)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FINALIZE_FUNC(js_delete_cc_render_LayoutGraphBuilder)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_clear(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->clear();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_clear)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_addRenderStage(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
ccstd::string *arg2 = 0 ;
|
||||
ccstd::string temp2 ;
|
||||
uint32_t result;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
result = (arg1)->addRenderStage((ccstd::string const &)*arg2);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_addRenderStage)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_addRenderPhase(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
ccstd::string *arg2 = 0 ;
|
||||
uint32_t arg3 ;
|
||||
ccstd::string temp2 ;
|
||||
uint32_t result;
|
||||
|
||||
if(argc != 2) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[1], &arg3, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
result = (arg1)->addRenderPhase((ccstd::string const &)*arg2,arg3);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_addRenderPhase)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_addShader(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
ccstd::string *arg2 = 0 ;
|
||||
uint32_t arg3 ;
|
||||
ccstd::string temp2 ;
|
||||
|
||||
if(argc != 2) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[1], &arg3, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
(arg1)->addShader((ccstd::string const &)*arg2,arg3);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_addShader)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_addDescriptorBlock(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
uint32_t arg2 ;
|
||||
DescriptorBlockIndex *arg3 = 0 ;
|
||||
DescriptorBlockFlattened *arg4 = 0 ;
|
||||
DescriptorBlockIndex temp3 ;
|
||||
DescriptorBlockFlattened temp4 ;
|
||||
|
||||
if(argc != 3) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[1], &temp3, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg3 = &temp3;
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[2], &temp4, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg4 = &temp4;
|
||||
|
||||
(arg1)->addDescriptorBlock(arg2,(DescriptorBlockIndex const &)*arg3,(DescriptorBlockFlattened const &)*arg4);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_addDescriptorBlock)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_addUniformBlock(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
uint32_t arg2 ;
|
||||
DescriptorBlockIndex *arg3 = 0 ;
|
||||
ccstd::string *arg4 = 0 ;
|
||||
gfx::UniformBlock *arg5 = 0 ;
|
||||
DescriptorBlockIndex temp3 ;
|
||||
ccstd::string temp4 ;
|
||||
gfx::UniformBlock temp5 ;
|
||||
|
||||
if(argc != 4) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[1], &temp3, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg3 = &temp3;
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[2], &temp4, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg4 = &temp4;
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[3], &temp5, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg5 = &temp5;
|
||||
|
||||
(arg1)->addUniformBlock(arg2,(DescriptorBlockIndex const &)*arg3,(ccstd::string const &)*arg4,(gfx::UniformBlock const &)*arg5);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_addUniformBlock)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_reserveDescriptorBlock(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
uint32_t arg2 ;
|
||||
DescriptorBlockIndex *arg3 = 0 ;
|
||||
DescriptorBlockFlattened *arg4 = 0 ;
|
||||
DescriptorBlockIndex temp3 ;
|
||||
DescriptorBlockFlattened temp4 ;
|
||||
|
||||
if(argc != 3) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[1], &temp3, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg3 = &temp3;
|
||||
|
||||
|
||||
ok &= sevalue_to_native(args[2], &temp4, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg4 = &temp4;
|
||||
|
||||
(arg1)->reserveDescriptorBlock(arg2,(DescriptorBlockIndex const &)*arg3,(DescriptorBlockFlattened const &)*arg4);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_reserveDescriptorBlock)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_compile(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
int result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (int)(arg1)->compile();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_compile)
|
||||
|
||||
static bool js_cc_render_LayoutGraphBuilder_print(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::render::LayoutGraphBuilder *arg1 = (cc::render::LayoutGraphBuilder *) NULL ;
|
||||
ccstd::string result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::render::LayoutGraphBuilder>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = ((cc::render::LayoutGraphBuilder const *)arg1)->print();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_LayoutGraphBuilder_print)
|
||||
|
||||
bool js_register_cc_render_LayoutGraphBuilder(se::Object* obj) {
|
||||
auto* cls = se::Class::create("LayoutGraphBuilder", obj, nullptr, nullptr);
|
||||
|
||||
cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE);
|
||||
|
||||
cls->defineFunction("clear", _SE(js_cc_render_LayoutGraphBuilder_clear));
|
||||
cls->defineFunction("addRenderStage", _SE(js_cc_render_LayoutGraphBuilder_addRenderStage));
|
||||
cls->defineFunction("addRenderPhase", _SE(js_cc_render_LayoutGraphBuilder_addRenderPhase));
|
||||
cls->defineFunction("addShader", _SE(js_cc_render_LayoutGraphBuilder_addShader));
|
||||
cls->defineFunction("addDescriptorBlock", _SE(js_cc_render_LayoutGraphBuilder_addDescriptorBlock));
|
||||
cls->defineFunction("addUniformBlock", _SE(js_cc_render_LayoutGraphBuilder_addUniformBlock));
|
||||
cls->defineFunction("reserveDescriptorBlock", _SE(js_cc_render_LayoutGraphBuilder_reserveDescriptorBlock));
|
||||
cls->defineFunction("compile", _SE(js_cc_render_LayoutGraphBuilder_compile));
|
||||
cls->defineFunction("print", _SE(js_cc_render_LayoutGraphBuilder_print));
|
||||
|
||||
|
||||
|
||||
|
||||
cls->defineFinalizeFunction(_SE(js_delete_cc_render_LayoutGraphBuilder));
|
||||
|
||||
|
||||
cls->install();
|
||||
JSBClassType::registerClass<cc::render::LayoutGraphBuilder>(cls);
|
||||
|
||||
__jsb_cc_render_LayoutGraphBuilder_proto = cls->getProto();
|
||||
__jsb_cc_render_LayoutGraphBuilder_class = cls;
|
||||
se::ScriptEngine::getInstance()->clearException();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
se::Class* __jsb_cc_render_Pipeline_class = nullptr;
|
||||
se::Object* __jsb_cc_render_Pipeline_proto = nullptr;
|
||||
SE_DECLARE_FINALIZE_FUNC(js_delete_cc_render_Pipeline)
|
||||
@@ -3218,6 +2928,7 @@ static bool js_cc_render_Pipeline_addRasterPass__SWIG_0(se::State& s)
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC();
|
||||
|
||||
|
||||
return true;
|
||||
@@ -3655,6 +3366,7 @@ static bool js_cc_render_Pipeline_addRasterPass__SWIG_1(se::State& s)
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
s.rval().toObject()->getPrivateObject()->tryAllowDestroyInGC();
|
||||
|
||||
|
||||
return true;
|
||||
@@ -3684,25 +3396,6 @@ static bool js_cc_render_Pipeline_addRasterPass(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_render_Pipeline_addRasterPass)
|
||||
|
||||
static bool js_cc_render_Pipeline_layoutGraphBuilder_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::render::Pipeline *arg1 = (cc::render::Pipeline *) NULL ;
|
||||
cc::render::LayoutGraphBuilder *result = 0 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::render::Pipeline>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (cc::render::LayoutGraphBuilder *)cc_render_Pipeline_layoutGraphBuilder_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_render_Pipeline_layoutGraphBuilder_get)
|
||||
|
||||
static bool js_delete_cc_render_Pipeline(se::State& s)
|
||||
{
|
||||
return true;
|
||||
@@ -3713,7 +3406,6 @@ bool js_register_cc_render_Pipeline(se::Object* obj) {
|
||||
auto* cls = se::Class::create("Pipeline", obj, __jsb_cc_render_PipelineRuntime_proto, nullptr);
|
||||
|
||||
cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE);
|
||||
cls->defineProperty("layoutGraphBuilder", _SE(js_cc_render_Pipeline_layoutGraphBuilder_get), nullptr);
|
||||
|
||||
cls->defineFunction("beginSetup", _SE(js_cc_render_Pipeline_beginSetup));
|
||||
cls->defineFunction("endSetup", _SE(js_cc_render_Pipeline_endSetup));
|
||||
@@ -4065,7 +3757,6 @@ bool register_all_render(se::Object* obj) {
|
||||
js_register_cc_render_SceneVisitor(ns);
|
||||
js_register_cc_render_SceneTask(ns);
|
||||
js_register_cc_render_SceneTransversal(ns);
|
||||
js_register_cc_render_LayoutGraphBuilder(ns);
|
||||
js_register_cc_render_Pipeline(ns);
|
||||
js_register_cc_render_PipelineBuilder(ns);
|
||||
js_register_cc_render_RenderingModule(ns);
|
||||
|
||||
@@ -103,11 +103,6 @@ extern se::Object *__jsb_cc_render_SceneTransversal_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_render_SceneTransversal_class; // NOLINT
|
||||
|
||||
|
||||
JSB_REGISTER_OBJECT_TYPE(cc::render::LayoutGraphBuilder);
|
||||
extern se::Object *__jsb_cc_render_LayoutGraphBuilder_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_render_LayoutGraphBuilder_class; // NOLINT
|
||||
|
||||
|
||||
JSB_REGISTER_OBJECT_TYPE(cc::render::Pipeline);
|
||||
extern se::Object *__jsb_cc_render_Pipeline_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_render_Pipeline_class; // NOLINT
|
||||
|
||||
@@ -123,6 +123,9 @@ using namespace cc;
|
||||
#define cc_Root_cameraList_get(self_) self_->getCameraList()
|
||||
|
||||
|
||||
#define cc_Root_debugView_get(self_) self_->getDebugView()
|
||||
|
||||
|
||||
#define cc_scene_RenderWindow_width_get(self_) self_->getWidth()
|
||||
|
||||
|
||||
@@ -828,6 +831,10 @@ using namespace cc;
|
||||
#define cc_scene_Model_reflectionProbeType_set(self_, val_) self_->setReflectionProbeType(val_)
|
||||
|
||||
|
||||
#define cc_scene_Model_receiveDirLight_get(self_) self_->isReceiveDirLight()
|
||||
#define cc_scene_Model_receiveDirLight_set(self_, val_) self_->setReceiveDirLight(val_)
|
||||
|
||||
|
||||
#define cc_scene_SubModel_passes_get(self_) self_->getPasses()
|
||||
#define cc_scene_SubModel_passes_set(self_, val_) self_->setPasses(val_)
|
||||
|
||||
@@ -4768,274 +4775,6 @@ bool js_register_cc_SceneGlobals(se::Object* obj) {
|
||||
}
|
||||
|
||||
|
||||
se::Class* __jsb_cc_DebugViewConfig_class = nullptr;
|
||||
se::Object* __jsb_cc_DebugViewConfig_proto = nullptr;
|
||||
SE_DECLARE_FINALIZE_FUNC(js_delete_cc_DebugViewConfig)
|
||||
|
||||
static bool js_cc_DebugViewConfig_singleMode_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg1->singleMode, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_DebugViewConfig_singleMode_set)
|
||||
|
||||
static bool js_cc_DebugViewConfig_singleMode_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= nativevalue_to_se(arg1->singleMode, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_DebugViewConfig_singleMode_get)
|
||||
|
||||
static bool js_cc_DebugViewConfig_compositeModeBitCount_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg1->compositeModeBitCount, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_DebugViewConfig_compositeModeBitCount_set)
|
||||
|
||||
static bool js_cc_DebugViewConfig_compositeModeBitCount_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= nativevalue_to_se(arg1->compositeModeBitCount, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_DebugViewConfig_compositeModeBitCount_get)
|
||||
|
||||
static bool js_cc_DebugViewConfig_compositeModeValue_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg1->compositeModeValue, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_DebugViewConfig_compositeModeValue_set)
|
||||
|
||||
static bool js_cc_DebugViewConfig_compositeModeValue_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= nativevalue_to_se(arg1->compositeModeValue, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_DebugViewConfig_compositeModeValue_get)
|
||||
|
||||
static bool js_cc_DebugViewConfig_lightingWithAlbedo_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg1->lightingWithAlbedo);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_DebugViewConfig_lightingWithAlbedo_set)
|
||||
|
||||
static bool js_cc_DebugViewConfig_lightingWithAlbedo_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= nativevalue_to_se(arg1->lightingWithAlbedo, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_DebugViewConfig_lightingWithAlbedo_get)
|
||||
|
||||
static bool js_cc_DebugViewConfig_csmLayerColoration_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg1->csmLayerColoration);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_DebugViewConfig_csmLayerColoration_set)
|
||||
|
||||
static bool js_cc_DebugViewConfig_csmLayerColoration_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::DebugViewConfig *arg1 = (cc::DebugViewConfig *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::DebugViewConfig>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= nativevalue_to_se(arg1->csmLayerColoration, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_DebugViewConfig_csmLayerColoration_get)
|
||||
|
||||
static bool js_new_cc_DebugViewConfig(se::State& s) // NOLINT(readability-identifier-naming)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
cc::DebugViewConfig *result;
|
||||
result = (cc::DebugViewConfig *)new cc::DebugViewConfig();
|
||||
|
||||
|
||||
auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result);
|
||||
s.thisObject()->setPrivateObject(ptr);
|
||||
return true;
|
||||
}
|
||||
SE_BIND_CTOR(js_new_cc_DebugViewConfig, __jsb_cc_DebugViewConfig_class, js_delete_cc_DebugViewConfig)
|
||||
|
||||
static bool js_delete_cc_DebugViewConfig(se::State& s)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FINALIZE_FUNC(js_delete_cc_DebugViewConfig)
|
||||
|
||||
template<>
|
||||
bool sevalue_to_native(const se::Value &from, cc::DebugViewConfig * to, se::Object *ctx)
|
||||
{
|
||||
assert(from.isObject());
|
||||
se::Object *json = from.toObject();
|
||||
auto* data = reinterpret_cast<cc::DebugViewConfig*>(json->getPrivateData());
|
||||
if (data) {
|
||||
*to = *data;
|
||||
return true;
|
||||
}
|
||||
se::Value field;
|
||||
bool ok = true;
|
||||
|
||||
json->getProperty("singleMode", &field, true);
|
||||
if (!field.isNullOrUndefined()) {
|
||||
ok &= sevalue_to_native(field, &(to->singleMode), ctx);
|
||||
}
|
||||
|
||||
|
||||
json->getProperty("compositeModeBitCount", &field, true);
|
||||
if (!field.isNullOrUndefined()) {
|
||||
ok &= sevalue_to_native(field, &(to->compositeModeBitCount), ctx);
|
||||
}
|
||||
|
||||
|
||||
json->getProperty("compositeModeValue", &field, true);
|
||||
if (!field.isNullOrUndefined()) {
|
||||
ok &= sevalue_to_native(field, &(to->compositeModeValue), ctx);
|
||||
}
|
||||
|
||||
|
||||
json->getProperty("lightingWithAlbedo", &field, true);
|
||||
if (!field.isNullOrUndefined()) {
|
||||
ok &= sevalue_to_native(field, &(to->lightingWithAlbedo), ctx);
|
||||
}
|
||||
|
||||
|
||||
json->getProperty("csmLayerColoration", &field, true);
|
||||
if (!field.isNullOrUndefined()) {
|
||||
ok &= sevalue_to_native(field, &(to->csmLayerColoration), ctx);
|
||||
}
|
||||
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool js_register_cc_DebugViewConfig(se::Object* obj) {
|
||||
auto* cls = se::Class::create("DebugViewConfig", obj, nullptr, _SE(js_new_cc_DebugViewConfig));
|
||||
|
||||
cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE);
|
||||
cls->defineProperty("singleMode", _SE(js_cc_DebugViewConfig_singleMode_get), _SE(js_cc_DebugViewConfig_singleMode_set));
|
||||
cls->defineProperty("compositeModeBitCount", _SE(js_cc_DebugViewConfig_compositeModeBitCount_get), _SE(js_cc_DebugViewConfig_compositeModeBitCount_set));
|
||||
cls->defineProperty("compositeModeValue", _SE(js_cc_DebugViewConfig_compositeModeValue_get), _SE(js_cc_DebugViewConfig_compositeModeValue_set));
|
||||
cls->defineProperty("lightingWithAlbedo", _SE(js_cc_DebugViewConfig_lightingWithAlbedo_get), _SE(js_cc_DebugViewConfig_lightingWithAlbedo_set));
|
||||
cls->defineProperty("csmLayerColoration", _SE(js_cc_DebugViewConfig_csmLayerColoration_get), _SE(js_cc_DebugViewConfig_csmLayerColoration_set));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cls->defineFinalizeFunction(_SE(js_delete_cc_DebugViewConfig));
|
||||
|
||||
|
||||
cls->install();
|
||||
JSBClassType::registerClass<cc::DebugViewConfig>(cls);
|
||||
|
||||
__jsb_cc_DebugViewConfig_proto = cls->getProto();
|
||||
__jsb_cc_DebugViewConfig_class = cls;
|
||||
se::ScriptEngine::getInstance()->clearException();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
se::Class* __jsb_cc_Root_class = nullptr;
|
||||
se::Object* __jsb_cc_Root_proto = nullptr;
|
||||
SE_DECLARE_FINALIZE_FUNC(js_delete_cc_Root)
|
||||
@@ -5603,58 +5342,6 @@ static bool js_cc_Root_getBatcher2D(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_Root_getBatcher2D)
|
||||
|
||||
static bool js_cc_Root_setDebugViewConfig(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::Root *arg1 = (cc::Root *) NULL ;
|
||||
cc::DebugViewConfig *arg2 = 0 ;
|
||||
cc::DebugViewConfig temp2 ;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::Root>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
(arg1)->setDebugViewConfig((cc::DebugViewConfig const &)*arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_Root_setDebugViewConfig)
|
||||
|
||||
static bool js_cc_Root_getDebugViewConfig(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::Root *arg1 = (cc::Root *) NULL ;
|
||||
cc::DebugViewConfig *result = 0 ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::Root>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (cc::DebugViewConfig *) &((cc::Root const *)arg1)->getDebugViewConfig();
|
||||
|
||||
ok &= nativevalue_to_se(*result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_Root_getDebugViewConfig)
|
||||
|
||||
static bool js_cc_Root_createRenderWindowFromSystemWindow__SWIG_0(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
@@ -6136,6 +5823,25 @@ static bool js_cc_Root_cameraList_get(se::State& s)
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_Root_cameraList_get)
|
||||
|
||||
static bool js_cc_Root_debugView_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::Root *arg1 = (cc::Root *) NULL ;
|
||||
cc::pipeline::DebugView *result = 0 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::Root>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (cc::pipeline::DebugView *)cc_Root_debugView_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_Root_debugView_get)
|
||||
|
||||
bool js_register_cc_Root(se::Object* obj) {
|
||||
auto* cls = se::Class::create("Root", obj, nullptr, _SE(js_new_cc_Root));
|
||||
|
||||
@@ -6157,6 +5863,7 @@ bool js_register_cc_Root(se::Object* obj) {
|
||||
cls->defineProperty("pipeline", _SE(js_cc_Root_pipeline_get), nullptr);
|
||||
cls->defineProperty("customPipeline", _SE(js_cc_Root_customPipeline_get), nullptr);
|
||||
cls->defineProperty("cameraList", _SE(js_cc_Root_cameraList_get), nullptr);
|
||||
cls->defineProperty("debugView", _SE(js_cc_Root_debugView_get), nullptr);
|
||||
|
||||
cls->defineFunction("_initialize", _SE(js_cc_Root__initialize));
|
||||
cls->defineFunction("destroy", _SE(js_cc_Root_destroy));
|
||||
@@ -6176,8 +5883,6 @@ bool js_register_cc_Root(se::Object* obj) {
|
||||
cls->defineFunction("destroyLight", _SE(js_cc_Root_destroyLight));
|
||||
cls->defineFunction("createCamera", _SE(js_cc_Root_createCamera));
|
||||
cls->defineFunction("getBatcher2D", _SE(js_cc_Root_getBatcher2D));
|
||||
cls->defineFunction("setDebugViewConfig", _SE(js_cc_Root_setDebugViewConfig));
|
||||
cls->defineFunction("getDebugViewConfig", _SE(js_cc_Root_getDebugViewConfig));
|
||||
cls->defineFunction("createRenderWindowFromSystemWindow", _SE(js_cc_Root_createRenderWindowFromSystemWindow));
|
||||
|
||||
|
||||
@@ -15596,6 +15301,43 @@ static bool js_cc_scene_Model_reflectionProbeType_get(se::State& s)
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_scene_Model_reflectionProbeType_get)
|
||||
|
||||
static bool js_cc_scene_Model_receiveDirLight_set(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::scene::Model *arg1 = (cc::scene::Model *) NULL ;
|
||||
bool arg2 ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::scene::Model>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &arg2);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
cc_scene_Model_receiveDirLight_set(arg1,arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_SET(js_cc_scene_Model_receiveDirLight_set)
|
||||
|
||||
static bool js_cc_scene_Model_receiveDirLight_get(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
cc::scene::Model *arg1 = (cc::scene::Model *) NULL ;
|
||||
bool result;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::scene::Model>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (bool)cc_scene_Model_receiveDirLight_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_PROP_GET(js_cc_scene_Model_receiveDirLight_get)
|
||||
|
||||
bool js_register_cc_scene_Model(se::Object* obj) {
|
||||
auto* cls = se::Class::create("Model", obj, nullptr, _SE(js_new_cc_scene_Model));
|
||||
|
||||
@@ -15627,6 +15369,7 @@ bool js_register_cc_scene_Model(se::Object* obj) {
|
||||
cls->defineProperty("useLightProbe", _SE(js_cc_scene_Model_useLightProbe_get), _SE(js_cc_scene_Model_useLightProbe_set));
|
||||
cls->defineProperty("bakeToReflectionProbe", _SE(js_cc_scene_Model_bakeToReflectionProbe_get), _SE(js_cc_scene_Model_bakeToReflectionProbe_set));
|
||||
cls->defineProperty("reflectionProbeType", _SE(js_cc_scene_Model_reflectionProbeType_get), _SE(js_cc_scene_Model_reflectionProbeType_set));
|
||||
cls->defineProperty("receiveDirLight", _SE(js_cc_scene_Model_receiveDirLight_get), _SE(js_cc_scene_Model_receiveDirLight_set));
|
||||
|
||||
cls->defineFunction("destroy", _SE(js_cc_scene_Model_destroy));
|
||||
cls->defineFunction("initSubModel", _SE(js_cc_scene_Model_initSubModel));
|
||||
@@ -18286,6 +18029,52 @@ static bool js_cc_scene_Pass_getRootBlock(se::State& s)
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_scene_Pass_getRootBlock)
|
||||
|
||||
static bool js_cc_scene_Pass_getPassID(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::scene::Pass *arg1 = (cc::scene::Pass *) NULL ;
|
||||
uint32_t result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::scene::Pass>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = ((cc::scene::Pass const *)arg1)->getPassID();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_scene_Pass_getPassID)
|
||||
|
||||
static bool js_cc_scene_Pass_getPhaseID(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::scene::Pass *arg1 = (cc::scene::Pass *) NULL ;
|
||||
uint32_t result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<cc::scene::Pass>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = ((cc::scene::Pass const *)arg1)->getPhaseID();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_cc_scene_Pass_getPhaseID)
|
||||
|
||||
static bool js_cc_scene_Pass__updatePassHash(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
@@ -18869,6 +18658,8 @@ bool js_register_cc_scene_Pass(se::Object* obj) {
|
||||
cls->defineFunction("getShaderVariant", _SE(js_cc_scene_Pass_getShaderVariant));
|
||||
cls->defineFunction("getPassInfoFull", _SE(js_cc_scene_Pass_getPassInfoFull));
|
||||
cls->defineFunction("getRootBlock", _SE(js_cc_scene_Pass_getRootBlock));
|
||||
cls->defineFunction("getPassID", _SE(js_cc_scene_Pass_getPassID));
|
||||
cls->defineFunction("getPhaseID", _SE(js_cc_scene_Pass_getPhaseID));
|
||||
cls->defineFunction("_updatePassHash", _SE(js_cc_scene_Pass__updatePassHash));
|
||||
cls->defineFunction("beginChangeStatesSilently", _SE(js_cc_scene_Pass_beginChangeStatesSilently));
|
||||
cls->defineFunction("endChangeStatesSilently", _SE(js_cc_scene_Pass_endChangeStatesSilently));
|
||||
@@ -26743,7 +26534,7 @@ static bool js_cc_ProgramLib_getTemplate(se::State& s)
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
result = (cc::IProgramInfo *)(arg1)->getTemplate((ccstd::string const &)*arg2);
|
||||
result = (cc::IProgramInfo *)((cc::ProgramLib const *)arg1)->getTemplate((ccstd::string const &)*arg2);
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
@@ -28340,7 +28131,6 @@ bool register_all_scene(se::Object* obj) {
|
||||
js_register_cc_Node_UserData(ns);
|
||||
js_register_cc_Scene(ns);
|
||||
js_register_cc_SceneGlobals(ns);
|
||||
js_register_cc_DebugViewConfig(ns);
|
||||
js_register_cc_Root(ns);
|
||||
js_register_cc_scene_IMacroPatch(ns);
|
||||
js_register_cc_scene_Light(ns);
|
||||
|
||||
@@ -96,15 +96,6 @@ extern se::Object *__jsb_cc_SceneGlobals_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_SceneGlobals_class; // NOLINT
|
||||
|
||||
|
||||
JSB_REGISTER_OBJECT_TYPE(cc::DebugViewConfig);
|
||||
extern se::Object *__jsb_cc_DebugViewConfig_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_DebugViewConfig_class; // NOLINT
|
||||
|
||||
|
||||
template<>
|
||||
bool sevalue_to_native(const se::Value &from, cc::DebugViewConfig * to, se::Object *ctx);
|
||||
|
||||
|
||||
JSB_REGISTER_OBJECT_TYPE(cc::Root);
|
||||
extern se::Object *__jsb_cc_Root_proto; // NOLINT
|
||||
extern se::Class * __jsb_cc_Root_class; // NOLINT
|
||||
|
||||
@@ -37,6 +37,11 @@ HandleObject::HandleObject(Object *obj)
|
||||
}
|
||||
}
|
||||
|
||||
HandleObject::HandleObject(HandleObject &&o) noexcept{
|
||||
_obj = o._obj;
|
||||
o._obj = nullptr;
|
||||
}
|
||||
|
||||
HandleObject::~HandleObject() {
|
||||
if (_obj != nullptr) {
|
||||
_obj->unroot();
|
||||
@@ -44,4 +49,10 @@ HandleObject::~HandleObject() {
|
||||
}
|
||||
}
|
||||
|
||||
HandleObject& HandleObject::operator=(HandleObject &&o) noexcept {
|
||||
_obj = o._obj;
|
||||
o._obj = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace se
|
||||
|
||||
@@ -97,11 +97,11 @@ public:
|
||||
inline bool isEmpty() const {
|
||||
return (_obj == nullptr);
|
||||
}
|
||||
HandleObject(HandleObject &&) noexcept;
|
||||
HandleObject& operator=(HandleObject &&) noexcept;
|
||||
|
||||
HandleObject(const HandleObject &) = delete;
|
||||
void operator=(const HandleObject &) = delete;
|
||||
HandleObject(HandleObject &&) = delete;
|
||||
void operator=(HandleObject &&) = delete;
|
||||
HandleObject& operator=(const HandleObject &) = delete;
|
||||
|
||||
void *operator new(size_t size) = delete;
|
||||
void operator delete(void *, size_t) = delete;
|
||||
|
||||
@@ -150,6 +150,13 @@ void Object::cleanup() {
|
||||
SE_ASSERT(NativePtrToObjectMap::size() == 0, "NativePtrToObjectMap should be empty!");
|
||||
}
|
||||
|
||||
Object *Object::createProxyTarget(se::Object *proxy) {
|
||||
SE_ASSERT(proxy->isProxy(), "parameter is not a Proxy object");
|
||||
v8::Local<v8::Object> jsobj = proxy->getProxyTarget().As<v8::Object>();
|
||||
Object *obj = Object::_createJSObject(nullptr, jsobj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
Object *Object::createPlainObject() {
|
||||
v8::Local<v8::Object> jsobj = v8::Object::New(__isolate);
|
||||
Object *obj = _createJSObject(nullptr, jsobj);
|
||||
@@ -564,6 +571,17 @@ bool Object::isTypedArray() const {
|
||||
return const_cast<Object *>(this)->_obj.handle(__isolate)->IsTypedArray();
|
||||
}
|
||||
|
||||
bool Object::isProxy() const {
|
||||
return const_cast<Object *>(this)->_obj.handle(__isolate)->IsProxy();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Object::getProxyTarget() const {
|
||||
v8::Local<v8::Value> value = const_cast<Object *>(this)->_obj.handle(__isolate);
|
||||
CC_ASSERTF(value->IsProxy(), "Object is not a Proxy");
|
||||
v8::Proxy *proxy = v8::Proxy::Cast(*value);
|
||||
return proxy->GetTarget();
|
||||
}
|
||||
|
||||
Object::TypedArrayType Object::getTypedArrayType() const {
|
||||
v8::Local<v8::Value> value = const_cast<Object *>(this)->_obj.handle(__isolate);
|
||||
TypedArrayType ret = TypedArrayType::NONE;
|
||||
@@ -794,8 +812,7 @@ bool Object::getArrayLength(uint32_t *length) const {
|
||||
CC_ASSERT(isArray());
|
||||
CC_ASSERT_NOT_NULL(length);
|
||||
auto *thiz = const_cast<Object *>(this);
|
||||
|
||||
v8::Local<v8::Array> v8Arr = v8::Local<v8::Array>::Cast(thiz->_obj.handle(__isolate));
|
||||
auto v8Arr = v8::Local<v8::Array>::Cast(thiz->_obj.handle(__isolate));
|
||||
*length = v8Arr->Length();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -177,6 +177,13 @@ public:
|
||||
*/
|
||||
static Object *createObjectWithConstructor(se::Object *constructor, const ValueArray &args);
|
||||
|
||||
/**
|
||||
* Gets the Proxy Target object
|
||||
* @param proxy The JavaScript Proxy object.
|
||||
* @return The target JavaScript object of the parameter.
|
||||
*/
|
||||
static Object *createProxyTarget(se::Object *proxy);
|
||||
|
||||
/**
|
||||
* @brief Gets a se::Object from an existing native object pointer.
|
||||
* @param[in] ptr The native object pointer associated with the se::Object
|
||||
@@ -314,6 +321,11 @@ public:
|
||||
*/
|
||||
bool isTypedArray() const;
|
||||
|
||||
/** @brief Tests whether an object is a proxy object.
|
||||
* @return true if object is a proxy object, otherwise false.
|
||||
*/
|
||||
bool isProxy() const;
|
||||
|
||||
/**
|
||||
* @brief Gets the type of a typed array object.
|
||||
* @return The type of a typed array object.
|
||||
@@ -656,6 +668,7 @@ private:
|
||||
~Object() override;
|
||||
|
||||
bool init(Class *cls, v8::Local<v8::Object> obj);
|
||||
v8::Local<v8::Value> getProxyTarget() const;
|
||||
|
||||
Class *_cls{nullptr};
|
||||
ObjectWrap _obj;
|
||||
|
||||
@@ -195,17 +195,25 @@ seval_to_type(const se::Value &v, bool &ok) { // NOLINT(readability-identifier-n
|
||||
return v.toString();
|
||||
}
|
||||
|
||||
inline se::HandleObject unwrapProxyObject(se::Object *obj) {
|
||||
if(obj->isProxy()) {
|
||||
return se::HandleObject(se::Object::createProxyTarget(obj));
|
||||
}
|
||||
obj->incRef();
|
||||
return se::HandleObject(obj);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_pointer<T>::value && std::is_class<typename std::remove_pointer<T>::type>::value, bool>::type
|
||||
seval_to_std_vector(const se::Value &v, ccstd::vector<T> *ret) { // NOLINT(readability-identifier-naming)
|
||||
CC_ASSERT_NOT_NULL(ret);
|
||||
CC_ASSERT(v.isObject());
|
||||
se::Object *obj = v.toObject();
|
||||
CC_ASSERT(obj->isArray());
|
||||
se::HandleObject array(unwrapProxyObject(v.toObject()));
|
||||
CC_ASSERT(array->isArray());
|
||||
|
||||
bool ok = true;
|
||||
uint32_t len = 0;
|
||||
ok = obj->getArrayLength(&len);
|
||||
ok = array->getArrayLength(&len);
|
||||
if (!ok) {
|
||||
ret->clear();
|
||||
return false;
|
||||
@@ -215,7 +223,7 @@ seval_to_std_vector(const se::Value &v, ccstd::vector<T> *ret) { // NOLINT(reada
|
||||
|
||||
se::Value tmp;
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
ok = obj->getArrayElement(i, &tmp);
|
||||
ok = array->getArrayElement(i, &tmp);
|
||||
if (!ok) {
|
||||
ret->clear();
|
||||
return false;
|
||||
@@ -240,12 +248,12 @@ typename std::enable_if<!std::is_pointer<T>::value, bool>::type
|
||||
seval_to_std_vector(const se::Value &v, ccstd::vector<T> *ret) { // NOLINT(readability-identifier-naming)
|
||||
CC_ASSERT_NOT_NULL(ret);
|
||||
CC_ASSERT(v.isObject());
|
||||
se::Object *obj = v.toObject();
|
||||
CC_ASSERT(obj->isArray());
|
||||
se::HandleObject array(unwrapProxyObject(v.toObject()));
|
||||
CC_ASSERT(array->isArray());
|
||||
|
||||
bool ok = true;
|
||||
uint32_t len = 0;
|
||||
ok = obj->getArrayLength(&len);
|
||||
ok = array->getArrayLength(&len);
|
||||
if (!ok) {
|
||||
ret->clear();
|
||||
return false;
|
||||
@@ -255,7 +263,7 @@ seval_to_std_vector(const se::Value &v, ccstd::vector<T> *ret) { // NOLINT(reada
|
||||
|
||||
se::Value tmp;
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
ok = obj->getArrayElement(i, &tmp);
|
||||
ok = array->getArrayElement(i, &tmp);
|
||||
if (!ok) {
|
||||
ret->clear();
|
||||
return false;
|
||||
@@ -709,8 +717,8 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector<T> *to, se::Object *
|
||||
}
|
||||
|
||||
CC_ASSERT(from.toObject());
|
||||
se::Object *array = from.toObject();
|
||||
|
||||
se::HandleObject array(unwrapProxyObject(from.toObject()));
|
||||
|
||||
if (array->isArray()) {
|
||||
uint32_t len = 0;
|
||||
array->getArrayLength(&len);
|
||||
|
||||
@@ -265,6 +265,14 @@ static void registerLocalPositionRotationScaleUpdated(cc::Node *node, se::Object
|
||||
});
|
||||
}
|
||||
|
||||
static void registerOnLightProbeBakingChanged(cc::Node *node, se::Object *jsObject) {
|
||||
node->on<cc::Node::LightProbeBakingChanged>(
|
||||
[jsObject](cc::Node * /*emitter*/) {
|
||||
se::AutoHandleScope hs;
|
||||
se::ScriptEngine::getInstance()->callFunction(jsObject, "_onLightProbeBakingChanged", 0, nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
static bool js_scene_Node_registerListeners(se::State &s) // NOLINT(readability-identifier-naming)
|
||||
{
|
||||
auto *cobj = SE_THIS_OBJECT<cc::Node>(s);
|
||||
@@ -405,6 +413,18 @@ static bool js_scene_Node_registerOnSiblingOrderChanged(se::State &s) // NOLINT(
|
||||
}
|
||||
SE_BIND_FUNC(js_scene_Node_registerOnSiblingOrderChanged) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool js_scene_Node_registerOnLightProbeBakingChanged(se::State &s) // NOLINT(readability-identifier-naming)
|
||||
{
|
||||
auto *cobj = SE_THIS_OBJECT<cc::Node>(s);
|
||||
SE_PRECONDITION2(cobj, false, "Invalid Native Object");
|
||||
|
||||
auto *jsObject = s.thisObject();
|
||||
|
||||
registerOnLightProbeBakingChanged(cobj, jsObject);
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_scene_Node_registerOnLightProbeBakingChanged) // NOLINT(readability-identifier-naming)
|
||||
|
||||
static bool js_scene_Camera_screenPointToRay(void *nativeObject) // NOLINT(readability-identifier-naming)
|
||||
{
|
||||
auto *cobj = reinterpret_cast<cc::scene::Camera *>(nativeObject);
|
||||
@@ -828,6 +848,7 @@ bool register_all_scene_manual(se::Object *obj) // NOLINT(readability-identifier
|
||||
__jsb_cc_Node_proto->defineFunction("_registerOnChildRemoved", _SE(js_scene_Node_registerOnChildRemoved));
|
||||
__jsb_cc_Node_proto->defineFunction("_registerOnChildAdded", _SE(js_scene_Node_registerOnChildAdded));
|
||||
__jsb_cc_Node_proto->defineFunction("_registerOnSiblingOrderChanged", _SE(js_scene_Node_registerOnSiblingOrderChanged));
|
||||
__jsb_cc_Node_proto->defineFunction("_registerOnLightProbeBakingChanged", _SE(js_scene_Node_registerOnLightProbeBakingChanged));
|
||||
|
||||
se::Value jsbVal;
|
||||
obj->getProperty("jsb", &jsbVal);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "2d/renderer/Batcher2d.h"
|
||||
#include "application/ApplicationManager.h"
|
||||
#include "bindings/event/EventDispatcher.h"
|
||||
#include "pipeline/custom/RenderingModule.h"
|
||||
#include "platform/interfaces/modules/IScreen.h"
|
||||
#include "platform/interfaces/modules/ISystemWindow.h"
|
||||
#include "platform/interfaces/modules/ISystemWindowManager.h"
|
||||
@@ -92,6 +93,8 @@ void Root::initialize(gfx::Swapchain * /*swapchain*/) {
|
||||
uint32_t maxJoints = (_device->getCapabilities().maxVertexUniformVectors - usedUBOVectorCount) / 3;
|
||||
maxJoints = maxJoints < 256 ? maxJoints : 256;
|
||||
pipeline::localDescriptorSetLayoutResizeMaxJoints(maxJoints);
|
||||
|
||||
_debugView = std::make_unique<pipeline::DebugView>();
|
||||
}
|
||||
|
||||
render::Pipeline *Root::getCustomPipeline() const {
|
||||
@@ -161,6 +164,8 @@ void Root::destroy() {
|
||||
}
|
||||
_swapchains.clear();
|
||||
|
||||
_debugView.reset();
|
||||
|
||||
// TODO(minggo):
|
||||
// this.dataPoolManager.clear();
|
||||
}
|
||||
@@ -316,8 +321,8 @@ bool Root::setRenderPipeline(pipeline::RenderPipeline *rppl /* = nullptr*/) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
_pipelineRuntime = std::make_unique<render::NativePipeline>(
|
||||
boost::container::pmr::get_default_resource());
|
||||
CC_ASSERT(!_pipelineRuntime);
|
||||
_pipelineRuntime.reset(render::Factory::createPipeline());
|
||||
if (!_pipelineRuntime->activate(_mainRenderWindow->getSwapchain())) {
|
||||
_pipelineRuntime->destroy();
|
||||
_pipelineRuntime.reset();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "core/event/Event.h"
|
||||
#include "core/memop/Pool.h"
|
||||
#include "renderer/pipeline/RenderPipeline.h"
|
||||
#include "renderer/pipeline/DebugView.h"
|
||||
#include "scene/DrawBatch2D.h"
|
||||
#include "scene/Light.h"
|
||||
#include "scene/Model.h"
|
||||
@@ -52,14 +53,6 @@ class Pipeline;
|
||||
} // namespace render
|
||||
class Batcher2d;
|
||||
|
||||
struct CC_DLL DebugViewConfig {
|
||||
uint8_t singleMode;
|
||||
uint8_t compositeModeBitCount;
|
||||
uint32_t compositeModeValue;
|
||||
bool lightingWithAlbedo;
|
||||
bool csmLayerColoration;
|
||||
};
|
||||
|
||||
struct ISystemWindowInfo;
|
||||
class ISystemWindow;
|
||||
|
||||
@@ -255,8 +248,7 @@ public:
|
||||
* @zh
|
||||
* 渲染调试数据
|
||||
*/
|
||||
inline void setDebugViewConfig(const DebugViewConfig &config) { _debugViewConfig = config; }
|
||||
inline const DebugViewConfig &getDebugViewConfig() const { return _debugViewConfig; }
|
||||
inline pipeline::DebugView *getDebugView() const { return _debugView.get(); }
|
||||
|
||||
/**
|
||||
* @zh
|
||||
@@ -320,7 +312,7 @@ private:
|
||||
std::unique_ptr<render::PipelineRuntime> _pipelineRuntime;
|
||||
// IntrusivePtr<DataPoolManager> _dataPoolMgr;
|
||||
ccstd::vector<IntrusivePtr<scene::RenderScene>> _scenes;
|
||||
DebugViewConfig _debugViewConfig;
|
||||
std::unique_ptr<pipeline::DebugView> _debugView;
|
||||
float _cumulativeTime{0.F};
|
||||
float _frameTime{0.F};
|
||||
float _fpsTime{0.F};
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "core/assets/EffectAsset.h"
|
||||
#include "ProgramUtils.h"
|
||||
#include "cocos.h"
|
||||
#include "core/Root.h"
|
||||
#include "core/platform/Debug.h"
|
||||
#include "cocos/renderer/pipeline/custom/RenderingModule.h"
|
||||
#include "engine/BaseEngine.h"
|
||||
#include "renderer/core/ProgramLib.h"
|
||||
|
||||
@@ -164,7 +166,13 @@ EffectAsset *EffectAsset::get(const ccstd::string &name) {
|
||||
}
|
||||
|
||||
void EffectAsset::onLoaded() {
|
||||
ProgramLib::getInstance()->registerEffect(this);
|
||||
auto *programLib = render::getProgramLibrary();
|
||||
if (programLib) {
|
||||
render::addEffectDefaultProperties(*this);
|
||||
programLib->addEffect(this);
|
||||
} else {
|
||||
ProgramLib::getInstance()->registerEffect(this);
|
||||
}
|
||||
EffectAsset::registerAsset(this);
|
||||
#if !CC_EDITOR
|
||||
if (CC_CURRENT_ENGINE()->isInited()) {
|
||||
|
||||
@@ -374,6 +374,8 @@ struct IPassInfoFull final { // cjh } : public IPassInfo {
|
||||
// IPassInfoFull
|
||||
// generated part
|
||||
index_t passIndex{0};
|
||||
uint32_t passID = 0xFFFFFFFF;
|
||||
uint32_t phaseID = 0xFFFFFFFF;
|
||||
MacroRecord defines;
|
||||
ccstd::optional<PassOverrides> stateOverrides;
|
||||
|
||||
@@ -542,6 +544,12 @@ struct IShaderInfo {
|
||||
if (version == "glsl4") return &glsl4;
|
||||
return nullptr;
|
||||
}
|
||||
IShaderSource *getSource(const ccstd::string &version) {
|
||||
if (version == "glsl1") return &glsl1;
|
||||
if (version == "glsl3") return &glsl3;
|
||||
if (version == "glsl4") return &glsl4;
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
using IPreCompileInfoValueType = ccstd::variant<ccstd::monostate, ccstd::vector<bool>, ccstd::vector<int32_t>, ccstd::vector<ccstd::string>>;
|
||||
|
||||
@@ -222,6 +222,7 @@ ccstd::unordered_map<uint32_t, ccstd::string> debugInfos = {
|
||||
{ 4300, "Can not found the %s page." },
|
||||
{ 4301, "Can not add a page without UITransform." },
|
||||
{ 4302, "Can not set the scroll view content when it hasn't UITransform or its parent hasn't UITransform." },
|
||||
{ 4303, "The %s scrollBar on the '%s' node is not available, please check it." },
|
||||
{ 4400, "Invalid RichText img tag! The sprite frame name can't be found in the ImageAtlas!" },
|
||||
{ 4500, "Graphics: There is no model in %s." },
|
||||
{ 4600, "Script attached to '%s' is missing or invalid." },
|
||||
@@ -459,6 +460,7 @@ ccstd::unordered_map<uint32_t, ccstd::string> debugInfos = {
|
||||
{ 16101, "The effect('%s') you are looking for does not exist, please confirm the effect name in the editor. NOTE: Since 3.6, the name of the built-in effect has been changed to its name in the editor, please check it out. More information please refer to https://docs.cocos.com/creator/manual/en/shader/effect-inspector.html" },
|
||||
{ 16201, "The asset replacing failed, can not found override asset('%s') for '%s'" },
|
||||
{ 16301, "node '%s' doesn't have any ModelRenderer component, this component will not work. please add ModelRenderer component first" },
|
||||
{ 16302, "There is no reflection probe in the scene or no probe is near the current object. No reflection probe will take effect on this object. Please create a new reflection probe or move existing ones closer." },
|
||||
|
||||
};
|
||||
}//namespace cc
|
||||
|
||||
@@ -648,7 +648,7 @@ int aabbFrustum(const AABB &aabb, const Frustum &frustum) {
|
||||
int aabbFrustumCompletelyInside(const AABB &aabb, const Frustum &frustum) {
|
||||
for (const auto &plane : frustum.planes) {
|
||||
// frustum plane normal points to the inside
|
||||
if (aabbPlane(aabb, *plane) == 0) {
|
||||
if (aabbPlane(aabb, *plane) != 0) {
|
||||
return 0;
|
||||
}
|
||||
} // completely inside
|
||||
|
||||
@@ -91,6 +91,7 @@ class Node : public CCObject {
|
||||
TARGET_EVENT_ARG3(LocalScaleUpdated, float, float, float)
|
||||
TARGET_EVENT_ARG10(LocalRTSUpdated, float, float, float, float, float, float, float, float, float, float)
|
||||
TARGET_EVENT_ARG1(EditorAttached, bool)
|
||||
TARGET_EVENT_ARG0(LightProbeBakingChanged)
|
||||
DECLARE_TARGET_EVENT_END()
|
||||
public:
|
||||
class UserData : public RefCounted {
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "renderer/GFXDeviceManager.h"
|
||||
#include "renderer/core/ProgramLib.h"
|
||||
#include "renderer/pipeline/RenderPipeline.h"
|
||||
#include "renderer/pipeline/custom/RenderingModule.h"
|
||||
|
||||
#if CC_USE_AUDIO
|
||||
#include "cocos/audio/include/AudioEngine.h"
|
||||
@@ -191,6 +192,11 @@ void Engine::destroy() {
|
||||
|
||||
delete _builtinResMgr;
|
||||
delete _programLib;
|
||||
|
||||
if (cc::render::getRenderingModule()) {
|
||||
cc::render::Factory::destroy(cc::render::getRenderingModule());
|
||||
}
|
||||
|
||||
CC_SAFE_DESTROY_AND_DELETE(_gfxDevice);
|
||||
delete _fs;
|
||||
_scheduler.reset();
|
||||
@@ -225,9 +231,9 @@ void Engine::close() { // NOLINT
|
||||
cc::AudioEngine::stopAll();
|
||||
#endif
|
||||
|
||||
//#if CC_USE_SOCKET
|
||||
// cc::network::WebSocket::closeAllConnections();
|
||||
//#endif
|
||||
// #if CC_USE_SOCKET
|
||||
// cc::network::WebSocket::closeAllConnections();
|
||||
// #endif
|
||||
|
||||
cc::DeferredReleasePool::clear();
|
||||
_scheduler->removeAllFunctionsToBePerformedInCocosThread();
|
||||
@@ -266,7 +272,7 @@ void Engine::tick() {
|
||||
|
||||
// iOS/macOS use its own fps limitation algorithm.
|
||||
// Windows for Editor should not sleep,because Editor call tick function synchronously
|
||||
#if (CC_PLATFORM == CC_PLATFORM_ANDROID || (CC_PLATFORM == CC_PLATFORM_WINDOWS && !defined(CC_EDITOR)) || CC_PLATFORM == CC_PLATFORM_OHOS) || (defined(CC_SERVER_MODE) && (CC_PLATFORM == CC_PLATFORM_MAC_OSX))
|
||||
#if (CC_PLATFORM == CC_PLATFORM_ANDROID || (CC_PLATFORM == CC_PLATFORM_WINDOWS && !CC_EDITOR) || CC_PLATFORM == CC_PLATFORM_OHOS) || (defined(CC_SERVER_MODE) && (CC_PLATFORM == CC_PLATFORM_MAC_OSX))
|
||||
if (dtNS < static_cast<double>(_prefererredNanosecondsPerFrame)) {
|
||||
CC_PROFILE(EngineSleep);
|
||||
std::this_thread::sleep_for(
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "LightProbe.h"
|
||||
#include "PolynomialSolver.h"
|
||||
#include "core/Root.h"
|
||||
#include "core/scene-graph/Node.h"
|
||||
#include "core/scene-graph/Scene.h"
|
||||
#include "math/Math.h"
|
||||
#include "math/Utils.h"
|
||||
@@ -205,6 +206,15 @@ void LightProbeInfo::activate(Scene *scene, LightProbes *resource) {
|
||||
_resource->initialize(this);
|
||||
}
|
||||
|
||||
void LightProbeInfo::onProbeBakeFinished() {
|
||||
onProbeBakingChanged(_scene);
|
||||
}
|
||||
|
||||
void LightProbeInfo::onProbeBakeCleared() {
|
||||
clearSHCoefficients();
|
||||
onProbeBakingChanged(_scene);
|
||||
}
|
||||
|
||||
void LightProbeInfo::clearSHCoefficients() {
|
||||
if (!_data) {
|
||||
return;
|
||||
@@ -293,6 +303,19 @@ void LightProbeInfo::update(bool updateTet) {
|
||||
}
|
||||
}
|
||||
|
||||
void LightProbeInfo::onProbeBakingChanged(Node *node) { // NOLINT(misc-no-recursion)
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
node->emit<Node::LightProbeBakingChanged>();
|
||||
|
||||
const auto &children = node->getChildren();
|
||||
for (const auto &child: children) {
|
||||
onProbeBakingChanged(child);
|
||||
}
|
||||
}
|
||||
|
||||
void LightProbeInfo::clearAllSHUBOs() {
|
||||
if (!_scene) {
|
||||
return;
|
||||
|
||||
@@ -59,11 +59,11 @@ public:
|
||||
void updateProbes(ccstd::vector<Vec3> &points);
|
||||
void updateTetrahedrons();
|
||||
|
||||
inline bool hasCoefficients() const { return !empty() && !_probes[0].coefficients.empty(); }
|
||||
bool getInterpolationSHCoefficients(int32_t tetIndex, const Vec4 &weights, ccstd::vector<Vec3> &coefficients) const;
|
||||
int32_t getInterpolationWeights(const Vec3 &position, int32_t tetIndex, Vec4 &weights) const;
|
||||
|
||||
private:
|
||||
inline bool hasCoefficients() const { return !empty() && !_probes[0].coefficients.empty(); }
|
||||
static Vec3 getTriangleBarycentricCoord(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &position);
|
||||
void getBarycentricCoord(const Vec3 &position, const Tetrahedron &tetrahedron, Vec4 &weights) const;
|
||||
void getTetrahedronBarycentricCoord(const Vec3 &position, const Tetrahedron &tetrahedron, Vec4 &weights) const;
|
||||
@@ -137,6 +137,8 @@ public:
|
||||
~LightProbeInfo() override = default;
|
||||
|
||||
void activate(Scene *scene, LightProbes *resource);
|
||||
void onProbeBakeFinished();
|
||||
void onProbeBakeCleared();
|
||||
void clearSHCoefficients();
|
||||
inline bool isUniqueNode() const { return _nodes.size() == 1; }
|
||||
bool addNode(Node *node);
|
||||
@@ -248,6 +250,7 @@ public:
|
||||
IntrusivePtr<LightProbesData> _data;
|
||||
|
||||
private:
|
||||
void onProbeBakingChanged(Node *node);
|
||||
void clearAllSHUBOs();
|
||||
void resetAllTetraIndices();
|
||||
|
||||
|
||||
@@ -557,7 +557,7 @@ bool Mat4::decompose(Vec3 *scale, Quaternion *rotation, Vec3 *translation) const
|
||||
// In this case, we simply negate a single axis of the scale.
|
||||
float det = determinant();
|
||||
if (det < 0) {
|
||||
scaleZ = -scaleZ;
|
||||
scaleX = -scaleX;
|
||||
}
|
||||
|
||||
if (scale) {
|
||||
@@ -595,10 +595,10 @@ bool Mat4::decompose(Vec3 *scale, Quaternion *rotation, Vec3 *translation) const
|
||||
zaxis.z *= rn;
|
||||
|
||||
// Now calculate the rotation from the resulting matrix (axes).
|
||||
float trace = xaxis.x + yaxis.y + zaxis.z + 1.0F;
|
||||
float trace = xaxis.x + yaxis.y + zaxis.z;
|
||||
|
||||
if (trace > MATH_EPSILON) {
|
||||
float s = 0.5F / std::sqrt(trace);
|
||||
if (trace > 0.0F) {
|
||||
float s = 0.5F / std::sqrt(trace + 1.0F);
|
||||
rotation->w = 0.25F / s;
|
||||
rotation->x = (yaxis.z - zaxis.y) * s;
|
||||
rotation->y = (zaxis.x - xaxis.z) * s;
|
||||
|
||||
+7
-3
@@ -416,9 +416,13 @@ public class CanvasRenderingContext2DImpl {
|
||||
}
|
||||
|
||||
private void configShadow(Paint paint) {
|
||||
if (mShadowColorA > 0 && (Math.abs(mShadowOffsetX) > Float.MIN_VALUE ||
|
||||
Math.abs(mShadowOffsetY) > Float.MIN_VALUE ||
|
||||
mShadowBlur > Float.MIN_VALUE)) {
|
||||
if (mShadowColorA > 0 && (Math.abs(mShadowOffsetX) > Float.MIN_VALUE || Math.abs(mShadowOffsetY) > Float.MIN_VALUE)) {
|
||||
if (mShadowBlur < 0) {
|
||||
return;
|
||||
}
|
||||
if (mShadowBlur < Float.MIN_VALUE) {
|
||||
mShadowBlur = 0.001f;//If shadowBlur is 0, the shadow effect is not consistent with the web.
|
||||
}
|
||||
paint.setShadowLayer(mShadowBlur, mShadowOffsetX, mShadowOffsetY,
|
||||
Color.argb(mShadowColorA, mShadowColorR, mShadowColorG, mShadowColorB));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package com.cocos.lib;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
@@ -34,6 +36,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.graphics.drawable.shapes.RoundRectShape;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
@@ -52,8 +55,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class CocosEditBoxActivity extends Activity {
|
||||
|
||||
@@ -83,6 +85,7 @@ public class CocosEditBoxActivity extends Activity {
|
||||
private float mLineWidth = 2f;
|
||||
private boolean keyboardVisible = false;
|
||||
private int mScreenHeight;
|
||||
private boolean mCheckKeyboardShowNormally = false;
|
||||
|
||||
public Cocos2dxEditText(Activity context){
|
||||
super(context);
|
||||
@@ -185,6 +188,7 @@ public class CocosEditBoxActivity extends Activity {
|
||||
}
|
||||
|
||||
private void setInputType(final String inputType, boolean isMultiLine){
|
||||
mCheckKeyboardShowNormally = false;
|
||||
if (inputType.contentEquals("text")) {
|
||||
if (isMultiLine)
|
||||
this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
@@ -197,8 +201,12 @@ public class CocosEditBoxActivity extends Activity {
|
||||
this.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);
|
||||
else if (inputType.contentEquals("phone"))
|
||||
this.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||
else if (inputType.contentEquals("password"))
|
||||
else if (inputType.contentEquals("password")) {
|
||||
if (Build.BRAND.equalsIgnoreCase("oppo")) {
|
||||
mCheckKeyboardShowNormally = true;
|
||||
}
|
||||
this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
}
|
||||
else
|
||||
Log.e(TAG, "unknown input type " + inputType);
|
||||
}
|
||||
@@ -238,6 +246,9 @@ public class CocosEditBoxActivity extends Activity {
|
||||
keyboardVisible = true;
|
||||
}
|
||||
} else {
|
||||
if (mCheckKeyboardShowNormally && !keyboardVisible) {
|
||||
Toast.makeText(CocosEditBoxActivity.this, R.string.tip_disable_safe_input_type, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
if (keyboardVisible) {
|
||||
keyboardVisible = false;
|
||||
CocosEditBoxActivity.this.hide();
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
<string name="search" translatable="false">搜索</string>
|
||||
<string name="go" translatable="false">前往</string>
|
||||
<string name="send" translatable="false">发送</string>
|
||||
<string name="tip_disable_safe_input_type" translatable="false">请到系统设置关闭安全键盘</string>
|
||||
</resources>
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
<string name="search" translatable="false">Search</string>
|
||||
<string name="go" translatable="false">Go</string>
|
||||
<string name="send" translatable="false">Send</string>
|
||||
<string name="tip_disable_safe_input_type" translatable="false">Please go to the system settings to turn off the security keyboard!</string>
|
||||
</resources>
|
||||
|
||||
@@ -145,10 +145,10 @@ public class CocosXRGLHelper {
|
||||
+ "precision mediump float; \n"
|
||||
+ "in vec2 texCoord; \n"
|
||||
+ "uniform samplerExternalOES texSampler2D; \n"
|
||||
+ "out vec4 gl_FragColor;\n"
|
||||
+ "out vec4 frag_color;\n"
|
||||
+ "void main() \n"
|
||||
+ "{ \n"
|
||||
+ " gl_FragColor = texture(texSampler2D, texCoord); \n"
|
||||
+ " frag_color = texture(texSampler2D, texCoord); \n"
|
||||
+ "}";
|
||||
float[] orthoQuadVertices = {
|
||||
-1.0f, -1.0f, 0.0f, 1.0f,
|
||||
|
||||
@@ -421,6 +421,7 @@ public class CocosXRVideoManager {
|
||||
for (Map.Entry<String, CocosXRVideoPlayer> entrySet : entrySets) {
|
||||
entrySet.getValue().onGLDestroy();
|
||||
}
|
||||
GLES30.glDeleteFramebuffers(1, new int[] {renderTargetFboId}, 0);
|
||||
EGL14.eglMakeCurrent(eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
|
||||
EGL14.eglDestroySurface(eglDisplay, pBufferSurface);
|
||||
EGL14.eglDestroyContext(eglDisplay, eglContext);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
namespace cc {
|
||||
|
||||
float Battery::getBatteryLevel() const {
|
||||
// set batteryMonitoringEnabled value to YES otherwise batteryLevel is always -1
|
||||
[UIDevice currentDevice].batteryMonitoringEnabled = YES;
|
||||
return [UIDevice currentDevice].batteryLevel;
|
||||
}
|
||||
|
||||
|
||||
@@ -268,14 +268,46 @@
|
||||
}
|
||||
|
||||
- (void)sendMouseEvent:(int)button type:(cc::MouseEvent::Type)type event:(NSEvent *)event {
|
||||
const NSRect contentRect = [self frame];
|
||||
const NSPoint pos = [event locationInWindow];
|
||||
|
||||
_mouseEvent.windowId = [self getWindowId];
|
||||
_mouseEvent.type = type;
|
||||
_mouseEvent.button = button;
|
||||
_mouseEvent.x = pos.x;
|
||||
_mouseEvent.y = contentRect.size.height - pos.y;
|
||||
|
||||
auto *windowMgr = CC_GET_PLATFORM_INTERFACE(cc::SystemWindowManager);
|
||||
auto *window = static_cast<cc::SystemWindow*>( windowMgr->getWindowFromNSWindow([self window]));
|
||||
const NSRect contentRect = [self frame];
|
||||
if(!window->isPointerLock()) {
|
||||
const NSPoint pos = [event locationInWindow];
|
||||
_mouseEvent.x = pos.x;
|
||||
_mouseEvent.y = contentRect.size.height - pos.y;
|
||||
} else {
|
||||
if(type == cc::MouseEvent::Type::MOVE) {
|
||||
// Out of window only happens when mouse is moved.
|
||||
_mouseEvent.x = _mouseEvent.x + [event deltaX];
|
||||
_mouseEvent.y = _mouseEvent.y + [event deltaY];
|
||||
float xMin = 0, xMax = 0;
|
||||
float yMin = 0, yMax = 0;
|
||||
xMax = contentRect.size.width;
|
||||
yMax = contentRect.size.height;
|
||||
--xMax;
|
||||
--yMax;
|
||||
if (_mouseEvent.x > xMax) {
|
||||
_mouseEvent.x = xMax;
|
||||
} else if (_mouseEvent.x < xMin) {
|
||||
_mouseEvent.x = xMin;
|
||||
}
|
||||
|
||||
if (_mouseEvent.y > yMax) {
|
||||
_mouseEvent.y = yMax;
|
||||
} else if (_mouseEvent.y < yMin) {
|
||||
_mouseEvent.y = yMin;
|
||||
}
|
||||
}
|
||||
auto mainDisplayId = CGMainDisplayID();
|
||||
float windowX = contentRect.origin.x;
|
||||
float windowY =
|
||||
CGDisplayPixelsHigh(mainDisplayId) - contentRect.origin.y - contentRect.size.height;
|
||||
window->setLastMousePos(windowX + _mouseEvent.x, windowY + _mouseEvent.y);
|
||||
}
|
||||
cc::events::Mouse::broadcast(_mouseEvent);
|
||||
}
|
||||
- (int)getWindowId {
|
||||
|
||||
@@ -57,8 +57,13 @@ public:
|
||||
*/
|
||||
void setCursorEnabled(bool value) override;
|
||||
void copyTextToClipboard(const std::string& text) override;
|
||||
|
||||
|
||||
bool isPointerLock() const;
|
||||
void setLastMousePos(float x, float y);
|
||||
private:
|
||||
bool _pointerLock{false};
|
||||
float _lastMousePosX{0.0F};
|
||||
float _lastMousePosY{0.0F};
|
||||
int32_t _width{0};
|
||||
int32_t _height{0};
|
||||
|
||||
|
||||
@@ -43,7 +43,9 @@ SystemWindow::SystemWindow(uint32_t windowId, void *externalHandle)
|
||||
}
|
||||
}
|
||||
|
||||
SystemWindow::~SystemWindow() = default;
|
||||
SystemWindow::~SystemWindow() {
|
||||
setCursorEnabled(true);
|
||||
}
|
||||
|
||||
bool SystemWindow::createWindow(const char *title,
|
||||
int w, int h, int flags) {
|
||||
@@ -98,6 +100,22 @@ void SystemWindow::closeWindow() {
|
||||
}
|
||||
|
||||
void SystemWindow::setCursorEnabled(bool value) {
|
||||
CGError result;
|
||||
if(value) {
|
||||
result = CGAssociateMouseAndMouseCursorPosition(YES);
|
||||
[NSCursor unhide];
|
||||
if(_pointerLock) {
|
||||
CGPoint point =
|
||||
CGPointMake((float)_lastMousePosX, _lastMousePosY);
|
||||
CGWarpMouseCursorPosition(point);
|
||||
}
|
||||
_pointerLock = false;
|
||||
} else {
|
||||
result = CGAssociateMouseAndMouseCursorPosition(NO);
|
||||
[NSCursor hide];
|
||||
_pointerLock = true;
|
||||
}
|
||||
CC_ASSERT(result == kCGErrorSuccess);
|
||||
}
|
||||
|
||||
void SystemWindow::copyTextToClipboard(const std::string &text) {
|
||||
@@ -120,4 +138,13 @@ uint32_t SystemWindow::getWindowId() const {
|
||||
return _windowId;
|
||||
}
|
||||
|
||||
bool SystemWindow::isPointerLock() const {
|
||||
return _pointerLock;
|
||||
}
|
||||
|
||||
void SystemWindow::setLastMousePos(float x, float y) {
|
||||
_lastMousePosX = x;
|
||||
_lastMousePosY = y;
|
||||
}
|
||||
|
||||
} // namespace cc
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2021-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
@@ -22,16 +22,17 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "renderer/core/PassInstance.h"
|
||||
#include <cstdint>
|
||||
#include "renderer/core/MaterialInstance.h"
|
||||
#include "renderer/core/ProgramLib.h"
|
||||
#include "renderer/pipeline/BatchedBuffer.h"
|
||||
#include "renderer/pipeline/InstancedBuffer.h"
|
||||
#include "cocos/renderer/core/PassInstance.h"
|
||||
#include "cocos/renderer/core/MaterialInstance.h"
|
||||
#include "cocos/renderer/core/ProgramLib.h"
|
||||
#include "cocos/renderer/pipeline/BatchedBuffer.h"
|
||||
#include "cocos/renderer/pipeline/InstancedBuffer.h"
|
||||
#include "cocos/renderer/pipeline/custom/RenderingModule.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
PassInstance::PassInstance(scene::Pass *parent, MaterialInstance *owner) : Super(parent->getRoot()), _parent(parent), _owner(owner) {
|
||||
PassInstance::PassInstance(scene::Pass *parent, MaterialInstance *owner)
|
||||
: Super(parent->getRoot()), _parent(parent), _owner(owner) {
|
||||
doInit(_parent->getPassInfoFull());
|
||||
for (const auto &b : _shaderInfo->blocks) {
|
||||
scene::IBlockRef &block = _blocks[b.binding];
|
||||
@@ -42,14 +43,30 @@ PassInstance::PassInstance(scene::Pass *parent, MaterialInstance *owner) : Super
|
||||
|
||||
_rootBufferDirty = true;
|
||||
gfx::DescriptorSet *parentDescriptorSet = _parent->getDescriptorSet();
|
||||
for (const auto &samplerTexture : _shaderInfo->samplerTextures) {
|
||||
for (uint32_t i = 0; i < samplerTexture.count; ++i) {
|
||||
auto *sampler = parentDescriptorSet->getSampler(samplerTexture.binding, i);
|
||||
auto *texture = parentDescriptorSet->getTexture(samplerTexture.binding, i);
|
||||
_descriptorSet->bindSampler(samplerTexture.binding, sampler, i);
|
||||
_descriptorSet->bindTexture(samplerTexture.binding, texture, i);
|
||||
|
||||
auto *programLib = render::getProgramLibrary();
|
||||
if (programLib) {
|
||||
const auto &set = _shaderInfo->descriptors.at(
|
||||
static_cast<size_t>(pipeline::SetIndex::MATERIAL));
|
||||
for (const auto &samplerTexture : set.samplerTextures) {
|
||||
for (uint32_t i = 0; i < samplerTexture.count; ++i) {
|
||||
auto *sampler = parentDescriptorSet->getSampler(samplerTexture.binding, i);
|
||||
auto *texture = parentDescriptorSet->getTexture(samplerTexture.binding, i);
|
||||
_descriptorSet->bindSampler(samplerTexture.binding, sampler, i);
|
||||
_descriptorSet->bindTexture(samplerTexture.binding, texture, i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const auto &samplerTexture : _shaderInfo->samplerTextures) {
|
||||
for (uint32_t i = 0; i < samplerTexture.count; ++i) {
|
||||
auto *sampler = parentDescriptorSet->getSampler(samplerTexture.binding, i);
|
||||
auto *texture = parentDescriptorSet->getTexture(samplerTexture.binding, i);
|
||||
_descriptorSet->bindSampler(samplerTexture.binding, sampler, i);
|
||||
_descriptorSet->bindTexture(samplerTexture.binding, texture, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Super::tryCompile();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,47 +37,6 @@ namespace cc {
|
||||
|
||||
namespace {
|
||||
|
||||
ccstd::string mapDefine(const IDefineInfo &info, const ccstd::optional<MacroRecord::mapped_type> &def) {
|
||||
if (info.type == "boolean") {
|
||||
return def.has_value() ? (macroRecordAsBool(def.value()) ? "1" : "0") : "0";
|
||||
}
|
||||
if (info.type == "string") {
|
||||
return def.has_value() ? macroRecordAsString(def.value()) : info.options.value()[0];
|
||||
}
|
||||
if (info.type == "number") {
|
||||
return def.has_value() ? macroRecordAsString(def.value()) : std::to_string(info.range.value()[0]);
|
||||
}
|
||||
CC_LOG_WARNING("unknown define type '%s', name: %s", info.type.c_str(), info.name.c_str());
|
||||
return "-1"; // should neven happen
|
||||
}
|
||||
|
||||
ccstd::vector<IMacroInfo> prepareDefines(const MacroRecord &records, const ccstd::vector<IDefineRecord> &defList) {
|
||||
ccstd::vector<IMacroInfo> macros{};
|
||||
for (const auto &tmp : defList) {
|
||||
const auto &name = tmp.name;
|
||||
auto it = records.find(name);
|
||||
auto value = mapDefine(tmp, it == records.end() ? ccstd::nullopt : ccstd::optional<MacroValue>(it->second));
|
||||
bool isDefault = it == records.end() || (ccstd::holds_alternative<ccstd::string>(it->second) && ccstd::get<ccstd::string>(it->second) == "0");
|
||||
macros.emplace_back();
|
||||
auto &info = macros.back();
|
||||
info.name = name;
|
||||
info.value = value;
|
||||
info.isDefault = isDefault;
|
||||
}
|
||||
return macros;
|
||||
}
|
||||
|
||||
ccstd::string getShaderInstanceName(const ccstd::string &name, const ccstd::vector<IMacroInfo> ¯os) {
|
||||
std::stringstream ret;
|
||||
ret << name;
|
||||
for (const auto &cur : macros) {
|
||||
if (!cur.isDefault) {
|
||||
ret << "|" << cur.name << cur.value;
|
||||
}
|
||||
}
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
void insertBuiltinBindings(const IProgramInfo &tmpl, ITemplateInfo &tmplInfo, const pipeline::DescriptorSetLayoutInfos &source,
|
||||
const ccstd::string &type, ccstd::vector<gfx::DescriptorSetLayoutBinding> *outBindings) {
|
||||
CC_ASSERT(type == "locals" || type == "globals");
|
||||
@@ -144,32 +103,6 @@ int32_t getSize(const IBlockInfo &block) {
|
||||
return s;
|
||||
}
|
||||
|
||||
bool dependencyCheck(const ccstd::vector<ccstd::string> &dependencies, const MacroRecord &defines) {
|
||||
for (const auto &d : dependencies) { // NOLINT(readability-use-anyofallof)
|
||||
if (d[0] == '!') { // negative dependency
|
||||
if (defines.find(d.substr(1)) != defines.end()) {
|
||||
return false;
|
||||
}
|
||||
} else if (defines.count(d) == 0 ? true : !macroRecordAsBool(defines.at(d))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ccstd::vector<gfx::Attribute> getActiveAttributes(const IProgramInfo &tmpl, const ITemplateInfo &tmplInfo, const MacroRecord &defines) {
|
||||
ccstd::vector<gfx::Attribute> out{};
|
||||
const auto &attributes = tmpl.attributes;
|
||||
const auto &gfxAttributes = tmplInfo.gfxAttributes;
|
||||
for (auto i = 0; i < attributes.size(); i++) {
|
||||
if (!dependencyCheck(attributes[i].defines, defines)) {
|
||||
continue;
|
||||
}
|
||||
out.emplace_back(gfxAttributes[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const char *getDeviceShaderVersion(const gfx::Device *device) {
|
||||
@@ -214,6 +147,7 @@ void IProgramInfo::copyFrom(const IShaderInfo &o) {
|
||||
buffers = o.buffers;
|
||||
images = o.images;
|
||||
subpassInputs = o.subpassInputs;
|
||||
descriptors = o.descriptors;
|
||||
}
|
||||
|
||||
ProgramLib::ProgramLib() {
|
||||
@@ -245,15 +179,7 @@ void ProgramLib::registerEffect(EffectAsset *effect) {
|
||||
auto *tmpl = define(shader);
|
||||
tmpl->effectName = effect->getName();
|
||||
}
|
||||
|
||||
for (auto &tech : effect->_techniques) {
|
||||
for (auto &pass : tech.passes) {
|
||||
// grab default property declaration if there is none
|
||||
if (pass.propertyIndex.has_value() && !pass.properties.has_value()) {
|
||||
pass.properties = tech.passes[pass.propertyIndex.value()].properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
render::addEffectDefaultProperties(*effect);
|
||||
}
|
||||
|
||||
IProgramInfo *ProgramLib::define(IShaderInfo &shader) {
|
||||
@@ -429,7 +355,7 @@ IProgramInfo *ProgramLib::define(IShaderInfo &shader) {
|
||||
* @param name Target shader name
|
||||
*/
|
||||
|
||||
IProgramInfo *ProgramLib::getTemplate(const ccstd::string &name) {
|
||||
const IProgramInfo *ProgramLib::getTemplate(const ccstd::string &name) const {
|
||||
auto it = _templates.find(name);
|
||||
return it != _templates.end() ? &it->second : nullptr;
|
||||
}
|
||||
@@ -540,7 +466,7 @@ gfx::Shader *ProgramLib::getGFXShader(gfx::Device *device, const ccstd::string &
|
||||
tmplInfo.pipelineLayout = device->createPipelineLayout(gfx::PipelineLayoutInfo{tmplInfo.setLayouts.get()});
|
||||
}
|
||||
|
||||
ccstd::vector<IMacroInfo> macroArray = prepareDefines(defines, tmpl.defines);
|
||||
ccstd::vector<IMacroInfo> macroArray = render::prepareDefines(defines, tmpl.defines);
|
||||
std::stringstream ss;
|
||||
ss << std::endl;
|
||||
for (const auto &m : macroArray) {
|
||||
@@ -559,9 +485,9 @@ gfx::Shader *ProgramLib::getGFXShader(gfx::Device *device, const ccstd::string &
|
||||
tmplInfo.shaderInfo.stages[1].source = prefix + src->frag;
|
||||
|
||||
// strip out the active attributes only, instancing depend on this
|
||||
tmplInfo.shaderInfo.attributes = getActiveAttributes(tmpl, tmplInfo, defines);
|
||||
tmplInfo.shaderInfo.attributes = render::getActiveAttributes(tmpl, tmplInfo.gfxAttributes, defines);
|
||||
|
||||
tmplInfo.shaderInfo.name = getShaderInstanceName(name, macroArray);
|
||||
tmplInfo.shaderInfo.name = render::getShaderInstanceName(name, macroArray);
|
||||
|
||||
auto *shader = device->createShader(tmplInfo.shaderInfo);
|
||||
_cache[key] = shader;
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
* @param name Target shader name
|
||||
*/
|
||||
|
||||
IProgramInfo *getTemplate(const ccstd::string &name);
|
||||
const IProgramInfo *getTemplate(const ccstd::string &name) const;
|
||||
|
||||
/**
|
||||
* @en Gets the shader template info with its name
|
||||
|
||||
@@ -163,6 +163,102 @@ ccstd::string getVariantKey(const IProgramInfo &tmpl, const MacroRecord &defines
|
||||
return ret;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
ccstd::string mapDefine(const IDefineInfo &info, const ccstd::optional<MacroRecord::mapped_type> &def) {
|
||||
if (info.type == "boolean") {
|
||||
return def.has_value() ? (macroRecordAsBool(def.value()) ? "1" : "0") : "0";
|
||||
}
|
||||
if (info.type == "string") {
|
||||
return def.has_value() ? macroRecordAsString(def.value()) : info.options.value()[0];
|
||||
}
|
||||
if (info.type == "number") {
|
||||
return def.has_value() ? macroRecordAsString(def.value()) : std::to_string(info.range.value()[0]);
|
||||
}
|
||||
CC_LOG_WARNING("unknown define type '%s', name: %s", info.type.c_str(), info.name.c_str());
|
||||
return "-1"; // should neven happen
|
||||
}
|
||||
|
||||
bool dependencyCheck(const ccstd::vector<ccstd::string> &dependencies, const MacroRecord &defines) {
|
||||
for (const auto &d : dependencies) { // NOLINT(readability-use-anyofallof)
|
||||
if (d[0] == '!') { // negative dependency
|
||||
if (defines.find(d.substr(1)) != defines.end()) {
|
||||
return false;
|
||||
}
|
||||
} else if (defines.count(d) == 0 ? true : !macroRecordAsBool(defines.at(d))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class Vector>
|
||||
ccstd::vector<gfx::Attribute> getActiveAttributesImpl(
|
||||
const IProgramInfo &tmpl,
|
||||
const Vector &gfxAttributes, const MacroRecord &defines) {
|
||||
ccstd::vector<gfx::Attribute> out{};
|
||||
const auto &attributes = tmpl.attributes;
|
||||
for (auto i = 0; i < attributes.size(); i++) {
|
||||
if (!dependencyCheck(attributes[i].defines, defines)) {
|
||||
continue;
|
||||
}
|
||||
out.emplace_back(gfxAttributes[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ccstd::vector<IMacroInfo> prepareDefines(const MacroRecord &records, const ccstd::vector<IDefineRecord> &defList) {
|
||||
ccstd::vector<IMacroInfo> macros{};
|
||||
for (const auto &tmp : defList) {
|
||||
const auto &name = tmp.name;
|
||||
auto it = records.find(name);
|
||||
auto value = mapDefine(tmp, it == records.end() ? ccstd::nullopt : ccstd::optional<MacroValue>(it->second));
|
||||
bool isDefault = it == records.end() || (ccstd::holds_alternative<ccstd::string>(it->second) && ccstd::get<ccstd::string>(it->second) == "0");
|
||||
macros.emplace_back();
|
||||
auto &info = macros.back();
|
||||
info.name = name;
|
||||
info.value = value;
|
||||
info.isDefault = isDefault;
|
||||
}
|
||||
return macros;
|
||||
}
|
||||
|
||||
ccstd::vector<gfx::Attribute> getActiveAttributes(
|
||||
const IProgramInfo &tmpl,
|
||||
const ccstd::vector<gfx::Attribute> &gfxAttributes, const MacroRecord &defines) {
|
||||
return getActiveAttributesImpl(tmpl, gfxAttributes, defines);
|
||||
}
|
||||
|
||||
ccstd::vector<gfx::Attribute> getActiveAttributes(
|
||||
const IProgramInfo &tmpl,
|
||||
const ccstd::pmr::vector<gfx::Attribute> &gfxAttributes, const MacroRecord &defines) {
|
||||
return getActiveAttributesImpl(tmpl, gfxAttributes, defines);
|
||||
}
|
||||
|
||||
ccstd::string getShaderInstanceName(const ccstd::string &name, const ccstd::vector<IMacroInfo> ¯os) {
|
||||
std::stringstream ret;
|
||||
ret << name;
|
||||
for (const auto &cur : macros) {
|
||||
if (!cur.isDefault) {
|
||||
ret << "|" << cur.name << cur.value;
|
||||
}
|
||||
}
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
void addEffectDefaultProperties(EffectAsset &effect) {
|
||||
for (auto &tech : effect._techniques) {
|
||||
for (auto &pass : tech.passes) {
|
||||
// grab default property declaration if there is none
|
||||
if (pass.propertyIndex.has_value() && !pass.properties.has_value()) {
|
||||
pass.properties = tech.passes[pass.propertyIndex.value()].properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
|
||||
} // namespace cc
|
||||
|
||||
@@ -34,6 +34,21 @@ void populateMacros(IProgramInfo& tmpl);
|
||||
ccstd::unordered_map<ccstd::string, uint32_t> genHandles(const IProgramInfo& tmpl);
|
||||
ccstd::unordered_map<ccstd::string, uint32_t> genHandles(const gfx::ShaderInfo& tmpl);
|
||||
ccstd::string getVariantKey(const IProgramInfo& tmpl, const MacroRecord& defines);
|
||||
ccstd::vector<IMacroInfo> prepareDefines(
|
||||
const MacroRecord& records, const ccstd::vector<IDefineRecord>& defList);
|
||||
|
||||
ccstd::vector<gfx::Attribute> getActiveAttributes(
|
||||
const IProgramInfo& tmpl,
|
||||
const ccstd::vector<gfx::Attribute>& gfxAttributes, const MacroRecord& defines);
|
||||
|
||||
ccstd::vector<gfx::Attribute> getActiveAttributes(
|
||||
const IProgramInfo& tmpl,
|
||||
const ccstd::pmr::vector<gfx::Attribute>& gfxAttributes, const MacroRecord& defines);
|
||||
|
||||
ccstd::string getShaderInstanceName(
|
||||
const ccstd::string& name, const ccstd::vector<IMacroInfo>& macros);
|
||||
|
||||
void addEffectDefaultProperties(EffectAsset& effect);
|
||||
|
||||
} // namespace render
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ DescriptorSetAgent::~DescriptorSetAgent() {
|
||||
|
||||
void DescriptorSetAgent::doInit(const DescriptorSetInfo &info) {
|
||||
DescriptorSetInfo actorInfo;
|
||||
actorInfo.layout = static_cast<DescriptorSetLayoutAgent *>(info.layout)->getActor();
|
||||
actorInfo.layout = static_cast<const DescriptorSetLayoutAgent *>(info.layout)->getActor();
|
||||
|
||||
ENQUEUE_MESSAGE_2(
|
||||
DeviceAgent::getInstance()->getMessageQueue(),
|
||||
|
||||
@@ -1419,7 +1419,7 @@ struct DescriptorSetLayoutInfo {
|
||||
};
|
||||
|
||||
struct DescriptorSetInfo {
|
||||
DescriptorSetLayout *layout{nullptr};
|
||||
const DescriptorSetLayout *layout{nullptr};
|
||||
|
||||
EXPOSE_COPY_FN(DescriptorSetInfo)
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
Texture *getTexture(uint32_t binding, uint32_t index) const;
|
||||
Sampler *getSampler(uint32_t binding, uint32_t index) const;
|
||||
|
||||
inline DescriptorSetLayout *getLayout() const { return _layout; }
|
||||
inline const DescriptorSetLayout *getLayout() const { return _layout; }
|
||||
|
||||
inline void bindBuffer(uint32_t binding, Buffer *buffer) { bindBuffer(binding, buffer, 0U); }
|
||||
inline void bindTexture(uint32_t binding, Texture *texture) { bindTexture(binding, texture, 0U); }
|
||||
@@ -73,7 +73,7 @@ protected:
|
||||
uint32_t id = INVALID_OBJECT_ID;
|
||||
};
|
||||
|
||||
DescriptorSetLayout *_layout = nullptr;
|
||||
const DescriptorSetLayout *_layout = nullptr;
|
||||
ccstd::vector<ObjectWithId<Buffer>> _buffers;
|
||||
ccstd::vector<ObjectWithId<Texture>> _textures;
|
||||
ccstd::vector<ObjectWithId<Sampler>> _samplers;
|
||||
|
||||
@@ -158,14 +158,6 @@ DefaultResource::DefaultResource(Device *device) {
|
||||
BufferTextureCopy region = {0, 0, 0, {0, 0, 0}, {2, 2, 2}, {0, 0, 1}};
|
||||
device->copyBuffersToTexture(&bufferData, _texture3D, ®ion, 1);
|
||||
}
|
||||
if (device->getCapabilities().maxArrayTextureLayers >= 2) {
|
||||
_texture1DArray = device->createTexture({TextureType::TEX1D_ARRAY, TextureUsageBit::STORAGE | TextureUsageBit::SAMPLED,
|
||||
Format::RGBA8, 1, 1, TextureFlagBit::NONE, 2});
|
||||
BufferTextureCopy region = {0, 0, 0, {0, 0, 0}, {1, 1, 1}, {0, 0, 1}};
|
||||
device->copyBuffersToTexture(&bufferData, _texture1DArray, ®ion, 1);
|
||||
region.texSubres.baseArrayLayer = 1;
|
||||
device->copyBuffersToTexture(&bufferData, _texture1DArray, ®ion, 1);
|
||||
}
|
||||
if (device->getCapabilities().maxArrayTextureLayers >= 2) {
|
||||
_texture2DArray = device->createTexture({TextureType::TEX2D_ARRAY, TextureUsageBit::STORAGE | TextureUsageBit::SAMPLED,
|
||||
Format::RGBA8, 2, 2, TextureFlagBit::NONE, 2});
|
||||
@@ -176,7 +168,7 @@ DefaultResource::DefaultResource(Device *device) {
|
||||
}
|
||||
}
|
||||
|
||||
const Texture *DefaultResource::getTexture(TextureType type) const {
|
||||
Texture *DefaultResource::getTexture(TextureType type) const {
|
||||
switch (type) {
|
||||
case TextureType::TEX2D:
|
||||
return _texture2D;
|
||||
@@ -184,8 +176,6 @@ const Texture *DefaultResource::getTexture(TextureType type) const {
|
||||
return _textureCube;
|
||||
case TextureType::TEX3D:
|
||||
return _texture3D;
|
||||
case TextureType::TEX1D_ARRAY:
|
||||
return _texture1DArray;
|
||||
case TextureType::TEX2D_ARRAY:
|
||||
return _texture2DArray;
|
||||
default:
|
||||
|
||||
@@ -196,12 +196,10 @@ public:
|
||||
|
||||
~DefaultResource() = default;
|
||||
|
||||
const Texture *getTexture(TextureType type) const;
|
||||
Texture *getTexture(TextureType type) const;
|
||||
|
||||
private:
|
||||
IntrusivePtr<Texture> _texture1D;
|
||||
IntrusivePtr<Texture> _texture2D;
|
||||
IntrusivePtr<Texture> _texture1DArray;
|
||||
IntrusivePtr<Texture> _texture2DArray;
|
||||
IntrusivePtr<Texture> _textureCube;
|
||||
IntrusivePtr<Texture> _texture3D;
|
||||
|
||||
@@ -43,7 +43,7 @@ GLES2DescriptorSet::~GLES2DescriptorSet() {
|
||||
}
|
||||
|
||||
void GLES2DescriptorSet::doInit(const DescriptorSetInfo & /*info*/) {
|
||||
const GLES2GPUDescriptorSetLayout *gpuDescriptorSetLayout = static_cast<GLES2DescriptorSetLayout *>(_layout)->gpuDescriptorSetLayout();
|
||||
const GLES2GPUDescriptorSetLayout *gpuDescriptorSetLayout = static_cast<const GLES2DescriptorSetLayout *>(_layout)->gpuDescriptorSetLayout();
|
||||
const size_t descriptorCount = gpuDescriptorSetLayout->descriptorCount;
|
||||
const size_t bindingCount = gpuDescriptorSetLayout->bindings.size();
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ GLES3DescriptorSet::~GLES3DescriptorSet() {
|
||||
}
|
||||
|
||||
void GLES3DescriptorSet::doInit(const DescriptorSetInfo & /*info*/) {
|
||||
const GLES3GPUDescriptorSetLayout *gpuDescriptorSetLayout = static_cast<GLES3DescriptorSetLayout *>(_layout)->gpuDescriptorSetLayout();
|
||||
const GLES3GPUDescriptorSetLayout *gpuDescriptorSetLayout = static_cast<const GLES3DescriptorSetLayout *>(_layout)->gpuDescriptorSetLayout();
|
||||
const size_t descriptorCount = gpuDescriptorSetLayout->descriptorCount;
|
||||
const size_t bindingCount = gpuDescriptorSetLayout->bindings.size();
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "MTLBuffer.h"
|
||||
#include "MTLCommandBuffer.h"
|
||||
#include "MTLDevice.h"
|
||||
#include "MTLQueue.h"
|
||||
#include "MTLRenderCommandEncoder.h"
|
||||
#include "MTLUtils.h"
|
||||
#include "MTLGPUObjects.h"
|
||||
@@ -245,14 +246,7 @@ void CCMTLBuffer::update(const void *buffer, uint32_t size) {
|
||||
|
||||
void CCMTLBuffer::updateMTLBuffer(const void *buffer, uint32_t /*offset*/, uint32_t size) {
|
||||
if (_gpuBuffer->mtlBuffer) {
|
||||
CommandBuffer *cmdBuffer = CCMTLDevice::getInstance()->getCommandBuffer();
|
||||
cmdBuffer->begin();
|
||||
static_cast<CCMTLCommandBuffer *>(cmdBuffer)->updateBuffer(this, buffer, size);
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MACOS)
|
||||
if (_mtlResourceOptions == MTLResourceStorageModeManaged) {
|
||||
[_gpuBuffer->mtlBuffer didModifyRange:NSMakeRange(0, _size)]; // Synchronize the managed buffer.
|
||||
}
|
||||
#endif
|
||||
CCMTLDevice::getInstance()->writeBuffer(this, buffer, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ CCMTLDescriptorSet::CCMTLDescriptorSet() : DescriptorSet() {
|
||||
}
|
||||
|
||||
void CCMTLDescriptorSet::doInit(const DescriptorSetInfo &info) {
|
||||
const auto gpuDescriptorSetLayout = static_cast<CCMTLDescriptorSetLayout *>(_layout)->gpuDescriptorSetLayout();
|
||||
const auto gpuDescriptorSetLayout = static_cast<const CCMTLDescriptorSetLayout *>(_layout)->gpuDescriptorSetLayout();
|
||||
const auto descriptorCount = gpuDescriptorSetLayout->descriptorCount;
|
||||
const auto bindingCount = gpuDescriptorSetLayout->bindings.size();
|
||||
|
||||
|
||||
@@ -87,6 +87,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
CommandBuffer *transferCommandBuffer() const;
|
||||
|
||||
void writeBuffer(Buffer *buffer, const void *data, uint32_t size);
|
||||
|
||||
protected:
|
||||
static CCMTLDevice *_instance;
|
||||
|
||||
@@ -134,6 +138,7 @@ protected:
|
||||
ccstd::vector<CCMTLSwapchain *> _swapchains;
|
||||
|
||||
CCMTLGPUDeviceObject *_gpuDeviceObj = nullptr;
|
||||
uint8_t _inFlightCount = 0;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -73,6 +73,7 @@ CCMTLDevice::~CCMTLDevice() {
|
||||
|
||||
bool CCMTLDevice::doInit(const DeviceInfo &info) {
|
||||
_gpuDeviceObj = ccnew CCMTLGPUDeviceObject;
|
||||
|
||||
_inFlightSemaphore = ccnew CCMTLSemaphore(3);
|
||||
_currentFrameIndex = 0;
|
||||
|
||||
@@ -142,6 +143,11 @@ bool CCMTLDevice::doInit(const DeviceInfo &info) {
|
||||
|
||||
QueryPoolInfo queryPoolInfo{QueryType::OCCLUSION, DEFAULT_MAX_QUERY_OBJECTS, true};
|
||||
_queryPool = createQueryPool(queryPoolInfo);
|
||||
|
||||
CommandBufferInfo transferCmdBuffInfo;
|
||||
transferCmdBuffInfo.type = CommandBufferType::PRIMARY;
|
||||
transferCmdBuffInfo.queue = _queue;
|
||||
_gpuDeviceObj->_transferCmdBuffer = static_cast<CCMTLCommandBuffer*>(createCommandBuffer(transferCmdBuffInfo));
|
||||
|
||||
CommandBufferInfo cmdBuffInfo;
|
||||
cmdBuffInfo.type = CommandBufferType::PRIMARY;
|
||||
@@ -157,6 +163,7 @@ bool CCMTLDevice::doInit(const DeviceInfo &info) {
|
||||
|
||||
void CCMTLDevice::doDestroy() {
|
||||
|
||||
CC_SAFE_DESTROY_AND_DELETE(_gpuDeviceObj->_transferCmdBuffer);
|
||||
CC_SAFE_DELETE(_gpuDeviceObj);
|
||||
|
||||
CC_SAFE_DESTROY_AND_DELETE(_queryPool)
|
||||
@@ -175,6 +182,7 @@ void CCMTLDevice::doDestroy() {
|
||||
CC_SAFE_DELETE(_gpuStagingBufferPools[i]);
|
||||
_gpuStagingBufferPools[i] = nullptr;
|
||||
}
|
||||
_inFlightCount = 0;
|
||||
|
||||
cc::gfx::mu::clearUtilResource();
|
||||
|
||||
@@ -224,6 +232,7 @@ void CCMTLDevice::present() {
|
||||
|
||||
// present drawable
|
||||
{
|
||||
++_inFlightCount;
|
||||
id<MTLCommandBuffer> cmdBuffer = [queue->gpuQueueObj()->mtlCommandQueue commandBuffer];
|
||||
[cmdBuffer enqueue];
|
||||
|
||||
@@ -247,6 +256,7 @@ void CCMTLDevice::onPresentCompleted(uint32_t index) {
|
||||
}
|
||||
}
|
||||
_inFlightSemaphore->signal();
|
||||
--_inFlightCount;
|
||||
}
|
||||
|
||||
Queue *CCMTLDevice::createQueue() {
|
||||
@@ -324,6 +334,32 @@ void CCMTLDevice::copyTextureToBuffers(Texture *src, uint8_t *const *buffers, co
|
||||
static_cast<CCMTLCommandBuffer *>(_cmdBuff)->copyTextureToBuffers(src, buffers, region, count);
|
||||
}
|
||||
|
||||
void CCMTLDevice::writeBuffer(Buffer* buffer, const void* data, uint32_t size) {
|
||||
bool hasFrameInFlight = _inFlightCount;
|
||||
auto* ccBuffer = static_cast<CCMTLBuffer*>(buffer);
|
||||
id<MTLBuffer> mtlBuffer = ccBuffer->getMTLBuffer();
|
||||
if(!hasFrameInFlight && mtlBuffer.storageMode != MTLStorageModePrivate) {
|
||||
if(@available(macOS 10.15, *)) {
|
||||
memcpy(mtlBuffer.contents, data, size);
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MACOS)
|
||||
if (mtlBuffer.storageMode == MTLStorageModeManaged) {
|
||||
[mtlBuffer didModifyRange:NSMakeRange(0, size)]; // Synchronize the managed buffer.
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if(@available(iOS 11.0, *)) {
|
||||
memcpy(mtlBuffer.contents, data, size);
|
||||
}
|
||||
} else {
|
||||
CCMTLCommandBuffer* transferCmdBuffer = _gpuDeviceObj->_transferCmdBuffer;
|
||||
transferCmdBuffer->updateBuffer(buffer, data, size);
|
||||
}
|
||||
}
|
||||
|
||||
CommandBuffer* CCMTLDevice::transferCommandBuffer() const {
|
||||
return _gpuDeviceObj ? _gpuDeviceObj->_transferCmdBuffer : nullptr;
|
||||
}
|
||||
|
||||
void CCMTLDevice::getQueryPoolResults(QueryPool *queryPool) {
|
||||
CC_PROFILE(CCMTLDeviceGetQueryPoolResults);
|
||||
auto *mtlQueryPool = static_cast<CCMTLQueryPool *>(queryPool);
|
||||
|
||||
@@ -47,6 +47,7 @@ class CCMTLFramebuffer;
|
||||
class CCMTLInputAssembler;
|
||||
class CCMTLPipelineState;
|
||||
class CCMTLSemaphore;
|
||||
class CCMTLCommandBuffer;
|
||||
|
||||
namespace {
|
||||
constexpr size_t MegaBytesToBytes = 1024 * 1024;
|
||||
@@ -312,6 +313,7 @@ struct CCMTLGPUCommandBufferObject {
|
||||
};
|
||||
|
||||
struct CCMTLGPUDeviceObject {
|
||||
CCMTLCommandBuffer* _transferCmdBuffer{nullptr};
|
||||
};
|
||||
|
||||
struct CCMTLGPUQueryPool {
|
||||
|
||||
@@ -145,6 +145,17 @@ bool CCMTLPipelineState::createMTLComputePipelineState() {
|
||||
}
|
||||
|
||||
bool CCMTLPipelineState::createMTLDepthStencilState() {
|
||||
const auto& colorAttachments = _renderPass->getColorAttachments();
|
||||
bool hasDS = std::any_of(colorAttachments.begin(), colorAttachments.end(), [](const ColorAttachment& attachemnt){
|
||||
return attachemnt.format == Format::DEPTH ||attachemnt.format == Format::DEPTH_STENCIL;
|
||||
});
|
||||
hasDS |= _renderPass->getDepthStencilAttachment().format != Format::UNKNOWN;
|
||||
|
||||
if(!hasDS) {
|
||||
// default nil
|
||||
return true;
|
||||
}
|
||||
|
||||
MTLDepthStencilDescriptor *descriptor = [[MTLDepthStencilDescriptor alloc] init];
|
||||
if (descriptor == nil) {
|
||||
CC_LOG_ERROR("CCMTLPipelineState: MTLDepthStencilDescriptor could not be allocated.");
|
||||
@@ -152,7 +163,6 @@ bool CCMTLPipelineState::createMTLDepthStencilState() {
|
||||
}
|
||||
|
||||
descriptor.depthWriteEnabled = _depthStencilState.depthWrite != 0;
|
||||
|
||||
if (!_depthStencilState.depthTest)
|
||||
descriptor.depthCompareFunction = MTLCompareFunctionAlways;
|
||||
else
|
||||
|
||||
@@ -73,6 +73,12 @@ void CCMTLQueue::submit(CommandBuffer *const *cmdBuffs, uint32_t count) {
|
||||
[mtlCmdBuffer commit];
|
||||
cmdBuffer->reset();
|
||||
}
|
||||
CCMTLCommandBuffer* transferCmdBuffer = static_cast<CCMTLCommandBuffer*>(CCMTLDevice::getInstance()->transferCommandBuffer());
|
||||
id<MTLCommandBuffer> mtlCmdBuffer = transferCmdBuffer->gpuCommandBufferObj()->mtlCommandBuffer;
|
||||
if(mtlCmdBuffer) {
|
||||
[mtlCmdBuffer commit];
|
||||
transferCmdBuffer->reset();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
@@ -404,9 +404,9 @@ CCMTLGPUPipelineState *getClearRenderPassPipelineState(CCMTLDevice *device, Rend
|
||||
pipelineInfo.renderPass = curPass;
|
||||
|
||||
DepthStencilState dsState;
|
||||
dsState.depthWrite = 0;
|
||||
dsState.depthTest = 1;
|
||||
dsState.depthFunc = ComparisonFunc::LESS_EQUAL;
|
||||
dsState.depthWrite = curPass->getDepthStencilAttachment().format != Format::UNKNOWN;
|
||||
dsState.depthTest = 0;
|
||||
dsState.depthFunc = ComparisonFunc::ALWAYS;
|
||||
pipelineInfo.depthStencilState = dsState;
|
||||
|
||||
PipelineState *pipelineState = device->createPipelineState(std::move(pipelineInfo));
|
||||
@@ -1748,8 +1748,7 @@ void mu::clearRenderArea(CCMTLDevice *device, id<MTLRenderCommandEncoder> render
|
||||
|
||||
const auto &colorAttachments = renderPass->getColorAttachments();
|
||||
const auto &depthStencilAttachment = renderPass->getDepthStencilAttachment();
|
||||
|
||||
[renderEncoder setViewport:(MTLViewport){0, 0, renderTargetWidth, renderTargetHeight}];
|
||||
[renderEncoder setViewport:(MTLViewport){0, 0, renderTargetWidth, renderTargetHeight, 0, 1}];
|
||||
MTLScissorRect scissorArea = {static_cast<NSUInteger>(renderArea.x), static_cast<NSUInteger>(renderArea.y), static_cast<NSUInteger>(renderArea.width), static_cast<NSUInteger>(renderArea.height)};
|
||||
#if defined(CC_DEBUG) && (CC_DEBUG > 0)
|
||||
scissorArea.width = MIN(scissorArea.width, renderTargetWidth - scissorArea.x);
|
||||
|
||||
@@ -48,12 +48,12 @@ DescriptorSetValidator::~DescriptorSetValidator() {
|
||||
void DescriptorSetValidator::doInit(const DescriptorSetInfo &info) {
|
||||
CC_ASSERT(!isInited());
|
||||
_inited = true;
|
||||
CC_ASSERT(info.layout && static_cast<DescriptorSetLayoutValidator *>(info.layout)->isInited());
|
||||
CC_ASSERT(info.layout && static_cast<const DescriptorSetLayoutValidator *>(info.layout)->isInited());
|
||||
|
||||
/////////// execute ///////////
|
||||
|
||||
DescriptorSetInfo actorInfo;
|
||||
actorInfo.layout = static_cast<DescriptorSetLayoutValidator *>(info.layout)->getActor();
|
||||
actorInfo.layout = static_cast<const DescriptorSetLayoutValidator *>(info.layout)->getActor();
|
||||
|
||||
_actor->initialize(actorInfo);
|
||||
}
|
||||
|
||||
@@ -52,17 +52,6 @@ void RenderPassValidator::doInit(const RenderPassInfo &info) {
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &attachment : _colorAttachments) {
|
||||
if (attachment.loadOp == LoadOp::LOAD && attachment.barrier->getInfo().prevAccesses == AccessFlagBit::NONE) {
|
||||
// Attachment missing beginAccesses for LoadOp::LOAD.
|
||||
CC_ABORT();
|
||||
}
|
||||
}
|
||||
if ((_depthStencilAttachment.depthLoadOp == LoadOp::LOAD || _depthStencilAttachment.stencilLoadOp == LoadOp::LOAD) && _depthStencilAttachment.barrier->getInfo().prevAccesses == AccessFlagBit::NONE) {
|
||||
// Attachment missing beginAccesses for LoadOp::LOAD.
|
||||
CC_ABORT();
|
||||
}
|
||||
|
||||
/////////// execute ///////////
|
||||
|
||||
_actor->initialize(info);
|
||||
|
||||
@@ -44,7 +44,7 @@ CCVKDescriptorSet::~CCVKDescriptorSet() {
|
||||
}
|
||||
|
||||
void CCVKDescriptorSet::doInit(const DescriptorSetInfo & /*info*/) {
|
||||
CCVKGPUDescriptorSetLayout *gpuDescriptorSetLayout = static_cast<CCVKDescriptorSetLayout *>(_layout)->gpuDescriptorSetLayout();
|
||||
CCVKGPUDescriptorSetLayout *gpuDescriptorSetLayout = static_cast<const CCVKDescriptorSetLayout *>(_layout)->gpuDescriptorSetLayout();
|
||||
uint32_t bindingCount = utils::toUint(gpuDescriptorSetLayout->bindings.size());
|
||||
uint32_t descriptorCount = gpuDescriptorSetLayout->descriptorCount;
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugView.h"
|
||||
#include "custom/RenderInterfaceTypes.h"
|
||||
#include "RenderPipeline.h"
|
||||
#include "core/Root.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
namespace pipeline {
|
||||
|
||||
void DebugView::activate() {
|
||||
_singleMode = DebugViewSingleType::NONE;
|
||||
enableAllCompositeModeValue(true);
|
||||
_lightingWithAlbedo = true;
|
||||
_csmLayerColoration = false;
|
||||
}
|
||||
|
||||
void DebugView::updatePipeline() {
|
||||
Root *root = Root::getInstance();
|
||||
auto *pipeline = root->getPipeline();
|
||||
|
||||
auto useDebugViewValue = static_cast<int32_t>(getType());
|
||||
|
||||
bool valueChanged = false;
|
||||
auto iter = pipeline->getMacros().find("CC_USE_DEBUG_VIEW");
|
||||
if (iter != pipeline->getMacros().end()) {
|
||||
const MacroValue ¯oValue = iter->second;
|
||||
const int32_t *macroPtr = ccstd::get_if<int32_t>(¯oValue);
|
||||
if (macroPtr != nullptr && (*macroPtr != useDebugViewValue)) {
|
||||
pipeline->setValue("CC_USE_DEBUG_VIEW", useDebugViewValue);
|
||||
valueChanged = true;
|
||||
}
|
||||
} else {
|
||||
pipeline->setValue("CC_USE_DEBUG_VIEW", useDebugViewValue);
|
||||
valueChanged = true;
|
||||
}
|
||||
|
||||
if (valueChanged) {
|
||||
root->onGlobalPipelineStateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace cc
|
||||
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
Copyright (c) 2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "base/TypeDef.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
namespace pipeline {
|
||||
|
||||
enum class RenderingDebugViewType {
|
||||
NONE,
|
||||
SINGLE,
|
||||
COMPOSITE_AND_MISC,
|
||||
};
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 渲染单项调试模式
|
||||
* @en
|
||||
* Rendering single debug mode
|
||||
* @readonly
|
||||
*/
|
||||
enum class DebugViewSingleType {
|
||||
NONE,
|
||||
VERTEX_COLOR,
|
||||
VERTEX_NORMAL,
|
||||
VERTEX_TANGENT,
|
||||
WORLD_POS,
|
||||
VERTEX_MIRROR,
|
||||
FACE_SIDE,
|
||||
UV0,
|
||||
UV1,
|
||||
UV_LIGHTMAP,
|
||||
PROJ_DEPTH,
|
||||
LINEAR_DEPTH,
|
||||
|
||||
FRAGMENT_NORMAL,
|
||||
FRAGMENT_TANGENT,
|
||||
FRAGMENT_BINORMAL,
|
||||
BASE_COLOR,
|
||||
DIFFUSE_COLOR,
|
||||
SPECULAR_COLOR,
|
||||
TRANSPARENCY,
|
||||
METALLIC,
|
||||
ROUGHNESS,
|
||||
SPECULAR_INTENSITY,
|
||||
IOR,
|
||||
|
||||
DIRECT_DIFFUSE,
|
||||
DIRECT_SPECULAR,
|
||||
DIRECT_ALL,
|
||||
ENV_DIFFUSE,
|
||||
ENV_SPECULAR,
|
||||
ENV_ALL,
|
||||
EMISSIVE,
|
||||
LIGHT_MAP,
|
||||
SHADOW,
|
||||
AO,
|
||||
|
||||
FRESNEL,
|
||||
DIRECT_TRANSMIT_DIFFUSE,
|
||||
DIRECT_TRANSMIT_SPECULAR,
|
||||
ENV_TRANSMIT_DIFFUSE,
|
||||
ENV_TRANSMIT_SPECULAR,
|
||||
TRANSMIT_ALL,
|
||||
DIRECT_TRT,
|
||||
ENV_TRT,
|
||||
TRT_ALL,
|
||||
|
||||
FOG,
|
||||
};
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 渲染组合调试模式
|
||||
* @en
|
||||
* Rendering composite debug mode
|
||||
* @readonly
|
||||
*/
|
||||
enum class DebugViewCompositeType {
|
||||
DIRECT_DIFFUSE = 0,
|
||||
DIRECT_SPECULAR,
|
||||
ENV_DIFFUSE,
|
||||
ENV_SPECULAR,
|
||||
EMISSIVE,
|
||||
LIGHT_MAP,
|
||||
SHADOW,
|
||||
AO,
|
||||
|
||||
NORMAL_MAP,
|
||||
FOG,
|
||||
|
||||
TONE_MAPPING,
|
||||
GAMMA_CORRECTION,
|
||||
|
||||
FRESNEL,
|
||||
TRANSMIT_DIFFUSE,
|
||||
TRANSMIT_SPECULAR,
|
||||
TRT,
|
||||
|
||||
MAX_BIT_COUNT
|
||||
};
|
||||
|
||||
/**
|
||||
* @en Rendering debug view control class
|
||||
* @zh 渲染调试控制类
|
||||
*/
|
||||
// @ccclass('cc.DebugView')
|
||||
// @help('i18n:cc.DebugView')
|
||||
class DebugView final {
|
||||
public:
|
||||
DebugView() {
|
||||
activate();
|
||||
}
|
||||
~DebugView() = default;
|
||||
|
||||
/**
|
||||
* @en Toggle rendering single debug mode.
|
||||
* @zh 设置渲染单项调试模式。
|
||||
*/
|
||||
inline DebugViewSingleType getSingleMode() const { return _singleMode; }
|
||||
inline void setSingleMode(DebugViewSingleType val) {
|
||||
_singleMode = val;
|
||||
updatePipeline();
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Toggle normal / pure lighting mode.
|
||||
* @zh 切换正常光照和仅光照模式。
|
||||
*/
|
||||
inline bool isLightingWithAlbedo() const { return _lightingWithAlbedo; }
|
||||
inline void setLightingWithAlbedo(bool val) {
|
||||
_lightingWithAlbedo = val;
|
||||
updatePipeline();
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Toggle CSM layer coloration mode.
|
||||
* @zh 切换级联阴影染色调试模式。
|
||||
*/
|
||||
inline bool isCsmLayerColoration() const { return _csmLayerColoration; }
|
||||
inline void setCsmLayerColoration(bool val) {
|
||||
_csmLayerColoration = val;
|
||||
updatePipeline();
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Whether enabled with specified rendering composite debug mode.
|
||||
* @zh 获取指定的渲染组合调试模式是否开启。
|
||||
* @param Specified composite type.
|
||||
*/
|
||||
inline bool isCompositeModeEnabled (uint32_t val) const {
|
||||
uint32_t mode = _compositeModeValue & (1 << val);
|
||||
return mode != 0;
|
||||
}
|
||||
/**
|
||||
* @en Toggle specified rendering composite debug mode.
|
||||
* @zh 开关指定的渲染组合调试模式。
|
||||
* @param Specified composite type, enable or disable.
|
||||
*/
|
||||
inline void enableCompositeMode (DebugViewCompositeType val, bool enable) {
|
||||
enableCompositeModeValue(val, enable);
|
||||
updatePipeline();
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Toggle all rendering composite debug mode.
|
||||
* @zh 开关所有的渲染组合调试模式。
|
||||
*/
|
||||
inline void enableAllCompositeMode (bool enable) {
|
||||
enableAllCompositeModeValue(enable);
|
||||
updatePipeline();
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Get rendering debug view on / off state.
|
||||
* @zh 查询当前是否开启了渲染调试模式。
|
||||
*/
|
||||
inline bool isEnabled() const {
|
||||
return getType() != RenderingDebugViewType::NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Disable all debug view modes, reset to standard rendering mode.
|
||||
* @zh 关闭所有的渲染调试模式,恢复到正常渲染。
|
||||
*/
|
||||
void reset () {
|
||||
activate();
|
||||
updatePipeline();
|
||||
}
|
||||
|
||||
protected:
|
||||
void activate();
|
||||
void updatePipeline();
|
||||
|
||||
private:
|
||||
inline void enableCompositeModeValue(DebugViewCompositeType val, bool enable) {
|
||||
if (enable) {
|
||||
_compositeModeValue |= (1 << static_cast<uint32_t>(val));
|
||||
} else {
|
||||
_compositeModeValue &= (~(1 << static_cast<uint32_t>(val)));
|
||||
}
|
||||
}
|
||||
|
||||
inline void enableAllCompositeModeValue(bool enable) {
|
||||
for (int i = 0; i < static_cast<int>(DebugViewCompositeType::MAX_BIT_COUNT); ++i) {
|
||||
if (enable) {
|
||||
_compositeModeValue |= (1 << i);
|
||||
} else {
|
||||
_compositeModeValue &= (~(1 << i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline RenderingDebugViewType getType () const {
|
||||
if (_singleMode != DebugViewSingleType::NONE) {
|
||||
return RenderingDebugViewType::SINGLE;
|
||||
} else if (!_lightingWithAlbedo || _csmLayerColoration) {
|
||||
return RenderingDebugViewType::COMPOSITE_AND_MISC;
|
||||
} else {
|
||||
for (int i = 0; i < static_cast<int>(DebugViewCompositeType::MAX_BIT_COUNT); ++i) {
|
||||
if (!isCompositeModeEnabled(i)) {
|
||||
return RenderingDebugViewType::COMPOSITE_AND_MISC;
|
||||
}
|
||||
}
|
||||
}
|
||||
return RenderingDebugViewType::NONE;
|
||||
}
|
||||
|
||||
private:
|
||||
DebugViewSingleType _singleMode{DebugViewSingleType::NONE};
|
||||
uint32_t _compositeModeValue{0};
|
||||
bool _lightingWithAlbedo{true};
|
||||
bool _csmLayerColoration{false};
|
||||
};
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace cc
|
||||
@@ -71,10 +71,11 @@ const gfx::UniformBlock UBOGlobal::LAYOUT = {
|
||||
{"cc_screenSize", gfx::Type::FLOAT4, 1},
|
||||
{"cc_nativeSize", gfx::Type::FLOAT4, 1},
|
||||
|
||||
{"cc_debug_view_mode", gfx::Type::FLOAT, 4},
|
||||
{"cc_debug_view_composite_pack_1", gfx::Type::FLOAT, 4},
|
||||
{"cc_debug_view_composite_pack_2", gfx::Type::FLOAT, 4},
|
||||
{"cc_debug_view_composite_pack_3", gfx::Type::FLOAT, 4},
|
||||
{"cc_debug_view_mode", gfx::Type::FLOAT4, 1},
|
||||
{"cc_debug_view_composite_pack_1", gfx::Type::FLOAT4, 1},
|
||||
{"cc_debug_view_composite_pack_2", gfx::Type::FLOAT4, 1},
|
||||
{"cc_debug_view_composite_pack_3", gfx::Type::FLOAT4, 1},
|
||||
{"cc_debug_view_composite_pack_4", gfx::Type::FLOAT4, 1},
|
||||
},
|
||||
1,
|
||||
};
|
||||
|
||||
@@ -447,8 +447,9 @@ struct CC_DLL UBOGlobal {
|
||||
static constexpr uint32_t DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET = UBOGlobal::DEBUG_VIEW_MODE_OFFSET + 4;
|
||||
static constexpr uint32_t DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET + 4;
|
||||
static constexpr uint32_t DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET + 4;
|
||||
static constexpr uint32_t DEBUG_VIEW_COMPOSITE_PACK_4_OFFSET = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET + 4;
|
||||
|
||||
static constexpr uint32_t COUNT = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET + 4;
|
||||
static constexpr uint32_t COUNT = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_4_OFFSET + 4;
|
||||
|
||||
static constexpr uint32_t SIZE = UBOGlobal::COUNT * 4;
|
||||
static constexpr uint32_t BINDING = static_cast<uint32_t>(PipelineGlobalBindings::UBO_GLOBAL);
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
inline const RenderObjectList &getRenderObjects() const { return _renderObjects; }
|
||||
inline void setRenderObjects(RenderObjectList &&ro) { _renderObjects = std::forward<RenderObjectList>(ro); }
|
||||
inline const ccstd::vector<const scene::Light *> &getValidPunctualLights() const { return _validPunctualLights; }
|
||||
inline void setValidPunctualLights(ccstd::vector<const scene::Light *> lights) { _validPunctualLights = std::move(lights); }
|
||||
inline bool isHDR() const { return _isHDR; }
|
||||
inline void setHDR(bool val) { _isHDR = val; }
|
||||
inline scene::Shadows *getShadows() const { return _shadow; }
|
||||
|
||||
@@ -78,13 +78,12 @@ void PipelineUBO::updateGlobalUBOView(const scene::Camera *camera, ccstd::array<
|
||||
uboGlobalView[UBOGlobal::NATIVE_SIZE_OFFSET + 2] = 1.0F / uboGlobalView[UBOGlobal::NATIVE_SIZE_OFFSET];
|
||||
uboGlobalView[UBOGlobal::NATIVE_SIZE_OFFSET + 3] = 1.0F / uboGlobalView[UBOGlobal::NATIVE_SIZE_OFFSET + 1];
|
||||
|
||||
auto debugViewConfig = root->getDebugViewConfig();
|
||||
uboGlobalView[UBOGlobal::DEBUG_VIEW_MODE_OFFSET] = debugViewConfig.singleMode;
|
||||
uboGlobalView[UBOGlobal::DEBUG_VIEW_MODE_OFFSET + 1] = debugViewConfig.lightingWithAlbedo;
|
||||
uboGlobalView[UBOGlobal::DEBUG_VIEW_MODE_OFFSET + 2] = debugViewConfig.csmLayerColoration;
|
||||
for (int i = 0; i < debugViewConfig.compositeModeBitCount; i++) {
|
||||
uint32_t mode = debugViewConfig.compositeModeValue & (1 << i);
|
||||
uboGlobalView[UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET + i] = mode ? 1.0 : 0.0;
|
||||
auto *debugView = root->getDebugView();
|
||||
uboGlobalView[UBOGlobal::DEBUG_VIEW_MODE_OFFSET] = static_cast<float>(debugView->getSingleMode());
|
||||
uboGlobalView[UBOGlobal::DEBUG_VIEW_MODE_OFFSET + 1] = debugView->isLightingWithAlbedo() ? 1.0F : 0.0F;
|
||||
uboGlobalView[UBOGlobal::DEBUG_VIEW_MODE_OFFSET + 2] = debugView->isCsmLayerColoration() ? 1.0F : 0.0F;
|
||||
for (int i = 0; i < static_cast<int>(pipeline::DebugViewCompositeType::MAX_BIT_COUNT); ++i) {
|
||||
uboGlobalView[UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET + i] = debugView->isCompositeModeEnabled(i) ? 1.0F : 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,7 @@
|
||||
namespace cc {
|
||||
namespace pipeline {
|
||||
|
||||
RenderAdditiveLightQueue::RenderAdditiveLightQueue(RenderPipeline *pipeline) : _pipeline(pipeline),
|
||||
_instancedQueue(ccnew RenderInstancedQueue),
|
||||
_batchedQueue(ccnew RenderBatchedQueue) {
|
||||
RenderAdditiveLightQueue::RenderAdditiveLightQueue(RenderPipeline *pipeline) : _pipeline(pipeline) {
|
||||
auto *device = gfx::Device::getInstance();
|
||||
const auto alignment = device->getCapabilities().uboOffsetAlignment;
|
||||
_lightBufferStride = ((UBOForwardLight::SIZE + alignment - 1) / alignment) * alignment;
|
||||
@@ -67,25 +65,20 @@ RenderAdditiveLightQueue::RenderAdditiveLightQueue(RenderPipeline *pipeline) : _
|
||||
_shadowUBO.fill(0.F);
|
||||
}
|
||||
|
||||
RenderAdditiveLightQueue ::~RenderAdditiveLightQueue() {
|
||||
CC_SAFE_DELETE(_instancedQueue);
|
||||
CC_SAFE_DELETE(_batchedQueue);
|
||||
}
|
||||
|
||||
void RenderAdditiveLightQueue::recordCommandBuffer(gfx::Device *device, scene::Camera *camera, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer) {
|
||||
const uint32_t offset = _pipeline->getPipelineUBO()->getCurrentCameraUBOOffset();
|
||||
for (uint32_t i = 0; i < _instancedLightPass.lights.size(); ++i) {
|
||||
for (uint32_t i = 0; i < _instancedQueues.size(); ++i) {
|
||||
const auto *light = _instancedLightPass.lights[i];
|
||||
_dynamicOffsets[0] = _instancedLightPass.dynamicOffsets[i];
|
||||
auto *globalDescriptorSet = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(light);
|
||||
_instancedQueue->recordCommandBuffer(device, renderPass, cmdBuffer, globalDescriptorSet, offset, &_dynamicOffsets);
|
||||
_instancedQueues[i]->recordCommandBuffer(device, renderPass, cmdBuffer, globalDescriptorSet, offset, &_dynamicOffsets);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < _batchedLightPass.lights.size(); ++i) {
|
||||
for (size_t i = 0; i < _batchedQueues.size(); ++i) {
|
||||
const auto *light = _batchedLightPass.lights[i];
|
||||
_dynamicOffsets[0] = _batchedLightPass.dynamicOffsets[i];
|
||||
auto *globalDescriptorSet = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(light);
|
||||
_batchedQueue->recordCommandBuffer(device, renderPass, cmdBuffer, globalDescriptorSet, offset, &_dynamicOffsets);
|
||||
_batchedQueues[i]->recordCommandBuffer(device, renderPass, cmdBuffer, globalDescriptorSet, offset, &_dynamicOffsets);
|
||||
}
|
||||
|
||||
const bool enableOcclusionQuery = _pipeline->isOcclusionQueryEnabled();
|
||||
@@ -166,13 +159,23 @@ void RenderAdditiveLightQueue::gatherLightPasses(const scene::Camera *camera, gf
|
||||
_batchedLightPass.lights.emplace_back(light);
|
||||
_batchedLightPass.dynamicOffsets.emplace_back(_lightBufferStride * l);
|
||||
}
|
||||
_instancedQueue->uploadBuffers(cmdBuffer);
|
||||
_batchedQueue->uploadBuffers(cmdBuffer);
|
||||
for (const auto &instancedQueue : _instancedQueues) {
|
||||
instancedQueue->uploadBuffers(cmdBuffer);
|
||||
}
|
||||
for (const auto &batchedQueue : _batchedQueues) {
|
||||
batchedQueue->uploadBuffers(cmdBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderAdditiveLightQueue::clear() {
|
||||
_instancedQueue->clear();
|
||||
_batchedQueue->clear();
|
||||
for (const auto &instancedQueue : _instancedQueues) {
|
||||
instancedQueue->clear();
|
||||
}
|
||||
_instancedQueues.clear();
|
||||
for (const auto &batchedQueue : _batchedQueues) {
|
||||
batchedQueue->clear();
|
||||
}
|
||||
_batchedQueues.clear();
|
||||
|
||||
for (auto lightPass : _lightPasses) {
|
||||
lightPass.dynamicOffsets.clear();
|
||||
@@ -217,13 +220,19 @@ void RenderAdditiveLightQueue::addRenderQueue(scene::SubModel *subModel, const s
|
||||
auto *buffer = pass->getInstancedBuffer(i);
|
||||
buffer->merge(subModel, lightPassIdx);
|
||||
buffer->setDynamicOffset(0, _lightBufferStride);
|
||||
_instancedQueue->add(buffer);
|
||||
if (i >= _instancedQueues.size()) {
|
||||
_instancedQueues.emplace_back(ccnew RenderInstancedQueue());
|
||||
}
|
||||
_instancedQueues[i]->add(buffer);
|
||||
} break;
|
||||
case scene::BatchingSchemes::VB_MERGING: {
|
||||
auto *buffer = pass->getBatchedBuffer(i);
|
||||
buffer->merge(subModel, lightPassIdx, model);
|
||||
buffer->setDynamicOffset(0, _lightBufferStride);
|
||||
_batchedQueue->add(buffer);
|
||||
if (i >= _batchedQueues.size()) {
|
||||
_batchedQueues.emplace_back(ccnew RenderBatchedQueue());
|
||||
}
|
||||
_batchedQueues[i]->add(buffer);
|
||||
} break;
|
||||
case scene::BatchingSchemes::NONE: {
|
||||
lightPass.lights.emplace_back(light);
|
||||
|
||||
@@ -54,7 +54,7 @@ struct AdditiveLightPass {
|
||||
class RenderAdditiveLightQueue final {
|
||||
public:
|
||||
explicit RenderAdditiveLightQueue(RenderPipeline *pipeline);
|
||||
~RenderAdditiveLightQueue();
|
||||
~RenderAdditiveLightQueue() = default;
|
||||
|
||||
void recordCommandBuffer(gfx::Device *device, scene::Camera *camera, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer);
|
||||
void gatherLightPasses(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer);
|
||||
@@ -77,10 +77,6 @@ private:
|
||||
|
||||
// weak reference
|
||||
RenderPipeline *_pipeline{nullptr};
|
||||
// manage memory manually
|
||||
RenderInstancedQueue *_instancedQueue{nullptr};
|
||||
// manage memory manually
|
||||
RenderBatchedQueue *_batchedQueue{nullptr};
|
||||
|
||||
IntrusivePtr<gfx::Buffer> _lightBuffer;
|
||||
IntrusivePtr<gfx::Buffer> _firstLightBufferView;
|
||||
@@ -99,6 +95,10 @@ private:
|
||||
// weak reference
|
||||
ccstd::vector<const scene::Light *> _validPunctualLights;
|
||||
|
||||
ccstd::vector<IntrusivePtr<RenderInstancedQueue>> _instancedQueues;
|
||||
|
||||
ccstd::vector<IntrusivePtr<RenderBatchedQueue>> _batchedQueues;
|
||||
|
||||
ccstd::vector<AdditiveLightPass> _lightPasses;
|
||||
|
||||
ccstd::vector<ccstd::vector<uint32_t>> _sortedPSOCIArray;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base/RefCounted.h"
|
||||
#include "base/std/container/unordered_set.h"
|
||||
#include "gfx-base/GFXDef.h"
|
||||
|
||||
@@ -39,10 +40,10 @@ namespace pipeline {
|
||||
|
||||
class BatchedBuffer;
|
||||
|
||||
class CC_DLL RenderBatchedQueue final {
|
||||
class CC_DLL RenderBatchedQueue final : public RefCounted {
|
||||
public:
|
||||
RenderBatchedQueue() = default;
|
||||
~RenderBatchedQueue() = default;
|
||||
~RenderBatchedQueue() override = default;
|
||||
|
||||
void clear();
|
||||
void uploadBuffers(gfx::CommandBuffer *cmdBuff);
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace pipeline {
|
||||
|
||||
class InstancedBuffer;
|
||||
|
||||
class CC_DLL RenderInstancedQueue final {
|
||||
class CC_DLL RenderInstancedQueue final : public RefCounted {
|
||||
public:
|
||||
RenderInstancedQueue() = default;
|
||||
~RenderInstancedQueue() = default;
|
||||
~RenderInstancedQueue() override = default;
|
||||
void recordCommandBuffer(gfx::Device *device, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer,
|
||||
gfx::DescriptorSet *ds = nullptr, uint32_t offset = 0, const ccstd::vector<uint32_t> *dynamicOffsets = nullptr);
|
||||
void add(InstancedBuffer *instancedBuffer);
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "PipelineStateManager.h"
|
||||
#include "PipelineUBO.h"
|
||||
#include "RenderFlow.h"
|
||||
#include "RenderPipeline.h"
|
||||
#include "base/StringUtil.h"
|
||||
#include "base/std/hash/hash.h"
|
||||
#include "frame-graph/FrameGraph.h"
|
||||
@@ -42,6 +41,7 @@
|
||||
#if CC_USE_DEBUG_RENDERER
|
||||
#include "profiler/DebugRenderer.h"
|
||||
#endif
|
||||
#include "custom/NativeUtils.h"
|
||||
#include "scene/Camera.h"
|
||||
#include "scene/Skybox.h"
|
||||
|
||||
@@ -291,31 +291,8 @@ void RenderPipeline::setShadingScale(float scale) {
|
||||
_pipelineSceneData->setShadingScale(scale);
|
||||
}
|
||||
|
||||
void RenderPipeline::genQuadVertexData(const Vec4 &viewport, float *vbData) {
|
||||
auto minX = static_cast<float>(viewport.x);
|
||||
auto maxX = static_cast<float>(viewport.x + viewport.z);
|
||||
auto minY = static_cast<float>(viewport.y);
|
||||
auto maxY = static_cast<float>(viewport.y + viewport.w);
|
||||
if (_device->getCapabilities().screenSpaceSignY > 0) {
|
||||
std::swap(minY, maxY);
|
||||
}
|
||||
int n = 0;
|
||||
vbData[n++] = -1.0F;
|
||||
vbData[n++] = -1.0F;
|
||||
vbData[n++] = minX; // uv
|
||||
vbData[n++] = maxY;
|
||||
vbData[n++] = 1.0F;
|
||||
vbData[n++] = -1.0F;
|
||||
vbData[n++] = maxX;
|
||||
vbData[n++] = maxY;
|
||||
vbData[n++] = -1.0F;
|
||||
vbData[n++] = 1.0F;
|
||||
vbData[n++] = minX;
|
||||
vbData[n++] = minY;
|
||||
vbData[n++] = 1.0F;
|
||||
vbData[n++] = 1.0F;
|
||||
vbData[n++] = maxX;
|
||||
vbData[n++] = minY;
|
||||
void RenderPipeline::genQuadVertexData(const Vec4 &viewport, float vbData[16]) {
|
||||
render::setupQuadVertexBuffer(*_device, viewport, vbData);
|
||||
}
|
||||
|
||||
void RenderPipeline::generateConstantMacros() {
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
|
||||
gfx::Viewport getViewport(scene::Camera *camera);
|
||||
gfx::Rect getScissor(scene::Camera *camera);
|
||||
void genQuadVertexData(const Vec4 &viewport, float *data);
|
||||
void genQuadVertexData(const Vec4 &viewport, float data[16]);
|
||||
uint32_t getWidth() const { return _width; }
|
||||
uint32_t getHeight() const { return _height; }
|
||||
framegraph::FrameGraph &getFrameGraph() { return _fg; }
|
||||
|
||||
@@ -105,31 +105,40 @@ void shadowCulling(const RenderPipeline *pipeline, const scene::Camera *camera,
|
||||
|
||||
layer->clearShadowObjects();
|
||||
|
||||
for (size_t i = 0; i < csmLayers->getLayerObjects().size(); ++i) {
|
||||
const auto *model = csmLayers->getLayerObjects()[i].model;
|
||||
if (csmLayers->getLayerObjects().empty()) return;
|
||||
|
||||
for (auto it = csmLayers->getLayerObjects().begin(); it != csmLayers->getLayerObjects().end();) {
|
||||
const auto *model = it->model;
|
||||
if (!model || !model->isEnabled() || !model->getNode()) {
|
||||
it = csmLayers->getLayerObjects().erase(it);
|
||||
continue;
|
||||
}
|
||||
const auto *node = model->getNode();
|
||||
if (((visibility & node->getLayer()) != node->getLayer()) && !(visibility & static_cast<uint32_t>(model->getVisFlags()))) {
|
||||
it = csmLayers->getLayerObjects().erase(it);
|
||||
continue;
|
||||
}
|
||||
if (!model->getWorldBounds() || !model->isCastShadow()) {
|
||||
it = csmLayers->getLayerObjects().erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
// frustum culling
|
||||
const bool accurate = model->getWorldBounds()->aabbFrustum(layer->getValidFrustum());
|
||||
if (!accurate) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
layer->addShadowObject(genRenderObject(model, camera));
|
||||
if (layer->getLevel() < static_cast<uint32_t>(mainLight->getCSMLevel())) {
|
||||
if (mainLight->getCSMOptimizationMode() == scene::CSMOptimizationMode::REMOVE_DUPLICATES &&
|
||||
aabbFrustumCompletelyInside(*model->getWorldBounds(), layer->getValidFrustum())) {
|
||||
csmLayers->getLayerObjects().erase(csmLayers->getLayerObjects().begin() + static_cast<uint32_t>(i));
|
||||
i--;
|
||||
it = csmLayers->getLayerObjects().erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ RelationGraph::Vertex::Vertex(Vertex const& rhs, const allocator_type& alloc)
|
||||
: outEdges(rhs.outEdges, alloc),
|
||||
inEdges(rhs.inEdges, alloc) {}
|
||||
|
||||
FrameGraphDispatcher::FrameGraphDispatcher(ResourceGraph& resourceGraphIn, const RenderGraph& graphIn, LayoutGraphData& layoutGraphIn, boost::container::pmr::memory_resource* scratchIn, const allocator_type& alloc) noexcept
|
||||
FrameGraphDispatcher::FrameGraphDispatcher(ResourceGraph& resourceGraphIn, const RenderGraph& graphIn, const LayoutGraphData& layoutGraphIn, boost::container::pmr::memory_resource* scratchIn, const allocator_type& alloc) noexcept
|
||||
: resourceAccessGraph(alloc),
|
||||
resourceGraph(resourceGraphIn),
|
||||
graph(graphIn),
|
||||
|
||||
@@ -391,7 +391,7 @@ struct FrameGraphDispatcher {
|
||||
return {resourceAccessGraph.get_allocator().resource()};
|
||||
}
|
||||
|
||||
FrameGraphDispatcher(ResourceGraph& resourceGraphIn, const RenderGraph& graphIn, LayoutGraphData& layoutGraphIn, boost::container::pmr::memory_resource* scratchIn, const allocator_type& alloc) noexcept;
|
||||
FrameGraphDispatcher(ResourceGraph& resourceGraphIn, const RenderGraph& graphIn, const LayoutGraphData& layoutGraphIn, boost::container::pmr::memory_resource* scratchIn, const allocator_type& alloc) noexcept;
|
||||
FrameGraphDispatcher(FrameGraphDispatcher&& rhs) = delete;
|
||||
FrameGraphDispatcher(FrameGraphDispatcher const& rhs) = delete;
|
||||
FrameGraphDispatcher& operator=(FrameGraphDispatcher&& rhs) = delete;
|
||||
@@ -417,7 +417,7 @@ struct FrameGraphDispatcher {
|
||||
ResourceAccessGraph resourceAccessGraph;
|
||||
ResourceGraph& resourceGraph;
|
||||
const RenderGraph& graph;
|
||||
LayoutGraphData& layoutGraph;
|
||||
const LayoutGraphData& layoutGraph;
|
||||
boost::container::pmr::memory_resource* scratch{nullptr};
|
||||
PmrFlatMap<ccstd::pmr::string, ResourceTransition> externalResMap;
|
||||
RelationGraph relationGraph;
|
||||
|
||||
@@ -177,7 +177,7 @@ bool isPassExecAdjecent(uint32_t passLID, uint32_t passRID) {
|
||||
return std::abs(static_cast<int>(passLID) - static_cast<int>(passRID)) <= 1;
|
||||
}
|
||||
|
||||
bool isStatusDependent(const AccessStatus &lhs, const AccessStatus &rhs);
|
||||
bool isTransitionStatusDependent(const AccessStatus &lhs, const AccessStatus &rhs);
|
||||
template <typename Graph>
|
||||
bool tryAddEdge(uint32_t srcVertex, uint32_t dstVertex, Graph &graph);
|
||||
|
||||
@@ -304,14 +304,14 @@ void buildAccessGraph(const RenderGraph &renderGraph, const Graphs &graphs) {
|
||||
bool isExternal = pass.second.isExternal;
|
||||
bool needCulling = pass.second.needCulling;
|
||||
|
||||
if (isExternal && !needCulling) {
|
||||
if (pass.first != resourceAccessGraph.presentPassID) {
|
||||
if(pass.first != resourceAccessGraph.presentPassID) {
|
||||
if (isExternal && !needCulling) {
|
||||
add_edge(pass.first, resourceAccessGraph.presentPassID, resourceAccessGraph);
|
||||
}
|
||||
} else {
|
||||
// write into transient resources, culled
|
||||
if constexpr (ENABLE_BRANCH_CULLING) {
|
||||
branchCulling(pass.first, resourceAccessGraph);
|
||||
} else {
|
||||
// write into transient resources, culled
|
||||
if constexpr (ENABLE_BRANCH_CULLING) {
|
||||
branchCulling(pass.first, resourceAccessGraph);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -454,7 +454,7 @@ struct BarrierVisitor : public boost::bfs_visitor<> {
|
||||
CC_ASSERT(fromIter != srcStatus.end());
|
||||
CC_ASSERT(toIter != dstStatus.end());
|
||||
|
||||
if (!isStatusDependent(*fromIter, *toIter)) {
|
||||
if (!isTransitionStatusDependent(*fromIter, *toIter)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ struct BarrierVisitor : public boost::bfs_visitor<> {
|
||||
externalMap[resName].currStatus = resourcecAccess;
|
||||
externalMap[resName].currStatus.vertID = vert;
|
||||
|
||||
if (isStatusDependent(externalMap[resName].lastStatus, externalMap[resName].currStatus)) {
|
||||
if (isTransitionStatusDependent(externalMap[resName].lastStatus, externalMap[resName].currStatus)) {
|
||||
barrierMap[vert].blockBarrier.frontBarriers.emplace_back(Barrier{
|
||||
rescID,
|
||||
gfx::BarrierType::SPLIT_END,
|
||||
@@ -809,6 +809,7 @@ void buildBarriers(FrameGraphDispatcher &fgDispatcher) {
|
||||
}
|
||||
};
|
||||
|
||||
// generate gfx barrier
|
||||
for (auto &passBarrierInfo : batchedBarriers) {
|
||||
auto &passBarrierNode = passBarrierInfo.second;
|
||||
genGFXBarrier(passBarrierNode.blockBarrier.frontBarriers);
|
||||
@@ -960,7 +961,7 @@ auto evaluateHeaviness(const RAG &rag, const ResourceGraph &rescGraph, ResourceA
|
||||
break;
|
||||
}
|
||||
}
|
||||
return std::tie(forceAdjacent, score);
|
||||
return std::make_tuple(forceAdjacent, score);
|
||||
};
|
||||
|
||||
void evaluateAndTryMerge(const RAG &rag, const ResourceGraph &rescGraph, RelationGraph &relationGraph, const RelationGraph &relationGraphTc, const RelationVerts &lhsVerts, const RelationVerts &rhsVerts) {
|
||||
@@ -1374,12 +1375,11 @@ bool tryAddEdge(uint32_t srcVertex, uint32_t dstVertex, Graph &graph) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isStatusDependent(const AccessStatus &lhs, const AccessStatus &rhs) {
|
||||
bool isTransitionStatusDependent(const AccessStatus &lhs, const AccessStatus &rhs) {
|
||||
bool res = true;
|
||||
if (lhs.passType == rhs.passType &&
|
||||
lhs.visibility == rhs.visibility &&
|
||||
lhs.access == gfx::MemoryAccessBit::READ_ONLY &&
|
||||
rhs.access == gfx::MemoryAccessBit::READ_ONLY &&
|
||||
lhs.access == rhs.access &&
|
||||
lhs.usage == rhs.usage) {
|
||||
res = false;
|
||||
}
|
||||
@@ -1451,7 +1451,7 @@ auto getResourceStatus(PassType passType, const PmrString &name, gfx::MemoryAcce
|
||||
accesFlag = gfx::getAccessFlags(texUsage, memAccess, vis);
|
||||
}
|
||||
|
||||
return std::tie(vis, usage, accesFlag);
|
||||
return std::make_tuple(vis, usage, accesFlag);
|
||||
}
|
||||
|
||||
void addCopyAccessStatus(RAG &rag, const ResourceGraph &rg, ResourceAccessNode &node, const ViewStatus &status, const Range &range) {
|
||||
@@ -1539,7 +1539,9 @@ AccessVertex dependencyCheck(RAG &rag, AccessVertex curVertID, const ResourceGra
|
||||
}
|
||||
}
|
||||
if (isExternalPass) {
|
||||
rag.leafPasses[curVertID] = LeafStatus{true, access == gfx::MemoryAccessBit::READ_ONLY && passType != PassType::PRESENT};
|
||||
// only external res will be manually record here, leaf pass with transient resource will be culled by default,
|
||||
// those leaf passes with ALL read access on external(or with transients) res can be culled.
|
||||
rag.leafPasses[curVertID].needCulling &= (access == gfx::MemoryAccessBit::READ_ONLY && passType != PassType::PRESENT);
|
||||
}
|
||||
trans.currStatus = {curVertID, visibility, access, passType, accessFlag, usage, Range{}};
|
||||
lastVertID = trans.lastStatus.vertID;
|
||||
@@ -1555,7 +1557,8 @@ AccessVertex dependencyCheck(RAG &rag, AccessVertex curVertID, const ResourceGra
|
||||
if (rag.leafPasses.find(curVertID) != rag.leafPasses.end()) {
|
||||
// only write into externalRes counts
|
||||
if (isExternalPass) {
|
||||
rag.leafPasses[curVertID] = LeafStatus{true, access == gfx::MemoryAccessBit::READ_ONLY && passType != PassType::PRESENT};
|
||||
// same as above
|
||||
rag.leafPasses[curVertID].needCulling &= (access == gfx::MemoryAccessBit::READ_ONLY && passType != PassType::PRESENT);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -199,6 +199,8 @@ inline void load(InputArchive& ar, DescriptorBlockData& v) {
|
||||
inline void save(OutputArchive& ar, const DescriptorSetLayoutData& v) {
|
||||
save(ar, v.slot);
|
||||
save(ar, v.capacity);
|
||||
save(ar, v.uniformBlockCapacity);
|
||||
save(ar, v.samplerTextureCapacity);
|
||||
save(ar, v.descriptorBlocks);
|
||||
save(ar, v.uniformBlocks);
|
||||
save(ar, v.bindingMap);
|
||||
@@ -207,6 +209,8 @@ inline void save(OutputArchive& ar, const DescriptorSetLayoutData& v) {
|
||||
inline void load(InputArchive& ar, DescriptorSetLayoutData& v) {
|
||||
load(ar, v.slot);
|
||||
load(ar, v.capacity);
|
||||
load(ar, v.uniformBlockCapacity);
|
||||
load(ar, v.samplerTextureCapacity);
|
||||
load(ar, v.descriptorBlocks);
|
||||
load(ar, v.uniformBlocks);
|
||||
load(ar, v.bindingMap);
|
||||
|
||||
@@ -146,6 +146,8 @@ DescriptorSetLayoutData::DescriptorSetLayoutData(uint32_t slotIn, uint32_t capac
|
||||
DescriptorSetLayoutData::DescriptorSetLayoutData(DescriptorSetLayoutData&& rhs, const allocator_type& alloc)
|
||||
: slot(rhs.slot),
|
||||
capacity(rhs.capacity),
|
||||
uniformBlockCapacity(rhs.uniformBlockCapacity),
|
||||
samplerTextureCapacity(rhs.samplerTextureCapacity),
|
||||
descriptorBlocks(std::move(rhs.descriptorBlocks), alloc),
|
||||
uniformBlocks(std::move(rhs.uniformBlocks), alloc),
|
||||
bindingMap(std::move(rhs.bindingMap), alloc) {}
|
||||
@@ -232,7 +234,6 @@ LayoutGraphData::LayoutGraphData(const allocator_type& alloc) noexcept
|
||||
constantIndex(alloc),
|
||||
shaderLayoutIndex(alloc),
|
||||
effects(alloc),
|
||||
constantMacros(alloc),
|
||||
pathIndex(alloc) {}
|
||||
|
||||
LayoutGraphData::LayoutGraphData(LayoutGraphData&& rhs, const allocator_type& alloc)
|
||||
@@ -247,7 +248,7 @@ LayoutGraphData::LayoutGraphData(LayoutGraphData&& rhs, const allocator_type& al
|
||||
constantIndex(std::move(rhs.constantIndex), alloc),
|
||||
shaderLayoutIndex(std::move(rhs.shaderLayoutIndex), alloc),
|
||||
effects(std::move(rhs.effects), alloc),
|
||||
constantMacros(std::move(rhs.constantMacros), alloc),
|
||||
constantMacros(std::move(rhs.constantMacros)),
|
||||
pathIndex(std::move(rhs.pathIndex), alloc) {}
|
||||
|
||||
// ContinuousContainer
|
||||
|
||||
@@ -365,6 +365,8 @@ struct DescriptorSetLayoutData {
|
||||
|
||||
uint32_t slot{0xFFFFFFFF};
|
||||
uint32_t capacity{0};
|
||||
uint32_t uniformBlockCapacity{0};
|
||||
uint32_t samplerTextureCapacity{0};
|
||||
ccstd::pmr::vector<DescriptorBlockData> descriptorBlocks;
|
||||
ccstd::pmr::unordered_map<NameLocalID, gfx::UniformBlock> uniformBlocks;
|
||||
PmrFlatMap<NameLocalID, uint32_t> bindingMap;
|
||||
@@ -704,7 +706,7 @@ struct LayoutGraphData {
|
||||
PmrFlatMap<ccstd::pmr::string, NameLocalID> constantIndex;
|
||||
PmrFlatMap<ccstd::pmr::string, uint32_t> shaderLayoutIndex;
|
||||
PmrFlatMap<ccstd::pmr::string, EffectData> effects;
|
||||
ccstd::pmr::string constantMacros;
|
||||
ccstd::string constantMacros;
|
||||
// Path
|
||||
PmrTransparentMap<ccstd::pmr::string, vertex_descriptor> pathIndex;
|
||||
};
|
||||
|
||||
@@ -26,12 +26,19 @@
|
||||
#include "LayoutGraphUtils.h"
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include "LayoutGraphGraphs.h"
|
||||
#include "LayoutGraphNames.h"
|
||||
#include "LayoutGraphTypes.h"
|
||||
#include "RenderCommonNames.h"
|
||||
#include "RenderCommonTypes.h"
|
||||
#include "cocos/base/Log.h"
|
||||
#include "cocos/base/StringUtil.h"
|
||||
#include "cocos/base/std/container/string.h"
|
||||
#include "cocos/renderer/gfx-base/GFXDef-common.h"
|
||||
#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h"
|
||||
#include "cocos/renderer/pipeline/custom/RenderCommonTypes.h"
|
||||
#include "details/DebugUtils.h"
|
||||
#include "details/GslUtils.h"
|
||||
#include "details/Map.h"
|
||||
#include "details/Range.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
@@ -49,7 +56,7 @@ DescriptorBlockData& getDescriptorBlockData(
|
||||
iter = map.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(index),
|
||||
std::forward_as_tuple())
|
||||
std::forward_as_tuple(index.descriptorType, index.visibility, 0))
|
||||
.first;
|
||||
|
||||
return iter->second;
|
||||
@@ -241,6 +248,13 @@ void makeDescriptorSetLayoutData(
|
||||
}
|
||||
// increate total capacity
|
||||
capacity += block.capacity;
|
||||
data.capacity += block.capacity;
|
||||
if (index.descriptorType == DescriptorTypeOrder::UNIFORM_BUFFER ||
|
||||
index.descriptorType == DescriptorTypeOrder::DYNAMIC_UNIFORM_BUFFER) {
|
||||
data.uniformBlockCapacity += block.capacity;
|
||||
} else if (index.descriptorType == DescriptorTypeOrder::SAMPLER_TEXTURE) {
|
||||
data.samplerTextureCapacity += block.capacity;
|
||||
}
|
||||
data.descriptorBlocks.emplace_back(std::move(block));
|
||||
}
|
||||
}
|
||||
@@ -267,16 +281,21 @@ void initializeDescriptorSetLayoutInfo(
|
||||
namespace {
|
||||
|
||||
const ccstd::unordered_map<ccstd::string, uint32_t> DEFAULT_UNIFORM_COUNTS{
|
||||
{"cc_joints", pipeline::UBOSkinning::layout.members[0].count},
|
||||
{"cc_lightPos", pipeline::UBOForwardLight::LIGHTS_PER_PASS},
|
||||
{"cc_lightColor", pipeline::UBOForwardLight::LIGHTS_PER_PASS},
|
||||
{"cc_lightSizeRangeAngle", pipeline::UBOForwardLight::LIGHTS_PER_PASS},
|
||||
{"cc_lightDir", pipeline::UBOForwardLight::LIGHTS_PER_PASS},
|
||||
};
|
||||
|
||||
const TransparentSet<ccstd::string> DYNAMIC_UNIFORM_BLOCK{
|
||||
{"CCCamera"},
|
||||
{"CCForwardLight"},
|
||||
{"CCUILocal"},
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
uint32_t getSize(const ccstd::vector<gfx::Uniform>& blockMembers) {
|
||||
uint32_t getUniformBlockSize(const ccstd::vector<gfx::Uniform>& blockMembers) {
|
||||
uint32_t prevSize = 0;
|
||||
for (const auto& m : blockMembers) {
|
||||
if (m.count) {
|
||||
@@ -288,11 +307,178 @@ uint32_t getSize(const ccstd::vector<gfx::Uniform>& blockMembers) {
|
||||
prevSize += getTypeSize(m.type) * iter->second;
|
||||
continue;
|
||||
}
|
||||
if (m.name == "cc_joints") {
|
||||
const auto sz = getTypeSize(m.type) * pipeline::UBOSkinning::layout.members[0].count;
|
||||
CC_EXPECTS(sz == pipeline::UBOSkinning::size);
|
||||
prevSize += sz;
|
||||
continue;
|
||||
}
|
||||
CC_LOG_ERROR("Invalid uniform count: %s", m.name.c_str());
|
||||
}
|
||||
CC_ENSURES(prevSize);
|
||||
return prevSize;
|
||||
}
|
||||
|
||||
bool isDynamicUniformBlock(std::string_view name) {
|
||||
return DYNAMIC_UNIFORM_BLOCK.find(name) != DYNAMIC_UNIFORM_BLOCK.end();
|
||||
}
|
||||
|
||||
gfx::DescriptorSet* getOrCreatePerPassDescriptorSet(
|
||||
gfx::Device* device,
|
||||
LayoutGraphData& lg, LayoutGraphData::vertex_descriptor vertID) {
|
||||
auto& ppl = get(LayoutGraphData::Layout, lg, vertID);
|
||||
auto iter = ppl.descriptorSets.find(UpdateFrequency::PER_PASS);
|
||||
if (iter == ppl.descriptorSets.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto& data = iter->second;
|
||||
if (!data.descriptorSet) {
|
||||
if (!data.descriptorSetLayout) {
|
||||
data.descriptorSetLayout = device->createDescriptorSetLayout(data.descriptorSetLayoutInfo);
|
||||
}
|
||||
CC_ENSURES(data.descriptorSetLayout);
|
||||
data.descriptorSet = device->createDescriptorSet(gfx::DescriptorSetInfo{data.descriptorSetLayout.get()});
|
||||
}
|
||||
CC_ENSURES(data.descriptorSet);
|
||||
return data.descriptorSet;
|
||||
}
|
||||
|
||||
void generateConstantMacros(
|
||||
gfx::Device* device,
|
||||
ccstd::string& constantMacros,
|
||||
bool clusterEnabled) {
|
||||
constantMacros = StringUtil::format(
|
||||
R"(
|
||||
#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE %d
|
||||
#define CC_ENABLE_CLUSTERED_LIGHT_CULLING %d
|
||||
#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS %d
|
||||
#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS %d
|
||||
#define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT %d
|
||||
#define CC_PLATFORM_ANDROID_AND_WEBGL 0
|
||||
#define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0
|
||||
#define CC_JOINT_UNIFORM_CAPACITY %d
|
||||
)",
|
||||
hasAnyFlags(device->getFormatFeatures(gfx::Format::RGBA32F),
|
||||
gfx::FormatFeature::RENDER_TARGET | gfx::FormatFeature::SAMPLED_TEXTURE),
|
||||
clusterEnabled ? 1 : 0,
|
||||
device->getCapabilities().maxVertexUniformVectors,
|
||||
device->getCapabilities().maxFragmentUniformVectors,
|
||||
device->hasFeature(gfx::Feature::INPUT_ATTACHMENT_BENEFIT),
|
||||
pipeline::SkinningJointCapacity::jointUniformCapacity);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
ccstd::string getName(gfx::ShaderStageFlagBit stage) {
|
||||
std::ostringstream oss;
|
||||
int count = 0;
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::VERTEX)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Vertex";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::CONTROL)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Control";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::EVALUATION)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Evaluation";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::GEOMETRY)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Geometry";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::FRAGMENT)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Fragment";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::COMPUTE)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Compute";
|
||||
}
|
||||
if (hasAllFlags(stage, gfx::ShaderStageFlagBit::ALL)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "All";
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void printLayoutGraphData(
|
||||
const LayoutGraphData& lg, std::ostream& oss,
|
||||
boost::container::pmr::memory_resource* scratch) {
|
||||
ccstd::pmr::string space(scratch);
|
||||
|
||||
oss << "\n";
|
||||
|
||||
for (const auto v : makeRange(vertices(lg))) {
|
||||
if (parent(v, lg) != LayoutGraphData::null_vertex()) {
|
||||
continue;
|
||||
}
|
||||
const auto& name = get(LayoutGraphData::Name, lg, v);
|
||||
OSS << "\"" << name << "\": ";
|
||||
|
||||
visit(
|
||||
[&](auto tag) {
|
||||
oss << getName(tag);
|
||||
},
|
||||
tag(v, lg));
|
||||
|
||||
oss << " {\n";
|
||||
INDENT_BEG();
|
||||
const auto& info = get(LayoutGraphData::Layout, lg, v);
|
||||
for (const auto& set : info.descriptorSets) {
|
||||
OSS << "Set<" << getName(set.first) << "> {\n";
|
||||
{
|
||||
INDENT();
|
||||
for (const auto& block : set.second.descriptorSetLayoutData.descriptorBlocks) {
|
||||
OSS << "Block<" << getName(block.type) << ", " << getName(block.visibility) << "> {\n";
|
||||
{
|
||||
INDENT();
|
||||
OSS << "capacity: " << block.capacity << ",\n";
|
||||
OSS << "count: " << block.descriptors.size() << ",\n";
|
||||
if (!block.descriptors.empty()) {
|
||||
OSS << "Descriptors{ ";
|
||||
int count = 0;
|
||||
for (const auto& d : block.descriptors) {
|
||||
if (count++) {
|
||||
oss << ", ";
|
||||
}
|
||||
const auto& name = lg.valueNames.at(d.descriptorID.value);
|
||||
oss << "\"" << name;
|
||||
if (d.count != 1) {
|
||||
oss << "[" << d.count << "]";
|
||||
}
|
||||
oss << "\"";
|
||||
}
|
||||
oss << " }\n";
|
||||
}
|
||||
}
|
||||
OSS << "}\n";
|
||||
}
|
||||
}
|
||||
OSS << "}\n";
|
||||
}
|
||||
INDENT_END();
|
||||
OSS << "}\n";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
|
||||
} // namespace cc
|
||||
|
||||
@@ -24,9 +24,11 @@
|
||||
|
||||
#pragma once
|
||||
#include <boost/container/pmr/memory_resource.hpp>
|
||||
#include <iosfwd>
|
||||
#include "cocos/core/assets/EffectAsset.h"
|
||||
#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h"
|
||||
#include "cocos/renderer/pipeline/custom/RenderCommonTypes.h"
|
||||
#include "gfx-base/GFXDevice.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
@@ -47,7 +49,22 @@ void initializeDescriptorSetLayoutInfo(
|
||||
const DescriptorSetLayoutData& layoutData,
|
||||
gfx::DescriptorSetLayoutInfo& info);
|
||||
|
||||
uint32_t getSize(const ccstd::vector<gfx::Uniform>& blockMembers);
|
||||
uint32_t getUniformBlockSize(const ccstd::vector<gfx::Uniform>& blockMembers);
|
||||
|
||||
bool isDynamicUniformBlock(std::string_view name);
|
||||
|
||||
gfx::DescriptorSet* getOrCreatePerPassDescriptorSet(
|
||||
gfx::Device* device,
|
||||
LayoutGraphData& lg, LayoutGraphData::vertex_descriptor vertID);
|
||||
|
||||
void generateConstantMacros(
|
||||
gfx::Device* device,
|
||||
ccstd::string& constantMacros,
|
||||
bool clusterEnabled);
|
||||
|
||||
void printLayoutGraphData(
|
||||
const LayoutGraphData& lg, std::ostream& oss,
|
||||
boost::container::pmr::memory_resource* scratch);
|
||||
|
||||
} // namespace render
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@
|
||||
#include "LayoutGraphSerialization.h"
|
||||
#include "NativePipelineTypes.h"
|
||||
#include "RenderInterfaceTypes.h"
|
||||
#include "RenderingModule.h"
|
||||
#include "details/GslUtils.h"
|
||||
#include "pipeline/custom/LayoutGraphTypes.h"
|
||||
#include "pipeline/custom/details/Pmr.h"
|
||||
@@ -39,12 +40,11 @@ namespace render {
|
||||
namespace {
|
||||
|
||||
NativeRenderingModule* sRenderingModule = nullptr;
|
||||
NativePipeline* sPipeline = nullptr;
|
||||
|
||||
} // namespace
|
||||
|
||||
RenderingModule* Factory::init(gfx::Device* deviceIn, const ccstd::vector<unsigned char>& bufferIn) {
|
||||
std::ignore = deviceIn;
|
||||
|
||||
std::shared_ptr<NativeProgramLibrary> ptr(
|
||||
allocatePmrUniquePtr<NativeProgramLibrary>(
|
||||
boost::container::pmr::get_default_resource()));
|
||||
@@ -54,6 +54,7 @@ RenderingModule* Factory::init(gfx::Device* deviceIn, const ccstd::vector<unsign
|
||||
BinaryInputArchive ar(iss, boost::container::pmr::get_default_resource());
|
||||
load(ar, ptr->layoutGraph);
|
||||
}
|
||||
ptr->init(deviceIn);
|
||||
|
||||
sRenderingModule = ccnew NativeRenderingModule(std::move(ptr));
|
||||
return sRenderingModule;
|
||||
@@ -63,11 +64,31 @@ void Factory::destroy(RenderingModule* renderingModule) noexcept {
|
||||
auto* ptr = dynamic_cast<NativeRenderingModule*>(renderingModule);
|
||||
if (ptr) {
|
||||
ptr->programLibrary.reset();
|
||||
CC_EXPECTS(sRenderingModule == renderingModule);
|
||||
sRenderingModule = nullptr;
|
||||
sPipeline = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Pipeline* Factory::createPipeline() {
|
||||
return ccnew NativePipeline(boost::container::pmr::get_default_resource());
|
||||
if (sPipeline) {
|
||||
return sPipeline;
|
||||
}
|
||||
sPipeline = ccnew NativePipeline(boost::container::pmr::get_default_resource());
|
||||
CC_EXPECTS(sRenderingModule);
|
||||
sRenderingModule->programLibrary->pipeline = sPipeline;
|
||||
return sPipeline;
|
||||
}
|
||||
|
||||
ProgramLibrary* getProgramLibrary() {
|
||||
if (!sRenderingModule) {
|
||||
return nullptr;
|
||||
}
|
||||
return sRenderingModule->programLibrary.get();
|
||||
}
|
||||
|
||||
RenderingModule* getRenderingModule() {
|
||||
return sRenderingModule;
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -30,16 +30,14 @@
|
||||
// clang-format off
|
||||
#pragma once
|
||||
#include "cocos/base/std/variant.h"
|
||||
#include "cocos/renderer/core/ProgramLib.h"
|
||||
#include "cocos/renderer/pipeline/custom/LayoutGraphFwd.h"
|
||||
#include "cocos/renderer/pipeline/custom/RenderInterfaceFwd.h"
|
||||
#include "cocos/renderer/pipeline/custom/PrivateFwd.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
struct ProgramInfo;
|
||||
struct ProgramHost;
|
||||
struct ProgramGroup;
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -1,334 +0,0 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2021-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "LayoutGraphGraphs.h"
|
||||
#include "LayoutGraphNames.h"
|
||||
#include "LayoutGraphTypes.h"
|
||||
#include "NativePipelineGraphs.h"
|
||||
#include "RenderCommonNames.h"
|
||||
#include "cocos/renderer/gfx-base/GFXDevice.h"
|
||||
#include "details/DebugUtils.h"
|
||||
#include "details/GslUtils.h"
|
||||
#include "details/Pmr.h"
|
||||
#include "details/Range.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
void NativeLayoutGraphBuilder::clear() {
|
||||
*data = LayoutGraphData(data->get_allocator());
|
||||
}
|
||||
|
||||
uint32_t NativeLayoutGraphBuilder::addRenderStage(const ccstd::string &name) {
|
||||
return add_vertex(*data, RenderStageTag{}, name.c_str());
|
||||
}
|
||||
|
||||
uint32_t NativeLayoutGraphBuilder::addRenderPhase(const ccstd::string &name, uint32_t parentID) {
|
||||
return add_vertex(*data, RenderPhaseTag{}, name.c_str(), parentID);
|
||||
}
|
||||
|
||||
void NativeLayoutGraphBuilder::addShader(const ccstd::string &name, uint32_t parentPhaseID) {
|
||||
auto res = data->shaderLayoutIndex.emplace(name.c_str(), parentPhaseID);
|
||||
CC_ENSURES(res.second);
|
||||
}
|
||||
|
||||
void NativeLayoutGraphBuilder::addDescriptorBlock(
|
||||
uint32_t nodeID,
|
||||
const DescriptorBlockIndex &index, const DescriptorBlockFlattened &b) {
|
||||
auto &g = *data;
|
||||
auto &ppl = get(LayoutGraphData::Layout, g, nodeID);
|
||||
|
||||
CC_EXPECTS(b.descriptorNames.size() == b.descriptors.size());
|
||||
CC_EXPECTS(b.uniformBlockNames.size() == b.uniformBlocks.size());
|
||||
DescriptorBlock block;
|
||||
for (uint32_t i = 0; i != b.descriptorNames.size(); ++i) {
|
||||
block.descriptors.emplace(b.descriptorNames[i], b.descriptors[i]);
|
||||
}
|
||||
for (uint32_t i = 0; i != b.uniformBlockNames.size(); ++i) {
|
||||
block.uniformBlocks.emplace(b.uniformBlockNames[i], b.uniformBlocks[i]);
|
||||
}
|
||||
block.capacity = b.capacity;
|
||||
block.count = b.count;
|
||||
|
||||
CC_ASSERT(block.capacity);
|
||||
auto &layout = ppl.descriptorSets[index.updateFrequency].descriptorSetLayoutData;
|
||||
|
||||
// add block
|
||||
layout.descriptorBlocks.emplace_back(
|
||||
index.descriptorType, index.visibility, block.capacity);
|
||||
|
||||
auto &dstBlock = layout.descriptorBlocks.back();
|
||||
dstBlock.offset = layout.capacity;
|
||||
dstBlock.capacity = block.capacity;
|
||||
for (const auto &pairD : block.descriptors) {
|
||||
const auto &name = pairD.first;
|
||||
const auto &d = pairD.second;
|
||||
auto iter = g.attributeIndex.find(std::string_view{name});
|
||||
if (iter == g.attributeIndex.end()) {
|
||||
auto attrID = gsl::narrow_cast<uint32_t>(g.valueNames.size());
|
||||
g.valueNames.emplace_back(name);
|
||||
bool added = false;
|
||||
std::tie(iter, added) = g.attributeIndex.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(name),
|
||||
std::forward_as_tuple(NameLocalID{attrID}));
|
||||
CC_ENSURES(added);
|
||||
}
|
||||
const auto &nameID = iter->second;
|
||||
dstBlock.descriptors.emplace_back(nameID, gfx::Type::UNKNOWN, d.count);
|
||||
}
|
||||
// update layout
|
||||
layout.capacity += block.capacity;
|
||||
}
|
||||
|
||||
void NativeLayoutGraphBuilder::addUniformBlock(uint32_t nodeID, const DescriptorBlockIndex &index, const ccstd::string &name, const gfx::UniformBlock &uniformBlock) {
|
||||
auto &g = *data;
|
||||
auto &ppl = get(LayoutGraphData::Layout, g, nodeID);
|
||||
auto &layout = ppl.descriptorSets[index.updateFrequency].descriptorSetLayoutData;
|
||||
auto iter = g.attributeIndex.find(std::string_view{name});
|
||||
if (iter == g.attributeIndex.end()) {
|
||||
auto attrID = gsl::narrow_cast<uint32_t>(g.valueNames.size());
|
||||
g.valueNames.emplace_back(name);
|
||||
bool added = false;
|
||||
std::tie(iter, added) = g.attributeIndex.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(name),
|
||||
std::forward_as_tuple(NameLocalID{attrID}));
|
||||
CC_ENSURES(added);
|
||||
}
|
||||
const auto &nameID = iter->second;
|
||||
layout.uniformBlocks.emplace(nameID, uniformBlock);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
gfx::DescriptorType getGfxType(DescriptorTypeOrder type) {
|
||||
switch (type) {
|
||||
case DescriptorTypeOrder::UNIFORM_BUFFER:
|
||||
return gfx::DescriptorType::UNIFORM_BUFFER;
|
||||
case DescriptorTypeOrder::DYNAMIC_UNIFORM_BUFFER:
|
||||
return gfx::DescriptorType::DYNAMIC_UNIFORM_BUFFER;
|
||||
case DescriptorTypeOrder::SAMPLER_TEXTURE:
|
||||
return gfx::DescriptorType::SAMPLER_TEXTURE;
|
||||
case DescriptorTypeOrder::SAMPLER:
|
||||
return gfx::DescriptorType::SAMPLER;
|
||||
case DescriptorTypeOrder::TEXTURE:
|
||||
return gfx::DescriptorType::TEXTURE;
|
||||
case DescriptorTypeOrder::STORAGE_BUFFER:
|
||||
return gfx::DescriptorType::STORAGE_BUFFER;
|
||||
case DescriptorTypeOrder::DYNAMIC_STORAGE_BUFFER:
|
||||
return gfx::DescriptorType::DYNAMIC_STORAGE_BUFFER;
|
||||
case DescriptorTypeOrder::STORAGE_IMAGE:
|
||||
return gfx::DescriptorType::STORAGE_IMAGE;
|
||||
case DescriptorTypeOrder::INPUT_ATTACHMENT:
|
||||
return gfx::DescriptorType::INPUT_ATTACHMENT;
|
||||
}
|
||||
throw std::invalid_argument("DescriptorType not found");
|
||||
}
|
||||
|
||||
IntrusivePtr<gfx::DescriptorSetLayout> createDescriptorSetLayout(
|
||||
gfx::Device *device, const DescriptorSetLayoutData &layoutData) {
|
||||
gfx::DescriptorSetLayoutInfo info;
|
||||
|
||||
for (const auto &block : layoutData.descriptorBlocks) {
|
||||
uint32_t slot = block.offset;
|
||||
for (const auto &d : block.descriptors) {
|
||||
gfx::DescriptorSetLayoutBinding binding;
|
||||
binding.binding = slot;
|
||||
binding.descriptorType = getGfxType(block.type);
|
||||
binding.count = d.count;
|
||||
binding.stageFlags = block.visibility;
|
||||
binding.immutableSamplers = {};
|
||||
info.bindings.emplace_back(std::move(binding));
|
||||
slot += d.count;
|
||||
}
|
||||
}
|
||||
|
||||
return {device->createDescriptorSetLayout(info)};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void NativeLayoutGraphBuilder::reserveDescriptorBlock(
|
||||
uint32_t nodeID,
|
||||
const DescriptorBlockIndex &index, const DescriptorBlockFlattened &block) {
|
||||
auto &g = *data;
|
||||
auto &ppl = get(LayoutGraphData::Layout, g, nodeID);
|
||||
|
||||
CC_ASSERT(block.capacity);
|
||||
auto &layout = ppl.descriptorSets[index.updateFrequency].descriptorSetLayoutData;
|
||||
|
||||
// add block
|
||||
layout.descriptorBlocks.emplace_back(
|
||||
index.descriptorType, index.visibility, block.capacity);
|
||||
|
||||
auto &dstBlock = layout.descriptorBlocks.back();
|
||||
dstBlock.offset = layout.capacity;
|
||||
dstBlock.capacity = block.capacity;
|
||||
|
||||
// update layout
|
||||
layout.capacity += block.capacity;
|
||||
}
|
||||
|
||||
int NativeLayoutGraphBuilder::compile() {
|
||||
auto &g = *data;
|
||||
// create descriptor sets
|
||||
for (const auto v : makeRange(vertices(g))) {
|
||||
auto &ppl = get(LayoutGraphData::Layout, g, v);
|
||||
for (auto &levelPair : ppl.descriptorSets) {
|
||||
auto &level = levelPair.second;
|
||||
const auto &layoutData = level.descriptorSetLayoutData;
|
||||
level.descriptorSetLayout = createDescriptorSetLayout(device, layoutData);
|
||||
level.descriptorSet = device->createDescriptorSet(
|
||||
gfx::DescriptorSetInfo{level.descriptorSetLayout.get()});
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
CC_LOG_DEBUG(print().c_str());
|
||||
#endif // _DEBUG
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
ccstd::string getName(gfx::ShaderStageFlagBit stage) {
|
||||
std::ostringstream oss;
|
||||
int count = 0;
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::VERTEX)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Vertex";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::CONTROL)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Control";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::EVALUATION)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Evaluation";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::GEOMETRY)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Geometry";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::FRAGMENT)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Fragment";
|
||||
}
|
||||
if (hasFlag(stage, gfx::ShaderStageFlagBit::COMPUTE)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "Compute";
|
||||
}
|
||||
if (hasAllFlags(stage, gfx::ShaderStageFlagBit::ALL)) {
|
||||
if (count++) {
|
||||
oss << " | ";
|
||||
}
|
||||
oss << "All";
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ccstd::string NativeLayoutGraphBuilder::print() const {
|
||||
std::ostringstream oss;
|
||||
boost::container::pmr::unsynchronized_pool_resource pool(
|
||||
boost::container::pmr::get_default_resource());
|
||||
ccstd::pmr::string space(&pool);
|
||||
|
||||
oss << "\n";
|
||||
|
||||
auto &g = *data;
|
||||
for (const auto v : makeRange(vertices(g))) {
|
||||
if (parent(v, g) != LayoutGraphData::null_vertex()) {
|
||||
continue;
|
||||
}
|
||||
const auto &name = get(LayoutGraphData::Name, g, v);
|
||||
const auto &freq = get(LayoutGraphData::Update, g, v);
|
||||
OSS << "\"" << name << "\": ";
|
||||
|
||||
visit(
|
||||
[&](auto tag) {
|
||||
oss << getName(tag);
|
||||
},
|
||||
tag(v, g));
|
||||
|
||||
oss << "<" << getName(freq) << "> {\n";
|
||||
INDENT_BEG();
|
||||
const auto &info = get(LayoutGraphData::Layout, g, v);
|
||||
for (const auto &set : info.descriptorSets) {
|
||||
OSS << "Set<" << getName(set.first) << "> {\n";
|
||||
{
|
||||
INDENT();
|
||||
for (const auto &block : set.second.descriptorSetLayoutData.descriptorBlocks) {
|
||||
OSS << "Block<" << getName(block.type) << ", " << getName(block.visibility) << "> {\n";
|
||||
{
|
||||
INDENT();
|
||||
OSS << "capacity: " << block.capacity << ",\n";
|
||||
OSS << "count: " << block.descriptors.size() << ",\n";
|
||||
if (!block.descriptors.empty()) {
|
||||
OSS << "Descriptors{ ";
|
||||
int count = 0;
|
||||
for (const auto &d : block.descriptors) {
|
||||
if (count++) {
|
||||
oss << ", ";
|
||||
}
|
||||
const auto &name = g.valueNames.at(d.descriptorID.value);
|
||||
oss << "\"" << name;
|
||||
if (d.count != 1) {
|
||||
oss << "[" << d.count << "]";
|
||||
}
|
||||
oss << "\"";
|
||||
}
|
||||
oss << " }\n";
|
||||
}
|
||||
}
|
||||
OSS << "}\n";
|
||||
}
|
||||
}
|
||||
OSS << "}\n";
|
||||
}
|
||||
INDENT_END();
|
||||
OSS << "}\n";
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
|
||||
} // namespace cc
|
||||
@@ -23,37 +23,39 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <boost/utility/string_view_fwd.hpp>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include "LayoutGraphFwd.h"
|
||||
#include "LayoutGraphGraphs.h"
|
||||
#include "LayoutGraphNames.h"
|
||||
#include "LayoutGraphTypes.h"
|
||||
#include "LayoutGraphUtils.h"
|
||||
#include "NativePipelineFwd.h"
|
||||
#include "NativePipelineTypes.h"
|
||||
#include "NativeUtils.h"
|
||||
#include "RenderCommonTypes.h"
|
||||
#include "RenderGraphGraphs.h"
|
||||
#include "RenderGraphTypes.h"
|
||||
#include "RenderInterfaceFwd.h"
|
||||
#include "RenderInterfaceTypes.h"
|
||||
#include "RenderingModule.h"
|
||||
#include "cocos/application/ApplicationManager.h"
|
||||
#include "cocos/base/Macros.h"
|
||||
#include "cocos/base/Ptr.h"
|
||||
#include "cocos/base/StringUtil.h"
|
||||
#include "cocos/base/std/container/string.h"
|
||||
#include "cocos/core/Root.h"
|
||||
#include "cocos/math/Mat4.h"
|
||||
#include "cocos/renderer/gfx-base/GFXBuffer.h"
|
||||
#include "cocos/renderer/gfx-base/GFXDef-common.h"
|
||||
#include "cocos/renderer/gfx-base/GFXDescriptorSetLayout.h"
|
||||
#include "cocos/renderer/gfx-base/GFXDevice.h"
|
||||
#include "cocos/renderer/gfx-base/GFXInputAssembler.h"
|
||||
#include "cocos/renderer/gfx-base/GFXSwapchain.h"
|
||||
#include "cocos/renderer/gfx-base/states/GFXSampler.h"
|
||||
#include "cocos/renderer/pipeline/Enum.h"
|
||||
#include "cocos/renderer/pipeline/GlobalDescriptorSetManager.h"
|
||||
#include "cocos/renderer/pipeline/PipelineSceneData.h"
|
||||
#include "cocos/renderer/pipeline/PipelineStateManager.h"
|
||||
#include "cocos/renderer/pipeline/RenderPipeline.h"
|
||||
#include "cocos/scene/RenderScene.h"
|
||||
#include "cocos/scene/RenderWindow.h"
|
||||
@@ -76,11 +78,14 @@ SceneTask *NativeSceneTransversal::transverse(SceneVisitor *visitor) const {
|
||||
NativePipeline::NativePipeline(const allocator_type &alloc) noexcept
|
||||
: device(gfx::Device::getInstance()),
|
||||
globalDSManager(std::make_unique<pipeline::GlobalDSManager>()),
|
||||
layoutGraph(alloc),
|
||||
programLibrary(dynamic_cast<NativeProgramLibrary *>(getProgramLibrary())),
|
||||
pipelineSceneData(ccnew pipeline::PipelineSceneData()), // NOLINT
|
||||
nativeContext(alloc),
|
||||
nativeContext(std::make_unique<gfx::DefaultResource>(device), alloc),
|
||||
resourceGraph(alloc),
|
||||
renderGraph(alloc) {}
|
||||
renderGraph(alloc),
|
||||
name(alloc) {
|
||||
programLibrary->setPipeline(this);
|
||||
}
|
||||
|
||||
gfx::Device *NativePipeline::getDevice() const {
|
||||
return device;
|
||||
@@ -128,6 +133,9 @@ uint32_t NativePipeline::addRenderTexture(const ccstd::string &name, gfx::Format
|
||||
|
||||
CC_ASSERT(renderWindow->getFramebuffer()->getColorTextures().size() == 1);
|
||||
CC_ASSERT(renderWindow->getFramebuffer()->getColorTextures().at(0));
|
||||
|
||||
desc.format = renderWindow->getFramebuffer()->getColorTextures()[0]->getFormat();
|
||||
|
||||
return addVertex(
|
||||
SwapchainTag{},
|
||||
std::forward_as_tuple(name.c_str()),
|
||||
@@ -209,6 +217,12 @@ void NativePipeline::updateRenderWindow(const ccstd::string &name, scene::Render
|
||||
},
|
||||
[&](RenderSwapchain &sc) {
|
||||
CC_EXPECTS(renderWindow->getSwapchain());
|
||||
auto* newSwapchain = renderWindow->getSwapchain();
|
||||
if (sc.generation != newSwapchain->getGeneration()) {
|
||||
resourceGraph.invalidatePersistentRenderPassAndFramebuffer(
|
||||
sc.swapchain->getColorTexture());
|
||||
sc.generation = newSwapchain->getGeneration();
|
||||
}
|
||||
desc.width = renderWindow->getSwapchain()->getWidth();
|
||||
desc.height = renderWindow->getSwapchain()->getHeight();
|
||||
sc.swapchain = renderWindow->getSwapchain();
|
||||
@@ -219,11 +233,36 @@ void NativePipeline::updateRenderWindow(const ccstd::string &name, scene::Render
|
||||
void NativePipeline::updateRenderTarget(
|
||||
const ccstd::string &name,
|
||||
uint32_t width, uint32_t height, gfx::Format format) { // NOLINT(bugprone-easily-swappable-parameters)
|
||||
auto resID = findVertex(ccstd::pmr::string(name, get_allocator()), resourceGraph);
|
||||
if (resID == ResourceGraph::null_vertex()) {
|
||||
return;
|
||||
}
|
||||
auto &desc = get(ResourceGraph::Desc, resourceGraph, resID);
|
||||
|
||||
// update format
|
||||
if (format == gfx::Format::UNKNOWN) {
|
||||
format = desc.format;
|
||||
}
|
||||
visitObject(
|
||||
resID, resourceGraph,
|
||||
[&](ManagedTexture &tex) {
|
||||
bool invalidate =
|
||||
std::forward_as_tuple(desc.width, desc.height, desc.format) !=
|
||||
std::forward_as_tuple(width, height, format);
|
||||
if (invalidate) {
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
desc.format = format;
|
||||
resourceGraph.invalidatePersistentRenderPassAndFramebuffer(tex.texture.get());
|
||||
}
|
||||
},
|
||||
[](const auto & /*res*/) {});
|
||||
}
|
||||
|
||||
void NativePipeline::updateDepthStencil(
|
||||
const ccstd::string &name,
|
||||
uint32_t width, uint32_t height, gfx::Format format) { // NOLINT(bugprone-easily-swappable-parameters)
|
||||
updateRenderTarget(name, width, height, format);
|
||||
}
|
||||
|
||||
void NativePipeline::beginFrame() {
|
||||
@@ -232,6 +271,68 @@ void NativePipeline::beginFrame() {
|
||||
void NativePipeline::endFrame() {
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
|
||||
void updateRasterPassConstants(uint32_t width, uint32_t height, Setter &setter) {
|
||||
const auto &root = *Root::getInstance();
|
||||
const auto shadingWidth = static_cast<float>(width);
|
||||
const auto shadingHeight = static_cast<float>(height);
|
||||
setter.setVec4(
|
||||
"cc_time",
|
||||
Vec4(
|
||||
root.getCumulativeTime(),
|
||||
root.getFrameTime(),
|
||||
static_cast<float>(CC_CURRENT_ENGINE()->getTotalFrames()),
|
||||
0.0F));
|
||||
|
||||
setter.setVec4(
|
||||
"cc_screenSize",
|
||||
Vec4(shadingWidth, shadingHeight, 1.0F / shadingWidth, 1.0F / shadingHeight));
|
||||
setter.setVec4(
|
||||
"cc_nativeSize",
|
||||
Vec4(shadingWidth, shadingHeight, 1.0F / shadingWidth, 1.0F / shadingHeight));
|
||||
#if 0
|
||||
const auto *debugView = root.getDebugView();
|
||||
if (debugView) {
|
||||
setter.setVec4(
|
||||
"cc_debug_view_mode",
|
||||
Vec4(static_cast<float>(debugView->getSingleMode()),
|
||||
debugView->isLightingWithAlbedo() ? 1.0F : 0.0F,
|
||||
debugView->isCsmLayerColoration() ? 1.0F : 0.0F,
|
||||
0.0F));
|
||||
Vec4 debugPackVec{};
|
||||
for (auto i = static_cast<uint32_t>(pipeline::DebugViewCompositeType::DIRECT_DIFFUSE);
|
||||
i < static_cast<uint32_t>(pipeline::DebugViewCompositeType::MAX_BIT_COUNT); ++i) {
|
||||
const auto idx = i % 4;
|
||||
(&debugPackVec.x)[idx] = debugView->isCompositeModeEnabled(i) ? 1.0F : 0.0F;
|
||||
const auto packIdx = static_cast<uint32_t>(floor(static_cast<float>(i) / 4.0F));
|
||||
if (idx == 3) {
|
||||
std::string name("cc_debug_view_composite_pack_");
|
||||
name.append(std::to_string(packIdx + 1));
|
||||
setter.setVec4(name, debugPackVec);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setter.setVec4("cc_debug_view_mode", Vec4(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
Vec4 debugPackVec{};
|
||||
for (auto i = static_cast<uint32_t>(pipeline::DebugViewCompositeType::DIRECT_DIFFUSE);
|
||||
i < static_cast<uint32_t>(pipeline::DebugViewCompositeType::MAX_BIT_COUNT); ++i) {
|
||||
const auto idx = i % 4;
|
||||
(&debugPackVec.x)[idx] = 1.0F;
|
||||
const auto packIdx = static_cast<uint32_t>(floor(i / 4.0));
|
||||
if (idx == 3) {
|
||||
std::string name("cc_debug_view_composite_pack_");
|
||||
name.append(std::to_string(packIdx + 1));
|
||||
setter.setVec4(name, debugPackVec);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
RasterPassBuilder *NativePipeline::addRasterPass(
|
||||
uint32_t width, uint32_t height, // NOLINT(bugprone-easily-swappable-parameters)
|
||||
const ccstd::string &layoutName) {
|
||||
@@ -251,10 +352,13 @@ RasterPassBuilder *NativePipeline::addRasterPass(
|
||||
std::forward_as_tuple(std::move(pass)),
|
||||
renderGraph);
|
||||
|
||||
auto passLayoutID = locate(LayoutGraphData::null_vertex(), layoutName, layoutGraph);
|
||||
auto passLayoutID = locate(LayoutGraphData::null_vertex(), layoutName, programLibrary->layoutGraph);
|
||||
CC_EXPECTS(passLayoutID != LayoutGraphData::null_vertex());
|
||||
|
||||
return ccnew NativeRasterPassBuilder(&renderGraph, passID, &layoutGraph, passLayoutID);
|
||||
auto *builder = ccnew NativeRasterPassBuilder(this, &renderGraph, passID, &programLibrary->layoutGraph, passLayoutID);
|
||||
updateRasterPassConstants(width, height, *builder);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
@@ -269,9 +373,9 @@ ComputePassBuilder *NativePipeline::addComputePass(const ccstd::string &layoutNa
|
||||
std::forward_as_tuple(),
|
||||
renderGraph);
|
||||
|
||||
auto passLayoutID = locate(LayoutGraphData::null_vertex(), layoutName, layoutGraph);
|
||||
auto passLayoutID = locate(LayoutGraphData::null_vertex(), layoutName, programLibrary->layoutGraph);
|
||||
|
||||
return ccnew NativeComputePassBuilder(&renderGraph, passID, &layoutGraph, passLayoutID);
|
||||
return ccnew NativeComputePassBuilder(&renderGraph, passID, &programLibrary->layoutGraph, passLayoutID);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
@@ -335,14 +439,11 @@ SceneTransversal *NativePipeline::createSceneTransversal(const scene::Camera *ca
|
||||
return ccnew NativeSceneTransversal(camera, scene);
|
||||
}
|
||||
|
||||
LayoutGraphBuilder *NativePipeline::getLayoutGraphBuilder() {
|
||||
return ccnew NativeLayoutGraphBuilder(device, &layoutGraph);
|
||||
}
|
||||
|
||||
gfx::DescriptorSetLayout *NativePipeline::getDescriptorSetLayout(const ccstd::string &shaderName, UpdateFrequency freq) {
|
||||
auto iter = layoutGraph.shaderLayoutIndex.find(std::string_view{shaderName});
|
||||
if (iter != layoutGraph.shaderLayoutIndex.end()) {
|
||||
const auto &layouts = get(LayoutGraphData::Layout, layoutGraph, iter->second).descriptorSets;
|
||||
const auto &lg = programLibrary->layoutGraph;
|
||||
auto iter = lg.shaderLayoutIndex.find(std::string_view{shaderName});
|
||||
if (iter != lg.shaderLayoutIndex.end()) {
|
||||
const auto &layouts = get(LayoutGraphData::Layout, lg, iter->second).descriptorSets;
|
||||
auto iter2 = layouts.find(freq);
|
||||
if (iter2 != layouts.end()) {
|
||||
return iter2->second.descriptorSetLayout.get();
|
||||
@@ -363,33 +464,33 @@ const ccstd::vector<gfx::CommandBuffer *> &NativePipeline::getCommandBuffers() c
|
||||
|
||||
namespace {
|
||||
|
||||
void generateConstantMacros(
|
||||
void buildLayoutGraphNodeBuffer(
|
||||
gfx::Device *device,
|
||||
ccstd::string &constantMacros, bool clusterEnabled) {
|
||||
constantMacros = StringUtil::format(
|
||||
R"(
|
||||
#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE %d
|
||||
#define CC_ENABLE_CLUSTERED_LIGHT_CULLING %d
|
||||
#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS %d
|
||||
#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS %d
|
||||
#define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT %d
|
||||
#define CC_PLATFORM_ANDROID_AND_WEBGL 0
|
||||
#define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0
|
||||
)",
|
||||
hasAnyFlags(device->getFormatFeatures(gfx::Format::RGBA32F),
|
||||
gfx::FormatFeature::RENDER_TARGET | gfx::FormatFeature::SAMPLED_TEXTURE),
|
||||
clusterEnabled ? 1 : 0,
|
||||
device->getCapabilities().maxVertexUniformVectors,
|
||||
device->getCapabilities().maxFragmentUniformVectors,
|
||||
device->hasFeature(gfx::Feature::INPUT_ATTACHMENT_BENEFIT));
|
||||
const DescriptorSetLayoutData &data,
|
||||
LayoutGraphNodeResource &node) {
|
||||
for (const auto &[nameID, uniformBlock] : data.uniformBlocks) {
|
||||
auto res = node.uniformBuffers.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(nameID),
|
||||
std::forward_as_tuple());
|
||||
CC_ENSURES(res.second);
|
||||
auto &buffer = res.first->second;
|
||||
CC_EXPECTS(uniformBlock.count);
|
||||
const auto bufferSize =
|
||||
getUniformBlockSize(uniformBlock.members) * uniformBlock.count;
|
||||
|
||||
CC_ENSURES(bufferSize);
|
||||
buffer.init(device, bufferSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
bool NativePipeline::activate(gfx::Swapchain *swapchainIn) {
|
||||
// setMacroInt("CC_PIPELINE_TYPE", 1);
|
||||
|
||||
swapchain = swapchainIn;
|
||||
macros["CC_PIPELINE_TYPE"] = 0;
|
||||
globalDSManager->activate(device);
|
||||
pipelineSceneData->activate(device);
|
||||
#if CC_USE_DEBUG_RENDERER
|
||||
@@ -401,6 +502,101 @@ bool NativePipeline::activate(gfx::Swapchain *swapchainIn) {
|
||||
generateConstantMacros(device, constantMacros, false);
|
||||
|
||||
_commandBuffers.resize(1, device->getCommandBuffer());
|
||||
|
||||
// reserve layout graph resource
|
||||
const auto &lg = programLibrary->layoutGraph;
|
||||
const auto numNodes = num_vertices(lg);
|
||||
nativeContext.layoutGraphResources.reserve(numNodes);
|
||||
|
||||
for (uint32_t i = 0; i != numNodes; ++i) {
|
||||
auto &node = nativeContext.layoutGraphResources.emplace_back();
|
||||
const auto &layout = get(LayoutGraphData::Layout, lg, i);
|
||||
if (holds<RenderStageTag>(i, lg)) {
|
||||
auto iter = layout.descriptorSets.find(UpdateFrequency::PER_PASS);
|
||||
if (iter == layout.descriptorSets.end()) {
|
||||
continue;
|
||||
}
|
||||
const auto &set = iter->second;
|
||||
// reserve buffer
|
||||
buildLayoutGraphNodeBuffer(device, set.descriptorSetLayoutData, node);
|
||||
// reserve descriptor sets
|
||||
node.descriptorSetPool.init(device, set.descriptorSetLayout);
|
||||
} else {
|
||||
auto iter = layout.descriptorSets.find(UpdateFrequency::PER_PHASE);
|
||||
if (iter == layout.descriptorSets.end()) {
|
||||
continue;
|
||||
}
|
||||
const auto &set = iter->second;
|
||||
// reserve buffer
|
||||
buildLayoutGraphNodeBuffer(device, set.descriptorSetLayoutData, node);
|
||||
// reserve descriptor sets
|
||||
node.descriptorSetPool.init(device, set.descriptorSetLayout);
|
||||
}
|
||||
}
|
||||
|
||||
// create ia
|
||||
{
|
||||
CC_EXPECTS(device);
|
||||
// create vertex buffer
|
||||
const auto vbStride = sizeof(float) * 4; // 4 float per vertex
|
||||
const auto vbSize = vbStride * 4; // 4 vertices
|
||||
IntrusivePtr<gfx::Buffer> quadVB = device->createBuffer(gfx::BufferInfo{
|
||||
gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST,
|
||||
gfx::MemoryUsageBit::DEVICE | gfx::MemoryUsageBit::HOST,
|
||||
vbSize,
|
||||
vbStride});
|
||||
|
||||
CC_ENSURES(quadVB);
|
||||
|
||||
// update vertex buffer
|
||||
float vbData[16] = {};
|
||||
render::setupQuadVertexBuffer(*device, Vec4{0, 0, 1, 1}, vbData);
|
||||
static_assert(sizeof(vbData) == 16 * 4);
|
||||
CC_ENSURES(sizeof(vbData) == vbSize);
|
||||
quadVB->update(vbData, sizeof(vbData));
|
||||
|
||||
// create index buffer
|
||||
const auto ibStride = sizeof(uint16_t);
|
||||
const auto ibSize = ibStride * 6;
|
||||
|
||||
IntrusivePtr<gfx::Buffer> quadIB = device->createBuffer(gfx::BufferInfo{
|
||||
gfx::BufferUsageBit::INDEX | gfx::BufferUsageBit::TRANSFER_DST,
|
||||
gfx::MemoryUsageBit::DEVICE,
|
||||
ibSize,
|
||||
ibStride});
|
||||
|
||||
CC_ENSURES(quadIB);
|
||||
|
||||
ccstd::vector<uint16_t> indices(6);
|
||||
indices[0] = 0;
|
||||
indices[1] = 1;
|
||||
indices[2] = 2;
|
||||
indices[3] = 1;
|
||||
indices[4] = 3;
|
||||
indices[5] = 2;
|
||||
|
||||
quadIB->update(indices.data(),
|
||||
static_cast<uint32_t>(indices.size() * sizeof(decltype(indices)::value_type)));
|
||||
|
||||
// create input assembler
|
||||
ccstd::vector<gfx::Attribute> attributes;
|
||||
attributes.reserve(2);
|
||||
attributes.emplace_back(gfx::Attribute{"a_position", gfx::Format::RG32F});
|
||||
attributes.emplace_back(gfx::Attribute{"a_texCoord", gfx::Format::RG32F});
|
||||
|
||||
ccstd::vector<gfx::Buffer *> buffers;
|
||||
buffers.emplace_back(quadVB.get());
|
||||
|
||||
IntrusivePtr<gfx::InputAssembler> quadIA = device->createInputAssembler(
|
||||
gfx::InputAssemblerInfo{attributes, buffers, quadIB});
|
||||
CC_ENSURES(quadIA);
|
||||
|
||||
// init fullscreenQuad
|
||||
nativeContext.fullscreenQuad.quadIB = quadIB;
|
||||
nativeContext.fullscreenQuad.quadVB = quadVB;
|
||||
nativeContext.fullscreenQuad.quadIA = quadIA;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -413,7 +609,7 @@ bool NativePipeline::destroy() noexcept {
|
||||
pipelineSceneData->destroy();
|
||||
pipelineSceneData = {};
|
||||
}
|
||||
|
||||
pipeline::PipelineStateManager::destroyAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,14 +32,12 @@
|
||||
#include "cocos/base/std/variant.h"
|
||||
#include "cocos/renderer/pipeline/InstancedBuffer.h"
|
||||
#include "cocos/renderer/pipeline/custom/NativeFwd.h"
|
||||
#include "cocos/renderer/pipeline/custom/PrivateFwd.h"
|
||||
#include "cocos/renderer/pipeline/custom/RenderGraphFwd.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
class NativeLayoutGraphBuilder;
|
||||
class NativeRasterQueueBuilder;
|
||||
class NativeRasterPassBuilder;
|
||||
class NativeComputeQueueBuilder;
|
||||
@@ -47,7 +45,6 @@ class NativeComputePassBuilder;
|
||||
class NativeMovePassBuilder;
|
||||
class NativeCopyPassBuilder;
|
||||
class NativeSceneTransversal;
|
||||
struct PersistentRenderPassAndFramebuffer;
|
||||
struct RenderInstancingQueue;
|
||||
struct DrawInstance;
|
||||
struct RenderDrawQueue;
|
||||
@@ -55,11 +52,18 @@ struct NativeRenderQueue;
|
||||
class DefaultSceneVisitor;
|
||||
class DefaultForwardLightingTransversal;
|
||||
struct ResourceGroup;
|
||||
struct BufferPool;
|
||||
struct DescriptorSetPool;
|
||||
struct UniformBlockResource;
|
||||
struct ProgramResource;
|
||||
struct LayoutGraphNodeResource;
|
||||
struct QuadResource;
|
||||
struct NativeRenderContext;
|
||||
class NativeProgramLibrary;
|
||||
class NativePipeline;
|
||||
class NativeProgramProxy;
|
||||
class NativeProgramLibrary;
|
||||
class NativeRenderingModule;
|
||||
class NativeSetter;
|
||||
|
||||
} // namespace render
|
||||
|
||||
|
||||
@@ -34,25 +34,6 @@ namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(const allocator_type& alloc) noexcept
|
||||
: clearColors(alloc) {}
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs, const allocator_type& alloc)
|
||||
: renderPass(std::move(rhs.renderPass)),
|
||||
framebuffer(std::move(rhs.framebuffer)),
|
||||
clearColors(std::move(rhs.clearColors), alloc),
|
||||
clearDepth(rhs.clearDepth),
|
||||
clearStencil(rhs.clearStencil),
|
||||
refCount(rhs.refCount) {}
|
||||
|
||||
PersistentRenderPassAndFramebuffer::PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs, const allocator_type& alloc)
|
||||
: renderPass(rhs.renderPass),
|
||||
framebuffer(rhs.framebuffer),
|
||||
clearColors(rhs.clearColors, alloc),
|
||||
clearDepth(rhs.clearDepth),
|
||||
clearStencil(rhs.clearStencil),
|
||||
refCount(rhs.refCount) {}
|
||||
|
||||
RenderInstancingQueue::RenderInstancingQueue(const allocator_type& alloc) noexcept
|
||||
: batches(alloc),
|
||||
sortedBatches(alloc) {}
|
||||
@@ -80,19 +61,21 @@ NativeRenderQueue::NativeRenderQueue(const allocator_type& alloc) noexcept
|
||||
opaqueInstancingQueue(alloc),
|
||||
transparentInstancingQueue(alloc) {}
|
||||
|
||||
NativeRenderQueue::NativeRenderQueue(SceneFlags sceneFlagsIn, const allocator_type& alloc) noexcept
|
||||
NativeRenderQueue::NativeRenderQueue(SceneFlags sceneFlagsIn, uint32_t layoutPassIDIn, const allocator_type& alloc) noexcept
|
||||
: opaqueQueue(alloc),
|
||||
transparentQueue(alloc),
|
||||
opaqueInstancingQueue(alloc),
|
||||
transparentInstancingQueue(alloc),
|
||||
sceneFlags(sceneFlagsIn) {}
|
||||
sceneFlags(sceneFlagsIn),
|
||||
layoutPassID(layoutPassIDIn) {}
|
||||
|
||||
NativeRenderQueue::NativeRenderQueue(NativeRenderQueue&& rhs, const allocator_type& alloc)
|
||||
: opaqueQueue(std::move(rhs.opaqueQueue), alloc),
|
||||
transparentQueue(std::move(rhs.transparentQueue), alloc),
|
||||
opaqueInstancingQueue(std::move(rhs.opaqueInstancingQueue), alloc),
|
||||
transparentInstancingQueue(std::move(rhs.transparentInstancingQueue), alloc),
|
||||
sceneFlags(rhs.sceneFlags) {}
|
||||
sceneFlags(rhs.sceneFlags),
|
||||
layoutPassID(rhs.layoutPassID) {}
|
||||
|
||||
DefaultSceneVisitor::DefaultSceneVisitor(const allocator_type& alloc) noexcept
|
||||
: name(alloc) {}
|
||||
@@ -103,13 +86,81 @@ DefaultForwardLightingTransversal::DefaultForwardLightingTransversal(const alloc
|
||||
ResourceGroup::ResourceGroup(const allocator_type& alloc) noexcept
|
||||
: instancingBuffers(alloc) {}
|
||||
|
||||
NativeRenderContext::NativeRenderContext(const allocator_type& alloc) noexcept
|
||||
: renderPasses(alloc),
|
||||
resourceGroups(alloc) {}
|
||||
BufferPool::BufferPool(const allocator_type& alloc) noexcept
|
||||
: currentBuffers(alloc),
|
||||
currentBufferViews(alloc),
|
||||
freeBuffers(alloc),
|
||||
freeBufferViews(alloc) {}
|
||||
|
||||
BufferPool::BufferPool(gfx::Device* deviceIn, uint32_t bufferSizeIn, bool dynamicIn, const allocator_type& alloc) noexcept // NOLINT
|
||||
: device(deviceIn),
|
||||
bufferSize(bufferSizeIn),
|
||||
dynamic(dynamicIn),
|
||||
currentBuffers(alloc),
|
||||
currentBufferViews(alloc),
|
||||
freeBuffers(alloc),
|
||||
freeBufferViews(alloc) {}
|
||||
|
||||
BufferPool::BufferPool(BufferPool&& rhs, const allocator_type& alloc)
|
||||
: device(rhs.device),
|
||||
bufferSize(rhs.bufferSize),
|
||||
dynamic(rhs.dynamic),
|
||||
currentBuffers(std::move(rhs.currentBuffers), alloc),
|
||||
currentBufferViews(std::move(rhs.currentBufferViews), alloc),
|
||||
freeBuffers(std::move(rhs.freeBuffers), alloc),
|
||||
freeBufferViews(std::move(rhs.freeBufferViews), alloc) {}
|
||||
|
||||
DescriptorSetPool::DescriptorSetPool(const allocator_type& alloc) noexcept
|
||||
: currentDescriptorSets(alloc),
|
||||
freeDescriptorSets(alloc) {}
|
||||
|
||||
DescriptorSetPool::DescriptorSetPool(gfx::Device* deviceIn, IntrusivePtr<gfx::DescriptorSetLayout> setLayoutIn, const allocator_type& alloc) noexcept // NOLINT
|
||||
: device(deviceIn),
|
||||
setLayout(std::move(setLayoutIn)),
|
||||
currentDescriptorSets(alloc),
|
||||
freeDescriptorSets(alloc) {}
|
||||
|
||||
DescriptorSetPool::DescriptorSetPool(DescriptorSetPool&& rhs, const allocator_type& alloc)
|
||||
: device(rhs.device),
|
||||
setLayout(std::move(rhs.setLayout)),
|
||||
currentDescriptorSets(std::move(rhs.currentDescriptorSets), alloc),
|
||||
freeDescriptorSets(std::move(rhs.freeDescriptorSets), alloc) {}
|
||||
|
||||
UniformBlockResource::UniformBlockResource(const allocator_type& alloc) noexcept
|
||||
: cpuBuffer(alloc),
|
||||
bufferPool(alloc) {}
|
||||
|
||||
UniformBlockResource::UniformBlockResource(UniformBlockResource&& rhs, const allocator_type& alloc)
|
||||
: cpuBuffer(std::move(rhs.cpuBuffer), alloc),
|
||||
bufferPool(std::move(rhs.bufferPool), alloc) {}
|
||||
|
||||
ProgramResource::ProgramResource(const allocator_type& alloc) noexcept
|
||||
: uniformBuffers(alloc),
|
||||
descriptorSetPool(alloc) {}
|
||||
|
||||
ProgramResource::ProgramResource(ProgramResource&& rhs, const allocator_type& alloc)
|
||||
: uniformBuffers(std::move(rhs.uniformBuffers), alloc),
|
||||
descriptorSetPool(std::move(rhs.descriptorSetPool), alloc) {}
|
||||
|
||||
LayoutGraphNodeResource::LayoutGraphNodeResource(const allocator_type& alloc) noexcept
|
||||
: uniformBuffers(alloc),
|
||||
descriptorSetPool(alloc),
|
||||
programResources(alloc) {}
|
||||
|
||||
LayoutGraphNodeResource::LayoutGraphNodeResource(LayoutGraphNodeResource&& rhs, const allocator_type& alloc)
|
||||
: uniformBuffers(std::move(rhs.uniformBuffers), alloc),
|
||||
descriptorSetPool(std::move(rhs.descriptorSetPool), alloc),
|
||||
programResources(std::move(rhs.programResources), alloc) {}
|
||||
|
||||
NativeRenderContext::NativeRenderContext(std::unique_ptr<gfx::DefaultResource> defaultResourceIn, const allocator_type& alloc) noexcept
|
||||
: defaultResource(std::move(defaultResourceIn)),
|
||||
resourceGroups(alloc),
|
||||
layoutGraphResources(alloc) {}
|
||||
|
||||
NativeProgramLibrary::NativeProgramLibrary(const allocator_type& alloc) noexcept
|
||||
: layoutGraph(alloc),
|
||||
phases(alloc) {}
|
||||
phases(alloc),
|
||||
localLayoutData(alloc) {}
|
||||
|
||||
} // namespace render
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "cocos/renderer/pipeline/InstancedBuffer.h"
|
||||
#include "cocos/renderer/pipeline/custom/NativePipelineFwd.h"
|
||||
#include "cocos/renderer/pipeline/custom/NativeTypes.h"
|
||||
#include "cocos/renderer/pipeline/custom/PrivateTypes.h"
|
||||
#include "cocos/renderer/pipeline/custom/RenderGraphTypes.h"
|
||||
#include "cocos/renderer/pipeline/custom/details/Map.h"
|
||||
#include "cocos/renderer/pipeline/custom/details/Set.h"
|
||||
@@ -47,32 +46,12 @@ namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
class NativeLayoutGraphBuilder final : public LayoutGraphBuilder {
|
||||
public:
|
||||
NativeLayoutGraphBuilder() = default;
|
||||
NativeLayoutGraphBuilder(gfx::Device* deviceIn, LayoutGraphData* dataIn) noexcept
|
||||
: device(deviceIn),
|
||||
data(dataIn) {}
|
||||
|
||||
void clear() override;
|
||||
uint32_t addRenderStage(const ccstd::string &name) override;
|
||||
uint32_t addRenderPhase(const ccstd::string &name, uint32_t parentID) override;
|
||||
void addShader(const ccstd::string &name, uint32_t parentPhaseID) override;
|
||||
void addDescriptorBlock(uint32_t nodeID, const DescriptorBlockIndex &index, const DescriptorBlockFlattened &block) override;
|
||||
void addUniformBlock(uint32_t nodeID, const DescriptorBlockIndex &index, const ccstd::string &name, const gfx::UniformBlock &uniformBlock) override;
|
||||
void reserveDescriptorBlock(uint32_t nodeID, const DescriptorBlockIndex &index, const DescriptorBlockFlattened &block) override;
|
||||
int compile() override;
|
||||
ccstd::string print() const override;
|
||||
|
||||
gfx::Device* device{nullptr};
|
||||
LayoutGraphData* data{nullptr};
|
||||
};
|
||||
|
||||
class NativeRasterQueueBuilder final : public RasterQueueBuilder {
|
||||
public:
|
||||
NativeRasterQueueBuilder() = default;
|
||||
NativeRasterQueueBuilder(RenderGraph* renderGraphIn, uint32_t queueIDIn, const LayoutGraphData* layoutGraphIn) noexcept
|
||||
: renderGraph(renderGraphIn),
|
||||
NativeRasterQueueBuilder(const PipelineRuntime* pipelineRuntimeIn, RenderGraph* renderGraphIn, uint32_t queueIDIn, const LayoutGraphData* layoutGraphIn) noexcept
|
||||
: pipelineRuntime(pipelineRuntimeIn),
|
||||
renderGraph(renderGraphIn),
|
||||
layoutGraph(layoutGraphIn),
|
||||
queueID(queueIDIn) {}
|
||||
|
||||
@@ -98,6 +77,7 @@ public:
|
||||
void clearRenderTarget(const ccstd::string &name, const gfx::Color &color) override;
|
||||
void setViewport(const gfx::Viewport &viewport) override;
|
||||
|
||||
const PipelineRuntime* pipelineRuntime{nullptr};
|
||||
RenderGraph* renderGraph{nullptr};
|
||||
const LayoutGraphData* layoutGraph{nullptr};
|
||||
uint32_t queueID{RenderGraph::null_vertex()};
|
||||
@@ -106,8 +86,9 @@ public:
|
||||
class NativeRasterPassBuilder final : public RasterPassBuilder {
|
||||
public:
|
||||
NativeRasterPassBuilder() = default;
|
||||
NativeRasterPassBuilder(RenderGraph* renderGraphIn, uint32_t passIDIn, const LayoutGraphData* layoutGraphIn, uint32_t layoutIDIn) noexcept // NOLINT
|
||||
: renderGraph(renderGraphIn),
|
||||
NativeRasterPassBuilder(const PipelineRuntime* pipelineRuntimeIn, RenderGraph* renderGraphIn, uint32_t passIDIn, const LayoutGraphData* layoutGraphIn, uint32_t layoutIDIn) noexcept // NOLINT
|
||||
: pipelineRuntime(pipelineRuntimeIn),
|
||||
renderGraph(renderGraphIn),
|
||||
layoutGraph(layoutGraphIn),
|
||||
passID(passIDIn),
|
||||
layoutID(layoutIDIn) {}
|
||||
@@ -132,7 +113,10 @@ public:
|
||||
RasterQueueBuilder *addQueue(QueueHint hint) override;
|
||||
void setViewport(const gfx::Viewport &viewport) override;
|
||||
void setVersion(const ccstd::string &name, uint64_t version) override;
|
||||
bool getShowStatistics() const override;
|
||||
void setShowStatistics(bool enable) override;
|
||||
|
||||
const PipelineRuntime* pipelineRuntime{nullptr};
|
||||
RenderGraph* renderGraph{nullptr};
|
||||
const LayoutGraphData* layoutGraph{nullptr};
|
||||
uint32_t passID{RenderGraph::null_vertex()};
|
||||
@@ -247,29 +231,6 @@ public:
|
||||
const scene::RenderScene* scene{nullptr};
|
||||
};
|
||||
|
||||
struct PersistentRenderPassAndFramebuffer {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {clearColors.get_allocator().resource()};
|
||||
}
|
||||
|
||||
PersistentRenderPassAndFramebuffer(const allocator_type& alloc) noexcept; // NOLINT
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs, const allocator_type& alloc);
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs, const allocator_type& alloc);
|
||||
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer&& rhs) noexcept = default;
|
||||
PersistentRenderPassAndFramebuffer(PersistentRenderPassAndFramebuffer const& rhs) = delete;
|
||||
PersistentRenderPassAndFramebuffer& operator=(PersistentRenderPassAndFramebuffer&& rhs) = default;
|
||||
PersistentRenderPassAndFramebuffer& operator=(PersistentRenderPassAndFramebuffer const& rhs) = default;
|
||||
|
||||
IntrusivePtr<gfx::RenderPass> renderPass;
|
||||
IntrusivePtr<gfx::Framebuffer> framebuffer;
|
||||
ccstd::pmr::vector<gfx::Color> clearColors;
|
||||
float clearDepth{0};
|
||||
uint8_t clearStencil{0};
|
||||
int32_t refCount{1};
|
||||
};
|
||||
|
||||
struct RenderInstancingQueue {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
@@ -297,7 +258,7 @@ struct RenderInstancingQueue {
|
||||
ccstd::pmr::vector<pipeline::InstancedBuffer*> sortedBatches;
|
||||
};
|
||||
|
||||
struct alignas(32) DrawInstance {
|
||||
struct DrawInstance {
|
||||
const scene::SubModel* subModel{nullptr};
|
||||
uint32_t priority{0};
|
||||
uint32_t hash{0};
|
||||
@@ -338,7 +299,7 @@ struct NativeRenderQueue {
|
||||
}
|
||||
|
||||
NativeRenderQueue(const allocator_type& alloc) noexcept; // NOLINT
|
||||
NativeRenderQueue(SceneFlags sceneFlagsIn, const allocator_type& alloc) noexcept;
|
||||
NativeRenderQueue(SceneFlags sceneFlagsIn, uint32_t layoutPassIDIn, const allocator_type& alloc) noexcept;
|
||||
NativeRenderQueue(NativeRenderQueue&& rhs, const allocator_type& alloc);
|
||||
|
||||
NativeRenderQueue(NativeRenderQueue&& rhs) noexcept = default;
|
||||
@@ -353,6 +314,7 @@ struct NativeRenderQueue {
|
||||
RenderInstancingQueue opaqueInstancingQueue;
|
||||
RenderInstancingQueue transparentInstancingQueue;
|
||||
SceneFlags sceneFlags{SceneFlags::NONE};
|
||||
uint32_t layoutPassID{0xFFFFFFFF};
|
||||
};
|
||||
|
||||
class DefaultSceneVisitor final : public SceneVisitor {
|
||||
@@ -406,13 +368,137 @@ struct ResourceGroup {
|
||||
PmrUnorderedSet<IntrusivePtr<pipeline::InstancedBuffer>> instancingBuffers;
|
||||
};
|
||||
|
||||
struct BufferPool {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {currentBuffers.get_allocator().resource()};
|
||||
}
|
||||
|
||||
BufferPool(const allocator_type& alloc) noexcept; // NOLINT
|
||||
BufferPool(gfx::Device* deviceIn, uint32_t bufferSizeIn, bool dynamicIn, const allocator_type& alloc) noexcept;
|
||||
BufferPool(BufferPool&& rhs, const allocator_type& alloc);
|
||||
|
||||
BufferPool(BufferPool&& rhs) noexcept = default;
|
||||
BufferPool(BufferPool const& rhs) = delete;
|
||||
BufferPool& operator=(BufferPool&& rhs) = default;
|
||||
BufferPool& operator=(BufferPool const& rhs) = delete;
|
||||
void init(gfx::Device* deviceIn, uint32_t sz, bool bDynamic);
|
||||
void syncResources();
|
||||
gfx::Buffer* allocateBuffer();
|
||||
|
||||
gfx::Device* device{nullptr};
|
||||
uint32_t bufferSize{0};
|
||||
bool dynamic{false};
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Buffer>> currentBuffers;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Buffer>> currentBufferViews;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Buffer>> freeBuffers;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::Buffer>> freeBufferViews;
|
||||
};
|
||||
|
||||
struct DescriptorSetPool {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {currentDescriptorSets.get_allocator().resource()};
|
||||
}
|
||||
|
||||
DescriptorSetPool(const allocator_type& alloc) noexcept; // NOLINT
|
||||
DescriptorSetPool(gfx::Device* deviceIn, IntrusivePtr<gfx::DescriptorSetLayout> setLayoutIn, const allocator_type& alloc) noexcept;
|
||||
DescriptorSetPool(DescriptorSetPool&& rhs, const allocator_type& alloc);
|
||||
|
||||
DescriptorSetPool(DescriptorSetPool&& rhs) noexcept = default;
|
||||
DescriptorSetPool(DescriptorSetPool const& rhs) = delete;
|
||||
DescriptorSetPool& operator=(DescriptorSetPool&& rhs) = default;
|
||||
DescriptorSetPool& operator=(DescriptorSetPool const& rhs) = delete;
|
||||
void init(gfx::Device* deviceIn, IntrusivePtr<gfx::DescriptorSetLayout> layout);
|
||||
void syncDescriptorSets();
|
||||
const gfx::DescriptorSet& getCurrentDescriptorSet() const;
|
||||
gfx::DescriptorSet& getCurrentDescriptorSet();
|
||||
gfx::DescriptorSet* allocateDescriptorSet();
|
||||
|
||||
gfx::Device* device{nullptr};
|
||||
IntrusivePtr<gfx::DescriptorSetLayout> setLayout;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::DescriptorSet>> currentDescriptorSets;
|
||||
ccstd::pmr::vector<IntrusivePtr<gfx::DescriptorSet>> freeDescriptorSets;
|
||||
};
|
||||
|
||||
struct UniformBlockResource {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {cpuBuffer.get_allocator().resource()};
|
||||
}
|
||||
|
||||
UniformBlockResource(const allocator_type& alloc) noexcept; // NOLINT
|
||||
UniformBlockResource(UniformBlockResource&& rhs, const allocator_type& alloc);
|
||||
|
||||
UniformBlockResource(UniformBlockResource&& rhs) noexcept = default;
|
||||
UniformBlockResource(UniformBlockResource const& rhs) = delete;
|
||||
UniformBlockResource& operator=(UniformBlockResource&& rhs) = default;
|
||||
UniformBlockResource& operator=(UniformBlockResource const& rhs) = delete;
|
||||
void init(gfx::Device* deviceIn, uint32_t sz, bool bDynamic);
|
||||
gfx::Buffer* createFromCpuBuffer();
|
||||
|
||||
ccstd::pmr::vector<char> cpuBuffer;
|
||||
BufferPool bufferPool;
|
||||
};
|
||||
|
||||
struct ProgramResource {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {uniformBuffers.get_allocator().resource()};
|
||||
}
|
||||
|
||||
ProgramResource(const allocator_type& alloc) noexcept; // NOLINT
|
||||
ProgramResource(ProgramResource&& rhs, const allocator_type& alloc);
|
||||
|
||||
ProgramResource(ProgramResource&& rhs) noexcept = default;
|
||||
ProgramResource(ProgramResource const& rhs) = delete;
|
||||
ProgramResource& operator=(ProgramResource&& rhs) = default;
|
||||
ProgramResource& operator=(ProgramResource const& rhs) = delete;
|
||||
void syncResources() noexcept;
|
||||
|
||||
ccstd::pmr::unordered_map<NameLocalID, UniformBlockResource> uniformBuffers;
|
||||
DescriptorSetPool descriptorSetPool;
|
||||
};
|
||||
|
||||
struct LayoutGraphNodeResource {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {uniformBuffers.get_allocator().resource()};
|
||||
}
|
||||
|
||||
LayoutGraphNodeResource(const allocator_type& alloc) noexcept; // NOLINT
|
||||
LayoutGraphNodeResource(LayoutGraphNodeResource&& rhs, const allocator_type& alloc);
|
||||
|
||||
LayoutGraphNodeResource(LayoutGraphNodeResource&& rhs) noexcept = default;
|
||||
LayoutGraphNodeResource(LayoutGraphNodeResource const& rhs) = delete;
|
||||
LayoutGraphNodeResource& operator=(LayoutGraphNodeResource&& rhs) = default;
|
||||
LayoutGraphNodeResource& operator=(LayoutGraphNodeResource const& rhs) = delete;
|
||||
void syncResources() noexcept;
|
||||
|
||||
PmrFlatMap<NameLocalID, UniformBlockResource> uniformBuffers;
|
||||
DescriptorSetPool descriptorSetPool;
|
||||
PmrTransparentMap<ccstd::pmr::string, ProgramResource> programResources;
|
||||
};
|
||||
|
||||
struct QuadResource {
|
||||
QuadResource() = default;
|
||||
QuadResource(IntrusivePtr<gfx::Buffer> quadVBIn, IntrusivePtr<gfx::Buffer> quadIBIn, IntrusivePtr<gfx::InputAssembler> quadIAIn) noexcept // NOLINT
|
||||
: quadVB(std::move(quadVBIn)),
|
||||
quadIB(std::move(quadIBIn)),
|
||||
quadIA(std::move(quadIAIn)) {}
|
||||
|
||||
IntrusivePtr<gfx::Buffer> quadVB;
|
||||
IntrusivePtr<gfx::Buffer> quadIB;
|
||||
IntrusivePtr<gfx::InputAssembler> quadIA;
|
||||
};
|
||||
|
||||
struct NativeRenderContext {
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {renderPasses.get_allocator().resource()};
|
||||
return {resourceGroups.get_allocator().resource()};
|
||||
}
|
||||
|
||||
NativeRenderContext(const allocator_type& alloc) noexcept; // NOLINT
|
||||
NativeRenderContext(std::unique_ptr<gfx::DefaultResource> defaultResourceIn, const allocator_type& alloc) noexcept;
|
||||
NativeRenderContext(NativeRenderContext&& rhs) = delete;
|
||||
NativeRenderContext(NativeRenderContext const& rhs) = delete;
|
||||
NativeRenderContext& operator=(NativeRenderContext&& rhs) = delete;
|
||||
@@ -420,16 +506,59 @@ struct NativeRenderContext {
|
||||
|
||||
void clearPreviousResources(uint64_t finishedFenceValue) noexcept;
|
||||
|
||||
ccstd::pmr::unordered_map<RasterPass, PersistentRenderPassAndFramebuffer> renderPasses;
|
||||
std::unique_ptr<gfx::DefaultResource> defaultResource;
|
||||
ccstd::pmr::map<uint64_t, ResourceGroup> resourceGroups;
|
||||
ccstd::pmr::vector<LayoutGraphNodeResource> layoutGraphResources;
|
||||
QuadResource fullscreenQuad;
|
||||
uint64_t nextFenceValue{0};
|
||||
};
|
||||
|
||||
class NativeProgramLibrary final : public ProgramLibrary {
|
||||
public:
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {layoutGraph.get_allocator().resource()};
|
||||
}
|
||||
|
||||
NativeProgramLibrary(const allocator_type& alloc) noexcept; // NOLINT
|
||||
|
||||
void addEffect(const EffectAsset *effectAsset) override;
|
||||
void precompileEffect(gfx::Device *device, EffectAsset *effectAsset) override;
|
||||
ccstd::string getKey(uint32_t phaseID, const ccstd::string &programName, const MacroRecord &defines) const override;
|
||||
IntrusivePtr<gfx::PipelineLayout> getPipelineLayout(gfx::Device *device, uint32_t phaseID, const ccstd::string &programName) override;
|
||||
const gfx::DescriptorSetLayout &getMaterialDescriptorSetLayout(gfx::Device *device, uint32_t phaseID, const ccstd::string &programName) override;
|
||||
const gfx::DescriptorSetLayout &getLocalDescriptorSetLayout(gfx::Device *device, uint32_t phaseID, const ccstd::string &programName) override;
|
||||
const IProgramInfo &getProgramInfo(uint32_t phaseID, const ccstd::string &programName) const override;
|
||||
const gfx::ShaderInfo &getShaderInfo(uint32_t phaseID, const ccstd::string &programName) const override;
|
||||
ProgramProxy *getProgramVariant(gfx::Device *device, uint32_t phaseID, const ccstd::string &name, MacroRecord &defines, const ccstd::pmr::string *key) override;
|
||||
const ccstd::vector<int32_t> &getBlockSizes(uint32_t phaseID, const ccstd::string &programName) const override;
|
||||
const Record<ccstd::string, uint32_t> &getHandleMap(uint32_t phaseID, const ccstd::string &programName) const override;
|
||||
uint32_t getProgramID(uint32_t phaseID, const ccstd::pmr::string &programName) override;
|
||||
uint32_t getDescriptorNameID(const ccstd::pmr::string &name) override;
|
||||
const ccstd::pmr::string &getDescriptorName(uint32_t nameID) override;
|
||||
|
||||
void init(gfx::Device* deviceIn);
|
||||
void setPipeline(PipelineRuntime* pipelineIn);
|
||||
void destroy();
|
||||
|
||||
LayoutGraphData layoutGraph;
|
||||
PmrFlatMap<uint32_t, ProgramGroup> phases;
|
||||
boost::container::pmr::unsynchronized_pool_resource unsycPool;
|
||||
bool mergeHighFrequency{false};
|
||||
bool fixedLocal{true};
|
||||
DescriptorSetLayoutData localLayoutData;
|
||||
IntrusivePtr<gfx::DescriptorSetLayout> localDescriptorSetLayout;
|
||||
IntrusivePtr<gfx::DescriptorSetLayout> emptyDescriptorSetLayout;
|
||||
IntrusivePtr<gfx::PipelineLayout> emptyPipelineLayout;
|
||||
PipelineRuntime* pipeline{nullptr};
|
||||
gfx::Device* device{nullptr};
|
||||
};
|
||||
|
||||
class NativePipeline final : public Pipeline {
|
||||
public:
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {nativeContext.get_allocator().resource()};
|
||||
return {name.get_allocator().resource()};
|
||||
}
|
||||
|
||||
NativePipeline(const allocator_type& alloc) noexcept; // NOLINT
|
||||
@@ -480,7 +609,6 @@ public:
|
||||
CopyPassBuilder *addCopyPass() override;
|
||||
void presentAll() override;
|
||||
SceneTransversal *createSceneTransversal(const scene::Camera *camera, const scene::RenderScene *scene) override;
|
||||
LayoutGraphBuilder *getLayoutGraphBuilder() override;
|
||||
gfx::DescriptorSetLayout *getDescriptorSetLayout(const ccstd::string &shaderName, UpdateFrequency freq) override;
|
||||
|
||||
void executeRenderGraph(const RenderGraph& rg);
|
||||
@@ -494,11 +622,12 @@ public:
|
||||
MacroRecord macros;
|
||||
ccstd::string constantMacros;
|
||||
std::unique_ptr<pipeline::GlobalDSManager> globalDSManager;
|
||||
ccstd::pmr::string name;
|
||||
NativeProgramLibrary* programLibrary;
|
||||
scene::Model* profiler{nullptr};
|
||||
LightingMode lightingMode{LightingMode::DEFAULT};
|
||||
IntrusivePtr<pipeline::PipelineSceneData> pipelineSceneData;
|
||||
NativeRenderContext nativeContext;
|
||||
LayoutGraphData layoutGraph;
|
||||
ResourceGraph resourceGraph;
|
||||
RenderGraph renderGraph;
|
||||
};
|
||||
@@ -515,42 +644,6 @@ public:
|
||||
IntrusivePtr<gfx::Shader> shader;
|
||||
};
|
||||
|
||||
class NativeProgramLibrary final : public ProgramLibrary {
|
||||
public:
|
||||
using allocator_type = boost::container::pmr::polymorphic_allocator<char>;
|
||||
allocator_type get_allocator() const noexcept { // NOLINT
|
||||
return {layoutGraph.get_allocator().resource()};
|
||||
}
|
||||
|
||||
NativeProgramLibrary(const allocator_type& alloc) noexcept; // NOLINT
|
||||
|
||||
void addEffect(EffectAsset *effectAsset) override;
|
||||
void precompileEffect(gfx::Device *device, EffectAsset *effectAsset) override;
|
||||
ccstd::string getKey(uint32_t phaseID, const ccstd::pmr::string &programName, const MacroRecord &defines) const override;
|
||||
const gfx::PipelineLayout &getPipelineLayout(gfx::Device *device, uint32_t phaseID, const ccstd::pmr::string &programName) override;
|
||||
const gfx::DescriptorSetLayout &getMaterialDescriptorSetLayout(gfx::Device *device, uint32_t phaseID, const ccstd::pmr::string &programName) override;
|
||||
const gfx::DescriptorSetLayout &getLocalDescriptorSetLayout(gfx::Device *device, uint32_t phaseID, const ccstd::pmr::string &programName) override;
|
||||
const IProgramInfo &getProgramInfo(uint32_t phaseID, const ccstd::pmr::string &programName) const override;
|
||||
const gfx::ShaderInfo &getShaderInfo(uint32_t phaseID, const ccstd::pmr::string &programName) const override;
|
||||
ProgramProxy *getProgramVariant(gfx::Device *device, uint32_t phaseID, const ccstd::string &name, const MacroRecord &defines, const ccstd::pmr::string *key) const override;
|
||||
const ccstd::pmr::vector<unsigned> &getBlockSizes(uint32_t phaseID, const ccstd::pmr::string &programName) const override;
|
||||
const Record<ccstd::string, uint32_t> &getHandleMap(uint32_t phaseID, const ccstd::pmr::string &programName) const override;
|
||||
uint32_t getProgramID(uint32_t phaseID, const ccstd::pmr::string &programName) override;
|
||||
uint32_t getDescriptorNameID(const ccstd::pmr::string &name) override;
|
||||
const ccstd::pmr::string &getDescriptorName(uint32_t nameID) override;
|
||||
|
||||
void init(gfx::Device* device);
|
||||
void destroy();
|
||||
|
||||
LayoutGraphData layoutGraph;
|
||||
PmrFlatMap<uint32_t, ProgramGroup> phases;
|
||||
boost::container::pmr::unsynchronized_pool_resource unsycPool;
|
||||
bool mergeHighFrequency{false};
|
||||
bool fixedLocal{true};
|
||||
IntrusivePtr<gfx::DescriptorSetLayout> emptyDescriptorSetLayout;
|
||||
IntrusivePtr<gfx::PipelineLayout> emptyPipelineLayout;
|
||||
};
|
||||
|
||||
class NativeRenderingModule final : public RenderingModule {
|
||||
public:
|
||||
NativeRenderingModule() = default;
|
||||
@@ -563,6 +656,37 @@ public:
|
||||
std::shared_ptr<NativeProgramLibrary> programLibrary;
|
||||
};
|
||||
|
||||
class NativeSetter final : public Setter {
|
||||
public:
|
||||
NativeSetter(const LayoutGraphData& layoutGraphIn, RenderData& renderDataIn) noexcept
|
||||
: layoutGraph(layoutGraphIn),
|
||||
renderData(renderDataIn) {}
|
||||
|
||||
ccstd::string getName() const override;
|
||||
void setName(const ccstd::string &name) override;
|
||||
|
||||
void setMat4(const ccstd::string &name, const Mat4 &mat) override;
|
||||
void setQuaternion(const ccstd::string &name, const Quaternion &quat) override;
|
||||
void setColor(const ccstd::string &name, const gfx::Color &color) override;
|
||||
void setVec4(const ccstd::string &name, const Vec4 &vec) override;
|
||||
void setVec2(const ccstd::string &name, const Vec2 &vec) override;
|
||||
void setFloat(const ccstd::string &name, float v) override;
|
||||
void setBuffer(const ccstd::string &name, gfx::Buffer *buffer) override;
|
||||
void setTexture(const ccstd::string &name, gfx::Texture *texture) override;
|
||||
void setReadWriteBuffer(const ccstd::string &name, gfx::Buffer *buffer) override;
|
||||
void setReadWriteTexture(const ccstd::string &name, gfx::Texture *texture) override;
|
||||
void setSampler(const ccstd::string &name, gfx::Sampler *sampler) override;
|
||||
|
||||
void setVec4ArraySize(const ccstd::string& name, uint32_t sz);
|
||||
void setVec4ArrayElem(const ccstd::string& name, const cc::Vec4& vec, uint32_t id);
|
||||
|
||||
void setMat4ArraySize(const ccstd::string& name, uint32_t sz);
|
||||
void setMat4ArrayElem(const ccstd::string& name, const cc::Mat4& mat, uint32_t id);
|
||||
|
||||
const LayoutGraphData& layoutGraph;
|
||||
RenderData& renderData;
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
||||
} // namespace cc
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
#include "NativePipelineTypes.h"
|
||||
#include "details/GslUtils.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
void BufferPool::init(gfx::Device* deviceIn, uint32_t sz, bool bDynamic) {
|
||||
CC_EXPECTS(deviceIn);
|
||||
CC_EXPECTS(sz);
|
||||
CC_EXPECTS(!device);
|
||||
CC_EXPECTS(bufferSize == 0);
|
||||
|
||||
device = deviceIn;
|
||||
bufferSize = sz;
|
||||
dynamic = bDynamic;
|
||||
}
|
||||
|
||||
void BufferPool::syncResources() {
|
||||
for (auto& buffer : currentBuffers) {
|
||||
freeBuffers.emplace_back(std::move(buffer));
|
||||
}
|
||||
currentBuffers.clear();
|
||||
|
||||
for (auto& bufferView : currentBufferViews) {
|
||||
freeBufferViews.emplace_back(std::move(bufferView));
|
||||
}
|
||||
currentBufferViews.clear();
|
||||
}
|
||||
|
||||
gfx::Buffer* BufferPool::allocateBuffer() {
|
||||
CC_EXPECTS(device);
|
||||
CC_EXPECTS(bufferSize);
|
||||
|
||||
gfx::Buffer* ptr = nullptr;
|
||||
|
||||
if (freeBuffers.empty()) {
|
||||
{
|
||||
gfx::BufferInfo info{
|
||||
gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST,
|
||||
gfx::MemoryUsageBit::HOST | gfx::MemoryUsageBit::DEVICE,
|
||||
bufferSize,
|
||||
bufferSize};
|
||||
freeBuffers.emplace_back(device->createBuffer(info));
|
||||
}
|
||||
|
||||
if (dynamic) {
|
||||
gfx::BufferViewInfo info{
|
||||
freeBuffers.back().get(),
|
||||
0, bufferSize};
|
||||
freeBufferViews.emplace_back(device->createBuffer(info));
|
||||
}
|
||||
}
|
||||
{
|
||||
CC_ENSURES(!freeBuffers.empty());
|
||||
auto& buffer = freeBuffers.back();
|
||||
ptr = buffer.get();
|
||||
CC_EXPECTS(buffer->getSize() == bufferSize);
|
||||
currentBuffers.emplace_back(std::move(buffer));
|
||||
freeBuffers.pop_back();
|
||||
}
|
||||
if (dynamic) {
|
||||
CC_ENSURES(!freeBufferViews.empty());
|
||||
auto& bufferView = freeBufferViews.back();
|
||||
ptr = bufferView.get();
|
||||
CC_EXPECTS(bufferView->getSize() == bufferSize);
|
||||
currentBufferViews.emplace_back(std::move(bufferView));
|
||||
freeBufferViews.pop_back();
|
||||
}
|
||||
CC_ENSURES(ptr);
|
||||
if (dynamic) {
|
||||
CC_ENSURES(ptr->isBufferView());
|
||||
} else {
|
||||
CC_ENSURES(!ptr->isBufferView());
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void UniformBlockResource::init(gfx::Device* deviceIn, uint32_t sz, bool bDynamic) {
|
||||
CC_EXPECTS(cpuBuffer.empty());
|
||||
cpuBuffer.resize(sz);
|
||||
bufferPool.init(deviceIn, sz, bDynamic);
|
||||
}
|
||||
|
||||
gfx::Buffer* UniformBlockResource::createFromCpuBuffer() {
|
||||
CC_EXPECTS(cpuBuffer.size() == bufferPool.bufferSize);
|
||||
auto* bufferOrView = bufferPool.allocateBuffer();
|
||||
if (bufferPool.dynamic) {
|
||||
auto* buffer = bufferPool.currentBuffers.back().get();
|
||||
buffer->update(cpuBuffer.data(), static_cast<uint32_t>(cpuBuffer.size()));
|
||||
} else {
|
||||
bufferOrView->update(cpuBuffer.data(), static_cast<uint32_t>(cpuBuffer.size()));
|
||||
}
|
||||
return bufferOrView;
|
||||
}
|
||||
|
||||
void DescriptorSetPool::init(gfx::Device* deviceIn,
|
||||
IntrusivePtr<gfx::DescriptorSetLayout> layout) {
|
||||
CC_EXPECTS(deviceIn);
|
||||
CC_EXPECTS(layout);
|
||||
CC_EXPECTS(!device);
|
||||
CC_EXPECTS(!setLayout);
|
||||
device = deviceIn;
|
||||
setLayout = std::move(layout);
|
||||
}
|
||||
|
||||
void DescriptorSetPool::syncDescriptorSets() {
|
||||
for (auto& set : currentDescriptorSets) {
|
||||
freeDescriptorSets.emplace_back(std::move(set));
|
||||
}
|
||||
currentDescriptorSets.clear();
|
||||
}
|
||||
|
||||
gfx::DescriptorSet& DescriptorSetPool::getCurrentDescriptorSet() {
|
||||
CC_EXPECTS(!currentDescriptorSets.empty());
|
||||
return *currentDescriptorSets.back();
|
||||
}
|
||||
|
||||
const gfx::DescriptorSet& DescriptorSetPool::getCurrentDescriptorSet() const {
|
||||
CC_EXPECTS(!currentDescriptorSets.empty());
|
||||
return *currentDescriptorSets.back();
|
||||
}
|
||||
|
||||
gfx::DescriptorSet* DescriptorSetPool::allocateDescriptorSet() {
|
||||
CC_EXPECTS(device);
|
||||
CC_EXPECTS(setLayout);
|
||||
|
||||
gfx::DescriptorSet* ptr = nullptr;
|
||||
|
||||
if (freeDescriptorSets.empty()) {
|
||||
freeDescriptorSets.emplace_back(
|
||||
device->createDescriptorSet(gfx::DescriptorSetInfo{setLayout.get()}));
|
||||
}
|
||||
|
||||
{
|
||||
CC_ENSURES(!freeDescriptorSets.empty());
|
||||
auto& set = freeDescriptorSets.back();
|
||||
ptr = set.get();
|
||||
CC_EXPECTS(set->getLayout() == setLayout);
|
||||
currentDescriptorSets.emplace_back(std::move(set));
|
||||
freeDescriptorSets.pop_back();
|
||||
}
|
||||
CC_ENSURES(ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
|
||||
} // namespace cc
|
||||
@@ -23,14 +23,20 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/container/pmr/global_resource.hpp>
|
||||
#include <boost/container/pmr/memory_resource.hpp>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <cctype>
|
||||
#include "LayoutGraphGraphs.h"
|
||||
#include "LayoutGraphUtils.h"
|
||||
#include "NativePipelineTypes.h"
|
||||
#include "ProgramLib.h"
|
||||
#include "ProgramUtils.h"
|
||||
#include "base/Ptr.h"
|
||||
#include "cocos/base/Log.h"
|
||||
#include "cocos/core/assets/EffectAsset.h"
|
||||
#include "cocos/renderer/core/ProgramUtils.h"
|
||||
@@ -38,8 +44,12 @@
|
||||
#include "cocos/renderer/pipeline/Define.h"
|
||||
#include "cocos/renderer/pipeline/custom/LayoutGraphGraphs.h"
|
||||
#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h"
|
||||
#include "details/Range.h"
|
||||
#include "gfx-base/GFXDescriptorSetLayout.h"
|
||||
#include "gfx-base/GFXShader.h"
|
||||
#include "pipeline/custom/NativePipelineFwd.h"
|
||||
#include "pipeline/custom/PrivateTypes.h"
|
||||
#include "pipeline/custom/RenderCommonTypes.h"
|
||||
#include "pipeline/custom/details/GslUtils.h"
|
||||
|
||||
namespace cc {
|
||||
@@ -122,49 +132,61 @@ IProgramInfo makeProgramInfo(const ccstd::string &effectName, const IShaderInfo
|
||||
return programInfo;
|
||||
}
|
||||
|
||||
std::tuple<std::string_view, gfx::Type> getDescriptorNameAndType(
|
||||
const pipeline::DescriptorSetLayoutInfos &source,
|
||||
uint32_t binding) {
|
||||
ccstd::pmr::vector<std::tuple<ccstd::pmr::string, gfx::Type>> getDescriptorNameAndType(
|
||||
const pipeline::DescriptorSetLayoutInfos &source, uint32_t binding,
|
||||
boost::container::pmr::memory_resource *scratch) {
|
||||
ccstd::pmr::vector<std::tuple<ccstd::pmr::string, gfx::Type>> results(scratch);
|
||||
|
||||
for (const auto &[name, block] : source.blocks) {
|
||||
if (block.binding == binding) {
|
||||
return {name, gfx::Type::UNKNOWN};
|
||||
results.emplace_back(std::tuple{name, gfx::Type::UNKNOWN});
|
||||
}
|
||||
}
|
||||
for (const auto &[name, texture] : source.samplers) {
|
||||
if (texture.binding == binding) {
|
||||
return {name, texture.type};
|
||||
results.emplace_back(std::tuple{name, texture.type});
|
||||
}
|
||||
}
|
||||
for (const auto &[name, image] : source.storeImages) {
|
||||
if (image.binding == binding) {
|
||||
return {name, image.type};
|
||||
results.emplace_back(std::tuple{name, image.type});
|
||||
}
|
||||
}
|
||||
return {"", gfx::Type::UNKNOWN};
|
||||
return results;
|
||||
}
|
||||
|
||||
void makeLocalDescriptorSetLayoutData(
|
||||
LayoutGraphData &lg,
|
||||
const pipeline::DescriptorSetLayoutInfos &source,
|
||||
DescriptorSetLayoutData &data) {
|
||||
DescriptorSetLayoutData &data,
|
||||
boost::container::pmr::memory_resource *scratch) {
|
||||
for (const auto &b : source.bindings) {
|
||||
const auto [name, type] = getDescriptorNameAndType(source, b.binding);
|
||||
const auto nameID = getOrCreateDescriptorID(lg, name);
|
||||
const auto order = getDescriptorTypeOrder(b.descriptorType);
|
||||
const auto &descriptors = getDescriptorNameAndType(source, b.binding, scratch);
|
||||
CC_ENSURES(!descriptors.empty());
|
||||
{
|
||||
const auto &[name, type] = descriptors.front();
|
||||
const auto nameID = getOrCreateDescriptorID(lg, name);
|
||||
const auto order = getDescriptorTypeOrder(b.descriptorType);
|
||||
auto &block = data.descriptorBlocks.emplace_back(order, b.stageFlags, b.count);
|
||||
block.offset = b.binding;
|
||||
block.descriptors.emplace_back(nameID, type, b.count);
|
||||
}
|
||||
{
|
||||
auto iter = data.bindingMap.find(nameID);
|
||||
if (iter != data.bindingMap.end()) {
|
||||
CC_LOG_ERROR("Duplicate descriptor name: %s", name.data());
|
||||
for (const auto &[name, type] : descriptors) {
|
||||
const auto nameID = getOrCreateDescriptorID(lg, name);
|
||||
{
|
||||
auto iter = data.bindingMap.find(nameID);
|
||||
if (iter != data.bindingMap.end()) {
|
||||
CC_LOG_ERROR("Duplicate descriptor name: %s", name.data());
|
||||
}
|
||||
data.bindingMap.emplace(nameID, b.binding);
|
||||
}
|
||||
{
|
||||
auto iter = source.blocks.find(ccstd::string(name));
|
||||
if (iter != source.blocks.end()) {
|
||||
data.uniformBlocks.emplace(nameID, iter->second);
|
||||
}
|
||||
}
|
||||
data.bindingMap.emplace(nameID, b.binding);
|
||||
}
|
||||
const auto &v = source.blocks.at(ccstd::string(name));
|
||||
data.uniformBlocks.emplace(nameID, v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +230,7 @@ ShaderProgramData &buildProgramData(
|
||||
CC_ENSURES(res.second);
|
||||
auto &setData = res.first->second;
|
||||
auto &perInstance = setData.descriptorSetLayoutData;
|
||||
makeLocalDescriptorSetLayoutData(lg, pipeline::localDescriptorSetLayout, perInstance);
|
||||
makeLocalDescriptorSetLayoutData(lg, pipeline::localDescriptorSetLayout, perInstance, scratch);
|
||||
initializeDescriptorSetLayoutInfo(
|
||||
setData.descriptorSetLayoutData,
|
||||
setData.descriptorSetLayoutInfo);
|
||||
@@ -249,7 +271,7 @@ ShaderProgramData &buildProgramData(
|
||||
void populateMergedShaderInfo(
|
||||
const ccstd::pmr::vector<ccstd::pmr::string> &valueNames,
|
||||
const DescriptorSetLayoutData &layout, uint32_t set,
|
||||
gfx::ShaderInfo &shaderInfo, ccstd::pmr::vector<uint32_t> &blockSizes) {
|
||||
gfx::ShaderInfo &shaderInfo, ccstd::vector<int32_t> &blockSizes) {
|
||||
for (const auto &descriptorBlock : layout.descriptorBlocks) {
|
||||
auto binding = descriptorBlock.offset;
|
||||
switch (descriptorBlock.type) {
|
||||
@@ -262,7 +284,7 @@ void populateMergedShaderInfo(
|
||||
continue;
|
||||
}
|
||||
const auto &uniformBlock = iter->second;
|
||||
blockSizes.emplace_back(getSize(uniformBlock.members));
|
||||
blockSizes.emplace_back(getUniformBlockSize(uniformBlock.members));
|
||||
shaderInfo.blocks.emplace_back(
|
||||
gfx::UniformBlock{
|
||||
set,
|
||||
@@ -367,7 +389,7 @@ void populateGroupedShaderInfo(
|
||||
const DescriptorSetLayoutData &layout,
|
||||
const IDescriptorInfo &descriptorInfo, uint32_t set,
|
||||
gfx::ShaderInfo &shaderInfo,
|
||||
ccstd::pmr::vector<uint32_t> &blockSizes) {
|
||||
ccstd::vector<int32_t> &blockSizes) {
|
||||
for (const auto &descriptorBlock : layout.descriptorBlocks) {
|
||||
const auto visibility = descriptorBlock.visibility;
|
||||
auto binding = descriptorBlock.offset;
|
||||
@@ -378,7 +400,7 @@ void populateGroupedShaderInfo(
|
||||
if (block.stageFlags != visibility) {
|
||||
continue;
|
||||
}
|
||||
blockSizes.emplace_back(getSize(block.members));
|
||||
blockSizes.emplace_back(getUniformBlockSize(block.members));
|
||||
shaderInfo.blocks.emplace_back(
|
||||
gfx::UniformBlock{
|
||||
set,
|
||||
@@ -496,8 +518,8 @@ void populateGroupedShaderInfo(
|
||||
void populateLocalShaderInfo(
|
||||
const IDescriptorInfo &target,
|
||||
const pipeline::DescriptorSetLayoutInfos &source,
|
||||
gfx::ShaderInfo &shaderInfo, ccstd::pmr::vector<uint32_t> &blockSizes) {
|
||||
const auto set = setIndex(UpdateFrequency::PER_INSTANCE);
|
||||
gfx::ShaderInfo &shaderInfo, ccstd::vector<int32_t> &blockSizes) {
|
||||
constexpr auto set = setIndex(UpdateFrequency::PER_INSTANCE);
|
||||
for (const auto &block : target.blocks) {
|
||||
auto blockIter = source.blocks.find(block.name);
|
||||
if (blockIter == source.blocks.end()) {
|
||||
@@ -517,7 +539,7 @@ void populateLocalShaderInfo(
|
||||
}
|
||||
|
||||
const auto &binding = *pBinding;
|
||||
blockSizes.emplace_back(getSize(block.members));
|
||||
blockSizes.emplace_back(getUniformBlockSize(block.members));
|
||||
shaderInfo.blocks.emplace_back(
|
||||
gfx::UniformBlock{
|
||||
set,
|
||||
@@ -556,6 +578,137 @@ void populateLocalShaderInfo(
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getIDescriptorSetLayoutInfoUniformBlockCapacity(const pipeline::DescriptorSetLayoutInfos &info) {
|
||||
uint32_t capacity = 0;
|
||||
for (const auto &binding : info.bindings) {
|
||||
if (binding.descriptorType == gfx::DescriptorType::UNIFORM_BUFFER ||
|
||||
binding.descriptorType == gfx::DescriptorType::DYNAMIC_UNIFORM_BUFFER) {
|
||||
capacity += binding.count;
|
||||
}
|
||||
}
|
||||
return capacity;
|
||||
}
|
||||
|
||||
uint32_t getIDescriptorSetLayoutInfoSamplerTextureCapacity(const pipeline::DescriptorSetLayoutInfos &info) {
|
||||
uint32_t capacity = 0;
|
||||
for (const auto &binding : info.bindings) {
|
||||
if (binding.descriptorType != gfx::DescriptorType::UNIFORM_BUFFER &&
|
||||
binding.descriptorType != gfx::DescriptorType::DYNAMIC_UNIFORM_BUFFER) {
|
||||
capacity += binding.count;
|
||||
}
|
||||
}
|
||||
return capacity;
|
||||
}
|
||||
|
||||
void setFlattenedUniformBlockBinding(
|
||||
const std::array<uint32_t, 4> &setOffsets,
|
||||
ccstd::vector<gfx::UniformBlock> &descriptors) {
|
||||
for (auto &d : descriptors) {
|
||||
d.flattened = setOffsets[d.set] + d.binding;
|
||||
}
|
||||
}
|
||||
|
||||
template <class Desc>
|
||||
void setFlattenedSamplerTextureBinding(
|
||||
const std::array<uint32_t, 4> &setOffsets,
|
||||
const std::array<uint32_t, 4> &uniformBlockCapacities,
|
||||
ccstd::vector<Desc> &descriptors) {
|
||||
for (auto &d : descriptors) {
|
||||
d.flattened = setOffsets[d.set] + d.binding - uniformBlockCapacities[d.set];
|
||||
}
|
||||
}
|
||||
|
||||
void calculateFlattenedBinding(
|
||||
const std::array<const DescriptorSetLayoutData *, 4> &descriptorSets,
|
||||
const pipeline::DescriptorSetLayoutInfos *fixedInstanceDescriptorSetLayout,
|
||||
gfx::ShaderInfo &shaderInfo) {
|
||||
// Descriptors of UniformBlock starts from 0, and Descriptors of SamplerTexture starts from the end of UniformBlock.
|
||||
std::array<uint32_t, 4> uniformBlockCapacities{};
|
||||
{
|
||||
const auto passCapacity =
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PASS)]
|
||||
? descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PASS)]->uniformBlockCapacity
|
||||
: 0;
|
||||
const auto phaseCapacity =
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PHASE)]
|
||||
? descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PHASE)]->uniformBlockCapacity
|
||||
: 0;
|
||||
const auto batchCapacity =
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_BATCH)]
|
||||
? descriptorSets[static_cast<size_t>(UpdateFrequency::PER_BATCH)]->uniformBlockCapacity
|
||||
: 0;
|
||||
const auto instanceCapacity =
|
||||
fixedInstanceDescriptorSetLayout
|
||||
? getIDescriptorSetLayoutInfoUniformBlockCapacity(*fixedInstanceDescriptorSetLayout)
|
||||
: (descriptorSets[static_cast<size_t>(UpdateFrequency::PER_INSTANCE)]
|
||||
? descriptorSets[static_cast<size_t>(UpdateFrequency::PER_INSTANCE)]->uniformBlockCapacity
|
||||
: 0);
|
||||
|
||||
// update uniform block capacities
|
||||
uniformBlockCapacities[setIndex(UpdateFrequency::PER_PASS)] = passCapacity;
|
||||
uniformBlockCapacities[setIndex(UpdateFrequency::PER_PHASE)] = phaseCapacity;
|
||||
uniformBlockCapacities[setIndex(UpdateFrequency::PER_BATCH)] = batchCapacity;
|
||||
uniformBlockCapacities[setIndex(UpdateFrequency::PER_INSTANCE)] = instanceCapacity;
|
||||
|
||||
// calculate uniform block offsets
|
||||
const auto passOffset = 0;
|
||||
const auto phaseOffset = passOffset + passCapacity;
|
||||
const auto instanceOffset = phaseOffset + phaseCapacity;
|
||||
const auto batchOffset = instanceOffset + instanceCapacity;
|
||||
|
||||
// save uniform block offsets by set index
|
||||
std::array<uint32_t, 4> uniformBlockOffsets{};
|
||||
uniformBlockOffsets[setIndex(UpdateFrequency::PER_PASS)] = passOffset;
|
||||
uniformBlockOffsets[setIndex(UpdateFrequency::PER_PHASE)] = phaseOffset;
|
||||
uniformBlockOffsets[setIndex(UpdateFrequency::PER_BATCH)] = batchOffset;
|
||||
uniformBlockOffsets[setIndex(UpdateFrequency::PER_INSTANCE)] = instanceOffset;
|
||||
|
||||
// update flattened uniform block binding
|
||||
setFlattenedUniformBlockBinding(uniformBlockOffsets, shaderInfo.blocks);
|
||||
}
|
||||
{
|
||||
// calculate sampler texture capacities
|
||||
const auto passCapacity =
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PASS)]
|
||||
? descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PASS)]->samplerTextureCapacity
|
||||
: 0;
|
||||
const auto phaseCapacity =
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PHASE)]
|
||||
? descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PHASE)]->samplerTextureCapacity
|
||||
: 0;
|
||||
const auto batchCapacity =
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_BATCH)]
|
||||
? descriptorSets[static_cast<size_t>(UpdateFrequency::PER_BATCH)]->samplerTextureCapacity
|
||||
: 0;
|
||||
const auto instanceCapacity =
|
||||
fixedInstanceDescriptorSetLayout
|
||||
? getIDescriptorSetLayoutInfoSamplerTextureCapacity(*fixedInstanceDescriptorSetLayout)
|
||||
: (descriptorSets[static_cast<size_t>(UpdateFrequency::PER_INSTANCE)]
|
||||
? descriptorSets[static_cast<size_t>(UpdateFrequency::PER_INSTANCE)]->samplerTextureCapacity
|
||||
: 0);
|
||||
|
||||
// calculate sampler texture offsets
|
||||
const auto passOffset = 0;
|
||||
const auto phaseOffset = passOffset + passCapacity;
|
||||
const auto instanceOffset = phaseOffset + phaseCapacity;
|
||||
const auto batchOffset = instanceOffset + instanceCapacity;
|
||||
|
||||
// save sampler texture offsets by set index
|
||||
std::array<uint32_t, 4> samplerTextureOffsets{};
|
||||
samplerTextureOffsets[setIndex(UpdateFrequency::PER_PASS)] = passOffset;
|
||||
samplerTextureOffsets[setIndex(UpdateFrequency::PER_PHASE)] = phaseOffset;
|
||||
samplerTextureOffsets[setIndex(UpdateFrequency::PER_BATCH)] = batchOffset;
|
||||
samplerTextureOffsets[setIndex(UpdateFrequency::PER_INSTANCE)] = instanceOffset;
|
||||
|
||||
// update flattened sampler texture binding
|
||||
setFlattenedSamplerTextureBinding(samplerTextureOffsets, uniformBlockCapacities, shaderInfo.samplerTextures);
|
||||
setFlattenedSamplerTextureBinding(samplerTextureOffsets, uniformBlockCapacities, shaderInfo.samplers);
|
||||
setFlattenedSamplerTextureBinding(samplerTextureOffsets, uniformBlockCapacities, shaderInfo.textures);
|
||||
setFlattenedSamplerTextureBinding(samplerTextureOffsets, uniformBlockCapacities, shaderInfo.buffers);
|
||||
setFlattenedSamplerTextureBinding(samplerTextureOffsets, uniformBlockCapacities, shaderInfo.images);
|
||||
}
|
||||
}
|
||||
|
||||
void makeShaderInfo(
|
||||
LayoutGraphData &lg,
|
||||
const PipelineLayoutData &passLayouts, // NOLINT(bugprone-easily-swappable-parameters)
|
||||
@@ -564,10 +717,13 @@ void makeShaderInfo(
|
||||
const ShaderProgramData *programData,
|
||||
bool fixedLocal,
|
||||
gfx::ShaderInfo &shaderInfo,
|
||||
ccstd::pmr::vector<uint32_t> &blockSizes) {
|
||||
ccstd::vector<int32_t> &blockSizes) {
|
||||
std::array<const DescriptorSetLayoutData *, 4> descriptorSets{};
|
||||
const pipeline::DescriptorSetLayoutInfos *fixedInstanceDescriptorSetLayout = nullptr;
|
||||
{ // pass
|
||||
auto iter = passLayouts.descriptorSets.find(UpdateFrequency::PER_PASS);
|
||||
if (iter != passLayouts.descriptorSets.end()) {
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PASS)] = &iter->second.descriptorSetLayoutData;
|
||||
populateMergedShaderInfo(
|
||||
lg.valueNames, iter->second.descriptorSetLayoutData,
|
||||
setIndex(UpdateFrequency::PER_PASS),
|
||||
@@ -576,7 +732,8 @@ void makeShaderInfo(
|
||||
}
|
||||
{ // phase
|
||||
auto iter = phaseLayouts.descriptorSets.find(UpdateFrequency::PER_PHASE);
|
||||
if (iter != passLayouts.descriptorSets.end()) {
|
||||
if (iter != phaseLayouts.descriptorSets.end()) {
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_PHASE)] = &iter->second.descriptorSetLayoutData;
|
||||
populateMergedShaderInfo(
|
||||
lg.valueNames, iter->second.descriptorSetLayoutData,
|
||||
setIndex(UpdateFrequency::PER_PHASE),
|
||||
@@ -589,6 +746,7 @@ void makeShaderInfo(
|
||||
if (programData) {
|
||||
auto iter = programData->layout.descriptorSets.find(UpdateFrequency::PER_BATCH);
|
||||
if (iter != programData->layout.descriptorSets.end()) {
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_BATCH)] = &iter->second.descriptorSetLayoutData;
|
||||
populateMergedShaderInfo(
|
||||
lg.valueNames, iter->second.descriptorSetLayoutData,
|
||||
setIndex(UpdateFrequency::PER_BATCH),
|
||||
@@ -597,6 +755,7 @@ void makeShaderInfo(
|
||||
} else {
|
||||
auto iter = phaseLayouts.descriptorSets.find(UpdateFrequency::PER_BATCH);
|
||||
if (iter != phaseLayouts.descriptorSets.end()) {
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_BATCH)] = &iter->second.descriptorSetLayoutData;
|
||||
populateGroupedShaderInfo(
|
||||
iter->second.descriptorSetLayoutData,
|
||||
batchInfo, setIndex(UpdateFrequency::PER_BATCH),
|
||||
@@ -609,6 +768,7 @@ void makeShaderInfo(
|
||||
static_cast<uint32_t>(UpdateFrequency::PER_INSTANCE));
|
||||
if (programData) {
|
||||
if (fixedLocal) {
|
||||
fixedInstanceDescriptorSetLayout = &pipeline::localDescriptorSetLayout;
|
||||
populateLocalShaderInfo(
|
||||
instanceInfo,
|
||||
pipeline::localDescriptorSetLayout, shaderInfo, blockSizes);
|
||||
@@ -616,6 +776,7 @@ void makeShaderInfo(
|
||||
auto iter = programData->layout.descriptorSets.find(
|
||||
UpdateFrequency::PER_INSTANCE);
|
||||
if (iter != programData->layout.descriptorSets.end()) {
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_INSTANCE)] = &iter->second.descriptorSetLayoutData;
|
||||
populateMergedShaderInfo(
|
||||
lg.valueNames, iter->second.descriptorSetLayoutData,
|
||||
setIndex(UpdateFrequency::PER_INSTANCE),
|
||||
@@ -625,6 +786,7 @@ void makeShaderInfo(
|
||||
} else {
|
||||
auto iter = phaseLayouts.descriptorSets.find(UpdateFrequency::PER_INSTANCE);
|
||||
if (iter != phaseLayouts.descriptorSets.end()) {
|
||||
descriptorSets[static_cast<size_t>(UpdateFrequency::PER_INSTANCE)] = &iter->second.descriptorSetLayoutData;
|
||||
populateGroupedShaderInfo(
|
||||
iter->second.descriptorSetLayoutData,
|
||||
instanceInfo, setIndex(UpdateFrequency::PER_INSTANCE),
|
||||
@@ -632,11 +794,181 @@ void makeShaderInfo(
|
||||
}
|
||||
}
|
||||
}
|
||||
calculateFlattenedBinding(descriptorSets, fixedInstanceDescriptorSetLayout, shaderInfo);
|
||||
shaderInfo.stages.emplace_back(gfx::ShaderStage{gfx::ShaderStageFlagBit::VERTEX, ""});
|
||||
shaderInfo.stages.emplace_back(gfx::ShaderStage{gfx::ShaderStageFlagBit::FRAGMENT, ""});
|
||||
}
|
||||
|
||||
std::pair<uint32_t, uint32_t> findBinding(
|
||||
const gfx::ShaderInfo &shaderInfo, std::string_view name) {
|
||||
for (const auto &v : shaderInfo.blocks) {
|
||||
if (v.name == name) {
|
||||
return std::pair{v.set, v.binding};
|
||||
}
|
||||
}
|
||||
for (const auto &v : shaderInfo.buffers) {
|
||||
if (v.name == name) {
|
||||
return std::pair{v.set, v.binding};
|
||||
}
|
||||
}
|
||||
for (const auto &v : shaderInfo.samplerTextures) {
|
||||
if (v.name == name) {
|
||||
return std::pair{v.set, v.binding};
|
||||
}
|
||||
}
|
||||
for (const auto &v : shaderInfo.samplers) {
|
||||
if (v.name == name) {
|
||||
return std::pair{v.set, v.binding};
|
||||
}
|
||||
}
|
||||
for (const auto &v : shaderInfo.textures) {
|
||||
if (v.name == name) {
|
||||
return std::pair{v.set, v.binding};
|
||||
}
|
||||
}
|
||||
for (const auto &v : shaderInfo.images) {
|
||||
if (v.name == name) {
|
||||
return std::pair{v.set, v.binding};
|
||||
}
|
||||
}
|
||||
CC_EXPECTS(false);
|
||||
return {};
|
||||
}
|
||||
|
||||
void overwriteShaderSourceBinding(
|
||||
const gfx::ShaderInfo &shaderInfo,
|
||||
ccstd::string &source,
|
||||
boost::container::pmr::memory_resource *scratch) {
|
||||
// find first uniform
|
||||
auto pos = source.find(" uniform ");
|
||||
while (pos != ccstd::string::npos) {
|
||||
// uniform statement is separated by ";{}";
|
||||
auto beg = source.find_last_of(";}", pos);
|
||||
auto end = source.find_first_of(";{", pos);
|
||||
if (beg == ccstd::string::npos) {
|
||||
// if separator is not found, start from 0
|
||||
beg = 0;
|
||||
} else {
|
||||
// bypass last separator
|
||||
beg += 1;
|
||||
}
|
||||
// uniform declaration is found
|
||||
CC_EXPECTS(beg != ccstd::string::npos);
|
||||
CC_EXPECTS(end != ccstd::string::npos);
|
||||
CC_ENSURES(end > beg);
|
||||
|
||||
// find uniform name
|
||||
std::string_view name{};
|
||||
{
|
||||
std::string_view decl(source.c_str() + beg, end - beg);
|
||||
auto nameEnd = decl.size();
|
||||
for (; nameEnd-- > 0;) {
|
||||
if (!std::isspace(decl[nameEnd])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto nameBeg = decl.find_last_of(' ', nameEnd);
|
||||
nameBeg += 1;
|
||||
nameEnd += 1;
|
||||
// uniform name found
|
||||
name = decl.substr(nameBeg, nameEnd - nameBeg);
|
||||
}
|
||||
CC_ENSURES(!name.empty());
|
||||
|
||||
// layout
|
||||
std::ptrdiff_t offset = 0;
|
||||
{
|
||||
std::string_view prevLayout;
|
||||
// find layout expression
|
||||
auto layoutBeg = source.rfind("layout", pos);
|
||||
auto layoutEnd = ccstd::string::npos;
|
||||
if (layoutBeg == ccstd::string::npos || layoutBeg < beg) {
|
||||
// layout not found
|
||||
layoutBeg = ccstd::string::npos;
|
||||
CC_ENSURES(layoutBeg == ccstd::string::npos);
|
||||
CC_ENSURES(layoutEnd == ccstd::string::npos);
|
||||
} else {
|
||||
CC_EXPECTS(layoutBeg >= beg && layoutBeg <= end);
|
||||
layoutEnd = source.find(')', layoutBeg) + 1;
|
||||
CC_EXPECTS(layoutEnd != ccstd::string::npos);
|
||||
CC_ENSURES(layoutBeg < layoutEnd && layoutEnd <= end);
|
||||
prevLayout = std::string_view(source.c_str() + layoutBeg, layoutEnd - layoutBeg);
|
||||
|
||||
// check layout expression is within uniform declaration
|
||||
// prev layout expression is from layoutBeg to layoutEnd
|
||||
CC_ENSURES(layoutBeg >= beg && layoutBeg <= end);
|
||||
CC_ENSURES(layoutEnd >= layoutBeg && layoutEnd <= end);
|
||||
}
|
||||
|
||||
// find uniform set and binding
|
||||
auto [set, binding] = findBinding(shaderInfo, name);
|
||||
|
||||
// compose new layout expression
|
||||
ccstd::pmr::string newLayout(scratch);
|
||||
newLayout.reserve(32);
|
||||
newLayout.append("layout(set = ");
|
||||
newLayout.append(std::to_string(set));
|
||||
newLayout.append(", binding = ");
|
||||
newLayout.append(std::to_string(binding));
|
||||
newLayout.append(")");
|
||||
|
||||
// replace layout expression
|
||||
if (layoutBeg == ccstd::string::npos) { // layout not found
|
||||
source.insert(pos, newLayout);
|
||||
offset = static_cast<std::ptrdiff_t>(newLayout.size());
|
||||
} else {
|
||||
// layout is found
|
||||
source.erase(layoutBeg, prevLayout.size());
|
||||
source.insert(layoutBeg, newLayout);
|
||||
// calculate string difference
|
||||
offset = static_cast<std::ptrdiff_t>(newLayout.size()) -
|
||||
static_cast<std::ptrdiff_t>(prevLayout.size());
|
||||
}
|
||||
}
|
||||
// offset end of uniform declaration, offset is caused by modification of layout
|
||||
end += offset;
|
||||
// find next uniform
|
||||
pos = source.find(" uniform ", end);
|
||||
auto exceptionPos = source.find(" uniform subpassInput ", end);
|
||||
if (exceptionPos != ccstd::string::npos) {
|
||||
while (pos == exceptionPos) {
|
||||
end += strlen(" uniform subpassInput ");
|
||||
pos = source.find(" uniform ", end);
|
||||
exceptionPos = source.find(" uniform subpassInput ", end);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void overwriteShaderProgramBinding(
|
||||
gfx::Device *device,
|
||||
const gfx::ShaderInfo &shaderInfo, IProgramInfo &programInfo,
|
||||
boost::container::pmr::memory_resource *scratch) {
|
||||
// get shader source to use
|
||||
IShaderSource *src = &programInfo.glsl3;
|
||||
const auto *deviceShaderVersion = getDeviceShaderVersion(device);
|
||||
if (deviceShaderVersion) {
|
||||
if (deviceShaderVersion != std::string_view{"glsl4"}) {
|
||||
return;
|
||||
}
|
||||
src = programInfo.getSource(deviceShaderVersion);
|
||||
} else {
|
||||
CC_LOG_ERROR("Invalid GFX API!");
|
||||
}
|
||||
CC_ENSURES(src);
|
||||
|
||||
overwriteShaderSourceBinding(shaderInfo, src->vert, scratch);
|
||||
overwriteShaderSourceBinding(shaderInfo, src->frag, scratch);
|
||||
}
|
||||
|
||||
// overwrite IProgramInfo using gfx.ShaderInfo
|
||||
void overwriteProgramBlockInfo(const gfx::ShaderInfo &shaderInfo, IProgramInfo &programInfo) {
|
||||
const auto set = setIndex(UpdateFrequency::PER_BATCH);
|
||||
void overwriteProgramBlockInfo(
|
||||
gfx::Device *device,
|
||||
const gfx::ShaderInfo &shaderInfo, IProgramInfo &programInfo,
|
||||
boost::container::pmr::memory_resource *scratch) {
|
||||
overwriteShaderProgramBinding(device, shaderInfo, programInfo, scratch);
|
||||
|
||||
constexpr auto set = setIndex(UpdateFrequency::PER_BATCH);
|
||||
for (auto &block : programInfo.blocks) {
|
||||
auto found = false;
|
||||
for (const auto &src : shaderInfo.blocks) {
|
||||
@@ -691,10 +1023,10 @@ gfx::DescriptorSetLayout *getDescriptorSetLayout(
|
||||
gfx::DescriptorSetLayout *getProgramDescriptorSetLayout(
|
||||
gfx::Device *device,
|
||||
LayoutGraphData &lg, uint32_t phaseID,
|
||||
const ccstd::pmr::string &programName, UpdateFrequency rate) {
|
||||
const ccstd::string &programName, UpdateFrequency rate) {
|
||||
CC_EXPECTS(rate < UpdateFrequency::PER_PHASE);
|
||||
auto &phase = get(RenderPhaseTag{}, phaseID, lg);
|
||||
const auto iter = phase.shaderIndex.find(programName);
|
||||
const auto iter = phase.shaderIndex.find(std::string_view{programName});
|
||||
if (iter == phase.shaderIndex.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -753,7 +1085,7 @@ const gfx::DescriptorSetLayout &getOrCreateProgramDescriptorSetLayout(
|
||||
const NativeProgramLibrary &lib,
|
||||
gfx::Device *device,
|
||||
LayoutGraphData &lg, uint32_t phaseID,
|
||||
const ccstd::pmr::string &programName, UpdateFrequency rate) {
|
||||
std::string_view programName, UpdateFrequency rate) {
|
||||
CC_EXPECTS(rate < UpdateFrequency::PER_PHASE);
|
||||
auto &phase = get(RenderPhaseTag{}, phaseID, lg);
|
||||
const auto iter = phase.shaderIndex.find(programName);
|
||||
@@ -774,11 +1106,110 @@ const gfx::DescriptorSetLayout &getOrCreateProgramDescriptorSetLayout(
|
||||
return *layout.descriptorSetLayout;
|
||||
}
|
||||
|
||||
void populatePipelineLayoutInfo(
|
||||
const NativeProgramLibrary &lib,
|
||||
const PipelineLayoutData &layout,
|
||||
UpdateFrequency rate,
|
||||
gfx::PipelineLayoutInfo &info) {
|
||||
auto iter = layout.descriptorSets.find(rate);
|
||||
if (iter != layout.descriptorSets.end()) {
|
||||
const auto &set = iter->second;
|
||||
CC_EXPECTS(set.descriptorSetLayout);
|
||||
info.setLayouts.emplace_back(set.descriptorSetLayout.get());
|
||||
} else {
|
||||
info.setLayouts.emplace_back(lib.emptyDescriptorSetLayout.get());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void NativeProgramLibrary::init(gfx::Device *device) {
|
||||
void NativeProgramLibrary::init(gfx::Device *deviceIn) {
|
||||
boost::container::pmr::memory_resource *scratch = &unsycPool;
|
||||
device = deviceIn;
|
||||
emptyDescriptorSetLayout = device->createDescriptorSetLayout({});
|
||||
emptyPipelineLayout = device->createPipelineLayout({});
|
||||
|
||||
if (false) { // NOLINT(readability-simplify-boolean-expr)
|
||||
std::ostringstream oss;
|
||||
printLayoutGraphData(layoutGraph, oss, scratch);
|
||||
auto content = oss.str();
|
||||
std::istringstream iss(content);
|
||||
std::string line;
|
||||
while (std::getline(iss, line)) {
|
||||
CC_LOG_INFO(line.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// update ubo
|
||||
// tips: for compatibility with old version, when maxVertexUniformVectors is 128, maxJoints = 30
|
||||
uint maxJoints = (device->getCapabilities().maxVertexUniformVectors - 38) / 3;
|
||||
maxJoints = maxJoints < 256 ? maxJoints : 256;
|
||||
pipeline::SkinningJointCapacity::jointUniformCapacity = maxJoints;
|
||||
pipeline::UBOSkinning::initLayout(maxJoints);
|
||||
|
||||
// init layout graph
|
||||
auto &lg = layoutGraph;
|
||||
for (const auto v : makeRange(vertices(lg))) {
|
||||
auto &layout = get(LayoutGraphData::Layout, lg, v);
|
||||
for (auto &&[update, set] : layout.descriptorSets) {
|
||||
if (set.descriptorSetLayout) {
|
||||
CC_LOG_WARNING("descriptor set layout already initialized. It will be overwritten");
|
||||
}
|
||||
initializeDescriptorSetLayoutInfo(
|
||||
set.descriptorSetLayoutData,
|
||||
set.descriptorSetLayoutInfo);
|
||||
set.descriptorSetLayout = device->createDescriptorSetLayout(set.descriptorSetLayoutInfo);
|
||||
CC_ENSURES(set.descriptorSetLayout);
|
||||
set.descriptorSet = device->createDescriptorSet(gfx::DescriptorSetInfo{set.descriptorSetLayout.get()});
|
||||
CC_ENSURES(set.descriptorSet);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto v : makeRange(vertices(lg))) {
|
||||
if (!holds<RenderPhaseTag>(v, lg)) {
|
||||
continue;
|
||||
}
|
||||
const auto phaseID = v;
|
||||
const auto passID = parent(phaseID, lg);
|
||||
const auto &passLayout = get(LayoutGraphData::Layout, lg, passID);
|
||||
const auto &phaseLayout = get(LayoutGraphData::Layout, lg, phaseID);
|
||||
gfx::PipelineLayoutInfo info;
|
||||
populatePipelineLayoutInfo(*this, passLayout, UpdateFrequency::PER_PASS, info);
|
||||
populatePipelineLayoutInfo(*this, phaseLayout, UpdateFrequency::PER_PHASE, info);
|
||||
populatePipelineLayoutInfo(*this, phaseLayout, UpdateFrequency::PER_BATCH, info);
|
||||
populatePipelineLayoutInfo(*this, phaseLayout, UpdateFrequency::PER_INSTANCE, info);
|
||||
auto &phase = get(RenderPhaseTag{}, phaseID, lg);
|
||||
phase.pipelineLayout = device->createPipelineLayout(info);
|
||||
}
|
||||
|
||||
// init local descriptor set
|
||||
{
|
||||
const auto &localSetLayout = pipeline::localDescriptorSetLayout;
|
||||
makeLocalDescriptorSetLayoutData(lg, localSetLayout, localLayoutData, scratch);
|
||||
gfx::DescriptorSetLayoutInfo info{};
|
||||
initializeDescriptorSetLayoutInfo(localLayoutData, info);
|
||||
localDescriptorSetLayout = device->createDescriptorSetLayout(info);
|
||||
CC_ENSURES(localDescriptorSetLayout);
|
||||
|
||||
uint32_t numUniformBuffers = 0;
|
||||
for (const auto &block : localLayoutData.descriptorBlocks) {
|
||||
if (block.type != DescriptorTypeOrder::UNIFORM_BUFFER &&
|
||||
block.type != DescriptorTypeOrder::DYNAMIC_UNIFORM_BUFFER) {
|
||||
continue;
|
||||
}
|
||||
for (const auto &d : block.descriptors) {
|
||||
numUniformBuffers += d.count;
|
||||
}
|
||||
}
|
||||
CC_ENSURES(numUniformBuffers == 7); // 7 is currently max uniform binding
|
||||
}
|
||||
|
||||
// generate constant macros string
|
||||
generateConstantMacros(device, lg.constantMacros, false);
|
||||
}
|
||||
|
||||
void NativeProgramLibrary::setPipeline(PipelineRuntime *pipelineIn) {
|
||||
pipeline = pipelineIn;
|
||||
}
|
||||
|
||||
void NativeProgramLibrary::destroy() {
|
||||
@@ -786,7 +1217,7 @@ void NativeProgramLibrary::destroy() {
|
||||
emptyPipelineLayout.reset();
|
||||
}
|
||||
|
||||
void NativeProgramLibrary::addEffect(EffectAsset *effectAssetIn) {
|
||||
void NativeProgramLibrary::addEffect(const EffectAsset *effectAssetIn) {
|
||||
auto &lg = layoutGraph;
|
||||
boost::container::pmr::memory_resource *scratch = &unsycPool;
|
||||
const auto &effect = *effectAssetIn;
|
||||
@@ -807,12 +1238,16 @@ void NativeProgramLibrary::addEffect(EffectAsset *effectAssetIn) {
|
||||
// programs
|
||||
auto iter = this->phases.find(phaseID);
|
||||
if (iter == this->phases.end()) {
|
||||
iter = this->phases.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(phaseID),
|
||||
std::forward_as_tuple())
|
||||
iter = this->phases.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(phaseID),
|
||||
std::forward_as_tuple())
|
||||
.first;
|
||||
}
|
||||
auto &phasePrograms = iter->second.programInfos;
|
||||
if (phasePrograms.find(std::string_view{srcShaderInfo.name}) != phasePrograms.end()) {
|
||||
continue;
|
||||
}
|
||||
auto alloc = phasePrograms.get_allocator();
|
||||
|
||||
// build program
|
||||
@@ -822,17 +1257,17 @@ void NativeProgramLibrary::addEffect(EffectAsset *effectAssetIn) {
|
||||
ShaderProgramData *programData = nullptr;
|
||||
if (!mergeHighFrequency) {
|
||||
auto &phase = get(RenderPhaseTag{}, phaseID, lg);
|
||||
buildProgramData(programName, srcShaderInfo, lg, phase, fixedLocal, scratch);
|
||||
programData = &buildProgramData(programName, srcShaderInfo, lg, phase, fixedLocal, scratch);
|
||||
}
|
||||
|
||||
// shaderInfo and blockSizes
|
||||
gfx::ShaderInfo shaderInfo;
|
||||
ccstd::pmr::vector<uint32_t> blockSizes(alloc);
|
||||
ccstd::vector<int32_t> blockSizes;
|
||||
makeShaderInfo(lg, passLayout, phaseLayout, srcShaderInfo, programData,
|
||||
fixedLocal, shaderInfo, blockSizes);
|
||||
|
||||
// overwrite programInfo
|
||||
overwriteProgramBlockInfo(shaderInfo, programInfo);
|
||||
overwriteProgramBlockInfo(device, shaderInfo, programInfo, scratch);
|
||||
|
||||
// handle map
|
||||
auto handleMap = genHandles(shaderInfo);
|
||||
@@ -870,7 +1305,7 @@ void NativeProgramLibrary::precompileEffect(gfx::Device *device, EffectAsset *ef
|
||||
}
|
||||
|
||||
ccstd::string NativeProgramLibrary::getKey(
|
||||
uint32_t phaseID, const ccstd::pmr::string &programName,
|
||||
uint32_t phaseID, const ccstd::string &programName,
|
||||
const MacroRecord &defines) const {
|
||||
auto iter = phases.find(phaseID);
|
||||
if (iter == phases.end()) {
|
||||
@@ -878,7 +1313,7 @@ ccstd::string NativeProgramLibrary::getKey(
|
||||
return "";
|
||||
}
|
||||
const auto &phase = iter->second;
|
||||
auto iter2 = phase.programInfos.find(programName);
|
||||
auto iter2 = phase.programInfos.find(std::string_view{programName});
|
||||
if (iter2 == phase.programInfos.end()) {
|
||||
CC_LOG_ERROR("program not found");
|
||||
return "";
|
||||
@@ -887,29 +1322,29 @@ ccstd::string NativeProgramLibrary::getKey(
|
||||
return getVariantKey(info.programInfo, defines);
|
||||
}
|
||||
|
||||
const gfx::PipelineLayout &NativeProgramLibrary::getPipelineLayout(
|
||||
gfx::Device *device, uint32_t phaseID, const ccstd::pmr::string &programName) {
|
||||
IntrusivePtr<gfx::PipelineLayout> NativeProgramLibrary::getPipelineLayout(
|
||||
gfx::Device *device, uint32_t phaseID, const ccstd::string &programName) {
|
||||
if (mergeHighFrequency) {
|
||||
CC_EXPECTS(phaseID != LayoutGraphData::null_vertex());
|
||||
const auto &layout = get(RenderPhaseTag{}, phaseID, layoutGraph);
|
||||
return *layout.pipelineLayout;
|
||||
return layout.pipelineLayout;
|
||||
}
|
||||
auto &lg = layoutGraph;
|
||||
auto &phase = get(RenderPhaseTag{}, phaseID, lg);
|
||||
const auto iter = phase.shaderIndex.find(programName);
|
||||
const auto iter = phase.shaderIndex.find(std::string_view{programName});
|
||||
if (iter == phase.shaderIndex.end()) {
|
||||
return *emptyPipelineLayout;
|
||||
return emptyPipelineLayout;
|
||||
}
|
||||
const auto programID = iter->second;
|
||||
auto &programData = phase.shaderPrograms.at(programID);
|
||||
if (programData.pipelineLayout) {
|
||||
return *programData.pipelineLayout;
|
||||
return programData.pipelineLayout;
|
||||
}
|
||||
|
||||
// get pass
|
||||
const auto passID = parent(phaseID, lg);
|
||||
if (passID == LayoutGraphData::null_vertex()) {
|
||||
return *emptyPipelineLayout;
|
||||
return emptyPipelineLayout;
|
||||
}
|
||||
// create pipeline layout
|
||||
gfx::PipelineLayoutInfo info{};
|
||||
@@ -932,11 +1367,11 @@ const gfx::PipelineLayout &NativeProgramLibrary::getPipelineLayout(
|
||||
info.setLayouts.emplace_back(instanceSet);
|
||||
}
|
||||
programData.pipelineLayout = device->createPipelineLayout(info);
|
||||
return *programData.pipelineLayout;
|
||||
return programData.pipelineLayout;
|
||||
}
|
||||
|
||||
const gfx::DescriptorSetLayout &NativeProgramLibrary::getMaterialDescriptorSetLayout(
|
||||
gfx::Device *device, uint32_t phaseID, const ccstd::pmr::string &programName) {
|
||||
gfx::Device *device, uint32_t phaseID, const ccstd::string &programName) {
|
||||
if (mergeHighFrequency) {
|
||||
CC_EXPECTS(phaseID != LayoutGraphData::null_vertex());
|
||||
const auto passID = parent(phaseID, layoutGraph);
|
||||
@@ -948,44 +1383,61 @@ const gfx::DescriptorSetLayout &NativeProgramLibrary::getMaterialDescriptorSetLa
|
||||
}
|
||||
|
||||
const gfx::DescriptorSetLayout &NativeProgramLibrary::getLocalDescriptorSetLayout(
|
||||
gfx::Device *device, uint32_t phaseID, const ccstd::pmr::string &programName) {
|
||||
gfx::Device *device, uint32_t phaseID, const ccstd::string &programName) {
|
||||
if (mergeHighFrequency) {
|
||||
CC_EXPECTS(phaseID != LayoutGraphData::null_vertex());
|
||||
const auto passID = parent(phaseID, layoutGraph);
|
||||
return getOrCreateDescriptorSetLayout(
|
||||
*this, layoutGraph, passID, phaseID, UpdateFrequency::PER_INSTANCE);
|
||||
}
|
||||
if (fixedLocal) {
|
||||
return *localDescriptorSetLayout;
|
||||
}
|
||||
return getOrCreateProgramDescriptorSetLayout(
|
||||
*this, device, layoutGraph, phaseID, programName, UpdateFrequency::PER_INSTANCE);
|
||||
}
|
||||
|
||||
const IProgramInfo &NativeProgramLibrary::getProgramInfo(
|
||||
uint32_t phaseID, const ccstd::pmr::string &programName) const {
|
||||
uint32_t phaseID, const ccstd::string &programName) const {
|
||||
const auto &group = phases.at(phaseID);
|
||||
return group.programInfos.at(programName).programInfo;
|
||||
auto iter = group.programInfos.find(std::string_view{programName});
|
||||
if (iter != group.programInfos.end()) {
|
||||
return iter->second.programInfo;
|
||||
}
|
||||
throw std::invalid_argument("program not found");
|
||||
}
|
||||
|
||||
const gfx::ShaderInfo &NativeProgramLibrary::getShaderInfo(
|
||||
uint32_t phaseID, const ccstd::pmr::string &programName) const {
|
||||
uint32_t phaseID, const ccstd::string &programName) const {
|
||||
const auto &group = phases.at(phaseID);
|
||||
return group.programInfos.at(programName).shaderInfo;
|
||||
auto iter = group.programInfos.find(std::string_view{programName});
|
||||
if (iter != group.programInfos.end()) {
|
||||
return iter->second.shaderInfo;
|
||||
}
|
||||
throw std::invalid_argument("program not found");
|
||||
}
|
||||
|
||||
ProgramProxy *NativeProgramLibrary::getProgramVariant(
|
||||
gfx::Device *device, uint32_t phaseID, const ccstd::string &name,
|
||||
const MacroRecord &defines, const ccstd::pmr::string *key0) const {
|
||||
MacroRecord &defines, const ccstd::pmr::string *key0) {
|
||||
if (pipeline) {
|
||||
for (const auto &it : pipeline->getMacros()) {
|
||||
defines[it.first] = it.second;
|
||||
}
|
||||
}
|
||||
|
||||
auto iter = phases.find(phaseID);
|
||||
if (iter == phases.end()) {
|
||||
CC_LOG_ERROR("phase not found");
|
||||
return nullptr;
|
||||
}
|
||||
const auto &phase = iter->second;
|
||||
auto &phase = iter->second;
|
||||
auto iter2 = phase.programInfos.find(std::string_view{name});
|
||||
if (iter2 == phase.programInfos.end()) {
|
||||
CC_LOG_ERROR("program not found");
|
||||
return nullptr;
|
||||
}
|
||||
const auto &info = iter2->second;
|
||||
auto &info = iter2->second;
|
||||
|
||||
const auto &programInfo = info.programInfo;
|
||||
|
||||
@@ -999,48 +1451,92 @@ ProgramProxy *NativeProgramLibrary::getProgramVariant(
|
||||
key = *key0;
|
||||
}
|
||||
|
||||
auto iter3 = phase.programHosts.find(key);
|
||||
if (iter3 != phase.programHosts.end()) {
|
||||
return new NativeProgramProxy(iter3->second.program);
|
||||
auto iter3 = phase.programProxies.find(key);
|
||||
if (iter3 != phase.programProxies.end()) {
|
||||
return iter3->second.get();
|
||||
}
|
||||
|
||||
std::ignore = device;
|
||||
std::ignore = phaseID;
|
||||
std::ignore = name;
|
||||
std::ignore = defines;
|
||||
std::ignore = key;
|
||||
return nullptr;
|
||||
// prepare defines
|
||||
ccstd::vector<IMacroInfo> macroArray = render::prepareDefines(defines, programInfo.defines);
|
||||
std::stringstream ss;
|
||||
ss << std::endl;
|
||||
for (const auto &m : macroArray) {
|
||||
ss << "#define " << m.name << " " << m.value << std::endl;
|
||||
}
|
||||
|
||||
std::string prefix;
|
||||
prefix += layoutGraph.constantMacros;
|
||||
prefix += programInfo.constantMacros + ss.str();
|
||||
|
||||
const IShaderSource *src = &programInfo.glsl3;
|
||||
const auto *deviceShaderVersion = getDeviceShaderVersion(device);
|
||||
if (deviceShaderVersion) {
|
||||
src = programInfo.getSource(deviceShaderVersion);
|
||||
} else {
|
||||
CC_LOG_ERROR("Invalid GFX API!");
|
||||
}
|
||||
info.shaderInfo.stages[0].source = prefix + src->vert;
|
||||
info.shaderInfo.stages[1].source = prefix + src->frag;
|
||||
|
||||
// strip out the active attributes only, instancing depend on this
|
||||
info.shaderInfo.attributes = getActiveAttributes(programInfo, info.attributes, defines);
|
||||
|
||||
info.shaderInfo.name = getShaderInstanceName(name, macroArray);
|
||||
|
||||
IntrusivePtr<gfx::Shader> shader = device->createShader(info.shaderInfo);
|
||||
auto res = phase.programProxies.emplace(
|
||||
key,
|
||||
IntrusivePtr<ProgramProxy>(new NativeProgramProxy(std::move(shader))));
|
||||
CC_ENSURES(res.second);
|
||||
|
||||
return res.first->second.get();
|
||||
}
|
||||
|
||||
const ccstd::pmr::vector<unsigned> &NativeProgramLibrary::getBlockSizes(
|
||||
uint32_t phaseID, const ccstd::pmr::string &programName) const {
|
||||
std::ignore = phaseID;
|
||||
std::ignore = programName;
|
||||
throw std::runtime_error("not implemented");
|
||||
const ccstd::vector<int32_t> &NativeProgramLibrary::getBlockSizes(
|
||||
uint32_t phaseID, const ccstd::string &programName) const {
|
||||
CC_EXPECTS(phaseID != LayoutGraphData::null_vertex());
|
||||
const auto &group = phases.at(phaseID);
|
||||
auto iter = group.programInfos.find(std::string_view{programName});
|
||||
if (iter != group.programInfos.end()) {
|
||||
return iter->second.blockSizes;
|
||||
}
|
||||
throw std::invalid_argument("program not found");
|
||||
}
|
||||
|
||||
const Record<ccstd::string, uint32_t> &NativeProgramLibrary::getHandleMap(
|
||||
uint32_t phaseID, const ccstd::pmr::string &programName) const {
|
||||
std::ignore = phaseID;
|
||||
std::ignore = programName;
|
||||
throw std::runtime_error("not implemented");
|
||||
uint32_t phaseID, const ccstd::string &programName) const {
|
||||
CC_EXPECTS(phaseID != LayoutGraphData::null_vertex());
|
||||
const auto &group = phases.at(phaseID);
|
||||
auto iter = group.programInfos.find(std::string_view{programName});
|
||||
if (iter != group.programInfos.end()) {
|
||||
return iter->second.handleMap;
|
||||
}
|
||||
throw std::invalid_argument("program not found");
|
||||
}
|
||||
|
||||
uint32_t NativeProgramLibrary::getProgramID(
|
||||
uint32_t phaseID, const ccstd::pmr::string &programName) {
|
||||
std::ignore = phaseID;
|
||||
std::ignore = programName;
|
||||
throw std::runtime_error("not implemented");
|
||||
CC_EXPECTS(phaseID != LayoutGraphData::null_vertex());
|
||||
const auto &phase = get(RenderPhaseTag{}, phaseID, layoutGraph);
|
||||
auto iter = phase.shaderIndex.find(programName);
|
||||
if (iter == phase.shaderIndex.end()) {
|
||||
CC_LOG_ERROR("program not found");
|
||||
return LayoutGraphData::null_vertex();
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
uint32_t NativeProgramLibrary::getDescriptorNameID(const ccstd::pmr::string &name) {
|
||||
std::ignore = name;
|
||||
return 0xFFFFFFFF;
|
||||
const auto iter = layoutGraph.attributeIndex.find(name);
|
||||
if (iter == layoutGraph.attributeIndex.end()) {
|
||||
CC_LOG_ERROR("descriptor name not found");
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
return iter->second.value;
|
||||
}
|
||||
|
||||
const ccstd::pmr::string &NativeProgramLibrary::getDescriptorName(uint32_t nameID) {
|
||||
std::ignore = nameID;
|
||||
throw std::runtime_error("not implemented");
|
||||
return layoutGraph.valueNames.at(static_cast<size_t>(nameID));
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -28,18 +28,229 @@
|
||||
#include "NativePipelineGraphs.h"
|
||||
#include "NativePipelineTypes.h"
|
||||
#include "RenderCommonNames.h"
|
||||
#include "RenderCommonTypes.h"
|
||||
#include "RenderGraphFwd.h"
|
||||
#include "RenderGraphGraphs.h"
|
||||
#include "RenderGraphTypes.h"
|
||||
#include "cocos/math/Utils.h"
|
||||
#include "cocos/renderer/pipeline/Define.h"
|
||||
#include "cocos/renderer/pipeline/PipelineUBO.h"
|
||||
#include "cocos/scene/DirectionalLight.h"
|
||||
#include "cocos/scene/Fog.h"
|
||||
#include "cocos/scene/Skybox.h"
|
||||
#include "cocos/scene/SpotLight.h"
|
||||
#include "details/DebugUtils.h"
|
||||
#include "details/GraphView.h"
|
||||
#include "details/GslUtils.h"
|
||||
#include "gfx-base/GFXDef-common.h"
|
||||
#include "pipeline/custom/RenderCommonTypes.h"
|
||||
#include "pipeline/custom/RenderGraphFwd.h"
|
||||
#include "pipeline/custom/RenderGraphTypes.h"
|
||||
#include "gfx-base/GFXDevice.h"
|
||||
#include "pipeline/PipelineSceneData.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
namespace render {
|
||||
|
||||
namespace {
|
||||
|
||||
render::NameLocalID getNameID(
|
||||
const PmrFlatMap<ccstd::pmr::string, render::NameLocalID> &index,
|
||||
std::string_view name) {
|
||||
auto iter = index.find(name);
|
||||
CC_EXPECTS(iter != index.end());
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
void addMat4(
|
||||
const LayoutGraphData &lg, std::string_view name,
|
||||
const cc::Mat4 &v, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Mat4) == 16 * 4, "sizeof(Mat4) is not 64 bytes");
|
||||
data.constants[nameID.value].resize(sizeof(Mat4));
|
||||
memcpy(data.constants[nameID.value].data(), v.m, sizeof(v));
|
||||
}
|
||||
|
||||
void setMat4ArrayElemImpl(
|
||||
const LayoutGraphData &lg, std::string_view name,
|
||||
const cc::Mat4 &v, uint32_t i, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Mat4) == 16 * 4, "sizeof(Mat4) is not 64 bytes");
|
||||
auto &dst = data.constants[nameID.value];
|
||||
CC_EXPECTS(sizeof(Mat4) * (i + 1) <= dst.size());
|
||||
memcpy(dst.data() + sizeof(Mat4) * i, v.m, sizeof(v));
|
||||
}
|
||||
|
||||
void setMat4ArraySizeImpl(
|
||||
const LayoutGraphData &lg, std::string_view name,
|
||||
uint32_t sz, RenderData &data) {
|
||||
CC_EXPECTS(sz);
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Mat4) == 16 * 4, "sizeof(Mat4) is not 64 bytes");
|
||||
data.constants[nameID.value].resize(sizeof(Mat4) * sz);
|
||||
}
|
||||
|
||||
void addQuaternion(const LayoutGraphData &lg, const ccstd::string &name, const Quaternion &quat, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Quaternion) == 4 * 4, "sizeof(Quaternion) is not 16 bytes");
|
||||
static_assert(std::is_trivially_copyable<Quaternion>::value, "Quaternion is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(Quaternion));
|
||||
memcpy(data.constants[nameID.value].data(), &quat, sizeof(quat));
|
||||
}
|
||||
|
||||
void addColor(const LayoutGraphData &lg, const ccstd::string &name, const gfx::Color &color, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(gfx::Color) == 4 * 4, "sizeof(Color) is not 16 bytes");
|
||||
static_assert(std::is_trivially_copyable<gfx::Color>::value, "Color is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(gfx::Color));
|
||||
memcpy(data.constants[nameID.value].data(), &color, sizeof(color));
|
||||
}
|
||||
|
||||
void addVec4(const LayoutGraphData &lg, const ccstd::string &name, const Vec4 &vec, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Vec4) == 4 * 4, "sizeof(Vec4) is not 16 bytes");
|
||||
// static_assert(std::is_trivially_copyable<Vec4>::value, "Vec4 is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(Vec4));
|
||||
memcpy(data.constants[nameID.value].data(), &vec.x, sizeof(vec));
|
||||
}
|
||||
|
||||
void setVec4ArrayElemImpl(const LayoutGraphData &lg, const ccstd::string &name,
|
||||
const Vec4 &vec, uint32_t i, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Vec4) == 4 * 4, "sizeof(Vec4) is not 16 bytes");
|
||||
// static_assert(std::is_trivially_copyable<Vec4>::value, "Vec4 is not trivially copyable");
|
||||
auto &dst = data.constants[nameID.value];
|
||||
CC_EXPECTS(sizeof(Vec4) * (i + 1) <= dst.size());
|
||||
memcpy(dst.data() + sizeof(Vec4) * i, &vec.x, sizeof(vec));
|
||||
}
|
||||
|
||||
void setVec4ArraySizeImpl(const LayoutGraphData &lg, const ccstd::string &name,
|
||||
uint32_t sz, RenderData &data) {
|
||||
CC_EXPECTS(sz);
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Vec4) == 4 * 4, "sizeof(Vec4) is not 16 bytes");
|
||||
// static_assert(std::is_trivially_copyable<Vec4>::value, "Vec4 is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(Vec4) * sz);
|
||||
}
|
||||
|
||||
void addVec2(const LayoutGraphData &lg, const ccstd::string &name, const Vec2 &vec, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Vec2) == 2 * 4, "sizeof(Vec2) is not 8 bytes");
|
||||
// static_assert(std::is_trivially_copyable<Vec4>::value, "Vec2 is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(Vec2));
|
||||
memcpy(data.constants[nameID.value].data(), &vec.x, sizeof(vec));
|
||||
}
|
||||
|
||||
void addFloat(const LayoutGraphData &lg, const ccstd::string &name, float v, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(float) == 4, "sizeof(float) is not 4 bytes");
|
||||
data.constants[nameID.value].resize(sizeof(float));
|
||||
memcpy(data.constants[nameID.value].data(), &v, sizeof(v));
|
||||
}
|
||||
|
||||
void addBuffer(const LayoutGraphData &lg, const ccstd::string &name, gfx::Buffer *buffer, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.buffers[nameID.value] = IntrusivePtr<gfx::Buffer>(buffer);
|
||||
}
|
||||
|
||||
void addTexture(const LayoutGraphData &lg, const ccstd::string &name, gfx::Texture *texture, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.textures[nameID.value] = IntrusivePtr<gfx::Texture>(texture);
|
||||
}
|
||||
|
||||
void addReadWriteBuffer(const LayoutGraphData &lg, const ccstd::string &name, gfx::Buffer *buffer, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.buffers[nameID.value] = IntrusivePtr<gfx::Buffer>(buffer);
|
||||
}
|
||||
|
||||
void addReadWriteTexture(const LayoutGraphData &lg, const ccstd::string &name, gfx::Texture *texture, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.textures[nameID.value] = IntrusivePtr<gfx::Texture>(texture);
|
||||
}
|
||||
|
||||
void addSampler(const LayoutGraphData &lg, const ccstd::string &name, gfx::Sampler *sampler, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.samplers[nameID.value].ptr = sampler;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ccstd::string NativeSetter::getName() const {
|
||||
return {};
|
||||
}
|
||||
void NativeSetter::setName(const ccstd::string &name) {
|
||||
// noop
|
||||
}
|
||||
|
||||
void NativeSetter::setMat4(const ccstd::string &name, const Mat4 &mat) {
|
||||
auto &data = renderData;
|
||||
addMat4(layoutGraph, name, mat, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setQuaternion(const ccstd::string &name, const Quaternion &quat) {
|
||||
auto &data = renderData;
|
||||
addQuaternion(layoutGraph, name, quat, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setColor(const ccstd::string &name, const gfx::Color &color) {
|
||||
auto &data = renderData;
|
||||
addColor(layoutGraph, name, color, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setVec4(const ccstd::string &name, const Vec4 &vec) {
|
||||
auto &data = renderData;
|
||||
addVec4(layoutGraph, name, vec, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setVec2(const ccstd::string &name, const Vec2 &vec) {
|
||||
auto &data = renderData;
|
||||
addVec2(layoutGraph, name, vec, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setFloat(const ccstd::string &name, float v) {
|
||||
auto &data = renderData;
|
||||
addFloat(layoutGraph, name, v, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setBuffer(const ccstd::string &name, gfx::Buffer *buffer) {
|
||||
auto &data = renderData;
|
||||
addBuffer(layoutGraph, name, buffer, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setTexture(const ccstd::string &name, gfx::Texture *texture) {
|
||||
auto &data = renderData;
|
||||
addTexture(layoutGraph, name, texture, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setReadWriteBuffer(const ccstd::string &name, gfx::Buffer *buffer) {
|
||||
auto &data = renderData;
|
||||
addReadWriteBuffer(layoutGraph, name, buffer, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setReadWriteTexture(const ccstd::string &name, gfx::Texture *texture) {
|
||||
auto &data = renderData;
|
||||
addReadWriteTexture(layoutGraph, name, texture, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setSampler(const ccstd::string &name, gfx::Sampler *sampler) {
|
||||
auto &data = renderData;
|
||||
addSampler(layoutGraph, name, sampler, data);
|
||||
}
|
||||
|
||||
void NativeSetter::setVec4ArraySize(const ccstd::string &name, uint32_t sz) {
|
||||
setVec4ArraySizeImpl(layoutGraph, name, sz, renderData);
|
||||
}
|
||||
|
||||
void NativeSetter::setVec4ArrayElem(const ccstd::string &name, const cc::Vec4 &vec, uint32_t id) {
|
||||
setVec4ArrayElemImpl(layoutGraph, name, vec, id, renderData);
|
||||
}
|
||||
|
||||
void NativeSetter::setMat4ArraySize(const ccstd::string &name, uint32_t sz) {
|
||||
setMat4ArraySizeImpl(layoutGraph, name, sz, renderData);
|
||||
}
|
||||
|
||||
void NativeSetter::setMat4ArrayElem(const ccstd::string &name, const cc::Mat4 &mat, uint32_t id) {
|
||||
setMat4ArrayElemImpl(layoutGraph, name, mat, id, renderData);
|
||||
}
|
||||
|
||||
ccstd::string NativeRasterPassBuilder::getName() const {
|
||||
return std::string(get(RenderGraph::Name, *renderGraph, passID));
|
||||
}
|
||||
@@ -50,13 +261,18 @@ void NativeRasterPassBuilder::setName(const ccstd::string &name) {
|
||||
|
||||
void NativeRasterPassBuilder::addRasterView(const ccstd::string &name, const RasterView &view) {
|
||||
auto &pass = get(RasterTag{}, passID, *renderGraph);
|
||||
pass.rasterViews.emplace(
|
||||
auto slotID = static_cast<uint32_t>(pass.rasterViews.size());
|
||||
auto res = pass.rasterViews.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(name.c_str()),
|
||||
std::forward_as_tuple(view));
|
||||
CC_ENSURES(res.second);
|
||||
res.first->second.slotID = slotID;
|
||||
}
|
||||
|
||||
void NativeRasterPassBuilder::addComputeView(const ccstd::string &name, const ComputeView &view) {
|
||||
CC_EXPECTS(!name.empty());
|
||||
CC_EXPECTS(!view.name.empty());
|
||||
auto &pass = get(RasterTag{}, passID, *renderGraph);
|
||||
auto iter = pass.computeViews.find(name.c_str());
|
||||
if (iter == pass.computeViews.end()) {
|
||||
@@ -70,6 +286,16 @@ void NativeRasterPassBuilder::addComputeView(const ccstd::string &name, const Co
|
||||
iter->second.emplace_back(view);
|
||||
}
|
||||
|
||||
bool NativeRasterPassBuilder::getShowStatistics() const {
|
||||
const auto &pass = get(RasterTag{}, passID, *renderGraph);
|
||||
return pass.showStatistics;
|
||||
}
|
||||
|
||||
void NativeRasterPassBuilder::setShowStatistics(bool enable) {
|
||||
auto &pass = get(RasterTag{}, passID, *renderGraph);
|
||||
pass.showStatistics = enable;
|
||||
}
|
||||
|
||||
ccstd::string NativeRasterQueueBuilder::getName() const {
|
||||
return std::string(get(RenderGraph::Name, *renderGraph, queueID));
|
||||
}
|
||||
@@ -78,13 +304,397 @@ void NativeRasterQueueBuilder::setName(const ccstd::string &name) {
|
||||
get(RenderGraph::Name, *renderGraph, queueID) = std::string_view{name};
|
||||
}
|
||||
|
||||
void NativeRasterQueueBuilder::addSceneOfCamera(scene::Camera *camera, LightInfo light, SceneFlags sceneFlags) {
|
||||
namespace {
|
||||
|
||||
uint8_t getCombineSignY(gfx::Device *device) {
|
||||
// 0: vk, 1: metal, 2: none, 3: gl-like
|
||||
static int8_t combineSignY{-1};
|
||||
if (combineSignY < 0) {
|
||||
const float screenSpaceSignY = device->getCapabilities().screenSpaceSignY * 0.5F + 0.5F;
|
||||
const float clipSpaceSignY = device->getCapabilities().clipSpaceSignY * 0.5F + 0.5F;
|
||||
combineSignY = static_cast<int8_t>(screenSpaceSignY) << 1 | static_cast<int8_t>(clipSpaceSignY);
|
||||
}
|
||||
return static_cast<uint8_t>(combineSignY);
|
||||
}
|
||||
|
||||
void setCameraUBOValues(
|
||||
const scene::Camera &camera,
|
||||
const pipeline::PipelineSceneData &cfg,
|
||||
const scene::DirectionalLight *mainLight,
|
||||
Setter &setter) {
|
||||
CC_EXPECTS(camera.getNode());
|
||||
CC_EXPECTS(cfg.getSkybox());
|
||||
const auto &skybox = *cfg.getSkybox();
|
||||
const auto &shadingScale = cfg.getShadingScale();
|
||||
// Camera
|
||||
setter.setMat4("cc_matView", camera.getMatView());
|
||||
setter.setMat4("cc_matViewInv", camera.getNode()->getWorldMatrix());
|
||||
setter.setMat4("cc_matProj", camera.getMatProj());
|
||||
setter.setMat4("cc_matProjInv", camera.getMatProjInv());
|
||||
setter.setMat4("cc_matViewProj", camera.getMatViewProj());
|
||||
setter.setMat4("cc_matViewProjInv", camera.getMatViewProjInv());
|
||||
setter.setVec4("cc_cameraPos", Vec4(camera.getPosition().x,
|
||||
camera.getPosition().y,
|
||||
camera.getPosition().z,
|
||||
getCombineSignY(cc::gfx::Device::getInstance())));
|
||||
setter.setVec4("cc_surfaceTransform", Vec4(static_cast<float>(camera.getSurfaceTransform()),
|
||||
0.0F,
|
||||
cosf(static_cast<float>(mathutils::toRadian(skybox.getRotationAngle()))),
|
||||
sinf(static_cast<float>(mathutils::toRadian(skybox.getRotationAngle())))));
|
||||
setter.setVec4("cc_screenScale", Vec4(cfg.getShadingScale(),
|
||||
cfg.getShadingScale(),
|
||||
1.0F / cfg.getShadingScale(),
|
||||
1.0F / cfg.getShadingScale()));
|
||||
setter.setVec4("cc_exposure", Vec4(camera.getExposure(),
|
||||
1.0F / camera.getExposure(),
|
||||
cfg.isHDR() ? 1.0F : 0.0F,
|
||||
1.0F / scene::Camera::getStandardExposureValue()));
|
||||
|
||||
if (mainLight) {
|
||||
const auto &shadowInfo = *cfg.getShadows();
|
||||
const bool shadowEnable = (mainLight->isShadowEnabled() &&
|
||||
shadowInfo.getType() == scene::ShadowType::SHADOW_MAP);
|
||||
setter.setVec4("cc_mainLitDir", Vec4(mainLight->getDirection().x,
|
||||
mainLight->getDirection().y,
|
||||
mainLight->getDirection().z,
|
||||
shadowEnable));
|
||||
auto r = mainLight->getColor().x;
|
||||
auto g = mainLight->getColor().y;
|
||||
auto b = mainLight->getColor().z;
|
||||
if (mainLight->isUseColorTemperature()) {
|
||||
r *= mainLight->getColorTemperatureRGB().x;
|
||||
g *= mainLight->getColorTemperatureRGB().y;
|
||||
b *= mainLight->getColorTemperatureRGB().z;
|
||||
}
|
||||
auto w = mainLight->getIlluminance();
|
||||
if (cfg.isHDR()) {
|
||||
w *= camera.getExposure();
|
||||
}
|
||||
setter.setVec4("cc_mainLitColor", Vec4(r, g, b, w));
|
||||
} else {
|
||||
setter.setVec4("cc_mainLitDir", Vec4(0, 0, 1, 0));
|
||||
setter.setVec4("cc_mainLitColor", Vec4(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
CC_EXPECTS(cfg.getAmbient());
|
||||
auto &ambient = *cfg.getAmbient();
|
||||
auto &skyColor = ambient.getSkyColor();
|
||||
if (cfg.isHDR()) {
|
||||
skyColor.w = ambient.getSkyIllum() * camera.getExposure();
|
||||
} else {
|
||||
skyColor.w = ambient.getSkyIllum();
|
||||
}
|
||||
setter.setVec4("cc_ambientSky", Vec4(skyColor.x, skyColor.y, skyColor.z, skyColor.w));
|
||||
setter.setVec4("cc_ambientGround", Vec4(ambient.getGroundAlbedo().x,
|
||||
ambient.getGroundAlbedo().y,
|
||||
ambient.getGroundAlbedo().z,
|
||||
skybox.getEnvmap()
|
||||
? static_cast<float>(skybox.getEnvmap()->mipmapLevel())
|
||||
: 1.0F));
|
||||
|
||||
CC_EXPECTS(cfg.getFog());
|
||||
const auto &fog = *cfg.getFog();
|
||||
|
||||
const auto &colorTempRGB = fog.getColorArray();
|
||||
setter.setVec4("cc_fogColor", Vec4(colorTempRGB.x, colorTempRGB.y, colorTempRGB.z, colorTempRGB.z));
|
||||
setter.setVec4("cc_fogBase", Vec4(fog.getFogStart(), fog.getFogEnd(), fog.getFogDensity(), 0.0F));
|
||||
setter.setVec4("cc_fogAdd", Vec4(fog.getFogTop(), fog.getFogRange(), fog.getFogAtten(), 0.0F));
|
||||
setter.setVec4("cc_nearFar", Vec4(camera.getNearClip(), camera.getFarClip(), 0.0F, 0.0F));
|
||||
setter.setVec4("cc_viewPort", Vec4(camera.getViewport().x,
|
||||
camera.getViewport().y,
|
||||
shadingScale * static_cast<float>(camera.getWindow()->getWidth()) * camera.getViewport().z,
|
||||
shadingScale * static_cast<float>(camera.getWindow()->getHeight()) * camera.getViewport().w));
|
||||
}
|
||||
|
||||
void setShadowUBOLightView(
|
||||
gfx::Device *device,
|
||||
const pipeline::PipelineSceneData &sceneData,
|
||||
const scene::Light &light,
|
||||
uint32_t level, Setter &setter) {
|
||||
const auto &shadowInfo = *sceneData.getShadows();
|
||||
const auto &csmLayers = *sceneData.getCSMLayers();
|
||||
const auto &packing = pipeline::supportsR32FloatTexture(device) ? 0.0F : 1.0F;
|
||||
const auto &cap = device->getCapabilities();
|
||||
Vec4 vec4ShadowInfo{};
|
||||
|
||||
// ShadowMap
|
||||
switch (light.getType()) {
|
||||
case scene::LightType::DIRECTIONAL: {
|
||||
const auto &mainLight = dynamic_cast<const scene::DirectionalLight &>(light);
|
||||
if (shadowInfo.isEnabled() && mainLight.isShadowEnabled()) {
|
||||
if (shadowInfo.getType() == scene::ShadowType::SHADOW_MAP) {
|
||||
float near = 0.1;
|
||||
float far = 0;
|
||||
Mat4 matShadowView;
|
||||
Mat4 matShadowProj;
|
||||
Mat4 matShadowViewProj;
|
||||
scene::CSMLevel levelCount{};
|
||||
if (mainLight.isShadowFixedArea() || mainLight.getCSMLevel() == scene::CSMLevel::LEVEL_1) {
|
||||
matShadowView = csmLayers.getSpecialLayer()->getMatShadowView();
|
||||
matShadowProj = csmLayers.getSpecialLayer()->getMatShadowProj();
|
||||
matShadowViewProj = csmLayers.getSpecialLayer()->getMatShadowViewProj();
|
||||
if (mainLight.isShadowFixedArea()) {
|
||||
near = mainLight.getShadowNear();
|
||||
far = mainLight.getShadowFar();
|
||||
levelCount = static_cast<scene::CSMLevel>(0);
|
||||
} else {
|
||||
near = 0.1;
|
||||
far = csmLayers.getSpecialLayer()->getShadowCameraFar();
|
||||
levelCount = scene::CSMLevel::LEVEL_1;
|
||||
}
|
||||
vec4ShadowInfo.set(0.0F, packing, mainLight.getShadowNormalBias(), 0);
|
||||
setter.setVec4("cc_shadowLPNNInfo", vec4ShadowInfo);
|
||||
} else {
|
||||
const auto &layer = *csmLayers.getLayers()[level];
|
||||
matShadowView = layer.getMatShadowView();
|
||||
matShadowProj = layer.getMatShadowProj();
|
||||
matShadowViewProj = layer.getMatShadowViewProj();
|
||||
|
||||
near = layer.getSplitCameraNear();
|
||||
far = layer.getSplitCameraFar();
|
||||
levelCount = mainLight.getCSMLevel();
|
||||
}
|
||||
setter.setMat4("cc_matLightView", matShadowView);
|
||||
setter.setVec4("cc_shadowProjDepthInfo", Vec4(matShadowProj.m[10], matShadowProj.m[14],
|
||||
matShadowProj.m[11], matShadowProj.m[15]));
|
||||
setter.setVec4("cc_shadowProjInfo", Vec4(matShadowProj.m[00], matShadowProj.m[05],
|
||||
1.0F / matShadowProj.m[00], 1.0F / matShadowProj.m[05]));
|
||||
setter.setMat4("cc_matLightViewProj", matShadowViewProj);
|
||||
vec4ShadowInfo.set(near, far, 0, 1.0F - mainLight.getShadowSaturation());
|
||||
setter.setVec4("cc_shadowNFLSInfo", vec4ShadowInfo);
|
||||
vec4ShadowInfo.set(0.0F, packing, mainLight.getShadowNormalBias(), static_cast<float>(levelCount));
|
||||
setter.setVec4("cc_shadowLPNNInfo", vec4ShadowInfo);
|
||||
vec4ShadowInfo.set(shadowInfo.getSize().x, shadowInfo.getSize().y, static_cast<float>(mainLight.getShadowPcf()), mainLight.getShadowBias());
|
||||
setter.setVec4("cc_shadowWHPBInfo", vec4ShadowInfo);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case scene::LightType::SPOT: {
|
||||
const auto &spotLight = dynamic_cast<const scene::SpotLight &>(light);
|
||||
if (shadowInfo.isEnabled() && spotLight.isShadowEnabled()) {
|
||||
const auto &matShadowCamera = spotLight.getNode()->getWorldMatrix();
|
||||
const auto matShadowView = matShadowCamera.getInversed();
|
||||
setter.setMat4("cc_matLightView", matShadowView);
|
||||
|
||||
Mat4 matShadowViewProj{};
|
||||
Mat4::createPerspective(spotLight.getAngle(), 1.0F, 0.001F,
|
||||
spotLight.getRange(), true,
|
||||
cap.clipSpaceMinZ, cap.clipSpaceSignY, 0, &matShadowViewProj);
|
||||
matShadowViewProj.multiply(matShadowView);
|
||||
setter.setMat4("cc_matLightViewProj", matShadowViewProj);
|
||||
|
||||
const Vec4 shadowNFLSInfos(0.01F, spotLight.getRange(), 0.0F, 0.0F);
|
||||
setter.setVec4("cc_shadowNFLSInfo", shadowNFLSInfos);
|
||||
|
||||
const Vec4 shadowWHPBInfos(
|
||||
shadowInfo.getSize().x,
|
||||
shadowInfo.getSize().y,
|
||||
spotLight.getShadowPcf(),
|
||||
spotLight.getShadowBias());
|
||||
setter.setVec4("cc_shadowWHPBInfo", shadowWHPBInfos);
|
||||
|
||||
const Vec4 shadowLPNNInfos(1.0F, packing, spotLight.getShadowNormalBias(), 0.0F);
|
||||
setter.setVec4("cc_shadowLPNNInfo", shadowLPNNInfos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const auto &data = shadowInfo.getShadowColor4f();
|
||||
setter.setColor("cc_shadowColor", gfx::Color{data[0], data[1], data[2], data[3]});
|
||||
}
|
||||
|
||||
float getPCFRadius(
|
||||
const scene::Shadows &shadowInfo,
|
||||
const scene::DirectionalLight &mainLight) {
|
||||
const auto &shadowMapSize = shadowInfo.getSize().x;
|
||||
switch (mainLight.getShadowPcf()) {
|
||||
case scene::PCFType::HARD:
|
||||
return 0.0F;
|
||||
case scene::PCFType::SOFT:
|
||||
return 1.0F / (shadowMapSize * 0.5F);
|
||||
case scene::PCFType::SOFT_2X:
|
||||
return 2.0F / (shadowMapSize * 0.5F);
|
||||
// case PCFType.SOFT_4X:
|
||||
// return 3.0F / (shadowMapSize * 0.5F);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
void setShadowUBOView(
|
||||
gfx::Device &device,
|
||||
const pipeline::PipelineSceneData &sceneData,
|
||||
const scene::DirectionalLight &mainLight,
|
||||
NativeSetter &setter) {
|
||||
const auto &shadowInfo = *sceneData.getShadows();
|
||||
const auto &csmLayers = *sceneData.getCSMLayers();
|
||||
const auto &csmSupported = sceneData.getCSMSupported();
|
||||
const auto &packing = pipeline::supportsR32FloatTexture(&device) ? 0.0F : 1.0F;
|
||||
Vec4 vec4ShadowInfo{};
|
||||
if (shadowInfo.isEnabled()) {
|
||||
if (shadowInfo.getType() == scene::ShadowType::SHADOW_MAP) {
|
||||
if (mainLight.isShadowEnabled()) {
|
||||
if (mainLight.isShadowFixedArea() ||
|
||||
mainLight.getCSMLevel() == scene::CSMLevel::LEVEL_1 || !csmSupported) {
|
||||
// Shadow
|
||||
const auto &matShadowView = csmLayers.getSpecialLayer()->getMatShadowView();
|
||||
const auto &matShadowProj = csmLayers.getSpecialLayer()->getMatShadowProj();
|
||||
const auto &matShadowViewProj = csmLayers.getSpecialLayer()->getMatShadowViewProj();
|
||||
const auto &near = mainLight.getShadowNear();
|
||||
const auto &far = mainLight.getShadowFar();
|
||||
|
||||
setter.setMat4("cc_matLightView", matShadowView);
|
||||
setter.setVec4("cc_shadowProjDepthInfo",
|
||||
Vec4(matShadowProj.m[10], matShadowProj.m[14],
|
||||
matShadowProj.m[11], matShadowProj.m[15]));
|
||||
|
||||
setter.setVec4("cc_shadowProjInfo",
|
||||
Vec4(matShadowProj.m[00], matShadowProj.m[05],
|
||||
1.0F / matShadowProj.m[00], 1.0F / matShadowProj.m[05]));
|
||||
setter.setMat4("cc_matLightViewProj", matShadowViewProj);
|
||||
vec4ShadowInfo.set(near, far, 0, 1.0F - mainLight.getShadowSaturation());
|
||||
setter.setVec4("cc_shadowNFLSInfo", vec4ShadowInfo);
|
||||
vec4ShadowInfo.set(0.0F, packing, mainLight.getShadowNormalBias(), 0);
|
||||
setter.setVec4("cc_shadowLPNNInfo", vec4ShadowInfo);
|
||||
} else {
|
||||
{ // CSM
|
||||
const auto layerThreshold = getPCFRadius(shadowInfo, mainLight);
|
||||
const auto numCascades = static_cast<uint32_t>(mainLight.getCSMLevel());
|
||||
setter.setVec4ArraySize("cc_csmViewDir0", numCascades);
|
||||
setter.setVec4ArraySize("cc_csmViewDir1", numCascades);
|
||||
setter.setVec4ArraySize("cc_csmViewDir2", numCascades);
|
||||
setter.setVec4ArraySize("cc_csmAtlas", numCascades);
|
||||
setter.setMat4ArraySize("cc_matCSMViewProj", numCascades);
|
||||
setter.setVec4ArraySize("cc_csmProjDepthInfo", numCascades);
|
||||
setter.setVec4ArraySize("cc_csmProjInfo", numCascades);
|
||||
|
||||
Vec4 csmSplitsInfo{};
|
||||
for (uint32_t i = 0; i < numCascades; ++i) {
|
||||
const auto &layer = *csmLayers.getLayers()[i];
|
||||
|
||||
const auto &matShadowView = layer.getMatShadowView();
|
||||
vec4ShadowInfo.set(matShadowView.m[0], matShadowView.m[4], matShadowView.m[8], layerThreshold);
|
||||
setter.setVec4ArrayElem("cc_csmViewDir0", vec4ShadowInfo, i);
|
||||
vec4ShadowInfo.set(matShadowView.m[1], matShadowView.m[5], matShadowView.m[9], 0.0F);
|
||||
setter.setVec4ArrayElem("cc_csmViewDir1", vec4ShadowInfo, i);
|
||||
vec4ShadowInfo.set(matShadowView.m[2], matShadowView.m[6], matShadowView.m[0], 0.0F);
|
||||
setter.setVec4ArrayElem("cc_csmViewDir2", vec4ShadowInfo, i);
|
||||
|
||||
const auto &csmAtlas = layer.getCSMAtlas();
|
||||
setter.setVec4ArrayElem("cc_csmAtlas", csmAtlas, i);
|
||||
|
||||
const auto &matShadowViewProj = layer.getMatShadowViewProj();
|
||||
setter.setMat4ArrayElem("cc_matCSMViewProj", matShadowViewProj, i);
|
||||
|
||||
const auto &matShadowProj = layer.getMatShadowProj();
|
||||
setter.setVec4ArrayElem(
|
||||
"cc_csmProjDepthInfo",
|
||||
Vec4(matShadowProj.m[10], matShadowProj.m[14],
|
||||
matShadowProj.m[11], matShadowProj.m[15]),
|
||||
i);
|
||||
|
||||
setter.setVec4ArrayElem(
|
||||
"cc_csmProjInfo",
|
||||
Vec4(matShadowProj.m[00], matShadowProj.m[05],
|
||||
1.0F / matShadowProj.m[00], 1.0F / matShadowProj.m[05]),
|
||||
i);
|
||||
|
||||
(&csmSplitsInfo.x)[i] = layer.getSplitCameraFar() / mainLight.getShadowDistance();
|
||||
}
|
||||
setter.setVec4("cc_csmSplitsInfo", csmSplitsInfo);
|
||||
}
|
||||
{ // Shadow
|
||||
vec4ShadowInfo.set(0, 0, 0, 1.0F - mainLight.getShadowSaturation());
|
||||
setter.setVec4("cc_shadowNFLSInfo", vec4ShadowInfo);
|
||||
vec4ShadowInfo.set(
|
||||
0.0F, packing,
|
||||
mainLight.getShadowNormalBias(),
|
||||
static_cast<float>(mainLight.getCSMLevel()));
|
||||
setter.setVec4("cc_shadowLPNNInfo", vec4ShadowInfo);
|
||||
}
|
||||
}
|
||||
{ // Shadow
|
||||
vec4ShadowInfo.set(
|
||||
shadowInfo.getSize().x, shadowInfo.getSize().y,
|
||||
static_cast<float>(mainLight.getShadowPcf()), mainLight.getShadowBias());
|
||||
setter.setVec4("cc_shadowWHPBInfo", vec4ShadowInfo);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Vec3 tempVec3 = shadowInfo.getNormal().getNormalized();
|
||||
setter.setVec4(
|
||||
"cc_planarNDInfo",
|
||||
Vec4(tempVec3.x, tempVec3.y, tempVec3.z, -shadowInfo.getDistance()));
|
||||
}
|
||||
{
|
||||
const auto &data = shadowInfo.getShadowColor4f();
|
||||
setter.setColor("cc_shadowColor", gfx::Color{data[0], data[1], data[2], data[3]});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setTextureUBOView(
|
||||
gfx::Device &device,
|
||||
const pipeline::PipelineSceneData &sceneData,
|
||||
Setter &setter) {
|
||||
const auto &skybox = *sceneData.getSkybox();
|
||||
if (skybox.getReflectionMap()) {
|
||||
auto &texture = *skybox.getReflectionMap()->getGFXTexture();
|
||||
auto *sampler = device.getSampler(skybox.getReflectionMap()->getSamplerInfo());
|
||||
setter.setTexture("cc_environment", &texture);
|
||||
setter.setSampler("cc_environment", sampler);
|
||||
} else {
|
||||
const auto *envmap =
|
||||
skybox.getEnvmap()
|
||||
? skybox.getEnvmap()
|
||||
: BuiltinResMgr::getInstance()->get<TextureCube>("default-cube-texture");
|
||||
if (envmap) {
|
||||
auto *texture = envmap->getGFXTexture();
|
||||
auto *sampler = device.getSampler(envmap->getSamplerInfo());
|
||||
setter.setTexture("cc_environment", texture);
|
||||
setter.setSampler("cc_environment", sampler);
|
||||
}
|
||||
}
|
||||
const auto *diffuseMap =
|
||||
skybox.getDiffuseMap()
|
||||
? skybox.getDiffuseMap()
|
||||
: BuiltinResMgr::getInstance()->get<TextureCube>("default-cube-texture");
|
||||
if (diffuseMap) {
|
||||
auto *texture = diffuseMap->getGFXTexture();
|
||||
auto *sampler = device.getSampler(diffuseMap->getSamplerInfo());
|
||||
setter.setTexture("cc_diffuseMap", texture);
|
||||
setter.setSampler("cc_diffuseMap", sampler);
|
||||
}
|
||||
gfx::SamplerInfo samplerPointInfo{
|
||||
gfx::Filter::POINT,
|
||||
gfx::Filter::POINT,
|
||||
gfx::Filter::NONE,
|
||||
gfx::Address::CLAMP,
|
||||
gfx::Address::CLAMP,
|
||||
gfx::Address::CLAMP};
|
||||
auto *pointSampler = device.getSampler(samplerPointInfo);
|
||||
setter.setSampler("cc_shadowMap", pointSampler);
|
||||
setter.setTexture("cc_shadowMap", BuiltinResMgr::getInstance()->get<Texture2D>("default-texture")->getGFXTexture());
|
||||
setter.setSampler("cc_spotShadowMap", pointSampler);
|
||||
setter.setTexture("cc_spotShadowMap", BuiltinResMgr::getInstance()->get<Texture2D>("default-texture")->getGFXTexture());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void NativeRasterQueueBuilder::addSceneOfCamera(
|
||||
scene::Camera *camera, LightInfo light, SceneFlags sceneFlags) {
|
||||
std::string_view name = "Camera";
|
||||
auto *pLight = light.light.get();
|
||||
SceneData scene(renderGraph->get_allocator());
|
||||
scene.name = name;
|
||||
scene.flags = sceneFlags;
|
||||
scene.camera = camera;
|
||||
scene.light = std::move(light);
|
||||
scene.light = light;
|
||||
auto sceneID = addVertex(
|
||||
SceneTag{},
|
||||
std::forward_as_tuple(name),
|
||||
@@ -94,6 +704,34 @@ void NativeRasterQueueBuilder::addSceneOfCamera(scene::Camera *camera, LightInfo
|
||||
std::forward_as_tuple(std::move(scene)),
|
||||
*renderGraph, queueID);
|
||||
CC_ENSURES(sceneID != RenderGraph::null_vertex());
|
||||
|
||||
auto &data = get(RenderGraph::Data, *renderGraph, sceneID);
|
||||
NativeSetter setter{*layoutGraph, data};
|
||||
|
||||
setCameraUBOValues(
|
||||
*camera,
|
||||
*pipelineRuntime->getPipelineSceneData(),
|
||||
camera->getScene()->getMainLight(), setter);
|
||||
|
||||
if (any(sceneFlags & SceneFlags::SHADOW_CASTER)) {
|
||||
if (pLight) {
|
||||
setShadowUBOLightView(
|
||||
pipelineRuntime->getDevice(),
|
||||
*pipelineRuntime->getPipelineSceneData(),
|
||||
*pLight, light.level, setter);
|
||||
}
|
||||
} else {
|
||||
const auto *pDirLight = camera->getScene()->getMainLight();
|
||||
if (pDirLight) {
|
||||
setShadowUBOView(*pipelineRuntime->getDevice(),
|
||||
*pipelineRuntime->getPipelineSceneData(),
|
||||
*pDirLight, setter);
|
||||
}
|
||||
}
|
||||
setTextureUBOView(
|
||||
*pipelineRuntime->getDevice(),
|
||||
*pipelineRuntime->getPipelineSceneData(),
|
||||
setter);
|
||||
}
|
||||
|
||||
void NativeRasterQueueBuilder::addScene(const ccstd::string &name, SceneFlags sceneFlags) {
|
||||
@@ -139,6 +777,28 @@ void NativeRasterQueueBuilder::addCameraQuad(
|
||||
std::forward_as_tuple(material, passID, sceneFlags, camera),
|
||||
*renderGraph, queueID);
|
||||
CC_ENSURES(drawID != RenderGraph::null_vertex());
|
||||
|
||||
auto &data = get(RenderGraph::Data, *renderGraph, drawID);
|
||||
NativeSetter setter{*layoutGraph, data};
|
||||
|
||||
setCameraUBOValues(
|
||||
*camera,
|
||||
*pipelineRuntime->getPipelineSceneData(),
|
||||
camera->getScene()->getMainLight(), setter);
|
||||
|
||||
if (any(sceneFlags & SceneFlags::SHADOW_CASTER)) {
|
||||
} else {
|
||||
const auto *pDirLight = camera->getScene()->getMainLight();
|
||||
if (pDirLight) {
|
||||
setShadowUBOView(*pipelineRuntime->getDevice(),
|
||||
*pipelineRuntime->getPipelineSceneData(),
|
||||
*pDirLight, setter);
|
||||
}
|
||||
}
|
||||
setTextureUBOView(
|
||||
*pipelineRuntime->getDevice(),
|
||||
*pipelineRuntime->getPipelineSceneData(),
|
||||
setter);
|
||||
}
|
||||
|
||||
void NativeRasterQueueBuilder::clearRenderTarget(const ccstd::string &name, const gfx::Color &color) {
|
||||
@@ -168,91 +828,6 @@ void NativeRasterQueueBuilder::setViewport(const gfx::Viewport &viewport) {
|
||||
CC_ENSURES(viewportID != RenderGraph::null_vertex());
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
render::NameLocalID getNameID(
|
||||
const PmrFlatMap<ccstd::pmr::string, render::NameLocalID> &index,
|
||||
std::string_view name) {
|
||||
auto iter = index.find(name);
|
||||
CC_EXPECTS(iter != index.end());
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
void addMat4(
|
||||
const LayoutGraphData &lg, std::string_view name,
|
||||
const cc::Mat4 &v, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Mat4) == 16 * 4, "sizeof(Mat4) is not 64 bytes");
|
||||
data.constants[nameID.value].resize(sizeof(Mat4));
|
||||
memcpy(data.constants[nameID.value].data(), v.m, sizeof(v));
|
||||
}
|
||||
|
||||
void addQuaternion(const LayoutGraphData &lg, const ccstd::string &name, const Quaternion &quat, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Quaternion) == 4 * 4, "sizeof(Quaternion) is not 16 bytes");
|
||||
static_assert(std::is_trivially_copyable<Quaternion>::value, "Quaternion is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(Quaternion));
|
||||
memcpy(data.constants[nameID.value].data(), &quat, sizeof(quat));
|
||||
}
|
||||
|
||||
void addColor(const LayoutGraphData &lg, const ccstd::string &name, const gfx::Color &color, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(gfx::Color) == 4 * 4, "sizeof(Color) is not 16 bytes");
|
||||
static_assert(std::is_trivially_copyable<gfx::Color>::value, "Color is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(gfx::Color));
|
||||
memcpy(data.constants[nameID.value].data(), &color, sizeof(color));
|
||||
}
|
||||
|
||||
void addVec4(const LayoutGraphData &lg, const ccstd::string &name, const Vec4 &vec, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Vec4) == 4 * 4, "sizeof(Vec4) is not 16 bytes");
|
||||
// static_assert(std::is_trivially_copyable<Vec4>::value, "Vec4 is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(Vec4));
|
||||
memcpy(data.constants[nameID.value].data(), &vec.x, sizeof(vec));
|
||||
}
|
||||
|
||||
void addVec2(const LayoutGraphData &lg, const ccstd::string &name, const Vec2 &vec, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(Vec2) == 2 * 4, "sizeof(Vec2) is not 8 bytes");
|
||||
// static_assert(std::is_trivially_copyable<Vec4>::value, "Vec2 is not trivially copyable");
|
||||
data.constants[nameID.value].resize(sizeof(Vec2));
|
||||
memcpy(data.constants[nameID.value].data(), &vec.x, sizeof(vec));
|
||||
}
|
||||
|
||||
void addFloat(const LayoutGraphData &lg, const ccstd::string &name, float v, RenderData &data) {
|
||||
auto nameID = getNameID(lg.constantIndex, name);
|
||||
static_assert(sizeof(float) == 4, "sizeof(float) is not 4 bytes");
|
||||
data.constants[nameID.value].resize(sizeof(float));
|
||||
memcpy(data.constants[nameID.value].data(), &v, sizeof(v));
|
||||
}
|
||||
|
||||
void addBuffer(const LayoutGraphData &lg, const ccstd::string &name, gfx::Buffer *buffer, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.buffers[nameID.value] = IntrusivePtr<gfx::Buffer>(buffer);
|
||||
}
|
||||
|
||||
void addTexture(const LayoutGraphData &lg, const ccstd::string &name, gfx::Texture *texture, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.textures[nameID.value] = IntrusivePtr<gfx::Texture>(texture);
|
||||
}
|
||||
|
||||
void addReadWriteBuffer(const LayoutGraphData &lg, const ccstd::string &name, gfx::Buffer *buffer, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.buffers[nameID.value] = IntrusivePtr<gfx::Buffer>(buffer);
|
||||
}
|
||||
|
||||
void addReadWriteTexture(const LayoutGraphData &lg, const ccstd::string &name, gfx::Texture *texture, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.textures[nameID.value] = IntrusivePtr<gfx::Texture>(texture);
|
||||
}
|
||||
|
||||
void addSampler(const LayoutGraphData &lg, const ccstd::string &name, gfx::Sampler *sampler, RenderData &data) {
|
||||
auto nameID = getNameID(lg.attributeIndex, name);
|
||||
data.samplers[nameID.value].ptr = sampler;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void NativeRasterQueueBuilder::setMat4(const ccstd::string &name, const Mat4 &mat) {
|
||||
auto &data = get(RenderGraph::Data, *renderGraph, queueID);
|
||||
addMat4(*layoutGraph, name, mat, data);
|
||||
@@ -319,7 +894,7 @@ RasterQueueBuilder *NativeRasterPassBuilder::addQueue(QueueHint hint) {
|
||||
std::forward_as_tuple(hint),
|
||||
*renderGraph, passID);
|
||||
|
||||
return new NativeRasterQueueBuilder(renderGraph, queueID, layoutGraph);
|
||||
return new NativeRasterQueueBuilder(pipelineRuntime, renderGraph, queueID, layoutGraph);
|
||||
}
|
||||
|
||||
void NativeRasterPassBuilder::setViewport(const gfx::Viewport &viewport) {
|
||||
@@ -475,6 +1050,8 @@ void NativeComputePassBuilder::setName(const ccstd::string &name) {
|
||||
}
|
||||
|
||||
void NativeComputePassBuilder::addComputeView(const ccstd::string &name, const ComputeView &view) {
|
||||
CC_EXPECTS(!name.empty());
|
||||
CC_EXPECTS(!view.name.empty());
|
||||
auto &pass = get(ComputeTag{}, passID, *renderGraph);
|
||||
auto iter = pass.computeViews.find(name.c_str());
|
||||
if (iter == pass.computeViews.end()) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user