mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 15:42:39 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 47ebc462e5 | |||
| b4bea55859 | |||
| 82f13c86e9 | |||
| 0fd910220e | |||
| 557b06f7e6 | |||
| b46553e615 |
@@ -115,7 +115,7 @@ export class TextProcessing {
|
||||
const maxValue = Math.max(outputLayoutData.canvasSize.width, outputLayoutData.canvasSize.height);
|
||||
const canvasScaleToMaxSizeRatio = MAX_SIZE / maxValue;
|
||||
this._fontScale *= canvasScaleToMaxSizeRatio;
|
||||
this._fontScale = Math.max(1, this._fontScale);
|
||||
this._fontScale = Math.max(0.1, this._fontScale);
|
||||
}
|
||||
|
||||
this._updatePaddingRect(style, outputLayoutData);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <bitset>
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include "base/Macros.h"
|
||||
#include "base/TypeDef.h"
|
||||
@@ -145,10 +146,27 @@ CC_FORCE_INLINE Tgt bit_cast(const Src &src) { // NOLINT(readability-identifier-
|
||||
Tgt tgt;
|
||||
// Load src into registers first. This allows the memcpy to be elided by CUDA.
|
||||
const Src staged = src;
|
||||
memcpy(&tgt, &staged, sizeof(Tgt));
|
||||
std::memcpy(&tgt, &staged, sizeof(Tgt));
|
||||
return tgt;
|
||||
}
|
||||
|
||||
// Map a float to a uint32 whose unsigned-integer ordering matches the float's
|
||||
// numeric ordering (the classic radix-sort "flip"):
|
||||
// * non-negative: flip the sign bit
|
||||
// * negative: complement all bits
|
||||
// This maps [-inf, -0.0] to [0, 2^31) and [+0.0, +inf] to [2^31, 2^32), so the
|
||||
// unsigned comparison orders floats correctly. NaN must be excluded by the caller.
|
||||
//
|
||||
// Requires IEEE 754 binary32 (32-bit) floats, which every Cocos platform has.
|
||||
static_assert(sizeof(float) == sizeof(uint32_t), "float must be 32-bit");
|
||||
static_assert(std::numeric_limits<float>::is_iec559, "float must be IEEE 754");
|
||||
|
||||
CC_FORCE_INLINE uint32_t floatToSortableUint(float value) {
|
||||
constexpr uint32_t signBit = 0x80000000U;
|
||||
const auto bits = bit_cast<uint32_t>(value);
|
||||
return (bits & signBit) ? ~bits : (bits ^ signBit);
|
||||
}
|
||||
|
||||
} // namespace numext
|
||||
|
||||
// Following the Arm ACLE arm_neon.h should also include arm_fp16.h but not all
|
||||
@@ -164,7 +182,7 @@ struct HalfRaw {
|
||||
#if defined(CC_HAS_ARM64_FP16_SCALAR_ARITHMETIC)
|
||||
explicit HalfRaw(uint16_t raw) : x(numext::bit_cast<__fp16>(raw)) {
|
||||
}
|
||||
__fp16 x;
|
||||
__fp16 x; // NOLINT(modernize-use-default-member-init)
|
||||
#else
|
||||
explicit constexpr HalfRaw(uint16_t raw) : x(raw) {}
|
||||
uint16_t x; // NOLINT(modernize-use-default-member-init)
|
||||
|
||||
@@ -751,7 +751,19 @@ void SpineSkeletonInstance::resizeSlotRegion(const spine::String &slotName, uint
|
||||
releaseSlotCacheInfo(cacheInfo);
|
||||
}
|
||||
_slotTextureSet.put(slot, info);
|
||||
|
||||
auto &bones = _skeleton->getBones();
|
||||
const size_t boneCount = bones.size();
|
||||
std::vector<bool> activeBackup(boneCount);
|
||||
for (size_t i = 0; i < boneCount; ++i) {
|
||||
activeBackup[i] = bones[i]->isActive();
|
||||
}
|
||||
|
||||
_skeleton->updateCache();
|
||||
|
||||
for (size_t i = 0; i < boneCount; ++i) {
|
||||
bones[i]->setActive(activeBackup[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void SpineSkeletonInstance::setSlotTexture(const spine::String &slotName, const spine::String& textureUuid) {
|
||||
|
||||
@@ -73,6 +73,15 @@ struct CC_DLL RenderPass {
|
||||
uint32_t hash = 0;
|
||||
float depth = 0.0F;
|
||||
uint32_t shaderID = 0;
|
||||
/**
|
||||
* Packed sort keys, computed once in RenderQueue::insertRenderPass so the
|
||||
* comparator degenerates to a single uint64 compare.
|
||||
* opaque: primaryKey = hash, secondaryKey = depthKey << 32 | shaderID
|
||||
* transparent: primaryKey = priority << 32 | hash, secondaryKey = ~depthKey << 32 | shaderID
|
||||
* depthKey is the order-preserving uint32 mapping of depth.
|
||||
*/
|
||||
uint64_t primaryKey = 0;
|
||||
uint64_t secondaryKey = 0;
|
||||
uint32_t passIndex = 0;
|
||||
const scene::SubModel *subModel = nullptr;
|
||||
};
|
||||
@@ -175,35 +184,17 @@ using RenderQueueDescList = ccstd::vector<IntrusivePtr<RenderQueueDesc>>;
|
||||
uint32_t getPhaseID(const ccstd::string &phase);
|
||||
|
||||
inline bool opaqueCompareFn(const RenderPass &a, const RenderPass &b) {
|
||||
if (a.hash != b.hash) {
|
||||
return a.hash < b.hash;
|
||||
if (a.primaryKey != b.primaryKey) {
|
||||
return a.primaryKey < b.primaryKey;
|
||||
}
|
||||
|
||||
CC_ASSERT(!std::isnan(a.depth) && !std::isnan(b.depth));
|
||||
|
||||
if (a.depth != b.depth) {
|
||||
return a.depth < b.depth;
|
||||
}
|
||||
|
||||
return a.shaderID < b.shaderID;
|
||||
return a.secondaryKey < b.secondaryKey;
|
||||
}
|
||||
|
||||
inline bool transparentCompareFn(const RenderPass &a, const RenderPass &b) {
|
||||
if (a.priority != b.priority) {
|
||||
return a.priority < b.priority;
|
||||
if (a.primaryKey != b.primaryKey) {
|
||||
return a.primaryKey < b.primaryKey;
|
||||
}
|
||||
|
||||
if (a.hash != b.hash) {
|
||||
return a.hash < b.hash;
|
||||
}
|
||||
|
||||
CC_ASSERT(!std::isnan(a.depth) && !std::isnan(b.depth));
|
||||
|
||||
if (a.depth != b.depth) {
|
||||
return b.depth < a.depth;
|
||||
}
|
||||
|
||||
return a.shaderID < b.shaderID;
|
||||
return a.secondaryKey < b.secondaryKey;
|
||||
}
|
||||
|
||||
inline uint32_t convertPhase(const ccstd::vector<ccstd::string> &stages) {
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
|
||||
#include "RenderQueue.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#include "PipelineSceneData.h"
|
||||
#include "PipelineStateManager.h"
|
||||
#include "RenderPipeline.h"
|
||||
#include "base/Utils.h"
|
||||
#include "gfx-base/GFXCommandBuffer.h"
|
||||
#include "gfx-base/GFXDevice.h"
|
||||
#include "gfx-base/GFXShader.h"
|
||||
@@ -60,7 +62,28 @@ bool RenderQueue::insertRenderPass(const RenderObject &renderObj, uint32_t subMo
|
||||
auto shaderId = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(subModel->getShader(passIdx)));
|
||||
const auto hash = (0 << 30) | (passPriority << 16) | (modelPriority << 8) | passIdx;
|
||||
const auto priority = renderObj.model->getPriority();
|
||||
RenderPass renderPass = {priority, hash, renderObj.depth, shaderId, passIdx, subModel};
|
||||
RenderPass renderPass{};
|
||||
renderPass.priority = priority;
|
||||
renderPass.hash = hash;
|
||||
renderPass.depth = renderObj.depth;
|
||||
renderPass.shaderID = shaderId;
|
||||
renderPass.passIndex = passIdx;
|
||||
renderPass.subModel = subModel;
|
||||
|
||||
/**
|
||||
* Pack the sort keys once here so the comparator only compares uint64 keys.
|
||||
* secondaryKey: depthKey << 32 | shaderID (transparent inverts depth for back-to-front).
|
||||
*/
|
||||
CC_ASSERT(!std::isnan(renderObj.depth));
|
||||
const uint32_t depthKey = utils::numext::floatToSortableUint(renderObj.depth);
|
||||
if (isTransparent) {
|
||||
const uint32_t invertedDepthKey = ~depthKey;
|
||||
renderPass.primaryKey = (static_cast<uint64_t>(priority) << 32) | hash;
|
||||
renderPass.secondaryKey = (static_cast<uint64_t>(invertedDepthKey) << 32) | shaderId;
|
||||
} else {
|
||||
renderPass.primaryKey = hash;
|
||||
renderPass.secondaryKey = (static_cast<uint64_t>(depthKey) << 32) | shaderId;
|
||||
}
|
||||
_queue.emplace_back(renderPass);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -60,7 +60,7 @@ float LODGroup::getScreenUsagePercentage(const Camera *camera) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto distance = 0;
|
||||
float distance = 0.0F;
|
||||
if (camera->getProjectionType() == CameraProjection::PERSPECTIVE) {
|
||||
Vec3 tmp{_localBoundaryCenter};
|
||||
tmp.transformMat4(_node->getWorldMatrix());
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"type": "github",
|
||||
"owner": "cocos",
|
||||
"name": "cocos-engine-external",
|
||||
"checkout": "v4.0.0-9"
|
||||
"checkout": "v4.0.0-10"
|
||||
}
|
||||
}
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "cocos-creator",
|
||||
"version": "4.0.0-alpha.34",
|
||||
"version": "4.0.0-alpha.35",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cocos-creator",
|
||||
"version": "4.0.0-alpha.34",
|
||||
"version": "4.0.0-alpha.35",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cocos-creator",
|
||||
"version": "4.0.0-alpha.34",
|
||||
"version": "4.0.0-alpha.35",
|
||||
"description": "Cocos Creator is a cross-platform 2D & 3D game engine written in C++ and TypeScript, licensed under MIT.",
|
||||
"homepage": "http://www.cocos.com",
|
||||
"license": "MIT",
|
||||
|
||||
Reference in New Issue
Block a user