From f6559ce49e6f8a6d37378587a3e42c6574af5c2a Mon Sep 17 00:00:00 2001 From: bjorn Date: Tue, 25 May 2021 23:22:05 -0600 Subject: [PATCH] Add threadgroups{x,y,z} SystemLimits; --- src/modules/graphics/Graphics.cpp | 3 +++ src/modules/graphics/Graphics.h | 3 +++ src/modules/graphics/opengl/Graphics.cpp | 5 +++- src/modules/graphics/opengl/OpenGL.cpp | 31 ++++++++++++++++++++++++ src/modules/graphics/opengl/OpenGL.h | 11 +++++++++ 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 14ecd897b..25154fa45 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -1878,6 +1878,9 @@ STRINGMAP_CLASS_BEGIN(Graphics, Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM, { "cubetexturesize", Graphics::LIMIT_CUBE_TEXTURE_SIZE }, { "texelbuffersize", Graphics::LIMIT_TEXEL_BUFFER_SIZE }, { "shaderstoragebuffersize", Graphics::LIMIT_SHADER_STORAGE_BUFFER_SIZE }, + { "threadgroupsx", Graphics::LIMIT_THREADGROUPS_X }, + { "threadgroupsy", Graphics::LIMIT_THREADGROUPS_Y }, + { "threadgroupsz", Graphics::LIMIT_THREADGROUPS_Z }, { "rendertargets", Graphics::LIMIT_RENDER_TARGETS }, { "texturemsaa", Graphics::LIMIT_TEXTURE_MSAA }, { "anisotropy", Graphics::LIMIT_ANISOTROPY }, diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 28f93ddbe..f202d69d3 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -164,6 +164,9 @@ public: LIMIT_TEXTURE_LAYERS, LIMIT_TEXEL_BUFFER_SIZE, LIMIT_SHADER_STORAGE_BUFFER_SIZE, + LIMIT_THREADGROUPS_X, + LIMIT_THREADGROUPS_Y, + LIMIT_THREADGROUPS_Z, LIMIT_RENDER_TARGETS, LIMIT_TEXTURE_MSAA, LIMIT_ANISOTROPY, diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 419a1afb5..1779d13e3 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -1543,10 +1543,13 @@ void Graphics::initCapabilities() capabilities.limits[LIMIT_CUBE_TEXTURE_SIZE] = gl.getMaxCubeTextureSize(); capabilities.limits[LIMIT_TEXEL_BUFFER_SIZE] = gl.getMaxTexelBufferSize(); capabilities.limits[LIMIT_SHADER_STORAGE_BUFFER_SIZE] = gl.getMaxShaderStorageBufferSize(); + capabilities.limits[LIMIT_THREADGROUPS_X] = gl.getMaxComputeWorkGroupsX(); + capabilities.limits[LIMIT_THREADGROUPS_Y] = gl.getMaxComputeWorkGroupsY(); + capabilities.limits[LIMIT_THREADGROUPS_Z] = gl.getMaxComputeWorkGroupsZ(); capabilities.limits[LIMIT_RENDER_TARGETS] = gl.getMaxRenderTargets(); capabilities.limits[LIMIT_TEXTURE_MSAA] = gl.getMaxSamples(); capabilities.limits[LIMIT_ANISOTROPY] = gl.getMaxAnisotropy(); - static_assert(LIMIT_MAX_ENUM == 10, "Graphics::initCapabilities must be updated when adding a new system limit!"); + static_assert(LIMIT_MAX_ENUM == 13, "Graphics::initCapabilities must be updated when adding a new system limit!"); for (int i = 0; i < TEXTURE_MAX_ENUM; i++) capabilities.textureTypes[i] = gl.isTextureTypeSupported((TextureType) i); diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 587540c08..5e4efbb73 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -103,6 +103,9 @@ OpenGL::OpenGL() , maxTextureArrayLayers(0) , maxTexelBufferSize(0) , maxShaderStorageBufferSize(0) + , maxComputeWorkGroupsX(0) + , maxComputeWorkGroupsY(0) + , maxComputeWorkGroupsZ(0) , maxRenderTargets(1) , maxSamples(1) , maxTextureUnits(1) @@ -500,6 +503,19 @@ void OpenGL::initMaxValues() maxShaderStorageBufferBindings = 0; } + if (GLAD_ES_VERSION_3_1 || GLAD_VERSION_4_3) + { + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, &maxComputeWorkGroupsX); + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 1, &maxComputeWorkGroupsY); + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 2, &maxComputeWorkGroupsZ); + } + else + { + maxComputeWorkGroupsX = 0; + maxComputeWorkGroupsY = 0; + maxComputeWorkGroupsZ = 0; + } + int maxattachments = 1; int maxdrawbuffers = 1; @@ -1510,6 +1526,21 @@ int OpenGL::getMaxShaderStorageBufferSize() const return maxShaderStorageBufferSize; } +int OpenGL::getMaxComputeWorkGroupsX() const +{ + return maxComputeWorkGroupsX; +} + +int OpenGL::getMaxComputeWorkGroupsY() const +{ + return maxComputeWorkGroupsY; +} + +int OpenGL::getMaxComputeWorkGroupsZ() const +{ + return maxComputeWorkGroupsZ; +} + int OpenGL::getMaxRenderTargets() const { return std::min(maxRenderTargets, MAX_COLOR_RENDER_TARGETS); diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index ff76510df..fb1d210d5 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -383,6 +383,14 @@ public: **/ int getMaxShaderStorageBufferSize() const; + /** + * Returns the maximum number of compute work groups that can be + * dispatched in a given dimension. + */ + int getMaxComputeWorkGroupsX() const; + int getMaxComputeWorkGroupsY() const; + int getMaxComputeWorkGroupsZ() const; + /** * Returns the maximum supported number of simultaneous render targets. **/ @@ -467,6 +475,9 @@ private: int maxTextureArrayLayers; int maxTexelBufferSize; int maxShaderStorageBufferSize; + int maxComputeWorkGroupsX; + int maxComputeWorkGroupsY; + int maxComputeWorkGroupsZ; int maxRenderTargets; int maxSamples; int maxTextureUnits;