From 73c7c7a47eab93ce0461c78f8cd56b0f9105d9b0 Mon Sep 17 00:00:00 2001 From: Zhou Zhenglong Date: Thu, 4 Jan 2024 16:44:17 +0800 Subject: [PATCH 1/2] fix glsl macro bug --- native/cocos/renderer/gfx-base/SPIRVUtils.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/native/cocos/renderer/gfx-base/SPIRVUtils.cpp b/native/cocos/renderer/gfx-base/SPIRVUtils.cpp index f47730a28fb..a77b8478445 100644 --- a/native/cocos/renderer/gfx-base/SPIRVUtils.cpp +++ b/native/cocos/renderer/gfx-base/SPIRVUtils.cpp @@ -31,6 +31,11 @@ #include "glslang/StandAlone/ResourceLimits.h" #include "spirv/spirv.h" +#define CC_GLSLANG_VERSION_GREATOR_OR_EQUAL_TO(major, minor, patch) \ + (((major) < GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \ + (((minor) < GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \ + ((patch) <= GLSLANG_VERSION_PATCH))))) + namespace cc { namespace gfx { @@ -57,7 +62,7 @@ glslang::EShTargetClientVersion getClientVersion(int vulkanMinorVersion) { case 0: return glslang::EShTargetVulkan_1_0; case 1: return glslang::EShTargetVulkan_1_1; case 2: return glslang::EShTargetVulkan_1_2; -#if GLSLANG_VERSION_LESS_OR_EQUAL_TO(11, 10, 0) +#if CC_GLSLANG_VERSION_GREATOR_OR_EQUAL_TO(11, 10, 0) // This macro is defined in glslang/build_info.h. This expression means that the // lib version is greater than or equal to 11.10.0 (not less than or equal to), // which is very counterintuitive. But it's the only way to do it. @@ -77,7 +82,7 @@ glslang::EShTargetLanguageVersion getTargetVersion(int vulkanMinorVersion) { case 0: return glslang::EShTargetSpv_1_0; case 1: return glslang::EShTargetSpv_1_3; case 2: return glslang::EShTargetSpv_1_5; -#if GLSLANG_VERSION_LESS_OR_EQUAL_TO(11, 10, 0) +#if CC_GLSLANG_VERSION_GREATOR_OR_EQUAL_TO(11, 10, 0) // This macro is defined in glslang/build_info.h. This expression means that the // lib version is greater than or equal to 11.10.0 (not less than or equal to), // which is very counterintuitive. But it's the only way to do it. From 732a11ef05bab492ec8f40410b6e4d3088e08e46 Mon Sep 17 00:00:00 2001 From: Zhou Zhenglong Date: Thu, 4 Jan 2024 16:45:29 +0800 Subject: [PATCH 2/2] lint --- native/cocos/renderer/gfx-base/SPIRVUtils.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/native/cocos/renderer/gfx-base/SPIRVUtils.cpp b/native/cocos/renderer/gfx-base/SPIRVUtils.cpp index a77b8478445..fbb32eda5b1 100644 --- a/native/cocos/renderer/gfx-base/SPIRVUtils.cpp +++ b/native/cocos/renderer/gfx-base/SPIRVUtils.cpp @@ -63,9 +63,6 @@ glslang::EShTargetClientVersion getClientVersion(int vulkanMinorVersion) { case 1: return glslang::EShTargetVulkan_1_1; case 2: return glslang::EShTargetVulkan_1_2; #if CC_GLSLANG_VERSION_GREATOR_OR_EQUAL_TO(11, 10, 0) - // This macro is defined in glslang/build_info.h. This expression means that the - // lib version is greater than or equal to 11.10.0 (not less than or equal to), - // which is very counterintuitive. But it's the only way to do it. case 3: return glslang::EShTargetVulkan_1_3; #else case 3: return glslang::EShTargetVulkan_1_2; @@ -83,9 +80,6 @@ glslang::EShTargetLanguageVersion getTargetVersion(int vulkanMinorVersion) { case 1: return glslang::EShTargetSpv_1_3; case 2: return glslang::EShTargetSpv_1_5; #if CC_GLSLANG_VERSION_GREATOR_OR_EQUAL_TO(11, 10, 0) - // This macro is defined in glslang/build_info.h. This expression means that the - // lib version is greater than or equal to 11.10.0 (not less than or equal to), - // which is very counterintuitive. But it's the only way to do it. case 3: return glslang::EShTargetSpv_1_6; #else case 3: return glslang::EShTargetSpv_1_5;