From e4b86beafebeb37c6f9d569204a51e2e96a97d4a Mon Sep 17 00:00:00 2001 From: Laura Hermanns Date: Sun, 22 Sep 2024 11:15:03 -0400 Subject: [PATCH] [GL] Fixed compile errors in GLES and WebGL profiles. - Fixed include path to GLProfile.h. - Exclude Desktop GL exclusive sampler parameters from GLEmulatedSampler in GLES and WebGL profiles. - Remove half-supported GL_EXT_separate_shader_objects extension; only GL_ARB_separate_shader_objects is supported. - Also fix BuildAndroid.sh script when -d/--debug argument is not present. --- BuildAndroid.sh | 10 ++---- sources/Renderer/OpenGL/OpenGL.h | 7 +--- .../OpenGL/Profile/GLES/GLESProfile.cpp | 2 +- .../OpenGL/Profile/GLES/GLESProfileCaps.cpp | 1 - .../OpenGL/Profile/WebGL/WebGLProfile.cpp | 2 +- .../OpenGL/Profile/WebGL/WebGLProfileCaps.cpp | 1 - .../OpenGL/Texture/GLEmulatedSampler.cpp | 32 +++++++++++++++++++ .../OpenGL/Texture/GLEmulatedSampler.h | 6 ++++ 8 files changed, 44 insertions(+), 17 deletions(-) diff --git a/BuildAndroid.sh b/BuildAndroid.sh index 0eeb293018..30f16370a7 100644 --- a/BuildAndroid.sh +++ b/BuildAndroid.sh @@ -316,17 +316,13 @@ generate_app_project() if [ $BUILD_APPS -ne 0 ]; then - PROJECT_DEBUG_BUILD=0 - BIN_FILE_BASE="${OUTPUT_DIR}/${SUPPORTED_ANDROID_ABIS[0]}/build/libExample_" BIN_FILE_BASE_LEN=${#BIN_FILE_BASE} - EXAMPLE_BIN_FILES_D=(${BIN_FILE_BASE}*D.so) - if [ -z "$EXAMPLE_BIN_FILES_D" ]; then - EXAMPLE_BIN_FILES=(${BIN_FILE_BASE}*.so) + if [ $BUILD_TYPE = "Debug" ]; then + EXAMPLE_BIN_FILES=(${BIN_FILE_BASE}*D.so) else - EXAMPLE_BIN_FILES=(${EXAMPLE_BIN_FILES_D[@]}) - PROJECT_DEBUG_BUILD=1 + EXAMPLE_BIN_FILES=(${BIN_FILE_BASE}*.so) fi for BIN_FILE in ${EXAMPLE_BIN_FILES[@]}; do diff --git a/sources/Renderer/OpenGL/OpenGL.h b/sources/Renderer/OpenGL/OpenGL.h index 02a7607448..a38673355f 100644 --- a/sources/Renderer/OpenGL/OpenGL.h +++ b/sources/Renderer/OpenGL/OpenGL.h @@ -44,13 +44,8 @@ # define LLGL_GLEXT_DRAW_INSTANCED 1 #endif -#if GL_ARB_separate_shader_objects || GL_ES_VERSION_3_1 +#if GL_ARB_separate_shader_objects # define LLGL_GLEXT_SEPARATE_SHADER_OBJECTS 1 -#elif GL_EXT_separate_shader_objects -# define LLGL_GLEXT_SEPARATE_SHADER_OBJECTS 1 -# ifndef GL_PROGRAM_PIPELINE_BINDING -# define GL_PROGRAM_PIPELINE_BINDING GL_PROGRAM_PIPELINE_BINDING_EXT -# endif #endif #if GL_ARB_uniform_buffer_object || GL_ES_VERSION_3_0 diff --git a/sources/Renderer/OpenGL/Profile/GLES/GLESProfile.cpp b/sources/Renderer/OpenGL/Profile/GLES/GLESProfile.cpp index 330b5eb880..1e7b0283ee 100644 --- a/sources/Renderer/OpenGL/Profile/GLES/GLESProfile.cpp +++ b/sources/Renderer/OpenGL/Profile/GLES/GLESProfile.cpp @@ -5,7 +5,7 @@ * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). */ -#include "../../GLProfile.h" +#include "../GLProfile.h" #include "../../Ext/GLExtensions.h" #include "../../../../Core/Assertion.h" #include diff --git a/sources/Renderer/OpenGL/Profile/GLES/GLESProfileCaps.cpp b/sources/Renderer/OpenGL/Profile/GLES/GLESProfileCaps.cpp index 27967f6445..816a8364fc 100644 --- a/sources/Renderer/OpenGL/Profile/GLES/GLESProfileCaps.cpp +++ b/sources/Renderer/OpenGL/Profile/GLES/GLESProfileCaps.cpp @@ -6,7 +6,6 @@ */ #include "../../GLRenderingCaps.h" -#include "../../GLProfile.h" #include "../../GLTypes.h" #include "../../Ext/GLExtensions.h" #include "../../Ext/GLExtensionRegistry.h" diff --git a/sources/Renderer/OpenGL/Profile/WebGL/WebGLProfile.cpp b/sources/Renderer/OpenGL/Profile/WebGL/WebGLProfile.cpp index a219c2becc..1592e58ef3 100644 --- a/sources/Renderer/OpenGL/Profile/WebGL/WebGLProfile.cpp +++ b/sources/Renderer/OpenGL/Profile/WebGL/WebGLProfile.cpp @@ -5,7 +5,7 @@ * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). */ -#include "../../GLProfile.h" +#include "../GLProfile.h" #include "../../GLTypes.h" #include "../../Ext/GLExtensions.h" #include "../../../../Core/Assertion.h" diff --git a/sources/Renderer/OpenGL/Profile/WebGL/WebGLProfileCaps.cpp b/sources/Renderer/OpenGL/Profile/WebGL/WebGLProfileCaps.cpp index 4fe297ab3d..bac1c7e098 100644 --- a/sources/Renderer/OpenGL/Profile/WebGL/WebGLProfileCaps.cpp +++ b/sources/Renderer/OpenGL/Profile/WebGL/WebGLProfileCaps.cpp @@ -6,7 +6,6 @@ */ #include "../../GLRenderingCaps.h" -#include "../../GLProfile.h" #include "../../GLTypes.h" #include "../../Ext/GLExtensions.h" #include "../../Ext/GLExtensionRegistry.h" diff --git a/sources/Renderer/OpenGL/Texture/GLEmulatedSampler.cpp b/sources/Renderer/OpenGL/Texture/GLEmulatedSampler.cpp index 6e4b861ec6..33d0fc28b2 100644 --- a/sources/Renderer/OpenGL/Texture/GLEmulatedSampler.cpp +++ b/sources/Renderer/OpenGL/Texture/GLEmulatedSampler.cpp @@ -24,12 +24,16 @@ static GLenum GetGLSamplerMinFilter(const SamplerDescriptor& desc) return GLTypes::Map(desc.minFilter); } +#if LLGL_SAMPLER_BORDER_COLOR + static bool IsGLTextureWrapUsingBorder(GLenum mode) { /* Accroding to GL2.x spec: "Border texture elements are accessed only if wrapping is set to GL_CLAMP or GL_CLAMP_TO_BORDER" */ return (mode == GL_CLAMP || mode == GL_CLAMP_TO_BORDER); } +#endif // /LLGL_SAMPLER_BORDER_COLOR + void GLEmulatedSampler::SamplerParameters(const SamplerDescriptor& desc) { /* Store texture coordinate wrap modes */ @@ -40,28 +44,38 @@ void GLEmulatedSampler::SamplerParameters(const SamplerDescriptor& desc) /* Store filter states */ minFilter_ = GetGLSamplerMinFilter(desc); magFilter_ = GLTypes::Map(desc.magFilter); + #if LLGL_OPENGL maxAnisotropy_ = static_cast(desc.maxAnisotropy); + #endif /* Store MIP-map level selection */ minLod_ = desc.minLOD; maxLod_ = desc.maxLOD; + #if LLGL_OPENGL lodBias_ = desc.mipMapLODBias; + #endif /* Store compare operation */ if (desc.compareEnabled) { + #if LLGL_GL_ENABLE_OPENGL2X compareMode_ = GL_COMPARE_R_TO_TEXTURE; + #else + compareMode_ = GL_COMPARE_REF_TO_TEXTURE; + #endif compareFunc_ = GLTypes::Map(desc.compareOp); } else compareMode_ = GL_NONE; + #if LLGL_SAMPLER_BORDER_COLOR /* Set border color */ borderColor_[0] = (std::max)(0.0f, (std::min)(desc.borderColor[0], 1.0f)); borderColor_[1] = (std::max)(0.0f, (std::min)(desc.borderColor[1], 1.0f)); borderColor_[2] = (std::max)(0.0f, (std::min)(desc.borderColor[2], 1.0f)); borderColor_[3] = (std::max)(0.0f, (std::min)(desc.borderColor[3], 1.0f)); borderColorUsed_ = (IsGLTextureWrapUsingBorder(wrapS_) || IsGLTextureWrapUsingBorder(wrapT_) || IsGLTextureWrapUsingBorder(wrapR_)); + #endif // /LLGL_SAMPLER_BORDER_COLOR } static void GLSetTexParameteri(GLenum target, GLenum param, GLint value) @@ -112,15 +126,21 @@ void GLEmulatedSampler::BindTexParameters(GLenum target, const GLEmulatedSampler GLChangeTexParameteri(target, GL_TEXTURE_WRAP_R, wrapR_, prevSampler->wrapR_); GLChangeTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter_, prevSampler->minFilter_); GLChangeTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter_, prevSampler->magFilter_); + #if LLGL_OPENGL GLChangeTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY, maxAnisotropy_, prevSampler->maxAnisotropy_); + #endif GLChangeTexParameterf(target, GL_TEXTURE_MIN_LOD, minLod_, prevSampler->minLod_); GLChangeTexParameterf(target, GL_TEXTURE_MAX_LOD, maxLod_, prevSampler->maxLod_); + #if LLGL_OPENGL GLChangeTexParameterf(target, GL_TEXTURE_LOD_BIAS, lodBias_, prevSampler->lodBias_); + #endif GLChangeTexParameteri(target, GL_TEXTURE_COMPARE_MODE, compareMode_, prevSampler->compareMode_); if (compareMode_ != GL_NONE) GLChangeTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, compareFunc_, prevSampler->compareFunc_); + #if LLGL_SAMPLER_BORDER_COLOR if (borderColorUsed_) GLChangeTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColor_, prevSampler->borderColor_); + #endif } else { @@ -130,13 +150,19 @@ void GLEmulatedSampler::BindTexParameters(GLenum target, const GLEmulatedSampler GLSetTexParameteri(target, GL_TEXTURE_WRAP_R, wrapR_); GLSetTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter_); GLSetTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter_); + #if LLGL_OPENGL GLSetTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY, maxAnisotropy_); + #endif GLSetTexParameterf(target, GL_TEXTURE_MIN_LOD, minLod_); GLSetTexParameterf(target, GL_TEXTURE_MAX_LOD, maxLod_); + #if LLGL_OPENGL GLSetTexParameterf(target, GL_TEXTURE_LOD_BIAS, lodBias_); + #endif GLSetTexParameteri(target, GL_TEXTURE_COMPARE_MODE, compareMode_); GLSetTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, compareFunc_); + #if LLGL_SAMPLER_BORDER_COLOR GLSetTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColor_); + #endif } } @@ -147,16 +173,21 @@ int GLEmulatedSampler::CompareSWO(const GLEmulatedSampler& lhs, const GLEmulated LLGL_COMPARE_MEMBER_SWO( wrapR_ ); LLGL_COMPARE_MEMBER_SWO( minFilter_ ); LLGL_COMPARE_MEMBER_SWO( magFilter_ ); + #if LLGL_OPENGL LLGL_COMPARE_MEMBER_SWO( maxAnisotropy_ ); + #endif LLGL_COMPARE_MEMBER_SWO( minLod_ ); LLGL_COMPARE_MEMBER_SWO( maxLod_ ); + #if LLGL_OPENGL LLGL_COMPARE_MEMBER_SWO( lodBias_ ); + #endif LLGL_COMPARE_MEMBER_SWO( compareMode_ ); if (lhs.compareMode_ != GL_NONE) { /* Only compare comparison-function if compare-mode is enabled */ LLGL_COMPARE_MEMBER_SWO( compareFunc_ ); } + #if LLGL_SAMPLER_BORDER_COLOR if (lhs.borderColorUsed_) { LLGL_COMPARE_MEMBER_SWO( borderColor_[0] ); @@ -164,6 +195,7 @@ int GLEmulatedSampler::CompareSWO(const GLEmulatedSampler& lhs, const GLEmulated LLGL_COMPARE_MEMBER_SWO( borderColor_[2] ); LLGL_COMPARE_MEMBER_SWO( borderColor_[3] ); } + #endif // /LLGL_SAMPLER_BORDER_COLOR return 0; } diff --git a/sources/Renderer/OpenGL/Texture/GLEmulatedSampler.h b/sources/Renderer/OpenGL/Texture/GLEmulatedSampler.h index 2a9730f45e..11ef743bfc 100644 --- a/sources/Renderer/OpenGL/Texture/GLEmulatedSampler.h +++ b/sources/Renderer/OpenGL/Texture/GLEmulatedSampler.h @@ -42,14 +42,20 @@ class GLEmulatedSampler final : public Sampler GLint wrapR_ = GL_REPEAT; GLint minFilter_ = GL_NEAREST_MIPMAP_LINEAR; GLint magFilter_ = GL_LINEAR; + #if LLGL_OPENGL GLfloat maxAnisotropy_ = 0.0f; + #endif GLfloat minLod_ = -1000.0f; GLfloat maxLod_ = +1000.0f; + #if LLGL_OPENGL GLfloat lodBias_ = 0.0f; + #endif GLint compareMode_ = GL_NONE; GLint compareFunc_ = GL_LESS; + #if LLGL_SAMPLER_BORDER_COLOR GLfloat borderColor_[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; bool borderColorUsed_ = false; + #endif };