mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
+2
-2
@@ -50,7 +50,7 @@ jobs:
|
||||
- added|modified: '**/*.m'
|
||||
- added|modified: '**/*.mm'
|
||||
- added|modified: '**/*.c'
|
||||
- exclude: 'cocos/editor-support/dragonbones/**'
|
||||
- exclude: 'cocos/editor-support/**'
|
||||
- exclude: 'cocos/base/etc1.*'
|
||||
- exclude: 'cocos/base/etc2.*'
|
||||
- exclude: 'cocos/bindings/manual/jsb_global.cpp'
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
- added|modified|deleted: '**'
|
||||
skipedDebug:
|
||||
- added|modified|deleted: '**'
|
||||
- exclude: 'cocos/editor-support/dragonbones/**'
|
||||
- exclude: 'cocos/editor-support/**'
|
||||
- name: Install CMake & Clang Tidy
|
||||
run: |
|
||||
sudo apt install -y cmake llvm clang-tidy-11
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
inline bool operator<(IndexHandle const &rhs) const noexcept;
|
||||
inline bool operator==(IndexHandle const &rhs) const noexcept;
|
||||
inline bool operator!=(IndexHandle const &rhs) const noexcept;
|
||||
inline operator IndexType() const noexcept; // NOLINT(google-explicit-constructor) we need this implicity
|
||||
inline operator IndexType() const noexcept; // NOLINT(google-explicit-constructor) we need this implicitly
|
||||
|
||||
static IndexType constexpr UNINITIALIZED{std::numeric_limits<IndexType>::max()};
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#include "MemDef.h"
|
||||
#include "MemTracker.h"
|
||||
#include "StlAlloc.h"
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS)
|
||||
#include <Availability.h>
|
||||
#endif
|
||||
|
||||
// Global Interface Definitions
|
||||
|
||||
@@ -145,3 +148,9 @@ inline void *operator new(size_t sz) { return BareNewErroneouslyCalled(sz); }
|
||||
inline void operator delete(void *ptr) throw() { free(ptr); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_11_0)
|
||||
#define ALIGNAS(x)
|
||||
#else
|
||||
#define ALIGNAS(x) alignas(x)
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <cstdint>
|
||||
#include "Event.h"
|
||||
#include "concurrentqueue/concurrentqueue.h"
|
||||
#include "../memory/Memory.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
@@ -65,7 +66,7 @@ private:
|
||||
friend class MessageQueue;
|
||||
};
|
||||
|
||||
struct alignas(64) WriterContext final {
|
||||
struct ALIGNAS(64) WriterContext final {
|
||||
uint8_t * currentMemoryChunk{nullptr};
|
||||
Message * lastMessage{nullptr};
|
||||
uint32_t offset{0};
|
||||
@@ -73,7 +74,7 @@ struct alignas(64) WriterContext final {
|
||||
std::atomic<uint32_t> writtenMessageCount{0};
|
||||
};
|
||||
|
||||
struct alignas(64) ReaderContext final {
|
||||
struct ALIGNAS(64) ReaderContext final {
|
||||
uint8_t *currentMemoryChunk{nullptr};
|
||||
Message *lastMessage{nullptr};
|
||||
uint32_t offset{0};
|
||||
@@ -85,7 +86,7 @@ struct alignas(64) ReaderContext final {
|
||||
|
||||
// A single-producer single-consumer circular buffer queue.
|
||||
// Both the messages and their submitting data should be allocated from here.
|
||||
class alignas(64) MessageQueue final {
|
||||
class ALIGNAS(64) MessageQueue final {
|
||||
public:
|
||||
static constexpr uint32_t MEMORY_CHUNK_SIZE = 4096 * 16;
|
||||
|
||||
@@ -132,7 +133,7 @@ public:
|
||||
inline uint32_t getNewMessageCount() const noexcept { return _reader.newMessageCount; }
|
||||
|
||||
private:
|
||||
class alignas(64) MemoryAllocator final {
|
||||
class ALIGNAS(64) MemoryAllocator final {
|
||||
public:
|
||||
MemoryAllocator() = default;
|
||||
~MemoryAllocator() = default;
|
||||
|
||||
@@ -27,11 +27,10 @@
|
||||
|
||||
// clang-format off
|
||||
#include "base/Macros.h"
|
||||
#include "uv.h"
|
||||
// clang-format on
|
||||
|
||||
#include <functional>
|
||||
#include <shared_mutex>
|
||||
#include <uv.h>
|
||||
|
||||
namespace cc {
|
||||
|
||||
|
||||
@@ -28,10 +28,11 @@
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include "../memory/Memory.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
class alignas(16) ThreadSafeLinearAllocator final {
|
||||
class ALIGNAS(16) ThreadSafeLinearAllocator final {
|
||||
public:
|
||||
explicit ThreadSafeLinearAllocator(uint32_t size) noexcept;
|
||||
~ThreadSafeLinearAllocator();
|
||||
|
||||
@@ -25,15 +25,42 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "Value.h"
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include "Object.h"
|
||||
|
||||
namespace se {
|
||||
|
||||
#ifndef LIKELY
|
||||
#ifdef __GNUC__
|
||||
#define LIKELY(expr) __builtin_expect(!!(expr), 1)
|
||||
#else
|
||||
#define LIKELY(expr) expr
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
typename std::enable_if<std::is_unsigned<T>::value, T>::type
|
||||
fromDoubleToIntegral(double d) {
|
||||
return static_cast<T>(static_cast<int64_t>(d));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
typename std::enable_if<std::is_signed<T>::value, T>::type
|
||||
fromDoubleToIntegral(double d) {
|
||||
return static_cast<T>(d);
|
||||
}
|
||||
|
||||
#define CONVERT_TO_TYPE(type) fromDoubleToIntegral<type>(toDouble())
|
||||
|
||||
ValueArray EmptyValueArray; // NOLINT(readability-identifier-naming)
|
||||
|
||||
Value Value::Null = Value(Type::Null);
|
||||
Value Value::Undefined = Value(Type::Undefined);
|
||||
Value Value::Null = Value(Type::Null); //NOLINT(readability-identifier-naming)
|
||||
Value Value::Undefined = Value(Type::Undefined); //NOLINT(readability-identifier-naming)
|
||||
|
||||
Value::Value()
|
||||
: _type(Type::Undefined),
|
||||
@@ -377,37 +404,37 @@ void Value::setObject(const HandleObject &o, bool autoRootUnroot /* = false*/) {
|
||||
}
|
||||
|
||||
int8_t Value::toInt8() const {
|
||||
return static_cast<int8_t>(toDouble());
|
||||
return CONVERT_TO_TYPE(int8_t);
|
||||
}
|
||||
|
||||
uint8_t Value::toUint8() const {
|
||||
return static_cast<uint8_t>(toDouble());
|
||||
return CONVERT_TO_TYPE(uint8_t);
|
||||
}
|
||||
|
||||
int16_t Value::toInt16() const {
|
||||
return static_cast<int16_t>(toDouble());
|
||||
return CONVERT_TO_TYPE(int16_t);
|
||||
}
|
||||
|
||||
uint16_t Value::toUint16() const {
|
||||
return static_cast<uint16_t>(toDouble());
|
||||
return CONVERT_TO_TYPE(uint16_t);
|
||||
}
|
||||
|
||||
int32_t Value::toInt32() const {
|
||||
return static_cast<int32_t>(toDouble());
|
||||
return CONVERT_TO_TYPE(int32_t);
|
||||
}
|
||||
|
||||
uint32_t Value::toUint32() const {
|
||||
return static_cast<uint32_t>(toDouble());
|
||||
return CONVERT_TO_TYPE(uint32_t);
|
||||
}
|
||||
|
||||
int64_t Value::toInt64() const {
|
||||
assert(isBigInt() || isNumber());
|
||||
return _type == Type::BigInt ? _u._bigint : static_cast<uint64_t>(_u._number);
|
||||
return _type == Type::BigInt ? _u._bigint : CONVERT_TO_TYPE(int64_t);
|
||||
}
|
||||
|
||||
uint64_t Value::toUint64() const {
|
||||
assert(isBigInt() || isNumber());
|
||||
return _type == Type::BigInt ? static_cast<uint64_t>(_u._bigint) : static_cast<uint64_t>(_u._number);
|
||||
return _type == Type::BigInt ? static_cast<uint64_t>(_u._bigint) : CONVERT_TO_TYPE(uint64_t);
|
||||
}
|
||||
|
||||
float Value::toFloat() const {
|
||||
@@ -415,15 +442,15 @@ float Value::toFloat() const {
|
||||
}
|
||||
|
||||
double Value::toDouble() const {
|
||||
assert(_type == Type::Number || _type == Type::Boolean);
|
||||
// assert(_type != Type::BigInt);
|
||||
if (_type == Type::Boolean) {
|
||||
if (_u._boolean) {
|
||||
return 1.0;
|
||||
}
|
||||
return 0.0;
|
||||
assert(_type == Type::Number || _type == Type::Boolean || _type == Type::BigInt);
|
||||
if(LIKELY(_type == Type::Number)) {
|
||||
return _u._number;
|
||||
}
|
||||
return _u._number;
|
||||
if (_type == Type::BigInt) {
|
||||
// CC_LOG_WARNING("convert int64 to double");
|
||||
return static_cast<double>(_u._bigint);
|
||||
}
|
||||
return _u._boolean ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
bool Value::toBoolean() const {
|
||||
@@ -520,15 +547,15 @@ void Value::setNumber(double v) {
|
||||
}
|
||||
|
||||
unsigned int Value::toUint() const {
|
||||
return static_cast<unsigned int>(toDouble());
|
||||
return CONVERT_TO_TYPE(unsigned int);
|
||||
}
|
||||
|
||||
long Value::toLong() const { // NOLINT(google-runtime-int)
|
||||
return static_cast<long>(toDouble()); // NOLINT(google-runtime-int)
|
||||
return CONVERT_TO_TYPE(long);
|
||||
}
|
||||
|
||||
unsigned long Value::toUlong() const { // NOLINT(google-runtime-int)
|
||||
return static_cast<unsigned long>(toDouble()); // NOLINT(google-runtime-int)
|
||||
unsigned long Value::toUlong() const { // NOLINT(google-runtime-int)
|
||||
return CONVERT_TO_TYPE(unsigned long);
|
||||
}
|
||||
|
||||
double Value::toNumber() const {
|
||||
|
||||
@@ -941,7 +941,9 @@ inline bool sevalue_to_native(const se::Value &from, int64_t *to, se::Object * /
|
||||
#if CC_PLATFORM == CC_PLATFORM_MAC_IOS || CC_PLATFORM == CC_PLATFORM_MAC_OSX
|
||||
template <>
|
||||
inline bool sevalue_to_native(const se::Value &from, unsigned long *to, se::Object * /*ctx*/) {
|
||||
*to = static_cast<unsigned long>(from.toDouble());
|
||||
// on mac: unsiged long === uintptr_t
|
||||
CC_STATIC_ASSERT(sizeof(*to) == 8);
|
||||
*to = static_cast<unsigned long>(from.toUint64());
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -25,13 +25,12 @@
|
||||
|
||||
// clang-format off
|
||||
#include "base/Macros.h"
|
||||
// clang-format: off
|
||||
#include <string>
|
||||
#include "uv.h"
|
||||
// clang-format on
|
||||
|
||||
#include "jsb_global_init.h"
|
||||
#include <chrono>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
@@ -43,14 +42,17 @@
|
||||
#include "jsb_conversions.h"
|
||||
#include "xxtea/xxtea.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
using namespace cc; //NOLINT
|
||||
|
||||
se::Object *__jsbObj = nullptr; //NOLINT
|
||||
se::Object *__glObj = nullptr; //NOLINT
|
||||
|
||||
namespace {
|
||||
std::basic_string<unsigned char> xxteaKey;
|
||||
}
|
||||
static std::basic_string<unsigned char> xxteaKey;
|
||||
|
||||
void jsb_set_xxtea_key(const std::string &key) { //NOLINT
|
||||
xxteaKey.assign(key.begin(), key.end());
|
||||
|
||||
@@ -47,7 +47,6 @@ void fastSetPasses(void *buffer) {
|
||||
uint32_t passSize;
|
||||
AlignedPtr<cc::scene::Pass> passes[0];
|
||||
};
|
||||
// static_assert(offsetof(Heap, passes) == 12); // C++17 required
|
||||
|
||||
Heap *heap = reinterpret_cast<Heap *>(buffer);
|
||||
auto &passes = heap->selfPtr.get()->passes;
|
||||
|
||||
@@ -6,34 +6,26 @@
|
||||
|
||||
DRAGONBONES_NAMESPACE_BEGIN
|
||||
|
||||
class ActionFrame
|
||||
{
|
||||
class ActionFrame {
|
||||
public:
|
||||
unsigned frameStart;
|
||||
unsigned frameStart;
|
||||
std::vector<unsigned> actions;
|
||||
|
||||
bool operator < (const ActionFrame& b) const
|
||||
{
|
||||
bool operator<(const ActionFrame& b) const {
|
||||
return frameStart < b.frameStart;
|
||||
}
|
||||
};
|
||||
|
||||
class JSONDataParser : public DataParser
|
||||
{
|
||||
class JSONDataParser : public DataParser {
|
||||
DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(JSONDataParser)
|
||||
|
||||
protected:
|
||||
inline static bool _getBoolean(const rapidjson::Value& rawData, const char* key, bool defaultValue)
|
||||
{
|
||||
if (rawData.HasMember(key))
|
||||
{
|
||||
inline static bool _getBoolean(const rapidjson::Value& rawData, const char* key, bool defaultValue) {
|
||||
if (rawData.HasMember(key)) {
|
||||
const auto& value = rawData[key];
|
||||
if (value.IsBool())
|
||||
{
|
||||
if (value.IsBool()) {
|
||||
return value.GetBool();
|
||||
}
|
||||
else if (value.IsString())
|
||||
{
|
||||
} else if (value.IsString()) {
|
||||
const std::string stringValue = value.GetString();
|
||||
if (
|
||||
stringValue == "0" ||
|
||||
@@ -41,16 +33,12 @@ protected:
|
||||
stringValue == "" ||
|
||||
stringValue == "false" ||
|
||||
stringValue == "null" ||
|
||||
stringValue == "undefined"
|
||||
)
|
||||
{
|
||||
stringValue == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (value.IsNumber())
|
||||
{
|
||||
} else if (value.IsNumber()) {
|
||||
return value.GetInt() != 0;
|
||||
}
|
||||
}
|
||||
@@ -58,42 +46,33 @@ protected:
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline static unsigned _getNumber(const rapidjson::Value& rawData, const char* key, unsigned defaultValue)
|
||||
{
|
||||
if (rawData.HasMember(key))
|
||||
{
|
||||
inline static unsigned _getNumber(const rapidjson::Value& rawData, const char* key, unsigned defaultValue) {
|
||||
if (rawData.HasMember(key)) {
|
||||
return rawData[key].GetUint();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline static int _getNumber(const rapidjson::Value& rawData, const char* key, int defaultValue)
|
||||
{
|
||||
if (rawData.HasMember(key))
|
||||
{
|
||||
inline static int _getNumber(const rapidjson::Value& rawData, const char* key, int defaultValue) {
|
||||
if (rawData.HasMember(key)) {
|
||||
return rawData[key].GetInt();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline static float _getNumber(const rapidjson::Value& rawData, const char* key, float defaultValue)
|
||||
{
|
||||
if (rawData.HasMember(key) && rawData[key].IsNumber())
|
||||
{
|
||||
return rawData[key].GetDouble(); // cocos can not support GetFloat();
|
||||
inline static float _getNumber(const rapidjson::Value& rawData, const char* key, float defaultValue) {
|
||||
if (rawData.HasMember(key) && rawData[key].IsNumber()) {
|
||||
return rawData[key].GetFloat(); // cocos can not support GetFloat();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline static std::string _getString(const rapidjson::Value& rawData, const char* key, const std::string& defaultValue)
|
||||
{
|
||||
if (rawData.HasMember(key))
|
||||
{
|
||||
if (rawData[key].IsString())
|
||||
{
|
||||
inline static std::string _getString(const rapidjson::Value& rawData, const char* key, const std::string& defaultValue) {
|
||||
if (rawData.HasMember(key)) {
|
||||
if (rawData[key].IsString()) {
|
||||
return rawData[key].GetString();
|
||||
}
|
||||
|
||||
@@ -103,167 +82,156 @@ protected:
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline static int _getParameter(const rapidjson::Value& rawData, std::size_t index, int defaultValue)
|
||||
{
|
||||
if (rawData.Size() > index)
|
||||
{
|
||||
return rawData[(int) index].GetInt();
|
||||
inline static int _getParameter(const rapidjson::Value& rawData, std::size_t index, int defaultValue) {
|
||||
if (rawData.Size() > index) {
|
||||
return rawData[(int)index].GetInt();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline static float _getParameter(const rapidjson::Value& rawData, std::size_t index, float defaultValue)
|
||||
{
|
||||
if (rawData.Size() > index)
|
||||
{
|
||||
return rawData[(int) index].GetDouble();
|
||||
inline static float _getParameter(const rapidjson::Value& rawData, std::size_t index, float defaultValue) {
|
||||
if (rawData.Size() > index) {
|
||||
return rawData[(int)index].GetFloat();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline static std::string _getParameter(const rapidjson::Value& rawData, std::size_t index, const std::string& defaultValue)
|
||||
{
|
||||
if (rawData.Size() > index)
|
||||
{
|
||||
return rawData[(int) index].GetString();
|
||||
inline static std::string _getParameter(const rapidjson::Value& rawData, std::size_t index, const std::string& defaultValue) {
|
||||
if (rawData.Size() > index) {
|
||||
return rawData[(int)index].GetString();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned _rawTextureAtlasIndex;
|
||||
unsigned _rawTextureAtlasIndex;
|
||||
std::vector<BoneData*> _rawBones;
|
||||
DragonBonesData* _data;
|
||||
ArmatureData* _armature;
|
||||
BoneData* _bone;
|
||||
SlotData* _slot;
|
||||
SkinData* _skin;
|
||||
MeshDisplayData* _mesh;
|
||||
AnimationData* _animation;
|
||||
TimelineData* _timeline;
|
||||
rapidjson::Value* _rawTextureAtlases;
|
||||
DragonBonesData* _data;
|
||||
ArmatureData* _armature;
|
||||
BoneData* _bone;
|
||||
SlotData* _slot;
|
||||
SkinData* _skin;
|
||||
MeshDisplayData* _mesh;
|
||||
AnimationData* _animation;
|
||||
TimelineData* _timeline;
|
||||
rapidjson::Value* _rawTextureAtlases;
|
||||
|
||||
private:
|
||||
int _defaultColorOffset;
|
||||
int _prevClockwise;
|
||||
float _prevRotation;
|
||||
Matrix _helpMatrixA;
|
||||
Matrix _helpMatrixB;
|
||||
Transform _helpTransform;
|
||||
ColorTransform _helpColorTransform;
|
||||
Point _helpPoint;
|
||||
std::vector<float> _helpArray;
|
||||
std::vector<std::int16_t> _intArray;
|
||||
std::vector<float> _floatArray;
|
||||
std::vector<std::int16_t> _frameIntArray;
|
||||
std::vector<float> _frameFloatArray;
|
||||
std::vector<std::int16_t> _frameArray;
|
||||
std::vector<std::uint16_t> _timelineArray;
|
||||
std::vector<const rapidjson::Value*> _cacheRawMeshes;
|
||||
std::vector<MeshDisplayData*> _cacheMeshes;
|
||||
std::vector<ActionFrame> _actionFrames;
|
||||
std::map<std::string, const rapidjson::Value*> _weightSlotPose;
|
||||
std::map<std::string, const rapidjson::Value*> _weightBonePoses;
|
||||
std::map<std::string, std::vector<BoneData*>> _cacheBones;
|
||||
int _defaultColorOffset;
|
||||
int _prevClockwise;
|
||||
float _prevRotation;
|
||||
Matrix _helpMatrixA;
|
||||
Matrix _helpMatrixB;
|
||||
Transform _helpTransform;
|
||||
ColorTransform _helpColorTransform;
|
||||
Point _helpPoint;
|
||||
std::vector<float> _helpArray;
|
||||
std::vector<std::int16_t> _intArray;
|
||||
std::vector<float> _floatArray;
|
||||
std::vector<std::int16_t> _frameIntArray;
|
||||
std::vector<float> _frameFloatArray;
|
||||
std::vector<std::int16_t> _frameArray;
|
||||
std::vector<std::uint16_t> _timelineArray;
|
||||
std::vector<const rapidjson::Value*> _cacheRawMeshes;
|
||||
std::vector<MeshDisplayData*> _cacheMeshes;
|
||||
std::vector<ActionFrame> _actionFrames;
|
||||
std::map<std::string, const rapidjson::Value*> _weightSlotPose;
|
||||
std::map<std::string, const rapidjson::Value*> _weightBonePoses;
|
||||
std::map<std::string, std::vector<BoneData*>> _cacheBones;
|
||||
std::map<std::string, std::vector<ActionData*>> _slotChildActions;
|
||||
|
||||
public:
|
||||
JSONDataParser() :
|
||||
_rawTextureAtlasIndex(0),
|
||||
_rawBones(),
|
||||
_data(nullptr),
|
||||
_armature(nullptr),
|
||||
_bone(nullptr),
|
||||
_slot(nullptr),
|
||||
_skin(nullptr),
|
||||
_mesh(nullptr),
|
||||
_animation(nullptr),
|
||||
_timeline(nullptr),
|
||||
_rawTextureAtlases(nullptr),
|
||||
JSONDataParser() : _rawTextureAtlasIndex(0),
|
||||
_rawBones(),
|
||||
_data(nullptr),
|
||||
_armature(nullptr),
|
||||
_bone(nullptr),
|
||||
_slot(nullptr),
|
||||
_skin(nullptr),
|
||||
_mesh(nullptr),
|
||||
_animation(nullptr),
|
||||
_timeline(nullptr),
|
||||
_rawTextureAtlases(nullptr),
|
||||
|
||||
_defaultColorOffset(-1),
|
||||
_prevClockwise(0),
|
||||
_prevRotation(0.0f),
|
||||
_helpMatrixA(),
|
||||
_helpMatrixB(),
|
||||
_helpTransform(),
|
||||
_helpColorTransform(),
|
||||
_helpPoint(),
|
||||
_helpArray(),
|
||||
_intArray(),
|
||||
_floatArray(),
|
||||
_frameIntArray(),
|
||||
_frameFloatArray(),
|
||||
_frameArray(),
|
||||
_timelineArray(),
|
||||
_cacheMeshes(),
|
||||
_cacheRawMeshes(),
|
||||
_actionFrames(),
|
||||
_weightSlotPose(),
|
||||
_weightBonePoses(),
|
||||
_cacheBones(),
|
||||
_slotChildActions()
|
||||
{
|
||||
_defaultColorOffset(-1),
|
||||
_prevClockwise(0),
|
||||
_prevRotation(0.0f),
|
||||
_helpMatrixA(),
|
||||
_helpMatrixB(),
|
||||
_helpTransform(),
|
||||
_helpColorTransform(),
|
||||
_helpPoint(),
|
||||
_helpArray(),
|
||||
_intArray(),
|
||||
_floatArray(),
|
||||
_frameIntArray(),
|
||||
_frameFloatArray(),
|
||||
_frameArray(),
|
||||
_timelineArray(),
|
||||
_cacheMeshes(),
|
||||
_cacheRawMeshes(),
|
||||
_actionFrames(),
|
||||
_weightSlotPose(),
|
||||
_weightBonePoses(),
|
||||
_cacheBones(),
|
||||
_slotChildActions() {
|
||||
}
|
||||
virtual ~JSONDataParser()
|
||||
{
|
||||
virtual ~JSONDataParser() {
|
||||
}
|
||||
|
||||
private:
|
||||
void _getCurvePoint(
|
||||
float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4,
|
||||
float t,
|
||||
Point& result
|
||||
);
|
||||
void _samplingEasingCurve(const rapidjson::Value& curve, std::vector<float>& samples);
|
||||
void _parseActionDataInFrame(const rapidjson::Value& rawData, unsigned frameStart, BoneData* bone, SlotData* slot);
|
||||
void _mergeActionFrame(const rapidjson::Value& rawData, unsigned frameStart, ActionType type, BoneData* bone, SlotData* slot);
|
||||
float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4,
|
||||
float t,
|
||||
Point& result);
|
||||
void _samplingEasingCurve(const rapidjson::Value& curve, std::vector<float>& samples);
|
||||
void _parseActionDataInFrame(const rapidjson::Value& rawData, unsigned frameStart, BoneData* bone, SlotData* slot);
|
||||
void _mergeActionFrame(const rapidjson::Value& rawData, unsigned frameStart, ActionType type, BoneData* bone, SlotData* slot);
|
||||
unsigned _parseCacheActionFrame(ActionFrame& frame);
|
||||
|
||||
protected:
|
||||
virtual ArmatureData* _parseArmature(const rapidjson::Value& rawData, float scale);
|
||||
virtual BoneData* _parseBone(const rapidjson::Value& rawData);
|
||||
virtual ConstraintData* _parseIKConstraint(const rapidjson::Value& rawData);
|
||||
virtual SlotData* _parseSlot(const rapidjson::Value& rawData, int zOrder);
|
||||
virtual SkinData* _parseSkin(const rapidjson::Value& rawData);
|
||||
virtual DisplayData* _parseDisplay(const rapidjson::Value& rawData);
|
||||
virtual void _parsePivot(const rapidjson::Value& rawData, ImageDisplayData& display);
|
||||
virtual void _parseMesh(const rapidjson::Value& rawData, MeshDisplayData& mesh);
|
||||
virtual BoundingBoxData* _parseBoundingBox(const rapidjson::Value& rawData);
|
||||
virtual ArmatureData* _parseArmature(const rapidjson::Value& rawData, float scale);
|
||||
virtual BoneData* _parseBone(const rapidjson::Value& rawData);
|
||||
virtual ConstraintData* _parseIKConstraint(const rapidjson::Value& rawData);
|
||||
virtual SlotData* _parseSlot(const rapidjson::Value& rawData, int zOrder);
|
||||
virtual SkinData* _parseSkin(const rapidjson::Value& rawData);
|
||||
virtual DisplayData* _parseDisplay(const rapidjson::Value& rawData);
|
||||
virtual void _parsePivot(const rapidjson::Value& rawData, ImageDisplayData& display);
|
||||
virtual void _parseMesh(const rapidjson::Value& rawData, MeshDisplayData& mesh);
|
||||
virtual BoundingBoxData* _parseBoundingBox(const rapidjson::Value& rawData);
|
||||
virtual PolygonBoundingBoxData* _parsePolygonBoundingBox(const rapidjson::Value& rawData);
|
||||
virtual AnimationData* _parseAnimation(const rapidjson::Value& rawData);
|
||||
virtual TimelineData* _parseTimeline(
|
||||
const rapidjson::Value& rawData, const char* framesKey, TimelineType type,
|
||||
bool addIntOffset, bool addFloatOffset, unsigned frameValueCount,
|
||||
const std::function<unsigned(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount)>& frameParser
|
||||
);
|
||||
virtual void _parseBoneTimeline(const rapidjson::Value& rawData);
|
||||
virtual void _parseSlotTimeline(const rapidjson::Value& rawData);
|
||||
virtual unsigned _parseFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseTweenFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseActionFrame(const ActionFrame& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseZOrderFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseBoneAllFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseBoneTranslateFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseBoneRotateFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseBoneScaleFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseSlotDisplayFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseSlotColorFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseSlotFFDFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseIKConstraintFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual AnimationData* _parseAnimation(const rapidjson::Value& rawData);
|
||||
virtual TimelineData* _parseTimeline(
|
||||
const rapidjson::Value& rawData, const char* framesKey, TimelineType type,
|
||||
bool addIntOffset, bool addFloatOffset, unsigned frameValueCount,
|
||||
const std::function<unsigned(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount)>& frameParser);
|
||||
virtual void _parseBoneTimeline(const rapidjson::Value& rawData);
|
||||
virtual void _parseSlotTimeline(const rapidjson::Value& rawData);
|
||||
virtual unsigned _parseFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseTweenFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseActionFrame(const ActionFrame& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseZOrderFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseBoneAllFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseBoneTranslateFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseBoneRotateFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseBoneScaleFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseSlotDisplayFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseSlotColorFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseSlotFFDFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual unsigned _parseIKConstraintFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount);
|
||||
virtual const std::vector<ActionData*>& _parseActionData(const rapidjson::Value& rawData, ActionType type, BoneData* bone, SlotData* slot);
|
||||
virtual void _parseTransform(const rapidjson::Value& rawData, Transform& transform, float scale);
|
||||
virtual void _parseColorTransform(const rapidjson::Value& rawData, ColorTransform& color);
|
||||
virtual void _parseArray(const rapidjson::Value& rawData);
|
||||
virtual DragonBonesData* _parseDragonBonesData(const rapidjson::Value& rawData, float scale = 1.0f);
|
||||
virtual void _parseTextureAtlasData(const rapidjson::Value& rawData, TextureAtlasData& textureAtlasData, float scale = 1.0f);
|
||||
virtual void _parseTransform(const rapidjson::Value& rawData, Transform& transform, float scale);
|
||||
virtual void _parseColorTransform(const rapidjson::Value& rawData, ColorTransform& color);
|
||||
virtual void _parseArray(const rapidjson::Value& rawData);
|
||||
virtual DragonBonesData* _parseDragonBonesData(const rapidjson::Value& rawData, float scale = 1.0f);
|
||||
virtual void _parseTextureAtlasData(const rapidjson::Value& rawData, TextureAtlasData& textureAtlasData, float scale = 1.0f);
|
||||
|
||||
public:
|
||||
virtual DragonBonesData* parseDragonBonesData(const char* rawData, float scale = 1.0f) override;
|
||||
virtual bool parseTextureAtlasData(const char* rawData, TextureAtlasData& textureAtlasData, float scale = 1.0f) override;
|
||||
virtual bool parseTextureAtlasData(const char* rawData, TextureAtlasData& textureAtlasData, float scale = 1.0f) override;
|
||||
};
|
||||
|
||||
DRAGONBONES_NAMESPACE_END
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,7 +48,7 @@ static std::string s_resourcePath = "";
|
||||
// D:\aaa\bbb\ccc\ddd\abc.txt --> D:/aaa/bbb/ccc/ddd/abc.txt
|
||||
static inline std::string convertPathFormatToUnixStyle(const std::string &path) {
|
||||
std::string ret = path;
|
||||
auto len = ret.length();
|
||||
size_t len = ret.length();
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (ret[i] == '\\') {
|
||||
ret[i] = '/';
|
||||
|
||||
@@ -414,7 +414,8 @@ void CommandBufferAgent::copyBuffersToTexture(const uint8_t *const *buffers, Tex
|
||||
actor->copyBuffersToTexture(buffers, dst, regions, count);
|
||||
// TODO(PatriceJiang): C++17 replace with: CC_DELETE(allocator);
|
||||
_CC_DELETE_T_ALIGN(allocator, ThreadSafeLinearAllocator, alignof(ThreadSafeLinearAllocator));
|
||||
allocator = nullptr; });
|
||||
allocator = nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
void CommandBufferAgent::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include <cstddef>
|
||||
#include "base/CoreStd.h"
|
||||
#include "base/threading/MessageQueue.h"
|
||||
|
||||
@@ -109,6 +110,7 @@ void DeviceAgent::doDestroy() {
|
||||
}
|
||||
|
||||
_mainMessageQueue->terminateConsumerThread();
|
||||
|
||||
// NOTE: C++17 required when enable alignment
|
||||
// TODO(PatriceJiang): replace with: CC_SAFE_DELETE(_mainMessageQueue);
|
||||
_CC_DELETE_T_ALIGN(_mainMessageQueue, MessageQueue, alignof(MessageQueue)); // NOLINT
|
||||
@@ -302,7 +304,8 @@ void DeviceAgent::copyBuffersToTexture(const uint8_t *const *buffers, Texture *d
|
||||
actor->copyBuffersToTexture(buffers, dst, regions, count);
|
||||
// TODO(PatriceJiang): C++17 replace with: CC_DELETE(allocator);
|
||||
_CC_DELETE_T_ALIGN(allocator, ThreadSafeLinearAllocator, alignof(ThreadSafeLinearAllocator));
|
||||
allocator = nullptr; });
|
||||
allocator = nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
void DeviceAgent::copyTextureToBuffers(Texture *srcTexture, uint8_t *const *buffers, const BufferTextureCopy *regions, uint32_t count) {
|
||||
|
||||
@@ -1602,10 +1602,10 @@ static void doCreateFramebufferInstance(GLES3Device *device, GLES3GPUFramebuffer
|
||||
: gpuFBO->gpuDepthStencilTexture;
|
||||
}
|
||||
|
||||
outFBO->framebuffer.initialize(doCreateFramebuffer(device, gpuFBO->gpuColorTextures, colors.data(), colors.size(),
|
||||
outFBO->framebuffer.initialize(doCreateFramebuffer(device, gpuFBO->gpuColorTextures, colors.data(), utils::toUint(colors.size()),
|
||||
depthStencilTexture, resolves, depthStencilResolveTexture, &outFBO->resolveMask));
|
||||
if (outFBO->resolveMask) {
|
||||
size_t resolveCount = outFBO->resolveMask & GL_COLOR_BUFFER_BIT ? colors.size() : 0U;
|
||||
size_t resolveCount = outFBO->resolveMask & GL_COLOR_BUFFER_BIT ? utils::toUint(colors.size()) : 0U;
|
||||
GLES3GPUSwapchain *resolveSwapchain{getSwapchainIfExists(gpuFBO->gpuColorTextures, resolves, resolveCount)};
|
||||
if (!resolveSwapchain) {
|
||||
outFBO->resolveFramebuffer.initialize(doCreateFramebuffer(device, gpuFBO->gpuColorTextures, resolves, resolveCount, depthStencilResolveTexture));
|
||||
|
||||
@@ -57,12 +57,12 @@ void GLES3PipelineLayout::doInit(const PipelineLayoutInfo & /*info*/) {
|
||||
uint32_t binding = gpuSetLayout->dynamicBindings[j];
|
||||
if (indices[binding] < 0) indices[binding] = static_cast<int32_t>(offset + j);
|
||||
}
|
||||
_gpuPipelineLayout->dynamicOffsetOffsets.push_back(offset);
|
||||
_gpuPipelineLayout->dynamicOffsetOffsets.push_back(static_cast<uint>(offset));
|
||||
_gpuPipelineLayout->setLayouts.push_back(gpuSetLayout);
|
||||
offset += dynamicCount;
|
||||
}
|
||||
_gpuPipelineLayout->dynamicOffsetOffsets.push_back(offset);
|
||||
_gpuPipelineLayout->dynamicOffsetCount = offset;
|
||||
_gpuPipelineLayout->dynamicOffsetOffsets.push_back(static_cast<uint>(offset));
|
||||
_gpuPipelineLayout->dynamicOffsetCount = static_cast<uint>(offset);
|
||||
_gpuPipelineLayout->dynamicOffsets.resize(offset);
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,9 @@ void CCMTLCommandBuffer::updateDepthStencilState(uint32_t index, MTLRenderPassDe
|
||||
descriptor.stencilAttachment.storeAction = subpass.stencilResolveMode == ResolveMode::NONE ? MTLStoreActionMultisampleResolve : MTLStoreActionStoreAndMultisampleResolve;
|
||||
|
||||
descriptor.depthAttachment.depthResolveFilter = mu::toMTLDepthResolveMode(subpass.depthResolveMode);
|
||||
descriptor.stencilAttachment.stencilResolveFilter = mu::toMTLStencilResolveMode(subpass.stencilResolveMode);
|
||||
if (@available(iOS 12.0, *)) {
|
||||
descriptor.stencilAttachment.stencilResolveFilter = mu::toMTLStencilResolveMode(subpass.stencilResolveMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,9 @@ public:
|
||||
|
||||
vector<CCMTLGPUSubpassAttachment> inputs;
|
||||
vector<CCMTLGPUSubpassAttachment> outputs;
|
||||
|
||||
NSString *shaderSrc = nil;
|
||||
bool specializeColor = true;
|
||||
};
|
||||
|
||||
struct CCMTLGPUPipelineState {
|
||||
|
||||
@@ -75,6 +75,8 @@ void CCMTLShader::doDestroy() {
|
||||
id<MTLFunction> cmptFunc = _cmptFunction;
|
||||
_cmptFunction = nil;
|
||||
|
||||
[_gpuShader->shaderSrc release];
|
||||
|
||||
// [_specializedFragFuncs release];
|
||||
const auto specFragFuncs = [_specializedFragFuncs retain];
|
||||
[_specializedFragFuncs release];
|
||||
@@ -82,7 +84,7 @@ void CCMTLShader::doDestroy() {
|
||||
CC_SAFE_DELETE(_gpuShader);
|
||||
|
||||
std::function<void(void)> destroyFunc = [=]() {
|
||||
if([specFragFuncs count]) {
|
||||
if([specFragFuncs count] > 0) {
|
||||
for (NSString* key in [specFragFuncs allKeys]) {
|
||||
[[specFragFuncs valueForKey:key] release];
|
||||
}
|
||||
@@ -146,13 +148,31 @@ bool CCMTLShader::createMTLFunction(const ShaderStage &stage) {
|
||||
id<MTLLibrary> &library = isVertexShader ? _vertLibrary : isFragmentShader ? _fragLibrary : _cmptLibrary;
|
||||
String shaderStage = isVertexShader ? "vertex" : isFragmentShader ? "fragment" : "compute";
|
||||
|
||||
library = [mtlDevice newLibraryWithSource:shader options:opts error:&error];
|
||||
[opts release];
|
||||
if (!library) {
|
||||
CC_LOG_ERROR("Can not compile %s shader: %s", shaderStage.c_str(), [[error localizedDescription] UTF8String]);
|
||||
CC_LOG_ERROR("%s", stage.source.c_str());
|
||||
return false;
|
||||
if(isFragmentShader) {
|
||||
if(@available(iOS 11.0, *)) {
|
||||
library = [mtlDevice newLibraryWithSource:shader options:opts error:&error];
|
||||
if (!library) {
|
||||
CC_LOG_ERROR("Can not compile %s shader: %s", shaderStage.c_str(), [[error localizedDescription] UTF8String]);
|
||||
CC_LOG_ERROR("%s", stage.source.c_str());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
//delayed instance and pretend tobe specialized function.
|
||||
_gpuShader->specializeColor = false;
|
||||
_gpuShader->shaderSrc = [shader retain];
|
||||
assert(_gpuShader->shaderSrc != nil);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
library = [mtlDevice newLibraryWithSource:shader options:opts error:&error];
|
||||
if (!library) {
|
||||
CC_LOG_ERROR("Can not compile %s shader: %s", shaderStage.c_str(), [[error localizedDescription] UTF8String]);
|
||||
CC_LOG_ERROR("%s", stage.source.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[opts release];
|
||||
|
||||
if (isVertexShader) {
|
||||
_vertFunction = [library newFunctionWithName:@"main0"];
|
||||
@@ -201,22 +221,51 @@ id<MTLFunction> CCMTLShader::getSpecializedFragFunction(uint* index, int* val, u
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
notEvenHash += val[i] * std::pow(10, index[i]);
|
||||
}
|
||||
|
||||
NSString *hashStr = [NSString stringWithFormat:@"%d", notEvenHash];
|
||||
id<MTLFunction> specFunc = [_specializedFragFuncs objectForKey:hashStr];
|
||||
|
||||
if(!specFunc) {
|
||||
MTLFunctionConstantValues* constantValues = [MTLFunctionConstantValues new];
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
[constantValues setConstantValue:&val[i] type:MTLDataTypeInt atIndex:index[i]];
|
||||
if(_gpuShader->specializeColor) {
|
||||
MTLFunctionConstantValues* constantValues = [MTLFunctionConstantValues new];
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
[constantValues setConstantValue:&val[i] type:MTLDataTypeInt atIndex:index[i]];
|
||||
}
|
||||
|
||||
NSError * error = nil;
|
||||
id<MTLFunction> specFragFunc = [_fragLibrary newFunctionWithName:@"main0" constantValues:constantValues error:&error];
|
||||
[constantValues release];
|
||||
if (!specFragFunc) {
|
||||
CC_LOG_ERROR("Can not specialize shader: %s", [[error localizedDescription] UTF8String]);
|
||||
}
|
||||
[_specializedFragFuncs setObject:specFragFunc forKey:hashStr];
|
||||
} else {
|
||||
NSString* res = nil;
|
||||
for(size_t i = 0; i < count; i++) {
|
||||
NSString* targetStr = [NSString stringWithFormat:@"(indexOffset%u)", static_cast<unsigned int>(i)];
|
||||
NSString* index = [NSString stringWithFormat:@"(%u)", static_cast<unsigned int>(i)];
|
||||
res = [_gpuShader->shaderSrc stringByReplacingOccurrencesOfString:targetStr withString:index];
|
||||
|
||||
}
|
||||
id<MTLDevice> mtlDevice = id<MTLDevice>(CCMTLDevice::getInstance()->getMTLDevice());
|
||||
NSError * error = nil;
|
||||
MTLCompileOptions *opts = [[MTLCompileOptions alloc] init];
|
||||
// always current
|
||||
if(_fragLibrary) {
|
||||
[_fragLibrary release];
|
||||
}
|
||||
_fragLibrary = [mtlDevice newLibraryWithSource:res options:opts error:&error];
|
||||
if (!_fragLibrary) {
|
||||
CC_LOG_ERROR("Can not compile frag shader: %s", [[error localizedDescription] UTF8String]);
|
||||
}
|
||||
[opts release];
|
||||
_fragFunction = [_fragLibrary newFunctionWithName:@"main0"];
|
||||
if (!_fragFunction) {
|
||||
[_fragLibrary release];
|
||||
CC_LOG_ERROR("Can not create fragment function: main0");
|
||||
}
|
||||
|
||||
[_specializedFragFuncs setObject:_fragFunction forKey:hashStr];
|
||||
}
|
||||
|
||||
NSError * error = nil;
|
||||
id<MTLFunction> specFragFunc = [_fragLibrary newFunctionWithName:@"main0" constantValues:constantValues error:&error];
|
||||
[constantValues release];
|
||||
if (!specFragFunc) {
|
||||
CC_LOG_ERROR("Can not specialize shader: %s", [[error localizedDescription] UTF8String]);
|
||||
}
|
||||
[_specializedFragFuncs setObject:specFragFunc forKey:hashStr];
|
||||
}
|
||||
return [_specializedFragFuncs valueForKey:hashStr];
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ namespace gfx {
|
||||
class CCMTLGPUShader;
|
||||
class CCMTLDevice;
|
||||
namespace mu {
|
||||
|
||||
API_AVAILABLE(ios(12.0)) MTLMultisampleStencilResolveFilter toMTLStencilResolveMode(ResolveMode mode);
|
||||
|
||||
MTLResourceOptions toMTLResourceOption(MemoryUsage usage);
|
||||
MTLLoadAction toMTLLoadAction(LoadOp op);
|
||||
MTLStoreAction toMTLStoreAction(StoreOp op);
|
||||
@@ -47,7 +50,6 @@ MTLClearColor toMTLClearColor(const Color &clearColor);
|
||||
MTLVertexFormat toMTLVertexFormat(Format, bool);
|
||||
MTLPixelFormat toMTLPixelFormat(Format);
|
||||
MTLMultisampleDepthResolveFilter toMTLDepthResolveMode(ResolveMode mode);
|
||||
MTLMultisampleStencilResolveFilter toMTLStencilResolveMode(ResolveMode mode);
|
||||
// Because some pixel format is not supported on metal, so need to convert to supported pixel format.
|
||||
Format convertGFXPixelFormat(Format);
|
||||
MTLColorWriteMask toMTLColorWriteMask(ColorMask);
|
||||
|
||||
@@ -477,6 +477,7 @@ MTLMultisampleDepthResolveFilter mu::toMTLDepthResolveMode(ResolveMode mode) {
|
||||
}
|
||||
}
|
||||
|
||||
API_AVAILABLE(ios(12.0))
|
||||
MTLMultisampleStencilResolveFilter mu::toMTLStencilResolveMode(ResolveMode mode) {
|
||||
switch (mode) {
|
||||
case ResolveMode::SAMPLE_ZERO:
|
||||
@@ -1083,7 +1084,7 @@ String mu::spirv2MSL(const uint32_t *ir, size_t word_count,
|
||||
int32_t maxIndex = static_cast<int32_t>(resources.stage_outputs.size() - 1);
|
||||
for(int i = maxIndex; i >=0; --i) {
|
||||
String indexStr = std::to_string(i);
|
||||
output.insert(customCodingPos, "\nconstant int indexOffset" + indexStr + " [[ function_constant(" + indexStr + ") ]];\n");
|
||||
output.insert(customCodingPos, "\nconstant int indexOffset" + indexStr + " [[function_constant(" + indexStr + ")]];\n");
|
||||
output.replace(output.find("color(" + indexStr + ")"), 8, "color(indexOffset" + indexStr + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ void InstancedBuffer::merge(const scene::Model *model, const scene::SubModel *su
|
||||
}
|
||||
|
||||
if (instance.stride != stride) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
if (instance.count >= instance.capacity) { // resize buffers
|
||||
instance.capacity <<= 1;
|
||||
|
||||
@@ -232,6 +232,7 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm
|
||||
const auto validLightCount = _validLights.size();
|
||||
auto *const sceneData = _pipeline->getPipelineSceneData();
|
||||
auto *const sharedData = sceneData->getSharedData();
|
||||
size_t offset = 0;
|
||||
if (validLightCount > _lightBufferCount) {
|
||||
_firstLightBufferView->destroy();
|
||||
|
||||
@@ -241,7 +242,7 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm
|
||||
_firstLightBufferView->initialize({_lightBuffer, 0, UBOForwardLight::SIZE});
|
||||
}
|
||||
|
||||
for (unsigned l = 0, offset = 0; l < validLightCount; l++, offset += _lightBufferElementCount) {
|
||||
for (unsigned l = 0; l < validLightCount; l++, offset += _lightBufferElementCount) {
|
||||
auto * light = _validLights[l];
|
||||
const bool isSpotLight = scene::LightType::SPOT == light->getType();
|
||||
const auto *spotLight = isSpotLight ? static_cast<scene::SpotLight *>(light) : nullptr;
|
||||
|
||||
@@ -70,7 +70,7 @@ void ShadowFlow::render(scene::Camera *camera) {
|
||||
|
||||
lightCollecting(camera, &_validLights);
|
||||
|
||||
if (sceneData->getDirShadowObjects().empty()) {
|
||||
if (sceneData->getDirShadowObjects().empty() && sceneData->getRenderObjects().empty()) {
|
||||
clearShadowMap(camera);
|
||||
return;
|
||||
}
|
||||
@@ -256,5 +256,6 @@ void ShadowFlow::destroy() {
|
||||
|
||||
RenderFlow::destroy();
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace cc
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2021 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
@@ -10,10 +10,10 @@
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@@ -84,6 +84,7 @@ public:
|
||||
_instancedBuffer = {buffer, size};
|
||||
_instanceAttributeBlock = std::move(block);
|
||||
_instanceAttributes = attributes;
|
||||
_transformUpdated = true;
|
||||
}
|
||||
inline void setOctreeNode(OctreeNode *node) { _octreeNode = node; }
|
||||
inline void setScene(RenderScene *scene) { _scene = scene; }
|
||||
|
||||
Reference in New Issue
Block a user