diff --git a/native/cocos/renderer/gfx-base/GFXDef-common.h b/native/cocos/renderer/gfx-base/GFXDef-common.h index 538f1536d7..3034c6b133 100644 --- a/native/cocos/renderer/gfx-base/GFXDef-common.h +++ b/native/cocos/renderer/gfx-base/GFXDef-common.h @@ -419,7 +419,7 @@ enum class MemoryUsageBit : FlagBits { HOST = 0x2, }; using MemoryUsage = MemoryUsageBit; -CC_ENUM_OPERATORS(MemoryUsageBit) +CC_ENUM_OPERATORS(MemoryUsageBit); enum class TextureType { TEX1D, @@ -441,7 +441,7 @@ enum class TextureUsageBit : FlagBits { INPUT_ATTACHMENT = 0x40, }; using TextureUsage = TextureUsageBit; -CC_ENUM_OPERATORS(TextureUsageBit) +CC_ENUM_OPERATORS(TextureUsageBit); enum class TextureFlagBit : FlagBits { NONE = 0, @@ -449,7 +449,7 @@ enum class TextureFlagBit : FlagBits { IMMUTABLE = 0x2, }; using TextureFlags = TextureFlagBit; -CC_ENUM_OPERATORS(TextureFlagBit) +CC_ENUM_OPERATORS(TextureFlagBit); enum class SampleCount { X1, @@ -531,7 +531,7 @@ enum class ColorMask : FlagBits { A = 0x8, ALL = R | G | B | A, }; -CC_ENUM_OPERATORS(ColorMask) +CC_ENUM_OPERATORS(ColorMask); enum class ShaderStageFlagBit : FlagBits { NONE = 0x0, @@ -544,7 +544,7 @@ enum class ShaderStageFlagBit : FlagBits { ALL = 0x3f, }; using ShaderStageFlags = ShaderStageFlagBit; -CC_ENUM_OPERATORS(ShaderStageFlagBit) +CC_ENUM_OPERATORS(ShaderStageFlagBit); enum class LoadOp { LOAD, // Load the contents from the fbo from previous @@ -647,7 +647,7 @@ enum class DynamicStateFlagBit : FlagBits { STENCIL_COMPARE_MASK = 0x80, }; using DynamicStateFlags = DynamicStateFlagBit; -CC_ENUM_OPERATORS(DynamicStateFlagBit) +CC_ENUM_OPERATORS(DynamicStateFlagBit); using DynamicStateList = vector; @@ -669,7 +669,7 @@ enum class DescriptorType : FlagBits { STORAGE_IMAGE = 0x80, INPUT_ATTACHMENT = 0x100, }; -CC_ENUM_OPERATORS(DescriptorType) +CC_ENUM_OPERATORS(DescriptorType); enum class QueueType { GRAPHICS, @@ -691,7 +691,7 @@ enum class ClearFlagBit : FlagBits { ALL = COLOR | DEPTH | STENCIL, }; using ClearFlags = ClearFlagBit; -CC_ENUM_OPERATORS(ClearFlagBit) +CC_ENUM_OPERATORS(ClearFlagBit); struct Size { uint x = 0U; diff --git a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp index f85bb68085..9698f5f40d 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp @@ -1354,8 +1354,6 @@ void cmdFuncGLES2BeginRenderPass(GLES2Device *device, GLES2GPURenderPass *gpuRen if (cache->glFramebuffer != gpuFramebuffer->glFramebuffer) { GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, gpuFramebuffer->glFramebuffer)); cache->glFramebuffer = gpuFramebuffer->glFramebuffer; - // render targets are drawn with flipped-Y - gfxStateCache.reverseCW = !!gpuFramebuffer->glFramebuffer; } if (cache->viewport.left != renderArea.x || @@ -1609,10 +1607,9 @@ void cmdFuncGLES2BindState(GLES2Device *device, GLES2GPUPipelineState *gpuPipeli } cache->rs.cullMode = gpuPipelineState->rs.cullMode; } - bool isFrontFaceCCW = static_cast(gpuPipelineState->rs.isFrontFaceCCW) != gfxStateCache.reverseCW; - if (static_cast(cache->rs.isFrontFaceCCW) != isFrontFaceCCW) { - GL_CHECK(glFrontFace(isFrontFaceCCW ? GL_CCW : GL_CW)); - cache->rs.isFrontFaceCCW = isFrontFaceCCW; + if (cache->rs.isFrontFaceCCW != gpuPipelineState->rs.isFrontFaceCCW) { + GL_CHECK(glFrontFace(gpuPipelineState->rs.isFrontFaceCCW ? GL_CCW : GL_CW)); + cache->rs.isFrontFaceCCW = gpuPipelineState->rs.isFrontFaceCCW; } if ((cache->rs.depthBias != gpuPipelineState->rs.depthBias) || (cache->rs.depthBiasSlop != gpuPipelineState->rs.depthBiasSlop)) { diff --git a/native/cocos/renderer/gfx-gles2/GLES2Device.cpp b/native/cocos/renderer/gfx-gles2/GLES2Device.cpp index 10e9521fa9..53518064d6 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Device.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Device.cpp @@ -125,6 +125,7 @@ bool GLES2Device::doInit(const DeviceInfo & info) { if (checkExtension("draw_buffers")) { _features[static_cast(Feature::MULTIPLE_RENDER_TARGETS)] = true; + glGetIntegerv(GL_MAX_DRAW_BUFFERS_EXT, reinterpret_cast(&_caps.maxColorRenderTargets)); } if (checkExtension("blend_minmax")) { @@ -198,13 +199,13 @@ bool GLES2Device::doInit(const DeviceInfo & info) { } void GLES2Device::doDestroy() { - CC_SAFE_DELETE(_gpuStagingBufferPool); - CC_SAFE_DELETE(_gpuStateCache); + CC_SAFE_DELETE(_gpuStagingBufferPool) + CC_SAFE_DELETE(_gpuStateCache) - CC_SAFE_DESTROY(_cmdBuff); - CC_SAFE_DESTROY(_queue); - CC_SAFE_DESTROY(_deviceContext); - CC_SAFE_DESTROY(_renderContext); + CC_SAFE_DESTROY(_cmdBuff) + CC_SAFE_DESTROY(_queue) + CC_SAFE_DESTROY(_deviceContext) + CC_SAFE_DESTROY(_renderContext) } void GLES2Device::releaseSurface(uintptr_t windowHandle) { diff --git a/native/cocos/renderer/gfx-gles2/GLES2GPUObjects.h b/native/cocos/renderer/gfx-gles2/GLES2GPUObjects.h index c79e34b9bb..8a680d6d5b 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2GPUObjects.h +++ b/native/cocos/renderer/gfx-gles2/GLES2GPUObjects.h @@ -300,7 +300,6 @@ struct GLES2ObjectCache final { GLES2GPUFramebuffer * gpuFramebuffer = nullptr; GLES2GPUPipelineState * gpuPipelineState = nullptr; GLES2GPUInputAssembler *gpuInputAssembler = nullptr; - bool reverseCW = false; GLenum glPrimitive = 0; GLenum invalidAttachments[MAX_ATTACHMENTS]; }; @@ -361,7 +360,6 @@ public: gfxStateCache.gpuFramebuffer = nullptr; gfxStateCache.gpuInputAssembler = nullptr; gfxStateCache.glPrimitive = 0U; - gfxStateCache.reverseCW = false; } }; diff --git a/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp b/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp index d1db6a1bfc..71b67ea041 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp @@ -1524,8 +1524,6 @@ void cmdFuncGLES3BeginRenderPass(GLES3Device *device, GLES3GPURenderPass *gpuRen if (cache->glDrawFramebuffer != gpuFramebuffer->glFramebuffer) { GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpuFramebuffer->glFramebuffer)); cache->glDrawFramebuffer = gpuFramebuffer->glFramebuffer; - // render targets are drawn with flipped-Y - gfxStateCache.reverseCW = gpuFramebuffer->isOffscreen; } if (cache->viewport.left != renderArea.x || @@ -1779,10 +1777,9 @@ void cmdFuncGLES3BindState(GLES3Device *device, GLES3GPUPipelineState *gpuPipeli } cache->rs.cullMode = gpuPipelineState->rs.cullMode; } - bool isFrontFaceCCW = gpuPipelineState->rs.isFrontFaceCCW != gfxStateCache.reverseCW; - if (static_cast(cache->rs.isFrontFaceCCW) != isFrontFaceCCW) { - GL_CHECK(glFrontFace(isFrontFaceCCW ? GL_CCW : GL_CW)); - cache->rs.isFrontFaceCCW = isFrontFaceCCW; + if (cache->rs.isFrontFaceCCW != gpuPipelineState->rs.isFrontFaceCCW) { + GL_CHECK(glFrontFace(gpuPipelineState->rs.isFrontFaceCCW ? GL_CCW : GL_CW)); + cache->rs.isFrontFaceCCW = gpuPipelineState->rs.isFrontFaceCCW; } if ((cache->rs.depthBias != gpuPipelineState->rs.depthBias) || (cache->rs.depthBiasSlop != gpuPipelineState->rs.depthBiasSlop)) { diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp index 62c4256443..e5c60c183d 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp @@ -171,6 +171,7 @@ bool GLES3Device::doInit(const DeviceInfo & info) { glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, reinterpret_cast(&_caps.maxFragmentUniformVectors)); glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, reinterpret_cast(&_caps.maxUniformBufferBindings)); glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, reinterpret_cast(&_caps.maxUniformBlockSize)); + glGetIntegerv(GL_MAX_DRAW_BUFFERS, reinterpret_cast(&_caps.maxColorRenderTargets)); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, reinterpret_cast(&_caps.maxTextureUnits)); glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, reinterpret_cast(&_caps.maxVertexTextureUnits)); glGetIntegerv(GL_MAX_TEXTURE_SIZE, reinterpret_cast(&_caps.maxTextureSize)); @@ -199,14 +200,14 @@ bool GLES3Device::doInit(const DeviceInfo & info) { } void GLES3Device::doDestroy() { - CC_SAFE_DELETE(_gpuFramebufferCacheMap); - CC_SAFE_DELETE(_gpuStagingBufferPool); - CC_SAFE_DELETE(_gpuStateCache); + CC_SAFE_DELETE(_gpuFramebufferCacheMap) + CC_SAFE_DELETE(_gpuStagingBufferPool) + CC_SAFE_DELETE(_gpuStateCache) - CC_SAFE_DESTROY(_cmdBuff); - CC_SAFE_DESTROY(_queue); - CC_SAFE_DESTROY(_deviceContext); - CC_SAFE_DESTROY(_renderContext); + CC_SAFE_DESTROY(_cmdBuff) + CC_SAFE_DESTROY(_queue) + CC_SAFE_DESTROY(_deviceContext) + CC_SAFE_DESTROY(_renderContext) } void GLES3Device::releaseSurface(const uintptr_t windowHandle) { diff --git a/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h b/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h index 7aa74d4512..2c3bbb9e2e 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h +++ b/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h @@ -297,7 +297,6 @@ struct GLES3ObjectCache final { GLES3GPUFramebuffer * gpuFramebuffer = nullptr; GLES3GPUPipelineState * gpuPipelineState = nullptr; GLES3GPUInputAssembler *gpuInputAssembler = nullptr; - uint reverseCW = 0U; GLenum glPrimitive = 0; GLenum invalidAttachments[MAX_ATTACHMENTS]; }; @@ -380,7 +379,6 @@ public: gfxStateCache.gpuPipelineState = nullptr; gfxStateCache.gpuInputAssembler = nullptr; gfxStateCache.glPrimitive = 0U; - gfxStateCache.reverseCW = false; } };