From 6ffef5b35bf22da4fe711357cf6c5ad59cfbd4ed Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Wed, 4 Nov 2020 19:03:00 +0800 Subject: [PATCH] fix render queue sort function (#2977) * fix render queue sort function * enable scissor by default --- native/cocos/renderer/core/gfx/GFXDef.h | 32 +++++++++++++++++++ .../cocos/renderer/gfx-gles2/GLES2Context.cpp | 1 + .../cocos/renderer/gfx-gles3/GLES3Context.cpp | 1 + native/cocos/renderer/gfx-vulkan/VKUtils.h | 31 ++++++++++++++++++ native/cocos/renderer/pipeline/Define.h | 2 +- 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/native/cocos/renderer/core/gfx/GFXDef.h b/native/cocos/renderer/core/gfx/GFXDef.h index 65277bd90d..704d44314a 100755 --- a/native/cocos/renderer/core/gfx/GFXDef.h +++ b/native/cocos/renderer/core/gfx/GFXDef.h @@ -224,6 +224,38 @@ enum class Format { PVRTC2_2BPP, PVRTC2_4BPP, + // ASTC (Adaptive Scalable Texture Compression) + ASTC_RGBA_4x4, + ASTC_RGBA_5x4, + ASTC_RGBA_5x5, + ASTC_RGBA_6x5, + ASTC_RGBA_6x6, + ASTC_RGBA_8x5, + ASTC_RGBA_8x6, + ASTC_RGBA_8x8, + ASTC_RGBA_10x5, + ASTC_RGBA_10x6, + ASTC_RGBA_10x8, + ASTC_RGBA_10x10, + ASTC_RGBA_12x10, + ASTC_RGBA_12x12, + + // ASTC (Adaptive Scalable Texture Compression) SRGB + ASTC_SRGBA_4x4, + ASTC_SRGBA_5x4, + ASTC_SRGBA_5x5, + ASTC_SRGBA_6x5, + ASTC_SRGBA_6x6, + ASTC_SRGBA_8x5, + ASTC_SRGBA_8x6, + ASTC_SRGBA_8x8, + ASTC_SRGBA_10x5, + ASTC_SRGBA_10x6, + ASTC_SRGBA_10x8, + ASTC_SRGBA_10x10, + ASTC_SRGBA_12x10, + ASTC_SRGBA_12x12, + // Total count COUNT, }; diff --git a/native/cocos/renderer/gfx-gles2/GLES2Context.cpp b/native/cocos/renderer/gfx-gles2/GLES2Context.cpp index 53f46f03b3..fac1563864 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Context.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Context.cpp @@ -409,6 +409,7 @@ bool GLES2Context::MakeCurrent() { ////////////////////////////////////////////////////////////////////////// + glEnable(GL_SCISSOR_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); diff --git a/native/cocos/renderer/gfx-gles3/GLES3Context.cpp b/native/cocos/renderer/gfx-gles3/GLES3Context.cpp index beb6781349..4f955125cb 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Context.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Context.cpp @@ -412,6 +412,7 @@ bool GLES3Context::MakeCurrent() { ////////////////////////////////////////////////////////////////////////// + glEnable(GL_SCISSOR_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); diff --git a/native/cocos/renderer/gfx-vulkan/VKUtils.h b/native/cocos/renderer/gfx-vulkan/VKUtils.h index 1b8d129aaa..2f86525fe0 100644 --- a/native/cocos/renderer/gfx-vulkan/VKUtils.h +++ b/native/cocos/renderer/gfx-vulkan/VKUtils.h @@ -105,6 +105,37 @@ VkFormat MapVkFormat(Format format) { case Format::PVRTC_RGBA4: return VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; case Format::PVRTC2_2BPP: return VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG; case Format::PVRTC2_4BPP: return VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG; + + case Format::ASTC_RGBA_4x4: return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; + case Format::ASTC_RGBA_5x4: return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; + case Format::ASTC_RGBA_5x5: return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; + case Format::ASTC_RGBA_6x5: return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; + case Format::ASTC_RGBA_6x6: return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; + case Format::ASTC_RGBA_8x5: return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; + case Format::ASTC_RGBA_8x6: return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; + case Format::ASTC_RGBA_8x8: return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; + case Format::ASTC_RGBA_10x5: return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; + case Format::ASTC_RGBA_10x6: return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; + case Format::ASTC_RGBA_10x8: return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; + case Format::ASTC_RGBA_10x10: return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; + case Format::ASTC_RGBA_12x10: return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; + case Format::ASTC_RGBA_12x12: return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; + + case Format::ASTC_SRGBA_4x4: return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; + case Format::ASTC_SRGBA_5x4: return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; + case Format::ASTC_SRGBA_5x5: return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; + case Format::ASTC_SRGBA_6x5: return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; + case Format::ASTC_SRGBA_6x6: return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; + case Format::ASTC_SRGBA_8x5: return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; + case Format::ASTC_SRGBA_8x6: return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; + case Format::ASTC_SRGBA_8x8: return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; + case Format::ASTC_SRGBA_10x5: return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; + case Format::ASTC_SRGBA_10x6: return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; + case Format::ASTC_SRGBA_10x8: return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; + case Format::ASTC_SRGBA_10x10: return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; + case Format::ASTC_SRGBA_12x10: return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; + case Format::ASTC_SRGBA_12x12: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; + default: { CCASSERT(false, "Unsupported Format, convert to VkFormat failed."); return VK_FORMAT_B8G8R8A8_UNORM; diff --git a/native/cocos/renderer/pipeline/Define.h b/native/cocos/renderer/pipeline/Define.h index 76078db179..a5b0577805 100644 --- a/native/cocos/renderer/pipeline/Define.h +++ b/native/cocos/renderer/pipeline/Define.h @@ -150,7 +150,7 @@ CC_INLINE bool opaqueCompareFn(const RenderPass &a, const RenderPass &b) { CC_INLINE bool transparentCompareFn(const RenderPass &a, const RenderPass &b) { if (a.hash != b.hash) return a.hash < b.hash; - else if (math::IsEqualF(a.depth, b.depth)) + else if (math::IsNotEqualF(a.depth, b.depth)) return b.depth < a.depth; else return a.shaderID < b.shaderID;