Skip to content

Commit

Permalink
[GL] Fixed compile error in GLES profile on iOS.
Browse files Browse the repository at this point in the history
GLES on iOS does not define GL_COLOR_ATTACHMENT31.
The GLES backend also doesn't need more color attachments than is defined through LLGL_MAX_NUM_COLOR_ATTACHMENTS.
  • Loading branch information
LukasBanana committed Sep 7, 2024
1 parent adca275 commit 794ed2d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions include/LLGL/SamplerFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct LLGL_EXPORT SamplerDescriptor
/**
\brief MIP-mapping level-of-detail (LOD) bias (or rather offset). By default 0.
\remarks For Metal and OpenGLES, the LOD bias can only be specified within the shader code.
\note Only supported with: OpenGL, Vulkan, Direct3D 11, Direct3D 12.
\note Only supported with: OpenGL (Desktop only), Vulkan, Direct3D 11, Direct3D 12.
*/
float mipMapLODBias = 0.0f;

Expand All @@ -148,7 +148,7 @@ struct LLGL_EXPORT SamplerDescriptor

/**
\brief Maximal anisotropy in the range [1, 16].
\note Only supported with: OpenGL, Vulkan, Direct3D 11, Direct3D 12, Metal.
\note Only supported with: OpenGL (Desktop only), Vulkan, Direct3D 11, Direct3D 12, Metal.
*/
std::uint32_t maxAnisotropy = 1;

Expand Down
16 changes: 8 additions & 8 deletions sources/Renderer/OpenGL/GLESProfile/GLESProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace GLProfile

int GetRendererID()
{
return RendererID::OpenGLES3;
return RendererID::OpenGLES;
}

const char* GetModuleName()
Expand Down Expand Up @@ -99,22 +99,22 @@ void UnmapBuffer(GLenum target)
glUnmapBuffer(target);
}

// Global memory bank of CL_COLOR_ATTACHMENT0-31 values initialized with GL_NONE
static GLenum g_colorAttachmentsBank[32] =
// Global memory bank of CL_COLOR_ATTACHMENT0-7 values initialized with GL_NONE
static GLenum g_colorAttachmentsBank[8] =
{
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
#if LLGL_MAX_NUM_COLOR_ATTACHMENTS > 8
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
#endif
};

static_assert(LLGL_MAX_NUM_COLOR_ATTACHMENTS <= 16, "GLES profile can only handle up to 16 color attachments, but LLGL_MAX_NUM_COLOR_ATTACHMENTS exceed that limit");

void DrawBuffer(GLenum buf)
{
if (buf >= GL_COLOR_ATTACHMENT0 && buf <= GL_COLOR_ATTACHMENT31)
if (buf >= GL_COLOR_ATTACHMENT0 && buf <= GL_COLOR_ATTACHMENT0 + LLGL_MAX_NUM_COLOR_ATTACHMENTS)
{
/*
GL_COLOR_ATTACHMENT(i) must only be used at the i-th binding point in GLES/WebGL,
Expand Down
14 changes: 7 additions & 7 deletions sources/Renderer/OpenGL/WebGLProfile/WebGLProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,22 @@ void UnmapBuffer(GLenum target)
}
}

// Global memory bank of CL_COLOR_ATTACHMENT0-31 values initialized with GL_NONE
static GLenum g_colorAttachmentsBank[32] =
// Global memory bank of CL_COLOR_ATTACHMENT0-7 values initialized with GL_NONE
static GLenum g_colorAttachmentsBank[8] =
{
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
#if LLGL_MAX_NUM_COLOR_ATTACHMENTS > 8
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
GL_NONE, GL_NONE, GL_NONE, GL_NONE,
#endif
};

static_assert(LLGL_MAX_NUM_COLOR_ATTACHMENTS <= 16, "WebGL profile can only handle up to 16 color attachments, but LLGL_MAX_NUM_COLOR_ATTACHMENTS exceed that limit");

void DrawBuffer(GLenum buf)
{
if (buf >= GL_COLOR_ATTACHMENT0 && buf <= GL_COLOR_ATTACHMENT31)
if (buf >= GL_COLOR_ATTACHMENT0 && buf <= GL_COLOR_ATTACHMENT0 + LLGL_MAX_NUM_COLOR_ATTACHMENTS)
{
/*
GL_COLOR_ATTACHMENT(i) must only be used at the i-th binding point in GLES/WebGL,
Expand Down
2 changes: 2 additions & 0 deletions sources/Renderer/VirtualCommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ class VirtualCommandBuffer
return reinterpret_cast<TCommand*>(AllocAlignedDataWithOpcode(opcode, sizeof(TCommand) + payloadSize, alignof(TCommand)));
}

// Runs the input function over every command in this virtual command buffer.
// The function callback must return the size (in bytes) of the command being processed.
template <typename Functor, typename... TArgs>
void Run(Functor func, TArgs&&... args) const
{
Expand Down

0 comments on commit 794ed2d

Please sign in to comment.