diff --git a/CMakeLists.txt b/CMakeLists.txt index 50ad511a..7a5310b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ set(SOURCE_FILES MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp + MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.cpp # @INSERTION_POINT:SOURCE_FILE_GLIMPL@ # MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp @@ -70,6 +71,7 @@ set(SOURCE_FILES MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp MobileGL/MG_Impl/GLImpl/Texture/Validators.cpp + MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.cpp MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp @@ -77,6 +79,8 @@ set(SOURCE_FILES MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp + MobileGL/MG_Impl/Init.cpp + MobileGL/MG_Backend/Init.cpp MobileGL/MG_State/GLState/Core.cpp @@ -101,9 +105,9 @@ add_library(${CMAKE_PROJECT_NAME} SHARED ) set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES - C_VISIBILITY_PRESET hidden - CXX_VISIBILITY_PRESET hidden - VISIBILITY_INLINES_HIDDEN ON + C_VISIBILITY_PRESET default + CXX_VISIBILITY_PRESET default + VISIBILITY_INLINES_HIDDEN OFF ) target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC @@ -170,4 +174,4 @@ set(BUILD_BENCHMARK ON CACHE BOOL "Build the benchmarks") add_subdirectory(MobileGL/MG_Test) add_subdirectory(MobileGL/MG_Benchmark) -endif() \ No newline at end of file +endif() diff --git a/MobileGL/Init.cpp b/MobileGL/Init.cpp index 21f66623..46fcd10f 100644 --- a/MobileGL/Init.cpp +++ b/MobileGL/Init.cpp @@ -1,4 +1,5 @@ #include "Includes.h" +#include #include #include @@ -10,13 +11,15 @@ namespace MobileGL { MGLOG_D("MobileGL State initialized"); MG_Backend::Init(); MGLOG_D("MobileGL Backend initialized"); + MG_Impl::Init(); + MGLOG_D("MobileGL Implementation initialized"); glslang::InitializeProcess(); MGLOG_D("glslang initialized"); - MGLOG_I("MobileGL Initialized"); + MGLOG_I("MobileGL initialized"); } void MG_Destroy() { - MGLOG_I("MobileGL Closing..."); + MGLOG_I("MobileGL closing..."); glslang::FinalizeProcess(); MG_Util::Debug::Close(); } diff --git a/MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.cpp b/MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.cpp index 2b2aa6cd..26c32e14 100644 --- a/MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.cpp +++ b/MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.cpp @@ -1,103 +1,88 @@ #include "EGLWrapper.h" +#include +#include +#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES namespace MobileGL { namespace MG_Impl::EGLImpl { // TODO: implement complete EGL functionality EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint* attrib_list) { - return (EGLSurface)1; + return MG_External::EGL::eglCreateWindowSurface(dpy, config, window, attrib_list); } EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) { - *num_config = 1; - return EGL_TRUE; + return MG_External::EGL::eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); } EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) { - return (EGLContext)1; + return MG_External::EGL::eglCreateContext(dpy, config, shareCtx, attrib_list); } EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor) { - if (major) *major = 1; - if (minor) *minor = 5; - return EGL_TRUE; + return MG_External::EGL::eglInitialize(dpy, major, minor); } EGLDisplay GetDisplay(NativeDisplayType display) { - return (EGLDisplay)1; + return MG_External::EGL::eglGetDisplay(display); } EGLint GetError() { - return EGL_SUCCESS; + return MG_External::EGL::eglGetError(); } EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { - return EGL_TRUE; + return MG_External::EGL::eglMakeCurrent(dpy, draw, read, ctx); } EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx) { - return EGL_TRUE; + return MG_External::EGL::eglDestroyContext(dpy, ctx); } EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface) { - return EGL_TRUE; + return MG_External::EGL::eglDestroySurface(dpy, surface); } EGLBoolean Terminate(EGLDisplay dpy) { - return EGL_TRUE; + return MG_External::EGL::eglTerminate(dpy); } EGLBoolean ReleaseThread(void) { - return EGL_TRUE; + return MG_External::EGL::eglReleaseThread(); } EGLContext GetCurrentContext(void) { - return (EGLContext)1; + return MG_External::EGL::eglGetCurrentContext(); } EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) { - if (attribute == EGL_NATIVE_VISUAL_ID) { -#if defined(ANDROID) - *value = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM; - return EGL_TRUE; -#elif defined(__linux__) - *value = 0; - return EGL_TRUE; -#elif defined(_WIN32) - *value = 0; - return EGL_TRUE; -#else - *value = 0; - return EGL_FALSE; -#endif - } - return EGL_TRUE; + return MG_External::EGL::eglGetConfigAttrib(dpy, config, attribute, value); } EGLBoolean BindAPI(EGLenum api) { - return EGL_TRUE; + return MG_External::EGL::eglBindAPI(api); } EGLSurface GetCurrentSurface(EGLint readdraw) { - return (EGLSurface)1; + return MG_External::EGL::eglGetCurrentSurface(readdraw); } EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) { - return EGL_TRUE; + return MG_External::EGL::eglQuerySurface(display, surface, attribute, value); } EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval) { - return EGL_TRUE; + return MG_External::EGL::eglSwapInterval(dpy, interval); } EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) { - return EGL_TRUE; + return MG_External::EGL::eglSwapBuffers(dpy, draw); } EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) { - return (EGLSurface)1; + return MG_External::EGL::eglCreatePbufferSurface(dpy, config, attrib_list); } __eglMustCastToProperFunctionPointerType GetProcAddress(const char* name) { @@ -114,4 +99,6 @@ namespace MobileGL { return (__eglMustCastToProperFunctionPointerType)proc; } } // namespace MG_Impl::EGLImpl -} // namespace MobileGL \ No newline at end of file +} // namespace MobileGL + +#endif \ No newline at end of file diff --git a/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp b/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp index b53a80c0..ce63acd0 100644 --- a/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp +++ b/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp @@ -1,5 +1,7 @@ #include "TemporaryEGLImpl.h" +#include +#if !(MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES) namespace MobileGL { namespace MG_Impl::EGLImpl { // TODO: implement complete EGL functionality @@ -114,4 +116,5 @@ namespace MobileGL { return (__eglMustCastToProperFunctionPointerType)proc; } } // namespace MG_Impl::EGLImpl -} // namespace MobileGL \ No newline at end of file +} // namespace MobileGL +#endif \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp index 485e7a50..03922ea9 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp @@ -3,9 +3,62 @@ #include #include #include +#include namespace MobileGL { namespace MG_Impl::GLImpl { + void GetBufferParameteriv_State(GLenum target, GLenum pname, GLint* params) { + if (!params) { + MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", + "GetBufferParameteriv_State", + "Params pointer cannot be null.")); + 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("MG_Impl/GLImpl", "GetBufferParameteriv_State", + "Buffer target is bound to no buffer object.")); + return; + } + + switch (pname) { + case GL_BUFFER_SIZE: + *params = static_cast(bufferObject->GetSize()); + break; + case GL_BUFFER_USAGE: + *params = MG_Util::ConvertBufferUsageToGLEnum(bufferObject->GetUsage()); + break; + case GL_BUFFER_ACCESS: + if (bufferObject->IsMapped()) { + auto access = bufferObject->GetMappingAccess(); + if (access & BufferMappingAccessBit::Read && access & BufferMappingAccessBit::Write) { + *params = GL_READ_WRITE; + } else if (access & BufferMappingAccessBit::Read) { + *params = GL_READ_ONLY; + } else if (access & BufferMappingAccessBit::Write) { + *params = GL_WRITE_ONLY; + } else { + *params = 0; + } + } else { + *params = 0; + } + break; + case GL_BUFFER_MAPPED: + *params = bufferObject->IsMapped() ? GL_TRUE : GL_FALSE; + break; + } + } + void DeleteBuffers_State(GLsizei n, const GLuint* buffers) { if (n < 0) { MG_State::pGLContext->RecordError( @@ -182,7 +235,8 @@ namespace MobileGL { 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 + // TODO: check if the buffer data is created by BufferStorage and its flags after its + // implementation MG_State::pGLContext->RecordError( ErrorCode::InvalidOperation, MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", @@ -368,9 +422,9 @@ namespace MobileGL { if (offset + size >= mappedRange.start) { MG_State::pGLContext->RecordError( ErrorCode::InvalidOperation, - MakeShared( - "MG_Impl/GLImpl", "BufferSubData_State", - "Cannot modify a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT.")); + MakeShared("MG_Impl/GLImpl", "BufferSubData_State", + "Cannot modify a mapped buffer object unless it was " + "mapped with GL_MAP_PERSISTENT_BIT.")); return; } } @@ -441,6 +495,10 @@ namespace MobileGL { } /* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */ + void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) { + GetBufferParameteriv_State(target, pname, params); + } + GLboolean IsBuffer(GLuint buffer) { return IsBuffer_State(buffer); } diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h index 1f3412ef..4fe9d1ef 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h @@ -4,6 +4,7 @@ namespace MobileGL { namespace MG_Impl::GLImpl { /* @INSERTION_POINT:FUNCTION_DECLARATION@ */ + void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params); GLboolean IsBuffer(GLuint buffer); void DeleteBuffers(GLsizei n, const GLuint* buffers); void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); diff --git a/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp b/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp index 15f6cdb1..e9694af2 100644 --- a/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp +++ b/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp @@ -37,8 +37,8 @@ DECLARE_GL_FUNCTION_HEAD(const GLubyte*, GetString, GLenum name) DECLARE_GL_FUNC DECLARE_GL_FUNCTION_HEAD(void*, MapBuffer, GLenum target, GLenum access) DECLARE_GL_FUNCTION_END(void*, MapBuffer, target, access) DECLARE_GL_FUNCTION_HEAD(void, ClearDepth, GLclampd depth) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ClearDepth, depth) DECLARE_GL_FUNCTION_HEAD(void, ActiveTexture, GLenum texture) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ActiveTexture, texture) -DECLARE_GL_FUNCTION_STUB_HEAD(void, AttachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, AttachShader, program, shader) -DECLARE_GL_FUNCTION_STUB_HEAD(void, BindAttribLocation, GLuint program, GLuint index, const GLchar* name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BindAttribLocation, program, index, name) +DECLARE_GL_FUNCTION_HEAD(void, AttachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_END_NO_RETURN(void, AttachShader, program, shader) +DECLARE_GL_FUNCTION_HEAD(void, BindAttribLocation, GLuint program, GLuint index, const GLchar* name) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindAttribLocation, program, index, name) DECLARE_GL_FUNCTION_HEAD(void, BindBuffer, GLenum target, GLuint buffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindBuffer, target, buffer) DECLARE_GL_FUNCTION_HEAD(void, BindFramebuffer, GLenum target, GLuint framebuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindFramebuffer, target, framebuffer) DECLARE_GL_FUNCTION_HEAD(void, BindRenderbuffer, GLenum target, GLuint renderbuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindRenderbuffer, target, renderbuffer) @@ -56,24 +56,24 @@ DECLARE_GL_FUNCTION_HEAD(void, ClearColor, GLfloat red, GLfloat green, GLfloat b DECLARE_GL_FUNCTION_STUB_HEAD(void, ClearDepthf, GLfloat d) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClearDepthf, d) DECLARE_GL_FUNCTION_HEAD(void, ClearStencil, GLint s) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ClearStencil, s) DECLARE_GL_FUNCTION_HEAD(void, ColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ColorMask, red, green, blue, alpha) -DECLARE_GL_FUNCTION_STUB_HEAD(void, CompileShader, GLuint shader) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, CompileShader, shader) +DECLARE_GL_FUNCTION_HEAD(void, CompileShader, GLuint shader) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CompileShader, shader) DECLARE_GL_FUNCTION_HEAD(void, CompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CompressedTexImage2D, target, level, internalformat, width, height, border, imageSize, data) DECLARE_GL_FUNCTION_HEAD(void, CompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CompressedTexSubImage2D, target, level, xoffset, yoffset, width, height, format, imageSize, data) DECLARE_GL_FUNCTION_HEAD(void, CopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CopyTexImage2D, target, level, internalformat, x, y, width, height, border) DECLARE_GL_FUNCTION_HEAD(void, CopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CopyTexSubImage2D, target, level, xoffset, yoffset, x, y, width, height) -DECLARE_GL_FUNCTION_STUB_HEAD(GLuint, CreateProgram) DECLARE_GL_FUNCTION_STUB_END(GLuint, CreateProgram) -DECLARE_GL_FUNCTION_STUB_HEAD(GLuint, CreateShader, GLenum type) DECLARE_GL_FUNCTION_STUB_END(GLuint, CreateShader, type) +DECLARE_GL_FUNCTION_HEAD(GLuint, CreateProgram) DECLARE_GL_FUNCTION_END(GLuint, CreateProgram) +DECLARE_GL_FUNCTION_HEAD(GLuint, CreateShader, GLenum type) DECLARE_GL_FUNCTION_END(GLuint, CreateShader, type) DECLARE_GL_FUNCTION_HEAD(void, CullFace, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CullFace, mode) DECLARE_GL_FUNCTION_HEAD(void, DeleteBuffers, GLsizei n, const GLuint* buffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteBuffers, n, buffers) DECLARE_GL_FUNCTION_HEAD(void, DeleteFramebuffers, GLsizei n, const GLuint* framebuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteFramebuffers, n, framebuffers) -DECLARE_GL_FUNCTION_STUB_HEAD(void, DeleteProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DeleteProgram, program) +DECLARE_GL_FUNCTION_HEAD(void, DeleteProgram, GLuint program) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteProgram, program) DECLARE_GL_FUNCTION_HEAD(void, DeleteRenderbuffers, GLsizei n, const GLuint* renderbuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteRenderbuffers, n, renderbuffers) -DECLARE_GL_FUNCTION_STUB_HEAD(void, DeleteShader, GLuint shader) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DeleteShader, shader) +DECLARE_GL_FUNCTION_HEAD(void, DeleteShader, GLuint shader) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteShader, shader) DECLARE_GL_FUNCTION_HEAD(void, DeleteTextures, GLsizei n, const GLuint* textures) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteTextures, n, textures) DECLARE_GL_FUNCTION_HEAD(void, DepthFunc, GLenum func) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DepthFunc, func) DECLARE_GL_FUNCTION_HEAD(void, DepthMask, GLboolean flag) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DepthMask, flag) DECLARE_GL_FUNCTION_STUB_HEAD(void, DepthRangef, GLfloat n, GLfloat f) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DepthRangef, n, f) -DECLARE_GL_FUNCTION_STUB_HEAD(void, DetachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DetachShader, program, shader) +DECLARE_GL_FUNCTION_HEAD(void, DetachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DetachShader, program, shader) DECLARE_GL_FUNCTION_HEAD(void, Disable, GLenum cap) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Disable, cap) DECLARE_GL_FUNCTION_HEAD(void, DisableVertexAttribArray, GLuint index) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DisableVertexAttribArray, index) DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawArrays, GLenum mode, GLint first, GLsizei count) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawArrays, mode, first, count) @@ -85,33 +85,33 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, Flush) DECLARE_GL_FUNCTION_STUB_END_NO_RETUR DECLARE_GL_FUNCTION_HEAD(void, FramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferRenderbuffer, target, attachment, renderbuffertarget, renderbuffer) DECLARE_GL_FUNCTION_HEAD(void, FramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferTexture2D, target, attachment, textarget, texture, level) DECLARE_GL_FUNCTION_HEAD(void, FrontFace, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FrontFace, mode) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GenBuffers, GLsizei n, GLuint* buffers) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GenBuffers, n, buffers) +DECLARE_GL_FUNCTION_HEAD(void, GenBuffers, GLsizei n, GLuint* buffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenBuffers, n, buffers) DECLARE_GL_FUNCTION_HEAD(void, GenerateMipmap, GLenum target) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenerateMipmap, target) DECLARE_GL_FUNCTION_HEAD(void, GenFramebuffers, GLsizei n, GLuint* framebuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenFramebuffers, n, framebuffers) DECLARE_GL_FUNCTION_HEAD(void, GenRenderbuffers, GLsizei n, GLuint* renderbuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenRenderbuffers, n, renderbuffers) DECLARE_GL_FUNCTION_HEAD(void, GenTextures, GLsizei n, GLuint* textures) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenTextures, n, textures) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetActiveAttrib, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetActiveAttrib, program, index, bufSize, length, size, type, name) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetActiveUniform, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetActiveUniform, program, index, bufSize, length, size, type, name) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetAttachedShaders, GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetAttachedShaders, program, maxCount, count, shaders) -DECLARE_GL_FUNCTION_STUB_HEAD(GLint, GetAttribLocation, GLuint program, const GLchar* name) DECLARE_GL_FUNCTION_STUB_END(GLint, GetAttribLocation, program, name) +DECLARE_GL_FUNCTION_HEAD(void, GetActiveAttrib, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetActiveAttrib, program, index, bufSize, length, size, type, name) +DECLARE_GL_FUNCTION_HEAD(void, GetActiveUniform, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetActiveUniform, program, index, bufSize, length, size, type, name) +DECLARE_GL_FUNCTION_HEAD(void, GetAttachedShaders, GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetAttachedShaders, program, maxCount, count, shaders) +DECLARE_GL_FUNCTION_HEAD(GLint, GetAttribLocation, GLuint program, const GLchar* name) DECLARE_GL_FUNCTION_END(GLint, GetAttribLocation, program, name) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetBooleanv, GLenum pname, GLboolean* data) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetBooleanv, pname, data) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetBufferParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetBufferParameteriv, target, pname, params) +DECLARE_GL_FUNCTION_HEAD(void, GetBufferParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetBufferParameteriv, target, pname, params) DECLARE_GL_FUNCTION_HEAD(GLenum, GetError) DECLARE_GL_FUNCTION_END(GLenum, GetError) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetFloatv, GLenum pname, GLfloat* data) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetFloatv, pname, data) DECLARE_GL_FUNCTION_HEAD(void, GetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetFramebufferAttachmentParameteriv, target, attachment, pname, params) DECLARE_GL_FUNCTION_HEAD(void, GetIntegerv, GLenum pname, GLint* data) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetIntegerv, pname, data) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetProgramiv, GLuint program, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetProgramiv, program, pname, params) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetProgramInfoLog, GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetProgramInfoLog, program, bufSize, length, infoLog) +DECLARE_GL_FUNCTION_HEAD(void, GetProgramiv, GLuint program, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetProgramiv, program, pname, params) +DECLARE_GL_FUNCTION_HEAD(void, GetProgramInfoLog, GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetProgramInfoLog, program, bufSize, length, infoLog) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetRenderbufferParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetRenderbufferParameteriv, target, pname, params) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderiv, GLuint shader, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderiv, shader, pname, params) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderInfoLog, GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderInfoLog, shader, bufSize, length, infoLog) +DECLARE_GL_FUNCTION_HEAD(void, GetShaderiv, GLuint shader, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetShaderiv, shader, pname, params) +DECLARE_GL_FUNCTION_HEAD(void, GetShaderInfoLog, GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetShaderInfoLog, shader, bufSize, length, infoLog) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderPrecisionFormat, shadertype, precisiontype, range, precision) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderSource, GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderSource, shader, bufSize, length, source) +DECLARE_GL_FUNCTION_HEAD(void, GetShaderSource, GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetShaderSource, shader, bufSize, length, source) DECLARE_GL_FUNCTION_HEAD(void, GetTexParameterfv, GLenum target, GLenum pname, GLfloat* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetTexParameterfv, target, pname, params) DECLARE_GL_FUNCTION_HEAD(void, GetTexParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetTexParameteriv, target, pname, params) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetUniformfv, GLuint program, GLint location, GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetUniformfv, program, location, params) -DECLARE_GL_FUNCTION_STUB_HEAD(void, GetUniformiv, GLuint program, GLint location, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetUniformiv, program, location, params) -DECLARE_GL_FUNCTION_STUB_HEAD(GLint, GetUniformLocation, GLuint program, const GLchar* name) DECLARE_GL_FUNCTION_STUB_END(GLint, GetUniformLocation, program, name) +DECLARE_GL_FUNCTION_HEAD(void, GetUniformfv, GLuint program, GLint location, GLfloat* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetUniformfv, program, location, params) +DECLARE_GL_FUNCTION_HEAD(void, GetUniformiv, GLuint program, GLint location, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetUniformiv, program, location, params) +DECLARE_GL_FUNCTION_HEAD(GLint, GetUniformLocation, GLuint program, const GLchar* name) DECLARE_GL_FUNCTION_END(GLint, GetUniformLocation, program, name) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetVertexAttribfv, GLuint index, GLenum pname, GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetVertexAttribfv, index, pname, params) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetVertexAttribiv, GLuint index, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetVertexAttribiv, index, pname, params) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetVertexAttribPointerv, GLuint index, GLenum pname, void** pointer) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetVertexAttribPointerv, index, pname, pointer) @@ -119,12 +119,12 @@ DECLARE_GL_FUNCTION_HEAD(void, Hint, GLenum target, GLenum mode) DECLARE_GL_FUNC DECLARE_GL_FUNCTION_HEAD(GLboolean, IsBuffer, GLuint buffer) DECLARE_GL_FUNCTION_END(GLboolean, IsBuffer, buffer) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsEnabled, GLenum cap) DECLARE_GL_FUNCTION_END(GLboolean, IsEnabled, cap) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsFramebuffer, GLuint framebuffer) DECLARE_GL_FUNCTION_END(GLboolean, IsFramebuffer, framebuffer) -DECLARE_GL_FUNCTION_STUB_HEAD(GLboolean, IsProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END(GLboolean, IsProgram, program) +DECLARE_GL_FUNCTION_HEAD(GLboolean, IsProgram, GLuint program) DECLARE_GL_FUNCTION_END(GLboolean, IsProgram, program) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsRenderbuffer, GLuint renderbuffer) DECLARE_GL_FUNCTION_END(GLboolean, IsRenderbuffer, renderbuffer) -DECLARE_GL_FUNCTION_STUB_HEAD(GLboolean, IsShader, GLuint shader) DECLARE_GL_FUNCTION_STUB_END(GLboolean, IsShader, shader) +DECLARE_GL_FUNCTION_HEAD(GLboolean, IsShader, GLuint shader) DECLARE_GL_FUNCTION_END(GLboolean, IsShader, shader) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsTexture, GLuint texture) DECLARE_GL_FUNCTION_END(GLboolean, IsTexture, texture) DECLARE_GL_FUNCTION_HEAD(void, LineWidth, GLfloat width) DECLARE_GL_FUNCTION_END_NO_RETURN(void, LineWidth, width) -DECLARE_GL_FUNCTION_STUB_HEAD(void, LinkProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, LinkProgram, program) +DECLARE_GL_FUNCTION_HEAD(void, LinkProgram, GLuint program) DECLARE_GL_FUNCTION_END_NO_RETURN(void, LinkProgram, program) DECLARE_GL_FUNCTION_HEAD(void, PixelStorei, GLenum pname, GLint param) DECLARE_GL_FUNCTION_END_NO_RETURN(void, PixelStorei, pname, param) DECLARE_GL_FUNCTION_HEAD(void, PolygonOffset, GLfloat factor, GLfloat units) DECLARE_GL_FUNCTION_END_NO_RETURN(void, PolygonOffset, factor, units) DECLARE_GL_FUNCTION_STUB_HEAD(void, ReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ReadPixels, x, y, width, height, format, type, pixels) @@ -133,7 +133,7 @@ DECLARE_GL_FUNCTION_HEAD(void, RenderbufferStorage, GLenum target, GLenum intern DECLARE_GL_FUNCTION_HEAD(void, SampleCoverage, GLfloat value, GLboolean invert) DECLARE_GL_FUNCTION_END_NO_RETURN(void, SampleCoverage, value, invert) DECLARE_GL_FUNCTION_HEAD(void, Scissor, GLint x, GLint y, GLsizei width, GLsizei height) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Scissor, x, y, width, height) DECLARE_GL_FUNCTION_STUB_HEAD(void, ShaderBinary, GLsizei count, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ShaderBinary, count, shaders, binaryformat, binary, length) -DECLARE_GL_FUNCTION_STUB_HEAD(void, ShaderSource, GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ShaderSource, shader, count, string, length) +DECLARE_GL_FUNCTION_HEAD(void, ShaderSource, GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ShaderSource, shader, count, string, length) DECLARE_GL_FUNCTION_HEAD(void, StencilFunc, GLenum func, GLint ref, GLuint mask) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilFunc, func, ref, mask) DECLARE_GL_FUNCTION_HEAD(void, StencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilFuncSeparate, face, func, ref, mask) DECLARE_GL_FUNCTION_HEAD(void, StencilMask, GLuint mask) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilMask, mask) @@ -146,27 +146,27 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, TexParameterfv, GLenum target, GLenum pname, DECLARE_GL_FUNCTION_HEAD(void, TexParameteri, GLenum target, GLenum pname, GLint param) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexParameteri, target, pname, param) DECLARE_GL_FUNCTION_STUB_HEAD(void, TexParameteriv, GLenum target, GLenum pname, const GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, TexParameteriv, target, pname, params) DECLARE_GL_FUNCTION_HEAD(void, TexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexSubImage2D, target, level, xoffset, yoffset, width, height, format, type, pixels) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform1f, GLint location, GLfloat v0) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform1f, location, v0) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform1fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform1fv, location, count, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform1i, GLint location, GLint v0) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform1i, location, v0) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform1iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform1iv, location, count, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform2f, GLint location, GLfloat v0, GLfloat v1) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform2f, location, v0, v1) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform2fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform2fv, location, count, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform2i, GLint location, GLint v0, GLint v1) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform2i, location, v0, v1) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform2iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform2iv, location, count, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform3f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform3f, location, v0, v1, v2) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform3fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform3fv, location, count, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform3i, GLint location, GLint v0, GLint v1, GLint v2) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform3i, location, v0, v1, v2) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform3iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform3iv, location, count, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform4f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform4f, location, v0, v1, v2, v3) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform4fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform4fv, location, count, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform4i, GLint location, GLint v0, GLint v1, GLint v2, GLint v3) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform4i, location, v0, v1, v2, v3) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform4iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform4iv, location, count, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, UniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, UniformMatrix2fv, location, count, transpose, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, UniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, UniformMatrix3fv, location, count, transpose, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, UniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, UniformMatrix4fv, location, count, transpose, value) -DECLARE_GL_FUNCTION_STUB_HEAD(void, UseProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, UseProgram, program) -DECLARE_GL_FUNCTION_STUB_HEAD(void, ValidateProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ValidateProgram, program) +DECLARE_GL_FUNCTION_HEAD(void, Uniform1f, GLint location, GLfloat v0) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform1f, location, v0) +DECLARE_GL_FUNCTION_HEAD(void, Uniform1fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform1fv, location, count, value) +DECLARE_GL_FUNCTION_HEAD(void, Uniform1i, GLint location, GLint v0) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform1i, location, v0) +DECLARE_GL_FUNCTION_HEAD(void, Uniform1iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform1iv, location, count, value) +DECLARE_GL_FUNCTION_HEAD(void, Uniform2f, GLint location, GLfloat v0, GLfloat v1) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform2f, location, v0, v1) +DECLARE_GL_FUNCTION_HEAD(void, Uniform2fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform2fv, location, count, value) +DECLARE_GL_FUNCTION_HEAD(void, Uniform2i, GLint location, GLint v0, GLint v1) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform2i, location, v0, v1) +DECLARE_GL_FUNCTION_HEAD(void, Uniform2iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform2iv, location, count, value) +DECLARE_GL_FUNCTION_HEAD(void, Uniform3f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform3f, location, v0, v1, v2) +DECLARE_GL_FUNCTION_HEAD(void, Uniform3fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform3fv, location, count, value) +DECLARE_GL_FUNCTION_HEAD(void, Uniform3i, GLint location, GLint v0, GLint v1, GLint v2) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform3i, location, v0, v1, v2) +DECLARE_GL_FUNCTION_HEAD(void, Uniform3iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform3iv, location, count, value) +DECLARE_GL_FUNCTION_HEAD(void, Uniform4f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform4f, location, v0, v1, v2, v3) +DECLARE_GL_FUNCTION_HEAD(void, Uniform4fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform4fv, location, count, value) +DECLARE_GL_FUNCTION_HEAD(void, Uniform4i, GLint location, GLint v0, GLint v1, GLint v2, GLint v3) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform4i, location, v0, v1, v2, v3) +DECLARE_GL_FUNCTION_HEAD(void, Uniform4iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform4iv, location, count, value) +DECLARE_GL_FUNCTION_HEAD(void, UniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, UniformMatrix2fv, location, count, transpose, value) +DECLARE_GL_FUNCTION_HEAD(void, UniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, UniformMatrix3fv, location, count, transpose, value) +DECLARE_GL_FUNCTION_HEAD(void, UniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, UniformMatrix4fv, location, count, transpose, value) +DECLARE_GL_FUNCTION_HEAD(void, UseProgram, GLuint program) DECLARE_GL_FUNCTION_END_NO_RETURN(void, UseProgram, program) +DECLARE_GL_FUNCTION_HEAD(void, ValidateProgram, GLuint program) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ValidateProgram, program) DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib1f, GLuint index, GLfloat x) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib1f, index, x) DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib1fv, GLuint index, const GLfloat* v) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib1fv, index, v) DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib2f, GLuint index, GLfloat x, GLfloat y) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib2f, index, x, y) diff --git a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp index 3ffc0843..f74e97ed 100644 --- a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp @@ -1,7 +1,6 @@ #include "GL_Framebuffer.h" -#include "GL/glext.h" #include "Validators.h" -#include +#include #include #include @@ -70,17 +69,20 @@ namespace MobileGL { void FramebufferTexture2D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { if (target == GL_FRAMEBUFFER) { - FramebufferTexture2D_State(GL_DRAW_FRAMEBUFFER, attachment, textarget, texture, level); - FramebufferTexture2D_State(GL_READ_FRAMEBUFFER, attachment, textarget, texture, level); - return; + target = GL_DRAW_FRAMEBUFFER; + } + + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + FramebufferTexture2D_State(target, GL_DEPTH_ATTACHMENT, textarget, texture, level); + FramebufferTexture2D_State(target, GL_STENCIL_ATTACHMENT, textarget, texture, level); } FramebufferAttachmentType attachmentType = MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment); - if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return; - - if (!FramebufferImpl::ValidateFramebufferName(texture, true)) return; FramebufferTarget framebufferTarget = MG_Util::ConvertGLEnumToFramebufferTarget(target); + + if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return; if (!FramebufferImpl::ValidateFramebufferTarget(framebufferTarget)) return; + if (!TextureImpl::ValidateTextureName(texture)) return; auto& bindingSlot = MG_State::pGLContext->GetFramebufferBindingSlot(framebufferTarget); auto framebufferObject = bindingSlot.GetBoundObject(); @@ -287,5 +289,9 @@ namespace MobileGL { void BindFramebuffer(GLenum target, GLuint framebuffer) { BindFramebuffer_State(target, framebuffer); } + + namespace FramebufferImpl { + DefaultFramebufferInfo* pDefaultFramebufferInfo; + } } // namespace MG_Impl::GLImpl } // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h index 0225d079..b10cd75d 100644 --- a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h +++ b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h @@ -1,5 +1,7 @@ #pragma once +#include "MG_State/GLState/FramebufferState/FramebufferObject.h" #include +#include namespace MobileGL { namespace MG_Impl::GLImpl { @@ -29,5 +31,16 @@ namespace MobileGL { GLint dstY1, GLbitfield mask, GLenum filter); void BindRenderbuffer(GLenum target, GLuint renderbuffer); void BindFramebuffer(GLenum target, GLuint framebuffer); + + namespace FramebufferImpl { + struct DefaultFramebufferInfo { + SharedPtr defaultFBO; + SharedPtr colorAttachment; + SharedPtr depthAttachment; + SharedPtr stencilAttachment; + }; + + extern DefaultFramebufferInfo* pDefaultFramebufferInfo; + } // namespace FramebufferImpl } // namespace MG_Impl::GLImpl } // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp index e7687982..d150fb15 100644 --- a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp +++ b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp @@ -29,10 +29,10 @@ namespace MobileGL { case GL_VERSION: { if (versionStr.empty()) { versionStr = - std::format("{} {}, {} Backend, Version {}", + std::format("{} {} {}, {} Backend", 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()); + MG_Config::ProjectName.c_str(), MG_Config::CoreVersion.toString().c_str(), + MG_Config::RendererInfoPtr->BackendName.c_str()); } return (const GLubyte*)versionStr.c_str(); } @@ -115,6 +115,9 @@ namespace MobileGL { case GL_MINOR_VERSION: params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Minor; break; + case GL_MAX_TEXTURE_SIZE: + params[0] = 1024 * 64; // TODO: get from backend + break; // State // TODO diff --git a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp index 1d2c62ae..2dd584b7 100644 --- a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp +++ b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp @@ -1,8 +1,8 @@ #include "GL_Texture.h" -#include "GL/glext.h" -#include "MG_State/GLState/TextureState/TextureObject.h" +#include "GL/gl.h" #include "MG_Util/Types.h" #include "Validators.h" +#include "ProxyTexture.h" #include #include #include @@ -93,11 +93,142 @@ namespace MobileGL { } void TexParameterf_State(GLenum target, GLenum pname, GLfloat param) { - // TODO: implement + + // ======================= Converting ================================ + TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target); + TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget); + + // ======================= Processing ================================ + SharedPtr textureObject = nullptr; + if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) { + textureObject = + TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget); + } else { + auto activeUnit = + MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); + auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); + textureObject = bindingSlot.GetBoundObject(); + } + + if (!TextureImpl::ValidateTextureObject(textureObject)) return; + + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + textureObject->GetSamplerObject()->SetMagFilter(MG_Util::ConvertGLEnumToSamplerFilterMode(param)); + break; + case GL_TEXTURE_MIN_FILTER: + textureObject->GetSamplerObject()->SetMinFilter(MG_Util::ConvertGLEnumToSamplerFilterMode(param)); + break; + case GL_TEXTURE_MIN_LOD: { + Float maxLod = textureObject->GetSamplerObject()->GetMaxLod(); + textureObject->GetSamplerObject()->SetLodRange(param, maxLod); + break; + } + case GL_TEXTURE_MAX_LOD: { + Float minLod = textureObject->GetSamplerObject()->GetMinLod(); + textureObject->GetSamplerObject()->SetLodRange(minLod, param); + break; + } + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_TEXTURE_SWIZZLE_R: + case GL_TEXTURE_SWIZZLE_G: + case GL_TEXTURE_SWIZZLE_B: + case GL_TEXTURE_SWIZZLE_A: + case GL_TEXTURE_SWIZZLE_RGBA: + case GL_TEXTURE_BORDER_COLOR: + break; // TODO + case GL_TEXTURE_WRAP_S: + textureObject->GetSamplerObject()->SetWrapS(MG_Util::ConvertGLEnumToSamplerWrapMode(param)); + break; + case GL_TEXTURE_WRAP_T: + textureObject->GetSamplerObject()->SetWrapT(MG_Util::ConvertGLEnumToSamplerWrapMode(param)); + break; + case GL_TEXTURE_WRAP_R: + textureObject->GetSamplerObject()->SetWrapR(MG_Util::ConvertGLEnumToSamplerWrapMode(param)); + break; + case GL_TEXTURE_COMPARE_MODE: + textureObject->GetSamplerObject()->SetCompareMode(MG_Util::ConvertGLEnumToSamplerCompareMode(param)); + break; + case GL_TEXTURE_COMPARE_FUNC: + textureObject->GetSamplerObject()->SetSamplerCompareFunc( + MG_Util::ConvertGLEnumToSamplerCompareFunc(param)); + break; + default: + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, MakeShared("MG_Impl/GLImpl", "TexParameteri_State", + "pname is not a valid texture parameter.")); + return; + } } void TexParameteri_State(GLenum target, GLenum pname, GLint param) { - // TODO: implement + // ======================= Converting ================================ + TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target); + TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget); + + // ======================= Processing ================================ + SharedPtr textureObject = nullptr; + if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) { + textureObject = + TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget); + } else { + auto activeUnit = + MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); + auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); + textureObject = bindingSlot.GetBoundObject(); + } + + if (!TextureImpl::ValidateTextureObject(textureObject)) return; + + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + textureObject->GetSamplerObject()->SetMagFilter(MG_Util::ConvertGLEnumToSamplerFilterMode(param)); + break; + case GL_TEXTURE_MIN_FILTER: + textureObject->GetSamplerObject()->SetMinFilter(MG_Util::ConvertGLEnumToSamplerFilterMode(param)); + break; + case GL_TEXTURE_MIN_LOD: { + Float maxLod = textureObject->GetSamplerObject()->GetMaxLod(); + textureObject->GetSamplerObject()->SetLodRange(param, maxLod); + break; + } + case GL_TEXTURE_MAX_LOD: { + Float minLod = textureObject->GetSamplerObject()->GetMinLod(); + textureObject->GetSamplerObject()->SetLodRange(minLod, param); + break; + } + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_TEXTURE_SWIZZLE_R: + case GL_TEXTURE_SWIZZLE_G: + case GL_TEXTURE_SWIZZLE_B: + case GL_TEXTURE_SWIZZLE_A: + case GL_TEXTURE_SWIZZLE_RGBA: + case GL_TEXTURE_BORDER_COLOR: + break; // TODO + case GL_TEXTURE_WRAP_S: + textureObject->GetSamplerObject()->SetWrapS(MG_Util::ConvertGLEnumToSamplerWrapMode(param)); + break; + case GL_TEXTURE_WRAP_T: + textureObject->GetSamplerObject()->SetWrapT(MG_Util::ConvertGLEnumToSamplerWrapMode(param)); + break; + case GL_TEXTURE_WRAP_R: + textureObject->GetSamplerObject()->SetWrapR(MG_Util::ConvertGLEnumToSamplerWrapMode(param)); + break; + case GL_TEXTURE_COMPARE_MODE: + textureObject->GetSamplerObject()->SetCompareMode(MG_Util::ConvertGLEnumToSamplerCompareMode(param)); + break; + case GL_TEXTURE_COMPARE_FUNC: + textureObject->GetSamplerObject()->SetSamplerCompareFunc( + MG_Util::ConvertGLEnumToSamplerCompareFunc(param)); + break; + default: + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, MakeShared("MG_Impl/GLImpl", "TexParameteri_State", + "pname is not a valid texture parameter.")); + return; + } } void TexImage3DMultisample_State(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, @@ -148,9 +279,16 @@ namespace MobileGL { // indicated by type. // ======================= Processing ================================ - auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); - auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); - auto textureObject = bindingSlot.GetBoundObject(); + SharedPtr textureObject = nullptr; + if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) { + textureObject = + TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget); + } else { + auto activeUnit = + MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); + auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); + textureObject = bindingSlot.GetBoundObject(); + } // ===================== Error Checking ============================== if (!TextureImpl::ValidateTextureObject(textureObject)) return; @@ -189,19 +327,307 @@ namespace MobileGL { } void GetTexParameteriv_State(GLenum target, GLenum pname, GLint* params) { - // TODO: implement + // ======================= Converting ================================ + TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target); + TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget); + + // ======================= Processing ================================ + SharedPtr textureObject = nullptr; + if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) { + textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget); + } else { + auto activeUnit = + MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); + auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); + textureObject = bindingSlot.GetBoundObject(); + } + + if (!TextureImpl::ValidateTextureObject(textureObject)) return; + + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + if (params) { + *params = + MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMagFilter()); + } + break; + case GL_TEXTURE_MIN_FILTER: + if (params) { + *params = + MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter()); + } + break; + case GL_TEXTURE_MIN_LOD: + if (params) { + *params = static_cast(textureObject->GetSamplerObject()->GetMinLod()); + } + break; + case GL_TEXTURE_MAX_LOD: + if (params) { + *params = static_cast(textureObject->GetSamplerObject()->GetMaxLod()); + } + break; + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_TEXTURE_SWIZZLE_R: + case GL_TEXTURE_SWIZZLE_G: + case GL_TEXTURE_SWIZZLE_B: + case GL_TEXTURE_SWIZZLE_A: + case GL_TEXTURE_SWIZZLE_RGBA: + case GL_TEXTURE_BORDER_COLOR: + break; // TODO + case GL_TEXTURE_WRAP_S: + if (params) { + *params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapS()); + } + break; + case GL_TEXTURE_WRAP_T: + if (params) { + *params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapT()); + } + break; + case GL_TEXTURE_WRAP_R: + if (params) { + *params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapR()); + } + break; + case GL_TEXTURE_COMPARE_MODE: + if (params) { + *params = + MG_Util::ConvertSamplerCompareModeToGLEnum(textureObject->GetSamplerObject()->GetCompareMode()); + } + break; + case GL_TEXTURE_COMPARE_FUNC: + if (params) { + *params = MG_Util::ConvertSamplerCompareFuncToGLEnum( + textureObject->GetSamplerObject()->GetSamplerCompareFunc()); + } + break; + default: + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, MakeShared("MG_Impl/GLImpl", "GetTexParameteriv_State", + "pname is not a valid texture parameter.")); + return; + } } void GetTexParameterfv_State(GLenum target, GLenum pname, GLfloat* params) { - // TODO: implement + // ======================= Converting ================================ + TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target); + TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget); + + // ======================= Processing ================================ + SharedPtr textureObject = nullptr; + if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) { + textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget); + } else { + auto activeUnit = + MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); + auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); + textureObject = bindingSlot.GetBoundObject(); + } + + if (!TextureImpl::ValidateTextureObject(textureObject)) return; + + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + if (params) { + *params = + MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMagFilter()); + } + break; + case GL_TEXTURE_MIN_FILTER: + if (params) { + *params = + MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter()); + } + break; + case GL_TEXTURE_MIN_LOD: + if (params) { + *params = static_cast(textureObject->GetSamplerObject()->GetMinLod()); + } + break; + case GL_TEXTURE_MAX_LOD: + if (params) { + *params = static_cast(textureObject->GetSamplerObject()->GetMaxLod()); + } + break; + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_TEXTURE_SWIZZLE_R: + case GL_TEXTURE_SWIZZLE_G: + case GL_TEXTURE_SWIZZLE_B: + case GL_TEXTURE_SWIZZLE_A: + case GL_TEXTURE_SWIZZLE_RGBA: + case GL_TEXTURE_BORDER_COLOR: + break; // TODO + case GL_TEXTURE_WRAP_S: + if (params) { + *params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapS()); + } + break; + case GL_TEXTURE_WRAP_T: + if (params) { + *params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapT()); + } + break; + case GL_TEXTURE_WRAP_R: + if (params) { + *params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapR()); + } + break; + case GL_TEXTURE_COMPARE_MODE: + if (params) { + *params = + MG_Util::ConvertSamplerCompareModeToGLEnum(textureObject->GetSamplerObject()->GetCompareMode()); + } + break; + case GL_TEXTURE_COMPARE_FUNC: + if (params) { + *params = MG_Util::ConvertSamplerCompareFuncToGLEnum( + textureObject->GetSamplerObject()->GetSamplerCompareFunc()); + } + break; + default: + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, MakeShared("MG_Impl/GLImpl", "GetTexParameterfv_State", + "pname is not a valid texture parameter.")); + return; + } } void GetTexLevelParameteriv_State(GLenum target, GLint level, GLenum pname, GLint* params) { - // TODO: implement + MGLOG_D("GetTexLevelParameteriv_State called"); + // ======================= Converting ================================ + TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target); + TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget); + + // ===================== Error Checking ============================== + if (!TextureImpl::ValidateTextureUploadTarget(textureUploadingTarget)) return; + if (!TextureImpl::ValidateTextureLevelNumber(level)) return; + if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return; + + // ======================= Processing ================================ + SharedPtr textureObject = nullptr; + + if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) { + textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget); + } else { + auto activeUnit = + MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); + auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); + textureObject = bindingSlot.GetBoundObject(); + } + + if (!TextureImpl::ValidateTextureObject(textureObject)) return; + + switch (pname) { + case GL_TEXTURE_WIDTH: + if (params) { + *params = textureObject->GetMipmap(level).size.x(); + } + break; + case GL_TEXTURE_HEIGHT: + if (params) { + *params = textureObject->GetMipmap(level).size.y(); + } + break; + case GL_TEXTURE_DEPTH: + if (params) { + *params = textureObject->GetMipmap(level).size.z(); + } + break; + case GL_TEXTURE_INTERNAL_FORMAT: + if (params) { + *params = MG_Util::ConvertTextureInternalFormatToGLEnum(textureObject->GetFormat()); + } + break; + case GL_TEXTURE_RED_TYPE: + case GL_TEXTURE_GREEN_TYPE: + case GL_TEXTURE_BLUE_TYPE: + case GL_TEXTURE_ALPHA_TYPE: + case GL_TEXTURE_DEPTH_TYPE: + case GL_TEXTURE_RED_SIZE: + case GL_TEXTURE_GREEN_SIZE: + case GL_TEXTURE_BLUE_SIZE: + case GL_TEXTURE_ALPHA_SIZE: + case GL_TEXTURE_DEPTH_SIZE: + case GL_TEXTURE_COMPRESSED: + case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: + break; // TODO + default: + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared("MG_Impl/GLImpl", "GetTexLevelParameteriv_State", + "pname is not a valid texture level parameter.")); + return; + } } void GetTexLevelParameterfv_State(GLenum target, GLint level, GLenum pname, GLfloat* params) { - // TODO: implement + // ======================= Converting ================================ + TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target); + TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget); + + // ===================== Error Checking ============================== + if (!TextureImpl::ValidateTextureUploadTarget(textureUploadingTarget)) return; + if (!TextureImpl::ValidateTextureLevelNumber(level)) return; + if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return; + + // ======================= Processing ================================ + SharedPtr textureObject = nullptr; + if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) { + textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget); + } else { + auto activeUnit = + MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); + auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); + textureObject = bindingSlot.GetBoundObject(); + } + + if (!TextureImpl::ValidateTextureObject(textureObject)) return; + + switch (pname) { + case GL_TEXTURE_WIDTH: + if (params) { + *params = textureObject->GetMipmap(level).size.x(); + } + break; + case GL_TEXTURE_HEIGHT: + if (params) { + *params = textureObject->GetMipmap(level).size.y(); + } + break; + case GL_TEXTURE_DEPTH: + if (params) { + *params = textureObject->GetMipmap(level).size.z(); + } + break; + case GL_TEXTURE_INTERNAL_FORMAT: + if (params) { + *params = MG_Util::ConvertTextureInternalFormatToGLEnum(textureObject->GetFormat()); + } + break; + case GL_TEXTURE_RED_TYPE: + case GL_TEXTURE_GREEN_TYPE: + case GL_TEXTURE_BLUE_TYPE: + case GL_TEXTURE_ALPHA_TYPE: + case GL_TEXTURE_DEPTH_TYPE: + case GL_TEXTURE_RED_SIZE: + case GL_TEXTURE_GREEN_SIZE: + case GL_TEXTURE_BLUE_SIZE: + case GL_TEXTURE_ALPHA_SIZE: + case GL_TEXTURE_DEPTH_SIZE: + case GL_TEXTURE_COMPRESSED: + case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: + break; // TODO + default: + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared("MG_Impl/GLImpl", "GetTexLevelParameterfv_State", + "pname is not a valid texture level parameter.")); + return; + } } void GetTexImage_State(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) { diff --git a/MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.cpp b/MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.cpp new file mode 100644 index 00000000..94d54a30 --- /dev/null +++ b/MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.cpp @@ -0,0 +1,41 @@ +#include "ProxyTexture.h" +#include "MG_State/GLState/TextureState/TextureObject.h" +#include "MG_Util/Types.h" + +namespace MobileGL::MG_Impl::GLImpl { + namespace TextureImpl { + ProxyTextureManager* pProxyTextureManager; + + Bool IsProxyTextureTarget(TextureUploadTarget target) { + switch (target) { + case TextureUploadTarget::ProxyCubeMap: + case TextureUploadTarget::ProxyTexture1DArray: + case TextureUploadTarget::ProxyTexture2D: + case TextureUploadTarget::ProxyTexture2DMultisample: + case TextureUploadTarget::ProxyTextureRectangle: + return true; + default: + return false; + } + } + + SharedPtr ProxyTextureManager::CreateOrReplaceProxyTextureObject( + TextureUploadTarget target) { + auto it = m_proxyTexturesMap.find(target); + if (it != m_proxyTexturesMap.end()) { + m_proxyTexturesMap.erase(it); + } + m_proxyTexturesMap[target] = MakeShared(); + return m_proxyTexturesMap[target]; + } + + SharedPtr ProxyTextureManager::GetProxyTextureObject( + TextureUploadTarget target) { + auto it = m_proxyTexturesMap.find(target); + if (it != m_proxyTexturesMap.end()) { + return it->second; + } + return nullptr; + } + } // namespace TextureImpl +} // namespace MobileGL::MG_Impl::GLImpl diff --git a/MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.h b/MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.h new file mode 100644 index 00000000..83f112f0 --- /dev/null +++ b/MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.h @@ -0,0 +1,20 @@ +#pragma once +#include +#include + +namespace MobileGL::MG_Impl::GLImpl { + namespace TextureImpl { + Bool IsProxyTextureTarget(TextureUploadTarget target); + + class ProxyTextureManager { + public: + SharedPtr CreateOrReplaceProxyTextureObject(TextureUploadTarget target); + SharedPtr GetProxyTextureObject(TextureUploadTarget target); + + private: + UnorderedMap> m_proxyTexturesMap; + }; + + extern ProxyTextureManager* pProxyTextureManager; + } // namespace TextureImpl +} // namespace MobileGL::MG_Impl::GLImpl diff --git a/MobileGL/MG_Impl/Init.cpp b/MobileGL/MG_Impl/Init.cpp new file mode 100644 index 00000000..dcdab740 --- /dev/null +++ b/MobileGL/MG_Impl/Init.cpp @@ -0,0 +1,30 @@ +#include "Init.h" +#include "GLImpl/Texture/ProxyTexture.h" +#include "GLImpl/Framebuffer/GL_Framebuffer.h" + +namespace MobileGL { + namespace MG_Impl { + void Init() { + MGLOG_D("Initializing MobileGL Implementation..."); + GLImpl::TextureImpl::pProxyTextureManager = new GLImpl::TextureImpl::ProxyTextureManager(); + + // TODO: get real info in EGL + auto fbo0 = MG_State::pGLContext->CreateFramebufferObject(0); + auto colorTex = MakeShared(); + colorTex->SetInternalFormat(TextureInternalFormat::RGBA8); + colorTex->SetMipmapLevel({{512, 512, 1}, 0, false, 0, {nullptr, 0}}); + auto depthTex = MakeShared(); + depthTex->SetInternalFormat(TextureInternalFormat::Depth32FStencil8); + depthTex->SetMipmapLevel({{512, 512, 1}, 0, false, 0, {nullptr, 0}}); + auto stencilTex = MakeShared(); + stencilTex->SetInternalFormat(TextureInternalFormat::Depth32FStencil8); + stencilTex->SetMipmapLevel({{512, 512, 1}, 0, false, 0, {nullptr, 0}}); + fbo0->AttachTexture(FramebufferAttachmentType::Color0, colorTex); + fbo0->AttachTexture(FramebufferAttachmentType::Depth, depthTex); + fbo0->AttachTexture(FramebufferAttachmentType::Depth, depthTex); + fbo0->AttachTexture(FramebufferAttachmentType::Stencil, stencilTex); + GLImpl::FramebufferImpl::pDefaultFramebufferInfo = + new GLImpl::FramebufferImpl::DefaultFramebufferInfo(fbo0, colorTex, depthTex, stencilTex); + } + } // namespace MG_Impl +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Impl/Init.h b/MobileGL/MG_Impl/Init.h new file mode 100644 index 00000000..45efa274 --- /dev/null +++ b/MobileGL/MG_Impl/Init.h @@ -0,0 +1,7 @@ +#include + +namespace MobileGL { + namespace MG_Impl { + void Init(); + } // namespace MG_Impl +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.cpp b/MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.cpp index 0b61d533..c206f6c4 100644 --- a/MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.cpp +++ b/MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.cpp @@ -9,9 +9,9 @@ namespace MobileGL { : m_texture(texture), m_textureLevel(level) {} FramebufferAttachment::FramebufferAttachment(SharedPtr renderbuffer) : m_renderbuffer(renderbuffer) {} - FramebufferAttachment::FramebufferAttachment(std::nullptr_t) - : m_texture(nullptr), m_renderbuffer(nullptr) {} - FramebufferAttachment::FramebufferAttachment() : m_texture(nullptr), m_renderbuffer(nullptr) {} + FramebufferAttachment::FramebufferAttachment(Bool IsValid) : m_texture(nullptr), m_renderbuffer(nullptr) { + m_isValid = IsValid; + } Bool FramebufferAttachment::IsTexture() const { return m_texture != nullptr; @@ -39,10 +39,13 @@ namespace MobileGL { Bool FramebufferAttachment::IsComplete() const { if (IsTexture()) { - return m_texture->IsComplete(); + Bool complete = m_texture->IsComplete(); + return complete; } else if (IsRenderbuffer()) { // TODO + return false; } + return false; } @@ -55,9 +58,13 @@ namespace MobileGL { return {0, 0}; } + Bool FramebufferAttachment::IsValid() const { + return m_isValid; + } + // FramebufferObject FramebufferObject::FramebufferObject() { - m_attachments.fill(FramebufferAttachment(nullptr)); + m_attachments.fill(FramebufferAttachment(false)); } void FramebufferObject::AttachTexture(FramebufferAttachmentType type, SharedPtr texture, @@ -73,7 +80,7 @@ namespace MobileGL { } void FramebufferObject::Detach(FramebufferAttachmentType type) { - m_attachments[static_cast(type)] = FramebufferAttachment(nullptr); + m_attachments[static_cast(type)] = FramebufferAttachment(false); m_drawBuffersDirty = true; } @@ -86,21 +93,30 @@ namespace MobileGL { return false; } - int width = -1, height = -1; - for (const auto& attachment : m_attachments) { + Int width = -1, height = -1; + Int validAttachmentCount = 0; + for (SizeT i = 0; i < m_attachments.size(); ++i) { + if (!m_attachments[i].IsValid()) continue; + + ++validAttachmentCount; + const auto& attachment = m_attachments[i]; auto attachmentSize = attachment.GetSize(); - int w = attachmentSize.x(); - int h = attachmentSize.y(); + Int w = attachmentSize.x(); + Int h = attachmentSize.y(); + if (width == -1) { width = w; height = h; } else if (width != w || height != h) { return false; } + if (!attachment.IsComplete()) { return false; } } + + if (validAttachmentCount == 0) return false; return true; } diff --git a/MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.h b/MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.h index 82ae0897..1e7879bd 100644 --- a/MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.h +++ b/MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.h @@ -46,7 +46,6 @@ namespace MobileGL { Color31, Depth, Stencil, - DepthStencil, FramebufferAttachmentTypeCount, Unknown = -1 }; @@ -60,8 +59,7 @@ namespace MobileGL { // TODO: add Renderbuffer when it is implemented explicit FramebufferAttachment(SharedPtr texture, Int level = 0); explicit FramebufferAttachment(SharedPtr renderbuffer); - explicit FramebufferAttachment(std::nullptr_t); - explicit FramebufferAttachment(); + explicit FramebufferAttachment(Bool IsValid = true); Bool IsTexture() const; Bool IsRenderbuffer() const; @@ -71,11 +69,13 @@ namespace MobileGL { Int GetTextureLevel() const; Bool IsComplete() const; IntVec3 GetSize() const; + Bool IsValid() const; private: SharedPtr m_texture = nullptr; SharedPtr m_renderbuffer = nullptr; Int m_textureLevel = 0; + Bool m_isValid = true; }; class FramebufferObject { diff --git a/MobileGL/MG_State/GLState/FramebufferState/FramebufferState.cpp b/MobileGL/MG_State/GLState/FramebufferState/FramebufferState.cpp index e5cac679..06ca2a12 100644 --- a/MobileGL/MG_State/GLState/FramebufferState/FramebufferState.cpp +++ b/MobileGL/MG_State/GLState/FramebufferState/FramebufferState.cpp @@ -1,13 +1,18 @@ #include "FramebufferState.h" +#include "MG_State/GLState/FramebufferState/FramebufferObject.h" namespace MobileGL { namespace MG_State { namespace GLState { - FramebufferState::FramebufferState() {} + FramebufferState::FramebufferState() { + for (SizeT i = 0; i < m_bindingSlots.size(); ++i) { + m_bindingSlots[i] = BindingSlot(static_cast(i)); + } + } SharedPtr FramebufferState::GetFramebufferObject(Uint index) { - auto it = m_bufferObjects.find(index); - if (it != m_bufferObjects.end()) { + auto it = m_framebufferObjects.find(index); + if (it != m_framebufferObjects.end()) { return it->second; } return nullptr; @@ -20,8 +25,15 @@ namespace MobileGL { } SharedPtr FramebufferState::CreateFramebufferObject(Uint index) { + if (index == 0) { + if (!m_indexGenerator.IsValid(0)) { + m_indexGenerator.Insert(0); + } else { + return nullptr; + } + } auto bufferObject = MakeShared(); - m_bufferObjects[index] = bufferObject; + m_framebufferObjects[index] = bufferObject; return bufferObject; } @@ -37,14 +49,14 @@ namespace MobileGL { void FramebufferState::MarkFramebufferObjectForDeletion(Uint index) { if (m_indexGenerator.IsValid(index)) { - auto it = m_bufferObjects.find(index); - if (it != m_bufferObjects.end()) { + auto it = m_framebufferObjects.find(index); + if (it != m_framebufferObjects.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_framebufferObjects.erase(it); } m_indexGenerator.Delete(index); } @@ -55,7 +67,7 @@ namespace MobileGL { } Bool FramebufferState::ValidateFramebufferObject(Uint index) const { - return m_bufferObjects.find(index) != m_bufferObjects.end(); + return m_framebufferObjects.find(index) != m_framebufferObjects.end(); } } // namespace GLState } // namespace MG_State diff --git a/MobileGL/MG_State/GLState/FramebufferState/FramebufferState.h b/MobileGL/MG_State/GLState/FramebufferState/FramebufferState.h index 1c7b22e4..14653f90 100644 --- a/MobileGL/MG_State/GLState/FramebufferState/FramebufferState.h +++ b/MobileGL/MG_State/GLState/FramebufferState/FramebufferState.h @@ -20,7 +20,7 @@ namespace MobileGL { Bool ValidateFramebufferObject(Uint index) const; private: - UnorderedMap> m_bufferObjects; + UnorderedMap> m_framebufferObjects; IndexGenerator m_indexGenerator; Array, static_cast(FramebufferTarget::FramebufferTargetCount)> m_bindingSlots; diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp index 8df444e3..afabb5a8 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp @@ -1,7 +1,6 @@ #include "ProgramObject.h" #include - -#include "MG_Util/Converters/SPIRVCrossToGL/SpvcTypeConverter.h" +#include namespace MobileGL { namespace MG_State { @@ -74,7 +73,9 @@ namespace MobileGL { for (int i = 0; i < m_activeUniformCount; i++) { auto& uniform = m_program->getUniform(i); auto location = uniform.layoutLocation(); - m_maxUniformLocation = std::max(m_maxUniformLocation, location); + if (location >= 0) { + m_maxUniformLocation = std::max(m_maxUniformLocation, location); + } m_uniformNameMaxLength = std::max(m_uniformNameMaxLength, (Int)uniform.name.length()); m_uniformLocations[uniform.name] = location; } @@ -88,37 +89,97 @@ namespace MobileGL { for (int i = 0; i < m_activeUniformCount; i++) { auto& uniform = m_program->getUniform(i); auto location = uniform.layoutLocation(); - m_uniformNames[location] = uniform.name; - m_uniformTypes[location] = uniform.glDefineType; - m_uniformIsOpaqueType[location] = uniform.getType()->isOpaque(); - m_uniformArraySizes[location] = uniform.size; - } - - // attributes (pipe in) - int inCount = m_program->getNumPipeInputs(); - m_attribs.resize(inCount); - m_attribTypes.resize(inCount); - - // Get locations parsed in program - for (int i = 0; i < inCount; i++) { - auto& inVar = m_program->getPipeInput(i); - auto location = inVar.layoutLocation(); - m_attribInNameMaxLength = std::max(m_attribInNameMaxLength, (Int)inVar.name.length()); - m_attribs[location] = inVar.name; - m_attribTypes[location] = inVar.glDefineType; - } - // Implement glBindAttribLocation semantics - for (auto& [name, location] : m_explicitAttribLocations) { - assert(location < m_attribs.size()); - if (m_attribs[location] != name) { - auto it = std::find(m_attribs.begin(), m_attribs.end(), name); - if (it == m_attribs.end()) continue; - std::swap(m_attribs[location], m_attribs[std::distance(m_attribs.begin(), it)]); - std::swap(m_attribTypes[location], m_attribTypes[std::distance(m_attribs.begin(), it)]); + if (location >= 0 && location < (int)m_uniformNames.size()) { + m_uniformNames[location] = uniform.name; + m_uniformTypes[location] = uniform.glDefineType; + m_uniformIsOpaqueType[location] = uniform.getType()->isOpaque(); + m_uniformArraySizes[location] = uniform.size; } } - // UBO + int inCount = m_program->getNumPipeInputs(); + + int maxLoc = -1; + for (int i = 0; i < inCount; ++i) { + int loc = m_program->getPipeInput(i).layoutLocation(); + if (loc >= 0) maxLoc = std::max(maxLoc, loc); + } + + if (maxLoc < 0) { + maxLoc = std::max(0, inCount - 1); + } + + GLint maxAttribs = 16; // TODO: get from backend + + if (maxLoc >= maxAttribs) { + MGLOG_W("ProgramObject::DoReflection - required attrib location %d >= GL_MAX_VERTEX_ATTRIBS (%d). " + "Clamping.", + maxLoc, maxAttribs); + maxLoc = maxAttribs - 1; + } + + m_attribs.resize(maxLoc + 1); + m_attribTypes.resize(maxLoc + 1); + + for (int i = 0; i < inCount; ++i) { + auto& inVar = m_program->getPipeInput(i); + int location = inVar.layoutLocation(); + m_attribInNameMaxLength = std::max(m_attribInNameMaxLength, (Int)inVar.name.length()); + + if (location >= 0 && location < (int)m_attribs.size()) { + m_attribs[location] = inVar.name; + m_attribTypes[location] = inVar.glDefineType; + } else if (location >= (int)m_attribs.size()) { + MGLOG_W("ProgramObject::DoReflection - attrib location %d >= attribs.size() (%zu). Ignoring.", + location, m_attribs.size()); + continue; + } else { + bool placed = false; + for (size_t idx = 0; idx < m_attribs.size(); ++idx) { + if (m_attribs[idx].empty()) { + m_attribs[idx] = inVar.name; + m_attribTypes[idx] = inVar.glDefineType; + placed = true; + break; + } + } + if (!placed && (int)m_attribs.size() < maxAttribs) { + m_attribs.push_back(inVar.name); + m_attribTypes.push_back(inVar.glDefineType); + placed = true; + } + if (!placed) { + MGLOG_W("ProgramObject::DoReflection - cannot place attrib '%s' (no free slot and at max " + "capacity). Ignoring.", + inVar.name.c_str()); + } + } + } + + // Implement glBindAttribLocation semantics (explicit locations set by user) + for (auto& [name, location] : m_explicitAttribLocations) { + if (location < 0) continue; + if (location >= (int)m_attribs.size()) { + if (location >= maxAttribs) { + MGLOG_W("SetExplicitAttribLocation: requested location %d >= GL_MAX_VERTEX_ATTRIBS (%d). " + "Ignored for attribute '%s'.", + location, maxAttribs, name.c_str()); + continue; + } + m_attribs.resize(location + 1); + m_attribTypes.resize(location + 1); + } + + if (m_attribs[location] != name) { + auto it = std::find(m_attribs.begin(), m_attribs.end(), name); + if (it == m_attribs.end()) continue; + auto idx = std::distance(m_attribs.begin(), it); + std::swap(m_attribs[location], m_attribs[idx]); + std::swap(m_attribTypes[location], m_attribTypes[idx]); + } + } + + // ---------- UBO ---------- int uboCount = m_program->getNumUniformBlocks(); for (int i = 0; i < uboCount; i++) { auto& ubo = m_program->getUniformBlock(i); diff --git a/MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp b/MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp index 8027da4e..c6b3dec4 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp +++ b/MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp @@ -1,7 +1,6 @@ #include "ShaderObject.h" #include - -#include "MG_Util/ShaderTranspiler/glslang/UniformTraverser.h" +#include namespace MobileGL { namespace MG_State { diff --git a/MobileGL/MG_State/GLState/TextureState/SamplerObject.h b/MobileGL/MG_State/GLState/TextureState/SamplerObject.h index ced34b58..40282da3 100644 --- a/MobileGL/MG_State/GLState/TextureState/SamplerObject.h +++ b/MobileGL/MG_State/GLState/TextureState/SamplerObject.h @@ -33,7 +33,7 @@ namespace MobileGL { Unknown = -1 }; - enum class CompareFunc { + enum class SamplerCompareFunc { Never, Less, Equal, @@ -42,7 +42,7 @@ namespace MobileGL { NotEqual, GreaterEqual, Always, - CompareFuncCount, + SamplerCompareFuncCount, Unknown = -1 }; @@ -55,7 +55,7 @@ namespace MobileGL { m_wrapR(SamplerWrapMode::Repeat), m_minFilter(SamplerFilterMode::Linear), m_magFilter(SamplerFilterMode::Linear), m_mipmapMode(SamplerMipmapMode::None), m_minLod(0.0f), m_maxLod(1000.0f), m_lodBias(0.0f), m_compareMode(SamplerCompareMode::None), - m_compareFunc(CompareFunc::Less) {} + m_compareFunc(SamplerCompareFunc::Less) {} void SetWrapS(SamplerWrapMode mode) { m_wrapS = mode; } void SetWrapT(SamplerWrapMode mode) { m_wrapT = mode; } @@ -71,7 +71,7 @@ namespace MobileGL { m_maxLod = maxLod; } void SetLodBias(Float bias) { m_lodBias = bias; } - void SetCompareFunc(CompareFunc func) { m_compareFunc = func; } + void SetSamplerCompareFunc(SamplerCompareFunc func) { m_compareFunc = func; } void SetCompareMode(SamplerCompareMode mode) { m_compareMode = mode; } SamplerWrapMode GetWrapS() const { return m_wrapS; } @@ -84,7 +84,7 @@ namespace MobileGL { Float GetMaxLod() const { return m_maxLod; } Float GetLodBias() const { return m_lodBias; } SamplerCompareMode GetCompareMode() const { return m_compareMode; } - CompareFunc GetCompareFunc() const { return m_compareFunc; } + SamplerCompareFunc GetSamplerCompareFunc() const { return m_compareFunc; } private: SamplerWrapMode m_wrapS, m_wrapT, m_wrapR; @@ -93,7 +93,7 @@ namespace MobileGL { Float m_minLod, m_maxLod; Float m_lodBias; SamplerCompareMode m_compareMode; - CompareFunc m_compareFunc; + SamplerCompareFunc m_compareFunc; }; } // namespace GLState } // namespace MG_State diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp b/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp index c80e6979..a241dc66 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject.cpp @@ -5,7 +5,9 @@ namespace MobileGL { namespace MG_State { namespace GLState { // TextureObjectBase implementations - TextureObjectBase::TextureObjectBase(TextureTarget target) : m_target(target), m_sampler(nullptr) {} + TextureObjectBase::TextureObjectBase(TextureTarget target) : m_target(target) { + m_sampler = MakeShared(); + } void TextureObjectBase::SetMipmapLevel(const MipmapLevelInput& level) { SetMipmapImpl(level); @@ -38,14 +40,18 @@ namespace MobileGL { if (m_internalFormat == TextureInternalFormat::Unknown) { return false; } + if (m_mipmaps.empty()) { return false; } - for (const auto& level : m_mipmaps) { + + for (size_t i = 0; i < m_mipmaps.size(); ++i) { + const auto& level = m_mipmaps[i]; if (level.size.x() <= 0 || level.size.y() <= 0 || level.size.z() <= 0) { return false; } } + // TODO: add more completeness checks based on texture type and mipmap levels return true; } diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject.h b/MobileGL/MG_State/GLState/TextureState/TextureObject.h index ca515a03..5e19ccb6 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject.h @@ -1,8 +1,7 @@ #pragma once +#include "SamplerObject.h" #include #include -#include "MG_Util/Types.h" -#include "SamplerObject.h" namespace MobileGL { enum class TextureTarget { @@ -197,6 +196,7 @@ namespace MobileGL { } }; + // TODO: BaseLevel, MaxLevel, Swizzle class ITextureObject { public: using TargetEnum = TextureTarget; diff --git a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp index 4b94d4c4..97f7aa99 100644 --- a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp +++ b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp @@ -863,21 +863,45 @@ namespace MobileGL { if (libEGL != NULL) { \ MG_External::EGL::name = (MG_External::EGL::name##_PTR)ProcAddress(libEGL, #name); \ } - void InitEGL() { - INIT_EGL_FUNC(eglGetProcAddress) INIT_EGL_FUNC(eglBindAPI) - INIT_EGL_FUNC(eglInitialize) - INIT_EGL_FUNC(eglGetDisplay) - INIT_EGL_FUNC(eglCreatePbufferSurface) - INIT_EGL_FUNC(eglDestroySurface) - INIT_EGL_FUNC(eglDestroyContext) - INIT_EGL_FUNC(eglMakeCurrent) + INIT_EGL_FUNC(eglBindTexImage) INIT_EGL_FUNC(eglChooseConfig) + INIT_EGL_FUNC(eglCopyBuffers) INIT_EGL_FUNC(eglCreateContext) - INIT_EGL_FUNC(eglQueryString) - INIT_EGL_FUNC(eglTerminate) + INIT_EGL_FUNC(eglCreatePbufferFromClientBuffer) + INIT_EGL_FUNC(eglCreatePbufferSurface) + INIT_EGL_FUNC(eglCreatePixmapSurface) + INIT_EGL_FUNC(eglCreatePlatformWindowSurface) + INIT_EGL_FUNC(eglCreateWindowSurface) + INIT_EGL_FUNC(eglDestroyContext) + INIT_EGL_FUNC(eglDestroySurface) + INIT_EGL_FUNC(eglGetConfigAttrib) + INIT_EGL_FUNC(eglGetConfigs) + INIT_EGL_FUNC(eglGetCurrentContext) + INIT_EGL_FUNC(eglGetCurrentDisplay) + INIT_EGL_FUNC(eglGetCurrentSurface) + INIT_EGL_FUNC(eglGetDisplay) + INIT_EGL_FUNC(eglGetPlatformDisplay) INIT_EGL_FUNC(eglGetError) + INIT_EGL_FUNC(eglGetProcAddress) + INIT_EGL_FUNC(eglInitialize) + INIT_EGL_FUNC(eglMakeCurrent) + INIT_EGL_FUNC(eglQueryAPI) + INIT_EGL_FUNC(eglQueryContext) + INIT_EGL_FUNC(eglQueryString) + INIT_EGL_FUNC(eglQuerySurface) + INIT_EGL_FUNC(eglReleaseTexImage) + INIT_EGL_FUNC(eglReleaseThread) + INIT_EGL_FUNC(eglSurfaceAttrib) + INIT_EGL_FUNC(eglSwapBuffers) + INIT_EGL_FUNC(eglSwapBuffersWithDamageEXT) + INIT_EGL_FUNC(eglSwapInterval) + INIT_EGL_FUNC(eglTerminate) + INIT_EGL_FUNC(eglUnlockSurfaceKHR) + INIT_EGL_FUNC(eglWaitClient) + INIT_EGL_FUNC(eglWaitGL) + INIT_EGL_FUNC(eglWaitNative) EGLint configAttribs[] = {EGL_RED_SIZE, 8, diff --git a/MobileGL/MG_Util/Converters/GLToMG/FramebufferEnumConverter.cpp b/MobileGL/MG_Util/Converters/GLToMG/FramebufferEnumConverter.cpp index b13b57b7..6dfb32ed 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/FramebufferEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/GLToMG/FramebufferEnumConverter.cpp @@ -26,8 +26,6 @@ namespace MobileGL { return FramebufferAttachmentType::Depth; case GL_STENCIL_ATTACHMENT: return FramebufferAttachmentType::Stencil; - case GL_DEPTH_STENCIL_ATTACHMENT: - return FramebufferAttachmentType::DepthStencil; case GL_UNKNOWN_MGL: default: return FramebufferAttachmentType::Unknown; diff --git a/MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.cpp b/MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.cpp index 8e2cc1a6..7733cf35 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.cpp @@ -305,5 +305,76 @@ namespace MobileGL { } } + SamplerFilterMode ConvertGLEnumToSamplerFilterMode(GLenum v) { + switch (v) { + case GL_NEAREST: + return SamplerFilterMode::Nearest; + case GL_LINEAR: + return SamplerFilterMode::Linear; + default: + return SamplerFilterMode::Unknown; + } + } + + SamplerMipmapMode ConvertGLEnumToSamplerMipmapMode(GLenum v) { + switch (v) { + case 0: + return SamplerMipmapMode::None; // 无 mipmap 时 + case GL_NEAREST_MIPMAP_NEAREST: + return SamplerMipmapMode::Nearest; + default: + return SamplerMipmapMode::Unknown; + } + } + + SamplerWrapMode ConvertGLEnumToSamplerWrapMode(GLenum v) { + switch (v) { + case GL_CLAMP_TO_EDGE: + return SamplerWrapMode::ClampToEdge; + case GL_MIRRORED_REPEAT: + return SamplerWrapMode::MirroredRepeat; + case GL_REPEAT: + return SamplerWrapMode::Repeat; + case GL_CLAMP_TO_BORDER: + return SamplerWrapMode::ClampToBorder; + default: + return SamplerWrapMode::Unknown; + } + } + + SamplerCompareMode ConvertGLEnumToSamplerCompareMode(GLenum v) { + switch (v) { + case 0: + return SamplerCompareMode::None; // 无 compare + case GL_COMPARE_REF_TO_TEXTURE: + return SamplerCompareMode::CompareToTexture; + default: + return SamplerCompareMode::Unknown; + } + } + + SamplerCompareFunc ConvertGLEnumToSamplerCompareFunc(GLenum v) { + switch (v) { + case GL_NEVER: + return SamplerCompareFunc::Never; + case GL_LESS: + return SamplerCompareFunc::Less; + case GL_EQUAL: + return SamplerCompareFunc::Equal; + case GL_LEQUAL: + return SamplerCompareFunc::LessEqual; + case GL_GREATER: + return SamplerCompareFunc::Greater; + case GL_NOTEQUAL: + return SamplerCompareFunc::NotEqual; + case GL_GEQUAL: + return SamplerCompareFunc::GreaterEqual; + case GL_ALWAYS: + return SamplerCompareFunc::Always; + default: + return SamplerCompareFunc::Unknown; + } + } + } // namespace MG_Util } // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.h b/MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.h index 777b0504..ad79ecaf 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.h +++ b/MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.h @@ -9,5 +9,10 @@ namespace MobileGL { TextureInternalFormat ConvertGLEnumToTextureInternalFormat(GLenum internalformat); TexturePixelDataType ConvertGLEnumToTexturePixelDataType(GLenum type); TextureUploadTarget ConvertGLEnumToTextureUploadTarget(GLenum target); + SamplerFilterMode ConvertGLEnumToSamplerFilterMode(GLenum value); + SamplerMipmapMode ConvertGLEnumToSamplerMipmapMode(GLenum value); + SamplerWrapMode ConvertGLEnumToSamplerWrapMode(GLenum value); + SamplerCompareMode ConvertGLEnumToSamplerCompareMode(GLenum value); + SamplerCompareFunc ConvertGLEnumToSamplerCompareFunc(GLenum value); } // namespace MG_Util } // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToGL/FramebufferEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToGL/FramebufferEnumConverter.cpp index 1b494f2e..cabca613 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/FramebufferEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToGL/FramebufferEnumConverter.cpp @@ -25,8 +25,6 @@ namespace MobileGL { return GL_DEPTH_ATTACHMENT; case FramebufferAttachmentType::Stencil: return GL_STENCIL_ATTACHMENT; - case FramebufferAttachmentType::DepthStencil: - return GL_DEPTH_STENCIL_ATTACHMENT; default: return GL_COLOR_ATTACHMENT0; } diff --git a/MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.cpp index 5581fe28..276cc307 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.cpp @@ -305,5 +305,76 @@ namespace MobileGL { } } + GLenum ConvertSamplerFilterModeToGLEnum(SamplerFilterMode v) { + switch (v) { + case SamplerFilterMode::Nearest: + return GL_NEAREST; + case SamplerFilterMode::Linear: + return GL_LINEAR; + default: + return 0; + } + } + + GLenum ConvertSamplerMipmapModeToGLEnum(SamplerMipmapMode v) { + switch (v) { + case SamplerMipmapMode::None: + return 0; + case SamplerMipmapMode::Nearest: + return GL_NEAREST_MIPMAP_NEAREST; + default: + return 0; + } + } + + GLenum ConvertSamplerWrapModeToGLEnum(SamplerWrapMode v) { + switch (v) { + case SamplerWrapMode::ClampToEdge: + return GL_CLAMP_TO_EDGE; + case SamplerWrapMode::MirroredRepeat: + return GL_MIRRORED_REPEAT; + case SamplerWrapMode::Repeat: + return GL_REPEAT; + case SamplerWrapMode::ClampToBorder: + return GL_CLAMP_TO_BORDER; + default: + return 0; + } + } + + GLenum ConvertSamplerCompareModeToGLEnum(SamplerCompareMode v) { + switch (v) { + case SamplerCompareMode::None: + return 0; + case SamplerCompareMode::CompareToTexture: + return GL_COMPARE_REF_TO_TEXTURE; + default: + return 0; + } + } + + GLenum ConvertSamplerCompareFuncToGLEnum(SamplerCompareFunc v) { + switch (v) { + case SamplerCompareFunc::Never: + return GL_NEVER; + case SamplerCompareFunc::Less: + return GL_LESS; + case SamplerCompareFunc::Equal: + return GL_EQUAL; + case SamplerCompareFunc::LessEqual: + return GL_LEQUAL; + case SamplerCompareFunc::Greater: + return GL_GREATER; + case SamplerCompareFunc::NotEqual: + return GL_NOTEQUAL; + case SamplerCompareFunc::GreaterEqual: + return GL_GEQUAL; + case SamplerCompareFunc::Always: + return GL_ALWAYS; + default: + return 0; + } + } + } // namespace MG_Util } // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.h b/MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.h index 777fa306..844058a3 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.h +++ b/MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.h @@ -9,5 +9,10 @@ namespace MobileGL { GLenum ConvertTextureInternalFormatToGLEnum(TextureInternalFormat internalformat); GLenum ConvertTexturePixelDataTypeToGLEnum(TexturePixelDataType type); GLenum ConvertTextureUploadTargetToGLEnum(TextureUploadTarget target); + GLenum ConvertSamplerFilterModeToGLEnum(SamplerFilterMode value); + GLenum ConvertSamplerMipmapModeToGLEnum(SamplerMipmapMode value); + GLenum ConvertSamplerWrapModeToGLEnum(SamplerWrapMode value); + GLenum ConvertSamplerCompareModeToGLEnum(SamplerCompareMode value); + GLenum ConvertSamplerCompareFuncToGLEnum(SamplerCompareFunc value); } // namespace MG_Util } // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToStr/FramebufferEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToStr/FramebufferEnumConverter.cpp index 9dcfa4d9..9be55c40 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/FramebufferEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToStr/FramebufferEnumConverter.cpp @@ -25,8 +25,6 @@ namespace MobileGL { return "Depth"; case FramebufferAttachmentType::Stencil: return "Stencil"; - case FramebufferAttachmentType::DepthStencil: - return "DepthStencil"; case FramebufferAttachmentType::Unknown: default: return "Unknown"; diff --git a/MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.cpp index 04c78954..97d6da6a 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.cpp @@ -300,5 +300,76 @@ namespace MobileGL { return "Unknown"; } } + + String ConvertSamplerFilterModeToString(SamplerFilterMode v) { + switch (v) { + case SamplerFilterMode::Nearest: + return "Nearest"; + case SamplerFilterMode::Linear: + return "Linear"; + default: + return "Unknown"; + } + } + + String ConvertSamplerMipmapModeToString(SamplerMipmapMode v) { + switch (v) { + case SamplerMipmapMode::None: + return "None"; + case SamplerMipmapMode::Nearest: + return "Nearest"; + default: + return "Unknown"; + } + } + + String ConvertSamplerWrapModeToString(SamplerWrapMode v) { + switch (v) { + case SamplerWrapMode::ClampToEdge: + return "ClampToEdge"; + case SamplerWrapMode::MirroredRepeat: + return "MirroredRepeat"; + case SamplerWrapMode::Repeat: + return "Repeat"; + case SamplerWrapMode::ClampToBorder: + return "ClampToBorder"; + default: + return "Unknown"; + } + } + + String ConvertSamplerCompareModeToString(SamplerCompareMode v) { + switch (v) { + case SamplerCompareMode::None: + return "None"; + case SamplerCompareMode::CompareToTexture: + return "CompareToTexture"; + default: + return "Unknown"; + } + } + + String ConvertSamplerCompareFuncToString(SamplerCompareFunc v) { + switch (v) { + case SamplerCompareFunc::Never: + return "Never"; + case SamplerCompareFunc::Less: + return "Less"; + case SamplerCompareFunc::Equal: + return "Equal"; + case SamplerCompareFunc::LessEqual: + return "LessEqual"; + case SamplerCompareFunc::Greater: + return "Greater"; + case SamplerCompareFunc::NotEqual: + return "NotEqual"; + case SamplerCompareFunc::GreaterEqual: + return "GreaterEqual"; + case SamplerCompareFunc::Always: + return "Always"; + default: + return "Unknown"; + } + } } // namespace MG_Util } // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.h b/MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.h index 0f764331..560b1ad2 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.h +++ b/MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.h @@ -9,5 +9,10 @@ namespace MobileGL { String ConvertTextureInternalFormatToString(TextureInternalFormat internalformat); String ConvertTexturePixelDataTypeToString(TexturePixelDataType type); String ConvertTextureUploadTargetToString(TextureUploadTarget target); + String ConvertSamplerFilterModeToString(SamplerFilterMode value); + String ConvertSamplerMipmapModeToString(SamplerMipmapMode value); + String ConvertSamplerWrapModeToString(SamplerWrapMode value); + String ConvertSamplerCompareModeToString(SamplerCompareMode value); + String ConvertSamplerCompareFuncToString(SamplerCompareFunc value); } // namespace MG_Util } // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Miscellany/IndexGenerator.h b/MobileGL/MG_Util/Miscellany/IndexGenerator.h index 6f6f4dde..aa289b0c 100644 --- a/MobileGL/MG_Util/Miscellany/IndexGenerator.h +++ b/MobileGL/MG_Util/Miscellany/IndexGenerator.h @@ -61,6 +61,28 @@ namespace MobileGL { m_active_count--; } + bool Insert(IndexType index) noexcept { + if (IsValid(index)) return false; + + if (index >= m_valid_bits.size()) { + m_valid_bits.resize(index + 1, false); + } + + auto it = std::find(m_free_list.begin(), m_free_list.end(), index); + if (it != m_free_list.end()) { + m_free_list.erase(it); + } + + m_valid_bits[index] = true; + m_active_count++; + + if (index >= m_next_index) { + m_next_index = index + 1; + } + + return true; + } + bool IsValid(IndexType index) const noexcept { return index < m_valid_bits.size() && m_valid_bits[index]; } SizeT FreeListSize() const noexcept { return m_free_list.size(); } @@ -74,5 +96,4 @@ namespace MobileGL { std::vector m_free_list; std::vector m_valid_bits; }; - } // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp index 15fabe9e..b66e1fff 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp +++ b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp @@ -132,7 +132,7 @@ namespace MobileGL { tshader->setStrings(src, 1); tshader->setInvertY(true); if (attrib.flags & ShaderCompileBits::CompileForOpenGL) { - tshader->setEnvInput(glslang::EShSourceGlsl, lang, glslang::EShClientOpenGL, 450); + tshader->setEnvInput(glslang::EShSourceGlsl, lang, glslang::EShClientVulkan, 450); tshader->setEnvClient(glslang::EShClientOpenGL, glslang::EShTargetOpenGL_450); tshader->setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_5); } else {