mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Refactor] (All): Restructure include system.
This commit is contained in:
+8
-3
@@ -10,11 +10,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -fvisibility=hidden -funwind-tables -g -D_THREAD_SAFE -fPIC -stdlib=libc++")
|
||||
|
||||
set(PROFILING OFF)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
find_library(GLSLANG_LIB glslang PATHS ${CMAKE_SOURCE_DIR}/libraries/arm64-v8a/)
|
||||
|
||||
add_library(${CMAKE_PROJECT_NAME} SHARED
|
||||
set(SOURCE_FILES
|
||||
MobileGL/Init.cpp
|
||||
|
||||
MobileGL/MG_Util/Debug/Log.cpp
|
||||
@@ -54,6 +54,10 @@ add_library(${CMAKE_PROJECT_NAME} SHARED
|
||||
MobileGL/MG_State/GLState/BufferState/BufferObject.cpp
|
||||
MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.cpp
|
||||
MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.cpp
|
||||
)
|
||||
|
||||
add_library(${CMAKE_PROJECT_NAME} SHARED
|
||||
${SOURCE_FILES}
|
||||
)
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
|
||||
@@ -79,8 +83,9 @@ target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
|
||||
|
||||
# add_subdirectory(3rdparty/DiligentCore)
|
||||
|
||||
target_include_directories(MobileGL PUBLIC
|
||||
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/MobileGL
|
||||
)
|
||||
|
||||
target_link_libraries(MobileGL
|
||||
|
||||
+16
-26
@@ -1,32 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_DEBUG
|
||||
|
||||
#define MOBILEGL_LOG_ENABLE_CONSOLE 0
|
||||
#define MOBILEGL_LOG_ENABLE_FILE 1
|
||||
#define MOBILEGL_LOG_ENABLE_ANDROID 1
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#define MOBILEGL_LOG_FILE_PATH "/sdcard/MG/latest.log"
|
||||
#else
|
||||
#define MOBILEGL_LOG_FILE_PATH ""
|
||||
#endif
|
||||
#include <Includes.h>
|
||||
#include <MG_Backend/Backends.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Config {
|
||||
inline const String ProjectName = "MobileGL";
|
||||
inline const String CoreName = "MobileGL Core";
|
||||
inline const String CoreVendor = "MobileGL-Dev";
|
||||
inline const Version CoreVersion = { 1, 0, 0, "-Dev" };
|
||||
extern RendererInfo* RendererInfoPtr;
|
||||
namespace MG_Config {
|
||||
inline const String ProjectName = "MobileGL";
|
||||
inline const String CoreName = "MobileGL Core";
|
||||
inline const String CoreVendor = "MobileGL-Dev";
|
||||
inline const Version CoreVersion = {1, 0, 0, "-Dev"};
|
||||
extern RendererInfo* RendererInfoPtr;
|
||||
|
||||
namespace Backend {
|
||||
namespace Backend {
|
||||
#define MOBILEGL_BACKEND MOBILEGL_BACKEND_UNKNOWN
|
||||
|
||||
namespace Diligent {
|
||||
inline const MG_Backend::Diligent::SpecificBackendType SpecificBackend =
|
||||
MG_Backend::Diligent::SpecificBackendType::Vulkan;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Diligent {
|
||||
inline const MG_Backend::Diligent::SpecificBackendType SpecificBackend =
|
||||
MG_Backend::Diligent::SpecificBackendType::Vulkan;
|
||||
}
|
||||
} // namespace Backend
|
||||
} // namespace MG_Config
|
||||
} // namespace MobileGL
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
// ============== Platform-specific definitions and macros ============== //
|
||||
#ifdef __ANDROID__
|
||||
#define __ANDROID_API__ 26 // force Android API level to 26 for compatibility
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define NOMINMAX // prevent Windows.h from defining min and max macros
|
||||
#endif
|
||||
|
||||
// ================== MobileGL definitions and macros =================== //
|
||||
#ifdef _WIN32
|
||||
#define MOBILEGL_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define MOBILEGL_EXPORT extern "C" __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#define MOBILEGL_API MOBILEGL_EXPORT
|
||||
|
||||
#define MOBILEGL_GLX_API MOBILEGL_API
|
||||
#define MOBILEGL_GL_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 3
|
||||
|
||||
// ====================== MobileGL configurations ======================= //
|
||||
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_DEBUG
|
||||
|
||||
#define MOBILEGL_LOG_ENABLE_CONSOLE 0
|
||||
#define MOBILEGL_LOG_ENABLE_FILE 1
|
||||
#define MOBILEGL_LOG_ENABLE_ANDROID 1
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#define MOBILEGL_LOG_FILE_PATH "/sdcard/MG/latest.log"
|
||||
#else
|
||||
#define MOBILEGL_LOG_FILE_PATH ""
|
||||
#endif
|
||||
+57
-112
@@ -1,137 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#define __ANDROID_API__ 26 // force Android API level to 26 for compatibility
|
||||
#endif
|
||||
// Include significant project headers
|
||||
#include "Defines.h"
|
||||
#include "MG_Util/PlatformStubs.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MOBILEGL_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define MOBILEGL_EXPORT extern "C" __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#define MOBILEGL_API MOBILEGL_EXPORT
|
||||
|
||||
#define MOBILEGL_GLX_API MOBILEGL_API
|
||||
#define MOBILEGL_GL_API MOBILEGL_API
|
||||
#define MOBILEGL_EGL_API MOBILEGL_API
|
||||
|
||||
#define NOMINMAX // prevent Windows.h from defining min and max macros
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
// Include necessary standard headers
|
||||
#include <bit>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <cctype>
|
||||
#include <stdexcept>
|
||||
#include <atomic>
|
||||
#include <regex>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <random>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <ctime>
|
||||
#include <queue>
|
||||
#include <regex>
|
||||
#include <atomic>
|
||||
#include <cctype>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <format>
|
||||
#include <memory>
|
||||
#include <bit>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <cstdarg>
|
||||
#include <functional>
|
||||
#include <cstring>
|
||||
#include <expected>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <functional>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
// Include ankerl::unordered_dense
|
||||
#include <ankerl/unordered_dense.h>
|
||||
|
||||
// Include spirv_cross
|
||||
#include <spirv_cross/spirv_cross_c.h>
|
||||
|
||||
// Include glm
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
// Include OpenGL and EGL headers
|
||||
#include <GL/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GL/glext.h>
|
||||
#include <GLES3/gl32.h>
|
||||
|
||||
// Include glslang headers
|
||||
#include <glslang/Include/Types.h>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
#include <spirv_cross/spirv_cross_c.h>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
#include <glslang/SPIRV/GlslangToSpv.h>
|
||||
#include <glslang/Include/intermediate.h>
|
||||
#include <glslang/MachineIndependent/localintermediate.h>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include <ankerl/unordered_dense.h>
|
||||
#include <GLES3/gl32.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/log.h>
|
||||
#include <pthread.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <vulkan/vulkan_android.h>
|
||||
#include <android/native_window.h>
|
||||
// Include headers for platform-specific functionality
|
||||
#ifdef __linux__
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <processthreadsapi.h>
|
||||
#else
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <android/log.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <android/native_window.h>
|
||||
#include <vulkan/vulkan_android.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ANDROID__
|
||||
// Define a stub for __android_log_print if not on Android
|
||||
#define ANDROID_LOG_UNKNOWN 0
|
||||
#define ANDROID_LOG_DEFAULT 1
|
||||
#define ANDROID_LOG_VERBOSE 2
|
||||
#define ANDROID_LOG_DEBUG 3
|
||||
#define ANDROID_LOG_INFO 4
|
||||
#define ANDROID_LOG_WARN 5
|
||||
#define ANDROID_LOG_ERROR 6
|
||||
#define ANDROID_LOG_FATAL 7
|
||||
#define ANDROID_LOG_SILENT 8
|
||||
|
||||
typedef int android_LogPriority;
|
||||
|
||||
inline int __android_log_print(int prio, const char* tag, const char* fmt, ...) { return 0; }
|
||||
#endif
|
||||
|
||||
#include "MG_Util/GLExtensions.h"
|
||||
// Post-includes for significant project headers
|
||||
#include "MG_Util/Types.h"
|
||||
#include "MG_Util/Miscellany/IndexGenerator.h"
|
||||
#include "MG_Util/Debug/Log.h"
|
||||
#include "MG_State/GLState/ErrorState/ErrorCode.h"
|
||||
#include "MG_State/GLState/ErrorState/ErrorInfo.h"
|
||||
#include "MG_State/GLState/ErrorState/Error.h"
|
||||
|
||||
#include "MG_Backend/Backends.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "MG_Impl/GLXImpl/LookUp/LookUp.h"
|
||||
#include "MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.h"
|
||||
|
||||
#include "MG_State/GLState/BufferState/BufferObject.h"
|
||||
#include "MG_State/GLState/BufferState/BufferState.h"
|
||||
#include "MG_State/GLState/VertexArrayState/VertexArrayObject.h"
|
||||
#include "MG_State/GLState/VertexArrayState/VertexArrayState.h"
|
||||
|
||||
/* @INSERTION_POINT:HEADER_FILE_GLIMPL@ */
|
||||
#include "MG_Impl/GLImpl/VertexArray/Validators.h"
|
||||
#include "MG_Impl/GLImpl/VertexArray/GL_VertexArray.h"
|
||||
#include "MG_Impl/GLImpl/Getter/GL_Getter.h"
|
||||
#include "MG_Impl/GLImpl/Buffer/GL_Buffer.h"
|
||||
#include "MG_Impl/GLImpl/Buffer/Validators.h"
|
||||
|
||||
#include "MG_State/GLState/Core.h"
|
||||
|
||||
#include "MG_Util/Converters/MGToGL/BufferEnumConverter.h"
|
||||
#include "MG_Util/Converters/MGToGL/ErrorCodeConverter.h"
|
||||
#include "MG_Util/Converters/MGToGL/DataTypeConverter.h"
|
||||
#include "MG_Util/Converters/MGToStr/DataTypeConverter.h"
|
||||
#include "MG_Util/Converters/MGToStr/BufferEnumConverter.h"
|
||||
#include "MG_Util/Converters/MGToStr/GLExtensionConverter.h"
|
||||
#include "MG_Util/Converters/GLToMG/BufferEnumConverter.h"
|
||||
#include "MG_Util/Converters/GLToMG/DataTypeConverter.h"
|
||||
#include "MG_Util/Converters/GLToStr/GLEnumConverter.h"
|
||||
#include "MG_Util/Converters/GLToGlslang/GLShaderLangConverter.h"
|
||||
|
||||
#include "MG_Util/ShaderTranspiler/SpvcSession.h"
|
||||
#include "MG_Util/ShaderTranspiler/ShaderCompiler.h"
|
||||
#include "MG_Util/Debug/Log.h"
|
||||
+5
-8
@@ -1,9 +1,10 @@
|
||||
#include "Includes.h"
|
||||
#include <MG_Backend/Backends.h>
|
||||
|
||||
namespace MobileGL {
|
||||
void MG_Initialize() {
|
||||
MG_Util::Debug::InitFile();
|
||||
MGLOG_I("MobileGL Initializing...");
|
||||
MGLOG_I("MobileGL Initializing...");
|
||||
MG_Backend::Init();
|
||||
glslang::InitializeProcess();
|
||||
}
|
||||
@@ -25,12 +26,8 @@ namespace MobileGL {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOL WINAPI DllMain(HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
MG_Initialize();
|
||||
break;
|
||||
@@ -42,4 +39,4 @@ namespace MobileGL {
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} // namespace MobileGL
|
||||
@@ -1,57 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#define MOBILEGL_BACKEND_TYPE_UNKNOWN 0
|
||||
#define MOBILEGL_BACKEND_TYPE_DILIGENT 1
|
||||
#define MOBILEGL_BACKEND_TYPE_MRHI 2
|
||||
#define MOBILEGL_BACKEND_TYPE_DIRECT 3 // the previous "ShittilyDraw"
|
||||
#include <Includes.h>
|
||||
#include <MG_Util/GLExtensions.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Backend {
|
||||
namespace Unknown {
|
||||
const RendererInfo RendererInfoUnknown = {
|
||||
"<unknown renderer of MobileGL>",
|
||||
"<unknown backend>",
|
||||
", <unknown>",
|
||||
{
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ },
|
||||
},
|
||||
{ }
|
||||
};
|
||||
}
|
||||
namespace Diligent {
|
||||
enum class SpecificBackendType {
|
||||
Vulkan,
|
||||
Metal
|
||||
};
|
||||
namespace MG_Backend {
|
||||
namespace Unknown {
|
||||
const RendererInfo RendererInfoUnknown = {"<unknown renderer of MobileGL>",
|
||||
"<unknown backend>",
|
||||
", <unknown>",
|
||||
{
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{},
|
||||
},
|
||||
{}};
|
||||
}
|
||||
|
||||
const RendererInfo RendererInfoVulkan = {
|
||||
"MobileGlued-vk",
|
||||
"Diligent Engine (Vulkan)",
|
||||
Nullopt,
|
||||
{
|
||||
{ 3, 2, 0 },
|
||||
{ 4, 5, 0 },
|
||||
{ V_OpenGL30, V_OpenGL31, V_OpenGL32 },
|
||||
false
|
||||
},
|
||||
{ }
|
||||
};
|
||||
namespace Diligent {
|
||||
enum class SpecificBackendType {
|
||||
Vulkan,
|
||||
Metal
|
||||
};
|
||||
|
||||
const RendererInfo RendererInfoMetal = {
|
||||
"MobileGlued-mtl",
|
||||
"Diligent Engine (Metal)",
|
||||
Nullopt,
|
||||
{
|
||||
{ 3, 2, 0 },
|
||||
{ 4, 5, 0 },
|
||||
{ V_OpenGL30, V_OpenGL31, V_OpenGL32 },
|
||||
},
|
||||
{ }
|
||||
};
|
||||
}
|
||||
const RendererInfo RendererInfoVulkan = {
|
||||
"MobileGlued-vk",
|
||||
"Diligent Engine (Vulkan)",
|
||||
Nullopt,
|
||||
{{3, 2, 0}, {4, 5, 0}, {V_OpenGL30, V_OpenGL31, V_OpenGL32}, false},
|
||||
{}};
|
||||
|
||||
void Init();
|
||||
}
|
||||
}
|
||||
const RendererInfo RendererInfoMetal = {"MobileGlued-mtl",
|
||||
"Diligent Engine (Metal)",
|
||||
Nullopt,
|
||||
{
|
||||
{3, 2, 0},
|
||||
{4, 5, 0},
|
||||
{V_OpenGL30, V_OpenGL31, V_OpenGL32},
|
||||
},
|
||||
{}};
|
||||
} // namespace Diligent
|
||||
|
||||
void Init();
|
||||
} // namespace MG_Backend
|
||||
} // namespace MobileGL
|
||||
@@ -1,28 +1,29 @@
|
||||
#include "../Includes.h"
|
||||
#include "Backends.h"
|
||||
#include <Config.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Config {
|
||||
RendererInfo* RendererInfoPtr = nullptr;
|
||||
}
|
||||
namespace MG_Config {
|
||||
RendererInfo* RendererInfoPtr = nullptr;
|
||||
}
|
||||
|
||||
namespace MG_Backend {
|
||||
void Init() {
|
||||
MGLOG_D("Initializing MobileGL Backend...");
|
||||
namespace MG_Backend {
|
||||
void Init() {
|
||||
MGLOG_D("Initializing MobileGL Backend...");
|
||||
|
||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_DILIGENT
|
||||
switch (MG_Config::Backend::Diligent::SpecificBackend) {
|
||||
case MG_Backend::Diligent::SpecificBackendType::Vulkan:
|
||||
MG_Config::RendererInfoPtr = (RendererInfo*)&MG_Backend::Diligent::RendererInfoVulkan;
|
||||
break;
|
||||
case MG_Backend::Diligent::SpecificBackendType::Metal:
|
||||
MG_Config::RendererInfoPtr = (RendererInfo*)&MG_Backend::Diligent::RendererInfoMetal;
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Unsupported renderer type");
|
||||
}
|
||||
switch (MG_Config::Backend::Diligent::SpecificBackend) {
|
||||
case MG_Backend::Diligent::SpecificBackendType::Vulkan:
|
||||
MG_Config::RendererInfoPtr = (RendererInfo*)&MG_Backend::Diligent::RendererInfoVulkan;
|
||||
break;
|
||||
case MG_Backend::Diligent::SpecificBackendType::Metal:
|
||||
MG_Config::RendererInfoPtr = (RendererInfo*)&MG_Backend::Diligent::RendererInfoMetal;
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Unsupported renderer type");
|
||||
}
|
||||
#else
|
||||
MG_Config::RendererInfoPtr = (RendererInfo*)&RendererInfoUnknown;
|
||||
MG_Config::RendererInfoPtr = (RendererInfo*)&RendererInfoUnknown;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MG_Backend
|
||||
} // namespace MobileGL
|
||||
@@ -1,17 +1,18 @@
|
||||
#include "../../../Includes.h"
|
||||
#include <Includes.h>
|
||||
#include "../Temporary/TemporaryEGLImpl.h"
|
||||
|
||||
MOBILEGL_EGL_API EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
||||
const EGLint* attrib_list) {
|
||||
const EGLint* 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,
|
||||
EGLint config_size, EGLint* num_config) {
|
||||
EGLint config_size, EGLint* 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,
|
||||
const EGLint* attrib_list) {
|
||||
const EGLint* attrib_list) {
|
||||
return MobileGL::MG_Impl::EGLImpl::CreateContext(dpy, config, shareCtx, attrib_list);
|
||||
}
|
||||
|
||||
@@ -82,4 +83,3 @@ MOBILEGL_EGL_API EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig co
|
||||
MOBILEGL_EGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* name) {
|
||||
return MobileGL::MG_Impl::EGLImpl::GetProcAddress(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "TemporaryEGLImpl.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::EGLImpl {
|
||||
// TODO: Implement complete EGL functionality
|
||||
// TODO: Implement complete EGL functionality
|
||||
|
||||
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
|
||||
const EGLint* attrib_list) {
|
||||
const EGLint* attrib_list) {
|
||||
return (EGLSurface)1;
|
||||
}
|
||||
|
||||
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs,
|
||||
EGLint config_size, EGLint* num_config) {
|
||||
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) {
|
||||
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) {
|
||||
return (EGLContext)1;
|
||||
}
|
||||
|
||||
@@ -59,8 +58,21 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
|
||||
if (attribute == EGL_NATIVE_VISUAL_ID)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -95,7 +107,7 @@ namespace MobileGL {
|
||||
MGLOG_W("Failed to get function: %s", (const char*)name);
|
||||
return nullptr;
|
||||
}
|
||||
return (__eglMustCastToProperFunctionPointerType)proc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (__eglMustCastToProperFunctionPointerType)proc;
|
||||
}
|
||||
} // namespace MG_Impl::EGLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,13 +1,13 @@
|
||||
#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);
|
||||
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();
|
||||
@@ -25,5 +25,5 @@ namespace MobileGL {
|
||||
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw);
|
||||
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list);
|
||||
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name);
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::EGLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,457 +1,497 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GL_Buffer.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_Util/Converters/GLToMG/BufferEnumConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
void DeleteBuffers_State(GLsizei n, const GLuint* buffers) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteBuffers_State",
|
||||
"n must be non-negative."));
|
||||
return;
|
||||
}
|
||||
namespace MG_Impl::GLImpl {
|
||||
void DeleteBuffers_State(GLsizei n, const GLuint* buffers) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteBuffers_State", "n must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!buffers) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteBuffers_State",
|
||||
"Buffer names array cannot be null."));
|
||||
return;
|
||||
}
|
||||
if (!buffers) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteBuffers_State",
|
||||
"Buffer names array cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
for (SizeT i = 0; i < static_cast<SizeT>(n); ++i) {
|
||||
Uint bufferName = buffers[i];
|
||||
if (bufferName == 0) continue;
|
||||
if (!BufferImpl::ValidateBufferName(bufferName)) continue;
|
||||
MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName);
|
||||
}
|
||||
for (SizeT i = 0; i < static_cast<SizeT>(n); ++i) {
|
||||
Uint bufferName = buffers[i];
|
||||
if (bufferName == 0) continue;
|
||||
if (!BufferImpl::ValidateBufferName(bufferName)) continue;
|
||||
MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FlushMappedBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length) {
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return;
|
||||
}
|
||||
void FlushMappedBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length) {
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped."));
|
||||
return;
|
||||
}
|
||||
if (!bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset + length > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return;
|
||||
}
|
||||
if (offset + length > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
if(!(mappingAccess & BufferMappingAccessBit::FlushExplicit)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped with GL_MAP_FLUSH_EXPLICIT_BIT."));
|
||||
return;
|
||||
}
|
||||
auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
if (!(mappingAccess & BufferMappingAccessBit::FlushExplicit)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "FlushMappedBufferRange_State",
|
||||
"Cannot flush a buffer object that is not mapped with GL_MAP_FLUSH_EXPLICIT_BIT."));
|
||||
return;
|
||||
}
|
||||
|
||||
bufferObject->FlushMemoryRange(static_cast<SizeT>(offset), static_cast<SizeT>(length));
|
||||
}
|
||||
|
||||
GLboolean UnmapBuffer_State(GLenum target) {
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return GL_FALSE;
|
||||
bufferObject->FlushMemoryRange(static_cast<SizeT>(offset), static_cast<SizeT>(length));
|
||||
}
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
GLboolean UnmapBuffer_State(GLenum target) {
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return GL_FALSE;
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "UnmapBuffer_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
if (!bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "UnmapBuffer_State",
|
||||
"Cannot unmap a buffer object that is not mapped."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "UnmapBuffer_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
bufferObject->ReleaseMemory();
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void* MapBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return nullptr;
|
||||
}
|
||||
if (!bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "UnmapBuffer_State",
|
||||
"Cannot unmap a buffer object that is not mapped."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (length == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Length must be greater than zero."));
|
||||
return nullptr;
|
||||
}
|
||||
bufferObject->ReleaseMemory();
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr;
|
||||
void* MapBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
if (length < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Offset and length must be non-negative."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return nullptr;
|
||||
}
|
||||
if (length == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Length must be greater than zero."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (offset + length > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return nullptr;
|
||||
}
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr;
|
||||
|
||||
auto accessBits = MG_Util::ConvertGLEnumToBufferMappingAccess(access);
|
||||
if (!BufferImpl::ValidateBufferMappingAccess(accessBits)) return nullptr;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"At least one of GL_MAP_READ_BIT or GL_MAP_WRITE_BIT must be set."));
|
||||
return nullptr;
|
||||
}
|
||||
if (offset + length > bufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Offset and length exceed buffer size."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (accessBits & BufferMappingAccessBit::Read) {
|
||||
const auto invalidFlags = BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::Unsynchronized;
|
||||
auto accessBits = MG_Util::ConvertGLEnumToBufferMappingAccess(access);
|
||||
if (!BufferImpl::ValidateBufferMappingAccess(accessBits)) return nullptr;
|
||||
|
||||
if (accessBits & invalidFlags) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"GL_MAP_READ_BIT cannot be combined with invalidation or unsynchronized flags."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (!(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"At least one of GL_MAP_READ_BIT or GL_MAP_WRITE_BIT must be set."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (accessBits & BufferMappingAccessBit::FlushExplicit) {
|
||||
if (!(accessBits & BufferMappingAccessBit::Write)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"GL_MAP_FLUSH_EXPLICIT_BIT requires GL_MAP_WRITE_BIT."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (accessBits & BufferMappingAccessBit::Read) {
|
||||
const auto invalidFlags = BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::Unsynchronized;
|
||||
|
||||
const auto storageFlags =
|
||||
BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent;
|
||||
auto requiredFlags = accessBits & storageFlags;
|
||||
if (requiredFlags) {
|
||||
// TODO: check if the buffer data is created by BufferStorage and its flags after its implementation
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Access flags require matching storage flags in buffer."));
|
||||
return nullptr;
|
||||
}
|
||||
if (accessBits & invalidFlags) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"GL_MAP_READ_BIT cannot be combined with invalidation or unsynchronized flags."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (bufferObject->IsMapped()) {
|
||||
const auto invalidateFlags = BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer;
|
||||
if (accessBits & BufferMappingAccessBit::FlushExplicit) {
|
||||
if (!(accessBits & BufferMappingAccessBit::Write)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"GL_MAP_FLUSH_EXPLICIT_BIT requires GL_MAP_WRITE_BIT."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(accessBits & invalidateFlags)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Cannot map a buffer object that is already mapped."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
const auto storageFlags = BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent;
|
||||
auto requiredFlags = accessBits & storageFlags;
|
||||
if (requiredFlags) {
|
||||
// TODO: check if the buffer data is created by BufferStorage and its flags after its implementation
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Access flags require matching storage flags in buffer."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* result = bufferObject->AcquireMemoryRange(
|
||||
{ static_cast<SizeT>(offset), static_cast<SizeT>(offset + length) },
|
||||
accessBits
|
||||
);
|
||||
if (!result) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::OutOfMemory,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Failed to map buffer due to insufficient memory."));
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void* MapBuffer_State(GLenum target, GLenum access) {
|
||||
bool readable = access == GL_READ_ONLY || access == GL_READ_WRITE;
|
||||
bool writable = access == GL_WRITE_ONLY || access == GL_READ_WRITE;
|
||||
if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Access must be one of GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Cannot map a buffer object that is already mapped."));
|
||||
return nullptr;
|
||||
}
|
||||
if (bufferObject->IsMapped()) {
|
||||
const auto invalidateFlags =
|
||||
BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer;
|
||||
|
||||
void* result = bufferObject->AcquireMemory(true, readable, writable);
|
||||
if (!result) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::OutOfMemory,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Failed to map buffer due to insufficient memory."));
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CopyBufferSubData_State(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
|
||||
if (size < 0 || readOffset < 0 || writeOffset < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
BufferTarget readBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(readTarget);
|
||||
BufferTarget writeBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(writeTarget);
|
||||
if (!BufferImpl::ValidateBufferTarget(readBufferTarget) || !BufferImpl::ValidateBufferTarget(writeBufferTarget)) return;
|
||||
|
||||
auto& readBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(readBufferTarget);
|
||||
auto& writeBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(writeBufferTarget);
|
||||
auto readBufferObject = readBindingSlot.GetBoundObject();
|
||||
auto writeBufferObject = writeBindingSlot.GetBoundObject();
|
||||
if (!(accessBits & invalidateFlags)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Cannot map a buffer object that is already mapped."));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!readBufferObject || !writeBufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"One of the buffer targets is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
void* result = bufferObject->AcquireMemoryRange(
|
||||
{static_cast<SizeT>(offset), static_cast<SizeT>(offset + length)}, accessBits);
|
||||
if (!result) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::OutOfMemory,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
|
||||
"Failed to map buffer due to insufficient memory."));
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (readOffset + size > readBufferObject->GetSize() || writeOffset + size > writeBufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Offset and size must be within the bounds of the buffer objects."));
|
||||
return;
|
||||
}
|
||||
void* MapBuffer_State(GLenum target, GLenum access) {
|
||||
bool readable = access == GL_READ_ONLY || access == GL_READ_WRITE;
|
||||
bool writable = access == GL_WRITE_ONLY || access == GL_READ_WRITE;
|
||||
if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Access must be one of GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (readBufferObject == writeBufferObject) {
|
||||
if ((readOffset <= writeOffset && readOffset + size > writeOffset) ||
|
||||
(writeOffset <= readOffset && writeOffset + size > readOffset)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Source and destination buffers overlap in the specified ranges."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
auto isIllegallyMapped = [](const SharedPtr<MG_State::GLState::BufferObject>& buffer) {
|
||||
return buffer->IsMapped() && !(buffer->GetMappingAccess() & BufferMappingAccessBit::Persistent);
|
||||
};
|
||||
if (isIllegallyMapped(readBufferObject) || isIllegallyMapped(writeBufferObject)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Cannot copy data from/to a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT."));
|
||||
return;
|
||||
}
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
writeBufferObject->CopyDataFrom(readBufferObject, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
void BufferSubData_State(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
if (!data) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::NoError, // somehow OpenGL does not generate an error for this
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Data pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
if (bufferObject->IsMapped()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Cannot map a buffer object that is already mapped."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (size < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
void* result = bufferObject->AcquireMemory(true, readable, writable);
|
||||
if (!result) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::OutOfMemory,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBuffer_State",
|
||||
"Failed to map buffer due to insufficient memory."));
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
void CopyBufferSubData_State(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset,
|
||||
GLsizeiptr size) {
|
||||
if (size < 0 || readOffset < 0 || writeOffset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
BufferTarget readBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(readTarget);
|
||||
BufferTarget writeBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(writeTarget);
|
||||
if (!BufferImpl::ValidateBufferTarget(readBufferTarget) ||
|
||||
!BufferImpl::ValidateBufferTarget(writeBufferTarget))
|
||||
return;
|
||||
|
||||
SizeT bufferSize = bufferObject->GetSize();
|
||||
Range1D mappedRange = bufferObject->GetMappedRange();
|
||||
if ((offset < mappedRange.end) && (offset + size > mappedRange.start)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size must not overlap with the mapped range of the buffer object."));
|
||||
return;
|
||||
}
|
||||
auto& readBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(readBufferTarget);
|
||||
auto& writeBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(writeBufferTarget);
|
||||
auto readBufferObject = readBindingSlot.GetBoundObject();
|
||||
auto writeBufferObject = writeBindingSlot.GetBoundObject();
|
||||
|
||||
auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
if (bufferObject->IsMapped() && !(mappingAccess & BufferMappingAccessBit::Persistent)) {
|
||||
Range1D mappedRange = bufferObject->GetMappedRange();
|
||||
if (offset + size >= mappedRange.start) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Cannot modify a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!readBufferObject || !writeBufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"One of the buffer targets is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
bufferObject->UploadSubData({ (void*)data, (SizeT)size }, offset);
|
||||
}
|
||||
|
||||
void BufferData_State(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
|
||||
if (size < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferData_State",
|
||||
"Size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
if (readOffset + size > readBufferObject->GetSize() || writeOffset + size > writeBufferObject->GetSize()) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Offset and size must be within the bounds of the buffer objects."));
|
||||
return;
|
||||
}
|
||||
|
||||
BufferUsage bufferUsage = MG_Util::ConvertGLEnumToBufferUsage(usage);
|
||||
if (!BufferImpl::ValidateBufferUsage(bufferUsage)) return;
|
||||
if (readBufferObject == writeBufferObject) {
|
||||
if ((readOffset <= writeOffset && readOffset + size > writeOffset) ||
|
||||
(writeOffset <= readOffset && writeOffset + size > readOffset)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Source and destination buffers overlap in the specified ranges."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
auto isIllegallyMapped = [](const SharedPtr<MG_State::GLState::BufferObject>& buffer) {
|
||||
return buffer->IsMapped() && !(buffer->GetMappingAccess() & BufferMappingAccessBit::Persistent);
|
||||
};
|
||||
if (isIllegallyMapped(readBufferObject) || isIllegallyMapped(writeBufferObject)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "CopyBufferSubData_State",
|
||||
"Cannot copy data from/to a mapped buffer object unless it was mapped "
|
||||
"with GL_MAP_PERSISTENT_BIT."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferData_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
writeBufferObject->CopyDataFrom(readBufferObject, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
bufferObject->SetUsage(bufferUsage);
|
||||
bufferObject->Resize(size);
|
||||
if (data) {
|
||||
bufferObject->UploadData({ (void*)data, (SizeT)size }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void BindBuffer_State(GLenum target, GLuint buffer) {
|
||||
if (buffer != 0 && !BufferImpl::ValidateBufferName(buffer)) return;
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
void BufferSubData_State(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
if (!data) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::NoError, // somehow OpenGL does not generate an error for this
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Data pointer cannot be null."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto bufferObject = MG_State::pGLContext->GetBufferObject(buffer);
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->CreateBufferObject(buffer);
|
||||
bufferObject = MG_State::pGLContext->GetBufferObject(buffer);
|
||||
}
|
||||
if (size < 0 || offset < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
bindingSlot.Bind(bufferObject);
|
||||
}
|
||||
|
||||
void GenBuffers_State(GLsizei n, GLuint* buffers) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenBuffers_State", "n must be non-negative"));
|
||||
return;
|
||||
}
|
||||
auto bufferNames = MG_State::pGLContext->GenBufferNames(n);
|
||||
Copy(bufferNames.data(), buffers, bufferNames.size());
|
||||
}
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
GLboolean IsBuffer_State(GLuint buffer) {
|
||||
if (buffer == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsBuffer_State",
|
||||
"Buffer name 0 is not a valid buffer object."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BufferImpl::ValidateBufferName(buffer)) return GL_FALSE;
|
||||
return MG_State::pGLContext->ValidateBufferObject(buffer) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
SizeT bufferSize = bufferObject->GetSize();
|
||||
Range1D mappedRange = bufferObject->GetMappedRange();
|
||||
if ((offset < mappedRange.end) && (offset + size > mappedRange.start)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Offset and size must not overlap with the mapped range of the buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||
GLboolean IsBuffer(GLuint buffer) {
|
||||
return IsBuffer_State(buffer);
|
||||
}
|
||||
|
||||
void DeleteBuffers(GLsizei n, const GLuint* buffers) {
|
||||
DeleteBuffers_State(n, buffers);
|
||||
}
|
||||
|
||||
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) {
|
||||
FlushMappedBufferRange_State(target, offset, length);
|
||||
}
|
||||
|
||||
GLboolean UnmapBuffer(GLenum target) {
|
||||
return UnmapBuffer_State(target);
|
||||
}
|
||||
|
||||
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
return MapBufferRange_State(target, offset, length, access);
|
||||
}
|
||||
|
||||
void* MapBuffer(GLenum target, GLenum access) {
|
||||
return MapBuffer_State(target, access);
|
||||
}
|
||||
|
||||
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
|
||||
CopyBufferSubData_State(readTarget, writeTarget, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
BufferSubData_State(target, offset, size, data);
|
||||
}
|
||||
|
||||
void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
|
||||
BufferData_State(target, size, data, usage);
|
||||
}
|
||||
|
||||
void BindBuffer(GLenum target, GLuint buffer) {
|
||||
BindBuffer_State(target, buffer);
|
||||
}
|
||||
|
||||
void GenBuffers(GLsizei n, GLuint* buffers) {
|
||||
GenBuffers_State(n, buffers);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto mappingAccess = bufferObject->GetMappingAccess();
|
||||
if (bufferObject->IsMapped() && !(mappingAccess & BufferMappingAccessBit::Persistent)) {
|
||||
Range1D mappedRange = bufferObject->GetMappedRange();
|
||||
if (offset + size >= mappedRange.start) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "BufferSubData_State",
|
||||
"Cannot modify a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bufferObject->UploadSubData({(void*)data, (SizeT)size}, offset);
|
||||
}
|
||||
|
||||
void BufferData_State(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
|
||||
if (size < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferData_State", "Size must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
BufferUsage bufferUsage = MG_Util::ConvertGLEnumToBufferUsage(usage);
|
||||
if (!BufferImpl::ValidateBufferUsage(bufferUsage)) return;
|
||||
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
|
||||
auto bufferObject = bindingSlot.GetBoundObject();
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferData_State",
|
||||
"Buffer target is bound to no buffer object."));
|
||||
return;
|
||||
}
|
||||
|
||||
bufferObject->SetUsage(bufferUsage);
|
||||
bufferObject->Resize(size);
|
||||
if (data) {
|
||||
bufferObject->UploadData({(void*)data, (SizeT)size}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void BindBuffer_State(GLenum target, GLuint buffer) {
|
||||
if (buffer != 0 && !BufferImpl::ValidateBufferName(buffer)) return;
|
||||
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
|
||||
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
|
||||
|
||||
auto bufferObject = MG_State::pGLContext->GetBufferObject(buffer);
|
||||
if (!bufferObject) {
|
||||
MG_State::pGLContext->CreateBufferObject(buffer);
|
||||
bufferObject = MG_State::pGLContext->GetBufferObject(buffer);
|
||||
}
|
||||
|
||||
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
|
||||
bindingSlot.Bind(bufferObject);
|
||||
}
|
||||
|
||||
void GenBuffers_State(GLsizei n, GLuint* buffers) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenBuffers_State", "n must be non-negative"));
|
||||
return;
|
||||
}
|
||||
auto bufferNames = MG_State::pGLContext->GenBufferNames(n);
|
||||
Copy(bufferNames.data(), buffers, bufferNames.size());
|
||||
}
|
||||
|
||||
GLboolean IsBuffer_State(GLuint buffer) {
|
||||
if (buffer == 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsBuffer_State",
|
||||
"Buffer name 0 is not a valid buffer object."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (!BufferImpl::ValidateBufferName(buffer)) return GL_FALSE;
|
||||
return MG_State::pGLContext->ValidateBufferObject(buffer) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||
GLboolean IsBuffer(GLuint buffer) {
|
||||
return IsBuffer_State(buffer);
|
||||
}
|
||||
|
||||
void DeleteBuffers(GLsizei n, const GLuint* buffers) {
|
||||
DeleteBuffers_State(n, buffers);
|
||||
}
|
||||
|
||||
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) {
|
||||
FlushMappedBufferRange_State(target, offset, length);
|
||||
}
|
||||
|
||||
GLboolean UnmapBuffer(GLenum target) {
|
||||
return UnmapBuffer_State(target);
|
||||
}
|
||||
|
||||
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
return MapBufferRange_State(target, offset, length, access);
|
||||
}
|
||||
|
||||
void* MapBuffer(GLenum target, GLenum access) {
|
||||
return MapBuffer_State(target, access);
|
||||
}
|
||||
|
||||
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset,
|
||||
GLsizeiptr size) {
|
||||
CopyBufferSubData_State(readTarget, writeTarget, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
|
||||
BufferSubData_State(target, offset, size, data);
|
||||
}
|
||||
|
||||
void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
|
||||
BufferData_State(target, size, data, usage);
|
||||
}
|
||||
|
||||
void BindBuffer(GLenum target, GLuint buffer) {
|
||||
BindBuffer_State(target, buffer);
|
||||
}
|
||||
|
||||
void GenBuffers(GLsizei n, GLuint* buffers) {
|
||||
GenBuffers_State(n, buffers);
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
GLboolean IsBuffer(GLuint buffer);
|
||||
void DeleteBuffers(GLsizei n, const GLuint* buffers);
|
||||
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
|
||||
GLboolean UnmapBuffer(GLenum target);
|
||||
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
void* MapBuffer(GLenum target, GLenum access);
|
||||
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
|
||||
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
|
||||
void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage);
|
||||
void BindBuffer(GLenum target, GLuint buffer);
|
||||
void GenBuffers(GLsizei n, GLuint* buffers);
|
||||
}
|
||||
}
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
GLboolean IsBuffer(GLuint buffer);
|
||||
void DeleteBuffers(GLsizei n, const GLuint* buffers);
|
||||
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
|
||||
GLboolean UnmapBuffer(GLenum target);
|
||||
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
void* MapBuffer(GLenum target, GLenum access);
|
||||
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset,
|
||||
GLsizeiptr size);
|
||||
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
|
||||
void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage);
|
||||
void BindBuffer(GLenum target, GLuint buffer);
|
||||
void GenBuffers(GLsizei n, GLuint* buffers);
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,79 +1,84 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToGL/BufferEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToStr/BufferEnumConverter.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target) {
|
||||
if (target == BufferTarget::Unknown) {
|
||||
using namespace MG_Util;
|
||||
String bufferTargetStr = ConvertBufferTargetToString(target);
|
||||
String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
|
||||
std::format("Target {} ({}) is not valid.",
|
||||
bufferTargetStr, glTargetStr)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target == BufferTarget::Index && MG_State::pGLContext->GetBoundVertexArray() == nullptr) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
|
||||
"No vertex array object is bound."));
|
||||
return false;
|
||||
}
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target) {
|
||||
if (target == BufferTarget::Unknown) {
|
||||
using namespace MG_Util;
|
||||
String bufferTargetStr = ConvertBufferTargetToString(target);
|
||||
String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
|
||||
std::format("Target {} ({}) is not valid.", bufferTargetStr, glTargetStr)));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
if (target == BufferTarget::Index && MG_State::pGLContext->GetBoundVertexArray() == nullptr) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl",
|
||||
"ValidateBufferTarget",
|
||||
"No vertex array object is bound."));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateBufferName(Uint index) {
|
||||
bool isValid = MG_State::pGLContext->ValidateBufferName(index);
|
||||
if (isValid)
|
||||
return true;
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferName",
|
||||
std::format("Buffer name {} is not valid.", index)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateBufferUsage(BufferUsage usage) {
|
||||
if (usage != BufferUsage::Unknown) {
|
||||
return true;
|
||||
}
|
||||
using namespace MG_Util;
|
||||
String bufferUsageStr = ConvertBufferUsageToString(usage);
|
||||
String glUsageStr = ConvertGLEnumToString(ConvertBufferUsageToGLEnum(usage));
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferUsage",
|
||||
std::format("Usage {} ({}) is not one of the allowable values.",
|
||||
bufferUsageStr, glUsageStr)));
|
||||
return false;
|
||||
}
|
||||
bool ValidateBufferName(Uint index) {
|
||||
bool isValid = MG_State::pGLContext->ValidateBufferName(index);
|
||||
if (isValid) return true;
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferName",
|
||||
std::format("Buffer name {} is not valid.", index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits) {
|
||||
if (accessBits == BufferMappingAccessBit::Null) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess",
|
||||
"Access bits cannot be null."));
|
||||
return false;
|
||||
}
|
||||
bool ValidateBufferUsage(BufferUsage usage) {
|
||||
if (usage != BufferUsage::Unknown) {
|
||||
return true;
|
||||
}
|
||||
using namespace MG_Util;
|
||||
String bufferUsageStr = ConvertBufferUsageToString(usage);
|
||||
String glUsageStr = ConvertGLEnumToString(ConvertBufferUsageToGLEnum(usage));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl/BufferImpl", "ValidateBufferUsage",
|
||||
std::format("Usage {} ({}) is not one of the allowable values.", bufferUsageStr, glUsageStr)));
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto validBits =
|
||||
BufferMappingAccessBit::Read |
|
||||
BufferMappingAccessBit::Write |
|
||||
BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::FlushExplicit |
|
||||
BufferMappingAccessBit::Unsynchronized |
|
||||
BufferMappingAccessBit::Persistent |
|
||||
BufferMappingAccessBit::Coherent;
|
||||
bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits) {
|
||||
if (accessBits == BufferMappingAccessBit::Null) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl",
|
||||
"ValidateBufferMappingAccess",
|
||||
"Access bits cannot be null."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((accessBits & validBits) != accessBits) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess",
|
||||
"Access bits cannot contain invalid flags."));
|
||||
return false;
|
||||
}
|
||||
const auto validBits = BufferMappingAccessBit::Read | BufferMappingAccessBit::Write |
|
||||
BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer |
|
||||
BufferMappingAccessBit::FlushExplicit | BufferMappingAccessBit::Unsynchronized |
|
||||
BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((accessBits & validBits) != accessBits) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess",
|
||||
"Access bits cannot contain invalid flags."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace BufferImpl
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target);
|
||||
bool ValidateBufferName(Uint index);
|
||||
bool ValidateBufferUsage(BufferUsage usage);
|
||||
bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits);
|
||||
}
|
||||
}
|
||||
namespace BufferImpl {
|
||||
bool ValidateBufferTarget(BufferTarget target);
|
||||
bool ValidateBufferName(Uint index);
|
||||
bool ValidateBufferUsage(BufferUsage usage);
|
||||
bool ValidateBufferMappingAccess(Flags<BufferMappingAccessBit> accessBits);
|
||||
} // namespace BufferImpl
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -1,4 +1,8 @@
|
||||
#include "../../../Includes.h"
|
||||
#include <Includes.h>
|
||||
#include "../Buffer/GL_Buffer.h"
|
||||
#include "../VertexArray/GL_VertexArray.h"
|
||||
#include "../Getter/GL_Getter.h"
|
||||
#include "../Program/GL_Program.h"
|
||||
|
||||
#define DECLARE_GL_FUNCTION_STUB_HEAD(type,name,...) \
|
||||
MOBILEGL_GL_API type gl##name(__VA_ARGS__) {
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GL_Getter.h"
|
||||
#include <Config.h>
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_Util/Converters/MGToGL/ErrorCodeConverter.h>
|
||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToStr/GLExtensionConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||
const GLubyte* GetString(GLenum name) {
|
||||
static String vendorString;
|
||||
@@ -14,40 +19,37 @@ namespace MobileGL {
|
||||
case GL_VENDOR:
|
||||
if (vendorString.empty()) {
|
||||
if (MG_Config::RendererInfoPtr->ExtraVendor.has_value()) {
|
||||
vendorString = std::format("{}{}",
|
||||
MG_Config::CoreVendor, MG_Config::RendererInfoPtr->ExtraVendor.value());
|
||||
vendorString =
|
||||
std::format("{}{}", MG_Config::CoreVendor, MG_Config::RendererInfoPtr->ExtraVendor.value());
|
||||
} else {
|
||||
vendorString = MG_Config::CoreVendor;
|
||||
vendorString = MG_Config::CoreVendor;
|
||||
}
|
||||
}
|
||||
return (const GLubyte*)vendorString.c_str();
|
||||
case GL_VERSION: {
|
||||
if (versionStr.empty()) {
|
||||
versionStr = std::format("{} {}, {} Backend, Version {}",
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
||||
MG_Config::ProjectName.c_str(),
|
||||
MG_Config::RendererInfoPtr->BackendName.c_str(),
|
||||
MG_Config::CoreVersion.toString().c_str());
|
||||
versionStr =
|
||||
std::format("{} {}, {} Backend, Version {}",
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
||||
MG_Config::ProjectName.c_str(), MG_Config::RendererInfoPtr->BackendName.c_str(),
|
||||
MG_Config::CoreVersion.toString().c_str());
|
||||
}
|
||||
return (const GLubyte*)versionStr.c_str();
|
||||
}
|
||||
|
||||
case GL_RENDERER:
|
||||
{
|
||||
case GL_RENDERER: {
|
||||
if (rendererString.empty()) {
|
||||
String deviceInfo;
|
||||
rendererString = std::format("{} ({}) ({})",
|
||||
MG_Config::RendererInfoPtr->RendererName.c_str(),
|
||||
MG_Config::CoreName.c_str(),
|
||||
deviceInfo);
|
||||
rendererString = std::format("{} ({}) ({})", MG_Config::RendererInfoPtr->RendererName.c_str(),
|
||||
MG_Config::CoreName.c_str(), deviceInfo);
|
||||
}
|
||||
return (const GLubyte*)rendererString.c_str();
|
||||
}
|
||||
case GL_SHADING_LANGUAGE_VERSION:
|
||||
if (shadingLanguageVersion.empty()) {
|
||||
shadingLanguageVersion = std::format("{} MobileGL",
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString(
|
||||
{ true, false }).c_str());
|
||||
shadingLanguageVersion = std::format(
|
||||
"{} MobileGL",
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString({true, false}).c_str());
|
||||
}
|
||||
return (const GLubyte*)shadingLanguageVersion.c_str();
|
||||
case GL_EXTENSIONS:
|
||||
@@ -55,10 +57,10 @@ namespace MobileGL {
|
||||
for (auto& ext : MG_Config::RendererInfoPtr->RendererGLInfo.Extensions) {
|
||||
extensionsString += MG_Util::ConvertetGLExtToString(ext);
|
||||
extensionsString += " ";
|
||||
}
|
||||
}
|
||||
extensionsString.pop_back();
|
||||
}
|
||||
return (const GLubyte*)extensionsString.c_str();
|
||||
return (const GLubyte*)extensionsString.c_str();
|
||||
default:
|
||||
return (const GLubyte*)"Unknown enum";
|
||||
}
|
||||
@@ -88,7 +90,6 @@ namespace MobileGL {
|
||||
return (const GLubyte*)extStrings[index].c_str();
|
||||
}
|
||||
|
||||
|
||||
void GetIntegerv(GLenum pname, GLint* params) {
|
||||
MGLOG_D("glGetIntegerv, pname: %s", MG_Util::ConvertGLEnumToString(pname).c_str());
|
||||
if (!params) {
|
||||
@@ -101,8 +102,9 @@ namespace MobileGL {
|
||||
case GL_CONTEXT_FLAGS:
|
||||
params[0] = 0;
|
||||
case GL_CONTEXT_PROFILE_MASK:
|
||||
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.IsCompatibilityProfile ?
|
||||
GL_CONTEXT_COMPATIBILITY_PROFILE_BIT : GL_CONTEXT_CORE_PROFILE_BIT;
|
||||
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.IsCompatibilityProfile
|
||||
? GL_CONTEXT_COMPATIBILITY_PROFILE_BIT
|
||||
: GL_CONTEXT_CORE_PROFILE_BIT;
|
||||
break;
|
||||
case GL_NUM_EXTENSIONS:
|
||||
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.Extensions.size();
|
||||
@@ -113,22 +115,21 @@ namespace MobileGL {
|
||||
case GL_MINOR_VERSION:
|
||||
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Minor;
|
||||
break;
|
||||
|
||||
|
||||
// State
|
||||
// TODO
|
||||
|
||||
|
||||
// Others...
|
||||
default:
|
||||
MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)",
|
||||
MG_Util::ConvertGLEnumToString(pname).c_str(), pname);
|
||||
// TODO: Report GL_INVALID_ENUM.
|
||||
MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)", MG_Util::ConvertGLEnumToString(pname).c_str(), pname);
|
||||
// TODO: Report GL_INVALID_ENUM.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum GetError() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
const GLubyte* GetString(GLenum name);
|
||||
const GLubyte* GetStringi(GLenum name, GLuint index);
|
||||
void GetIntegerv(GLenum pname, GLint* params);
|
||||
GLenum GetError();
|
||||
}
|
||||
}
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
const GLubyte* GetString(GLenum name);
|
||||
const GLubyte* GetStringi(GLenum name, GLuint index);
|
||||
void GetIntegerv(GLenum pname, GLint* params);
|
||||
GLenum GetError();
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,260 +1,363 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GL_Program.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
void AttachShader_State(GLuint program, GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void BindAttribLocation_State(GLuint program, GLuint index, const GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void BindAttribLocation_State(GLuint program, GLuint index, const GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void CompileShader_State(GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLuint CreateProgram_State(void) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLuint CreateShader_State(GLenum type) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void DeleteProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void DeleteShader_State(GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void DetachShader_State(GLuint program, GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetActiveAttrib_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetActiveAttrib_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size,
|
||||
GLenum* type, GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetActiveUniform_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetActiveUniform_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size,
|
||||
GLenum* type, GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetAttachedShaders_State(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetAttachedShaders_State(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLint GetAttribLocation_State(GLuint program, const GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
GLint GetAttribLocation_State(GLuint program, const GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetProgramiv_State(GLuint program, GLenum pname, GLint *params) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetProgramiv_State(GLuint program, GLenum pname, GLint* params) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetProgramInfoLog_State(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetProgramInfoLog_State(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetShaderiv_State(GLuint shader, GLenum pname, GLint *params) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetShaderiv_State(GLuint shader, GLenum pname, GLint* params) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetShaderInfoLog_State(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetShaderInfoLog_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetShaderSource_State(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetShaderSource_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLint GetUniformLocation_State(GLuint program, const GLchar *name) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
GLint GetUniformLocation_State(GLuint program, const GLchar* name) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetUniformfv_State(GLuint program, GLint location, GLfloat *params) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetUniformfv_State(GLuint program, GLint location, GLfloat* params) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void GetUniformiv_State(GLuint program, GLint location, GLint *params) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void GetUniformiv_State(GLuint program, GLint location, GLint* params) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLboolean IsProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
GLboolean IsShader_State(GLuint shader) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void LinkProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void ShaderSource_State(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void ShaderSource_State(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void UseProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform1f_State(GLint location, GLfloat v0) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform2f_State(GLint location, GLfloat v0, GLfloat v1) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform3f_State(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform4f_State(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform1i_State(GLint location, GLint v0) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform2i_State(GLint location, GLint v0, GLint v1) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform3i_State(GLint location, GLint v0, GLint v1, GLint v2) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform4i_State(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform1fv_State(GLint location, GLsizei count, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform1fv_State(GLint location, GLsizei count, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform2fv_State(GLint location, GLsizei count, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform2fv_State(GLint location, GLsizei count, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform3fv_State(GLint location, GLsizei count, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform3fv_State(GLint location, GLsizei count, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform4fv_State(GLint location, GLsizei count, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform4fv_State(GLint location, GLsizei count, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform1iv_State(GLint location, GLsizei count, const GLint *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform1iv_State(GLint location, GLsizei count, const GLint* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform2iv_State(GLint location, GLsizei count, const GLint *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform2iv_State(GLint location, GLsizei count, const GLint* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform3iv_State(GLint location, GLsizei count, const GLint *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform3iv_State(GLint location, GLsizei count, const GLint* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void Uniform4iv_State(GLint location, GLsizei count, const GLint *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void Uniform4iv_State(GLint location, GLsizei count, const GLint* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void UniformMatrix2fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void UniformMatrix2fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void UniformMatrix3fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void UniformMatrix3fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void UniformMatrix4fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
void UniformMatrix4fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void ValidateProgram_State(GLuint program) {
|
||||
THROW_UNIMPL_EXCEPTION
|
||||
THROW_UNIMPL_EXCEPTION;
|
||||
}
|
||||
|
||||
void AttachShader(GLuint program, GLuint shader) {
|
||||
AttachShader_State(program, shader);
|
||||
}
|
||||
|
||||
void AttachShader(GLuint program, GLuint shader) { AttachShader_State(program, shader); }
|
||||
void BindAttribLocation(GLuint program, GLuint index, const GLchar *name) {
|
||||
void BindAttribLocation(GLuint program, GLuint index, const GLchar* name) {
|
||||
BindAttribLocation_State(program, index, name);
|
||||
}
|
||||
void CompileShader(GLuint shader) { CompileShader_State(shader); }
|
||||
GLuint CreateProgram(void) { return CreateProgram_State(); }
|
||||
GLuint CreateShader(GLenum type) { return CreateShader_State(type); }
|
||||
void DeleteProgram(GLuint program) { DeleteProgram_State(program); }
|
||||
void DeleteShader(GLuint shader) { DeleteShader_State(shader); }
|
||||
void DetachShader(GLuint program, GLuint shader) { DetachShader_State(program, shader); }
|
||||
void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) {
|
||||
|
||||
void CompileShader(GLuint shader) {
|
||||
CompileShader_State(shader);
|
||||
}
|
||||
GLuint CreateProgram(void) {
|
||||
return CreateProgram_State();
|
||||
}
|
||||
GLuint CreateShader(GLenum type) {
|
||||
return CreateShader_State(type);
|
||||
}
|
||||
|
||||
void DeleteProgram(GLuint program) {
|
||||
DeleteProgram_State(program);
|
||||
}
|
||||
|
||||
void DeleteShader(GLuint shader) {
|
||||
DeleteShader_State(shader);
|
||||
}
|
||||
|
||||
void DetachShader(GLuint program, GLuint shader) {
|
||||
DetachShader_State(program, shader);
|
||||
}
|
||||
|
||||
void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type,
|
||||
GLchar* name) {
|
||||
GetActiveAttrib_State(program, index, bufSize, length, size, type, name);
|
||||
}
|
||||
void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) {
|
||||
|
||||
void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type,
|
||||
GLchar* name) {
|
||||
GetActiveUniform_State(program, index, bufSize, length, size, type, name);
|
||||
}
|
||||
void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) {
|
||||
|
||||
void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) {
|
||||
GetAttachedShaders_State(program, maxCount, count, shaders);
|
||||
}
|
||||
GLint GetAttribLocation(GLuint program, const GLchar *name) {
|
||||
GLint GetAttribLocation(GLuint program, const GLchar* name) {
|
||||
GetAttribLocation_State(program, name);
|
||||
}
|
||||
void GetProgramiv(GLuint program, GLenum pname, GLint *params) {
|
||||
|
||||
void GetProgramiv(GLuint program, GLenum pname, GLint* params) {
|
||||
GetProgramiv_State(program, pname, params);
|
||||
}
|
||||
void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
|
||||
|
||||
void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||
GetProgramInfoLog_State(program, bufSize, length, infoLog);
|
||||
}
|
||||
void GetShaderiv(GLuint shader, GLenum pname, GLint *params) {
|
||||
|
||||
void GetShaderiv(GLuint shader, GLenum pname, GLint* params) {
|
||||
GetShaderiv_State(shader, pname, params);
|
||||
}
|
||||
void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
|
||||
|
||||
void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
||||
GetShaderInfoLog_State(shader, bufSize, length, infoLog);
|
||||
}
|
||||
void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) {
|
||||
|
||||
void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) {
|
||||
GetShaderSource_State(shader, bufSize, length, source);
|
||||
}
|
||||
GLint GetUniformLocation(GLuint program, const GLchar *name) {
|
||||
GLint GetUniformLocation(GLuint program, const GLchar* name) {
|
||||
GetUniformLocation_State(program, name);
|
||||
}
|
||||
void GetUniformfv(GLuint program, GLint location, GLfloat *params) {
|
||||
|
||||
void GetUniformfv(GLuint program, GLint location, GLfloat* params) {
|
||||
GetUniformfv_State(program, location, params);
|
||||
}
|
||||
void GetUniformiv(GLuint program, GLint location, GLint *params) {
|
||||
|
||||
void GetUniformiv(GLuint program, GLint location, GLint* params) {
|
||||
GetUniformiv_State(program, location, params);
|
||||
}
|
||||
GLboolean IsProgram(GLuint program) { return IsProgram_State(program); }
|
||||
GLboolean IsShader(GLuint shader) { return IsShader_State(shader); }
|
||||
void LinkProgram(GLuint program) { LinkProgram_State(program); }
|
||||
void ShaderSource(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length) {
|
||||
GLboolean IsProgram(GLuint program) {
|
||||
return IsProgram_State(program);
|
||||
}
|
||||
GLboolean IsShader(GLuint shader) {
|
||||
return IsShader_State(shader);
|
||||
}
|
||||
|
||||
void LinkProgram(GLuint program) {
|
||||
LinkProgram_State(program);
|
||||
}
|
||||
|
||||
void ShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
|
||||
ShaderSource_State(shader, count, string, length);
|
||||
}
|
||||
void UseProgram(GLuint program) { UseProgram_State(program); }
|
||||
void Uniform1f(GLint location, GLfloat v0) { Uniform1f_State(location, v0); }
|
||||
void Uniform2f(GLint location, GLfloat v0, GLfloat v1) { Uniform2f_State(location, v0, v1); }
|
||||
void Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) { Uniform3f_State(location, v0, v1, v2); }
|
||||
void Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
||||
void Uniform1i(GLint location, GLint v0) { Uniform1i_State(location, v0); }
|
||||
void Uniform2i(GLint location, GLint v0, GLint v1) { Uniform2i_State(location, v0, v1); }
|
||||
void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) { Uniform3i_State(location, v0, v1, v2); }
|
||||
void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { Uniform4i_State(location, v0, v1, v2, v3); }
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat *value) { Uniform1fv_State(location, count, value); }
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat *value) { Uniform2fv_State(location, count, value); }
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat *value) { Uniform3fv_State(location, count, value); }
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat *value) { Uniform4fv_State(location, count, value); }
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint *value) { Uniform1iv_State(location, count, value); }
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint *value) { Uniform2iv_State(location, count, value); }
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint *value) { Uniform3iv_State(location, count, value); }
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint *value) { Uniform4iv_State(location, count, value); }
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix2fv_State(location, count, transpose, value); }
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix3fv_State(location, count, transpose, value); }
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix4fv_State(location, count, transpose, value); }
|
||||
void ValidateProgram(GLuint program) { ValidateProgram_State(program); }
|
||||
}
|
||||
}
|
||||
|
||||
void UseProgram(GLuint program) {
|
||||
UseProgram_State(program);
|
||||
}
|
||||
|
||||
void Uniform1f(GLint location, GLfloat v0) {
|
||||
Uniform1f_State(location, v0);
|
||||
}
|
||||
|
||||
void Uniform2f(GLint location, GLfloat v0, GLfloat v1) {
|
||||
Uniform2f_State(location, v0, v1);
|
||||
}
|
||||
|
||||
void Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
|
||||
Uniform3f_State(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
|
||||
Uniform4f_State(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void Uniform1i(GLint location, GLint v0) {
|
||||
Uniform1i_State(location, v0);
|
||||
}
|
||||
|
||||
void Uniform2i(GLint location, GLint v0, GLint v1) {
|
||||
Uniform2i_State(location, v0, v1);
|
||||
}
|
||||
|
||||
void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) {
|
||||
Uniform3i_State(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
|
||||
Uniform4i_State(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
Uniform1fv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
Uniform2fv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
Uniform3fv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
Uniform4fv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint* value) {
|
||||
Uniform1iv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint* value) {
|
||||
Uniform2iv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint* value) {
|
||||
Uniform3iv_State(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint* value) {
|
||||
Uniform4iv_State(location, count, value);
|
||||
}
|
||||
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
UniformMatrix2fv_State(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
UniformMatrix3fv_State(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
UniformMatrix4fv_State(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void ValidateProgram(GLuint program) {
|
||||
ValidateProgram_State(program);
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -1,31 +1,34 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
void AttachShader(GLuint program, GLuint shader);
|
||||
void BindAttribLocation(GLuint program, GLuint index, const GLchar *name);
|
||||
void BindAttribLocation(GLuint program, GLuint index, const GLchar* name);
|
||||
void CompileShader(GLuint shader);
|
||||
GLuint CreateProgram(void);
|
||||
GLuint CreateShader(GLenum type);
|
||||
void DeleteProgram(GLuint program);
|
||||
void DeleteShader(GLuint shader);
|
||||
void DetachShader(GLuint program, GLuint shader);
|
||||
void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
|
||||
void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
|
||||
void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
|
||||
GLint GetAttribLocation(GLuint program, const GLchar *name);
|
||||
void GetProgramiv(GLuint program, GLenum pname, GLint *params);
|
||||
void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
void GetShaderiv(GLuint shader, GLenum pname, GLint *params);
|
||||
void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
|
||||
GLint GetUniformLocation(GLuint program, const GLchar *name);
|
||||
void GetUniformfv(GLuint program, GLint location, GLfloat *params);
|
||||
void GetUniformiv(GLuint program, GLint location, GLint *params);
|
||||
void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type,
|
||||
GLchar* name);
|
||||
void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type,
|
||||
GLchar* name);
|
||||
void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders);
|
||||
GLint GetAttribLocation(GLuint program, const GLchar* name);
|
||||
void GetProgramiv(GLuint program, GLenum pname, GLint* params);
|
||||
void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
|
||||
void GetShaderiv(GLuint shader, GLenum pname, GLint* params);
|
||||
void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
|
||||
void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source);
|
||||
GLint GetUniformLocation(GLuint program, const GLchar* name);
|
||||
void GetUniformfv(GLuint program, GLint location, GLfloat* params);
|
||||
void GetUniformiv(GLuint program, GLint location, GLint* params);
|
||||
GLboolean IsProgram(GLuint program);
|
||||
GLboolean IsShader(GLuint shader);
|
||||
void LinkProgram(GLuint program);
|
||||
void ShaderSource(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
|
||||
void ShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
|
||||
void UseProgram(GLuint program);
|
||||
void Uniform1f(GLint location, GLfloat v0);
|
||||
void Uniform2f(GLint location, GLfloat v0, GLfloat v1);
|
||||
@@ -35,17 +38,17 @@ namespace MobileGL {
|
||||
void Uniform2i(GLint location, GLint v0, GLint v1);
|
||||
void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2);
|
||||
void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat *value);
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat *value);
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat *value);
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat *value);
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint *value);
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint *value);
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint *value);
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint *value);
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat* value);
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat* value);
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat* value);
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat* value);
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint* value);
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint* value);
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint* value);
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint* value);
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void ValidateProgram(GLuint program);
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GL_VertexArray.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_Util/Converters/GLToMG/DataTypeConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
namespace MG_Impl::GLImpl {
|
||||
void DisableVertexAttribArray_State(GLuint index) {
|
||||
if (!VertexArrayImpl::ValidateVertexAttributeIndex(index)) return;
|
||||
|
||||
auto vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (!vao) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "EnableVertexAttribArray_State",
|
||||
"No vertex array object is bound."));
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"EnableVertexAttribArray_State",
|
||||
"No vertex array object is bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,8 +27,9 @@ namespace MobileGL {
|
||||
auto vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (!vao) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "EnableVertexAttribArray_State",
|
||||
"No vertex array object is bound."));
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"EnableVertexAttribArray_State",
|
||||
"No vertex array object is bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,17 +46,19 @@ namespace MobileGL {
|
||||
auto vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (!vao) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "VertexAttribPointer_State",
|
||||
"No vertex array object is bound."));
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"VertexAttribPointer_State",
|
||||
"No vertex array object is bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto& vboSlot = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Vertex);
|
||||
auto vbo = vboSlot.GetBoundObject();
|
||||
if (!vbo) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "VertexAttribPointer_State",
|
||||
"No buffer is bound to GL_ARRAY_BUFFER."));
|
||||
"No buffer is bound to GL_ARRAY_BUFFER."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,27 +68,30 @@ namespace MobileGL {
|
||||
vao->BindAttributeBuffer(index, vbo);
|
||||
}
|
||||
|
||||
// TODO: Implement GL_BGRA support
|
||||
void VertexAttribPointer_State(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) {
|
||||
// TODO: Implement GL_BGRA support
|
||||
void VertexAttribPointer_State(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
|
||||
const void* pointer) {
|
||||
if (!VertexArrayImpl::ValidateVertexAttributeIndex(index)) return;
|
||||
|
||||
DataType dataType = MG_Util::ConvertGLEnumToDataType(type);
|
||||
DataType dataType = MG_Util::ConvertGLEnumToDataType(type);
|
||||
if (!VertexArrayImpl::ValidateVertexAttribPointerParams(index, size, dataType, stride)) return;
|
||||
|
||||
auto vao = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (!vao) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "VertexAttribPointer_State",
|
||||
"No vertex array object is bound."));
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
|
||||
"VertexAttribPointer_State",
|
||||
"No vertex array object is bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto& vboSlot = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Vertex);
|
||||
auto vbo = vboSlot.GetBoundObject();
|
||||
if (!vbo) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "VertexAttribPointer_State",
|
||||
"No buffer is bound to GL_ARRAY_BUFFER."));
|
||||
"No buffer is bound to GL_ARRAY_BUFFER."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,9 +118,9 @@ namespace MobileGL {
|
||||
|
||||
void DeleteVertexArrays_State(GLsizei n, const GLuint* arrays) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteVertexArrays_State",
|
||||
"n must be non-negative."));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteVertexArrays_State",
|
||||
"n must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,8 +131,7 @@ namespace MobileGL {
|
||||
if (!VertexArrayImpl::ValidateVertexArrayName(vao)) continue;
|
||||
|
||||
if (MG_State::pGLContext->GetBoundVertexArray() &&
|
||||
MG_State::pGLContext->GetBoundVertexArray() ==
|
||||
MG_State::pGLContext->GetVertexArrayObject(vao)) {
|
||||
MG_State::pGLContext->GetBoundVertexArray() == MG_State::pGLContext->GetVertexArrayObject(vao)) {
|
||||
MG_State::pGLContext->BindVertexArray(0);
|
||||
}
|
||||
|
||||
@@ -131,64 +141,66 @@ namespace MobileGL {
|
||||
|
||||
void GenVertexArrays_State(GLsizei n, GLuint* arrays) {
|
||||
if (n < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenVertexArrays_State",
|
||||
"n must be non-negative."));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenVertexArrays_State", "n must be non-negative."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto vaoNames = MG_State::pGLContext->GenVertexArrayNames(n);
|
||||
Copy(vaoNames.data(), arrays, vaoNames.size());
|
||||
}
|
||||
|
||||
|
||||
GLboolean IsVertexArray_State(GLuint array) {
|
||||
if (array == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsVertexArray_State",
|
||||
"Vertex array name 0 is not supported."));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsVertexArray_State",
|
||||
"Vertex array name 0 is not supported."));
|
||||
return GL_FALSE;
|
||||
}
|
||||
if (!VertexArrayImpl::ValidateVertexArrayName(array)) return GL_FALSE;
|
||||
if (!MG_State::pGLContext->ValidateVertexArrayObject(array)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "IsVertexArray_State",
|
||||
std::format("Vertex array object {} does not exist.", array)));
|
||||
std::format("Vertex array object {} does not exist.", array)));
|
||||
return GL_FALSE;
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
|
||||
GLboolean IsVertexArray(GLuint array) {
|
||||
return IsVertexArray_State(array);
|
||||
}
|
||||
|
||||
|
||||
void DisableVertexAttribArray(GLuint index) {
|
||||
DisableVertexAttribArray_State(index);
|
||||
DisableVertexAttribArray_State(index);
|
||||
}
|
||||
|
||||
|
||||
void EnableVertexAttribArray(GLuint index) {
|
||||
EnableVertexAttribArray_State(index);
|
||||
EnableVertexAttribArray_State(index);
|
||||
}
|
||||
|
||||
|
||||
void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer) {
|
||||
VertexAttribIPointer_State(index, size, type, stride, pointer);
|
||||
VertexAttribIPointer_State(index, size, type, stride, pointer);
|
||||
}
|
||||
|
||||
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) {
|
||||
VertexAttribPointer_State(index, size, type, normalized, stride, pointer);
|
||||
|
||||
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
|
||||
const void* pointer) {
|
||||
VertexAttribPointer_State(index, size, type, normalized, stride, pointer);
|
||||
}
|
||||
|
||||
|
||||
void BindVertexArray(GLuint array) {
|
||||
BindVertexArray_State(array);
|
||||
BindVertexArray_State(array);
|
||||
}
|
||||
|
||||
|
||||
void DeleteVertexArrays(GLsizei n, const GLuint* arrays) {
|
||||
DeleteVertexArrays_State(n, arrays);
|
||||
DeleteVertexArrays_State(n, arrays);
|
||||
}
|
||||
|
||||
|
||||
void GenVertexArrays(GLsizei n, GLuint* arrays) {
|
||||
GenVertexArrays_State(n, arrays);
|
||||
GenVertexArrays_State(n, arrays);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
namespace MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
GLboolean IsVertexArray(GLuint array);
|
||||
void DisableVertexAttribArray(GLuint index);
|
||||
void EnableVertexAttribArray(GLuint index);
|
||||
void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);
|
||||
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer);
|
||||
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
|
||||
const void* pointer);
|
||||
void BindVertexArray(GLuint array);
|
||||
void DeleteVertexArrays(GLsizei n, const GLuint* arrays);
|
||||
void GenVertexArrays(GLsizei n, GLuint* arrays);
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,31 +1,37 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_Util/Converters/MGToGL/DataTypeConverter.h>
|
||||
#include <MG_Util/Converters/MGToStr/DataTypeConverter.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace VertexArrayImpl {
|
||||
namespace VertexArrayImpl {
|
||||
|
||||
bool ValidateVertexArrayName(Uint index) {
|
||||
if (index == 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
|
||||
"Vertex array name 0 is not supported."));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
|
||||
"Vertex array name 0 is not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool isValid = MG_State::pGLContext->ValidateVertexArrayName(index);
|
||||
if (!isValid) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
if (!isValid) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
|
||||
std::format("Vertex array name {} is not valid.", index)));
|
||||
std::format("Vertex array name {} is not valid.", index)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateVertexArrayObject(Uint index) {
|
||||
if (!MG_State::pGLContext->ValidateVertexArrayObject(index)) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayObject",
|
||||
std::format("Vertex array object {} does not exist.", index)));
|
||||
std::format("Vertex array object {} does not exist.", index)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -33,10 +39,12 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
bool ValidateVertexAttributeIndex(Uint index) {
|
||||
if (index >= MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexAttributeIndex",
|
||||
std::format("Attribute index {} exceeds maximum of {}.",
|
||||
index, MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS - 1)));
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateVertexAttributeIndex",
|
||||
std::format("Attribute index {} exceeds maximum of {}.", index,
|
||||
MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS - 1)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -44,27 +52,33 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
|
||||
bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride) {
|
||||
if (size < 1 || size > 4) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
std::format("Invalid size {} for attribute {}. Must be 1-4.", size, index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type == DataType::Unknown) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidEnum,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
std::format("Invalid type {} for attribute {}.", MG_Util::ConvertDataTypeToString(type).c_str(), index)));
|
||||
std::format("Invalid type {} for attribute {}.",
|
||||
MG_Util::ConvertDataTypeToString(type).c_str(), index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stride < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeShared<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", "ValidateVertexAttribPointerParams",
|
||||
std::format("Negative stride {} is not allowed for attribute {}.", stride, index)));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace VertexArrayImpl
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/VertexArrayState/VertexArrayObject.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace VertexArrayImpl {
|
||||
namespace VertexArrayImpl {
|
||||
bool ValidateVertexArrayName(Uint index);
|
||||
bool ValidateVertexArrayObject(Uint index);
|
||||
bool ValidateVertexAttributeIndex(Uint index);
|
||||
bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride);
|
||||
}
|
||||
}
|
||||
} // namespace VertexArrayImpl
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../../../Includes.h"
|
||||
#include <Includes.h>
|
||||
#include "../LookUp/LookUp.h"
|
||||
|
||||
MOBILEGL_GLX_API void* glXGetProcAddress(const char* name) {
|
||||
return MG_Impl::GLXImpl::GetProcAddress(name);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "LookUp.h"
|
||||
|
||||
namespace MG_Impl::GLXImpl {
|
||||
// TODO: Implement complete glx functionality
|
||||
// TODO: Implement complete GLX functionality
|
||||
|
||||
void* GetProcAddress(const char* name) {
|
||||
MGLOG_D("glXGetProcAddress(\"%s\")", name);
|
||||
@@ -18,4 +18,4 @@ namespace MG_Impl::GLXImpl {
|
||||
void* GetProcAddressARB(const char* name) {
|
||||
return GetProcAddress(name);
|
||||
}
|
||||
}
|
||||
} // namespace MG_Impl::GLXImpl
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MG_Impl {
|
||||
namespace GLXImpl {
|
||||
void* GetProcAddress(const char* name);
|
||||
void* GetProcAddressARB(const char* name);
|
||||
}
|
||||
}
|
||||
} // namespace GLXImpl
|
||||
} // namespace MG_Impl
|
||||
@@ -1,159 +1,155 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "BufferObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
BufferObject::BufferObject()
|
||||
: m_id(0), m_size(0), m_usage(BufferUsage::StaticDraw),
|
||||
m_isMapped(false), m_mappingAccess(BufferMappingAccessBit::Null),
|
||||
m_dirtyRange({ 0, 0 }), m_mappedRange({ 0, 0 }) {
|
||||
}
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
BufferObject::BufferObject()
|
||||
: m_id(0), m_size(0), m_usage(BufferUsage::StaticDraw), m_isMapped(false),
|
||||
m_mappingAccess(BufferMappingAccessBit::Null), m_dirtyRange({0, 0}), m_mappedRange({0, 0}) {}
|
||||
|
||||
void BufferObject::Resize(SizeT size) {
|
||||
m_size = size;
|
||||
m_data.reserve(std::bit_ceil(size)); // power-of-2 reserve
|
||||
m_data.resize(size);
|
||||
m_dirtyRange = { 0, 0 };
|
||||
}
|
||||
void BufferObject::Resize(SizeT size) {
|
||||
m_size = size;
|
||||
m_data.reserve(std::bit_ceil(size)); // power-of-2 reserve
|
||||
m_data.resize(size);
|
||||
m_dirtyRange = {0, 0};
|
||||
}
|
||||
|
||||
void BufferObject::UploadData(DataPtr data, SizeT atOffset) {
|
||||
assert(atOffset + data.size <= m_size);
|
||||
assert(!m_isMapped);
|
||||
memcpy(m_data.data() + atOffset, data.data, data.size);
|
||||
m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size);
|
||||
}
|
||||
void BufferObject::UploadData(DataPtr data, SizeT atOffset) {
|
||||
assert(atOffset + data.size <= m_size);
|
||||
assert(!m_isMapped);
|
||||
memcpy(m_data.data() + atOffset, data.data, data.size);
|
||||
m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size);
|
||||
}
|
||||
|
||||
void BufferObject::SetUsage(BufferUsage usage) {
|
||||
m_usage = usage;
|
||||
}
|
||||
void BufferObject::SetUsage(BufferUsage usage) {
|
||||
m_usage = usage;
|
||||
}
|
||||
|
||||
void BufferObject::ReleaseMemory() {
|
||||
if (!m_isMapped) return;
|
||||
void BufferObject::ReleaseMemory() {
|
||||
if (!m_isMapped) return;
|
||||
|
||||
if (m_mappingAccess & BufferMappingAccessBit::Write) { // if we wrote to the buffer
|
||||
if (!(m_mappingAccess & BufferMappingAccessBit::FlushExplicit)) { // if we didn't flush explicitly
|
||||
memcpy(m_data.data() + m_mappedRange.start,
|
||||
m_stagingData.data(),
|
||||
m_mappedRange.end - m_mappedRange.start);
|
||||
m_dirtyRange.UnionUpdate(m_mappedRange.start, m_mappedRange.end);
|
||||
}
|
||||
if (m_mappingAccess & BufferMappingAccessBit::Write) { // if we wrote to the buffer
|
||||
if (!(m_mappingAccess & BufferMappingAccessBit::FlushExplicit)) { // if we didn't flush explicitly
|
||||
memcpy(m_data.data() + m_mappedRange.start, m_stagingData.data(),
|
||||
m_mappedRange.end - m_mappedRange.start);
|
||||
m_dirtyRange.UnionUpdate(m_mappedRange.start, m_mappedRange.end);
|
||||
}
|
||||
|
||||
m_stagingData.clear();
|
||||
}
|
||||
m_stagingData.clear();
|
||||
}
|
||||
|
||||
m_isMapped = false;
|
||||
m_mappingAccess = BufferMappingAccessBit::Null;
|
||||
m_mappedRange = { 0, 0 };
|
||||
m_ownsStagingData = false;
|
||||
}
|
||||
m_isMapped = false;
|
||||
m_mappingAccess = BufferMappingAccessBit::Null;
|
||||
m_mappedRange = {0, 0};
|
||||
m_ownsStagingData = false;
|
||||
}
|
||||
|
||||
void BufferObject::FlushMemoryRange(SizeT offset, SizeT length) {
|
||||
assert(m_isMapped);
|
||||
assert((m_mappingAccess & BufferMappingAccessBit::FlushExplicit));
|
||||
assert((m_mappingAccess & BufferMappingAccessBit::Write));
|
||||
void BufferObject::FlushMemoryRange(SizeT offset, SizeT length) {
|
||||
assert(m_isMapped);
|
||||
assert((m_mappingAccess & BufferMappingAccessBit::FlushExplicit));
|
||||
assert((m_mappingAccess & BufferMappingAccessBit::Write));
|
||||
|
||||
SizeT start = m_mappedRange.start + offset;
|
||||
SizeT end = start + length;
|
||||
assert(end <= m_mappedRange.end);
|
||||
SizeT start = m_mappedRange.start + offset;
|
||||
SizeT end = start + length;
|
||||
assert(end <= m_mappedRange.end);
|
||||
|
||||
memcpy(m_data.data() + start, m_stagingData.data() + offset, length);
|
||||
m_dirtyRange.UnionUpdate(start, end);
|
||||
}
|
||||
memcpy(m_data.data() + start, m_stagingData.data() + offset, length);
|
||||
m_dirtyRange.UnionUpdate(start, end);
|
||||
}
|
||||
|
||||
void BufferObject::UploadSubData(DataPtr data, SizeT atOffset) {
|
||||
assert(!m_isMapped);
|
||||
assert(atOffset + data.size <= m_size);
|
||||
void BufferObject::UploadSubData(DataPtr data, SizeT atOffset) {
|
||||
assert(!m_isMapped);
|
||||
assert(atOffset + data.size <= m_size);
|
||||
|
||||
memcpy(m_data.data() + atOffset, data.data, data.size);
|
||||
m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size);
|
||||
}
|
||||
memcpy(m_data.data() + atOffset, data.data, data.size);
|
||||
m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size);
|
||||
}
|
||||
|
||||
void BufferObject::CopyDataFrom(const SharedPtr<BufferObject>& src, SizeT srcOffset, SizeT dstOffset, SizeT size) {
|
||||
assert(!m_isMapped);
|
||||
assert(!src->IsMapped());
|
||||
assert(srcOffset + size <= src->GetSize());
|
||||
assert(dstOffset + size <= m_size);
|
||||
void BufferObject::CopyDataFrom(const SharedPtr<BufferObject>& src, SizeT srcOffset, SizeT dstOffset,
|
||||
SizeT size) {
|
||||
assert(!m_isMapped);
|
||||
assert(!src->IsMapped());
|
||||
assert(srcOffset + size <= src->GetSize());
|
||||
assert(dstOffset + size <= m_size);
|
||||
|
||||
const Uint8* srcData = src->m_data.data() + srcOffset;
|
||||
memcpy(m_data.data() + dstOffset, srcData, size);
|
||||
m_dirtyRange.UnionUpdate(dstOffset, dstOffset + size);
|
||||
}
|
||||
const Uint8* srcData = src->m_data.data() + srcOffset;
|
||||
memcpy(m_data.data() + dstOffset, srcData, size);
|
||||
m_dirtyRange.UnionUpdate(dstOffset, dstOffset + size);
|
||||
}
|
||||
|
||||
void* BufferObject::AcquireMemory(Bool markMapped, Bool read, Bool write) {
|
||||
if (markMapped) {
|
||||
m_isMapped = true;
|
||||
auto a = BufferMappingAccessBit::Coherent | BufferMappingAccessBit::Read;
|
||||
m_mappingAccess =
|
||||
(read ? BufferMappingAccessBit::Read : BufferMappingAccessBit::Null) |
|
||||
(write ? BufferMappingAccessBit::Write : BufferMappingAccessBit::Null);
|
||||
m_mappedRange = { 0, m_size };
|
||||
void* BufferObject::AcquireMemory(Bool markMapped, Bool read, Bool write) {
|
||||
if (markMapped) {
|
||||
m_isMapped = true;
|
||||
auto a = BufferMappingAccessBit::Coherent | BufferMappingAccessBit::Read;
|
||||
m_mappingAccess = (read ? BufferMappingAccessBit::Read : BufferMappingAccessBit::Null) |
|
||||
(write ? BufferMappingAccessBit::Write : BufferMappingAccessBit::Null);
|
||||
m_mappedRange = {0, m_size};
|
||||
|
||||
if (m_mappingAccess & BufferMappingAccessBit::Write) {
|
||||
m_stagingData.resize(m_size);
|
||||
m_ownsStagingData = true;
|
||||
if (m_mappingAccess & BufferMappingAccessBit::Write) {
|
||||
m_stagingData.resize(m_size);
|
||||
m_ownsStagingData = true;
|
||||
|
||||
if (!(m_mappingAccess & (BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer))) {
|
||||
memcpy(m_stagingData.data(), m_data.data(), m_size);
|
||||
}
|
||||
if (!(m_mappingAccess &
|
||||
(BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer))) {
|
||||
memcpy(m_stagingData.data(), m_data.data(), m_size);
|
||||
}
|
||||
|
||||
return m_stagingData.data();
|
||||
}
|
||||
}
|
||||
return m_stagingData.data();
|
||||
}
|
||||
}
|
||||
|
||||
return m_data.data();
|
||||
}
|
||||
return m_data.data();
|
||||
}
|
||||
|
||||
void* BufferObject::AcquireMemoryRange(Range1D range, Flags<BufferMappingAccessBit> access) {
|
||||
assert(range.end <= m_size && range.start <= range.end);
|
||||
m_isMapped = true;
|
||||
m_mappingAccess = access;
|
||||
m_mappedRange = range;
|
||||
void* BufferObject::AcquireMemoryRange(Range1D range, Flags<BufferMappingAccessBit> access) {
|
||||
assert(range.end <= m_size && range.start <= range.end);
|
||||
m_isMapped = true;
|
||||
m_mappingAccess = access;
|
||||
m_mappedRange = range;
|
||||
|
||||
if (access & BufferMappingAccessBit::Write) {
|
||||
m_stagingData.resize(range.end - range.start);
|
||||
m_ownsStagingData = true;
|
||||
if (access & BufferMappingAccessBit::Write) {
|
||||
m_stagingData.resize(range.end - range.start);
|
||||
m_ownsStagingData = true;
|
||||
|
||||
if (!(access & (BufferMappingAccessBit::InvalidateRange |
|
||||
BufferMappingAccessBit::InvalidateBuffer))) {
|
||||
memcpy(m_stagingData.data(), m_data.data() + range.start, m_stagingData.size());
|
||||
}
|
||||
if (!(access &
|
||||
(BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer))) {
|
||||
memcpy(m_stagingData.data(), m_data.data() + range.start, m_stagingData.size());
|
||||
}
|
||||
|
||||
return m_stagingData.data();
|
||||
}
|
||||
else {
|
||||
m_ownsStagingData = false;
|
||||
return m_data.data() + range.start;
|
||||
}
|
||||
}
|
||||
return m_stagingData.data();
|
||||
} else {
|
||||
m_ownsStagingData = false;
|
||||
return m_data.data() + range.start;
|
||||
}
|
||||
}
|
||||
|
||||
void BufferObject::ClearDirty() {
|
||||
m_dirtyRange = { 0, 0 };
|
||||
}
|
||||
void BufferObject::ClearDirty() {
|
||||
m_dirtyRange = {0, 0};
|
||||
}
|
||||
|
||||
SizeT BufferObject::GetSize() const {
|
||||
return m_size;
|
||||
}
|
||||
SizeT BufferObject::GetSize() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
BufferUsage BufferObject::GetUsage() const {
|
||||
return m_usage;
|
||||
}
|
||||
BufferUsage BufferObject::GetUsage() const {
|
||||
return m_usage;
|
||||
}
|
||||
|
||||
Range1D BufferObject::GetDirtyRange() const {
|
||||
return m_dirtyRange;
|
||||
}
|
||||
Range1D BufferObject::GetDirtyRange() const {
|
||||
return m_dirtyRange;
|
||||
}
|
||||
|
||||
Bool BufferObject::IsMapped() const {
|
||||
return m_isMapped;
|
||||
}
|
||||
Bool BufferObject::IsMapped() const {
|
||||
return m_isMapped;
|
||||
}
|
||||
|
||||
Range1D BufferObject::GetMappedRange() const {
|
||||
return m_isMapped ? m_mappedRange : Range1D{ 0, 0 };
|
||||
}
|
||||
Range1D BufferObject::GetMappedRange() const {
|
||||
return m_isMapped ? m_mappedRange : Range1D{0, 0};
|
||||
}
|
||||
|
||||
Flags<BufferMappingAccessBit> BufferObject::GetMappingAccess() const {
|
||||
return m_isMapped ? m_mappingAccess : BufferMappingAccessBit::Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Flags<BufferMappingAccessBit> BufferObject::GetMappingAccess() const {
|
||||
return m_isMapped ? m_mappingAccess : BufferMappingAccessBit::Null;
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,106 +1,89 @@
|
||||
#pragma once
|
||||
#include "MG_Util/Types.h"
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
enum class BufferTarget {
|
||||
Vertex,
|
||||
Index,
|
||||
Uniform,
|
||||
CopyRead,
|
||||
CopyWrite,
|
||||
PixelPack,
|
||||
PixelUnpack,
|
||||
Query,
|
||||
Texture,
|
||||
TransformFeedback,
|
||||
AtomicCounter,
|
||||
DispatchIndirect,
|
||||
DrawIndirect,
|
||||
ShaderStorage,
|
||||
enum class BufferTarget {
|
||||
Vertex,
|
||||
Index,
|
||||
Uniform,
|
||||
CopyRead,
|
||||
CopyWrite,
|
||||
PixelPack,
|
||||
PixelUnpack,
|
||||
Query,
|
||||
Texture,
|
||||
TransformFeedback,
|
||||
AtomicCounter,
|
||||
DispatchIndirect,
|
||||
DrawIndirect,
|
||||
ShaderStorage,
|
||||
BufferTargetCount,
|
||||
Unknown = -1
|
||||
};
|
||||
Unknown = -1
|
||||
};
|
||||
|
||||
enum class BufferUsage {
|
||||
StreamDraw,
|
||||
StreamRead,
|
||||
StreamCopy,
|
||||
StaticDraw,
|
||||
StaticRead,
|
||||
StaticCopy,
|
||||
DynamicDraw,
|
||||
DynamicRead,
|
||||
DynamicCopy,
|
||||
Unknown = -1
|
||||
};
|
||||
enum class BufferUsage {
|
||||
StreamDraw,
|
||||
StreamRead,
|
||||
StreamCopy,
|
||||
StaticDraw,
|
||||
StaticRead,
|
||||
StaticCopy,
|
||||
DynamicDraw,
|
||||
DynamicRead,
|
||||
DynamicCopy,
|
||||
Unknown = -1
|
||||
};
|
||||
|
||||
enum class BufferMappingAccessBit : Uint {
|
||||
Null = 0x00,
|
||||
Read = 0x01,
|
||||
Write = 0x02,
|
||||
InvalidateRange = 0x04,
|
||||
InvalidateBuffer = 0x08,
|
||||
FlushExplicit = 0x10,
|
||||
Unsynchronized = 0x20,
|
||||
Persistent = 0x40,
|
||||
Coherent = 0x80
|
||||
};
|
||||
enum class BufferMappingAccessBit : Uint {
|
||||
Null = 0x00,
|
||||
Read = 0x01,
|
||||
Write = 0x02,
|
||||
InvalidateRange = 0x04,
|
||||
InvalidateBuffer = 0x08,
|
||||
FlushExplicit = 0x10,
|
||||
Unsynchronized = 0x20,
|
||||
Persistent = 0x40,
|
||||
Coherent = 0x80
|
||||
};
|
||||
|
||||
// inline Flags<BufferMappingAccessBit> operator|(BufferMappingAccessBit a, const BufferMappingAccessBit b) {
|
||||
// return Flags(a) | b;
|
||||
// }
|
||||
//
|
||||
// inline BufferMappingAccessBit& operator|=(BufferMappingAccessBit& a, BufferMappingAccessBit b) {
|
||||
// a = a | b;
|
||||
// return a;
|
||||
// }
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
class BufferObject {
|
||||
public:
|
||||
using TargetEnum = BufferTarget;
|
||||
|
||||
// inline Flags<BufferMappingAccessBit> operator&(const BufferMappingAccessBit a, const BufferMappingAccessBit b) {
|
||||
// return Flags(a) & b;
|
||||
// }
|
||||
BufferObject();
|
||||
|
||||
// inline bool Any(BufferMappingAccessBit a) {
|
||||
// using T = std::underlying_type_t<BufferMappingAccessBit>;
|
||||
// return static_cast<T>(a) != 0;
|
||||
// }
|
||||
void Resize(SizeT size);
|
||||
void UploadData(DataPtr data, SizeT atOffset);
|
||||
void SetUsage(BufferUsage usage);
|
||||
void* AcquireMemory(Bool markMapped, Bool read, Bool write);
|
||||
void* AcquireMemoryRange(Range1D range, Flags<BufferMappingAccessBit> access);
|
||||
void ReleaseMemory();
|
||||
void FlushMemoryRange(SizeT offset, SizeT length);
|
||||
void UploadSubData(DataPtr data, SizeT atOffset);
|
||||
void CopyDataFrom(const SharedPtr<BufferObject>& src, SizeT srcOffset, SizeT dstOffset, SizeT size);
|
||||
void ClearDirty();
|
||||
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
class BufferObject {
|
||||
public:
|
||||
using TargetEnum = BufferTarget;
|
||||
|
||||
BufferObject();
|
||||
Bool IsMapped() const;
|
||||
SizeT GetSize() const;
|
||||
BufferUsage GetUsage() const;
|
||||
Range1D GetDirtyRange() const;
|
||||
Range1D GetMappedRange() const;
|
||||
Flags<BufferMappingAccessBit> GetMappingAccess() const;
|
||||
|
||||
void Resize(SizeT size);
|
||||
void UploadData(DataPtr data, SizeT atOffset);
|
||||
void SetUsage(BufferUsage usage);
|
||||
void* AcquireMemory(Bool markMapped, Bool read, Bool write);
|
||||
void* AcquireMemoryRange(Range1D range, Flags<BufferMappingAccessBit> access);
|
||||
void ReleaseMemory();
|
||||
void FlushMemoryRange(SizeT offset, SizeT length);
|
||||
void UploadSubData(DataPtr data, SizeT atOffset);
|
||||
void CopyDataFrom(const SharedPtr<BufferObject>& src, SizeT srcOffset, SizeT dstOffset, SizeT size);
|
||||
void ClearDirty();
|
||||
|
||||
Bool IsMapped() const;
|
||||
SizeT GetSize() const;
|
||||
BufferUsage GetUsage() const;
|
||||
Range1D GetDirtyRange() const;
|
||||
Range1D GetMappedRange() const;
|
||||
Flags<BufferMappingAccessBit> GetMappingAccess() const;
|
||||
private:
|
||||
Int m_id = 0;
|
||||
SizeT m_size = 0;
|
||||
BufferUsage m_usage = BufferUsage::StaticDraw;
|
||||
Data m_data;
|
||||
Bool m_isMapped;
|
||||
Flags<BufferMappingAccessBit> m_mappingAccess;
|
||||
Range1D m_dirtyRange;
|
||||
Range1D m_mappedRange;
|
||||
std::vector<Uint8> m_stagingData;
|
||||
bool m_ownsStagingData;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
Int m_id = 0;
|
||||
SizeT m_size = 0;
|
||||
BufferUsage m_usage = BufferUsage::StaticDraw;
|
||||
Data m_data;
|
||||
Bool m_isMapped;
|
||||
Flags<BufferMappingAccessBit> m_mappingAccess;
|
||||
Range1D m_dirtyRange;
|
||||
Range1D m_mappedRange;
|
||||
std::vector<Uint8> m_stagingData;
|
||||
bool m_ownsStagingData;
|
||||
};
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,66 +1,65 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "BufferState.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
BufferState::BufferState()
|
||||
: m_indexGenerator(1024, 1) {
|
||||
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
|
||||
m_bindingSlots[i] = BindingSlot<BufferObject>(GlobalBufferTargets[i]);
|
||||
}
|
||||
}
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
BufferState::BufferState() : m_indexGenerator(1024, 1) {
|
||||
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
|
||||
m_bindingSlots[i] = BindingSlot<BufferObject>(GlobalBufferTargets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SharedPtr<BufferObject> BufferState::GetBufferObject(Uint index) {
|
||||
auto it = m_bufferObjects.find(index);
|
||||
if (it != m_bufferObjects.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
SharedPtr<BufferObject> BufferState::GetBufferObject(Uint index) {
|
||||
auto it = m_bufferObjects.find(index);
|
||||
if (it != m_bufferObjects.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector<Uint> BufferState::GenerateNames(Uint number) {
|
||||
Vector<Uint> buffers(number);
|
||||
m_indexGenerator.Generate(number, buffers.data());
|
||||
return buffers;
|
||||
}
|
||||
Vector<Uint> BufferState::GenerateNames(Uint number) {
|
||||
Vector<Uint> buffers(number);
|
||||
m_indexGenerator.Generate(number, buffers.data());
|
||||
return buffers;
|
||||
}
|
||||
|
||||
SharedPtr<BufferObject> BufferState::CreateBufferObject(Uint index) {
|
||||
auto bufferObject = MakeShared<BufferObject>();
|
||||
m_bufferObjects[index] = bufferObject;
|
||||
return bufferObject;
|
||||
}
|
||||
SharedPtr<BufferObject> BufferState::CreateBufferObject(Uint index) {
|
||||
auto bufferObject = MakeShared<BufferObject>();
|
||||
m_bufferObjects[index] = bufferObject;
|
||||
return bufferObject;
|
||||
}
|
||||
|
||||
BindingSlot<BufferObject>& BufferState::GetBindingSlot(BufferTarget target) {
|
||||
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
|
||||
if (m_bindingSlots[i].GetTarget() == target) {
|
||||
return m_bindingSlots[i];
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
BindingSlot<BufferObject>& BufferState::GetBindingSlot(BufferTarget target) {
|
||||
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
|
||||
if (m_bindingSlots[i].GetTarget() == target) {
|
||||
return m_bindingSlots[i];
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void BufferState::MarkBufferObjectForDeletion(Uint index) {
|
||||
if (m_indexGenerator.IsValid(index)) {
|
||||
auto it = m_bufferObjects.find(index);
|
||||
if (it != m_bufferObjects.end()) {
|
||||
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
|
||||
if (m_bindingSlots[i].GetBoundObject() == it->second) {
|
||||
m_bindingSlots[i].Bind(nullptr);
|
||||
}
|
||||
}
|
||||
m_bufferObjects.erase(it);
|
||||
}
|
||||
m_indexGenerator.Delete(index);
|
||||
}
|
||||
}
|
||||
void BufferState::MarkBufferObjectForDeletion(Uint index) {
|
||||
if (m_indexGenerator.IsValid(index)) {
|
||||
auto it = m_bufferObjects.find(index);
|
||||
if (it != m_bufferObjects.end()) {
|
||||
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
|
||||
if (m_bindingSlots[i].GetBoundObject() == it->second) {
|
||||
m_bindingSlots[i].Bind(nullptr);
|
||||
}
|
||||
}
|
||||
m_bufferObjects.erase(it);
|
||||
}
|
||||
m_indexGenerator.Delete(index);
|
||||
}
|
||||
}
|
||||
|
||||
bool BufferState::ValidateName(Uint index) const {
|
||||
return m_indexGenerator.IsValid(index);
|
||||
}
|
||||
bool BufferState::ValidateName(Uint index) const {
|
||||
return m_indexGenerator.IsValid(index);
|
||||
}
|
||||
|
||||
bool BufferState::ValidateBufferObject(Uint index) const {
|
||||
return m_bufferObjects.find(index) != m_bufferObjects.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool BufferState::ValidateBufferObject(Uint index) const {
|
||||
return m_bufferObjects.find(index) != m_bufferObjects.end();
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,40 +1,34 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "BufferObject.h"
|
||||
#include <MG_Util/Miscellany/IndexGenerator.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
constexpr const auto GlobalBufferTargets = ToArray(
|
||||
BufferTarget::Vertex,
|
||||
BufferTarget::Uniform,
|
||||
BufferTarget::CopyRead,
|
||||
BufferTarget::CopyWrite,
|
||||
BufferTarget::PixelPack,
|
||||
BufferTarget::PixelUnpack,
|
||||
BufferTarget::Query,
|
||||
BufferTarget::Texture,
|
||||
BufferTarget::TransformFeedback,
|
||||
BufferTarget::AtomicCounter,
|
||||
BufferTarget::DispatchIndirect,
|
||||
BufferTarget::DrawIndirect,
|
||||
BufferTarget::ShaderStorage);
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
constexpr const auto GlobalBufferTargets =
|
||||
ToArray(BufferTarget::Vertex, BufferTarget::Uniform, BufferTarget::CopyRead, BufferTarget::CopyWrite,
|
||||
BufferTarget::PixelPack, BufferTarget::PixelUnpack, BufferTarget::Query, BufferTarget::Texture,
|
||||
BufferTarget::TransformFeedback, BufferTarget::AtomicCounter, BufferTarget::DispatchIndirect,
|
||||
BufferTarget::DrawIndirect, BufferTarget::ShaderStorage);
|
||||
|
||||
class BufferState {
|
||||
public:
|
||||
BufferState();
|
||||
class BufferState {
|
||||
public:
|
||||
BufferState();
|
||||
|
||||
SharedPtr<BufferObject> GetBufferObject(Uint index);
|
||||
Vector<Uint> GenerateNames(Uint number);
|
||||
SharedPtr<BufferObject> CreateBufferObject(Uint index);
|
||||
BindingSlot<BufferObject>& GetBindingSlot(BufferTarget target);
|
||||
void MarkBufferObjectForDeletion(Uint index);
|
||||
bool ValidateName(Uint index) const;
|
||||
bool ValidateBufferObject(Uint index) const;
|
||||
SharedPtr<BufferObject> GetBufferObject(Uint index);
|
||||
Vector<Uint> GenerateNames(Uint number);
|
||||
SharedPtr<BufferObject> CreateBufferObject(Uint index);
|
||||
BindingSlot<BufferObject>& GetBindingSlot(BufferTarget target);
|
||||
void MarkBufferObjectForDeletion(Uint index);
|
||||
bool ValidateName(Uint index) const;
|
||||
bool ValidateBufferObject(Uint index) const;
|
||||
|
||||
private:
|
||||
UnorderedMap<Uint, SharedPtr<BufferObject>> m_bufferObjects;
|
||||
IndexGenerator<Uint> m_indexGenerator;
|
||||
Array<BindingSlot<BufferObject>, GlobalBufferTargets.size()> m_bindingSlots;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
UnorderedMap<Uint, SharedPtr<BufferObject>> m_bufferObjects;
|
||||
IndexGenerator<Uint> m_indexGenerator;
|
||||
Array<BindingSlot<BufferObject>, GlobalBufferTargets.size()> m_bindingSlots;
|
||||
};
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../Includes.h"
|
||||
#include "Core.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -36,7 +36,7 @@ namespace MobileGL {
|
||||
m_errorState.Clear();
|
||||
}
|
||||
|
||||
// Buffer
|
||||
// Buffer
|
||||
Vector<Uint> GLContext::GenBufferNames(Uint number) {
|
||||
return m_bufferState.GenerateNames(number);
|
||||
}
|
||||
@@ -47,9 +47,9 @@ namespace MobileGL {
|
||||
|
||||
BindingSlot<BufferObject>& GLContext::GetBufferBindingSlot(BufferTarget target) {
|
||||
if (target == BufferTarget::Index) {
|
||||
return m_vertexArrayState.GetBoundVertexArray()->GetIndexBufferBindingSlot();
|
||||
return m_vertexArrayState.GetBoundVertexArray()->GetIndexBufferBindingSlot();
|
||||
}
|
||||
|
||||
|
||||
return m_bufferState.GetBindingSlot(target);
|
||||
}
|
||||
|
||||
@@ -59,12 +59,11 @@ namespace MobileGL {
|
||||
|
||||
void GLContext::MarkBufferObjectForDeletion(Uint index) {
|
||||
if (ValidateBufferObject(index)) {
|
||||
auto bufferObject = m_bufferState.GetBufferObject(index);
|
||||
auto bufferObject = m_bufferState.GetBufferObject(index);
|
||||
auto& vaos = m_vertexArrayState.GetAllVertexArrays();
|
||||
for (SizeT i = 0; i < vaos.size(); ++i) {
|
||||
auto vao = vaos[i];
|
||||
if (vao == nullptr)
|
||||
continue;
|
||||
if (vao == nullptr) continue;
|
||||
|
||||
if (vao->GetIndexBufferBindingSlot().GetBoundObject() == bufferObject) {
|
||||
vao->GetIndexBufferBindingSlot().Bind(nullptr);
|
||||
@@ -81,11 +80,11 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
bool GLContext::ValidateBufferName(Uint index) const {
|
||||
return m_bufferState.ValidateName(index);
|
||||
return m_bufferState.ValidateName(index);
|
||||
}
|
||||
|
||||
bool GLContext::ValidateBufferObject(Uint index) const {
|
||||
return m_bufferState.ValidateBufferObject(index);
|
||||
return m_bufferState.ValidateBufferObject(index);
|
||||
}
|
||||
|
||||
// VertexArray
|
||||
@@ -120,8 +119,8 @@ namespace MobileGL {
|
||||
SharedPtr<VertexArrayObject> GLContext::GetBoundVertexArray() {
|
||||
return m_vertexArrayState.GetBoundVertexArray();
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
|
||||
GLState::GLContext* pGLContext;
|
||||
}
|
||||
}
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,53 +1,58 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "BufferState/BufferState.h"
|
||||
#include "VertexArrayState/VertexArrayState.h"
|
||||
#include "ErrorState/Error.h"
|
||||
#include "ProgramState/ProgramState.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
class GLContext {
|
||||
public:
|
||||
GLContext() = default;
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
class GLContext {
|
||||
public:
|
||||
GLContext() = default;
|
||||
|
||||
// Error
|
||||
void RecordError(ErrorCode code, SharedPtr<ErrorInfo> info = nullptr);
|
||||
bool HasGLError() const;
|
||||
Optional<const Error> PeekGLError() const;
|
||||
Optional<Error> PopGLError();
|
||||
bool HasNonGLError() const;
|
||||
Optional<const Error> PeekNonGLError() const;
|
||||
Optional<Error> PopNonGLError();
|
||||
void ClearErrors();
|
||||
// Error
|
||||
void RecordError(ErrorCode code, SharedPtr<ErrorInfo> info = nullptr);
|
||||
bool HasGLError() const;
|
||||
Optional<const Error> PeekGLError() const;
|
||||
Optional<Error> PopGLError();
|
||||
bool HasNonGLError() const;
|
||||
Optional<const Error> PeekNonGLError() const;
|
||||
Optional<Error> PopNonGLError();
|
||||
void ClearErrors();
|
||||
|
||||
// Buffer
|
||||
Vector<Uint> GenBufferNames(Uint number);
|
||||
SharedPtr<BufferObject> GetBufferObject(Uint index);
|
||||
BindingSlot<BufferObject>& GetBufferBindingSlot(BufferTarget target);
|
||||
SharedPtr<BufferObject> CreateBufferObject(Uint index);
|
||||
void MarkBufferObjectForDeletion(Uint index);
|
||||
bool ValidateBufferName(Uint index) const;
|
||||
bool ValidateBufferObject(Uint index) const;
|
||||
// Buffer
|
||||
Vector<Uint> GenBufferNames(Uint number);
|
||||
SharedPtr<BufferObject> GetBufferObject(Uint index);
|
||||
BindingSlot<BufferObject>& GetBufferBindingSlot(BufferTarget target);
|
||||
SharedPtr<BufferObject> CreateBufferObject(Uint index);
|
||||
void MarkBufferObjectForDeletion(Uint index);
|
||||
bool ValidateBufferName(Uint index) const;
|
||||
bool ValidateBufferObject(Uint index) const;
|
||||
|
||||
// VertexArray
|
||||
Vector<Uint> GenVertexArrayNames(Uint number);
|
||||
SharedPtr<VertexArrayObject> GetVertexArrayObject(Uint index);
|
||||
void BindVertexArray(Uint index);
|
||||
SharedPtr<VertexArrayObject> CreateVertexArrayObject(Uint index);
|
||||
void MarkVertexArrayForDeletion(Uint index);
|
||||
bool ValidateVertexArrayName(Uint index) const;
|
||||
bool ValidateVertexArrayObject(Uint index) const;
|
||||
SharedPtr<VertexArrayObject> GetBoundVertexArray();
|
||||
// VertexArray
|
||||
Vector<Uint> GenVertexArrayNames(Uint number);
|
||||
SharedPtr<VertexArrayObject> GetVertexArrayObject(Uint index);
|
||||
void BindVertexArray(Uint index);
|
||||
SharedPtr<VertexArrayObject> CreateVertexArrayObject(Uint index);
|
||||
void MarkVertexArrayForDeletion(Uint index);
|
||||
bool ValidateVertexArrayName(Uint index) const;
|
||||
bool ValidateVertexArrayObject(Uint index) const;
|
||||
SharedPtr<VertexArrayObject> GetBoundVertexArray();
|
||||
|
||||
private:
|
||||
// Error
|
||||
ErrorState m_errorState;
|
||||
private:
|
||||
// Error
|
||||
ErrorState m_errorState;
|
||||
|
||||
// Buffer
|
||||
BufferState m_bufferState;
|
||||
// Buffer
|
||||
BufferState m_bufferState;
|
||||
|
||||
// VertexArray
|
||||
VertexArrayState m_vertexArrayState;
|
||||
};
|
||||
}
|
||||
// VertexArray
|
||||
VertexArrayState m_vertexArrayState;
|
||||
};
|
||||
} // namespace GLState
|
||||
|
||||
extern GLState::GLContext* pGLContext;
|
||||
}
|
||||
}
|
||||
extern GLState::GLContext* pGLContext;
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,19 +1,19 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "Error.h"
|
||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToGL/ErrorCodeConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
void ErrorState::RecordError(ErrorCode code, SharedPtr<ErrorInfo> info) {
|
||||
if (code == ErrorCode::NoError) {
|
||||
MGLOG_E("Recording Non-OpenGL error:\n%s",
|
||||
info->ToString().c_str());
|
||||
m_nonGLErrors.push_back(Error{ code, info });
|
||||
}
|
||||
else {
|
||||
MGLOG_E("Recording OpenGL error (%s):\n%s",
|
||||
MG_Util::ConvertGLEnumToString(MG_Util::ConvertErrorCodeToGLEnum(code)).c_str(),
|
||||
info->ToString().c_str());
|
||||
m_errors.push_back(Error{ code, info });
|
||||
MGLOG_E("Recording Non-OpenGL error:\n%s", info->ToString().c_str());
|
||||
m_nonGLErrors.push_back(Error{code, info});
|
||||
} else {
|
||||
MGLOG_E("Recording OpenGL error (%s):\n%s",
|
||||
MG_Util::ConvertGLEnumToString(MG_Util::ConvertErrorCodeToGLEnum(code)).c_str(),
|
||||
info->ToString().c_str());
|
||||
m_errors.push_back(Error{code, info});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
Optional<const Error> ErrorState::PeekNonGLError() const {
|
||||
if (m_nonGLErrors.empty()) return Optional<const Error>{ };
|
||||
if (m_nonGLErrors.empty()) return Optional<const Error>{};
|
||||
return Optional<const Error>{m_nonGLErrors.front()};
|
||||
}
|
||||
|
||||
Optional<Error> ErrorState::PopNonGLError() {
|
||||
if (m_nonGLErrors.empty()) return Optional<const Error>{ };
|
||||
if (m_nonGLErrors.empty()) return Optional<const Error>{};
|
||||
auto error = Move(m_nonGLErrors.front());
|
||||
m_nonGLErrors.erase(m_nonGLErrors.begin());
|
||||
return Optional<const Error>{ error };
|
||||
return Optional<const Error>{error};
|
||||
}
|
||||
|
||||
bool ErrorState::HasGLError() const {
|
||||
@@ -38,21 +38,21 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
Optional<const Error> ErrorState::PeekGLError() const {
|
||||
if (m_errors.empty()) return Optional<const Error>{ };
|
||||
if (m_errors.empty()) return Optional<const Error>{};
|
||||
return Optional<const Error>{m_errors.front()};
|
||||
}
|
||||
|
||||
Optional<Error> ErrorState::PopGLError() {
|
||||
if (m_errors.empty()) return Optional<const Error>{ };
|
||||
if (m_errors.empty()) return Optional<const Error>{};
|
||||
auto error = Move(m_errors.front());
|
||||
m_errors.erase(m_errors.begin());
|
||||
return Optional<const Error>{ error };
|
||||
return Optional<const Error>{error};
|
||||
}
|
||||
|
||||
void ErrorState::Clear() {
|
||||
m_errors.clear();
|
||||
m_nonGLErrors.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,4 +1,7 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "ErrorCode.h"
|
||||
#include "ErrorInfo.h"
|
||||
|
||||
namespace MobileGL {
|
||||
struct Error {
|
||||
@@ -23,6 +26,6 @@ namespace MobileGL {
|
||||
Vector<Error> m_errors;
|
||||
Vector<Error> m_nonGLErrors;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
class ErrorInfo {
|
||||
@@ -10,9 +11,11 @@ namespace MobileGL {
|
||||
class GenericErrorInfo : public ErrorInfo {
|
||||
public:
|
||||
explicit GenericErrorInfo(String message) : m_message(Move(message)) {}
|
||||
explicit GenericErrorInfo(String m_prefix, String message) : m_message(Move(message)), m_prefix(Move(m_prefix)) {}
|
||||
explicit GenericErrorInfo(String m_prefix, String m_prefix_2, String message) : m_message(Move(message)), m_prefix(Move(m_prefix)), m_prefix_2(Move(m_prefix_2)) {}
|
||||
|
||||
explicit GenericErrorInfo(String m_prefix, String message)
|
||||
: m_message(Move(message)), m_prefix(Move(m_prefix)) {}
|
||||
explicit GenericErrorInfo(String m_prefix, String m_prefix_2, String message)
|
||||
: m_message(Move(message)), m_prefix(Move(m_prefix)), m_prefix_2(Move(m_prefix_2)) {}
|
||||
|
||||
String ToString() const override {
|
||||
StringStream ss;
|
||||
if (m_prefix.has_value()) {
|
||||
@@ -22,11 +25,12 @@ namespace MobileGL {
|
||||
ss << "[" << m_prefix_2.value() << "] ";
|
||||
}
|
||||
ss << m_message;
|
||||
return ss.str();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
private:
|
||||
String m_message;
|
||||
Optional<String> m_prefix;
|
||||
Optional<String> m_prefix_2;
|
||||
Optional<String> m_prefix;
|
||||
Optional<String> m_prefix_2;
|
||||
};
|
||||
}
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "ProgramObject.h"
|
||||
#include <MG_Util/ShaderTranspiler/ShaderCompiler.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -8,10 +9,8 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
void ProgramObject::DetachShader(SharedPtr<ShaderObject> shader) {
|
||||
auto count = std::erase_if(m_shaders,
|
||||
[shader](const SharedPtr<ShaderObject>& s) {
|
||||
return s.get() == shader.get();
|
||||
});
|
||||
auto count = std::erase_if(
|
||||
m_shaders, [shader](const SharedPtr<ShaderObject>& s) { return s.get() == shader.get(); });
|
||||
|
||||
if (count == 0) {
|
||||
// FIXME: handle error here
|
||||
@@ -27,7 +26,7 @@ namespace MobileGL {
|
||||
shaders[i] = m_shaders[i]->m_shader;
|
||||
}
|
||||
|
||||
MG_Util::ShaderTranspiler::ProgramAttrib attrib {
|
||||
MG_Util::ShaderTranspiler::ProgramAttrib attrib{
|
||||
.shaderTypes = Move(shaderTypes),
|
||||
.shaders = Move(shaders),
|
||||
};
|
||||
@@ -40,12 +39,11 @@ namespace MobileGL {
|
||||
m_linkStatus = false;
|
||||
m_infoLog = result.error().log;
|
||||
|
||||
const std::string e =
|
||||
std::format("Shader link failed: \nerrc: {}\nmsg: {}\n",
|
||||
result.error().errc, result.error().log);
|
||||
const std::string e = std::format("Shader link failed: \nerrc: {}\nmsg: {}\n", result.error().errc,
|
||||
result.error().log);
|
||||
THROW_EXCEPTION(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,23 +1,25 @@
|
||||
#pragma once
|
||||
#include "MG_Util/Types.h"
|
||||
#include <Includes.h>
|
||||
#include "ShaderObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
class ProgramObject {
|
||||
public:
|
||||
void AttachShader(SharedPtr<ShaderObject> shader);
|
||||
void DetachShader(SharedPtr<ShaderObject> shader);
|
||||
void Link();
|
||||
private:
|
||||
Vector<SharedPtr<ShaderObject>> m_shaders;
|
||||
// basically this contains SPIR-V in binary format
|
||||
Vector<Vector<Uint>> m_programBinary;
|
||||
String m_infoLog;
|
||||
bool m_deleteStatus = false;
|
||||
bool m_linkStatus = true;
|
||||
bool m_validateStatus = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
class ProgramObject {
|
||||
public:
|
||||
void AttachShader(SharedPtr<ShaderObject> shader);
|
||||
void DetachShader(SharedPtr<ShaderObject> shader);
|
||||
void Link();
|
||||
|
||||
private:
|
||||
Vector<SharedPtr<ShaderObject>> m_shaders;
|
||||
// basically this contains SPIR-V in binary format
|
||||
Vector<Vector<Uint>> m_programBinary;
|
||||
String m_infoLog;
|
||||
bool m_deleteStatus = false;
|
||||
bool m_linkStatus = true;
|
||||
bool m_validateStatus = true;
|
||||
};
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "ProgramState.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -12,16 +12,14 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
SharedPtr<ProgramObject> ProgramState::GetProgramObject(Uint id) {
|
||||
if (!CheckIndexAvail(id))
|
||||
return nullptr; // FIXME: add error reporting here
|
||||
if (!CheckIndexAvail(id)) return nullptr; // FIXME: add error reporting here
|
||||
return m_programObjects[id];
|
||||
}
|
||||
|
||||
void ProgramState::DeleteProgram(Uint id) {
|
||||
if (!CheckIndexAvail(id))
|
||||
return; // FIXME: add error reporting here
|
||||
if (!CheckIndexAvail(id)) return; // FIXME: add error reporting here
|
||||
m_programObjects[id].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,4 +1,7 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_Util/Miscellany/IndexGenerator.h>
|
||||
#include "ProgramObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -10,10 +13,9 @@ namespace MobileGL {
|
||||
Uint CreateProgram();
|
||||
SharedPtr<ProgramObject> GetProgramObject(Uint id);
|
||||
void DeleteProgram(Uint program);
|
||||
|
||||
private:
|
||||
bool CheckIndexAvail(SizeT idx) {
|
||||
return idx < m_programObjects.size();
|
||||
}
|
||||
bool CheckIndexAvail(SizeT idx) { return idx < m_programObjects.size(); }
|
||||
|
||||
void EnsureIndexAvail(SizeT idx) {
|
||||
if (CheckIndexAvail(idx)) return;
|
||||
@@ -25,6 +27,6 @@ namespace MobileGL {
|
||||
IndexGenerator<Uint> m_indexGenerator;
|
||||
Vector<SharedPtr<ProgramObject>> m_programObjects;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "ShaderObject.h"
|
||||
#include <MG_Util/ShaderTranspiler/ShaderCompiler.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -9,11 +10,8 @@ namespace MobileGL {
|
||||
|
||||
void ShaderObject::Compile() {
|
||||
using namespace MG_Util::ShaderTranspiler;
|
||||
ShaderAttrib attrib {
|
||||
.sourceStr = m_source,
|
||||
.shaderType = GetGLShaderTypeByMGLShaderStage(m_stage),
|
||||
.flags = 0
|
||||
};
|
||||
ShaderAttrib attrib{
|
||||
.sourceStr = m_source, .shaderType = GetGLShaderTypeByMGLShaderStage(m_stage), .flags = 0};
|
||||
|
||||
auto result = ShaderCompiler::CompileShader(attrib);
|
||||
if (result) {
|
||||
@@ -23,12 +21,11 @@ namespace MobileGL {
|
||||
m_compileStatus = false;
|
||||
m_infoLog = result.error().log;
|
||||
|
||||
const std::string e =
|
||||
std::format("Shader compilation failed: \nerrc: {}\nmsg: {}\n",
|
||||
result.error().errc, result.error().log);
|
||||
const std::string e = std::format("Shader compilation failed: \nerrc: {}\nmsg: {}\n",
|
||||
result.error().errc, result.error().log);
|
||||
THROW_EXCEPTION(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "MG_Util/Types.h"
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -15,27 +15,27 @@ namespace MobileGL {
|
||||
|
||||
inline static GLenum GetGLShaderTypeByMGLShaderStage(ShaderStage stage) {
|
||||
switch (stage) {
|
||||
case ShaderStage::Vertex:
|
||||
return GL_VERTEX_SHADER;
|
||||
case ShaderStage::TessControl:
|
||||
return GL_TESS_CONTROL_SHADER;
|
||||
case ShaderStage::TessEval:
|
||||
return GL_TESS_EVALUATION_SHADER;
|
||||
case ShaderStage::Geometry:
|
||||
return GL_GEOMETRY_SHADER;
|
||||
case ShaderStage::Fragment:
|
||||
return GL_FRAGMENT_SHADER;
|
||||
case ShaderStage::Compute:
|
||||
return GL_COMPUTE_SHADER;
|
||||
default:
|
||||
assert(false);
|
||||
return 0;
|
||||
case ShaderStage::Vertex:
|
||||
return GL_VERTEX_SHADER;
|
||||
case ShaderStage::TessControl:
|
||||
return GL_TESS_CONTROL_SHADER;
|
||||
case ShaderStage::TessEval:
|
||||
return GL_TESS_EVALUATION_SHADER;
|
||||
case ShaderStage::Geometry:
|
||||
return GL_GEOMETRY_SHADER;
|
||||
case ShaderStage::Fragment:
|
||||
return GL_FRAGMENT_SHADER;
|
||||
case ShaderStage::Compute:
|
||||
return GL_COMPUTE_SHADER;
|
||||
default:
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class ShaderObject {
|
||||
public:
|
||||
ShaderObject(const ShaderStage stage): m_stage(stage) {}
|
||||
ShaderObject(const ShaderStage stage) : m_stage(stage) {}
|
||||
void SetShaderSource(const std::string& source);
|
||||
void Compile();
|
||||
|
||||
@@ -47,6 +47,6 @@ namespace MobileGL {
|
||||
bool m_deleteStatus = false;
|
||||
bool m_compileStatus = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "VertexArrayObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -30,8 +30,8 @@ namespace MobileGL {
|
||||
return m_attributes[index].Enabled;
|
||||
}
|
||||
|
||||
void VertexArrayObject::SetAttributeFormat(Uint index, int size, DataType type,
|
||||
bool normalized, int stride, SizeT offset, bool isInteger) {
|
||||
void VertexArrayObject::SetAttributeFormat(Uint index, int size, DataType type, bool normalized, int stride,
|
||||
SizeT offset, bool isInteger) {
|
||||
if (index >= MAX_VERTEX_ATTRIBS) return;
|
||||
|
||||
if (size < 1 || size > 4) {
|
||||
@@ -44,17 +44,16 @@ namespace MobileGL {
|
||||
attr.Normalized = normalized;
|
||||
attr.Stride = stride;
|
||||
attr.Offset = offset;
|
||||
attr.IsInteger = isInteger;
|
||||
attr.IsInteger = isInteger;
|
||||
}
|
||||
|
||||
void VertexArrayObject::BindAttributeBuffer(Uint index,
|
||||
const SharedPtr<BufferObject>& buffer) {
|
||||
void VertexArrayObject::BindAttributeBuffer(Uint index, const SharedPtr<BufferObject>& buffer) {
|
||||
if (index >= MAX_VERTEX_ATTRIBS) return;
|
||||
m_attributes[index].Buffer = buffer;
|
||||
}
|
||||
|
||||
BindingSlot<BufferObject>& VertexArrayObject::GetIndexBufferBindingSlot() {
|
||||
return m_indexBufferBindingSlot;
|
||||
return m_indexBufferBindingSlot;
|
||||
}
|
||||
|
||||
const VertexAttribute& VertexArrayObject::GetAttribute(Uint index) const {
|
||||
@@ -62,6 +61,6 @@ namespace MobileGL {
|
||||
if (index >= MAX_VERTEX_ATTRIBS) return emptyAttr;
|
||||
return m_attributes[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "../BufferState/BufferObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -24,7 +26,8 @@ namespace MobileGL {
|
||||
void DisableAttribute(Uint index);
|
||||
bool IsAttributeEnabled(Uint index) const;
|
||||
|
||||
void SetAttributeFormat(Uint index, int size, DataType type, bool normalized, int stride, SizeT offset, bool isInteger);
|
||||
void SetAttributeFormat(Uint index, int size, DataType type, bool normalized, int stride, SizeT offset,
|
||||
bool isInteger);
|
||||
|
||||
void BindAttributeBuffer(Uint index, const SharedPtr<BufferObject>& buffer);
|
||||
|
||||
@@ -36,6 +39,6 @@ namespace MobileGL {
|
||||
Array<VertexAttribute, MAX_VERTEX_ATTRIBS> m_attributes;
|
||||
BindingSlot<BufferObject> m_indexBufferBindingSlot;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "VertexArrayState.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
VertexArrayState::VertexArrayState()
|
||||
: m_indexGenerator(1024, 1) {
|
||||
}
|
||||
VertexArrayState::VertexArrayState() : m_indexGenerator(1024, 1) {}
|
||||
|
||||
SharedPtr<VertexArrayObject> VertexArrayState::GetVertexArrayObject(Uint index) {
|
||||
if (index >= m_vertexArrays.size())
|
||||
@@ -71,6 +69,6 @@ namespace MobileGL {
|
||||
Vector<SharedPtr<VertexArrayObject>>& VertexArrayState::GetAllVertexArrays() {
|
||||
return m_vertexArrays;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "VertexArrayObject.h"
|
||||
#include <MG_Util/Miscellany/IndexGenerator.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -22,6 +25,6 @@ namespace MobileGL {
|
||||
IndexGenerator<Uint> m_indexGenerator;
|
||||
SharedPtr<VertexArrayObject> m_boundVertexArray;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GLShaderLangConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
EShLanguage ConvertGLEnumToEShLanguage(GLenum shaderType) {
|
||||
switch (shaderType) {
|
||||
case GL_VERTEX_SHADER:
|
||||
return EShLanguage::EShLangVertex;
|
||||
case GL_FRAGMENT_SHADER:
|
||||
return EShLanguage::EShLangFragment;
|
||||
case GL_COMPUTE_SHADER:
|
||||
return EShLanguage::EShLangCompute;
|
||||
case GL_TESS_CONTROL_SHADER:
|
||||
return EShLanguage::EShLangTessControl;
|
||||
case GL_TESS_EVALUATION_SHADER:
|
||||
return EShLanguage::EShLangTessEvaluation;
|
||||
case GL_GEOMETRY_SHADER:
|
||||
return EShLanguage::EShLangGeometry;
|
||||
default:
|
||||
return EShLanguage::EShLangCount;
|
||||
case GL_VERTEX_SHADER:
|
||||
return EShLanguage::EShLangVertex;
|
||||
case GL_FRAGMENT_SHADER:
|
||||
return EShLanguage::EShLangFragment;
|
||||
case GL_COMPUTE_SHADER:
|
||||
return EShLanguage::EShLangCompute;
|
||||
case GL_TESS_CONTROL_SHADER:
|
||||
return EShLanguage::EShLangTessControl;
|
||||
case GL_TESS_EVALUATION_SHADER:
|
||||
return EShLanguage::EShLangTessEvaluation;
|
||||
case GL_GEOMETRY_SHADER:
|
||||
return EShLanguage::EShLangGeometry;
|
||||
default:
|
||||
return EShLanguage::EShLangCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
EShLanguage ConvertGLEnumToEShLanguage(GLenum shaderType);
|
||||
}
|
||||
}
|
||||
} // namespace MobileGL
|
||||
@@ -1,54 +1,79 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "BufferEnumConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
BufferTarget ConvertGLEnumToBufferTarget(GLenum bufferTarget) {
|
||||
switch (bufferTarget) {
|
||||
case GL_ARRAY_BUFFER: return BufferTarget::Vertex;
|
||||
case GL_ELEMENT_ARRAY_BUFFER: return BufferTarget::Index;
|
||||
case GL_UNIFORM_BUFFER: return BufferTarget::Uniform;
|
||||
case GL_COPY_READ_BUFFER: return BufferTarget::CopyRead;
|
||||
case GL_COPY_WRITE_BUFFER: return BufferTarget::CopyWrite;
|
||||
case GL_PIXEL_PACK_BUFFER: return BufferTarget::PixelPack;
|
||||
case GL_PIXEL_UNPACK_BUFFER: return BufferTarget::PixelUnpack;
|
||||
case GL_QUERY_BUFFER: return BufferTarget::Query;
|
||||
case GL_TEXTURE_BUFFER: return BufferTarget::Texture;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER: return BufferTarget::TransformFeedback;
|
||||
case GL_ATOMIC_COUNTER_BUFFER: return BufferTarget::AtomicCounter;
|
||||
case GL_DISPATCH_INDIRECT_BUFFER: return BufferTarget::DispatchIndirect;
|
||||
case GL_DRAW_INDIRECT_BUFFER: return BufferTarget::DrawIndirect;
|
||||
case GL_SHADER_STORAGE_BUFFER: return BufferTarget::ShaderStorage;
|
||||
case GL_UNKNOWN_MGL:
|
||||
default: return BufferTarget::Unknown;
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
BufferTarget ConvertGLEnumToBufferTarget(GLenum bufferTarget) {
|
||||
switch (bufferTarget) {
|
||||
case GL_ARRAY_BUFFER:
|
||||
return BufferTarget::Vertex;
|
||||
case GL_ELEMENT_ARRAY_BUFFER:
|
||||
return BufferTarget::Index;
|
||||
case GL_UNIFORM_BUFFER:
|
||||
return BufferTarget::Uniform;
|
||||
case GL_COPY_READ_BUFFER:
|
||||
return BufferTarget::CopyRead;
|
||||
case GL_COPY_WRITE_BUFFER:
|
||||
return BufferTarget::CopyWrite;
|
||||
case GL_PIXEL_PACK_BUFFER:
|
||||
return BufferTarget::PixelPack;
|
||||
case GL_PIXEL_UNPACK_BUFFER:
|
||||
return BufferTarget::PixelUnpack;
|
||||
case GL_QUERY_BUFFER:
|
||||
return BufferTarget::Query;
|
||||
case GL_TEXTURE_BUFFER:
|
||||
return BufferTarget::Texture;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER:
|
||||
return BufferTarget::TransformFeedback;
|
||||
case GL_ATOMIC_COUNTER_BUFFER:
|
||||
return BufferTarget::AtomicCounter;
|
||||
case GL_DISPATCH_INDIRECT_BUFFER:
|
||||
return BufferTarget::DispatchIndirect;
|
||||
case GL_DRAW_INDIRECT_BUFFER:
|
||||
return BufferTarget::DrawIndirect;
|
||||
case GL_SHADER_STORAGE_BUFFER:
|
||||
return BufferTarget::ShaderStorage;
|
||||
case GL_UNKNOWN_MGL:
|
||||
default:
|
||||
return BufferTarget::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
BufferUsage ConvertGLEnumToBufferUsage(GLenum usage) {
|
||||
switch (usage) {
|
||||
case GL_STREAM_DRAW: return BufferUsage::StreamDraw;
|
||||
case GL_STREAM_READ: return BufferUsage::StreamRead;
|
||||
case GL_STREAM_COPY: return BufferUsage::StreamCopy;
|
||||
case GL_STATIC_DRAW: return BufferUsage::StaticDraw;
|
||||
case GL_STATIC_READ: return BufferUsage::StaticRead;
|
||||
case GL_STATIC_COPY: return BufferUsage::StaticCopy;
|
||||
case GL_DYNAMIC_DRAW: return BufferUsage::DynamicDraw;
|
||||
case GL_DYNAMIC_READ: return BufferUsage::DynamicRead;
|
||||
case GL_DYNAMIC_COPY: return BufferUsage::DynamicCopy;
|
||||
default: return BufferUsage::Unknown;
|
||||
}
|
||||
}
|
||||
BufferUsage ConvertGLEnumToBufferUsage(GLenum usage) {
|
||||
switch (usage) {
|
||||
case GL_STREAM_DRAW:
|
||||
return BufferUsage::StreamDraw;
|
||||
case GL_STREAM_READ:
|
||||
return BufferUsage::StreamRead;
|
||||
case GL_STREAM_COPY:
|
||||
return BufferUsage::StreamCopy;
|
||||
case GL_STATIC_DRAW:
|
||||
return BufferUsage::StaticDraw;
|
||||
case GL_STATIC_READ:
|
||||
return BufferUsage::StaticRead;
|
||||
case GL_STATIC_COPY:
|
||||
return BufferUsage::StaticCopy;
|
||||
case GL_DYNAMIC_DRAW:
|
||||
return BufferUsage::DynamicDraw;
|
||||
case GL_DYNAMIC_READ:
|
||||
return BufferUsage::DynamicRead;
|
||||
case GL_DYNAMIC_COPY:
|
||||
return BufferUsage::DynamicCopy;
|
||||
default:
|
||||
return BufferUsage::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
Flags<BufferMappingAccessBit> ConvertGLEnumToBufferMappingAccess(GLbitfield access) {
|
||||
Flags result = BufferMappingAccessBit::Null;
|
||||
if (access & GL_MAP_READ_BIT) result |= BufferMappingAccessBit::Read;
|
||||
if (access & GL_MAP_WRITE_BIT) result |= BufferMappingAccessBit::Write;
|
||||
if (access & GL_MAP_INVALIDATE_RANGE_BIT) result |= BufferMappingAccessBit::InvalidateRange;
|
||||
if (access & GL_MAP_INVALIDATE_BUFFER_BIT) result |= BufferMappingAccessBit::InvalidateBuffer;
|
||||
if (access & GL_MAP_FLUSH_EXPLICIT_BIT) result |= BufferMappingAccessBit::FlushExplicit;
|
||||
if (access & GL_MAP_UNSYNCHRONIZED_BIT) result |= BufferMappingAccessBit::Unsynchronized;
|
||||
if (access & GL_MAP_PERSISTENT_BIT) result |= BufferMappingAccessBit::Persistent;
|
||||
if (access & GL_MAP_COHERENT_BIT) result |= BufferMappingAccessBit::Coherent;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Flags<BufferMappingAccessBit> ConvertGLEnumToBufferMappingAccess(GLbitfield access) {
|
||||
Flags result = BufferMappingAccessBit::Null;
|
||||
if (access & GL_MAP_READ_BIT) result |= BufferMappingAccessBit::Read;
|
||||
if (access & GL_MAP_WRITE_BIT) result |= BufferMappingAccessBit::Write;
|
||||
if (access & GL_MAP_INVALIDATE_RANGE_BIT) result |= BufferMappingAccessBit::InvalidateRange;
|
||||
if (access & GL_MAP_INVALIDATE_BUFFER_BIT) result |= BufferMappingAccessBit::InvalidateBuffer;
|
||||
if (access & GL_MAP_FLUSH_EXPLICIT_BIT) result |= BufferMappingAccessBit::FlushExplicit;
|
||||
if (access & GL_MAP_UNSYNCHRONIZED_BIT) result |= BufferMappingAccessBit::Unsynchronized;
|
||||
if (access & GL_MAP_PERSISTENT_BIT) result |= BufferMappingAccessBit::Persistent;
|
||||
if (access & GL_MAP_COHERENT_BIT) result |= BufferMappingAccessBit::Coherent;
|
||||
return result;
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
BufferTarget ConvertGLEnumToBufferTarget(GLenum bufferTarget);
|
||||
BufferUsage ConvertGLEnumToBufferUsage(GLenum usage);
|
||||
Flags<BufferMappingAccessBit> ConvertGLEnumToBufferMappingAccess(GLbitfield access);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
BufferTarget ConvertGLEnumToBufferTarget(GLenum bufferTarget);
|
||||
BufferUsage ConvertGLEnumToBufferUsage(GLenum usage);
|
||||
Flags<BufferMappingAccessBit> ConvertGLEnumToBufferMappingAccess(GLbitfield access);
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,21 +1,30 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "DataTypeConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
DataType ConvertGLEnumToDataType(GLenum type) {
|
||||
switch (type) {
|
||||
case GL_BYTE: return DataType::Int8;
|
||||
case GL_UNSIGNED_BYTE: return DataType::Uint8;
|
||||
case GL_SHORT: return DataType::Int16;
|
||||
case GL_UNSIGNED_SHORT: return DataType::Uint16;
|
||||
case GL_INT: return DataType::Int32;
|
||||
case GL_UNSIGNED_INT: return DataType::Uint32;
|
||||
case GL_HALF_FLOAT: return DataType::Float16;
|
||||
case GL_FLOAT: return DataType::Float32;
|
||||
case GL_DOUBLE: return DataType::Float64;
|
||||
default:
|
||||
return DataType::Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
DataType ConvertGLEnumToDataType(GLenum type) {
|
||||
switch (type) {
|
||||
case GL_BYTE:
|
||||
return DataType::Int8;
|
||||
case GL_UNSIGNED_BYTE:
|
||||
return DataType::Uint8;
|
||||
case GL_SHORT:
|
||||
return DataType::Int16;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
return DataType::Uint16;
|
||||
case GL_INT:
|
||||
return DataType::Int32;
|
||||
case GL_UNSIGNED_INT:
|
||||
return DataType::Uint32;
|
||||
case GL_HALF_FLOAT:
|
||||
return DataType::Float16;
|
||||
case GL_FLOAT:
|
||||
return DataType::Float32;
|
||||
case GL_DOUBLE:
|
||||
return DataType::Float64;
|
||||
default:
|
||||
return DataType::Unknown;
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
DataType ConvertGLEnumToDataType(GLenum type);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
DataType ConvertGLEnumToDataType(GLenum type);
|
||||
}
|
||||
} // namespace MobileGL
|
||||
@@ -1,20 +1,21 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "GLEnumConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
namespace MG_Util {
|
||||
String ConvertGLEnumToString(GLenum value) {
|
||||
switch (value) {
|
||||
#define CASE(value) \
|
||||
case value: return #value;
|
||||
//CASE(GL_VERSION_1_0)
|
||||
//CASE(GL_VERSION_1_1)
|
||||
#define CASE(value) \
|
||||
case value: \
|
||||
return #value;
|
||||
// CASE(GL_VERSION_1_0)
|
||||
// CASE(GL_VERSION_1_1)
|
||||
CASE(GL_DEPTH_BUFFER_BIT)
|
||||
CASE(GL_STENCIL_BUFFER_BIT)
|
||||
CASE(GL_COLOR_BUFFER_BIT)
|
||||
CASE(GL_FALSE)
|
||||
CASE(GL_TRUE)
|
||||
//CASE(GL_POINTS)
|
||||
//CASE(GL_LINES)
|
||||
// CASE(GL_POINTS)
|
||||
// CASE(GL_LINES)
|
||||
CASE(GL_LINE_LOOP)
|
||||
CASE(GL_LINE_STRIP)
|
||||
CASE(GL_TRIANGLES)
|
||||
@@ -29,8 +30,8 @@ namespace MobileGL {
|
||||
CASE(GL_NOTEQUAL)
|
||||
CASE(GL_GEQUAL)
|
||||
CASE(GL_ALWAYS)
|
||||
//CASE(GL_ZERO)
|
||||
//CASE(GL_ONE)
|
||||
// CASE(GL_ZERO)
|
||||
// CASE(GL_ONE)
|
||||
CASE(GL_SRC_COLOR)
|
||||
CASE(GL_ONE_MINUS_SRC_COLOR)
|
||||
CASE(GL_SRC_ALPHA)
|
||||
@@ -40,8 +41,8 @@ namespace MobileGL {
|
||||
CASE(GL_DST_COLOR)
|
||||
CASE(GL_ONE_MINUS_DST_COLOR)
|
||||
CASE(GL_SRC_ALPHA_SATURATE)
|
||||
//CASE(GL_NONE)
|
||||
//CASE(GL_FRONT_LEFT)
|
||||
// CASE(GL_NONE)
|
||||
// CASE(GL_FRONT_LEFT)
|
||||
CASE(GL_FRONT_RIGHT)
|
||||
CASE(GL_BACK_LEFT)
|
||||
CASE(GL_BACK_RIGHT)
|
||||
@@ -50,7 +51,7 @@ namespace MobileGL {
|
||||
CASE(GL_LEFT)
|
||||
CASE(GL_RIGHT)
|
||||
CASE(GL_FRONT_AND_BACK)
|
||||
//CASE(GL_NO_ERROR)
|
||||
// CASE(GL_NO_ERROR)
|
||||
CASE(GL_INVALID_ENUM)
|
||||
CASE(GL_INVALID_VALUE)
|
||||
CASE(GL_INVALID_OPERATION)
|
||||
@@ -182,7 +183,7 @@ namespace MobileGL {
|
||||
CASE(GL_DECR)
|
||||
CASE(GL_VENDOR)
|
||||
CASE(GL_RENDERER)
|
||||
//CASE(GL_VERSION)
|
||||
// CASE(GL_VERSION)
|
||||
CASE(GL_EXTENSIONS)
|
||||
CASE(GL_NEAREST)
|
||||
CASE(GL_LINEAR)
|
||||
@@ -212,7 +213,7 @@ namespace MobileGL {
|
||||
CASE(GL_RGBA12)
|
||||
CASE(GL_RGBA16)
|
||||
CASE(GL_VERTEX_ARRAY)
|
||||
//CASE(GL_VERSION_1_2)
|
||||
// CASE(GL_VERSION_1_2)
|
||||
CASE(GL_UNSIGNED_BYTE_3_3_2)
|
||||
CASE(GL_UNSIGNED_SHORT_4_4_4_4)
|
||||
CASE(GL_UNSIGNED_SHORT_5_5_5_1)
|
||||
@@ -244,12 +245,12 @@ namespace MobileGL {
|
||||
CASE(GL_TEXTURE_MAX_LOD)
|
||||
CASE(GL_TEXTURE_BASE_LEVEL)
|
||||
CASE(GL_TEXTURE_MAX_LEVEL)
|
||||
//CASE(GL_SMOOTH_POINT_SIZE_RANGE)
|
||||
//CASE(GL_SMOOTH_POINT_SIZE_GRANULARITY)
|
||||
//CASE(GL_SMOOTH_LINE_WIDTH_RANGE)
|
||||
//CASE(GL_SMOOTH_LINE_WIDTH_GRANULARITY)
|
||||
// CASE(GL_SMOOTH_POINT_SIZE_RANGE)
|
||||
// CASE(GL_SMOOTH_POINT_SIZE_GRANULARITY)
|
||||
// CASE(GL_SMOOTH_LINE_WIDTH_RANGE)
|
||||
// CASE(GL_SMOOTH_LINE_WIDTH_GRANULARITY)
|
||||
CASE(GL_ALIASED_LINE_WIDTH_RANGE)
|
||||
//CASE(GL_VERSION_1_3)
|
||||
// CASE(GL_VERSION_1_3)
|
||||
CASE(GL_TEXTURE0)
|
||||
CASE(GL_TEXTURE1)
|
||||
CASE(GL_TEXTURE2)
|
||||
@@ -309,7 +310,7 @@ namespace MobileGL {
|
||||
CASE(GL_NUM_COMPRESSED_TEXTURE_FORMATS)
|
||||
CASE(GL_COMPRESSED_TEXTURE_FORMATS)
|
||||
CASE(GL_CLAMP_TO_BORDER)
|
||||
//CASE(GL_VERSION_1_4)
|
||||
// CASE(GL_VERSION_1_4)
|
||||
CASE(GL_BLEND_DST_RGB)
|
||||
CASE(GL_BLEND_SRC_RGB)
|
||||
CASE(GL_BLEND_DST_ALPHA)
|
||||
@@ -335,7 +336,7 @@ namespace MobileGL {
|
||||
CASE(GL_ONE_MINUS_CONSTANT_COLOR)
|
||||
CASE(GL_CONSTANT_ALPHA)
|
||||
CASE(GL_ONE_MINUS_CONSTANT_ALPHA)
|
||||
//CASE(GL_VERSION_1_5)
|
||||
// CASE(GL_VERSION_1_5)
|
||||
CASE(GL_BUFFER_SIZE)
|
||||
CASE(GL_BUFFER_USAGE)
|
||||
CASE(GL_QUERY_COUNTER_BITS)
|
||||
@@ -364,7 +365,7 @@ namespace MobileGL {
|
||||
CASE(GL_DYNAMIC_COPY)
|
||||
CASE(GL_SAMPLES_PASSED)
|
||||
CASE(GL_SRC1_ALPHA)
|
||||
//CASE(GL_VERSION_2_0)
|
||||
// CASE(GL_VERSION_2_0)
|
||||
CASE(GL_BLEND_EQUATION_RGB)
|
||||
CASE(GL_VERTEX_ATTRIB_ARRAY_ENABLED)
|
||||
CASE(GL_VERTEX_ATTRIB_ARRAY_SIZE)
|
||||
@@ -445,7 +446,7 @@ namespace MobileGL {
|
||||
CASE(GL_STENCIL_BACK_REF)
|
||||
CASE(GL_STENCIL_BACK_VALUE_MASK)
|
||||
CASE(GL_STENCIL_BACK_WRITEMASK)
|
||||
//CASE(GL_VERSION_2_1)
|
||||
// CASE(GL_VERSION_2_1)
|
||||
CASE(GL_PIXEL_PACK_BUFFER)
|
||||
CASE(GL_PIXEL_UNPACK_BUFFER)
|
||||
CASE(GL_PIXEL_PACK_BUFFER_BINDING)
|
||||
@@ -456,7 +457,7 @@ namespace MobileGL {
|
||||
CASE(GL_SRGB8_ALPHA8)
|
||||
CASE(GL_COMPRESSED_SRGB)
|
||||
CASE(GL_COMPRESSED_SRGB_ALPHA)
|
||||
//CASE(GL_VERSION_3_0)
|
||||
// CASE(GL_VERSION_3_0)
|
||||
CASE(GL_COMPARE_REF_TO_TEXTURE)
|
||||
CASE(GL_CLIP_DISTANCE0)
|
||||
CASE(GL_CLIP_DISTANCE1)
|
||||
@@ -473,7 +474,7 @@ namespace MobileGL {
|
||||
CASE(GL_CONTEXT_FLAGS)
|
||||
CASE(GL_COMPRESSED_RED)
|
||||
CASE(GL_COMPRESSED_RG)
|
||||
//CASE(GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
||||
// CASE(GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
||||
CASE(GL_RGBA32F)
|
||||
CASE(GL_RGB32F)
|
||||
CASE(GL_RGBA16F)
|
||||
@@ -484,7 +485,7 @@ namespace MobileGL {
|
||||
CASE(GL_MAX_PROGRAM_TEXEL_OFFSET)
|
||||
CASE(GL_CLAMP_READ_COLOR)
|
||||
CASE(GL_FIXED_ONLY)
|
||||
//CASE(GL_MAX_VARYING_COMPONENTS)
|
||||
// CASE(GL_MAX_VARYING_COMPONENTS)
|
||||
CASE(GL_TEXTURE_1D_ARRAY)
|
||||
CASE(GL_PROXY_TEXTURE_1D_ARRAY)
|
||||
CASE(GL_TEXTURE_2D_ARRAY)
|
||||
@@ -584,7 +585,7 @@ namespace MobileGL {
|
||||
CASE(GL_TEXTURE_DEPTH_TYPE)
|
||||
CASE(GL_UNSIGNED_NORMALIZED)
|
||||
CASE(GL_FRAMEBUFFER_BINDING)
|
||||
//CASE(GL_DRAW_FRAMEBUFFER_BINDING)
|
||||
// CASE(GL_DRAW_FRAMEBUFFER_BINDING)
|
||||
CASE(GL_RENDERBUFFER_BINDING)
|
||||
CASE(GL_READ_FRAMEBUFFER)
|
||||
CASE(GL_DRAW_FRAMEBUFFER)
|
||||
@@ -655,9 +656,9 @@ namespace MobileGL {
|
||||
CASE(GL_MAX_SAMPLES)
|
||||
CASE(GL_FRAMEBUFFER_SRGB)
|
||||
CASE(GL_HALF_FLOAT)
|
||||
//CASE(GL_MAP_READ_BIT)
|
||||
//CASE(GL_MAP_WRITE_BIT)
|
||||
//CASE(GL_MAP_INVALIDATE_RANGE_BIT)
|
||||
// CASE(GL_MAP_READ_BIT)
|
||||
// CASE(GL_MAP_WRITE_BIT)
|
||||
// CASE(GL_MAP_INVALIDATE_RANGE_BIT)
|
||||
CASE(GL_MAP_INVALIDATE_BUFFER_BIT)
|
||||
CASE(GL_MAP_FLUSH_EXPLICIT_BIT)
|
||||
CASE(GL_MAP_UNSYNCHRONIZED_BIT)
|
||||
@@ -688,7 +689,7 @@ namespace MobileGL {
|
||||
CASE(GL_RG32I)
|
||||
CASE(GL_RG32UI)
|
||||
CASE(GL_VERTEX_ARRAY_BINDING)
|
||||
//CASE(GL_VERSION_3_1)
|
||||
// CASE(GL_VERSION_3_1)
|
||||
CASE(GL_SAMPLER_2D_RECT)
|
||||
CASE(GL_SAMPLER_2D_RECT_SHADOW)
|
||||
CASE(GL_SAMPLER_BUFFER)
|
||||
@@ -749,14 +750,14 @@ namespace MobileGL {
|
||||
CASE(GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER)
|
||||
CASE(GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER)
|
||||
CASE(GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER)
|
||||
//CASE(GL_VERSION_3_2)
|
||||
//CASE(GL_CONTEXT_CORE_PROFILE_BIT)
|
||||
//CASE(GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
||||
// CASE(GL_VERSION_3_2)
|
||||
// CASE(GL_CONTEXT_CORE_PROFILE_BIT)
|
||||
// CASE(GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
||||
CASE(GL_LINES_ADJACENCY)
|
||||
CASE(GL_LINE_STRIP_ADJACENCY)
|
||||
CASE(GL_TRIANGLES_ADJACENCY)
|
||||
CASE(GL_TRIANGLE_STRIP_ADJACENCY)
|
||||
//CASE(GL_PROGRAM_POINT_SIZE)
|
||||
// CASE(GL_PROGRAM_POINT_SIZE)
|
||||
CASE(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS)
|
||||
CASE(GL_FRAMEBUFFER_ATTACHMENT_LAYERED)
|
||||
CASE(GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS)
|
||||
@@ -791,7 +792,7 @@ namespace MobileGL {
|
||||
CASE(GL_TIMEOUT_EXPIRED)
|
||||
CASE(GL_CONDITION_SATISFIED)
|
||||
CASE(GL_WAIT_FAILED)
|
||||
//CASE(GL_SYNC_FLUSH_COMMANDS_BIT)
|
||||
// CASE(GL_SYNC_FLUSH_COMMANDS_BIT)
|
||||
CASE(GL_SAMPLE_POSITION)
|
||||
CASE(GL_SAMPLE_MASK)
|
||||
CASE(GL_SAMPLE_MASK_VALUE)
|
||||
@@ -813,7 +814,7 @@ namespace MobileGL {
|
||||
CASE(GL_MAX_COLOR_TEXTURE_SAMPLES)
|
||||
CASE(GL_MAX_DEPTH_TEXTURE_SAMPLES)
|
||||
CASE(GL_MAX_INTEGER_SAMPLES)
|
||||
//CASE(GL_VERSION_3_3)
|
||||
// CASE(GL_VERSION_3_3)
|
||||
CASE(GL_VERTEX_ATTRIB_ARRAY_DIVISOR)
|
||||
CASE(GL_SRC1_COLOR)
|
||||
CASE(GL_ONE_MINUS_SRC1_COLOR)
|
||||
@@ -830,7 +831,7 @@ namespace MobileGL {
|
||||
CASE(GL_TIME_ELAPSED)
|
||||
CASE(GL_TIMESTAMP)
|
||||
CASE(GL_INT_2_10_10_10_REV)
|
||||
//CASE(GL_VERSION_4_0)
|
||||
// CASE(GL_VERSION_4_0)
|
||||
CASE(GL_SAMPLE_SHADING)
|
||||
CASE(GL_MIN_SAMPLE_SHADING_VALUE)
|
||||
CASE(GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET)
|
||||
@@ -902,7 +903,7 @@ namespace MobileGL {
|
||||
CASE(GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE)
|
||||
CASE(GL_TRANSFORM_FEEDBACK_BINDING)
|
||||
CASE(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS)
|
||||
//CASE(GL_VERSION_4_1)
|
||||
// CASE(GL_VERSION_4_1)
|
||||
CASE(GL_FIXED)
|
||||
CASE(GL_IMPLEMENTATION_COLOR_READ_TYPE)
|
||||
CASE(GL_IMPLEMENTATION_COLOR_READ_FORMAT)
|
||||
@@ -923,11 +924,11 @@ namespace MobileGL {
|
||||
CASE(GL_PROGRAM_BINARY_LENGTH)
|
||||
CASE(GL_NUM_PROGRAM_BINARY_FORMATS)
|
||||
CASE(GL_PROGRAM_BINARY_FORMATS)
|
||||
//CASE(GL_VERTEX_SHADER_BIT)
|
||||
//CASE(GL_FRAGMENT_SHADER_BIT)
|
||||
//CASE(GL_GEOMETRY_SHADER_BIT)
|
||||
//CASE(GL_TESS_CONTROL_SHADER_BIT)
|
||||
//CASE(GL_TESS_EVALUATION_SHADER_BIT)
|
||||
// CASE(GL_VERTEX_SHADER_BIT)
|
||||
// CASE(GL_FRAGMENT_SHADER_BIT)
|
||||
// CASE(GL_GEOMETRY_SHADER_BIT)
|
||||
// CASE(GL_TESS_CONTROL_SHADER_BIT)
|
||||
// CASE(GL_TESS_EVALUATION_SHADER_BIT)
|
||||
CASE(GL_PROGRAM_SEPARABLE)
|
||||
CASE(GL_ACTIVE_PROGRAM)
|
||||
CASE(GL_PROGRAM_PIPELINE_BINDING)
|
||||
@@ -937,11 +938,11 @@ namespace MobileGL {
|
||||
CASE(GL_LAYER_PROVOKING_VERTEX)
|
||||
CASE(GL_VIEWPORT_INDEX_PROVOKING_VERTEX)
|
||||
CASE(GL_UNDEFINED_VERTEX)
|
||||
//CASE(GL_VERSION_4_2)
|
||||
//CASE(GL_COPY_READ_BUFFER_BINDING)
|
||||
//CASE(GL_COPY_WRITE_BUFFER_BINDING)
|
||||
//CASE(GL_TRANSFORM_FEEDBACK_ACTIVE)
|
||||
//CASE(GL_TRANSFORM_FEEDBACK_PAUSED)
|
||||
// CASE(GL_VERSION_4_2)
|
||||
// CASE(GL_COPY_READ_BUFFER_BINDING)
|
||||
// CASE(GL_COPY_WRITE_BUFFER_BINDING)
|
||||
// CASE(GL_TRANSFORM_FEEDBACK_ACTIVE)
|
||||
// CASE(GL_TRANSFORM_FEEDBACK_PAUSED)
|
||||
CASE(GL_UNPACK_COMPRESSED_BLOCK_WIDTH)
|
||||
CASE(GL_UNPACK_COMPRESSED_BLOCK_HEIGHT)
|
||||
CASE(GL_UNPACK_COMPRESSED_BLOCK_DEPTH)
|
||||
@@ -981,18 +982,18 @@ namespace MobileGL {
|
||||
CASE(GL_ACTIVE_ATOMIC_COUNTER_BUFFERS)
|
||||
CASE(GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX)
|
||||
CASE(GL_UNSIGNED_INT_ATOMIC_COUNTER)
|
||||
//CASE(GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT)
|
||||
//CASE(GL_ELEMENT_ARRAY_BARRIER_BIT)
|
||||
//CASE(GL_UNIFORM_BARRIER_BIT)
|
||||
//CASE(GL_TEXTURE_FETCH_BARRIER_BIT)
|
||||
//CASE(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT)
|
||||
// CASE(GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT)
|
||||
// CASE(GL_ELEMENT_ARRAY_BARRIER_BIT)
|
||||
// CASE(GL_UNIFORM_BARRIER_BIT)
|
||||
// CASE(GL_TEXTURE_FETCH_BARRIER_BIT)
|
||||
// CASE(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT)
|
||||
CASE(GL_COMMAND_BARRIER_BIT)
|
||||
CASE(GL_PIXEL_BUFFER_BARRIER_BIT)
|
||||
//CASE(GL_TEXTURE_UPDATE_BARRIER_BIT)
|
||||
//CASE(GL_BUFFER_UPDATE_BARRIER_BIT)
|
||||
//CASE(GL_FRAMEBUFFER_BARRIER_BIT)
|
||||
// CASE(GL_TEXTURE_UPDATE_BARRIER_BIT)
|
||||
// CASE(GL_BUFFER_UPDATE_BARRIER_BIT)
|
||||
// CASE(GL_FRAMEBUFFER_BARRIER_BIT)
|
||||
CASE(GL_TRANSFORM_FEEDBACK_BARRIER_BIT)
|
||||
//CASE(GL_ATOMIC_COUNTER_BARRIER_BIT)
|
||||
// CASE(GL_ATOMIC_COUNTER_BARRIER_BIT)
|
||||
CASE(GL_MAX_IMAGE_UNITS)
|
||||
CASE(GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS)
|
||||
CASE(GL_IMAGE_BINDING_NAME)
|
||||
@@ -1049,7 +1050,7 @@ namespace MobileGL {
|
||||
CASE(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT)
|
||||
CASE(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT)
|
||||
CASE(GL_TEXTURE_IMMUTABLE_FORMAT)
|
||||
//CASE(GL_VERSION_4_3)
|
||||
// CASE(GL_VERSION_4_3)
|
||||
CASE(GL_NUM_SHADING_LANGUAGE_VERSIONS)
|
||||
CASE(GL_VERTEX_ATTRIB_ARRAY_LONG)
|
||||
CASE(GL_COMPRESSED_RGB8_ETC2)
|
||||
@@ -1082,7 +1083,7 @@ namespace MobileGL {
|
||||
CASE(GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER)
|
||||
CASE(GL_DISPATCH_INDIRECT_BUFFER)
|
||||
CASE(GL_DISPATCH_INDIRECT_BUFFER_BINDING)
|
||||
//CASE(GL_COMPUTE_SHADER_BIT)
|
||||
// CASE(GL_COMPUTE_SHADER_BIT)
|
||||
CASE(GL_DEBUG_OUTPUT_SYNCHRONOUS)
|
||||
CASE(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH)
|
||||
CASE(GL_DEBUG_CALLBACK_FUNCTION)
|
||||
@@ -1119,7 +1120,7 @@ namespace MobileGL {
|
||||
CASE(GL_SAMPLER)
|
||||
CASE(GL_MAX_LABEL_LENGTH)
|
||||
CASE(GL_DEBUG_OUTPUT)
|
||||
//CASE(GL_CONTEXT_FLAG_DEBUG_BIT)
|
||||
// CASE(GL_CONTEXT_FLAG_DEBUG_BIT)
|
||||
CASE(GL_MAX_UNIFORM_LOCATIONS)
|
||||
CASE(GL_FRAMEBUFFER_DEFAULT_WIDTH)
|
||||
CASE(GL_FRAMEBUFFER_DEFAULT_HEIGHT)
|
||||
@@ -1290,7 +1291,7 @@ namespace MobileGL {
|
||||
CASE(GL_MAX_SHADER_STORAGE_BLOCK_SIZE)
|
||||
CASE(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT)
|
||||
CASE(GL_SHADER_STORAGE_BARRIER_BIT)
|
||||
//CASE(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES)
|
||||
// CASE(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES)
|
||||
CASE(GL_DEPTH_STENCIL_TEXTURE_MODE)
|
||||
CASE(GL_TEXTURE_BUFFER_OFFSET)
|
||||
CASE(GL_TEXTURE_BUFFER_SIZE)
|
||||
@@ -1308,15 +1309,15 @@ namespace MobileGL {
|
||||
CASE(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET)
|
||||
CASE(GL_MAX_VERTEX_ATTRIB_BINDINGS)
|
||||
CASE(GL_VERTEX_BINDING_BUFFER)
|
||||
//CASE(GL_VERSION_4_4)
|
||||
// CASE(GL_VERSION_4_4)
|
||||
CASE(GL_MAX_VERTEX_ATTRIB_STRIDE)
|
||||
CASE(GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED)
|
||||
//CASE(GL_TEXTURE_BUFFER_BINDING)
|
||||
//CASE(GL_MAP_PERSISTENT_BIT)
|
||||
//CASE(GL_MAP_COHERENT_BIT)
|
||||
//CASE(GL_DYNAMIC_STORAGE_BIT)
|
||||
//CASE(GL_CLIENT_STORAGE_BIT)
|
||||
//CASE(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT)
|
||||
// CASE(GL_TEXTURE_BUFFER_BINDING)
|
||||
// CASE(GL_MAP_PERSISTENT_BIT)
|
||||
// CASE(GL_MAP_COHERENT_BIT)
|
||||
// CASE(GL_DYNAMIC_STORAGE_BIT)
|
||||
// CASE(GL_CLIENT_STORAGE_BIT)
|
||||
// CASE(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT)
|
||||
CASE(GL_BUFFER_IMMUTABLE_STORAGE)
|
||||
CASE(GL_BUFFER_STORAGE_FLAGS)
|
||||
CASE(GL_CLEAR_TEXTURE)
|
||||
@@ -1328,7 +1329,7 @@ namespace MobileGL {
|
||||
CASE(GL_QUERY_BUFFER_BINDING)
|
||||
CASE(GL_QUERY_RESULT_NO_WAIT)
|
||||
CASE(GL_MIRROR_CLAMP_TO_EDGE)
|
||||
//CASE(GL_VERSION_4_5)
|
||||
// CASE(GL_VERSION_4_5)
|
||||
CASE(GL_CONTEXT_LOST)
|
||||
CASE(GL_NEGATIVE_ONE_TO_ONE)
|
||||
CASE(GL_ZERO_TO_ONE)
|
||||
@@ -1348,40 +1349,40 @@ namespace MobileGL {
|
||||
CASE(GL_RESET_NOTIFICATION_STRATEGY)
|
||||
CASE(GL_LOSE_CONTEXT_ON_RESET)
|
||||
CASE(GL_NO_RESET_NOTIFICATION)
|
||||
//CASE(GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT)
|
||||
// CASE(GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT)
|
||||
CASE(GL_CONTEXT_RELEASE_BEHAVIOR)
|
||||
CASE(GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
|
||||
CASE(GL_UNSIGNED_INT64_ARB)
|
||||
CASE(GL_SYNC_CL_EVENT_ARB)
|
||||
CASE(GL_SYNC_CL_EVENT_COMPLETE_ARB)
|
||||
CASE(GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB)
|
||||
//CASE(GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB)
|
||||
// CASE(GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB)
|
||||
CASE(GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB)
|
||||
//CASE(GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB)
|
||||
//CASE(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB)
|
||||
//CASE(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB)
|
||||
//CASE(GL_DEBUG_CALLBACK_FUNCTION_ARB)
|
||||
//CASE(GL_DEBUG_CALLBACK_USER_PARAM_ARB)
|
||||
//CASE(GL_DEBUG_SOURCE_API_ARB)
|
||||
//CASE(GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB)
|
||||
//CASE(GL_DEBUG_SOURCE_SHADER_COMPILER_ARB)
|
||||
//CASE(GL_DEBUG_SOURCE_THIRD_PARTY_ARB)
|
||||
//CASE(GL_DEBUG_SOURCE_APPLICATION_ARB)
|
||||
//CASE(GL_DEBUG_SOURCE_OTHER_ARB)
|
||||
//CASE(GL_DEBUG_TYPE_ERROR_ARB)
|
||||
//CASE(GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB)
|
||||
//CASE(GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB)
|
||||
//CASE(GL_DEBUG_TYPE_PORTABILITY_ARB)
|
||||
//CASE(GL_DEBUG_TYPE_PERFORMANCE_ARB)
|
||||
//CASE(GL_DEBUG_TYPE_OTHER_ARB)
|
||||
//CASE(GL_MAX_DEBUG_MESSAGE_LENGTH_ARB)
|
||||
//CASE(GL_MAX_DEBUG_LOGGED_MESSAGES_ARB)
|
||||
//CASE(GL_DEBUG_LOGGED_MESSAGES_ARB)
|
||||
//CASE(GL_DEBUG_SEVERITY_HIGH_ARB)
|
||||
//CASE(GL_DEBUG_SEVERITY_MEDIUM_ARB)
|
||||
//CASE(GL_DEBUG_SEVERITY_LOW_ARB)
|
||||
// CASE(GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB)
|
||||
// CASE(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB)
|
||||
// CASE(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB)
|
||||
// CASE(GL_DEBUG_CALLBACK_FUNCTION_ARB)
|
||||
// CASE(GL_DEBUG_CALLBACK_USER_PARAM_ARB)
|
||||
// CASE(GL_DEBUG_SOURCE_API_ARB)
|
||||
// CASE(GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB)
|
||||
// CASE(GL_DEBUG_SOURCE_SHADER_COMPILER_ARB)
|
||||
// CASE(GL_DEBUG_SOURCE_THIRD_PARTY_ARB)
|
||||
// CASE(GL_DEBUG_SOURCE_APPLICATION_ARB)
|
||||
// CASE(GL_DEBUG_SOURCE_OTHER_ARB)
|
||||
// CASE(GL_DEBUG_TYPE_ERROR_ARB)
|
||||
// CASE(GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB)
|
||||
// CASE(GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB)
|
||||
// CASE(GL_DEBUG_TYPE_PORTABILITY_ARB)
|
||||
// CASE(GL_DEBUG_TYPE_PERFORMANCE_ARB)
|
||||
// CASE(GL_DEBUG_TYPE_OTHER_ARB)
|
||||
// CASE(GL_MAX_DEBUG_MESSAGE_LENGTH_ARB)
|
||||
// CASE(GL_MAX_DEBUG_LOGGED_MESSAGES_ARB)
|
||||
// CASE(GL_DEBUG_LOGGED_MESSAGES_ARB)
|
||||
// CASE(GL_DEBUG_SEVERITY_HIGH_ARB)
|
||||
// CASE(GL_DEBUG_SEVERITY_MEDIUM_ARB)
|
||||
// CASE(GL_DEBUG_SEVERITY_LOW_ARB)
|
||||
CASE(GL_BLEND_COLOR)
|
||||
//CASE(GL_BLEND_EQUATION)
|
||||
// CASE(GL_BLEND_EQUATION)
|
||||
CASE(GL_PARAMETER_BUFFER_ARB)
|
||||
CASE(GL_PARAMETER_BUFFER_BINDING_ARB)
|
||||
CASE(GL_SRGB_DECODE_ARB)
|
||||
@@ -1395,19 +1396,19 @@ namespace MobileGL {
|
||||
CASE(GL_COMPUTE_SHADER_INVOCATIONS_ARB)
|
||||
CASE(GL_CLIPPING_INPUT_PRIMITIVES_ARB)
|
||||
CASE(GL_CLIPPING_OUTPUT_PRIMITIVES_ARB)
|
||||
//CASE(GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB)
|
||||
//CASE(GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||
//CASE(GL_GUILTY_CONTEXT_RESET_ARB)
|
||||
//CASE(GL_INNOCENT_CONTEXT_RESET_ARB)
|
||||
//CASE(GL_UNKNOWN_CONTEXT_RESET_ARB)
|
||||
//CASE(GL_RESET_NOTIFICATION_STRATEGY_ARB)
|
||||
//CASE(GL_NO_RESET_NOTIFICATION_ARB)
|
||||
//CASE(GL_SAMPLE_SHADING_ARB)
|
||||
//CASE(GL_MIN_SAMPLE_SHADING_VALUE_ARB)
|
||||
// CASE(GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB)
|
||||
// CASE(GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||
// CASE(GL_GUILTY_CONTEXT_RESET_ARB)
|
||||
// CASE(GL_INNOCENT_CONTEXT_RESET_ARB)
|
||||
// CASE(GL_UNKNOWN_CONTEXT_RESET_ARB)
|
||||
// CASE(GL_RESET_NOTIFICATION_STRATEGY_ARB)
|
||||
// CASE(GL_NO_RESET_NOTIFICATION_ARB)
|
||||
// CASE(GL_SAMPLE_SHADING_ARB)
|
||||
// CASE(GL_MIN_SAMPLE_SHADING_VALUE_ARB)
|
||||
CASE(GL_SHADER_INCLUDE_ARB)
|
||||
CASE(GL_NAMED_STRING_LENGTH_ARB)
|
||||
CASE(GL_NAMED_STRING_TYPE_ARB)
|
||||
//CASE(GL_SPARSE_STORAGE_BIT_ARB)
|
||||
// CASE(GL_SPARSE_STORAGE_BIT_ARB)
|
||||
CASE(GL_SPARSE_BUFFER_PAGE_SIZE_ARB)
|
||||
CASE(GL_TEXTURE_SPARSE_ARB)
|
||||
CASE(GL_VIRTUAL_PAGE_SIZE_INDEX_ARB)
|
||||
@@ -1420,55 +1421,55 @@ namespace MobileGL {
|
||||
CASE(GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB)
|
||||
CASE(GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB)
|
||||
CASE(GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB)
|
||||
//CASE(GL_COMPRESSED_RGBA_BPTC_UNORM_ARB)
|
||||
//CASE(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB)
|
||||
//CASE(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB)
|
||||
//CASE(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB)
|
||||
//CASE(GL_TEXTURE_CUBE_MAP_ARRAY_ARB)
|
||||
//CASE(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB)
|
||||
//CASE(GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB)
|
||||
//CASE(GL_SAMPLER_CUBE_MAP_ARRAY_ARB)
|
||||
//CASE(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB)
|
||||
//CASE(GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB)
|
||||
//CASE(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB)
|
||||
//CASE(GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB)
|
||||
//CASE(GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB)
|
||||
// CASE(GL_COMPRESSED_RGBA_BPTC_UNORM_ARB)
|
||||
// CASE(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB)
|
||||
// CASE(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB)
|
||||
// CASE(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB)
|
||||
// CASE(GL_TEXTURE_CUBE_MAP_ARRAY_ARB)
|
||||
// CASE(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB)
|
||||
// CASE(GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB)
|
||||
// CASE(GL_SAMPLER_CUBE_MAP_ARRAY_ARB)
|
||||
// CASE(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB)
|
||||
// CASE(GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB)
|
||||
// CASE(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB)
|
||||
// CASE(GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB)
|
||||
// CASE(GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB)
|
||||
CASE(GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB)
|
||||
CASE(GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB)
|
||||
CASE(GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB)
|
||||
//CASE(GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
|
||||
// CASE(GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
|
||||
CASE(GL_CONTEXT_ROBUST_ACCESS)
|
||||
//CASE(GL_ACCUM)
|
||||
// CASE(GL_ACCUM)
|
||||
CASE(GL_LOAD)
|
||||
CASE(GL_RETURN)
|
||||
CASE(GL_MULT)
|
||||
CASE(GL_ADD)
|
||||
//CASE(GL_CURRENT_BIT)
|
||||
//CASE(GL_POINT_BIT)
|
||||
//CASE(GL_LINE_BIT)
|
||||
//CASE(GL_POLYGON_BIT)
|
||||
//CASE(GL_POLYGON_STIPPLE_BIT)
|
||||
//CASE(GL_PIXEL_MODE_BIT)
|
||||
//CASE(GL_LIGHTING_BIT)
|
||||
//CASE(GL_FOG_BIT)
|
||||
//CASE(GL_ACCUM_BUFFER_BIT)
|
||||
//CASE(GL_VIEWPORT_BIT)
|
||||
//CASE(GL_TRANSFORM_BIT)
|
||||
//CASE(GL_ENABLE_BIT)
|
||||
//CASE(GL_HINT_BIT)
|
||||
// CASE(GL_CURRENT_BIT)
|
||||
// CASE(GL_POINT_BIT)
|
||||
// CASE(GL_LINE_BIT)
|
||||
// CASE(GL_POLYGON_BIT)
|
||||
// CASE(GL_POLYGON_STIPPLE_BIT)
|
||||
// CASE(GL_PIXEL_MODE_BIT)
|
||||
// CASE(GL_LIGHTING_BIT)
|
||||
// CASE(GL_FOG_BIT)
|
||||
// CASE(GL_ACCUM_BUFFER_BIT)
|
||||
// CASE(GL_VIEWPORT_BIT)
|
||||
// CASE(GL_TRANSFORM_BIT)
|
||||
// CASE(GL_ENABLE_BIT)
|
||||
// CASE(GL_HINT_BIT)
|
||||
CASE(GL_EVAL_BIT)
|
||||
CASE(GL_LIST_BIT)
|
||||
CASE(GL_TEXTURE_BIT)
|
||||
CASE(GL_SCISSOR_BIT)
|
||||
CASE(GL_ALL_ATTRIB_BITS)
|
||||
//CASE(GL_QUAD_STRIP)
|
||||
// CASE(GL_QUAD_STRIP)
|
||||
CASE(GL_POLYGON)
|
||||
//CASE(GL_CLIP_PLANE0)
|
||||
//CASE(GL_CLIP_PLANE1)
|
||||
//CASE(GL_CLIP_PLANE2)
|
||||
//CASE(GL_CLIP_PLANE3)
|
||||
//CASE(GL_CLIP_PLANE4)
|
||||
//CASE(GL_CLIP_PLANE5)
|
||||
// CASE(GL_CLIP_PLANE0)
|
||||
// CASE(GL_CLIP_PLANE1)
|
||||
// CASE(GL_CLIP_PLANE2)
|
||||
// CASE(GL_CLIP_PLANE3)
|
||||
// CASE(GL_CLIP_PLANE4)
|
||||
// CASE(GL_CLIP_PLANE5)
|
||||
CASE(GL_2_BYTES)
|
||||
CASE(GL_3_BYTES)
|
||||
CASE(GL_4_BYTES)
|
||||
@@ -1489,7 +1490,7 @@ namespace MobileGL {
|
||||
CASE(GL_DRAW_PIXEL_TOKEN)
|
||||
CASE(GL_COPY_PIXEL_TOKEN)
|
||||
CASE(GL_LINE_RESET_TOKEN)
|
||||
//CASE(GL_EXP)
|
||||
// CASE(GL_EXP)
|
||||
CASE(GL_EXP2)
|
||||
CASE(GL_COEFF)
|
||||
CASE(GL_ORDER)
|
||||
@@ -1595,7 +1596,7 @@ namespace MobileGL {
|
||||
CASE(GL_DEPTH_BIAS)
|
||||
CASE(GL_MAX_EVAL_ORDER)
|
||||
CASE(GL_MAX_LIGHTS)
|
||||
//CASE(GL_MAX_CLIP_PLANES)
|
||||
// CASE(GL_MAX_CLIP_PLANES)
|
||||
CASE(GL_MAX_PIXEL_MAP_TABLE)
|
||||
CASE(GL_MAX_ATTRIB_STACK_DEPTH)
|
||||
CASE(GL_MAX_MODELVIEW_STACK_DEPTH)
|
||||
@@ -1644,7 +1645,7 @@ namespace MobileGL {
|
||||
CASE(GL_SELECTION_BUFFER_POINTER)
|
||||
CASE(GL_SELECTION_BUFFER_SIZE)
|
||||
CASE(GL_TEXTURE_BORDER)
|
||||
//CASE(GL_LIGHT0)
|
||||
// CASE(GL_LIGHT0)
|
||||
CASE(GL_LIGHT1)
|
||||
CASE(GL_LIGHT2)
|
||||
CASE(GL_LIGHT3)
|
||||
@@ -1679,7 +1680,7 @@ namespace MobileGL {
|
||||
CASE(GL_SELECT)
|
||||
CASE(GL_FLAT)
|
||||
CASE(GL_SMOOTH)
|
||||
//CASE(GL_S)
|
||||
// CASE(GL_S)
|
||||
CASE(GL_T)
|
||||
CASE(GL_R)
|
||||
CASE(GL_Q)
|
||||
@@ -1695,8 +1696,8 @@ namespace MobileGL {
|
||||
CASE(GL_OBJECT_PLANE)
|
||||
CASE(GL_EYE_PLANE)
|
||||
CASE(GL_CLAMP)
|
||||
//CASE(GL_CLIENT_PIXEL_STORE_BIT)
|
||||
//CASE(GL_CLIENT_VERTEX_ARRAY_BIT)
|
||||
// CASE(GL_CLIENT_PIXEL_STORE_BIT)
|
||||
// CASE(GL_CLIENT_VERTEX_ARRAY_BIT)
|
||||
CASE(GL_ALPHA4)
|
||||
CASE(GL_ALPHA8)
|
||||
CASE(GL_ALPHA12)
|
||||
@@ -1759,56 +1760,56 @@ namespace MobileGL {
|
||||
CASE(GL_T2F_N3F_V3F)
|
||||
CASE(GL_T2F_C4F_N3F_V3F)
|
||||
CASE(GL_T4F_C4F_N3F_V4F)
|
||||
//CASE(GL_VERTEX_ARRAY_EXT)
|
||||
//CASE(GL_NORMAL_ARRAY_EXT)
|
||||
//CASE(GL_COLOR_ARRAY_EXT)
|
||||
//CASE(GL_INDEX_ARRAY_EXT)
|
||||
//CASE(GL_TEXTURE_COORD_ARRAY_EXT)
|
||||
//CASE(GL_EDGE_FLAG_ARRAY_EXT)
|
||||
//CASE(GL_VERTEX_ARRAY_SIZE_EXT)
|
||||
//CASE(GL_VERTEX_ARRAY_TYPE_EXT)
|
||||
//CASE(GL_VERTEX_ARRAY_STRIDE_EXT)
|
||||
// CASE(GL_VERTEX_ARRAY_EXT)
|
||||
// CASE(GL_NORMAL_ARRAY_EXT)
|
||||
// CASE(GL_COLOR_ARRAY_EXT)
|
||||
// CASE(GL_INDEX_ARRAY_EXT)
|
||||
// CASE(GL_TEXTURE_COORD_ARRAY_EXT)
|
||||
// CASE(GL_EDGE_FLAG_ARRAY_EXT)
|
||||
// CASE(GL_VERTEX_ARRAY_SIZE_EXT)
|
||||
// CASE(GL_VERTEX_ARRAY_TYPE_EXT)
|
||||
// CASE(GL_VERTEX_ARRAY_STRIDE_EXT)
|
||||
CASE(GL_VERTEX_ARRAY_COUNT_EXT)
|
||||
//CASE(GL_NORMAL_ARRAY_TYPE_EXT)
|
||||
//CASE(GL_NORMAL_ARRAY_STRIDE_EXT)
|
||||
// CASE(GL_NORMAL_ARRAY_TYPE_EXT)
|
||||
// CASE(GL_NORMAL_ARRAY_STRIDE_EXT)
|
||||
CASE(GL_NORMAL_ARRAY_COUNT_EXT)
|
||||
//CASE(GL_COLOR_ARRAY_SIZE_EXT)
|
||||
//CASE(GL_COLOR_ARRAY_TYPE_EXT)
|
||||
//CASE(GL_COLOR_ARRAY_STRIDE_EXT)
|
||||
// CASE(GL_COLOR_ARRAY_SIZE_EXT)
|
||||
// CASE(GL_COLOR_ARRAY_TYPE_EXT)
|
||||
// CASE(GL_COLOR_ARRAY_STRIDE_EXT)
|
||||
CASE(GL_COLOR_ARRAY_COUNT_EXT)
|
||||
//CASE(GL_INDEX_ARRAY_TYPE_EXT)
|
||||
//CASE(GL_INDEX_ARRAY_STRIDE_EXT)
|
||||
// CASE(GL_INDEX_ARRAY_TYPE_EXT)
|
||||
// CASE(GL_INDEX_ARRAY_STRIDE_EXT)
|
||||
CASE(GL_INDEX_ARRAY_COUNT_EXT)
|
||||
//CASE(GL_TEXTURE_COORD_ARRAY_SIZE_EXT)
|
||||
//CASE(GL_TEXTURE_COORD_ARRAY_TYPE_EXT)
|
||||
//CASE(GL_TEXTURE_COORD_ARRAY_STRIDE_EXT)
|
||||
// CASE(GL_TEXTURE_COORD_ARRAY_SIZE_EXT)
|
||||
// CASE(GL_TEXTURE_COORD_ARRAY_TYPE_EXT)
|
||||
// CASE(GL_TEXTURE_COORD_ARRAY_STRIDE_EXT)
|
||||
CASE(GL_TEXTURE_COORD_ARRAY_COUNT_EXT)
|
||||
//CASE(GL_EDGE_FLAG_ARRAY_STRIDE_EXT)
|
||||
// CASE(GL_EDGE_FLAG_ARRAY_STRIDE_EXT)
|
||||
CASE(GL_EDGE_FLAG_ARRAY_COUNT_EXT)
|
||||
//CASE(GL_VERTEX_ARRAY_POINTER_EXT)
|
||||
//CASE(GL_NORMAL_ARRAY_POINTER_EXT)
|
||||
//CASE(GL_COLOR_ARRAY_POINTER_EXT)
|
||||
//CASE(GL_INDEX_ARRAY_POINTER_EXT)
|
||||
//CASE(GL_TEXTURE_COORD_ARRAY_POINTER_EXT)
|
||||
//CASE(GL_EDGE_FLAG_ARRAY_POINTER_EXT)
|
||||
//CASE(GL_BGR_EXT)
|
||||
//CASE(GL_BGRA_EXT)
|
||||
//CASE(GL_COLOR_TABLE_FORMAT_EXT)
|
||||
//CASE(GL_COLOR_TABLE_WIDTH_EXT)
|
||||
//CASE(GL_COLOR_TABLE_RED_SIZE_EXT)
|
||||
//CASE(GL_COLOR_TABLE_GREEN_SIZE_EXT)
|
||||
//CASE(GL_COLOR_TABLE_BLUE_SIZE_EXT)
|
||||
//CASE(GL_COLOR_TABLE_ALPHA_SIZE_EXT)
|
||||
//CASE(GL_COLOR_TABLE_LUMINANCE_SIZE_EXT)
|
||||
//CASE(GL_COLOR_TABLE_INTENSITY_SIZE_EXT)
|
||||
// CASE(GL_VERTEX_ARRAY_POINTER_EXT)
|
||||
// CASE(GL_NORMAL_ARRAY_POINTER_EXT)
|
||||
// CASE(GL_COLOR_ARRAY_POINTER_EXT)
|
||||
// CASE(GL_INDEX_ARRAY_POINTER_EXT)
|
||||
// CASE(GL_TEXTURE_COORD_ARRAY_POINTER_EXT)
|
||||
// CASE(GL_EDGE_FLAG_ARRAY_POINTER_EXT)
|
||||
// CASE(GL_BGR_EXT)
|
||||
// CASE(GL_BGRA_EXT)
|
||||
// CASE(GL_COLOR_TABLE_FORMAT_EXT)
|
||||
// CASE(GL_COLOR_TABLE_WIDTH_EXT)
|
||||
// CASE(GL_COLOR_TABLE_RED_SIZE_EXT)
|
||||
// CASE(GL_COLOR_TABLE_GREEN_SIZE_EXT)
|
||||
// CASE(GL_COLOR_TABLE_BLUE_SIZE_EXT)
|
||||
// CASE(GL_COLOR_TABLE_ALPHA_SIZE_EXT)
|
||||
// CASE(GL_COLOR_TABLE_LUMINANCE_SIZE_EXT)
|
||||
// CASE(GL_COLOR_TABLE_INTENSITY_SIZE_EXT)
|
||||
CASE(GL_COLOR_INDEX1_EXT)
|
||||
CASE(GL_COLOR_INDEX2_EXT)
|
||||
CASE(GL_COLOR_INDEX4_EXT)
|
||||
CASE(GL_COLOR_INDEX8_EXT)
|
||||
CASE(GL_COLOR_INDEX12_EXT)
|
||||
CASE(GL_COLOR_INDEX16_EXT)
|
||||
//CASE(GL_MAX_ELEMENTS_VERTICES_WIN)
|
||||
//CASE(GL_MAX_ELEMENTS_INDICES_WIN)
|
||||
// CASE(GL_MAX_ELEMENTS_VERTICES_WIN)
|
||||
// CASE(GL_MAX_ELEMENTS_INDICES_WIN)
|
||||
CASE(GL_PHONG_WIN)
|
||||
CASE(GL_PHONG_HINT_WIN)
|
||||
CASE(GL_FOG_SPECULAR_TEXTURE_WIN)
|
||||
@@ -1817,6 +1818,6 @@ namespace MobileGL {
|
||||
return std::format("0x%x", value);
|
||||
}
|
||||
#undef CASE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
String ConvertGLEnumToString(GLenum value);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
String ConvertGLEnumToString(GLenum value);
|
||||
}
|
||||
} // namespace MobileGL
|
||||
@@ -1,54 +1,79 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "BufferEnumConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget) {
|
||||
switch (bufferTarget) {
|
||||
case BufferTarget::Vertex: return GL_ARRAY_BUFFER;
|
||||
case BufferTarget::Index: return GL_ELEMENT_ARRAY_BUFFER;
|
||||
case BufferTarget::Uniform: return GL_UNIFORM_BUFFER;
|
||||
case BufferTarget::CopyRead: return GL_COPY_READ_BUFFER;
|
||||
case BufferTarget::CopyWrite: return GL_COPY_WRITE_BUFFER;
|
||||
case BufferTarget::PixelPack: return GL_PIXEL_PACK_BUFFER;
|
||||
case BufferTarget::PixelUnpack: return GL_PIXEL_UNPACK_BUFFER;
|
||||
case BufferTarget::Query: return GL_QUERY_BUFFER;
|
||||
case BufferTarget::Texture: return GL_TEXTURE_BUFFER;
|
||||
case BufferTarget::TransformFeedback: return GL_TRANSFORM_FEEDBACK_BUFFER;
|
||||
case BufferTarget::AtomicCounter: return GL_ATOMIC_COUNTER_BUFFER;
|
||||
case BufferTarget::DispatchIndirect: return GL_DISPATCH_INDIRECT_BUFFER;
|
||||
case BufferTarget::DrawIndirect: return GL_DRAW_INDIRECT_BUFFER;
|
||||
case BufferTarget::ShaderStorage: return GL_SHADER_STORAGE_BUFFER;
|
||||
case BufferTarget::Unknown:
|
||||
default: return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget) {
|
||||
switch (bufferTarget) {
|
||||
case BufferTarget::Vertex:
|
||||
return GL_ARRAY_BUFFER;
|
||||
case BufferTarget::Index:
|
||||
return GL_ELEMENT_ARRAY_BUFFER;
|
||||
case BufferTarget::Uniform:
|
||||
return GL_UNIFORM_BUFFER;
|
||||
case BufferTarget::CopyRead:
|
||||
return GL_COPY_READ_BUFFER;
|
||||
case BufferTarget::CopyWrite:
|
||||
return GL_COPY_WRITE_BUFFER;
|
||||
case BufferTarget::PixelPack:
|
||||
return GL_PIXEL_PACK_BUFFER;
|
||||
case BufferTarget::PixelUnpack:
|
||||
return GL_PIXEL_UNPACK_BUFFER;
|
||||
case BufferTarget::Query:
|
||||
return GL_QUERY_BUFFER;
|
||||
case BufferTarget::Texture:
|
||||
return GL_TEXTURE_BUFFER;
|
||||
case BufferTarget::TransformFeedback:
|
||||
return GL_TRANSFORM_FEEDBACK_BUFFER;
|
||||
case BufferTarget::AtomicCounter:
|
||||
return GL_ATOMIC_COUNTER_BUFFER;
|
||||
case BufferTarget::DispatchIndirect:
|
||||
return GL_DISPATCH_INDIRECT_BUFFER;
|
||||
case BufferTarget::DrawIndirect:
|
||||
return GL_DRAW_INDIRECT_BUFFER;
|
||||
case BufferTarget::ShaderStorage:
|
||||
return GL_SHADER_STORAGE_BUFFER;
|
||||
case BufferTarget::Unknown:
|
||||
default:
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum ConvertBufferUsageToGLEnum(BufferUsage usage) {
|
||||
switch (usage) {
|
||||
case BufferUsage::StreamDraw: return GL_STREAM_DRAW;
|
||||
case BufferUsage::StreamRead: return GL_STREAM_READ;
|
||||
case BufferUsage::StreamCopy: return GL_STREAM_COPY;
|
||||
case BufferUsage::StaticDraw: return GL_STATIC_DRAW;
|
||||
case BufferUsage::StaticRead: return GL_STATIC_READ;
|
||||
case BufferUsage::StaticCopy: return GL_STATIC_COPY;
|
||||
case BufferUsage::DynamicDraw: return GL_DYNAMIC_DRAW;
|
||||
case BufferUsage::DynamicRead: return GL_DYNAMIC_READ;
|
||||
case BufferUsage::DynamicCopy: return GL_DYNAMIC_COPY;
|
||||
default: return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
GLenum ConvertBufferUsageToGLEnum(BufferUsage usage) {
|
||||
switch (usage) {
|
||||
case BufferUsage::StreamDraw:
|
||||
return GL_STREAM_DRAW;
|
||||
case BufferUsage::StreamRead:
|
||||
return GL_STREAM_READ;
|
||||
case BufferUsage::StreamCopy:
|
||||
return GL_STREAM_COPY;
|
||||
case BufferUsage::StaticDraw:
|
||||
return GL_STATIC_DRAW;
|
||||
case BufferUsage::StaticRead:
|
||||
return GL_STATIC_READ;
|
||||
case BufferUsage::StaticCopy:
|
||||
return GL_STATIC_COPY;
|
||||
case BufferUsage::DynamicDraw:
|
||||
return GL_DYNAMIC_DRAW;
|
||||
case BufferUsage::DynamicRead:
|
||||
return GL_DYNAMIC_READ;
|
||||
case BufferUsage::DynamicCopy:
|
||||
return GL_DYNAMIC_COPY;
|
||||
default:
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
|
||||
GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access) {
|
||||
GLbitfield result = 0;
|
||||
if (access & BufferMappingAccessBit::Read) result |= GL_MAP_READ_BIT;
|
||||
if (access & BufferMappingAccessBit::Write) result |= GL_MAP_WRITE_BIT;
|
||||
if (access & BufferMappingAccessBit::InvalidateRange) result |= GL_MAP_INVALIDATE_RANGE_BIT;
|
||||
if (access & BufferMappingAccessBit::InvalidateBuffer) result |= GL_MAP_INVALIDATE_BUFFER_BIT;
|
||||
if (access & BufferMappingAccessBit::FlushExplicit) result |= GL_MAP_FLUSH_EXPLICIT_BIT;
|
||||
if (access & BufferMappingAccessBit::Unsynchronized) result |= GL_MAP_UNSYNCHRONIZED_BIT;
|
||||
if (access & BufferMappingAccessBit::Persistent) result |= GL_MAP_PERSISTENT_BIT;
|
||||
if (access & BufferMappingAccessBit::Coherent) result |= GL_MAP_COHERENT_BIT;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access) {
|
||||
GLbitfield result = 0;
|
||||
if (access & BufferMappingAccessBit::Read) result |= GL_MAP_READ_BIT;
|
||||
if (access & BufferMappingAccessBit::Write) result |= GL_MAP_WRITE_BIT;
|
||||
if (access & BufferMappingAccessBit::InvalidateRange) result |= GL_MAP_INVALIDATE_RANGE_BIT;
|
||||
if (access & BufferMappingAccessBit::InvalidateBuffer) result |= GL_MAP_INVALIDATE_BUFFER_BIT;
|
||||
if (access & BufferMappingAccessBit::FlushExplicit) result |= GL_MAP_FLUSH_EXPLICIT_BIT;
|
||||
if (access & BufferMappingAccessBit::Unsynchronized) result |= GL_MAP_UNSYNCHRONIZED_BIT;
|
||||
if (access & BufferMappingAccessBit::Persistent) result |= GL_MAP_PERSISTENT_BIT;
|
||||
if (access & BufferMappingAccessBit::Coherent) result |= GL_MAP_COHERENT_BIT;
|
||||
return result;
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget);
|
||||
GLenum ConvertBufferUsageToGLEnum(BufferUsage usage);
|
||||
GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget);
|
||||
GLenum ConvertBufferUsageToGLEnum(BufferUsage usage);
|
||||
GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access);
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,21 +1,30 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "DataTypeConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
GLenum ConvertDataTypeToGLEnum(DataType type) {
|
||||
switch (type) {
|
||||
case DataType::Int8: return GL_BYTE;
|
||||
case DataType::Uint8: return GL_UNSIGNED_BYTE;
|
||||
case DataType::Int16: return GL_SHORT;
|
||||
case DataType::Uint16: return GL_UNSIGNED_SHORT;
|
||||
case DataType::Int32: return GL_INT;
|
||||
case DataType::Uint32: return GL_UNSIGNED_INT;
|
||||
case DataType::Float16: return GL_HALF_FLOAT;
|
||||
case DataType::Float32: return GL_FLOAT;
|
||||
case DataType::Float64: return GL_DOUBLE;
|
||||
default:
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
GLenum ConvertDataTypeToGLEnum(DataType type) {
|
||||
switch (type) {
|
||||
case DataType::Int8:
|
||||
return GL_BYTE;
|
||||
case DataType::Uint8:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
case DataType::Int16:
|
||||
return GL_SHORT;
|
||||
case DataType::Uint16:
|
||||
return GL_UNSIGNED_SHORT;
|
||||
case DataType::Int32:
|
||||
return GL_INT;
|
||||
case DataType::Uint32:
|
||||
return GL_UNSIGNED_INT;
|
||||
case DataType::Float16:
|
||||
return GL_HALF_FLOAT;
|
||||
case DataType::Float32:
|
||||
return GL_FLOAT;
|
||||
case DataType::Float64:
|
||||
return GL_DOUBLE;
|
||||
default:
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
GLenum ConvertDataTypeToGLEnum(DataType type);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
GLenum ConvertDataTypeToGLEnum(DataType type);
|
||||
}
|
||||
} // namespace MobileGL
|
||||
@@ -1,28 +1,28 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "ErrorCodeConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
GLenum ConvertErrorCodeToGLEnum(ErrorCode code) {
|
||||
switch (code) {
|
||||
case ErrorCode::NoError:
|
||||
return GL_NO_ERROR;
|
||||
case ErrorCode::InvalidEnum:
|
||||
return GL_INVALID_ENUM;
|
||||
case ErrorCode::InvalidValue:
|
||||
return GL_INVALID_VALUE;
|
||||
case ErrorCode::InvalidOperation:
|
||||
return GL_INVALID_OPERATION;
|
||||
case ErrorCode::InvalidFramebufferOperation:
|
||||
return GL_INVALID_FRAMEBUFFER_OPERATION;
|
||||
case ErrorCode::OutOfMemory:
|
||||
return GL_OUT_OF_MEMORY;
|
||||
case ErrorCode::StackUnderflow:
|
||||
return GL_STACK_UNDERFLOW;
|
||||
case ErrorCode::StackOverflow:
|
||||
return GL_STACK_OVERFLOW;
|
||||
default:
|
||||
return GL_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
GLenum ConvertErrorCodeToGLEnum(ErrorCode code) {
|
||||
switch (code) {
|
||||
case ErrorCode::NoError:
|
||||
return GL_NO_ERROR;
|
||||
case ErrorCode::InvalidEnum:
|
||||
return GL_INVALID_ENUM;
|
||||
case ErrorCode::InvalidValue:
|
||||
return GL_INVALID_VALUE;
|
||||
case ErrorCode::InvalidOperation:
|
||||
return GL_INVALID_OPERATION;
|
||||
case ErrorCode::InvalidFramebufferOperation:
|
||||
return GL_INVALID_FRAMEBUFFER_OPERATION;
|
||||
case ErrorCode::OutOfMemory:
|
||||
return GL_OUT_OF_MEMORY;
|
||||
case ErrorCode::StackUnderflow:
|
||||
return GL_STACK_UNDERFLOW;
|
||||
case ErrorCode::StackOverflow:
|
||||
return GL_STACK_OVERFLOW;
|
||||
default:
|
||||
return GL_NO_ERROR;
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/ErrorState/ErrorCode.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
GLenum ConvertErrorCodeToGLEnum(ErrorCode code);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
GLenum ConvertErrorCodeToGLEnum(ErrorCode code);
|
||||
}
|
||||
} // namespace MobileGL
|
||||
@@ -1,57 +1,82 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "BufferEnumConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
String ConvertBufferTargetToString(BufferTarget bufferTarget) {
|
||||
switch (bufferTarget) {
|
||||
case BufferTarget::Vertex: return "Vertex";
|
||||
case BufferTarget::Index: return "Index";
|
||||
case BufferTarget::Uniform: return "Uniform";
|
||||
case BufferTarget::CopyRead: return "CopyRead";
|
||||
case BufferTarget::CopyWrite: return "CopyWrite";
|
||||
case BufferTarget::PixelPack: return "PixelPack";
|
||||
case BufferTarget::PixelUnpack: return "PixelUnpack";
|
||||
case BufferTarget::Query: return "Query";
|
||||
case BufferTarget::Texture: return "Texture";
|
||||
case BufferTarget::TransformFeedback: return "TransformFeedback";
|
||||
case BufferTarget::AtomicCounter: return "AtomicCounter";
|
||||
case BufferTarget::DispatchIndirect: return "DispatchIndirect";
|
||||
case BufferTarget::DrawIndirect: return "DrawIndirect";
|
||||
case BufferTarget::ShaderStorage: return "ShaderStorage";
|
||||
case BufferTarget::Unknown:
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
String ConvertBufferTargetToString(BufferTarget bufferTarget) {
|
||||
switch (bufferTarget) {
|
||||
case BufferTarget::Vertex:
|
||||
return "Vertex";
|
||||
case BufferTarget::Index:
|
||||
return "Index";
|
||||
case BufferTarget::Uniform:
|
||||
return "Uniform";
|
||||
case BufferTarget::CopyRead:
|
||||
return "CopyRead";
|
||||
case BufferTarget::CopyWrite:
|
||||
return "CopyWrite";
|
||||
case BufferTarget::PixelPack:
|
||||
return "PixelPack";
|
||||
case BufferTarget::PixelUnpack:
|
||||
return "PixelUnpack";
|
||||
case BufferTarget::Query:
|
||||
return "Query";
|
||||
case BufferTarget::Texture:
|
||||
return "Texture";
|
||||
case BufferTarget::TransformFeedback:
|
||||
return "TransformFeedback";
|
||||
case BufferTarget::AtomicCounter:
|
||||
return "AtomicCounter";
|
||||
case BufferTarget::DispatchIndirect:
|
||||
return "DispatchIndirect";
|
||||
case BufferTarget::DrawIndirect:
|
||||
return "DrawIndirect";
|
||||
case BufferTarget::ShaderStorage:
|
||||
return "ShaderStorage";
|
||||
case BufferTarget::Unknown:
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
String ConvertBufferUsageToString(BufferUsage usage) {
|
||||
switch (usage) {
|
||||
case BufferUsage::StreamDraw: return "StreamDraw";
|
||||
case BufferUsage::StreamRead: return "StreamRead";
|
||||
case BufferUsage::StreamCopy: return "StreamCopy";
|
||||
case BufferUsage::StaticDraw: return "StaticDraw";
|
||||
case BufferUsage::StaticRead: return "StaticRead";
|
||||
case BufferUsage::StaticCopy: return "StaticCopy";
|
||||
case BufferUsage::DynamicDraw: return "DynamicDraw";
|
||||
case BufferUsage::DynamicRead: return "DynamicRead";
|
||||
case BufferUsage::DynamicCopy: return "DynamicCopy";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
String ConvertBufferUsageToString(BufferUsage usage) {
|
||||
switch (usage) {
|
||||
case BufferUsage::StreamDraw:
|
||||
return "StreamDraw";
|
||||
case BufferUsage::StreamRead:
|
||||
return "StreamRead";
|
||||
case BufferUsage::StreamCopy:
|
||||
return "StreamCopy";
|
||||
case BufferUsage::StaticDraw:
|
||||
return "StaticDraw";
|
||||
case BufferUsage::StaticRead:
|
||||
return "StaticRead";
|
||||
case BufferUsage::StaticCopy:
|
||||
return "StaticCopy";
|
||||
case BufferUsage::DynamicDraw:
|
||||
return "DynamicDraw";
|
||||
case BufferUsage::DynamicRead:
|
||||
return "DynamicRead";
|
||||
case BufferUsage::DynamicCopy:
|
||||
return "DynamicCopy";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
String ConvertBufferMappingAccessToString(Flags<BufferMappingAccessBit> access) {
|
||||
String result = "[";
|
||||
if (access & BufferMappingAccessBit::Read) result += "Read, ";
|
||||
if (access & BufferMappingAccessBit::Write) result += "Write, ";
|
||||
if (access & BufferMappingAccessBit::InvalidateRange) result += "InvalidateRange, ";
|
||||
if (access & BufferMappingAccessBit::InvalidateBuffer) result += "InvalidateBuffer, ";
|
||||
if (access & BufferMappingAccessBit::FlushExplicit) result += "FlushExplicit, ";
|
||||
if (access & BufferMappingAccessBit::Unsynchronized) result += "Unsynchronized, ";
|
||||
if (access & BufferMappingAccessBit::Persistent) result += "Persistent, ";
|
||||
if (access & BufferMappingAccessBit::Coherent) result += "Coherent, ";
|
||||
result.pop_back();
|
||||
result.pop_back();
|
||||
result += "]";
|
||||
return result.empty() ? "[]" : result;
|
||||
}
|
||||
}
|
||||
}
|
||||
String ConvertBufferMappingAccessToString(Flags<BufferMappingAccessBit> access) {
|
||||
String result = "[";
|
||||
if (access & BufferMappingAccessBit::Read) result += "Read, ";
|
||||
if (access & BufferMappingAccessBit::Write) result += "Write, ";
|
||||
if (access & BufferMappingAccessBit::InvalidateRange) result += "InvalidateRange, ";
|
||||
if (access & BufferMappingAccessBit::InvalidateBuffer) result += "InvalidateBuffer, ";
|
||||
if (access & BufferMappingAccessBit::FlushExplicit) result += "FlushExplicit, ";
|
||||
if (access & BufferMappingAccessBit::Unsynchronized) result += "Unsynchronized, ";
|
||||
if (access & BufferMappingAccessBit::Persistent) result += "Persistent, ";
|
||||
if (access & BufferMappingAccessBit::Coherent) result += "Coherent, ";
|
||||
result.pop_back();
|
||||
result.pop_back();
|
||||
result += "]";
|
||||
return result.empty() ? "[]" : result;
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
String ConvertBufferTargetToString(BufferTarget bufferTarget);
|
||||
String ConvertBufferUsageToString(BufferUsage usage);
|
||||
String ConvertBufferMappingAccessToString(Flags<BufferMappingAccessBit> access);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
String ConvertBufferTargetToString(BufferTarget bufferTarget);
|
||||
String ConvertBufferUsageToString(BufferUsage usage);
|
||||
String ConvertBufferMappingAccessToString(Flags<BufferMappingAccessBit> access);
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,22 +1,33 @@
|
||||
#include "../../../Includes.h"
|
||||
#include "DataTypeConverter.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
String ConvertDataTypeToString(DataType type) {
|
||||
switch (type) {
|
||||
case DataType::Int8: return "Int8";
|
||||
case DataType::Uint8: return "Uint8";
|
||||
case DataType::Int16: return "Int16";
|
||||
case DataType::Uint16: return "Uint16";
|
||||
case DataType::Int32: return "Int32";
|
||||
case DataType::Uint32: return "Uint32";
|
||||
case DataType::Float16: return "Float16";
|
||||
case DataType::Float32: return "Float32";
|
||||
case DataType::Float64: return "Float64";
|
||||
case DataType::Fixed32: return "Fixed32";
|
||||
case DataType::Unknown:
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
String ConvertDataTypeToString(DataType type) {
|
||||
switch (type) {
|
||||
case DataType::Int8:
|
||||
return "Int8";
|
||||
case DataType::Uint8:
|
||||
return "Uint8";
|
||||
case DataType::Int16:
|
||||
return "Int16";
|
||||
case DataType::Uint16:
|
||||
return "Uint16";
|
||||
case DataType::Int32:
|
||||
return "Int32";
|
||||
case DataType::Uint32:
|
||||
return "Uint32";
|
||||
case DataType::Float16:
|
||||
return "Float16";
|
||||
case DataType::Float32:
|
||||
return "Float32";
|
||||
case DataType::Float64:
|
||||
return "Float64";
|
||||
case DataType::Fixed32:
|
||||
return "Fixed32";
|
||||
case DataType::Unknown:
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
String ConvertDataTypeToString(DataType type);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
String ConvertDataTypeToString(DataType type);
|
||||
}
|
||||
} // namespace MobileGL
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
String ConvertetGLExtToString(GLExtension extension);
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
String ConvertetGLExtToString(GLExtension extension);
|
||||
}
|
||||
} // namespace MobileGL
|
||||
@@ -1,56 +1,62 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
#define MOBILEGL_LOG_LEVEL_DEBUG 0
|
||||
#define MOBILEGL_LOG_LEVEL_WARN 1
|
||||
#define MOBILEGL_LOG_LEVEL_WARN 1
|
||||
#define MOBILEGL_LOG_LEVEL_ERROR 2
|
||||
#define MOBILEGL_LOG_LEVEL_INFO 3
|
||||
#define MOBILEGL_LOG_LEVEL_INFO 3
|
||||
#define MOBILEGL_LOG_LEVEL_FATAL 4
|
||||
|
||||
#define MOBILEGL_LOG_INTERNAL(levelTag, androidLogLevel, fmt, ...) \
|
||||
do { \
|
||||
MobileGL::MG_Util::Debug::Log(levelTag, androidLogLevel, fmt, ##__VA_ARGS__); \
|
||||
} while(0)
|
||||
#define MOBILEGL_LOG_INTERNAL(levelTag, androidLogLevel, fmt, ...) \
|
||||
do { \
|
||||
MobileGL::MG_Util::Debug::Log(levelTag, androidLogLevel, fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_DEBUG
|
||||
# define MGLOG_D(fmt, ...) MOBILEGL_LOG_INTERNAL("DEBUG", ANDROID_LOG_DEBUG, fmt, ##__VA_ARGS__)
|
||||
#define MGLOG_D(fmt, ...) MOBILEGL_LOG_INTERNAL("DEBUG", ANDROID_LOG_DEBUG, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
# define MGLOG_D(fmt, ...) { }
|
||||
#define MGLOG_D(fmt, ...) \
|
||||
{}
|
||||
#endif
|
||||
|
||||
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_INFO
|
||||
# define MGLOG_I(fmt, ...) MOBILEGL_LOG_INTERNAL("INFO", ANDROID_LOG_INFO, fmt, ##__VA_ARGS__)
|
||||
#define MGLOG_I(fmt, ...) MOBILEGL_LOG_INTERNAL("INFO", ANDROID_LOG_INFO, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
# define MGLOG_I(fmt, ...) { }
|
||||
#define MGLOG_I(fmt, ...) \
|
||||
{}
|
||||
#endif
|
||||
|
||||
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_WARN
|
||||
# define MGLOG_W(fmt, ...) MOBILEGL_LOG_INTERNAL("WARN", ANDROID_LOG_WARN, fmt, ##__VA_ARGS__)
|
||||
#define MGLOG_W(fmt, ...) MOBILEGL_LOG_INTERNAL("WARN", ANDROID_LOG_WARN, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
# define MGLOG_W(fmt, ...) { }
|
||||
#define MGLOG_W(fmt, ...) \
|
||||
{}
|
||||
#endif
|
||||
|
||||
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_ERROR
|
||||
# define MGLOG_E(fmt, ...) MOBILEGL_LOG_INTERNAL("ERROR", ANDROID_LOG_ERROR, fmt, ##__VA_ARGS__)
|
||||
#define MGLOG_E(fmt, ...) MOBILEGL_LOG_INTERNAL("ERROR", ANDROID_LOG_ERROR, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
# define MGLOG_E(fmt, ...) { }
|
||||
#define MGLOG_E(fmt, ...) \
|
||||
{}
|
||||
#endif
|
||||
|
||||
#if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_FATAL
|
||||
# define MGLOG_F(fmt, ...) MOBILEGL_LOG_INTERNAL("FATAL", ANDROID_LOG_FATAL, fmt, ##__VA_ARGS__)
|
||||
#define MGLOG_F(fmt, ...) MOBILEGL_LOG_INTERNAL("FATAL", ANDROID_LOG_FATAL, fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
# define MGLOG_F(fmt, ...) { }
|
||||
#define MGLOG_F(fmt, ...) \
|
||||
{}
|
||||
#endif
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
namespace Debug {
|
||||
void Log(const char* levelTag, android_LogPriority androidLogLevel, const char* fmt, ...);
|
||||
void Log(const char* levelTag, android_LogPriority androidLogLevel, const char* fmt, ...);
|
||||
void InitFile();
|
||||
void WriteToFile(const char* msg);
|
||||
std::string GetCurrentTime();
|
||||
constexpr char* GetOSName();
|
||||
std::string GetThreadName();
|
||||
std::string GetThreadName();
|
||||
void Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Debug
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -763,4 +763,4 @@ namespace MobileGL {
|
||||
E_GL_NV_uniform_buffer_std430_layout ,
|
||||
E_GL_MESA_texture_const_bandwidth
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,38 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
template <typename IndexType>
|
||||
class IndexGenerator {
|
||||
public:
|
||||
explicit IndexGenerator(size_t initial_capacity = 1024, IndexType first_index = 0)
|
||||
: next_index_(first_index)
|
||||
{
|
||||
const size_t words_needed = (initial_capacity + 63) / 64;
|
||||
explicit IndexGenerator(SizeT initial_capacity = 1024, IndexType first_index = 0) : next_index_(first_index) {
|
||||
const SizeT words_needed = (initial_capacity + 63) / 64;
|
||||
is_valid_.resize(words_needed, ~0ull);
|
||||
freed_indices_.reserve(initial_capacity);
|
||||
}
|
||||
|
||||
void Generate(size_t n, IndexType* indices) {
|
||||
void Generate(SizeT n, IndexType* indices) {
|
||||
if (n == 0) return;
|
||||
|
||||
size_t from_freed = std::min(n, freed_indices_.size());
|
||||
SizeT from_freed = std::min(n, freed_indices_.size());
|
||||
if (from_freed > 0) {
|
||||
std::copy_n(freed_indices_.end() - from_freed, from_freed, indices);
|
||||
freed_indices_.resize(freed_indices_.size() - from_freed);
|
||||
|
||||
for (size_t i = 0; i < from_freed; ++i) {
|
||||
for (SizeT i = 0; i < from_freed; ++i) {
|
||||
SetValid(indices[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
size_t need_new = n - from_freed;
|
||||
SizeT need_new = n - from_freed;
|
||||
if (need_new > 0) {
|
||||
size_t required_index = next_index_ + need_new;
|
||||
size_t required_words = (required_index + 63) / 64;
|
||||
SizeT required_index = next_index_ + need_new;
|
||||
SizeT required_words = (required_index + 63) / 64;
|
||||
if (required_words > is_valid_.size()) {
|
||||
is_valid_.resize(required_words, ~0ull);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < need_new; ++i) {
|
||||
for (SizeT i = 0; i < need_new; ++i) {
|
||||
indices[from_freed + i] = next_index_++;
|
||||
}
|
||||
}
|
||||
@@ -48,25 +47,24 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
bool IsValid(IndexType index) const {
|
||||
size_t word = index >> 6;
|
||||
size_t bit = index & 0x3F;
|
||||
SizeT word = index >> 6;
|
||||
SizeT bit = index & 0x3F;
|
||||
return word < is_valid_.size() && (is_valid_[word] & (1ull << bit));
|
||||
}
|
||||
|
||||
size_t FreeListSize() const { return freed_indices_.size(); }
|
||||
size_t ActiveCount() const { return next_index_ - freed_indices_.size(); }
|
||||
SizeT FreeListSize() const { return freed_indices_.size(); }
|
||||
SizeT ActiveCount() const { return next_index_ - freed_indices_.size(); }
|
||||
|
||||
private:
|
||||
inline void SetValid(IndexType index, bool valid) {
|
||||
size_t word = index >> 6;
|
||||
SizeT word = index >> 6;
|
||||
uint64_t mask = 1ull << (index & 0x3F);
|
||||
|
||||
if (word >= is_valid_.size()) return;
|
||||
|
||||
if (valid) {
|
||||
is_valid_[word] |= mask;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
is_valid_[word] &= ~mask;
|
||||
}
|
||||
}
|
||||
@@ -82,4 +80,4 @@ namespace MobileGL {
|
||||
std::vector<IndexType> freed_indices_;
|
||||
std::vector<Uint64> is_valid_;
|
||||
};
|
||||
}
|
||||
} // namespace MobileGL
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
// Stubs for non-Android platforms
|
||||
#ifndef __ANDROID__
|
||||
|
||||
// Stubs for Android logging functions
|
||||
#define ANDROID_LOG_UNKNOWN 0
|
||||
#define ANDROID_LOG_DEFAULT 1
|
||||
#define ANDROID_LOG_VERBOSE 2
|
||||
#define ANDROID_LOG_DEBUG 3
|
||||
#define ANDROID_LOG_INFO 4
|
||||
#define ANDROID_LOG_WARN 5
|
||||
#define ANDROID_LOG_ERROR 6
|
||||
#define ANDROID_LOG_FATAL 7
|
||||
#define ANDROID_LOG_SILENT 8
|
||||
|
||||
typedef int android_LogPriority;
|
||||
|
||||
inline int __android_log_print(int prio, const char* tag, const char* fmt, ...) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,113 +1,114 @@
|
||||
#include "../../Includes.h"
|
||||
#include "ShaderCompiler.h"
|
||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||
#include <MG_Util/Converters/GLToGlslang/GLShaderLangConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
namespace ShaderTranspiler {
|
||||
TBuiltInResource& GetTBuiltInResourceInstance()
|
||||
{
|
||||
TBuiltInResource& GetTBuiltInResourceInstance() {
|
||||
static TBuiltInResource Resources{};
|
||||
Resources.maxLights = 32;
|
||||
Resources.maxClipPlanes = 6;
|
||||
Resources.maxTextureUnits = 32;
|
||||
Resources.maxTextureCoords = 32;
|
||||
Resources.maxVertexAttribs = 64;
|
||||
Resources.maxVertexUniformComponents = 4096;
|
||||
Resources.maxVaryingFloats = 64;
|
||||
Resources.maxVertexTextureImageUnits = 32;
|
||||
Resources.maxCombinedTextureImageUnits = 80;
|
||||
Resources.maxTextureImageUnits = 32;
|
||||
Resources.maxFragmentUniformComponents = 4096;
|
||||
Resources.maxDrawBuffers = 32;
|
||||
Resources.maxVertexUniformVectors = 128;
|
||||
Resources.maxVaryingVectors = 8;
|
||||
Resources.maxFragmentUniformVectors = 16;
|
||||
Resources.maxVertexOutputVectors = 16;
|
||||
Resources.maxFragmentInputVectors = 15;
|
||||
Resources.minProgramTexelOffset = -8;
|
||||
Resources.maxProgramTexelOffset = 7;
|
||||
Resources.maxClipDistances = 8;
|
||||
Resources.maxComputeWorkGroupCountX = 65535;
|
||||
Resources.maxComputeWorkGroupCountY = 65535;
|
||||
Resources.maxComputeWorkGroupCountZ = 65535;
|
||||
Resources.maxComputeWorkGroupSizeX = 1024;
|
||||
Resources.maxComputeWorkGroupSizeY = 1024;
|
||||
Resources.maxComputeWorkGroupSizeZ = 64;
|
||||
Resources.maxComputeUniformComponents = 1024;
|
||||
Resources.maxComputeTextureImageUnits = 16;
|
||||
Resources.maxComputeImageUniforms = 8;
|
||||
Resources.maxComputeAtomicCounters = 8;
|
||||
Resources.maxComputeAtomicCounterBuffers = 1;
|
||||
Resources.maxVaryingComponents = 60;
|
||||
Resources.maxVertexOutputComponents = 64;
|
||||
Resources.maxGeometryInputComponents = 64;
|
||||
Resources.maxGeometryOutputComponents = 128;
|
||||
Resources.maxFragmentInputComponents = 128;
|
||||
Resources.maxImageUnits = 8;
|
||||
Resources.maxCombinedImageUnitsAndFragmentOutputs = 8;
|
||||
Resources.maxCombinedShaderOutputResources = 8;
|
||||
Resources.maxImageSamples = 0;
|
||||
Resources.maxVertexImageUniforms = 0;
|
||||
Resources.maxTessControlImageUniforms = 0;
|
||||
Resources.maxTessEvaluationImageUniforms = 0;
|
||||
Resources.maxGeometryImageUniforms = 0;
|
||||
Resources.maxFragmentImageUniforms = 8;
|
||||
Resources.maxCombinedImageUniforms = 8;
|
||||
Resources.maxGeometryTextureImageUnits = 16;
|
||||
Resources.maxGeometryOutputVertices = 256;
|
||||
Resources.maxGeometryTotalOutputComponents = 1024;
|
||||
Resources.maxGeometryUniformComponents = 1024;
|
||||
Resources.maxGeometryVaryingComponents = 64;
|
||||
Resources.maxTessControlInputComponents = 128;
|
||||
Resources.maxTessControlOutputComponents = 128;
|
||||
Resources.maxTessControlTextureImageUnits = 16;
|
||||
Resources.maxTessControlUniformComponents = 1024;
|
||||
Resources.maxTessControlTotalOutputComponents = 4096;
|
||||
Resources.maxTessEvaluationInputComponents = 128;
|
||||
Resources.maxTessEvaluationOutputComponents = 128;
|
||||
Resources.maxTessEvaluationTextureImageUnits = 16;
|
||||
Resources.maxTessEvaluationUniformComponents = 1024;
|
||||
Resources.maxTessPatchComponents = 120;
|
||||
Resources.maxPatchVertices = 32;
|
||||
Resources.maxTessGenLevel = 64;
|
||||
Resources.maxViewports = 16;
|
||||
Resources.maxVertexAtomicCounters = 0;
|
||||
Resources.maxTessControlAtomicCounters = 0;
|
||||
Resources.maxTessEvaluationAtomicCounters = 0;
|
||||
Resources.maxGeometryAtomicCounters = 0;
|
||||
Resources.maxFragmentAtomicCounters = 8;
|
||||
Resources.maxCombinedAtomicCounters = 8;
|
||||
Resources.maxAtomicCounterBindings = 1;
|
||||
Resources.maxVertexAtomicCounterBuffers = 0;
|
||||
Resources.maxTessControlAtomicCounterBuffers = 0;
|
||||
Resources.maxTessEvaluationAtomicCounterBuffers = 0;
|
||||
Resources.maxGeometryAtomicCounterBuffers = 0;
|
||||
Resources.maxFragmentAtomicCounterBuffers = 1;
|
||||
Resources.maxCombinedAtomicCounterBuffers = 1;
|
||||
Resources.maxAtomicCounterBufferSize = 16384;
|
||||
Resources.maxTransformFeedbackBuffers = 4;
|
||||
Resources.maxLights = 32;
|
||||
Resources.maxClipPlanes = 6;
|
||||
Resources.maxTextureUnits = 32;
|
||||
Resources.maxTextureCoords = 32;
|
||||
Resources.maxVertexAttribs = 64;
|
||||
Resources.maxVertexUniformComponents = 4096;
|
||||
Resources.maxVaryingFloats = 64;
|
||||
Resources.maxVertexTextureImageUnits = 32;
|
||||
Resources.maxCombinedTextureImageUnits = 80;
|
||||
Resources.maxTextureImageUnits = 32;
|
||||
Resources.maxFragmentUniformComponents = 4096;
|
||||
Resources.maxDrawBuffers = 32;
|
||||
Resources.maxVertexUniformVectors = 128;
|
||||
Resources.maxVaryingVectors = 8;
|
||||
Resources.maxFragmentUniformVectors = 16;
|
||||
Resources.maxVertexOutputVectors = 16;
|
||||
Resources.maxFragmentInputVectors = 15;
|
||||
Resources.minProgramTexelOffset = -8;
|
||||
Resources.maxProgramTexelOffset = 7;
|
||||
Resources.maxClipDistances = 8;
|
||||
Resources.maxComputeWorkGroupCountX = 65535;
|
||||
Resources.maxComputeWorkGroupCountY = 65535;
|
||||
Resources.maxComputeWorkGroupCountZ = 65535;
|
||||
Resources.maxComputeWorkGroupSizeX = 1024;
|
||||
Resources.maxComputeWorkGroupSizeY = 1024;
|
||||
Resources.maxComputeWorkGroupSizeZ = 64;
|
||||
Resources.maxComputeUniformComponents = 1024;
|
||||
Resources.maxComputeTextureImageUnits = 16;
|
||||
Resources.maxComputeImageUniforms = 8;
|
||||
Resources.maxComputeAtomicCounters = 8;
|
||||
Resources.maxComputeAtomicCounterBuffers = 1;
|
||||
Resources.maxVaryingComponents = 60;
|
||||
Resources.maxVertexOutputComponents = 64;
|
||||
Resources.maxGeometryInputComponents = 64;
|
||||
Resources.maxGeometryOutputComponents = 128;
|
||||
Resources.maxFragmentInputComponents = 128;
|
||||
Resources.maxImageUnits = 8;
|
||||
Resources.maxCombinedImageUnitsAndFragmentOutputs = 8;
|
||||
Resources.maxCombinedShaderOutputResources = 8;
|
||||
Resources.maxImageSamples = 0;
|
||||
Resources.maxVertexImageUniforms = 0;
|
||||
Resources.maxTessControlImageUniforms = 0;
|
||||
Resources.maxTessEvaluationImageUniforms = 0;
|
||||
Resources.maxGeometryImageUniforms = 0;
|
||||
Resources.maxFragmentImageUniforms = 8;
|
||||
Resources.maxCombinedImageUniforms = 8;
|
||||
Resources.maxGeometryTextureImageUnits = 16;
|
||||
Resources.maxGeometryOutputVertices = 256;
|
||||
Resources.maxGeometryTotalOutputComponents = 1024;
|
||||
Resources.maxGeometryUniformComponents = 1024;
|
||||
Resources.maxGeometryVaryingComponents = 64;
|
||||
Resources.maxTessControlInputComponents = 128;
|
||||
Resources.maxTessControlOutputComponents = 128;
|
||||
Resources.maxTessControlTextureImageUnits = 16;
|
||||
Resources.maxTessControlUniformComponents = 1024;
|
||||
Resources.maxTessControlTotalOutputComponents = 4096;
|
||||
Resources.maxTessEvaluationInputComponents = 128;
|
||||
Resources.maxTessEvaluationOutputComponents = 128;
|
||||
Resources.maxTessEvaluationTextureImageUnits = 16;
|
||||
Resources.maxTessEvaluationUniformComponents = 1024;
|
||||
Resources.maxTessPatchComponents = 120;
|
||||
Resources.maxPatchVertices = 32;
|
||||
Resources.maxTessGenLevel = 64;
|
||||
Resources.maxViewports = 16;
|
||||
Resources.maxVertexAtomicCounters = 0;
|
||||
Resources.maxTessControlAtomicCounters = 0;
|
||||
Resources.maxTessEvaluationAtomicCounters = 0;
|
||||
Resources.maxGeometryAtomicCounters = 0;
|
||||
Resources.maxFragmentAtomicCounters = 8;
|
||||
Resources.maxCombinedAtomicCounters = 8;
|
||||
Resources.maxAtomicCounterBindings = 1;
|
||||
Resources.maxVertexAtomicCounterBuffers = 0;
|
||||
Resources.maxTessControlAtomicCounterBuffers = 0;
|
||||
Resources.maxTessEvaluationAtomicCounterBuffers = 0;
|
||||
Resources.maxGeometryAtomicCounterBuffers = 0;
|
||||
Resources.maxFragmentAtomicCounterBuffers = 1;
|
||||
Resources.maxCombinedAtomicCounterBuffers = 1;
|
||||
Resources.maxAtomicCounterBufferSize = 16384;
|
||||
Resources.maxTransformFeedbackBuffers = 4;
|
||||
Resources.maxTransformFeedbackInterleavedComponents = 64;
|
||||
Resources.maxCullDistances = 8;
|
||||
Resources.maxCombinedClipAndCullDistances = 8;
|
||||
Resources.maxSamples = 4;
|
||||
Resources.maxMeshOutputVerticesNV = 256;
|
||||
Resources.maxMeshOutputPrimitivesNV = 512;
|
||||
Resources.maxMeshWorkGroupSizeX_NV = 32;
|
||||
Resources.maxMeshWorkGroupSizeY_NV = 1;
|
||||
Resources.maxMeshWorkGroupSizeZ_NV = 1;
|
||||
Resources.maxTaskWorkGroupSizeX_NV = 32;
|
||||
Resources.maxTaskWorkGroupSizeY_NV = 1;
|
||||
Resources.maxTaskWorkGroupSizeZ_NV = 1;
|
||||
Resources.maxMeshViewCountNV = 4;
|
||||
Resources.maxCullDistances = 8;
|
||||
Resources.maxCombinedClipAndCullDistances = 8;
|
||||
Resources.maxSamples = 4;
|
||||
Resources.maxMeshOutputVerticesNV = 256;
|
||||
Resources.maxMeshOutputPrimitivesNV = 512;
|
||||
Resources.maxMeshWorkGroupSizeX_NV = 32;
|
||||
Resources.maxMeshWorkGroupSizeY_NV = 1;
|
||||
Resources.maxMeshWorkGroupSizeZ_NV = 1;
|
||||
Resources.maxTaskWorkGroupSizeX_NV = 32;
|
||||
Resources.maxTaskWorkGroupSizeY_NV = 1;
|
||||
Resources.maxTaskWorkGroupSizeZ_NV = 1;
|
||||
Resources.maxMeshViewCountNV = 4;
|
||||
|
||||
Resources.limits.nonInductiveForLoops = true;
|
||||
Resources.limits.whileLoops = true;
|
||||
Resources.limits.doWhileLoops = true;
|
||||
Resources.limits.generalUniformIndexing = true;
|
||||
Resources.limits.nonInductiveForLoops = true;
|
||||
Resources.limits.whileLoops = true;
|
||||
Resources.limits.doWhileLoops = true;
|
||||
Resources.limits.generalUniformIndexing = true;
|
||||
Resources.limits.generalAttributeMatrixVectorIndexing = true;
|
||||
Resources.limits.generalVaryingIndexing = true;
|
||||
Resources.limits.generalSamplerIndexing = true;
|
||||
Resources.limits.generalVariableIndexing = true;
|
||||
Resources.limits.generalConstantMatrixVectorIndexing = true;
|
||||
Resources.limits.generalVaryingIndexing = true;
|
||||
Resources.limits.generalSamplerIndexing = true;
|
||||
Resources.limits.generalVariableIndexing = true;
|
||||
Resources.limits.generalConstantMatrixVectorIndexing = true;
|
||||
|
||||
return Resources;
|
||||
}
|
||||
@@ -119,8 +120,7 @@ namespace MobileGL {
|
||||
auto lang = GetEShLanguageByShaderType(shaderType);
|
||||
if (lang == EShLanguage::EShLangCount) {
|
||||
ResultInfo r;
|
||||
r.log += "Error: [Preprocess] Unsupported shader type: " +
|
||||
ConvertGLEnumToString(shaderType);
|
||||
r.log += "Error: [Preprocess] Unsupported shader type: " + ConvertGLEnumToString(shaderType);
|
||||
r.errc = -1;
|
||||
return std::unexpected(r);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace MobileGL {
|
||||
SharedPtr<glslang::TShader> res;
|
||||
auto& tshader = res;
|
||||
tshader = MakeShared<glslang::TShader>(lang);
|
||||
const char* src[] = { sourceStr.data() };
|
||||
const char* src[] = {sourceStr.data()};
|
||||
tshader->setStrings(src, 1);
|
||||
tshader->setInvertY(true);
|
||||
tshader->setEnvInput(glslang::EShSourceGlsl, lang, glslang::EShClientVulkan, 450);
|
||||
@@ -136,14 +136,15 @@ namespace MobileGL {
|
||||
tshader->setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_5);
|
||||
tshader->setAutoMapLocations(true);
|
||||
tshader->setAutoMapBindings(true);
|
||||
tshader->setEnvInputVulkanRulesRelaxed(); // using EXT_vulkan_glsl_relaxed for gl_VertexID and gl_InstanceID?
|
||||
tshader->setEnvInputVulkanRulesRelaxed(); // using EXT_vulkan_glsl_relaxed for gl_VertexID and
|
||||
// gl_InstanceID?
|
||||
tshader->setGlobalUniformBlockName(GLOBAL_UBO_NAME);
|
||||
if (!tshader->parse(&GetTBuiltInResourceInstance(), 150, ECoreProfile,
|
||||
/*forceDefaultVersionAndProfile: */false,
|
||||
/*forwardCompatible: */true, EShMsgDefault)) {
|
||||
/*forceDefaultVersionAndProfile: */ false,
|
||||
/*forwardCompatible: */ true, EShMsgDefault)) {
|
||||
ResultInfo r;
|
||||
r.log += "Error: [glslang] Cannot compile " + ConvertGLEnumToString(shaderType) + ":\n"
|
||||
+ std::string(tshader->getInfoLog());
|
||||
r.log += "Error: [glslang] Cannot compile " + ConvertGLEnumToString(shaderType) + ":\n" +
|
||||
std::string(tshader->getInfoLog());
|
||||
r.errc = -2;
|
||||
return std::unexpected(r);
|
||||
}
|
||||
@@ -204,7 +205,7 @@ namespace MobileGL {
|
||||
|
||||
session.SetOptions(options);
|
||||
|
||||
const char *result = nullptr;
|
||||
const char* result = nullptr;
|
||||
session.Compile(&result);
|
||||
|
||||
if (!result) {
|
||||
@@ -219,6 +220,6 @@ namespace MobileGL {
|
||||
|
||||
return glsl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ShaderTranspiler
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "SpvcSession.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
namespace ShaderTranspiler {
|
||||
class ShaderCompiler {
|
||||
public:
|
||||
static Result<SharedPtr<glslang::TShader>> CompileShader(const ShaderAttrib& attrib);
|
||||
static Result<Vector<Vector<unsigned>>> LinkProgram(const ProgramAttrib& attrib);
|
||||
static Result<String> DecompileShader(SpvcSession& session);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace MG_Util {
|
||||
namespace ShaderTranspiler {
|
||||
class ShaderCompiler {
|
||||
public:
|
||||
static Result<SharedPtr<glslang::TShader>> CompileShader(const ShaderAttrib& attrib);
|
||||
static Result<Vector<Vector<unsigned>>> LinkProgram(const ProgramAttrib& attrib);
|
||||
static Result<String> DecompileShader(SpvcSession& session);
|
||||
};
|
||||
} // namespace ShaderTranspiler
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,111 +1,113 @@
|
||||
#include "../../Includes.h"
|
||||
#include "SpvcSession.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
namespace ShaderTranspiler {
|
||||
SpvcSession::SpvcSession(const Vector<unsigned int>& spirv) {
|
||||
const SpvId *p_spirv = spirv.data();
|
||||
size_t word_count = spirv.size();
|
||||
namespace MG_Util {
|
||||
namespace ShaderTranspiler {
|
||||
SpvcSession::SpvcSession(const Vector<unsigned int>& spirv) {
|
||||
const SpvId* p_spirv = spirv.data();
|
||||
size_t word_count = spirv.size();
|
||||
|
||||
spvc_context_create(&context);
|
||||
spvc_context_parse_spirv(context, p_spirv, word_count, &ir);
|
||||
spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, &compiler);
|
||||
spvc_compiler_create_shader_resources(compiler, &resources);
|
||||
}
|
||||
|
||||
SpvcSession::SpvcSession(SpvcSession&& that) {
|
||||
std::swap(this->context, that.context);
|
||||
std::swap(this->compiler, that.compiler);
|
||||
std::swap(this->ir, that.ir);
|
||||
std::swap(this->compiler_options, that.compiler_options);
|
||||
std::swap(this->resources, that.resources);
|
||||
}
|
||||
|
||||
SpvcSession& SpvcSession::operator=(SpvcSession&& that) {
|
||||
std::swap(this->context, that.context);
|
||||
std::swap(this->compiler, that.compiler);
|
||||
std::swap(this->ir, that.ir);
|
||||
std::swap(this->compiler_options, that.compiler_options);
|
||||
std::swap(this->resources, that.resources);
|
||||
return *this;
|
||||
}
|
||||
|
||||
spvc_result SpvcSession::CreateOptions(spvc_compiler_options *options) {
|
||||
return spvc_compiler_create_compiler_options(compiler, options);
|
||||
}
|
||||
|
||||
spvc_result SpvcSession::SetOptions(spvc_compiler_options options) {
|
||||
compiler_options = options;
|
||||
return spvc_compiler_install_compiler_options(compiler, options);
|
||||
}
|
||||
|
||||
Vector<InterfaceVariable> SpvcSession::GetShaderInterface(spvc_resource_type resource_type) const {
|
||||
const spvc_reflected_resource *list = nullptr;
|
||||
size_t count = 0;
|
||||
spvc_resources_get_resource_list_for_type(resources, resource_type, &list, &count);
|
||||
|
||||
Vector<InterfaceVariable> variables;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
if (spvc_compiler_has_decoration(compiler, list[i].id, SpvDecorationBuiltIn)) {
|
||||
continue;
|
||||
spvc_context_create(&context);
|
||||
spvc_context_parse_spirv(context, p_spirv, word_count, &ir);
|
||||
spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP,
|
||||
&compiler);
|
||||
spvc_compiler_create_shader_resources(compiler, &resources);
|
||||
}
|
||||
|
||||
InterfaceVariable var;
|
||||
var.name = list[i].name;
|
||||
var.location = spvc_compiler_get_decoration(compiler, list[i].id, SpvDecorationLocation);
|
||||
variables.push_back(var);
|
||||
}
|
||||
std::sort(variables.begin(), variables.end());
|
||||
return variables;
|
||||
}
|
||||
|
||||
spvc_result SpvcSession::Compile(const char** result) {
|
||||
SPVC_CHK_INIT
|
||||
SPVC_CHK_RESULT(spvc_compiler_compile(compiler, result));
|
||||
SPVC_CHK_RESULT(ParseMetaData());
|
||||
SPVC_CHK_RETURN
|
||||
}
|
||||
|
||||
spvc_result SpvcSession::ParseMetaData() {
|
||||
SPVC_CHK_INIT
|
||||
|
||||
metadata = SpvcMetadata();
|
||||
|
||||
const spvc_reflected_resource *list = nullptr;
|
||||
size_t count = 0;
|
||||
|
||||
SPVC_CHK_RESULT(
|
||||
spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER, &list, &count);
|
||||
)
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
if (spvc_compiler_has_decoration(compiler, list[i].id, SpvDecorationBuiltIn)) {
|
||||
continue;
|
||||
SpvcSession::SpvcSession(SpvcSession&& that) {
|
||||
std::swap(this->context, that.context);
|
||||
std::swap(this->compiler, that.compiler);
|
||||
std::swap(this->ir, that.ir);
|
||||
std::swap(this->compiler_options, that.compiler_options);
|
||||
std::swap(this->resources, that.resources);
|
||||
}
|
||||
|
||||
if (strcmp(list[i].name, GLOBAL_UBO_NAME) == 0) {
|
||||
spvc_type type = spvc_compiler_get_type_handle(compiler, list[i].base_type_id);
|
||||
size_t num_members = spvc_type_get_num_member_types(type);
|
||||
for (size_t j = 0; j < num_members; ++j) {
|
||||
const char *memberName = spvc_compiler_get_member_name(compiler, list[i].base_type_id, j);
|
||||
SpvcSession& SpvcSession::operator=(SpvcSession&& that) {
|
||||
std::swap(this->context, that.context);
|
||||
std::swap(this->compiler, that.compiler);
|
||||
std::swap(this->ir, that.ir);
|
||||
std::swap(this->compiler_options, that.compiler_options);
|
||||
std::swap(this->resources, that.resources);
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned memberOffset = 0;
|
||||
SPVC_CHK_RESULT(spvc_compiler_type_struct_member_offset(compiler, type, j, &memberOffset);)
|
||||
metadata.plainUniformOffsetsInUBO[memberName] = memberOffset;
|
||||
spvc_result SpvcSession::CreateOptions(spvc_compiler_options* options) {
|
||||
return spvc_compiler_create_compiler_options(compiler, options);
|
||||
}
|
||||
|
||||
spvc_result SpvcSession::SetOptions(spvc_compiler_options options) {
|
||||
compiler_options = options;
|
||||
return spvc_compiler_install_compiler_options(compiler, options);
|
||||
}
|
||||
|
||||
Vector<InterfaceVariable> SpvcSession::GetShaderInterface(spvc_resource_type resource_type) const {
|
||||
const spvc_reflected_resource* list = nullptr;
|
||||
size_t count = 0;
|
||||
spvc_resources_get_resource_list_for_type(resources, resource_type, &list, &count);
|
||||
|
||||
Vector<InterfaceVariable> variables;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
if (spvc_compiler_has_decoration(compiler, list[i].id, SpvDecorationBuiltIn)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InterfaceVariable var;
|
||||
var.name = list[i].name;
|
||||
var.location = spvc_compiler_get_decoration(compiler, list[i].id, SpvDecorationLocation);
|
||||
variables.push_back(var);
|
||||
}
|
||||
std::sort(variables.begin(), variables.end());
|
||||
return variables;
|
||||
}
|
||||
}
|
||||
SPVC_CHK_RETURN
|
||||
}
|
||||
|
||||
const SpvcMetadata& SpvcSession::GetMetadata() const {
|
||||
return metadata;
|
||||
}
|
||||
spvc_result SpvcSession::Compile(const char** result) {
|
||||
SPVC_CHK_INIT
|
||||
SPVC_CHK_RESULT(spvc_compiler_compile(compiler, result));
|
||||
SPVC_CHK_RESULT(ParseMetaData());
|
||||
SPVC_CHK_RETURN
|
||||
}
|
||||
|
||||
const char* SpvcSession::GetLastErrorString() const {
|
||||
return spvc_context_get_last_error_string(context);
|
||||
}
|
||||
spvc_result SpvcSession::ParseMetaData() {
|
||||
SPVC_CHK_INIT
|
||||
|
||||
SpvcSession::~SpvcSession() { spvc_context_destroy(context); }
|
||||
}
|
||||
}
|
||||
}
|
||||
metadata = SpvcMetadata();
|
||||
|
||||
const spvc_reflected_resource* list = nullptr;
|
||||
size_t count = 0;
|
||||
|
||||
SPVC_CHK_RESULT(spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER,
|
||||
&list, &count);)
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
if (spvc_compiler_has_decoration(compiler, list[i].id, SpvDecorationBuiltIn)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(list[i].name, GLOBAL_UBO_NAME) == 0) {
|
||||
spvc_type type = spvc_compiler_get_type_handle(compiler, list[i].base_type_id);
|
||||
size_t num_members = spvc_type_get_num_member_types(type);
|
||||
for (size_t j = 0; j < num_members; ++j) {
|
||||
const char* memberName = spvc_compiler_get_member_name(compiler, list[i].base_type_id, j);
|
||||
|
||||
unsigned memberOffset = 0;
|
||||
SPVC_CHK_RESULT(spvc_compiler_type_struct_member_offset(compiler, type, j, &memberOffset);)
|
||||
metadata.plainUniformOffsetsInUBO[memberName] = memberOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
SPVC_CHK_RETURN
|
||||
}
|
||||
|
||||
const SpvcMetadata& SpvcSession::GetMetadata() const {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
const char* SpvcSession::GetLastErrorString() const {
|
||||
return spvc_context_get_last_error_string(context);
|
||||
}
|
||||
|
||||
SpvcSession::~SpvcSession() {
|
||||
spvc_context_destroy(context);
|
||||
}
|
||||
} // namespace ShaderTranspiler
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -1,69 +1,59 @@
|
||||
//
|
||||
// Created by Swung0x48 on 2025/8/7.
|
||||
//
|
||||
|
||||
#ifndef SPVCSESSION_H
|
||||
#define SPVCSESSION_H
|
||||
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "Types.h"
|
||||
|
||||
#define SPVC_CHK_INIT \
|
||||
auto __r = SPVC_SUCCESS;
|
||||
#define SPVC_CHK_INIT auto __r = SPVC_SUCCESS;
|
||||
|
||||
#define SPVC_CHK_RESULT(res) \
|
||||
__r = res; \
|
||||
if (__r != SPVC_SUCCESS) { \
|
||||
return __r; \
|
||||
#define SPVC_CHK_RESULT(res) \
|
||||
__r = res; \
|
||||
if (__r != SPVC_SUCCESS) { \
|
||||
return __r; \
|
||||
}
|
||||
|
||||
#define SPVC_CHK_RETURN \
|
||||
return __r;
|
||||
#define SPVC_CHK_RETURN return __r;
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
namespace ShaderTranspiler {
|
||||
struct SpvcMetadata {
|
||||
UnorderedMap<String, unsigned> plainUniformOffsetsInUBO;
|
||||
};
|
||||
namespace MG_Util {
|
||||
namespace ShaderTranspiler {
|
||||
struct SpvcMetadata {
|
||||
UnorderedMap<String, unsigned> plainUniformOffsetsInUBO;
|
||||
};
|
||||
|
||||
class SpvcSession {
|
||||
public:
|
||||
SpvcSession() {}
|
||||
class SpvcSession {
|
||||
public:
|
||||
SpvcSession() {}
|
||||
|
||||
explicit SpvcSession(const Vector<unsigned int>& spirv);
|
||||
explicit SpvcSession(const Vector<unsigned int>& spirv);
|
||||
|
||||
SpvcSession(SpvcSession&) = delete;
|
||||
SpvcSession(SpvcSession&) = delete;
|
||||
|
||||
SpvcSession(SpvcSession&& that);
|
||||
SpvcSession(SpvcSession&& that);
|
||||
|
||||
~SpvcSession();
|
||||
~SpvcSession();
|
||||
|
||||
SpvcSession& operator=(SpvcSession& session) = delete;
|
||||
SpvcSession& operator=(SpvcSession& session) = delete;
|
||||
|
||||
SpvcSession& operator=(SpvcSession&& that);
|
||||
SpvcSession& operator=(SpvcSession&& that);
|
||||
|
||||
spvc_result CreateOptions(spvc_compiler_options *options);
|
||||
spvc_result SetOptions(spvc_compiler_options options);
|
||||
Vector<InterfaceVariable> GetShaderInterface(spvc_resource_type resource_type) const;
|
||||
spvc_result Compile(const char** result);
|
||||
const SpvcMetadata& GetMetadata() const;
|
||||
const char* GetLastErrorString() const;
|
||||
spvc_result CreateOptions(spvc_compiler_options* options);
|
||||
spvc_result SetOptions(spvc_compiler_options options);
|
||||
Vector<InterfaceVariable> GetShaderInterface(spvc_resource_type resource_type) const;
|
||||
spvc_result Compile(const char** result);
|
||||
const SpvcMetadata& GetMetadata() const;
|
||||
const char* GetLastErrorString() const;
|
||||
|
||||
private:
|
||||
// Should be called once, and only once, for every SPIR-V binary
|
||||
spvc_result ParseMetaData();
|
||||
private:
|
||||
// Should be called once, and only once, for every SPIR-V binary
|
||||
spvc_result ParseMetaData();
|
||||
|
||||
spvc_context context = nullptr;
|
||||
spvc_parsed_ir ir = nullptr;
|
||||
spvc_compiler compiler = nullptr;
|
||||
spvc_compiler_options compiler_options = nullptr;
|
||||
spvc_resources resources = nullptr;
|
||||
spvc_context context = nullptr;
|
||||
spvc_parsed_ir ir = nullptr;
|
||||
spvc_compiler compiler = nullptr;
|
||||
spvc_compiler_options compiler_options = nullptr;
|
||||
spvc_resources resources = nullptr;
|
||||
|
||||
SpvcMetadata metadata;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif //SPVCSESSION_H
|
||||
SpvcMetadata metadata;
|
||||
};
|
||||
} // namespace ShaderTranspiler
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "MG_Util/Debug/Log.h"
|
||||
#include <Includes.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
@@ -10,7 +10,6 @@ namespace MobileGL {
|
||||
|
||||
enum class ShaderCompileBits : Uint {
|
||||
EmitDiscardAsDemote = 1 << 0,
|
||||
|
||||
};
|
||||
|
||||
struct ShaderAttrib {
|
||||
@@ -36,9 +35,7 @@ namespace MobileGL {
|
||||
std::string name;
|
||||
uint32_t location;
|
||||
|
||||
bool operator<(const InterfaceVariable& other) const {
|
||||
return location < other.location;
|
||||
}
|
||||
bool operator<(const InterfaceVariable& other) const { return location < other.location; }
|
||||
|
||||
bool operator==(const InterfaceVariable& other) const {
|
||||
return location == other.location && name == other.name;
|
||||
@@ -55,8 +52,8 @@ namespace MobileGL {
|
||||
//
|
||||
// spvc_context_create(&context);
|
||||
// spvc_context_parse_spirv(context, p_spirv, word_count, &ir);
|
||||
// spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, &compiler);
|
||||
// spvc_compiler_create_shader_resources(compiler, &resources);
|
||||
// spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP,
|
||||
// &compiler); spvc_compiler_create_shader_resources(compiler, &resources);
|
||||
// }
|
||||
//
|
||||
// SpvcSession(SpvcSession&) = delete;
|
||||
@@ -110,7 +107,8 @@ namespace MobileGL {
|
||||
// size_t num_members = spvc_type_get_num_member_types(type);
|
||||
// printf("uniform %s {\n", var.name.c_str());
|
||||
// for (size_t j = 0; j < num_members; ++j) {
|
||||
// const char *memberName = spvc_compiler_get_member_name(compiler, list[i].base_type_id, j);
|
||||
// const char *memberName = spvc_compiler_get_member_name(compiler,
|
||||
// list[i].base_type_id, j);
|
||||
// // auto memberTypeId = spvc_type_get_member_type(type, j);
|
||||
// // auto memberType = spvc_compiler_get_type_handle(compiler, memberTypeId);
|
||||
//
|
||||
@@ -144,22 +142,22 @@ namespace MobileGL {
|
||||
|
||||
inline static EShLanguage GetEShLanguageByShaderType(GLenum shaderType) {
|
||||
switch (shaderType) {
|
||||
case GL_VERTEX_SHADER:
|
||||
return EShLanguage::EShLangVertex;
|
||||
case GL_FRAGMENT_SHADER:
|
||||
return EShLanguage::EShLangFragment;
|
||||
case GL_COMPUTE_SHADER:
|
||||
return EShLanguage::EShLangCompute;
|
||||
case GL_TESS_CONTROL_SHADER:
|
||||
return EShLanguage::EShLangTessControl;
|
||||
case GL_TESS_EVALUATION_SHADER:
|
||||
return EShLanguage::EShLangTessEvaluation;
|
||||
case GL_GEOMETRY_SHADER:
|
||||
return EShLanguage::EShLangGeometry;
|
||||
default:
|
||||
return EShLanguage::EShLangCount;
|
||||
case GL_VERTEX_SHADER:
|
||||
return EShLanguage::EShLangVertex;
|
||||
case GL_FRAGMENT_SHADER:
|
||||
return EShLanguage::EShLangFragment;
|
||||
case GL_COMPUTE_SHADER:
|
||||
return EShLanguage::EShLangCompute;
|
||||
case GL_TESS_CONTROL_SHADER:
|
||||
return EShLanguage::EShLangTessControl;
|
||||
case GL_TESS_EVALUATION_SHADER:
|
||||
return EShLanguage::EShLangTessEvaluation;
|
||||
case GL_GEOMETRY_SHADER:
|
||||
return EShLanguage::EShLangGeometry;
|
||||
default:
|
||||
return EShLanguage::EShLangCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ShaderTranspiler
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
|
||||
+192
-224
@@ -1,271 +1,239 @@
|
||||
#pragma once
|
||||
|
||||
#include <Includes.h>
|
||||
#include "GLExtensions.h"
|
||||
|
||||
#define GL_UNKNOWN_MGL 0
|
||||
|
||||
#define THROW_EXCEPTION(msg) \
|
||||
throw std::runtime_error(msg);
|
||||
#define THROW_EXCEPTION(msg) throw std::runtime_error(msg)
|
||||
|
||||
#define THROW_UNIMPL_EXCEPTION \
|
||||
THROW_EXCEPTION("Unimplemented function called!")
|
||||
#define THROW_UNIMPL_EXCEPTION THROW_EXCEPTION("Unimplemented function called!")
|
||||
|
||||
namespace MobileGL {
|
||||
using String = std::string;
|
||||
using StringStream = std::stringstream;
|
||||
using Int8 = int8_t;
|
||||
using Uint8 = uint8_t;
|
||||
using Int16 = int16_t;
|
||||
using Uint16 = uint16_t;
|
||||
using Int32 = int32_t;
|
||||
using Uint32 = uint32_t;
|
||||
using Int = Int32;
|
||||
using Uint = Uint32;
|
||||
using Int64 = int64_t;
|
||||
using Uint64 = uint64_t;
|
||||
using Bool = bool;
|
||||
using Float = float;
|
||||
using Double = double;
|
||||
using StringView = std::string_view;
|
||||
template <typename T>
|
||||
using Vector = std::vector<T>;
|
||||
template <typename T, typename N>
|
||||
using Pair = std::pair<T, N>;
|
||||
template <typename T>
|
||||
using SharedPtr = std::shared_ptr<T>;
|
||||
template <typename T>
|
||||
using UniquePtr = std::unique_ptr<T>;
|
||||
template <typename T, typename... Args>
|
||||
inline SharedPtr<T> MakeShared(Args&&... args) {
|
||||
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
template <typename T, typename... Args>
|
||||
inline UniquePtr<T> MakeUnique(Args&&... args) {
|
||||
return std::make_unique<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
using SizeT = std::size_t;
|
||||
template <typename T, SizeT N>
|
||||
using Array = std::array<T, N>;
|
||||
template <typename Key, typename Value>
|
||||
using UnorderedMap = std::unordered_map<Key, Value>;
|
||||
template <typename T>
|
||||
inline constexpr std::remove_reference_t<T>&& Move(T&& t) noexcept {
|
||||
return static_cast<std::remove_reference_t<T>&&>(t);
|
||||
}
|
||||
template <typename T>
|
||||
inline constexpr void Copy(const T* src, T* dest, SizeT count) {
|
||||
std::copy(src, src + count, dest);
|
||||
}
|
||||
template<typename... Ts>
|
||||
constexpr auto ToArray(Ts&&... elems) {
|
||||
using E = std::common_type_t<Ts...>;
|
||||
return std::array<E, sizeof...(Ts)>{ { std::forward<Ts>(elems)... } };
|
||||
}
|
||||
class RuntimeError : public std::runtime_error {
|
||||
public:
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
template <typename T>
|
||||
using Optional = std::optional<T>;
|
||||
using NulloptT = std::nullopt_t;
|
||||
const NulloptT Nullopt = std::nullopt;
|
||||
using String = std::string;
|
||||
using StringStream = std::stringstream;
|
||||
using Int8 = int8_t;
|
||||
using Uint8 = uint8_t;
|
||||
using Int16 = int16_t;
|
||||
using Uint16 = uint16_t;
|
||||
using Int32 = int32_t;
|
||||
using Uint32 = uint32_t;
|
||||
using Int = Int32;
|
||||
using Uint = Uint32;
|
||||
using Int64 = int64_t;
|
||||
using Uint64 = uint64_t;
|
||||
using Bool = bool;
|
||||
using Float = float;
|
||||
using Double = double;
|
||||
using StringView = std::string_view;
|
||||
template <typename T>
|
||||
using Vector = std::vector<T>;
|
||||
template <typename T, typename N>
|
||||
using Pair = std::pair<T, N>;
|
||||
template <typename T>
|
||||
using SharedPtr = std::shared_ptr<T>;
|
||||
template <typename T>
|
||||
using UniquePtr = std::unique_ptr<T>;
|
||||
template <typename T, typename... Args>
|
||||
inline SharedPtr<T> MakeShared(Args&&... args) {
|
||||
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
template <typename T, typename... Args>
|
||||
inline UniquePtr<T> MakeUnique(Args&&... args) {
|
||||
return std::make_unique<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
using SizeT = std::size_t;
|
||||
template <typename T, SizeT N>
|
||||
using Array = std::array<T, N>;
|
||||
template <typename Key, typename Value>
|
||||
using UnorderedMap = std::unordered_map<Key, Value>;
|
||||
template <typename T>
|
||||
inline constexpr std::remove_reference_t<T>&& Move(T&& t) noexcept {
|
||||
return static_cast<std::remove_reference_t<T>&&>(t);
|
||||
}
|
||||
template <typename T>
|
||||
inline constexpr void Copy(const T* src, T* dest, SizeT count) {
|
||||
std::copy(src, src + count, dest);
|
||||
}
|
||||
template <typename... Ts>
|
||||
constexpr auto ToArray(Ts&&... elems) {
|
||||
using E = std::common_type_t<Ts...>;
|
||||
return std::array<E, sizeof...(Ts)>{{std::forward<Ts>(elems)...}};
|
||||
}
|
||||
class RuntimeError : public std::runtime_error {
|
||||
public:
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
template <typename T>
|
||||
using Optional = std::optional<T>;
|
||||
using NulloptT = std::nullopt_t;
|
||||
const NulloptT Nullopt = std::nullopt;
|
||||
|
||||
using std::format;
|
||||
|
||||
using Data = Vector<Uint8>;
|
||||
struct DataPtr {
|
||||
void* data;
|
||||
SizeT size;
|
||||
};
|
||||
using Data = Vector<Uint8>;
|
||||
struct DataPtr {
|
||||
void* data;
|
||||
SizeT size;
|
||||
};
|
||||
|
||||
enum class DataType {
|
||||
Int8,
|
||||
Uint8,
|
||||
Int16,
|
||||
Uint16,
|
||||
Int32,
|
||||
Uint32,
|
||||
Float16,
|
||||
Float32,
|
||||
Float64,
|
||||
Fixed32,
|
||||
Unknown = -1
|
||||
};
|
||||
enum class DataType {
|
||||
Int8,
|
||||
Uint8,
|
||||
Int16,
|
||||
Uint16,
|
||||
Int32,
|
||||
Uint32,
|
||||
Float16,
|
||||
Float32,
|
||||
Float64,
|
||||
Fixed32,
|
||||
Unknown = -1
|
||||
};
|
||||
|
||||
// represents a range of [start, end)
|
||||
struct Range1D {
|
||||
SizeT start = 0;
|
||||
SizeT end = 0;
|
||||
// represents a range of [start, end)
|
||||
struct Range1D {
|
||||
SizeT start = 0;
|
||||
SizeT end = 0;
|
||||
|
||||
void Update(SizeT newStart, SizeT newEnd) {
|
||||
assert(newStart <= newEnd);
|
||||
start = newStart;
|
||||
end = newEnd;
|
||||
}
|
||||
void Update(SizeT newStart, SizeT newEnd) {
|
||||
assert(newStart <= newEnd);
|
||||
start = newStart;
|
||||
end = newEnd;
|
||||
}
|
||||
|
||||
void UnionUpdate(SizeT newStart, SizeT newEnd) {
|
||||
assert(newStart <= newEnd);
|
||||
if (start == end) {
|
||||
Update(newStart, newEnd);
|
||||
return;
|
||||
}
|
||||
start = std::min(start, newStart);
|
||||
end = std::max(end, newEnd);
|
||||
}
|
||||
void UnionUpdate(SizeT newStart, SizeT newEnd) {
|
||||
assert(newStart <= newEnd);
|
||||
if (start == end) {
|
||||
Update(newStart, newEnd);
|
||||
return;
|
||||
}
|
||||
start = std::min(start, newStart);
|
||||
end = std::max(end, newEnd);
|
||||
}
|
||||
|
||||
void IntersectionUpdate(SizeT newStart, SizeT newEnd) {
|
||||
assert(newStart <= newEnd);
|
||||
start = std::max(start, newStart);
|
||||
end = std::min(end, newEnd);
|
||||
assert(start <= end);
|
||||
}
|
||||
};
|
||||
void IntersectionUpdate(SizeT newStart, SizeT newEnd) {
|
||||
assert(newStart <= newEnd);
|
||||
start = std::max(start, newStart);
|
||||
end = std::min(end, newEnd);
|
||||
assert(start <= end);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ObjectType>
|
||||
class BindingSlot {
|
||||
public:
|
||||
using TargetEnum = typename ObjectType::TargetEnum;
|
||||
template <typename ObjectType>
|
||||
class BindingSlot {
|
||||
public:
|
||||
using TargetEnum = typename ObjectType::TargetEnum;
|
||||
|
||||
BindingSlot(): m_target((TargetEnum)0), m_boundObject(nullptr) {}
|
||||
BindingSlot() : m_target((TargetEnum)0), m_boundObject(nullptr) {}
|
||||
|
||||
explicit BindingSlot(TargetEnum target)
|
||||
: m_target(target), m_boundObject(nullptr) {
|
||||
}
|
||||
explicit BindingSlot(TargetEnum target) : m_target(target), m_boundObject(nullptr) {}
|
||||
|
||||
void Bind(SharedPtr<ObjectType> object) {
|
||||
m_boundObject = object;
|
||||
}
|
||||
void Bind(SharedPtr<ObjectType> object) { m_boundObject = object; }
|
||||
|
||||
SharedPtr<ObjectType> GetBoundObject() const {
|
||||
return m_boundObject;
|
||||
}
|
||||
SharedPtr<ObjectType> GetBoundObject() const { return m_boundObject; }
|
||||
|
||||
TargetEnum GetTarget() const {
|
||||
return m_target;
|
||||
}
|
||||
TargetEnum GetTarget() const { return m_target; }
|
||||
|
||||
private:
|
||||
TargetEnum m_target;
|
||||
SharedPtr<ObjectType> m_boundObject;
|
||||
};
|
||||
private:
|
||||
TargetEnum m_target;
|
||||
SharedPtr<ObjectType> m_boundObject;
|
||||
};
|
||||
|
||||
struct Version {
|
||||
Int Major;
|
||||
Int Minor;
|
||||
Int Patch;
|
||||
Optional<String> Suffix;
|
||||
struct Version {
|
||||
Int Major;
|
||||
Int Minor;
|
||||
Int Patch;
|
||||
Optional<String> Suffix;
|
||||
|
||||
String toString(Pair<Bool, Bool> dots = { true, true }, Bool useSuffix = true) const {
|
||||
StringStream result;
|
||||
result << Major << (dots.first ? "." : "") << Minor << (dots.second ? "." : "") << Patch <<
|
||||
(useSuffix && Suffix.has_value() ? *Suffix : "");
|
||||
return result.str();
|
||||
}
|
||||
};
|
||||
String toString(Pair<Bool, Bool> dots = {true, true}, Bool useSuffix = true) const {
|
||||
StringStream result;
|
||||
result << Major << (dots.first ? "." : "") << Minor << (dots.second ? "." : "") << Patch
|
||||
<< (useSuffix && Suffix.has_value() ? *Suffix : "");
|
||||
return result.str();
|
||||
}
|
||||
};
|
||||
|
||||
struct BackendCap {
|
||||
struct BackendCap {};
|
||||
|
||||
};
|
||||
struct GLInfo {
|
||||
Version TargetGLVersion;
|
||||
Version TargetGLSLVersion;
|
||||
Vector<GLExtension> Extensions;
|
||||
Bool IsCompatibilityProfile;
|
||||
};
|
||||
|
||||
struct GLInfo {
|
||||
Version TargetGLVersion;
|
||||
Version TargetGLSLVersion;
|
||||
Vector<GLExtension> Extensions;
|
||||
Bool IsCompatibilityProfile;
|
||||
};
|
||||
struct RendererInfo {
|
||||
String RendererName;
|
||||
String BackendName;
|
||||
Optional<String> ExtraVendor;
|
||||
GLInfo RendererGLInfo;
|
||||
BackendCap BackendCapability;
|
||||
};
|
||||
|
||||
struct RendererInfo {
|
||||
String RendererName;
|
||||
String BackendName;
|
||||
Optional<String> ExtraVendor;
|
||||
GLInfo RendererGLInfo;
|
||||
BackendCap BackendCapability;
|
||||
};
|
||||
template <typename Bit,
|
||||
typename Underlying = std::enable_if<std::is_scoped_enum_v<Bit>, std::underlying_type_t<Bit>>>
|
||||
class Flags {
|
||||
public:
|
||||
Flags() = default;
|
||||
|
||||
template <typename Bit, typename Underlying =
|
||||
std::enable_if<std::is_scoped_enum_v<Bit>, std::underlying_type_t<Bit>>
|
||||
>
|
||||
class Flags {
|
||||
public:
|
||||
Flags() = default;
|
||||
Flags(Bit b) : flags(static_cast<typename Underlying::type>(b)) {}
|
||||
|
||||
Flags(Bit b): flags(static_cast<typename Underlying::type>(b)) {}
|
||||
Flags(typename Underlying::type b) : flags(b) {}
|
||||
|
||||
Flags(typename Underlying::type b): flags(b) {}
|
||||
// Flags - Bit
|
||||
Flags operator|(const Bit b) const { return Flags(flags | static_cast<typename Underlying::type>(b)); }
|
||||
|
||||
// Flags - Bit
|
||||
Flags operator|(const Bit b) const {
|
||||
return Flags(flags | static_cast<typename Underlying::type>(b));
|
||||
}
|
||||
Flags operator&(const Bit b) const { return Flags(flags & static_cast<typename Underlying::type>(b)); }
|
||||
|
||||
Flags operator&(const Bit b) const {
|
||||
return Flags(flags & static_cast<typename Underlying::type>(b));
|
||||
}
|
||||
Flags& operator|=(const Bit b) {
|
||||
flags |= static_cast<typename Underlying::type>(b);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Flags& operator|=(const Bit b) {
|
||||
flags |= static_cast<typename Underlying::type>(b);
|
||||
return *this;
|
||||
}
|
||||
Flags& operator&=(const Bit b) {
|
||||
flags &= static_cast<typename Underlying::type>(b);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Flags& operator&=(const Bit b) {
|
||||
flags &= static_cast<typename Underlying::type>(b);
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const Bit b) const { return flags == static_cast<typename Underlying::type>(b); }
|
||||
|
||||
bool operator==(const Bit b) const {
|
||||
return flags == static_cast<typename Underlying::type>(b);
|
||||
}
|
||||
bool operator!=(const Bit b) const { return !(*this == b); }
|
||||
|
||||
bool operator!=(const Bit b) const {
|
||||
return !(*this == b);
|
||||
}
|
||||
// Flags - Flags
|
||||
Flags operator|(const Flags b) const { return Flags(flags | b.flags); }
|
||||
|
||||
// Flags - Flags
|
||||
Flags operator|(const Flags b) const {
|
||||
return Flags(flags | b.flags);
|
||||
}
|
||||
Flags operator&(const Flags b) const { return Flags(flags & b.flags); }
|
||||
|
||||
Flags operator&(const Flags b) const {
|
||||
return Flags(flags & b.flags);
|
||||
}
|
||||
Flags& operator|=(Flags b) {
|
||||
flags |= b.flags;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Flags& operator|=(Flags b) {
|
||||
flags |= b.flags;
|
||||
return *this;
|
||||
}
|
||||
Flags& operator&=(Flags b) {
|
||||
flags &= b.flags;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Flags& operator&=(Flags b) {
|
||||
flags &= b.flags;
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const Flags b) const { return flags == b.flags; }
|
||||
|
||||
bool operator==(const Flags b) const {
|
||||
return flags == b.flags;
|
||||
}
|
||||
bool operator!=(const Flags b) const { return !(*this == b); }
|
||||
|
||||
bool operator!=(const Flags b) const {
|
||||
return !(*this == b);
|
||||
}
|
||||
operator bool() const { return Any(); }
|
||||
|
||||
operator bool() const {
|
||||
return Any();
|
||||
}
|
||||
private:
|
||||
bool Any() const { return static_cast<typename Underlying::type>(flags) != 0; }
|
||||
|
||||
private:
|
||||
bool Any() const {
|
||||
return static_cast<typename Underlying::type>(flags) != 0;
|
||||
}
|
||||
typename Underlying::type flags = 0;
|
||||
};
|
||||
|
||||
typename Underlying::type flags = 0;
|
||||
};
|
||||
template <typename Bit, typename = std::enable_if_t<std::is_scoped_enum_v<Bit>>>
|
||||
Flags<Bit> operator|(const Bit lhs, const Bit rhs) {
|
||||
return Flags<Bit>(lhs) | rhs;
|
||||
}
|
||||
|
||||
template<typename Bit, typename = std::enable_if_t<std::is_scoped_enum_v<Bit>>>
|
||||
Flags<Bit> operator|(const Bit lhs, const Bit rhs) {
|
||||
return Flags<Bit>(lhs) | rhs;
|
||||
}
|
||||
|
||||
template<typename Bit, typename = std::enable_if_t<std::is_scoped_enum_v<Bit>>>
|
||||
Flags<Bit> operator&(const Bit lhs, const Bit rhs) {
|
||||
return Flags<Bit>(lhs) & rhs;
|
||||
}
|
||||
}
|
||||
|
||||
#include "../MG_Util/ShaderTranspiler/Types.h"
|
||||
template <typename Bit, typename = std::enable_if_t<std::is_scoped_enum_v<Bit>>>
|
||||
Flags<Bit> operator&(const Bit lhs, const Bit rhs) {
|
||||
return Flags<Bit>(lhs) & rhs;
|
||||
}
|
||||
} // namespace MobileGL
|
||||
Reference in New Issue
Block a user