mirror of
https://github.com/minetest/minetest.git
synced 2025-01-03 20:07:30 +01:00
Fix some issues with mt_opengl
This commit is contained in:
parent
1fb7202028
commit
a799a54894
@ -15,11 +15,18 @@
|
|||||||
#ifndef APIENTRYP
|
#ifndef APIENTRYP
|
||||||
#define APIENTRYP APIENTRY *
|
#define APIENTRYP APIENTRY *
|
||||||
#endif
|
#endif
|
||||||
#ifndef GLAPI
|
// undefine a few names that can easily clash with system headers
|
||||||
#define GLAPI extern
|
#ifdef NO_ERROR
|
||||||
|
#undef NO_ERROR
|
||||||
|
#endif
|
||||||
|
#ifdef ZERO
|
||||||
|
#undef ZERO
|
||||||
|
#endif
|
||||||
|
#ifdef ONE
|
||||||
|
#undef ONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class OpenGLProcedures {
|
class OpenGLProcedures final {
|
||||||
private:
|
private:
|
||||||
// ./glcorearb.h
|
// ./glcorearb.h
|
||||||
typedef void GLvoid;
|
typedef void GLvoid;
|
||||||
@ -49,8 +56,6 @@ private:
|
|||||||
typedef khronos_int64_t GLint64EXT;
|
typedef khronos_int64_t GLint64EXT;
|
||||||
|
|
||||||
typedef void *GLeglClientBufferEXT;
|
typedef void *GLeglClientBufferEXT;
|
||||||
// The script will miss this particular typedef thinking it's a PFN,
|
|
||||||
// so we have to paste it in manually. It's the only such type in OpenGL.
|
|
||||||
typedef void (APIENTRY *GLDEBUGPROC)
|
typedef void (APIENTRY *GLDEBUGPROC)
|
||||||
(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
|
(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
|
||||||
|
|
||||||
@ -775,10 +780,12 @@ private:
|
|||||||
typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);
|
typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);
|
||||||
|
|
||||||
std::unordered_set<std::string> extensions;
|
std::unordered_set<std::string> extensions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Call this once after creating the context.
|
// Call this once after creating the context.
|
||||||
void LoadAllProcedures(irr::video::IContextManager *cmgr);
|
void LoadAllProcedures(irr::video::IContextManager *cmgr);
|
||||||
// Check if an extension is supported.
|
/// Check if an extension is supported.
|
||||||
|
/// @param ext full extension name e.g. "GL_KHR_no_error"
|
||||||
inline bool IsExtensionPresent(const std::string &ext) const
|
inline bool IsExtensionPresent(const std::string &ext) const
|
||||||
{
|
{
|
||||||
return extensions.count(ext) > 0;
|
return extensions.count(ext) > 0;
|
||||||
@ -3185,6 +3192,7 @@ public:
|
|||||||
static constexpr const GLenum STATE_RESTORE = 0x8BDC;
|
static constexpr const GLenum STATE_RESTORE = 0x8BDC;
|
||||||
static constexpr const GLenum SHADER_BINARY_VIV = 0x8FC4;
|
static constexpr const GLenum SHADER_BINARY_VIV = 0x8FC4;
|
||||||
|
|
||||||
|
static constexpr const GLenum NO_ERROR = 0;
|
||||||
static constexpr const GLenum ZERO = 0;
|
static constexpr const GLenum ZERO = 0;
|
||||||
static constexpr const GLenum ONE = 1;
|
static constexpr const GLenum ONE = 1;
|
||||||
static constexpr const GLenum NONE = 0;
|
static constexpr const GLenum NONE = 0;
|
||||||
|
@ -219,11 +219,11 @@ local function ParseHeader( path, into, apiRegex, defs, consts, nameSet, noNewNa
|
|||||||
};
|
};
|
||||||
end
|
end
|
||||||
elseif ( line:find( "#" ) and not line:find( "#include" ) ) then
|
elseif ( line:find( "#" ) and not line:find( "#include" ) ) then
|
||||||
local rawName, value = line:match( "#define%s+GL_([_%w]+)%s+0x(%w+)" );
|
local rawName, value = line:match( "#define%s+GL_([_%w]+)%s+(0x%w+)" );
|
||||||
if rawName and value then
|
if rawName and value then
|
||||||
local name, vendor = StripVendorSuffix( rawName, true );
|
local name, vendor = StripVendorSuffix( rawName, true );
|
||||||
if not constBanned[vendor] then
|
if not constBanned[vendor] then
|
||||||
consts:Add{ name = name, vendor = vendor, value = "0x"..value };
|
consts:Add{ name = name, vendor = vendor, value = value };
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
::skip::
|
::skip::
|
||||||
@ -359,21 +359,28 @@ f:write[[
|
|||||||
#ifndef APIENTRYP
|
#ifndef APIENTRYP
|
||||||
#define APIENTRYP APIENTRY *
|
#define APIENTRYP APIENTRY *
|
||||||
#endif
|
#endif
|
||||||
#ifndef GLAPI
|
// undefine a few names that can easily clash with system headers
|
||||||
#define GLAPI extern
|
#ifdef NO_ERROR
|
||||||
|
#undef NO_ERROR
|
||||||
|
#endif
|
||||||
|
#ifdef ZERO
|
||||||
|
#undef ZERO
|
||||||
|
#endif
|
||||||
|
#ifdef ONE
|
||||||
|
#undef ONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
]];
|
]];
|
||||||
|
|
||||||
f:write[[
|
f:write[[
|
||||||
class OpenGLProcedures {
|
class OpenGLProcedures final {
|
||||||
private:
|
private:
|
||||||
]];
|
]];
|
||||||
f:write( definitions:Concat( "\n" ) );
|
f:write( definitions:Concat( "\n" ) );
|
||||||
f:write( "\n" );
|
f:write( "\n" );
|
||||||
|
-- The script will miss this particular typedef thinking it's a PFN,
|
||||||
|
-- so we have to paste it in manually. It's the only such type in OpenGL.
|
||||||
f:write[[
|
f:write[[
|
||||||
// The script will miss this particular typedef thinking it's a PFN,
|
|
||||||
// so we have to paste it in manually. It's the only such type in OpenGL.
|
|
||||||
typedef void (APIENTRY *GLDEBUGPROC)
|
typedef void (APIENTRY *GLDEBUGPROC)
|
||||||
(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
|
(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
|
||||||
|
|
||||||
@ -382,10 +389,12 @@ f:write( typedefs:Concat( "\n" ) );
|
|||||||
f:write( "\n\n" );
|
f:write( "\n\n" );
|
||||||
f:write [[
|
f:write [[
|
||||||
std::unordered_set<std::string> extensions;
|
std::unordered_set<std::string> extensions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Call this once after creating the context.
|
// Call this once after creating the context.
|
||||||
void LoadAllProcedures(irr::video::IContextManager *cmgr);
|
void LoadAllProcedures(irr::video::IContextManager *cmgr);
|
||||||
// Check if an extension is supported.
|
/// Check if an extension is supported.
|
||||||
|
/// @param ext full extension name e.g. "GL_KHR_no_error"
|
||||||
inline bool IsExtensionPresent(const std::string &ext) const
|
inline bool IsExtensionPresent(const std::string &ext) const
|
||||||
{
|
{
|
||||||
return extensions.count(ext) > 0;
|
return extensions.count(ext) > 0;
|
||||||
@ -396,7 +405,10 @@ f:write( pointers:Concat( "\n" ) );
|
|||||||
f:write( "\n\n" );
|
f:write( "\n\n" );
|
||||||
f:write( cppConsts:Concat( "\n" ) );
|
f:write( cppConsts:Concat( "\n" ) );
|
||||||
f:write( "\n\n" );
|
f:write( "\n\n" );
|
||||||
|
-- We filter constants not in hex format to avoid the VERSION_X_X and extension
|
||||||
|
-- defines, but that means we miss these.
|
||||||
f:write[[
|
f:write[[
|
||||||
|
static constexpr const GLenum NO_ERROR = 0;
|
||||||
static constexpr const GLenum ZERO = 0;
|
static constexpr const GLenum ZERO = 0;
|
||||||
static constexpr const GLenum ONE = 1;
|
static constexpr const GLenum ONE = 1;
|
||||||
static constexpr const GLenum NONE = 0;
|
static constexpr const GLenum NONE = 0;
|
||||||
@ -416,7 +428,7 @@ f:write[[
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
OpenGLProcedures GL = OpenGLProcedures();
|
OpenGLProcedures GL;
|
||||||
|
|
||||||
void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
|
void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
|
||||||
{
|
{
|
||||||
@ -425,9 +437,11 @@ void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
|
|||||||
f:write( loader:Concat() );
|
f:write( loader:Concat() );
|
||||||
f:write[[
|
f:write[[
|
||||||
|
|
||||||
// OpenGL 3 way to enumerate extensions
|
/* OpenGL 3 & ES 3 way to enumerate extensions */
|
||||||
GLint ext_count = 0;
|
GLint ext_count = 0;
|
||||||
GetIntegerv(NUM_EXTENSIONS, &ext_count);
|
GetIntegerv(NUM_EXTENSIONS, &ext_count);
|
||||||
|
// clear error which is raised if unsupported
|
||||||
|
while (GetError() != GL.NO_ERROR) {}
|
||||||
extensions.reserve(ext_count);
|
extensions.reserve(ext_count);
|
||||||
for (GLint k = 0; k < ext_count; k++) {
|
for (GLint k = 0; k < ext_count; k++) {
|
||||||
auto tmp = GetStringi(EXTENSIONS, k);
|
auto tmp = GetStringi(EXTENSIONS, k);
|
||||||
@ -437,16 +451,15 @@ f:write[[
|
|||||||
if (!extensions.empty())
|
if (!extensions.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// OpenGL 2 / ES 2 way to enumerate extensions
|
/* OpenGL 2 / ES 2 way to enumerate extensions */
|
||||||
auto ext_str = GetString(EXTENSIONS);
|
auto ext_str = GetString(EXTENSIONS);
|
||||||
if (!ext_str)
|
if (!ext_str)
|
||||||
return;
|
return;
|
||||||
// get the extension string, chop it up
|
// get the extension string, chop it up
|
||||||
std::stringstream ext_ss((char*)ext_str);
|
std::istringstream ext_ss((char*)ext_str);
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
while (std::getline(ext_ss, tmp, ' '))
|
while (std::getline(ext_ss, tmp, ' '))
|
||||||
extensions.emplace(tmp);
|
extensions.emplace(tmp);
|
||||||
|
|
||||||
}
|
}
|
||||||
]];
|
]];
|
||||||
f:close();
|
f:close();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
OpenGLProcedures GL = OpenGLProcedures();
|
OpenGLProcedures GL;
|
||||||
|
|
||||||
void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
|
void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
|
||||||
{
|
{
|
||||||
@ -758,9 +758,11 @@ void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
|
|||||||
if (!NamedBufferPageCommitment) NamedBufferPageCommitment = (PFNGLNAMEDBUFFERPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glNamedBufferPageCommitmentARB");
|
if (!NamedBufferPageCommitment) NamedBufferPageCommitment = (PFNGLNAMEDBUFFERPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glNamedBufferPageCommitmentARB");
|
||||||
if (!TexPageCommitment) TexPageCommitment = (PFNGLTEXPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glTexPageCommitmentARB");
|
if (!TexPageCommitment) TexPageCommitment = (PFNGLTEXPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glTexPageCommitmentARB");
|
||||||
|
|
||||||
// OpenGL 3 way to enumerate extensions
|
/* OpenGL 3 & ES 3 way to enumerate extensions */
|
||||||
GLint ext_count = 0;
|
GLint ext_count = 0;
|
||||||
GetIntegerv(NUM_EXTENSIONS, &ext_count);
|
GetIntegerv(NUM_EXTENSIONS, &ext_count);
|
||||||
|
// clear error which is raised if unsupported
|
||||||
|
while (GetError() != GL.NO_ERROR) {}
|
||||||
extensions.reserve(ext_count);
|
extensions.reserve(ext_count);
|
||||||
for (GLint k = 0; k < ext_count; k++) {
|
for (GLint k = 0; k < ext_count; k++) {
|
||||||
auto tmp = GetStringi(EXTENSIONS, k);
|
auto tmp = GetStringi(EXTENSIONS, k);
|
||||||
@ -770,14 +772,13 @@ void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
|
|||||||
if (!extensions.empty())
|
if (!extensions.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// OpenGL 2 / ES 2 way to enumerate extensions
|
/* OpenGL 2 / ES 2 way to enumerate extensions */
|
||||||
auto ext_str = GetString(EXTENSIONS);
|
auto ext_str = GetString(EXTENSIONS);
|
||||||
if (!ext_str)
|
if (!ext_str)
|
||||||
return;
|
return;
|
||||||
// get the extension string, chop it up
|
// get the extension string, chop it up
|
||||||
std::stringstream ext_ss((char*)ext_str);
|
std::istringstream ext_ss((char*)ext_str);
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
while (std::getline(ext_ss, tmp, ' '))
|
while (std::getline(ext_ss, tmp, ' '))
|
||||||
extensions.emplace(tmp);
|
extensions.emplace(tmp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user