diff --git a/native/cocos/base/Macros.h b/native/cocos/base/Macros.h index 930ff469d5..559e8cbf50 100644 --- a/native/cocos/base/Macros.h +++ b/native/cocos/base/Macros.h @@ -29,6 +29,8 @@ #pragma once +#include + #if (CC_PLATFORM == CC_PLATFORM_WINDOWS) #include #if !defined(__SSIZE_T) && !defined(_SSIZE_T_) @@ -325,10 +327,10 @@ It should work same as apples CFSwapInt32LittleToHost(..) #define CC_CPU CC_CPU_UNKNOWN #endif -#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) || defined(__arm64__) || defined(_aarch64_) || defined(__mips64) || defined(__mips64_) - #define CC_CPU_ARCH CC_CPU_ARCH_64 -#else +#if INTPTR_MAX == INT32_MAX #define CC_CPU_ARCH CC_CPU_ARCH_32 +#else + #define CC_CPU_ARCH CC_CPU_ARCH_64 #endif // C11 features diff --git a/native/cocos/bindings/auto/jsb_gfx_auto.cpp b/native/cocos/bindings/auto/jsb_gfx_auto.cpp index 36d83a06d0..7fddd2f9ae 100644 --- a/native/cocos/bindings/auto/jsb_gfx_auto.cpp +++ b/native/cocos/bindings/auto/jsb_gfx_auto.cpp @@ -4061,141 +4061,6 @@ bool js_register_gfx_DeviceInfo(se::Object* obj) // NOLINT(readability-identifie se::Object* __jsb_cc_gfx_BufferInfo_proto = nullptr; se::Class* __jsb_cc_gfx_BufferInfo_class = nullptr; -static bool js_gfx_BufferInfo_get_usage(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_get_usage : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->usage, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->usage, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_BufferInfo_get_usage) - -static bool js_gfx_BufferInfo_set_usage(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_set_usage : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->usage, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_BufferInfo_set_usage : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_BufferInfo_set_usage) - -static bool js_gfx_BufferInfo_get_memUsage(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_get_memUsage : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->memUsage, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->memUsage, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_BufferInfo_get_memUsage) - -static bool js_gfx_BufferInfo_set_memUsage(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_set_memUsage : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->memUsage, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_BufferInfo_set_memUsage : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_BufferInfo_set_memUsage) - -static bool js_gfx_BufferInfo_get_size(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_get_size : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->size, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->size, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_BufferInfo_get_size) - -static bool js_gfx_BufferInfo_set_size(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_set_size : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->size, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_BufferInfo_set_size : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_BufferInfo_set_size) - -static bool js_gfx_BufferInfo_get_stride(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_get_stride : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->stride, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->stride, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_BufferInfo_get_stride) - -static bool js_gfx_BufferInfo_set_stride(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_set_stride : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->stride, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_BufferInfo_set_stride : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_BufferInfo_set_stride) - -static bool js_gfx_BufferInfo_get_flags(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_get_flags : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->flags, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->flags, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_BufferInfo_get_flags) - -static bool js_gfx_BufferInfo_set_flags(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_BufferInfo_set_flags : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->flags, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_BufferInfo_set_flags : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_BufferInfo_set_flags) - template<> bool sevalue_to_native(const se::Value &from, cc::gfx::BufferInfo * to, se::Object *ctx) @@ -4209,26 +4074,6 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::BufferInfo * to, se::Obje } se::Value field; bool ok = true; - json->getProperty("usage", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->usage), ctx); - } - json->getProperty("memUsage", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->memUsage), ctx); - } - json->getProperty("size", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->size), ctx); - } - json->getProperty("stride", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->stride), ctx); - } - json->getProperty("flags", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->flags), ctx); - } return ok; } @@ -4248,40 +4093,7 @@ static bool js_gfx_BufferInfo_constructor(se::State& s) // NOLINT(readability-id return true; } - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::gfx::BufferInfo* cobj = JSB_ALLOC(cc::gfx::BufferInfo); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - cc::gfx::BufferInfo* cobj = JSB_ALLOC(cc::gfx::BufferInfo); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->usage), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->memUsage), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->size), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->stride), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->flags), nullptr); - } if(!ok) { JSB_FREE(cobj); @@ -4314,11 +4126,6 @@ bool js_register_gfx_BufferInfo(se::Object* obj) // NOLINT(readability-identifie { auto* cls = se::Class::create("BufferInfo", obj, nullptr, _SE(js_gfx_BufferInfo_constructor)); - cls->defineProperty("usage", _SE(js_gfx_BufferInfo_get_usage), _SE(js_gfx_BufferInfo_set_usage)); - cls->defineProperty("memUsage", _SE(js_gfx_BufferInfo_get_memUsage), _SE(js_gfx_BufferInfo_set_memUsage)); - cls->defineProperty("size", _SE(js_gfx_BufferInfo_get_size), _SE(js_gfx_BufferInfo_set_size)); - cls->defineProperty("stride", _SE(js_gfx_BufferInfo_get_stride), _SE(js_gfx_BufferInfo_set_stride)); - cls->defineProperty("flags", _SE(js_gfx_BufferInfo_get_flags), _SE(js_gfx_BufferInfo_set_flags)); cls->defineFinalizeFunction(_SE(js_cc_gfx_BufferInfo_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -5258,303 +5065,6 @@ bool js_register_gfx_IndirectBuffer(se::Object* obj) // NOLINT(readability-ident se::Object* __jsb_cc_gfx_TextureInfo_proto = nullptr; se::Class* __jsb_cc_gfx_TextureInfo_class = nullptr; -static bool js_gfx_TextureInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_type : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->type, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->type, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_type) - -static bool js_gfx_TextureInfo_set_type(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_type : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->type, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_type : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_type) - -static bool js_gfx_TextureInfo_get_usage(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_usage : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->usage, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->usage, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_usage) - -static bool js_gfx_TextureInfo_set_usage(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_usage : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->usage, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_usage : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_usage) - -static bool js_gfx_TextureInfo_get_format(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_format : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->format, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->format, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_format) - -static bool js_gfx_TextureInfo_set_format(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_format : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->format, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_format : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_format) - -static bool js_gfx_TextureInfo_get_width(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_width : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->width, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->width, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_width) - -static bool js_gfx_TextureInfo_set_width(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_width : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->width, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_width : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_width) - -static bool js_gfx_TextureInfo_get_height(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_height : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->height, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->height, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_height) - -static bool js_gfx_TextureInfo_set_height(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_height : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->height, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_height : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_height) - -static bool js_gfx_TextureInfo_get_flags(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_flags : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->flags, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->flags, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_flags) - -static bool js_gfx_TextureInfo_set_flags(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_flags : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->flags, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_flags : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_flags) - -static bool js_gfx_TextureInfo_get_layerCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_layerCount : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->layerCount, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->layerCount, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_layerCount) - -static bool js_gfx_TextureInfo_set_layerCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_layerCount : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->layerCount, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_layerCount : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_layerCount) - -static bool js_gfx_TextureInfo_get_levelCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_levelCount : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->levelCount, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->levelCount, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_levelCount) - -static bool js_gfx_TextureInfo_set_levelCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_levelCount : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->levelCount, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_levelCount : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_levelCount) - -static bool js_gfx_TextureInfo_get_samples(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_samples : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->samples, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->samples, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_samples) - -static bool js_gfx_TextureInfo_set_samples(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_samples : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->samples, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_samples : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_samples) - -static bool js_gfx_TextureInfo_get_depth(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_depth : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->depth, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->depth, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_depth) - -static bool js_gfx_TextureInfo_set_depth(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_depth : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->depth, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_depth : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_depth) - -static bool js_gfx_TextureInfo_get_externalRes(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_get_externalRes : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->externalRes, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->externalRes, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureInfo_get_externalRes) - -static bool js_gfx_TextureInfo_set_externalRes(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureInfo_set_externalRes : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->externalRes, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureInfo_set_externalRes : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureInfo_set_externalRes) - template<> bool sevalue_to_native(const se::Value &from, cc::gfx::TextureInfo * to, se::Object *ctx) @@ -5568,50 +5078,6 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureInfo * to, se::Obj } se::Value field; bool ok = true; - json->getProperty("type", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->type), ctx); - } - json->getProperty("usage", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->usage), ctx); - } - json->getProperty("format", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->format), ctx); - } - json->getProperty("width", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->width), ctx); - } - json->getProperty("height", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->height), ctx); - } - json->getProperty("flags", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->flags), ctx); - } - json->getProperty("layerCount", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->layerCount), ctx); - } - json->getProperty("levelCount", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->levelCount), ctx); - } - json->getProperty("samples", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->samples), ctx); - } - json->getProperty("depth", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->depth), ctx); - } - json->getProperty("externalRes", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->externalRes), ctx); - } return ok; } @@ -5631,58 +5097,7 @@ static bool js_gfx_TextureInfo_constructor(se::State& s) // NOLINT(readability-i return true; } - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::gfx::TextureInfo* cobj = JSB_ALLOC(cc::gfx::TextureInfo); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - cc::gfx::TextureInfo* cobj = JSB_ALLOC(cc::gfx::TextureInfo); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->type), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->usage), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->format), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->width), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->height), nullptr); - } - if (argc > 5 && !args[5].isUndefined()) { - ok &= sevalue_to_native(args[5], &(cobj->flags), nullptr); - } - if (argc > 6 && !args[6].isUndefined()) { - ok &= sevalue_to_native(args[6], &(cobj->layerCount), nullptr); - } - if (argc > 7 && !args[7].isUndefined()) { - ok &= sevalue_to_native(args[7], &(cobj->levelCount), nullptr); - } - if (argc > 8 && !args[8].isUndefined()) { - ok &= sevalue_to_native(args[8], &(cobj->samples), nullptr); - } - if (argc > 9 && !args[9].isUndefined()) { - ok &= sevalue_to_native(args[9], &(cobj->depth), nullptr); - } - if (argc > 10 && !args[10].isUndefined()) { - ok &= sevalue_to_native(args[10], &(cobj->externalRes), nullptr); - } if(!ok) { JSB_FREE(cobj); @@ -5715,17 +5130,6 @@ bool js_register_gfx_TextureInfo(se::Object* obj) // NOLINT(readability-identifi { auto* cls = se::Class::create("TextureInfo", obj, nullptr, _SE(js_gfx_TextureInfo_constructor)); - cls->defineProperty("type", _SE(js_gfx_TextureInfo_get_type), _SE(js_gfx_TextureInfo_set_type)); - cls->defineProperty("usage", _SE(js_gfx_TextureInfo_get_usage), _SE(js_gfx_TextureInfo_set_usage)); - cls->defineProperty("format", _SE(js_gfx_TextureInfo_get_format), _SE(js_gfx_TextureInfo_set_format)); - cls->defineProperty("width", _SE(js_gfx_TextureInfo_get_width), _SE(js_gfx_TextureInfo_set_width)); - cls->defineProperty("height", _SE(js_gfx_TextureInfo_get_height), _SE(js_gfx_TextureInfo_set_height)); - cls->defineProperty("flags", _SE(js_gfx_TextureInfo_get_flags), _SE(js_gfx_TextureInfo_set_flags)); - cls->defineProperty("layerCount", _SE(js_gfx_TextureInfo_get_layerCount), _SE(js_gfx_TextureInfo_set_layerCount)); - cls->defineProperty("levelCount", _SE(js_gfx_TextureInfo_get_levelCount), _SE(js_gfx_TextureInfo_set_levelCount)); - cls->defineProperty("samples", _SE(js_gfx_TextureInfo_get_samples), _SE(js_gfx_TextureInfo_set_samples)); - cls->defineProperty("depth", _SE(js_gfx_TextureInfo_get_depth), _SE(js_gfx_TextureInfo_set_depth)); - cls->defineProperty("externalRes", _SE(js_gfx_TextureInfo_get_externalRes), _SE(js_gfx_TextureInfo_set_externalRes)); cls->defineFinalizeFunction(_SE(js_cc_gfx_TextureInfo_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -5739,195 +5143,6 @@ bool js_register_gfx_TextureInfo(se::Object* obj) // NOLINT(readability-identifi se::Object* __jsb_cc_gfx_TextureViewInfo_proto = nullptr; se::Class* __jsb_cc_gfx_TextureViewInfo_class = nullptr; -static bool js_gfx_TextureViewInfo_get_texture(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_get_texture : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->texture, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->texture, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureViewInfo_get_texture) - -static bool js_gfx_TextureViewInfo_set_texture(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_set_texture : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->texture, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureViewInfo_set_texture : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureViewInfo_set_texture) - -static bool js_gfx_TextureViewInfo_get_type(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_get_type : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->type, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->type, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureViewInfo_get_type) - -static bool js_gfx_TextureViewInfo_set_type(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_set_type : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->type, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureViewInfo_set_type : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureViewInfo_set_type) - -static bool js_gfx_TextureViewInfo_get_format(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_get_format : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->format, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->format, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureViewInfo_get_format) - -static bool js_gfx_TextureViewInfo_set_format(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_set_format : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->format, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureViewInfo_set_format : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureViewInfo_set_format) - -static bool js_gfx_TextureViewInfo_get_baseLevel(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_get_baseLevel : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->baseLevel, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->baseLevel, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureViewInfo_get_baseLevel) - -static bool js_gfx_TextureViewInfo_set_baseLevel(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_set_baseLevel : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->baseLevel, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureViewInfo_set_baseLevel : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureViewInfo_set_baseLevel) - -static bool js_gfx_TextureViewInfo_get_levelCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_get_levelCount : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->levelCount, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->levelCount, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureViewInfo_get_levelCount) - -static bool js_gfx_TextureViewInfo_set_levelCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_set_levelCount : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->levelCount, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureViewInfo_set_levelCount : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureViewInfo_set_levelCount) - -static bool js_gfx_TextureViewInfo_get_baseLayer(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_get_baseLayer : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->baseLayer, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->baseLayer, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureViewInfo_get_baseLayer) - -static bool js_gfx_TextureViewInfo_set_baseLayer(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_set_baseLayer : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->baseLayer, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureViewInfo_set_baseLayer : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureViewInfo_set_baseLayer) - -static bool js_gfx_TextureViewInfo_get_layerCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_get_layerCount : Invalid Native Object"); - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->layerCount, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->layerCount, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_gfx_TextureViewInfo_get_layerCount) - -static bool js_gfx_TextureViewInfo_set_layerCount(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "js_gfx_TextureViewInfo_set_layerCount : Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->layerCount, s.thisObject()); - SE_PRECONDITION2(ok, false, "js_gfx_TextureViewInfo_set_layerCount : Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_gfx_TextureViewInfo_set_layerCount) - template<> bool sevalue_to_native(const se::Value &from, cc::gfx::TextureViewInfo * to, se::Object *ctx) @@ -5941,34 +5156,6 @@ bool sevalue_to_native(const se::Value &from, cc::gfx::TextureViewInfo * to, se: } se::Value field; bool ok = true; - json->getProperty("texture", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->texture), ctx); - } - json->getProperty("type", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->type), ctx); - } - json->getProperty("format", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->format), ctx); - } - json->getProperty("baseLevel", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->baseLevel), ctx); - } - json->getProperty("levelCount", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->levelCount), ctx); - } - json->getProperty("baseLayer", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->baseLayer), ctx); - } - json->getProperty("layerCount", &field); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->layerCount), ctx); - } return ok; } @@ -5988,46 +5175,7 @@ static bool js_gfx_TextureViewInfo_constructor(se::State& s) // NOLINT(readabili return true; } - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - - cc::gfx::TextureViewInfo* cobj = JSB_ALLOC(cc::gfx::TextureViewInfo); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - JSB_FREE(cobj); - SE_REPORT_ERROR("argument convertion error"); - return false; - } - - s.thisObject()->setPrivateData(cobj); - se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); - return true; - } - cc::gfx::TextureViewInfo* cobj = JSB_ALLOC(cc::gfx::TextureViewInfo); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->texture), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->type), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->format), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->baseLevel), nullptr); - } - if (argc > 4 && !args[4].isUndefined()) { - ok &= sevalue_to_native(args[4], &(cobj->levelCount), nullptr); - } - if (argc > 5 && !args[5].isUndefined()) { - ok &= sevalue_to_native(args[5], &(cobj->baseLayer), nullptr); - } - if (argc > 6 && !args[6].isUndefined()) { - ok &= sevalue_to_native(args[6], &(cobj->layerCount), nullptr); - } if(!ok) { JSB_FREE(cobj); @@ -6060,13 +5208,6 @@ bool js_register_gfx_TextureViewInfo(se::Object* obj) // NOLINT(readability-iden { auto* cls = se::Class::create("TextureViewInfo", obj, nullptr, _SE(js_gfx_TextureViewInfo_constructor)); - cls->defineProperty("texture", _SE(js_gfx_TextureViewInfo_get_texture), _SE(js_gfx_TextureViewInfo_set_texture)); - cls->defineProperty("type", _SE(js_gfx_TextureViewInfo_get_type), _SE(js_gfx_TextureViewInfo_set_type)); - cls->defineProperty("format", _SE(js_gfx_TextureViewInfo_get_format), _SE(js_gfx_TextureViewInfo_set_format)); - cls->defineProperty("baseLevel", _SE(js_gfx_TextureViewInfo_get_baseLevel), _SE(js_gfx_TextureViewInfo_set_baseLevel)); - cls->defineProperty("levelCount", _SE(js_gfx_TextureViewInfo_get_levelCount), _SE(js_gfx_TextureViewInfo_set_levelCount)); - cls->defineProperty("baseLayer", _SE(js_gfx_TextureViewInfo_get_baseLayer), _SE(js_gfx_TextureViewInfo_set_baseLayer)); - cls->defineProperty("layerCount", _SE(js_gfx_TextureViewInfo_get_layerCount), _SE(js_gfx_TextureViewInfo_set_layerCount)); cls->defineFinalizeFunction(_SE(js_cc_gfx_TextureViewInfo_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -15541,9 +14682,9 @@ bool js_register_gfx_GFXObject(se::Object* obj) // NOLINT(readability-identifier { auto* cls = se::Class::create("GFXObject", obj, nullptr, _SE(js_gfx_GFXObject_constructor)); - cls->defineProperty("typedID", _SE(js_gfx_GFXObject_getTypedID), nullptr); - cls->defineProperty("objectID", _SE(js_gfx_GFXObject_getObjectID), nullptr); cls->defineProperty("objectType", _SE(js_gfx_GFXObject_getObjectType), nullptr); + cls->defineProperty("objectID", _SE(js_gfx_GFXObject_getObjectID), nullptr); + cls->defineProperty("typedID", _SE(js_gfx_GFXObject_getTypedID), nullptr); cls->defineFinalizeFunction(_SE(js_cc_gfx_GFXObject_finalize)); cls->install(); JSBClassType::registerClass(cls); @@ -15733,7 +14874,7 @@ static bool js_gfx_Buffer_computeHash(se::State& s) // NOLINT(readability-identi HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); SE_PRECONDITION2(ok, false, "js_gfx_Buffer_computeHash : Error processing arguments"); - unsigned int result = cc::gfx::Buffer::computeHash(arg0.value()); + size_t result = cc::gfx::Buffer::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Buffer_computeHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -15773,12 +14914,12 @@ bool js_register_gfx_Buffer(se::Object* obj) // NOLINT(readability-identifier-na { auto* cls = se::Class::create("Buffer", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Buffer_constructor)); - cls->defineProperty("count", _SE(js_gfx_Buffer_getCount), nullptr); + cls->defineProperty("usage", _SE(js_gfx_Buffer_getUsage), nullptr); cls->defineProperty("memUsage", _SE(js_gfx_Buffer_getMemUsage), nullptr); cls->defineProperty("stride", _SE(js_gfx_Buffer_getStride), nullptr); - cls->defineProperty("flags", _SE(js_gfx_Buffer_getFlags), nullptr); - cls->defineProperty("usage", _SE(js_gfx_Buffer_getUsage), nullptr); + cls->defineProperty("count", _SE(js_gfx_Buffer_getCount), nullptr); cls->defineProperty("size", _SE(js_gfx_Buffer_getSize), nullptr); + cls->defineProperty("flags", _SE(js_gfx_Buffer_getFlags), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Buffer_destroy)); cls->defineFunction("isBufferView", _SE(js_gfx_Buffer_isBufferView)); cls->defineFunction("resize", _SE(js_gfx_Buffer_resize)); @@ -15838,7 +14979,7 @@ static bool js_gfx_InputAssembler_getAttributesHash(se::State& s) // NOLINT(read size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - unsigned int result = cobj->getAttributesHash(); + size_t result = cobj->getAttributesHash(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_InputAssembler_getAttributesHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -16239,19 +15380,19 @@ bool js_register_gfx_InputAssembler(se::Object* obj) // NOLINT(readability-ident { auto* cls = se::Class::create("InputAssembler", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_InputAssembler_constructor)); - cls->defineProperty("instanceCount", _SE(js_gfx_InputAssembler_getInstanceCount), _SE(js_gfx_InputAssembler_setInstanceCount)); cls->defineProperty("vertexBuffers", _SE(js_gfx_InputAssembler_getVertexBuffers), nullptr); - cls->defineProperty("attributesHash", _SE(js_gfx_InputAssembler_getAttributesHash), nullptr); - cls->defineProperty("firstInstance", _SE(js_gfx_InputAssembler_getFirstInstance), _SE(js_gfx_InputAssembler_setFirstInstance)); - cls->defineProperty("vertexCount", _SE(js_gfx_InputAssembler_getVertexCount), _SE(js_gfx_InputAssembler_setVertexCount)); - cls->defineProperty("drawInfo", _SE(js_gfx_InputAssembler_getDrawInfo), nullptr); - cls->defineProperty("indexBuffer", _SE(js_gfx_InputAssembler_getIndexBuffer), nullptr); - cls->defineProperty("vertexOffset", _SE(js_gfx_InputAssembler_getVertexOffset), _SE(js_gfx_InputAssembler_setVertexOffset)); cls->defineProperty("attributes", _SE(js_gfx_InputAssembler_getAttributes), nullptr); + cls->defineProperty("indexBuffer", _SE(js_gfx_InputAssembler_getIndexBuffer), nullptr); + cls->defineProperty("indirectBuffer", _SE(js_gfx_InputAssembler_getIndirectBuffer), nullptr); + cls->defineProperty("attributesHash", _SE(js_gfx_InputAssembler_getAttributesHash), nullptr); + cls->defineProperty("drawInfo", _SE(js_gfx_InputAssembler_getDrawInfo), nullptr); + cls->defineProperty("vertexCount", _SE(js_gfx_InputAssembler_getVertexCount), _SE(js_gfx_InputAssembler_setVertexCount)); + cls->defineProperty("firstVertex", _SE(js_gfx_InputAssembler_getFirstVertex), _SE(js_gfx_InputAssembler_setFirstVertex)); cls->defineProperty("indexCount", _SE(js_gfx_InputAssembler_getIndexCount), _SE(js_gfx_InputAssembler_setIndexCount)); cls->defineProperty("firstIndex", _SE(js_gfx_InputAssembler_getFirstIndex), _SE(js_gfx_InputAssembler_setFirstIndex)); - cls->defineProperty("indirectBuffer", _SE(js_gfx_InputAssembler_getIndirectBuffer), nullptr); - cls->defineProperty("firstVertex", _SE(js_gfx_InputAssembler_getFirstVertex), _SE(js_gfx_InputAssembler_setFirstVertex)); + cls->defineProperty("vertexOffset", _SE(js_gfx_InputAssembler_getVertexOffset), _SE(js_gfx_InputAssembler_setVertexOffset)); + cls->defineProperty("instanceCount", _SE(js_gfx_InputAssembler_getInstanceCount), _SE(js_gfx_InputAssembler_setInstanceCount)); + cls->defineProperty("firstInstance", _SE(js_gfx_InputAssembler_getFirstInstance), _SE(js_gfx_InputAssembler_setFirstInstance)); cls->defineFunction("destroy", _SE(js_gfx_InputAssembler_destroy)); cls->defineFunction("initialize", _SE(js_gfx_InputAssembler_initialize)); cls->defineFinalizeFunction(_SE(js_cc_gfx_InputAssembler_finalize)); @@ -17827,7 +16968,7 @@ static bool js_gfx_Framebuffer_computeHash(se::State& s) // NOLINT(readability-i HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); SE_PRECONDITION2(ok, false, "js_gfx_Framebuffer_computeHash : Error processing arguments"); - unsigned int result = cc::gfx::Framebuffer::computeHash(arg0.value()); + size_t result = cc::gfx::Framebuffer::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Framebuffer_computeHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -17867,8 +17008,8 @@ bool js_register_gfx_Framebuffer(se::Object* obj) // NOLINT(readability-identifi { auto* cls = se::Class::create("Framebuffer", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Framebuffer_constructor)); - cls->defineProperty("colorTextures", _SE(js_gfx_Framebuffer_getColorTextures), nullptr); cls->defineProperty("renderPass", _SE(js_gfx_Framebuffer_getRenderPass), nullptr); + cls->defineProperty("colorTextures", _SE(js_gfx_Framebuffer_getColorTextures), nullptr); cls->defineProperty("depthStencilTexture", _SE(js_gfx_Framebuffer_getDepthStencilTexture), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Framebuffer_destroy)); cls->defineFunction("initialize", _SE(js_gfx_Framebuffer_initialize)); @@ -18237,14 +17378,14 @@ bool js_register_gfx_PipelineState(se::Object* obj) // NOLINT(readability-identi { auto* cls = se::Class::create("PipelineState", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_PipelineState_constructor)); - cls->defineProperty("primitive", _SE(js_gfx_PipelineState_getPrimitive), nullptr); - cls->defineProperty("rasterizerState", _SE(js_gfx_PipelineState_getRasterizerState), nullptr); cls->defineProperty("shader", _SE(js_gfx_PipelineState_getShader), nullptr); + cls->defineProperty("primitive", _SE(js_gfx_PipelineState_getPrimitive), nullptr); + cls->defineProperty("bindPoint", _SE(js_gfx_PipelineState_getBindPoint), nullptr); + cls->defineProperty("inputState", _SE(js_gfx_PipelineState_getInputState), nullptr); + cls->defineProperty("rasterizerState", _SE(js_gfx_PipelineState_getRasterizerState), nullptr); + cls->defineProperty("depthStencilState", _SE(js_gfx_PipelineState_getDepthStencilState), nullptr); cls->defineProperty("blendState", _SE(js_gfx_PipelineState_getBlendState), nullptr); cls->defineProperty("renderPass", _SE(js_gfx_PipelineState_getRenderPass), nullptr); - cls->defineProperty("inputState", _SE(js_gfx_PipelineState_getInputState), nullptr); - cls->defineProperty("bindPoint", _SE(js_gfx_PipelineState_getBindPoint), nullptr); - cls->defineProperty("depthStencilState", _SE(js_gfx_PipelineState_getDepthStencilState), nullptr); cls->defineFunction("destroy", _SE(js_gfx_PipelineState_destroy)); cls->defineFunction("getDynamicStates", _SE(js_gfx_PipelineState_getDynamicStates)); cls->defineFunction("getPipelineLayout", _SE(js_gfx_PipelineState_getPipelineLayout)); @@ -18459,7 +17600,7 @@ static bool js_gfx_RenderPass_getHash(se::State& s) // NOLINT(readability-identi size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - unsigned int result = cobj->getHash(); + size_t result = cobj->getHash(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_RenderPass_getHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -18517,7 +17658,7 @@ static bool js_gfx_RenderPass_computeHash(se::State& s) // NOLINT(readability-id HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); SE_PRECONDITION2(ok, false, "js_gfx_RenderPass_computeHash : Error processing arguments"); - unsigned int result = cc::gfx::RenderPass::computeHash(arg0.value()); + size_t result = cc::gfx::RenderPass::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_RenderPass_computeHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -18830,10 +17971,10 @@ bool js_register_gfx_Shader(se::Object* obj) // NOLINT(readability-identifier-na { auto* cls = se::Class::create("Shader", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Shader_constructor)); - cls->defineProperty("attributes", _SE(js_gfx_Shader_getAttributes), nullptr); - cls->defineProperty("stages", _SE(js_gfx_Shader_getStages), nullptr); - cls->defineProperty("blocks", _SE(js_gfx_Shader_getBlocks), nullptr); cls->defineProperty("name", _SE(js_gfx_Shader_getName), nullptr); + cls->defineProperty("stages", _SE(js_gfx_Shader_getStages), nullptr); + cls->defineProperty("attributes", _SE(js_gfx_Shader_getAttributes), nullptr); + cls->defineProperty("blocks", _SE(js_gfx_Shader_getBlocks), nullptr); cls->defineProperty("samplers", _SE(js_gfx_Shader_getSamplers), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Shader_destroy)); cls->defineFunction("getBuffers", _SE(js_gfx_Shader_getBuffers)); @@ -18897,7 +18038,7 @@ static bool js_gfx_Texture_getHash(se::State& s) // NOLINT(readability-identifie size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - unsigned int result = cobj->getHash(); + size_t result = cobj->getHash(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Texture_getHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -19053,7 +18194,7 @@ static bool js_gfx_Texture_computeHash(se::State& s) // NOLINT(readability-ident HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); if (!ok) { ok = true; break; } - unsigned int result = cc::gfx::Texture::computeHash(arg0.value()); + size_t result = cc::gfx::Texture::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Texture_computeHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -19065,7 +18206,7 @@ static bool js_gfx_Texture_computeHash(se::State& s) // NOLINT(readability-ident HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); if (!ok) { ok = true; break; } - unsigned int result = cc::gfx::Texture::computeHash(arg0.value()); + size_t result = cc::gfx::Texture::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Texture_computeHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -19107,12 +18248,12 @@ bool js_register_gfx_Texture(se::Object* obj) // NOLINT(readability-identifier-n auto* cls = se::Class::create("Texture", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Texture_constructor)); cls->defineProperty("info", _SE(js_gfx_Texture_getInfo), nullptr); - cls->defineProperty("hash", _SE(js_gfx_Texture_getHash), nullptr); - cls->defineProperty("format", _SE(js_gfx_Texture_getFormat), nullptr); - cls->defineProperty("height", _SE(js_gfx_Texture_getHeight), nullptr); - cls->defineProperty("width", _SE(js_gfx_Texture_getWidth), nullptr); cls->defineProperty("viewInfo", _SE(js_gfx_Texture_getViewInfo), nullptr); + cls->defineProperty("width", _SE(js_gfx_Texture_getWidth), nullptr); + cls->defineProperty("height", _SE(js_gfx_Texture_getHeight), nullptr); + cls->defineProperty("format", _SE(js_gfx_Texture_getFormat), nullptr); cls->defineProperty("size", _SE(js_gfx_Texture_getSize), nullptr); + cls->defineProperty("hash", _SE(js_gfx_Texture_getHash), nullptr); cls->defineFunction("destroy", _SE(js_gfx_Texture_destroy)); cls->defineFunction("isTextureView", _SE(js_gfx_Texture_isTextureView)); cls->defineFunction("resize", _SE(js_gfx_Texture_resize)); @@ -19384,10 +18525,10 @@ bool js_register_gfx_Swapchain(se::Object* obj) // NOLINT(readability-identifier auto* cls = se::Class::create("Swapchain", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Swapchain_constructor)); cls->defineProperty("width", _SE(js_gfx_Swapchain_getWidth), nullptr); - cls->defineProperty("surfaceTransform", _SE(js_gfx_Swapchain_getSurfaceTransform), nullptr); - cls->defineProperty("depthStencilTexture", _SE(js_gfx_Swapchain_getDepthStencilTexture), nullptr); - cls->defineProperty("colorTexture", _SE(js_gfx_Swapchain_getColorTexture), nullptr); cls->defineProperty("height", _SE(js_gfx_Swapchain_getHeight), nullptr); + cls->defineProperty("surfaceTransform", _SE(js_gfx_Swapchain_getSurfaceTransform), nullptr); + cls->defineProperty("colorTexture", _SE(js_gfx_Swapchain_getColorTexture), nullptr); + cls->defineProperty("depthStencilTexture", _SE(js_gfx_Swapchain_getDepthStencilTexture), nullptr); cls->defineFunction("createSurface", _SE(js_gfx_Swapchain_createSurface)); cls->defineFunction("destroy", _SE(js_gfx_Swapchain_destroy)); cls->defineFunction("destroySurface", _SE(js_gfx_Swapchain_destroySurface)); @@ -19416,7 +18557,7 @@ static bool js_gfx_GlobalBarrier_getHash(se::State& s) // NOLINT(readability-ide size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const unsigned int& result = cobj->getHash(); + const size_t& result = cobj->getHash(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_GlobalBarrier_getHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -19455,7 +18596,7 @@ static bool js_gfx_GlobalBarrier_computeHash(se::State& s) // NOLINT(readability HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); SE_PRECONDITION2(ok, false, "js_gfx_GlobalBarrier_computeHash : Error processing arguments"); - unsigned int result = cc::gfx::GlobalBarrier::computeHash(arg0.value()); + size_t result = cc::gfx::GlobalBarrier::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_GlobalBarrier_computeHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -19519,7 +18660,7 @@ static bool js_gfx_Sampler_getHash(se::State& s) // NOLINT(readability-identifie size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const unsigned int& result = cobj->getHash(); + const size_t& result = cobj->getHash(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Sampler_getHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -19558,7 +18699,7 @@ static bool js_gfx_Sampler_computeHash(se::State& s) // NOLINT(readability-ident HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); SE_PRECONDITION2(ok, false, "js_gfx_Sampler_computeHash : Error processing arguments"); - unsigned int result = cc::gfx::Sampler::computeHash(arg0.value()); + size_t result = cc::gfx::Sampler::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_Sampler_computeHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -19622,7 +18763,7 @@ static bool js_gfx_TextureBarrier_getHash(se::State& s) // NOLINT(readability-id size_t argc = args.size(); CC_UNUSED bool ok = true; if (argc == 0) { - const unsigned int& result = cobj->getHash(); + const size_t& result = cobj->getHash(); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_TextureBarrier_getHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -19661,7 +18802,7 @@ static bool js_gfx_TextureBarrier_computeHash(se::State& s) // NOLINT(readabilit HolderType arg0 = {}; ok &= sevalue_to_native(args[0], &arg0, nullptr); SE_PRECONDITION2(ok, false, "js_gfx_TextureBarrier_computeHash : Error processing arguments"); - unsigned int result = cc::gfx::TextureBarrier::computeHash(arg0.value()); + size_t result = cc::gfx::TextureBarrier::computeHash(arg0.value()); ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); SE_PRECONDITION2(ok, false, "js_gfx_TextureBarrier_computeHash : Error processing arguments"); SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); @@ -20418,17 +19559,17 @@ bool js_register_gfx_Device(se::Object* obj) // NOLINT(readability-identifier-na { auto* cls = se::Class::create("Device", obj, nullptr, nullptr); + cls->defineProperty("gfxAPI", _SE(js_gfx_Device_getGfxAPI), nullptr); cls->defineProperty("deviceName", _SE(js_gfx_Device_getDeviceName), nullptr); + cls->defineProperty("memoryStatus", _SE(js_gfx_Device_getMemoryStatus), nullptr); + cls->defineProperty("queue", _SE(js_gfx_Device_getQueue), nullptr); + cls->defineProperty("commandBuffer", _SE(js_gfx_Device_getCommandBuffer), nullptr); + cls->defineProperty("renderer", _SE(js_gfx_Device_getRenderer), nullptr); cls->defineProperty("vendor", _SE(js_gfx_Device_getVendor), nullptr); cls->defineProperty("numDrawCalls", _SE(js_gfx_Device_getNumDrawCalls), nullptr); - cls->defineProperty("memoryStatus", _SE(js_gfx_Device_getMemoryStatus), nullptr); - cls->defineProperty("gfxAPI", _SE(js_gfx_Device_getGfxAPI), nullptr); - cls->defineProperty("capabilities", _SE(js_gfx_Device_getCapabilities), nullptr); - cls->defineProperty("numTris", _SE(js_gfx_Device_getNumTris), nullptr); - cls->defineProperty("queue", _SE(js_gfx_Device_getQueue), nullptr); - cls->defineProperty("renderer", _SE(js_gfx_Device_getRenderer), nullptr); - cls->defineProperty("commandBuffer", _SE(js_gfx_Device_getCommandBuffer), nullptr); cls->defineProperty("numInstances", _SE(js_gfx_Device_getNumInstances), nullptr); + cls->defineProperty("numTris", _SE(js_gfx_Device_getNumTris), nullptr); + cls->defineProperty("capabilities", _SE(js_gfx_Device_getCapabilities), nullptr); cls->defineFunction("acquire", _SE(js_gfx_Device_acquire)); cls->defineFunction("bindingMappingInfo", _SE(js_gfx_Device_bindingMappingInfo)); cls->defineFunction("createCommandBuffer", _SE(js_gfx_Device_createCommandBuffer)); @@ -20462,19 +19603,6 @@ bool js_register_gfx_Device(se::Object* obj) // NOLINT(readability-identifier-na se::Object* __jsb_cc_gfx_DeviceManager_proto = nullptr; se::Class* __jsb_cc_gfx_DeviceManager_class = nullptr; -static bool js_gfx_DeviceManager_destroy(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cc::gfx::DeviceManager::destroy(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_gfx_DeviceManager_destroy) - static bool js_gfx_DeviceManager_create(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); @@ -20495,6 +19623,19 @@ static bool js_gfx_DeviceManager_create(se::State& s) // NOLINT(readability-iden } SE_BIND_FUNC(js_gfx_DeviceManager_create) +static bool js_gfx_DeviceManager_destroy(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + size_t argc = args.size(); + if (argc == 0) { + cc::gfx::DeviceManager::destroy(); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_gfx_DeviceManager_destroy) + static bool js_gfx_DeviceManager_addSurfaceEventListener(se::State& s) // NOLINT(readability-identifier-naming) { const auto& args = s.args(); @@ -20526,8 +19667,8 @@ bool js_register_gfx_DeviceManager(se::Object* obj) // NOLINT(readability-identi { auto* cls = se::Class::create("DeviceManager", obj, nullptr, nullptr); - cls->defineStaticFunction("destroy", _SE(js_gfx_DeviceManager_destroy)); cls->defineStaticFunction("create", _SE(js_gfx_DeviceManager_create)); + cls->defineStaticFunction("destroy", _SE(js_gfx_DeviceManager_destroy)); cls->defineStaticFunction("addSurfaceEventListener", _SE(js_gfx_DeviceManager_addSurfaceEventListener)); cls->defineFinalizeFunction(_SE(js_cc_gfx_DeviceManager_finalize)); cls->install(); @@ -20551,81 +19692,81 @@ bool register_all_gfx(se::Object* obj) } se::Object* ns = nsVal.toObject(); + js_register_gfx_Size(ns); + js_register_gfx_DeviceCaps(ns); + js_register_gfx_Offset(ns); + js_register_gfx_Rect(ns); + js_register_gfx_Extent(ns); + js_register_gfx_TextureSubresLayers(ns); + js_register_gfx_TextureSubresRange(ns); + js_register_gfx_TextureCopy(ns); + js_register_gfx_TextureBlit(ns); + js_register_gfx_BufferTextureCopy(ns); + js_register_gfx_Viewport(ns); + js_register_gfx_Color(ns); + js_register_gfx_BindingMappingInfo(ns); js_register_gfx_SwapchainInfo(ns); + js_register_gfx_DeviceInfo(ns); + js_register_gfx_BufferInfo(ns); + js_register_gfx_BufferViewInfo(ns); + js_register_gfx_DrawInfo(ns); + js_register_gfx_DispatchInfo(ns); + js_register_gfx_IndirectBuffer(ns); + js_register_gfx_TextureInfo(ns); + js_register_gfx_TextureViewInfo(ns); + js_register_gfx_SamplerInfo(ns); + js_register_gfx_Uniform(ns); + js_register_gfx_UniformBlock(ns); + js_register_gfx_UniformSamplerTexture(ns); + js_register_gfx_UniformSampler(ns); + js_register_gfx_UniformTexture(ns); + js_register_gfx_UniformStorageImage(ns); + js_register_gfx_UniformStorageBuffer(ns); + js_register_gfx_UniformInputAttachment(ns); + js_register_gfx_ShaderStage(ns); + js_register_gfx_Attribute(ns); + js_register_gfx_ShaderInfo(ns); + js_register_gfx_InputAssemblerInfo(ns); + js_register_gfx_ColorAttachment(ns); + js_register_gfx_DepthStencilAttachment(ns); js_register_gfx_SubpassInfo(ns); + js_register_gfx_SubpassDependency(ns); + js_register_gfx_RenderPassInfo(ns); + js_register_gfx_GlobalBarrierInfo(ns); + js_register_gfx_TextureBarrierInfo(ns); + js_register_gfx_FramebufferInfo(ns); + js_register_gfx_DescriptorSetLayoutBinding(ns); + js_register_gfx_DescriptorSetLayoutInfo(ns); + js_register_gfx_DescriptorSetInfo(ns); + js_register_gfx_PipelineLayoutInfo(ns); + js_register_gfx_InputState(ns); + js_register_gfx_RasterizerState(ns); + js_register_gfx_DepthStencilState(ns); + js_register_gfx_BlendTarget(ns); + js_register_gfx_BlendState(ns); + js_register_gfx_PipelineStateInfo(ns); + js_register_gfx_CommandBufferInfo(ns); + js_register_gfx_QueueInfo(ns); + js_register_gfx_MemoryStatus(ns); js_register_gfx_GFXObject(ns); js_register_gfx_Buffer(ns); + js_register_gfx_InputAssembler(ns); + js_register_gfx_CommandBuffer(ns); + js_register_gfx_DescriptorSet(ns); + js_register_gfx_DescriptorSetLayout(ns); + js_register_gfx_Framebuffer(ns); + js_register_gfx_PipelineLayout(ns); + js_register_gfx_PipelineState(ns); + js_register_gfx_Queue(ns); + js_register_gfx_RenderPass(ns); + js_register_gfx_Shader(ns); + js_register_gfx_Texture(ns); + js_register_gfx_Swapchain(ns); + js_register_gfx_GlobalBarrier(ns); + js_register_gfx_Sampler(ns); js_register_gfx_TextureBarrier(ns); js_register_gfx_Device(ns); - js_register_gfx_Texture(ns); - js_register_gfx_Uniform(ns); - js_register_gfx_DescriptorSet(ns); - js_register_gfx_BlendTarget(ns); - js_register_gfx_DispatchInfo(ns); - js_register_gfx_PipelineState(ns); - js_register_gfx_TextureBarrierInfo(ns); - js_register_gfx_PipelineLayout(ns); - js_register_gfx_Sampler(ns); - js_register_gfx_InputAssembler(ns); - js_register_gfx_RenderPass(ns); - js_register_gfx_BufferInfo(ns); - js_register_gfx_SamplerInfo(ns); - js_register_gfx_QueueInfo(ns); - js_register_gfx_UniformStorageBuffer(ns); - js_register_gfx_SubpassDependency(ns); - js_register_gfx_UniformSamplerTexture(ns); - js_register_gfx_BufferTextureCopy(ns); - js_register_gfx_PipelineLayoutInfo(ns); - js_register_gfx_InputAssemblerInfo(ns); - js_register_gfx_TextureBlit(ns); - js_register_gfx_TextureInfo(ns); - js_register_gfx_GlobalBarrierInfo(ns); - js_register_gfx_RenderPassInfo(ns); - js_register_gfx_Extent(ns); - js_register_gfx_Offset(ns); - js_register_gfx_CommandBuffer(ns); - js_register_gfx_Framebuffer(ns); - js_register_gfx_Viewport(ns); - js_register_gfx_TextureSubresLayers(ns); - js_register_gfx_BufferViewInfo(ns); - js_register_gfx_UniformInputAttachment(ns); - js_register_gfx_UniformSampler(ns); - js_register_gfx_ShaderInfo(ns); - js_register_gfx_PipelineStateInfo(ns); - js_register_gfx_Shader(ns); - js_register_gfx_BlendState(ns); - js_register_gfx_GlobalBarrier(ns); - js_register_gfx_DescriptorSetInfo(ns); - js_register_gfx_DescriptorSetLayoutInfo(ns); - js_register_gfx_DrawInfo(ns); - js_register_gfx_InputState(ns); - js_register_gfx_CommandBufferInfo(ns); - js_register_gfx_UniformStorageImage(ns); - js_register_gfx_UniformBlock(ns); - js_register_gfx_DepthStencilAttachment(ns); - js_register_gfx_TextureSubresRange(ns); - js_register_gfx_TextureViewInfo(ns); - js_register_gfx_Queue(ns); - js_register_gfx_ColorAttachment(ns); - js_register_gfx_RasterizerState(ns); js_register_gfx_DeviceManager(ns); - js_register_gfx_Color(ns); - js_register_gfx_Attribute(ns); - js_register_gfx_MemoryStatus(ns); - js_register_gfx_DeviceInfo(ns); - js_register_gfx_Swapchain(ns); - js_register_gfx_DepthStencilState(ns); - js_register_gfx_BindingMappingInfo(ns); - js_register_gfx_FramebufferInfo(ns); - js_register_gfx_DeviceCaps(ns); - js_register_gfx_Rect(ns); - js_register_gfx_ShaderStage(ns); - js_register_gfx_DescriptorSetLayoutBinding(ns); - js_register_gfx_UniformTexture(ns); - js_register_gfx_DescriptorSetLayout(ns); - js_register_gfx_TextureCopy(ns); - js_register_gfx_IndirectBuffer(ns); - js_register_gfx_Size(ns); return true; } diff --git a/native/cocos/bindings/auto/jsb_gfx_auto.h b/native/cocos/bindings/auto/jsb_gfx_auto.h index ed4bd3b93d..d445c48bc7 100644 --- a/native/cocos/bindings/auto/jsb_gfx_auto.h +++ b/native/cocos/bindings/auto/jsb_gfx_auto.h @@ -850,7 +850,7 @@ bool js_register_cc_gfx_DeviceManager(se::Object* obj); bool register_all_gfx(se::Object* obj); JSB_REGISTER_OBJECT_TYPE(cc::gfx::DeviceManager); -SE_DECLARE_FUNC(js_gfx_DeviceManager_destroy); SE_DECLARE_FUNC(js_gfx_DeviceManager_create); +SE_DECLARE_FUNC(js_gfx_DeviceManager_destroy); SE_DECLARE_FUNC(js_gfx_DeviceManager_addSurfaceEventListener); diff --git a/native/cocos/renderer/frame-graph/FrameGraph.h b/native/cocos/renderer/frame-graph/FrameGraph.h index 92cc9d964b..8779913abc 100644 --- a/native/cocos/renderer/frame-graph/FrameGraph.h +++ b/native/cocos/renderer/frame-graph/FrameGraph.h @@ -43,8 +43,8 @@ class FrameGraph final { public: using ResourceHandleBlackboard = Blackboard; - FrameGraph() = default; - ~FrameGraph() = default; + FrameGraph() = default; + ~FrameGraph() = default; FrameGraph(const FrameGraph &) = delete; FrameGraph(FrameGraph &&) noexcept = delete; FrameGraph &operator=(const FrameGraph &) = delete; @@ -64,8 +64,8 @@ public: template const CallbackPass &addPass(PassInsertPoint insertPoint, const StringHandle &name, SetupMethod setup, ExecuteMethod &&execute) noexcept; - template - TypedHandle create(const StringHandle &name, const typename ResourceType::Descriptor &desc) noexcept; + template ::Resource> + TypedHandle create(const StringHandle &name, const DescriptorType &desc) noexcept; template TypedHandle importExternal(const StringHandle &name, ResourceType &resource) noexcept; void move(TextureHandle from, TextureHandle to, uint8_t mipmapLevel, uint8_t faceId, uint8_t arrayPosition) noexcept; @@ -113,8 +113,8 @@ const CallbackPass &FrameGraph::addPass(const PassInsertPoi return *pass; } -template -TypedHandle FrameGraph::create(const StringHandle &name, const typename ResourceType::Descriptor &desc) noexcept { +template +TypedHandle FrameGraph::create(const StringHandle &name, const DescriptorType &desc) noexcept { auto *const virtualResource = new ResourceEntry(name, static_cast(_virtualResources.size()), desc); return TypedHandle(create(virtualResource)); } @@ -132,9 +132,9 @@ void FrameGraph::enableMerge(bool const enable) noexcept { ////////////////////////////////////////////////////////////////////////// -template -TypedHandle PassNodeBuilder::create(const StringHandle &name, const typename ResourceType::Descriptor &desc) const noexcept { - return _graph.create(name, desc); +template +TypedHandle PassNodeBuilder::create(const StringHandle &name, const DescriptorType &desc) const noexcept { + return _graph.create(name, desc); } template diff --git a/native/cocos/renderer/frame-graph/PassNodeBuilder.h b/native/cocos/renderer/frame-graph/PassNodeBuilder.h index 3a59969c88..daa9099249 100644 --- a/native/cocos/renderer/frame-graph/PassNodeBuilder.h +++ b/native/cocos/renderer/frame-graph/PassNodeBuilder.h @@ -40,8 +40,8 @@ public: PassNodeBuilder &operator=(const PassNodeBuilder &) = delete; PassNodeBuilder &operator=(PassNodeBuilder &&) = delete; - template - TypedHandle create(const StringHandle &name, const typename ResourceType::Descriptor &desc) const noexcept; + template ::Resource> + TypedHandle create(const StringHandle &name, const DescriptorType &desc) const noexcept; template TypedHandle importExternal(const StringHandle &name, ResourceType &resource) const noexcept; template diff --git a/native/cocos/renderer/frame-graph/Resource.h b/native/cocos/renderer/frame-graph/Resource.h index df2913cf70..40930788a2 100644 --- a/native/cocos/renderer/frame-graph/Resource.h +++ b/native/cocos/renderer/frame-graph/Resource.h @@ -44,13 +44,16 @@ struct DeviceResourceCreator final { } }; +template +struct ResourceTypeLookupTable final {}; + template > class Resource final { public: - using Allocator = ResourceAllocator; - using DeviceResource = DeviceResourceType; - using Descriptor = DescriptorType; + using Allocator = ResourceAllocator; + using DeviceResource = DeviceResourceType; + using Descriptor = DescriptorType; Resource() = default; explicit Resource(const Descriptor &desc); @@ -136,7 +139,11 @@ const DescriptorType &Resource; \ - using Type##Handle = TypedHandle; + using Type##Handle = TypedHandle; \ + template <> \ + struct ResourceTypeLookupTable final { \ + using Resource = Type; \ + }; // Descriptors must have std::hash specialization and == operators DEFINE_GFX_RESOURCE(Buffer) diff --git a/native/cocos/renderer/frame-graph/ResourceAllocator.h b/native/cocos/renderer/frame-graph/ResourceAllocator.h index de6a4a22e7..1627971221 100644 --- a/native/cocos/renderer/frame-graph/ResourceAllocator.h +++ b/native/cocos/renderer/frame-graph/ResourceAllocator.h @@ -28,6 +28,7 @@ #include #include #include "base/memory/Memory.h" +#include "gfx-base/GFXDef.h" namespace cc { namespace framegraph { @@ -62,9 +63,9 @@ private: ResourceAllocator() noexcept = default; ~ResourceAllocator() = default; - std::unordered_map _livepool{}; - std::unordered_map _deadpool{}; - uint64_t _age{0}; + std::unordered_map> _livepool{}; + std::unordered_map> _deadpool{}; + uint64_t _age{0}; }; ////////////////////////////////////////////////////////////////////////// diff --git a/native/cocos/renderer/gfx-agent/DeviceAgent.cpp b/native/cocos/renderer/gfx-agent/DeviceAgent.cpp index ef18f66eb8..2228105f75 100644 --- a/native/cocos/renderer/gfx-agent/DeviceAgent.cpp +++ b/native/cocos/renderer/gfx-agent/DeviceAgent.cpp @@ -249,15 +249,15 @@ PipelineState *DeviceAgent::createPipelineState() { return CC_NEW(PipelineStateAgent(actor)); } -Sampler *DeviceAgent::createSampler(const SamplerInfo &info, uint32_t hash) { +Sampler *DeviceAgent::createSampler(const SamplerInfo &info, size_t hash) { return _actor->createSampler(info, hash); } -GlobalBarrier *DeviceAgent::createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) { +GlobalBarrier *DeviceAgent::createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) { return _actor->createGlobalBarrier(info, hash); } -TextureBarrier *DeviceAgent::createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) { +TextureBarrier *DeviceAgent::createTextureBarrier(const TextureBarrierInfo &info, size_t hash) { return _actor->createTextureBarrier(info, hash); } diff --git a/native/cocos/renderer/gfx-agent/DeviceAgent.h b/native/cocos/renderer/gfx-agent/DeviceAgent.h index ed1bd42a44..68b82739b2 100644 --- a/native/cocos/renderer/gfx-agent/DeviceAgent.h +++ b/native/cocos/renderer/gfx-agent/DeviceAgent.h @@ -80,9 +80,9 @@ public: PipelineLayout * createPipelineLayout() override; PipelineState * createPipelineState() override; - Sampler * createSampler(const SamplerInfo &info, uint32_t hash) override; - GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) override; - TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) override; + Sampler * createSampler(const SamplerInfo &info, size_t hash) override; + GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) override; + TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, size_t hash) override; void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) override; void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) override; diff --git a/native/cocos/renderer/gfx-base/GFXBuffer.cpp b/native/cocos/renderer/gfx-base/GFXBuffer.cpp index 1450c7dbf5..2784cf1042 100644 --- a/native/cocos/renderer/gfx-base/GFXBuffer.cpp +++ b/native/cocos/renderer/gfx-base/GFXBuffer.cpp @@ -27,7 +27,6 @@ #include "GFXBuffer.h" #include "GFXDevice.h" -#include "GFXObject.h" namespace cc { namespace gfx { @@ -38,9 +37,8 @@ Buffer::Buffer() Buffer::~Buffer() = default; -uint32_t Buffer::computeHash(const BufferInfo &info) { - std::hash hasher; - return utils::toUint(hasher(info)); +size_t Buffer::computeHash(const BufferInfo &info) { + return Hasher()(info); } void Buffer::initialize(const BufferInfo &info) { diff --git a/native/cocos/renderer/gfx-base/GFXBuffer.h b/native/cocos/renderer/gfx-base/GFXBuffer.h index aa18bf9aa9..df9010851e 100644 --- a/native/cocos/renderer/gfx-base/GFXBuffer.h +++ b/native/cocos/renderer/gfx-base/GFXBuffer.h @@ -35,7 +35,7 @@ public: Buffer(); ~Buffer() override; - static uint32_t computeHash(const BufferInfo &info); + static size_t computeHash(const BufferInfo &info); void initialize(const BufferInfo &info); void initialize(const BufferViewInfo &info); diff --git a/native/cocos/renderer/gfx-base/GFXDef-common.h b/native/cocos/renderer/gfx-base/GFXDef-common.h index fd628fd3e8..4fbba1db8c 100644 --- a/native/cocos/renderer/gfx-base/GFXDef-common.h +++ b/native/cocos/renderer/gfx-base/GFXDef-common.h @@ -44,6 +44,7 @@ * * @ts-nullable: declare the member optional * * @ts-overrides `YAML declaration`: overrides any parsed results, use with caution * * each struct member have to be specified in a single line, including optional parser directives + * * members with a name starts with an underscore is automatically ignored */ namespace cc { @@ -797,17 +798,6 @@ struct Rect { int32_t y{0}; uint32_t width{0U}; uint32_t height{0U}; - - bool operator==(const Rect &rs) const { - return x == rs.x && - y == rs.y && - width == rs.width && - height == rs.height; - } - - bool operator!=(const Rect &rs) const { - return !(*this == rs); - } }; struct Extent { @@ -863,19 +853,6 @@ struct Viewport { uint32_t height{0U}; float minDepth{0.F}; float maxDepth{1.F}; - - bool operator==(const Viewport &rs) const { - return (left == rs.left && - top == rs.top && - width == rs.width && - height == rs.height && - math::IsEqualF(minDepth, rs.minDepth) && - math::IsEqualF(maxDepth, maxDepth)); - } - - bool operator!=(const Viewport &rs) const { - return !(*this == rs); - } }; struct Color { @@ -883,13 +860,6 @@ struct Color { float y{0.F}; float z{0.F}; float w{0.F}; - - bool operator==(const Color &rhs) const { - return (math::IsEqualF(x, rhs.x) && - math::IsEqualF(y, rhs.y) && - math::IsEqualF(z, rhs.z) && - math::IsEqualF(w, rhs.w)); - } }; using ColorList = vector; @@ -922,12 +892,13 @@ struct DeviceInfo { BindingMappingInfo bindingMappingInfo; }; -struct BufferInfo { +struct ALIGNAS(8) BufferInfo { BufferUsage usage{BufferUsageBit::NONE}; MemoryUsage memUsage{MemoryUsageBit::NONE}; uint32_t size{0U}; uint32_t stride{0U}; // in bytes BufferFlags flags{BufferFlagBit::NONE}; + uint32_t _padding{0U}; }; struct BufferViewInfo { @@ -963,7 +934,7 @@ struct IndirectBuffer { DrawInfoList drawInfos; }; -struct TextureInfo { +struct ALIGNAS(8) TextureInfo { TextureType type{TextureType::TEX2D}; TextureUsage usage{TextureUsageBit::NONE}; Format format{Format::UNKNOWN}; @@ -975,9 +946,12 @@ struct TextureInfo { SampleCount samples{SampleCount::ONE}; uint32_t depth{1U}; void * externalRes{nullptr}; // CVPixelBuffer for Metal, EGLImage for GLES +#if CC_CPU_ARCH == CC_CPU_ARCH_32 + uint32_t _padding{0U}; +#endif }; -struct TextureViewInfo { +struct ALIGNAS(8) TextureViewInfo { Texture * texture{nullptr}; TextureType type{TextureType::TEX2D}; Format format{Format::UNKNOWN}; @@ -985,6 +959,9 @@ struct TextureViewInfo { uint32_t levelCount{1U}; uint32_t baseLayer{0U}; uint32_t layerCount{1U}; +#if CC_CPU_ARCH == CC_CPU_ARCH_32 + uint32_t _padding{0U}; +#endif }; struct SamplerInfo { diff --git a/native/cocos/renderer/gfx-base/GFXDef.cpp b/native/cocos/renderer/gfx-base/GFXDef.cpp index 668c2d5e77..b9d2f6a8c1 100644 --- a/native/cocos/renderer/gfx-base/GFXDef.cpp +++ b/native/cocos/renderer/gfx-base/GFXDef.cpp @@ -23,167 +23,108 @@ THE SOFTWARE. ****************************************************************************/ +#include + #include "base/CoreStd.h" #include "base/Utils.h" #include "GFXDef.h" #include "GFXTexture.h" -#include "gfx-base/GFXDef-common.h" - -namespace std { -std::size_t hash::operator()(const cc::gfx::RenderPassInfo& info) const { - static auto computeAttachmentHash = [](const cc::gfx::ColorAttachment& attachment, uint32_t& seed) { - seed ^= toNumber(attachment.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(attachment.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(attachment.loadOp) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(attachment.storeOp) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - for (cc::gfx::AccessType type : attachment.beginAccesses) { - seed ^= toNumber(type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - for (cc::gfx::AccessType type : attachment.endAccesses) { - seed ^= toNumber(type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - }; - static auto computeDSAttachmentHash = [](const cc::gfx::DepthStencilAttachment& attachment, uint32_t& seed) { - seed ^= toNumber(attachment.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(attachment.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(attachment.depthLoadOp) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(attachment.depthStoreOp) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(attachment.stencilLoadOp) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(attachment.stencilStoreOp) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - for (auto type : attachment.beginAccesses) { - seed ^= toNumber(type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - for (auto type : attachment.endAccesses) { - seed ^= toNumber(type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - }; - uint32_t seed = 0; - if (!info.subpasses.empty()) { - for (const auto& subpass : info.subpasses) { - for (const uint32_t iaIndex : subpass.inputs) { - if (iaIndex >= info.colorAttachments.size()) break; - const auto& ia = info.colorAttachments[iaIndex]; - seed += cc::utils::toUint(4 + ia.beginAccesses.size() + ia.endAccesses.size()); - } - for (const uint32_t caIndex : subpass.colors) { - if (caIndex >= info.colorAttachments.size()) break; - const auto& ca = info.colorAttachments[caIndex]; - seed += cc::utils::toUint(4 + ca.beginAccesses.size() + ca.endAccesses.size()); - } - for (const uint32_t raIndex : subpass.resolves) { - if (raIndex >= info.colorAttachments.size()) break; - const auto& ra = info.colorAttachments[raIndex]; - seed += cc::utils::toUint(4 + ra.beginAccesses.size() + ra.endAccesses.size()); - } - for (const uint32_t paIndex : subpass.preserves) { - if (paIndex >= info.colorAttachments.size()) break; - const auto& pa = info.colorAttachments[paIndex]; - seed += cc::utils::toUint(4 + pa.beginAccesses.size() + pa.endAccesses.size()); - } - if (subpass.depthStencil != cc::gfx::INVALID_BINDING) { - if (subpass.depthStencil < info.colorAttachments.size()) { - const auto& ds = info.colorAttachments[subpass.depthStencil]; - seed += cc::utils::toUint(4 + ds.beginAccesses.size() + ds.endAccesses.size()); - } else { - const auto& ds = info.depthStencilAttachment; - seed += cc::utils::toUint(6 + ds.beginAccesses.size() + ds.endAccesses.size()); - } - } - } - for (const auto& subpass : info.subpasses) { - for (const uint32_t iaIndex : subpass.inputs) { - if (iaIndex >= info.colorAttachments.size()) break; - computeAttachmentHash(info.colorAttachments[iaIndex], seed); - } - for (const uint32_t caIndex : subpass.colors) { - if (caIndex >= info.colorAttachments.size()) break; - computeAttachmentHash(info.colorAttachments[caIndex], seed); - } - for (const uint32_t raIndex : subpass.resolves) { - if (raIndex >= info.colorAttachments.size()) break; - computeAttachmentHash(info.colorAttachments[raIndex], seed); - } - for (const uint32_t paIndex : subpass.preserves) { - if (paIndex >= info.colorAttachments.size()) break; - computeAttachmentHash(info.colorAttachments[paIndex], seed); - } - if (subpass.depthStencil != cc::gfx::INVALID_BINDING) { - if (subpass.depthStencil < info.colorAttachments.size()) { - computeAttachmentHash(info.colorAttachments[subpass.depthStencil], seed); - } else { - computeDSAttachmentHash(info.depthStencilAttachment, seed); - } - } - } - } else { - for (const auto& ca : info.colorAttachments) { - seed += cc::utils::toUint(4 + ca.beginAccesses.size() + ca.endAccesses.size()); - } - seed += cc::utils::toUint(6 + info.depthStencilAttachment.beginAccesses.size() + info.depthStencilAttachment.endAccesses.size()); - - for (const auto& ca : info.colorAttachments) { - computeAttachmentHash(ca, seed); - } - computeDSAttachmentHash(info.depthStencilAttachment, seed); - } - - return seed; -} - -std::size_t hash::operator()(const cc::gfx::FramebufferInfo& info) const { - auto seed = cc::utils::toUint(info.colorTextures.size() * 2 + (info.depthStencilTexture ? 2 : 0)); - for (const auto* attachment : info.colorTextures) { - seed ^= attachment->getHash() + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= attachment->getTypedID() + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - if (info.depthStencilTexture) { - seed ^= info.depthStencilTexture->getHash() + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.depthStencilTexture->getTypedID() + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - return seed; -} - -std::size_t hash::operator()(const cc::gfx::TextureInfo& info) const { - uint32_t seed = 10; - seed ^= toNumber(info.type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(info.usage) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(info.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(info.flags) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(info.samples) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.width + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.height + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.depth + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.layerCount + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.levelCount + 0x9e3779b9 + (seed << 6) + (seed >> 2); - return seed; -} - -std::size_t hash::operator()(const cc::gfx::TextureViewInfo& info) const { - uint32_t seed = 7; - seed ^= info.texture->getHash() + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(info.type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(info.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.baseLevel + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.levelCount + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.baseLayer + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.layerCount + 0x9e3779b9 + (seed << 6) + (seed >> 2); - return seed; -} - -std::size_t hash::operator()(const cc::gfx::BufferInfo& info) const { - uint32_t seed = 4; - seed ^= toNumber(info.usage) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(info.memUsage) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= toNumber(info.flags) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= info.size + 0x9e3779b9 + (seed << 6) + (seed >> 2); - return seed; -} -} // namespace std namespace cc { namespace gfx { +// T must have no implicit padding +template +size_t quickHashTrivialStruct(const T* info, size_t count = 1) { + static_assert(std::is_trivially_copyable::value && sizeof(T) % 8 == 0, "T must be 8 bytes aligned and trivially copyable"); + return boost::hash_range(reinterpret_cast(info), reinterpret_cast(info + count)); +} + +template <> +size_t Hasher::operator()(const ColorAttachment& info) const { + size_t seed = 6; + boost::hash_combine(seed, info.format); + boost::hash_combine(seed, info.sampleCount); + boost::hash_combine(seed, info.loadOp); + boost::hash_combine(seed, info.storeOp); + boost::hash_combine(seed, info.beginAccesses); + boost::hash_combine(seed, info.endAccesses); + return seed; +} + +template <> +size_t Hasher::operator()(const DepthStencilAttachment& info) const { + size_t seed = 8; + boost::hash_combine(seed, info.format); + boost::hash_combine(seed, info.sampleCount); + boost::hash_combine(seed, info.depthLoadOp); + boost::hash_combine(seed, info.depthStoreOp); + boost::hash_combine(seed, info.stencilLoadOp); + boost::hash_combine(seed, info.stencilStoreOp); + boost::hash_combine(seed, info.beginAccesses); + boost::hash_combine(seed, info.endAccesses); + return seed; +} + +template <> +size_t Hasher::operator()(const SubpassInfo& info) const { + size_t seed = 8; + boost::hash_combine(seed, info.inputs); + boost::hash_combine(seed, info.colors); + boost::hash_combine(seed, info.resolves); + boost::hash_combine(seed, info.preserves); + boost::hash_combine(seed, info.depthStencil); + boost::hash_combine(seed, info.depthStencilResolve); + boost::hash_combine(seed, info.depthResolveMode); + boost::hash_combine(seed, info.stencilResolveMode); + return seed; +} + +template <> +size_t Hasher::operator()(const SubpassDependency& info) const { + size_t seed = 4; + boost::hash_combine(seed, info.srcSubpass); + boost::hash_combine(seed, info.dstSubpass); + boost::hash_combine(seed, info.srcAccesses); + boost::hash_combine(seed, info.dstAccesses); + return seed; +} + +template <> +size_t Hasher::operator()(const RenderPassInfo& info) const { + size_t seed = 4; + boost::hash_combine(seed, info.colorAttachments); + boost::hash_combine(seed, info.depthStencilAttachment); + boost::hash_combine(seed, info.subpasses); + boost::hash_combine(seed, info.dependencies); + return seed; +} + +template <> +size_t Hasher::operator()(const FramebufferInfo& info) const { + size_t seed = 3; + boost::hash_combine(seed, info.renderPass); + boost::hash_combine(seed, info.colorTextures); + boost::hash_combine(seed, info.depthStencilTexture); + return seed; +} + +template <> +size_t Hasher::operator()(const TextureInfo& info) const { + return quickHashTrivialStruct(&info); +} + +template <> +size_t Hasher::operator()(const TextureViewInfo& info) const { + return quickHashTrivialStruct(&info); +} + +template <> +size_t Hasher::operator()(const BufferInfo& info) const { + return quickHashTrivialStruct(&info); +} + bool operator==(const ColorAttachment& lhs, const ColorAttachment& rhs) { return lhs.format == rhs.format && lhs.sampleCount == rhs.sampleCount && @@ -237,6 +178,53 @@ bool operator==(const FramebufferInfo& lhs, const FramebufferInfo& rhs) { lhs.depthStencilTexture == rhs.depthStencilTexture; } +bool operator==(const Viewport& lhs, const Viewport& rhs) { + return lhs.left == rhs.left && + lhs.top == rhs.top && + lhs.width == rhs.width && + lhs.height == rhs.height && + lhs.minDepth == rhs.minDepth && + lhs.maxDepth == rhs.maxDepth; +} +bool operator!=(const Viewport& lhs, const Viewport& rhs) { + return !(lhs == rhs); +} + +bool operator==(const Rect& lhs, const Rect& rhs) { + return lhs.x == rhs.x && + lhs.y == rhs.y && + lhs.width == rhs.width && + lhs.height == rhs.height; +} +bool operator!=(const Rect& lhs, const Rect& rhs) { + return !(lhs == rhs); +} + +bool operator==(const Color& lhs, const Color& rhs) { + return lhs.x == rhs.x && + lhs.y == rhs.y && + lhs.z == rhs.z && + lhs.w == rhs.w; +} + +bool operator==(const Offset& lhs, const Offset& rhs) { + return lhs.x == rhs.x && + lhs.y == rhs.y && + lhs.z == rhs.z; +} + +bool operator==(const Extent& lhs, const Extent& rhs) { + return lhs.width == rhs.width && + lhs.height == rhs.height && + lhs.depth == rhs.depth; +} + +bool operator==(const Size& lhs, const Size& rhs) { + return lhs.x == rhs.x && + lhs.y == rhs.y && + lhs.z == rhs.z; +} + bool operator==(const TextureInfo& lhs, const TextureInfo& rhs) { return !memcmp(&lhs, &rhs, sizeof(TextureInfo)); } diff --git a/native/cocos/renderer/gfx-base/GFXDef.h b/native/cocos/renderer/gfx-base/GFXDef.h index 7d08807142..9bb3555ec1 100644 --- a/native/cocos/renderer/gfx-base/GFXDef.h +++ b/native/cocos/renderer/gfx-base/GFXDef.h @@ -28,33 +28,36 @@ #include #include "GFXDef-common.h" -namespace std { -template <> -struct hash { std::size_t operator()(const cc::gfx::RenderPassInfo& info) const; }; -template <> -struct hash { std::size_t operator()(const cc::gfx::FramebufferInfo& info) const; }; -template <> -struct hash { std::size_t operator()(const cc::gfx::TextureInfo& info) const; }; -template <> -struct hash { std::size_t operator()(const cc::gfx::TextureViewInfo& info) const; }; -template <> -struct hash { std::size_t operator()(const cc::gfx::BufferInfo& info) const; }; -} // namespace std - namespace cc { namespace gfx { -extern bool operator==(const ColorAttachment& lhs, const ColorAttachment& rhs); -extern bool operator==(const DepthStencilAttachment& lhs, const DepthStencilAttachment& rhs); -extern bool operator==(const SubpassInfo& lhs, const SubpassInfo& rhs); -extern bool operator==(const SubpassDependency& lhs, const SubpassDependency& rhs); -extern bool operator==(const RenderPassInfo& lhs, const RenderPassInfo& rhs); -extern bool operator==(const FramebufferInfo& lhs, const FramebufferInfo& rhs); -extern bool operator==(const TextureInfo& lhs, const TextureInfo& rhs); -extern bool operator==(const TextureViewInfo& lhs, const TextureViewInfo& rhs); -extern bool operator==(const BufferInfo& lhs, const BufferInfo& rhs); +template ::value>> +struct Hasher final { size_t operator()(const T& info) const; }; -struct SwapchainTextureInfo { +// make this boost::hash compatible +template ::value>> +size_t hash_value(const T& info) { return Hasher()(info); } // NOLINT(readability-identifier-naming) + +bool operator==(const ColorAttachment& lhs, const ColorAttachment& rhs); +bool operator==(const DepthStencilAttachment& lhs, const DepthStencilAttachment& rhs); +bool operator==(const SubpassInfo& lhs, const SubpassInfo& rhs); +bool operator==(const SubpassDependency& lhs, const SubpassDependency& rhs); +bool operator==(const RenderPassInfo& lhs, const RenderPassInfo& rhs); +bool operator==(const FramebufferInfo& lhs, const FramebufferInfo& rhs); +bool operator==(const Viewport& lhs, const Viewport& rhs); +bool operator==(const Rect& lhs, const Rect& rhs); +bool operator==(const Color& lhs, const Color& rhs); +bool operator==(const Offset& lhs, const Offset& rhs); +bool operator==(const Extent& lhs, const Extent& rhs); +bool operator==(const Size& lhs, const Size& rhs); +bool operator==(const TextureInfo& lhs, const TextureInfo& rhs); +bool operator==(const TextureViewInfo& lhs, const TextureViewInfo& rhs); +bool operator==(const BufferInfo& lhs, const BufferInfo& rhs); + +bool operator!=(const Viewport& lhs, const Viewport& rhs); +bool operator!=(const Rect& lhs, const Rect& rhs); + +struct SwapchainTextureInfo final { Swapchain* swapchain{nullptr}; Format format{Format::UNKNOWN}; uint32_t width{0}; diff --git a/native/cocos/renderer/gfx-base/GFXDevice.cpp b/native/cocos/renderer/gfx-base/GFXDevice.cpp index 2cf476c3bf..ad00683f53 100644 --- a/native/cocos/renderer/gfx-base/GFXDevice.cpp +++ b/native/cocos/renderer/gfx-base/GFXDevice.cpp @@ -55,6 +55,12 @@ bool Device::initialize(const DeviceInfo &info) { _bindingMappingInfo.samplerOffsets.push_back(0); } +#if CC_CPU_ARCH == CC_CPU_ARCH_32 + static_assert(sizeof(void*) == 4, "pointer size assumption broken"); +#else + static_assert(sizeof(void*) == 8, "pointer size assumption broken"); +#endif + return doInit(info); } diff --git a/native/cocos/renderer/gfx-base/GFXDevice.h b/native/cocos/renderer/gfx-base/GFXDevice.h index 8bf785dfde..8ac91631fb 100644 --- a/native/cocos/renderer/gfx-base/GFXDevice.h +++ b/native/cocos/renderer/gfx-base/GFXDevice.h @@ -133,9 +133,9 @@ protected: virtual PipelineLayout * createPipelineLayout() = 0; virtual PipelineState * createPipelineState() = 0; - virtual Sampler * createSampler(const SamplerInfo &info, uint32_t hash) = 0; - virtual GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) = 0; - virtual TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) = 0; + virtual Sampler * createSampler(const SamplerInfo &info, size_t hash) = 0; + virtual GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) = 0; + virtual TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, size_t hash) = 0; // For context switching between threads virtual void bindContext(bool bound) {} @@ -159,9 +159,9 @@ protected: uint32_t _numTriangles{0U}; MemoryStatus _memoryStatus; - unordered_map _samplers; - unordered_map _globalBarriers; - unordered_map _textureBarriers; + unordered_map _samplers; + unordered_map _globalBarriers; + unordered_map _textureBarriers; private: vector _swapchains; @@ -261,7 +261,7 @@ PipelineState *Device::createPipelineState(const PipelineStateInfo &info) { } Sampler *Device::getSampler(const SamplerInfo &info) { - uint32_t hash = gfx::Sampler::computeHash(info); + size_t hash = gfx::Sampler::computeHash(info); if (!_samplers.count(hash)) { _samplers[hash] = createSampler(info, hash); } @@ -269,7 +269,7 @@ Sampler *Device::getSampler(const SamplerInfo &info) { } GlobalBarrier *Device::getGlobalBarrier(const GlobalBarrierInfo &info) { - uint32_t hash = gfx::GlobalBarrier::computeHash(info); + size_t hash = gfx::GlobalBarrier::computeHash(info); if (!_globalBarriers.count(hash)) { _globalBarriers[hash] = createGlobalBarrier(info, hash); } @@ -277,7 +277,7 @@ GlobalBarrier *Device::getGlobalBarrier(const GlobalBarrierInfo &info) { } TextureBarrier *Device::getTextureBarrier(const TextureBarrierInfo &info) { - uint32_t hash = gfx::TextureBarrier::computeHash(info); + size_t hash = gfx::TextureBarrier::computeHash(info); if (!_textureBarriers.count(hash)) { _textureBarriers[hash] = createTextureBarrier(info, hash); } diff --git a/native/cocos/renderer/gfx-base/GFXFramebuffer.cpp b/native/cocos/renderer/gfx-base/GFXFramebuffer.cpp index dde57cb7b3..8c37c641ab 100644 --- a/native/cocos/renderer/gfx-base/GFXFramebuffer.cpp +++ b/native/cocos/renderer/gfx-base/GFXFramebuffer.cpp @@ -38,9 +38,8 @@ Framebuffer::Framebuffer() Framebuffer::~Framebuffer() = default; -uint32_t Framebuffer::computeHash(const FramebufferInfo &info) { - std::hash hasher; - return utils::toUint(hasher(info)); +size_t Framebuffer::computeHash(const FramebufferInfo &info) { + return Hasher()(info); } void Framebuffer::initialize(const FramebufferInfo &info) { diff --git a/native/cocos/renderer/gfx-base/GFXFramebuffer.h b/native/cocos/renderer/gfx-base/GFXFramebuffer.h index 4f984a6b60..a21be11cd7 100644 --- a/native/cocos/renderer/gfx-base/GFXFramebuffer.h +++ b/native/cocos/renderer/gfx-base/GFXFramebuffer.h @@ -35,7 +35,7 @@ public: Framebuffer(); ~Framebuffer() override; - static uint32_t computeHash(const FramebufferInfo &info); + static size_t computeHash(const FramebufferInfo &info); void initialize(const FramebufferInfo &info); void destroy(); diff --git a/native/cocos/renderer/gfx-base/GFXInputAssembler.cpp b/native/cocos/renderer/gfx-base/GFXInputAssembler.cpp index 3bd538d3be..bd0975f019 100644 --- a/native/cocos/renderer/gfx-base/GFXInputAssembler.cpp +++ b/native/cocos/renderer/gfx-base/GFXInputAssembler.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#include + #include "base/CoreStd.h" #include "GFXBuffer.h" @@ -38,19 +40,17 @@ InputAssembler::InputAssembler() InputAssembler::~InputAssembler() = default; -uint32_t InputAssembler::computeAttributesHash() const { - // https://stackoverflow.com/questions/20511347/a-good-hash-function-for-a-vector - // 6: Attribute has 6 elements. - std::size_t seed = _attributes.size() * 6; +size_t InputAssembler::computeAttributesHash() const { + size_t seed = _attributes.size() * 6; for (const auto &attribute : _attributes) { - seed ^= std::hash{}(attribute.name) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(attribute.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= attribute.isNormalized + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= attribute.stream + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= attribute.isInstanced + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= attribute.location + 0x9e3779b9 + (seed << 6) + (seed >> 2); + boost::hash_combine(seed, attribute.name); + boost::hash_combine(seed, attribute.format); + boost::hash_combine(seed, attribute.isNormalized); + boost::hash_combine(seed, attribute.stream); + boost::hash_combine(seed, attribute.isInstanced); + boost::hash_combine(seed, attribute.location); } - return static_cast(seed); + return seed; } void InputAssembler::initialize(const InputAssemblerInfo &info) { diff --git a/native/cocos/renderer/gfx-base/GFXInputAssembler.h b/native/cocos/renderer/gfx-base/GFXInputAssembler.h index d892a37f0d..4d2871ac79 100644 --- a/native/cocos/renderer/gfx-base/GFXInputAssembler.h +++ b/native/cocos/renderer/gfx-base/GFXInputAssembler.h @@ -42,7 +42,7 @@ public: inline const BufferList & getVertexBuffers() const { return _vertexBuffers; } inline Buffer * getIndexBuffer() const { return _indexBuffer; } inline Buffer * getIndirectBuffer() const { return _indirectBuffer; } - inline uint32_t getAttributesHash() const { return _attributesHash; } + inline size_t getAttributesHash() const { return _attributesHash; } inline const DrawInfo &getDrawInfo() const { return _drawInfo; } @@ -66,10 +66,10 @@ protected: virtual void doInit(const InputAssemblerInfo &info) = 0; virtual void doDestroy() = 0; - uint32_t computeAttributesHash() const; + size_t computeAttributesHash() const; AttributeList _attributes; - uint32_t _attributesHash = 0; + size_t _attributesHash = 0; BufferList _vertexBuffers; Buffer * _indexBuffer{nullptr}; diff --git a/native/cocos/renderer/gfx-base/GFXRenderPass.cpp b/native/cocos/renderer/gfx-base/GFXRenderPass.cpp index 1bdb3d02f3..3f28ac9887 100644 --- a/native/cocos/renderer/gfx-base/GFXRenderPass.cpp +++ b/native/cocos/renderer/gfx-base/GFXRenderPass.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#include + #include "base/CoreStd.h" #include "GFXObject.h" @@ -40,84 +42,22 @@ RenderPass::RenderPass() RenderPass::~RenderPass() = default; // Based on render pass compatibility -uint32_t RenderPass::computeHash() { - // https://stackoverflow.com/questions/20511347/a-good-hash-function-for-a-vector - uint32_t seed = 0; - if (!_subpasses.empty()) { - for (const SubpassInfo &subPass : _subpasses) { - for (const uint32_t iaIndex : subPass.inputs) { - if (iaIndex >= _colorAttachments.size()) break; - seed += 2; - } - for (const uint32_t caIndex : subPass.colors) { - if (caIndex >= _colorAttachments.size()) break; - seed += 2; - } - for (const uint32_t raIndex : subPass.resolves) { - if (raIndex >= _colorAttachments.size()) break; - seed += 2; - } - for (const uint32_t paIndex : subPass.preserves) { - if (paIndex >= _colorAttachments.size()) break; - seed += 2; - } - if (subPass.depthStencil != INVALID_BINDING) { - seed += 2; - } - } - for (const SubpassInfo &subpass : _subpasses) { - for (const uint32_t iaIndex : subpass.inputs) { - if (iaIndex >= _colorAttachments.size()) break; - const ColorAttachment &ia = _colorAttachments[iaIndex]; - seed ^= static_cast(ia.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(ia.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - for (const uint32_t caIndex : subpass.colors) { - if (caIndex >= _colorAttachments.size()) break; - const ColorAttachment &ca = _colorAttachments[caIndex]; - seed ^= static_cast(ca.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(ca.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - for (const uint32_t raIndex : subpass.resolves) { - if (raIndex >= _colorAttachments.size()) break; - const ColorAttachment &ca = _colorAttachments[raIndex]; - seed ^= static_cast(ca.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(ca.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - for (const uint32_t paIndex : subpass.preserves) { - if (paIndex >= _colorAttachments.size()) break; - const ColorAttachment &ca = _colorAttachments[paIndex]; - seed ^= static_cast(ca.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(ca.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - if (subpass.depthStencil != INVALID_BINDING) { - if (subpass.depthStencil < _colorAttachments.size()) { - const auto &ds = _colorAttachments[subpass.depthStencil]; - seed ^= static_cast(ds.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(ds.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } else { - const auto &ds = _depthStencilAttachment; - seed ^= static_cast(ds.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(ds.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - } - } - } else { - seed = static_cast(_colorAttachments.size() * 2 + 2); - for (const ColorAttachment &colorAttachment : _colorAttachments) { - seed ^= static_cast(colorAttachment.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(colorAttachment.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - seed ^= static_cast(_depthStencilAttachment.format) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast(_depthStencilAttachment.sampleCount) + 0x9e3779b9 + (seed << 6) + (seed >> 2); +size_t RenderPass::computeHash() { + size_t seed = _colorAttachments.size() * 2 + 3; + for (const ColorAttachment &ca : _colorAttachments) { + boost::hash_combine(seed, ca.format); + boost::hash_combine(seed, ca.sampleCount); } + const auto &ds = _depthStencilAttachment; + boost::hash_combine(seed, ds.format); + boost::hash_combine(seed, ds.sampleCount); + boost::hash_combine(seed, _subpasses); return seed; } -uint32_t RenderPass::computeHash(const RenderPassInfo &info) { - std::hash hasher; - return utils::toUint(hasher(info)); +size_t RenderPass::computeHash(const RenderPassInfo &info) { + return Hasher()(info); } void RenderPass::initialize(const RenderPassInfo &info) { diff --git a/native/cocos/renderer/gfx-base/GFXRenderPass.h b/native/cocos/renderer/gfx-base/GFXRenderPass.h index 25a25df021..3f2b865a03 100644 --- a/native/cocos/renderer/gfx-base/GFXRenderPass.h +++ b/native/cocos/renderer/gfx-base/GFXRenderPass.h @@ -35,7 +35,7 @@ public: RenderPass(); ~RenderPass() override; - static uint32_t computeHash(const RenderPassInfo &info); + static size_t computeHash(const RenderPassInfo &info); void initialize(const RenderPassInfo &info); void destroy(); @@ -44,10 +44,10 @@ public: inline const DepthStencilAttachment &getDepthStencilAttachment() const { return _depthStencilAttachment; } inline const SubpassInfoList & getSubpasses() const { return _subpasses; } inline const SubpassDependencyList & getDependencies() const { return _dependencies; } - inline uint32_t getHash() const { return _hash; } + inline size_t getHash() const { return _hash; } protected: - uint32_t computeHash(); + size_t computeHash(); virtual void doInit(const RenderPassInfo &info) = 0; virtual void doDestroy() = 0; @@ -56,7 +56,7 @@ protected: DepthStencilAttachment _depthStencilAttachment; SubpassInfoList _subpasses; SubpassDependencyList _dependencies; - uint32_t _hash = 0; + size_t _hash = 0; }; } // namespace gfx diff --git a/native/cocos/renderer/gfx-base/GFXTexture.cpp b/native/cocos/renderer/gfx-base/GFXTexture.cpp index b8d769f00f..b1d4011c00 100644 --- a/native/cocos/renderer/gfx-base/GFXTexture.cpp +++ b/native/cocos/renderer/gfx-base/GFXTexture.cpp @@ -28,6 +28,7 @@ #include "GFXSwapchain.h" #include "GFXTexture.h" +#include namespace cc { namespace gfx { @@ -38,19 +39,17 @@ Texture::Texture() Texture::~Texture() = default; -uint32_t Texture::computeHash(const TextureInfo &info) { - std::hash hasher; - return utils::toUint(hasher(info)); +size_t Texture::computeHash(const TextureInfo &info) { + return Hasher()(info); } -uint32_t Texture::computeHash(const TextureViewInfo &info) { - std::hash hasher; - return utils::toUint(hasher(info)); +size_t Texture::computeHash(const TextureViewInfo &info) { + return Hasher()(info); } -uint32_t Texture::computeHash(const Texture *texture) { - uint32_t hash = texture->isTextureView() ? computeHash(texture->getViewInfo()) : computeHash(texture->getInfo()); - if (texture->_swapchain) hash ^= (texture->_swapchain->getObjectID()) + 0x9e3779b9 + (hash << 6) + (hash >> 2); +size_t Texture::computeHash(const Texture *texture) { + size_t hash = texture->isTextureView() ? computeHash(texture->getViewInfo()) : computeHash(texture->getInfo()); + if (texture->_swapchain) boost::hash_combine(hash, texture->_swapchain->getObjectID()); return hash; } @@ -100,7 +99,7 @@ void Texture::destroy() { _viewInfo = TextureViewInfo(); _isTextureView = false; - _size = _hash = 0; + _hash = _size = 0; } ///////////////////////////// Swapchain Specific ///////////////////////////// diff --git a/native/cocos/renderer/gfx-base/GFXTexture.h b/native/cocos/renderer/gfx-base/GFXTexture.h index 1ee7ac1782..7554042f6d 100644 --- a/native/cocos/renderer/gfx-base/GFXTexture.h +++ b/native/cocos/renderer/gfx-base/GFXTexture.h @@ -35,8 +35,8 @@ public: Texture(); ~Texture() override; - static uint32_t computeHash(const TextureInfo &info); - static uint32_t computeHash(const TextureViewInfo &info); + static size_t computeHash(const TextureInfo &info); + static size_t computeHash(const TextureViewInfo &info); void initialize(const TextureInfo &info); void initialize(const TextureViewInfo &info); @@ -48,7 +48,7 @@ public: inline bool isTextureView() const { return _isTextureView; } inline uint32_t getSize() const { return _size; } - inline uint32_t getHash() const { return _hash; } + inline size_t getHash() const { return _hash; } // convenient getter for common usages inline Format getFormat() const { return _info.format; } @@ -63,9 +63,9 @@ protected: virtual void doDestroy() = 0; virtual void doResize(uint32_t width, uint32_t height, uint32_t size) = 0; - static uint32_t computeHash(const Texture *texture); - static void initialize(const SwapchainTextureInfo &info, Texture *out); - virtual void doInit(const SwapchainTextureInfo &info) = 0; + static size_t computeHash(const Texture *texture); + static void initialize(const SwapchainTextureInfo &info, Texture *out); + virtual void doInit(const SwapchainTextureInfo &info) = 0; TextureInfo _info; TextureViewInfo _viewInfo; @@ -73,7 +73,7 @@ protected: Swapchain *_swapchain{nullptr}; bool _isTextureView{false}; uint32_t _size{0U}; - uint32_t _hash{0U}; + size_t _hash{0U}; }; } // namespace gfx diff --git a/native/cocos/renderer/gfx-base/states/GFXGlobalBarrier.cpp b/native/cocos/renderer/gfx-base/states/GFXGlobalBarrier.cpp index ea242cfa20..5b2684cf73 100644 --- a/native/cocos/renderer/gfx-base/states/GFXGlobalBarrier.cpp +++ b/native/cocos/renderer/gfx-base/states/GFXGlobalBarrier.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#include + #include "base/CoreStd.h" #include "GFXGlobalBarrier.h" @@ -31,22 +33,16 @@ namespace cc { namespace gfx { -GlobalBarrier::GlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) +GlobalBarrier::GlobalBarrier(const GlobalBarrierInfo &info, size_t hash) : GFXObject(ObjectType::GLOBAL_BARRIER) { _info = info; _hash = hash; } -uint32_t GlobalBarrier::computeHash(const GlobalBarrierInfo &info) { - auto seed = utils::toUint(info.prevAccesses.size() + info.nextAccesses.size()); - - for (const AccessType type : info.prevAccesses) { - seed ^= toNumber(type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - for (const AccessType type : info.nextAccesses) { - seed ^= toNumber(type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - +size_t GlobalBarrier::computeHash(const GlobalBarrierInfo &info) { + size_t seed = 2; + boost::hash_combine(seed, info.prevAccesses); + boost::hash_combine(seed, info.nextAccesses); return seed; } diff --git a/native/cocos/renderer/gfx-base/states/GFXGlobalBarrier.h b/native/cocos/renderer/gfx-base/states/GFXGlobalBarrier.h index d945642128..8b9d696d51 100644 --- a/native/cocos/renderer/gfx-base/states/GFXGlobalBarrier.h +++ b/native/cocos/renderer/gfx-base/states/GFXGlobalBarrier.h @@ -32,16 +32,16 @@ namespace gfx { class CC_DLL GlobalBarrier : public GFXObject { public: - GlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash); + GlobalBarrier(const GlobalBarrierInfo &info, size_t hash); - static uint32_t computeHash(const GlobalBarrierInfo &info); + static size_t computeHash(const GlobalBarrierInfo &info); inline const GlobalBarrierInfo &getInfo() const { return _info; } - inline const uint32_t & getHash() const { return _hash; } + inline const size_t & getHash() const { return _hash; } protected: GlobalBarrierInfo _info; - uint32_t _hash{0U}; + size_t _hash{0U}; }; } // namespace gfx diff --git a/native/cocos/renderer/gfx-base/states/GFXSampler.cpp b/native/cocos/renderer/gfx-base/states/GFXSampler.cpp index 6f26b69b5b..d3e8739909 100644 --- a/native/cocos/renderer/gfx-base/states/GFXSampler.cpp +++ b/native/cocos/renderer/gfx-base/states/GFXSampler.cpp @@ -30,14 +30,14 @@ namespace cc { namespace gfx { -Sampler::Sampler(const SamplerInfo &info, uint32_t hash) +Sampler::Sampler(const SamplerInfo &info, size_t hash) : GFXObject(ObjectType::SAMPLER) { _info = info; _hash = hash; } -uint32_t Sampler::computeHash(const SamplerInfo &info) { - uint32_t hash = toNumber(info.minFilter); +size_t Sampler::computeHash(const SamplerInfo &info) { + size_t hash = toNumber(info.minFilter); hash |= (toNumber(info.magFilter) << 2); hash |= (toNumber(info.mipFilter) << 4); hash |= (toNumber(info.addressU) << 6); diff --git a/native/cocos/renderer/gfx-base/states/GFXSampler.h b/native/cocos/renderer/gfx-base/states/GFXSampler.h index 4a203111cb..59b49f5dc0 100644 --- a/native/cocos/renderer/gfx-base/states/GFXSampler.h +++ b/native/cocos/renderer/gfx-base/states/GFXSampler.h @@ -33,16 +33,16 @@ namespace gfx { class CC_DLL Sampler : public GFXObject { public: - Sampler(const SamplerInfo &info, uint32_t hash); + Sampler(const SamplerInfo &info, size_t hash); - static uint32_t computeHash(const SamplerInfo &info); + static size_t computeHash(const SamplerInfo &info); inline const SamplerInfo &getInfo() const { return _info; } - inline const uint32_t & getHash() const { return _hash; } + inline const size_t & getHash() const { return _hash; } protected: SamplerInfo _info; - uint32_t _hash{0U}; + size_t _hash{0U}; }; } // namespace gfx diff --git a/native/cocos/renderer/gfx-base/states/GFXTextureBarrier.cpp b/native/cocos/renderer/gfx-base/states/GFXTextureBarrier.cpp index 8dcad8ca83..f7db9c92b6 100644 --- a/native/cocos/renderer/gfx-base/states/GFXTextureBarrier.cpp +++ b/native/cocos/renderer/gfx-base/states/GFXTextureBarrier.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#include + #include "base/CoreStd.h" #include "../GFXQueue.h" @@ -32,26 +34,19 @@ namespace cc { namespace gfx { -TextureBarrier::TextureBarrier(const TextureBarrierInfo &info, uint32_t hash) +TextureBarrier::TextureBarrier(const TextureBarrierInfo &info, size_t hash) : GFXObject(ObjectType::TEXTURE_BARRIER) { _info = info; _hash = hash; } -uint32_t TextureBarrier::computeHash(const TextureBarrierInfo &info) { - auto seed = utils::toUint(info.prevAccesses.size() + info.nextAccesses.size() + 3); - - for (const AccessType type : info.prevAccesses) { - seed ^= toNumber(type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - for (const AccessType type : info.nextAccesses) { - seed ^= toNumber(type) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - - seed ^= info.discardContents + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= (info.srcQueue ? toNumber(info.srcQueue->getType()) : 0U) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= (info.dstQueue ? toNumber(info.dstQueue->getType()) : 0U) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - +size_t TextureBarrier::computeHash(const TextureBarrierInfo &info) { + size_t seed = 5; + boost::hash_combine(seed, info.prevAccesses); + boost::hash_combine(seed, info.nextAccesses); + boost::hash_combine(seed, info.discardContents); + boost::hash_combine(seed, info.srcQueue); + boost::hash_combine(seed, info.dstQueue); return seed; } diff --git a/native/cocos/renderer/gfx-base/states/GFXTextureBarrier.h b/native/cocos/renderer/gfx-base/states/GFXTextureBarrier.h index e7ae287aca..146f8748d9 100644 --- a/native/cocos/renderer/gfx-base/states/GFXTextureBarrier.h +++ b/native/cocos/renderer/gfx-base/states/GFXTextureBarrier.h @@ -32,16 +32,16 @@ namespace gfx { class CC_DLL TextureBarrier : public GFXObject { public: - TextureBarrier(const TextureBarrierInfo &info, uint32_t hash); + TextureBarrier(const TextureBarrierInfo &info, size_t hash); - static uint32_t computeHash(const TextureBarrierInfo &info); + static size_t computeHash(const TextureBarrierInfo &info); inline const TextureBarrierInfo &getInfo() const { return _info; } - inline const uint32_t & getHash() const { return _hash; } + inline const size_t & getHash() const { return _hash; } protected: TextureBarrierInfo _info; - uint32_t _hash{0U}; + size_t _hash{0U}; }; } // namespace gfx diff --git a/native/cocos/renderer/gfx-empty/EmptyDevice.cpp b/native/cocos/renderer/gfx-empty/EmptyDevice.cpp index ef51116b69..870e064b77 100644 --- a/native/cocos/renderer/gfx-empty/EmptyDevice.cpp +++ b/native/cocos/renderer/gfx-empty/EmptyDevice.cpp @@ -136,15 +136,15 @@ PipelineState *EmptyDevice::createPipelineState() { return CC_NEW(EmptyPipelineState()); } -Sampler *EmptyDevice::createSampler(const SamplerInfo &info, uint32_t hash) { +Sampler *EmptyDevice::createSampler(const SamplerInfo &info, size_t hash) { return CC_NEW(Sampler(info, hash)); } -GlobalBarrier *EmptyDevice::createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) { +GlobalBarrier *EmptyDevice::createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) { return CC_NEW(GlobalBarrier(info, hash)); } -TextureBarrier *EmptyDevice::createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) { +TextureBarrier *EmptyDevice::createTextureBarrier(const TextureBarrierInfo &info, size_t hash) { return CC_NEW(TextureBarrier(info, hash)); } diff --git a/native/cocos/renderer/gfx-empty/EmptyDevice.h b/native/cocos/renderer/gfx-empty/EmptyDevice.h index 44dc1f4bd6..cc2834aff8 100644 --- a/native/cocos/renderer/gfx-empty/EmptyDevice.h +++ b/native/cocos/renderer/gfx-empty/EmptyDevice.h @@ -72,9 +72,9 @@ public: PipelineLayout * createPipelineLayout() override; PipelineState * createPipelineState() override; - Sampler * createSampler(const SamplerInfo &info, uint32_t hash) override; - GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) override; - TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) override; + Sampler * createSampler(const SamplerInfo &info, size_t hash) override; + GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) override; + TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, size_t hash) override; void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) override; void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) override; diff --git a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp index 262ba6b5d6..a08d5a0601 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp @@ -1194,7 +1194,7 @@ void cmdFuncGLES2CreateRenderPass(GLES2Device * /*device*/, GLES2GPURenderPass * statistics.storeSubpass = index; }; auto calculateLifeCycle = [&](GLES2GPURenderPass::AttachmentStatistics &statistics, uint32_t targetAttachment) { - for (size_t j = 0U; j < gpuRenderPass->subpasses.size(); ++j) { + for (uint32_t j = 0U; j < utils::toUint(gpuRenderPass->subpasses.size()); ++j) { auto &subpass = gpuRenderPass->subpasses[j]; for (size_t k = 0U; k < subpass.colors.size(); ++k) { if (subpass.colors[k] == targetAttachment) { @@ -1220,7 +1220,7 @@ void cmdFuncGLES2CreateRenderPass(GLES2Device * /*device*/, GLES2GPURenderPass * bool hasDepth = gpuRenderPass->depthStencilAttachment.format != Format::UNKNOWN; gpuRenderPass->statistics.resize(gpuRenderPass->colorAttachments.size() + hasDepth); - for (size_t i = 0U; i < gpuRenderPass->statistics.size(); ++i) { + for (uint32_t i = 0U; i < utils::toUint(gpuRenderPass->statistics.size()); ++i) { calculateLifeCycle(gpuRenderPass->statistics[i], i); CC_ASSERT(gpuRenderPass->statistics[i].loadSubpass != SUBPASS_EXTERNAL && gpuRenderPass->statistics[i].storeSubpass != SUBPASS_EXTERNAL); @@ -1440,7 +1440,7 @@ void cmdFuncGLES2CreateFramebuffer(GLES2Device *device, GLES2GPUFramebuffer *gpu gpuFBO->uberColorAttachmentIndices.clear(); bool hasDepth{gpuFBO->gpuRenderPass->depthStencilAttachment.format != Format::UNKNOWN}; - gpuFBO->uberDepthStencil = hasDepth ? gpuFBO->gpuColorTextures.size() : INVALID_BINDING; + gpuFBO->uberDepthStencil = hasDepth ? utils::toUint(gpuFBO->gpuColorTextures.size()) : INVALID_BINDING; for (uint32_t i = 0U; i < gpuFBO->gpuColorTextures.size(); ++i) { if (i == gpuFBO->uberFinalOutput) continue; const auto *gpuTexture = gpuFBO->gpuColorTextures[i]; diff --git a/native/cocos/renderer/gfx-gles2/GLES2Device.cpp b/native/cocos/renderer/gfx-gles2/GLES2Device.cpp index 085939c96b..c7ec4a80eb 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Device.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Device.cpp @@ -327,15 +327,15 @@ PipelineState *GLES2Device::createPipelineState() { return CC_NEW(GLES2PipelineState); } -Sampler *GLES2Device::createSampler(const SamplerInfo &info, uint32_t hash) { +Sampler *GLES2Device::createSampler(const SamplerInfo &info, size_t hash) { return CC_NEW(GLES2Sampler(info, hash)); } -GlobalBarrier *GLES2Device::createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) { +GlobalBarrier *GLES2Device::createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) { return CC_NEW(GlobalBarrier(info, hash)); } -TextureBarrier *GLES2Device::createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) { +TextureBarrier *GLES2Device::createTextureBarrier(const TextureBarrierInfo &info, size_t hash) { return CC_NEW(TextureBarrier(info, hash)); } diff --git a/native/cocos/renderer/gfx-gles2/GLES2Device.h b/native/cocos/renderer/gfx-gles2/GLES2Device.h index 3429c82001..118d12a0dd 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Device.h +++ b/native/cocos/renderer/gfx-gles2/GLES2Device.h @@ -100,9 +100,9 @@ protected: PipelineLayout * createPipelineLayout() override; PipelineState * createPipelineState() override; - Sampler * createSampler(const SamplerInfo &info, uint32_t hash) override; - GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) override; - TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) override; + Sampler * createSampler(const SamplerInfo &info, size_t hash) override; + GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) override; + TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, size_t hash) override; void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) override; void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) override; diff --git a/native/cocos/renderer/gfx-gles2/states/GLES2Sampler.cpp b/native/cocos/renderer/gfx-gles2/states/GLES2Sampler.cpp index c84a0ca16b..b99efc9035 100644 --- a/native/cocos/renderer/gfx-gles2/states/GLES2Sampler.cpp +++ b/native/cocos/renderer/gfx-gles2/states/GLES2Sampler.cpp @@ -30,7 +30,7 @@ namespace cc { namespace gfx { -GLES2Sampler::GLES2Sampler(const SamplerInfo &info, uint32_t hash) : Sampler(info, hash) { +GLES2Sampler::GLES2Sampler(const SamplerInfo &info, size_t hash) : Sampler(info, hash) { _typedID = generateObjectID(); _gpuSampler = CC_NEW(GLES2GPUSampler); diff --git a/native/cocos/renderer/gfx-gles2/states/GLES2Sampler.h b/native/cocos/renderer/gfx-gles2/states/GLES2Sampler.h index ec0c62e3bd..02fbe639da 100644 --- a/native/cocos/renderer/gfx-gles2/states/GLES2Sampler.h +++ b/native/cocos/renderer/gfx-gles2/states/GLES2Sampler.h @@ -36,7 +36,7 @@ class GLES2GPUSampler; class CC_GLES2_API GLES2Sampler final : public Sampler { public: - GLES2Sampler(const SamplerInfo &info, uint32_t hash); + GLES2Sampler(const SamplerInfo &info, size_t hash); ~GLES2Sampler() override; inline GLES2GPUSampler *gpuSampler() const { return _gpuSampler; } diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp index 1e2ea8b0f7..e10c53b2bc 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp @@ -320,15 +320,15 @@ PipelineState *GLES3Device::createPipelineState() { return CC_NEW(GLES3PipelineState); } -Sampler *GLES3Device::createSampler(const SamplerInfo &info, uint32_t hash) { +Sampler *GLES3Device::createSampler(const SamplerInfo &info, size_t hash) { return CC_NEW(GLES3Sampler(info, hash)); } -GlobalBarrier *GLES3Device::createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) { +GlobalBarrier *GLES3Device::createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) { return CC_NEW(GLES3GlobalBarrier(info, hash)); } -TextureBarrier *GLES3Device::createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) { +TextureBarrier *GLES3Device::createTextureBarrier(const TextureBarrierInfo &info, size_t hash) { return CC_NEW(TextureBarrier(info, hash)); } diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.h b/native/cocos/renderer/gfx-gles3/GLES3Device.h index 66c4583003..94c204dd5f 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Device.h +++ b/native/cocos/renderer/gfx-gles3/GLES3Device.h @@ -98,9 +98,9 @@ protected: PipelineLayout * createPipelineLayout() override; PipelineState * createPipelineState() override; - Sampler * createSampler(const SamplerInfo &info, uint32_t hash) override; - GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) override; - TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) override; + Sampler * createSampler(const SamplerInfo &info, size_t hash) override; + GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) override; + TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, size_t hash) override; void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) override; void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) override; diff --git a/native/cocos/renderer/gfx-gles3/states/GLES3GlobalBarrier.cpp b/native/cocos/renderer/gfx-gles3/states/GLES3GlobalBarrier.cpp index f485ba0b80..6a20fd527f 100644 --- a/native/cocos/renderer/gfx-gles3/states/GLES3GlobalBarrier.cpp +++ b/native/cocos/renderer/gfx-gles3/states/GLES3GlobalBarrier.cpp @@ -29,7 +29,7 @@ namespace cc { namespace gfx { -GLES3GlobalBarrier::GLES3GlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) : GlobalBarrier(info, hash) { +GLES3GlobalBarrier::GLES3GlobalBarrier(const GlobalBarrierInfo &info, size_t hash) : GlobalBarrier(info, hash) { _typedID = generateObjectID(); _gpuBarrier = CC_NEW(GLES3GPUGlobalBarrier); diff --git a/native/cocos/renderer/gfx-gles3/states/GLES3GlobalBarrier.h b/native/cocos/renderer/gfx-gles3/states/GLES3GlobalBarrier.h index fb9be2297e..4f4e8a2604 100644 --- a/native/cocos/renderer/gfx-gles3/states/GLES3GlobalBarrier.h +++ b/native/cocos/renderer/gfx-gles3/states/GLES3GlobalBarrier.h @@ -35,7 +35,7 @@ class GLES3GPUGlobalBarrier; class CC_GLES3_API GLES3GlobalBarrier : public GlobalBarrier { public: - explicit GLES3GlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash); + explicit GLES3GlobalBarrier(const GlobalBarrierInfo &info, size_t hash); ~GLES3GlobalBarrier() override; inline const GLES3GPUGlobalBarrier *gpuBarrier() const { return _gpuBarrier; } diff --git a/native/cocos/renderer/gfx-gles3/states/GLES3Sampler.cpp b/native/cocos/renderer/gfx-gles3/states/GLES3Sampler.cpp index 42bf542ee4..837178d389 100644 --- a/native/cocos/renderer/gfx-gles3/states/GLES3Sampler.cpp +++ b/native/cocos/renderer/gfx-gles3/states/GLES3Sampler.cpp @@ -30,7 +30,7 @@ namespace cc { namespace gfx { -GLES3Sampler::GLES3Sampler(const SamplerInfo &info, uint32_t hash) : Sampler(info, hash) { +GLES3Sampler::GLES3Sampler(const SamplerInfo &info, size_t hash) : Sampler(info, hash) { _typedID = generateObjectID(); _gpuSampler = CC_NEW(GLES3GPUSampler); diff --git a/native/cocos/renderer/gfx-gles3/states/GLES3Sampler.h b/native/cocos/renderer/gfx-gles3/states/GLES3Sampler.h index 70b7fdafe9..e49a0fa234 100644 --- a/native/cocos/renderer/gfx-gles3/states/GLES3Sampler.h +++ b/native/cocos/renderer/gfx-gles3/states/GLES3Sampler.h @@ -35,7 +35,7 @@ class GLES3GPUSampler; class CC_GLES3_API GLES3Sampler final : public Sampler { public: - explicit GLES3Sampler(const SamplerInfo &info, uint32_t hash); + explicit GLES3Sampler(const SamplerInfo &info, size_t hash); ~GLES3Sampler() override; inline GLES3GPUSampler *gpuSampler() const { return _gpuSampler; } diff --git a/native/cocos/renderer/gfx-metal/MTLDevice.h b/native/cocos/renderer/gfx-metal/MTLDevice.h index 7e8b8fb014..ea54d669f4 100644 --- a/native/cocos/renderer/gfx-metal/MTLDevice.h +++ b/native/cocos/renderer/gfx-metal/MTLDevice.h @@ -106,9 +106,9 @@ protected: DescriptorSetLayout *createDescriptorSetLayout() override; PipelineLayout *createPipelineLayout() override; PipelineState *createPipelineState() override; - GlobalBarrier *createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) override; - TextureBarrier *createTextureBarrier(const TextureBarrierInfo& info, uint32_t hash) override; - Sampler *createSampler(const SamplerInfo& info, uint32_t hash) override; + GlobalBarrier *createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) override; + TextureBarrier *createTextureBarrier(const TextureBarrierInfo& info, size_t hash) override; + Sampler *createSampler(const SamplerInfo& info, size_t hash) override; Swapchain *createSwapchain() override; void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint count) override; void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint count) override; diff --git a/native/cocos/renderer/gfx-metal/MTLDevice.mm b/native/cocos/renderer/gfx-metal/MTLDevice.mm index 7738f202b3..9031fbd54b 100644 --- a/native/cocos/renderer/gfx-metal/MTLDevice.mm +++ b/native/cocos/renderer/gfx-metal/MTLDevice.mm @@ -213,7 +213,7 @@ void CCMTLDevice::present() { //hold this pointer before update _currentFrameIndex _currentBufferPoolId = _currentFrameIndex; _currentFrameIndex = (_currentFrameIndex + 1) % MAX_FRAMES_IN_FLIGHT; - + std::vector> releaseQ; for (auto* swapchain: _swapchains) { auto drawable = swapchain->currentDrawable(); @@ -233,7 +233,7 @@ void CCMTLDevice::present() { [cmdBuffer presentDrawable:drawable]; [drawable release]; } - + [cmdBuffer addCompletedHandler:^(id commandBuffer) { onPresentCompleted(); }]; @@ -307,15 +307,15 @@ PipelineState *CCMTLDevice::createPipelineState() { return CC_NEW(CCMTLPipelineState); } -GlobalBarrier *CCMTLDevice::createGlobalBarrier(const GlobalBarrierInfo& info, uint32_t hash) { +GlobalBarrier *CCMTLDevice::createGlobalBarrier(const GlobalBarrierInfo& info, size_t hash) { return new GlobalBarrier(info, hash); } -TextureBarrier *CCMTLDevice::createTextureBarrier(const TextureBarrierInfo& info, uint32_t hash) { +TextureBarrier *CCMTLDevice::createTextureBarrier(const TextureBarrierInfo& info, size_t hash) { return new TextureBarrier(info, hash); } -Sampler *CCMTLDevice::createSampler(const SamplerInfo &info, uint32_t hash) { +Sampler *CCMTLDevice::createSampler(const SamplerInfo &info, size_t hash) { return new CCMTLSampler(info, hash); } diff --git a/native/cocos/renderer/gfx-metal/MTLSampler.h b/native/cocos/renderer/gfx-metal/MTLSampler.h index 1854a77218..dc4616eaca 100644 --- a/native/cocos/renderer/gfx-metal/MTLSampler.h +++ b/native/cocos/renderer/gfx-metal/MTLSampler.h @@ -34,7 +34,7 @@ namespace gfx { class CCMTLSampler final : public Sampler { public: - explicit CCMTLSampler(const SamplerInfo& info, uint32_t hash); + explicit CCMTLSampler(const SamplerInfo& info, size_t hash); ~CCMTLSampler(); CCMTLSampler() = delete; CCMTLSampler(const CCMTLSampler &)=delete; diff --git a/native/cocos/renderer/gfx-metal/MTLSampler.mm b/native/cocos/renderer/gfx-metal/MTLSampler.mm index d46c6423b2..a6a9de221f 100644 --- a/native/cocos/renderer/gfx-metal/MTLSampler.mm +++ b/native/cocos/renderer/gfx-metal/MTLSampler.mm @@ -34,7 +34,7 @@ namespace cc { namespace gfx { -CCMTLSampler::CCMTLSampler(const SamplerInfo& info, uint32_t hash) : Sampler(info, hash) { +CCMTLSampler::CCMTLSampler(const SamplerInfo& info, size_t hash) : Sampler(info, hash) { _typedID = generateObjectID(); MTLSamplerDescriptor *descriptor = [[MTLSamplerDescriptor alloc] init]; #if (CC_PLATFORM == CC_PLATFORM_MAC_OSX) diff --git a/native/cocos/renderer/gfx-metal/MTLUtils.mm b/native/cocos/renderer/gfx-metal/MTLUtils.mm index 5bad2d31e8..ae7aec3883 100644 --- a/native/cocos/renderer/gfx-metal/MTLUtils.mm +++ b/native/cocos/renderer/gfx-metal/MTLUtils.mm @@ -40,8 +40,8 @@ namespace cc { namespace gfx { namespace { -std::unordered_map pipelineMap; -std::unordered_map renderPassMap; +std::unordered_map pipelineMap; +std::unordered_map renderPassMap; EShLanguage getShaderStage(ShaderStageFlagBit type) { switch (type) { @@ -357,13 +357,13 @@ gfx::Shader *createShader(CCMTLDevice *device) { } CCMTLGPUPipelineState *getClearRenderPassPipelineState(CCMTLDevice *device, RenderPass * curPass) { - uint rpHash = curPass->getHash(); + size_t rpHash = curPass->getHash(); const auto iter = pipelineMap.find(rpHash); if(iter != pipelineMap.end()) { auto *ccMtlPiplineState = static_cast(iter->second); return ccMtlPiplineState->getGPUPipelineState(); } - + RenderPass* renderPass = nullptr; const auto rpIter = renderPassMap.find(rpHash); if(rpIter != renderPassMap.end()) { @@ -379,7 +379,7 @@ CCMTLGPUPipelineState *getClearRenderPassPipelineState(CCMTLDevice *device, Rend uint32_t color = subpasses[curSubpassIndex].colors[i]; colorAttachments.push_back(originAttachments[color]); } - + uint32_t depthStencil = subpasses[curSubpassIndex].depthStencil; if(depthStencil >= subpasses[curSubpassIndex].colors.size()) { depthStencilAttachment = curPass->getDepthStencilAttachment(); @@ -407,7 +407,7 @@ CCMTLGPUPipelineState *getClearRenderPassPipelineState(CCMTLDevice *device, Rend }); } } - + gfx::Attribute position = {"a_position", gfx::Format::RG32F, false, 0, false}; gfx::PipelineStateInfo pipelineInfo; pipelineInfo.primitive = gfx::PrimitiveMode::TRIANGLE_LIST; @@ -944,7 +944,7 @@ String mu::spirv2MSL(const uint32_t *ir, size_t word_count, auto active = msl.get_active_interface_variables(); spirv_cross::ShaderResources resources = msl.get_shader_resources(active); msl.set_enabled_interface_variables(std::move(active)); - + // Set some options. spirv_cross::CompilerMSL::Options options; options.enable_decoration_binding = true; @@ -1049,7 +1049,7 @@ String mu::spirv2MSL(const uint32_t *ir, size_t word_count, samplerIndex++; } } - + if(executionModel == spv::ExecutionModelFragment) { gpuShader->outputs.resize(resources.stage_outputs.size()); for(size_t i = 0; i < resources.stage_outputs.size(); i++) { @@ -1061,7 +1061,7 @@ String mu::spirv2MSL(const uint32_t *ir, size_t word_count, gpuShader->outputs[i].set = set; gpuShader->outputs[i].binding = attachmentIndex; } - + if(!resources.subpass_inputs.empty()) { gpuShader->inputs.resize(resources.subpass_inputs.size()); for(size_t i = 0; i < resources.subpass_inputs.size(); i++) { diff --git a/native/cocos/renderer/gfx-validator/DeviceValidator.cpp b/native/cocos/renderer/gfx-validator/DeviceValidator.cpp index 30b19796b9..4cbf8e84a7 100644 --- a/native/cocos/renderer/gfx-validator/DeviceValidator.cpp +++ b/native/cocos/renderer/gfx-validator/DeviceValidator.cpp @@ -225,15 +225,15 @@ PipelineState *DeviceValidator::createPipelineState() { return result; } -Sampler *DeviceValidator::createSampler(const SamplerInfo &info, uint32_t hash) { +Sampler *DeviceValidator::createSampler(const SamplerInfo &info, size_t hash) { return _actor->createSampler(info, hash); } -GlobalBarrier *DeviceValidator::createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) { +GlobalBarrier *DeviceValidator::createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) { return _actor->createGlobalBarrier(info, hash); } -TextureBarrier *DeviceValidator::createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) { +TextureBarrier *DeviceValidator::createTextureBarrier(const TextureBarrierInfo &info, size_t hash) { return _actor->createTextureBarrier(info, hash); } diff --git a/native/cocos/renderer/gfx-validator/DeviceValidator.h b/native/cocos/renderer/gfx-validator/DeviceValidator.h index 4c59de705c..3e72eb9e2a 100644 --- a/native/cocos/renderer/gfx-validator/DeviceValidator.h +++ b/native/cocos/renderer/gfx-validator/DeviceValidator.h @@ -71,9 +71,9 @@ public: PipelineLayout * createPipelineLayout() override; PipelineState * createPipelineState() override; - Sampler * createSampler(const SamplerInfo &info, uint32_t hash) override; - GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) override; - TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) override; + Sampler * createSampler(const SamplerInfo &info, size_t hash) override; + GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) override; + TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, size_t hash) override; void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) override; void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) override; diff --git a/native/cocos/renderer/gfx-vulkan/VKCommands.cpp b/native/cocos/renderer/gfx-vulkan/VKCommands.cpp index 161616ac67..8170e1fef4 100644 --- a/native/cocos/renderer/gfx-vulkan/VKCommands.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKCommands.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#include + #include "VKStd.h" #include "VKCommands.h" @@ -307,21 +309,16 @@ struct SubpassDependencyManager final { } void append(const VkSubpassDependency2 &dependency) { - uint32_t hash = 6U; - hash ^= (dependency.srcSubpass) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - hash ^= (dependency.srcStageMask) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - hash ^= (dependency.srcAccessMask) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - hash ^= (dependency.dstSubpass) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - hash ^= (dependency.dstStageMask) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - hash ^= (dependency.dstAccessMask) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - + // only cares about src/dst attributes + size_t hash = boost::hash_range(reinterpret_cast(&dependency.srcSubpass), + reinterpret_cast(&dependency.dependencyFlags)); if (_hashes.count(hash)) return; subpassDependencies.push_back(dependency); _hashes.insert(hash); } private: - unordered_set _hashes; + unordered_set _hashes; }; void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRenderPass) { @@ -603,7 +600,7 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende statistics.storeSubpass = index; }; auto calculateLifeCycle = [&](uint32_t targetAttachment, AttachmentStatistics &statistics) { - for (size_t j = 0U; j < subpassCount; ++j) { + for (uint32_t j = 0U; j < utils::toUint(subpassCount); ++j) { auto &subpass = subpassDescriptions[j]; for (size_t k = 0U; k < subpass.colorAttachmentCount; ++k) { if (subpass.pColorAttachments[k].attachment == targetAttachment) { @@ -628,7 +625,7 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende } }; attachmentStatistics.resize(colorAttachmentCount + hasDepth); - for (size_t i = 0U; i < colorAttachmentCount + hasDepth; ++i) { + for (uint32_t i = 0U; i < utils ::toUint(colorAttachmentCount + hasDepth); ++i) { attachmentStatistics[i].clear(); calculateLifeCycle(i, attachmentStatistics[i]); CC_ASSERT(attachmentStatistics[i].loadSubpass != VK_SUBPASS_EXTERNAL && @@ -654,7 +651,7 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende VkSubpassDependency2 beginDependency; uint32_t lastLoadSubpass{VK_SUBPASS_EXTERNAL}; bool beginDependencyValid{false}; - for (size_t i = 0U; i < colorAttachmentCount + hasDepth; ++i) { + for (uint32_t i = 0U; i < utils ::toUint(colorAttachmentCount + hasDepth); ++i) { auto &statistics = attachmentStatistics[i]; if (lastLoadSubpass != statistics.loadSubpass) { if (beginDependencyValid) dependencyManager.append(beginDependency); @@ -686,7 +683,7 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende VkSubpassDependency2 endDependency; uint32_t lastStoreSubpass{VK_SUBPASS_EXTERNAL}; bool endDependencyValid{false}; - for (size_t i = 0U; i < colorAttachmentCount + hasDepth; ++i) { + for (uint32_t i = 0U; i < utils ::toUint(colorAttachmentCount + hasDepth); ++i) { auto &statistics = attachmentStatistics[i]; if (lastStoreSubpass != statistics.storeSubpass) { if (endDependencyValid) dependencyManager.append(endDependency); diff --git a/native/cocos/renderer/gfx-vulkan/VKDevice.cpp b/native/cocos/renderer/gfx-vulkan/VKDevice.cpp index ce677dda3f..7b313f2e73 100644 --- a/native/cocos/renderer/gfx-vulkan/VKDevice.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKDevice.cpp @@ -726,15 +726,15 @@ PipelineState *CCVKDevice::createPipelineState() { return CC_NEW(CCVKPipelineState); } -Sampler *CCVKDevice::createSampler(const SamplerInfo &info, uint32_t hash) { +Sampler *CCVKDevice::createSampler(const SamplerInfo &info, size_t hash) { return CC_NEW(CCVKSampler(info, hash)); } -GlobalBarrier *CCVKDevice::createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) { +GlobalBarrier *CCVKDevice::createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) { return CC_NEW(CCVKGlobalBarrier(info, hash)); } -TextureBarrier *CCVKDevice::createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) { +TextureBarrier *CCVKDevice::createTextureBarrier(const TextureBarrierInfo &info, size_t hash) { return CC_NEW(CCVKTextureBarrier(info, hash)); } diff --git a/native/cocos/renderer/gfx-vulkan/VKDevice.h b/native/cocos/renderer/gfx-vulkan/VKDevice.h index b61a00b6c4..8a59fbb569 100644 --- a/native/cocos/renderer/gfx-vulkan/VKDevice.h +++ b/native/cocos/renderer/gfx-vulkan/VKDevice.h @@ -118,9 +118,9 @@ protected: PipelineLayout * createPipelineLayout() override; PipelineState * createPipelineState() override; - Sampler * createSampler(const SamplerInfo &info, uint32_t hash) override; - GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) override; - TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) override; + Sampler * createSampler(const SamplerInfo &info, size_t hash) override; + GlobalBarrier * createGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) override; + TextureBarrier *createTextureBarrier(const TextureBarrierInfo &info, size_t hash) override; void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) override; void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) override; diff --git a/native/cocos/renderer/gfx-vulkan/states/VKGlobalBarrier.cpp b/native/cocos/renderer/gfx-vulkan/states/VKGlobalBarrier.cpp index c4875d3ee7..3d317a3395 100644 --- a/native/cocos/renderer/gfx-vulkan/states/VKGlobalBarrier.cpp +++ b/native/cocos/renderer/gfx-vulkan/states/VKGlobalBarrier.cpp @@ -29,7 +29,7 @@ namespace cc { namespace gfx { -CCVKGlobalBarrier::CCVKGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash) : GlobalBarrier(info, hash) { +CCVKGlobalBarrier::CCVKGlobalBarrier(const GlobalBarrierInfo &info, size_t hash) : GlobalBarrier(info, hash) { _typedID = generateObjectID(); _gpuBarrier = CC_NEW(CCVKGPUGlobalBarrier); diff --git a/native/cocos/renderer/gfx-vulkan/states/VKGlobalBarrier.h b/native/cocos/renderer/gfx-vulkan/states/VKGlobalBarrier.h index e46fedbc11..15bea13a5b 100644 --- a/native/cocos/renderer/gfx-vulkan/states/VKGlobalBarrier.h +++ b/native/cocos/renderer/gfx-vulkan/states/VKGlobalBarrier.h @@ -35,7 +35,7 @@ class CCVKGPUGlobalBarrier; class CC_VULKAN_API CCVKGlobalBarrier : public GlobalBarrier { public: - explicit CCVKGlobalBarrier(const GlobalBarrierInfo &info, uint32_t hash); + explicit CCVKGlobalBarrier(const GlobalBarrierInfo &info, size_t hash); ~CCVKGlobalBarrier() override; inline const CCVKGPUGlobalBarrier *gpuBarrier() const { return _gpuBarrier; } diff --git a/native/cocos/renderer/gfx-vulkan/states/VKSampler.cpp b/native/cocos/renderer/gfx-vulkan/states/VKSampler.cpp index 39ff0dcf62..59bfda957d 100644 --- a/native/cocos/renderer/gfx-vulkan/states/VKSampler.cpp +++ b/native/cocos/renderer/gfx-vulkan/states/VKSampler.cpp @@ -30,7 +30,7 @@ namespace cc { namespace gfx { -CCVKSampler::CCVKSampler(const SamplerInfo &info, uint32_t hash) : Sampler(info, hash) { +CCVKSampler::CCVKSampler(const SamplerInfo &info, size_t hash) : Sampler(info, hash) { _typedID = generateObjectID(); _gpuSampler = CC_NEW(CCVKGPUSampler); diff --git a/native/cocos/renderer/gfx-vulkan/states/VKSampler.h b/native/cocos/renderer/gfx-vulkan/states/VKSampler.h index dc738df8f6..de9cfb60d1 100644 --- a/native/cocos/renderer/gfx-vulkan/states/VKSampler.h +++ b/native/cocos/renderer/gfx-vulkan/states/VKSampler.h @@ -35,7 +35,7 @@ class CCVKGPUSampler; class CC_VULKAN_API CCVKSampler final : public Sampler { public: - explicit CCVKSampler(const SamplerInfo &info, uint32_t hash); + explicit CCVKSampler(const SamplerInfo &info, size_t hash); ~CCVKSampler() override; inline CCVKGPUSampler *gpuSampler() const { return _gpuSampler; } diff --git a/native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.cpp b/native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.cpp index 716209fdae..65d2c75b32 100644 --- a/native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.cpp +++ b/native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.cpp @@ -30,7 +30,7 @@ namespace cc { namespace gfx { -CCVKTextureBarrier::CCVKTextureBarrier(const TextureBarrierInfo &info, uint32_t hash) : TextureBarrier(info, hash) { +CCVKTextureBarrier::CCVKTextureBarrier(const TextureBarrierInfo &info, size_t hash) : TextureBarrier(info, hash) { _typedID = generateObjectID(); _gpuBarrier = CC_NEW(CCVKGPUTextureBarrier); diff --git a/native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.h b/native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.h index ccb40454b9..021661f727 100644 --- a/native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.h +++ b/native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.h @@ -35,7 +35,7 @@ class CCVKGPUTextureBarrier; class CC_VULKAN_API CCVKTextureBarrier : public TextureBarrier { public: - explicit CCVKTextureBarrier(const TextureBarrierInfo &info, uint32_t hash); + explicit CCVKTextureBarrier(const TextureBarrierInfo &info, size_t hash); ~CCVKTextureBarrier() override; inline const CCVKGPUTextureBarrier *gpuBarrier() const { return _gpuBarrier; } diff --git a/native/cocos/renderer/pipeline/ClusterLightCulling.cpp b/native/cocos/renderer/pipeline/ClusterLightCulling.cpp index 7622c8dcef..ed3117e537 100644 --- a/native/cocos/renderer/pipeline/ClusterLightCulling.cpp +++ b/native/cocos/renderer/pipeline/ClusterLightCulling.cpp @@ -670,7 +670,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { bufferInfo.size = clusterBufferSize; bufferInfo.stride = clusterBufferSize; bufferInfo.flags = gfx::BufferFlagBit::NONE; - data.clusterBuffer = builder.create(fgStrHandleClusterBuffer, bufferInfo); + data.clusterBuffer = builder.create(fgStrHandleClusterBuffer, bufferInfo); builder.writeToBlackboard(fgStrHandleClusterBuffer, data.clusterBuffer); } // only rebuild cluster necceray @@ -689,7 +689,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { bufferInfo.size = atomicIndexBufferSize; bufferInfo.stride = atomicIndexBufferSize; bufferInfo.flags = gfx::BufferFlagBit::NONE; - data.globalIndexBuffer = builder.create(fgStrHandleClusterGlobalIndexBuffer, bufferInfo); + data.globalIndexBuffer = builder.create(fgStrHandleClusterGlobalIndexBuffer, bufferInfo); builder.writeToBlackboard(fgStrHandleClusterGlobalIndexBuffer, data.globalIndexBuffer); } // atomic counter for building the light grid @@ -735,7 +735,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { bufferInfo.size = _lightBufferStride * _lightBufferCount; bufferInfo.stride = _lightBufferStride; bufferInfo.flags = gfx::BufferFlagBit::NONE; - data.lightBuffer = builder.create(fgStrHandleClusterLightBuffer, bufferInfo); + data.lightBuffer = builder.create(fgStrHandleClusterLightBuffer, bufferInfo); builder.writeToBlackboard(fgStrHandleClusterLightBuffer, data.lightBuffer); _lightBufferResized = false; } @@ -753,7 +753,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { bufferInfo.size = lightIndicesBufferSize; bufferInfo.stride = lightIndicesBufferSize; bufferInfo.flags = gfx::BufferFlagBit::NONE; - data.lightIndexBuffer = builder.create(fgStrHandleClusterLightIndexBuffer, bufferInfo); + data.lightIndexBuffer = builder.create(fgStrHandleClusterLightIndexBuffer, bufferInfo); builder.writeToBlackboard(fgStrHandleClusterLightIndexBuffer, data.lightIndexBuffer); } data.lightIndexBuffer = builder.write(data.lightIndexBuffer); @@ -770,7 +770,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera* camera) { bufferInfo.size = lightGridBufferSize; bufferInfo.stride = lightGridBufferSize; bufferInfo.flags = gfx::BufferFlagBit::NONE; - data.lightGridBuffer = builder.create(fgStrHandleClusterLightGridBuffer, bufferInfo); + data.lightGridBuffer = builder.create(fgStrHandleClusterLightGridBuffer, bufferInfo); builder.writeToBlackboard(fgStrHandleClusterLightGridBuffer, data.lightGridBuffer); } data.lightGridBuffer = builder.write(data.lightGridBuffer); diff --git a/native/cocos/renderer/pipeline/PipelineStateManager.cpp b/native/cocos/renderer/pipeline/PipelineStateManager.cpp index f9f111b9d8..ab23e17100 100644 --- a/native/cocos/renderer/pipeline/PipelineStateManager.cpp +++ b/native/cocos/renderer/pipeline/PipelineStateManager.cpp @@ -30,7 +30,7 @@ namespace cc { namespace pipeline { -unordered_map PipelineStateManager::psoHashMap; +unordered_map PipelineStateManager::psoHashMap; gfx::PipelineState *PipelineStateManager::getOrCreatePipelineState(const scene::Pass * pass, gfx::Shader * shader, diff --git a/native/cocos/renderer/pipeline/PipelineStateManager.h b/native/cocos/renderer/pipeline/PipelineStateManager.h index 0a660175aa..26339d417d 100644 --- a/native/cocos/renderer/pipeline/PipelineStateManager.h +++ b/native/cocos/renderer/pipeline/PipelineStateManager.h @@ -41,7 +41,7 @@ public: static void destroyAll(); private: - static unordered_map psoHashMap; + static unordered_map psoHashMap; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/RenderPipeline.cpp b/native/cocos/renderer/pipeline/RenderPipeline.cpp index d72339bf78..befe33ff91 100644 --- a/native/cocos/renderer/pipeline/RenderPipeline.cpp +++ b/native/cocos/renderer/pipeline/RenderPipeline.cpp @@ -23,10 +23,12 @@ THE SOFTWARE. ****************************************************************************/ -#include "RenderPipeline.h" +#include + #include "InstancedBuffer.h" #include "PipelineStateManager.h" #include "RenderFlow.h" +#include "RenderPipeline.h" #include "gfx-base/GFXCommandBuffer.h" #include "gfx-base/GFXDescriptorSet.h" #include "gfx-base/GFXDescriptorSetLayout.h" @@ -161,7 +163,7 @@ gfx::Color RenderPipeline::getClearcolor(scene::Camera *camera) const { } void RenderPipeline::updateQuadVertexData(const Vec4 &viewport, gfx::Buffer *buffer) { - float vbData[16] = {0}; + float vbData[16] = {0}; genQuadVertexData(viewport, vbData); buffer->update(vbData, sizeof(vbData)); } @@ -170,17 +172,14 @@ gfx::InputAssembler *RenderPipeline::getIAByRenderArea(const gfx::Rect &renderAr auto bufferWidth{static_cast(_width)}; auto bufferHeight{static_cast(_height)}; Vec4 viewport{ - static_cast(renderArea.x) / bufferWidth, - static_cast(renderArea.y) / bufferHeight, - static_cast(renderArea.width) / bufferWidth, - static_cast(renderArea.height) / bufferHeight, + static_cast(renderArea.x) / bufferWidth, + static_cast(renderArea.y) / bufferHeight, + static_cast(renderArea.width) / bufferWidth, + static_cast(renderArea.height) / bufferHeight, }; - uint32_t hash = 4; - hash ^= *reinterpret_cast(&viewport.x) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - hash ^= *reinterpret_cast(&viewport.y) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - hash ^= *reinterpret_cast(&viewport.z) + 0x9e3779b9 + (hash << 6) + (hash >> 2); - hash ^= *reinterpret_cast(&viewport.w) + 0x9e3779b9 + (hash << 6) + (hash >> 2); + size_t hash = boost::hash_range(reinterpret_cast(&viewport.x), + reinterpret_cast(&viewport.x + 4)); const auto iter = _quadIA.find(hash); if (iter != _quadIA.end()) { diff --git a/native/cocos/renderer/pipeline/RenderPipeline.h b/native/cocos/renderer/pipeline/RenderPipeline.h index a14b8c1d88..2b187cd397 100644 --- a/native/cocos/renderer/pipeline/RenderPipeline.h +++ b/native/cocos/renderer/pipeline/RenderPipeline.h @@ -126,14 +126,14 @@ protected: scene::Model * _profiler{nullptr}; // has not initBuiltinRes, // create temporary default Texture to binding sampler2d - gfx::Texture * _defaultTexture{nullptr}; - uint _width{0}; - uint _height{0}; - gfx::Buffer * _quadIB{nullptr}; - std::vector _quadVB; - std::unordered_map _quadIA; + gfx::Texture * _defaultTexture{nullptr}; + uint _width{0}; + uint _height{0}; + gfx::Buffer * _quadIB{nullptr}; + std::vector _quadVB; + std::unordered_map _quadIA; - framegraph::FrameGraph _fg; + framegraph::FrameGraph _fg; unordered_map _renderPasses; // use cluster culling or not diff --git a/native/cocos/renderer/pipeline/common/BloomStage.cpp b/native/cocos/renderer/pipeline/common/BloomStage.cpp index a296d9d71f..0a3bec88fe 100644 --- a/native/cocos/renderer/pipeline/common/BloomStage.cpp +++ b/native/cocos/renderer/pipeline/common/BloomStage.cpp @@ -177,7 +177,7 @@ void BloomStage::render(scene::Camera *camera) { colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); - data.inputTexHandle = builder.create( + data.inputTexHandle = builder.create( RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); } @@ -193,7 +193,7 @@ void BloomStage::render(scene::Camera *camera) { colorTexInfo.width = static_cast(renderArea.width * shadingScale); colorTexInfo.height = static_cast(renderArea.height * shadingScale); - data.outputTexHandle = builder.create(prefilterTexHandle, colorTexInfo); + data.outputTexHandle = builder.create(prefilterTexHandle, colorTexInfo); } data.outputTexHandle = builder.write(data.outputTexHandle, colorAttachmentInfo); builder.writeToBlackboard(prefilterTexHandle, data.outputTexHandle); @@ -268,7 +268,7 @@ void BloomStage::render(scene::Camera *camera) { colorTexInfo.width = static_cast(renderArea.width * shadingScale); colorTexInfo.height = static_cast(renderArea.height * shadingScale); - data.outputTexHandle = builder.create(downsampleTexHandles[data.index], colorTexInfo); + data.outputTexHandle = builder.create(downsampleTexHandles[data.index], colorTexInfo); } data.outputTexHandle = builder.write(data.outputTexHandle, colorAttachmentInfo); builder.writeToBlackboard(downsampleTexHandles[data.index], data.outputTexHandle); @@ -345,7 +345,7 @@ void BloomStage::render(scene::Camera *camera) { colorTexInfo.width = static_cast(renderArea.width * shadingScale); colorTexInfo.height = static_cast(renderArea.height * shadingScale); - data.outputTexHandle = builder.create( + data.outputTexHandle = builder.create( upsampleTexHandles[data.index], colorTexInfo); } data.outputTexHandle = builder.write(data.outputTexHandle, colorAttachmentInfo); @@ -427,7 +427,7 @@ void BloomStage::render(scene::Camera *camera) { colorTexInfo.width = static_cast(renderArea.width * shadingScale); colorTexInfo.height = static_cast(renderArea.height * shadingScale); - data.bloomOutTexHandle = builder.create( + data.bloomOutTexHandle = builder.create( RenderPipeline::fgStrHandleBloomOutTexture, colorTexInfo); } data.bloomOutTexHandle = builder.write(data.bloomOutTexHandle, colorAttachmentInfo); diff --git a/native/cocos/renderer/pipeline/common/PostProcessStage.cpp b/native/cocos/renderer/pipeline/common/PostProcessStage.cpp index c96c494c11..bbdc124c8c 100644 --- a/native/cocos/renderer/pipeline/common/PostProcessStage.cpp +++ b/native/cocos/renderer/pipeline/common/PostProcessStage.cpp @@ -126,7 +126,7 @@ void PostProcessStage::render(scene::Camera *camera) { colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); - data.outColorTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); + data.outColorTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); } data.outColorTex = builder.read(data.outColorTex); @@ -156,7 +156,7 @@ void PostProcessStage::render(scene::Camera *camera) { static_cast(camera->window->getWidth() * shadingScale), static_cast(camera->window->getHeight() * shadingScale), }; - data.backBuffer = builder.create(fgStrHandlePostProcessOutTexture, textureInfo); + data.backBuffer = builder.create(fgStrHandlePostProcessOutTexture, textureInfo); data.backBuffer = builder.write(data.backBuffer, colorAttachmentInfo); builder.writeToBlackboard(fgStrHandlePostProcessOutTexture, data.backBuffer); diff --git a/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp b/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp index eb395ceaf8..247f7805df 100644 --- a/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp @@ -174,18 +174,18 @@ void GbufferStage::render(scene::Camera *camera) { }; for (int i = 0; i < DeferredPipeline::GBUFFER_COUNT - 1; ++i) { if (i != 0) { // positions & normals need more precision - data.gbuffer[i] = builder.create(DeferredPipeline::fgStrHandleGbufferTexture[i], gbufferInfoFloat); + data.gbuffer[i] = builder.create(DeferredPipeline::fgStrHandleGbufferTexture[i], gbufferInfoFloat); } else { - data.gbuffer[i] = builder.create(DeferredPipeline::fgStrHandleGbufferTexture[i], gbufferInfo); + data.gbuffer[i] = builder.create(DeferredPipeline::fgStrHandleGbufferTexture[i], gbufferInfo); } } auto subpassEnabled = _device->hasFeature(gfx::Feature::INPUT_ATTACHMENT_BENEFIT); if (subpassEnabled) { // when subpass enabled, the color result (gles2/gles3) will write to gbuffer[3] and the blit to color texture, so the format should be RGBA16F - data.gbuffer[3] = builder.create(DeferredPipeline::fgStrHandleGbufferTexture[3], gbufferInfoFloat); + data.gbuffer[3] = builder.create(DeferredPipeline::fgStrHandleGbufferTexture[3], gbufferInfoFloat); } else { - data.gbuffer[3] = builder.create(DeferredPipeline::fgStrHandleGbufferTexture[3], gbufferInfo); + data.gbuffer[3] = builder.create(DeferredPipeline::fgStrHandleGbufferTexture[3], gbufferInfo); } gfx::Color clearColor{0.0, 0.0, 0.0, 0.0}; @@ -209,7 +209,7 @@ void GbufferStage::render(scene::Camera *camera) { static_cast(pipeline->getWidth() * shadingScale), static_cast(pipeline->getHeight() * shadingScale), }; - data.depth = builder.create(DeferredPipeline::fgStrHandleOutDepthTexture, depthTexInfo); + data.depth = builder.create(DeferredPipeline::fgStrHandleOutDepthTexture, depthTexInfo); framegraph::RenderTargetAttachment::Descriptor depthInfo; depthInfo.usage = framegraph::RenderTargetAttachment::Usage::DEPTH_STENCIL; diff --git a/native/cocos/renderer/pipeline/deferred/LightingStage.cpp b/native/cocos/renderer/pipeline/deferred/LightingStage.cpp index b22a93ec63..ad57ed5da0 100644 --- a/native/cocos/renderer/pipeline/deferred/LightingStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/LightingStage.cpp @@ -376,7 +376,7 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); - data.outputTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); + data.outputTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); framegraph::RenderTargetAttachment::Descriptor colorAttachmentInfo; colorAttachmentInfo.usage = framegraph::RenderTargetAttachment::Usage::COLOR; @@ -465,7 +465,7 @@ void LightingStage::fgTransparent(scene::Camera *camera) { colorAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; colorAttachmentInfo.clearColor = clearColor; - data.outputTex = builder.create(DeferredPipeline::fgStrHandleOutColorTexture, colorTexInfo); + data.outputTex = builder.create(DeferredPipeline::fgStrHandleOutColorTexture, colorTexInfo); } data.outputTex = builder.write(data.outputTex, colorAttachmentInfo); @@ -486,7 +486,7 @@ void LightingStage::fgTransparent(scene::Camera *camera) { static_cast(pipeline->getWidth() * shadingScale), static_cast(pipeline->getHeight() * shadingScale), }; - data.depth = builder.create(DeferredPipeline::fgStrHandleOutDepthTexture, depthTexInfo); + data.depth = builder.create(DeferredPipeline::fgStrHandleOutDepthTexture, depthTexInfo); } data.depth = builder.write(data.depth, depthAttachmentInfo); builder.writeToBlackboard(DeferredPipeline::fgStrHandleOutDepthTexture, data.depth); @@ -595,7 +595,7 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { gfx::TextureUsageBit::SAMPLED | gfx::TextureUsageBit::TRANSFER_SRC | gfx::TextureUsageBit::TRANSFER_DST; colorTexInfo.width = _ssprTexWidth; colorTexInfo.height = _ssprTexHeight; - data.reflection = builder.create(reflectTexHandle, colorTexInfo); + data.reflection = builder.create(reflectTexHandle, colorTexInfo); framegraph::RenderTargetAttachment::Descriptor colorAttachmentInfo; colorAttachmentInfo.usage = framegraph::RenderTargetAttachment::Usage::COLOR; @@ -634,7 +634,7 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { colorTexInfo.usage = gfx::TextureUsageBit::STORAGE | gfx::TextureUsageBit::SAMPLED | gfx::TextureUsageBit::TRANSFER_SRC | gfx::TextureUsageBit::TRANSFER_DST; colorTexInfo.width = _ssprTexWidth; colorTexInfo.height = _ssprTexHeight; - data.reflection = builder.create(reflectTexHandle, colorTexInfo); + data.reflection = builder.create(reflectTexHandle, colorTexInfo); } data.reflection = builder.read(framegraph::TextureHandle(builder.readFromBlackboard(reflectTexHandle))); @@ -700,7 +700,7 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { colorTexInfo.usage = gfx::TextureUsageBit::STORAGE | gfx::TextureUsageBit::SAMPLED | gfx::TextureUsageBit::TRANSFER_SRC; colorTexInfo.width = _ssprTexWidth; colorTexInfo.height = _ssprTexHeight; - data.denoise = builder.create(denoiseTexHandle[_denoiseIndex], colorTexInfo); + data.denoise = builder.create(denoiseTexHandle[_denoiseIndex], colorTexInfo); data.denoise = builder.write(data.denoise); builder.writeToBlackboard(denoiseTexHandle[_denoiseIndex], data.denoise); diff --git a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp index 2520059048..803c3fc23d 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp +++ b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp @@ -168,7 +168,7 @@ void ForwardStage::render(scene::Camera *camera) { colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; colorTexInfo.width = static_cast(pipeline->getWidth() * shadingScale); colorTexInfo.height = static_cast(pipeline->getHeight() * shadingScale); - data.outputTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); + data.outputTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); framegraph::RenderTargetAttachment::Descriptor colorAttachmentInfo; colorAttachmentInfo.usage = framegraph::RenderTargetAttachment::Usage::COLOR; colorAttachmentInfo.clearColor = _clearColors[0]; @@ -202,7 +202,7 @@ void ForwardStage::render(scene::Camera *camera) { depthAttachmentInfo.clearStencil = camera->clearStencil; depthAttachmentInfo.endAccesses = {gfx::AccessType::DEPTH_STENCIL_ATTACHMENT_WRITE}; - data.depth = builder.create(RenderPipeline::fgStrHandleOutDepthTexture, depthTexInfo); + data.depth = builder.create(RenderPipeline::fgStrHandleOutDepthTexture, depthTexInfo); data.depth = builder.write(data.depth, depthAttachmentInfo); builder.writeToBlackboard(RenderPipeline::fgStrHandleOutDepthTexture, data.depth); builder.setViewport(pipeline->getViewport(camera), _renderArea); diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp index 0a16865e94..91710aa7a2 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp +++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp @@ -36,7 +36,7 @@ namespace cc { namespace pipeline { -std::unordered_map ShadowFlow::renderPassHashMap; +std::unordered_map ShadowFlow::renderPassHashMap; RenderFlowInfo ShadowFlow::initInfo = { "ShadowFlow", @@ -207,7 +207,7 @@ void ShadowFlow::initShadowFrameBuffer(RenderPipeline *pipeline, const scene::Li rpInfo.colorAttachments.emplace_back(colorAttachment); rpInfo.depthStencilAttachment = depthStencilAttachment; - uint rpHash = cc::gfx::RenderPass::computeHash(rpInfo); + size_t rpHash = cc::gfx::RenderPass::computeHash(rpInfo); auto iter = renderPassHashMap.find(rpHash); if (iter != renderPassHashMap.end()) { _renderPass = iter->second; diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.h b/native/cocos/renderer/pipeline/shadow/ShadowFlow.h index 5fa9ed6ce4..d91e1519a8 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.h +++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.h @@ -62,7 +62,7 @@ private: vector _validLights; vector _usedTextures; - static std::unordered_map renderPassHashMap; + static std::unordered_map renderPassHashMap; }; } // namespace pipeline } // namespace cc diff --git a/native/tools/bindings-generator/generator.py b/native/tools/bindings-generator/generator.py index 0d6a5e8795..9078ed3c74 100755 --- a/native/tools/bindings-generator/generator.py +++ b/native/tools/bindings-generator/generator.py @@ -1240,7 +1240,7 @@ class NativeClass(object): elif cursor.kind == cindex.CursorKind.FIELD_DECL: self.fields.append(NativeField(cursor, self.generator)) - if (self.is_struct or self._current_visibility == cindex.AccessSpecifier.PUBLIC) and NativeField.can_parse(cursor.type, self.generator, cursor): + if (self.is_struct or self._current_visibility == cindex.AccessSpecifier.PUBLIC) and NativeField.can_parse(cursor.type, self.generator, cursor) and not self.generator.should_skip(self.class_name, cursor.displayname): self.public_fields.append(NativeField(cursor, self.generator)) elif cursor.kind == cindex.CursorKind.CXX_ACCESS_SPEC_DECL: self._current_visibility = cursor.access_specifier diff --git a/native/tools/gfx-define-generator/generate.js b/native/tools/gfx-define-generator/generate.js index e747e7301b..aae8ea8081 100644 --- a/native/tools/gfx-define-generator/generate.js +++ b/native/tools/gfx-define-generator/generate.js @@ -76,6 +76,8 @@ while (enumCap) { header = header.replace(/\/\*.*?\*\//gs, ''); header = header.replace(/\s*[*&](.)/g, (_, c) => (c === '>' ? '' : ' ') + c); header = header.replace(/(?:\w*::)?vector<(.+?)>/g, '$1[]'); +// and preprocessors +header = header.replace(/\s*#(if|else|elif|end).*/gm, ''); const typedefRE = /^\s*using\s+(.+?)\s*=\s*(.+?);/gsm; const typedefMap = { lists: {}, others: [] }; @@ -122,7 +124,7 @@ const getMemberList = (() => { }; })(); -const structRE = /struct\s+(\w+).*?{\s*(.+?)\s*};/gs; +const structRE = /(struct\s+(?:\w+\(\w+\)\s+)?)(\w+).*?{\s*(.+?)\s*};/gs; const structMemberRE = /^\s*(const\w*\s*)?([\w[\]]+)\s+?(\w+)(?:\s*[={]?\s*(.*?)\s*}*\s*)?;(?:\s*\/\/\s*@ts-(.*?)$)?/gm; const structMap = {}; const replaceConstants = (() => { @@ -150,60 +152,62 @@ const getArrayValue = (decayedType, value) => { }; let structCap = structRE.exec(header); while (structCap) { - const struct = structMap[structCap[1]] = {}; + const struct = structMap[structCap[2]] = {}; struct.member = {}; - // structRE can not reliably extract the corrent member declaration range - const memberList = getMemberList(header, structCap.index); + // structRE can not reliably extract the correct member declaration range + const memberList = getMemberList(header, structCap.index + structCap[1].length); let memberCap = structMemberRE.exec(memberList); while (memberCap) { - - let type = memberCap[2]; - let readonly = false; - if (typedefMap.lists[type]) { - type = typedefMap.lists[type]; - } else { - type = type.replace(/(\b)(void)(\b)/, '$1number$1'); - type = type.replace(/(\b)(?:uint\w+?_t|int\w+?_t|float)(\b)/, '$1number$1'); - type = type.replace(/(\b)(?:bool)(\b)/, '$1boolean$2'); - type = type.replace(/(\b)(?:String)(\b)/, '$1string$2'); - } - if (memberCap[1]) { readonly = true; } - const isArray = type.endsWith('[]'); - const decayedType = isArray ? type.slice(0, -2) : type; - - let value = memberCap[4]; - let n = Number.parseInt(value); - if (!Number.isNaN(n)) { - if (!value.startsWith('0x')) { value = n; } // keep hexadecimal numbers - } else if (value) { - value = replaceConstants(value); - if (isArray) { value = getArrayValue(decayedType, value); } - } else { - if (isArray) { value = '[]'; } - else if (type === 'string') { value = '\'\''; } - else { value = `new ${type}()`; } - } - - const info = struct.member[memberCap[3]] = { - // all the overridable values - readonly, type, value, isArray, decayedType, - }; - - const directives = memberCap[5]; - if (directives) { - if (directives.startsWith('nullable')) { - info.type += ' | null'; - info.value = 'null'; - } else if (directives.startsWith('overrides')) { - let overrides = {}; - try { overrides = yaml.load(memberCap[5].slice(9)); } - catch (e) { console.warn(e); } - Object.assign(info, overrides); + if (!memberCap[3].startsWith('_')) { + let type = memberCap[2]; + let readonly = false; + if (typedefMap.lists[type]) { + type = typedefMap.lists[type]; + } else { + type = type.replace(/(\b)(void)(\b)/, '$1number$1'); + type = type.replace(/(\b)(?:uint\w+?_t|int\w+?_t|float)(\b)/, '$1number$1'); + type = type.replace(/(\b)(?:bool)(\b)/, '$1boolean$2'); + type = type.replace(/(\b)(?:String)(\b)/, '$1string$2'); } + if (memberCap[1]) { readonly = true; } + const isArray = type.endsWith('[]'); + const decayedType = isArray ? type.slice(0, -2) : type; + + let value = memberCap[4]; + let n = Number.parseInt(value); + if (!Number.isNaN(n)) { + if (!value.startsWith('0x')) { value = n; } // keep hexadecimal numbers + } else if (value) { + value = replaceConstants(value); + if (isArray) { value = getArrayValue(decayedType, value); } + } else { + if (isArray) { value = '[]'; } + else if (type === 'string') { value = '\'\''; } + else { value = `new ${type}()`; } + } + + const info = struct.member[memberCap[3]] = { + // all the overridable values + readonly, type, value, isArray, decayedType, + }; + + const directives = memberCap[5]; + if (directives) { + if (directives.startsWith('nullable')) { + info.type += ' | null'; + info.value = 'null'; + } else if (directives.startsWith('overrides')) { + let overrides = {}; + try { overrides = yaml.load(memberCap[5].slice(9)); } + catch (e) { console.warn(e); } + Object.assign(info, overrides); + } + } + + if (info.type === 'number' && info.value === 'null!') { info.value = 0; } } - if (info.type === 'number' && info.value === 'null!') { info.value = 0; } memberCap = structMemberRE.exec(memberList); } diff --git a/native/tools/tojs/gfx.ini b/native/tools/tojs/gfx.ini index 3e8013a5be..701792be42 100644 --- a/native/tools/tojs/gfx.ini +++ b/native/tools/tojs/gfx.ini @@ -72,7 +72,10 @@ skip = Buffer::[Buffer initialize update], Sampler::[Sampler], GlobalBarrier::[GlobalBarrier], TextureBarrier::[TextureBarrier], - Device::[Device copyBuffersToTexture copyTextureToBuffers createBuffer createTexture getInstance] + Device::[Device copyBuffersToTexture copyTextureToBuffers createBuffer createTexture getInstance], + TextureInfo::[_*], + TextureViewInfo::[_*], + BufferInfo::[_*] getter_setter = Device::[gfxAPI deviceName memoryStatus queue commandBuffer renderer vendor numDrawCalls numInstances numTris capabilities], Shader::[name stages attributes blocks samplers],