From cedc01c57599cfbb3d3be5cb1fb2413f12f948f3 Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Sat, 18 Jun 2022 18:47:45 +0800 Subject: [PATCH] use uint32_t instead of uint (#11598) * use uint32_t instead of uint --- .../gfx-gles3/GLES3PipelineLayout.cpp | 6 +- native/cocos/renderer/gfx-metal/MTLBuffer.h | 12 +- native/cocos/renderer/gfx-metal/MTLBuffer.mm | 20 +- .../renderer/gfx-metal/MTLCommandBuffer.h | 24 +- .../renderer/gfx-metal/MTLCommandBuffer.mm | 54 ++-- .../gfx-metal/MTLComputeCommandEncoder.h | 4 +- .../gfx-metal/MTLDescriptorSetLayout.mm | 2 +- native/cocos/renderer/gfx-metal/MTLDevice.h | 22 +- native/cocos/renderer/gfx-metal/MTLDevice.mm | 6 +- .../cocos/renderer/gfx-metal/MTLGPUObjects.h | 66 ++--- .../renderer/gfx-metal/MTLPipelineState.mm | 6 +- native/cocos/renderer/gfx-metal/MTLQueue.h | 2 +- native/cocos/renderer/gfx-metal/MTLQueue.mm | 4 +- .../gfx-metal/MTLRenderCommandEncoder.h | 32 +-- .../cocos/renderer/gfx-metal/MTLRenderPass.h | 10 +- .../cocos/renderer/gfx-metal/MTLRenderPass.mm | 2 +- .../cocos/renderer/gfx-metal/MTLSemaphore.h | 8 +- native/cocos/renderer/gfx-metal/MTLShader.h | 12 +- native/cocos/renderer/gfx-metal/MTLShader.mm | 20 +- native/cocos/renderer/gfx-metal/MTLTexture.h | 2 +- native/cocos/renderer/gfx-metal/MTLTexture.mm | 2 +- native/cocos/renderer/gfx-metal/MTLUtils.h | 64 ++--- native/cocos/renderer/gfx-metal/MTLUtils.mm | 90 +++--- native/cocos/renderer/gfx-wgpu/WGPUBuffer.cpp | 4 +- native/cocos/renderer/gfx-wgpu/WGPUBuffer.h | 8 +- .../renderer/gfx-wgpu/WGPUCommandBuffer.cpp | 28 +- .../renderer/gfx-wgpu/WGPUCommandBuffer.h | 22 +- native/cocos/renderer/gfx-wgpu/WGPUDef.h | 12 +- native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp | 8 +- native/cocos/renderer/gfx-wgpu/WGPUDevice.h | 4 +- native/cocos/renderer/gfx-wgpu/WGPUExports.h | 24 +- native/cocos/renderer/gfx-wgpu/WGPUObject.h | 6 +- .../renderer/gfx-wgpu/WGPUPipelineState.cpp | 16 +- native/cocos/renderer/gfx-wgpu/WGPUQueue.cpp | 2 +- native/cocos/renderer/gfx-wgpu/WGPUQueue.h | 2 +- .../cocos/renderer/pipeline/BatchedBuffer.cpp | 26 +- .../cocos/renderer/pipeline/BatchedBuffer.h | 14 +- .../renderer/pipeline/ClusterLightCulling.cpp | 104 +++---- .../renderer/pipeline/ClusterLightCulling.h | 32 +-- native/cocos/renderer/pipeline/Define.cpp | 34 +-- native/cocos/renderer/pipeline/Define.h | 270 +++++++++--------- .../pipeline/GlobalDescriptorSetManager.cpp | 6 +- .../renderer/pipeline/InstancedBuffer.cpp | 18 +- .../cocos/renderer/pipeline/InstancedBuffer.h | 22 +- .../pipeline/PipelineStateManager.cpp | 2 +- .../renderer/pipeline/PipelineStateManager.h | 2 +- .../cocos/renderer/pipeline/PipelineUBO.cpp | 16 +- native/cocos/renderer/pipeline/PipelineUBO.h | 12 +- .../renderer/pipeline/PlanarShadowQueue.cpp | 2 +- .../pipeline/RenderAdditiveLightQueue.cpp | 18 +- .../pipeline/RenderAdditiveLightQueue.h | 26 +- .../renderer/pipeline/RenderBatchedQueue.cpp | 2 +- .../renderer/pipeline/RenderBatchedQueue.h | 2 +- native/cocos/renderer/pipeline/RenderFlow.h | 12 +- .../pipeline/RenderInstancedQueue.cpp | 2 +- .../renderer/pipeline/RenderInstancedQueue.h | 2 +- .../renderer/pipeline/RenderPipeline.cpp | 12 +- .../cocos/renderer/pipeline/RenderPipeline.h | 14 +- .../cocos/renderer/pipeline/RenderQueue.cpp | 2 +- native/cocos/renderer/pipeline/RenderQueue.h | 2 +- native/cocos/renderer/pipeline/RenderStage.h | 12 +- .../cocos/renderer/pipeline/SceneCulling.cpp | 4 +- .../pipeline/ShadowMapBatchedQueue.cpp | 2 +- .../renderer/pipeline/ShadowMapBatchedQueue.h | 6 +- native/cocos/renderer/pipeline/UIPhase.h | 2 +- .../pipeline/custom/NativePipelineImpl.cpp | 14 +- .../renderer/pipeline/deferred/BloomStage.cpp | 40 +-- .../renderer/pipeline/deferred/BloomStage.h | 8 +- .../pipeline/deferred/DeferredPipeline.cpp | 4 +- .../pipeline/deferred/DeferredPipeline.h | 2 +- .../pipeline/deferred/GbufferStage.cpp | 26 +- .../renderer/pipeline/deferred/GbufferStage.h | 2 +- .../pipeline/deferred/LightingStage.cpp | 72 ++--- .../pipeline/deferred/LightingStage.h | 20 +- .../renderer/pipeline/deferred/MainFlow.cpp | 4 +- .../pipeline/deferred/PostProcessStage.cpp | 20 +- .../pipeline/deferred/PostProcessStage.h | 2 +- .../pipeline/deferred/ReflectionComp.cpp | 14 +- .../pipeline/deferred/ReflectionComp.h | 12 +- .../renderer/pipeline/forward/ForwardFlow.cpp | 4 +- .../pipeline/forward/ForwardPipeline.cpp | 6 +- .../pipeline/forward/ForwardStage.cpp | 20 +- .../renderer/pipeline/forward/ForwardStage.h | 2 +- .../renderer/pipeline/shadow/CSMLayers.cpp | 18 +- .../renderer/pipeline/shadow/CSMLayers.h | 12 +- .../renderer/pipeline/shadow/ShadowFlow.cpp | 20 +- .../renderer/pipeline/shadow/ShadowFlow.h | 2 +- .../renderer/pipeline/shadow/ShadowStage.cpp | 18 +- .../renderer/pipeline/shadow/ShadowStage.h | 4 +- 89 files changed, 816 insertions(+), 816 deletions(-) diff --git a/native/cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp b/native/cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp index 7aa3d47c4a..6044225fc2 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp @@ -57,12 +57,12 @@ void GLES3PipelineLayout::doInit(const PipelineLayoutInfo & /*info*/) { uint32_t binding = gpuSetLayout->dynamicBindings[j]; if (indices[binding] < 0) indices[binding] = static_cast(offset + j); } - _gpuPipelineLayout->dynamicOffsetOffsets.push_back(static_cast(offset)); + _gpuPipelineLayout->dynamicOffsetOffsets.push_back(static_cast(offset)); _gpuPipelineLayout->setLayouts.push_back(gpuSetLayout); offset += dynamicCount; } - _gpuPipelineLayout->dynamicOffsetOffsets.push_back(static_cast(offset)); - _gpuPipelineLayout->dynamicOffsetCount = static_cast(offset); + _gpuPipelineLayout->dynamicOffsetOffsets.push_back(static_cast(offset)); + _gpuPipelineLayout->dynamicOffsetCount = static_cast(offset); _gpuPipelineLayout->dynamicOffsets.resize(offset); } diff --git a/native/cocos/renderer/gfx-metal/MTLBuffer.h b/native/cocos/renderer/gfx-metal/MTLBuffer.h index 288e6510b3..91875a2208 100644 --- a/native/cocos/renderer/gfx-metal/MTLBuffer.h +++ b/native/cocos/renderer/gfx-metal/MTLBuffer.h @@ -46,9 +46,9 @@ public: CCMTLBuffer &operator=(const CCMTLBuffer &) = default; CCMTLBuffer &operator=(CCMTLBuffer &&) = delete; - void update(const void *buffer, uint offset) override; + void update(const void *buffer, uint32_t offset) override; - void encodeBuffer(CCMTLCommandEncoder &encoder, uint offset, uint binding, ShaderStageFlags stages); + void encodeBuffer(CCMTLCommandEncoder &encoder, uint32_t offset, uint32_t binding, ShaderStageFlags stages); id getMTLBuffer() const; @@ -61,15 +61,15 @@ protected: void doInit(const BufferInfo &info) override; void doInit(const BufferViewInfo &info) override; void doDestroy() override; - void doResize(uint size, uint count) override; + void doResize(uint32_t size, uint32_t count) override; - bool createMTLBuffer(uint size, MemoryUsage usage); - void updateMTLBuffer(const void *buffer, uint offset, uint size); + bool createMTLBuffer(uint32_t size, MemoryUsage usage); + void updateMTLBuffer(const void *buffer, uint32_t offset, uint32_t size); MTLIndexType _indexType = MTLIndexTypeUInt16; MTLResourceOptions _mtlResourceOptions = MTLResourceStorageModePrivate; bool _isIndirectDrawSupported = false; - uint _bufferViewOffset = 0; + uint32_t _bufferViewOffset = 0; bool _isDrawIndirectByIndex = false; ccstd::vector _indexedPrimitivesIndirectArguments; diff --git a/native/cocos/renderer/gfx-metal/MTLBuffer.mm b/native/cocos/renderer/gfx-metal/MTLBuffer.mm index ff8ac21444..d9e618c290 100644 --- a/native/cocos/renderer/gfx-metal/MTLBuffer.mm +++ b/native/cocos/renderer/gfx-metal/MTLBuffer.mm @@ -96,7 +96,7 @@ void CCMTLBuffer::doInit(const BufferViewInfo &info) { _isBufferView = true; } -bool CCMTLBuffer::createMTLBuffer(uint size, MemoryUsage usage) { +bool CCMTLBuffer::createMTLBuffer(uint32_t size, MemoryUsage usage) { if (!size) { return false; } @@ -163,7 +163,7 @@ void CCMTLBuffer::doDestroy() { CC_SAFE_DELETE(_gpuBuffer); } -void CCMTLBuffer::doResize(uint size, uint count) { +void CCMTLBuffer::doResize(uint32_t size, uint32_t count) { if (hasFlag(_usage, BufferUsageBit::VERTEX) || hasFlag(_usage, BufferUsageBit::INDEX) || hasFlag(_usage, BufferUsageBit::UNIFORM)) { @@ -188,7 +188,7 @@ void CCMTLBuffer::doResize(uint size, uint count) { } } -void CCMTLBuffer::update(const void *buffer, uint size) { +void CCMTLBuffer::update(const void *buffer, uint32_t size) { CC_PROFILE(CCMTLBufferUpdate); if (_isBufferView) { CC_LOG_WARNING("Cannot update a buffer view."); @@ -198,7 +198,7 @@ void CCMTLBuffer::update(const void *buffer, uint size) { _isDrawIndirectByIndex = false; if (hasFlag(_usage, BufferUsageBit::INDIRECT)) { - uint drawInfoCount = size / _stride; + uint32_t drawInfoCount = size / _stride; const auto *drawInfo = static_cast(buffer); if (drawInfoCount > 0) { if (drawInfo->indexCount) { @@ -209,9 +209,9 @@ void CCMTLBuffer::update(const void *buffer, uint size) { if (_isIndirectDrawSupported) { if (drawInfoCount > 0) { if (_isDrawIndirectByIndex) { - uint stride = sizeof(MTLDrawIndexedPrimitivesIndirectArguments); + uint32_t stride = sizeof(MTLDrawIndexedPrimitivesIndirectArguments); - for (uint i = 0; i < drawInfoCount; ++i) { + for (uint32_t i = 0; i < drawInfoCount; ++i) { auto &arguments = _indexedPrimitivesIndirectArguments[i]; arguments.indexCount = drawInfo->indexCount; arguments.instanceCount = std::max(drawInfo->instanceCount, 1U); @@ -222,9 +222,9 @@ void CCMTLBuffer::update(const void *buffer, uint size) { } updateMTLBuffer(_indexedPrimitivesIndirectArguments.data(), 0, drawInfoCount * stride); } else { - uint stride = sizeof(MTLDrawPrimitivesIndirectArguments); + uint32_t stride = sizeof(MTLDrawPrimitivesIndirectArguments); - for (uint i = 0; i < drawInfoCount; ++i) { + for (uint32_t i = 0; i < drawInfoCount; ++i) { auto &arguments = _primitiveIndirectArguments[i]; arguments.vertexCount = drawInfo->vertexCount; arguments.instanceCount = std::max(drawInfo->instanceCount, 1U); @@ -243,7 +243,7 @@ void CCMTLBuffer::update(const void *buffer, uint size) { } } -void CCMTLBuffer::updateMTLBuffer(const void *buffer, uint /*offset*/, uint size) { +void CCMTLBuffer::updateMTLBuffer(const void *buffer, uint32_t /*offset*/, uint32_t size) { if (_gpuBuffer->mtlBuffer) { CommandBuffer *cmdBuffer = CCMTLDevice::getInstance()->getCommandBuffer(); cmdBuffer->begin(); @@ -256,7 +256,7 @@ void CCMTLBuffer::updateMTLBuffer(const void *buffer, uint /*offset*/, uint size } } -void CCMTLBuffer::encodeBuffer(CCMTLCommandEncoder &encoder, uint offset, uint binding, ShaderStageFlags stages) { +void CCMTLBuffer::encodeBuffer(CCMTLCommandEncoder &encoder, uint32_t offset, uint32_t binding, ShaderStageFlags stages) { if (_isBufferView) { offset += _bufferViewOffset; } diff --git a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.h b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.h index aee5b57f71..25dec2b68f 100644 --- a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.h +++ b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.h @@ -53,12 +53,12 @@ public: CCMTLCommandBuffer &operator=(const CCMTLCommandBuffer &) = delete; CCMTLCommandBuffer &operator=(CCMTLCommandBuffer &&) = delete; - void begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer) override; + void begin(RenderPass *renderPass, uint32_t subpass, Framebuffer *frameBuffer) override; void end() override; - void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint stencil, CommandBuffer *const *secondaryCBs, uint secondaryCBCount) override; + void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint32_t stencil, CommandBuffer *const *secondaryCBs, uint32_t secondaryCBCount) override; void endRenderPass() override; void bindPipelineState(PipelineState *pso) override; - void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) override; + void bindDescriptorSet(uint32_t set, DescriptorSet *descriptorSet, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets) override; void bindInputAssembler(InputAssembler *ia) override; void setViewport(const Viewport &vp) override; void setScissor(const Rect &rect) override; @@ -66,17 +66,17 @@ public: void setDepthBias(float constant, float clamp, float slope) override; void setBlendConstants(const Color &constants) override; void setDepthBound(float minBounds, float maxBounds) override; - void setStencilWriteMask(StencilFace face, uint mask) override; - void setStencilCompareMask(StencilFace face, uint ref, uint mask) override; + void setStencilWriteMask(StencilFace face, uint32_t mask) override; + void setStencilCompareMask(StencilFace face, uint32_t ref, uint32_t mask) override; void nextSubpass() override; void draw(const DrawInfo &info) override; - void updateBuffer(Buffer *buff, const void *data, uint size) override; - void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) override; - void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint count, Filter filter) override; + void updateBuffer(Buffer *buff, const void *data, uint32_t size) override; + void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override; + void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override; void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override; void dispatch(const DispatchInfo &info) override; - void pipelineBarrier(const GeneralBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint textureBarrierCount) override; - void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *regions, uint count); + void pipelineBarrier(const GeneralBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) override; + void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *regions, uint32_t count); void beginQuery(QueryPool *queryPool, uint32_t id) override; void endQuery(QueryPool *queryPool, uint32_t id) override; void resetQueryPool(QueryPool *queryPool) override; @@ -99,8 +99,8 @@ protected: id getMTLCommandBuffer(); ccstd::vector _GPUDescriptorSets; // NOLINT(bugprone-reserved-identifier) - ccstd::vector> _dynamicOffsets; - uint _firstDirtyDescriptorSet = UINT_MAX; + ccstd::vector> _dynamicOffsets; + uint32_t _firstDirtyDescriptorSet = UINT_MAX; bool _indirectDrawSuppotred = false; bool _commandBufferBegan = false; diff --git a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm index 3bf8e41dbc..139be9d038 100644 --- a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm +++ b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm @@ -107,7 +107,7 @@ id CCMTLCommandBuffer::getMTLCommandBuffer() { return _gpuCommandBufferObj->mtlCommandBuffer; } -void CCMTLCommandBuffer::begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer) { +void CCMTLCommandBuffer::begin(RenderPass *renderPass, uint32_t subpass, Framebuffer *frameBuffer) { if (_commandBufferBegan) { return; } @@ -140,7 +140,7 @@ void CCMTLCommandBuffer::end() { } } -void CCMTLCommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint stencil, CommandBuffer *const *secondaryCBs, uint secondaryCBCount) { +void CCMTLCommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint32_t stencil, CommandBuffer *const *secondaryCBs, uint32_t secondaryCBCount) { // Sub CommandBuffer shouldn't call begin render pass if (_gpuCommandBufferObj->isSecondary) { return; @@ -267,7 +267,7 @@ void CCMTLCommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fb if (secondaryCBCount > 0) { _parallelEncoder = [[mtlCommandBuffer parallelRenderCommandEncoderWithDescriptor:mtlRenderPassDescriptor] retain]; // Create command encoders from parallel encoder and assign to command buffers - for (uint i = 0u; i < secondaryCBCount; ++i) { + for (uint32_t i = 0u; i < secondaryCBCount; ++i) { CCMTLCommandBuffer *cmdBuff = (CCMTLCommandBuffer *)secondaryCBs[i]; cmdBuff->_renderEncoder.initialize(_parallelEncoder); cmdBuff->_gpuCommandBufferObj->mtlCommandBuffer = mtlCommandBuffer; @@ -446,7 +446,7 @@ void CCMTLCommandBuffer::bindPipelineState(PipelineState *pso) { _gpuCommandBufferObj->pipelineState = ccPipeline; } -void CCMTLCommandBuffer::bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) { +void CCMTLCommandBuffer::bindDescriptorSet(uint32_t set, DescriptorSet *descriptorSet, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets) { CC_ASSERT(set < _GPUDescriptorSets.size()); if (dynamicOffsetCount) { _dynamicOffsets[set].assign(dynamicOffsets, dynamicOffsets + dynamicOffsetCount); @@ -494,11 +494,11 @@ void CCMTLCommandBuffer::setDepthBound(float /*minBounds*/, float /*maxBounds*/) CC_LOG_ERROR("Metal doesn't support setting depth bound."); } -void CCMTLCommandBuffer::setStencilWriteMask(StencilFace /*face*/, uint /*mask*/) { +void CCMTLCommandBuffer::setStencilWriteMask(StencilFace /*face*/, uint32_t /*mask*/) { CC_LOG_ERROR("Don't support change stencil write mask here."); } -void CCMTLCommandBuffer::setStencilCompareMask(StencilFace /*face*/, uint /*ref*/, uint /*mask*/) { +void CCMTLCommandBuffer::setStencilCompareMask(StencilFace /*face*/, uint32_t /*ref*/, uint32_t /*mask*/) { CC_LOG_ERROR("Don't support change stencil compare mask here."); } @@ -513,7 +513,7 @@ void CCMTLCommandBuffer::nextSubpass() { bool setTexNeeded = !mu::isFramebufferFetchSupported(); if (setTexNeeded) { _renderEncoder.endEncoding(); - uint curSubpassIndex = ccRenderpass->getCurrentSubpassIndex(); + uint32_t curSubpassIndex = ccRenderpass->getCurrentSubpassIndex(); auto *mtlRenderPassDescriptor = ccRenderpass->getMTLRenderPassDescriptor(); const auto &colorAttachments = curRenderPass->getColorAttachments(); const auto colorAttachmentCount = colorAttachments.size(); @@ -529,7 +529,7 @@ void CCMTLCommandBuffer::nextSubpass() { if (!subpasses.empty()) { const auto &inputs = subpasses[curSubpassIndex].inputs; for (size_t i = 0; i < inputs.size(); i++) { - const uint input = inputs[i]; + const uint32_t input = inputs[i]; if(input >= colorTextures.size()) { continue;// ds should be set already by updateDepthStencilState } @@ -569,13 +569,13 @@ void CCMTLCommandBuffer::draw(const DrawInfo &info) { indirectBufferOffset:0]; } } else { - uint stride = indirectBuffer->getStride(); - uint offset = 0; - uint drawInfoCount = indirectBuffer->getCount(); + uint32_t stride = indirectBuffer->getStride(); + uint32_t offset = 0; + uint32_t drawInfoCount = indirectBuffer->getCount(); const auto &drawInfos = indirectBuffer->getDrawInfos(); _numDrawCalls += drawInfoCount; - for (uint i = 0; i < drawInfoCount; ++i) { + for (uint32_t i = 0; i < drawInfoCount; ++i) { const auto &drawInfo = drawInfos[i]; offset += drawInfo.firstIndex * stride; if (indirectBuffer->isDrawIndirectByIndex()) { @@ -609,7 +609,7 @@ void CCMTLCommandBuffer::draw(const DrawInfo &info) { } } else { if (info.indexCount > 0) { - uint offset = 0; + uint32_t offset = 0; offset += info.firstIndex * indexBuffer->getStride(); if (info.instanceCount == 0) { [mtlEncoder drawIndexedPrimitives:_mtlPrimitiveType @@ -641,7 +641,7 @@ void CCMTLCommandBuffer::draw(const DrawInfo &info) { _numInstances += info.instanceCount; _numDrawCalls++; if (_gpuCommandBufferObj->pipelineState) { - uint indexCount = info.indexCount ? info.indexCount : info.vertexCount; + uint32_t indexCount = info.indexCount ? info.indexCount : info.vertexCount; switch (_mtlPrimitiveType) { case MTLPrimitiveTypeTriangle: _numTriangles += indexCount / 3 * std::max(info.instanceCount, 1U); @@ -655,7 +655,7 @@ void CCMTLCommandBuffer::draw(const DrawInfo &info) { } } -void CCMTLCommandBuffer::updateBuffer(Buffer *buff, const void *data, uint size) { +void CCMTLCommandBuffer::updateBuffer(Buffer *buff, const void *data, uint32_t size) { CC_PROFILE(CCMTLCmdBufUpdateBuffer); if (!buff) { CC_LOG_ERROR("CCMTLCommandBuffer::updateBuffer: buffer is nullptr."); @@ -675,14 +675,14 @@ void CCMTLCommandBuffer::updateBuffer(Buffer *buff, const void *data, uint size) [encoder endEncoding]; } -void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) { +void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) { if (!texture) { CC_LOG_ERROR("CCMTLCommandBuffer::copyBufferToTexture: texture is nullptr"); return; } - uint totalSize = 0; - ccstd::vector bufferSize(count); + uint32_t totalSize = 0; + ccstd::vector bufferSize(count); ccstd::vector stagingRegions(count); auto format = texture->getFormat(); auto *mtlTexture = static_cast(texture); @@ -699,9 +699,9 @@ void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex stagingRegion.destinationSlice = region.texSubres.baseArrayLayer; stagingRegion.destinationLevel = region.texSubres.mipLevel; stagingRegion.destinationOrigin = { - static_cast(region.texOffset.x), - static_cast(region.texOffset.y), - static_cast(region.texOffset.z)}; + static_cast(region.texOffset.x), + static_cast(region.texOffset.y), + static_cast(region.texOffset.z)}; totalSize += stagingRegion.sourceBytesPerImage; } @@ -735,7 +735,7 @@ void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex } void CCMTLCommandBuffer::execute(CommandBuffer *const *commandBuffs, uint32_t count) { - for (uint i = 0; i < count; ++i) { + for (uint32_t i = 0; i < count; ++i) { const auto *commandBuffer = static_cast(commandBuffs[i]); _numDrawCalls += commandBuffer->_numDrawCalls; _numInstances += commandBuffer->_numInstances; @@ -769,7 +769,7 @@ void CCMTLCommandBuffer::bindDescriptorSets() { const auto &dynamicOffset = dynamicOffsetIndices[block.set]; auto dynamicOffsetIndex = (block.binding < dynamicOffset.size()) ? dynamicOffset[block.binding] : -1; if (gpuDescriptor.buffer) { - uint offset = (dynamicOffsetIndex >= 0) ? _dynamicOffsets[block.set][dynamicOffsetIndex] : 0; + uint32_t offset = (dynamicOffsetIndex >= 0) ? _dynamicOffsets[block.set][dynamicOffsetIndex] : 0; // compute pipeline and render pipeline mutually exlusive if (pipelineStateObj->mtlComputePipelineState) { gpuDescriptor.buffer->encodeBuffer(_computeEncoder, @@ -814,7 +814,7 @@ void CCMTLCommandBuffer::bindDescriptorSets() { } } -void CCMTLCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint count, Filter filter) { +void CCMTLCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) { if (srcTexture && dstTexture && regions) { id cmdBuffer = getMTLCommandBuffer(); @@ -882,7 +882,7 @@ void CCMTLCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, c //blit id encoder = [cmdBuffer blitCommandEncoder]; - for (uint i = 0; i < count; ++i) { + for (uint32_t i = 0; i < count; ++i) { // source region scale uint32_t width = (uint32_t)(regions[i].srcExtent.width * scaleFactorW); uint32_t height = (uint32_t)(regions[i].srcExtent.height * scaleFactorH); @@ -919,11 +919,11 @@ void CCMTLCommandBuffer::dispatch(const DispatchInfo &info) { _computeEncoder.endEncoding(); } -void CCMTLCommandBuffer::pipelineBarrier(const GeneralBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint textureBarrierCount) { +void CCMTLCommandBuffer::pipelineBarrier(const GeneralBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) { // Metal tracks non-heap resources automatically, which means no need to add a barrier same encoder. } -void CCMTLCommandBuffer::copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *regions, uint count) { +void CCMTLCommandBuffer::copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *regions, uint32_t count) { auto *ccMTLTexture = static_cast(src); Format convertedFormat = ccMTLTexture->getConvertedFormat(); id mtlTexture = ccMTLTexture->getMTLTexture(); diff --git a/native/cocos/renderer/gfx-metal/MTLComputeCommandEncoder.h b/native/cocos/renderer/gfx-metal/MTLComputeCommandEncoder.h index 34a9ca6ea7..f0fca976e7 100644 --- a/native/cocos/renderer/gfx-metal/MTLComputeCommandEncoder.h +++ b/native/cocos/renderer/gfx-metal/MTLComputeCommandEncoder.h @@ -59,11 +59,11 @@ public: _pipelineState = pipelineState; } - inline void setBuffer(const id buffer, uint offset, uint index) { + inline void setBuffer(const id buffer, uint32_t offset, uint32_t index) { [_mtlEncoder setBuffer:buffer offset:offset atIndex:index]; } - inline void setTexture(const id texture, uint index) { + inline void setTexture(const id texture, uint32_t index) { [_mtlEncoder setTexture:texture atIndex:index]; _resourceSize = {texture.width, texture.height, texture.depth}; } diff --git a/native/cocos/renderer/gfx-metal/MTLDescriptorSetLayout.mm b/native/cocos/renderer/gfx-metal/MTLDescriptorSetLayout.mm index 4e7ba98545..1b98c53bd5 100644 --- a/native/cocos/renderer/gfx-metal/MTLDescriptorSetLayout.mm +++ b/native/cocos/renderer/gfx-metal/MTLDescriptorSetLayout.mm @@ -48,7 +48,7 @@ void CCMTLDescriptorSetLayout::doInit(const DescriptorSetLayoutInfo &info) { for (size_t i = 0; i < _bindings.size(); i++) { const auto binding = _bindings[i]; if (hasAnyFlags(binding.descriptorType, DESCRIPTOR_DYNAMIC_TYPE)) { - for (uint j = 0; j < binding.count; j++) { + for (uint32_t j = 0; j < binding.count; j++) { _gpuDescriptorSetLayout->dynamicBindings.push_back(binding.binding); } } diff --git a/native/cocos/renderer/gfx-metal/MTLDevice.h b/native/cocos/renderer/gfx-metal/MTLDevice.h index da1e40e898..e67ff95104 100644 --- a/native/cocos/renderer/gfx-metal/MTLDevice.h +++ b/native/cocos/renderer/gfx-metal/MTLDevice.h @@ -71,14 +71,14 @@ public: inline void *getMTLCommandQueue() const { return _mtlCommandQueue; } inline void *getMTLDevice() const { return _mtlDevice; } - inline uint getMaximumSamplerUnits() const { return _maxSamplerUnits; } - inline uint getMaximumColorRenderTargets() const { return _caps.maxColorRenderTargets; } - inline uint getMaximumBufferBindingIndex() const { return _maxBufferBindingIndex; } + inline uint32_t getMaximumSamplerUnits() const { return _maxSamplerUnits; } + inline uint32_t getMaximumColorRenderTargets() const { return _caps.maxColorRenderTargets; } + inline uint32_t getMaximumBufferBindingIndex() const { return _maxBufferBindingIndex; } inline bool isIndirectCommandBufferSupported() const { return _icbSuppored; } inline bool isIndirectDrawSupported() const { return _indirectDrawSupported; } inline CCMTLGPUStagingBufferPool *gpuStagingBufferPool() const { return _gpuStagingBufferPools[_currentFrameIndex]; } inline bool isSamplerDescriptorCompareFunctionSupported() const { return _isSamplerDescriptorCompareFunctionSupported; } - inline uint currentFrameIndex() const { return _currentFrameIndex; } + inline uint32_t currentFrameIndex() const { return _currentFrameIndex; } inline void registerSwapchain(CCMTLSwapchain *swapchain) { _swapchains.push_back(swapchain); } inline void unRegisterSwapchain(CCMTLSwapchain *swapchain) { @@ -110,25 +110,25 @@ protected: PipelineState *createPipelineState() override; Sampler *createSampler(const SamplerInfo &info) 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; + 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; void getQueryPoolResults(QueryPool *queryPool) override; void onMemoryWarning(); - void initFormatFeatures(uint family); + void initFormatFeatures(uint32_t family); void *_mtlCommandQueue = nullptr; void *_mtlDevice = nullptr; void *_activeDrawable = nullptr; unsigned long _mtlFeatureSet = 0; - uint _maxSamplerUnits = 0; - uint _maxBufferBindingIndex = 0; + uint32_t _maxSamplerUnits = 0; + uint32_t _maxBufferBindingIndex = 0; bool _icbSuppored = false; bool _indirectDrawSupported = false; bool _isSamplerDescriptorCompareFunctionSupported = false; CCMTLGPUStagingBufferPool *_gpuStagingBufferPools[MAX_FRAMES_IN_FLIGHT] = {nullptr}; - uint _currentBufferPoolId = 0; - uint _currentFrameIndex = 0; + uint32_t _currentBufferPoolId = 0; + uint32_t _currentFrameIndex = 0; CCMTLSemaphore *_inFlightSemaphore = nullptr; CC_UNUSED uint32_t _memoryAlarmListenerId = 0; diff --git a/native/cocos/renderer/gfx-metal/MTLDevice.mm b/native/cocos/renderer/gfx-metal/MTLDevice.mm index 9c10419386..59622144c8 100644 --- a/native/cocos/renderer/gfx-metal/MTLDevice.mm +++ b/native/cocos/renderer/gfx-metal/MTLDevice.mm @@ -306,7 +306,7 @@ Swapchain *CCMTLDevice::createSwapchain() { return ccnew CCMTLSwapchain; } -void CCMTLDevice::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) { +void CCMTLDevice::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) { CC_PROFILE(CCMTLDeviceCopyBuffersToTexture); // This assumes the default command buffer will get submitted every frame, // which is true for now but may change in the future. This approach gives us @@ -316,7 +316,7 @@ void CCMTLDevice::copyBuffersToTexture(const uint8_t *const *buffers, Texture *t static_cast(_cmdBuff)->copyBuffersToTexture(buffers, texture, regions, count); } -void CCMTLDevice::copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint count) { +void CCMTLDevice::copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) { CC_PROFILE(CCMTLDeviceCopyTextureToBuffers); static_cast(_cmdBuff)->copyTextureToBuffers(src, buffers, region, count); } @@ -353,7 +353,7 @@ void CCMTLDevice::onMemoryWarning() { _gpuStagingBufferPools[i]->shrinkSize(); } } -void CCMTLDevice::initFormatFeatures(uint gpuFamily) { +void CCMTLDevice::initFormatFeatures(uint32_t gpuFamily) { const FormatFeature completeFeature = FormatFeature::RENDER_TARGET | FormatFeature::SAMPLED_TEXTURE | FormatFeature::LINEAR_FILTER | FormatFeature::STORAGE_TEXTURE; FormatFeature tempFeature = FormatFeature::RENDER_TARGET | FormatFeature::SAMPLED_TEXTURE | FormatFeature::STORAGE_TEXTURE; diff --git a/native/cocos/renderer/gfx-metal/MTLGPUObjects.h b/native/cocos/renderer/gfx-metal/MTLGPUObjects.h index 86b90d9ed4..b478a7e4a4 100644 --- a/native/cocos/renderer/gfx-metal/MTLGPUObjects.h +++ b/native/cocos/renderer/gfx-metal/MTLGPUObjects.h @@ -57,10 +57,10 @@ constexpr size_t MAX_COLORATTACHMENTS = 16u; struct CCMTLGPUDescriptorSetLayout { DescriptorSetLayoutBindingList bindings; - ccstd::vector dynamicBindings; - ccstd::vector descriptorIndices; - ccstd::vector bindingIndices; - uint descriptorCount = 0; + ccstd::vector dynamicBindings; + ccstd::vector descriptorIndices; + ccstd::vector bindingIndices; + uint32_t descriptorCount = 0; }; typedef ccstd::vector MTLGPUDescriptorSetLayoutList; @@ -71,34 +71,34 @@ struct CCMTLGPUPipelineLayout { struct CCMTLGPUUniformBlock { ccstd::string name; - uint set = INVALID_BINDING; - uint binding = INVALID_BINDING; - uint mappedBinding = INVALID_BINDING; + uint32_t set = INVALID_BINDING; + uint32_t binding = INVALID_BINDING; + uint32_t mappedBinding = INVALID_BINDING; ShaderStageFlags stages = ShaderStageFlagBit::NONE; size_t size = 0; - uint count = 0; + uint32_t count = 0; }; struct CCMTLGPUSamplerBlock { ccstd::string name; - uint set = INVALID_BINDING; - uint binding = INVALID_BINDING; - uint textureBinding = INVALID_BINDING; - uint samplerBinding = INVALID_BINDING; + uint32_t set = INVALID_BINDING; + uint32_t binding = INVALID_BINDING; + uint32_t textureBinding = INVALID_BINDING; + uint32_t samplerBinding = INVALID_BINDING; ShaderStageFlags stages = ShaderStageFlagBit::NONE; Type type = Type::UNKNOWN; - uint count = 0; + uint32_t count = 0; }; struct CCMTLGPUSubpassAttachment { ccstd::string name; - uint set = INVALID_BINDING; - uint binding = INVALID_BINDING; + uint32_t set = INVALID_BINDING; + uint32_t binding = INVALID_BINDING; }; struct CCMTLGPUShader { - ccstd::unordered_map blocks; - ccstd::unordered_map samplers; + ccstd::unordered_map blocks; + ccstd::unordered_map samplers; ccstd::vector inputs; ccstd::vector outputs; @@ -119,18 +119,18 @@ struct CCMTLGPUPipelineState { id mtlRenderPipelineState = nil; id mtlDepthStencilState = nil; id mtlComputePipelineState = nil; - uint stencilRefFront = 0; - uint stencilRefBack = 0; - ccstd::vector> vertexBufferBindingInfo; + uint32_t stencilRefFront = 0; + uint32_t stencilRefBack = 0; + ccstd::vector> vertexBufferBindingInfo; const CCMTLGPUPipelineLayout *gpuPipelineLayout = nullptr; const CCMTLGPUShader *gpuShader = nullptr; }; struct CCMTLGPUBuffer { - uint stride = 0; - uint count = 0; - uint size = 0; - uint startOffset = 0; + uint32_t stride = 0; + uint32_t count = 0; + uint32_t size = 0; + uint32_t startOffset = 0; uint8_t *mappedData = nullptr; id mtlBuffer = nil; }; @@ -161,7 +161,7 @@ typedef ccstd::vector MTLGPUDescriptorList; struct CCMTLGPUDescriptorSet { MTLGPUDescriptorList gpuDescriptors; - const ccstd::vector *descriptorIndices = nullptr; + const ccstd::vector *descriptorIndices = nullptr; }; class CCMTLGPUStagingBufferPool final { @@ -186,10 +186,10 @@ public: } inline void alloc(CCMTLGPUBuffer *gpuBuffer) { alloc(gpuBuffer, 1); } - void alloc(CCMTLGPUBuffer *gpuBuffer, uint alignment) { + void alloc(CCMTLGPUBuffer *gpuBuffer, uint32_t alignment) { size_t bufferCount = _pool.size(); Buffer *buffer = nullptr; - uint offset = 0; + uint32_t offset = 0; for (size_t idx = 0; idx < bufferCount; idx++) { auto *cur = &_pool[idx]; offset = mu::alignUp(cur->curOffset, alignment); @@ -199,7 +199,7 @@ public: } } if (!buffer) { - uint mbNeeds = mu::roundUp(gpuBuffer->size, MegaBytesToBytes); + uint32_t mbNeeds = mu::roundUp(gpuBuffer->size, MegaBytesToBytes); mbNeeds = cc::utils::nextPOT(mbNeeds); CC_ASSERT(mbNeeds > gpuBuffer->size / static_cast(MegaBytesToBytes)); @@ -262,11 +262,11 @@ protected: id mtlBuffer = nil; ccstd::vector> dynamicDataBuffers{MAX_FRAMES_IN_FLIGHT}; uint8_t *mappedData = nullptr; - uint curOffset = 0; + uint32_t curOffset = 0; }; bool _tripleEnabled = false; - uint _inflightIndex = 0; + uint32_t _inflightIndex = 0; id _device = nil; ccstd::vector _pool; }; @@ -334,9 +334,9 @@ struct CCMTLGPUSwapChainObject { struct CCMTLGPUQueueObject { id mtlCommandQueue = nil; - uint numDrawCalls = 0; - uint numInstances = 0; - uint numTriangles = 0; + uint32_t numDrawCalls = 0; + uint32_t numInstances = 0; + uint32_t numTriangles = 0; }; struct CCMTLGPUCommandBufferObject { diff --git a/native/cocos/renderer/gfx-metal/MTLPipelineState.mm b/native/cocos/renderer/gfx-metal/MTLPipelineState.mm index a5ac40bc41..baeb6ce498 100644 --- a/native/cocos/renderer/gfx-metal/MTLPipelineState.mm +++ b/native/cocos/renderer/gfx-metal/MTLPipelineState.mm @@ -210,9 +210,9 @@ bool CCMTLPipelineState::createMTLRenderPipelineState() { //TODO: reconstruction void CCMTLPipelineState::setVertexDescriptor(MTLRenderPipelineDescriptor *descriptor) { auto activeAttributes = static_cast(_shader)->getAttributes(); - ccstd::vector> layouts; - ccstd::unordered_map> map; - ccstd::vector streamOffsets(CCMTLDevice::getInstance()->getCapabilities().maxVertexAttributes, 0u); + ccstd::vector> layouts; + ccstd::unordered_map> map; + ccstd::vector streamOffsets(CCMTLDevice::getInstance()->getCapabilities().maxVertexAttributes, 0u); ccstd::vector activeAttribIdx(activeAttributes.size(), false); for (const auto &inputAttrib : _inputState.attributes) { auto bufferIndex = static_cast(_shader)->getAvailableBufferBindingIndex(ShaderStageFlagBit::VERTEX, inputAttrib.stream); diff --git a/native/cocos/renderer/gfx-metal/MTLQueue.h b/native/cocos/renderer/gfx-metal/MTLQueue.h index 281d1f95aa..eb2c5d3ed4 100644 --- a/native/cocos/renderer/gfx-metal/MTLQueue.h +++ b/native/cocos/renderer/gfx-metal/MTLQueue.h @@ -41,7 +41,7 @@ public: CCMTLQueue &operator=(const CCMTLQueue &) = delete; CCMTLQueue &operator=(CCMTLQueue &&) = delete; - void submit(CommandBuffer *const *cmdBuffs, uint count) override; + void submit(CommandBuffer *const *cmdBuffs, uint32_t count) override; inline CCMTLGPUQueueObject *gpuQueueObj() { return _gpuQueueObj; } diff --git a/native/cocos/renderer/gfx-metal/MTLQueue.mm b/native/cocos/renderer/gfx-metal/MTLQueue.mm index 983d9ee1ee..49cfa4c250 100644 --- a/native/cocos/renderer/gfx-metal/MTLQueue.mm +++ b/native/cocos/renderer/gfx-metal/MTLQueue.mm @@ -63,8 +63,8 @@ void CCMTLQueue::doDestroy() { } } -void CCMTLQueue::submit(CommandBuffer *const *cmdBuffs, uint count) { - for (uint i = 0u; i < count; ++i) { +void CCMTLQueue::submit(CommandBuffer *const *cmdBuffs, uint32_t count) { + for (uint32_t i = 0u; i < count; ++i) { CCMTLCommandBuffer *cmdBuffer = static_cast(cmdBuffs[i]); _gpuQueueObj->numDrawCalls += cmdBuffer->getNumDrawCalls(); _gpuQueueObj->numInstances += cmdBuffer->getNumInstances(); diff --git a/native/cocos/renderer/gfx-metal/MTLRenderCommandEncoder.h b/native/cocos/renderer/gfx-metal/MTLRenderCommandEncoder.h index af8ce10012..7056f5f780 100644 --- a/native/cocos/renderer/gfx-metal/MTLRenderCommandEncoder.h +++ b/native/cocos/renderer/gfx-metal/MTLRenderCommandEncoder.h @@ -42,7 +42,7 @@ struct Color; class CCMTLRenderCommandEncoder final : public CCMTLCommandEncoder { struct BufferBinding final { id buffer; - uint offset = 0; + uint32_t offset = 0; }; public: @@ -157,7 +157,7 @@ public: _pipelineState = pipelineState; } - inline void setStencilFrontBackReferenceValue(uint frontReferenceValue, uint backReferenceValue) { + inline void setStencilFrontBackReferenceValue(uint32_t frontReferenceValue, uint32_t backReferenceValue) { if (_frontReferenceValue == frontReferenceValue && _backReferenceValue == backReferenceValue) return; @@ -204,7 +204,7 @@ public: alpha:_blendColor.w]; } - inline void setVertexBuffer(const id buffer, uint offset, uint index) { + inline void setVertexBuffer(const id buffer, uint32_t offset, uint32_t index) { if (_vertexBufferMap.count(index) > 0) { const auto &bufferBinding = _vertexBufferMap[index]; if (buffer == bufferBinding.buffer && offset == bufferBinding.offset) { @@ -218,7 +218,7 @@ public: atIndex:index]; } - inline void setFragmentBuffer(const id buffer, uint offset, uint index) { + inline void setFragmentBuffer(const id buffer, uint32_t offset, uint32_t index) { if (_fragmentBufferMap.count(index) > 0) { const auto &bufferBinding = _fragmentBufferMap[index]; if (buffer == bufferBinding.buffer && offset == bufferBinding.offset) { @@ -232,7 +232,7 @@ public: atIndex:index]; } - void setVertexTexture(const id texture, uint index) { + void setVertexTexture(const id texture, uint32_t index) { if (_vertexTextureMap.count(index) > 0 && (texture == _vertexTextureMap[index])) return; @@ -240,7 +240,7 @@ public: [_mtlEncoder setVertexTexture:texture atIndex:index]; } - void setFragmentTexture(const id texture, uint index) { + void setFragmentTexture(const id texture, uint32_t index) { if (_fragmentTextureMap.count(index) > 0 && (texture == _fragmentTextureMap[index])) return; @@ -248,7 +248,7 @@ public: [_mtlEncoder setFragmentTexture:texture atIndex:index]; } - void setVertexSampler(const id sampler, uint index) { + void setVertexSampler(const id sampler, uint32_t index) { if (_vertexSamplerMap.count(index) > 0 && (sampler == _vertexSamplerMap[index])) return; @@ -256,7 +256,7 @@ public: [_mtlEncoder setVertexSamplerState:sampler atIndex:index]; } - void setFragmentSampler(const id sampler, uint index) { + void setFragmentSampler(const id sampler, uint32_t index) { if (_fragmentSamplerMap.count(index) > 0 && (sampler == _fragmentSamplerMap[index])) return; @@ -286,8 +286,8 @@ protected: id _mtlEncoder = nil; id _pipelineState = nil; id _depthStencilState = nil; - uint _frontReferenceValue = UINT_MAX; - uint _backReferenceValue = UINT_MAX; + uint32_t _frontReferenceValue = UINT_MAX; + uint32_t _backReferenceValue = UINT_MAX; float _depthBias = 0.f; float _clamp = 0.f; float _slope = 0.f; @@ -298,12 +298,12 @@ protected: Viewport _viewport; Rect _scissorRect; Color _blendColor; - ccstd::unordered_map _vertexBufferMap; - ccstd::unordered_map _fragmentBufferMap; - ccstd::unordered_map> _vertexTextureMap; - ccstd::unordered_map> _fragmentTextureMap; - ccstd::unordered_map> _vertexSamplerMap; - ccstd::unordered_map> _fragmentSamplerMap; + ccstd::unordered_map _vertexBufferMap; + ccstd::unordered_map _fragmentBufferMap; + ccstd::unordered_map> _vertexTextureMap; + ccstd::unordered_map> _fragmentTextureMap; + ccstd::unordered_map> _vertexSamplerMap; + ccstd::unordered_map> _fragmentSamplerMap; }; } // namespace gfx diff --git a/native/cocos/renderer/gfx-metal/MTLRenderPass.h b/native/cocos/renderer/gfx-metal/MTLRenderPass.h index 208af23c1e..f36d2eb364 100644 --- a/native/cocos/renderer/gfx-metal/MTLRenderPass.h +++ b/native/cocos/renderer/gfx-metal/MTLRenderPass.h @@ -46,20 +46,20 @@ public: void setDepthStencilAttachment(CCMTLTexture *texture, int level); inline MTLRenderPassDescriptor *getMTLRenderPassDescriptor() const { return _mtlRenderPassDescriptor; } - inline uint getColorRenderTargetNums() const { return _colorRenderTargetNums; } + inline uint32_t getColorRenderTargetNums() const { return _colorRenderTargetNums; } inline const ccstd::vector &getRenderTargetSizes() const { return _renderTargetSizes; } inline void nextSubpass() { _currentSubpassIndex++; } - inline uint getCurrentSubpassIndex() { return _currentSubpassIndex; } + inline uint32_t getCurrentSubpassIndex() { return _currentSubpassIndex; } inline void reset() { _currentSubpassIndex = 0; } protected: void doInit(const RenderPassInfo &info) override; void doDestroy() override; - uint _outputAttachmentOffset = 0; - uint _currentSubpassIndex = 0; + uint32_t _outputAttachmentOffset = 0; + uint32_t _currentSubpassIndex = 0; MTLRenderPassDescriptor *_mtlRenderPassDescriptor = nil; - uint _colorRenderTargetNums = 0; + uint32_t _colorRenderTargetNums = 0; ccstd::vector _renderTargetSizes; }; diff --git a/native/cocos/renderer/gfx-metal/MTLRenderPass.mm b/native/cocos/renderer/gfx-metal/MTLRenderPass.mm index e280ee727f..ad517c613a 100644 --- a/native/cocos/renderer/gfx-metal/MTLRenderPass.mm +++ b/native/cocos/renderer/gfx-metal/MTLRenderPass.mm @@ -46,7 +46,7 @@ void CCMTLRenderPass::doInit(const RenderPassInfo& info) { _renderTargetSizes.resize(_colorAttachments.size()); _mtlRenderPassDescriptor = [[MTLRenderPassDescriptor alloc] init]; - uint i = 0; + uint32_t i = 0; for (const auto& colorAttachment : _colorAttachments) { _mtlRenderPassDescriptor.colorAttachments[i].loadAction = mu::toMTLLoadAction(colorAttachment.loadOp); _mtlRenderPassDescriptor.colorAttachments[i].storeAction = mu::toMTLStoreAction(colorAttachment.storeOp); diff --git a/native/cocos/renderer/gfx-metal/MTLSemaphore.h b/native/cocos/renderer/gfx-metal/MTLSemaphore.h index 23cba29b5a..011e4eb5dc 100644 --- a/native/cocos/renderer/gfx-metal/MTLSemaphore.h +++ b/native/cocos/renderer/gfx-metal/MTLSemaphore.h @@ -32,7 +32,7 @@ namespace gfx { class CCMTLSemaphore final { public: - explicit CCMTLSemaphore(uint initialValue) : _semaphoreCount(initialValue) { + explicit CCMTLSemaphore(uint32_t initialValue) : _semaphoreCount(initialValue) { _semaphore = dispatch_semaphore_create(initialValue); } ~CCMTLSemaphore() = default; @@ -50,20 +50,20 @@ public: } void trySyncAll(uint64_t nanoSec) { - for (uint i = 0; i < _semaphoreCount; i++) { + for (uint32_t i = 0; i < _semaphoreCount; i++) { dispatch_semaphore_wait(_semaphore, nanoSec); } } void syncAll() { - for (uint i = 0; i < _semaphoreCount; i++) { + for (uint32_t i = 0; i < _semaphoreCount; i++) { dispatch_semaphore_wait(_semaphore, DISPATCH_TIME_FOREVER); } } protected: dispatch_semaphore_t _semaphore = nullptr; - uint _semaphoreCount = 0; + uint32_t _semaphoreCount = 0; }; } // namespace gfx diff --git a/native/cocos/renderer/gfx-metal/MTLShader.h b/native/cocos/renderer/gfx-metal/MTLShader.h index 0ca479e9cd..a89e6216d5 100644 --- a/native/cocos/renderer/gfx-metal/MTLShader.h +++ b/native/cocos/renderer/gfx-metal/MTLShader.h @@ -45,12 +45,12 @@ public: inline id getVertMTLFunction() const { return _vertFunction; } inline id getFragmentMTLFunction() const { return _fragFunction; } inline id getComputeMTLFunction() const { return _cmptFunction; } - inline const ccstd::unordered_map &getFragmentSamplerBindings() const { return _mtlFragmentSamplerBindings; } + inline const ccstd::unordered_map &getFragmentSamplerBindings() const { return _mtlFragmentSamplerBindings; } inline const CCMTLGPUShader *gpuShader() const { return _gpuShader; } - uint getAvailableBufferBindingIndex(ShaderStageFlagBit stage, uint stream); + uint32_t getAvailableBufferBindingIndex(ShaderStageFlagBit stage, uint32_t stream); - id getSpecializedFragFunction(uint *index, int *val, uint count); + id getSpecializedFragFunction(uint32_t *index, int *val, uint32_t count); #ifdef DEBUG_SHADER inline const ccstd::string &getVertGlslShader() const { return _vertGlslShader; } @@ -79,9 +79,9 @@ protected: // function constant hash , specialized MTLFunction NSMutableDictionary> *_specializedFragFuncs = nil; - ccstd::unordered_map _mtlFragmentSamplerBindings; - ccstd::vector _availableVertexBufferBindingIndex; - ccstd::vector _availableFragmentBufferBindingIndex; + ccstd::unordered_map _mtlFragmentSamplerBindings; + ccstd::vector _availableVertexBufferBindingIndex; + ccstd::vector _availableFragmentBufferBindingIndex; CCMTLGPUShader *_gpuShader = nullptr; diff --git a/native/cocos/renderer/gfx-metal/MTLShader.mm b/native/cocos/renderer/gfx-metal/MTLShader.mm index 2fcd7344fb..b65cac030a 100644 --- a/native/cocos/renderer/gfx-metal/MTLShader.mm +++ b/native/cocos/renderer/gfx-metal/MTLShader.mm @@ -219,8 +219,8 @@ bool CCMTLShader::createMTLFunction(const ShaderStage& stage) { return true; } -id CCMTLShader::getSpecializedFragFunction(uint* index, int* val, uint count) { - uint notEvenHash = 0; +id CCMTLShader::getSpecializedFragFunction(uint32_t* index, int* val, uint32_t count) { + uint32_t notEvenHash = 0; for (size_t i = 0; i < count; i++) { notEvenHash += val[i] * std::pow(10, index[i]); } @@ -272,7 +272,7 @@ id CCMTLShader::getSpecializedFragFunction(uint* index, int* val, u return [_specializedFragFuncs valueForKey:hashStr]; } -uint CCMTLShader::getAvailableBufferBindingIndex(ShaderStageFlagBit stage, uint stream) { +uint32_t CCMTLShader::getAvailableBufferBindingIndex(ShaderStageFlagBit stage, uint32_t stream) { if (hasFlag(stage, ShaderStageFlagBit::VERTEX)) { return _availableVertexBufferBindingIndex.at(stream); } @@ -286,10 +286,10 @@ uint CCMTLShader::getAvailableBufferBindingIndex(ShaderStageFlagBit stage, uint } void CCMTLShader::setAvailableBufferBindingIndex() { - uint usedVertexBufferBindingIndexes = 0; - uint usedFragmentBufferBindingIndexes = 0; - uint vertexBindingCount = 0; - uint fragmentBindingCount = 0; + uint32_t usedVertexBufferBindingIndexes = 0; + uint32_t usedFragmentBufferBindingIndexes = 0; + uint32_t vertexBindingCount = 0; + uint32_t fragmentBindingCount = 0; for (const auto& block : _gpuShader->blocks) { if (hasFlag(block.second.stages, ShaderStageFlagBit::VERTEX)) { vertexBindingCount++; @@ -304,10 +304,10 @@ void CCMTLShader::setAvailableBufferBindingIndex() { auto maxBufferBindingIndex = CCMTLDevice::getInstance()->getMaximumBufferBindingIndex(); _availableVertexBufferBindingIndex.resize(maxBufferBindingIndex - vertexBindingCount); _availableFragmentBufferBindingIndex.resize(maxBufferBindingIndex - fragmentBindingCount); - uint availableVertexBufferBit = ~usedVertexBufferBindingIndexes; - uint availableFragmentBufferBit = ~usedFragmentBufferBindingIndexes; + uint32_t availableVertexBufferBit = ~usedVertexBufferBindingIndexes; + uint32_t availableFragmentBufferBit = ~usedFragmentBufferBindingIndexes; int theBit = maxBufferBindingIndex - 1; - uint i = 0, j = 0; + uint32_t i = 0, j = 0; for (; theBit >= 0; theBit--) { if ((availableVertexBufferBit & (1 << theBit))) { _availableVertexBufferBindingIndex[i++] = theBit; diff --git a/native/cocos/renderer/gfx-metal/MTLTexture.h b/native/cocos/renderer/gfx-metal/MTLTexture.h index e5f46b1a7b..78083ae95d 100644 --- a/native/cocos/renderer/gfx-metal/MTLTexture.h +++ b/native/cocos/renderer/gfx-metal/MTLTexture.h @@ -64,7 +64,7 @@ protected: void doInit(const TextureInfo &info) override; void doInit(const TextureViewInfo &info) override; void doDestroy() override; - void doResize(uint width, uint height, uint size) override; + void doResize(uint32_t width, uint32_t height, uint32_t size) override; void doInit(const SwapchainTextureInfo &info) override; bool createMTLTexture(); diff --git a/native/cocos/renderer/gfx-metal/MTLTexture.mm b/native/cocos/renderer/gfx-metal/MTLTexture.mm index 90c19c46eb..75fe8899fe 100644 --- a/native/cocos/renderer/gfx-metal/MTLTexture.mm +++ b/native/cocos/renderer/gfx-metal/MTLTexture.mm @@ -252,7 +252,7 @@ void CCMTLTexture::doDestroy() { CCMTLGPUGarbageCollectionPool::getInstance()->collect(destroyFunc); } -void CCMTLTexture::doResize(uint width, uint height, uint size) { +void CCMTLTexture::doResize(uint32_t width, uint32_t height, uint32_t size) { if (_isTextureView) { CC_LOG_ERROR("TextureView does not support resize! at %p", this); return; diff --git a/native/cocos/renderer/gfx-metal/MTLUtils.h b/native/cocos/renderer/gfx-metal/MTLUtils.h index 06c2acb3f5..f64e66fb77 100644 --- a/native/cocos/renderer/gfx-metal/MTLUtils.h +++ b/native/cocos/renderer/gfx-metal/MTLUtils.h @@ -73,45 +73,45 @@ int toMTLSamplerBorderColor(const Color &); MTLSamplerMinMagFilter toMTLSamplerMinMagFilter(Filter); MTLSamplerMipFilter toMTLSamplerMipFilter(Filter); ccstd::string spirv2MSL(const uint32_t *ir, size_t word_count, ShaderStageFlagBit shaderType, CCMTLGPUShader *gpuShader); -const uint8_t *convertRGB8ToRGBA8(const uint8_t *source, uint length); -const uint8_t *convertRGB32FToRGBA32F(const uint8_t *source, uint length); +const uint8_t *convertRGB8ToRGBA8(const uint8_t *source, uint32_t length); +const uint8_t *convertRGB32FToRGBA32F(const uint8_t *source, uint32_t length); NSUInteger highestSupportedFeatureSet(id device); -uint getGPUFamily(MTLFeatureSet featureSet); -uint getMaxVertexAttributes(uint family); -uint getMaxEntriesInBufferArgumentTable(uint family); -uint getMaxEntriesInTextureArgumentTable(uint family); -uint getMaxEntriesInSamplerStateArgumentTable(uint family); -uint getMaxTexture2DWidthHeight(uint family); -uint getMaxCubeMapTextureWidthHeight(uint family); -uint getMaxColorRenderTarget(uint family); -uint getMinBufferOffsetAlignment(uint family); -uint getMaxThreadsPerGroup(uint family); -bool isPVRTCSuppported(uint family); -bool isEAC_ETCCSuppported(uint family); -bool isASTCSuppported(uint family); -bool isBCSupported(uint family); -bool isColorBufferFloatSupported(uint family); -bool isColorBufferHalfFloatSupported(uint family); -bool isLinearTextureSupported(uint family); -bool isUISamplerSupported(uint family); -bool isRGB10A2UIStorageSupported(uint family); -bool isDDepthStencilFilterSupported(uint family); +uint32_t getGPUFamily(MTLFeatureSet featureSet); +uint32_t getMaxVertexAttributes(uint32_t family); +uint32_t getMaxEntriesInBufferArgumentTable(uint32_t family); +uint32_t getMaxEntriesInTextureArgumentTable(uint32_t family); +uint32_t getMaxEntriesInSamplerStateArgumentTable(uint32_t family); +uint32_t getMaxTexture2DWidthHeight(uint32_t family); +uint32_t getMaxCubeMapTextureWidthHeight(uint32_t family); +uint32_t getMaxColorRenderTarget(uint32_t family); +uint32_t getMinBufferOffsetAlignment(uint32_t family); +uint32_t getMaxThreadsPerGroup(uint32_t family); +bool isPVRTCSuppported(uint32_t family); +bool isEAC_ETCCSuppported(uint32_t family); +bool isASTCSuppported(uint32_t family); +bool isBCSupported(uint32_t family); +bool isColorBufferFloatSupported(uint32_t family); +bool isColorBufferHalfFloatSupported(uint32_t family); +bool isLinearTextureSupported(uint32_t family); +bool isUISamplerSupported(uint32_t family); +bool isRGB10A2UIStorageSupported(uint32_t family); +bool isDDepthStencilFilterSupported(uint32_t family); bool isIndirectCommandBufferSupported(MTLFeatureSet featureSet); -bool isDepthStencilFormatSupported(id device, Format format, uint family); -MTLPixelFormat getSupportedDepthStencilFormat(id device, uint family, uint &depthBits); -bool isIndirectDrawSupported(uint family); +bool isDepthStencilFormatSupported(id device, Format format, uint32_t family); +MTLPixelFormat getSupportedDepthStencilFormat(id device, uint32_t family, uint32_t &depthBits); +bool isIndirectDrawSupported(uint32_t family); bool isImageBlockSupported(); bool isFramebufferFetchSupported(); ccstd::string featureSetToString(MTLFeatureSet featureSet); -const uint8_t *const convertData(const uint8_t *source, uint length, Format type); -uint getBlockSize(Format format); -uint getBytesPerRow(Format format, uint width); +const uint8_t *const convertData(const uint8_t *source, uint32_t length, Format type); +uint32_t getBlockSize(Format format); +uint32_t getBytesPerRow(Format format, uint32_t width); bool pixelFormatIsColorRenderable(Format format); -bool isSamplerDescriptorCompareFunctionSupported(uint family); -void clearRenderArea(CCMTLDevice *device, id renderEncoder, RenderPass *renderPass, const Rect &renderArea, const Color *colors, float depth, uint stencil); -inline uint alignUp(uint inSize, uint align) { return ((inSize + align - 1) / align) * align; } +bool isSamplerDescriptorCompareFunctionSupported(uint32_t family); +void clearRenderArea(CCMTLDevice *device, id renderEncoder, RenderPass *renderPass, const Rect &renderArea, const Color *colors, float depth, uint32_t stencil); +inline uint32_t alignUp(uint32_t inSize, uint32_t align) { return ((inSize + align - 1) / align) * align; } void clearUtilResource(); -inline uint roundUp(uint dividend, uint divisor) { return (dividend - 1) / divisor + 1; } +inline uint32_t roundUp(uint32_t dividend, uint32_t divisor) { return (dividend - 1) / divisor + 1; } } // namespace mu } // namespace gfx diff --git a/native/cocos/renderer/gfx-metal/MTLUtils.mm b/native/cocos/renderer/gfx-metal/MTLUtils.mm index e14ced7bbb..8cb0dc3571 100644 --- a/native/cocos/renderer/gfx-metal/MTLUtils.mm +++ b/native/cocos/renderer/gfx-metal/MTLUtils.mm @@ -696,7 +696,7 @@ MTLBlendFactor mu::toMTLBlendFactor(BlendFactor factor) { case BlendFactor::ONE_MINUS_DST_COLOR: return MTLBlendFactorOneMinusDestinationColor; case BlendFactor::SRC_ALPHA_SATURATE: return MTLBlendFactorSourceAlphaSaturated; default: { - CC_LOG_ERROR("Unsupported blend factor %u", (uint)factor); + CC_LOG_ERROR("Unsupported blend factor %u", (uint32_t)factor); return MTLBlendFactorZero; } } @@ -963,7 +963,7 @@ ccstd::string mu::spirv2MSL(const uint32_t *ir, size_t word_count, // TODO: bindings from shader just kind of validation, cannot be directly input // Get all uniform buffers in the shader. - uint maxBufferBindingIndex = device->getMaximumBufferBindingIndex(); + uint32_t maxBufferBindingIndex = device->getMaximumBufferBindingIndex(); for (const auto &ubo : resources.uniform_buffers) { auto set = msl.get_decoration(ubo.id, spv::DecorationDescriptorSet); auto binding = msl.get_decoration(ubo.id, spv::DecorationBinding); @@ -973,7 +973,7 @@ ccstd::string mu::spirv2MSL(const uint32_t *ir, size_t word_count, CC_LOG_ERROR("Implementation limits: %s binding at %d, should not use more than %d entries in the buffer argument table", ubo.name.c_str(), binding, maxBufferBindingIndex); } - uint fakeHash = set * 128 + binding; + uint32_t fakeHash = set * 128 + binding; if (gpuShader->blocks.find(fakeHash) == gpuShader->blocks.end()) { auto mappedBinding = gpuShader->bufferIndex; newBinding.desc_set = set; @@ -1002,7 +1002,7 @@ ccstd::string mu::spirv2MSL(const uint32_t *ir, size_t word_count, CC_LOG_ERROR("Implementation limits: %s binding at %d, should not use more than %d entries in the buffer argument table", ubo.name.c_str(), binding, maxBufferBindingIndex); } - uint fakeHash = set * 128 + binding; + uint32_t fakeHash = set * 128 + binding; if (gpuShader->blocks.find(fakeHash) == gpuShader->blocks.end()) { auto mappedBinding = gpuShader->bufferIndex; newBinding.desc_set = set; @@ -1101,8 +1101,8 @@ ccstd::string mu::spirv2MSL(const uint32_t *ir, size_t word_count, return output; } -const uint8_t *mu::convertRGB8ToRGBA8(const uint8_t *source, uint length) { - uint finalLength = length * 4; +const uint8_t *mu::convertRGB8ToRGBA8(const uint8_t *source, uint32_t length) { + uint32_t finalLength = length * 4; uint8_t *out = (uint8_t *)CC_MALLOC(finalLength); if (!out) { CC_LOG_WARNING("Failed to alloc memory in convertRGB8ToRGBA8()."); @@ -1111,7 +1111,7 @@ const uint8_t *mu::convertRGB8ToRGBA8(const uint8_t *source, uint length) { const uint8_t *src = source; uint8_t *dst = out; - for (uint i = 0; i < length; ++i) { + for (uint32_t i = 0; i < length; ++i) { *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; @@ -1121,8 +1121,8 @@ const uint8_t *mu::convertRGB8ToRGBA8(const uint8_t *source, uint length) { return out; } -const uint8_t *mu::convertRGB32FToRGBA32F(const uint8_t *source, uint length) { - uint finalLength = length * sizeof(float) * 4; +const uint8_t *mu::convertRGB32FToRGBA32F(const uint8_t *source, uint32_t length) { + uint32_t finalLength = length * sizeof(float) * 4; uint8_t *out = (uint8_t *)CC_MALLOC(finalLength); if (!out) { CC_LOG_WARNING("Failed to alloc memory in convertRGB32FToRGBA32F()."); @@ -1131,7 +1131,7 @@ const uint8_t *mu::convertRGB32FToRGBA32F(const uint8_t *source, uint length) { const float *src = reinterpret_cast(source); float *dst = reinterpret_cast(out); - for (uint i = 0; i < length; ++i) { + for (uint32_t i = 0; i < length; ++i) { *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; @@ -1177,15 +1177,15 @@ NSUInteger mu::highestSupportedFeatureSet(id device) { return defaultFeatureSet; } -uint mu::getGPUFamily(MTLFeatureSet featureSet) { +uint32_t mu::getGPUFamily(MTLFeatureSet featureSet) { #if CC_PLATFORM == CC_PLATFORM_IOS - return static_cast(getIOSGPUFamily(featureSet)); + return static_cast(getIOSGPUFamily(featureSet)); #else - return static_cast(getMacGPUFamily(featureSet)); + return static_cast(getMacGPUFamily(featureSet)); #endif } -uint mu::getMaxVertexAttributes(uint family) { +uint32_t mu::getMaxVertexAttributes(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1199,7 +1199,7 @@ uint mu::getMaxVertexAttributes(uint family) { } } -uint mu::getMaxEntriesInBufferArgumentTable(uint family) { +uint32_t mu::getMaxEntriesInBufferArgumentTable(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1213,7 +1213,7 @@ uint mu::getMaxEntriesInBufferArgumentTable(uint family) { } } -uint mu::getMaxEntriesInTextureArgumentTable(uint family) { +uint32_t mu::getMaxEntriesInTextureArgumentTable(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1229,7 +1229,7 @@ uint mu::getMaxEntriesInTextureArgumentTable(uint family) { } } -uint mu::getMaxEntriesInSamplerStateArgumentTable(uint family) { +uint32_t mu::getMaxEntriesInSamplerStateArgumentTable(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1243,7 +1243,7 @@ uint mu::getMaxEntriesInSamplerStateArgumentTable(uint family) { } } -uint mu::getMaxTexture2DWidthHeight(uint family) { +uint32_t mu::getMaxTexture2DWidthHeight(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1258,7 +1258,7 @@ uint mu::getMaxTexture2DWidthHeight(uint family) { } } -uint mu::getMaxCubeMapTextureWidthHeight(uint family) { +uint32_t mu::getMaxCubeMapTextureWidthHeight(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1273,7 +1273,7 @@ uint mu::getMaxCubeMapTextureWidthHeight(uint family) { } } -uint mu::getMaxThreadsPerGroup(uint family) { +uint32_t mu::getMaxThreadsPerGroup(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1288,7 +1288,7 @@ uint mu::getMaxThreadsPerGroup(uint family) { } } -uint mu::getMaxColorRenderTarget(uint family) { +uint32_t mu::getMaxColorRenderTarget(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: return 4; @@ -1303,7 +1303,7 @@ uint mu::getMaxColorRenderTarget(uint family) { } } -uint mu::getMinBufferOffsetAlignment(uint family) { +uint32_t mu::getMinBufferOffsetAlignment(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1322,7 +1322,7 @@ uint mu::getMinBufferOffsetAlignment(uint family) { } } -bool mu::isPVRTCSuppported(uint family) { +bool mu::isPVRTCSuppported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1337,7 +1337,7 @@ bool mu::isPVRTCSuppported(uint family) { } } -bool mu::isEAC_ETCCSuppported(uint family) { +bool mu::isEAC_ETCCSuppported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1352,7 +1352,7 @@ bool mu::isEAC_ETCCSuppported(uint family) { } } -bool mu::isASTCSuppported(uint family) { +bool mu::isASTCSuppported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: return false; @@ -1368,7 +1368,7 @@ bool mu::isASTCSuppported(uint family) { } } -bool mu::isBCSupported(uint family) { +bool mu::isBCSupported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1383,7 +1383,7 @@ bool mu::isBCSupported(uint family) { } } -bool mu::isColorBufferFloatSupported(uint family) { +bool mu::isColorBufferFloatSupported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1397,7 +1397,7 @@ bool mu::isColorBufferFloatSupported(uint family) { } } -bool mu::isColorBufferHalfFloatSupported(uint family) { +bool mu::isColorBufferHalfFloatSupported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1411,7 +1411,7 @@ bool mu::isColorBufferHalfFloatSupported(uint family) { } } -bool mu::isLinearTextureSupported(uint family) { +bool mu::isLinearTextureSupported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1425,7 +1425,7 @@ bool mu::isLinearTextureSupported(uint family) { } } -bool mu::isUISamplerSupported(uint family) { +bool mu::isUISamplerSupported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1440,7 +1440,7 @@ bool mu::isUISamplerSupported(uint family) { } } -bool mu::isRGB10A2UIStorageSupported(uint family) { +bool mu::isRGB10A2UIStorageSupported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1455,7 +1455,7 @@ bool mu::isRGB10A2UIStorageSupported(uint family) { } } -bool mu::isDDepthStencilFilterSupported(uint family) { +bool mu::isDDepthStencilFilterSupported(uint32_t family) { switch (static_cast(family)) { case GPUFamily::Apple1: case GPUFamily::Apple2: @@ -1482,7 +1482,7 @@ bool mu::isIndirectCommandBufferSupported(MTLFeatureSet featureSet) { #endif return false; } -bool mu::isDepthStencilFormatSupported(id device, Format format, uint family) { +bool mu::isDepthStencilFormatSupported(id device, Format format, uint32_t family) { return true; // GPUFamily gpuFamily = static_cast(family); // switch (format) { @@ -1527,7 +1527,7 @@ bool mu::isDepthStencilFormatSupported(id device, Format format, uint // } } -bool mu::isIndirectDrawSupported(uint family) { +bool mu::isIndirectDrawSupported(uint32_t family) { #if CC_PLATFORM == CC_PLATFORM_IOS return static_cast(family) < GPUFamily::Apple3 ? false : true; //is only supported on MTLFeatureSet_iOS_GPUFamily3_v1 and later' #else @@ -1535,7 +1535,7 @@ bool mu::isIndirectDrawSupported(uint family) { #endif } -MTLPixelFormat mu::getSupportedDepthStencilFormat(id device, uint family, uint &depthBits) { +MTLPixelFormat mu::getSupportedDepthStencilFormat(id device, uint32_t family, uint32_t &depthBits) { #if CC_PLATFORM == CC_PLATFORM_MACOS return MTLPixelFormatDepth24Unorm_Stencil8; #else @@ -1551,7 +1551,7 @@ ccstd::string mu::featureSetToString(MTLFeatureSet featureSet) { #endif } -const uint8_t *const mu::convertData(const uint8_t *source, uint length, Format type) { +const uint8_t *const mu::convertData(const uint8_t *source, uint32_t length, Format type) { switch (type) { case Format::RGB8: return mu::convertRGB8ToRGBA8(source, length); case Format::RGB32F: return mu::convertRGB32FToRGBA32F(source, length); @@ -1559,7 +1559,7 @@ const uint8_t *const mu::convertData(const uint8_t *source, uint length, Format } } -uint mu::getBlockSize(Format format) { +uint32_t mu::getBlockSize(Format format) { switch (format) { case Format::ASTC_RGBA_4X4: case Format::ASTC_SRGBA_4X4: @@ -1609,13 +1609,13 @@ uint mu::getBlockSize(Format format) { case Format::EAC_RG11SN: // blockWidth = 4, blockHeight = 4; return 16u; default: - return GFX_FORMAT_INFOS[static_cast(format)].size; + return GFX_FORMAT_INFOS[static_cast(format)].size; } } -uint mu::getBytesPerRow(Format format, uint width) { - uint blockSize = getBlockSize(format); - uint widthInBlock = 1u; +uint32_t mu::getBytesPerRow(Format format, uint32_t width) { + uint32_t blockSize = getBlockSize(format); + uint32_t widthInBlock = 1u; switch (format) { case Format::ASTC_RGBA_4X4: case Format::ASTC_SRGBA_4X4: @@ -1700,7 +1700,7 @@ bool mu::pixelFormatIsColorRenderable(Format format) { } //CompareFunction of MTLSamplerDescriptor is only supported on MTLFeatureSet_iOS_GPUFamily3_v1 and later -bool mu::isSamplerDescriptorCompareFunctionSupported(uint family) { +bool mu::isSamplerDescriptorCompareFunctionSupported(uint32_t family) { #if CC_PLATFORM == CC_PLATFORM_IOS return (static_cast(family) < GPUFamily::Apple3) ? false : true; #else @@ -1708,10 +1708,10 @@ bool mu::isSamplerDescriptorCompareFunctionSupported(uint family) { #endif } -void mu::clearRenderArea(CCMTLDevice *device, id renderEncoder, RenderPass *renderPass, const Rect &renderArea, const Color *colors, float /*depth*/, uint /*stencil*/) { +void mu::clearRenderArea(CCMTLDevice *device, id renderEncoder, RenderPass *renderPass, const Rect &renderArea, const Color *colors, float /*depth*/, uint32_t /*stencil*/) { const auto gpuPSO = getClearRenderPassPipelineState(device, renderPass); const auto mtlRenderPass = static_cast(renderPass); - uint slot = 0u; + uint32_t slot = 0u; const auto &renderTargetSizes = mtlRenderPass->getRenderTargetSizes(); float renderTargetWidth = renderTargetSizes[slot].x; @@ -1753,7 +1753,7 @@ void mu::clearRenderArea(CCMTLDevice *device, id render length:sizeof(colors[slot]) atIndex:0]; - uint count = sizeof(vertexes) / sizeof(Vec2); + uint32_t count = sizeof(vertexes) / sizeof(Vec2); [renderEncoder drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:count]; diff --git a/native/cocos/renderer/gfx-wgpu/WGPUBuffer.cpp b/native/cocos/renderer/gfx-wgpu/WGPUBuffer.cpp index d18ef27869..4a7ec4c0cf 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUBuffer.cpp +++ b/native/cocos/renderer/gfx-wgpu/WGPUBuffer.cpp @@ -91,7 +91,7 @@ void CCWGPUBuffer::doDestroy() { _internalChanged = true; } -void CCWGPUBuffer::doResize(uint size, uint count) { +void CCWGPUBuffer::doResize(uint32_t size, uint32_t count) { if (_isBufferView) { printf("Resize is not support on buffer view!"); return; @@ -126,7 +126,7 @@ void bufferUpdateCallback(WGPUBufferMapAsyncStatus status, void *userdata) { } } -void CCWGPUBuffer::update(const void *buffer, uint size) { +void CCWGPUBuffer::update(const void *buffer, uint32_t size) { // uint32_t alignedSize = ceil(size / 4.0) * 4; // size_t buffSize = alignedSize; // // if (hasFlag(_memUsage, MemoryUsageBit::DEVICE)) { diff --git a/native/cocos/renderer/gfx-wgpu/WGPUBuffer.h b/native/cocos/renderer/gfx-wgpu/WGPUBuffer.h index 52d6a064de..fd18b64c0f 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUBuffer.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUBuffer.h @@ -40,7 +40,7 @@ public: CCWGPUBuffer(); ~CCWGPUBuffer() = default; - void update(const void *buffer, uint size) override; + void update(const void *buffer, uint32_t size) override; inline CCWGPUBufferObject *gpuBufferObject() const { return _gpuBufferObject; } @@ -48,9 +48,9 @@ public: static CCWGPUBuffer *defaultStorageBuffer(); - inline uint getOffset() const { return _offset; } + inline uint32_t getOffset() const { return _offset; } - void update(const emscripten::val &v, uint size) { + void update(const emscripten::val &v, uint32_t size) { ccstd::vector buffer = emscripten::convertJSArrayToNumberVector(v); update(reinterpret_cast(buffer.data()), size); } @@ -70,7 +70,7 @@ protected: void doInit(const BufferInfo &info) override; void doInit(const BufferViewInfo &info) override; void doDestroy() override; - void doResize(uint size, uint count) override; + void doResize(uint32_t size, uint32_t count) override; CCWGPUBufferObject *_gpuBufferObject = nullptr; diff --git a/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.cpp b/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.cpp index d6ebb78dc2..e5bc63475c 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.cpp +++ b/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.cpp @@ -68,7 +68,7 @@ void CCWGPUCommandBuffer::doDestroy() { } } -void CCWGPUCommandBuffer::begin(RenderPass * /*renderPass*/, uint /*subpass*/, Framebuffer * /*frameBuffer*/) { +void CCWGPUCommandBuffer::begin(RenderPass * /*renderPass*/, uint32_t /*subpass*/, Framebuffer * /*frameBuffer*/) { //TODO_Zeqiang: subpass support // printf("begin\n"); _gpuCommandBufferObj->wgpuCommandEncoder = wgpuDeviceCreateCommandEncoder(CCWGPUDevice::getInstance()->gpuDeviceObject()->wgpuDevice, nullptr); @@ -96,7 +96,7 @@ void CCWGPUCommandBuffer::end() { } } -void CCWGPUCommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint stencil, CommandBuffer *const * /*secondaryCBs*/, uint /*secondaryCBCount*/) { +void CCWGPUCommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint32_t stencil, CommandBuffer *const * /*secondaryCBs*/, uint32_t /*secondaryCBCount*/) { _renderPass = renderPass; _frameBuffer = fbo; @@ -196,9 +196,9 @@ void CCWGPUCommandBuffer::bindPipelineState(PipelineState *pso) { _gpuCommandBufferObj->stateCache.pipelineState = static_cast(pso); } -void CCWGPUCommandBuffer::bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) { - uint dynOffsetCount = dynamicOffsetCount; - const uint *dynOffsets = dynamicOffsets; +void CCWGPUCommandBuffer::bindDescriptorSet(uint32_t set, DescriptorSet *descriptorSet, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets) { + uint32_t dynOffsetCount = dynamicOffsetCount; + const uint32_t *dynOffsets = dynamicOffsets; auto &descriptorSets = _gpuCommandBufferObj->stateCache.descriptorSets; auto iter = std::find_if(descriptorSets.begin(), descriptorSets.end(), [set](const CCWGPUDescriptorSetObject &descriptorSet) { return descriptorSet.index == set; @@ -255,11 +255,11 @@ void CCWGPUCommandBuffer::setDepthBound(float minBounds, float maxBounds) { _gpuCommandBufferObj->stateCache.depthMaxBound = maxBounds; } -void CCWGPUCommandBuffer::setStencilWriteMask(StencilFace face, uint mask) { +void CCWGPUCommandBuffer::setStencilWriteMask(StencilFace face, uint32_t mask) { _gpuCommandBufferObj->stateCache.stencilMasks[face].writeMask = mask; } -void CCWGPUCommandBuffer::setStencilCompareMask(StencilFace face, uint ref, uint mask) { +void CCWGPUCommandBuffer::setStencilCompareMask(StencilFace face, uint32_t ref, uint32_t mask) { _gpuCommandBufferObj->stateCache.stencilMasks[face].compareRef = ref; _gpuCommandBufferObj->stateCache.stencilMasks[face].compareMask = mask; } @@ -286,9 +286,9 @@ void CCWGPUCommandBuffer::bindStates() { descriptorSets[i].descriptorSet->prepare(); if (descriptorSets[i].descriptorSet->dynamicOffsetCount() != descriptorSets[i].dynamicOffsetCount) { - uint *dynOffsets = dynamicOffsetBuffer; + uint32_t *dynOffsets = dynamicOffsetBuffer; const Pairs &dynamicOffsets = descriptorSets[i].descriptorSet->dynamicOffsets(); - uint givenOffsetIndex = 0; + uint32_t givenOffsetIndex = 0; for (size_t j = 0; j < descriptorSets[i].descriptorSet->dynamicOffsetCount(); ++j) { if (j >= descriptorSets[i].dynamicOffsetCount || dynamicOffsets[j].second == 0) { dynOffsets[j] = 0; @@ -525,7 +525,7 @@ void CCWGPUCommandBuffer::draw(const DrawInfo &info) { } } -void CCWGPUCommandBuffer::updateBuffer(Buffer *buff, const void *data, uint size) { +void CCWGPUCommandBuffer::updateBuffer(Buffer *buff, const void *data, uint32_t size) { uint32_t alignedSize = ceil(size / 4.0) * 4; size_t buffSize = alignedSize; @@ -560,7 +560,7 @@ void CCWGPUCommandBuffer::updateBuffer(Buffer *buff, const void *data, uint size } } -void CCWGPUCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) { +void CCWGPUCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) { for (size_t i = 0; i < count; i++) { WGPUOrigin3D origin = { .x = static_cast(regions[i].texOffset.x), @@ -579,7 +579,7 @@ void CCWGPUCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Te uint32_t width = regions[i].texExtent.width; uint32_t height = regions[i].texExtent.height; uint32_t depth = regions[i].texExtent.depth; - uint32_t bytesPerRow = GFX_FORMAT_INFOS[static_cast(ccTex->getFormat())].size * width; + uint32_t bytesPerRow = GFX_FORMAT_INFOS[static_cast(ccTex->getFormat())].size * width; uint32_t dataSize = bytesPerRow * height * depth; WGPUTextureDataLayout texLayout = { @@ -598,7 +598,7 @@ void CCWGPUCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Te } } -void CCWGPUCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint count, Filter filter) { +void CCWGPUCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) { for (size_t i = 0; i < count; i++) { auto *srcTex = static_cast(srcTexture); auto *dstTex = static_cast(dstTexture); @@ -663,7 +663,7 @@ void CCWGPUCommandBuffer::dispatch(const DispatchInfo &info) { } } -void CCWGPUCommandBuffer::pipelineBarrier(const GlobalBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint textureBarrierCount) { +void CCWGPUCommandBuffer::pipelineBarrier(const GlobalBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) { } void CCWGPUCommandBuffer::updateIndirectBuffer(Buffer *buffer, const DrawInfoList &list) { diff --git a/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h b/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h index 12fe43306a..c12794a271 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h @@ -43,12 +43,12 @@ public: CCWGPUCommandBuffer(); ~CCWGPUCommandBuffer() = default; - void begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer) override; + void begin(RenderPass *renderPass, uint32_t subpass, Framebuffer *frameBuffer) override; void end() override; - void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint stencil, CommandBuffer *const *secondaryCBs, uint secondaryCBCount) override; + void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint32_t stencil, CommandBuffer *const *secondaryCBs, uint32_t secondaryCBCount) override; void endRenderPass() override; void bindPipelineState(PipelineState *pso) override; - void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) override; + void bindDescriptorSet(uint32_t set, DescriptorSet *descriptorSet, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets) override; void bindInputAssembler(InputAssembler *ia) override; void setViewport(const Viewport &vp) override; void setScissor(const Rect &rect) override; @@ -56,16 +56,16 @@ public: void setDepthBias(float constant, float clamp, float slope) override; void setBlendConstants(const Color &constants) override; void setDepthBound(float minBounds, float maxBounds) override; - void setStencilWriteMask(StencilFace face, uint mask) override; - void setStencilCompareMask(StencilFace face, uint ref, uint mask) override; + void setStencilWriteMask(StencilFace face, uint32_t mask) override; + void setStencilCompareMask(StencilFace face, uint32_t ref, uint32_t mask) override; void nextSubpass() override; void draw(const DrawInfo &info) override; - void updateBuffer(Buffer *buff, const void *data, uint size) override; - void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) override; - void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint count, Filter filter) override; + void updateBuffer(Buffer *buff, const void *data, uint32_t size) override; + void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override; + void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override; void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override; void dispatch(const DispatchInfo &info) override; - void pipelineBarrier(const GlobalBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint textureBarrierCount) override; + void pipelineBarrier(const GlobalBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) override; //TODO_Zeqiang: wgpu query pool void beginQuery(QueryPool *queryPool, uint32_t id) override{}; @@ -77,12 +77,12 @@ public: void updateIndirectBuffer(Buffer *buffer, const DrawInfoList &list); - void updateBuffer(Buffer *buff, const emscripten::val &v, uint size) { + void updateBuffer(Buffer *buff, const emscripten::val &v, uint32_t size) { ccstd::vector buffer = emscripten::convertJSArrayToNumberVector(v); updateBuffer(buff, reinterpret_cast(buffer.data()), size); } - void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const ColorList &colors, float depth, uint stencil) { + void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const ColorList &colors, float depth, uint32_t stencil) { this->CommandBuffer::beginRenderPass(renderPass, fbo, renderArea, colors.data(), depth, stencil); } diff --git a/native/cocos/renderer/gfx-wgpu/WGPUDef.h b/native/cocos/renderer/gfx-wgpu/WGPUDef.h index 917d84ca3e..775756a8b7 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUDef.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUDef.h @@ -52,8 +52,8 @@ public: info.flags = flags; } - inline void setLevelCount(uint levelCount) { info.levelCount = levelCount; } - inline void setLayerCount(uint layerCount) { info.layerCount = layerCount; } + inline void setLevelCount(uint32_t levelCount) { info.levelCount = levelCount; } + inline void setLayerCount(uint32_t layerCount) { info.layerCount = layerCount; } inline void setSamples(SampleCount sample) { info.samples = sample; } inline void setDepth(uint32_t depth) { info.depth = depth; } inline void setImageBuffer(intptr_t imgBuff) { info.externalRes = reinterpret_cast(imgBuff); } @@ -71,10 +71,10 @@ public: inline void setTexture(Texture *tex) { info.texture = tex; } inline void setType(TextureType type) { info.type = type; } inline void setFormat(Format format) { info.format = format; } - inline void setBaseLevel(uint baseLevel) { info.baseLevel = baseLevel; } - inline void setLevelCount(uint levelCount) { info.levelCount = levelCount; } - inline void setBaseLayer(uint baseLayer) { info.baseLayer = baseLayer; } - inline void setLayerCount(uint layerCount) { info.layerCount = layerCount; } + inline void setBaseLevel(uint32_t baseLevel) { info.baseLevel = baseLevel; } + inline void setLevelCount(uint32_t levelCount) { info.levelCount = levelCount; } + inline void setBaseLayer(uint32_t baseLayer) { info.baseLayer = baseLayer; } + inline void setLayerCount(uint32_t layerCount) { info.layerCount = layerCount; } explicit operator const TextureViewInfo() const { return info; } diff --git a/native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp b/native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp index 005d09213c..2c35ef6355 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp +++ b/native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp @@ -162,9 +162,9 @@ CommandBuffer *CCWGPUDevice::createCommandBuffer(const CommandBufferInfo &info, return ccnew CCWGPUCommandBuffer; } -void CCWGPUDevice::copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint count) { +void CCWGPUDevice::copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) { Format dstFormat = dst->getFormat(); - uint32_t pxSize = GFX_FORMAT_INFOS[static_cast(dstFormat)].size; + uint32_t pxSize = GFX_FORMAT_INFOS[static_cast(dstFormat)].size; auto *texture = static_cast(dst); for (size_t i = 0; i < count; i++) { @@ -232,7 +232,7 @@ void onQueueDone(WGPUQueueWorkDoneStatus status, void *userdata) { emscripten::val CCWGPUDevice::copyTextureToBuffers(Texture *src, const BufferTextureCopyList ®ions) { auto *texture = static_cast(src); Format dstFormat = src->getFormat(); - uint32_t pxSize = GFX_FORMAT_INFOS[static_cast(dstFormat)].size; + uint32_t pxSize = GFX_FORMAT_INFOS[static_cast(dstFormat)].size; auto wgpuCommandEncoder = wgpuDeviceCreateCommandEncoder(CCWGPUDevice::getInstance()->gpuDeviceObject()->wgpuDevice, nullptr); uint64_t size = std::accumulate(regions.begin(), regions.end(), 0, [pxSize](uint64_t initVal, const BufferTextureCopy &in) { @@ -305,7 +305,7 @@ emscripten::val CCWGPUDevice::copyTextureToBuffers(Texture *src, const BufferTex return *bufferMapData->retBuffer; } -void CCWGPUDevice::copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint count) { +void CCWGPUDevice::copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) { } void CCWGPUDevice::acquire(Swapchain *const *swapchains, uint32_t count) { diff --git a/native/cocos/renderer/gfx-wgpu/WGPUDevice.h b/native/cocos/renderer/gfx-wgpu/WGPUDevice.h index 7f9c17dd49..a0972fb007 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUDevice.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUDevice.h @@ -153,8 +153,8 @@ protected: QueryPool *createQueryPool() override; Sampler *createSampler(const SamplerInfo &info) 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; + 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; void getQueryPoolResults(QueryPool *queryPool) override; CCWGPUDeviceObject *_gpuDeviceObj = nullptr; diff --git a/native/cocos/renderer/gfx-wgpu/WGPUExports.h b/native/cocos/renderer/gfx-wgpu/WGPUExports.h index 0df44f4eec..b02a3dea3d 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUExports.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUExports.h @@ -972,7 +972,7 @@ EMSCRIPTEN_BINDINGS(WEBGPU_DEVICE_WASM_EXPORT) { .function("resize", &Buffer::resize) .function("destroy", &Buffer::destroy); class_>("CCWGPUBuffer") - .function("update", select_overload(&CCWGPUBuffer::update), allow_raw_pointer>()) + .function("update", select_overload(&CCWGPUBuffer::update), allow_raw_pointer>()) .function("updateDrawInfo", select_overload(&CCWGPUBuffer::update), allow_raw_pointer>()) .constructor<>(); @@ -986,9 +986,9 @@ EMSCRIPTEN_BINDINGS(WEBGPU_DEVICE_WASM_EXPORT) { .function("initialize", &DescriptorSet::initialize) .function("destroy", &DescriptorSet::destroy) .function("update", &DescriptorSet::update) - .function("bindBuffer", select_overload(&DescriptorSet::bindBuffer), allow_raw_pointer>()) - .function("bindTexture", select_overload(&DescriptorSet::bindTexture), allow_raw_pointer>()) - .function("bindSampler", select_overload(&DescriptorSet::bindSampler), allow_raw_pointer>()); + .function("bindBuffer", select_overload(&DescriptorSet::bindBuffer), allow_raw_pointer>()) + .function("bindTexture", select_overload(&DescriptorSet::bindTexture), allow_raw_pointer>()) + .function("bindSampler", select_overload(&DescriptorSet::bindSampler), allow_raw_pointer>()); class_>("CCWGPUDescriptorSet") .constructor<>(); @@ -1014,11 +1014,11 @@ EMSCRIPTEN_BINDINGS(WEBGPU_DEVICE_WASM_EXPORT) { class_("CommandBuffer") .function("initialize", &CommandBuffer::initialize) .function("destroy", &CommandBuffer::destroy) - .function("begin", select_overload(&CommandBuffer::begin), allow_raw_pointers()) + .function("begin", select_overload(&CommandBuffer::begin), allow_raw_pointers()) .function("end", &CommandBuffer::end) .function("endRenderPass", &CommandBuffer::endRenderPass) .function("bindPipelineState", &CommandBuffer::bindPipelineState, allow_raw_pointer>()) - .function("bindDescriptorSet", select_overload &)>(&CommandBuffer::bindDescriptorSet), allow_raw_pointers()) + .function("bindDescriptorSet", select_overload &)>(&CommandBuffer::bindDescriptorSet), allow_raw_pointers()) .function("bindInputAssembler", &CommandBuffer::bindInputAssembler, allow_raw_pointer>()) .function("setViewport", &CommandBuffer::setViewport) .function("setScissor", &CommandBuffer::setScissor) @@ -1029,23 +1029,23 @@ EMSCRIPTEN_BINDINGS(WEBGPU_DEVICE_WASM_EXPORT) { .function("setStencilCompareMask", &CommandBuffer::setStencilCompareMask) .function("nextSubpass", &CommandBuffer::nextSubpass) .function("draw", select_overload(&CommandBuffer::draw)) - .function("copyBuffersToTexture", select_overload(&CommandBuffer::copyBuffersToTexture), allow_raw_pointers()) - .function("blitTexture", select_overload(&CommandBuffer::blitTexture), allow_raw_pointers()) + .function("copyBuffersToTexture", select_overload(&CommandBuffer::copyBuffersToTexture), allow_raw_pointers()) + .function("blitTexture", select_overload(&CommandBuffer::blitTexture), allow_raw_pointers()) .function("execute", select_overload(&CommandBuffer::execute), allow_raw_pointer>()) .function("dispatch", &CommandBuffer::dispatch) .function("begin4", select_overload(&CommandBuffer::begin)) .function("begin3", select_overload(&CommandBuffer::begin), allow_raw_pointers()) - .function("begin2", select_overload(&CommandBuffer::begin), allow_raw_pointers()) + .function("begin2", select_overload(&CommandBuffer::begin), allow_raw_pointers()) .function("execute", select_overload(&CommandBuffer::execute)) - .function("bindDescriptorSet2", select_overload(&CommandBuffer::bindDescriptorSet), allow_raw_pointer>()) + .function("bindDescriptorSet2", select_overload(&CommandBuffer::bindDescriptorSet), allow_raw_pointer>()) .function("drawIA", select_overload(&CommandBuffer::draw), allow_raw_pointer>()) .function("blitTexture2", select_overload(&CommandBuffer::blitTexture), allow_raw_pointers()) .function("getQueue", &CommandBuffer::getQueue, allow_raw_pointer>()); class_>("CCWGPUCommandBuffer") .constructor<>() - .function("beginRenderPass", select_overload(&CCWGPUCommandBuffer::beginRenderPass), allow_raw_pointers()) + .function("beginRenderPass", select_overload(&CCWGPUCommandBuffer::beginRenderPass), allow_raw_pointers()) .function("updateIndirectBuffer", select_overload(&CCWGPUCommandBuffer::updateIndirectBuffer), allow_raw_pointers()) - .function("updateBuffer", select_overload(&CCWGPUCommandBuffer::updateBuffer), allow_raw_pointers()); + .function("updateBuffer", select_overload(&CCWGPUCommandBuffer::updateBuffer), allow_raw_pointers()); class_("Queue") .function("initialize", &Queue::initialize) diff --git a/native/cocos/renderer/gfx-wgpu/WGPUObject.h b/native/cocos/renderer/gfx-wgpu/WGPUObject.h index 87a491770b..deeab6dbe3 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUObject.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUObject.h @@ -198,9 +198,9 @@ struct CCWGPUDescriptorSetObject { }; struct CCWGPUStencilMasks { - uint writeMask = 0; - uint compareRef = 0; - uint compareMask = 0; + uint32_t writeMask = 0; + uint32_t compareRef = 0; + uint32_t compareMask = 0; }; struct CCWGPUStateCache { diff --git a/native/cocos/renderer/gfx-wgpu/WGPUPipelineState.cpp b/native/cocos/renderer/gfx-wgpu/WGPUPipelineState.cpp index 1bf6c6a8eb..a58319797d 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUPipelineState.cpp +++ b/native/cocos/renderer/gfx-wgpu/WGPUPipelineState.cpp @@ -68,7 +68,7 @@ void CCWGPUPipelineState::prepare(const ccstd::set &setInUse) { }); auto longestAttr = std::max_element(_inputState.attributes.begin(), _inputState.attributes.end(), [&](const Attribute &lhs, const Attribute &rhs) { - return GFX_FORMAT_INFOS[static_cast(lhs.format)].size < GFX_FORMAT_INFOS[static_cast(rhs.format)].size; + return GFX_FORMAT_INFOS[static_cast(lhs.format)].size < GFX_FORMAT_INFOS[static_cast(rhs.format)].size; }); uint8_t mostToleranceStream = (*longestAttr).stream; @@ -98,7 +98,7 @@ void CCWGPUPipelineState::prepare(const ccstd::set &setInUse) { .shaderLocation = attrs[i].location, }; wgpuAttrsVec[(*iter).stream].push_back(attr); - offset[(*iter).stream] += GFX_FORMAT_INFOS[static_cast(format)].size; + offset[(*iter).stream] += GFX_FORMAT_INFOS[static_cast(format)].size; } else { // all none-input attr are put in 1st buffer layout with offset = 0; Format format = attrs[i].format; @@ -108,12 +108,12 @@ void CCWGPUPipelineState::prepare(const ccstd::set &setInUse) { .shaderLocation = attrs[i].location, }; - if (GFX_FORMAT_INFOS[static_cast(format)].size > GFX_FORMAT_INFOS[static_cast((*longestAttr).format)].size) { - printf("found attr %s %s in shader exceed size of longest attr %s %s\n", attrName.c_str(), GFX_FORMAT_INFOS[static_cast(format)].name.c_str(), - (*longestAttr).name.c_str(), GFX_FORMAT_INFOS[static_cast((*longestAttr).format)].name.c_str()); + if (GFX_FORMAT_INFOS[static_cast(format)].size > GFX_FORMAT_INFOS[static_cast((*longestAttr).format)].size) { + printf("found attr %s %s in shader exceed size of longest attr %s %s\n", attrName.c_str(), GFX_FORMAT_INFOS[static_cast(format)].name.c_str(), + (*longestAttr).name.c_str(), GFX_FORMAT_INFOS[static_cast((*longestAttr).format)].name.c_str()); _gpuPipelineStateObj->redundantAttr.push_back(attr); - if (GFX_FORMAT_INFOS[static_cast(format)].size > _gpuPipelineStateObj->maxAttrLength) { - _gpuPipelineStateObj->maxAttrLength = GFX_FORMAT_INFOS[static_cast(format)].size; + if (GFX_FORMAT_INFOS[static_cast(format)].size > _gpuPipelineStateObj->maxAttrLength) { + _gpuPipelineStateObj->maxAttrLength = GFX_FORMAT_INFOS[static_cast(format)].size; } } else { wgpuAttrsVec[mostToleranceStream].push_back(attr); @@ -130,7 +130,7 @@ void CCWGPUPipelineState::prepare(const ccstd::set &setInUse) { }); if (iter == attrs.end()) { Format format = attribute.format; - offset[attribute.stream] += GFX_FORMAT_INFOS[static_cast(format)].size; + offset[attribute.stream] += GFX_FORMAT_INFOS[static_cast(format)].size; } } diff --git a/native/cocos/renderer/gfx-wgpu/WGPUQueue.cpp b/native/cocos/renderer/gfx-wgpu/WGPUQueue.cpp index a25fbdb53a..1d5837a0c6 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUQueue.cpp +++ b/native/cocos/renderer/gfx-wgpu/WGPUQueue.cpp @@ -53,7 +53,7 @@ void CCWGPUQueue::doDestroy() { } } -void CCWGPUQueue::submit(CommandBuffer *const *cmdBuffs, uint count) { +void CCWGPUQueue::submit(CommandBuffer *const *cmdBuffs, uint32_t count) { // ccstd::vector commandBuffs(count); // for (size_t i = 0; i < count; i++) { // auto* commandBuff = static_cast(cmdBuffs[i]); diff --git a/native/cocos/renderer/gfx-wgpu/WGPUQueue.h b/native/cocos/renderer/gfx-wgpu/WGPUQueue.h index 2f12ce0747..163ed709c2 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUQueue.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUQueue.h @@ -39,7 +39,7 @@ public: CCWGPUQueue(); ~CCWGPUQueue() = default; - void submit(CommandBuffer *const *cmdBuffs, uint count) override; + void submit(CommandBuffer *const *cmdBuffs, uint32_t count) override; inline CCWGPUQueueObject *gpuQueueObject() { return _gpuQueueObject; } diff --git a/native/cocos/renderer/pipeline/BatchedBuffer.cpp b/native/cocos/renderer/pipeline/BatchedBuffer.cpp index 994392cd64..4e7c973a24 100644 --- a/native/cocos/renderer/pipeline/BatchedBuffer.cpp +++ b/native/cocos/renderer/pipeline/BatchedBuffer.cpp @@ -34,11 +34,11 @@ namespace cc { namespace pipeline { -ccstd::unordered_map> BatchedBuffer::buffers; +ccstd::unordered_map> BatchedBuffer::buffers; BatchedBuffer *BatchedBuffer::get(scene::Pass *pass) { return BatchedBuffer::get(pass, 0); } -BatchedBuffer *BatchedBuffer::get(scene::Pass *pass, uint extraKey) { +BatchedBuffer *BatchedBuffer::get(scene::Pass *pass, uint32_t extraKey) { auto &record = BatchedBuffer::buffers[pass]; auto &buffer = record[extraKey]; if (buffer == nullptr) buffer = ccnew BatchedBuffer(pass); @@ -47,7 +47,7 @@ BatchedBuffer *BatchedBuffer::get(scene::Pass *pass, uint extraKey) { void BatchedBuffer::destroyBatchedBuffer() { for (auto &pair : BatchedBuffer::buffers) { - const ccstd::unordered_map &bufferItem = pair.second; + const ccstd::unordered_map &bufferItem = pair.second; for (const auto &item : bufferItem) { BatchedBuffer *batchedBuffer = item.second; if (batchedBuffer) { @@ -84,7 +84,7 @@ void BatchedBuffer::destroy() { _batches.clear(); } -void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const scene::Model *model) { +void BatchedBuffer::merge(const scene::SubModel *subModel, uint32_t passIdx, const scene::Model *model) { const auto *subMesh = subModel->getSubMesh(); const auto &flatBuffers = subMesh->getFlatBuffers(); auto flatBuffersCount = static_cast(flatBuffers.size()); @@ -93,8 +93,8 @@ void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const s } const auto &flatBuffer = flatBuffers[0]; - uint vbSize = 0; - uint indexSize = 0; + uint32_t vbSize = 0; + uint32_t indexSize = 0; const auto vbCount = flatBuffer.count; const auto *const pass = subModel->getPass(passIdx); auto *const shader = subModel->getShader(passIdx); @@ -104,7 +104,7 @@ void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const s for (auto &batch : _batches) { if (batch.vbs.size() == flatBuffersCount && batch.mergeCount < UBOLocalBatched::BATCHING_COUNT) { isBatchExist = true; - for (uint j = 0; j < flatBuffersCount; ++j) { + for (uint32_t j = 0; j < flatBuffersCount; ++j) { auto *const vb = batch.vbs[j]; if (vb->getStride() != flatBuffers[j].stride) { isBatchExist = false; @@ -113,11 +113,11 @@ void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const s } if (isBatchExist) { - for (uint j = 0; j < flatBuffersCount; ++j) { + for (uint32_t j = 0; j < flatBuffersCount; ++j) { const auto &flatBuffer = flatBuffers[j]; auto *batchVB = batch.vbs[j]; auto *vbData = batch.vbDatas[j]; - const uint vbBufSizeOld = batchVB->getSize(); + const uint32_t vbBufSizeOld = batchVB->getSize(); vbSize = (vbCount + batch.vbCount) * flatBuffer.stride; if (vbSize > vbBufSizeOld) { auto *vbDataNew = static_cast(CC_MALLOC(vbSize)); @@ -179,7 +179,7 @@ void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const s ccstd::vector vbDatas(flatBuffersCount, nullptr); ccstd::vector totalVBs(flatBuffersCount + 1, nullptr); - for (uint i = 0; i < flatBuffersCount; ++i) { + for (uint32_t i = 0; i < flatBuffersCount; ++i) { const auto &flatBuffer = flatBuffers[i]; auto *newVB = _device->createBuffer({ gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST, @@ -200,12 +200,12 @@ void BatchedBuffer::merge(const scene::SubModel *subModel, uint passIdx, const s auto *indexBuffer = _device->createBuffer({ gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST, gfx::MemoryUsageBit::HOST | gfx::MemoryUsageBit::DEVICE, - static_cast(indexBufferSize), + static_cast(indexBufferSize), sizeof(float), }); auto *indexData = static_cast(CC_MALLOC(indexBufferSize)); memset(indexData, 0, indexBufferSize); - indexBuffer->update(indexData, static_cast(indexBufferSize)); + indexBuffer->update(indexData, static_cast(indexBufferSize)); totalVBs[flatBuffersCount] = indexBuffer; ccstd::vector attributes = subModel->getInputAssembler()->getAttributes(); @@ -257,7 +257,7 @@ void BatchedBuffer::clear() { } } -void BatchedBuffer::setDynamicOffset(uint idx, uint value) { +void BatchedBuffer::setDynamicOffset(uint32_t idx, uint32_t value) { _dynamicOffsets[idx] = value; } diff --git a/native/cocos/renderer/pipeline/BatchedBuffer.h b/native/cocos/renderer/pipeline/BatchedBuffer.h index 6ff38df8a8..04287b0a81 100644 --- a/native/cocos/renderer/pipeline/BatchedBuffer.h +++ b/native/cocos/renderer/pipeline/BatchedBuffer.h @@ -43,8 +43,8 @@ struct CC_DLL BatchedItem { ccstd::vector vbDatas; gfx::Buffer *indexBuffer = nullptr; float *indexData = nullptr; - uint vbCount = 0; - uint mergeCount = 0; + uint32_t vbCount = 0; + uint32_t mergeCount = 0; gfx::InputAssembler *ia = nullptr; gfx::Buffer *ubo = nullptr; ccstd::array uboData; @@ -53,28 +53,28 @@ struct CC_DLL BatchedItem { gfx::Shader *shader = nullptr; }; using BatchedItemList = ccstd::vector; -using DynamicOffsetList = ccstd::vector; +using DynamicOffsetList = ccstd::vector; class CC_DLL BatchedBuffer : public RefCounted { public: static BatchedBuffer *get(scene::Pass *pass); - static BatchedBuffer *get(scene::Pass *pass, uint extraKey); + static BatchedBuffer *get(scene::Pass *pass, uint32_t extraKey); static void destroyBatchedBuffer(); explicit BatchedBuffer(const scene::Pass *pass); ~BatchedBuffer() override; void destroy(); - void merge(const scene::SubModel *, uint passIdx, const scene::Model *); + void merge(const scene::SubModel *, uint32_t passIdx, const scene::Model *); void clear(); - void setDynamicOffset(uint idx, uint value); + void setDynamicOffset(uint32_t idx, uint32_t value); inline const BatchedItemList &getBatches() const { return _batches; } inline const scene::Pass *getPass() const { return _pass; } inline const DynamicOffsetList &getDynamicOffset() const { return _dynamicOffsets; } private: - static ccstd::unordered_map> buffers; + static ccstd::unordered_map> buffers; DynamicOffsetList _dynamicOffsets; BatchedItemList _batches; const scene::Pass *_pass = nullptr; diff --git a/native/cocos/renderer/pipeline/ClusterLightCulling.cpp b/native/cocos/renderer/pipeline/ClusterLightCulling.cpp index 012be5e137..f8e1818745 100644 --- a/native/cocos/renderer/pipeline/ClusterLightCulling.cpp +++ b/native/cocos/renderer/pipeline/ClusterLightCulling.cpp @@ -74,7 +74,7 @@ void ClusterLightCulling::initialize(gfx::Device *dev) { _device = dev; if (!_device->hasFeature(gfx::Feature::COMPUTE_SHADER)) return; - uint maxInvocations = _device->getCapabilities().maxComputeWorkGroupInvocations; + uint32_t maxInvocations = _device->getCapabilities().maxComputeWorkGroupInvocations; if (CLUSTERS_X_THREADS * CLUSTERS_Y_THREADS * 4 <= maxInvocations) { clusterZThreads = 4; } else if (CLUSTERS_X_THREADS * CLUSTERS_Y_THREADS * 2 <= maxInvocations) { @@ -129,10 +129,10 @@ void ClusterLightCulling::update() { _constantsBuffer->update(_constants.data(), 2 * sizeof(Vec4) + 2 * sizeof(Mat4)); updateLights(); - uint cameraIndex = _pipeline->getPipelineUBO()->getCurrentCameraUBOOffset(); + uint32_t cameraIndex = _pipeline->getPipelineUBO()->getCurrentCameraUBOOffset(); if (cameraIndex >= _oldCamProjMats.size()) { _rebuildClusters = true; - uint nextLength = std::max(nextPow2(static_cast(cameraIndex)), uint(1)); + uint32_t nextLength = std::max(nextPow2(static_cast(cameraIndex)), uint32_t(1)); _oldCamProjMats.resize(nextLength, Mat4::ZERO); _oldCamProjMats[cameraIndex] = _camera->getMatProj(); } else { @@ -172,7 +172,7 @@ void ClusterLightCulling::updateLights() { if (validLightCount > _lightBufferCount) { _lightBufferResized = true; - _lightBufferCount = nextPow2(static_cast(validLightCount)); + _lightBufferCount = nextPow2(static_cast(validLightCount)); _lightBufferData.resize(16 * _lightBufferCount); } @@ -265,7 +265,7 @@ void ClusterLightCulling::initBuildingSatge() { layout(local_size_x=16, local_size_y=8, local_size_z=%d) in; void main() { - uint clusterIndex = gl_GlobalInvocationID.z * uvec3(16, 8, %d).x * uvec3(16, 8, %d).y + + uint32_t clusterIndex = gl_GlobalInvocationID.z * uvec3(16, 8, %d).x * uvec3(16, 8, %d).y + gl_GlobalInvocationID.y * uvec3(16, 8, %d).x + gl_GlobalInvocationID.x; float clusterSizeX = ceil(cc_viewPort.z / float(CLUSTERS_X)); float clusterSizeY = ceil(cc_viewPort.w / float(CLUSTERS_Y)); @@ -311,7 +311,7 @@ void ClusterLightCulling::initBuildingSatge() { layout(local_size_x=16, local_size_y=8, local_size_z=%d) in; void main() { - uint clusterIndex = gl_GlobalInvocationID.z * uvec3(16, 8, %d).x * uvec3(16, 8, %d).y + + uint32_t clusterIndex = gl_GlobalInvocationID.z * uvec3(16, 8, %d).x * uvec3(16, 8, %d).y + gl_GlobalInvocationID.y * uvec3(16, 8, %d).x + gl_GlobalInvocationID.x; float clusterSizeX = ceil(cc_viewPort.z / float(CLUSTERS_X)); float clusterSizeY = ceil(cc_viewPort.w / float(CLUSTERS_Y)); @@ -364,7 +364,7 @@ void ClusterLightCulling::initResetStage() { ShaderStrings sources; sources.glsl4 = StringUtil::format( R"( - layout(std430, binding = 0) buffer b_globalIndexBuffer { uint b_globalIndex[]; }; + layout(std430, binding = 0) buffer b_globalIndexBuffer { uint32_t b_globalIndex[]; }; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { @@ -375,7 +375,7 @@ void ClusterLightCulling::initResetStage() { )"); sources.glsl3 = StringUtil::format( R"( - layout(std430, binding = 0) buffer b_globalIndexBuffer { uint b_globalIndex[]; }; + layout(std430, binding = 0) buffer b_globalIndexBuffer { uint32_t b_globalIndex[]; }; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { @@ -419,21 +419,21 @@ void ClusterLightCulling::initCullingStage() { mat4 cc_matProjInv; }; layout(set=0, binding=1, std430) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; }; - layout(set=0, binding=2, std430) buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; }; + layout(set=0, binding=2, std430) buffer b_clusterLightIndicesBuffer { uint32_t b_clusterLightIndices[]; }; layout(set=0, binding=3, std430) buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; }; layout(set=0, binding=4, std430) buffer b_clustersBuffer { vec4 b_clusters[]; }; - layout(set=0, binding=5, std430) buffer b_globalIndexBuffer { uint b_globalIndex[]; }; + layout(set=0, binding=5, std430) buffer b_globalIndexBuffer { uint32_t b_globalIndex[]; }; struct CCLight { vec4 cc_lightPos; vec4 cc_lightColor; vec4 cc_lightSizeRangeAngle; vec4 cc_lightDir; }; - uint ccLightCount() + uint32_t ccLightCount() { - return uint(b_ccLights[3].w); + return uint32_t(b_ccLights[3].w); } - CCLight getCCLight(uint i) + CCLight getCCLight(uint32_t i) { CCLight light; light.cc_lightPos = b_ccLights[4u * i + 0u]; @@ -447,10 +447,10 @@ void ClusterLightCulling::initCullingStage() { vec3 maxBounds; }; struct LightGrid { - uint offset; - uint ccLights; + uint32_t offset; + uint32_t ccLights; }; - Cluster getCluster(uint index) + Cluster getCluster(uint32_t index) { Cluster cluster; cluster.minBounds = b_clusters[2u * index + 0u].xyz; @@ -485,23 +485,23 @@ void ClusterLightCulling::initCullingStage() { layout(local_size_x = 16, local_size_y = 8, local_size_z = %d) in; void main() { - uint visibleLights[100]; - uint visibleCount = 0u; - uint clusterIndex = gl_GlobalInvocationID.z * uvec3(16, 8, %d).x * uvec3(16, 8, %d).y + + uint32_t visibleLights[100]; + uint32_t visibleCount = 0u; + uint32_t clusterIndex = gl_GlobalInvocationID.z * uvec3(16, 8, %d).x * uvec3(16, 8, %d).y + gl_GlobalInvocationID.y * uvec3(16, 8, %d).x + gl_GlobalInvocationID.x; Cluster cluster = getCluster(clusterIndex); - uint lightCount = ccLightCount(); - uint lightOffset = 0u; + uint32_t lightCount = ccLightCount(); + uint32_t lightOffset = 0u; while (lightOffset < lightCount) { - uint batchSize = min((16u * 8u * %du), lightCount - lightOffset); - if (uint(gl_LocalInvocationIndex) < batchSize) { - uint lightIndex = lightOffset + gl_LocalInvocationIndex; + uint32_t batchSize = min((16u * 8u * %du), lightCount - lightOffset); + if (uint32_t(gl_LocalInvocationIndex) < batchSize) { + uint32_t lightIndex = lightOffset + gl_LocalInvocationIndex; CCLight light = getCCLight(lightIndex); light.cc_lightPos.xyz = ((cc_matView) * (vec4(light.cc_lightPos.xyz, 1.0))).xyz; lights[gl_LocalInvocationIndex] = light; } barrier(); - for (uint i = 0u; i < batchSize; i++) { + for (uint32_t i = 0u; i < batchSize; i++) { if (visibleCount < 100u && ccLightIntersectsCluster(lights[i], cluster)) { visibleLights[visibleCount] = lightOffset + i; visibleCount++; @@ -510,9 +510,9 @@ void ClusterLightCulling::initCullingStage() { lightOffset += batchSize; } barrier(); - uint offset = 0u; + uint32_t offset = 0u; offset = atomicAdd(b_globalIndex[0], visibleCount); - for (uint i = 0u; i < visibleCount; i++) { + for (uint32_t i = 0u; i < visibleCount; i++) { b_clusterLightIndices[offset + i] = visibleLights[i]; } b_clusterLightGrid[clusterIndex] = uvec4(offset, visibleCount, 0, 0); @@ -527,21 +527,21 @@ void ClusterLightCulling::initCullingStage() { mat4 cc_matProjInv; }; layout(std430, binding=1) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; }; - layout(std430, binding=2) buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; }; + layout(std430, binding=2) buffer b_clusterLightIndicesBuffer { uint32_t b_clusterLightIndices[]; }; layout(std430, binding=3) buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; }; layout(std430, binding=4) buffer b_clustersBuffer { vec4 b_clusters[]; }; - layout(std430, binding=5) buffer b_globalIndexBuffer { uint b_globalIndex[]; }; + layout(std430, binding=5) buffer b_globalIndexBuffer { uint32_t b_globalIndex[]; }; struct CCLight { vec4 cc_lightPos; vec4 cc_lightColor; vec4 cc_lightSizeRangeAngle; vec4 cc_lightDir; }; - uint ccLightCount() + uint32_t ccLightCount() { - return uint(b_ccLights[3].w); + return uint32_t(b_ccLights[3].w); } - CCLight getCCLight(uint i) + CCLight getCCLight(uint32_t i) { CCLight light; light.cc_lightPos = b_ccLights[4u * i + 0u]; @@ -555,10 +555,10 @@ void ClusterLightCulling::initCullingStage() { vec3 maxBounds; }; struct LightGrid { - uint offset; - uint ccLights; + uint32_t offset; + uint32_t ccLights; }; - Cluster getCluster(uint index) + Cluster getCluster(uint32_t index) { Cluster cluster; cluster.minBounds = b_clusters[2u * index + 0u].xyz; @@ -593,23 +593,23 @@ void ClusterLightCulling::initCullingStage() { layout(local_size_x = 16, local_size_y = 8, local_size_z = %d) in; void main() { - uint visibleLights[100]; - uint visibleCount = 0u; - uint clusterIndex = gl_GlobalInvocationID.z * uvec3(16, 8, %d).x * uvec3(16, 8, %d).y + + uint32_t visibleLights[100]; + uint32_t visibleCount = 0u; + uint32_t clusterIndex = gl_GlobalInvocationID.z * uvec3(16, 8, %d).x * uvec3(16, 8, %d).y + gl_GlobalInvocationID.y * uvec3(16, 8, %d).x + gl_GlobalInvocationID.x; Cluster cluster = getCluster(clusterIndex); - uint lightCount = ccLightCount(); - uint lightOffset = 0u; + uint32_t lightCount = ccLightCount(); + uint32_t lightOffset = 0u; while (lightOffset < lightCount) { - uint batchSize = min((16u * 8u * %du), lightCount - lightOffset); - if (uint(gl_LocalInvocationIndex) < batchSize) { - uint lightIndex = lightOffset + gl_LocalInvocationIndex; + uint32_t batchSize = min((16u * 8u * %du), lightCount - lightOffset); + if (uint32_t(gl_LocalInvocationIndex) < batchSize) { + uint32_t lightIndex = lightOffset + gl_LocalInvocationIndex; CCLight light = getCCLight(lightIndex); light.cc_lightPos.xyz = ((cc_matView) * (vec4(light.cc_lightPos.xyz, 1.0))).xyz; lights[gl_LocalInvocationIndex] = light; } barrier(); - for (uint i = 0u; i < batchSize; i++) { + for (uint32_t i = 0u; i < batchSize; i++) { if (visibleCount < 100u && ccLightIntersectsCluster(lights[i], cluster)) { visibleLights[visibleCount] = lightOffset + i; visibleCount++; @@ -618,9 +618,9 @@ void ClusterLightCulling::initCullingStage() { lightOffset += batchSize; } barrier(); - uint offset = 0u; + uint32_t offset = 0u; offset = atomicAdd(b_globalIndex[0], visibleCount); - for (uint i = 0u; i < visibleCount; i++) { + for (uint32_t i = 0u; i < visibleCount; i++) { b_clusterLightIndices[offset + i] = visibleLights[i]; } b_clusterLightGrid[clusterIndex] = uvec4(offset, visibleCount, 0, 0); @@ -677,7 +677,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera *camera) { data.clusterBuffer = framegraph::BufferHandle(builder.readFromBlackboard(fgStrHandleClusterBuffer)); if (!data.clusterBuffer.isValid()) { // each cluster has 2 vec4, min + max position for AABB - uint clusterBufferSize = 2 * sizeof(Vec4) * CLUSTER_COUNT; + uint32_t clusterBufferSize = 2 * sizeof(Vec4) * CLUSTER_COUNT; framegraph::Buffer::Descriptor bufferInfo; bufferInfo.usage = gfx::BufferUsageBit::STORAGE; @@ -696,7 +696,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera *camera) { data.globalIndexBuffer = framegraph::BufferHandle(builder.readFromBlackboard(fgStrHandleClusterGlobalIndexBuffer)); if (!data.globalIndexBuffer.isValid()) { - uint atomicIndexBufferSize = sizeof(uint); + uint32_t atomicIndexBufferSize = sizeof(uint32_t); framegraph::Buffer::Descriptor bufferInfo; bufferInfo.usage = gfx::BufferUsageBit::STORAGE; @@ -760,7 +760,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera *camera) { data.lightIndexBuffer = framegraph::BufferHandle(builder.readFromBlackboard(fgStrHandleClusterLightIndexBuffer)); if (!data.lightIndexBuffer.isValid()) { // light indices belonging to clusters - uint lightIndicesBufferSize = MAX_LIGHTS_PER_CLUSTER * CLUSTER_COUNT * sizeof(int); + uint32_t lightIndicesBufferSize = MAX_LIGHTS_PER_CLUSTER * CLUSTER_COUNT * sizeof(int); framegraph::Buffer::Descriptor bufferInfo; bufferInfo.usage = gfx::BufferUsageBit::STORAGE; @@ -777,7 +777,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera *camera) { data.lightGridBuffer = framegraph::BufferHandle(builder.readFromBlackboard(fgStrHandleClusterLightGridBuffer)); if (!data.lightGridBuffer.isValid()) { // for each cluster: (start index in b_clusterLightIndices, number of point lights, empty, empty) - uint lightGridBufferSize = CLUSTER_COUNT * 4 * sizeof(uint); + uint32_t lightGridBufferSize = CLUSTER_COUNT * 4 * sizeof(uint32_t); framegraph::Buffer::Descriptor bufferInfo; bufferInfo.usage = gfx::BufferUsageBit::STORAGE; @@ -804,7 +804,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera *camera) { auto lightCullingExec = [&](DataLightCulling const &data, const framegraph::DevicePassResourceTable &table) { auto *cmdBuff = _pipeline->getCommandBuffers()[0]; cmdBuff->updateBuffer(table.getRead(data.lightBuffer), _lightBufferData.data(), - static_cast(_lightBufferData.size() * sizeof(float))); + static_cast(_lightBufferData.size() * sizeof(float))); _cullingDescriptorSet->bindBuffer(0, _constantsBuffer); _cullingDescriptorSet->bindBuffer(1, table.getRead(data.lightBuffer)); @@ -820,7 +820,7 @@ void ClusterLightCulling::clusterLightCulling(scene::Camera *camera) { }; auto *pipeline = static_cast(_pipeline); - uint insertPoint = static_cast(DeferredInsertPoint::DIP_CLUSTER); + auto insertPoint = static_cast(DeferredInsertPoint::DIP_CLUSTER); pipeline->getFrameGraph().addPass(insertPoint++, fgStrHandleClusterBuildPass, clusterBuildSetup, clusterBuildExec); pipeline->getFrameGraph().addPass(insertPoint++, fgStrHandleClusterCullingPass, lightCullingSetup, lightCullingExec); } diff --git a/native/cocos/renderer/pipeline/ClusterLightCulling.h b/native/cocos/renderer/pipeline/ClusterLightCulling.h index accb5ca4d3..b0ac561ec5 100644 --- a/native/cocos/renderer/pipeline/ClusterLightCulling.h +++ b/native/cocos/renderer/pipeline/ClusterLightCulling.h @@ -43,21 +43,21 @@ public: explicit ClusterLightCulling(RenderPipeline *pipeline) : _pipeline(pipeline){}; ~ClusterLightCulling(); - static constexpr uint CLUSTERS_X = 16; - static constexpr uint CLUSTERS_Y = 8; - static constexpr uint CLUSTERS_Z = 24; + static constexpr uint32_t CLUSTERS_X = 16; + static constexpr uint32_t CLUSTERS_Y = 8; + static constexpr uint32_t CLUSTERS_Z = 24; // z threads varies to meet limit number of threads - static constexpr uint CLUSTERS_X_THREADS = 16; - static constexpr uint CLUSTERS_Y_THREADS = 8; + static constexpr uint32_t CLUSTERS_X_THREADS = 16; + static constexpr uint32_t CLUSTERS_Y_THREADS = 8; - uint clusterZThreads = 1; + uint32_t clusterZThreads = 1; - static constexpr uint CLUSTER_COUNT = CLUSTERS_X * CLUSTERS_Y * CLUSTERS_Z; + static constexpr uint32_t CLUSTER_COUNT = CLUSTERS_X * CLUSTERS_Y * CLUSTERS_Z; - static constexpr uint MAX_LIGHTS_PER_CLUSTER = 100; + static constexpr uint32_t MAX_LIGHTS_PER_CLUSTER = 100; - static constexpr uint MAX_LIGHTS_GLOBAL = 1000; + static constexpr uint32_t MAX_LIGHTS_GLOBAL = 1000; void initialize(gfx::Device *dev); @@ -92,7 +92,7 @@ private: void updateLights(); static bool isProjMatChange(const Mat4 &curProj, const Mat4 &oldProj) { - for (uint i = 0; i < sizeof(curProj.m) / sizeof(float); i++) { + for (uint32_t i = 0; i < sizeof(curProj.m) / sizeof(float); i++) { if (math::IsNotEqualF(curProj.m[i], oldProj.m[i])) { return true; } @@ -122,10 +122,10 @@ private: gfx::PipelineState *_cullingPipelineState{nullptr}; gfx::DescriptorSet *_cullingDescriptorSet{nullptr}; - static constexpr uint NEAR_FAR_OFFSET = 0; - static constexpr uint VIEW_PORT_OFFSET = 4; - static constexpr uint MAT_VIEW_OFFSET = 8; - static constexpr uint MAT_PROJ_INV_OFFSET = 24; + static constexpr uint32_t NEAR_FAR_OFFSET = 0; + static constexpr uint32_t VIEW_PORT_OFFSET = 4; + static constexpr uint32_t MAT_VIEW_OFFSET = 8; + static constexpr uint32_t MAT_PROJ_INV_OFFSET = 24; ccstd::array _constants{}; gfx::Buffer *_constantsBuffer{nullptr}; @@ -140,8 +140,8 @@ private: gfx::DispatchInfo _cullingDispatchInfo; bool _lightBufferResized{false}; - uint _lightBufferStride{0}; - uint _lightBufferCount{0}; + uint32_t _lightBufferStride{0}; + uint32_t _lightBufferCount{0}; float _lightMeterScale{10000.0F}; // only rebuild clusters when camera project matrix changed diff --git a/native/cocos/renderer/pipeline/Define.cpp b/native/cocos/renderer/pipeline/Define.cpp index 57f6be96d3..0d67f34bde 100644 --- a/native/cocos/renderer/pipeline/Define.cpp +++ b/native/cocos/renderer/pipeline/Define.cpp @@ -38,9 +38,9 @@ static uint32_t localUBOCount = static_cast(ModelLocalBindings::SAMPLE static uint32_t localSamplerCount = static_cast(ModelLocalBindings::STORAGE_REFLECTION) - localUBOCount; static uint32_t localStorageImageCount = static_cast(ModelLocalBindings::COUNT) - localUBOCount - localSamplerCount; -uint globalSet = static_cast(SetIndex::GLOBAL); -uint materialSet = static_cast(SetIndex::MATERIAL); -uint localSet = static_cast(SetIndex::LOCAL); +uint32_t globalSet = static_cast(SetIndex::GLOBAL); +uint32_t materialSet = static_cast(SetIndex::MATERIAL); +uint32_t localSet = static_cast(SetIndex::LOCAL); gfx::BindingMappingInfo bindingMappingInfo = { {globalUBOCount, 0, localUBOCount}, // Uniform Buffer Counts @@ -93,7 +93,7 @@ const gfx::UniformBlock UBOLocalBatched::LAYOUT = { UBOLocalBatched::BINDING, UBOLocalBatched::NAME, { - {"cc_matWorlds", gfx::Type::MAT4, static_cast(UBOLocalBatched::BATCHING_COUNT)}, + {"cc_matWorlds", gfx::Type::MAT4, static_cast(UBOLocalBatched::BATCHING_COUNT)}, }, 1, }; @@ -222,10 +222,10 @@ const gfx::UniformBlock UBOForwardLight::LAYOUT = { UBOForwardLight::BINDING, UBOForwardLight::NAME, { - {"cc_lightPos", gfx::Type::FLOAT4, static_cast(UBOForwardLight::LIGHTS_PER_PASS)}, - {"cc_lightColor", gfx::Type::FLOAT4, static_cast(UBOForwardLight::LIGHTS_PER_PASS)}, - {"cc_lightSizeRangeAngle", gfx::Type::FLOAT4, static_cast(UBOForwardLight::LIGHTS_PER_PASS)}, - {"cc_lightDir", gfx::Type::FLOAT4, static_cast(UBOForwardLight::LIGHTS_PER_PASS)}, + {"cc_lightPos", gfx::Type::FLOAT4, static_cast(UBOForwardLight::LIGHTS_PER_PASS)}, + {"cc_lightColor", gfx::Type::FLOAT4, static_cast(UBOForwardLight::LIGHTS_PER_PASS)}, + {"cc_lightSizeRangeAngle", gfx::Type::FLOAT4, static_cast(UBOForwardLight::LIGHTS_PER_PASS)}, + {"cc_lightDir", gfx::Type::FLOAT4, static_cast(UBOForwardLight::LIGHTS_PER_PASS)}, }, 1, }; @@ -284,8 +284,8 @@ const gfx::UniformBlock UBOSkinning::LAYOUT = { 1, }; -const uint UBOMorph::COUNT_BASE_4_BYTES = static_cast(4 * std::ceil(UBOMorph::MAX_MORPH_TARGET_COUNT / 4) + 4); -const uint UBOMorph::SIZE = UBOMorph::COUNT_BASE_4_BYTES * 4; +const uint32_t UBOMorph::COUNT_BASE_4_BYTES = static_cast(4 * std::ceil(UBOMorph::MAX_MORPH_TARGET_COUNT / 4) + 4); +const uint32_t UBOMorph::SIZE = UBOMorph::COUNT_BASE_4_BYTES * 4; const ccstd::string UBOMorph::NAME = "CCMorph"; const gfx::DescriptorSetLayoutBinding UBOMorph::DESCRIPTOR = { UBOMorph::BINDING, @@ -299,7 +299,7 @@ const gfx::UniformBlock UBOMorph::LAYOUT = { UBOMorph::BINDING, UBOMorph::NAME, { - {"cc_displacementWeights", gfx::Type::FLOAT4, static_cast(UBOMorph::MAX_MORPH_TARGET_COUNT / 4)}, + {"cc_displacementWeights", gfx::Type::FLOAT4, static_cast(UBOMorph::MAX_MORPH_TARGET_COUNT / 4)}, {"cc_displacementTextureInfo", gfx::Type::FLOAT4, 1}, }, 1, @@ -476,7 +476,7 @@ const gfx::DescriptorSetLayoutBinding SPRITETEXTURE::DESCRIPTOR = { }; const gfx::UniformSamplerTexture SPRITETEXTURE::LAYOUT = { localSet, - static_cast(ModelLocalBindings::SAMPLER_SPRITE), + static_cast(ModelLocalBindings::SAMPLER_SPRITE), "cc_spriteTexture", gfx::Type::SAMPLER2D, 1, @@ -492,7 +492,7 @@ const gfx::DescriptorSetLayoutBinding REFLECTIONTEXTURE::DESCRIPTOR = { }; const gfx::UniformSamplerTexture REFLECTIONTEXTURE::LAYOUT = { localSet, - static_cast(ModelLocalBindings::SAMPLER_REFLECTION), + static_cast(ModelLocalBindings::SAMPLER_REFLECTION), "cc_reflectionTexture", gfx::Type::SAMPLER2D, 1, @@ -508,15 +508,15 @@ const gfx::DescriptorSetLayoutBinding REFLECTIONSTORAGE::DESCRIPTOR = { }; const gfx::UniformStorageImage REFLECTIONSTORAGE::LAYOUT = { localSet, - static_cast(ModelLocalBindings::STORAGE_REFLECTION), + static_cast(ModelLocalBindings::STORAGE_REFLECTION), "cc_reflectionStorage", gfx::Type::IMAGE2D, 1, }; -uint skyboxFlag = static_cast(gfx::ClearFlagBit::STENCIL) << 1; +uint32_t skyboxFlag = static_cast(gfx::ClearFlagBit::STENCIL) << 1; -uint nextPow2(uint val) { +uint32_t nextPow2(uint32_t val) { --val; val |= (val >> 1); val |= (val >> 2); @@ -538,7 +538,7 @@ bool supportsR32FloatTexture(const gfx::Device* device) { static ccstd::unordered_map phases; //cjh how to clear this global variable when exiting game? static uint32_t phaseNum = 0; -uint getPhaseID(const ccstd::string &phaseName) { +uint32_t getPhaseID(const ccstd::string &phaseName) { const auto iter = phases.find(phaseName); if (iter == phases.end()) { phases.emplace(phaseName, 1 << phaseNum); diff --git a/native/cocos/renderer/pipeline/Define.h b/native/cocos/renderer/pipeline/Define.h index 162156b6f1..c983bddeb9 100644 --- a/native/cocos/renderer/pipeline/Define.h +++ b/native/cocos/renderer/pipeline/Define.h @@ -60,15 +60,15 @@ struct CC_DLL RenderObject { using RenderObjectList = ccstd::vector; struct CC_DLL RenderTargetInfo { - uint width = 0; - uint height = 0; + uint32_t width = 0; + uint32_t height = 0; }; struct CC_DLL RenderPass { - uint hash = 0; + uint32_t hash = 0; float depth = 0.0F; - uint shaderID = 0; - uint passIndex = 0; + uint32_t shaderID = 0; + uint32_t passIndex = 0; const scene::SubModel *subModel = nullptr; }; using RenderPassList = ccstd::vector; @@ -79,7 +79,7 @@ using ColorDescList = ccstd::vector; using DepthStencilDesc = gfx::DepthStencilAttachment; struct CC_DLL RenderPassDesc { - uint index = 0; + uint32_t index = 0; ColorDescList colorAttachments; DepthStencilDesc depthStencilAttachment; }; @@ -97,7 +97,7 @@ using RenderTextureDescList = ccstd::vector; struct CC_DLL FrameBufferDesc { ccstd::string name; - uint renderPass = 0; + uint32_t renderPass = 0; ccstd::vector colorTextures; ccstd::string depthStencilTexture; }; @@ -113,7 +113,7 @@ CC_ENUM_CONVERSION_OPERATOR(RenderFlowType) using RenderStageList = ccstd::vector; using RenderFlowList = ccstd::vector; using LightList = ccstd::vector; -using UintList = ccstd::vector; +using UintList = ccstd::vector; enum class CC_DLL RenderPassStage { DEFAULT = 100, @@ -136,7 +136,7 @@ struct CC_DLL InternalBindingInst : public InternalBindingDesc { struct CC_DLL RenderQueueCreateInfo { bool isTransparent = false; - uint phases = 0; + uint32_t phases = 0; std::function sortFunc; }; @@ -160,7 +160,7 @@ struct CC_DLL RenderQueueDesc { }; using RenderQueueDescList = ccstd::vector; -uint getPhaseID(const ccstd::string &phase); +uint32_t getPhaseID(const ccstd::string &phase); inline bool opaqueCompareFn(const RenderPass &a, const RenderPass &b) { if (a.hash != b.hash) { @@ -186,8 +186,8 @@ inline bool transparentCompareFn(const RenderPass &a, const RenderPass &b) { return a.shaderID < b.shaderID; } -inline uint convertPhase(const ccstd::vector &stages) { - uint phase = 0; +inline uint32_t convertPhase(const ccstd::vector &stages) { + uint32_t phase = 0; for (const auto &stage : stages) { phase |= getPhaseID(stage); } @@ -256,111 +256,111 @@ enum class CC_DLL SetIndex { }; CC_ENUM_CONVERSION_OPERATOR(SetIndex) -extern CC_DLL uint globalSet; -extern CC_DLL uint materialSet; -extern CC_DLL uint localSet; +extern CC_DLL uint32_t globalSet; +extern CC_DLL uint32_t materialSet; +extern CC_DLL uint32_t localSet; extern CC_DLL gfx::BindingMappingInfo bindingMappingInfo; struct CC_DLL UBOLocalBatched { - static constexpr uint BATCHING_COUNT = 10; - static constexpr uint MAT_WORLDS_OFFSET = 0; - static constexpr uint COUNT = 16 * UBOLocalBatched::BATCHING_COUNT; - static constexpr uint SIZE = UBOLocalBatched::COUNT * 4; - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_LOCAL); + static constexpr uint32_t BATCHING_COUNT = 10; + static constexpr uint32_t MAT_WORLDS_OFFSET = 0; + static constexpr uint32_t COUNT = 16 * UBOLocalBatched::BATCHING_COUNT; + static constexpr uint32_t SIZE = UBOLocalBatched::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_LOCAL); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOLocal { - static constexpr uint MAT_WORLD_OFFSET = 0; - static constexpr uint MAT_WORLD_IT_OFFSET = UBOLocal::MAT_WORLD_OFFSET + 16; - static constexpr uint LIGHTINGMAP_UVPARAM = UBOLocal::MAT_WORLD_IT_OFFSET + 16; - static constexpr uint LOCAL_SHADOW_BIAS = UBOLocal::LIGHTINGMAP_UVPARAM + 4; - static constexpr uint COUNT = UBOLocal::LOCAL_SHADOW_BIAS + 4; - static constexpr uint SIZE = UBOLocal::COUNT * 4; - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_LOCAL); + static constexpr uint32_t MAT_WORLD_OFFSET = 0; + static constexpr uint32_t MAT_WORLD_IT_OFFSET = UBOLocal::MAT_WORLD_OFFSET + 16; + static constexpr uint32_t LIGHTINGMAP_UVPARAM = UBOLocal::MAT_WORLD_IT_OFFSET + 16; + static constexpr uint32_t LOCAL_SHADOW_BIAS = UBOLocal::LIGHTINGMAP_UVPARAM + 4; + static constexpr uint32_t COUNT = UBOLocal::LOCAL_SHADOW_BIAS + 4; + static constexpr uint32_t SIZE = UBOLocal::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_LOCAL); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOWorldBound { - static constexpr uint WORLD_BOUND_CENTER = 0; - static constexpr uint WORLD_BOUND_HALF_EXTENTS = UBOWorldBound::WORLD_BOUND_CENTER + 4; - static constexpr uint COUNT = UBOWorldBound::WORLD_BOUND_HALF_EXTENTS + 4; - static constexpr uint SIZE = UBOWorldBound::COUNT * 4; - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_LOCAL); + static constexpr uint32_t WORLD_BOUND_CENTER = 0; + static constexpr uint32_t WORLD_BOUND_HALF_EXTENTS = UBOWorldBound::WORLD_BOUND_CENTER + 4; + static constexpr uint32_t COUNT = UBOWorldBound::WORLD_BOUND_HALF_EXTENTS + 4; + static constexpr uint32_t SIZE = UBOWorldBound::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_LOCAL); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOForwardLight { - static constexpr uint LIGHTS_PER_PASS = 1; - static constexpr uint LIGHT_POS_OFFSET = 0; - static constexpr uint LIGHT_COLOR_OFFSET = UBOForwardLight::LIGHT_POS_OFFSET + UBOForwardLight::LIGHTS_PER_PASS * 4; - static constexpr uint LIGHT_SIZE_RANGE_ANGLE_OFFSET = UBOForwardLight::LIGHT_COLOR_OFFSET + UBOForwardLight::LIGHTS_PER_PASS * 4; - static constexpr uint LIGHT_DIR_OFFSET = UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + UBOForwardLight::LIGHTS_PER_PASS * 4; - static constexpr uint COUNT = UBOForwardLight::LIGHT_DIR_OFFSET + UBOForwardLight::LIGHTS_PER_PASS * 4; - static constexpr uint SIZE = UBOForwardLight::COUNT * 4; - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_FORWARD_LIGHTS); + static constexpr uint32_t LIGHTS_PER_PASS = 1; + static constexpr uint32_t LIGHT_POS_OFFSET = 0; + static constexpr uint32_t LIGHT_COLOR_OFFSET = UBOForwardLight::LIGHT_POS_OFFSET + UBOForwardLight::LIGHTS_PER_PASS * 4; + static constexpr uint32_t LIGHT_SIZE_RANGE_ANGLE_OFFSET = UBOForwardLight::LIGHT_COLOR_OFFSET + UBOForwardLight::LIGHTS_PER_PASS * 4; + static constexpr uint32_t LIGHT_DIR_OFFSET = UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + UBOForwardLight::LIGHTS_PER_PASS * 4; + static constexpr uint32_t COUNT = UBOForwardLight::LIGHT_DIR_OFFSET + UBOForwardLight::LIGHTS_PER_PASS * 4; + static constexpr uint32_t SIZE = UBOForwardLight::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_FORWARD_LIGHTS); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBODeferredLight { - static constexpr uint LIGHTS_PER_PASS = 10; + static constexpr uint32_t LIGHTS_PER_PASS = 10; }; struct CC_DLL UBOSkinningTexture { - static constexpr uint JOINTS_TEXTURE_INFO_OFFSET = 0; - static constexpr uint COUNT = UBOSkinningTexture::JOINTS_TEXTURE_INFO_OFFSET + 4; - static constexpr uint SIZE = UBOSkinningTexture::COUNT * 4; - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_SKINNING_TEXTURE); + static constexpr uint32_t JOINTS_TEXTURE_INFO_OFFSET = 0; + static constexpr uint32_t COUNT = UBOSkinningTexture::JOINTS_TEXTURE_INFO_OFFSET + 4; + static constexpr uint32_t SIZE = UBOSkinningTexture::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_SKINNING_TEXTURE); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOSkinningAnimation { - static constexpr uint JOINTS_ANIM_INFO_OFFSET = 0; - static constexpr uint COUNT = UBOSkinningAnimation::JOINTS_ANIM_INFO_OFFSET + 4; - static constexpr uint SIZE = UBOSkinningAnimation::COUNT * 4; - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_SKINNING_ANIMATION); + static constexpr uint32_t JOINTS_ANIM_INFO_OFFSET = 0; + static constexpr uint32_t COUNT = UBOSkinningAnimation::JOINTS_ANIM_INFO_OFFSET + 4; + static constexpr uint32_t SIZE = UBOSkinningAnimation::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_SKINNING_ANIMATION); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOSkinning { - static constexpr uint JOINTS_OFFSET = 0; - static constexpr uint COUNT = UBOSkinning::JOINTS_OFFSET + JOINT_UNIFORM_CAPACITY * 12; - static constexpr uint SIZE = UBOSkinning::COUNT * 4; - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_SKINNING_TEXTURE); + static constexpr uint32_t JOINTS_OFFSET = 0; + static constexpr uint32_t COUNT = UBOSkinning::JOINTS_OFFSET + JOINT_UNIFORM_CAPACITY * 12; + static constexpr uint32_t SIZE = UBOSkinning::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_SKINNING_TEXTURE); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOMorph { - static constexpr uint MAX_MORPH_TARGET_COUNT = 60; - static constexpr uint OFFSET_OF_WEIGHTS = 0; - static constexpr uint OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH = 4 * MAX_MORPH_TARGET_COUNT; - static constexpr uint OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT = OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH + 4; - static constexpr uint OFFSET_OF_VERTICES_COUNT = OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT + 4; - static const uint COUNT_BASE_4_BYTES; - static const uint SIZE; - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_MORPH); + static constexpr uint32_t MAX_MORPH_TARGET_COUNT = 60; + static constexpr uint32_t OFFSET_OF_WEIGHTS = 0; + static constexpr uint32_t OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH = 4 * MAX_MORPH_TARGET_COUNT; + static constexpr uint32_t OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT = OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH + 4; + static constexpr uint32_t OFFSET_OF_VERTICES_COUNT = OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT + 4; + static const uint32_t COUNT_BASE_4_BYTES; + static const uint32_t SIZE; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_MORPH); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOUILocal { - static constexpr uint BINDING = static_cast(ModelLocalBindings::UBO_UI_LOCAL); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_UI_LOCAL); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; @@ -404,75 +404,75 @@ enum class CC_DLL DeferredFlowPriority { CC_ENUM_CONVERSION_OPERATOR(DeferredFlowPriority) struct CC_DLL UBOGlobal { - static constexpr uint TIME_OFFSET = 0; - static constexpr uint SCREEN_SIZE_OFFSET = UBOGlobal::TIME_OFFSET + 4; - static constexpr uint NATIVE_SIZE_OFFSET = UBOGlobal::SCREEN_SIZE_OFFSET + 4; + static constexpr uint32_t TIME_OFFSET = 0; + static constexpr uint32_t SCREEN_SIZE_OFFSET = UBOGlobal::TIME_OFFSET + 4; + static constexpr uint32_t NATIVE_SIZE_OFFSET = UBOGlobal::SCREEN_SIZE_OFFSET + 4; - static constexpr uint DEBUG_VIEW_MODE_OFFSET = UBOGlobal::NATIVE_SIZE_OFFSET + 4; - static constexpr uint DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET = UBOGlobal::DEBUG_VIEW_MODE_OFFSET + 4; - static constexpr uint DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET + 4; - static constexpr uint DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET + 4; + static constexpr uint32_t DEBUG_VIEW_MODE_OFFSET = UBOGlobal::NATIVE_SIZE_OFFSET + 4; + static constexpr uint32_t DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET = UBOGlobal::DEBUG_VIEW_MODE_OFFSET + 4; + static constexpr uint32_t DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_1_OFFSET + 4; + static constexpr uint32_t DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_2_OFFSET + 4; - static constexpr uint COUNT = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET + 4; + static constexpr uint32_t COUNT = UBOGlobal::DEBUG_VIEW_COMPOSITE_PACK_3_OFFSET + 4; - static constexpr uint SIZE = UBOGlobal::COUNT * 4; - static constexpr uint BINDING = static_cast(PipelineGlobalBindings::UBO_GLOBAL); + static constexpr uint32_t SIZE = UBOGlobal::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(PipelineGlobalBindings::UBO_GLOBAL); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOCamera { - static constexpr uint MAT_VIEW_OFFSET = 0; - static constexpr uint MAT_VIEW_INV_OFFSET = UBOCamera::MAT_VIEW_OFFSET + 16; - static constexpr uint MAT_PROJ_OFFSET = UBOCamera::MAT_VIEW_INV_OFFSET + 16; - static constexpr uint MAT_PROJ_INV_OFFSET = UBOCamera::MAT_PROJ_OFFSET + 16; - static constexpr uint MAT_VIEW_PROJ_OFFSET = UBOCamera::MAT_PROJ_INV_OFFSET + 16; - static constexpr uint MAT_VIEW_PROJ_INV_OFFSET = UBOCamera::MAT_VIEW_PROJ_OFFSET + 16; - static constexpr uint CAMERA_POS_OFFSET = UBOCamera::MAT_VIEW_PROJ_INV_OFFSET + 16; - static constexpr uint SURFACE_TRANSFORM_OFFSET = UBOCamera::CAMERA_POS_OFFSET + 4; - static constexpr uint SCREEN_SCALE_OFFSET = UBOCamera::SURFACE_TRANSFORM_OFFSET + 4; - static constexpr uint EXPOSURE_OFFSET = UBOCamera::SCREEN_SCALE_OFFSET + 4; - static constexpr uint MAIN_LIT_DIR_OFFSET = UBOCamera::EXPOSURE_OFFSET + 4; - static constexpr uint MAIN_LIT_COLOR_OFFSET = UBOCamera::MAIN_LIT_DIR_OFFSET + 4; - static constexpr uint AMBIENT_SKY_OFFSET = UBOCamera::MAIN_LIT_COLOR_OFFSET + 4; - static constexpr uint AMBIENT_GROUND_OFFSET = UBOCamera::AMBIENT_SKY_OFFSET + 4; - static constexpr uint GLOBAL_FOG_COLOR_OFFSET = UBOCamera::AMBIENT_GROUND_OFFSET + 4; - static constexpr uint GLOBAL_FOG_BASE_OFFSET = UBOCamera::GLOBAL_FOG_COLOR_OFFSET + 4; - static constexpr uint GLOBAL_FOG_ADD_OFFSET = UBOCamera::GLOBAL_FOG_BASE_OFFSET + 4; - static constexpr uint GLOBAL_NEAR_FAR_OFFSET = UBOCamera::GLOBAL_FOG_ADD_OFFSET + 4; - static constexpr uint GLOBAL_VIEW_PORT_OFFSET = UBOCamera::GLOBAL_NEAR_FAR_OFFSET + 4; - static constexpr uint COUNT = UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 4; - static constexpr uint SIZE = UBOCamera::COUNT * 4; - static constexpr uint BINDING = static_cast(PipelineGlobalBindings::UBO_CAMERA); + static constexpr uint32_t MAT_VIEW_OFFSET = 0; + static constexpr uint32_t MAT_VIEW_INV_OFFSET = UBOCamera::MAT_VIEW_OFFSET + 16; + static constexpr uint32_t MAT_PROJ_OFFSET = UBOCamera::MAT_VIEW_INV_OFFSET + 16; + static constexpr uint32_t MAT_PROJ_INV_OFFSET = UBOCamera::MAT_PROJ_OFFSET + 16; + static constexpr uint32_t MAT_VIEW_PROJ_OFFSET = UBOCamera::MAT_PROJ_INV_OFFSET + 16; + static constexpr uint32_t MAT_VIEW_PROJ_INV_OFFSET = UBOCamera::MAT_VIEW_PROJ_OFFSET + 16; + static constexpr uint32_t CAMERA_POS_OFFSET = UBOCamera::MAT_VIEW_PROJ_INV_OFFSET + 16; + static constexpr uint32_t SURFACE_TRANSFORM_OFFSET = UBOCamera::CAMERA_POS_OFFSET + 4; + static constexpr uint32_t SCREEN_SCALE_OFFSET = UBOCamera::SURFACE_TRANSFORM_OFFSET + 4; + static constexpr uint32_t EXPOSURE_OFFSET = UBOCamera::SCREEN_SCALE_OFFSET + 4; + static constexpr uint32_t MAIN_LIT_DIR_OFFSET = UBOCamera::EXPOSURE_OFFSET + 4; + static constexpr uint32_t MAIN_LIT_COLOR_OFFSET = UBOCamera::MAIN_LIT_DIR_OFFSET + 4; + static constexpr uint32_t AMBIENT_SKY_OFFSET = UBOCamera::MAIN_LIT_COLOR_OFFSET + 4; + static constexpr uint32_t AMBIENT_GROUND_OFFSET = UBOCamera::AMBIENT_SKY_OFFSET + 4; + static constexpr uint32_t GLOBAL_FOG_COLOR_OFFSET = UBOCamera::AMBIENT_GROUND_OFFSET + 4; + static constexpr uint32_t GLOBAL_FOG_BASE_OFFSET = UBOCamera::GLOBAL_FOG_COLOR_OFFSET + 4; + static constexpr uint32_t GLOBAL_FOG_ADD_OFFSET = UBOCamera::GLOBAL_FOG_BASE_OFFSET + 4; + static constexpr uint32_t GLOBAL_NEAR_FAR_OFFSET = UBOCamera::GLOBAL_FOG_ADD_OFFSET + 4; + static constexpr uint32_t GLOBAL_VIEW_PORT_OFFSET = UBOCamera::GLOBAL_NEAR_FAR_OFFSET + 4; + static constexpr uint32_t COUNT = UBOCamera::GLOBAL_VIEW_PORT_OFFSET + 4; + static constexpr uint32_t SIZE = UBOCamera::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(PipelineGlobalBindings::UBO_CAMERA); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; }; struct CC_DLL UBOShadow { - static constexpr uint CSM_LEVEL_COUNT = 4; - static constexpr uint MAT_LIGHT_PLANE_PROJ_OFFSET = 0; - static constexpr uint MAT_LIGHT_VIEW_OFFSET = MAT_LIGHT_PLANE_PROJ_OFFSET + 16; - static constexpr uint MAT_LIGHT_VIEW_PROJ_OFFSET = UBOShadow::MAT_LIGHT_VIEW_OFFSET + 16; - static constexpr uint SHADOW_INV_PROJ_DEPTH_INFO_OFFSET = UBOShadow::MAT_LIGHT_VIEW_PROJ_OFFSET + 16; - static constexpr uint SHADOW_PROJ_DEPTH_INFO_OFFSET = UBOShadow::SHADOW_INV_PROJ_DEPTH_INFO_OFFSET + 4; - static constexpr uint SHADOW_PROJ_INFO_OFFSET = UBOShadow::SHADOW_PROJ_DEPTH_INFO_OFFSET + 4; - static constexpr uint SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET = UBOShadow::SHADOW_PROJ_INFO_OFFSET + 4; - static constexpr uint SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET = UBOShadow::SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET + 4; - static constexpr uint SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET = UBOShadow::SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET + 4; - static constexpr uint SHADOW_COLOR_OFFSET = UBOShadow::SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 4; - static constexpr uint PLANAR_NORMAL_DISTANCE_INFO_OFFSET = UBOShadow::SHADOW_COLOR_OFFSET + 4; - static constexpr uint MAT_CSM_VIEW_LEVELS_OFFSET = UBOShadow::PLANAR_NORMAL_DISTANCE_INFO_OFFSET + 4; - static constexpr uint MAT_CSM_VIEW_PROJ_LEVELS_OFFSET = UBOShadow::MAT_CSM_VIEW_LEVELS_OFFSET + 16 * UBOShadow::CSM_LEVEL_COUNT; - static constexpr uint MAT_CSM_VIEW_PROJ_ATLAS_LEVELS_OFFSET = UBOShadow::MAT_CSM_VIEW_PROJ_LEVELS_OFFSET + 16 * UBOShadow::CSM_LEVEL_COUNT; - static constexpr uint CSM_PROJ_DEPTH_INFO_LEVELS_OFFSET = UBOShadow::MAT_CSM_VIEW_PROJ_ATLAS_LEVELS_OFFSET + 16 * UBOShadow::CSM_LEVEL_COUNT; - static constexpr uint CSM_PROJ_INFO_LEVELS_OFFSET = UBOShadow::CSM_PROJ_DEPTH_INFO_LEVELS_OFFSET + 4 * UBOShadow::CSM_LEVEL_COUNT; - static constexpr uint CSM_SPLITS_INFO_OFFSET = UBOShadow::CSM_PROJ_INFO_LEVELS_OFFSET + 4 * UBOShadow::CSM_LEVEL_COUNT; - static constexpr uint CSM_INFO_OFFSET = UBOShadow::CSM_SPLITS_INFO_OFFSET + 4; - static constexpr uint COUNT = UBOShadow::CSM_INFO_OFFSET + 4; - static constexpr uint SIZE = UBOShadow::COUNT * 4; - static constexpr uint BINDING = static_cast(PipelineGlobalBindings::UBO_SHADOW); + static constexpr uint32_t CSM_LEVEL_COUNT = 4; + static constexpr uint32_t MAT_LIGHT_PLANE_PROJ_OFFSET = 0; + static constexpr uint32_t MAT_LIGHT_VIEW_OFFSET = MAT_LIGHT_PLANE_PROJ_OFFSET + 16; + static constexpr uint32_t MAT_LIGHT_VIEW_PROJ_OFFSET = UBOShadow::MAT_LIGHT_VIEW_OFFSET + 16; + static constexpr uint32_t SHADOW_INV_PROJ_DEPTH_INFO_OFFSET = UBOShadow::MAT_LIGHT_VIEW_PROJ_OFFSET + 16; + static constexpr uint32_t SHADOW_PROJ_DEPTH_INFO_OFFSET = UBOShadow::SHADOW_INV_PROJ_DEPTH_INFO_OFFSET + 4; + static constexpr uint32_t SHADOW_PROJ_INFO_OFFSET = UBOShadow::SHADOW_PROJ_DEPTH_INFO_OFFSET + 4; + static constexpr uint32_t SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET = UBOShadow::SHADOW_PROJ_INFO_OFFSET + 4; + static constexpr uint32_t SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET = UBOShadow::SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET + 4; + static constexpr uint32_t SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET = UBOShadow::SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET + 4; + static constexpr uint32_t SHADOW_COLOR_OFFSET = UBOShadow::SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET + 4; + static constexpr uint32_t PLANAR_NORMAL_DISTANCE_INFO_OFFSET = UBOShadow::SHADOW_COLOR_OFFSET + 4; + static constexpr uint32_t MAT_CSM_VIEW_LEVELS_OFFSET = UBOShadow::PLANAR_NORMAL_DISTANCE_INFO_OFFSET + 4; + static constexpr uint32_t MAT_CSM_VIEW_PROJ_LEVELS_OFFSET = UBOShadow::MAT_CSM_VIEW_LEVELS_OFFSET + 16 * UBOShadow::CSM_LEVEL_COUNT; + static constexpr uint32_t MAT_CSM_VIEW_PROJ_ATLAS_LEVELS_OFFSET = UBOShadow::MAT_CSM_VIEW_PROJ_LEVELS_OFFSET + 16 * UBOShadow::CSM_LEVEL_COUNT; + static constexpr uint32_t CSM_PROJ_DEPTH_INFO_LEVELS_OFFSET = UBOShadow::MAT_CSM_VIEW_PROJ_ATLAS_LEVELS_OFFSET + 16 * UBOShadow::CSM_LEVEL_COUNT; + static constexpr uint32_t CSM_PROJ_INFO_LEVELS_OFFSET = UBOShadow::CSM_PROJ_DEPTH_INFO_LEVELS_OFFSET + 4 * UBOShadow::CSM_LEVEL_COUNT; + static constexpr uint32_t CSM_SPLITS_INFO_OFFSET = UBOShadow::CSM_PROJ_INFO_LEVELS_OFFSET + 4 * UBOShadow::CSM_LEVEL_COUNT; + static constexpr uint32_t CSM_INFO_OFFSET = UBOShadow::CSM_SPLITS_INFO_OFFSET + 4; + static constexpr uint32_t COUNT = UBOShadow::CSM_INFO_OFFSET + 4; + static constexpr uint32_t SIZE = UBOShadow::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(PipelineGlobalBindings::UBO_SHADOW); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformBlock LAYOUT; static const ccstd::string NAME; @@ -487,7 +487,7 @@ struct CC_DLL DescriptorSetLayoutInfos { extern CC_DLL DescriptorSetLayoutInfos globalDescriptorSetLayout; extern CC_DLL DescriptorSetLayoutInfos localDescriptorSetLayout; -enum class LayerList : uint { +enum class LayerList : uint32_t { NONE = 0, IGNORE_RAYCAST = (1 << 20), GIZMOS = (1 << 21), @@ -502,105 +502,105 @@ enum class LayerList : uint { }; CC_ENUM_CONVERSION_OPERATOR(LayerList) -const uint CAMERA_DEFAULT_MASK = ~static_cast(LayerList::UI_2D) & ~static_cast(LayerList::PROFILER); +const uint32_t CAMERA_DEFAULT_MASK = ~static_cast(LayerList::UI_2D) & ~static_cast(LayerList::PROFILER); //constexpr CAMERA_DEFAULT_MASK = Layers.makeMaskExclude([Layers.BitMask.UI_2D, Layers.BitMask.GIZMOS, Layers.BitMask.EDITOR, // Layers.BitMask.SCENE_GIZMO, Layers.BitMask.PROFILER]); -uint nextPow2(uint val); +uint32_t nextPow2(uint32_t val); bool supportsR16HalfFloatTexture(const gfx::Device* device); bool supportsR32FloatTexture(const gfx::Device* device); -extern CC_DLL uint skyboxFlag; +extern CC_DLL uint32_t skyboxFlag; struct CC_DLL SHADOWMAP { - static constexpr uint BINDING = static_cast(PipelineGlobalBindings::SAMPLER_SHADOWMAP); + static constexpr uint32_t BINDING = static_cast(PipelineGlobalBindings::SAMPLER_SHADOWMAP); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL ENVIRONMENT { - static constexpr uint BINDING = static_cast(PipelineGlobalBindings::SAMPLER_ENVIRONMENT); + static constexpr uint32_t BINDING = static_cast(PipelineGlobalBindings::SAMPLER_ENVIRONMENT); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL SPOTLIGHTINGMAP { - static constexpr uint BINDING = static_cast(PipelineGlobalBindings::SAMPLER_SPOT_LIGHTING_MAP); + static constexpr uint32_t BINDING = static_cast(PipelineGlobalBindings::SAMPLER_SPOT_LIGHTING_MAP); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL DIFFUSEMAP { - static constexpr uint BINDING = static_cast(PipelineGlobalBindings::SAMPLER_DIFFUSEMAP); + static constexpr uint32_t BINDING = static_cast(PipelineGlobalBindings::SAMPLER_DIFFUSEMAP); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL JOINTTEXTURE { - static constexpr uint BINDING = static_cast(ModelLocalBindings::SAMPLER_JOINTS); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::SAMPLER_JOINTS); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL POSITIONMORPH { - static constexpr uint BINDING = static_cast(ModelLocalBindings::SAMPLER_MORPH_POSITION); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::SAMPLER_MORPH_POSITION); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL NORMALMORPH { - static constexpr uint BINDING = static_cast(ModelLocalBindings::SAMPLER_MORPH_NORMAL); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::SAMPLER_MORPH_NORMAL); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL TANGENTMORPH { - static constexpr uint BINDING = static_cast(ModelLocalBindings::SAMPLER_MORPH_TANGENT); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::SAMPLER_MORPH_TANGENT); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL LIGHTMAPTEXTURE { - static constexpr uint BINDING = static_cast(ModelLocalBindings::SAMPLER_LIGHTMAP); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::SAMPLER_LIGHTMAP); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL SPRITETEXTURE { - static constexpr uint BINDING = static_cast(ModelLocalBindings::SAMPLER_SPRITE); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::SAMPLER_SPRITE); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL REFLECTIONTEXTURE { - static constexpr uint BINDING = static_cast(ModelLocalBindings::SAMPLER_REFLECTION); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::SAMPLER_REFLECTION); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformSamplerTexture LAYOUT; static const ccstd::string NAME; }; struct CC_DLL REFLECTIONSTORAGE { - static constexpr uint BINDING = static_cast(ModelLocalBindings::STORAGE_REFLECTION); + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::STORAGE_REFLECTION); static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; static const gfx::UniformStorageImage LAYOUT; static const ccstd::string NAME; }; -static constexpr uint CLUSTER_LIGHT_BINDING = 4; -static constexpr uint CLUSTER_LIGHT_INDEX_BINDING = 5; -static constexpr uint CLUSTER_LIGHT_GRID_BINDING = 6; +static constexpr uint32_t CLUSTER_LIGHT_BINDING = 4; +static constexpr uint32_t CLUSTER_LIGHT_INDEX_BINDING = 5; +static constexpr uint32_t CLUSTER_LIGHT_GRID_BINDING = 6; } // namespace pipeline } // namespace cc diff --git a/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp b/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp index fd21becf9d..285f9d6b29 100644 --- a/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp +++ b/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp @@ -113,9 +113,9 @@ gfx::DescriptorSet *GlobalDSManager::getOrCreateDescriptorSet(uint32_t idx) { auto *descriptorSet = _device->createDescriptorSet({_descriptorSetLayout}); _descriptorSetMap.emplace(idx, descriptorSet); - const auto begin = static_cast(PipelineGlobalBindings::UBO_GLOBAL); - const auto end = static_cast(PipelineGlobalBindings::COUNT); - for (uint i = begin; i < end; ++i) { + const auto begin = static_cast(PipelineGlobalBindings::UBO_GLOBAL); + const auto end = static_cast(PipelineGlobalBindings::COUNT); + for (uint32_t i = begin; i < end; ++i) { auto *const buffer = _globalDescriptorSet->getBuffer(i); if (buffer != nullptr) { descriptorSet->bindBuffer(i, buffer); diff --git a/native/cocos/renderer/pipeline/InstancedBuffer.cpp b/native/cocos/renderer/pipeline/InstancedBuffer.cpp index 72a176f4d7..03dbff37af 100644 --- a/native/cocos/renderer/pipeline/InstancedBuffer.cpp +++ b/native/cocos/renderer/pipeline/InstancedBuffer.cpp @@ -33,11 +33,11 @@ namespace cc { namespace pipeline { -ccstd::unordered_map> InstancedBuffer::buffers; +ccstd::unordered_map> InstancedBuffer::buffers; InstancedBuffer *InstancedBuffer::get(scene::Pass *pass) { return InstancedBuffer::get(pass, 0); } -InstancedBuffer *InstancedBuffer::get(scene::Pass *pass, uint extraKey) { +InstancedBuffer *InstancedBuffer::get(scene::Pass *pass, uint32_t extraKey) { auto &record = buffers[pass]; auto &buffer = record[extraKey]; if (buffer == nullptr) buffer = ccnew InstancedBuffer(pass); @@ -47,7 +47,7 @@ InstancedBuffer *InstancedBuffer::get(scene::Pass *pass, uint extraKey) { void InstancedBuffer::destroyInstancedBuffer() { for (auto &pair : InstancedBuffer::buffers) { - const ccstd::unordered_map &instanceItem = pair.second; + const ccstd::unordered_map &instanceItem = pair.second; for (const auto &item : instanceItem) { InstancedBuffer *instanceBuffer = item.second; if (instanceBuffer) { @@ -74,11 +74,11 @@ void InstancedBuffer::destroy() { _instances.clear(); } -void InstancedBuffer::merge(const scene::Model *model, const scene::SubModel *subModel, uint passIdx) { +void InstancedBuffer::merge(const scene::Model *model, const scene::SubModel *subModel, uint32_t passIdx) { merge(model, subModel, passIdx, nullptr); } -void InstancedBuffer::merge(const scene::Model *model, const scene::SubModel *subModel, uint passIdx, gfx::Shader *shaderImplant) { +void InstancedBuffer::merge(const scene::Model *model, const scene::SubModel *subModel, uint32_t passIdx, gfx::Shader *shaderImplant) { auto stride = model->getInstancedBufferSize(); const auto *instancedBuffer = model->getInstancedBuffer(); @@ -126,8 +126,8 @@ void InstancedBuffer::merge(const scene::Model *model, const scene::SubModel *su auto *vb = _device->createBuffer({ gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST, gfx::MemoryUsageBit::DEVICE, - static_cast(newSize), - static_cast(stride), + static_cast(newSize), + static_cast(stride), }); const auto &instancedAttributes = model->getInstanceAttributes(); @@ -141,7 +141,7 @@ void InstancedBuffer::merge(const scene::Model *model, const scene::SubModel *su attribute.name, attribute.format, attribute.isNormalized, - static_cast(vertexBuffers.size()), // stream + static_cast(vertexBuffers.size()), // stream true, attribute.location}); } @@ -172,7 +172,7 @@ void InstancedBuffer::clear() { _hasPendingModels = false; } -void InstancedBuffer::setDynamicOffset(uint idx, uint value) { +void InstancedBuffer::setDynamicOffset(uint32_t idx, uint32_t value) { if (_dynamicOffsets.size() <= idx) _dynamicOffsets.resize(idx + 1); _dynamicOffsets[idx] = value; } diff --git a/native/cocos/renderer/pipeline/InstancedBuffer.h b/native/cocos/renderer/pipeline/InstancedBuffer.h index bbd2df3b58..e31bb4beca 100644 --- a/native/cocos/renderer/pipeline/InstancedBuffer.h +++ b/native/cocos/renderer/pipeline/InstancedBuffer.h @@ -43,36 +43,36 @@ struct PSOInfo; #endif struct CC_DLL InstancedItem { - uint count = 0; - uint capacity = 0; + uint32_t count = 0; + uint32_t capacity = 0; gfx::Buffer *vb = nullptr; uint8_t *data = nullptr; gfx::InputAssembler *ia = nullptr; - uint stride = 0; + uint32_t stride = 0; gfx::Shader *shader = nullptr; gfx::DescriptorSet *descriptorSet = nullptr; gfx::Texture *lightingMap = nullptr; }; using InstancedItemList = ccstd::vector; -using DynamicOffsetList = ccstd::vector; +using DynamicOffsetList = ccstd::vector; class InstancedBuffer : public RefCounted { public: - static constexpr uint INITIAL_CAPACITY = 32; - static constexpr uint MAX_CAPACITY = 1024; + static constexpr uint32_t INITIAL_CAPACITY = 32; + static constexpr uint32_t MAX_CAPACITY = 1024; static InstancedBuffer *get(scene::Pass *pass); - static InstancedBuffer *get(scene::Pass *, uint extraKey); + static InstancedBuffer *get(scene::Pass *, uint32_t extraKey); static void destroyInstancedBuffer(); explicit InstancedBuffer(const scene::Pass *pass); ~InstancedBuffer() override; void destroy(); - void merge(const scene::Model *, const scene::SubModel *, uint); - void merge(const scene::Model *, const scene::SubModel *, uint, gfx::Shader *); + void merge(const scene::Model *, const scene::SubModel *, uint32_t); + void merge(const scene::Model *, const scene::SubModel *, uint32_t, gfx::Shader *); void uploadBuffers(gfx::CommandBuffer *cmdBuff); void clear(); - void setDynamicOffset(uint idx, uint value); + void setDynamicOffset(uint32_t idx, uint32_t value); inline const InstancedItemList &getInstances() const { return _instances; } inline const scene::Pass *getPass() const { return _pass; } @@ -80,7 +80,7 @@ public: inline const DynamicOffsetList &dynamicOffsets() const { return _dynamicOffsets; } private: - static ccstd::unordered_map> buffers; + static ccstd::unordered_map> buffers; InstancedItemList _instances; const scene::Pass *_pass = nullptr; bool _hasPendingModels = false; diff --git a/native/cocos/renderer/pipeline/PipelineStateManager.cpp b/native/cocos/renderer/pipeline/PipelineStateManager.cpp index bfee270a85..e01a679550 100644 --- a/native/cocos/renderer/pipeline/PipelineStateManager.cpp +++ b/native/cocos/renderer/pipeline/PipelineStateManager.cpp @@ -37,7 +37,7 @@ gfx::PipelineState *PipelineStateManager::getOrCreatePipelineState(const scene:: gfx::Shader *shader, gfx::InputAssembler *inputAssembler, gfx::RenderPass *renderPass, - uint subpass) { + uint32_t subpass) { const auto passHash = pass->getHash(); const auto renderPassHash = renderPass->getHash(); const auto iaHash = inputAssembler->getAttributesHash(); diff --git a/native/cocos/renderer/pipeline/PipelineStateManager.h b/native/cocos/renderer/pipeline/PipelineStateManager.h index bebcb5b53d..34412c0988 100644 --- a/native/cocos/renderer/pipeline/PipelineStateManager.h +++ b/native/cocos/renderer/pipeline/PipelineStateManager.h @@ -40,7 +40,7 @@ public: gfx::Shader *shader, gfx::InputAssembler *inputAssembler, gfx::RenderPass *renderPass, - uint subpass = 0); + uint32_t subpass = 0); static void destroyAll(); private: diff --git a/native/cocos/renderer/pipeline/PipelineUBO.cpp b/native/cocos/renderer/pipeline/PipelineUBO.cpp index 8350b49df3..231ee096e9 100644 --- a/native/cocos/renderer/pipeline/PipelineUBO.cpp +++ b/native/cocos/renderer/pipeline/PipelineUBO.cpp @@ -150,7 +150,7 @@ void PipelineUBO::updateCameraUBOView(const RenderPipeline *pipeline, float *out output[UBOCamera::AMBIENT_GROUND_OFFSET + 3] = ambient->getMipmapCount(); } - // cjh TS doesn't have this logic ? auto *const envmap = descriptorSet->getTexture(static_cast(PipelineGlobalBindings::SAMPLER_ENVIRONMENT)); + // cjh TS doesn't have this logic ? auto *const envmap = descriptorSet->getTexture(static_cast(PipelineGlobalBindings::SAMPLER_ENVIRONMENT)); // if (envmap != nullptr) { // output[UBOCamera::AMBIENT_GROUND_OFFSET + 3] = static_cast(envmap->getLevelCount()); // } @@ -231,7 +231,7 @@ void PipelineUBO::updateShadowUBOView(const RenderPipeline *pipeline, ccstd::arr const float shadowLPNNInfos[4] = {0.0F, packing, mainLight->getShadowNormalBias(), 0.0F}; memcpy(sv.data() + UBOShadow::SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET, &shadowLPNNInfos, sizeof(shadowLPNNInfos)); } else { - for (uint i = 0; i < static_cast(mainLight->getCSMLevel()); ++i) { + for (uint32_t i = 0; i < static_cast(mainLight->getCSMLevel()); ++i) { sv[UBOShadow::CSM_SPLITS_INFO_OFFSET + i] = csmLayers->getLayers()[i]->getSplitCameraFar() / mainLight->getShadowDistance(); const Mat4 &matShadowView = csmLayers->getLayers()[i]->getMatShadowView(); @@ -274,7 +274,7 @@ void PipelineUBO::updateShadowUBOView(const RenderPipeline *pipeline, ccstd::arr } void PipelineUBO::updateShadowUBOLightView(const RenderPipeline *pipeline, ccstd::array *shadowBufferView, - const scene::Light *light, uint level) { + const scene::Light *light, uint32_t level) { const auto *sceneData = pipeline->getPipelineSceneData(); const CSMLayers *csmLayers = sceneData->getCSMLayers(); const auto *shadowInfo = sceneData->getShadows(); @@ -469,14 +469,14 @@ void PipelineUBO::updateCameraUBO(const scene::Camera *camera) { void PipelineUBO::updateMultiCameraUBO(const ccstd::vector &cameras) { const auto cameraCount = cameras.size(); - const auto totalUboSize = static_cast(_alignedCameraUBOSize * cameraCount); + const auto totalUboSize = static_cast(_alignedCameraUBOSize * cameraCount); if (_cameraBuffer->getSize() < totalUboSize) { _cameraBuffer->resize(totalUboSize); _cameraUBOs.resize(totalUboSize / sizeof(float)); } - for (uint cameraIdx = 0; cameraIdx < cameraCount; ++cameraIdx) { + for (uint32_t cameraIdx = 0; cameraIdx < cameraCount; ++cameraIdx) { const auto *camera = cameras[cameraIdx]; const auto offset = cameraIdx * _alignedCameraUBOSize / sizeof(float); PipelineUBO::updateCameraUBOView(_pipeline, &_cameraUBOs[offset], camera); @@ -511,18 +511,18 @@ void PipelineUBO::updateShadowUBO(const scene::Camera *camera) { cmdBuffer->updateBuffer(ds->getBuffer(UBOShadow::BINDING), _shadowUBO.data(), UBOShadow::SIZE); } -void PipelineUBO::updateShadowUBOLight(gfx::DescriptorSet *globalDS, const scene::Light *light, uint level) { +void PipelineUBO::updateShadowUBOLight(gfx::DescriptorSet *globalDS, const scene::Light *light, uint32_t level) { auto *const cmdBuffer = _pipeline->getCommandBuffers()[0]; updateShadowUBOLightView(_pipeline, &_shadowUBO, light, level); globalDS->update(); cmdBuffer->updateBuffer(globalDS->getBuffer(UBOShadow::BINDING), _shadowUBO.data(), UBOShadow::SIZE); } -void PipelineUBO::updateShadowUBORange(uint offset, const Mat4 *data) { +void PipelineUBO::updateShadowUBORange(uint32_t offset, const Mat4 *data) { memcpy(_shadowUBO.data() + offset, data->m, sizeof(*data)); } -uint PipelineUBO::getCurrentCameraUBOOffset() const { +uint32_t PipelineUBO::getCurrentCameraUBOOffset() const { return _currentCameraUBOOffset; } diff --git a/native/cocos/renderer/pipeline/PipelineUBO.h b/native/cocos/renderer/pipeline/PipelineUBO.h index 435805e6aa..bc1fd39718 100644 --- a/native/cocos/renderer/pipeline/PipelineUBO.h +++ b/native/cocos/renderer/pipeline/PipelineUBO.h @@ -44,7 +44,7 @@ public: static void updateShadowUBOView(const RenderPipeline *pipeline, ccstd::array *shadowBufferView, const scene::Camera *camera); static void updateShadowUBOLightView(const RenderPipeline *pipeline, ccstd::array *shadowBufferView, - const scene::Light *light, uint level); + const scene::Light *light, uint32_t level); static uint8_t getCombineSignY(); PipelineUBO() = default; @@ -55,10 +55,10 @@ public: void updateCameraUBO(const scene::Camera *camera); void updateMultiCameraUBO(const ccstd::vector &cameras); void updateShadowUBO(const scene::Camera *camera); - void updateShadowUBOLight(gfx::DescriptorSet *globalDS, const scene::Light *light, uint level = 0U); - void updateShadowUBORange(uint offset, const Mat4 *data); + void updateShadowUBOLight(gfx::DescriptorSet *globalDS, const scene::Light *light, uint32_t level = 0U); + void updateShadowUBORange(uint32_t offset, const Mat4 *data); - uint getCurrentCameraUBOOffset() const; + uint32_t getCurrentCameraUBOOffset() const; void incCameraUBOOffset(); private: @@ -75,8 +75,8 @@ private: ccstd::vector _cameraUBOs; gfx::Buffer *_cameraBuffer{nullptr}; - uint _currentCameraUBOOffset{0}; - uint _alignedCameraUBOSize{0}; + uint32_t _currentCameraUBOOffset{0}; + uint32_t _alignedCameraUBOSize{0}; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/PlanarShadowQueue.cpp b/native/cocos/renderer/pipeline/PlanarShadowQueue.cpp index 643c4c15bb..b1e478cd9e 100644 --- a/native/cocos/renderer/pipeline/PlanarShadowQueue.cpp +++ b/native/cocos/renderer/pipeline/PlanarShadowQueue.cpp @@ -59,7 +59,7 @@ void PlanarShadowQueue::gatherShadowPasses(scene::Camera *camera, gfx::CommandBu } const auto *scene = camera->getScene(); - const bool shadowVisible = camera->getVisibility() & static_cast(LayerList::DEFAULT); + const bool shadowVisible = camera->getVisibility() & static_cast(LayerList::DEFAULT); if (!scene->getMainLight() || !shadowVisible) { return; } diff --git a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp index cd330d1d82..65a39c3c0d 100644 --- a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp @@ -80,7 +80,7 @@ RenderAdditiveLightQueue ::~RenderAdditiveLightQueue() { } void RenderAdditiveLightQueue::recordCommandBuffer(gfx::Device *device, scene::Camera *camera, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer) { - const uint offset = _pipeline->getPipelineUBO()->getCurrentCameraUBOOffset(); + const uint32_t offset = _pipeline->getPipelineUBO()->getCurrentCameraUBOOffset(); for (const auto light : _lightInstancedPasses) { auto *globalDescriptorSet = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(light); _instancedQueue->recordCommandBuffer(device, renderPass, cmdBuffer, globalDescriptorSet, offset); @@ -121,7 +121,7 @@ void RenderAdditiveLightQueue::recordCommandBuffer(gfx::Device *device, scene::C } void RenderAdditiveLightQueue::gatherLightPasses(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer) { - static ccstd::vector lightPassIndices; + static ccstd::vector lightPassIndices; clear(); @@ -188,11 +188,11 @@ bool RenderAdditiveLightQueue::cullSpotLight(const scene::SpotLight *light, cons bool RenderAdditiveLightQueue::isInstancedOrBatched(const scene::Model* model) { const auto & subModels = model->getSubModels(); const auto subModelCount = subModels.size(); - for (uint subModelIdx = 0; subModelIdx < subModelCount; ++subModelIdx) { + for (uint32_t subModelIdx = 0; subModelIdx < subModelCount; ++subModelIdx) { const auto &subModel = subModels[subModelIdx]; const auto &passes = subModel->getPasses(); const auto passCount = passes.size(); - for (uint passIdx = 0; passIdx < passCount; ++passIdx) { + for (uint32_t passIdx = 0; passIdx < passCount; ++passIdx) { const auto &pass = passes[passIdx]; if (pass->getBatchingScheme() == scene::BatchingSchemes::INSTANCING) { return true; @@ -205,7 +205,7 @@ bool RenderAdditiveLightQueue::isInstancedOrBatched(const scene::Model* model) { return false; } -void RenderAdditiveLightQueue::addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint lightPassIdx) { +void RenderAdditiveLightQueue::addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint32_t lightPassIdx) { const auto batchingScheme = pass->getBatchingScheme(); if (batchingScheme == scene::BatchingSchemes::INSTANCING) { // instancing for (const auto idx : _lightIndices) { @@ -250,7 +250,7 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm if (validLightCount > _lightBufferCount) { _firstLightBufferView->destroy(); - _lightBufferCount = nextPow2(static_cast(validLightCount)); + _lightBufferCount = nextPow2(static_cast(validLightCount)); _lightBuffer->resize(utils::toUint(_lightBufferStride * _lightBufferCount)); _lightBufferData.resize(static_cast(_lightBufferElementCount) * _lightBufferCount); _firstLightBufferView->initialize({_lightBuffer, 0, UBOForwardLight::SIZE}); @@ -318,7 +318,7 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm } } - cmdBuffer->updateBuffer(_lightBuffer, _lightBufferData.data(), static_cast(_lightBufferData.size() * sizeof(float))); + cmdBuffer->updateBuffer(_lightBuffer, _lightBufferData.data(), static_cast(_lightBufferData.size() * sizeof(float))); } void RenderAdditiveLightQueue::updateLightDescriptorSet(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer) { @@ -331,7 +331,7 @@ void RenderAdditiveLightQueue::updateLightDescriptorSet(const scene::Camera *cam const float packing = hFTexture ? 0.0F : 1.0F; const scene::Light *mainLight = scene->getMainLight(); - for (uint i = 0; i < _validPunctualLights.size(); ++i) { + for (uint32_t i = 0; i < _validPunctualLights.size(); ++i) { const auto *light = _validPunctualLights[i]; auto *descriptorSet = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(i); if (!descriptorSet) { @@ -419,7 +419,7 @@ void RenderAdditiveLightQueue::updateLightDescriptorSet(const scene::Camera *cam } } -bool RenderAdditiveLightQueue::getLightPassIndex(const scene::Model *model, ccstd::vector *lightPassIndices) const { +bool RenderAdditiveLightQueue::getLightPassIndex(const scene::Model *model, ccstd::vector *lightPassIndices) const { lightPassIndices->clear(); bool hasValidLightPass = false; diff --git a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h index 57711e0abc..f15d2cd4a4 100644 --- a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h +++ b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h @@ -47,8 +47,8 @@ struct AdditiveLightPass { const scene::SubModel *subModel = nullptr; const scene::Pass *pass = nullptr; gfx::Shader *shader = nullptr; - ccstd::vector dynamicOffsets; - ccstd::vector lights; + ccstd::vector dynamicOffsets; + ccstd::vector lights; }; class RenderAdditiveLightQueue final { @@ -65,21 +65,21 @@ private: static bool isInstancedOrBatched(const scene::Model *model); void clear(); - void addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint lightPassIdx); + void addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint32_t lightPassIdx); void updateUBOs(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer); void updateLightDescriptorSet(const scene::Camera *camera, gfx::CommandBuffer *cmdBuffer); - bool getLightPassIndex(const scene::Model *model, ccstd::vector *lightPassIndices) const; + bool getLightPassIndex(const scene::Model *model, ccstd::vector *lightPassIndices) const; void lightCulling(const scene::Model *model); RenderPipeline *_pipeline = nullptr; ccstd::vector> _sortedSubModelsArray; - ccstd::vector> _sortedPSOCIArray; + ccstd::vector> _sortedPSOCIArray; ccstd::vector _validPunctualLights; - ccstd::vector _lightIndices; + ccstd::vector _lightIndices; ccstd::vector _lightPasses; - ccstd::vector _lightInstancedPasses; - ccstd::vector _lightBatchedPasses; - ccstd::vector _dynamicOffsets; + ccstd::vector _lightInstancedPasses; + ccstd::vector _lightBatchedPasses; + ccstd::vector _dynamicOffsets; ccstd::vector _lightBufferData; RenderInstancedQueue *_instancedQueue = nullptr; RenderBatchedQueue *_batchedQueue = nullptr; @@ -88,11 +88,11 @@ private: ccstd::array _shadowUBO{}; - uint _lightBufferStride = 0; - uint _lightBufferElementCount = 0; - uint _lightBufferCount = 16; + uint32_t _lightBufferStride = 0; + uint32_t _lightBufferElementCount = 0; + uint32_t _lightBufferCount = 16; float _lightMeterScale = 10000.0F; - uint _phaseID = 0; + uint32_t _phaseID = 0; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/RenderBatchedQueue.cpp b/native/cocos/renderer/pipeline/RenderBatchedQueue.cpp index d2866a3ce6..7b2f6b24f6 100644 --- a/native/cocos/renderer/pipeline/RenderBatchedQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderBatchedQueue.cpp @@ -57,7 +57,7 @@ void RenderBatchedQueue::uploadBuffers(gfx::CommandBuffer *cmdBuffer) { } } -void RenderBatchedQueue::recordCommandBuffer(gfx::Device * /*device*/, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer, gfx::DescriptorSet *ds, uint offset) { +void RenderBatchedQueue::recordCommandBuffer(gfx::Device * /*device*/, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer, gfx::DescriptorSet *ds, uint32_t offset) { for (const auto *batchedBuffer : _queues) { bool boundPSO = false; const auto &batches = batchedBuffer->getBatches(); diff --git a/native/cocos/renderer/pipeline/RenderBatchedQueue.h b/native/cocos/renderer/pipeline/RenderBatchedQueue.h index 3764e21d8e..591653e588 100644 --- a/native/cocos/renderer/pipeline/RenderBatchedQueue.h +++ b/native/cocos/renderer/pipeline/RenderBatchedQueue.h @@ -47,7 +47,7 @@ public: void clear(); void uploadBuffers(gfx::CommandBuffer *cmdBuff); - void recordCommandBuffer(gfx::Device *, gfx::RenderPass *, gfx::CommandBuffer *, gfx::DescriptorSet *ds = nullptr, uint offset = 0); + void recordCommandBuffer(gfx::Device *, gfx::RenderPass *, gfx::CommandBuffer *, gfx::DescriptorSet *ds = nullptr, uint32_t offset = 0); void add(BatchedBuffer *batchedBuffer); bool empty() const { return _queues.empty(); } diff --git a/native/cocos/renderer/pipeline/RenderFlow.h b/native/cocos/renderer/pipeline/RenderFlow.h index 9860d76c42..cca62f0029 100644 --- a/native/cocos/renderer/pipeline/RenderFlow.h +++ b/native/cocos/renderer/pipeline/RenderFlow.h @@ -38,8 +38,8 @@ class RenderStage; struct CC_DLL RenderFlowInfo { ccstd::string name; - uint priority = 0; - uint tag = 0; + uint32_t priority = 0; + uint32_t tag = 0; RenderStageList stages; }; @@ -54,16 +54,16 @@ public: virtual void destroy(); inline const ccstd::string &getName() const { return _name; } - inline uint getPriority() const { return _priority; } - inline uint getTag() const { return _tag; } + inline uint32_t getPriority() const { return _priority; } + inline uint32_t getTag() const { return _tag; } RenderStage *getRenderstageByName(const ccstd::string &name) const; protected: RenderStageList _stages; ccstd::string _name; RenderPipeline *_pipeline = nullptr; - uint _priority = 0; - uint _tag = 0; + uint32_t _priority = 0; + uint32_t _tag = 0; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/RenderInstancedQueue.cpp b/native/cocos/renderer/pipeline/RenderInstancedQueue.cpp index 83cb0881d9..b89799a342 100644 --- a/native/cocos/renderer/pipeline/RenderInstancedQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderInstancedQueue.cpp @@ -49,7 +49,7 @@ void RenderInstancedQueue::uploadBuffers(gfx::CommandBuffer *cmdBuffer) { } } -void RenderInstancedQueue::recordCommandBuffer(gfx::Device * /*device*/, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer, gfx::DescriptorSet *ds, uint offset) { +void RenderInstancedQueue::recordCommandBuffer(gfx::Device * /*device*/, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer, gfx::DescriptorSet *ds, uint32_t offset) { for (const auto *instanceBuffer : _queues) { if (!instanceBuffer->hasPendingModels()) continue; diff --git a/native/cocos/renderer/pipeline/RenderInstancedQueue.h b/native/cocos/renderer/pipeline/RenderInstancedQueue.h index 1574cd5949..cccfcde29c 100644 --- a/native/cocos/renderer/pipeline/RenderInstancedQueue.h +++ b/native/cocos/renderer/pipeline/RenderInstancedQueue.h @@ -47,7 +47,7 @@ public: RenderInstancedQueue() = default; ~RenderInstancedQueue() = default; - void recordCommandBuffer(gfx::Device *device, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer, gfx::DescriptorSet *ds = nullptr, uint offset = 0); + void recordCommandBuffer(gfx::Device *device, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuffer, gfx::DescriptorSet *ds = nullptr, uint32_t offset = 0); void add(InstancedBuffer *instancedBuffer); void uploadBuffers(gfx::CommandBuffer *cmdBuffer); void clear(); diff --git a/native/cocos/renderer/pipeline/RenderPipeline.cpp b/native/cocos/renderer/pipeline/RenderPipeline.cpp index 61d41c2fda..dadc13790e 100644 --- a/native/cocos/renderer/pipeline/RenderPipeline.cpp +++ b/native/cocos/renderer/pipeline/RenderPipeline.cpp @@ -215,8 +215,8 @@ gfx::InputAssembler *RenderPipeline::getIAByRenderArea(const gfx::Rect &renderAr bool RenderPipeline::createQuadInputAssembler(gfx::Buffer *quadIB, gfx::Buffer **quadVB, gfx::InputAssembler **quadIA) { // step 1 create vertex buffer - uint vbStride = sizeof(float) * 4; - uint vbSize = vbStride * 4; + uint32_t vbStride = sizeof(float) * 4; + uint32_t vbSize = vbStride * 4; if (*quadVB == nullptr) { *quadVB = _device->createBuffer({gfx::BufferUsageBit::VERTEX | gfx::BufferUsageBit::TRANSFER_DST, @@ -246,8 +246,8 @@ gfx::Viewport RenderPipeline::getViewport(scene::Camera *camera) { return { static_cast(static_cast(rect.x) * scale), static_cast(static_cast(rect.y) * scale), - static_cast(static_cast(rect.width) * scale), - static_cast(static_cast(rect.height) * scale)}; + static_cast(static_cast(rect.width) * scale), + static_cast(static_cast(rect.height) * scale)}; } gfx::Rect RenderPipeline::getScissor(scene::Camera *camera) { @@ -256,8 +256,8 @@ gfx::Rect RenderPipeline::getScissor(scene::Camera *camera) { return { static_cast(static_cast(rect.x) * scale), static_cast(static_cast(rect.y) * scale), - static_cast(static_cast(rect.width) * scale), - static_cast(static_cast(rect.height) * scale)}; + static_cast(static_cast(rect.width) * scale), + static_cast(static_cast(rect.height) * scale)}; } gfx::Rect RenderPipeline::getRenderArea(scene::Camera *camera) { diff --git a/native/cocos/renderer/pipeline/RenderPipeline.h b/native/cocos/renderer/pipeline/RenderPipeline.h index d809631a9b..1d0680f72a 100644 --- a/native/cocos/renderer/pipeline/RenderPipeline.h +++ b/native/cocos/renderer/pipeline/RenderPipeline.h @@ -52,7 +52,7 @@ class GlobalDSManager; class RenderStage; class GeometryRenderer; struct CC_DLL RenderPipelineInfo { - uint tag = 0; + uint32_t tag = 0; RenderFlowList flows; }; @@ -76,7 +76,7 @@ public: virtual void onGlobalPipelineStateChanged(); inline const RenderFlowList &getFlows() const { return _flows; } - inline uint getTag() const { return _tag; } + inline uint32_t getTag() const { return _tag; } inline const ccstd::unordered_map &getGlobalBindings() const { return _globalBindings; } inline const MacroRecord &getMacros() const { return _macros; } inline void setValue(const ccstd::string &name, int32_t value) { _macros[name] = value; } @@ -100,8 +100,8 @@ public: gfx::Viewport getViewport(scene::Camera *camera); gfx::Rect getScissor(scene::Camera *camera); void genQuadVertexData(const Vec4 &viewport, float *data); - uint getWidth() const { return _width; } - uint getHeight() const { return _height; } + uint32_t getWidth() const { return _width; } + uint32_t getHeight() const { return _height; } framegraph::FrameGraph &getFrameGraph() { return _fg; } gfx::Color getClearcolor(scene::Camera *camera) const; gfx::InputAssembler *getIAByRenderArea(const gfx::Rect &renderArea); @@ -138,7 +138,7 @@ protected: RenderFlowList _flows; ccstd::unordered_map _globalBindings; MacroRecord _macros; - uint _tag = 0; + uint32_t _tag = 0; ccstd::string _constantMacros; gfx::Device *_device{nullptr}; @@ -151,8 +151,8 @@ protected: // has not initBuiltinRes, // create temporary default Texture to binding sampler2d - uint _width{0}; - uint _height{0}; + uint32_t _width{0}; + uint32_t _height{0}; gfx::Buffer *_quadIB{nullptr}; ccstd::vector _quadVB; ccstd::unordered_map> _quadIA; diff --git a/native/cocos/renderer/pipeline/RenderQueue.cpp b/native/cocos/renderer/pipeline/RenderQueue.cpp index 76d0382956..3c9552a54a 100644 --- a/native/cocos/renderer/pipeline/RenderQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderQueue.cpp @@ -47,7 +47,7 @@ void RenderQueue::clear() { _queue.clear(); } -bool RenderQueue::insertRenderPass(const RenderObject &renderObj, uint subModelIdx, uint passIdx) { +bool RenderQueue::insertRenderPass(const RenderObject &renderObj, uint32_t subModelIdx, uint32_t passIdx) { const auto *subModel = renderObj.model->getSubModels()[subModelIdx].get(); const auto *const pass = subModel->getPass(passIdx); const bool isTransparent = pass->getBlendState()->targets[0].blend; diff --git a/native/cocos/renderer/pipeline/RenderQueue.h b/native/cocos/renderer/pipeline/RenderQueue.h index 5082c0f6e7..b8c93ca1f5 100644 --- a/native/cocos/renderer/pipeline/RenderQueue.h +++ b/native/cocos/renderer/pipeline/RenderQueue.h @@ -40,7 +40,7 @@ public: explicit RenderQueue(RenderPipeline *pipeline, RenderQueueCreateInfo desc, bool useOcclusionQuery = false); void clear(); - bool insertRenderPass(const RenderObject &renderObj, uint subModelIdx, uint passIdx); + bool insertRenderPass(const RenderObject &renderObj, uint32_t subModelIdx, uint32_t passIdx); void recordCommandBuffer(gfx::Device *device, scene::Camera *camera, gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuff, uint32_t subpassIndex = 0); void sort(); bool empty() { return _queue.empty(); } diff --git a/native/cocos/renderer/pipeline/RenderStage.h b/native/cocos/renderer/pipeline/RenderStage.h index 3213330e20..a6dcc136a6 100644 --- a/native/cocos/renderer/pipeline/RenderStage.h +++ b/native/cocos/renderer/pipeline/RenderStage.h @@ -43,8 +43,8 @@ class RenderQueue; struct CC_DLL RenderStageInfo { ccstd::string name; - uint priority = 0; - uint tag = 0; + uint32_t priority = 0; + uint32_t tag = 0; RenderQueueDescList renderQueues; }; @@ -60,8 +60,8 @@ public: virtual void render(scene::Camera *camera) = 0; inline const ccstd::string &getName() const { return _name; } - inline uint getPriority() const { return _priority; } - inline uint getTag() const { return _tag; } + inline uint32_t getPriority() const { return _priority; } + inline uint32_t getTag() const { return _tag; } inline RenderFlow *getFlow() const { return _flow; } protected: @@ -74,8 +74,8 @@ protected: RenderFlow *_flow = nullptr; gfx::Device *_device = nullptr; ccstd::string _name; - uint _priority = 0; - uint _tag = 0; + uint32_t _priority = 0; + uint32_t _tag = 0; gfx::ColorList _clearColors = {{0.0F, 0.0F, 0.0F, 0.0F}, {0.0F, 0.0F, 0.0F, 0.0F}, {0.0F, 0.0F, 0.0F, 0.0F}, {0.0F, 0.0F, 0.0F, 0.0F}}; }; diff --git a/native/cocos/renderer/pipeline/SceneCulling.cpp b/native/cocos/renderer/pipeline/SceneCulling.cpp index 40d736ba27..e2b0c54989 100644 --- a/native/cocos/renderer/pipeline/SceneCulling.cpp +++ b/native/cocos/renderer/pipeline/SceneCulling.cpp @@ -218,8 +218,8 @@ void shadowCulling(const RenderPipeline* pipeline, const scene::Camera* camera, const bool accurate = model->getWorldBounds()->aabbFrustum(layer->getValidFrustum()); if (accurate) { layer->addShadowObject(genRenderObject(model, camera)); - if (layer->getLevel() < static_cast(mainLight->getCSMLevel())) { - if (static_cast(mainLight->getCSMOptimizationMode()) == 2 && + if (layer->getLevel() < static_cast(mainLight->getCSMLevel())) { + if (static_cast(mainLight->getCSMOptimizationMode()) == 2 && aabbFrustumCompletelyInside(*model->getWorldBounds(), layer->getValidFrustum())) { csmLayers->getLayerObjects().erase(csmLayers->getLayerObjects().begin() + static_cast(i)); i--; diff --git a/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp b/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp index 81ef180e2c..945ed90267 100644 --- a/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp +++ b/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp @@ -54,7 +54,7 @@ ShadowMapBatchedQueue::ShadowMapBatchedQueue(RenderPipeline *pipeline) ShadowMapBatchedQueue::~ShadowMapBatchedQueue() = default; -void ShadowMapBatchedQueue::gatherLightPasses(const scene::Camera *camera, const scene::Light *light, gfx::CommandBuffer *cmdBuffer, uint level) { +void ShadowMapBatchedQueue::gatherLightPasses(const scene::Camera *camera, const scene::Light *light, gfx::CommandBuffer *cmdBuffer, uint32_t level) { clear(); const PipelineSceneData *sceneData = _pipeline->getPipelineSceneData(); diff --git a/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.h b/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.h index ba2d8a2d1a..0360271858 100644 --- a/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.h +++ b/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.h @@ -38,7 +38,7 @@ class RenderInstancedQueue; class RenderBatchedQueue; class RenderPipeline; -//const uint phaseID(PassPhase::getPhaseID("shadow-caster")); +//const uint32_t phaseID(PassPhase::getPhaseID("shadow-caster")); class CC_DLL ShadowMapBatchedQueue final { public: @@ -47,7 +47,7 @@ public: void destroy(); void clear(); - void gatherLightPasses(const scene::Camera *, const scene::Light *, gfx::CommandBuffer *, uint level = 0); + void gatherLightPasses(const scene::Camera *, const scene::Light *, gfx::CommandBuffer *, uint32_t level = 0); void add(const scene::Model *); void recordCommandBuffer(gfx::Device *, gfx::RenderPass *, gfx::CommandBuffer *) const; @@ -60,7 +60,7 @@ private: ccstd::vector _shaders; RenderInstancedQueue *_instancedQueue = nullptr; RenderBatchedQueue *_batchedQueue = nullptr; - uint _phaseID = 0; + uint32_t _phaseID = 0; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/UIPhase.h b/native/cocos/renderer/pipeline/UIPhase.h index 769d4a3a5a..a33a90c16e 100644 --- a/native/cocos/renderer/pipeline/UIPhase.h +++ b/native/cocos/renderer/pipeline/UIPhase.h @@ -45,7 +45,7 @@ public: protected: RenderPipeline *_pipeline = nullptr; - uint _phaseID = 0; + uint32_t _phaseID = 0; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/custom/NativePipelineImpl.cpp b/native/cocos/renderer/pipeline/custom/NativePipelineImpl.cpp index 51e426baa4..e9a530509f 100644 --- a/native/cocos/renderer/pipeline/custom/NativePipelineImpl.cpp +++ b/native/cocos/renderer/pipeline/custom/NativePipelineImpl.cpp @@ -370,8 +370,8 @@ void NativePipeline::render(const ccstd::vector &cameras) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = sceneData->isHDR() ? gfx::Format::RGBA16F : gfx::Format::RGBA8; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT; - colorTexInfo.width = static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale); - colorTexInfo.height = static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale); + colorTexInfo.width = static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale); if (shadingScale != 1.F) { colorTexInfo.usage |= gfx::TextureUsageBit::TRANSFER_SRC; } @@ -405,8 +405,8 @@ void NativePipeline::render(const ccstd::vector &cameras) { return gfx::Viewport{ static_cast(static_cast(rect.x) * shadingScale), static_cast(static_cast(rect.y) * shadingScale), - static_cast(static_cast(rect.width) * shadingScale), - static_cast(static_cast(rect.height) * shadingScale)}; + static_cast(static_cast(rect.width) * shadingScale), + static_cast(static_cast(rect.height) * shadingScale)}; }; auto getScissor = [&shadingScale, &getRenderArea](const scene::Camera *camera) { @@ -414,8 +414,8 @@ void NativePipeline::render(const ccstd::vector &cameras) { return gfx::Rect{ static_cast(static_cast(rect.x) * shadingScale), static_cast(static_cast(rect.y) * shadingScale), - static_cast(static_cast(rect.width) * shadingScale), - static_cast(static_cast(rect.height) * shadingScale)}; + static_cast(static_cast(rect.width) * shadingScale), + static_cast(static_cast(rect.height) * shadingScale)}; }; builder.setViewport(getViewport(camera), getScissor(camera)); @@ -429,7 +429,7 @@ void NativePipeline::render(const ccstd::vector &cameras) { auto passHandle = framegraph::FrameGraph::stringToHandle("forwardPass"); frameGraph.addPass( - static_cast(ForwardInsertPoint::IP_FORWARD), + static_cast(ForwardInsertPoint::IP_FORWARD), passHandle, forwardSetup, forwardExec); frameGraph.presentFromBlackboard(colorHandle, diff --git a/native/cocos/renderer/pipeline/deferred/BloomStage.cpp b/native/cocos/renderer/pipeline/deferred/BloomStage.cpp index e51637911e..7e718496f6 100644 --- a/native/cocos/renderer/pipeline/deferred/BloomStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/BloomStage.cpp @@ -84,7 +84,7 @@ void initStrHandle() { RenderStageInfo BloomStage::initInfo = { BLOOM_STAGE_NAME, - static_cast(DeferredStagePriority::BLOOM), + static_cast(DeferredStagePriority::BLOOM), 0, {{true, RenderQueueSortMode::BACK_TO_FRONT, {"default"}}}, }; @@ -153,7 +153,7 @@ void BloomStage::render(scene::Camera *camera) { colorAttachmentInfo.clearColor = _clearColors[0]; colorAttachmentInfo.endAccesses = gfx::AccessFlagBit::FRAGMENT_SHADER_READ_TEXTURE; - uint insertPoint = static_cast(CommonInsertPoint::DIP_BLOOM); + auto insertPoint = static_cast(CommonInsertPoint::DIP_BLOOM); // prefilter pass struct PrefilterRenderData { @@ -184,8 +184,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); - colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); data.inputTexHandle = builder.create( RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); @@ -200,8 +200,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); - colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); + colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); + colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); data.outputTexHandle = builder.create(prefilterTexHandle, colorTexInfo); } @@ -218,7 +218,7 @@ void BloomStage::render(scene::Camera *camera) { gfx::RenderPass *renderPass = table.getRenderPass(); auto *cmdBf = pipeline->getCommandBuffers()[0]; - const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBf->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); auto *sceneData = static_cast(pipeline->getPipelineSceneData()); @@ -277,8 +277,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); - colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); + colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); + colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); data.outputTexHandle = builder.create(downsampleTexHandles[data.index], colorTexInfo); } @@ -287,8 +287,8 @@ void BloomStage::render(scene::Camera *camera) { // Update cc_textureSize data.bloomUBO = stage->getDownsampleUBO()[data.index]; - data.textureSize[0] = static_cast(static_cast(static_cast(_renderArea.width) * shadingScale) << 1); - data.textureSize[1] = static_cast(static_cast(static_cast(_renderArea.height) * shadingScale) << 1); + data.textureSize[0] = static_cast(static_cast(static_cast(_renderArea.width) * shadingScale) << 1); + data.textureSize[1] = static_cast(static_cast(static_cast(_renderArea.height) * shadingScale) << 1); }; auto downsampleExec = [this, camera](ScalingSampleRenderData const &data, const framegraph::DevicePassResourceTable &table) { @@ -296,7 +296,7 @@ void BloomStage::render(scene::Camera *camera) { gfx::RenderPass *renderPass = table.getRenderPass(); auto *cmdBf = pipeline->getCommandBuffers()[0]; - const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBf->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); auto *const sceneData = static_cast(pipeline->getPipelineSceneData()); @@ -348,8 +348,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); - colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); + colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); + colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); data.outputTexHandle = builder.create( upsampleTexHandles[data.index], colorTexInfo); @@ -359,8 +359,8 @@ void BloomStage::render(scene::Camera *camera) { // Update cc_textureSize data.bloomUBO = stage->getUpsampleUBO()[data.index]; - data.textureSize[0] = static_cast(static_cast(static_cast(_renderArea.width) * shadingScale) >> 1); - data.textureSize[1] = static_cast(static_cast(static_cast(_renderArea.height) * shadingScale) >> 1); + data.textureSize[0] = static_cast(static_cast(static_cast(_renderArea.width) * shadingScale) >> 1); + data.textureSize[1] = static_cast(static_cast(static_cast(_renderArea.height) * shadingScale) >> 1); }; auto upsampleExec = [this, camera](ScalingSampleRenderData const &data, const framegraph::DevicePassResourceTable &table) { @@ -368,7 +368,7 @@ void BloomStage::render(scene::Camera *camera) { gfx::RenderPass *renderPass = table.getRenderPass(); auto *cmdBf = pipeline->getCommandBuffers()[0]; - const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBf->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); auto *const sceneData = static_cast(pipeline->getPipelineSceneData()); @@ -426,8 +426,8 @@ void BloomStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); - colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); + colorTexInfo.width = static_cast(static_cast(_renderArea.width) * shadingScale); + colorTexInfo.height = static_cast(static_cast(_renderArea.height) * shadingScale); data.bloomOutTexHandle = builder.create( RenderPipeline::fgStrHandleBloomOutTexture, colorTexInfo); @@ -445,7 +445,7 @@ void BloomStage::render(scene::Camera *camera) { gfx::RenderPass *renderPass = table.getRenderPass(); auto *cmdBf = pipeline->getCommandBuffers()[0]; - const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBf->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); auto *const sceneData = static_cast(pipeline->getPipelineSceneData()); diff --git a/native/cocos/renderer/pipeline/deferred/BloomStage.h b/native/cocos/renderer/pipeline/deferred/BloomStage.h index de53ce5944..20f4bb2ea6 100644 --- a/native/cocos/renderer/pipeline/deferred/BloomStage.h +++ b/native/cocos/renderer/pipeline/deferred/BloomStage.h @@ -36,9 +36,9 @@ namespace cc { namespace pipeline { struct CC_DLL UBOBloom { - static constexpr uint TEXTURE_SIZE_OFFSET = 0; - static constexpr uint COUNT = UBOBloom::TEXTURE_SIZE_OFFSET + 4; - static constexpr uint SIZE = UBOBloom::COUNT * 4; + static constexpr uint32_t TEXTURE_SIZE_OFFSET = 0; + static constexpr uint32_t COUNT = UBOBloom::TEXTURE_SIZE_OFFSET + 4; + static constexpr uint32_t SIZE = UBOBloom::COUNT * 4; }; class CC_DLL BloomStage : public RenderStage { @@ -70,7 +70,7 @@ public: } private: - uint _phaseID = 0; + uint32_t _phaseID = 0; static RenderStageInfo initInfo; diff --git a/native/cocos/renderer/pipeline/deferred/DeferredPipeline.cpp b/native/cocos/renderer/pipeline/deferred/DeferredPipeline.cpp index 816216fd0a..9e941c0b4d 100644 --- a/native/cocos/renderer/pipeline/deferred/DeferredPipeline.cpp +++ b/native/cocos/renderer/pipeline/deferred/DeferredPipeline.cpp @@ -172,8 +172,8 @@ bool DeferredPipeline::activeRenderer(gfx::Swapchain *swapchain) { _macros["CC_SUPPORT_FLOAT_TEXTURE"] = hasAnyFlags(_device->getFormatFeatures(gfx::Format::RGBA32F), gfx::FormatFeature::RENDER_TARGET | gfx::FormatFeature::SAMPLED_TEXTURE); // step 2 create index buffer - uint ibStride = 4; - uint ibSize = ibStride * 6; + uint32_t ibStride = 4; + uint32_t ibSize = ibStride * 6; if (_quadIB == nullptr) { _quadIB = _device->createBuffer({gfx::BufferUsageBit::INDEX | gfx::BufferUsageBit::TRANSFER_DST, gfx::MemoryUsageBit::DEVICE, ibSize, ibStride}); diff --git a/native/cocos/renderer/pipeline/deferred/DeferredPipeline.h b/native/cocos/renderer/pipeline/deferred/DeferredPipeline.h index e172cdb8ec..2bfef01684 100644 --- a/native/cocos/renderer/pipeline/deferred/DeferredPipeline.h +++ b/native/cocos/renderer/pipeline/deferred/DeferredPipeline.h @@ -68,7 +68,7 @@ private: ClusterLightCulling *_clusterComp{nullptr}; public: - static constexpr uint GBUFFER_COUNT = 3; + static constexpr uint32_t GBUFFER_COUNT = 3; // deferred resource names static framegraph::StringHandle fgStrHandleGbufferTexture[GBUFFER_COUNT]; diff --git a/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp b/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp index 75e1dddbe9..f01e2947fe 100644 --- a/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/GbufferStage.cpp @@ -45,8 +45,8 @@ namespace cc { namespace pipeline { RenderStageInfo GbufferStage::initInfo = { "GbufferStage", - static_cast(DeferredStagePriority::GBUFFER), - static_cast(RenderFlowTag::SCENE), + static_cast(DeferredStagePriority::GBUFFER), + static_cast(RenderFlowTag::SCENE), {{false, RenderQueueSortMode::FRONT_TO_BACK, {"default"}}, {true, RenderQueueSortMode::BACK_TO_FRONT, {"default", "planarShadow"}}}}; const RenderStageInfo &GbufferStage::getInitializeInfo() { return GbufferStage::initInfo; } @@ -69,7 +69,7 @@ void GbufferStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { RenderStage::activate(pipeline, flow); for (const auto &descriptor : _renderQueueDescriptors) { - uint phase = convertPhase(descriptor.stages); + uint32_t phase = convertPhase(descriptor.stages); RenderQueueSortFunc sortFunc = convertQueueSortFunc(descriptor.sortMode); RenderQueueCreateInfo info = {descriptor.isTransparent, phase, sortFunc}; _renderQueues.emplace_back(ccnew RenderQueue(_pipeline, std::move(info), true)); @@ -93,8 +93,8 @@ void GbufferStage::dispenseRenderObject2Queues() { queue->clear(); } - uint subModelIdx = 0; - uint passIdx = 0; + uint32_t subModelIdx = 0; + uint32_t passIdx = 0; size_t k = 0; for (auto ro : renderObjects) { const auto *const model = ro.model; @@ -132,7 +132,7 @@ void GbufferStage::recordCommands(DeferredPipeline *pipeline, scene::Camera *cam auto *cmdBuff = pipeline->getCommandBuffers()[0]; // DescriptorSet bindings - const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBuff->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); // record commands @@ -160,15 +160,15 @@ void GbufferStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::INPUT_ATTACHMENT, gfx::Format::RGBA8, - static_cast(static_cast(pipeline->getWidth()) * shadingScale), - static_cast(static_cast(pipeline->getHeight()) * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; gfx::TextureInfo gbufferInfoFloat = { gfx::TextureType::TEX2D, gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::INPUT_ATTACHMENT, gfx::Format::RGBA16F, - static_cast(static_cast(pipeline->getWidth()) * shadingScale), - static_cast(static_cast(pipeline->getHeight()) * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; for (int i = 0; i < DeferredPipeline::GBUFFER_COUNT - 1; ++i) { if (i != 0) { // normals need more precision @@ -204,8 +204,8 @@ void GbufferStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT | gfx::TextureUsageBit::SAMPLED, gfx::Format::DEPTH_STENCIL, - static_cast(static_cast(pipeline->getWidth()) * shadingScale), - static_cast(static_cast(pipeline->getHeight()) * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; depthTexInfo.usage |= gfx::TextureUsageBit::INPUT_ATTACHMENT; @@ -238,7 +238,7 @@ void GbufferStage::render(scene::Camera *camera) { // if empty == true, gbuffer and lightig passes will be ignored bool empty = _renderQueues[0]->empty() && _instancedQueue->empty() && _batchedQueue->empty(); if (!empty) { - pipeline->getFrameGraph().addPass(static_cast(DeferredInsertPoint::DIP_GBUFFER), DeferredPipeline::fgStrHandleGbufferPass, gbufferSetup, gbufferExec); + pipeline->getFrameGraph().addPass(static_cast(DeferredInsertPoint::DIP_GBUFFER), DeferredPipeline::fgStrHandleGbufferPass, gbufferSetup, gbufferExec); } } } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/deferred/GbufferStage.h b/native/cocos/renderer/pipeline/deferred/GbufferStage.h index 11b57f974e..fd3a737518 100644 --- a/native/cocos/renderer/pipeline/deferred/GbufferStage.h +++ b/native/cocos/renderer/pipeline/deferred/GbufferStage.h @@ -62,7 +62,7 @@ private: PlanarShadowQueue *_planarShadowQueue = nullptr; RenderBatchedQueue *_batchedQueue = nullptr; RenderInstancedQueue *_instancedQueue = nullptr; - uint _phaseID = 0; + uint32_t _phaseID = 0; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/deferred/LightingStage.cpp b/native/cocos/renderer/pipeline/deferred/LightingStage.cpp index 1e1233081b..ba9af779a3 100644 --- a/native/cocos/renderer/pipeline/deferred/LightingStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/LightingStage.cpp @@ -52,7 +52,7 @@ namespace pipeline { namespace { const ccstd::string STAGE_NAME = "LightingStage"; -const uint MAX_REFLECTOR_SIZE = 5; +const uint32_t MAX_REFLECTOR_SIZE = 5; framegraph::StringHandle reflectTexHandle = framegraph::FrameGraph::stringToHandle("reflectionTex"); framegraph::StringHandle denoiseTexHandle[MAX_REFLECTOR_SIZE]; framegraph::StringHandle ssprClearPass[MAX_REFLECTOR_SIZE]; @@ -87,8 +87,8 @@ void initStrHandle() { RenderStageInfo LightingStage::initInfo = { STAGE_NAME, - static_cast(DeferredStagePriority::LIGHTING), - static_cast(RenderFlowTag::SCENE), + static_cast(DeferredStagePriority::LIGHTING), + static_cast(RenderFlowTag::SCENE), }; const RenderStageInfo &LightingStage::getInitializeInfo() { return LightingStage::initInfo; } @@ -119,10 +119,10 @@ void LightingStage::gatherLights(scene::Camera *camera) { geometry::Sphere sphere; auto exposure = camera->getExposure(); - uint idx = 0; + uint32_t idx = 0; int elementLen = sizeof(cc::Vec4) / sizeof(float); - uint fieldLen = elementLen * _maxDeferredLights; - uint offset = 0; + uint32_t fieldLen = elementLen * _maxDeferredLights; + uint32_t offset = 0; cc::Vec4 tmpArray; for (const auto &light : scene->getSphereLights()) { @@ -239,8 +239,8 @@ void LightingStage::initLightingBuffer() { auto *const device = _pipeline->getDevice(); // color/pos/dir/angle 都是vec4存储, 最后一个vec4只要x存储光源个数 - uint stride = utils::alignTo(sizeof(Vec4) * 4, device->getCapabilities().uboOffsetAlignment); - uint totalSize = stride * _maxDeferredLights; + auto stride = utils::alignTo(sizeof(Vec4) * 4, device->getCapabilities().uboOffsetAlignment); + uint32_t totalSize = stride * _maxDeferredLights; // create lighting buffer and view if (_deferredLitsBufs == nullptr) { @@ -256,7 +256,7 @@ void LightingStage::initLightingBuffer() { if (_deferredLitsBufView == nullptr) { gfx::BufferViewInfo bvInfo = {_deferredLitsBufs, 0, totalSize}; _deferredLitsBufView = device->createBuffer(bvInfo); - _descriptorSet->bindBuffer(static_cast(ModelLocalBindings::UBO_FORWARD_LIGHTS), _deferredLitsBufView); + _descriptorSet->bindBuffer(static_cast(ModelLocalBindings::UBO_FORWARD_LIGHTS), _deferredLitsBufView); } _lightBufferData.resize(totalSize / sizeof(float)); @@ -268,7 +268,7 @@ void LightingStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { auto *const device = pipeline->getDevice(); for (const auto &descriptor : _renderQueueDescriptors) { - uint phase = convertPhase(descriptor.stages); + uint32_t phase = convertPhase(descriptor.stages); RenderQueueSortFunc sortFunc = convertQueueSortFunc(descriptor.sortMode); RenderQueueCreateInfo info = {descriptor.isTransparent, phase, sortFunc}; _renderQueues.emplace_back(ccnew RenderQueue(_pipeline, std::move(info), true)); @@ -376,8 +376,8 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); - colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); data.outputTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); framegraph::RenderTargetAttachment::Descriptor colorAttachmentInfo; @@ -400,18 +400,18 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { // no need to bind localSet in cluster if (!_pipeline->isClusterEnabled()) { - ccstd::vector dynamicOffsets = {0}; + ccstd::vector dynamicOffsets = {0}; cmdBuff->bindDescriptorSet(localSet, _descriptorSet, dynamicOffsets); } - const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBuff->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); // get PSO and draw quad scene::Pass *pass = sceneData->getLightPass(); gfx::Shader *shader = sceneData->getLightPassShader(); gfx::PipelineState *pso = PipelineStateManager::getOrCreatePipelineState(pass, shader, _inputAssembler, table.getRenderPass(), table.getSubpassIndex()); - for (uint i = 0; i < DeferredPipeline::GBUFFER_COUNT; ++i) { + for (uint32_t i = 0; i < DeferredPipeline::GBUFFER_COUNT; ++i) { pass->getDescriptorSet()->bindTexture(i, table.getRead(data.gbuffer[i])); pass->getDescriptorSet()->bindSampler(i, _defaultSampler); } @@ -443,7 +443,7 @@ void LightingStage::fgLightingPass(scene::Camera *camera) { } }; - pipeline->getFrameGraph().addPass(static_cast(DeferredInsertPoint::DIP_LIGHTING), DeferredPipeline::fgStrHandleLightingPass, lightingSetup, lightingExec); + pipeline->getFrameGraph().addPass(static_cast(DeferredInsertPoint::DIP_LIGHTING), DeferredPipeline::fgStrHandleLightingPass, lightingSetup, lightingExec); } void LightingStage::fgTransparent(scene::Camera *camera) { @@ -469,8 +469,8 @@ void LightingStage::fgTransparent(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); - colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); colorAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; colorAttachmentInfo.clearColor = clearColor; @@ -493,8 +493,8 @@ void LightingStage::fgTransparent(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT, gfx::Format::DEPTH_STENCIL, - static_cast(static_cast(pipeline->getWidth()) * shadingScale), - static_cast(static_cast(pipeline->getHeight()) * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; data.depth = builder.create(DeferredPipeline::fgStrHandleOutDepthTexture, depthTexInfo); depthAttachmentInfo.loadOp = gfx::LoadOp::CLEAR; @@ -512,11 +512,11 @@ void LightingStage::fgTransparent(scene::Camera *camera) { // no need to bind localSet in cluster if (!_pipeline->isClusterEnabled()) { - ccstd::vector dynamicOffsets = {0}; + ccstd::vector dynamicOffsets = {0}; cmdBuff->bindDescriptorSet(localSet, _descriptorSet, dynamicOffsets); } - const ccstd::array globalOffsets = {pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBuff->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); // transparent @@ -530,7 +530,7 @@ void LightingStage::fgTransparent(scene::Camera *camera) { }; if (!_isTransparentQueueEmpty || !camera->getGeometryRenderer()->empty()) { - pipeline->getFrameGraph().addPass(static_cast(DeferredInsertPoint::DIP_TRANSPARENT), + pipeline->getFrameGraph().addPass(static_cast(DeferredInsertPoint::DIP_TRANSPARENT), DeferredPipeline::fgStrHandleTransparentPass, transparentSetup, transparentExec); } } @@ -543,8 +543,8 @@ void LightingStage::putTransparentObj2Queue() { auto *const sceneData = _pipeline->getPipelineSceneData(); const auto &renderObjects = sceneData->getRenderObjects(); _isTransparentQueueEmpty = true; - uint m = 0; - uint p = 0; + uint32_t m = 0; + uint32_t p = 0; size_t k = 0; for (auto ro : renderObjects) { m = 0; @@ -582,9 +582,9 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { _reflectionElems.clear(); // step 1 prepare clear model's reflection texture pass. should switch to image clear command after available - uint minSize = 512; - uint width = pipeline->getWidth(); - uint height = pipeline->getHeight(); + uint32_t minSize = 512; + uint32_t width = pipeline->getWidth(); + uint32_t height = pipeline->getHeight(); if (height < width) { _ssprTexWidth = minSize * width / height; _ssprTexHeight = minSize; @@ -741,7 +741,7 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { _reflectionComp->getDenoiseDescriptorSet()->bindSampler(0, _reflectionComp->getSampler()); if (useEnvmap) { - _reflectionComp->getDenoiseDescriptorSet()->bindTexture(1, pipeline->getDescriptorSet()->getTexture(static_cast(PipelineGlobalBindings::SAMPLER_ENVIRONMENT))); + _reflectionComp->getDenoiseDescriptorSet()->bindTexture(1, pipeline->getDescriptorSet()->getTexture(static_cast(PipelineGlobalBindings::SAMPLER_ENVIRONMENT))); _reflectionComp->getDenoiseDescriptorSet()->bindSampler(1, _reflectionComp->getSampler()); _reflectionComp->getDenoiseDescriptorSet()->bindTexture(2, depth); _reflectionComp->getDenoiseDescriptorSet()->bindSampler(2, _reflectionComp->getSampler()); @@ -817,8 +817,8 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { gfx::DescriptorSet *descLocal = elem.set; // sub model descriptor set auto *denoiseTex = static_cast(table.getRead(data.denoise)); - descLocal->bindTexture(static_cast(ModelLocalBindings::SAMPLER_REFLECTION), denoiseTex); - descLocal->bindSampler(static_cast(ModelLocalBindings::SAMPLER_REFLECTION), _defaultSampler); + descLocal->bindTexture(static_cast(ModelLocalBindings::SAMPLER_REFLECTION), denoiseTex); + descLocal->bindSampler(static_cast(ModelLocalBindings::SAMPLER_REFLECTION), _defaultSampler); descLocal->update(); cmdBuff->bindDescriptorSet(localSet, descLocal); @@ -833,8 +833,8 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { // step 5 add framegraph passes auto *const sceneData = _pipeline->getPipelineSceneData(); const auto &renderObjects = sceneData->getRenderObjects(); - uint m = 0; - uint p = 0; + uint32_t m = 0; + uint32_t p = 0; for (const auto &ro : renderObjects) { const auto *model = ro.model; const auto &subModels = model->getSubModels(); @@ -852,15 +852,15 @@ void LightingStage::fgSsprPass(scene::Camera *camera) { } } - uint insertPoint = static_cast(DeferredInsertPoint::DIP_SSPR); - for (uint i = 0; i < _reflectionElems.size(); ++i) { + auto insertPoint = static_cast(DeferredInsertPoint::DIP_SSPR); + for (uint32_t i = 0; i < _reflectionElems.size(); ++i) { // add clear and comp passes here pipeline->getFrameGraph().addPass(insertPoint++, ssprClearPass[i], clearSetup, clearExec); pipeline->getFrameGraph().addPass(insertPoint++, ssprCompReflectPass[i], compReflectSetup, compReflectExec); pipeline->getFrameGraph().addPass(insertPoint++, ssprCompDenoisePass[i], compDenoiseSetup, compDenoiseExec); } - for (uint i = 0; i < _reflectionElems.size(); ++i) { + for (uint32_t i = 0; i < _reflectionElems.size(); ++i) { // add graphic pass here pipeline->getFrameGraph().addPass(insertPoint++, ssprRenderPass[i], renderSetup, renderExec); } diff --git a/native/cocos/renderer/pipeline/deferred/LightingStage.h b/native/cocos/renderer/pipeline/deferred/LightingStage.h index db6ff689be..c6e22cf54d 100644 --- a/native/cocos/renderer/pipeline/deferred/LightingStage.h +++ b/native/cocos/renderer/pipeline/deferred/LightingStage.h @@ -43,8 +43,8 @@ class DeferredPipeline; struct RenderElem { RenderObject renderObject; gfx::DescriptorSet *set; - uint modelIndex; - uint passIndex; + uint32_t modelIndex; + uint32_t passIndex; }; class CC_DLL LightingStage : public RenderStage { @@ -70,31 +70,31 @@ private: static RenderStageInfo initInfo; PlanarShadowQueue *_planarShadowQueue{nullptr}; - uint _phaseID{0}; + uint32_t _phaseID{0}; gfx::Buffer *_deferredLitsBufs{nullptr}; gfx::Buffer *_deferredLitsBufView{nullptr}; ccstd::vector _lightBufferData; - uint _lightBufferStride{0}; - uint _lightBufferElementCount{0}; + uint32_t _lightBufferStride{0}; + uint32_t _lightBufferElementCount{0}; bool _isTransparentQueueEmpty{true}; float _lightMeterScale{10000.0}; gfx::DescriptorSet *_descriptorSet{nullptr}; gfx::DescriptorSetLayout *_descLayout{nullptr}; - uint _maxDeferredLights{UBODeferredLight::LIGHTS_PER_PASS}; + uint32_t _maxDeferredLights{UBODeferredLight::LIGHTS_PER_PASS}; ReflectionComp *_reflectionComp{nullptr}; RenderQueue *_reflectionRenderQueue{nullptr}; - uint _reflectionPhaseID{0}; + uint32_t _reflectionPhaseID{0}; ccstd::vector _reflectionElems; - uint _denoiseIndex = 0; // use to get corrrect texture string handle + uint32_t _denoiseIndex = 0; // use to get corrrect texture string handle gfx::Sampler *_defaultSampler{nullptr}; // SSPR texture size - uint _ssprTexWidth = 0; - uint _ssprTexHeight = 0; + uint32_t _ssprTexWidth = 0; + uint32_t _ssprTexHeight = 0; Mat4 _matViewProj; }; diff --git a/native/cocos/renderer/pipeline/deferred/MainFlow.cpp b/native/cocos/renderer/pipeline/deferred/MainFlow.cpp index 888b4928ca..7601e9710f 100644 --- a/native/cocos/renderer/pipeline/deferred/MainFlow.cpp +++ b/native/cocos/renderer/pipeline/deferred/MainFlow.cpp @@ -38,8 +38,8 @@ namespace cc { namespace pipeline { RenderFlowInfo MainFlow::initInfo = { "MainFlow", - static_cast(DeferredFlowPriority::MAIN), - static_cast(RenderFlowTag::SCENE), + static_cast(DeferredFlowPriority::MAIN), + static_cast(RenderFlowTag::SCENE), {}, }; const RenderFlowInfo &MainFlow::getInitializeInfo() { return MainFlow::initInfo; } diff --git a/native/cocos/renderer/pipeline/deferred/PostProcessStage.cpp b/native/cocos/renderer/pipeline/deferred/PostProcessStage.cpp index 6a9aa2defa..57e150dd7a 100644 --- a/native/cocos/renderer/pipeline/deferred/PostProcessStage.cpp +++ b/native/cocos/renderer/pipeline/deferred/PostProcessStage.cpp @@ -53,7 +53,7 @@ const ccstd::string STAGE_NAME = "PostProcessStage"; RenderStageInfo PostProcessStage::initInfo = { STAGE_NAME, - static_cast(DeferredStagePriority::POSTPROCESS), + static_cast(DeferredStagePriority::POSTPROCESS), 0, {{true, RenderQueueSortMode::BACK_TO_FRONT, {"default"}}}, }; @@ -76,7 +76,7 @@ void PostProcessStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { _phaseID = getPhaseID("default"); for (const auto &descriptor : _renderQueueDescriptors) { - uint phase = 0; + uint32_t phase = 0; for (const auto &stage : descriptor.stages) { phase |= getPhaseID(stage); } @@ -131,8 +131,8 @@ void PostProcessStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = gfx::Format::RGBA16F; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT | gfx::TextureUsageBit::SAMPLED; - colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); - colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); + colorTexInfo.width = static_cast(static_cast(pipeline->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(pipeline->getHeight()) * shadingScale); data.outColorTex = builder.create(RenderPipeline::fgStrHandleOutColorTexture, colorTexInfo); } @@ -163,8 +163,8 @@ void PostProcessStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::COLOR_ATTACHMENT, gfx::Format::RGBA8, - static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale), - static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale), + static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale), + static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale), }; if (shadingScale != 1.F) { textureInfo.usage |= gfx::TextureUsageBit::TRANSFER_SRC; @@ -185,8 +185,8 @@ void PostProcessStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT, gfx::Format::DEPTH_STENCIL, - static_cast(static_cast(pipeline->getWidth()) * shadingScale), - static_cast(static_cast(pipeline->getHeight()) * shadingScale), + static_cast(static_cast(pipeline->getWidth()) * shadingScale), + static_cast(static_cast(pipeline->getHeight()) * shadingScale), }; data.depth = builder.create(RenderPipeline::fgStrHandleOutDepthTexture, depthTexInfo); } @@ -201,7 +201,7 @@ void PostProcessStage::render(scene::Camera *camera) { gfx::RenderPass *renderPass = table.getRenderPass(); auto *cmdBuff = pipeline->getCommandBuffers()[0]; - const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBuff->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), utils::toUint(globalOffsets.size()), globalOffsets.data()); if (!pipeline->getPipelineSceneData()->getRenderObjects().empty()) { @@ -231,7 +231,7 @@ void PostProcessStage::render(scene::Camera *camera) { }; // add pass - pipeline->getFrameGraph().addPass(static_cast(CommonInsertPoint::DIP_POSTPROCESS), RenderPipeline::fgStrHandlePostprocessPass, postSetup, postExec); + pipeline->getFrameGraph().addPass(static_cast(CommonInsertPoint::DIP_POSTPROCESS), RenderPipeline::fgStrHandlePostprocessPass, postSetup, postExec); pipeline->getFrameGraph().presentFromBlackboard(fgStrHandlePostProcessOutTexture, camera->getWindow()->getFramebuffer()->getColorTextures()[0], shadingScale == 1.F); } diff --git a/native/cocos/renderer/pipeline/deferred/PostProcessStage.h b/native/cocos/renderer/pipeline/deferred/PostProcessStage.h index 5a770e3b71..292a9df811 100644 --- a/native/cocos/renderer/pipeline/deferred/PostProcessStage.h +++ b/native/cocos/renderer/pipeline/deferred/PostProcessStage.h @@ -47,7 +47,7 @@ public: private: UIPhase *_uiPhase = nullptr; - uint _phaseID = 0; + uint32_t _phaseID = 0; static RenderStageInfo initInfo; }; diff --git a/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp b/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp index 5c0d698d01..2178cf4800 100644 --- a/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp +++ b/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp @@ -39,13 +39,13 @@ struct ConstantBuffer { } // namespace -void ReflectionComp::applyTexSize(uint width, uint height, const Mat4 &matView, +void ReflectionComp::applyTexSize(uint32_t width, uint32_t height, const Mat4 &matView, const Mat4 &matViewProj, const Mat4 &matViewProjInv, const Mat4 &matProjInv, const Vec4 &viewPort) { - uint globalWidth = width; - uint globalHeight = height; - uint groupWidth = this->getGroupSizeX(); - uint groupHeight = this->getGroupSizeY(); + uint32_t globalWidth = width; + uint32_t globalHeight = height; + uint32_t groupWidth = this->getGroupSizeX(); + uint32_t groupHeight = this->getGroupSizeY(); _dispatchInfo = {(globalWidth - 1) / groupWidth + 1, (globalHeight - 1) / groupHeight + 1, 1}; _denoiseDispatchInfo = {((globalWidth - 1) / 2) / groupWidth + 1, ((globalHeight - 1) / 2) / groupHeight + 1, 1}; @@ -64,7 +64,7 @@ void ReflectionComp::applyTexSize(uint width, uint height, const Mat4 &matView, } } -void ReflectionComp::init(gfx::Device *dev, uint groupSizeX, uint groupSizeY) { +void ReflectionComp::init(gfx::Device *dev, uint32_t groupSizeX, uint32_t groupSizeY) { if (!dev->hasFeature(gfx::Feature::COMPUTE_SHADER)) return; _device = dev; @@ -76,7 +76,7 @@ void ReflectionComp::init(gfx::Device *dev, uint groupSizeX, uint groupSizeY) { samplerInfo.magFilter = gfx::Filter::POINT; _sampler = _device->getSampler(samplerInfo); - uint maxInvocations = _device->getCapabilities().maxComputeWorkGroupInvocations; + uint32_t maxInvocations = _device->getCapabilities().maxComputeWorkGroupInvocations; CC_ASSERT(_groupSizeX * _groupSizeY <= maxInvocations); // maxInvocations is too small CC_LOG_INFO(" work group size: %dx%d", _groupSizeX, _groupSizeY); diff --git a/native/cocos/renderer/pipeline/deferred/ReflectionComp.h b/native/cocos/renderer/pipeline/deferred/ReflectionComp.h index 720eaf6942..0a16ffaff0 100644 --- a/native/cocos/renderer/pipeline/deferred/ReflectionComp.h +++ b/native/cocos/renderer/pipeline/deferred/ReflectionComp.h @@ -22,13 +22,13 @@ class ReflectionComp { public: ReflectionComp() = default; ~ReflectionComp(); - void init(gfx::Device *dev, uint groupSizeX, uint groupSizeY); + void init(gfx::Device *dev, uint32_t groupSizeX, uint32_t groupSizeY); void getReflectorShader(ShaderSources &sources, bool useEnvmap) const; void getDenoiseShader(ShaderSources &sources, bool useEnvmap) const; void initReflectionRes(); void initDenoiseRes(); void initDenoiseResEnvmap(); - void applyTexSize(uint width, uint height, const Mat4 &matView, + void applyTexSize(uint32_t width, uint32_t height, const Mat4 &matView, const Mat4 &matViewProj, const Mat4 &matViewProjInv, const Mat4 &matProjInv, const Vec4 &viewPort); @@ -42,8 +42,8 @@ public: inline const gfx::TextureBarrierList &getBarrierAfterDenoise() { return _barrierAfterDenoise; } inline const gfx::DispatchInfo &getDispatchInfo() { return _dispatchInfo; } inline const gfx::DispatchInfo &getDenoiseDispatchInfo() { return _denoiseDispatchInfo; } - inline uint getGroupSizeX() const { return _groupSizeX; } - inline uint getGroupSizeY() const { return _groupSizeY; } + inline uint32_t getGroupSizeX() const { return _groupSizeX; } + inline uint32_t getGroupSizeY() const { return _groupSizeY; } inline gfx::Buffer *getConstantsBuffer() { return _compConstantsBuffer; } inline gfx::Sampler *getSampler() { return _sampler; } @@ -80,8 +80,8 @@ private: gfx::DispatchInfo _dispatchInfo; gfx::DispatchInfo _denoiseDispatchInfo; - uint _groupSizeX{8}; - uint _groupSizeY{8}; + uint32_t _groupSizeX{8}; + uint32_t _groupSizeY{8}; }; } // namespace cc diff --git a/native/cocos/renderer/pipeline/forward/ForwardFlow.cpp b/native/cocos/renderer/pipeline/forward/ForwardFlow.cpp index 5d7062b0d0..0907a2e88c 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardFlow.cpp +++ b/native/cocos/renderer/pipeline/forward/ForwardFlow.cpp @@ -33,8 +33,8 @@ namespace cc { namespace pipeline { RenderFlowInfo ForwardFlow::initInfo = { "ForwardFlow", - static_cast(ForwardFlowPriority::FORWARD), - static_cast(RenderFlowTag::SCENE), + static_cast(ForwardFlowPriority::FORWARD), + static_cast(RenderFlowTag::SCENE), {}, }; const RenderFlowInfo &ForwardFlow::getInitializeInfo() { return ForwardFlow::initInfo; } diff --git a/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp b/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp index 4284d7a32f..2d46efc020 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp +++ b/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp @@ -150,8 +150,8 @@ bool ForwardPipeline::activeRenderer(gfx::Swapchain *swapchain) { _macros["CC_USE_DEBUG_VIEW"] = static_cast(0); // step 2 create index buffer - uint ibStride = 4; - uint ibSize = ibStride * 6; + uint32_t ibStride = 4; + uint32_t ibSize = ibStride * 6; if (_quadIB == nullptr) { _quadIB = _device->createBuffer({gfx::BufferUsageBit::INDEX | gfx::BufferUsageBit::TRANSFER_DST, gfx::MemoryUsageBit::DEVICE, ibSize, ibStride}); @@ -161,7 +161,7 @@ bool ForwardPipeline::activeRenderer(gfx::Swapchain *swapchain) { return false; } - uint ibData[] = {0, 1, 2, 1, 3, 2}; + uint32_t ibData[] = {0, 1, 2, 1, 3, 2}; _quadIB->update(ibData, sizeof(ibData)); _width = swapchain->getWidth(); diff --git a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp index 96efb428a1..2535751c15 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp +++ b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp @@ -48,8 +48,8 @@ namespace pipeline { RenderStageInfo ForwardStage::initInfo = { "ForwardStage", - static_cast(ForwardStagePriority::FORWARD), - static_cast(RenderFlowTag::SCENE), + static_cast(ForwardStagePriority::FORWARD), + static_cast(RenderFlowTag::SCENE), {{false, RenderQueueSortMode::FRONT_TO_BACK, {"default"}}, {true, RenderQueueSortMode::BACK_TO_FRONT, {"default", "planarShadow"}}}}; const RenderStageInfo &ForwardStage::getInitializeInfo() { return ForwardStage::initInfo; } @@ -73,7 +73,7 @@ void ForwardStage::activate(RenderPipeline *pipeline, RenderFlow *flow) { RenderStage::activate(pipeline, flow); for (const auto &descriptor : _renderQueueDescriptors) { - uint phase = convertPhase(descriptor.stages); + uint32_t phase = convertPhase(descriptor.stages); RenderQueueSortFunc sortFunc = convertQueueSortFunc(descriptor.sortMode); RenderQueueCreateInfo info = {descriptor.isTransparent, phase, sortFunc}; _renderQueues.emplace_back(ccnew RenderQueue(_pipeline, std::move(info), true)); @@ -108,11 +108,11 @@ void ForwardStage::dispenseRenderObject2Queues() { const auto *const model = ro.model; const auto &subModels = model->getSubModels(); const auto subModelCount = subModels.size(); - for (uint subModelIdx = 0; subModelIdx < subModelCount; ++subModelIdx) { + for (uint32_t subModelIdx = 0; subModelIdx < subModelCount; ++subModelIdx) { const auto &subModel = subModels[subModelIdx]; const auto &passes = subModel->getPasses(); const auto passCount = passes.size(); - for (uint passIdx = 0; passIdx < passCount; ++passIdx) { + for (uint32_t passIdx = 0; passIdx < passCount; ++passIdx) { const auto &pass = passes[passIdx]; if (pass->getPhase() != _phaseID) continue; if (pass->getBatchingScheme() == scene::BatchingSchemes::INSTANCING) { @@ -168,8 +168,8 @@ void ForwardStage::render(scene::Camera *camera) { framegraph::Texture::Descriptor colorTexInfo; colorTexInfo.format = sceneData->isHDR() ? gfx::Format::RGBA16F : gfx::Format::RGBA8; colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT; - colorTexInfo.width = static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale); - colorTexInfo.height = static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale); + colorTexInfo.width = static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale); + colorTexInfo.height = static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale); if (shadingScale != 1.F) { colorTexInfo.usage |= gfx::TextureUsageBit::TRANSFER_SRC; } @@ -195,8 +195,8 @@ void ForwardStage::render(scene::Camera *camera) { gfx::TextureType::TEX2D, gfx::TextureUsageBit::DEPTH_STENCIL_ATTACHMENT, gfx::Format::DEPTH_STENCIL, - static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale), - static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale), + static_cast(static_cast(camera->getWindow()->getWidth()) * shadingScale), + static_cast(static_cast(camera->getWindow()->getHeight()) * shadingScale), }; framegraph::RenderTargetAttachment::Descriptor depthAttachmentInfo; @@ -238,7 +238,7 @@ void ForwardStage::render(scene::Camera *camera) { }; // add pass - pipeline->getFrameGraph().addPass(static_cast(ForwardInsertPoint::IP_FORWARD), ForwardPipeline::fgStrHandleForwardPass, forwardSetup, forwardExec); + pipeline->getFrameGraph().addPass(static_cast(ForwardInsertPoint::IP_FORWARD), ForwardPipeline::fgStrHandleForwardPass, forwardSetup, forwardExec); pipeline->getFrameGraph().presentFromBlackboard(RenderPipeline::fgStrHandleOutColorTexture, camera->getWindow()->getFramebuffer()->getColorTextures()[0], true); } diff --git a/native/cocos/renderer/pipeline/forward/ForwardStage.h b/native/cocos/renderer/pipeline/forward/ForwardStage.h index a0c0e146e3..96b5205f9c 100644 --- a/native/cocos/renderer/pipeline/forward/ForwardStage.h +++ b/native/cocos/renderer/pipeline/forward/ForwardStage.h @@ -60,7 +60,7 @@ private: RenderAdditiveLightQueue *_additiveLightQueue = nullptr; UIPhase *_uiPhase = nullptr; gfx::Rect _renderArea; - uint _phaseID = 0; + uint32_t _phaseID = 0; }; } // namespace pipeline diff --git a/native/cocos/renderer/pipeline/shadow/CSMLayers.cpp b/native/cocos/renderer/pipeline/shadow/CSMLayers.cpp index 950956b24c..19321e8224 100644 --- a/native/cocos/renderer/pipeline/shadow/CSMLayers.cpp +++ b/native/cocos/renderer/pipeline/shadow/CSMLayers.cpp @@ -30,7 +30,7 @@ namespace cc { namespace pipeline { -ShadowTransformInfo::ShadowTransformInfo(uint level):_level(level) { +ShadowTransformInfo::ShadowTransformInfo(uint32_t level):_level(level) { _validFrustum.setType(geometry::ShapeEnum::SHAPE_FRUSTUM_ACCURATE); _splitFrustum.setType(geometry::ShapeEnum::SHAPE_FRUSTUM_ACCURATE); _lightViewFrustum.setType(geometry::ShapeEnum::SHAPE_FRUSTUM_ACCURATE); @@ -66,7 +66,7 @@ void ShadowTransformInfo::createMatrix(const geometry::Frustum &splitFrustum, co if (dirLight->getCSMLevel() != scene::CSMLevel::LEVEL_1 && dirLight->getCSMOptimizationMode() == scene::CSMOptimizationMode::REMOVE_DUPLICATES) { - if (_level >= static_cast(dirLight->getCSMLevel()) - 1U) { + if (_level >= static_cast(dirLight->getCSMLevel()) - 1U) { _maxLayerFarPlane = _castLightViewBoundingBox.halfExtents.z; _maxLayerPosz = _castLightViewBoundingBox.center.z; } else { @@ -130,13 +130,13 @@ void ShadowTransformInfo::calculateSplitFrustum(float start, float end, float as _splitFrustum.split(start, end, aspect, fov, transform); } -CSMLayerInfo::CSMLayerInfo(uint level) : ShadowTransformInfo(level) { +CSMLayerInfo::CSMLayerInfo(uint32_t level) : ShadowTransformInfo(level) { _matShadowAtlas.setZero(); _matShadowViewProjAtlas.setZero(); calculateAtlas(level); } -void CSMLayerInfo::calculateAtlas(uint level) { +void CSMLayerInfo::calculateAtlas(uint32_t level) { const gfx::Device *device = gfx::Device::getInstance(); const float clipSpaceSignY = device->getCapabilities().clipSpaceSignY; const float x = floorf(static_cast(level % 2U)) - 0.5F; @@ -149,7 +149,7 @@ void CSMLayerInfo::calculateAtlas(uint level) { CSMLayers::CSMLayers() { _specialLayer = ccnew ShadowTransformInfo(1U); - for (uint i = 0; i < static_cast(scene::CSMLevel::LEVEL_4); ++i) { + for (uint32_t i = 0; i < static_cast(scene::CSMLevel::LEVEL_4); ++i) { _layers[i] = ccnew CSMLayerInfo(i); } } @@ -172,8 +172,8 @@ void CSMLayers::update(const PipelineSceneData *sceneData, const scene::Camera * CC_ASSERT(dirLight); - const uint levelCount = static_cast(dirLight->getCSMLevel()); - CC_ASSERT(levelCount <= static_cast(scene::CSMLevel::LEVEL_4)); + const auto levelCount = static_cast(dirLight->getCSMLevel()); + CC_ASSERT(levelCount <= static_cast(scene::CSMLevel::LEVEL_4)); const float shadowDistance = dirLight->getShadowDistance(); if (!shadowInfo->isEnabled() || !dirLight->isShadowEnabled()) { @@ -223,10 +223,10 @@ void CSMLayers::splitFrustumLevels(scene::DirectionalLight *dirLight) { constexpr float nd = 0.1F; const float fd = dirLight->getShadowDistance(); const float ratio = fd / nd; - const uint level = static_cast(dirLight->getCSMLevel()); + const auto level = static_cast(dirLight->getCSMLevel()); const float lambda = dirLight->getCSMLayerLambda(); _layers.at(0)->setSplitCameraNear(nd); - for (uint i = 1; i < level; ++i) { + for (uint32_t i = 1; i < level; ++i) { // i ÷ numbers of level const float si = static_cast(i) / static_cast(level); const float preNear = lambda * (nd * powf(ratio, si)) + (1.0F - lambda) * (nd + (fd - nd) * si); diff --git a/native/cocos/renderer/pipeline/shadow/CSMLayers.h b/native/cocos/renderer/pipeline/shadow/CSMLayers.h index f60e063397..2d334ddaf2 100644 --- a/native/cocos/renderer/pipeline/shadow/CSMLayers.h +++ b/native/cocos/renderer/pipeline/shadow/CSMLayers.h @@ -35,10 +35,10 @@ class PipelineSceneData; class ShadowTransformInfo { public: - explicit ShadowTransformInfo(uint level); + explicit ShadowTransformInfo(uint32_t level); ~ShadowTransformInfo() = default; - inline uint getLevel() const { return _level; } + inline uint32_t getLevel() const { return _level; } inline RenderObjectList &getShadowObjects() { return _shadowObjects; } inline void setShadowObjects(RenderObjectList &&ro) { _shadowObjects = std::forward(ro); } @@ -77,7 +77,7 @@ private: RenderObjectList _shadowObjects; // Level is a vector, Indicates the location.range: [0 ~ 3] - uint _level{1U}; + uint32_t _level{1U}; float _shadowCameraFar{0.0F}; @@ -98,7 +98,7 @@ private: class CSMLayerInfo : public ShadowTransformInfo { public: - explicit CSMLayerInfo(uint level); + explicit CSMLayerInfo(uint32_t level); ~CSMLayerInfo() = default; inline float getSplitCameraNear() const { return _splitCameraNear; } @@ -114,7 +114,7 @@ public: inline void setMatShadowViewProjAtlas(const Mat4 &matShadowViewProjAtlas) { _matShadowViewProjAtlas = matShadowViewProjAtlas; } private: - void calculateAtlas(uint level); + void calculateAtlas(uint32_t level); float _splitCameraNear{0.0F}; float _splitCameraFar{0.0F}; @@ -155,7 +155,7 @@ private: RenderObjectList _layerObjects; // LevelCount is a scalar, Indicates the number. - uint _levelCount{0U}; + uint32_t _levelCount{0U}; // The ShadowTransformInfo object for 'fixed area shadow' || 'maximum clipping info' || 'CSM layers = 1'. ShadowTransformInfo *_specialLayer{nullptr}; ccstd::array _layers{}; diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp index 7080fd2121..80b2f5254e 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp +++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp @@ -46,8 +46,8 @@ ccstd::unordered_map ShadowFlow::renderPas RenderFlowInfo ShadowFlow::initInfo = { "ShadowFlow", - static_cast(ForwardFlowPriority::SHADOW), - static_cast(RenderFlowTag::SCENE), + static_cast(ForwardFlowPriority::SHADOW), + static_cast(RenderFlowTag::SCENE), {}, }; const RenderFlowInfo &ShadowFlow::getInitializeInfo() { return ShadowFlow::initInfo; } @@ -107,13 +107,13 @@ void ShadowFlow::render(scene::Camera *camera) { if (mainLight->isShadowFixedArea()) { renderStage(globalDS, camera, mainLight, shadowFrameBuffer); } else { - for (uint i = 0; i < static_cast(mainLight->getCSMLevel()); ++i) { + for (uint32_t i = 0; i < static_cast(mainLight->getCSMLevel()); ++i) { renderStage(globalDS, camera, mainLight, shadowFrameBuffer, i); } } } - for (uint l = 0; l < _validLights.size(); ++l) { + for (uint32_t l = 0; l < _validLights.size(); ++l) { const scene::Light *light = _validLights[l]; gfx::DescriptorSet *globalDS = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(l); @@ -132,7 +132,7 @@ void ShadowFlow::render(scene::Camera *camera) { shadowInfo->setShadowMapDirty(false); } -void ShadowFlow::renderStage(gfx::DescriptorSet *globalDS, scene::Camera *camera, const scene::Light *light, gfx::Framebuffer *framebuffer, uint level) { +void ShadowFlow::renderStage(gfx::DescriptorSet *globalDS, scene::Camera *camera, const scene::Light *light, gfx::Framebuffer *framebuffer, uint32_t level) { for (auto *stage : _stages) { auto *shadowStage = static_cast(stage); shadowStage->setUsage(globalDS, light, framebuffer, level); @@ -173,7 +173,7 @@ void ShadowFlow::clearShadowMap(scene::Camera *camera) { } } - for (uint l = 0; l < _validLights.size(); ++l) { + for (uint32_t l = 0; l < _validLights.size(); ++l) { const scene::Light *light = _validLights[l]; gfx::DescriptorSet *globalDS = _pipeline->getGlobalDSManager()->getOrCreateDescriptorSet(l); @@ -194,8 +194,8 @@ void ShadowFlow::resizeShadowMap(const scene::Light *light, gfx::DescriptorSet * const auto *sceneData = _pipeline->getPipelineSceneData(); const auto *shadowInfo = sceneData->getShadows(); auto *device = gfx::Device::getInstance(); - const auto width = static_cast(shadowInfo->getSize().x); - const auto height = static_cast(shadowInfo->getSize().y); + const auto width = static_cast(shadowInfo->getSize().x); + const auto height = static_cast(shadowInfo->getSize().y); const auto format = supportsR32FloatTexture(device) ? gfx::Format::R32F : gfx::Format::RGBA8; gfx::Framebuffer *framebuffer = sceneData->getShadowFramebufferMap().at(light); @@ -254,8 +254,8 @@ void ShadowFlow::initShadowFrameBuffer(const RenderPipeline* pipeline, const sce const auto *sceneData = _pipeline->getPipelineSceneData(); const auto *shadowInfo = sceneData->getShadows(); const auto &shadowMapSize = shadowInfo->getSize(); - const auto width = static_cast(shadowMapSize.x); - const auto height = static_cast(shadowMapSize.y); + const auto width = static_cast(shadowMapSize.x); + const auto height = static_cast(shadowMapSize.y); const auto format = supportsR32FloatTexture(device) ? gfx::Format::R32F : gfx::Format::RGBA8; const gfx::ColorAttachment colorAttachment = { diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.h b/native/cocos/renderer/pipeline/shadow/ShadowFlow.h index c09798136e..c5230bec3a 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.h +++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.h @@ -48,7 +48,7 @@ public: void destroy() override; private: - void renderStage(gfx::DescriptorSet *globalDS, scene::Camera *camera, const scene::Light *light, gfx::Framebuffer *framebuffer, uint level = 0); + void renderStage(gfx::DescriptorSet *globalDS, scene::Camera *camera, const scene::Light *light, gfx::Framebuffer *framebuffer, uint32_t level = 0); void lightCollecting(); diff --git a/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp b/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp index 378d80499d..25e419128c 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp +++ b/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp @@ -47,8 +47,8 @@ ShadowStage::~ShadowStage() = default; RenderStageInfo ShadowStage::initInfo = { "ShadowStage", - static_cast(ForwardStagePriority::FORWARD), - static_cast(RenderFlowTag::SCENE), + static_cast(ForwardStagePriority::FORWARD), + static_cast(RenderFlowTag::SCENE), {}}; const RenderStageInfo &ShadowStage::getInitializeInfo() { return ShadowStage::initInfo; } @@ -96,8 +96,8 @@ void ShadowStage::render(scene::Camera *camera) { if (mainLight->isShadowFixedArea() || mainLight->getCSMLevel() == scene::CSMLevel::LEVEL_1) { _renderArea.x = 0; _renderArea.y = 0; - _renderArea.width = static_cast(shadowMapSize.x); - _renderArea.height = static_cast(shadowMapSize.y); + _renderArea.width = static_cast(shadowMapSize.x); + _renderArea.height = static_cast(shadowMapSize.y); } else { const gfx::Device *device = gfx::Device::getInstance(); const float clipSpaceSignY = device->getCapabilities().clipSpaceSignY; @@ -115,8 +115,8 @@ void ShadowStage::render(scene::Camera *camera) { case scene::LightType::SPOT: { _renderArea.x = 0; _renderArea.y = 0; - _renderArea.width = static_cast(shadowMapSize.x); - _renderArea.height = static_cast(shadowMapSize.y); + _renderArea.width = static_cast(shadowMapSize.x); + _renderArea.height = static_cast(shadowMapSize.y); break; } case scene::LightType::SPHERE: { @@ -134,7 +134,7 @@ void ShadowStage::render(scene::Camera *camera) { cmdBuffer->beginRenderPass(renderPass, _framebuffer, _renderArea, _clearColors, camera->getClearDepth(), camera->getClearStencil()); - const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; + const ccstd::array globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()}; cmdBuffer->bindDescriptorSet(globalSet, _globalDS, utils::toUint(globalOffsets.size()), globalOffsets.data()); _additiveShadowQueue->recordCommandBuffer(_device, renderPass, cmdBuffer); @@ -165,8 +165,8 @@ void ShadowStage::clearFramebuffer(const scene::Camera* camera) { _renderArea.x = static_cast(viewport.x * shadowMapSize.x); _renderArea.y = static_cast(viewport.y * shadowMapSize.y); - _renderArea.width = static_cast(viewport.z * shadowMapSize.x * sceneData->getShadingScale()); - _renderArea.height = static_cast(viewport.w * shadowMapSize.y * sceneData->getShadingScale()); + _renderArea.width = static_cast(viewport.z * shadowMapSize.x * sceneData->getShadingScale()); + _renderArea.height = static_cast(viewport.w * shadowMapSize.y * sceneData->getShadingScale()); _clearColors[0] = {1.0F, 1.0F, 1.0F, 1.0F}; auto *renderPass = _framebuffer->getRenderPass(); diff --git a/native/cocos/renderer/pipeline/shadow/ShadowStage.h b/native/cocos/renderer/pipeline/shadow/ShadowStage.h index 2402559cad..910cd3359b 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowStage.h +++ b/native/cocos/renderer/pipeline/shadow/ShadowStage.h @@ -44,7 +44,7 @@ public: void activate(RenderPipeline *pipeline, RenderFlow *flow) override; inline void setFramebuffer(gfx::Framebuffer *framebuffer) { _framebuffer = framebuffer; } - inline void setUsage(gfx::DescriptorSet *globalDS, const scene::Light *light, gfx::Framebuffer *framebuffer, uint level = 0) { + inline void setUsage(gfx::DescriptorSet *globalDS, const scene::Light *light, gfx::Framebuffer *framebuffer, uint32_t level = 0) { _globalDS = globalDS; _light = light; _framebuffer = framebuffer; @@ -60,7 +60,7 @@ private: gfx::DescriptorSet *_globalDS = nullptr; const scene::Light *_light = nullptr; gfx::Framebuffer *_framebuffer = nullptr; - uint _level; + uint32_t _level; ShadowMapBatchedQueue *_additiveShadowQueue = nullptr; };