Add initial support for compute pipelines
This commit is contained in:
committed by
Jérôme Leclercq
parent
e4064997d8
commit
9578ba3ef5
@@ -54,9 +54,12 @@ namespace Nz::GL
|
||||
enum class Extension
|
||||
{
|
||||
ClipControl,
|
||||
ComputeShader,
|
||||
DebugOutput,
|
||||
DepthClamp,
|
||||
PolygonMode,
|
||||
ShaderImageLoadFormatted,
|
||||
ShaderImageLoadStore,
|
||||
SpirV,
|
||||
StorageBuffers,
|
||||
TextureCompressionS3tc,
|
||||
@@ -127,6 +130,7 @@ namespace Nz::GL
|
||||
void BindBuffer(BufferTarget target, GLuint buffer, bool force = false) const;
|
||||
[[nodiscard]] GLenum BindFramebuffer(GLuint fbo) const;
|
||||
void BindFramebuffer(FramebufferTarget target, GLuint fbo) const;
|
||||
void BindImageTexture(GLuint imageUnit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format) const;
|
||||
void BindProgram(GLuint program) const;
|
||||
void BindSampler(UInt32 textureUnit, GLuint sampler) const;
|
||||
void BindStorageBuffer(UInt32 storageUnit, GLuint buffer, GLintptr offset, GLsizeiptr size) const;
|
||||
@@ -145,11 +149,16 @@ namespace Nz::GL
|
||||
|
||||
virtual void EnableVerticalSync(bool enabled) = 0;
|
||||
|
||||
inline bool GetBoolean(GLenum name) const;
|
||||
inline bool GetBoolean(GLenum name, GLuint index) const;
|
||||
inline const OpenGLDevice* GetDevice() const;
|
||||
inline ExtensionStatus GetExtensionStatus(Extension extension) const;
|
||||
inline float GetFloat(GLenum name) const;
|
||||
inline GLFunction GetFunctionByIndex(std::size_t funcIndex) const;
|
||||
inline const OpenGLVaoCache& GetVaoCache() const;
|
||||
template<typename T> T GetInteger(GLenum name) const;
|
||||
template<typename T> T GetInteger(GLenum name, GLuint index) const;
|
||||
inline const ContextParams& GetParams() const;
|
||||
inline const OpenGLVaoCache& GetVaoCache() const;
|
||||
|
||||
inline bool IsExtensionSupported(Extension extension) const;
|
||||
inline bool IsExtensionSupported(const std::string& extension) const;
|
||||
@@ -232,6 +241,16 @@ namespace Nz::GL
|
||||
GLsizeiptr size = 0;
|
||||
};
|
||||
|
||||
struct ImageUnits
|
||||
{
|
||||
GLboolean layered = GL_FALSE;
|
||||
GLenum access = GL_READ_ONLY;
|
||||
GLenum format = GL_RGBA8;
|
||||
GLint layer = 0;
|
||||
GLint level = 0;
|
||||
GLuint texture = 0;
|
||||
};
|
||||
|
||||
struct TextureUnit
|
||||
{
|
||||
GLuint sampler = 0;
|
||||
@@ -239,9 +258,10 @@ namespace Nz::GL
|
||||
};
|
||||
|
||||
std::array<GLuint, UnderlyingCast(BufferTarget::Max) + 1> bufferTargets = { 0 };
|
||||
std::vector<TextureUnit> textureUnits;
|
||||
std::vector<BufferBinding> storageUnits;
|
||||
std::vector<BufferBinding> uboUnits;
|
||||
std::vector<ImageUnits> imageUnits;
|
||||
std::vector<TextureUnit> textureUnits;
|
||||
Box scissorBox;
|
||||
Box viewport;
|
||||
GLuint boundProgram = 0;
|
||||
|
||||
@@ -15,6 +15,22 @@ namespace Nz::GL
|
||||
return !m_hadAnyError;
|
||||
}
|
||||
|
||||
inline bool Context::GetBoolean(GLenum name) const
|
||||
{
|
||||
GLboolean value;
|
||||
glGetBooleanv(name, &value);
|
||||
|
||||
return value != GL_FALSE;
|
||||
}
|
||||
|
||||
inline bool Context::GetBoolean(GLenum name, GLuint index) const
|
||||
{
|
||||
GLboolean value;
|
||||
glGetBooleani_v(name, index, &value);
|
||||
|
||||
return value != GL_FALSE;
|
||||
}
|
||||
|
||||
inline const OpenGLDevice* Context::GetDevice() const
|
||||
{
|
||||
return m_device;
|
||||
@@ -25,15 +41,56 @@ namespace Nz::GL
|
||||
return m_extensionStatus[UnderlyingCast(extension)];
|
||||
}
|
||||
|
||||
inline float Context::GetFloat(GLenum name) const
|
||||
{
|
||||
GLfloat value;
|
||||
glGetFloatv(name, &value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
inline GLFunction Context::GetFunctionByIndex(std::size_t funcIndex) const
|
||||
{
|
||||
assert(funcIndex < m_originalFunctionPointer.size());
|
||||
return m_originalFunctionPointer[funcIndex];
|
||||
}
|
||||
|
||||
inline const OpenGLVaoCache& Context::GetVaoCache() const
|
||||
template<typename T>
|
||||
T Context::GetInteger(GLenum name) const
|
||||
{
|
||||
return m_vaoCache;
|
||||
if constexpr (std::is_same_v<T, Int64> || std::is_same_v<T, UInt64>)
|
||||
{
|
||||
GLint64 value;
|
||||
glGetInteger64v(name, &value);
|
||||
|
||||
return SafeCast<T>(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint value;
|
||||
glGetIntegerv(name, &value);
|
||||
|
||||
return SafeCast<T>(value);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Context::GetInteger(GLenum name, GLuint index) const
|
||||
{
|
||||
if constexpr (std::is_same_v<T, Int64> || std::is_same_v<T, UInt64>)
|
||||
{
|
||||
GLint64 value;
|
||||
glGetInteger64i_v(name, index, &value);
|
||||
|
||||
return SafeCast<T>(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint value;
|
||||
glGetIntegeri_v(name, index, &value);
|
||||
|
||||
return SafeCast<T>(value);
|
||||
}
|
||||
}
|
||||
|
||||
inline const ContextParams& Context::GetParams() const
|
||||
@@ -41,6 +98,11 @@ namespace Nz::GL
|
||||
return m_params;
|
||||
}
|
||||
|
||||
inline const OpenGLVaoCache& Context::GetVaoCache() const
|
||||
{
|
||||
return m_vaoCache;
|
||||
}
|
||||
|
||||
inline bool Context::IsExtensionSupported(Extension extension) const
|
||||
{
|
||||
return GetExtensionStatus(extension) != ExtensionStatus::NotSupported;
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Nz::GL
|
||||
EnsureContext();
|
||||
|
||||
if (m_context->glObjectLabel)
|
||||
m_context->glObjectLabel(ObjectType, m_objectId, name.size(), name.data());
|
||||
m_context->glObjectLabel(ObjectType, m_objectId, SafeCast<GLsizei>(name.size()), name.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,9 +118,13 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLch
|
||||
cb(glGetActiveUniformBlockiv, PFNGLGETACTIVEUNIFORMBLOCKIVPROC) \
|
||||
cb(glGetActiveUniformBlockName, PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) \
|
||||
cb(glGetBooleanv, PFNGLGETBOOLEANVPROC) \
|
||||
cb(glGetBooleani_v, PFNGLGETBOOLEANI_VPROC) \
|
||||
cb(glGetBufferParameteriv, PFNGLGETBUFFERPARAMETERIVPROC) \
|
||||
cb(glGetError, PFNGLGETERRORPROC) \
|
||||
cb(glGetFloatv, PFNGLGETFLOATVPROC) \
|
||||
cb(glGetInteger64i_v, PFNGLGETINTEGER64I_VPROC) \
|
||||
cb(glGetInteger64v, PFNGLGETINTEGER64VPROC) \
|
||||
cb(glGetIntegeri_v, PFNGLGETINTEGERI_VPROC) \
|
||||
cb(glGetIntegerv, PFNGLGETINTEGERVPROC) \
|
||||
cb(glGetProgramBinary, PFNGLGETPROGRAMBINARYPROC) \
|
||||
cb(glGetProgramInfoLog, PFNGLGETPROGRAMINFOLOGPROC) \
|
||||
@@ -195,8 +199,11 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLch
|
||||
extCb(glDrawBuffer, PFNGLDRAWBUFFERPROC) \
|
||||
extCb(glPolygonMode, PFNGLPOLYGONMODEPROC) \
|
||||
/* OpenGL 4.2 - OpenGL ES 3.1 */\
|
||||
extCb(glBindImageTexture, PFNGLBINDIMAGETEXTUREPROC) \
|
||||
extCb(glMemoryBarrier, PFNGLMEMORYBARRIERPROC) \
|
||||
extCb(glMemoryBarrierByRegion, PFNGLMEMORYBARRIERBYREGIONPROC) \
|
||||
/* OpenGL 4.3 - OpenGL ES 3.1 */\
|
||||
extCb(glDispatchCompute, PFNGLDISPATCHCOMPUTEPROC) \
|
||||
/* OpenGL 4.3 - OpenGL ES 3.2 */\
|
||||
extCb(glCopyImageSubData, PFNGLCOPYIMAGESUBDATAPROC) \
|
||||
extCb(glDebugMessageCallback, PFNGLDEBUGMESSAGECALLBACKPROC) \
|
||||
|
||||
Reference in New Issue
Block a user