mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Feat|Refactor] (MG_Backend|MG_Impl): Implement BackendObject, replacing previous methods.
This commit is contained in:
+4
-2
@@ -122,6 +122,7 @@ endif ()
|
|||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
MobileGL/Init.cpp
|
MobileGL/Init.cpp
|
||||||
|
MobileGL/GlobalObjects.cpp
|
||||||
|
|
||||||
MobileGL/MG_Util/Debug/Log.cpp
|
MobileGL/MG_Util/Debug/Log.cpp
|
||||||
|
|
||||||
@@ -171,8 +172,7 @@ set(SOURCE_FILES
|
|||||||
MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp
|
MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp
|
||||||
|
|
||||||
MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp
|
MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp
|
||||||
MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp
|
MobileGL/MG_Impl/EGLImpl/EGLImpl.cpp
|
||||||
MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.cpp
|
|
||||||
|
|
||||||
# @INSERTION_POINT:SOURCE_FILE_GLIMPL@ #
|
# @INSERTION_POINT:SOURCE_FILE_GLIMPL@ #
|
||||||
MobileGL/MG_Impl/GLImpl/Sampler/Validators.cpp
|
MobileGL/MG_Impl/GLImpl/Sampler/Validators.cpp
|
||||||
@@ -197,8 +197,10 @@ set(SOURCE_FILES
|
|||||||
MobileGL/MG_Impl/GetProcAddress.cpp
|
MobileGL/MG_Impl/GetProcAddress.cpp
|
||||||
|
|
||||||
MobileGL/MG_Backend/Init.cpp
|
MobileGL/MG_Backend/Init.cpp
|
||||||
|
MobileGL/MG_Backend/BackendObject.cpp
|
||||||
|
|
||||||
MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp
|
MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp
|
||||||
|
MobileGL/MG_Backend/DirectGLES/BackendObject_DirectGLES.cpp
|
||||||
MobileGL/MG_Backend/DirectGLES/Utils.cpp
|
MobileGL/MG_Backend/DirectGLES/Utils.cpp
|
||||||
MobileGL/MG_Backend/DirectGLES/Managers.cpp
|
MobileGL/MG_Backend/DirectGLES/Managers.cpp
|
||||||
|
|
||||||
|
|||||||
+4
-14
@@ -8,24 +8,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
#include <MG_Backend/Backends.h>
|
#include <MG_Backend/BackendObjects.h>
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL::MG_Config {
|
||||||
namespace MG_Config {
|
|
||||||
inline const String ProjectName = "MobileGL";
|
inline const String ProjectName = "MobileGL";
|
||||||
inline const String CoreName = "MobileGL Core";
|
inline const String CoreName = "MobileGL Core";
|
||||||
inline const String CoreVendor = "MobileGL-Dev (BZLZHH, Swung0x48, Tungsten)";
|
inline const String CoreVendor = "MobileGL-Dev (BZLZHH, Swung0x48, Tungsten)";
|
||||||
inline const Version CoreVersion = {26, 2, 0, "-dev", VersionType::Development};
|
inline const Version CoreVersion = {26, 2, 0, "-dev", VersionType::Development};
|
||||||
inline const VersionStringFormatAttrib DefaultVersionStringFormatAttrib = {2, 2, 0, true, true};
|
inline const VersionStringFormatAttrib DefaultVersionStringFormatAttrib = {2, 2, 0, true, true};
|
||||||
extern UniquePtr<RendererInfo> RendererInfoPtr;
|
|
||||||
|
|
||||||
namespace Backend {
|
extern BackendType ActiveBackendType;
|
||||||
#define MOBILEGL_BACKEND MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
} // namespace MobileGL::MG_Config
|
||||||
|
|
||||||
namespace Diligent {
|
|
||||||
inline const MG_Backend::Diligent::SpecificBackendType SpecificBackend =
|
|
||||||
MG_Backend::Diligent::SpecificBackendType::Vulkan;
|
|
||||||
}
|
|
||||||
} // namespace Backend
|
|
||||||
} // namespace MG_Config
|
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -33,11 +33,6 @@
|
|||||||
#define MOBILEGL_GL_API MOBILEGL_API
|
#define MOBILEGL_GL_API MOBILEGL_API
|
||||||
#define MOBILEGL_EGL_API MOBILEGL_API
|
#define MOBILEGL_EGL_API MOBILEGL_API
|
||||||
|
|
||||||
#define MOBILEGL_BACKEND_TYPE_UNKNOWN 0
|
|
||||||
#define MOBILEGL_BACKEND_TYPE_DILIGENT 1
|
|
||||||
#define MOBILEGL_BACKEND_TYPE_MRHI 2
|
|
||||||
#define MOBILEGL_BACKEND_TYPE_DIRECT_GLES 3
|
|
||||||
|
|
||||||
// ====================== MobileGL configurations ======================= //
|
// ====================== MobileGL configurations ======================= //
|
||||||
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_INFO
|
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_INFO
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// MobileGL - MobileGL/GlobalObjects.cpp
|
||||||
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||||
|
// Licensed under the GNU Lesser General Public License v3.0:
|
||||||
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
// End of Source File Header
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
namespace MobileGL {
|
||||||
|
namespace MG_Config {
|
||||||
|
BackendType ActiveBackendType;
|
||||||
|
} // namespace MG_Config
|
||||||
|
|
||||||
|
namespace MG_Backend {
|
||||||
|
UniquePtr<BackendObject> pActiveBackendObject;
|
||||||
|
GlobalBackendFunctionsTable gBackendFunctionsTable;
|
||||||
|
} // namespace MG_Backend
|
||||||
|
} // namespace MobileGL
|
||||||
+1
-2
@@ -9,7 +9,7 @@
|
|||||||
#include "Init.h"
|
#include "Init.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include <MG_Impl/Init.h>
|
#include <MG_Impl/Init.h>
|
||||||
#include <MG_Backend/Backends.h>
|
#include <MG_Backend/BackendObjects.h>
|
||||||
#include <MG_State/GLState/Core.h>
|
#include <MG_State/GLState/Core.h>
|
||||||
#include <MG_Impl/GLImpl/Texture/ProxyTexture.h>
|
#include <MG_Impl/GLImpl/Texture/ProxyTexture.h>
|
||||||
#include <MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h>
|
#include <MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h>
|
||||||
@@ -33,7 +33,6 @@ namespace MobileGL {
|
|||||||
MGLOG_I("MobileGL closing...");
|
MGLOG_I("MobileGL closing...");
|
||||||
glslang::FinalizeProcess();
|
glslang::FinalizeProcess();
|
||||||
delete MG_State::pGLContext;
|
delete MG_State::pGLContext;
|
||||||
MG_Config::RendererInfoPtr.reset();
|
|
||||||
delete MG_Impl::GLImpl::TextureImpl::pProxyTextureManager;
|
delete MG_Impl::GLImpl::TextureImpl::pProxyTextureManager;
|
||||||
delete MG_Impl::GLImpl::FramebufferImpl::pDefaultFramebufferInfo;
|
delete MG_Impl::GLImpl::FramebufferImpl::pDefaultFramebufferInfo;
|
||||||
MG_Util::Debug::Close();
|
MG_Util::Debug::Close();
|
||||||
|
|||||||
+8
-3
@@ -1,4 +1,4 @@
|
|||||||
// MobileGL - MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.h
|
// MobileGL - MobileGL/MG_Backend/BackendObject.cpp
|
||||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||||
// Licensed under the GNU Lesser General Public License v3.0:
|
// Licensed under the GNU Lesser General Public License v3.0:
|
||||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
@@ -6,5 +6,10 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-only
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#pragma once
|
#include "BackendObject.h"
|
||||||
#include <Includes.h>
|
|
||||||
|
namespace MobileGL::MG_Backend {
|
||||||
|
void BackendObject::SetWindowHandle(const WindowHandle& handle) {
|
||||||
|
m_windowHandle = handle;
|
||||||
|
}
|
||||||
|
} // namespace MobileGL::MG_Backend
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Backend/BackendObject.h
|
||||||
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||||
|
// Licensed under the GNU Lesser General Public License v3.0:
|
||||||
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
// End of Source File Header
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <Includes.h>
|
||||||
|
|
||||||
|
namespace MobileGL {
|
||||||
|
|
||||||
|
enum class BackendType {
|
||||||
|
DirectGLES,
|
||||||
|
BackendTypeCount,
|
||||||
|
Unknown = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace MG_Backend {
|
||||||
|
struct GLFunctionsTable {
|
||||||
|
void (*DrawArrays)(GLenum mode, GLint first, GLsizei count);
|
||||||
|
void (*DrawElements)(GLenum mode, GLsizei count, GLenum type, const void* indices);
|
||||||
|
void (*DrawElementsBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
|
GLint basevertex);
|
||||||
|
void (*MultiDrawElements)(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices,
|
||||||
|
GLsizei drawcount);
|
||||||
|
void (*MultiDrawElementsBaseVertex)(GLenum mode, const GLsizei* count, GLenum type,
|
||||||
|
const GLvoid* const* indices, GLsizei drawcount,
|
||||||
|
const GLint* basevertex);
|
||||||
|
void (*MultiDrawElementsIndirect)(GLenum mode, GLenum type, const void* indirect, GLsizei drawcount,
|
||||||
|
GLsizei stride);
|
||||||
|
void (*MultiDrawArraysIndirect)(GLenum mode, const void* indirect, GLsizei drawcount, GLsizei stride);
|
||||||
|
void (*DrawRangeElementsBaseVertex)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type,
|
||||||
|
const void* indices, GLint basevertex);
|
||||||
|
void (*DrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type,
|
||||||
|
const void* indices);
|
||||||
|
void (*DrawElementsInstancedBaseVertexBaseInstance)(GLenum mode, GLsizei count, GLenum type,
|
||||||
|
const void* indices, GLsizei instancecount,
|
||||||
|
GLint basevertex, GLuint baseinstance);
|
||||||
|
void (*DrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
|
GLsizei instancecount, GLint basevertex);
|
||||||
|
void (*DrawElementsInstancedBaseInstance)(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
|
GLsizei instancecount, GLuint baseinstance);
|
||||||
|
void (*DrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
|
GLsizei instancecount);
|
||||||
|
void (*DrawArraysInstancedBaseInstance)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount,
|
||||||
|
GLuint baseinstance);
|
||||||
|
void (*DrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
|
||||||
|
void (*DrawElementsIndirect)(GLenum mode, GLenum type, const void* indirect);
|
||||||
|
void (*DrawArraysIndirect)(GLenum mode, const void* indirect);
|
||||||
|
void (*Clear)(GLbitfield mask);
|
||||||
|
void (*ClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
|
||||||
|
void (*ClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat* value);
|
||||||
|
void (*ClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint* value);
|
||||||
|
void (*ClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint* value);
|
||||||
|
void (*BlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0,
|
||||||
|
GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||||
|
void (*CopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
||||||
|
GLsizei height, GLint border);
|
||||||
|
void (*CopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
|
||||||
|
GLsizei width, GLsizei height);
|
||||||
|
void (*GenerateMipmap)(GLenum target);
|
||||||
|
void (*ReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
|
||||||
|
void* pixels);
|
||||||
|
void (*GetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels);
|
||||||
|
};
|
||||||
|
struct GlobalBackendFunctionsTable {
|
||||||
|
GLFunctionsTable GL;
|
||||||
|
void (*Present)();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DynamicBackendParameters {
|
||||||
|
SizeT UniformBufferOffsetAlignment = 256;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class WindowBackend {
|
||||||
|
Android,
|
||||||
|
// TODO: X11, Wayland, Windows, macOS, etc.
|
||||||
|
WindowBackendCount,
|
||||||
|
Unknown = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WindowHandle {
|
||||||
|
WindowBackend Backend = WindowBackend::Unknown;
|
||||||
|
void* Handle = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BackendObject {
|
||||||
|
public:
|
||||||
|
virtual ~BackendObject() = default;
|
||||||
|
|
||||||
|
virtual void Initialize() = 0;
|
||||||
|
virtual void InitWindowSurface() = 0;
|
||||||
|
|
||||||
|
void SetWindowHandle(const WindowHandle& handle);
|
||||||
|
|
||||||
|
virtual const RendererInfo& GetRendererInfo() const = 0;
|
||||||
|
virtual String GetBackendAPIVersionString() const = 0;
|
||||||
|
virtual const GlobalBackendFunctionsTable& GetBackendFunctions() const = 0;
|
||||||
|
virtual const DynamicBackendParameters& GetDynamicParameters() const = 0;
|
||||||
|
virtual BackendType GetBackendType() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
WindowHandle m_windowHandle;
|
||||||
|
};
|
||||||
|
} // namespace MG_Backend
|
||||||
|
} // namespace MobileGL
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Backend/BackendObjects.h
|
||||||
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||||
|
// Licensed under the GNU Lesser General Public License v3.0:
|
||||||
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
// End of Source File Header
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <Includes.h>
|
||||||
|
#include "BackendObject.h"
|
||||||
|
#include "DirectGLES/BackendObject_DirectGLES.h"
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Backend {
|
||||||
|
extern UniquePtr<BackendObject> pActiveBackendObject;
|
||||||
|
extern GlobalBackendFunctionsTable gBackendFunctionsTable;
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
} // namespace MobileGL::MG_Backend
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
// MobileGL - MobileGL/MG_Backend/Backends.h
|
|
||||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
|
||||||
// Licensed under the GNU Lesser General Public License v3.0:
|
|
||||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
|
||||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
||||||
// SPDX-License-Identifier: LGPL-3.0-only
|
|
||||||
// End of Source File Header
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <Includes.h>
|
|
||||||
#include <MG_Util/GLExtensions.h>
|
|
||||||
|
|
||||||
namespace MobileGL {
|
|
||||||
namespace MG_Backend {
|
|
||||||
namespace Unknown {
|
|
||||||
inline RendererInfo RendererInfoUnknown = {
|
|
||||||
.RendererName = "<unknown renderer of MobileGL>", // Renderer Name
|
|
||||||
.BackendName = "<unknown backend>", // Backend Name
|
|
||||||
.ExtraVendor = ", <unknown>", // Extra vendor
|
|
||||||
.RendererGLInfo =
|
|
||||||
{
|
|
||||||
// OpenGL Info
|
|
||||||
.TargetGLVersion = {3, 3, 0}, // Target OpenGL Version
|
|
||||||
.TargetGLSLVersion = {4, 6, 0}, // Target Shading Language Version
|
|
||||||
.Extensions = {}, // OpenGL Extensions
|
|
||||||
.IsCompatibilityProfile = false // Is Compatibility Profile
|
|
||||||
},
|
|
||||||
.BackendCapability = {.AllowVSOnlyPrograms = false} // Backend Capability
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Diligent {
|
|
||||||
enum class SpecificBackendType {
|
|
||||||
Vulkan,
|
|
||||||
Metal
|
|
||||||
};
|
|
||||||
|
|
||||||
inline RendererInfo RendererInfoVulkan = {
|
|
||||||
.RendererName = "MG-DE-Vulkan", // Renderer Name
|
|
||||||
.BackendName = "Diligent Engine (Vulkan)", // Backend Name
|
|
||||||
.ExtraVendor = Nullopt, // Extra vendor
|
|
||||||
.RendererGLInfo =
|
|
||||||
{
|
|
||||||
// OpenGL Info
|
|
||||||
.TargetGLVersion = {3, 3, 0}, // Target OpenGL Version
|
|
||||||
.TargetGLSLVersion = {4, 6, 0}, // Target Shading Language Version
|
|
||||||
.Extensions = {V_OpenGL30, V_OpenGL31, V_OpenGL32, // OpenGL Extensions
|
|
||||||
V_OpenGL33},
|
|
||||||
.IsCompatibilityProfile = false // Is Compatibility Profile
|
|
||||||
},
|
|
||||||
.BackendCapability = {.AllowVSOnlyPrograms = false} // Backend Capability
|
|
||||||
};
|
|
||||||
|
|
||||||
inline RendererInfo RendererInfoMetal = {
|
|
||||||
.RendererName = "MG-DE-Metal", // Renderer Name
|
|
||||||
.BackendName = "Diligent Engine (Metal)", // Backend Name
|
|
||||||
.ExtraVendor = Nullopt, // Extra vendor
|
|
||||||
.RendererGLInfo =
|
|
||||||
{
|
|
||||||
// OpenGL Info
|
|
||||||
.TargetGLVersion = {3, 3, 0}, // Target OpenGL Version
|
|
||||||
.TargetGLSLVersion = {4, 6, 0}, // Target Shading Language Version
|
|
||||||
.Extensions = {V_OpenGL30, V_OpenGL31, V_OpenGL32, // OpenGL Extensions
|
|
||||||
V_OpenGL33},
|
|
||||||
.IsCompatibilityProfile = false // Is Compatibility Profile
|
|
||||||
},
|
|
||||||
.BackendCapability = {.AllowVSOnlyPrograms = false} // Backend Capability
|
|
||||||
};
|
|
||||||
} // namespace Diligent
|
|
||||||
|
|
||||||
namespace DirectGLES {
|
|
||||||
inline RendererInfo RendererInfo = {
|
|
||||||
.RendererName = "Espryt", // Renderer Name
|
|
||||||
.BackendName = "Direct (OpenGL ES)", // Backend Name
|
|
||||||
.ExtraVendor = Nullopt, // Extra vendor
|
|
||||||
.RendererGLInfo =
|
|
||||||
{
|
|
||||||
// OpenGL Info
|
|
||||||
.TargetGLVersion = {3, 3, 0}, // Target OpenGL Version
|
|
||||||
.TargetGLSLVersion = {4, 6, 0}, // Target Shading Language Version
|
|
||||||
.Extensions = {V_OpenGL30, V_OpenGL31, V_OpenGL32, // OpenGL Extensions
|
|
||||||
V_OpenGL33, E_GL_ARB_draw_buffers_blend},
|
|
||||||
.IsCompatibilityProfile = false // Is Compatibility Profile
|
|
||||||
},
|
|
||||||
.BackendCapability = {.AllowVSOnlyPrograms = false} // Backend Capability
|
|
||||||
};
|
|
||||||
} // namespace DirectGLES
|
|
||||||
|
|
||||||
void Init();
|
|
||||||
} // namespace MG_Backend
|
|
||||||
} // namespace MobileGL
|
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Backend/DirectGLES/BackendObject_DirectGLES.cpp
|
||||||
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||||
|
// Licensed under the GNU Lesser General Public License v3.0:
|
||||||
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
// End of Source File Header
|
||||||
|
|
||||||
|
#include "BackendObject_DirectGLES.h"
|
||||||
|
#include "MG_Backend/BackendObject.h"
|
||||||
|
#include <MG_Backend/DirectGLES/DirectGLES.h>
|
||||||
|
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Backend::DirectGLES {
|
||||||
|
BackendObject_DirectGLES::~BackendObject_DirectGLES() {
|
||||||
|
DestroyEGLContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BackendObject_DirectGLES::InitWindowSurface() {
|
||||||
|
// Only use EGL for now
|
||||||
|
auto nativeWindow = reinterpret_cast<NativeWindowType>(m_windowHandle.Handle);
|
||||||
|
if (!DirectGLES::InitWindowSurface(nativeWindow)) {
|
||||||
|
MGLOG_E("Failed to initialize window surface for DirectGLES backend");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BackendObject_DirectGLES::Initialize() {
|
||||||
|
if (!MG_Util::BackendLoader::AcquireEGLFunctions(m_EGLFunctions)) {
|
||||||
|
MGLOG_E("Failed to acquire EGL functions for DirectGLES backend");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!MG_Util::BackendLoader::AcquireGLESFunctions(m_GLESFunctions, m_EGLFunctions.eglGetProcAddress)) {
|
||||||
|
MGLOG_E("Failed to acquire GLES functions for DirectGLES backend");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_initialized = true;
|
||||||
|
|
||||||
|
DirectGLES::SetEGLFuncsTable(m_EGLFunctions);
|
||||||
|
DirectGLES::SetGLESFuncsTable(m_GLESFunctions);
|
||||||
|
|
||||||
|
if (!MG_Util::BackendLoader::FillInGLESCapabilities(m_GLESCapabilities, m_GLESFunctions, m_EGLFunctions)) {
|
||||||
|
MGLOG_E("Failed to fill in GLES capabilities for DirectGLES backend");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DirectGLES::SetGLESCapabilities(m_GLESCapabilities);
|
||||||
|
UpdateDynamicBackendParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
const RendererInfo& BackendObject_DirectGLES::GetRendererInfo() const {
|
||||||
|
static RendererInfo RendererInfo = {
|
||||||
|
.RendererName = "Espryt", // Renderer Name
|
||||||
|
.BackendName = "Direct (OpenGL ES)", // Backend Name
|
||||||
|
.ExtraVendor = Nullopt, // Extra vendor
|
||||||
|
.RendererGLInfo =
|
||||||
|
{
|
||||||
|
.TargetGLVersion = {3, 3, 0}, // Target OpenGL Version
|
||||||
|
.TargetGLSLVersion = {4, 6, 0}, // Target Shading Language Version
|
||||||
|
.Extensions = {V_OpenGL30, V_OpenGL31, V_OpenGL32, // OpenGL Extensions
|
||||||
|
V_OpenGL33, E_GL_ARB_draw_buffers_blend},
|
||||||
|
.IsCompatibilityProfile = false // Is Compatibility Profile
|
||||||
|
},
|
||||||
|
.StaticBackendCapability = {.AllowVSOnlyPrograms = false} // Backend Capability
|
||||||
|
};
|
||||||
|
return RendererInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
String BackendObject_DirectGLES::GetBackendAPIVersionString() const {
|
||||||
|
if (!m_initialized) {
|
||||||
|
return "<uninitialized DirectGLES backend>";
|
||||||
|
}
|
||||||
|
// Format:
|
||||||
|
// <OpenGL ES Renderer>, OpenGL ES <OpenGL ES Version>
|
||||||
|
String versionString = std::format("{}, OpenGL ES {}.{}", m_GLESCapabilities.GLESRendererString,
|
||||||
|
m_GLESCapabilities.GLESVersion.Major, m_GLESCapabilities.GLESVersion.Minor);
|
||||||
|
return versionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
BackendType BackendObject_DirectGLES::GetBackendType() const {
|
||||||
|
return BackendType::DirectGLES;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GlobalBackendFunctionsTable& BackendObject_DirectGLES::GetBackendFunctions() const {
|
||||||
|
static GlobalBackendFunctionsTable funcsTable;
|
||||||
|
static Bool funcsTableInitialized = false;
|
||||||
|
if (!funcsTableInitialized) {
|
||||||
|
funcsTable.Present = DirectGLES::Present;
|
||||||
|
funcsTable.GL.DrawArrays = DrawArrays;
|
||||||
|
funcsTable.GL.DrawElements = DrawElements;
|
||||||
|
funcsTable.GL.DrawElementsBaseVertex = DrawElementsBaseVertex;
|
||||||
|
funcsTable.GL.MultiDrawElements = MultiDrawElements;
|
||||||
|
funcsTable.GL.MultiDrawElementsBaseVertex = MultiDrawElementsBaseVertex;
|
||||||
|
funcsTable.GL.MultiDrawElementsIndirect = MultiDrawElementsIndirect;
|
||||||
|
funcsTable.GL.MultiDrawArraysIndirect = MultiDrawArraysIndirect;
|
||||||
|
funcsTable.GL.DrawRangeElementsBaseVertex = DrawRangeElementsBaseVertex;
|
||||||
|
funcsTable.GL.DrawRangeElements = DrawRangeElements;
|
||||||
|
funcsTable.GL.DrawElementsInstancedBaseVertexBaseInstance = DrawElementsInstancedBaseVertexBaseInstance;
|
||||||
|
funcsTable.GL.DrawElementsInstancedBaseVertex = DrawElementsInstancedBaseVertex;
|
||||||
|
funcsTable.GL.DrawElementsInstancedBaseInstance = DrawElementsInstancedBaseInstance;
|
||||||
|
funcsTable.GL.DrawElementsInstanced = DrawElementsInstanced;
|
||||||
|
funcsTable.GL.DrawArraysInstancedBaseInstance = DrawArraysInstancedBaseInstance;
|
||||||
|
funcsTable.GL.DrawArraysInstanced = DrawArraysInstanced;
|
||||||
|
funcsTable.GL.DrawElementsIndirect = DrawElementsIndirect;
|
||||||
|
funcsTable.GL.DrawArraysIndirect = DrawArraysIndirect;
|
||||||
|
funcsTable.GL.Clear = Clear;
|
||||||
|
funcsTable.GL.ClearBufferfi = ClearBufferfi;
|
||||||
|
funcsTable.GL.ClearBufferfv = ClearBufferfv;
|
||||||
|
funcsTable.GL.ClearBufferuiv = ClearBufferuiv;
|
||||||
|
funcsTable.GL.ClearBufferiv = ClearBufferiv;
|
||||||
|
funcsTable.GL.BlitFramebuffer = BlitFramebuffer;
|
||||||
|
funcsTable.GL.CopyTexImage2D = CopyTexImage2D;
|
||||||
|
funcsTable.GL.CopyTexSubImage2D = CopyTexSubImage2D;
|
||||||
|
funcsTable.GL.GenerateMipmap = GenerateMipmap;
|
||||||
|
funcsTable.GL.ReadPixels = ReadPixels;
|
||||||
|
funcsTable.GL.GetTexImage = GetTexImage;
|
||||||
|
funcsTableInitialized = true;
|
||||||
|
}
|
||||||
|
return funcsTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DynamicBackendParameters& BackendObject_DirectGLES::GetDynamicParameters() const {
|
||||||
|
return m_dynamicParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BackendObject_DirectGLES::UpdateDynamicBackendParameters() {
|
||||||
|
m_dynamicParameters.UniformBufferOffsetAlignment = m_GLESCapabilities.UniformBufferOffsetAlignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MG_External::GLESFunctionsTable& BackendObject_DirectGLES::GetGLESFunctions() const {
|
||||||
|
return m_GLESFunctions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MG_External::EGLFunctionsTable& BackendObject_DirectGLES::GetEGLFunctions() const {
|
||||||
|
return m_EGLFunctions;
|
||||||
|
}
|
||||||
|
} // namespace MobileGL::MG_Backend::DirectGLES
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Backend/DirectGLES/BackendObject_DirectGLES.h
|
||||||
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||||
|
// Licensed under the GNU Lesser General Public License v3.0:
|
||||||
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
// End of Source File Header
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <Includes.h>
|
||||||
|
#include "../BackendObject.h"
|
||||||
|
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Backend::DirectGLES {
|
||||||
|
class BackendObject_DirectGLES : public BackendObject {
|
||||||
|
public:
|
||||||
|
~BackendObject_DirectGLES() override;
|
||||||
|
void Initialize() override;
|
||||||
|
void InitWindowSurface() override;
|
||||||
|
|
||||||
|
const RendererInfo& GetRendererInfo() const override;
|
||||||
|
String GetBackendAPIVersionString() const override;
|
||||||
|
const GlobalBackendFunctionsTable& GetBackendFunctions() const override;
|
||||||
|
const DynamicBackendParameters& GetDynamicParameters() const override;
|
||||||
|
BackendType GetBackendType() const override;
|
||||||
|
|
||||||
|
const MG_External::GLESFunctionsTable& GetGLESFunctions() const;
|
||||||
|
const MG_External::EGLFunctionsTable& GetEGLFunctions() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void UpdateDynamicBackendParameters();
|
||||||
|
|
||||||
|
Bool m_initialized = false;
|
||||||
|
MG_External::EGLFunctionsTable m_EGLFunctions;
|
||||||
|
MG_External::GLESFunctionsTable m_GLESFunctions;
|
||||||
|
MG_External::GLESCapabilities m_GLESCapabilities;
|
||||||
|
DynamicBackendParameters m_dynamicParameters;
|
||||||
|
};
|
||||||
|
} // namespace MobileGL::MG_Backend::DirectGLES
|
||||||
@@ -7,12 +7,7 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "DirectGLES.h"
|
#include "DirectGLES.h"
|
||||||
#include "GLES3/gl32.h"
|
#include "EGL/egl.h"
|
||||||
#include "MG_State/GLState/ErrorState/Error.h"
|
|
||||||
#include "MG_State/GLState/RenderState/RenderState.h"
|
|
||||||
#include "MG_State/GLState/SamplerState/SamplerObject.h"
|
|
||||||
#include "MG_Util/Debug/Log.h"
|
|
||||||
#include "MG_Util/Types.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Managers.h"
|
#include "Managers.h"
|
||||||
#include <MG_Util/Converters/GLToMG/TextureEnumConverter.h>
|
#include <MG_Util/Converters/GLToMG/TextureEnumConverter.h>
|
||||||
@@ -28,6 +23,10 @@
|
|||||||
#include <MG_Util/Texture/PixelStoreProcessor.h>
|
#include <MG_Util/Texture/PixelStoreProcessor.h>
|
||||||
|
|
||||||
namespace MobileGL::MG_Backend::DirectGLES {
|
namespace MobileGL::MG_Backend::DirectGLES {
|
||||||
|
MG_External::EGLFunctionsTable g_EGLFuncs;
|
||||||
|
MG_External::GLESFunctionsTable g_GLESFuncs;
|
||||||
|
MG_External::GLESCapabilities g_GLESCapabilities;
|
||||||
|
|
||||||
enum class DrawSyncBit : Uint32 {
|
enum class DrawSyncBit : Uint32 {
|
||||||
None = 0,
|
None = 0,
|
||||||
IndexBuffer = 1 << 0,
|
IndexBuffer = 1 << 0,
|
||||||
@@ -47,18 +46,18 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
namespace DebugImpl {
|
namespace DebugImpl {
|
||||||
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_DEBUG
|
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_DEBUG
|
||||||
void ErrorLopper::Loop(std::function<void(GLenum)> func) {
|
void ErrorLopper::Loop(std::function<void(GLenum)> func) {
|
||||||
GLenum err = MG_External::GLES::glGetError();
|
GLenum err = g_GLESFuncs.glGetError();
|
||||||
while (err != GL_NO_ERROR) {
|
while (err != GL_NO_ERROR) {
|
||||||
func(err);
|
func(err);
|
||||||
err = MG_External::GLES::glGetError();
|
err = g_GLESFuncs.glGetError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorLopper::Clear() {
|
void ErrorLopper::Clear() {
|
||||||
GLenum err = MG_External::GLES::glGetError();
|
GLenum err = g_GLESFuncs.glGetError();
|
||||||
while (err != GL_NO_ERROR) {
|
while (err != GL_NO_ERROR) {
|
||||||
MGLOG_D("Stray GL Error cleared: %s", MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("Stray GL Error cleared: %s", MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
err = MG_External::GLES::glGetError();
|
err = g_GLESFuncs.glGetError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,11 +76,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_DEBUG
|
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_DEBUG
|
||||||
OpenGLScopeMarker::OpenGLScopeMarker(String scopeName) {
|
OpenGLScopeMarker::OpenGLScopeMarker(String scopeName) {
|
||||||
MG_External::GLES::glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, scopeName.c_str());
|
g_GLESFuncs.glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, scopeName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGLScopeMarker::~OpenGLScopeMarker() {
|
OpenGLScopeMarker::~OpenGLScopeMarker() {
|
||||||
MG_External::GLES::glPopDebugGroup();
|
g_GLESFuncs.glPopDebugGroup();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
OpenGLScopeMarker::OpenGLScopeMarker(String scopeName) {}
|
OpenGLScopeMarker::OpenGLScopeMarker(String scopeName) {}
|
||||||
@@ -297,16 +296,16 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
const auto& parameters = MG_State::pGLContext->GetRenderStateParameters();
|
const auto& parameters = MG_State::pGLContext->GetRenderStateParameters();
|
||||||
|
|
||||||
if (parameters.Viewport != g_syncedRenderStateParameters.Viewport) {
|
if (parameters.Viewport != g_syncedRenderStateParameters.Viewport) {
|
||||||
MG_External::GLES::glViewport(parameters.Viewport.x(), parameters.Viewport.y(), parameters.Viewport.z(),
|
g_GLESFuncs.glViewport(parameters.Viewport.x(), parameters.Viewport.y(), parameters.Viewport.z(),
|
||||||
parameters.Viewport.w());
|
parameters.Viewport.w());
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SYNC_CAPABILITY(cap_mg, cap_gl) \
|
#define SYNC_CAPABILITY(cap_mg, cap_gl) \
|
||||||
if (parameters.cap_mg##Enabled != g_syncedRenderStateParameters.cap_mg##Enabled) { \
|
if (parameters.cap_mg##Enabled != g_syncedRenderStateParameters.cap_mg##Enabled) { \
|
||||||
if (parameters.cap_mg##Enabled) { \
|
if (parameters.cap_mg##Enabled) { \
|
||||||
MG_External::GLES::glEnable(cap_gl); \
|
g_GLESFuncs.glEnable(cap_gl); \
|
||||||
} else { \
|
} else { \
|
||||||
MG_External::GLES::glDisable(cap_gl); \
|
g_GLESFuncs.glDisable(cap_gl); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
SYNC_CAPABILITY(DepthTest, GL_DEPTH_TEST);
|
SYNC_CAPABILITY(DepthTest, GL_DEPTH_TEST);
|
||||||
@@ -340,19 +339,19 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
if (anyCapDirty) {
|
if (anyCapDirty) {
|
||||||
if (allEnabled) {
|
if (allEnabled) {
|
||||||
MG_External::GLES::glEnable(GL_BLEND);
|
g_GLESFuncs.glEnable(GL_BLEND);
|
||||||
for (auto& s : syncedStates)
|
for (auto& s : syncedStates)
|
||||||
s.Enabled = true;
|
s.Enabled = true;
|
||||||
} else if (allDisabled) {
|
} else if (allDisabled) {
|
||||||
MG_External::GLES::glDisable(GL_BLEND);
|
g_GLESFuncs.glDisable(GL_BLEND);
|
||||||
for (auto& s : syncedStates)
|
for (auto& s : syncedStates)
|
||||||
s.Enabled = false;
|
s.Enabled = false;
|
||||||
} else {
|
} else {
|
||||||
for (Uint i = 0; i < FBO::MAX_DRAW_BUFFERS; ++i) {
|
for (Uint i = 0; i < FBO::MAX_DRAW_BUFFERS; ++i) {
|
||||||
if (targetStates[i].Enabled != syncedStates[i].Enabled) {
|
if (targetStates[i].Enabled != syncedStates[i].Enabled) {
|
||||||
syncedStates[i].Enabled = targetStates[i].Enabled;
|
syncedStates[i].Enabled = targetStates[i].Enabled;
|
||||||
syncedStates[i].Enabled ? MG_External::GLES::glEnablei(GL_BLEND, i)
|
syncedStates[i].Enabled ? g_GLESFuncs.glEnablei(GL_BLEND, i)
|
||||||
: MG_External::GLES::glDisablei(GL_BLEND, i);
|
: g_GLESFuncs.glDisablei(GL_BLEND, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,8 +381,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
if (anyFuncDirty) {
|
if (anyFuncDirty) {
|
||||||
if (allFuncsSame) {
|
if (allFuncsSame) {
|
||||||
MG_External::GLES::glBlendFuncSeparate(
|
g_GLESFuncs.glBlendFuncSeparate(MG_Util::ConvertBlendFactorToGLEnum(first.SrcFactorRGB),
|
||||||
MG_Util::ConvertBlendFactorToGLEnum(first.SrcFactorRGB),
|
|
||||||
MG_Util::ConvertBlendFactorToGLEnum(first.DstFactorRGB),
|
MG_Util::ConvertBlendFactorToGLEnum(first.DstFactorRGB),
|
||||||
MG_Util::ConvertBlendFactorToGLEnum(first.SrcFactorAlpha),
|
MG_Util::ConvertBlendFactorToGLEnum(first.SrcFactorAlpha),
|
||||||
MG_Util::ConvertBlendFactorToGLEnum(first.DstFactorAlpha));
|
MG_Util::ConvertBlendFactorToGLEnum(first.DstFactorAlpha));
|
||||||
@@ -406,7 +404,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
syn.SrcFactorAlpha = cur.SrcFactorAlpha;
|
syn.SrcFactorAlpha = cur.SrcFactorAlpha;
|
||||||
syn.DstFactorAlpha = cur.DstFactorAlpha;
|
syn.DstFactorAlpha = cur.DstFactorAlpha;
|
||||||
|
|
||||||
MG_External::GLES::glBlendFuncSeparatei(
|
g_GLESFuncs.glBlendFuncSeparatei(
|
||||||
i, MG_Util::ConvertBlendFactorToGLEnum(cur.SrcFactorRGB),
|
i, MG_Util::ConvertBlendFactorToGLEnum(cur.SrcFactorRGB),
|
||||||
MG_Util::ConvertBlendFactorToGLEnum(cur.DstFactorRGB),
|
MG_Util::ConvertBlendFactorToGLEnum(cur.DstFactorRGB),
|
||||||
MG_Util::ConvertBlendFactorToGLEnum(cur.SrcFactorAlpha),
|
MG_Util::ConvertBlendFactorToGLEnum(cur.SrcFactorAlpha),
|
||||||
@@ -419,17 +417,17 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
{ // Depth state
|
{ // Depth state
|
||||||
if (parameters.DepthFunc != g_syncedRenderStateParameters.DepthFunc) {
|
if (parameters.DepthFunc != g_syncedRenderStateParameters.DepthFunc) {
|
||||||
MG_External::GLES::glDepthFunc(MG_Util::ConvertDepthTestFuncToGLEnum(parameters.DepthFunc));
|
g_GLESFuncs.glDepthFunc(MG_Util::ConvertDepthTestFuncToGLEnum(parameters.DepthFunc));
|
||||||
}
|
}
|
||||||
if (parameters.DepthMask != g_syncedRenderStateParameters.DepthMask) {
|
if (parameters.DepthMask != g_syncedRenderStateParameters.DepthMask) {
|
||||||
MG_External::GLES::glDepthMask(parameters.DepthMask ? GL_TRUE : GL_FALSE);
|
g_GLESFuncs.glDepthMask(parameters.DepthMask ? GL_TRUE : GL_FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Color mask
|
{ // Color mask
|
||||||
if (parameters.ColorMask != g_syncedRenderStateParameters.ColorMask) {
|
if (parameters.ColorMask != g_syncedRenderStateParameters.ColorMask) {
|
||||||
const BoolVec4& colorMask = parameters.ColorMask;
|
const BoolVec4& colorMask = parameters.ColorMask;
|
||||||
MG_External::GLES::glColorMask(ToGLBoolean(colorMask.x()), ToGLBoolean(colorMask.y()),
|
g_GLESFuncs.glColorMask(ToGLBoolean(colorMask.x()), ToGLBoolean(colorMask.y()),
|
||||||
ToGLBoolean(colorMask.z()), ToGLBoolean(colorMask.w()));
|
ToGLBoolean(colorMask.z()), ToGLBoolean(colorMask.w()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -437,24 +435,24 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
{ // Clear values
|
{ // Clear values
|
||||||
if (parameters.ClearColor != g_syncedRenderStateParameters.ClearColor) {
|
if (parameters.ClearColor != g_syncedRenderStateParameters.ClearColor) {
|
||||||
const FloatVec4& clearCol = parameters.ClearColor;
|
const FloatVec4& clearCol = parameters.ClearColor;
|
||||||
MG_External::GLES::glClearColor(clearCol.x(), clearCol.y(), clearCol.z(), clearCol.w());
|
g_GLESFuncs.glClearColor(clearCol.x(), clearCol.y(), clearCol.z(), clearCol.w());
|
||||||
}
|
}
|
||||||
if (parameters.ClearDepth != g_syncedRenderStateParameters.ClearDepth) {
|
if (parameters.ClearDepth != g_syncedRenderStateParameters.ClearDepth) {
|
||||||
MG_External::GLES::glClearDepthf(parameters.ClearDepth);
|
g_GLESFuncs.glClearDepthf(parameters.ClearDepth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Cull face mode
|
{ // Cull face mode
|
||||||
if (parameters.CullFaceModeSetting != g_syncedRenderStateParameters.CullFaceModeSetting) {
|
if (parameters.CullFaceModeSetting != g_syncedRenderStateParameters.CullFaceModeSetting) {
|
||||||
const CullFaceMode& cfm = parameters.CullFaceModeSetting;
|
const CullFaceMode& cfm = parameters.CullFaceModeSetting;
|
||||||
MG_External::GLES::glCullFace(MG_Util::ConvertCullFaceModeToGLEnum(cfm));
|
g_GLESFuncs.glCullFace(MG_Util::ConvertCullFaceModeToGLEnum(cfm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Scissor box
|
{ // Scissor box
|
||||||
if (parameters.ScissorBox != g_syncedRenderStateParameters.ScissorBox) {
|
if (parameters.ScissorBox != g_syncedRenderStateParameters.ScissorBox) {
|
||||||
const IntVec4& scissorBox = parameters.ScissorBox;
|
const IntVec4& scissorBox = parameters.ScissorBox;
|
||||||
MG_External::GLES::glScissor(scissorBox.x(), scissorBox.y(), scissorBox.z(), scissorBox.w());
|
g_GLESFuncs.glScissor(scissorBox.x(), scissorBox.y(), scissorBox.z(), scissorBox.w());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +468,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#endif
|
#endif
|
||||||
auto currentProgram = MG_State::pGLContext->GetCurrentProgram();
|
auto currentProgram = MG_State::pGLContext->GetCurrentProgram();
|
||||||
if (!currentProgram || !currentProgram->GetLinkStatus()) {
|
if (!currentProgram || !currentProgram->GetLinkStatus()) {
|
||||||
MG_External::GLES::glUseProgram(0);
|
g_GLESFuncs.glUseProgram(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto& backendProgramIt = g_backendProgramObjects.find(currentProgram);
|
const auto& backendProgramIt = g_backendProgramObjects.find(currentProgram);
|
||||||
@@ -506,8 +504,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("Binding default framebuffer as %s FBO", (target == FramebufferTarget::Read ? "READ" : "DRAW"));
|
MGLOG_D("Binding default framebuffer as %s FBO", (target == FramebufferTarget::Read ? "READ" : "DRAW"));
|
||||||
MG_External::GLES::glBindFramebuffer(
|
g_GLESFuncs.glBindFramebuffer(target == FramebufferTarget::Draw ? GL_DRAW_FRAMEBUFFER : GL_READ_FRAMEBUFFER,
|
||||||
target == FramebufferTarget::Draw ? GL_DRAW_FRAMEBUFFER : GL_READ_FRAMEBUFFER, 0);
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,7 +533,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
backendVAOIt->second->Bind();
|
backendVAOIt->second->Bind();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MG_External::GLES::glBindVertexArray(0);
|
g_GLESFuncs.glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,18 +590,17 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedNC("UpdateGlobalUBO", TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedNC("UpdateGlobalUBO", TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glBindBuffer(GL_UNIFORM_BUFFER,
|
g_GLESFuncs.glBindBuffer(GL_UNIFORM_BUFFER, backendProgramIt->second->GetBackendGlobalUBOId());
|
||||||
backendProgramIt->second->GetBackendGlobalUBOId());
|
g_GLESFuncs.glBufferSubData(GL_UNIFORM_BUFFER, 0, currentProgram->GetUBOSize(),
|
||||||
MG_External::GLES::glBufferSubData(GL_UNIFORM_BUFFER, 0, currentProgram->GetUBOSize(),
|
|
||||||
currentProgram->MapUBO());
|
currentProgram->MapUBO());
|
||||||
MG_External::GLES::glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
g_GLESFuncs.glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||||
|
|
||||||
Uint blockIndex = MG_External::GLES::glGetUniformBlockIndex(
|
Uint blockIndex = g_GLESFuncs.glGetUniformBlockIndex(backendProgramId,
|
||||||
backendProgramId, MG_Util::ShaderTranspiler::GLOBAL_UBO_NAME);
|
MG_Util::ShaderTranspiler::GLOBAL_UBO_NAME);
|
||||||
|
|
||||||
MG_External::GLES::glUniformBlockBinding(backendProgramId, blockIndex, 0);
|
g_GLESFuncs.glUniformBlockBinding(backendProgramId, blockIndex, 0);
|
||||||
|
|
||||||
MG_External::GLES::glBindBufferBase(GL_UNIFORM_BUFFER, 0,
|
g_GLESFuncs.glBindBufferBase(GL_UNIFORM_BUFFER, 0,
|
||||||
backendProgramIt->second->GetBackendGlobalUBOId());
|
backendProgramIt->second->GetBackendGlobalUBOId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,9 +618,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
// Connect program ubo index to backend binding point
|
// Connect program ubo index to backend binding point
|
||||||
auto binding = currentProgram->GetUniformBlockBinding(i);
|
auto binding = currentProgram->GetUniformBlockBinding(i);
|
||||||
auto& name = currentProgram->GetUniformBlockName(i);
|
auto& name = currentProgram->GetUniformBlockName(i);
|
||||||
GLuint backendBlkIdx =
|
GLuint backendBlkIdx = g_GLESFuncs.glGetUniformBlockIndex(backendProgramId, name.c_str());
|
||||||
MG_External::GLES::glGetUniformBlockIndex(backendProgramId, name.c_str());
|
g_GLESFuncs.glUniformBlockBinding(backendProgramId, backendBlkIdx, lastUBOBinding);
|
||||||
MG_External::GLES::glUniformBlockBinding(backendProgramId, backendBlkIdx, lastUBOBinding);
|
|
||||||
|
|
||||||
// Connect buffer to backend binding point
|
// Connect buffer to backend binding point
|
||||||
auto& point = MG_State::pGLContext->GetBufferBindingPoint(BufferTarget::Uniform, binding);
|
auto& point = MG_State::pGLContext->GetBufferBindingPoint(BufferTarget::Uniform, binding);
|
||||||
@@ -636,10 +632,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
const auto& backendBufferObject = backendBufferIt->second;
|
const auto& backendBufferObject = backendBufferIt->second;
|
||||||
backendBufferObject->Bind(GL_UNIFORM_BUFFER);
|
backendBufferObject->Bind(GL_UNIFORM_BUFFER);
|
||||||
if (range.end == 0) {
|
if (range.end == 0) {
|
||||||
MG_External::GLES::glBindBufferBase(GL_UNIFORM_BUFFER, lastUBOBinding,
|
g_GLESFuncs.glBindBufferBase(GL_UNIFORM_BUFFER, lastUBOBinding,
|
||||||
backendBufferObject->GetBackendBufferId());
|
backendBufferObject->GetBackendBufferId());
|
||||||
} else {
|
} else {
|
||||||
MG_External::GLES::glBindBufferRange(GL_UNIFORM_BUFFER, lastUBOBinding,
|
g_GLESFuncs.glBindBufferRange(GL_UNIFORM_BUFFER, lastUBOBinding,
|
||||||
backendBufferObject->GetBackendBufferId(),
|
backendBufferObject->GetBackendBufferId(),
|
||||||
range.start, range.end - range.start);
|
range.start, range.end - range.start);
|
||||||
}
|
}
|
||||||
@@ -660,9 +656,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
auto unit = currentProgram->GetUniformSamplerOrImageUnitIndex(loc);
|
auto unit = currentProgram->GetUniformSamplerOrImageUnitIndex(loc);
|
||||||
if (unit == -1) continue;
|
if (unit == -1) continue;
|
||||||
auto& name = currentProgram->GetUniformName(loc);
|
auto& name = currentProgram->GetUniformName(loc);
|
||||||
auto locAtBackend = MG_External::GLES::glGetUniformLocation(
|
auto locAtBackend = g_GLESFuncs.glGetUniformLocation(
|
||||||
backendProgramIt->second->GetBackendProgramId(), name.c_str());
|
backendProgramIt->second->GetBackendProgramId(), name.c_str());
|
||||||
MG_External::GLES::glUniform1i(locAtBackend, unit);
|
g_GLESFuncs.glUniform1i(locAtBackend, unit);
|
||||||
|
|
||||||
auto samplerObject = MG_State::pGLContext->GetTextureUnitObject(unit).GetSamplerObject();
|
auto samplerObject = MG_State::pGLContext->GetTextureUnitObject(unit).GetSamplerObject();
|
||||||
|
|
||||||
@@ -682,7 +678,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MG_External::GLES::glUseProgram(0);
|
g_GLESFuncs.glUseProgram(0);
|
||||||
MGLOG_E("No backend program found (maybe not synced) for current program, cannot use program.");
|
MGLOG_E("No backend program found (maybe not synced) for current program, cannot use program.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -698,7 +694,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
BindCurrentFBO(FramebufferTarget::Draw);
|
BindCurrentFBO(FramebufferTarget::Draw);
|
||||||
|
|
||||||
MG_External::GLES::glClear(mask);
|
g_GLESFuncs.glClear(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) {
|
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) {
|
||||||
@@ -707,7 +703,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#endif
|
#endif
|
||||||
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer;
|
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawElements(mode, count, type, indices);
|
g_GLESFuncs.glDrawElements(mode, count, type, indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
|
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
|
||||||
@@ -716,7 +712,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#endif
|
#endif
|
||||||
DrawSyncBit syncBit = DrawSyncBit::None;
|
DrawSyncBit syncBit = DrawSyncBit::None;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawArrays(mode, first, count);
|
g_GLESFuncs.glDrawArrays(mode, first, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLint basevertex) {
|
void DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLint basevertex) {
|
||||||
@@ -725,7 +721,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#endif
|
#endif
|
||||||
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer;
|
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawElementsBaseVertex(mode, count, type, indices, basevertex);
|
g_GLESFuncs.glDrawElementsBaseVertex(mode, count, type, indices, basevertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiDrawElements(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices,
|
void MultiDrawElements(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices,
|
||||||
@@ -737,7 +733,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
|
|
||||||
for (GLsizei i = 0; i < drawcount; ++i) {
|
for (GLsizei i = 0; i < drawcount; ++i) {
|
||||||
MG_External::GLES::glDrawElements(mode, count[i], type, indices[i]);
|
g_GLESFuncs.glDrawElements(mode, count[i], type, indices[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,7 +746,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
|
|
||||||
for (GLsizei i = 0; i < drawcount; ++i) {
|
for (GLsizei i = 0; i < drawcount; ++i) {
|
||||||
MG_External::GLES::glDrawElementsBaseVertex(mode, count[i], type, indices[i], basevertex[i]);
|
g_GLESFuncs.glDrawElementsBaseVertex(mode, count[i], type, indices[i], basevertex[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,7 +760,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
for (GLsizei i = 0; i < drawcount; ++i) {
|
for (GLsizei i = 0; i < drawcount; ++i) {
|
||||||
const GLvoid* cmd = reinterpret_cast<const GLvoid*>(reinterpret_cast<const uint8_t*>(indirect) +
|
const GLvoid* cmd = reinterpret_cast<const GLvoid*>(reinterpret_cast<const uint8_t*>(indirect) +
|
||||||
i * (stride ? stride : sizeof(GLsizei) * 4));
|
i * (stride ? stride : sizeof(GLsizei) * 4));
|
||||||
MG_External::GLES::glDrawElementsIndirect(mode, type, cmd);
|
g_GLESFuncs.glDrawElementsIndirect(mode, type, cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,7 +774,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
for (GLsizei i = 0; i < drawcount; ++i) {
|
for (GLsizei i = 0; i < drawcount; ++i) {
|
||||||
const GLvoid* cmd = reinterpret_cast<const GLvoid*>(reinterpret_cast<const uint8_t*>(indirect) +
|
const GLvoid* cmd = reinterpret_cast<const GLvoid*>(reinterpret_cast<const uint8_t*>(indirect) +
|
||||||
i * (stride ? stride : sizeof(GLsizei) * 4));
|
i * (stride ? stride : sizeof(GLsizei) * 4));
|
||||||
MG_External::GLES::glDrawArraysIndirect(mode, cmd);
|
g_GLESFuncs.glDrawArraysIndirect(mode, cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,13 +782,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
const void* indices, GLint basevertex) {
|
const void* indices, GLint basevertex) {
|
||||||
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer;
|
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawRangeElementsBaseVertex(mode, start, end, count, type, indices, basevertex);
|
g_GLESFuncs.glDrawRangeElementsBaseVertex(mode, start, end, count, type, indices, basevertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices) {
|
void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices) {
|
||||||
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer;
|
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawRangeElements(mode, start, end, count, type, indices);
|
g_GLESFuncs.glDrawRangeElements(mode, start, end, count, type, indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
void DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
@@ -805,7 +801,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
GLsizei instancecount, GLint basevertex) {
|
GLsizei instancecount, GLint basevertex) {
|
||||||
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer | DrawSyncBit::Instancing;
|
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer | DrawSyncBit::Instancing;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawElementsInstancedBaseVertex(mode, count, type, indices, instancecount, basevertex);
|
g_GLESFuncs.glDrawElementsInstancedBaseVertex(mode, count, type, indices, instancecount, basevertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
void DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
@@ -817,13 +813,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount) {
|
void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount) {
|
||||||
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer | DrawSyncBit::Instancing;
|
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer | DrawSyncBit::Instancing;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawElementsInstanced(mode, count, type, indices, instancecount);
|
g_GLESFuncs.glDrawElementsInstanced(mode, count, type, indices, instancecount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsIndirect(GLenum mode, GLenum type, const void* indirect) {
|
void DrawElementsIndirect(GLenum mode, GLenum type, const void* indirect) {
|
||||||
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer | DrawSyncBit::IndirectBuffer;
|
DrawSyncBit syncBit = DrawSyncBit::IndexBuffer | DrawSyncBit::IndirectBuffer;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawElementsIndirect(mode, type, indirect);
|
g_GLESFuncs.glDrawElementsIndirect(mode, type, indirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawArraysInstancedBaseInstance(GLenum mode, GLint first, GLsizei count, GLsizei instancecount,
|
void DrawArraysInstancedBaseInstance(GLenum mode, GLint first, GLsizei count, GLsizei instancecount,
|
||||||
@@ -835,13 +831,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) {
|
void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) {
|
||||||
DrawSyncBit syncBit = DrawSyncBit::Instancing;
|
DrawSyncBit syncBit = DrawSyncBit::Instancing;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawArraysInstanced(mode, first, count, instancecount);
|
g_GLESFuncs.glDrawArraysInstanced(mode, first, count, instancecount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawArraysIndirect(GLenum mode, const void* indirect) {
|
void DrawArraysIndirect(GLenum mode, const void* indirect) {
|
||||||
DrawSyncBit syncBit = DrawSyncBit::IndirectBuffer;
|
DrawSyncBit syncBit = DrawSyncBit::IndirectBuffer;
|
||||||
PrepareForDraw(syncBit);
|
PrepareForDraw(syncBit);
|
||||||
MG_External::GLES::glDrawArraysIndirect(mode, indirect);
|
g_GLESFuncs.glDrawArraysIndirect(mode, indirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1,
|
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1,
|
||||||
@@ -871,7 +867,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
});
|
});
|
||||||
MGLOG_D("ES %s(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)", __func__, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0,
|
MGLOG_D("ES %s(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)", __func__, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0,
|
||||||
dstX1, dstY1, mask, MG_Util::ConvertGLEnumToString(filter).c_str());
|
dstX1, dstY1, mask, MG_Util::ConvertGLEnumToString(filter).c_str());
|
||||||
MG_External::GLES::glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
g_GLESFuncs.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
@@ -920,23 +916,23 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
__func__, s_prevDrawFBO, s_prevReadFBO);
|
__func__, s_prevDrawFBO, s_prevReadFBO);
|
||||||
static GLuint tempFBO = 0;
|
static GLuint tempFBO = 0;
|
||||||
if (!tempFBO) {
|
if (!tempFBO) {
|
||||||
MG_External::GLES::glGenFramebuffers(1, &tempFBO);
|
g_GLESFuncs.glGenFramebuffers(1, &tempFBO);
|
||||||
}
|
}
|
||||||
if (isRead) {
|
if (isRead) {
|
||||||
MG_External::GLES::glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint*)&s_prevReadFBO);
|
g_GLESFuncs.glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint*)&s_prevReadFBO);
|
||||||
MG_External::GLES::glBindFramebuffer(GL_READ_FRAMEBUFFER, tempFBO);
|
g_GLESFuncs.glBindFramebuffer(GL_READ_FRAMEBUFFER, tempFBO);
|
||||||
} else {
|
} else {
|
||||||
MG_External::GLES::glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&s_prevDrawFBO);
|
g_GLESFuncs.glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&s_prevDrawFBO);
|
||||||
MG_External::GLES::glBindFramebuffer(GL_DRAW_FRAMEBUFFER, tempFBO);
|
g_GLESFuncs.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, tempFBO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RestoreFBOFromTemp(Bool isRead) {
|
void RestoreFBOFromTemp(Bool isRead) {
|
||||||
if (isRead) {
|
if (isRead) {
|
||||||
MGLOG_D("%s: Restoring previous read FBO=%u", __func__, s_prevReadFBO);
|
MGLOG_D("%s: Restoring previous read FBO=%u", __func__, s_prevReadFBO);
|
||||||
MG_External::GLES::glBindFramebuffer(GL_READ_FRAMEBUFFER, s_prevReadFBO);
|
g_GLESFuncs.glBindFramebuffer(GL_READ_FRAMEBUFFER, s_prevReadFBO);
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("%s: Restoring previous draw FBO=%u", __func__, s_prevDrawFBO);
|
MGLOG_D("%s: Restoring previous draw FBO=%u", __func__, s_prevDrawFBO);
|
||||||
MG_External::GLES::glBindFramebuffer(GL_DRAW_FRAMEBUFFER, s_prevDrawFBO);
|
g_GLESFuncs.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, s_prevDrawFBO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1001,13 +997,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
MG_Util::IsStencilFormatInternalFormat(MG_Util::ConvertGLEnumToTextureInternalFormat(internalformat));
|
MG_Util::IsStencilFormatInternalFormat(MG_Util::ConvertGLEnumToTextureInternalFormat(internalformat));
|
||||||
|
|
||||||
if (!isDepthFormat) {
|
if (!isDepthFormat) {
|
||||||
MG_External::GLES::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
|
g_GLESFuncs.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("%s: Backend depth", __func__);
|
MGLOG_D("%s: Backend depth", __func__);
|
||||||
MG_External::GLES::glTexImage2D(target, level, (GLint)internalformat, width, height, border, format, type,
|
g_GLESFuncs.glTexImage2D(target, level, (GLint)internalformat, width, height, border, format, type,
|
||||||
nullptr);
|
nullptr);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
@@ -1020,14 +1016,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
GLenum attachment = isStencilFormat ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT;
|
GLenum attachment = isStencilFormat ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT;
|
||||||
TempFBOBinder tempFBOBinder(false);
|
TempFBOBinder tempFBOBinder(false);
|
||||||
MG_External::GLES::glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, target, currentTex, level);
|
g_GLESFuncs.glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, target, currentTex, level);
|
||||||
|
|
||||||
if (MG_External::GLES::glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
if (g_GLESFuncs.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
MGLOG_E("ES glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE");
|
MGLOG_E("ES glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MG_External::GLES::glBlitFramebuffer(x, y, x + width, y + height, 0, 0, width, height,
|
g_GLESFuncs.glBlitFramebuffer(x, y, x + width, y + height, 0, 0, width, height,
|
||||||
GL_DEPTH_BUFFER_BIT | (isStencilFormat ? GL_STENCIL_BUFFER_BIT : 0),
|
GL_DEPTH_BUFFER_BIT | (isStencilFormat ? GL_STENCIL_BUFFER_BIT : 0),
|
||||||
GL_NEAREST);
|
GL_NEAREST);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
@@ -1077,7 +1073,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
GLenum internalFormat;
|
GLenum internalFormat;
|
||||||
MG_External::GLES::glGetTexLevelParameteriv(target, level, GL_TEXTURE_INTERNAL_FORMAT, (GLint*)&internalFormat);
|
g_GLESFuncs.glGetTexLevelParameteriv(target, level, GL_TEXTURE_INTERNAL_FORMAT, (GLint*)&internalFormat);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
@@ -1087,7 +1083,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
Bool isStencilFormat = MG_Util::IsStencilFormatInternalFormat(mgInternalFormat);
|
Bool isStencilFormat = MG_Util::IsStencilFormatInternalFormat(mgInternalFormat);
|
||||||
|
|
||||||
if (!isDepthFormat) {
|
if (!isDepthFormat) {
|
||||||
MG_External::GLES::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
g_GLESFuncs.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
@@ -1099,16 +1095,16 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
});
|
});
|
||||||
GLenum attachment = isStencilFormat ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT;
|
GLenum attachment = isStencilFormat ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT;
|
||||||
TempFBOBinder tempFBOBinder(false);
|
TempFBOBinder tempFBOBinder(false);
|
||||||
MG_External::GLES::glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, target, currentTex, level);
|
g_GLESFuncs.glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, target, currentTex, level);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
if (MG_External::GLES::glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
if (g_GLESFuncs.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
MGLOG_E("ES glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE");
|
MGLOG_E("ES glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MG_External::GLES::glBlitFramebuffer(
|
g_GLESFuncs.glBlitFramebuffer(
|
||||||
x, y, x + width, y + height, xoffset, yoffset, xoffset + width, yoffset + height,
|
x, y, x + width, y + height, xoffset, yoffset, xoffset + width, yoffset + height,
|
||||||
GL_DEPTH_BUFFER_BIT | (isStencilFormat ? GL_STENCIL_BUFFER_BIT : 0), GL_NEAREST);
|
GL_DEPTH_BUFFER_BIT | (isStencilFormat ? GL_STENCIL_BUFFER_BIT : 0), GL_NEAREST);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
@@ -1128,11 +1124,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
auto backendTexture = TextureImpl::SyncTextureObjectToBackend(texture);
|
auto backendTexture = TextureImpl::SyncTextureObjectToBackend(texture);
|
||||||
|
|
||||||
backendTexture->Bind(target, unitIndex);
|
backendTexture->Bind(target, unitIndex);
|
||||||
MG_External::GLES::glGenerateMipmap(target);
|
g_GLESFuncs.glGenerateMipmap(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLubyte* GetString(GLenum name) {
|
const GLubyte* GetString(GLenum name) {
|
||||||
return MG_External::GLES::glGetString(name);
|
return g_GLESFuncs.glGetString(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) {
|
void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) {
|
||||||
@@ -1142,7 +1138,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
BindCurrentFBO(FramebufferTarget::Draw);
|
BindCurrentFBO(FramebufferTarget::Draw);
|
||||||
|
|
||||||
MG_External::GLES::glClearBufferfi(buffer, drawbuffer, depth, stencil);
|
g_GLESFuncs.glClearBufferfi(buffer, drawbuffer, depth, stencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) {
|
void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) {
|
||||||
@@ -1152,7 +1148,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
BindCurrentFBO(FramebufferTarget::Draw);
|
BindCurrentFBO(FramebufferTarget::Draw);
|
||||||
|
|
||||||
MG_External::GLES::glClearBufferfv(buffer, drawbuffer, value);
|
g_GLESFuncs.glClearBufferfv(buffer, drawbuffer, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) {
|
void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) {
|
||||||
@@ -1160,7 +1156,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
FramebufferImpl::SyncCurrentFBO();
|
FramebufferImpl::SyncCurrentFBO();
|
||||||
RenderStateImpl::SyncRenderState();
|
RenderStateImpl::SyncRenderState();
|
||||||
|
|
||||||
MG_External::GLES::glClearBufferiv(buffer, drawbuffer, value);
|
g_GLESFuncs.glClearBufferiv(buffer, drawbuffer, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) {
|
void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) {
|
||||||
@@ -1170,7 +1166,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
BindCurrentFBO(FramebufferTarget::Draw);
|
BindCurrentFBO(FramebufferTarget::Draw);
|
||||||
|
|
||||||
MG_External::GLES::glClearBufferuiv(buffer, drawbuffer, value);
|
g_GLESFuncs.glClearBufferuiv(buffer, drawbuffer, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
class TempPixelStoreParameterSync {
|
class TempPixelStoreParameterSync {
|
||||||
@@ -1191,28 +1187,28 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
PixelStoreParameters QueryCurrentGLPixelStoreParams(Bool isUnpack) {
|
PixelStoreParameters QueryCurrentGLPixelStoreParams(Bool isUnpack) {
|
||||||
PixelStoreParameters p;
|
PixelStoreParameters p;
|
||||||
if (!isUnpack) {
|
if (!isUnpack) {
|
||||||
MG_External::GLES::glGetIntegerv(GL_PACK_ALIGNMENT, (GLint*)&p.Alignment);
|
g_GLESFuncs.glGetIntegerv(GL_PACK_ALIGNMENT, (GLint*)&p.Alignment);
|
||||||
MG_External::GLES::glGetIntegerv(GL_PACK_ROW_LENGTH, (GLint*)&p.RowLength);
|
g_GLESFuncs.glGetIntegerv(GL_PACK_ROW_LENGTH, (GLint*)&p.RowLength);
|
||||||
MG_External::GLES::glGetIntegerv(GL_PACK_SKIP_ROWS, (GLint*)&p.SkipRows);
|
g_GLESFuncs.glGetIntegerv(GL_PACK_SKIP_ROWS, (GLint*)&p.SkipRows);
|
||||||
MG_External::GLES::glGetIntegerv(GL_PACK_SKIP_PIXELS, (GLint*)&p.SkipPixels);
|
g_GLESFuncs.glGetIntegerv(GL_PACK_SKIP_PIXELS, (GLint*)&p.SkipPixels);
|
||||||
// MG_External::GLES::glGetIntegerv(GL_PACK_IMAGE_HEIGHT, (GLint*)&p.ImageHeight);
|
// g_GLESFuncs.glGetIntegerv(GL_PACK_IMAGE_HEIGHT, (GLint*)&p.ImageHeight);
|
||||||
// MG_External::GLES::glGetIntegerv(GL_PACK_SKIP_IMAGES, (GLint*)&p.SkipImages);
|
// g_GLESFuncs.glGetIntegerv(GL_PACK_SKIP_IMAGES, (GLint*)&p.SkipImages);
|
||||||
// GLint tmp;
|
// GLint tmp;
|
||||||
// MG_External::GLES::glGetIntegerv(GL_PACK_SWAP_BYTES, &tmp);
|
// g_GLESFuncs.glGetIntegerv(GL_PACK_SWAP_BYTES, &tmp);
|
||||||
// p.SwapBytes = tmp ? true : false;
|
// p.SwapBytes = tmp ? true : false;
|
||||||
// MG_External::GLES::glGetIntegerv(GL_PACK_LSB_FIRST, &tmp);
|
// g_GLESFuncs.glGetIntegerv(GL_PACK_LSB_FIRST, &tmp);
|
||||||
// p.LSBFirst = tmp ? true : false;
|
// p.LSBFirst = tmp ? true : false;
|
||||||
} else {
|
} else {
|
||||||
MG_External::GLES::glGetIntegerv(GL_UNPACK_ALIGNMENT, (GLint*)&p.Alignment);
|
g_GLESFuncs.glGetIntegerv(GL_UNPACK_ALIGNMENT, (GLint*)&p.Alignment);
|
||||||
MG_External::GLES::glGetIntegerv(GL_UNPACK_ROW_LENGTH, (GLint*)&p.RowLength);
|
g_GLESFuncs.glGetIntegerv(GL_UNPACK_ROW_LENGTH, (GLint*)&p.RowLength);
|
||||||
MG_External::GLES::glGetIntegerv(GL_UNPACK_SKIP_ROWS, (GLint*)&p.SkipRows);
|
g_GLESFuncs.glGetIntegerv(GL_UNPACK_SKIP_ROWS, (GLint*)&p.SkipRows);
|
||||||
MG_External::GLES::glGetIntegerv(GL_UNPACK_SKIP_PIXELS, (GLint*)&p.SkipPixels);
|
g_GLESFuncs.glGetIntegerv(GL_UNPACK_SKIP_PIXELS, (GLint*)&p.SkipPixels);
|
||||||
MG_External::GLES::glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, (GLint*)&p.ImageHeight);
|
g_GLESFuncs.glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, (GLint*)&p.ImageHeight);
|
||||||
MG_External::GLES::glGetIntegerv(GL_UNPACK_SKIP_IMAGES, (GLint*)&p.SkipImages);
|
g_GLESFuncs.glGetIntegerv(GL_UNPACK_SKIP_IMAGES, (GLint*)&p.SkipImages);
|
||||||
// GLint tmp;
|
// GLint tmp;
|
||||||
// MG_External::GLES::glGetIntegerv(GL_UNPACK_SWAP_BYTES, &tmp);
|
// g_GLESFuncs.glGetIntegerv(GL_UNPACK_SWAP_BYTES, &tmp);
|
||||||
// p.SwapBytes = tmp ? true : false;
|
// p.SwapBytes = tmp ? true : false;
|
||||||
// MG_External::GLES::glGetIntegerv(GL_UNPACK_LSB_FIRST, &tmp);
|
// g_GLESFuncs.glGetIntegerv(GL_UNPACK_LSB_FIRST, &tmp);
|
||||||
// p.LSBFirst = tmp ? true : false;
|
// p.LSBFirst = tmp ? true : false;
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
@@ -1220,23 +1216,23 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
void Sync(Bool isUnpack, const PixelStoreParameters& params) {
|
void Sync(Bool isUnpack, const PixelStoreParameters& params) {
|
||||||
if (!isUnpack) {
|
if (!isUnpack) {
|
||||||
MG_External::GLES::glPixelStorei(GL_PACK_ALIGNMENT, params.Alignment);
|
g_GLESFuncs.glPixelStorei(GL_PACK_ALIGNMENT, params.Alignment);
|
||||||
MG_External::GLES::glPixelStorei(GL_PACK_ROW_LENGTH, params.RowLength);
|
g_GLESFuncs.glPixelStorei(GL_PACK_ROW_LENGTH, params.RowLength);
|
||||||
MG_External::GLES::glPixelStorei(GL_PACK_SKIP_ROWS, params.SkipRows);
|
g_GLESFuncs.glPixelStorei(GL_PACK_SKIP_ROWS, params.SkipRows);
|
||||||
MG_External::GLES::glPixelStorei(GL_PACK_SKIP_PIXELS, params.SkipPixels);
|
g_GLESFuncs.glPixelStorei(GL_PACK_SKIP_PIXELS, params.SkipPixels);
|
||||||
// MG_External::GLES::glPixelStorei(GL_PACK_IMAGE_HEIGHT, params.ImageHeight);
|
// g_GLESFuncs.glPixelStorei(GL_PACK_IMAGE_HEIGHT, params.ImageHeight);
|
||||||
// MG_External::GLES::glPixelStorei(GL_PACK_SKIP_IMAGES, params.SkipImages);
|
// g_GLESFuncs.glPixelStorei(GL_PACK_SKIP_IMAGES, params.SkipImages);
|
||||||
// MG_External::GLES::glPixelStorei(GL_PACK_SWAP_BYTES, params.SwapBytes ? GL_TRUE : GL_FALSE);
|
// g_GLESFuncs.glPixelStorei(GL_PACK_SWAP_BYTES, params.SwapBytes ? GL_TRUE : GL_FALSE);
|
||||||
// MG_External::GLES::glPixelStorei(GL_PACK_LSB_FIRST, params.LSBFirst ? GL_TRUE : GL_FALSE);
|
// g_GLESFuncs.glPixelStorei(GL_PACK_LSB_FIRST, params.LSBFirst ? GL_TRUE : GL_FALSE);
|
||||||
} else {
|
} else {
|
||||||
MG_External::GLES::glPixelStorei(GL_UNPACK_ALIGNMENT, params.Alignment);
|
g_GLESFuncs.glPixelStorei(GL_UNPACK_ALIGNMENT, params.Alignment);
|
||||||
MG_External::GLES::glPixelStorei(GL_UNPACK_ROW_LENGTH, params.RowLength);
|
g_GLESFuncs.glPixelStorei(GL_UNPACK_ROW_LENGTH, params.RowLength);
|
||||||
MG_External::GLES::glPixelStorei(GL_UNPACK_SKIP_ROWS, params.SkipRows);
|
g_GLESFuncs.glPixelStorei(GL_UNPACK_SKIP_ROWS, params.SkipRows);
|
||||||
MG_External::GLES::glPixelStorei(GL_UNPACK_SKIP_PIXELS, params.SkipPixels);
|
g_GLESFuncs.glPixelStorei(GL_UNPACK_SKIP_PIXELS, params.SkipPixels);
|
||||||
MG_External::GLES::glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, params.ImageHeight);
|
g_GLESFuncs.glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, params.ImageHeight);
|
||||||
MG_External::GLES::glPixelStorei(GL_UNPACK_SKIP_IMAGES, params.SkipImages);
|
g_GLESFuncs.glPixelStorei(GL_UNPACK_SKIP_IMAGES, params.SkipImages);
|
||||||
// MG_External::GLES::glPixelStorei(GL_UNPACK_SWAP_BYTES, params.SwapBytes ? GL_TRUE : GL_FALSE);
|
// g_GLESFuncs.glPixelStorei(GL_UNPACK_SWAP_BYTES, params.SwapBytes ? GL_TRUE : GL_FALSE);
|
||||||
// MG_External::GLES::glPixelStorei(GL_UNPACK_LSB_FIRST, params.LSBFirst ? GL_TRUE : GL_FALSE);
|
// g_GLESFuncs.glPixelStorei(GL_UNPACK_LSB_FIRST, params.LSBFirst ? GL_TRUE : GL_FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1266,7 +1262,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
MGLOG_D("ReadPixels: Applying TempPixelStoreParameterSync (PACK)");
|
MGLOG_D("ReadPixels: Applying TempPixelStoreParameterSync (PACK)");
|
||||||
TempPixelStoreParameterSync tempPackParamsSync(false);
|
TempPixelStoreParameterSync tempPackParamsSync(false);
|
||||||
|
|
||||||
GLenum fbStatus = MG_External::GLES::glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
|
GLenum fbStatus = g_GLESFuncs.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
|
||||||
MGLOG_D("ReadPixels: GL_READ_FRAMEBUFFER status = %s", MG_Util::ConvertGLEnumToString(fbStatus).c_str());
|
MGLOG_D("ReadPixels: GL_READ_FRAMEBUFFER status = %s", MG_Util::ConvertGLEnumToString(fbStatus).c_str());
|
||||||
|
|
||||||
if (fbStatus != GL_FRAMEBUFFER_COMPLETE) {
|
if (fbStatus != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
@@ -1292,32 +1288,32 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
const auto& backendBufferObject = backendBufferIt->second;
|
const auto& backendBufferObject = backendBufferIt->second;
|
||||||
backendBufferObject->Bind(GL_PIXEL_PACK_BUFFER);
|
backendBufferObject->Bind(GL_PIXEL_PACK_BUFFER);
|
||||||
MG_External::GLES::glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, (GLint*)&prevPixelPackBuffer);
|
g_GLESFuncs.glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, (GLint*)&prevPixelPackBuffer);
|
||||||
} else {
|
} else {
|
||||||
usePBO = false;
|
usePBO = false;
|
||||||
MGLOG_D("ReadPixels: Not using PBO");
|
MGLOG_D("ReadPixels: Not using PBO");
|
||||||
}
|
}
|
||||||
|
|
||||||
MGLOG_D("ReadPixels: glReadPixels()");
|
MGLOG_D("ReadPixels: glReadPixels()");
|
||||||
MG_External::GLES::glReadPixels(x, y, width, height, format, type, pixels);
|
g_GLESFuncs.glReadPixels(x, y, width, height, format, type, pixels);
|
||||||
if (usePBO) {
|
if (usePBO) {
|
||||||
// pull back to client memory if PBO is used
|
// pull back to client memory if PBO is used
|
||||||
MGLOG_D("ReadPixels: PBO used, mapping buffer to client memory");
|
MGLOG_D("ReadPixels: PBO used, mapping buffer to client memory");
|
||||||
GLvoid* pboMappedPtr = MG_External::GLES::glMapBufferRange(
|
GLvoid* pboMappedPtr = g_GLESFuncs.glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0,
|
||||||
GL_PIXEL_PACK_BUFFER, 0, pixelPackBufferObject->GetSize(), GL_MAP_READ_BIT);
|
pixelPackBufferObject->GetSize(), GL_MAP_READ_BIT);
|
||||||
if (pboMappedPtr) {
|
if (pboMappedPtr) {
|
||||||
MGLOG_D("ReadPixels: Copying data from PBO to client memory");
|
MGLOG_D("ReadPixels: Copying data from PBO to client memory");
|
||||||
SizeT size = pixelPackBufferObject->GetSize();
|
SizeT size = pixelPackBufferObject->GetSize();
|
||||||
pixelPackBufferObject->UploadSubData({pboMappedPtr, size}, 0);
|
pixelPackBufferObject->UploadSubData({pboMappedPtr, size}, 0);
|
||||||
pixelPackBufferObject->ClearDirty();
|
pixelPackBufferObject->ClearDirty();
|
||||||
MGLOG_D("ReadPixels: Unmapping PBO");
|
MGLOG_D("ReadPixels: Unmapping PBO");
|
||||||
MG_External::GLES::glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
g_GLESFuncs.glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||||
} else {
|
} else {
|
||||||
MGLOG_E("ReadPixels: glMapBufferRange returned nullptr");
|
MGLOG_E("ReadPixels: glMapBufferRange returned nullptr");
|
||||||
MGLOG_E("ReadPixels: glMapBufferRange returned nullptr");
|
MGLOG_E("ReadPixels: glMapBufferRange returned nullptr");
|
||||||
}
|
}
|
||||||
MGLOG_D("ReadPixels: Restoring previous pixel pack buffer binding %u", prevPixelPackBuffer);
|
MGLOG_D("ReadPixels: Restoring previous pixel pack buffer binding %u", prevPixelPackBuffer);
|
||||||
MG_External::GLES::glBindBuffer(GL_PIXEL_PACK_BUFFER, prevPixelPackBuffer);
|
g_GLESFuncs.glBindBuffer(GL_PIXEL_PACK_BUFFER, prevPixelPackBuffer);
|
||||||
}
|
}
|
||||||
MGLOG_D("ReadPixels: finished");
|
MGLOG_D("ReadPixels: finished");
|
||||||
}
|
}
|
||||||
@@ -1332,18 +1328,16 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
"Only GL_RGBA, GL_RGBA_INTEGER and GL_BGRA are supported currently, while requested %s.",
|
"Only GL_RGBA, GL_RGBA_INTEGER and GL_BGRA are supported currently, while requested %s.",
|
||||||
MG_Util::ConvertGLEnumToString(format).c_str());
|
MG_Util::ConvertGLEnumToString(format).c_str());
|
||||||
MOBILEGL_ASSERT(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT || type == GL_UNSIGNED_INT_2_10_10_10_REV ||
|
MOBILEGL_ASSERT(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT || type == GL_UNSIGNED_INT_2_10_10_10_REV ||
|
||||||
type == GL_INT || type == GL_FLOAT ||
|
type == GL_INT || type == GL_FLOAT || type == GL_UNSIGNED_INT_8_8_8_8 ||
|
||||||
type == GL_UNSIGNED_INT_8_8_8_8 || type == GL_UNSIGNED_INT_8_8_8_8_REV,
|
type == GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||||
"Only GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, GL_UNSIGNED_INT_2_10_10_10_REV, "
|
"Only GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, GL_UNSIGNED_INT_2_10_10_10_REV, "
|
||||||
"GL_INT, GL_FLOAT, GL_UNSIGNED_INT_8_8_8_8 and GL_UNSIGNED_INT_8_8_8_8_REV "
|
"GL_INT, GL_FLOAT, GL_UNSIGNED_INT_8_8_8_8 and GL_UNSIGNED_INT_8_8_8_8_REV "
|
||||||
"are supported currently, while requested %s.",
|
"are supported currently, while requested %s.",
|
||||||
MG_Util::ConvertGLEnumToString(type).c_str());
|
MG_Util::ConvertGLEnumToString(type).c_str());
|
||||||
|
|
||||||
GLenum esFormat = format, esType = type;
|
GLenum esFormat = format, esType = type;
|
||||||
if (esFormat == GL_BGRA)
|
if (esFormat == GL_BGRA) esFormat = GL_RGBA;
|
||||||
esFormat = GL_RGBA;
|
if (esType == GL_UNSIGNED_INT_8_8_8_8 || esType == GL_UNSIGNED_INT_8_8_8_8_REV) esType = GL_UNSIGNED_BYTE;
|
||||||
if (esType == GL_UNSIGNED_INT_8_8_8_8 || esType == GL_UNSIGNED_INT_8_8_8_8_REV)
|
|
||||||
esType = GL_UNSIGNED_BYTE;
|
|
||||||
|
|
||||||
MGLOG_D("GetTexImage: SyncNeccessaryTextures()");
|
MGLOG_D("GetTexImage: SyncNeccessaryTextures()");
|
||||||
TextureImpl::SyncNeccessaryTextures();
|
TextureImpl::SyncNeccessaryTextures();
|
||||||
@@ -1376,12 +1370,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
TempFBOBinder tempFBOBinder(true);
|
TempFBOBinder tempFBOBinder(true);
|
||||||
|
|
||||||
MGLOG_D("GetTexImage: glFramebufferTexture2D(level=%d)", level);
|
MGLOG_D("GetTexImage: glFramebufferTexture2D(level=%d)", level);
|
||||||
MG_External::GLES::glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, backendTexId,
|
g_GLESFuncs.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, backendTexId, level);
|
||||||
level);
|
|
||||||
MGLOG_D("GetTexImage: glReadBuffer(GL_COLOR_ATTACHMENT0)");
|
MGLOG_D("GetTexImage: glReadBuffer(GL_COLOR_ATTACHMENT0)");
|
||||||
MG_External::GLES::glReadBuffer(GL_COLOR_ATTACHMENT0);
|
g_GLESFuncs.glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
|
|
||||||
GLenum fbStatus = MG_External::GLES::glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
|
GLenum fbStatus = g_GLESFuncs.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
|
||||||
MGLOG_D("GetTexImage: GL_READ_FRAMEBUFFER status = %s", MG_Util::ConvertGLEnumToString(fbStatus).c_str());
|
MGLOG_D("GetTexImage: GL_READ_FRAMEBUFFER status = %s", MG_Util::ConvertGLEnumToString(fbStatus).c_str());
|
||||||
|
|
||||||
if (fbStatus != GL_FRAMEBUFFER_COMPLETE) {
|
if (fbStatus != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
@@ -1444,7 +1437,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
const auto& backendBufferObject = backendBufferIt->second;
|
const auto& backendBufferObject = backendBufferIt->second;
|
||||||
backendBufferObject->Bind(GL_PIXEL_PACK_BUFFER);
|
backendBufferObject->Bind(GL_PIXEL_PACK_BUFFER);
|
||||||
MG_External::GLES::glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, (GLint*)&prevPixelPackBuffer);
|
g_GLESFuncs.glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, (GLint*)&prevPixelPackBuffer);
|
||||||
} else {
|
} else {
|
||||||
usePBO = false;
|
usePBO = false;
|
||||||
MGLOG_D("GetTexImage: Not using PBO");
|
MGLOG_D("GetTexImage: Not using PBO");
|
||||||
@@ -1454,8 +1447,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
MGLOG_D("GetTexImage: glReadPixels(0, 0, %d, %d, %s, %s, %p)", size.x(), size.y(),
|
MGLOG_D("GetTexImage: glReadPixels(0, 0, %d, %d, %s, %s, %p)", size.x(), size.y(),
|
||||||
MG_Util::ConvertGLEnumToString(esFormat).c_str(), MG_Util::ConvertGLEnumToString(esType).c_str(), pixels);
|
MG_Util::ConvertGLEnumToString(esFormat).c_str(), MG_Util::ConvertGLEnumToString(esType).c_str(),
|
||||||
MG_External::GLES::glReadPixels(0, 0, size.x(), size.y(), esFormat, esType, pixels);
|
pixels);
|
||||||
|
g_GLESFuncs.glReadPixels(0, 0, size.x(), size.y(), esFormat, esType, pixels);
|
||||||
|
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
@@ -1463,25 +1457,25 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
if (usePBO) {
|
if (usePBO) {
|
||||||
// pull back to client memory if PBO is used
|
// pull back to client memory if PBO is used
|
||||||
MGLOG_D("ReadPixels: PBO used, mapping buffer to client memory");
|
MGLOG_D("ReadPixels: PBO used, mapping buffer to client memory");
|
||||||
GLvoid* pboMappedPtr = MG_External::GLES::glMapBufferRange(
|
GLvoid* pboMappedPtr = g_GLESFuncs.glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0,
|
||||||
GL_PIXEL_PACK_BUFFER, 0, pixelPackBufferObject->GetSize(), GL_MAP_READ_BIT);
|
pixelPackBufferObject->GetSize(), GL_MAP_READ_BIT);
|
||||||
if (pboMappedPtr) {
|
if (pboMappedPtr) {
|
||||||
MGLOG_D("ReadPixels: Copying data from PBO to client memory");
|
MGLOG_D("ReadPixels: Copying data from PBO to client memory");
|
||||||
SizeT size = pixelPackBufferObject->GetSize();
|
SizeT size = pixelPackBufferObject->GetSize();
|
||||||
pixelPackBufferObject->UploadSubData({pboMappedPtr, size}, 0);
|
pixelPackBufferObject->UploadSubData({pboMappedPtr, size}, 0);
|
||||||
pixelPackBufferObject->ClearDirty();
|
pixelPackBufferObject->ClearDirty();
|
||||||
MGLOG_D("ReadPixels: Unmapping PBO");
|
MGLOG_D("ReadPixels: Unmapping PBO");
|
||||||
MG_External::GLES::glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
g_GLESFuncs.glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||||
} else {
|
} else {
|
||||||
MGLOG_E("ReadPixels: glMapBufferRange returned nullptr");
|
MGLOG_E("ReadPixels: glMapBufferRange returned nullptr");
|
||||||
}
|
}
|
||||||
MGLOG_D("ReadPixels: Restoring previous pixel pack buffer binding %u", prevPixelPackBuffer);
|
MGLOG_D("ReadPixels: Restoring previous pixel pack buffer binding %u", prevPixelPackBuffer);
|
||||||
|
|
||||||
MG_External::GLES::glBindBuffer(GL_PIXEL_PACK_BUFFER, prevPixelPackBuffer);
|
g_GLESFuncs.glBindBuffer(GL_PIXEL_PACK_BUFFER, prevPixelPackBuffer);
|
||||||
} else {
|
} else {
|
||||||
if (esFormat == GL_RGBA && format == GL_BGRA && esType == GL_UNSIGNED_BYTE && type == GL_UNSIGNED_INT_8_8_8_8_REV) {
|
if (esFormat == GL_RGBA && format == GL_BGRA && esType == GL_UNSIGNED_BYTE &&
|
||||||
|
type == GL_UNSIGNED_INT_8_8_8_8_REV) {
|
||||||
MGLOG_D("ReadPixels: ProcessColorSwizzle BGRA (not implemented)");
|
MGLOG_D("ReadPixels: ProcessColorSwizzle BGRA (not implemented)");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1491,4 +1485,89 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
MGLOG_D("GetTexImage: finished");
|
MGLOG_D("GetTexImage: finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetEGLFuncsTable(const MG_External::EGLFunctionsTable& eglFuncs) {
|
||||||
|
g_EGLFuncs = eglFuncs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetGLESFuncsTable(const MG_External::GLESFunctionsTable& glesFuncs) {
|
||||||
|
g_GLESFuncs = glesFuncs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetGLESCapabilities(const MG_External::GLESCapabilities& capabilities) {
|
||||||
|
g_GLESCapabilities = capabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
static EGLDisplay g_Display = EGL_NO_DISPLAY;
|
||||||
|
static EGLContext g_Context = EGL_NO_CONTEXT;
|
||||||
|
static EGLSurface g_Surface = EGL_NO_SURFACE;
|
||||||
|
static EGLConfig g_Config = nullptr;
|
||||||
|
Bool InitWindowSurface(NativeWindowType window) {
|
||||||
|
// TODO: handle custom EGL paramters
|
||||||
|
if (!window) return false;
|
||||||
|
|
||||||
|
g_Display = g_EGLFuncs.eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
if (g_Display == EGL_NO_DISPLAY) return false;
|
||||||
|
|
||||||
|
if (!g_EGLFuncs.eglInitialize(g_Display, nullptr, nullptr)) return false;
|
||||||
|
g_EGLFuncs.eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
|
|
||||||
|
const EGLint configAttribs[] = {EGL_SURFACE_TYPE,
|
||||||
|
EGL_WINDOW_BIT,
|
||||||
|
EGL_RENDERABLE_TYPE,
|
||||||
|
EGL_OPENGL_ES3_BIT,
|
||||||
|
EGL_RED_SIZE,
|
||||||
|
8,
|
||||||
|
EGL_GREEN_SIZE,
|
||||||
|
8,
|
||||||
|
EGL_BLUE_SIZE,
|
||||||
|
8,
|
||||||
|
EGL_ALPHA_SIZE,
|
||||||
|
8,
|
||||||
|
EGL_DEPTH_SIZE,
|
||||||
|
24,
|
||||||
|
EGL_STENCIL_SIZE,
|
||||||
|
8,
|
||||||
|
EGL_NONE};
|
||||||
|
|
||||||
|
EGLint numConfigs = 0;
|
||||||
|
if (!g_EGLFuncs.eglChooseConfig(g_Display, configAttribs, &g_Config, 1, &numConfigs) || numConfigs == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
|
||||||
|
|
||||||
|
g_Context = g_EGLFuncs.eglCreateContext(g_Display, g_Config, EGL_NO_CONTEXT, contextAttribs);
|
||||||
|
if (g_Context == EGL_NO_CONTEXT) return false;
|
||||||
|
|
||||||
|
g_Surface = g_EGLFuncs.eglCreateWindowSurface(g_Display, g_Config, window, nullptr);
|
||||||
|
if (g_Surface == EGL_NO_SURFACE) return false;
|
||||||
|
|
||||||
|
if (!g_EGLFuncs.eglMakeCurrent(g_Display, g_Surface, g_Surface, g_Context)) return false;
|
||||||
|
|
||||||
|
MGLOG_D("EGL context created successfully: display=%p, surface=%p, context=%p. window=%p", g_Display, g_Surface,
|
||||||
|
g_Context, window);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Present() {
|
||||||
|
if (g_Display != EGL_NO_DISPLAY && g_Surface != EGL_NO_SURFACE) {
|
||||||
|
g_EGLFuncs.eglSwapBuffers(g_Display, g_Surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DestroyEGLContext() {
|
||||||
|
if (g_Display != EGL_NO_DISPLAY) {
|
||||||
|
g_EGLFuncs.eglMakeCurrent(g_Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
if (g_Context != EGL_NO_CONTEXT) {
|
||||||
|
g_EGLFuncs.eglDestroyContext(g_Display, g_Context);
|
||||||
|
g_Context = EGL_NO_CONTEXT;
|
||||||
|
}
|
||||||
|
if (g_Surface != EGL_NO_SURFACE) {
|
||||||
|
g_EGLFuncs.eglDestroySurface(g_Display, g_Surface);
|
||||||
|
g_Surface = EGL_NO_SURFACE;
|
||||||
|
}
|
||||||
|
g_EGLFuncs.eglTerminate(g_Display);
|
||||||
|
g_Display = EGL_NO_DISPLAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace MobileGL::MG_Backend::DirectGLES
|
} // namespace MobileGL::MG_Backend::DirectGLES
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
#include <MG_State/GLState/TextureState/TextureState.h>
|
#include <MG_State/GLState/TextureState/TextureState.h>
|
||||||
#include <MG_State/GLState/SamplerState/SamplerObject.h>
|
#include <MG_State/GLState/SamplerState/SamplerObject.h>
|
||||||
|
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
|
||||||
|
|
||||||
#define CallAndCheck(operation) \
|
#define CallAndCheck(operation) \
|
||||||
MGLOG_D("Call GLES func: %s", #operation); \
|
MGLOG_D("Call GLES func: %s", #operation); \
|
||||||
@@ -55,5 +56,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
const GLubyte* GetString(GLenum name);
|
const GLubyte* GetString(GLenum name);
|
||||||
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
|
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
|
||||||
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels);
|
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels);
|
||||||
|
Bool InitWindowSurface(NativeWindowType window);
|
||||||
|
void Present();
|
||||||
|
void SetEGLFuncsTable(const MG_External::EGLFunctionsTable& eglFuncs);
|
||||||
|
void SetGLESFuncsTable(const MG_External::GLESFunctionsTable& glesFuncs);
|
||||||
|
void SetGLESCapabilities(const MG_External::GLESCapabilities& capabilities);
|
||||||
|
void DestroyEGLContext();
|
||||||
|
|
||||||
|
extern MG_External::EGLFunctionsTable g_EGLFuncs;
|
||||||
|
extern MG_External::GLESFunctionsTable g_GLESFuncs;
|
||||||
|
extern MG_External::GLESCapabilities g_GLESCapabilities;
|
||||||
} // namespace MobileGL::MG_Backend::DirectGLES
|
} // namespace MobileGL::MG_Backend::DirectGLES
|
||||||
@@ -35,10 +35,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glGenBuffers(1, &m_backendBufferId);
|
g_GLESFuncs.glGenBuffers(1, &m_backendBufferId);
|
||||||
if (m_backendBufferId == 0) {
|
if (m_backendBufferId == 0) {
|
||||||
MGLOG_E("Failed to generate buffer object.");
|
MGLOG_E("Failed to generate buffer object.");
|
||||||
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(MG_External::GLES::glGetError()).c_str());
|
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(g_GLESFuncs.glGetError()).c_str());
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("Generated buffer object with ID: %u.", m_backendBufferId);
|
MGLOG_D("Generated buffer object with ID: %u.", m_backendBufferId);
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
GLenum usage = MG_Util::ConvertBufferUsageToGLEnum(stateBufferObject->GetUsage());
|
GLenum usage = MG_Util::ConvertBufferUsageToGLEnum(stateBufferObject->GetUsage());
|
||||||
|
|
||||||
Bind();
|
Bind();
|
||||||
MG_External::GLES::glBufferData(TempBufferTarget, size, data, usage);
|
g_GLESFuncs.glBufferData(TempBufferTarget, size, data, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackendBufferObject::SyncToBackend_glBufferSubData(
|
void BackendBufferObject::SyncToBackend_glBufferSubData(
|
||||||
@@ -138,7 +138,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
for (const auto& range : ranges) {
|
for (const auto& range : ranges) {
|
||||||
Bind();
|
Bind();
|
||||||
MG_External::GLES::glBufferSubData(TempBufferTarget, range.start, range.end - range.start,
|
g_GLESFuncs.glBufferSubData(TempBufferTarget, range.start, range.end - range.start,
|
||||||
reinterpret_cast<const char*>(data) + range.start);
|
reinterpret_cast<const char*>(data) + range.start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,9 +159,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
SizeT minStart = ranges.GetOverallMinStart();
|
SizeT minStart = ranges.GetOverallMinStart();
|
||||||
SizeT maxEnd = ranges.GetOverallMaxEnd();
|
SizeT maxEnd = ranges.GetOverallMaxEnd();
|
||||||
Bind();
|
Bind();
|
||||||
void* mappedData = MG_External::GLES::glMapBufferRange(
|
void* mappedData = g_GLESFuncs.glMapBufferRange(TempBufferTarget, minStart, maxEnd - minStart,
|
||||||
TempBufferTarget, minStart, maxEnd - minStart,
|
(invalidate ? GL_MAP_INVALIDATE_RANGE_BIT : 0) |
|
||||||
(invalidate ? GL_MAP_INVALIDATE_RANGE_BIT : 0) | (unsynchronized ? GL_MAP_UNSYNCHRONIZED_BIT : 0) |
|
(unsynchronized ? GL_MAP_UNSYNCHRONIZED_BIT : 0) |
|
||||||
GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
|
GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
|
||||||
const void* data = stateBufferObject->GetDataReadOnly()->data();
|
const void* data = stateBufferObject->GetDataReadOnly()->data();
|
||||||
if (mappedData) {
|
if (mappedData) {
|
||||||
@@ -169,10 +169,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
Memcpy(mappedData, reinterpret_cast<const char*>(data) + minStart, maxEnd - minStart);
|
Memcpy(mappedData, reinterpret_cast<const char*>(data) + minStart, maxEnd - minStart);
|
||||||
// Explicitly flush the dirty ranges
|
// Explicitly flush the dirty ranges
|
||||||
for (const auto& range : ranges) {
|
for (const auto& range : ranges) {
|
||||||
MG_External::GLES::glFlushMappedBufferRange(TempBufferTarget, range.start - minStart,
|
g_GLESFuncs.glFlushMappedBufferRange(TempBufferTarget, range.start - minStart,
|
||||||
range.end - range.start);
|
range.end - range.start);
|
||||||
}
|
}
|
||||||
MG_External::GLES::glUnmapBuffer(TempBufferTarget);
|
g_GLESFuncs.glUnmapBuffer(TempBufferTarget);
|
||||||
} else {
|
} else {
|
||||||
MGLOG_E("Failed to map buffer with ID: %u", m_backendBufferId);
|
MGLOG_E("Failed to map buffer with ID: %u", m_backendBufferId);
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
g_boundVertexBufferObject = this;
|
g_boundVertexBufferObject = this;
|
||||||
}
|
}
|
||||||
MG_External::GLES::glBindBuffer(target, m_backendBufferId);
|
g_GLESFuncs.glBindBuffer(target, m_backendBufferId);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnorderedMap<SharedPtr<MG_State::GLState::BufferObject>, SharedPtr<BackendBufferObject>> g_backendBufferObjects;
|
UnorderedMap<SharedPtr<MG_State::GLState::BufferObject>, SharedPtr<BackendBufferObject>> g_backendBufferObjects;
|
||||||
@@ -200,10 +200,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glGenVertexArrays(1, &m_backendVAOId);
|
g_GLESFuncs.glGenVertexArrays(1, &m_backendVAOId);
|
||||||
if (m_backendVAOId == 0) {
|
if (m_backendVAOId == 0) {
|
||||||
MGLOG_E("Failed to generate vertex array object.");
|
MGLOG_E("Failed to generate vertex array object.");
|
||||||
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(MG_External::GLES::glGetError()).c_str());
|
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(g_GLESFuncs.glGetError()).c_str());
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("Generated vertex array object with ID: %u.", m_backendVAOId);
|
MGLOG_D("Generated vertex array object with ID: %u.", m_backendVAOId);
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glBindVertexArray(m_backendVAOId);
|
g_GLESFuncs.glBindVertexArray(m_backendVAOId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackendVertexArrayObject::BindAttributeBuffer(Uint index,
|
void BackendVertexArrayObject::BindAttributeBuffer(Uint index,
|
||||||
@@ -256,9 +256,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
m_syncedAttributeVersions[attribIndex].SwitchVersion;
|
m_syncedAttributeVersions[attribIndex].SwitchVersion;
|
||||||
if (needsSyncSwitch) {
|
if (needsSyncSwitch) {
|
||||||
if (attrib.Enabled) {
|
if (attrib.Enabled) {
|
||||||
MG_External::GLES::glEnableVertexAttribArray(attribIndex);
|
g_GLESFuncs.glEnableVertexAttribArray(attribIndex);
|
||||||
} else {
|
} else {
|
||||||
MG_External::GLES::glDisableVertexAttribArray(attribIndex);
|
g_GLESFuncs.glDisableVertexAttribArray(attribIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,17 +271,17 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
BindAttributeBuffer(attribIndex, attrib);
|
BindAttributeBuffer(attribIndex, attrib);
|
||||||
|
|
||||||
if (!attrib.IsInteger) {
|
if (!attrib.IsInteger) {
|
||||||
MG_External::GLES::glVertexAttribPointer(
|
g_GLESFuncs.glVertexAttribPointer(
|
||||||
attribIndex, attrib.Size, MG_Util::ConvertDataTypeToGLEnum(attrib.Type),
|
attribIndex, attrib.Size, MG_Util::ConvertDataTypeToGLEnum(attrib.Type),
|
||||||
attrib.Normalized ? GL_TRUE : GL_FALSE, attrib.Stride, (const void*)attrib.Offset);
|
attrib.Normalized ? GL_TRUE : GL_FALSE, attrib.Stride, (const void*)attrib.Offset);
|
||||||
} else {
|
} else {
|
||||||
MG_External::GLES::glVertexAttribIPointer(attribIndex, attrib.Size,
|
g_GLESFuncs.glVertexAttribIPointer(attribIndex, attrib.Size,
|
||||||
MG_Util::ConvertDataTypeToGLEnum(attrib.Type),
|
MG_Util::ConvertDataTypeToGLEnum(attrib.Type), attrib.Stride,
|
||||||
attrib.Stride, (const void*)attrib.Offset);
|
(const void*)attrib.Offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsSyncFormat) {
|
if (needsSyncFormat) {
|
||||||
MG_External::GLES::glVertexAttribDivisor(attribIndex, attrib.Divisor);
|
g_GLESFuncs.glVertexAttribDivisor(attribIndex, attrib.Divisor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,10 +312,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glGenTextures(1, &m_backendTextureId);
|
g_GLESFuncs.glGenTextures(1, &m_backendTextureId);
|
||||||
if (m_backendTextureId == 0) {
|
if (m_backendTextureId == 0) {
|
||||||
MGLOG_E("Failed to generate texture object.");
|
MGLOG_E("Failed to generate texture object.");
|
||||||
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(MG_External::GLES::glGetError()).c_str());
|
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(g_GLESFuncs.glGetError()).c_str());
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("Generated texture object with ID: %u.", m_backendTextureId);
|
MGLOG_D("Generated texture object with ID: %u.", m_backendTextureId);
|
||||||
}
|
}
|
||||||
@@ -332,7 +332,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
auto targetN = static_cast<SizeT>(MG_Util::ConvertGLEnumToTextureTarget(target));
|
auto targetN = static_cast<SizeT>(MG_Util::ConvertGLEnumToTextureTarget(target));
|
||||||
if (this == g_boundTexturesCache[unit][targetN]) return;
|
if (this == g_boundTexturesCache[unit][targetN]) return;
|
||||||
|
|
||||||
MG_External::GLES::glBindTexture(target, m_backendTextureId);
|
g_GLESFuncs.glBindTexture(target, m_backendTextureId);
|
||||||
g_boundTexturesCache[unit][targetN] = this;
|
g_boundTexturesCache[unit][targetN] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,20 +430,20 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
levelDirty ? "true" : "false");
|
levelDirty ? "true" : "false");
|
||||||
|
|
||||||
errorLopper.Clear();
|
errorLopper.Clear();
|
||||||
MG_External::GLES::glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
g_GLESFuncs.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||||
auto textureTarget = stateTextureObject->GetTarget();
|
auto textureTarget = stateTextureObject->GetTarget();
|
||||||
// TODO: handle more texture types
|
// TODO: handle more texture types
|
||||||
switch (textureTarget) {
|
switch (textureTarget) {
|
||||||
case TextureTarget::Texture2D:
|
case TextureTarget::Texture2D:
|
||||||
case TextureTarget::TextureCubeMap: {
|
case TextureTarget::TextureCubeMap: {
|
||||||
MG_External::GLES::glTexImage2D(
|
g_GLESFuncs.glTexImage2D(glUploadTarget, static_cast<GLint>(level), glInternalFormat,
|
||||||
glUploadTarget, static_cast<GLint>(level), glInternalFormat,
|
static_cast<GLsizei>(levelTexelSize.x()),
|
||||||
static_cast<GLsizei>(levelTexelSize.x()), static_cast<GLsizei>(levelTexelSize.y()),
|
static_cast<GLsizei>(levelTexelSize.y()), 0, glFormat, glType,
|
||||||
0, glFormat, glType, pData);
|
pData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TextureTarget::Texture3D: {
|
case TextureTarget::Texture3D: {
|
||||||
MG_External::GLES::glTexImage3D(
|
g_GLESFuncs.glTexImage3D(
|
||||||
glUploadTarget, static_cast<GLint>(level), glInternalFormat,
|
glUploadTarget, static_cast<GLint>(level), glInternalFormat,
|
||||||
static_cast<GLsizei>(levelTexelSize.x()), static_cast<GLsizei>(levelTexelSize.y()),
|
static_cast<GLsizei>(levelTexelSize.x()), static_cast<GLsizei>(levelTexelSize.y()),
|
||||||
static_cast<GLsizei>(levelTexelSize.z()), 0, glFormat, glType, pData);
|
static_cast<GLsizei>(levelTexelSize.z()), 0, glFormat, glType, pData);
|
||||||
@@ -498,13 +498,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
textureMipmapObject->GetMipmapTexelSize(uploadTarget, level).y(), byteSize);
|
textureMipmapObject->GetMipmapTexelSize(uploadTarget, level).y(), byteSize);
|
||||||
|
|
||||||
auto glUploadTarget = MG_Util::ConvertTextureUploadTargetToGLEnum(uploadTarget);
|
auto glUploadTarget = MG_Util::ConvertTextureUploadTargetToGLEnum(uploadTarget);
|
||||||
MG_External::GLES::glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
g_GLESFuncs.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
||||||
MGLOG_D("%s(%s:%d) ES error: %s", func, file, line,
|
MGLOG_D("%s(%s:%d) ES error: %s", func, file, line,
|
||||||
MG_Util::ConvertGLEnumToString(err).c_str());
|
MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
auto texelSize = textureMipmapObject->GetMipmapTexelSize(uploadTarget, level);
|
auto texelSize = textureMipmapObject->GetMipmapTexelSize(uploadTarget, level);
|
||||||
MG_External::GLES::glTexSubImage2D(glUploadTarget, static_cast<GLint>(level), 0, 0,
|
g_GLESFuncs.glTexSubImage2D(glUploadTarget, static_cast<GLint>(level), 0, 0,
|
||||||
static_cast<GLsizei>(texelSize.x()),
|
static_cast<GLsizei>(texelSize.x()),
|
||||||
static_cast<GLsizei>(texelSize.y()), glFormat, glType,
|
static_cast<GLsizei>(texelSize.y()), glFormat, glType,
|
||||||
textureMipmapObject->MapMipmapData(uploadTarget, level));
|
textureMipmapObject->MapMipmapData(uploadTarget, level));
|
||||||
@@ -546,7 +546,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
TextureImpl::GenerateTextureFormatInfo(textureBufferObject->GetFormat(), &glInternalFormat, &glFormat,
|
TextureImpl::GenerateTextureFormatInfo(textureBufferObject->GetFormat(), &glInternalFormat, &glFormat,
|
||||||
&glType);
|
&glType);
|
||||||
|
|
||||||
MG_External::GLES::glTexBuffer(GL_TEXTURE_BUFFER, glInternalFormat, backendId);
|
g_GLESFuncs.glTexBuffer(GL_TEXTURE_BUFFER, glInternalFormat, backendId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -604,7 +604,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
#define SYNC_TEX_SAMPLER_PARAM_IF_CHANGED(internalName, glName, type) \
|
#define SYNC_TEX_SAMPLER_PARAM_IF_CHANGED(internalName, glName, type) \
|
||||||
if (m_cacheSamplerParameters.internalName != samplerParams.internalName) { \
|
if (m_cacheSamplerParameters.internalName != samplerParams.internalName) { \
|
||||||
MG_External::GLES::glTexParameteri(target, glName, \
|
g_GLESFuncs.glTexParameteri(target, glName, \
|
||||||
MG_Util::ConvertSampler##type##ToGLEnum(samplerParams.internalName)); \
|
MG_Util::ConvertSampler##type##ToGLEnum(samplerParams.internalName)); \
|
||||||
m_cacheSamplerParameters.internalName = samplerParams.internalName; \
|
m_cacheSamplerParameters.internalName = samplerParams.internalName; \
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__, \
|
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__, \
|
||||||
@@ -616,14 +616,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
if (m_cacheSamplerParameters.minFilter != samplerParams.minFilter ||
|
if (m_cacheSamplerParameters.minFilter != samplerParams.minFilter ||
|
||||||
m_cacheSamplerParameters.mipmapMode != samplerParams.mipmapMode) {
|
m_cacheSamplerParameters.mipmapMode != samplerParams.mipmapMode) {
|
||||||
MG_External::GLES::glTexParameteri(
|
g_GLESFuncs.glTexParameteri(
|
||||||
target, GL_TEXTURE_MIN_FILTER,
|
target, GL_TEXTURE_MIN_FILTER,
|
||||||
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.minFilter, samplerParams.mipmapMode));
|
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.minFilter, samplerParams.mipmapMode));
|
||||||
m_cacheSamplerParameters.minFilter = samplerParams.minFilter;
|
m_cacheSamplerParameters.minFilter = samplerParams.minFilter;
|
||||||
m_cacheSamplerParameters.mipmapMode = samplerParams.mipmapMode;
|
m_cacheSamplerParameters.mipmapMode = samplerParams.mipmapMode;
|
||||||
}
|
}
|
||||||
if (m_cacheSamplerParameters.magFilter != samplerParams.magFilter) {
|
if (m_cacheSamplerParameters.magFilter != samplerParams.magFilter) {
|
||||||
MG_External::GLES::glTexParameteri(
|
g_GLESFuncs.glTexParameteri(
|
||||||
target, GL_TEXTURE_MAG_FILTER,
|
target, GL_TEXTURE_MAG_FILTER,
|
||||||
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.magFilter, SamplerMipmapMode::None));
|
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.magFilter, SamplerMipmapMode::None));
|
||||||
m_cacheSamplerParameters.magFilter = samplerParams.magFilter;
|
m_cacheSamplerParameters.magFilter = samplerParams.magFilter;
|
||||||
@@ -638,11 +638,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
SYNC_TEX_SAMPLER_PARAM_IF_CHANGED(compareFunc, GL_TEXTURE_COMPARE_FUNC, CompareFunc)
|
SYNC_TEX_SAMPLER_PARAM_IF_CHANGED(compareFunc, GL_TEXTURE_COMPARE_FUNC, CompareFunc)
|
||||||
SYNC_TEX_SAMPLER_PARAM_IF_CHANGED(compareMode, GL_TEXTURE_COMPARE_MODE, CompareMode)
|
SYNC_TEX_SAMPLER_PARAM_IF_CHANGED(compareMode, GL_TEXTURE_COMPARE_MODE, CompareMode)
|
||||||
if (m_cacheSamplerParameters.minLod != samplerParams.minLod) {
|
if (m_cacheSamplerParameters.minLod != samplerParams.minLod) {
|
||||||
MG_External::GLES::glTexParameterf(target, GL_TEXTURE_MIN_LOD, samplerParams.minLod);
|
g_GLESFuncs.glTexParameterf(target, GL_TEXTURE_MIN_LOD, samplerParams.minLod);
|
||||||
m_cacheSamplerParameters.minLod = samplerParams.minLod;
|
m_cacheSamplerParameters.minLod = samplerParams.minLod;
|
||||||
}
|
}
|
||||||
if (m_cacheSamplerParameters.maxLod != samplerParams.maxLod) {
|
if (m_cacheSamplerParameters.maxLod != samplerParams.maxLod) {
|
||||||
MG_External::GLES::glTexParameterf(target, GL_TEXTURE_MAX_LOD, samplerParams.maxLod);
|
g_GLESFuncs.glTexParameterf(target, GL_TEXTURE_MAX_LOD, samplerParams.maxLod);
|
||||||
m_cacheSamplerParameters.maxLod = samplerParams.maxLod;
|
m_cacheSamplerParameters.maxLod = samplerParams.maxLod;
|
||||||
}
|
}
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
||||||
@@ -693,14 +693,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
const auto& levelRange = stateTextureObject->GetLevelRange();
|
const auto& levelRange = stateTextureObject->GetLevelRange();
|
||||||
|
|
||||||
if (m_cacheLodRange.x() != levelRange.x()) {
|
if (m_cacheLodRange.x() != levelRange.x()) {
|
||||||
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, static_cast<GLint>(levelRange.x()));
|
g_GLESFuncs.glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, static_cast<GLint>(levelRange.x()));
|
||||||
m_cacheLodRange.x() = levelRange.x();
|
m_cacheLodRange.x() = levelRange.x();
|
||||||
}
|
}
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
||||||
MGLOG_D("%s(%s:%d) ES error %s", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("%s(%s:%d) ES error %s", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
if (m_cacheLodRange.y() != levelRange.y()) {
|
if (m_cacheLodRange.y() != levelRange.y()) {
|
||||||
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, static_cast<GLint>(levelRange.y()));
|
g_GLESFuncs.glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, static_cast<GLint>(levelRange.y()));
|
||||||
m_cacheLodRange.y() = levelRange.y();
|
m_cacheLodRange.y() = levelRange.y();
|
||||||
}
|
}
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
||||||
@@ -711,8 +711,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
if (swizzleParams != m_cacheSwizzleParams) {
|
if (swizzleParams != m_cacheSwizzleParams) {
|
||||||
#define SYNC_TEX_SWIZZLE_PARAM_IF_CHANGED(func, glEnum) \
|
#define SYNC_TEX_SWIZZLE_PARAM_IF_CHANGED(func, glEnum) \
|
||||||
if (m_cacheSwizzleParams.func != swizzleParams.func) { \
|
if (m_cacheSwizzleParams.func != swizzleParams.func) { \
|
||||||
MG_External::GLES::glTexParameteri(target, glEnum, \
|
g_GLESFuncs.glTexParameteri(target, glEnum, MG_Util::ConvertTextureSwizzleParamToGLEnum(swizzleParams.func)); \
|
||||||
MG_Util::ConvertTextureSwizzleParamToGLEnum(swizzleParams.func)); \
|
|
||||||
m_cacheSwizzleParams.func = swizzleParams.func; \
|
m_cacheSwizzleParams.func = swizzleParams.func; \
|
||||||
}
|
}
|
||||||
SYNC_TEX_SWIZZLE_PARAM_IF_CHANGED(r(), GL_TEXTURE_SWIZZLE_R);
|
SYNC_TEX_SWIZZLE_PARAM_IF_CHANGED(r(), GL_TEXTURE_SWIZZLE_R);
|
||||||
@@ -729,7 +728,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
if (m_cacheBorderColor != stateTextureObject->GetBorderColor()) {
|
if (m_cacheBorderColor != stateTextureObject->GetBorderColor()) {
|
||||||
const auto& borderColor = stateTextureObject->GetBorderColor();
|
const auto& borderColor = stateTextureObject->GetBorderColor();
|
||||||
GLfloat borderColorArray[4] = {borderColor.x(), borderColor.y(), borderColor.z(), borderColor.w()};
|
GLfloat borderColorArray[4] = {borderColor.x(), borderColor.y(), borderColor.z(), borderColor.w()};
|
||||||
MG_External::GLES::glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColorArray);
|
g_GLESFuncs.glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColorArray);
|
||||||
m_cacheBorderColor = borderColor;
|
m_cacheBorderColor = borderColor;
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
|
||||||
MGLOG_D("%s(%s:%d) ES error %s", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("%s(%s:%d) ES error %s", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
@@ -741,7 +740,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
if (unit == g_activeTextureUnit) {
|
if (unit == g_activeTextureUnit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MG_External::GLES::glActiveTexture(GL_TEXTURE0 + unit);
|
g_GLESFuncs.glActiveTexture(GL_TEXTURE0 + unit);
|
||||||
g_activeTextureUnit = unit;
|
g_activeTextureUnit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,7 +752,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
auto targetN = static_cast<SizeT>(MG_Util::ConvertGLEnumToTextureTarget(target));
|
auto targetN = static_cast<SizeT>(MG_Util::ConvertGLEnumToTextureTarget(target));
|
||||||
if (g_boundTexturesCache[unit][targetN] == nullptr) return;
|
if (g_boundTexturesCache[unit][targetN] == nullptr) return;
|
||||||
|
|
||||||
MG_External::GLES::glBindTexture(target, 0);
|
g_GLESFuncs.glBindTexture(target, 0);
|
||||||
g_boundTexturesCache[unit][targetN] = nullptr;
|
g_boundTexturesCache[unit][targetN] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,10 +769,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glGenFramebuffers(1, &m_backendFBOId);
|
g_GLESFuncs.glGenFramebuffers(1, &m_backendFBOId);
|
||||||
if (m_backendFBOId == 0) {
|
if (m_backendFBOId == 0) {
|
||||||
MGLOG_E("Failed to generate framebuffer object.");
|
MGLOG_E("Failed to generate framebuffer object.");
|
||||||
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(MG_External::GLES::glGetError()).c_str());
|
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(g_GLESFuncs.glGetError()).c_str());
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("Generated framebuffer object with ID: %u.", m_backendFBOId);
|
MGLOG_D("Generated framebuffer object with ID: %u.", m_backendFBOId);
|
||||||
}
|
}
|
||||||
@@ -784,9 +783,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
if (target == FramebufferTarget::Read)
|
if (target == FramebufferTarget::Read)
|
||||||
MG_External::GLES::glBindFramebuffer(GL_READ_FRAMEBUFFER, m_backendFBOId);
|
g_GLESFuncs.glBindFramebuffer(GL_READ_FRAMEBUFFER, m_backendFBOId);
|
||||||
else
|
else
|
||||||
MG_External::GLES::glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_backendFBOId);
|
g_GLESFuncs.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_backendFBOId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool BackendFramebufferObject::SyncAttachmentObject(
|
Bool BackendFramebufferObject::SyncAttachmentObject(
|
||||||
@@ -802,7 +801,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
const auto& backendTextureObject = backendTextureIt->second;
|
const auto& backendTextureObject = backendTextureIt->second;
|
||||||
auto glTextureTarget = MG_Util::ConvertTextureTargetToGLEnum(textureObject->GetTarget());
|
auto glTextureTarget = MG_Util::ConvertTextureTargetToGLEnum(textureObject->GetTarget());
|
||||||
backendTextureObject->Bind(glTextureTarget);
|
backendTextureObject->Bind(glTextureTarget);
|
||||||
MG_External::GLES::glFramebufferTexture2D(glFBOTarget, glBackendAttachment, glTextureTarget,
|
g_GLESFuncs.glFramebufferTexture2D(glFBOTarget, glBackendAttachment, glTextureTarget,
|
||||||
backendTextureObject->GetBackendTextureId(),
|
backendTextureObject->GetBackendTextureId(),
|
||||||
static_cast<GLint>(attachmentObject.GetTextureLevel()));
|
static_cast<GLint>(attachmentObject.GetTextureLevel()));
|
||||||
} else if (attachmentObject.IsRenderbuffer()) {
|
} else if (attachmentObject.IsRenderbuffer()) {
|
||||||
@@ -819,7 +818,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
backendRenderbufferObject->SyncToBackend(renderbufferObject);
|
backendRenderbufferObject->SyncToBackend(renderbufferObject);
|
||||||
backendRenderbufferObject->Bind();
|
backendRenderbufferObject->Bind();
|
||||||
MG_External::GLES::glFramebufferRenderbuffer(glFBOTarget, glBackendAttachment, GL_RENDERBUFFER,
|
g_GLESFuncs.glFramebufferRenderbuffer(glFBOTarget, glBackendAttachment, GL_RENDERBUFFER,
|
||||||
backendRenderbufferObject->GetBackendRenderbufferId());
|
backendRenderbufferObject->GetBackendRenderbufferId());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -872,7 +871,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
nEffectiveBuffers = i + 1;
|
nEffectiveBuffers = i + 1;
|
||||||
}
|
}
|
||||||
MG_External::GLES::glDrawBuffers(nEffectiveBuffers, m_backendDrawBuffers);
|
g_GLESFuncs.glDrawBuffers(nEffectiveBuffers, m_backendDrawBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Remap read buffer
|
// 2. Remap read buffer
|
||||||
@@ -884,7 +883,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
if (m_backendReadBuffer != glBackendReadBuffer) {
|
if (m_backendReadBuffer != glBackendReadBuffer) {
|
||||||
m_backendReadBuffer = glBackendReadBuffer;
|
m_backendReadBuffer = glBackendReadBuffer;
|
||||||
MG_External::GLES::glReadBuffer(glBackendReadBuffer);
|
g_GLESFuncs.glReadBuffer(glBackendReadBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -917,14 +916,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
MG_Util::ConvertGLEnumToString(glBackendAttachment).c_str(),
|
MG_Util::ConvertGLEnumToString(glBackendAttachment).c_str(),
|
||||||
m_syncedFrontendAttachmentVersions[i]);
|
m_syncedFrontendAttachmentVersions[i]);
|
||||||
GLint objectType = GL_NONE;
|
GLint objectType = GL_NONE;
|
||||||
MG_External::GLES::glGetFramebufferAttachmentParameteriv(
|
g_GLESFuncs.glGetFramebufferAttachmentParameteriv(
|
||||||
glFBOTarget, glBackendAttachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &objectType);
|
glFBOTarget, glBackendAttachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &objectType);
|
||||||
MOBILEGL_ASSERT((objectType == GL_NONE) ||
|
MOBILEGL_ASSERT((objectType == GL_NONE) ||
|
||||||
(attachmentObject.IsTexture() && objectType == GL_TEXTURE) ||
|
(attachmentObject.IsTexture() && objectType == GL_TEXTURE) ||
|
||||||
(attachmentObject.IsRenderbuffer() && objectType == GL_RENDERBUFFER),
|
(attachmentObject.IsRenderbuffer() && objectType == GL_RENDERBUFFER),
|
||||||
"Attachment type not match!");
|
"Attachment type not match!");
|
||||||
GLint objectName = 0;
|
GLint objectName = 0;
|
||||||
MG_External::GLES::glGetFramebufferAttachmentParameteriv(
|
g_GLESFuncs.glGetFramebufferAttachmentParameteriv(
|
||||||
glFBOTarget, glBackendAttachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &objectName);
|
glFBOTarget, glBackendAttachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &objectName);
|
||||||
// Verify that the backend object's name and parameters match the frontend attachment state
|
// Verify that the backend object's name and parameters match the frontend attachment state
|
||||||
if (attachmentObject.IsTexture()) {
|
if (attachmentObject.IsTexture()) {
|
||||||
@@ -939,7 +938,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
objectName, backendTexId, textureObject->GetExternalIndex());
|
objectName, backendTexId, textureObject->GetExternalIndex());
|
||||||
|
|
||||||
GLint texLevel = 0;
|
GLint texLevel = 0;
|
||||||
MG_External::GLES::glGetFramebufferAttachmentParameteriv(
|
g_GLESFuncs.glGetFramebufferAttachmentParameteriv(
|
||||||
glFBOTarget, glBackendAttachment, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &texLevel);
|
glFBOTarget, glBackendAttachment, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &texLevel);
|
||||||
MOBILEGL_ASSERT(texLevel == static_cast<GLint>(attachmentObject.GetTextureLevel()),
|
MOBILEGL_ASSERT(texLevel == static_cast<GLint>(attachmentObject.GetTextureLevel()),
|
||||||
"Attachment texture level mismatch between GLES and state object.");
|
"Attachment texture level mismatch between GLES and state object.");
|
||||||
@@ -989,10 +988,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
m_backendProgramId = MG_External::GLES::glCreateProgram();
|
m_backendProgramId = g_GLESFuncs.glCreateProgram();
|
||||||
if (m_backendProgramId == 0) {
|
if (m_backendProgramId == 0) {
|
||||||
MGLOG_E("Failed to create program object in backend.");
|
MGLOG_E("Failed to create program object in backend.");
|
||||||
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(MG_External::GLES::glGetError()).c_str());
|
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(g_GLESFuncs.glGetError()).c_str());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("Created backend program object with ID: %u", m_backendProgramId);
|
MGLOG_D("Created backend program object with ID: %u", m_backendProgramId);
|
||||||
@@ -1005,7 +1004,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#endif
|
#endif
|
||||||
if (m_backendProgramId != 0) {
|
if (m_backendProgramId != 0) {
|
||||||
MGLOG_D("Deleting backend program object with ID: %u", m_backendProgramId);
|
MGLOG_D("Deleting backend program object with ID: %u", m_backendProgramId);
|
||||||
MG_External::GLES::glDeleteProgram(m_backendProgramId);
|
g_GLESFuncs.glDeleteProgram(m_backendProgramId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1029,19 +1028,19 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
// Detach all existing shaders
|
// Detach all existing shaders
|
||||||
GLint attachedCount = 0;
|
GLint attachedCount = 0;
|
||||||
MG_External::GLES::glGetProgramiv(m_backendProgramId, GL_ATTACHED_SHADERS, &attachedCount);
|
g_GLESFuncs.glGetProgramiv(m_backendProgramId, GL_ATTACHED_SHADERS, &attachedCount);
|
||||||
MGLOG_D("Currently attached shaders count: %d", attachedCount);
|
MGLOG_D("Currently attached shaders count: %d", attachedCount);
|
||||||
|
|
||||||
if (attachedCount > 0) {
|
if (attachedCount > 0) {
|
||||||
Vector<GLuint> attachedShaders(attachedCount);
|
Vector<GLuint> attachedShaders(attachedCount);
|
||||||
GLsizei actualCount;
|
GLsizei actualCount;
|
||||||
MG_External::GLES::glGetAttachedShaders(m_backendProgramId, attachedCount, &actualCount,
|
g_GLESFuncs.glGetAttachedShaders(m_backendProgramId, attachedCount, &actualCount,
|
||||||
attachedShaders.data());
|
attachedShaders.data());
|
||||||
MGLOG_D("Detaching %d existing shaders from program %u", actualCount, m_backendProgramId);
|
MGLOG_D("Detaching %d existing shaders from program %u", actualCount, m_backendProgramId);
|
||||||
|
|
||||||
for (GLsizei i = 0; i < actualCount; ++i) {
|
for (GLsizei i = 0; i < actualCount; ++i) {
|
||||||
MGLOG_D("Detaching shader ID: %u from program %u", attachedShaders[i], m_backendProgramId);
|
MGLOG_D("Detaching shader ID: %u from program %u", attachedShaders[i], m_backendProgramId);
|
||||||
MG_External::GLES::glDetachShader(m_backendProgramId, attachedShaders[i]);
|
g_GLESFuncs.glDetachShader(m_backendProgramId, attachedShaders[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1060,7 +1059,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
for (int index = 0; index < attachedShaders.size(); ++index) {
|
for (int index = 0; index < attachedShaders.size(); ++index) {
|
||||||
auto& shader = attachedShaders[index];
|
auto& shader = attachedShaders[index];
|
||||||
GLenum glShaderType = MG_Util::ConvertShaderStageToGLEnum(shader->GetShaderStage());
|
GLenum glShaderType = MG_Util::ConvertShaderStageToGLEnum(shader->GetShaderStage());
|
||||||
GLuint backendShaderId = MG_External::GLES::glCreateShader(glShaderType);
|
GLuint backendShaderId = g_GLESFuncs.glCreateShader(glShaderType);
|
||||||
|
|
||||||
if (backendShaderId == 0) {
|
if (backendShaderId == 0) {
|
||||||
MGLOG_E("Failed to create backend shader for attachment.");
|
MGLOG_E("Failed to create backend shader for attachment.");
|
||||||
@@ -1111,37 +1110,37 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
const char* sourceCStr = source.c_str();
|
const char* sourceCStr = source.c_str();
|
||||||
MGLOG_D("Setting shader source for backend shader ID: %u\nsrc:\n%s", backendShaderId, sourceCStr);
|
MGLOG_D("Setting shader source for backend shader ID: %u\nsrc:\n%s", backendShaderId, sourceCStr);
|
||||||
MG_External::GLES::glShaderSource(backendShaderId, 1, &sourceCStr, nullptr);
|
g_GLESFuncs.glShaderSource(backendShaderId, 1, &sourceCStr, nullptr);
|
||||||
MG_External::GLES::glCompileShader(backendShaderId);
|
g_GLESFuncs.glCompileShader(backendShaderId);
|
||||||
|
|
||||||
GLint compileStatus;
|
GLint compileStatus;
|
||||||
MG_External::GLES::glGetShaderiv(backendShaderId, GL_COMPILE_STATUS, &compileStatus);
|
g_GLESFuncs.glGetShaderiv(backendShaderId, GL_COMPILE_STATUS, &compileStatus);
|
||||||
if (compileStatus == GL_FALSE) {
|
if (compileStatus == GL_FALSE) {
|
||||||
GLint logLength;
|
GLint logLength;
|
||||||
MG_External::GLES::glGetShaderiv(backendShaderId, GL_INFO_LOG_LENGTH, &logLength);
|
g_GLESFuncs.glGetShaderiv(backendShaderId, GL_INFO_LOG_LENGTH, &logLength);
|
||||||
Vector<GLchar> log(logLength);
|
Vector<GLchar> log(logLength);
|
||||||
MG_External::GLES::glGetShaderInfoLog(backendShaderId, logLength, nullptr, log.data());
|
g_GLESFuncs.glGetShaderInfoLog(backendShaderId, logLength, nullptr, log.data());
|
||||||
MGLOG_E("Shader compilation failed for backend ID %u: %s", backendShaderId, log.data());
|
MGLOG_E("Shader compilation failed for backend ID %u: %s", backendShaderId, log.data());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MGLOG_D("Attaching shader ID: %u to program %u", backendShaderId, m_backendProgramId);
|
MGLOG_D("Attaching shader ID: %u to program %u", backendShaderId, m_backendProgramId);
|
||||||
MG_External::GLES::glAttachShader(m_backendProgramId, backendShaderId);
|
g_GLESFuncs.glAttachShader(m_backendProgramId, backendShaderId);
|
||||||
|
|
||||||
MGLOG_D("Processed shader source length: %zu", source.length());
|
MGLOG_D("Processed shader source length: %zu", source.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link program
|
// Link program
|
||||||
MGLOG_D("Linking program %u", m_backendProgramId);
|
MGLOG_D("Linking program %u", m_backendProgramId);
|
||||||
MG_External::GLES::glLinkProgram(m_backendProgramId);
|
g_GLESFuncs.glLinkProgram(m_backendProgramId);
|
||||||
|
|
||||||
GLint linkStatus;
|
GLint linkStatus;
|
||||||
MG_External::GLES::glGetProgramiv(m_backendProgramId, GL_LINK_STATUS, &linkStatus);
|
g_GLESFuncs.glGetProgramiv(m_backendProgramId, GL_LINK_STATUS, &linkStatus);
|
||||||
if (linkStatus != GL_TRUE) {
|
if (linkStatus != GL_TRUE) {
|
||||||
GLint logLength;
|
GLint logLength;
|
||||||
MG_External::GLES::glGetProgramiv(m_backendProgramId, GL_INFO_LOG_LENGTH, &logLength);
|
g_GLESFuncs.glGetProgramiv(m_backendProgramId, GL_INFO_LOG_LENGTH, &logLength);
|
||||||
Vector<GLchar> log(logLength);
|
Vector<GLchar> log(logLength);
|
||||||
MG_External::GLES::glGetProgramInfoLog(m_backendProgramId, logLength, nullptr, log.data());
|
g_GLESFuncs.glGetProgramInfoLog(m_backendProgramId, logLength, nullptr, log.data());
|
||||||
MGLOG_E("Program %u linking failed for %u: %s", stateProgramObject->GetExternalIndex(),
|
MGLOG_E("Program %u linking failed for %u: %s", stateProgramObject->GetExternalIndex(),
|
||||||
m_backendProgramId, log.data());
|
m_backendProgramId, log.data());
|
||||||
} else {
|
} else {
|
||||||
@@ -1150,11 +1149,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
// Create global UBO
|
// Create global UBO
|
||||||
if (stateProgramObject->GetUBOSize() > 0) {
|
if (stateProgramObject->GetUBOSize() > 0) {
|
||||||
MG_External::GLES::glGenBuffers(1, &m_backendGlobalUBOId);
|
g_GLESFuncs.glGenBuffers(1, &m_backendGlobalUBOId);
|
||||||
MG_External::GLES::glBindBuffer(GL_UNIFORM_BUFFER, m_backendGlobalUBOId);
|
g_GLESFuncs.glBindBuffer(GL_UNIFORM_BUFFER, m_backendGlobalUBOId);
|
||||||
MG_External::GLES::glBufferData(GL_UNIFORM_BUFFER, stateProgramObject->GetUBOSize(), nullptr,
|
g_GLESFuncs.glBufferData(GL_UNIFORM_BUFFER, stateProgramObject->GetUBOSize(), nullptr, GL_STREAM_DRAW);
|
||||||
GL_STREAM_DRAW);
|
g_GLESFuncs.glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||||
MG_External::GLES::glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
|
||||||
} else {
|
} else {
|
||||||
m_backendGlobalUBOId = 0;
|
m_backendGlobalUBOId = 0;
|
||||||
}
|
}
|
||||||
@@ -1168,7 +1166,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MGLOG_D("Using program %u", m_backendProgramId);
|
MGLOG_D("Using program %u", m_backendProgramId);
|
||||||
MG_External::GLES::glUseProgram(m_backendProgramId);
|
g_GLESFuncs.glUseProgram(m_backendProgramId);
|
||||||
}
|
}
|
||||||
} // namespace PrgramImpl
|
} // namespace PrgramImpl
|
||||||
|
|
||||||
@@ -1177,10 +1175,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glGenSamplers(1, &m_backendSamplerId);
|
g_GLESFuncs.glGenSamplers(1, &m_backendSamplerId);
|
||||||
if (m_backendSamplerId == 0) {
|
if (m_backendSamplerId == 0) {
|
||||||
MGLOG_E("Failed to generate sampler object.");
|
MGLOG_E("Failed to generate sampler object.");
|
||||||
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(MG_External::GLES::glGetError()).c_str());
|
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(g_GLESFuncs.glGetError()).c_str());
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("Generated sampler object with ID: %u.", m_backendSamplerId);
|
MGLOG_D("Generated sampler object with ID: %u.", m_backendSamplerId);
|
||||||
}
|
}
|
||||||
@@ -1211,21 +1209,21 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
|
|
||||||
#define SYNC_SAMPLER_PARAM_IF_CHANGED(internalName, glName, type) \
|
#define SYNC_SAMPLER_PARAM_IF_CHANGED(internalName, glName, type) \
|
||||||
if (m_cacheSamplerParameters.internalName != samplerParams.internalName) { \
|
if (m_cacheSamplerParameters.internalName != samplerParams.internalName) { \
|
||||||
MG_External::GLES::glSamplerParameteri(m_backendSamplerId, glName, \
|
g_GLESFuncs.glSamplerParameteri(m_backendSamplerId, glName, \
|
||||||
MG_Util::ConvertSampler##type##ToGLEnum(samplerParams.internalName)); \
|
MG_Util::ConvertSampler##type##ToGLEnum(samplerParams.internalName)); \
|
||||||
m_cacheSamplerParameters.internalName = samplerParams.internalName; \
|
m_cacheSamplerParameters.internalName = samplerParams.internalName; \
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cacheSamplerParameters.minFilter != samplerParams.minFilter ||
|
if (m_cacheSamplerParameters.minFilter != samplerParams.minFilter ||
|
||||||
m_cacheSamplerParameters.mipmapMode != samplerParams.mipmapMode) {
|
m_cacheSamplerParameters.mipmapMode != samplerParams.mipmapMode) {
|
||||||
MG_External::GLES::glSamplerParameteri(
|
g_GLESFuncs.glSamplerParameteri(
|
||||||
m_backendSamplerId, GL_TEXTURE_MIN_FILTER,
|
m_backendSamplerId, GL_TEXTURE_MIN_FILTER,
|
||||||
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.minFilter, samplerParams.mipmapMode));
|
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.minFilter, samplerParams.mipmapMode));
|
||||||
m_cacheSamplerParameters.minFilter = samplerParams.minFilter;
|
m_cacheSamplerParameters.minFilter = samplerParams.minFilter;
|
||||||
m_cacheSamplerParameters.mipmapMode = samplerParams.mipmapMode;
|
m_cacheSamplerParameters.mipmapMode = samplerParams.mipmapMode;
|
||||||
}
|
}
|
||||||
if (m_cacheSamplerParameters.magFilter != samplerParams.magFilter) {
|
if (m_cacheSamplerParameters.magFilter != samplerParams.magFilter) {
|
||||||
MG_External::GLES::glSamplerParameteri(
|
g_GLESFuncs.glSamplerParameteri(
|
||||||
m_backendSamplerId, GL_TEXTURE_MAG_FILTER,
|
m_backendSamplerId, GL_TEXTURE_MAG_FILTER,
|
||||||
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.magFilter, SamplerMipmapMode::None));
|
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.magFilter, SamplerMipmapMode::None));
|
||||||
m_cacheSamplerParameters.magFilter = samplerParams.magFilter;
|
m_cacheSamplerParameters.magFilter = samplerParams.magFilter;
|
||||||
@@ -1237,11 +1235,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
SYNC_SAMPLER_PARAM_IF_CHANGED(compareFunc, GL_TEXTURE_COMPARE_FUNC, CompareFunc)
|
SYNC_SAMPLER_PARAM_IF_CHANGED(compareFunc, GL_TEXTURE_COMPARE_FUNC, CompareFunc)
|
||||||
SYNC_SAMPLER_PARAM_IF_CHANGED(compareMode, GL_TEXTURE_COMPARE_MODE, CompareMode)
|
SYNC_SAMPLER_PARAM_IF_CHANGED(compareMode, GL_TEXTURE_COMPARE_MODE, CompareMode)
|
||||||
if (m_cacheSamplerParameters.minLod != samplerParams.minLod) {
|
if (m_cacheSamplerParameters.minLod != samplerParams.minLod) {
|
||||||
MG_External::GLES::glSamplerParameterf(m_backendSamplerId, GL_TEXTURE_MIN_LOD, samplerParams.minLod);
|
g_GLESFuncs.glSamplerParameterf(m_backendSamplerId, GL_TEXTURE_MIN_LOD, samplerParams.minLod);
|
||||||
m_cacheSamplerParameters.minLod = samplerParams.minLod;
|
m_cacheSamplerParameters.minLod = samplerParams.minLod;
|
||||||
}
|
}
|
||||||
if (m_cacheSamplerParameters.maxLod != samplerParams.maxLod) {
|
if (m_cacheSamplerParameters.maxLod != samplerParams.maxLod) {
|
||||||
MG_External::GLES::glSamplerParameterf(m_backendSamplerId, GL_TEXTURE_MAX_LOD, samplerParams.maxLod);
|
g_GLESFuncs.glSamplerParameterf(m_backendSamplerId, GL_TEXTURE_MAX_LOD, samplerParams.maxLod);
|
||||||
m_cacheSamplerParameters.maxLod = samplerParams.maxLod;
|
m_cacheSamplerParameters.maxLod = samplerParams.maxLod;
|
||||||
}
|
}
|
||||||
#undef SYNC_SAMPLER_PARAM_IF_CHANGED
|
#undef SYNC_SAMPLER_PARAM_IF_CHANGED
|
||||||
@@ -1254,7 +1252,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#endif
|
#endif
|
||||||
if (g_boundSamplersCache[unit] == this) return;
|
if (g_boundSamplersCache[unit] == this) return;
|
||||||
|
|
||||||
MG_External::GLES::glBindSampler(static_cast<GLenum>(unit), m_backendSamplerId);
|
g_GLESFuncs.glBindSampler(static_cast<GLenum>(unit), m_backendSamplerId);
|
||||||
g_boundSamplersCache[unit] = this;
|
g_boundSamplersCache[unit] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,7 +1266,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
void UnbindSampler(Uint unit) {
|
void UnbindSampler(Uint unit) {
|
||||||
if (g_boundSamplersCache[unit] == nullptr) return;
|
if (g_boundSamplersCache[unit] == nullptr) return;
|
||||||
|
|
||||||
MG_External::GLES::glBindSampler(static_cast<GLenum>(unit), 0);
|
g_GLESFuncs.glBindSampler(static_cast<GLenum>(unit), 0);
|
||||||
g_boundSamplersCache[unit] = nullptr;
|
g_boundSamplersCache[unit] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1282,10 +1280,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glGenRenderbuffers(1, &m_backendRBOId);
|
g_GLESFuncs.glGenRenderbuffers(1, &m_backendRBOId);
|
||||||
if (m_backendRBOId == 0) {
|
if (m_backendRBOId == 0) {
|
||||||
MGLOG_E("Failed to generate renderbuffer object.");
|
MGLOG_E("Failed to generate renderbuffer object.");
|
||||||
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(MG_External::GLES::glGetError()).c_str());
|
MGLOG_E("ES glGetError(): %s", MG_Util::ConvertGLEnumToString(g_GLESFuncs.glGetError()).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1293,7 +1291,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
MG_External::GLES::glBindRenderbuffer(GL_RENDERBUFFER, m_backendRBOId);
|
g_GLESFuncs.glBindRenderbuffer(GL_RENDERBUFFER, m_backendRBOId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackendRenderbufferObject::SyncToBackend(
|
void BackendRenderbufferObject::SyncToBackend(
|
||||||
@@ -1325,7 +1323,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
GLenum glInternalFormat, glType, glFormat;
|
GLenum glInternalFormat, glType, glFormat;
|
||||||
TextureImpl::GenerateTextureFormatInfo(internalFormat, &glInternalFormat, &glFormat, &glType);
|
TextureImpl::GenerateTextureFormatInfo(internalFormat, &glInternalFormat, &glFormat, &glType);
|
||||||
|
|
||||||
MG_External::GLES::glRenderbufferStorage(GL_RENDERBUFFER, glInternalFormat, static_cast<GLsizei>(width),
|
g_GLESFuncs.glRenderbufferStorage(GL_RENDERBUFFER, glInternalFormat, static_cast<GLsizei>(width),
|
||||||
static_cast<GLsizei>(height));
|
static_cast<GLsizei>(height));
|
||||||
|
|
||||||
m_cacheInternalFormat = internalFormat;
|
m_cacheInternalFormat = internalFormat;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
using namespace MobileGL::MG_Util::TextureFormatProcessor;
|
using namespace MobileGL::MG_Util::TextureFormatProcessor;
|
||||||
auto options = (MG_External::GLES::g_glesCaps.hasNorm16Texture) ? PixelFormatNormalizeOptionBit::None
|
auto options = (g_GLESCapabilities.SupportsNorm16Texture) ? PixelFormatNormalizeOptionBit::None
|
||||||
: PixelFormatNormalizeOptionBit::NoNorm16;
|
: PixelFormatNormalizeOptionBit::NoNorm16;
|
||||||
NormalizePixelFormat(MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat), options,
|
NormalizePixelFormat(MG_Util::ConvertTextureInternalFormatToGLEnum(internalFormat), options,
|
||||||
outInternalFormat, outFormat, outType);
|
outInternalFormat, outFormat, outType);
|
||||||
@@ -125,7 +125,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
while (GLenum err = MG_External::GLES::glGetError() != GL_NO_ERROR) {
|
while (GLenum err = g_GLESFuncs.glGetError() != GL_NO_ERROR) {
|
||||||
MGLOG_E("-> GLES Error: %s", MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_E("-> GLES Error: %s", MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,76 +6,57 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-only
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "Backends.h"
|
#include "BackendObjects.h"
|
||||||
#include "MG_Util/Types.h"
|
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
|
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
|
||||||
#include <MG_Util/Converters/MGToStr/GLExtensionConverter.h>
|
#include <MG_Util/Converters/MGToStr/GLExtensionConverter.h>
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL::MG_Backend {
|
||||||
namespace MG_Config {
|
|
||||||
UniquePtr<RendererInfo> RendererInfoPtr = nullptr;
|
|
||||||
} // namespace MG_Config
|
|
||||||
|
|
||||||
namespace MG_Backend {
|
|
||||||
void LogBackendInfo() {
|
void LogBackendInfo() {
|
||||||
if (MG_Config::RendererInfoPtr) {
|
if (!pActiveBackendObject) {
|
||||||
|
MGLOG_W("No active backend object, cannot log backend info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& rendererInfo = pActiveBackendObject->GetRendererInfo();
|
||||||
MGLOG_I("MobileGL Backend Info:");
|
MGLOG_I("MobileGL Backend Info:");
|
||||||
MGLOG_I(" Renderer Name: %s", MG_Config::RendererInfoPtr->RendererName.c_str());
|
MGLOG_I(" Renderer Name: %s", rendererInfo.RendererName.c_str());
|
||||||
MGLOG_I(" Backend Name: %s", MG_Config::RendererInfoPtr->BackendName.c_str());
|
MGLOG_I(" Backend Name: %s", rendererInfo.BackendName.c_str());
|
||||||
if (MG_Config::RendererInfoPtr->ExtraVendor) {
|
if (rendererInfo.ExtraVendor) {
|
||||||
MGLOG_I(" Extra Vendor Info: %s", MG_Config::RendererInfoPtr->ExtraVendor->c_str());
|
MGLOG_I(" Extra Vendor Info: %s", rendererInfo.ExtraVendor->c_str());
|
||||||
}
|
}
|
||||||
MGLOG_I(" Target OpenGL Version: %d.%d",
|
MGLOG_I(" Target OpenGL Version: %d.%d", rendererInfo.RendererGLInfo.TargetGLVersion.Major,
|
||||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Major,
|
rendererInfo.RendererGLInfo.TargetGLVersion.Minor);
|
||||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Minor);
|
MGLOG_I(" Target GLSL Version: %d.%d", rendererInfo.RendererGLInfo.TargetGLSLVersion.Major,
|
||||||
MGLOG_I(" Target GLSL Version: %d.%d",
|
rendererInfo.RendererGLInfo.TargetGLSLVersion.Minor);
|
||||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.Major,
|
|
||||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.Minor);
|
|
||||||
MGLOG_I(" OpenGL Extensions:");
|
MGLOG_I(" OpenGL Extensions:");
|
||||||
for (const auto& ext : MG_Config::RendererInfoPtr->RendererGLInfo.Extensions) {
|
for (const auto& ext : rendererInfo.RendererGLInfo.Extensions) {
|
||||||
MGLOG_I(" - %s", MG_Util::ConvertGLExtToString(ext).c_str());
|
MGLOG_I(" - %s", MG_Util::ConvertGLExtToString(ext).c_str());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
MGLOG_W(" No renderer info available");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool InitSpecificBackendLibs() {
|
Bool InitSpecificBackendLibs() {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_DILIGENT
|
if (!pActiveBackendObject) {
|
||||||
// Nothing to do
|
MGLOG_W("No active backend object, cannot initialize backend libraries");
|
||||||
MGLOG_D("Diligent Engine backend loaded");
|
|
||||||
return true;
|
|
||||||
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
|
||||||
Bool result = MG_Util::BackendLoader::GLES::Init();
|
|
||||||
MGLOG_D("DirectGLES backend loaded, GLES version: %d.%d", MG_External::GLES::g_glesCaps.version.Major,
|
|
||||||
MG_External::GLES::g_glesCaps.version.Minor);
|
|
||||||
return result;
|
|
||||||
#else
|
|
||||||
MGLOG_W("Unknown backend, skipping backend initialization");
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
}
|
||||||
|
pActiveBackendObject->Initialize();
|
||||||
|
gBackendFunctionsTable = pActiveBackendObject->GetBackendFunctions();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
MGLOG_D("Initializing MobileGL Backend...");
|
MGLOG_D("Initializing MobileGL Backend...");
|
||||||
|
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_DILIGENT
|
switch (MG_Config::ActiveBackendType) {
|
||||||
switch (MG_Config::Backend::Diligent::SpecificBackend) {
|
case BackendType::DirectGLES:
|
||||||
case MG_Backend::Diligent::SpecificBackendType::Vulkan:
|
pActiveBackendObject = MakeUnique<DirectGLES::BackendObject_DirectGLES>();
|
||||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(Diligent::RendererInfoVulkan);
|
|
||||||
break;
|
|
||||||
case MG_Backend::Diligent::SpecificBackendType::Metal:
|
|
||||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(Diligent::RendererInfoMetal);
|
|
||||||
break;
|
break;
|
||||||
|
case BackendType::Unknown:
|
||||||
default:
|
default:
|
||||||
throw RuntimeError("Unsupported renderer type");
|
MGLOG_W("Unknown backend type, defaulting to unknown backend");
|
||||||
|
pActiveBackendObject = nullptr;
|
||||||
}
|
}
|
||||||
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
|
||||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(DirectGLES::RendererInfo);
|
|
||||||
#else
|
|
||||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(Unknown::RendererInfoUnknown);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Bool result = InitSpecificBackendLibs();
|
Bool result = InitSpecificBackendLibs();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@@ -84,5 +65,4 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
LogBackendInfo();
|
LogBackendInfo();
|
||||||
}
|
}
|
||||||
} // namespace MG_Backend
|
} // namespace MobileGL::MG_Backend
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -0,0 +1,253 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Impl/EGLImpl/EGLImpl.cpp
|
||||||
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||||
|
// Licensed under the GNU Lesser General Public License v3.0:
|
||||||
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
// End of Source File Header
|
||||||
|
|
||||||
|
#include "EGLImpl.h"
|
||||||
|
#include "EGL/egl.h"
|
||||||
|
#include <MG_Backend/BackendObjects.h>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Impl::EGLImpl {
|
||||||
|
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
||||||
|
const EGLint* attrib_list) {
|
||||||
|
MGLOG_D("EGLImpl::CreateWindowSurface called with window=%p", window);
|
||||||
|
const auto& activeBackendObject = MG_Backend::pActiveBackendObject;
|
||||||
|
if (!activeBackendObject) {
|
||||||
|
MGLOG_E("activeBackendObject not initialized!");
|
||||||
|
return EGL_NO_SURFACE;
|
||||||
|
}
|
||||||
|
activeBackendObject->SetWindowHandle({MG_Backend::WindowBackend::Android, reinterpret_cast<void*>(window)});
|
||||||
|
activeBackendObject->InitWindowSurface();
|
||||||
|
glClearColor(1, 1, 1, 1);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
SwapBuffers((EGLDisplay)1, (EGLSurface)1);
|
||||||
|
return (EGLSurface)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) {
|
||||||
|
MGLOG_D("EGLImpl::SwapBuffers called with dpy=%p", dpy);
|
||||||
|
if (!MG_Backend::gBackendFunctionsTable.Present) {
|
||||||
|
MGLOG_E("MG_Backend::gBackendFunctionsTable.Present not initialized!");
|
||||||
|
return EGL_FALSE;
|
||||||
|
}
|
||||||
|
MG_Backend::gBackendFunctionsTable.Present();
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size,
|
||||||
|
EGLint* num_config) {
|
||||||
|
*num_config = 1;
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) {
|
||||||
|
return (EGLContext)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
|
||||||
|
if (major) *major = 1;
|
||||||
|
if (minor) *minor = 5;
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLDisplay GetDisplay(NativeDisplayType display) {
|
||||||
|
return (EGLDisplay)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLint GetError() {
|
||||||
|
return EGL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean Terminate(EGLDisplay dpy) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean ReleaseThread() {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLContext GetCurrentContext() {
|
||||||
|
return (EGLContext)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
|
||||||
|
if (attribute == EGL_NATIVE_VISUAL_ID) {
|
||||||
|
#if defined(ANDROID)
|
||||||
|
*value = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
return EGL_TRUE;
|
||||||
|
#elif defined(__linux__)
|
||||||
|
*value = 0;
|
||||||
|
return EGL_TRUE;
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
*value = 0;
|
||||||
|
return EGL_TRUE;
|
||||||
|
#else
|
||||||
|
*value = 0;
|
||||||
|
return EGL_FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean BindAPI(EGLenum api) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSurface GetCurrentSurface(EGLint readdraw) {
|
||||||
|
return (EGLSurface)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char const* QueryString(EGLDisplay display, EGLint name) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
|
||||||
|
return (EGLSurface)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config,
|
||||||
|
const EGLint* attrib_list) {
|
||||||
|
return (EGLSurface)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap,
|
||||||
|
const EGLint* attrib_list) {
|
||||||
|
return (EGLSurface)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean GetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config) {
|
||||||
|
if (num_config) {
|
||||||
|
*num_config = 1;
|
||||||
|
}
|
||||||
|
if (configs && config_size > 0) {
|
||||||
|
configs[0] = (EGLConfig)1;
|
||||||
|
}
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLDisplay GetCurrentDisplay() {
|
||||||
|
return (EGLDisplay)1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLenum QueryAPI() {
|
||||||
|
return EGL_OPENGL_API;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) {
|
||||||
|
if (value) {
|
||||||
|
*value = 1;
|
||||||
|
}
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean WaitClient() {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean WaitGL() {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean WaitNative(EGLint engine) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSync CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib* attrib_list) {
|
||||||
|
return reinterpret_cast<EGLSync>(0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean DestroySync(void* dpy, void* sync) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLint ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) {
|
||||||
|
return EGL_CONDITION_SATISFIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean GetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib* value) {
|
||||||
|
if (value) {
|
||||||
|
*value = 1;
|
||||||
|
}
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLImage CreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
||||||
|
const EGLAttrib* attrib_list) {
|
||||||
|
return reinterpret_cast<EGLImage>(0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean DestroyImage(EGLDisplay dpy, EGLImage image) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLDisplay GetPlatformDisplay(EGLenum platform, void* native_display, const EGLAttrib* attrib_list) {
|
||||||
|
return reinterpret_cast<EGLDisplay>(0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSurface CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void* native_window,
|
||||||
|
const EGLAttrib* attrib_list) {
|
||||||
|
return reinterpret_cast<EGLSurface>(0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSurface CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void* native_pixmap,
|
||||||
|
const EGLAttrib* attrib_list) {
|
||||||
|
return reinterpret_cast<EGLSurface>(0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLBoolean WaitSync(void* dpy, void* sync, int flags) {
|
||||||
|
return EGL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name) {
|
||||||
|
MGLOG_D("eglGetProcAddress(%s)", name);
|
||||||
|
#if !defined(WIN32) && !defined(__APPLE__)
|
||||||
|
void* proc = dlsym(RTLD_DEFAULT, (const char*)name);
|
||||||
|
#else
|
||||||
|
void* proc = NULL;
|
||||||
|
#endif
|
||||||
|
if (!proc) {
|
||||||
|
MGLOG_W("Failed to get function: %s", (const char*)name);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return (__eglMustCastToProperFunctionPointerType)proc;
|
||||||
|
}
|
||||||
|
} // namespace MobileGL::MG_Impl::EGLImpl
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Impl/EGLImpl/EGLImpl.h
|
||||||
|
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||||
|
// Licensed under the GNU Lesser General Public License v3.0:
|
||||||
|
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
// End of Source File Header
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <Includes.h>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Impl::EGLImpl {
|
||||||
|
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
||||||
|
const EGLint* attrib_list);
|
||||||
|
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw);
|
||||||
|
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size,
|
||||||
|
EGLint* num_config);
|
||||||
|
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list);
|
||||||
|
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor);
|
||||||
|
EGLDisplay GetDisplay(NativeDisplayType display);
|
||||||
|
EGLint GetError();
|
||||||
|
EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||||
|
EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx);
|
||||||
|
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface);
|
||||||
|
EGLBoolean Terminate(EGLDisplay dpy);
|
||||||
|
EGLBoolean ReleaseThread();
|
||||||
|
EGLContext GetCurrentContext();
|
||||||
|
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value);
|
||||||
|
EGLBoolean BindAPI(EGLenum api);
|
||||||
|
EGLSurface GetCurrentSurface(EGLint readdraw);
|
||||||
|
EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value);
|
||||||
|
const char* QueryString(EGLDisplay display, EGLint name);
|
||||||
|
EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval);
|
||||||
|
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list);
|
||||||
|
EGLBoolean BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||||
|
EGLBoolean ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||||
|
EGLBoolean CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
|
||||||
|
EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config,
|
||||||
|
const EGLint* attrib_list);
|
||||||
|
EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap,
|
||||||
|
const EGLint* attrib_list);
|
||||||
|
EGLBoolean GetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config);
|
||||||
|
EGLDisplay GetCurrentDisplay();
|
||||||
|
EGLenum QueryAPI();
|
||||||
|
EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value);
|
||||||
|
EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
|
||||||
|
EGLBoolean WaitClient();
|
||||||
|
EGLBoolean WaitGL();
|
||||||
|
EGLBoolean WaitNative(EGLint engine);
|
||||||
|
EGLSync CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib* attrib_list);
|
||||||
|
EGLBoolean DestroySync(void* dpy, void* sync);
|
||||||
|
EGLint ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
|
||||||
|
EGLBoolean GetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib* value);
|
||||||
|
EGLImage CreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
||||||
|
const EGLAttrib* attrib_list);
|
||||||
|
EGLBoolean DestroyImage(EGLDisplay dpy, EGLImage image);
|
||||||
|
EGLDisplay GetPlatformDisplay(EGLenum platform, void* native_display, const EGLAttrib* attrib_list);
|
||||||
|
EGLSurface CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void* native_window,
|
||||||
|
const EGLAttrib* attrib_list);
|
||||||
|
EGLSurface CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void* native_pixmap,
|
||||||
|
const EGLAttrib* attrib_list);
|
||||||
|
EGLBoolean WaitSync(void* dpy, void* sync, int flags);
|
||||||
|
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name);
|
||||||
|
} // namespace MobileGL::MG_Impl::EGLImpl
|
||||||
@@ -1,218 +0,0 @@
|
|||||||
// MobileGL - MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.cpp
|
|
||||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
|
||||||
// Licensed under the GNU Lesser General Public License v3.0:
|
|
||||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
|
||||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
||||||
// SPDX-License-Identifier: LGPL-3.0-only
|
|
||||||
// End of Source File Header
|
|
||||||
|
|
||||||
#include "EGLWrapper.h"
|
|
||||||
|
|
||||||
#include "MG_Impl/GetProcAddress.h"
|
|
||||||
|
|
||||||
#include <Config.h>
|
|
||||||
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
|
|
||||||
|
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
|
||||||
namespace MobileGL {
|
|
||||||
namespace MG_Impl::EGLImpl {
|
|
||||||
// TODO: implement complete EGL functionality
|
|
||||||
|
|
||||||
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
|
||||||
const EGLint* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreateWindowSurface(dpy, config, window, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size,
|
|
||||||
EGLint* num_config) {
|
|
||||||
return MG_External::EGL::eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreateContext(dpy, config, shareCtx, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
|
|
||||||
return MG_External::EGL::eglInitialize(dpy, major, minor);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLDisplay GetDisplay(NativeDisplayType display) {
|
|
||||||
return MG_External::EGL::eglGetDisplay(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLint GetError() {
|
|
||||||
return MG_External::EGL::eglGetError();
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
|
|
||||||
return MG_External::EGL::eglMakeCurrent(dpy, draw, read, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx) {
|
|
||||||
return MG_External::EGL::eglDestroyContext(dpy, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface) {
|
|
||||||
return MG_External::EGL::eglDestroySurface(dpy, surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean Terminate(EGLDisplay dpy) {
|
|
||||||
return MG_External::EGL::eglTerminate(dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean ReleaseThread(void) {
|
|
||||||
return MG_External::EGL::eglReleaseThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLContext GetCurrentContext(void) {
|
|
||||||
return MG_External::EGL::eglGetCurrentContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
|
|
||||||
return MG_External::EGL::eglGetConfigAttrib(dpy, config, attribute, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean BindAPI(EGLenum api) {
|
|
||||||
// We should accept `EGL_OPENGL_API`,
|
|
||||||
// and bind to `EGL_OPENGL_ES_API` at the backend
|
|
||||||
MGLOG_D("%s: api = %s", __func__, api == EGL_OPENGL_API ? "EGL_OPENGL_API" : "EGL_OPENGL_ES_API");
|
|
||||||
MGLOG_D("%s: calling backend as EGL_OPENGL_ES_API", __func__);
|
|
||||||
return MG_External::EGL::eglBindAPI(EGL_OPENGL_ES_API);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface GetCurrentSurface(EGLint readdraw) {
|
|
||||||
return MG_External::EGL::eglGetCurrentSurface(readdraw);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) {
|
|
||||||
return MG_External::EGL::eglQuerySurface(display, surface, attribute, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
char const* QueryString(EGLDisplay display, EGLint name) {
|
|
||||||
return MG_External::EGL::eglQueryString(display, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval) {
|
|
||||||
return MG_External::EGL::eglSwapInterval(dpy, interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) {
|
|
||||||
return MG_External::EGL::eglSwapBuffers(dpy, draw);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreatePbufferSurface(dpy, config, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
|
||||||
return MG_External::EGL::eglBindTexImage(dpy, surface, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
|
||||||
return MG_External::EGL::eglReleaseTexImage(dpy, surface, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) {
|
|
||||||
return MG_External::EGL::eglCopyBuffers(dpy, surface, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
|
|
||||||
EGLConfig config, const EGLint* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap,
|
|
||||||
const EGLint* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean GetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config) {
|
|
||||||
return MG_External::EGL::eglGetConfigs(dpy, configs, config_size, num_config);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLDisplay GetCurrentDisplay(void) {
|
|
||||||
return MG_External::EGL::eglGetCurrentDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLenum QueryAPI(void) {
|
|
||||||
return MG_External::EGL::eglQueryAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) {
|
|
||||||
return MG_External::EGL::eglQueryContext(dpy, ctx, attribute, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) {
|
|
||||||
return MG_External::EGL::eglSurfaceAttrib(dpy, surface, attribute, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean WaitClient(void) {
|
|
||||||
return MG_External::EGL::eglWaitClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean WaitGL(void) {
|
|
||||||
return MG_External::EGL::eglWaitGL();
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean WaitNative(EGLint engine) {
|
|
||||||
return MG_External::EGL::eglWaitNative(engine);
|
|
||||||
}
|
|
||||||
|
|
||||||
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name) {
|
|
||||||
MGLOG_D("eglGetProcAddress(%s)", name);
|
|
||||||
|
|
||||||
void* proc = MG_Impl::GetProcAddress(name);
|
|
||||||
|
|
||||||
if (!proc) {
|
|
||||||
MGLOG_W("Failed to get function: %s", (const char*)name);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return (__eglMustCastToProperFunctionPointerType)proc;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSync CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreateSync(dpy, type, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean DestroySync(EGLDisplay dpy, EGLSync sync) {
|
|
||||||
return MG_External::EGL::eglDestroySync(dpy, sync);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLint ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) {
|
|
||||||
return MG_External::EGL::eglClientWaitSync(dpy, sync, flags, timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean GetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib* value) {
|
|
||||||
return MG_External::EGL::eglGetSyncAttrib(dpy, sync, attribute, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLImage CreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
|
||||||
const EGLAttrib* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreateImage(dpy, ctx, target, buffer, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean DestroyImage(EGLDisplay dpy, EGLImage image) {
|
|
||||||
return MG_External::EGL::eglDestroyImage(dpy, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLDisplay GetPlatformDisplay(EGLenum platform, void* native_display, const EGLAttrib* attrib_list) {
|
|
||||||
return MG_External::EGL::eglGetPlatformDisplay(platform, native_display, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void* native_window,
|
|
||||||
const EGLAttrib* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreatePlatformWindowSurface(dpy, config, native_window, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void* native_pixmap,
|
|
||||||
const EGLAttrib* attrib_list) {
|
|
||||||
return MG_External::EGL::eglCreatePlatformPixmapSurface(dpy, config, native_pixmap, attrib_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean WaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) {
|
|
||||||
return MG_External::EGL::eglWaitSync(dpy, sync, flags);
|
|
||||||
}
|
|
||||||
} // namespace MG_Impl::EGLImpl
|
|
||||||
} // namespace MobileGL
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -7,20 +7,26 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
#include "../Temporary/TemporaryEGLImpl.h"
|
#include "../EGLImpl.h"
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
MOBILEGL_EGL_API EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
||||||
const EGLint* attrib_list) {
|
const EGLint* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglCreateWindowSurface(dpy=%p, config=%p, window=%p, attrib_list=%p)", dpy, config, window,
|
||||||
|
attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CreateWindowSurface(dpy, config, window, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::CreateWindowSurface(dpy, config, window, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
|
MOBILEGL_EGL_API EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
|
||||||
EGLint config_size, EGLint* num_config) {
|
EGLint config_size, EGLint* num_config) {
|
||||||
|
MGLOG_D("[MobileGL] eglChooseConfig(dpy=%p, attrib_list=%p, configs=%p, config_size=%d, num_config=%p)", dpy,
|
||||||
|
attrib_list, configs, config_size, num_config);
|
||||||
return MobileGL::MG_Impl::EGLImpl::ChooseConfig(dpy, attrib_list, configs, config_size, num_config);
|
return MobileGL::MG_Impl::EGLImpl::ChooseConfig(dpy, attrib_list, configs, config_size, num_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx,
|
MOBILEGL_EGL_API EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx,
|
||||||
const EGLint* attrib_list) {
|
const EGLint* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglCreateContext(dpy=%p, config=%p, shareCtx=%p, attrib_list=%p)", dpy, config, shareCtx,
|
||||||
|
attrib_list);
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
tracy::StartupProfiler();
|
tracy::StartupProfiler();
|
||||||
#endif
|
#endif
|
||||||
@@ -28,22 +34,27 @@ MOBILEGL_EGL_API EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, E
|
|||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
|
MOBILEGL_EGL_API EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
|
||||||
|
MGLOG_D("[MobileGL] eglInitialize(dpy=%p, major=%p, minor=%p)", dpy, major, minor);
|
||||||
return MobileGL::MG_Impl::EGLImpl::Initialize(dpy, major, minor);
|
return MobileGL::MG_Impl::EGLImpl::Initialize(dpy, major, minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLDisplay eglGetDisplay(NativeDisplayType display) {
|
MOBILEGL_EGL_API EGLDisplay eglGetDisplay(NativeDisplayType display) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetDisplay(display=%p)", display);
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetDisplay(display);
|
return MobileGL::MG_Impl::EGLImpl::GetDisplay(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLint eglGetError() {
|
MOBILEGL_EGL_API EGLint eglGetError() {
|
||||||
|
MGLOG_D("[MobileGL] eglGetError()");
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetError();
|
return MobileGL::MG_Impl::EGLImpl::GetError();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
|
MOBILEGL_EGL_API EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
|
||||||
|
MGLOG_D("[MobileGL] eglMakeCurrent(dpy=%p, draw=%p, read=%p, ctx=%p)", dpy, draw, read, ctx);
|
||||||
return MobileGL::MG_Impl::EGLImpl::MakeCurrent(dpy, draw, read, ctx);
|
return MobileGL::MG_Impl::EGLImpl::MakeCurrent(dpy, draw, read, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) {
|
MOBILEGL_EGL_API EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) {
|
||||||
|
MGLOG_D("[MobileGL] eglDestroyContext(dpy=%p, ctx=%p)", dpy, ctx);
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
tracy::ShutdownProfiler();
|
tracy::ShutdownProfiler();
|
||||||
#endif
|
#endif
|
||||||
@@ -51,46 +62,58 @@ MOBILEGL_EGL_API EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) {
|
MOBILEGL_EGL_API EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) {
|
||||||
|
MGLOG_D("[MobileGL] eglDestroySurface(dpy=%p, surface=%p)", dpy, surface);
|
||||||
return MobileGL::MG_Impl::EGLImpl::DestroySurface(dpy, surface);
|
return MobileGL::MG_Impl::EGLImpl::DestroySurface(dpy, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglTerminate(EGLDisplay dpy) {
|
MOBILEGL_EGL_API EGLBoolean eglTerminate(EGLDisplay dpy) {
|
||||||
|
MGLOG_D("[MobileGL] eglTerminate(dpy=%p)", dpy);
|
||||||
return MobileGL::MG_Impl::EGLImpl::Terminate(dpy);
|
return MobileGL::MG_Impl::EGLImpl::Terminate(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglReleaseThread(void) {
|
MOBILEGL_EGL_API EGLBoolean eglReleaseThread(void) {
|
||||||
|
MGLOG_D("[MobileGL] eglReleaseThread()");
|
||||||
return MobileGL::MG_Impl::EGLImpl::ReleaseThread();
|
return MobileGL::MG_Impl::EGLImpl::ReleaseThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLContext eglGetCurrentContext(void) {
|
MOBILEGL_EGL_API EGLContext eglGetCurrentContext(void) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetCurrentContext()");
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetCurrentContext();
|
return MobileGL::MG_Impl::EGLImpl::GetCurrentContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
|
MOBILEGL_EGL_API EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetConfigAttrib(dpy=%p, config=%p, attribute=%d, value=%p)", dpy, config, attribute, value);
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetConfigAttrib(dpy, config, attribute, value);
|
return MobileGL::MG_Impl::EGLImpl::GetConfigAttrib(dpy, config, attribute, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglBindAPI(EGLenum api) {
|
MOBILEGL_EGL_API EGLBoolean eglBindAPI(EGLenum api) {
|
||||||
|
MGLOG_D("[MobileGL] eglBindAPI(api=%u)", api);
|
||||||
return MobileGL::MG_Impl::EGLImpl::BindAPI(api);
|
return MobileGL::MG_Impl::EGLImpl::BindAPI(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLSurface eglGetCurrentSurface(EGLint readdraw) {
|
MOBILEGL_EGL_API EGLSurface eglGetCurrentSurface(EGLint readdraw) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetCurrentSurface(readdraw=%d)", readdraw);
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetCurrentSurface(readdraw);
|
return MobileGL::MG_Impl::EGLImpl::GetCurrentSurface(readdraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglQuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) {
|
MOBILEGL_EGL_API EGLBoolean eglQuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) {
|
||||||
|
MGLOG_D("[MobileGL] eglQuerySurface(display=%p, surface=%p, attribute=%d, value=%p)", display, surface, attribute,
|
||||||
|
value);
|
||||||
return MobileGL::MG_Impl::EGLImpl::QuerySurface(display, surface, attribute, value);
|
return MobileGL::MG_Impl::EGLImpl::QuerySurface(display, surface, attribute, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API char const* eglQueryString(EGLDisplay display, EGLint name) {
|
MOBILEGL_EGL_API char const* eglQueryString(EGLDisplay display, EGLint name) {
|
||||||
|
MGLOG_D("[MobileGL] eglQueryString(display=%p, name=%d)", display, name);
|
||||||
return MobileGL::MG_Impl::EGLImpl::QueryString(display, name);
|
return MobileGL::MG_Impl::EGLImpl::QueryString(display, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) {
|
MOBILEGL_EGL_API EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) {
|
||||||
|
MGLOG_D("[MobileGL] eglSwapInterval(dpy=%p, interval=%d)", dpy, interval);
|
||||||
return MobileGL::MG_Impl::EGLImpl::SwapInterval(dpy, interval);
|
return MobileGL::MG_Impl::EGLImpl::SwapInterval(dpy, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) {
|
MOBILEGL_EGL_API EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) {
|
||||||
|
MGLOG_D("[MobileGL] eglSwapBuffers(dpy=%p, draw=%p)", dpy, draw);
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
FrameMark;
|
FrameMark;
|
||||||
#endif
|
#endif
|
||||||
@@ -98,108 +121,140 @@ MOBILEGL_EGL_API EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
|
MOBILEGL_EGL_API EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglCreatePbufferSurface(dpy=%p, config=%p, attrib_list=%p)", dpy, config, attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CreatePbufferSurface(dpy, config, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::CreatePbufferSurface(dpy, config, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* name) {
|
MOBILEGL_EGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* name) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetProcAddress(name=%s)", name ? name : "null");
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetProcAddress(name);
|
return MobileGL::MG_Impl::EGLImpl::GetProcAddress(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
MOBILEGL_EGL_API EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
||||||
|
MGLOG_D("[MobileGL] eglBindTexImage(dpy=%p, surface=%p, buffer=%d)", dpy, surface, buffer);
|
||||||
return MobileGL::MG_Impl::EGLImpl::BindTexImage(dpy, surface, buffer);
|
return MobileGL::MG_Impl::EGLImpl::BindTexImage(dpy, surface, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
MOBILEGL_EGL_API EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
||||||
|
MGLOG_D("[MobileGL] eglReleaseTexImage(dpy=%p, surface=%p, buffer=%d)", dpy, surface, buffer);
|
||||||
return MobileGL::MG_Impl::EGLImpl::ReleaseTexImage(dpy, surface, buffer);
|
return MobileGL::MG_Impl::EGLImpl::ReleaseTexImage(dpy, surface, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) {
|
MOBILEGL_EGL_API EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) {
|
||||||
|
MGLOG_D("[MobileGL] eglCopyBuffers(dpy=%p, surface=%p, target=%p)", dpy, surface, target);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CopyBuffers(dpy, surface, target);
|
return MobileGL::MG_Impl::EGLImpl::CopyBuffers(dpy, surface, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
|
MOBILEGL_EGL_API EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
|
||||||
EGLClientBuffer buffer, EGLConfig config,
|
EGLConfig config, const EGLint* attrib_list) {
|
||||||
const EGLint* attrib_list) {
|
MGLOG_D("[MobileGL] eglCreatePbufferFromClientBuffer(dpy=%p, buftype=%u, buffer=%p, config=%p, attrib_list=%p)",
|
||||||
|
dpy, buftype, buffer, config, attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::CreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap,
|
MOBILEGL_EGL_API EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap,
|
||||||
const EGLint* attrib_list) {
|
const EGLint* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglCreatePixmapSurface(dpy=%p, config=%p, pixmap=%p, attrib_list=%p)", dpy, config, pixmap,
|
||||||
|
attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CreatePixmapSurface(dpy, config, pixmap, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::CreatePixmapSurface(dpy, config, pixmap, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config) {
|
MOBILEGL_EGL_API EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetConfigs(dpy=%p, configs=%p, config_size=%d, num_config=%p)", dpy, configs, config_size,
|
||||||
|
num_config);
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetConfigs(dpy, configs, config_size, num_config);
|
return MobileGL::MG_Impl::EGLImpl::GetConfigs(dpy, configs, config_size, num_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLDisplay eglGetCurrentDisplay(void) {
|
MOBILEGL_EGL_API EGLDisplay eglGetCurrentDisplay(void) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetCurrentDisplay()");
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetCurrentDisplay();
|
return MobileGL::MG_Impl::EGLImpl::GetCurrentDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLenum eglQueryAPI(void) {
|
MOBILEGL_EGL_API EGLenum eglQueryAPI(void) {
|
||||||
|
MGLOG_D("[MobileGL] eglQueryAPI()");
|
||||||
return MobileGL::MG_Impl::EGLImpl::QueryAPI();
|
return MobileGL::MG_Impl::EGLImpl::QueryAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) {
|
MOBILEGL_EGL_API EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) {
|
||||||
|
MGLOG_D("[MobileGL] eglQueryContext(dpy=%p, ctx=%p, attribute=%d, value=%p)", dpy, ctx, attribute, value);
|
||||||
return MobileGL::MG_Impl::EGLImpl::QueryContext(dpy, ctx, attribute, value);
|
return MobileGL::MG_Impl::EGLImpl::QueryContext(dpy, ctx, attribute, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) {
|
MOBILEGL_EGL_API EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) {
|
||||||
|
MGLOG_D("[MobileGL] eglSurfaceAttrib(dpy=%p, surface=%p, attribute=%d, value=%d)", dpy, surface, attribute, value);
|
||||||
return MobileGL::MG_Impl::EGLImpl::SurfaceAttrib(dpy, surface, attribute, value);
|
return MobileGL::MG_Impl::EGLImpl::SurfaceAttrib(dpy, surface, attribute, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglWaitClient(void) {
|
MOBILEGL_EGL_API EGLBoolean eglWaitClient(void) {
|
||||||
|
MGLOG_D("[MobileGL] eglWaitClient()");
|
||||||
return MobileGL::MG_Impl::EGLImpl::WaitClient();
|
return MobileGL::MG_Impl::EGLImpl::WaitClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglWaitGL(void) {
|
MOBILEGL_EGL_API EGLBoolean eglWaitGL(void) {
|
||||||
|
MGLOG_D("[MobileGL] eglWaitGL()");
|
||||||
return MobileGL::MG_Impl::EGLImpl::WaitGL();
|
return MobileGL::MG_Impl::EGLImpl::WaitGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglWaitNative(EGLint engine) {
|
MOBILEGL_EGL_API EGLBoolean eglWaitNative(EGLint engine) {
|
||||||
|
MGLOG_D("[MobileGL] eglWaitNative(engine=%d)", engine);
|
||||||
return MobileGL::MG_Impl::EGLImpl::WaitNative(engine);
|
return MobileGL::MG_Impl::EGLImpl::WaitNative(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLSync eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib* attrib_list) {
|
MOBILEGL_EGL_API EGLSync eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglCreateSync(dpy=%p, type=%u, attrib_list=%p)", dpy, type, attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CreateSync(dpy, type, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::CreateSync(dpy, type, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglDestroySync(EGLDisplay dpy, EGLSync sync) {
|
MOBILEGL_EGL_API EGLBoolean eglDestroySync(EGLDisplay dpy, EGLSync sync) {
|
||||||
|
MGLOG_D("[MobileGL] eglDestroySync(dpy=%p, sync=%p)", dpy, sync);
|
||||||
return MobileGL::MG_Impl::EGLImpl::DestroySync(dpy, sync);
|
return MobileGL::MG_Impl::EGLImpl::DestroySync(dpy, sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLint eglClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) {
|
MOBILEGL_EGL_API EGLint eglClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) {
|
||||||
|
MGLOG_D("[MobileGL] eglClientWaitSync(dpy=%p, sync=%p, flags=%d, timeout=%llu)", dpy, sync, flags,
|
||||||
|
static_cast<unsigned long long>(timeout));
|
||||||
return MobileGL::MG_Impl::EGLImpl::ClientWaitSync(dpy, sync, flags, timeout);
|
return MobileGL::MG_Impl::EGLImpl::ClientWaitSync(dpy, sync, flags, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib* value) {
|
MOBILEGL_EGL_API EGLBoolean eglGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib* value) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetSyncAttrib(dpy=%p, sync=%p, attribute=%d, value=%p)", dpy, sync, attribute, value);
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetSyncAttrib(dpy, sync, attribute, value);
|
return MobileGL::MG_Impl::EGLImpl::GetSyncAttrib(dpy, sync, attribute, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLImage eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
MOBILEGL_EGL_API EGLImage eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
||||||
const EGLAttrib* attrib_list) {
|
const EGLAttrib* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglCreateImage(dpy=%p, ctx=%p, target=%u, buffer=%p, attrib_list=%p)", dpy, ctx, target, buffer,
|
||||||
|
attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CreateImage(dpy, ctx, target, buffer, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::CreateImage(dpy, ctx, target, buffer, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglDestroyImage(EGLDisplay dpy, EGLImage image) {
|
MOBILEGL_EGL_API EGLBoolean eglDestroyImage(EGLDisplay dpy, EGLImage image) {
|
||||||
|
MGLOG_D("[MobileGL] eglDestroyImage(dpy=%p, image=%p)", dpy, image);
|
||||||
return MobileGL::MG_Impl::EGLImpl::DestroyImage(dpy, image);
|
return MobileGL::MG_Impl::EGLImpl::DestroyImage(dpy, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLDisplay eglGetPlatformDisplay(EGLenum platform, void* native_display,
|
MOBILEGL_EGL_API EGLDisplay eglGetPlatformDisplay(EGLenum platform, void* native_display,
|
||||||
const EGLAttrib* attrib_list) {
|
const EGLAttrib* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglGetPlatformDisplay(platform=%u, native_display=%p, attrib_list=%p)", platform,
|
||||||
|
native_display, attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::GetPlatformDisplay(platform, native_display, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::GetPlatformDisplay(platform, native_display, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLSurface eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void* native_window,
|
MOBILEGL_EGL_API EGLSurface eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void* native_window,
|
||||||
const EGLAttrib* attrib_list) {
|
const EGLAttrib* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglCreatePlatformWindowSurface(dpy=%p, config=%p, native_window=%p, attrib_list=%p)", dpy,
|
||||||
|
config, native_window, attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CreatePlatformWindowSurface(dpy, config, native_window, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::CreatePlatformWindowSurface(dpy, config, native_window, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLSurface eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void* native_pixmap,
|
MOBILEGL_EGL_API EGLSurface eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void* native_pixmap,
|
||||||
const EGLAttrib* attrib_list) {
|
const EGLAttrib* attrib_list) {
|
||||||
|
MGLOG_D("[MobileGL] eglCreatePlatformPixmapSurface(dpy=%p, config=%p, native_pixmap=%p, attrib_list=%p)", dpy,
|
||||||
|
config, native_pixmap, attrib_list);
|
||||||
return MobileGL::MG_Impl::EGLImpl::CreatePlatformPixmapSurface(dpy, config, native_pixmap, attrib_list);
|
return MobileGL::MG_Impl::EGLImpl::CreatePlatformPixmapSurface(dpy, config, native_pixmap, attrib_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOBILEGL_EGL_API EGLBoolean eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) {
|
MOBILEGL_EGL_API EGLBoolean eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) {
|
||||||
|
MGLOG_D("[MobileGL] eglWaitSync(dpy=%p, sync=%p, flags=%d)", dpy, sync, flags);
|
||||||
return MobileGL::MG_Impl::EGLImpl::WaitSync(dpy, sync, flags);
|
return MobileGL::MG_Impl::EGLImpl::WaitSync(dpy, sync, flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,195 +0,0 @@
|
|||||||
// MobileGL - MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp
|
|
||||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
|
||||||
// Licensed under the GNU Lesser General Public License v3.0:
|
|
||||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
|
||||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
||||||
// SPDX-License-Identifier: LGPL-3.0-only
|
|
||||||
// End of Source File Header
|
|
||||||
|
|
||||||
#include "TemporaryEGLImpl.h"
|
|
||||||
#include <Config.h>
|
|
||||||
|
|
||||||
#if !(MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES)
|
|
||||||
namespace MobileGL {
|
|
||||||
namespace MG_Impl::EGLImpl {
|
|
||||||
// TODO: implement complete EGL functionality
|
|
||||||
|
|
||||||
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
|
||||||
const EGLint* attrib_list) {
|
|
||||||
return (EGLSurface)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size,
|
|
||||||
EGLint* num_config) {
|
|
||||||
*num_config = 1;
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) {
|
|
||||||
return (EGLContext)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
|
|
||||||
if (major) *major = 1;
|
|
||||||
if (minor) *minor = 5;
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLDisplay GetDisplay(NativeDisplayType display) {
|
|
||||||
return (EGLDisplay)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLint GetError() {
|
|
||||||
return EGL_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean Terminate(EGLDisplay dpy) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean ReleaseThread(void) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLContext GetCurrentContext(void) {
|
|
||||||
return (EGLContext)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
|
|
||||||
if (attribute == EGL_NATIVE_VISUAL_ID) {
|
|
||||||
#if defined(ANDROID)
|
|
||||||
*value = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
return EGL_TRUE;
|
|
||||||
#elif defined(__linux__)
|
|
||||||
*value = 0;
|
|
||||||
return EGL_TRUE;
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
*value = 0;
|
|
||||||
return EGL_TRUE;
|
|
||||||
#else
|
|
||||||
*value = 0;
|
|
||||||
return EGL_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean BindAPI(EGLenum api) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface GetCurrentSurface(EGLint readdraw) {
|
|
||||||
return (EGLSurface)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
char const* QueryString(EGLDisplay display, EGLint name) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
|
|
||||||
return (EGLSurface)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
|
|
||||||
EGLConfig config, const EGLint* attrib_list) {
|
|
||||||
return (EGLSurface)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap,
|
|
||||||
const EGLint* attrib_list) {
|
|
||||||
return (EGLSurface)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean GetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config) {
|
|
||||||
if (num_config) {
|
|
||||||
*num_config = 1;
|
|
||||||
}
|
|
||||||
if (configs && config_size > 0) {
|
|
||||||
configs[0] = (EGLConfig)1;
|
|
||||||
}
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLDisplay GetCurrentDisplay(void) {
|
|
||||||
return (EGLDisplay)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLenum QueryAPI(void) {
|
|
||||||
return EGL_OPENGL_API;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) {
|
|
||||||
if (value) {
|
|
||||||
*value = 0;
|
|
||||||
}
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean WaitClient(void) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean WaitGL(void) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean WaitNative(EGLint engine) {
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name) {
|
|
||||||
MGLOG_D("eglGetProcAddress(%s)", name);
|
|
||||||
#if !defined(WIN32) && !defined(__APPLE__)
|
|
||||||
void* proc = dlsym(RTLD_DEFAULT, (const char*)name);
|
|
||||||
#else
|
|
||||||
void* proc = NULL;
|
|
||||||
#endif
|
|
||||||
if (!proc) {
|
|
||||||
MGLOG_W("Failed to get function: %s", (const char*)name);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return (__eglMustCastToProperFunctionPointerType)proc;
|
|
||||||
}
|
|
||||||
} // namespace MG_Impl::EGLImpl
|
|
||||||
} // namespace MobileGL
|
|
||||||
#endif
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
// MobileGL - MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.h
|
|
||||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
|
||||||
// Licensed under the GNU Lesser General Public License v3.0:
|
|
||||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
|
||||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
||||||
// SPDX-License-Identifier: LGPL-3.0-only
|
|
||||||
// End of Source File Header
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <Includes.h>
|
|
||||||
|
|
||||||
namespace MobileGL {
|
|
||||||
namespace MG_Impl::EGLImpl {
|
|
||||||
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
|
||||||
const EGLint* attrib_list);
|
|
||||||
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size,
|
|
||||||
EGLint* num_config);
|
|
||||||
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list);
|
|
||||||
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor);
|
|
||||||
EGLDisplay GetDisplay(NativeDisplayType display);
|
|
||||||
EGLint GetError();
|
|
||||||
EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
|
||||||
EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx);
|
|
||||||
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface);
|
|
||||||
EGLBoolean Terminate(EGLDisplay dpy);
|
|
||||||
EGLBoolean ReleaseThread(void);
|
|
||||||
EGLContext GetCurrentContext(void);
|
|
||||||
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value);
|
|
||||||
EGLBoolean BindAPI(EGLenum api);
|
|
||||||
EGLSurface GetCurrentSurface(EGLint readdraw);
|
|
||||||
EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value);
|
|
||||||
char const* QueryString(EGLDisplay display, EGLint name);
|
|
||||||
EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval);
|
|
||||||
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw);
|
|
||||||
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list);
|
|
||||||
EGLBoolean BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
|
||||||
EGLBoolean ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
|
||||||
EGLBoolean CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
|
|
||||||
EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
|
|
||||||
EGLConfig config, const EGLint* attrib_list);
|
|
||||||
EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap,
|
|
||||||
const EGLint* attrib_list);
|
|
||||||
EGLBoolean GetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config);
|
|
||||||
EGLDisplay GetCurrentDisplay(void);
|
|
||||||
EGLenum QueryAPI(void);
|
|
||||||
EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value);
|
|
||||||
EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
|
|
||||||
EGLBoolean WaitClient(void);
|
|
||||||
EGLBoolean WaitGL(void);
|
|
||||||
EGLBoolean WaitNative(EGLint engine);
|
|
||||||
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name);
|
|
||||||
EGLSync CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib* attrib_list);
|
|
||||||
EGLBoolean DestroySync(EGLDisplay dpy, EGLSync sync);
|
|
||||||
EGLint ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
|
|
||||||
EGLBoolean GetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib* value);
|
|
||||||
EGLImage CreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
|
|
||||||
const EGLAttrib* attrib_list);
|
|
||||||
EGLBoolean DestroyImage(EGLDisplay dpy, EGLImage image);
|
|
||||||
EGLDisplay GetPlatformDisplay(EGLenum platform, void* native_display, const EGLAttrib* attrib_list);
|
|
||||||
EGLSurface CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void* native_window,
|
|
||||||
const EGLAttrib* attrib_list);
|
|
||||||
EGLSurface CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void* native_pixmap,
|
|
||||||
const EGLAttrib* attrib_list);
|
|
||||||
EGLBoolean WaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags);
|
|
||||||
} // namespace MG_Impl::EGLImpl
|
|
||||||
} // namespace MobileGL
|
|
||||||
@@ -9,29 +9,21 @@
|
|||||||
#include "GL_Drawing.h"
|
#include "GL_Drawing.h"
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <MG_State/GLState/Core.h>
|
#include <MG_State/GLState/Core.h>
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
#include <MG_Backend/BackendObjects.h>
|
||||||
#include <MG_Backend/DirectGLES/DirectGLES.h>
|
|
||||||
#endif
|
|
||||||
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
|
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL::MG_Impl::GLImpl {
|
||||||
namespace MG_Impl::GLImpl {
|
|
||||||
void Clear_Backend(GLbitfield mask) {
|
void Clear_Backend(GLbitfield mask) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.Clear(mask);
|
||||||
MG_Backend::DirectGLES::Clear(mask);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElements_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices) {
|
void DrawElements_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawElements(mode, count, type, indices);
|
||||||
MG_Backend::DirectGLES::DrawElements(mode, count, type, indices);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiDrawElements_Backend(GLenum mode, const GLsizei* count, GLenum type, const void* const* indices,
|
void MultiDrawElements_Backend(GLenum mode, const GLsizei* count, GLenum type, const void* const* indices,
|
||||||
@@ -39,29 +31,23 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.MultiDrawElements(mode, count, type, indices, drawcount);
|
||||||
MG_Backend::DirectGLES::MultiDrawElements(mode, count, type, indices, drawcount);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiDrawElementsBaseVertex_Backend(GLenum mode, const GLsizei* count, GLenum type,
|
void MultiDrawElementsBaseVertex_Backend(GLenum mode, const GLsizei* count, GLenum type, const void* const* indices,
|
||||||
const void* const* indices, GLsizei drawcount,
|
GLsizei drawcount, const GLint* basevertex) {
|
||||||
const GLint* basevertex) {
|
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.MultiDrawElementsBaseVertex(mode, count, type, indices, drawcount,
|
||||||
MG_Backend::DirectGLES::MultiDrawElementsBaseVertex(mode, count, type, indices, drawcount, basevertex);
|
basevertex);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawArrays_Backend(GLenum mode, GLint first, GLsizei count) {
|
void DrawArrays_Backend(GLenum mode, GLint first, GLsizei count) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawArrays(mode, first, count);
|
||||||
MG_Backend::DirectGLES::DrawArrays(mode, first, count);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsBaseVertex_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
void DrawElementsBaseVertex_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
@@ -69,9 +55,7 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawElementsBaseVertex(mode, count, type, indices, basevertex);
|
||||||
MG_Backend::DirectGLES::DrawElementsBaseVertex(mode, count, type, indices, basevertex);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiDrawElementsIndirect_Backend(GLenum mode, GLenum type, const void* indirect, GLsizei drawcount,
|
void MultiDrawElementsIndirect_Backend(GLenum mode, GLenum type, const void* indirect, GLsizei drawcount,
|
||||||
@@ -79,18 +63,14 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.MultiDrawElementsIndirect(mode, type, indirect, drawcount, stride);
|
||||||
MG_Backend::DirectGLES::MultiDrawElementsIndirect(mode, type, indirect, drawcount, stride);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiDrawArraysIndirect_Backend(GLenum mode, const void* indirect, GLsizei drawcount, GLsizei stride) {
|
void MultiDrawArraysIndirect_Backend(GLenum mode, const void* indirect, GLsizei drawcount, GLsizei stride) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.MultiDrawArraysIndirect(mode, indirect, drawcount, stride);
|
||||||
MG_Backend::DirectGLES::MultiDrawArraysIndirect(mode, indirect, drawcount, stride);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawRangeElementsBaseVertex_Backend(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type,
|
void DrawRangeElementsBaseVertex_Backend(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type,
|
||||||
@@ -98,9 +78,8 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawRangeElementsBaseVertex(mode, start, end, count, type, indices,
|
||||||
MG_Backend::DirectGLES::DrawRangeElementsBaseVertex(mode, start, end, count, type, indices, basevertex);
|
basevertex);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawRangeElements_Backend(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type,
|
void DrawRangeElements_Backend(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type,
|
||||||
@@ -108,9 +87,7 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawRangeElements(mode, start, end, count, type, indices);
|
||||||
MG_Backend::DirectGLES::DrawRangeElements(mode, start, end, count, type, indices);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsInstancedBaseVertexBaseInstance_Backend(GLenum mode, GLsizei count, GLenum type,
|
void DrawElementsInstancedBaseVertexBaseInstance_Backend(GLenum mode, GLsizei count, GLenum type,
|
||||||
@@ -119,10 +96,8 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawElementsInstancedBaseVertexBaseInstance(
|
||||||
MG_Backend::DirectGLES::DrawElementsInstancedBaseVertexBaseInstance(
|
|
||||||
mode, count, type, indices, instancecount, basevertex, baseinstance);
|
mode, count, type, indices, instancecount, basevertex, baseinstance);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsInstancedBaseVertex_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
void DrawElementsInstancedBaseVertex_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
@@ -130,10 +105,8 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawElementsInstancedBaseVertex(mode, count, type, indices, instancecount,
|
||||||
MG_Backend::DirectGLES::DrawElementsInstancedBaseVertex(mode, count, type, indices, instancecount,
|
|
||||||
basevertex);
|
basevertex);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsInstancedBaseInstance_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
void DrawElementsInstancedBaseInstance_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
@@ -141,10 +114,8 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawElementsInstancedBaseInstance(mode, count, type, indices,
|
||||||
MG_Backend::DirectGLES::DrawElementsInstancedBaseInstance(mode, count, type, indices, instancecount,
|
instancecount, baseinstance);
|
||||||
baseinstance);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsInstanced_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
void DrawElementsInstanced_Backend(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
||||||
@@ -152,50 +123,40 @@ namespace MobileGL {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawElementsInstanced(mode, count, type, indices, instancecount);
|
||||||
MG_Backend::DirectGLES::DrawElementsInstanced(mode, count, type, indices, instancecount);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsIndirect_Backend(GLenum mode, GLenum type, const void* indirect) {
|
void DrawElementsIndirect_Backend(GLenum mode, GLenum type, const void* indirect) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawElementsIndirect(mode, type, indirect);
|
||||||
MG_Backend::DirectGLES::DrawElementsIndirect(mode, type, indirect);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
void DrawArraysInstancedBaseInstance_Backend(GLenum mode, GLint first, GLsizei count, GLsizei instancecount,
|
void DrawArraysInstancedBaseInstance_Backend(GLenum mode, GLint first, GLsizei count, GLsizei instancecount,
|
||||||
GLuint baseinstance) {
|
GLuint baseinstance) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawArraysInstancedBaseInstance(mode, first, count, instancecount,
|
||||||
MG_Backend::DirectGLES::DrawArraysInstancedBaseInstance(mode, first, count, instancecount, baseinstance);
|
baseinstance);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawArraysInstanced_Backend(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) {
|
void DrawArraysInstanced_Backend(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawArraysInstanced(mode, first, count, instancecount);
|
||||||
MG_Backend::DirectGLES::DrawArraysInstanced(mode, first, count, instancecount);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawArraysIndirect_Backend(GLenum mode, const void* indirect) {
|
void DrawArraysIndirect_Backend(GLenum mode, const void* indirect) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.DrawArraysIndirect(mode, indirect);
|
||||||
MG_Backend::DirectGLES::DrawArraysIndirect(mode, indirect);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||||
void MultiDrawElementsIndirect(GLenum mode, GLenum type, const void* indirect, GLsizei drawcount,
|
void MultiDrawElementsIndirect(GLenum mode, GLenum type, const void* indirect, GLsizei drawcount, GLsizei stride) {
|
||||||
GLsizei stride) {
|
|
||||||
MultiDrawElementsIndirect_Backend(mode, type, indirect, drawcount, stride);
|
MultiDrawElementsIndirect_Backend(mode, type, indirect, drawcount, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,8 +189,7 @@ namespace MobileGL {
|
|||||||
DrawElementsInstancedBaseInstance_Backend(mode, count, type, indices, instancecount, baseinstance);
|
DrawElementsInstancedBaseInstance_Backend(mode, count, type, indices, instancecount, baseinstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void* indices,
|
void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount) {
|
||||||
GLsizei instancecount) {
|
|
||||||
DrawElementsInstanced_Backend(mode, count, type, indices, instancecount);
|
DrawElementsInstanced_Backend(mode, count, type, indices, instancecount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,5 +236,4 @@ namespace MobileGL {
|
|||||||
DrawElements_Backend(mode, count, type, indices);
|
DrawElements_Backend(mode, count, type, indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace MG_Impl::GLImpl
|
} // namespace MobileGL::MG_Impl::GLImpl
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "GL_Framebuffer.h"
|
#include "GL_Framebuffer.h"
|
||||||
#include "Validators.h"
|
#include "Validators.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include <MG_Backend/BackendObjects.h>
|
||||||
#include <MG_Util/Metrics/TextureMetrics.h>
|
#include <MG_Util/Metrics/TextureMetrics.h>
|
||||||
#include <MG_Impl/GLImpl/Texture/Validators.h>
|
#include <MG_Impl/GLImpl/Texture/Validators.h>
|
||||||
#include <MG_State/GLState/ErrorState/Error.h>
|
#include <MG_State/GLState/ErrorState/Error.h>
|
||||||
@@ -16,18 +17,12 @@
|
|||||||
#include <MG_Util/Converters/GLToMG/TextureEnumConverter.h>
|
#include <MG_Util/Converters/GLToMG/TextureEnumConverter.h>
|
||||||
#include <MG_Util/Converters/MGToGL/TextureEnumConverter.h>
|
#include <MG_Util/Converters/MGToGL/TextureEnumConverter.h>
|
||||||
#include <MG_Util/Converters/GLToMG/FramebufferEnumConverter.h>
|
#include <MG_Util/Converters/GLToMG/FramebufferEnumConverter.h>
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
|
||||||
#include <MG_Backend/DirectGLES/DirectGLES.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL::MG_Impl::GLImpl {
|
||||||
namespace MG_Impl::GLImpl {
|
|
||||||
void BlitFramebuffer_Backend(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0,
|
void BlitFramebuffer_Backend(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0,
|
||||||
GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
|
GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
|
||||||
MG_Backend::DirectGLES::BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask,
|
mask, filter);
|
||||||
filter);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SampleMaski_State(GLuint maskNumber, GLbitfield mask) {
|
void SampleMaski_State(GLuint maskNumber, GLbitfield mask) {
|
||||||
@@ -75,12 +70,6 @@ namespace MobileGL {
|
|||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateMipmap_Backend(GLenum target) {
|
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
|
||||||
MG_Backend::DirectGLES::GenerateMipmap(target);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenRenderbuffers_State(GLsizei n, GLuint* renderbuffers) {
|
void GenRenderbuffers_State(GLsizei n, GLuint* renderbuffers) {
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
@@ -112,8 +101,7 @@ namespace MobileGL {
|
|||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramebufferTexture2D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
|
void FramebufferTexture2D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
|
||||||
GLint level) {
|
|
||||||
if (target == GL_FRAMEBUFFER) {
|
if (target == GL_FRAMEBUFFER) {
|
||||||
target = GL_DRAW_FRAMEBUFFER;
|
target = GL_DRAW_FRAMEBUFFER;
|
||||||
}
|
}
|
||||||
@@ -157,8 +145,7 @@ namespace MobileGL {
|
|||||||
framebufferObject->AttachTexture(attachmentType, textureObject, textureObject ? level : 0);
|
framebufferObject->AttachTexture(attachmentType, textureObject, textureObject ? level : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramebufferTexture1D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
|
void FramebufferTexture1D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
|
||||||
GLint level) {
|
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,8 +201,7 @@ namespace MobileGL {
|
|||||||
} else if (n > MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
} else if (n > MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidValue,
|
ErrorCode::InvalidValue,
|
||||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "`n` is greater than `GL_MAX_DRAW_BUFFERS`."));
|
||||||
"`n` is greater than `GL_MAX_DRAW_BUFFERS`."));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,8 +211,7 @@ namespace MobileGL {
|
|||||||
bool isDefaultFBO = (fbo == FramebufferImpl::pDefaultFramebufferInfo->defaultFBO);
|
bool isDefaultFBO = (fbo == FramebufferImpl::pDefaultFramebufferInfo->defaultFBO);
|
||||||
|
|
||||||
static int existenceMap[(SizeT)FramebufferAttachmentType::FramebufferAttachmentTypeCount] = {-1};
|
static int existenceMap[(SizeT)FramebufferAttachmentType::FramebufferAttachmentTypeCount] = {-1};
|
||||||
std::fill(existenceMap, existenceMap + (SizeT)FramebufferAttachmentType::FramebufferAttachmentTypeCount,
|
std::fill(existenceMap, existenceMap + (SizeT)FramebufferAttachmentType::FramebufferAttachmentTypeCount, -1);
|
||||||
-1);
|
|
||||||
|
|
||||||
for (GLsizei i = 0; i < n; ++i) {
|
for (GLsizei i = 0; i < n; ++i) {
|
||||||
auto attType = MG_Util::ConvertGLEnumToFramebufferAttachmentType(bufs[i]);
|
auto attType = MG_Util::ConvertGLEnumToFramebufferAttachmentType(bufs[i]);
|
||||||
@@ -327,8 +312,8 @@ namespace MobileGL {
|
|||||||
void DeleteRenderbuffers_State(GLsizei n, const GLuint* renderbuffers) {
|
void DeleteRenderbuffers_State(GLsizei n, const GLuint* renderbuffers) {
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteRenderbuffers_State",
|
ErrorCode::InvalidValue,
|
||||||
"n must be non-negative."));
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteRenderbuffers_State", "n must be non-negative."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,14 +335,14 @@ namespace MobileGL {
|
|||||||
void DeleteFramebuffers_State(GLsizei n, const GLuint* framebuffers) {
|
void DeleteFramebuffers_State(GLsizei n, const GLuint* framebuffers) {
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteFramebuffers_State",
|
ErrorCode::InvalidValue,
|
||||||
"n must be non-negative."));
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteFramebuffers_State", "n must be non-negative."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!framebuffers) {
|
if (!framebuffers) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteFramebuffers_State",
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteFramebuffers_State",
|
||||||
"Framebuffer names array cannot be null."));
|
"Framebuffer names array cannot be null."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -485,38 +470,29 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClearBufferfi_Backend(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) {
|
void ClearBufferfi_Backend(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.ClearBufferfi(buffer, drawbuffer, depth, stencil);
|
||||||
MG_Backend::DirectGLES::ClearBufferfi(buffer, drawbuffer, depth, stencil);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearBufferfv_Backend(GLenum buffer, GLint drawbuffer, const GLfloat* value) {
|
void ClearBufferfv_Backend(GLenum buffer, GLint drawbuffer, const GLfloat* value) {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.ClearBufferfv(buffer, drawbuffer, value);
|
||||||
MG_Backend::DirectGLES::ClearBufferfv(buffer, drawbuffer, value);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearBufferuiv_Backend(GLenum buffer, GLint drawbuffer, const GLuint* value) {
|
void ClearBufferuiv_Backend(GLenum buffer, GLint drawbuffer, const GLuint* value) {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.ClearBufferuiv(buffer, drawbuffer, value);
|
||||||
MG_Backend::DirectGLES::ClearBufferuiv(buffer, drawbuffer, value);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearBufferiv_Backend(GLenum buffer, GLint drawbuffer, const GLint* value) {
|
void ClearBufferiv_Backend(GLenum buffer, GLint drawbuffer, const GLint* value) {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.ClearBufferiv(buffer, drawbuffer, value);
|
||||||
MG_Backend::DirectGLES::ClearBufferiv(buffer, drawbuffer, value);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadPixels_State(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
|
void ReadPixels_State(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) {
|
||||||
void* pixels) {
|
|
||||||
TextureInputFormat textureInputFormat = MG_Util::ConvertGLEnumToTextureInputFormat(format);
|
TextureInputFormat textureInputFormat = MG_Util::ConvertGLEnumToTextureInputFormat(format);
|
||||||
TexturePixelDataType texturePixelDataType = MG_Util::ConvertGLEnumToTexturePixelDataType(type);
|
TexturePixelDataType texturePixelDataType = MG_Util::ConvertGLEnumToTexturePixelDataType(type);
|
||||||
|
|
||||||
// Check width/height
|
// Check width/height
|
||||||
if (width < 0 || height < 0) {
|
if (width < 0 || height < 0) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ReadPixels_State",
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ReadPixels_State",
|
||||||
"Width and height must be non-negative"));
|
"Width and height must be non-negative"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -601,8 +577,7 @@ namespace MobileGL {
|
|||||||
// Check if PBO is mapped
|
// Check if PBO is mapped
|
||||||
if (pixelPackBufferObject->IsMapped()) {
|
if (pixelPackBufferObject->IsMapped()) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidOperation,
|
ErrorCode::InvalidOperation, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ReadPixels_State",
|
||||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ReadPixels_State",
|
|
||||||
"Pixel pack buffer is currently mapped"));
|
"Pixel pack buffer is currently mapped"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -631,11 +606,8 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadPixels_Backend(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
|
void ReadPixels_Backend(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) {
|
||||||
void* pixels) {
|
MG_Backend::gBackendFunctionsTable.GL.ReadPixels(x, y, width, height, format, type, pixels);
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
|
||||||
MG_Backend::DirectGLES::ReadPixels(x, y, width, height, format, type, pixels);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||||
@@ -685,10 +657,6 @@ namespace MobileGL {
|
|||||||
GetFramebufferAttachmentParameteriv_State(target, attachment, pname, params);
|
GetFramebufferAttachmentParameteriv_State(target, attachment, pname, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateMipmap(GLenum target) {
|
|
||||||
GenerateMipmap_Backend(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
|
void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
|
||||||
GenRenderbuffers_State(n, renderbuffers);
|
GenRenderbuffers_State(n, renderbuffers);
|
||||||
}
|
}
|
||||||
@@ -765,6 +733,5 @@ namespace MobileGL {
|
|||||||
|
|
||||||
namespace FramebufferImpl {
|
namespace FramebufferImpl {
|
||||||
DefaultFramebufferInfo* pDefaultFramebufferInfo;
|
DefaultFramebufferInfo* pDefaultFramebufferInfo;
|
||||||
}
|
} // namespace FramebufferImpl
|
||||||
} // namespace MG_Impl::GLImpl
|
} // namespace MobileGL::MG_Impl::GLImpl
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -29,14 +29,8 @@ namespace MobileGL {
|
|||||||
void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
|
void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
|
||||||
void BindRenderbuffer(GLenum target, GLuint renderbuffer);
|
void BindRenderbuffer(GLenum target, GLuint renderbuffer);
|
||||||
void SampleMaski(GLuint maskNumber, GLbitfield mask);
|
void SampleMaski(GLuint maskNumber, GLbitfield mask);
|
||||||
void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width,
|
|
||||||
GLsizei height);
|
|
||||||
void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
|
||||||
GLboolean IsRenderbuffer(GLuint renderbuffer);
|
|
||||||
GLboolean IsFramebuffer(GLuint framebuffer);
|
GLboolean IsFramebuffer(GLuint framebuffer);
|
||||||
void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
|
void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
|
||||||
void GenerateMipmap(GLenum target);
|
|
||||||
void GenRenderbuffers(GLsizei n, GLuint* renderbuffers);
|
|
||||||
void GenFramebuffers(GLsizei n, GLuint* framebuffers);
|
void GenFramebuffers(GLsizei n, GLuint* framebuffers);
|
||||||
void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
|
void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
|
||||||
void FramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level,
|
void FramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level,
|
||||||
@@ -44,16 +38,13 @@ namespace MobileGL {
|
|||||||
void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||||
void FramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
void FramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||||
void FramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level);
|
void FramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level);
|
||||||
void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
|
||||||
void DrawBuffer(GLenum buf);
|
void DrawBuffer(GLenum buf);
|
||||||
void DrawBuffers(GLsizei n, const GLenum* bufs);
|
void DrawBuffers(GLsizei n, const GLenum* bufs);
|
||||||
void ReadBuffer(GLenum src);
|
void ReadBuffer(GLenum src);
|
||||||
void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
|
|
||||||
void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
|
void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
|
||||||
GLenum CheckFramebufferStatus(GLenum target);
|
GLenum CheckFramebufferStatus(GLenum target);
|
||||||
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1,
|
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1,
|
||||||
GLint dstY1, GLbitfield mask, GLenum filter);
|
GLint dstY1, GLbitfield mask, GLenum filter);
|
||||||
void BindRenderbuffer(GLenum target, GLuint renderbuffer);
|
|
||||||
void BindFramebuffer(GLenum target, GLuint framebuffer);
|
void BindFramebuffer(GLenum target, GLuint framebuffer);
|
||||||
|
|
||||||
namespace FramebufferImpl {
|
namespace FramebufferImpl {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "GL_Getter.h"
|
#include "GL_Getter.h"
|
||||||
|
#include "GL/gl.h"
|
||||||
|
#include "MG_Util/Debug/Log.h"
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <MGGitHash.h>
|
#include <MGGitHash.h>
|
||||||
#include <MG_State/GLState/Core.h>
|
#include <MG_State/GLState/Core.h>
|
||||||
@@ -16,47 +18,9 @@
|
|||||||
#include <MG_Util/Converters/MGToStr/GLExtensionConverter.h>
|
#include <MG_Util/Converters/MGToStr/GLExtensionConverter.h>
|
||||||
#include <MG_Util/Converters/MGToGL/RenderStateEnumConverter.h>
|
#include <MG_Util/Converters/MGToGL/RenderStateEnumConverter.h>
|
||||||
#include <MG_State/GLState/FramebufferState/FramebufferObject.h>
|
#include <MG_State/GLState/FramebufferState/FramebufferObject.h>
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
#include <MG_Backend/BackendObjects.h>
|
||||||
#include <MG_Backend/DirectGLES/DirectGLES.h>
|
|
||||||
#include "MG_Util/BackendLoaders/OpenGL/Loader.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace MobileGL {
|
|
||||||
namespace MG_Impl::GLImpl {
|
|
||||||
const GLubyte* GetString_Backend(GLenum name) {
|
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
|
||||||
return MG_Backend::DirectGLES::GetString(name);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline String GetFormattedBackendGLVersion() {
|
|
||||||
const char* raw = reinterpret_cast<const char*>(GetString_Backend(GL_VERSION));
|
|
||||||
if (!raw || raw[0] == '\0') {
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr SizeT kOpenGLESLen = 9; // "OpenGL ES"
|
|
||||||
if (std::strncmp(raw, "OpenGL ES", kOpenGLESLen) == 0) {
|
|
||||||
std::istringstream iss(raw);
|
|
||||||
String a, b, c;
|
|
||||||
if (iss >> a >> b >> c) {
|
|
||||||
return a + " " + b + " " + c; // e.g. "OpenGL ES 3.2"
|
|
||||||
} else {
|
|
||||||
return "OpenGL ES ?";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::istringstream iss(raw);
|
|
||||||
String ver;
|
|
||||||
if (iss >> ver) {
|
|
||||||
return String("OpenGL ") + ver; // e.g. "OpenGL 4.6"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Impl::GLImpl {
|
||||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||||
const GLubyte* GetString(GLenum name) {
|
const GLubyte* GetString(GLenum name) {
|
||||||
static String vendorString;
|
static String vendorString;
|
||||||
@@ -64,50 +28,58 @@ namespace MobileGL {
|
|||||||
static String rendererString;
|
static String rendererString;
|
||||||
static String shadingLanguageVersion;
|
static String shadingLanguageVersion;
|
||||||
static String extensionsString;
|
static String extensionsString;
|
||||||
|
const auto& activeBackendObject = MG_Backend::pActiveBackendObject;
|
||||||
|
|
||||||
MGLOG_D("glGetString, name: %s", MG_Util::ConvertGLEnumToString(name).c_str());
|
MGLOG_D("glGetString, name: %s", MG_Util::ConvertGLEnumToString(name).c_str());
|
||||||
|
if (!activeBackendObject) {
|
||||||
|
MGLOG_E("activeBackendObject is not initialized!");
|
||||||
|
return (GLubyte*)"Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& rendererInfo = activeBackendObject->GetRendererInfo();
|
||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case GL_VENDOR:
|
case GL_VENDOR:
|
||||||
if (vendorString.empty()) {
|
if (vendorString.empty()) {
|
||||||
if (MG_Config::RendererInfoPtr->ExtraVendor.has_value()) {
|
if (rendererInfo.ExtraVendor.has_value()) {
|
||||||
vendorString =
|
vendorString = std::format("{}{}", MG_Config::CoreVendor, rendererInfo.ExtraVendor.value());
|
||||||
std::format("{}{}", MG_Config::CoreVendor, MG_Config::RendererInfoPtr->ExtraVendor.value());
|
|
||||||
} else {
|
} else {
|
||||||
vendorString = MG_Config::CoreVendor;
|
vendorString = MG_Config::CoreVendor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MGLOG_D("vendorString: %s", vendorString.c_str());
|
||||||
return (const GLubyte*)vendorString.c_str();
|
return (const GLubyte*)vendorString.c_str();
|
||||||
case GL_VERSION: {
|
case GL_VERSION: {
|
||||||
if (versionStr.empty()) {
|
if (versionStr.empty()) {
|
||||||
versionStr = std::format(
|
versionStr =
|
||||||
"{} {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT,
|
std::format("{} {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT,
|
||||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
rendererInfo.RendererGLInfo.TargetGLVersion.toString(), MG_Config::ProjectName,
|
||||||
MG_Config::ProjectName.c_str(),
|
MG_Config::CoreVersion.toFormattedString(MG_Config::DefaultVersionStringFormatAttrib),
|
||||||
MG_Config::CoreVersion.toFormattedString(MG_Config::DefaultVersionStringFormatAttrib).c_str(),
|
rendererInfo.BackendName);
|
||||||
MG_Config::RendererInfoPtr->BackendName.c_str());
|
|
||||||
}
|
}
|
||||||
|
MGLOG_D("versionStr: %s", versionStr.c_str());
|
||||||
return (const GLubyte*)versionStr.c_str();
|
return (const GLubyte*)versionStr.c_str();
|
||||||
}
|
}
|
||||||
case GL_RENDERER: {
|
case GL_RENDERER: {
|
||||||
if (rendererString.empty()) {
|
if (rendererString.empty()) {
|
||||||
const char* backendStr = (const char*)GetString_Backend(GL_RENDERER);
|
String backendVersionStr = activeBackendObject->GetBackendAPIVersionString();
|
||||||
String backendVersionStr = GetFormattedBackendGLVersion();
|
rendererString =
|
||||||
rendererString = std::format("{} ({}) ({}, {})", MG_Config::RendererInfoPtr->RendererName.c_str(),
|
std::format("{} ({}) ({})", rendererInfo.RendererName, MG_Config::CoreName, backendVersionStr);
|
||||||
MG_Config::CoreName.c_str(), backendStr ? backendStr : "<Unknown GPU>",
|
|
||||||
!backendVersionStr.empty() ? backendVersionStr : "<Unknown Version>");
|
|
||||||
}
|
}
|
||||||
|
MGLOG_D("rendererString: %s", rendererString.c_str());
|
||||||
return (const GLubyte*)rendererString.c_str();
|
return (const GLubyte*)rendererString.c_str();
|
||||||
}
|
}
|
||||||
case GL_SHADING_LANGUAGE_VERSION:
|
case GL_SHADING_LANGUAGE_VERSION:
|
||||||
if (shadingLanguageVersion.empty()) {
|
if (shadingLanguageVersion.empty()) {
|
||||||
shadingLanguageVersion = std::format(
|
shadingLanguageVersion =
|
||||||
"{} {}",
|
std::format("{} {}", rendererInfo.RendererGLInfo.TargetGLSLVersion.toString({true, false}),
|
||||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString({true, false}).c_str(),
|
MG_Config::ProjectName);
|
||||||
MG_Config::ProjectName.c_str());
|
|
||||||
}
|
}
|
||||||
|
MGLOG_D("shadingLanguageVersion: %s", shadingLanguageVersion.c_str());
|
||||||
return (const GLubyte*)shadingLanguageVersion.c_str();
|
return (const GLubyte*)shadingLanguageVersion.c_str();
|
||||||
case GL_EXTENSIONS:
|
case GL_EXTENSIONS:
|
||||||
if (extensionsString.empty()) {
|
if (extensionsString.empty()) {
|
||||||
for (auto& ext : MG_Config::RendererInfoPtr->RendererGLInfo.Extensions) {
|
for (auto& ext : rendererInfo.RendererGLInfo.Extensions) {
|
||||||
extensionsString += MG_Util::ConvertGLExtToString(ext);
|
extensionsString += MG_Util::ConvertGLExtToString(ext);
|
||||||
extensionsString += " ";
|
extensionsString += " ";
|
||||||
}
|
}
|
||||||
@@ -125,7 +97,14 @@ namespace MobileGL {
|
|||||||
return (const GLubyte*)"";
|
return (const GLubyte*)"";
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& exts = MG_Config::RendererInfoPtr->RendererGLInfo.Extensions;
|
const auto& activeBackendObject = MG_Backend::pActiveBackendObject;
|
||||||
|
if (!activeBackendObject) {
|
||||||
|
MGLOG_E("activeBackendObject is not initialized!");
|
||||||
|
return (GLubyte*)"Unknown";
|
||||||
|
}
|
||||||
|
const auto& rendererInfo = activeBackendObject->GetRendererInfo();
|
||||||
|
|
||||||
|
const auto& exts = rendererInfo.RendererGLInfo.Extensions;
|
||||||
if (index >= exts.size()) {
|
if (index >= exts.size()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -152,6 +131,13 @@ namespace MobileGL {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto& activeBackendObject = MG_Backend::pActiveBackendObject;
|
||||||
|
if (!activeBackendObject) {
|
||||||
|
MGLOG_E("activeBackendObject is not initialized!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto& rendererInfo = activeBackendObject->GetRendererInfo();
|
||||||
|
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_ACTIVE_TEXTURE:
|
case GL_ACTIVE_TEXTURE:
|
||||||
*params = MG_State::pGLContext->GetActiveTextureUnit() + GL_TEXTURE0;
|
*params = MG_State::pGLContext->GetActiveTextureUnit() + GL_TEXTURE0;
|
||||||
@@ -301,14 +287,12 @@ namespace MobileGL {
|
|||||||
*params = 0; // TODO
|
*params = 0; // TODO
|
||||||
break;
|
break;
|
||||||
case GL_DRAW_FRAMEBUFFER_BINDING: {
|
case GL_DRAW_FRAMEBUFFER_BINDING: {
|
||||||
const auto& FBO =
|
const auto& FBO = MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw).GetBoundObject();
|
||||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw).GetBoundObject();
|
|
||||||
*params = FBO ? FBO->GetExternalIndex() : 0;
|
*params = FBO ? FBO->GetExternalIndex() : 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GL_READ_FRAMEBUFFER_BINDING: {
|
case GL_READ_FRAMEBUFFER_BINDING: {
|
||||||
const auto& FBO =
|
const auto& FBO = MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Read).GetBoundObject();
|
||||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Read).GetBoundObject();
|
|
||||||
*params = FBO ? FBO->GetExternalIndex() : 0;
|
*params = FBO ? FBO->GetExternalIndex() : 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -317,8 +301,7 @@ namespace MobileGL {
|
|||||||
*params = 0;
|
*params = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const auto& bufferObject =
|
const auto& bufferObject = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Index).GetBoundObject();
|
||||||
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Index).GetBoundObject();
|
|
||||||
*params = bufferObject ? bufferObject->GetExternalIndex() : 0;
|
*params = bufferObject ? bufferObject->GetExternalIndex() : 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -347,7 +330,7 @@ namespace MobileGL {
|
|||||||
*params = 0; // TODO
|
*params = 0; // TODO
|
||||||
break;
|
break;
|
||||||
case GL_MAJOR_VERSION:
|
case GL_MAJOR_VERSION:
|
||||||
*params = MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Major;
|
*params = rendererInfo.RendererGLInfo.TargetGLVersion.Major;
|
||||||
break;
|
break;
|
||||||
case GL_MAX_3D_TEXTURE_SIZE:
|
case GL_MAX_3D_TEXTURE_SIZE:
|
||||||
*params = 1024 * 16; // TODO
|
*params = 1024 * 16; // TODO
|
||||||
@@ -546,13 +529,13 @@ namespace MobileGL {
|
|||||||
*params = 16; // TODO
|
*params = 16; // TODO
|
||||||
break;
|
break;
|
||||||
case GL_MINOR_VERSION:
|
case GL_MINOR_VERSION:
|
||||||
*params = MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Minor;
|
*params = rendererInfo.RendererGLInfo.TargetGLVersion.Minor;
|
||||||
break;
|
break;
|
||||||
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
|
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
|
||||||
*params = 18; // TODO
|
*params = 18; // TODO
|
||||||
break;
|
break;
|
||||||
case GL_NUM_EXTENSIONS:
|
case GL_NUM_EXTENSIONS:
|
||||||
*params = static_cast<GLint>(MG_Config::RendererInfoPtr->RendererGLInfo.Extensions.size());
|
*params = (Int)rendererInfo.RendererGLInfo.Extensions.size();
|
||||||
break;
|
break;
|
||||||
case GL_NUM_PROGRAM_BINARY_FORMATS:
|
case GL_NUM_PROGRAM_BINARY_FORMATS:
|
||||||
*params = 2; // TODO
|
*params = 2; // TODO
|
||||||
@@ -603,8 +586,7 @@ namespace MobileGL {
|
|||||||
*params = 0; // TODO
|
*params = 0; // TODO
|
||||||
break;
|
break;
|
||||||
case GL_PROGRAM_POINT_SIZE:
|
case GL_PROGRAM_POINT_SIZE:
|
||||||
*params =
|
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::ProgramPointSize) ? GL_TRUE : GL_FALSE;
|
||||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::ProgramPointSize) ? GL_TRUE : GL_FALSE;
|
|
||||||
break;
|
break;
|
||||||
case GL_PROVOKING_VERTEX:
|
case GL_PROVOKING_VERTEX:
|
||||||
*params = 0; // TODO
|
*params = 0; // TODO
|
||||||
@@ -637,8 +619,7 @@ namespace MobileGL {
|
|||||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PolygonOffsetPoint) ? GL_TRUE : GL_FALSE;
|
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PolygonOffsetPoint) ? GL_TRUE : GL_FALSE;
|
||||||
break;
|
break;
|
||||||
case GL_POLYGON_SMOOTH:
|
case GL_POLYGON_SMOOTH:
|
||||||
*params =
|
*params = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PolygonSmooth) ? GL_TRUE : GL_FALSE;
|
||||||
MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::PolygonSmooth) ? GL_TRUE : GL_FALSE;
|
|
||||||
break;
|
break;
|
||||||
case GL_POLYGON_SMOOTH_HINT:
|
case GL_POLYGON_SMOOTH_HINT:
|
||||||
*params = 0; // TODO
|
*params = 0; // TODO
|
||||||
@@ -820,11 +801,7 @@ namespace MobileGL {
|
|||||||
*params = 0; // TODO
|
*params = 0; // TODO
|
||||||
break;
|
break;
|
||||||
case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
|
case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
*params = (Int)activeBackendObject->GetDynamicParameters().UniformBufferOffsetAlignment;
|
||||||
*params = MG_External::GLES::g_glesCaps.uniformBufferOffsetAlignment;
|
|
||||||
#else
|
|
||||||
*params = 256;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case GL_UNIFORM_BUFFER_SIZE:
|
case GL_UNIFORM_BUFFER_SIZE:
|
||||||
*params = 0; // TODO
|
*params = 0; // TODO
|
||||||
@@ -908,8 +885,8 @@ namespace MobileGL {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)", MG_Util::ConvertGLEnumToString(pname).c_str(), pname);
|
MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)", MG_Util::ConvertGLEnumToString(pname).c_str(), pname);
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||||
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetIntegerv",
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetIntegerv",
|
||||||
std::format("Invalid enum: 0x{:X}", pname)));
|
std::format("Invalid enum: 0x{:X}", pname)));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -920,5 +897,4 @@ namespace MobileGL {
|
|||||||
ErrorCode errorCode = MG_State::pGLContext->PopGLError().value_or(Error{ErrorCode::NoError, nullptr}).code;
|
ErrorCode errorCode = MG_State::pGLContext->PopGLError().value_or(Error{ErrorCode::NoError, nullptr}).code;
|
||||||
return MG_Util::ConvertErrorCodeToGLEnum(errorCode);
|
return MG_Util::ConvertErrorCodeToGLEnum(errorCode);
|
||||||
}
|
}
|
||||||
} // namespace MG_Impl::GLImpl
|
} // namespace MobileGL::MG_Impl::GLImpl
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -9,12 +9,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL::MG_Impl::GLImpl {
|
||||||
namespace MG_Impl::GLImpl {
|
|
||||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||||
const GLubyte* GetString(GLenum name);
|
const GLubyte* GetString(GLenum name);
|
||||||
const GLubyte* GetStringi(GLenum name, GLuint index);
|
const GLubyte* GetStringi(GLenum name, GLuint index);
|
||||||
void GetIntegerv(GLenum pname, GLint* params);
|
void GetIntegerv(GLenum pname, GLint* params);
|
||||||
GLenum GetError();
|
GLenum GetError();
|
||||||
} // namespace MG_Impl::GLImpl
|
} // namespace MobileGL::MG_Impl::GLImpl
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -477,7 +477,19 @@ namespace MobileGL {
|
|||||||
auto programObject = TryToGetProgramObject(program);
|
auto programObject = TryToGetProgramObject(program);
|
||||||
if (!programObject) return;
|
if (!programObject) return;
|
||||||
MGLOG_D("%s: linking program %d", __func__, program);
|
MGLOG_D("%s: linking program %d", __func__, program);
|
||||||
programObject->Link(!MG_Config::RendererInfoPtr->BackendCapability.AllowVSOnlyPrograms);
|
|
||||||
|
static Bool allowVSOnlyPrograms;
|
||||||
|
static Bool initialized = false;
|
||||||
|
if (!initialized) {
|
||||||
|
const auto& activeBackendObject = MG_Backend::pActiveBackendObject;
|
||||||
|
if (!activeBackendObject) {
|
||||||
|
MGLOG_E("activeBackendObject is not initialized!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto& rendererInfo = activeBackendObject->GetRendererInfo();
|
||||||
|
allowVSOnlyPrograms = (Int)rendererInfo.StaticBackendCapability.AllowVSOnlyPrograms;
|
||||||
|
}
|
||||||
|
programObject->Link(!allowVSOnlyPrograms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderSource_State(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
|
void ShaderSource_State(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "ProxyTexture.h"
|
#include "ProxyTexture.h"
|
||||||
|
|
||||||
#include <MG_State/GLState/Core.h>
|
#include <MG_State/GLState/Core.h>
|
||||||
|
#include <MG_Backend/BackendObjects.h>
|
||||||
#include <MG_Util/Metrics/TextureMetrics.h>
|
#include <MG_Util/Metrics/TextureMetrics.h>
|
||||||
#include <MG_State/GLState/ErrorState/Error.h>
|
#include <MG_State/GLState/ErrorState/Error.h>
|
||||||
#include <MG_Util/Texture/PixelStoreProcessor.h>
|
#include <MG_Util/Texture/PixelStoreProcessor.h>
|
||||||
@@ -25,21 +26,15 @@
|
|||||||
#include <MG_Util/Converters/MGToStr/TextureEnumConverter.h>
|
#include <MG_Util/Converters/MGToStr/TextureEnumConverter.h>
|
||||||
#include <MG_State/GLState/TextureState/TextureObjectBuffer.h>
|
#include <MG_State/GLState/TextureState/TextureObjectBuffer.h>
|
||||||
|
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
namespace MobileGL::MG_Impl::GLImpl {
|
||||||
#include <MG_Backend/DirectGLES/DirectGLES.h>
|
SharedPtr<MG_State::GLState::ITextureObject> GetTextureObjectByTarget(TextureUploadTarget textureUploadingTarget,
|
||||||
#endif
|
TextureTarget textureTarget) {
|
||||||
|
|
||||||
namespace MobileGL {
|
|
||||||
namespace MG_Impl::GLImpl {
|
|
||||||
SharedPtr<MG_State::GLState::ITextureObject> GetTextureObjectByTarget(
|
|
||||||
TextureUploadTarget textureUploadingTarget, TextureTarget textureTarget) {
|
|
||||||
SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
|
SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
|
||||||
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
||||||
textureObject =
|
textureObject =
|
||||||
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
|
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
|
||||||
} else {
|
} else {
|
||||||
auto activeUnit =
|
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
||||||
textureObject = bindingSlot.GetBoundObject();
|
textureObject = bindingSlot.GetBoundObject();
|
||||||
}
|
}
|
||||||
@@ -49,13 +44,17 @@ namespace MobileGL {
|
|||||||
return textureObject;
|
return textureObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenerateMipmap_Backend(GLenum target) {
|
||||||
|
MG_Backend::gBackendFunctionsTable.GL.GenerateMipmap(target);
|
||||||
|
}
|
||||||
|
|
||||||
void TexSubImage3D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
|
void TexSubImage3D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
|
||||||
GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) {
|
GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexSubImage2D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
|
void TexSubImage2D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
|
||||||
GLsizei height, GLenum format, GLenum type, const void* pixels) {
|
GLenum format, GLenum type, const void* pixels) {
|
||||||
// ======================= Converting ================================
|
// ======================= Converting ================================
|
||||||
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
|
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
|
||||||
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
|
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
|
||||||
@@ -93,8 +92,8 @@ namespace MobileGL {
|
|||||||
// ===================== Error Checking ==============================
|
// ===================== Error Checking ==============================
|
||||||
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
|
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
|
||||||
if (!TextureImpl::ValidateTextureSubImageOffsets(textureObject, xoffset, width, yoffset, height)) return;
|
if (!TextureImpl::ValidateTextureSubImageOffsets(textureObject, xoffset, width, yoffset, height)) return;
|
||||||
if (!TextureImpl::ValidateTextureInternalFormatCompatibleWithInput(
|
if (!TextureImpl::ValidateTextureInternalFormatCompatibleWithInput(textureInputFormat, textureInternalFormat,
|
||||||
textureInputFormat, textureInternalFormat, texturePixelDataType))
|
texturePixelDataType))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// ======================= Processing ================================
|
// ======================= Processing ================================
|
||||||
@@ -134,8 +133,8 @@ namespace MobileGL {
|
|||||||
{width, height, 1}, false, inputSize);
|
{width, height, 1}, false, inputSize);
|
||||||
|
|
||||||
if (!processedPixels || inputSize == 0) {
|
if (!processedPixels || inputSize == 0) {
|
||||||
MGLOG_E("TexSubImage2D_State: Failed to process pixel data for TexSubImage2D, width: %d, height: %d",
|
MGLOG_E("TexSubImage2D_State: Failed to process pixel data for TexSubImage2D, width: %d, height: %d", width,
|
||||||
width, height);
|
height);
|
||||||
if (processedPixels) free(processedPixels);
|
if (processedPixels) free(processedPixels);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -233,8 +232,7 @@ namespace MobileGL {
|
|||||||
textureObject->GetSamplerObject()->SetCompareMode(MG_Util::ConvertGLEnumToSamplerCompareMode(param));
|
textureObject->GetSamplerObject()->SetCompareMode(MG_Util::ConvertGLEnumToSamplerCompareMode(param));
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_COMPARE_FUNC:
|
case GL_TEXTURE_COMPARE_FUNC:
|
||||||
textureObject->GetSamplerObject()->SetSamplerCompareFunc(
|
textureObject->GetSamplerObject()->SetSamplerCompareFunc(MG_Util::ConvertGLEnumToSamplerCompareFunc(param));
|
||||||
MG_Util::ConvertGLEnumToSamplerCompareFunc(param));
|
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_LOD_BIAS:
|
case GL_TEXTURE_LOD_BIAS:
|
||||||
textureObject->GetSamplerObject()->SetLodBias(param);
|
textureObject->GetSamplerObject()->SetLodBias(param);
|
||||||
@@ -246,9 +244,9 @@ namespace MobileGL {
|
|||||||
default:
|
default:
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidEnum,
|
ErrorCode::InvalidEnum,
|
||||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
MakeShared<GenericErrorInfo>(
|
||||||
std::format("pname {} is not a valid texture parameter.",
|
"MG_Impl/GLImpl", __func__,
|
||||||
MG_Util::ConvertGLEnumToString(pname))));
|
std::format("pname {} is not a valid texture parameter.", MG_Util::ConvertGLEnumToString(pname))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,8 +307,7 @@ namespace MobileGL {
|
|||||||
textureObject->GetSamplerObject()->SetCompareMode(MG_Util::ConvertGLEnumToSamplerCompareMode(param));
|
textureObject->GetSamplerObject()->SetCompareMode(MG_Util::ConvertGLEnumToSamplerCompareMode(param));
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_COMPARE_FUNC:
|
case GL_TEXTURE_COMPARE_FUNC:
|
||||||
textureObject->GetSamplerObject()->SetSamplerCompareFunc(
|
textureObject->GetSamplerObject()->SetSamplerCompareFunc(MG_Util::ConvertGLEnumToSamplerCompareFunc(param));
|
||||||
MG_Util::ConvertGLEnumToSamplerCompareFunc(param));
|
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_LOD_BIAS:
|
case GL_TEXTURE_LOD_BIAS:
|
||||||
textureObject->GetSamplerObject()->SetLodBias((GLfloat)param);
|
textureObject->GetSamplerObject()->SetLodBias((GLfloat)param);
|
||||||
@@ -322,9 +319,9 @@ namespace MobileGL {
|
|||||||
default:
|
default:
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidEnum,
|
ErrorCode::InvalidEnum,
|
||||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
MakeShared<GenericErrorInfo>(
|
||||||
std::format("pname {} is not a valid texture parameter.",
|
"MG_Impl/GLImpl", __func__,
|
||||||
MG_Util::ConvertGLEnumToString(pname))));
|
std::format("pname {} is not a valid texture parameter.", MG_Util::ConvertGLEnumToString(pname))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -504,16 +501,13 @@ namespace MobileGL {
|
|||||||
"%s called with target: %s, level: %d, internalformat: %s, width: %d, height: %d, depth: %d, "
|
"%s called with target: %s, level: %d, internalformat: %s, width: %d, height: %d, depth: %d, "
|
||||||
"border: %d, format: %s, type: %s (%u), pixels: %p",
|
"border: %d, format: %s, type: %s (%u), pixels: %p",
|
||||||
__func__,
|
__func__,
|
||||||
MG_Util::ConvertTextureUploadTargetToString(MG_Util::ConvertGLEnumToTextureUploadTarget(target))
|
MG_Util::ConvertTextureUploadTargetToString(MG_Util::ConvertGLEnumToTextureUploadTarget(target)).c_str(),
|
||||||
.c_str(),
|
|
||||||
level,
|
level,
|
||||||
MG_Util::ConvertTextureInternalFormatToString(
|
MG_Util::ConvertTextureInternalFormatToString(MG_Util::ConvertGLEnumToTextureInternalFormat(internalformat))
|
||||||
MG_Util::ConvertGLEnumToTextureInternalFormat(internalformat))
|
|
||||||
.c_str(),
|
.c_str(),
|
||||||
width, height, depth, border,
|
width, height, depth, border,
|
||||||
MG_Util::ConvertTextureInputFormatToString(MG_Util::ConvertGLEnumToTextureInputFormat(format)).c_str(),
|
MG_Util::ConvertTextureInputFormatToString(MG_Util::ConvertGLEnumToTextureInputFormat(format)).c_str(),
|
||||||
MG_Util::ConvertTexturePixelDataTypeToString(MG_Util::ConvertGLEnumToTexturePixelDataType(type))
|
MG_Util::ConvertTexturePixelDataTypeToString(MG_Util::ConvertGLEnumToTexturePixelDataType(type)).c_str(),
|
||||||
.c_str(),
|
|
||||||
type, pixels);
|
type, pixels);
|
||||||
// ======================= Converting ================================
|
// ======================= Converting ================================
|
||||||
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
|
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
|
||||||
@@ -531,8 +525,8 @@ namespace MobileGL {
|
|||||||
if (!TextureImpl::ValidateTextureSizeRange(width, height, depth)) return;
|
if (!TextureImpl::ValidateTextureSizeRange(width, height, depth)) return;
|
||||||
if (!TextureImpl::ValidateTextureInternalFormat(textureInternalFormat)) return;
|
if (!TextureImpl::ValidateTextureInternalFormat(textureInternalFormat)) return;
|
||||||
if (!TextureImpl::ValidateTextureBorderNumber(border)) return;
|
if (!TextureImpl::ValidateTextureBorderNumber(border)) return;
|
||||||
if (!TextureImpl::ValidateTextureInternalFormatCompatibleWithInput(
|
if (!TextureImpl::ValidateTextureInternalFormatCompatibleWithInput(textureInputFormat, textureInternalFormat,
|
||||||
textureInputFormat, textureInternalFormat, texturePixelDataType))
|
texturePixelDataType))
|
||||||
return;
|
return;
|
||||||
if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return;
|
if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return;
|
||||||
|
|
||||||
@@ -551,8 +545,7 @@ namespace MobileGL {
|
|||||||
textureObject =
|
textureObject =
|
||||||
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
|
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
|
||||||
} else {
|
} else {
|
||||||
auto activeUnit =
|
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
||||||
textureObject = bindingSlot.GetBoundObject();
|
textureObject = bindingSlot.GetBoundObject();
|
||||||
}
|
}
|
||||||
@@ -589,8 +582,7 @@ namespace MobileGL {
|
|||||||
auto textureMipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
|
auto textureMipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
|
||||||
|
|
||||||
// Allocate in TextureObject
|
// Allocate in TextureObject
|
||||||
textureMipmapObject->AllocateStorage(textureUploadingTarget, level,
|
textureMipmapObject->AllocateStorage(textureUploadingTarget, level, {{width, height, depth}, internalBytes});
|
||||||
{{width, height, depth}, internalBytes});
|
|
||||||
|
|
||||||
if (!originalPixels) {
|
if (!originalPixels) {
|
||||||
MGLOG_D("%s: No input pixel and no PBO bound, no pixel transfer", __func__);
|
MGLOG_D("%s: No input pixel and no PBO bound, no pixel transfer", __func__);
|
||||||
@@ -619,8 +611,8 @@ namespace MobileGL {
|
|||||||
free(processedPixels);
|
free(processedPixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexImage2D_State(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
|
void TexImage2D_State(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border,
|
||||||
GLint border, GLenum format, GLenum type, const void* pixels) {
|
GLenum format, GLenum type, const void* pixels) {
|
||||||
// ======================= Converting ================================
|
// ======================= Converting ================================
|
||||||
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
|
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
|
||||||
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
|
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
|
||||||
@@ -646,8 +638,8 @@ namespace MobileGL {
|
|||||||
if (!TextureImpl::ValidateTextureSizeRange(width, height, 1)) return;
|
if (!TextureImpl::ValidateTextureSizeRange(width, height, 1)) return;
|
||||||
if (!TextureImpl::ValidateTextureInternalFormat(textureInternalFormat)) return;
|
if (!TextureImpl::ValidateTextureInternalFormat(textureInternalFormat)) return;
|
||||||
if (!TextureImpl::ValidateTextureBorderNumber(border)) return;
|
if (!TextureImpl::ValidateTextureBorderNumber(border)) return;
|
||||||
if (!TextureImpl::ValidateTextureInternalFormatCompatibleWithInput(
|
if (!TextureImpl::ValidateTextureInternalFormatCompatibleWithInput(textureInputFormat, textureInternalFormat,
|
||||||
textureInputFormat, textureInternalFormat, texturePixelDataType))
|
texturePixelDataType))
|
||||||
return;
|
return;
|
||||||
if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return;
|
if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return;
|
||||||
|
|
||||||
@@ -669,8 +661,7 @@ namespace MobileGL {
|
|||||||
textureObject =
|
textureObject =
|
||||||
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
|
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
|
||||||
} else {
|
} else {
|
||||||
auto activeUnit =
|
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
||||||
textureObject = bindingSlot.GetBoundObject();
|
textureObject = bindingSlot.GetBoundObject();
|
||||||
}
|
}
|
||||||
@@ -743,8 +734,8 @@ namespace MobileGL {
|
|||||||
textureMipmapObject->MarkStorageDirty(textureUploadingTarget, level, true);
|
textureMipmapObject->MarkStorageDirty(textureUploadingTarget, level, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexImage1D_State(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border,
|
void TexImage1D_State(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format,
|
||||||
GLenum format, GLenum type, const GLvoid* pixels) {
|
GLenum type, const GLvoid* pixels) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
THROW_UNIMPL_EXCEPTION;
|
THROW_UNIMPL_EXCEPTION;
|
||||||
}
|
}
|
||||||
@@ -763,8 +754,7 @@ namespace MobileGL {
|
|||||||
if (!bufferObject) {
|
if (!bufferObject) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidOperation,
|
ErrorCode::InvalidOperation,
|
||||||
MakeShared<GenericErrorInfo>(
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
"MG_Impl/GLImpl", __func__,
|
|
||||||
"`buffer` is not zero and is not the name of an existing buffer object."));
|
"`buffer` is not zero and is not the name of an existing buffer object."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -819,8 +809,7 @@ namespace MobileGL {
|
|||||||
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
||||||
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
|
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
|
||||||
} else {
|
} else {
|
||||||
auto activeUnit =
|
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
||||||
textureObject = bindingSlot.GetBoundObject();
|
textureObject = bindingSlot.GetBoundObject();
|
||||||
}
|
}
|
||||||
@@ -830,14 +819,13 @@ namespace MobileGL {
|
|||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_TEXTURE_MAG_FILTER:
|
case GL_TEXTURE_MAG_FILTER:
|
||||||
if (params) {
|
if (params) {
|
||||||
*params = MG_Util::ConvertSamplerFilterModeToGLEnum(
|
*params = MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMagFilter(),
|
||||||
textureObject->GetSamplerObject()->GetMagFilter(), SamplerMipmapMode::None);
|
SamplerMipmapMode::None);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_MIN_FILTER:
|
case GL_TEXTURE_MIN_FILTER:
|
||||||
if (params) {
|
if (params) {
|
||||||
*params =
|
*params = MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter(),
|
||||||
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter(),
|
|
||||||
textureObject->GetSamplerObject()->GetMipmapMode());
|
textureObject->GetSamplerObject()->GetMipmapMode());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -883,8 +871,8 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||||
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexParameteriv_State",
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexParameteriv_State",
|
||||||
"pname is not a valid texture parameter."));
|
"pname is not a valid texture parameter."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -900,8 +888,7 @@ namespace MobileGL {
|
|||||||
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
||||||
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
|
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
|
||||||
} else {
|
} else {
|
||||||
auto activeUnit =
|
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
||||||
textureObject = bindingSlot.GetBoundObject();
|
textureObject = bindingSlot.GetBoundObject();
|
||||||
}
|
}
|
||||||
@@ -911,14 +898,13 @@ namespace MobileGL {
|
|||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_TEXTURE_MAG_FILTER:
|
case GL_TEXTURE_MAG_FILTER:
|
||||||
if (params) {
|
if (params) {
|
||||||
*params = MG_Util::ConvertSamplerFilterModeToGLEnum(
|
*params = MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMagFilter(),
|
||||||
textureObject->GetSamplerObject()->GetMagFilter(), SamplerMipmapMode::None);
|
SamplerMipmapMode::None);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_MIN_FILTER:
|
case GL_TEXTURE_MIN_FILTER:
|
||||||
if (params) {
|
if (params) {
|
||||||
*params =
|
*params = MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter(),
|
||||||
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter(),
|
|
||||||
textureObject->GetSamplerObject()->GetMipmapMode());
|
textureObject->GetSamplerObject()->GetMipmapMode());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -969,8 +955,8 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||||
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexParameterfv_State",
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexParameterfv_State",
|
||||||
"pname is not a valid texture parameter."));
|
"pname is not a valid texture parameter."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -993,8 +979,7 @@ namespace MobileGL {
|
|||||||
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
||||||
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
|
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
|
||||||
} else {
|
} else {
|
||||||
auto activeUnit =
|
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
||||||
textureObject = bindingSlot.GetBoundObject();
|
textureObject = bindingSlot.GetBoundObject();
|
||||||
}
|
}
|
||||||
@@ -1064,8 +1049,7 @@ namespace MobileGL {
|
|||||||
break; // TODO
|
break; // TODO
|
||||||
default:
|
default:
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidEnum,
|
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexLevelParameteriv_State",
|
||||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexLevelParameteriv_State",
|
|
||||||
"pname is not a valid texture level parameter."));
|
"pname is not a valid texture level parameter."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1086,8 +1070,7 @@ namespace MobileGL {
|
|||||||
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
|
||||||
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
|
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
|
||||||
} else {
|
} else {
|
||||||
auto activeUnit =
|
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
||||||
textureObject = bindingSlot.GetBoundObject();
|
textureObject = bindingSlot.GetBoundObject();
|
||||||
}
|
}
|
||||||
@@ -1157,8 +1140,7 @@ namespace MobileGL {
|
|||||||
break; // TODO
|
break; // TODO
|
||||||
default:
|
default:
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidEnum,
|
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexLevelParameterfv_State",
|
||||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexLevelParameterfv_State",
|
|
||||||
"pname is not a valid texture level parameter."));
|
"pname is not a valid texture level parameter."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1214,9 +1196,7 @@ namespace MobileGL {
|
|||||||
|
|
||||||
void CopyTexSubImage2D_Backend(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
|
void CopyTexSubImage2D_Backend(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
|
||||||
GLsizei width, GLsizei height) {
|
GLsizei width, GLsizei height) {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
||||||
MG_Backend::DirectGLES::CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyTexSubImage1D_State(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) {
|
void CopyTexSubImage1D_State(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) {
|
||||||
@@ -1231,8 +1211,7 @@ namespace MobileGL {
|
|||||||
if (!currentReadFBO) {
|
if (!currentReadFBO) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidOperation,
|
ErrorCode::InvalidOperation,
|
||||||
MakeShared<GenericErrorInfo>(
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyTexImage2D_State",
|
||||||
"MG_Impl/GLImpl", "CopyTexImage2D_State",
|
|
||||||
"No framebuffer is currently bound to the GL_READ_FRAMEBUFFER target."));
|
"No framebuffer is currently bound to the GL_READ_FRAMEBUFFER target."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1264,15 +1243,14 @@ namespace MobileGL {
|
|||||||
GET_SRC_INTERNAL_FORMAT(readBufferType);
|
GET_SRC_INTERNAL_FORMAT(readBufferType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextureImpl::ValidateBaseInternalFormatMatch(internalFormat, srcInternalFormat))
|
if (!TextureImpl::ValidateBaseInternalFormatMatch(internalFormat, srcInternalFormat)) THROW_UNIMPL_EXCEPTION;
|
||||||
THROW_UNIMPL_EXCEPTION;
|
|
||||||
|
|
||||||
GLenum outInternalFormat = MG_Util::ConvertTextureInternalFormatToGLEnum(srcInternalFormat);
|
GLenum outInternalFormat = MG_Util::ConvertTextureInternalFormatToGLEnum(srcInternalFormat);
|
||||||
GLenum realInternalFormat = GL_RGBA8;
|
GLenum realInternalFormat = GL_RGBA8;
|
||||||
GLenum format = GL_DEPTH_COMPONENT;
|
GLenum format = GL_DEPTH_COMPONENT;
|
||||||
GLenum type = GL_UNSIGNED_INT;
|
GLenum type = GL_UNSIGNED_INT;
|
||||||
MG_Util::TextureFormatProcessor::NormalizePixelFormat(
|
MG_Util::TextureFormatProcessor::NormalizePixelFormat(outInternalFormat, PixelFormatNormalizeOptionBit::None,
|
||||||
outInternalFormat, PixelFormatNormalizeOptionBit::None, &realInternalFormat, &format, &type);
|
&realInternalFormat, &format, &type);
|
||||||
const auto pixelUnpackBufferObject =
|
const auto pixelUnpackBufferObject =
|
||||||
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelUnpack).GetBoundObject();
|
MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::PixelUnpack).GetBoundObject();
|
||||||
TexImage2D_State(target, level, realInternalFormat, width, height, border, format, type, nullptr);
|
TexImage2D_State(target, level, realInternalFormat, width, height, border, format, type, nullptr);
|
||||||
@@ -1281,9 +1259,8 @@ namespace MobileGL {
|
|||||||
|
|
||||||
void CopyTexImage2D_Backend(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
void CopyTexImage2D_Backend(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
||||||
GLsizei height, GLint border) {
|
GLsizei height, GLint border) {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.CopyTexImage2D(target, level, internalformat, x, y, width, height,
|
||||||
MG_Backend::DirectGLES::CopyTexImage2D(target, level, internalformat, x, y, width, height, border);
|
border);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyTexImage1D_State(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
void CopyTexImage1D_State(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
||||||
@@ -1293,8 +1270,8 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CompressedTexSubImage3D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
|
void CompressedTexSubImage3D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
|
||||||
GLsizei width, GLsizei height, GLsizei depth, GLenum format,
|
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize,
|
||||||
GLsizei imageSize, const void* data) {
|
const void* data) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
THROW_UNIMPL_EXCEPTION;
|
THROW_UNIMPL_EXCEPTION;
|
||||||
}
|
}
|
||||||
@@ -1311,15 +1288,14 @@ namespace MobileGL {
|
|||||||
THROW_UNIMPL_EXCEPTION;
|
THROW_UNIMPL_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompressedTexImage3D_State(GLenum target, GLint level, GLenum internalformat, GLsizei width,
|
void CompressedTexImage3D_State(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
|
||||||
GLsizei height, GLsizei depth, GLint border, GLsizei imageSize,
|
GLsizei depth, GLint border, GLsizei imageSize, const void* data) {
|
||||||
const void* data) {
|
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
THROW_UNIMPL_EXCEPTION;
|
THROW_UNIMPL_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompressedTexImage2D_State(GLenum target, GLint level, GLenum internalformat, GLsizei width,
|
void CompressedTexImage2D_State(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
|
||||||
GLsizei height, GLint border, GLsizei imageSize, const void* data) {
|
GLint border, GLsizei imageSize, const void* data) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
THROW_UNIMPL_EXCEPTION;
|
THROW_UNIMPL_EXCEPTION;
|
||||||
}
|
}
|
||||||
@@ -1351,8 +1327,7 @@ namespace MobileGL {
|
|||||||
textureObject = MG_State::pGLContext->CreateTextureObject(texture, textureTarget);
|
textureObject = MG_State::pGLContext->CreateTextureObject(texture, textureTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& currentUnit =
|
auto& currentUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = currentUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = currentUnit.GetBindingSlot(textureTarget);
|
||||||
bindingSlot.Bind(textureObject);
|
bindingSlot.Bind(textureObject);
|
||||||
}
|
}
|
||||||
@@ -1371,13 +1346,11 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ======================= Processing ================================
|
// ======================= Processing ================================
|
||||||
MG_State::pGLContext->SetActiveTextureUnit(texture - GL_TEXTURE0);
|
MG_State::pGLContext->SetActiveTextureUnit((Int)texture - GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetTexImage_Backend(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {
|
void GetTexImage_Backend(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {
|
||||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
MG_Backend::gBackendFunctionsTable.GL.GetTexImage(target, level, format, type, pixels);
|
||||||
MG_Backend::DirectGLES::GetTexImage(target, level, format, type, pixels);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to GL_Texture.cpp
|
// Add to GL_Texture.cpp
|
||||||
@@ -1426,8 +1399,7 @@ namespace MobileGL {
|
|||||||
if (TextureImpl::IsProxyTextureTarget(textureUploadTarget)) {
|
if (TextureImpl::IsProxyTextureTarget(textureUploadTarget)) {
|
||||||
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadTarget);
|
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadTarget);
|
||||||
} else {
|
} else {
|
||||||
auto activeUnit =
|
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
||||||
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
|
|
||||||
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
|
||||||
textureObject = bindingSlot.GetBoundObject();
|
textureObject = bindingSlot.GetBoundObject();
|
||||||
}
|
}
|
||||||
@@ -1455,8 +1427,7 @@ namespace MobileGL {
|
|||||||
// Check if PBO is mapped
|
// Check if PBO is mapped
|
||||||
if (pixelPackBufferObject->IsMapped()) {
|
if (pixelPackBufferObject->IsMapped()) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidOperation,
|
ErrorCode::InvalidOperation, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexImage_State",
|
||||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexImage_State",
|
|
||||||
"Pixel pack buffer is currently mapped"));
|
"Pixel pack buffer is currently mapped"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1499,6 +1470,10 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||||
|
void GenerateMipmap(GLenum target) {
|
||||||
|
GenerateMipmap_Backend(target);
|
||||||
|
}
|
||||||
|
|
||||||
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {
|
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {
|
||||||
GetTexImage_State(target, level, format, type, pixels);
|
GetTexImage_State(target, level, format, type, pixels);
|
||||||
GetTexImage_Backend(target, level, format, type, pixels);
|
GetTexImage_Backend(target, level, format, type, pixels);
|
||||||
@@ -1612,13 +1587,13 @@ namespace MobileGL {
|
|||||||
DeleteTextures_State(n, textures);
|
DeleteTextures_State(n, textures);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x,
|
void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y,
|
||||||
GLint y, GLsizei width, GLsizei height) {
|
GLsizei width, GLsizei height) {
|
||||||
CopyTexSubImage3D_State(target, level, xoffset, yoffset, zoffset, x, y, width, height);
|
CopyTexSubImage3D_State(target, level, xoffset, yoffset, zoffset, x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
|
void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
|
||||||
GLsizei width, GLsizei height) {
|
GLsizei height) {
|
||||||
CopyTexSubImage2D_Backend(target, level, xoffset, yoffset, x, y, width, height);
|
CopyTexSubImage2D_Backend(target, level, xoffset, yoffset, x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1637,11 +1612,10 @@ namespace MobileGL {
|
|||||||
CopyTexImage1D_State(target, level, internalformat, x, y, width, border);
|
CopyTexImage1D_State(target, level, internalformat, x, y, width, border);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
|
void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
|
||||||
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize,
|
GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data) {
|
||||||
const void* data) {
|
CompressedTexSubImage3D_State(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize,
|
||||||
CompressedTexSubImage3D_State(target, level, xoffset, yoffset, zoffset, width, height, depth, format,
|
data);
|
||||||
imageSize, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
|
void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
|
||||||
@@ -1677,5 +1651,4 @@ namespace MobileGL {
|
|||||||
ActiveTexture_State(texture);
|
ActiveTexture_State(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace MG_Impl::GLImpl
|
} // namespace MobileGL::MG_Impl::GLImpl
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL::MG_Impl::GLImpl {
|
||||||
namespace MG_Impl::GLImpl {
|
|
||||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||||
|
void GenerateMipmap(GLenum target);
|
||||||
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels);
|
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels);
|
||||||
void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
|
void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
|
||||||
GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);
|
GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);
|
||||||
@@ -47,18 +47,17 @@ namespace MobileGL {
|
|||||||
void GetCompressedTexImage(GLenum target, GLint level, void* img);
|
void GetCompressedTexImage(GLenum target, GLint level, void* img);
|
||||||
void GenTextures(GLsizei n, GLuint* textures);
|
void GenTextures(GLsizei n, GLuint* textures);
|
||||||
void DeleteTextures(GLsizei n, const GLuint* textures);
|
void DeleteTextures(GLsizei n, const GLuint* textures);
|
||||||
void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x,
|
void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y,
|
||||||
GLint y, GLsizei width, GLsizei height);
|
|
||||||
void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
|
|
||||||
GLsizei width, GLsizei height);
|
GLsizei width, GLsizei height);
|
||||||
|
void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
|
||||||
|
GLsizei height);
|
||||||
void CopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
|
void CopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
|
||||||
void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
||||||
GLsizei height, GLint border);
|
GLsizei height, GLint border);
|
||||||
void CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
void CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
|
||||||
GLint border);
|
GLint border);
|
||||||
void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
|
void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
|
||||||
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize,
|
GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data);
|
||||||
const void* data);
|
|
||||||
void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
|
void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
|
||||||
GLsizei height, GLenum format, GLsizei imageSize, const void* data);
|
GLsizei height, GLenum format, GLsizei imageSize, const void* data);
|
||||||
void CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format,
|
void CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format,
|
||||||
@@ -71,5 +70,4 @@ namespace MobileGL {
|
|||||||
GLsizei imageSize, const void* data);
|
GLsizei imageSize, const void* data);
|
||||||
void BindTexture(GLenum target, GLuint texture);
|
void BindTexture(GLenum target, GLuint texture);
|
||||||
void ActiveTexture(GLenum texture);
|
void ActiveTexture(GLenum texture);
|
||||||
} // namespace MG_Impl::GLImpl
|
} // namespace MobileGL::MG_Impl::GLImpl
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
#include <MG_State/GLState/TextureState/TextureObject2D.h>
|
#include <MG_State/GLState/TextureState/TextureObject2D.h>
|
||||||
#include <MG_State/GLState/TextureState/TextureObject3D.h>
|
#include <MG_State/GLState/TextureState/TextureObject3D.h>
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL::MG_Impl {
|
||||||
namespace MG_Impl {
|
|
||||||
void Init() {
|
void Init() {
|
||||||
MGLOG_D("Initializing MobileGL Implementation...");
|
MGLOG_D("Initializing MobileGL Implementation...");
|
||||||
GLImpl::TextureImpl::pProxyTextureManager = new GLImpl::TextureImpl::ProxyTextureManager();
|
GLImpl::TextureImpl::pProxyTextureManager = new GLImpl::TextureImpl::ProxyTextureManager();
|
||||||
@@ -40,5 +39,4 @@ namespace MobileGL {
|
|||||||
GLImpl::FramebufferImpl::pDefaultFramebufferInfo =
|
GLImpl::FramebufferImpl::pDefaultFramebufferInfo =
|
||||||
new GLImpl::FramebufferImpl::DefaultFramebufferInfo(fbo0, colorTex, depthTex, stencilTex);
|
new GLImpl::FramebufferImpl::DefaultFramebufferInfo(fbo0, colorTex, depthTex, stencilTex);
|
||||||
}
|
}
|
||||||
} // namespace MG_Impl
|
} // namespace MobileGL::MG_Impl
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
@@ -13,12 +13,13 @@ namespace MobileGL {
|
|||||||
namespace MG_State {
|
namespace MG_State {
|
||||||
namespace GLState {
|
namespace GLState {
|
||||||
// FramebufferAttachmentObject
|
// FramebufferAttachmentObject
|
||||||
FramebufferAttachmentObject::FramebufferAttachmentObject(SharedPtr<MG_State::GLState::ITextureObject> texture,
|
FramebufferAttachmentObject::FramebufferAttachmentObject(
|
||||||
Int level)
|
SharedPtr<MG_State::GLState::ITextureObject> texture, Int level)
|
||||||
: m_texture(texture), m_textureLevel(level) {}
|
: m_texture(texture), m_textureLevel(level) {}
|
||||||
FramebufferAttachmentObject::FramebufferAttachmentObject(SharedPtr<RenderbufferObject> renderbuffer)
|
FramebufferAttachmentObject::FramebufferAttachmentObject(SharedPtr<RenderbufferObject> renderbuffer)
|
||||||
: m_renderbuffer(renderbuffer) {}
|
: m_renderbuffer(renderbuffer) {}
|
||||||
FramebufferAttachmentObject::FramebufferAttachmentObject(Bool IsValid) : m_texture(nullptr), m_renderbuffer(nullptr) {
|
FramebufferAttachmentObject::FramebufferAttachmentObject(Bool IsValid)
|
||||||
|
: m_texture(nullptr), m_renderbuffer(nullptr) {
|
||||||
m_isValid = IsValid;
|
m_isValid = IsValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +105,8 @@ namespace MobileGL {
|
|||||||
return m_attachmentObjects[static_cast<SizeT>(type)];
|
return m_attachmentObjects[static_cast<SizeT>(type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
const FramebufferObject::FramebufferAttachmentObjectArray& FramebufferObject::GetAllAttachmentObjects() const {
|
const FramebufferObject::FramebufferAttachmentObjectArray& FramebufferObject::GetAllAttachmentObjects()
|
||||||
|
const {
|
||||||
return m_attachmentObjects;
|
return m_attachmentObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ namespace MobileGL {
|
|||||||
void SetBaseLevel(Uint baseLevel) override;
|
void SetBaseLevel(Uint baseLevel) override;
|
||||||
void SetMaxLevel(Uint maxLevel) override;
|
void SetMaxLevel(Uint maxLevel) override;
|
||||||
Uint16 GetTextureParamsVersion() const override;
|
Uint16 GetTextureParamsVersion() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const Uint m_externalIndex;
|
const Uint m_externalIndex;
|
||||||
const TextureTarget m_target = TextureTarget::Unknown;
|
const TextureTarget m_target = TextureTarget::Unknown;
|
||||||
|
|||||||
@@ -7,540 +7,55 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "Loader.h"
|
#include "Loader.h"
|
||||||
|
#include "MG_Util/Types.h"
|
||||||
|
|
||||||
#define GL_FUNC_DECL(name) name##_PTR name;
|
namespace MobileGL::MG_Util::BackendLoader {
|
||||||
#define EGL_FUNC_DECL(name) name##_PTR name;
|
static void* OpenLib(const Vector<String>& names) {
|
||||||
|
|
||||||
namespace MobileGL {
|
|
||||||
namespace MG_External {
|
|
||||||
namespace GLES {
|
|
||||||
Caps::GLESCaps g_glesCaps;
|
|
||||||
|
|
||||||
GL_FUNC_DECL(glActiveTexture)
|
|
||||||
GL_FUNC_DECL(glAttachShader)
|
|
||||||
GL_FUNC_DECL(glBindAttribLocation)
|
|
||||||
GL_FUNC_DECL(glBindBuffer)
|
|
||||||
GL_FUNC_DECL(glBindFramebuffer)
|
|
||||||
GL_FUNC_DECL(glBindRenderbuffer)
|
|
||||||
GL_FUNC_DECL(glBindTexture)
|
|
||||||
GL_FUNC_DECL(glBlendColor)
|
|
||||||
GL_FUNC_DECL(glBlendEquation)
|
|
||||||
GL_FUNC_DECL(glBlendEquationSeparate)
|
|
||||||
GL_FUNC_DECL(glBlendFunc)
|
|
||||||
GL_FUNC_DECL(glBlendFuncSeparate)
|
|
||||||
GL_FUNC_DECL(glBufferData)
|
|
||||||
GL_FUNC_DECL(glBufferSubData)
|
|
||||||
GL_FUNC_DECL(glCheckFramebufferStatus)
|
|
||||||
GL_FUNC_DECL(glClear)
|
|
||||||
GL_FUNC_DECL(glClearColor)
|
|
||||||
GL_FUNC_DECL(glClearDepthf)
|
|
||||||
GL_FUNC_DECL(glClearStencil)
|
|
||||||
GL_FUNC_DECL(glColorMask)
|
|
||||||
GL_FUNC_DECL(glCompileShader)
|
|
||||||
GL_FUNC_DECL(glCompressedTexImage2D)
|
|
||||||
GL_FUNC_DECL(glCompressedTexSubImage2D)
|
|
||||||
GL_FUNC_DECL(glCopyTexImage2D)
|
|
||||||
GL_FUNC_DECL(glCopyTexSubImage2D)
|
|
||||||
GL_FUNC_DECL(glCreateProgram)
|
|
||||||
GL_FUNC_DECL(glCreateShader)
|
|
||||||
GL_FUNC_DECL(glCullFace)
|
|
||||||
GL_FUNC_DECL(glDeleteBuffers)
|
|
||||||
GL_FUNC_DECL(glDeleteFramebuffers)
|
|
||||||
GL_FUNC_DECL(glDeleteProgram)
|
|
||||||
GL_FUNC_DECL(glDeleteRenderbuffers)
|
|
||||||
GL_FUNC_DECL(glDeleteShader)
|
|
||||||
GL_FUNC_DECL(glDeleteTextures)
|
|
||||||
GL_FUNC_DECL(glDepthFunc)
|
|
||||||
GL_FUNC_DECL(glDepthMask)
|
|
||||||
GL_FUNC_DECL(glDepthRangef)
|
|
||||||
GL_FUNC_DECL(glDetachShader)
|
|
||||||
GL_FUNC_DECL(glDisable)
|
|
||||||
GL_FUNC_DECL(glDisableVertexAttribArray)
|
|
||||||
GL_FUNC_DECL(glDrawArrays)
|
|
||||||
GL_FUNC_DECL(glDrawElements)
|
|
||||||
GL_FUNC_DECL(glEnable)
|
|
||||||
GL_FUNC_DECL(glEnableVertexAttribArray)
|
|
||||||
GL_FUNC_DECL(glFinish)
|
|
||||||
GL_FUNC_DECL(glFlush)
|
|
||||||
GL_FUNC_DECL(glFramebufferRenderbuffer)
|
|
||||||
GL_FUNC_DECL(glFramebufferTexture2D)
|
|
||||||
GL_FUNC_DECL(glFrontFace)
|
|
||||||
GL_FUNC_DECL(glGenBuffers)
|
|
||||||
GL_FUNC_DECL(glGenerateMipmap)
|
|
||||||
GL_FUNC_DECL(glGenFramebuffers)
|
|
||||||
GL_FUNC_DECL(glGenRenderbuffers)
|
|
||||||
GL_FUNC_DECL(glGenTextures)
|
|
||||||
GL_FUNC_DECL(glGetActiveAttrib)
|
|
||||||
GL_FUNC_DECL(glGetActiveUniform)
|
|
||||||
GL_FUNC_DECL(glGetAttachedShaders)
|
|
||||||
GL_FUNC_DECL(glGetAttribLocation)
|
|
||||||
GL_FUNC_DECL(glGetBooleanv)
|
|
||||||
GL_FUNC_DECL(glGetBufferParameteriv)
|
|
||||||
GL_FUNC_DECL(glGetError)
|
|
||||||
GL_FUNC_DECL(glGetString)
|
|
||||||
GL_FUNC_DECL(glGetStringi)
|
|
||||||
GL_FUNC_DECL(glGetFloatv)
|
|
||||||
GL_FUNC_DECL(glGetFramebufferAttachmentParameteriv)
|
|
||||||
GL_FUNC_DECL(glGetIntegerv)
|
|
||||||
GL_FUNC_DECL(glGetProgramiv)
|
|
||||||
GL_FUNC_DECL(glGetProgramInfoLog)
|
|
||||||
GL_FUNC_DECL(glGetRenderbufferParameteriv)
|
|
||||||
GL_FUNC_DECL(glGetShaderiv)
|
|
||||||
GL_FUNC_DECL(glGetShaderInfoLog)
|
|
||||||
GL_FUNC_DECL(glGetShaderPrecisionFormat)
|
|
||||||
GL_FUNC_DECL(glGetShaderSource)
|
|
||||||
GL_FUNC_DECL(glGetTexParameterfv)
|
|
||||||
GL_FUNC_DECL(glGetTexParameteriv)
|
|
||||||
GL_FUNC_DECL(glGetUniformfv)
|
|
||||||
GL_FUNC_DECL(glGetUniformiv)
|
|
||||||
GL_FUNC_DECL(glGetUniformLocation)
|
|
||||||
GL_FUNC_DECL(glGetVertexAttribfv)
|
|
||||||
GL_FUNC_DECL(glGetVertexAttribiv)
|
|
||||||
GL_FUNC_DECL(glGetVertexAttribPointerv)
|
|
||||||
GL_FUNC_DECL(glHint)
|
|
||||||
GL_FUNC_DECL(glIsBuffer)
|
|
||||||
GL_FUNC_DECL(glIsEnabled)
|
|
||||||
GL_FUNC_DECL(glIsFramebuffer)
|
|
||||||
GL_FUNC_DECL(glIsProgram)
|
|
||||||
GL_FUNC_DECL(glIsRenderbuffer)
|
|
||||||
GL_FUNC_DECL(glIsShader)
|
|
||||||
GL_FUNC_DECL(glIsTexture)
|
|
||||||
GL_FUNC_DECL(glLineWidth)
|
|
||||||
GL_FUNC_DECL(glLinkProgram)
|
|
||||||
GL_FUNC_DECL(glPixelStorei)
|
|
||||||
GL_FUNC_DECL(glPolygonOffset)
|
|
||||||
GL_FUNC_DECL(glReadPixels)
|
|
||||||
GL_FUNC_DECL(glReleaseShaderCompiler)
|
|
||||||
GL_FUNC_DECL(glRenderbufferStorage)
|
|
||||||
GL_FUNC_DECL(glSampleCoverage)
|
|
||||||
GL_FUNC_DECL(glScissor)
|
|
||||||
GL_FUNC_DECL(glShaderBinary)
|
|
||||||
GL_FUNC_DECL(glShaderSource)
|
|
||||||
GL_FUNC_DECL(glStencilFunc)
|
|
||||||
GL_FUNC_DECL(glStencilFuncSeparate)
|
|
||||||
GL_FUNC_DECL(glStencilMask)
|
|
||||||
GL_FUNC_DECL(glStencilMaskSeparate)
|
|
||||||
GL_FUNC_DECL(glStencilOp)
|
|
||||||
GL_FUNC_DECL(glStencilOpSeparate)
|
|
||||||
GL_FUNC_DECL(glTexImage2D)
|
|
||||||
GL_FUNC_DECL(glTexParameterf)
|
|
||||||
GL_FUNC_DECL(glTexParameterfv)
|
|
||||||
GL_FUNC_DECL(glTexParameteri)
|
|
||||||
GL_FUNC_DECL(glTexParameteriv)
|
|
||||||
GL_FUNC_DECL(glTexSubImage2D)
|
|
||||||
GL_FUNC_DECL(glUniform1f)
|
|
||||||
GL_FUNC_DECL(glUniform1fv)
|
|
||||||
GL_FUNC_DECL(glUniform1i)
|
|
||||||
GL_FUNC_DECL(glUniform1iv)
|
|
||||||
GL_FUNC_DECL(glUniform2f)
|
|
||||||
GL_FUNC_DECL(glUniform2fv)
|
|
||||||
GL_FUNC_DECL(glUniform2i)
|
|
||||||
GL_FUNC_DECL(glUniform2iv)
|
|
||||||
GL_FUNC_DECL(glUniform3f)
|
|
||||||
GL_FUNC_DECL(glUniform3fv)
|
|
||||||
GL_FUNC_DECL(glUniform3i)
|
|
||||||
GL_FUNC_DECL(glUniform3iv)
|
|
||||||
GL_FUNC_DECL(glUniform4f)
|
|
||||||
GL_FUNC_DECL(glUniform4fv)
|
|
||||||
GL_FUNC_DECL(glUniform4i)
|
|
||||||
GL_FUNC_DECL(glUniform4iv)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix2fv)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix3fv)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix4fv)
|
|
||||||
GL_FUNC_DECL(glUseProgram)
|
|
||||||
GL_FUNC_DECL(glValidateProgram)
|
|
||||||
GL_FUNC_DECL(glVertexAttrib1f)
|
|
||||||
GL_FUNC_DECL(glVertexAttrib1fv)
|
|
||||||
GL_FUNC_DECL(glVertexAttrib2f)
|
|
||||||
GL_FUNC_DECL(glVertexAttrib2fv)
|
|
||||||
GL_FUNC_DECL(glVertexAttrib3f)
|
|
||||||
GL_FUNC_DECL(glVertexAttrib3fv)
|
|
||||||
GL_FUNC_DECL(glVertexAttrib4f)
|
|
||||||
GL_FUNC_DECL(glVertexAttrib4fv)
|
|
||||||
GL_FUNC_DECL(glVertexAttribPointer)
|
|
||||||
GL_FUNC_DECL(glViewport)
|
|
||||||
GL_FUNC_DECL(glReadBuffer)
|
|
||||||
GL_FUNC_DECL(glDrawRangeElements)
|
|
||||||
GL_FUNC_DECL(glTexImage3D)
|
|
||||||
GL_FUNC_DECL(glTexSubImage3D)
|
|
||||||
GL_FUNC_DECL(glCopyTexSubImage3D)
|
|
||||||
GL_FUNC_DECL(glCompressedTexImage3D)
|
|
||||||
GL_FUNC_DECL(glCompressedTexSubImage3D)
|
|
||||||
GL_FUNC_DECL(glGenQueries)
|
|
||||||
GL_FUNC_DECL(glDeleteQueries)
|
|
||||||
GL_FUNC_DECL(glIsQuery)
|
|
||||||
GL_FUNC_DECL(glBeginQuery)
|
|
||||||
GL_FUNC_DECL(glEndQuery)
|
|
||||||
GL_FUNC_DECL(glGetQueryiv)
|
|
||||||
GL_FUNC_DECL(glGetQueryObjectuiv)
|
|
||||||
GL_FUNC_DECL(glUnmapBuffer)
|
|
||||||
GL_FUNC_DECL(glGetBufferPointerv)
|
|
||||||
GL_FUNC_DECL(glDrawBuffers)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix2x3fv)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix3x2fv)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix2x4fv)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix4x2fv)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix3x4fv)
|
|
||||||
GL_FUNC_DECL(glUniformMatrix4x3fv)
|
|
||||||
GL_FUNC_DECL(glBlitFramebuffer)
|
|
||||||
GL_FUNC_DECL(glRenderbufferStorageMultisample)
|
|
||||||
GL_FUNC_DECL(glFramebufferTextureLayer)
|
|
||||||
GL_FUNC_DECL(glFlushMappedBufferRange)
|
|
||||||
GL_FUNC_DECL(glBindVertexArray)
|
|
||||||
GL_FUNC_DECL(glDeleteVertexArrays)
|
|
||||||
GL_FUNC_DECL(glGenVertexArrays)
|
|
||||||
GL_FUNC_DECL(glIsVertexArray)
|
|
||||||
GL_FUNC_DECL(glGetIntegeri_v)
|
|
||||||
GL_FUNC_DECL(glBeginTransformFeedback)
|
|
||||||
GL_FUNC_DECL(glEndTransformFeedback)
|
|
||||||
GL_FUNC_DECL(glBindBufferRange)
|
|
||||||
GL_FUNC_DECL(glBindBufferBase)
|
|
||||||
GL_FUNC_DECL(glTransformFeedbackVaryings)
|
|
||||||
GL_FUNC_DECL(glGetTransformFeedbackVarying)
|
|
||||||
GL_FUNC_DECL(glVertexAttribIPointer)
|
|
||||||
GL_FUNC_DECL(glGetVertexAttribIiv)
|
|
||||||
GL_FUNC_DECL(glGetVertexAttribIuiv)
|
|
||||||
GL_FUNC_DECL(glVertexAttribI4i)
|
|
||||||
GL_FUNC_DECL(glVertexAttribI4ui)
|
|
||||||
GL_FUNC_DECL(glVertexAttribI4iv)
|
|
||||||
GL_FUNC_DECL(glVertexAttribI4uiv)
|
|
||||||
GL_FUNC_DECL(glGetUniformuiv)
|
|
||||||
GL_FUNC_DECL(glGetFragDataLocation)
|
|
||||||
GL_FUNC_DECL(glUniform1ui)
|
|
||||||
GL_FUNC_DECL(glUniform2ui)
|
|
||||||
GL_FUNC_DECL(glUniform3ui)
|
|
||||||
GL_FUNC_DECL(glUniform4ui)
|
|
||||||
GL_FUNC_DECL(glUniform1uiv)
|
|
||||||
GL_FUNC_DECL(glUniform2uiv)
|
|
||||||
GL_FUNC_DECL(glUniform3uiv)
|
|
||||||
GL_FUNC_DECL(glUniform4uiv)
|
|
||||||
GL_FUNC_DECL(glClearBufferiv)
|
|
||||||
GL_FUNC_DECL(glClearBufferuiv)
|
|
||||||
GL_FUNC_DECL(glClearBufferfv)
|
|
||||||
GL_FUNC_DECL(glClearBufferfi)
|
|
||||||
GL_FUNC_DECL(glCopyBufferSubData)
|
|
||||||
GL_FUNC_DECL(glGetUniformIndices)
|
|
||||||
GL_FUNC_DECL(glGetActiveUniformsiv)
|
|
||||||
GL_FUNC_DECL(glGetUniformBlockIndex)
|
|
||||||
GL_FUNC_DECL(glGetActiveUniformBlockiv)
|
|
||||||
GL_FUNC_DECL(glGetActiveUniformBlockName)
|
|
||||||
GL_FUNC_DECL(glUniformBlockBinding)
|
|
||||||
GL_FUNC_DECL(glDrawArraysInstanced)
|
|
||||||
GL_FUNC_DECL(glDrawElementsInstanced)
|
|
||||||
GL_FUNC_DECL(glFenceSync)
|
|
||||||
GL_FUNC_DECL(glIsSync)
|
|
||||||
GL_FUNC_DECL(glDeleteSync)
|
|
||||||
GL_FUNC_DECL(glClientWaitSync)
|
|
||||||
GL_FUNC_DECL(glWaitSync)
|
|
||||||
GL_FUNC_DECL(glGetInteger64v)
|
|
||||||
GL_FUNC_DECL(glGetSynciv)
|
|
||||||
GL_FUNC_DECL(glGetInteger64i_v)
|
|
||||||
GL_FUNC_DECL(glGetBufferParameteri64v)
|
|
||||||
GL_FUNC_DECL(glGenSamplers)
|
|
||||||
GL_FUNC_DECL(glDeleteSamplers)
|
|
||||||
GL_FUNC_DECL(glIsSampler)
|
|
||||||
GL_FUNC_DECL(glBindSampler)
|
|
||||||
GL_FUNC_DECL(glSamplerParameteri)
|
|
||||||
GL_FUNC_DECL(glSamplerParameteriv)
|
|
||||||
GL_FUNC_DECL(glSamplerParameterf)
|
|
||||||
GL_FUNC_DECL(glSamplerParameterfv)
|
|
||||||
GL_FUNC_DECL(glGetSamplerParameteriv)
|
|
||||||
GL_FUNC_DECL(glGetSamplerParameterfv)
|
|
||||||
GL_FUNC_DECL(glVertexAttribDivisor)
|
|
||||||
GL_FUNC_DECL(glBindTransformFeedback)
|
|
||||||
GL_FUNC_DECL(glDeleteTransformFeedbacks)
|
|
||||||
GL_FUNC_DECL(glGenTransformFeedbacks)
|
|
||||||
GL_FUNC_DECL(glIsTransformFeedback)
|
|
||||||
GL_FUNC_DECL(glPauseTransformFeedback)
|
|
||||||
GL_FUNC_DECL(glResumeTransformFeedback)
|
|
||||||
GL_FUNC_DECL(glGetProgramBinary)
|
|
||||||
GL_FUNC_DECL(glProgramBinary)
|
|
||||||
GL_FUNC_DECL(glProgramParameteri)
|
|
||||||
GL_FUNC_DECL(glInvalidateFramebuffer)
|
|
||||||
GL_FUNC_DECL(glInvalidateSubFramebuffer)
|
|
||||||
GL_FUNC_DECL(glTexStorage2D)
|
|
||||||
GL_FUNC_DECL(glTexStorage3D)
|
|
||||||
GL_FUNC_DECL(glGetInternalformativ)
|
|
||||||
GL_FUNC_DECL(glDispatchCompute)
|
|
||||||
GL_FUNC_DECL(glDispatchComputeIndirect)
|
|
||||||
GL_FUNC_DECL(glDrawArraysIndirect)
|
|
||||||
GL_FUNC_DECL(glDrawElementsIndirect)
|
|
||||||
GL_FUNC_DECL(glFramebufferParameteri)
|
|
||||||
GL_FUNC_DECL(glGetFramebufferParameteriv)
|
|
||||||
GL_FUNC_DECL(glGetProgramInterfaceiv)
|
|
||||||
GL_FUNC_DECL(glGetProgramResourceIndex)
|
|
||||||
GL_FUNC_DECL(glGetProgramResourceName)
|
|
||||||
GL_FUNC_DECL(glGetProgramResourceiv)
|
|
||||||
GL_FUNC_DECL(glGetProgramResourceLocation)
|
|
||||||
GL_FUNC_DECL(glUseProgramStages)
|
|
||||||
GL_FUNC_DECL(glActiveShaderProgram)
|
|
||||||
GL_FUNC_DECL(glCreateShaderProgramv)
|
|
||||||
GL_FUNC_DECL(glBindProgramPipeline)
|
|
||||||
GL_FUNC_DECL(glDeleteProgramPipelines)
|
|
||||||
GL_FUNC_DECL(glGenProgramPipelines)
|
|
||||||
GL_FUNC_DECL(glIsProgramPipeline)
|
|
||||||
GL_FUNC_DECL(glGetProgramPipelineiv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform1i)
|
|
||||||
GL_FUNC_DECL(glProgramUniform2i)
|
|
||||||
GL_FUNC_DECL(glProgramUniform3i)
|
|
||||||
GL_FUNC_DECL(glProgramUniform4i)
|
|
||||||
GL_FUNC_DECL(glProgramUniform1ui)
|
|
||||||
GL_FUNC_DECL(glProgramUniform2ui)
|
|
||||||
GL_FUNC_DECL(glProgramUniform3ui)
|
|
||||||
GL_FUNC_DECL(glProgramUniform4ui)
|
|
||||||
GL_FUNC_DECL(glProgramUniform1f)
|
|
||||||
GL_FUNC_DECL(glProgramUniform2f)
|
|
||||||
GL_FUNC_DECL(glProgramUniform3f)
|
|
||||||
GL_FUNC_DECL(glProgramUniform4f)
|
|
||||||
GL_FUNC_DECL(glProgramUniform1iv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform2iv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform3iv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform4iv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform1uiv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform2uiv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform3uiv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform4uiv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform1fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform2fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform3fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniform4fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix2fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix3fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix4fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix2x3fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix3x2fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix2x4fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix4x2fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix3x4fv)
|
|
||||||
GL_FUNC_DECL(glProgramUniformMatrix4x3fv)
|
|
||||||
GL_FUNC_DECL(glValidateProgramPipeline)
|
|
||||||
GL_FUNC_DECL(glGetProgramPipelineInfoLog)
|
|
||||||
GL_FUNC_DECL(glBindImageTexture)
|
|
||||||
GL_FUNC_DECL(glGetBooleani_v)
|
|
||||||
GL_FUNC_DECL(glMemoryBarrier)
|
|
||||||
GL_FUNC_DECL(glMemoryBarrierByRegion)
|
|
||||||
GL_FUNC_DECL(glTexStorage2DMultisample)
|
|
||||||
GL_FUNC_DECL(glGetMultisamplefv)
|
|
||||||
GL_FUNC_DECL(glSampleMaski)
|
|
||||||
GL_FUNC_DECL(glGetTexLevelParameteriv)
|
|
||||||
GL_FUNC_DECL(glGetTexLevelParameterfv)
|
|
||||||
GL_FUNC_DECL(glBindVertexBuffer)
|
|
||||||
GL_FUNC_DECL(glVertexAttribFormat)
|
|
||||||
GL_FUNC_DECL(glVertexAttribIFormat)
|
|
||||||
GL_FUNC_DECL(glVertexAttribBinding)
|
|
||||||
GL_FUNC_DECL(glVertexBindingDivisor)
|
|
||||||
GL_FUNC_DECL(glBlendBarrier)
|
|
||||||
GL_FUNC_DECL(glCopyImageSubData)
|
|
||||||
GL_FUNC_DECL(glDebugMessageControl)
|
|
||||||
GL_FUNC_DECL(glDebugMessageInsert)
|
|
||||||
GL_FUNC_DECL(glDebugMessageCallback)
|
|
||||||
GL_FUNC_DECL(glGetDebugMessageLog)
|
|
||||||
GL_FUNC_DECL(glPushDebugGroup)
|
|
||||||
GL_FUNC_DECL(glPopDebugGroup)
|
|
||||||
GL_FUNC_DECL(glObjectLabel)
|
|
||||||
GL_FUNC_DECL(glGetObjectLabel)
|
|
||||||
GL_FUNC_DECL(glObjectPtrLabel)
|
|
||||||
GL_FUNC_DECL(glGetObjectPtrLabel)
|
|
||||||
GL_FUNC_DECL(glGetPointerv)
|
|
||||||
GL_FUNC_DECL(glEnablei)
|
|
||||||
GL_FUNC_DECL(glDisablei)
|
|
||||||
GL_FUNC_DECL(glBlendEquationi)
|
|
||||||
GL_FUNC_DECL(glBlendEquationSeparatei)
|
|
||||||
GL_FUNC_DECL(glBlendFunci)
|
|
||||||
GL_FUNC_DECL(glBlendFuncSeparatei)
|
|
||||||
GL_FUNC_DECL(glColorMaski)
|
|
||||||
GL_FUNC_DECL(glIsEnabledi)
|
|
||||||
GL_FUNC_DECL(glDrawElementsBaseVertex)
|
|
||||||
GL_FUNC_DECL(glDrawRangeElementsBaseVertex)
|
|
||||||
GL_FUNC_DECL(glDrawElementsInstancedBaseVertex)
|
|
||||||
GL_FUNC_DECL(glFramebufferTexture)
|
|
||||||
GL_FUNC_DECL(glPrimitiveBoundingBox)
|
|
||||||
GL_FUNC_DECL(glGetGraphicsResetStatus)
|
|
||||||
GL_FUNC_DECL(glReadnPixels)
|
|
||||||
GL_FUNC_DECL(glGetnUniformfv)
|
|
||||||
GL_FUNC_DECL(glGetnUniformiv)
|
|
||||||
GL_FUNC_DECL(glGetnUniformuiv)
|
|
||||||
GL_FUNC_DECL(glMinSampleShading)
|
|
||||||
GL_FUNC_DECL(glPatchParameteri)
|
|
||||||
GL_FUNC_DECL(glTexParameterIiv)
|
|
||||||
GL_FUNC_DECL(glTexParameterIuiv)
|
|
||||||
GL_FUNC_DECL(glGetTexParameterIiv)
|
|
||||||
GL_FUNC_DECL(glGetTexParameterIuiv)
|
|
||||||
GL_FUNC_DECL(glSamplerParameterIiv)
|
|
||||||
GL_FUNC_DECL(glSamplerParameterIuiv)
|
|
||||||
GL_FUNC_DECL(glGetSamplerParameterIiv)
|
|
||||||
GL_FUNC_DECL(glGetSamplerParameterIuiv)
|
|
||||||
GL_FUNC_DECL(glTexBuffer)
|
|
||||||
GL_FUNC_DECL(glTexBufferRange)
|
|
||||||
GL_FUNC_DECL(glTexStorage3DMultisample)
|
|
||||||
GL_FUNC_DECL(glMapBufferRange)
|
|
||||||
GL_FUNC_DECL(glBufferStorageEXT)
|
|
||||||
GL_FUNC_DECL(glGetQueryObjectivEXT)
|
|
||||||
GL_FUNC_DECL(glGetQueryObjecti64vEXT)
|
|
||||||
GL_FUNC_DECL(glBindFragDataLocationEXT)
|
|
||||||
GL_FUNC_DECL(glMapBufferOES)
|
|
||||||
|
|
||||||
GL_FUNC_DECL(glMultiDrawArraysIndirectEXT)
|
|
||||||
GL_FUNC_DECL(glMultiDrawElementsIndirectEXT)
|
|
||||||
GL_FUNC_DECL(glMultiDrawElementsBaseVertexEXT)
|
|
||||||
|
|
||||||
GL_FUNC_DECL(glBruh)
|
|
||||||
} // namespace GLES
|
|
||||||
|
|
||||||
namespace EGL {
|
|
||||||
EGL_FUNC_DECL(eglBindAPI)
|
|
||||||
EGL_FUNC_DECL(eglBindTexImage)
|
|
||||||
EGL_FUNC_DECL(eglChooseConfig)
|
|
||||||
EGL_FUNC_DECL(eglCopyBuffers)
|
|
||||||
EGL_FUNC_DECL(eglCreateContext)
|
|
||||||
EGL_FUNC_DECL(eglCreatePbufferFromClientBuffer)
|
|
||||||
EGL_FUNC_DECL(eglCreatePbufferSurface)
|
|
||||||
EGL_FUNC_DECL(eglCreatePixmapSurface)
|
|
||||||
EGL_FUNC_DECL(eglCreatePlatformWindowSurface)
|
|
||||||
EGL_FUNC_DECL(eglCreateWindowSurface)
|
|
||||||
EGL_FUNC_DECL(eglDestroyContext)
|
|
||||||
EGL_FUNC_DECL(eglDestroySurface)
|
|
||||||
EGL_FUNC_DECL(eglGetConfigAttrib)
|
|
||||||
EGL_FUNC_DECL(eglGetConfigs)
|
|
||||||
EGL_FUNC_DECL(eglGetCurrentContext)
|
|
||||||
EGL_FUNC_DECL(eglGetCurrentDisplay)
|
|
||||||
EGL_FUNC_DECL(eglGetCurrentSurface)
|
|
||||||
EGL_FUNC_DECL(eglGetDisplay)
|
|
||||||
EGL_FUNC_DECL(eglGetPlatformDisplay)
|
|
||||||
EGL_FUNC_DECL(eglGetError)
|
|
||||||
EGL_FUNC_DECL(eglGetProcAddress)
|
|
||||||
EGL_FUNC_DECL(eglInitialize)
|
|
||||||
EGL_FUNC_DECL(eglMakeCurrent)
|
|
||||||
EGL_FUNC_DECL(eglQueryAPI)
|
|
||||||
EGL_FUNC_DECL(eglQueryContext)
|
|
||||||
EGL_FUNC_DECL(eglQueryString)
|
|
||||||
EGL_FUNC_DECL(eglQuerySurface)
|
|
||||||
EGL_FUNC_DECL(eglReleaseTexImage)
|
|
||||||
EGL_FUNC_DECL(eglReleaseThread)
|
|
||||||
EGL_FUNC_DECL(eglSurfaceAttrib)
|
|
||||||
EGL_FUNC_DECL(eglSwapBuffers)
|
|
||||||
EGL_FUNC_DECL(eglSwapBuffersWithDamageEXT)
|
|
||||||
EGL_FUNC_DECL(eglSwapInterval)
|
|
||||||
EGL_FUNC_DECL(eglTerminate)
|
|
||||||
EGL_FUNC_DECL(eglUnlockSurfaceKHR)
|
|
||||||
EGL_FUNC_DECL(eglWaitClient)
|
|
||||||
EGL_FUNC_DECL(eglWaitGL)
|
|
||||||
EGL_FUNC_DECL(eglWaitNative)
|
|
||||||
EGL_FUNC_DECL(eglCreateSync)
|
|
||||||
EGL_FUNC_DECL(eglDestroySync)
|
|
||||||
EGL_FUNC_DECL(eglClientWaitSync)
|
|
||||||
EGL_FUNC_DECL(eglGetSyncAttrib)
|
|
||||||
EGL_FUNC_DECL(eglCreateImage)
|
|
||||||
EGL_FUNC_DECL(eglDestroyImage)
|
|
||||||
EGL_FUNC_DECL(eglCreatePlatformPixmapSurface)
|
|
||||||
EGL_FUNC_DECL(eglWaitSync)
|
|
||||||
} // namespace EGL
|
|
||||||
} // namespace MG_External
|
|
||||||
|
|
||||||
#undef GL_FUNC_DECL
|
|
||||||
#undef EGL_FUNC_DECL
|
|
||||||
|
|
||||||
namespace MG_Util {
|
|
||||||
namespace BackendLoader::GLES {
|
|
||||||
Bool Init() {
|
|
||||||
LoadLibs();
|
|
||||||
if (libGLES == nullptr || libEGL == nullptr ||
|
|
||||||
(glGetError_PTR)ProcAddress(libGLES, "glGetError") == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
InitEGL();
|
|
||||||
InitGLES();
|
|
||||||
DestroyTempEGLCtx();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *libGLES = nullptr, *libEGL = nullptr;
|
|
||||||
|
|
||||||
static const char* LibPathPrefixes[] = {
|
|
||||||
"/opt/vc/lib/",
|
|
||||||
"/usr/local/lib/",
|
|
||||||
"/usr/lib/",
|
|
||||||
"/usr/lib/x86_64-linux-gnu/",
|
|
||||||
"", // We should put this to the end of the list to avoid breaking `LD_LIBRARY_PATH` usage
|
|
||||||
nullptr};
|
|
||||||
static const char* LibExts[] = {"so", "so.1", "so.2", "dylib", "dll", nullptr};
|
|
||||||
static const char* GLES3Libs[] = {"libGLESv3_CM", "libGLESv3", "libGLESv2_CM", "libGLESv2", nullptr};
|
|
||||||
static const char* EGLLibs[] = {"libEGL", nullptr};
|
|
||||||
|
|
||||||
void* OpenLib(const char** names, const char* override) {
|
|
||||||
#if !defined(__WIN32) && !defined(_WIN32) && !defined(__APPLE__)
|
#if !defined(__WIN32) && !defined(_WIN32) && !defined(__APPLE__)
|
||||||
|
static const String LibPathPrefixes[] = {
|
||||||
|
"/opt/vc/lib/", "/usr/local/lib/", "/usr/lib/", "/usr/lib/x86_64-linux-gnu/",
|
||||||
|
"" // We should put this to the end of the list to avoid breaking `LD_LIBRARY_PATH` usage
|
||||||
|
};
|
||||||
|
|
||||||
void* lib = nullptr;
|
void* lib = nullptr;
|
||||||
|
|
||||||
char path_name[PATH_MAX + 1];
|
Int flags = RTLD_LOCAL | RTLD_NOW;
|
||||||
int flags = RTLD_LOCAL | RTLD_NOW;
|
for (const auto& prefix : LibPathPrefixes) {
|
||||||
if (override) {
|
for (const auto& name : names) {
|
||||||
if ((lib = dlopen(override, flags))) {
|
String path_name = prefix + name;
|
||||||
strncpy(path_name, override, PATH_MAX);
|
if ((lib = dlopen(path_name.c_str(), flags))) {
|
||||||
return lib;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int p = 0; LibPathPrefixes[p]; p++) {
|
|
||||||
for (int i = 0; names[i]; i++) {
|
|
||||||
for (int e = 0; LibExts[e]; e++) {
|
|
||||||
snprintf(path_name, PATH_MAX, "%s%s.%s", LibPathPrefixes[p], names[i], LibExts[e]);
|
|
||||||
if ((lib = dlopen(path_name, flags))) {
|
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return lib;
|
|
||||||
#else
|
|
||||||
return nullptr;
|
|
||||||
#endif
|
#endif
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadLibs() {
|
inline void* ProcAddress(void* lib, const char* name) {
|
||||||
// TODO: Add ANGLE override?
|
|
||||||
libGLES = OpenLib(GLES3Libs, nullptr);
|
|
||||||
libEGL = OpenLib(EGLLibs, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* ProcAddress(void* lib, const char* name) {
|
|
||||||
#if !defined(__WIN32) && !defined(_WIN32) && !defined(__APPLE__)
|
#if !defined(__WIN32) && !defined(_WIN32) && !defined(__APPLE__)
|
||||||
return dlsym(lib, name);
|
return dlsym(lib, name);
|
||||||
#else
|
#else
|
||||||
return nullptr;
|
return nullptrptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitGLESCapabilities() {
|
Bool AcquireGLESFunctions(MG_External::GLESFunctionsTable& funcs,
|
||||||
auto* vendorName = MG_External::GLES::glGetString(GL_VENDOR);
|
MG_External::EGL::eglGetProcAddress_PTR procAddress) {
|
||||||
MGLOG_I("GL_VENDOR: %s", vendorName);
|
if (!procAddress) {
|
||||||
auto* gpuName = MG_External::GLES::glGetString(GL_RENDERER);
|
MGLOG_E("eglGetProcAddress is nullptr, cannot load GLES functions");
|
||||||
MGLOG_I("GL_RENDERER: %s", gpuName);
|
return false;
|
||||||
MG_External::GLES::glGetIntegerv(GL_MAJOR_VERSION, &MG_External::GLES::g_glesCaps.version.Major);
|
|
||||||
MG_External::GLES::glGetIntegerv(GL_MINOR_VERSION, &MG_External::GLES::g_glesCaps.version.Minor);
|
|
||||||
|
|
||||||
GLint extCount = 0;
|
|
||||||
MG_External::GLES::glGetIntegerv(GL_NUM_EXTENSIONS, &extCount);
|
|
||||||
MGLOG_I("Detected %d OpenGL ES extensions:", extCount);
|
|
||||||
for (GLint i = 0; i < extCount; ++i) {
|
|
||||||
const char* extension = (const char*)MG_External::GLES::glGetStringi(GL_EXTENSIONS, i);
|
|
||||||
if (extension) {
|
|
||||||
MGLOG_I(" %s", extension);
|
|
||||||
if (std::strcmp(extension, "GL_EXT_buffer_storage") == 0) {
|
|
||||||
MG_External::GLES::g_glesCaps.hasPersistentMapping = true;
|
|
||||||
}
|
|
||||||
if (std::strcmp(extension, "GL_EXT_texture_norm16") == 0) {
|
|
||||||
MG_External::GLES::g_glesCaps.hasNorm16Texture = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MGLOG_I("OpenGL ES capabilities:");
|
#define INIT_GLES_FUNC(name) \
|
||||||
MG_External::GLES::glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
|
do { \
|
||||||
&MG_External::GLES::g_glesCaps.uniformBufferOffsetAlignment);
|
funcs.name = (MG_External::GLES::name##_PTR)procAddress(#name); \
|
||||||
MGLOG_I(" GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: %d",
|
if (!funcs.name) { \
|
||||||
MG_External::GLES::g_glesCaps.uniformBufferOffsetAlignment);
|
MGLOG_E("Failed to load GLES function: %s", #name); \
|
||||||
}
|
} \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
void InitGLES() {
|
{
|
||||||
INIT_GLES_FUNC(glActiveTexture)
|
INIT_GLES_FUNC(glActiveTexture)
|
||||||
INIT_GLES_FUNC(glAttachShader)
|
INIT_GLES_FUNC(glAttachShader)
|
||||||
INIT_GLES_FUNC(glBindAttribLocation)
|
INIT_GLES_FUNC(glBindAttribLocation)
|
||||||
@@ -910,19 +425,26 @@ namespace MobileGL {
|
|||||||
INIT_GLES_FUNC(glMultiDrawArraysIndirectEXT)
|
INIT_GLES_FUNC(glMultiDrawArraysIndirectEXT)
|
||||||
INIT_GLES_FUNC(glMultiDrawElementsIndirectEXT)
|
INIT_GLES_FUNC(glMultiDrawElementsIndirectEXT)
|
||||||
INIT_GLES_FUNC(glMultiDrawElementsBaseVertexEXT)
|
INIT_GLES_FUNC(glMultiDrawElementsBaseVertexEXT)
|
||||||
|
}
|
||||||
InitGLESCapabilities();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EGLDisplay eglDisplay = EGL_NO_DISPLAY;
|
Bool AcquireEGLFunctions(MG_External::EGLFunctionsTable& funcs) {
|
||||||
static EGLSurface eglSurface = EGL_NO_SURFACE;
|
static const Vector<String> EGLLibNames = {"libEGL.so"};
|
||||||
static EGLContext eglContext = EGL_NO_CONTEXT;
|
void* eglLib = OpenLib(EGLLibNames);
|
||||||
|
if (!eglLib) {
|
||||||
|
MGLOG_E("Failed to open libEGL.so");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#define INIT_EGL_FUNC(name) \
|
#define INIT_EGL_FUNC(name) \
|
||||||
if (libEGL != NULL) { \
|
do { \
|
||||||
MG_External::EGL::name = (MG_External::EGL::name##_PTR)ProcAddress(libEGL, #name); \
|
funcs.name = (MG_External::EGL::name##_PTR)ProcAddress(eglLib, #name); \
|
||||||
}
|
if (!funcs.name) { \
|
||||||
void InitEGL() {
|
MGLOG_E("Failed to load EGL function: %s", #name); \
|
||||||
|
} \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
{
|
||||||
INIT_EGL_FUNC(eglBindAPI)
|
INIT_EGL_FUNC(eglBindAPI)
|
||||||
INIT_EGL_FUNC(eglBindTexImage)
|
INIT_EGL_FUNC(eglBindTexImage)
|
||||||
INIT_EGL_FUNC(eglChooseConfig)
|
INIT_EGL_FUNC(eglChooseConfig)
|
||||||
@@ -970,7 +492,28 @@ namespace MobileGL {
|
|||||||
INIT_EGL_FUNC(eglDestroyImage)
|
INIT_EGL_FUNC(eglDestroyImage)
|
||||||
INIT_EGL_FUNC(eglGetPlatformDisplay)
|
INIT_EGL_FUNC(eglGetPlatformDisplay)
|
||||||
INIT_EGL_FUNC(eglWaitSync)
|
INIT_EGL_FUNC(eglWaitSync)
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static EGLDisplay eglDisplay = EGL_NO_DISPLAY;
|
||||||
|
static EGLSurface eglSurface = EGL_NO_SURFACE;
|
||||||
|
static EGLContext eglContext = EGL_NO_CONTEXT;
|
||||||
|
inline void DestroyTempEGLCtx(const MG_External::EGLFunctionsTable& eglFuncs) {
|
||||||
|
if (eglSurface != EGL_NO_SURFACE) {
|
||||||
|
eglFuncs.eglDestroySurface(eglDisplay, eglSurface);
|
||||||
|
eglSurface = EGL_NO_SURFACE;
|
||||||
|
}
|
||||||
|
if (eglContext != EGL_NO_CONTEXT) {
|
||||||
|
eglFuncs.eglDestroyContext(eglDisplay, eglContext);
|
||||||
|
eglContext = EGL_NO_CONTEXT;
|
||||||
|
}
|
||||||
|
if (eglDisplay != EGL_NO_DISPLAY) {
|
||||||
|
eglFuncs.eglTerminate(eglDisplay);
|
||||||
|
eglDisplay = EGL_NO_DISPLAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inline Bool InitTmpEGLContext(const MG_External::EGLFunctionsTable& eglFuncs) {
|
||||||
EGLint configAttribs[] = {EGL_RED_SIZE,
|
EGLint configAttribs[] = {EGL_RED_SIZE,
|
||||||
8,
|
8,
|
||||||
EGL_GREEN_SIZE,
|
EGL_GREEN_SIZE,
|
||||||
@@ -992,78 +535,109 @@ namespace MobileGL {
|
|||||||
EGLConfig pbufConfig;
|
EGLConfig pbufConfig;
|
||||||
EGLint configsFound = 0;
|
EGLint configsFound = 0;
|
||||||
|
|
||||||
eglDisplay = MG_External::EGL::eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
eglDisplay = eglFuncs.eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
if (eglDisplay == EGL_NO_DISPLAY) {
|
if (eglDisplay == EGL_NO_DISPLAY) {
|
||||||
goto cleanup;
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MG_External::EGL::eglInitialize(eglDisplay, NULL, NULL) != EGL_TRUE) {
|
if (eglFuncs.eglInitialize(eglDisplay, nullptr, nullptr) != EGL_TRUE) {
|
||||||
goto cleanup;
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MG_External::EGL::eglBindAPI(EGL_OPENGL_ES_API) != EGL_TRUE) {
|
if (eglFuncs.eglBindAPI(EGL_OPENGL_ES_API) != EGL_TRUE) {
|
||||||
goto cleanup;
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MG_External::EGL::eglChooseConfig(eglDisplay, configAttribs, &pbufConfig, 1, &configsFound) !=
|
if (eglFuncs.eglChooseConfig(eglDisplay, configAttribs, &pbufConfig, 1, &configsFound) != EGL_TRUE) {
|
||||||
EGL_TRUE) {
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configsFound == 0) {
|
if (configsFound == 0) {
|
||||||
configAttribs[6] = 0;
|
configAttribs[6] = 0;
|
||||||
if (MG_External::EGL::eglChooseConfig(eglDisplay, configAttribs, &pbufConfig, 1, &configsFound) !=
|
if (eglFuncs.eglChooseConfig(eglDisplay, configAttribs, &pbufConfig, 1, &configsFound) != EGL_TRUE) {
|
||||||
EGL_TRUE) {
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
if (!configsFound) {
|
if (!configsFound) {
|
||||||
goto cleanup;
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eglContext = MG_External::EGL::eglCreateContext(eglDisplay, pbufConfig, EGL_NO_CONTEXT, ctxAttribs);
|
eglContext = eglFuncs.eglCreateContext(eglDisplay, pbufConfig, EGL_NO_CONTEXT, ctxAttribs);
|
||||||
if (eglContext == EGL_NO_CONTEXT) {
|
if (eglContext == EGL_NO_CONTEXT) {
|
||||||
goto cleanup;
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
eglSurface = MG_External::EGL::eglCreatePbufferSurface(eglDisplay, pbufConfig, pbAttribs);
|
eglSurface = eglFuncs.eglCreatePbufferSurface(eglDisplay, pbufConfig, pbAttribs);
|
||||||
if (eglSurface == EGL_NO_SURFACE) {
|
if (eglSurface == EGL_NO_SURFACE) {
|
||||||
goto cleanup;
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MG_External::EGL::eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) != EGL_TRUE) {
|
if (eglFuncs.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) != EGL_TRUE) {
|
||||||
goto cleanup;
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
Bool FillInGLESCapabilities(MG_External::GLESCapabilities& caps, const MG_External::GLESFunctionsTable& glesFuncs,
|
||||||
|
const MG_External::EGLFunctionsTable& eglFuncs) {
|
||||||
|
if (!glesFuncs.glGetString || !glesFuncs.glGetIntegerv) {
|
||||||
|
MGLOG_E("Required GLES functions are not loaded, cannot query capabilities");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!eglFuncs.eglGetDisplay || !eglFuncs.eglInitialize || !eglFuncs.eglChooseConfig ||
|
||||||
|
!eglFuncs.eglCreateContext || !eglFuncs.eglCreatePbufferSurface || !eglFuncs.eglMakeCurrent) {
|
||||||
|
MGLOG_E("Required EGL functions are not loaded, cannot create temporary EGL context");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
Bool eglCtxCreated = InitTmpEGLContext(eglFuncs);
|
||||||
if (eglSurface != EGL_NO_SURFACE) {
|
if (!eglCtxCreated) {
|
||||||
MG_External::EGL::eglDestroySurface(eglDisplay, eglSurface);
|
MGLOG_E("Failed to create temporary EGL context, cannot query GLES capabilities");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (eglContext != EGL_NO_CONTEXT) {
|
|
||||||
MG_External::EGL::eglDestroyContext(eglDisplay, eglContext);
|
auto* vendorName = glesFuncs.glGetString(GL_VENDOR);
|
||||||
|
MGLOG_I("GL_VENDOR: %s", vendorName);
|
||||||
|
auto* gpuName = glesFuncs.glGetString(GL_RENDERER);
|
||||||
|
MGLOG_I("GL_RENDERER: %s", gpuName);
|
||||||
|
glesFuncs.glGetIntegerv(GL_MAJOR_VERSION, &caps.GLESVersion.Major);
|
||||||
|
glesFuncs.glGetIntegerv(GL_MINOR_VERSION, &caps.GLESVersion.Minor);
|
||||||
|
|
||||||
|
caps.GLESVersionString = ToString(glesFuncs.glGetString(GL_VERSION));
|
||||||
|
caps.GLESRendererString = ToString(gpuName);
|
||||||
|
caps.GLESVendorString = ToString(vendorName);
|
||||||
|
caps.GLESShadingLanguageVersionString = ToString(glesFuncs.glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||||
|
|
||||||
|
GLint extCount = 0;
|
||||||
|
glesFuncs.glGetIntegerv(GL_NUM_EXTENSIONS, &extCount);
|
||||||
|
MGLOG_I("Detected %d OpenGL ES extensions:", extCount);
|
||||||
|
for (GLint i = 0; i < extCount; ++i) {
|
||||||
|
const char* extension = (const char*)glesFuncs.glGetStringi(GL_EXTENSIONS, i);
|
||||||
|
if (extension) {
|
||||||
|
MGLOG_I(" %s", extension);
|
||||||
|
if (std::strcmp(extension, "GL_EXT_buffer_storage") == 0) {
|
||||||
|
caps.SupportsPersistentMapping = true;
|
||||||
|
}
|
||||||
|
if (std::strcmp(extension, "GL_EXT_texture_norm16") == 0) {
|
||||||
|
caps.SupportsNorm16Texture = true;
|
||||||
}
|
}
|
||||||
if (eglDisplay != EGL_NO_DISPLAY) {
|
|
||||||
MG_External::EGL::eglTerminate(eglDisplay);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyTempEGLCtx() {
|
MGLOG_I("OpenGL ES capabilities:");
|
||||||
INIT_EGL_FUNC(eglDestroySurface)
|
glesFuncs.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &caps.UniformBufferOffsetAlignment);
|
||||||
INIT_EGL_FUNC(eglDestroyContext)
|
MGLOG_I(" GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: %d", caps.UniformBufferOffsetAlignment);
|
||||||
INIT_EGL_FUNC(eglMakeCurrent)
|
|
||||||
INIT_EGL_FUNC(eglTerminate)
|
|
||||||
|
|
||||||
MG_External::EGL::eglMakeCurrent(eglDisplay, 0, 0, EGL_NO_CONTEXT);
|
DestroyTempEGLCtx(eglFuncs);
|
||||||
MG_External::EGL::eglDestroySurface(eglDisplay, eglSurface);
|
return true;
|
||||||
MG_External::EGL::eglDestroyContext(eglDisplay, eglContext);
|
|
||||||
|
|
||||||
MG_External::EGL::eglTerminate(eglDisplay);
|
|
||||||
}
|
}
|
||||||
|
} // namespace MobileGL::MG_Util::BackendLoader
|
||||||
#undef LOAD_EGL
|
|
||||||
|
|
||||||
} // namespace BackendLoader::GLES
|
|
||||||
} // namespace MG_Util
|
|
||||||
} // namespace MobileGL
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -12,5 +12,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
String ConvertEGLEnumToString(GLenum value);
|
String ConvertEGLEnumToString(GLenum value);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
EShLanguage ConvertGLEnumToEShLanguage(GLenum shaderType);
|
EShLanguage ConvertGLEnumToEShLanguage(GLenum shaderType);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
DataType ConvertGLEnumToDataType(GLenum type);
|
DataType ConvertGLEnumToDataType(GLenum type);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -13,5 +13,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
ShaderStage ConvertGLEnumToShaderStage(GLenum type);
|
ShaderStage ConvertGLEnumToShaderStage(GLenum type);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -1823,7 +1823,7 @@ namespace MobileGL {
|
|||||||
CASE(GL_FOG_SPECULAR_TEXTURE_WIN)
|
CASE(GL_FOG_SPECULAR_TEXTURE_WIN)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return std::format("0x%x", value);
|
return std::format("0x{:x}", value);
|
||||||
}
|
}
|
||||||
#undef CASE
|
#undef CASE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
String ConvertGLEnumToString(GLenum value);
|
String ConvertGLEnumToString(GLenum value);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
GLenum ConvertDataTypeToGLEnum(DataType type);
|
GLenum ConvertDataTypeToGLEnum(DataType type);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -13,5 +13,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
GLenum ConvertErrorCodeToGLEnum(ErrorCode code);
|
GLenum ConvertErrorCodeToGLEnum(ErrorCode code);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -13,5 +13,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
GLenum ConvertShaderStageToGLEnum(ShaderStage stage);
|
GLenum ConvertShaderStageToGLEnum(ShaderStage stage);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
String ConvertDataTypeToString(DataType type);
|
String ConvertDataTypeToString(DataType type);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
String ConvertGLExtToString(GLExtension extension);
|
String ConvertGLExtToString(GLExtension extension);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
SizeT GetGLTypeSize(GLenum type);
|
SizeT GetGLTypeSize(GLenum type);
|
||||||
}
|
} // namespace MG_Util
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
|
|||||||
@@ -208,11 +208,11 @@ namespace MobileGL::MG_Util::PixelStoreProcessor {
|
|||||||
|
|
||||||
bool needSwizzle = false;
|
bool needSwizzle = false;
|
||||||
static Vector<TextureSwizzleParam> swizzle;
|
static Vector<TextureSwizzleParam> swizzle;
|
||||||
swizzle = { TextureSwizzleParam::Red, TextureSwizzleParam::Green,
|
swizzle = {TextureSwizzleParam::Red, TextureSwizzleParam::Green, TextureSwizzleParam::Blue,
|
||||||
TextureSwizzleParam::Blue, TextureSwizzleParam::Alpha };
|
TextureSwizzleParam::Alpha};
|
||||||
if (srcInternalFormat == TextureInternalFormat::RGBA && dstInputFormat == TextureInputFormat::BGRA) {
|
if (srcInternalFormat == TextureInternalFormat::RGBA && dstInputFormat == TextureInputFormat::BGRA) {
|
||||||
swizzle = { TextureSwizzleParam::Blue, TextureSwizzleParam::Green,
|
swizzle = {TextureSwizzleParam::Blue, TextureSwizzleParam::Green, TextureSwizzleParam::Red,
|
||||||
TextureSwizzleParam::Red, TextureSwizzleParam::Alpha };
|
TextureSwizzleParam::Alpha};
|
||||||
needSwizzle = true;
|
needSwizzle = true;
|
||||||
}
|
}
|
||||||
if (dstDataType == TexturePixelDataType::UnsignedInt8888) {
|
if (dstDataType == TexturePixelDataType::UnsignedInt8888) {
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ namespace MobileGL {
|
|||||||
namespace MG_Util::TextureFormatProcessor {
|
namespace MG_Util::TextureFormatProcessor {
|
||||||
void NormalizePixelFormat(GLenum internalFormat, Flags<PixelFormatNormalizeOptionBit> options,
|
void NormalizePixelFormat(GLenum internalFormat, Flags<PixelFormatNormalizeOptionBit> options,
|
||||||
GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType);
|
GLenum* outInternalFormat, GLenum* outFormat, GLenum* outType);
|
||||||
}
|
} // namespace MG_Util::TextureFormatProcessor
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
@@ -75,6 +75,10 @@ namespace MobileGL {
|
|||||||
using E = std::common_type_t<Ts...>;
|
using E = std::common_type_t<Ts...>;
|
||||||
return std::array<E, sizeof...(Ts)>{{std::forward<Ts>(elems)...}};
|
return std::array<E, sizeof...(Ts)>{{std::forward<Ts>(elems)...}};
|
||||||
}
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline String ToString(const T& value) {
|
||||||
|
return std::to_string(value);
|
||||||
|
}
|
||||||
class RuntimeError : public std::runtime_error {
|
class RuntimeError : public std::runtime_error {
|
||||||
public:
|
public:
|
||||||
using std::runtime_error::runtime_error;
|
using std::runtime_error::runtime_error;
|
||||||
@@ -252,7 +256,7 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BackendCap {
|
struct StaticBackendCapabilityT {
|
||||||
Bool AllowVSOnlyPrograms = false;
|
Bool AllowVSOnlyPrograms = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -268,7 +272,7 @@ namespace MobileGL {
|
|||||||
String BackendName;
|
String BackendName;
|
||||||
Optional<String> ExtraVendor;
|
Optional<String> ExtraVendor;
|
||||||
GLInfo RendererGLInfo;
|
GLInfo RendererGLInfo;
|
||||||
BackendCap BackendCapability;
|
StaticBackendCapabilityT StaticBackendCapability;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Bit,
|
template <typename Bit,
|
||||||
|
|||||||
Reference in New Issue
Block a user