From c132f90d7dc604087da2fab2213f71463e9b3dc9 Mon Sep 17 00:00:00 2001 From: aliPMPAINT Date: Wed, 24 Feb 2021 12:53:11 +0330 Subject: [PATCH 1/6] made changes for include paths for complete installation --- single_include/kompute/Kompute.hpp | 2 +- src/include/kompute/Shader.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index 5d50a74c7..77201ac1a 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -115,7 +115,7 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error; #include #include -#include +#include #include namespace kp { diff --git a/src/include/kompute/Shader.hpp b/src/include/kompute/Shader.hpp index 0b363ae5c..0a1bee98f 100644 --- a/src/include/kompute/Shader.hpp +++ b/src/include/kompute/Shader.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include "kompute/Core.hpp" From eafcd04b107fd42e81f4279e3eb8ace4c7c63239 Mon Sep 17 00:00:00 2001 From: aliPMPAINT Date: Thu, 25 Feb 2021 09:46:20 +0330 Subject: [PATCH 2/6] included StandAlone/ResourceLimits.h in src/Shader.cpp? --- src/Shader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Shader.cpp b/src/Shader.cpp index 17429919e..d2f63633c 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -1,6 +1,7 @@ #if !defined(KOMPUTE_DISABLE_SHADER_UTILS) || !KOMPUTE_DISABLE_SHADER_UTILS #include "kompute/Shader.hpp" +#include namespace kp { From f60e71dd0bc6a4c8f7016911f7abf5b54723018f Mon Sep 17 00:00:00 2001 From: aliPMPAINT Date: Sat, 27 Feb 2021 10:59:42 +0330 Subject: [PATCH 3/6] Fixed include paths and added resources parameter to Shader::compile_sources method --- src/Shader.cpp | 11 +-- src/include/kompute/Shader.hpp | 120 +++++++++++++++++++++++++++++++-- 2 files changed, 122 insertions(+), 9 deletions(-) diff --git a/src/Shader.cpp b/src/Shader.cpp index d2f63633c..9ca2e858f 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -1,7 +1,6 @@ #if !defined(KOMPUTE_DISABLE_SHADER_UTILS) || !KOMPUTE_DISABLE_SHADER_UTILS #include "kompute/Shader.hpp" -#include namespace kp { @@ -9,7 +8,8 @@ std::vector Shader::compile_sources(const std::vector& sources, const std::vector& files, const std::string& entryPoint, - std::vector> definitions) { + std::vector> definitions, + const TBuiltInResource resources) { // Initialize glslang library. glslang::InitializeProcess(); @@ -36,7 +36,7 @@ Shader::compile_sources(const std::vector& sources, std::string info_log = ""; const EShMessages messages = static_cast(EShMsgDefault | EShMsgVulkanRules | EShMsgSpvRules); - if (!shader.parse(&glslang::DefaultTBuiltInResource, 100, false, messages)) + if (!shader.parse(&resources, 100, false, messages)) { info_log = std::string(shader.getInfoLog()) + "\n" + std::string(shader.getInfoDebugLog()); KP_LOG_ERROR("Kompute Shader Error: {}", info_log); @@ -89,8 +89,9 @@ Shader::compile_sources(const std::vector& sources, std::vector Shader::compile_source(const std::string& source, const std::string& entryPoint, - std::vector> definitions) { - return compile_sources({source}); + std::vector> definitions, + const TBuiltInResource resource) { + return compile_sources({source}, std::vector({}), entryPoint, definitions, resource); } } diff --git a/src/include/kompute/Shader.hpp b/src/include/kompute/Shader.hpp index 0a1bee98f..5f840b025 100644 --- a/src/include/kompute/Shader.hpp +++ b/src/include/kompute/Shader.hpp @@ -4,9 +4,9 @@ #include #include -#include #include -#include +#include +#include #include "kompute/Core.hpp" @@ -28,13 +28,15 @@ public: * @param files A list of file names respective to each of the sources * @param entryPoint The function name to use as entry point * @param definitions List of pairs containing key value definitions + * @param resourcesLimit A list that contains the resource limits for the GLSL compiler * @return The compiled SPIR-V binary in unsigned int32 format */ static std::vector compile_sources( const std::vector& sources, const std::vector& files = {}, const std::string& entryPoint = "main", - std::vector> definitions = {}); + std::vector> definitions = {}, + const TBuiltInResource resources = defaultResource); /** * Compile a single glslang source from string value. Currently this function @@ -46,13 +48,123 @@ public: * @param source An individual raw glsl shader in string format * @param entryPoint The function name to use as entry point * @param definitions List of pairs containing key value definitions + * @param resourcesLimit A list that contains the resource limits for the GLSL compiler * @return The compiled SPIR-V binary in unsigned int32 format */ static std::vector compile_source( const std::string& source, const std::string& entryPoint = "main", - std::vector> definitions = {}); + std::vector> definitions = {}, + const TBuiltInResource resources = defaultResource); +private: + // The default resource limit for the GLSL compiler, can be overwritten + static constexpr TBuiltInResource defaultResource = { + /* .MaxLights = */ 0, + /* .MaxClipPlanes = */ 0, + /* .MaxTextureUnits = */ 0, + /* .MaxTextureCoords = */ 0, + /* .MaxVertexAttribs = */ 64, + /* .MaxVertexUniformComponents = */ 4096, + /* .MaxVaryingFloats = */ 64, + /* .MaxVertexTextureImageUnits = */ 0, + /* .MaxCombinedTextureImageUnits = */ 0, + /* .MaxTextureImageUnits = */ 0, + /* .MaxFragmentUniformComponents = */ 0, + /* .MaxDrawBuffers = */ 0, + /* .MaxVertexUniformVectors = */ 128, + /* .MaxVaryingVectors = */ 8, + /* .MaxFragmentUniformVectors = */ 0, + /* .MaxVertexOutputVectors = */ 16, + /* .MaxFragmentInputVectors = */ 0, + /* .MinProgramTexelOffset = */ -8, + /* .MaxProgramTexelOffset = */ 7, + /* .MaxClipDistances = */ 8, + /* .MaxComputeWorkGroupCountX = */ 65535, + /* .MaxComputeWorkGroupCountY = */ 65535, + /* .MaxComputeWorkGroupCountZ = */ 65535, + /* .MaxComputeWorkGroupSizeX = */ 1024, + /* .MaxComputeWorkGroupSizeY = */ 1024, + /* .MaxComputeWorkGroupSizeZ = */ 64, + /* .MaxComputeUniformComponents = */ 1024, + /* .MaxComputeTextureImageUnits = */ 16, + /* .MaxComputeImageUniforms = */ 8, + /* .MaxComputeAtomicCounters = */ 8, + /* .MaxComputeAtomicCounterBuffers = */ 1, + /* .MaxVaryingComponents = */ 60, + /* .MaxVertexOutputComponents = */ 64, + /* .MaxGeometryInputComponents = */ 64, + /* .MaxGeometryOutputComponents = */ 128, + /* .MaxFragmentInputComponents = */ 0, + /* .MaxImageUnits = */ 0, + /* .MaxCombinedImageUnitsAndFragmentOutputs = */ 0, + /* .MaxCombinedShaderOutputResources = */ 8, + /* .MaxImageSamples = */ 0, + /* .MaxVertexImageUniforms = */ 0, + /* .MaxTessControlImageUniforms = */ 0, + /* .MaxTessEvaluationImageUniforms = */ 0, + /* .MaxGeometryImageUniforms = */ 0, + /* .MaxFragmentImageUniforms = */ 0, + /* .MaxCombinedImageUniforms = */ 0, + /* .MaxGeometryTextureImageUnits = */ 0, + /* .MaxGeometryOutputVertices = */ 256, + /* .MaxGeometryTotalOutputComponents = */ 1024, + /* .MaxGeometryUniformComponents = */ 1024, + /* .MaxGeometryVaryingComponents = */ 64, + /* .MaxTessControlInputComponents = */ 128, + /* .MaxTessControlOutputComponents = */ 128, + /* .MaxTessControlTextureImageUnits = */ 0, + /* .MaxTessControlUniformComponents = */ 1024, + /* .MaxTessControlTotalOutputComponents = */ 4096, + /* .MaxTessEvaluationInputComponents = */ 128, + /* .MaxTessEvaluationOutputComponents = */ 128, + /* .MaxTessEvaluationTextureImageUnits = */ 16, + /* .MaxTessEvaluationUniformComponents = */ 1024, + /* .MaxTessPatchComponents = */ 120, + /* .MaxPatchVertices = */ 32, + /* .MaxTessGenLevel = */ 64, + /* .MaxViewports = */ 16, + /* .MaxVertexAtomicCounters = */ 0, + /* .MaxTessControlAtomicCounters = */ 0, + /* .MaxTessEvaluationAtomicCounters = */ 0, + /* .MaxGeometryAtomicCounters = */ 0, + /* .MaxFragmentAtomicCounters = */ 0, + /* .MaxCombinedAtomicCounters = */ 8, + /* .MaxAtomicCounterBindings = */ 1, + /* .MaxVertexAtomicCounterBuffers = */ 0, + /* .MaxTessControlAtomicCounterBuffers = */ 0, + /* .MaxTessEvaluationAtomicCounterBuffers = */ 0, + /* .MaxGeometryAtomicCounterBuffers = */ 0, + /* .MaxFragmentAtomicCounterBuffers = */ 0, + /* .MaxCombinedAtomicCounterBuffers = */ 1, + /* .MaxAtomicCounterBufferSize = */ 16384, + /* .MaxTransformFeedbackBuffers = */ 4, + /* .MaxTransformFeedbackInterleavedComponents = */ 64, + /* .MaxCullDistances = */ 8, + /* .MaxCombinedClipAndCullDistances = */ 8, + /* .MaxSamples = */ 4, + /* .maxMeshOutputVerticesNV = */ 256, + /* .maxMeshOutputPrimitivesNV = */ 512, + /* .maxMeshWorkGroupSizeX_NV = */ 32, + /* .maxMeshWorkGroupSizeY_NV = */ 1, + /* .maxMeshWorkGroupSizeZ_NV = */ 1, + /* .maxTaskWorkGroupSizeX_NV = */ 32, + /* .maxTaskWorkGroupSizeY_NV = */ 1, + /* .maxTaskWorkGroupSizeZ_NV = */ 1, + /* .maxMeshViewCountNV = */ 4, + /* .maxDualSourceDrawBuffersEXT = */ 1, + + /* .limits = */ { + /* .nonInductiveForLoops = */ 1, + /* .whileLoops = */ 1, + /* .doWhileLoops = */ 1, + /* .generalUniformIndexing = */ 1, + /* .generalAttributeMatrixVectorIndexing = */ 1, + /* .generalVaryingIndexing = */ 1, + /* .generalSamplerIndexing = */ 1, + /* .generalVariableIndexing = */ 1, + /* .generalConstantMatrixVectorIndexing = */ 1, + }}; }; } #endif // DKOMPUTE_DISABLE_SHADER_UTILS From 3cad95c2b64b8cf048113262b52babd32c305df8 Mon Sep 17 00:00:00 2001 From: aliPMPAINT Date: Sat, 27 Feb 2021 11:22:49 +0330 Subject: [PATCH 4/6] refrence parameter by const refrence, linked tothe original GLSL resources, fixed inlude --- src/Shader.cpp | 4 ++-- src/include/kompute/Shader.hpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Shader.cpp b/src/Shader.cpp index 9ca2e858f..cdcd66e74 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -9,7 +9,7 @@ Shader::compile_sources(const std::vector& sources, const std::vector& files, const std::string& entryPoint, std::vector> definitions, - const TBuiltInResource resources) { + const TBuiltInResource& resources) { // Initialize glslang library. glslang::InitializeProcess(); @@ -90,7 +90,7 @@ std::vector Shader::compile_source(const std::string& source, const std::string& entryPoint, std::vector> definitions, - const TBuiltInResource resource) { + const TBuiltInResource& resource) { return compile_sources({source}, std::vector({}), entryPoint, definitions, resource); } diff --git a/src/include/kompute/Shader.hpp b/src/include/kompute/Shader.hpp index 5f840b025..bb76dbbef 100644 --- a/src/include/kompute/Shader.hpp +++ b/src/include/kompute/Shader.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include "kompute/Core.hpp" @@ -36,7 +36,7 @@ public: const std::vector& files = {}, const std::string& entryPoint = "main", std::vector> definitions = {}, - const TBuiltInResource resources = defaultResource); + const TBuiltInResource& resources = defaultResource); /** * Compile a single glslang source from string value. Currently this function @@ -55,10 +55,12 @@ public: const std::string& source, const std::string& entryPoint = "main", std::vector> definitions = {}, - const TBuiltInResource resources = defaultResource); + const TBuiltInResource& resources = defaultResource); private: // The default resource limit for the GLSL compiler, can be overwritten + // Has been adobted by: + // https://github.com/KhronosGroup/glslang/blob/master/StandAlone/ResourceLimits.cpp static constexpr TBuiltInResource defaultResource = { /* .MaxLights = */ 0, /* .MaxClipPlanes = */ 0, From bb7893bf544fa8fd9b3f50127eb8e14350af3c2f Mon Sep 17 00:00:00 2001 From: aliPMPAINT Date: Sat, 27 Feb 2021 11:32:09 +0330 Subject: [PATCH 5/6] updated ingle_include/kompute/Kompute.hpp --- single_include/kompute/Kompute.hpp | 120 ++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 3 deletions(-) diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index 77201ac1a..1d58810b7 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -114,8 +114,8 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error; #include #include -#include #include +#include #include namespace kp { @@ -136,13 +136,15 @@ public: * @param files A list of file names respective to each of the sources * @param entryPoint The function name to use as entry point * @param definitions List of pairs containing key value definitions + * @param resourcesLimit A list that contains the resource limits for the GLSL compiler * @return The compiled SPIR-V binary in unsigned int32 format */ static std::vector compile_sources( const std::vector& sources, const std::vector& files = {}, const std::string& entryPoint = "main", - std::vector> definitions = {}); + std::vector> definitions = {}, + const TBuiltInResource& resources = defaultResource); /** * Compile a single glslang source from string value. Currently this function @@ -154,13 +156,125 @@ public: * @param source An individual raw glsl shader in string format * @param entryPoint The function name to use as entry point * @param definitions List of pairs containing key value definitions + * @param resourcesLimit A list that contains the resource limits for the GLSL compiler * @return The compiled SPIR-V binary in unsigned int32 format */ static std::vector compile_source( const std::string& source, const std::string& entryPoint = "main", - std::vector> definitions = {}); + std::vector> definitions = {}, + const TBuiltInResource& resources = defaultResource); +private: + // The default resource limit for the GLSL compiler, can be overwritten + // Has been adobted by: + // https://github.com/KhronosGroup/glslang/blob/master/StandAlone/ResourceLimits.cpp + static constexpr TBuiltInResource defaultResource = { + /* .MaxLights = */ 0, + /* .MaxClipPlanes = */ 0, + /* .MaxTextureUnits = */ 0, + /* .MaxTextureCoords = */ 0, + /* .MaxVertexAttribs = */ 64, + /* .MaxVertexUniformComponents = */ 4096, + /* .MaxVaryingFloats = */ 64, + /* .MaxVertexTextureImageUnits = */ 0, + /* .MaxCombinedTextureImageUnits = */ 0, + /* .MaxTextureImageUnits = */ 0, + /* .MaxFragmentUniformComponents = */ 0, + /* .MaxDrawBuffers = */ 0, + /* .MaxVertexUniformVectors = */ 128, + /* .MaxVaryingVectors = */ 8, + /* .MaxFragmentUniformVectors = */ 0, + /* .MaxVertexOutputVectors = */ 16, + /* .MaxFragmentInputVectors = */ 0, + /* .MinProgramTexelOffset = */ -8, + /* .MaxProgramTexelOffset = */ 7, + /* .MaxClipDistances = */ 8, + /* .MaxComputeWorkGroupCountX = */ 65535, + /* .MaxComputeWorkGroupCountY = */ 65535, + /* .MaxComputeWorkGroupCountZ = */ 65535, + /* .MaxComputeWorkGroupSizeX = */ 1024, + /* .MaxComputeWorkGroupSizeY = */ 1024, + /* .MaxComputeWorkGroupSizeZ = */ 64, + /* .MaxComputeUniformComponents = */ 1024, + /* .MaxComputeTextureImageUnits = */ 16, + /* .MaxComputeImageUniforms = */ 8, + /* .MaxComputeAtomicCounters = */ 8, + /* .MaxComputeAtomicCounterBuffers = */ 1, + /* .MaxVaryingComponents = */ 60, + /* .MaxVertexOutputComponents = */ 64, + /* .MaxGeometryInputComponents = */ 64, + /* .MaxGeometryOutputComponents = */ 128, + /* .MaxFragmentInputComponents = */ 0, + /* .MaxImageUnits = */ 0, + /* .MaxCombinedImageUnitsAndFragmentOutputs = */ 0, + /* .MaxCombinedShaderOutputResources = */ 8, + /* .MaxImageSamples = */ 0, + /* .MaxVertexImageUniforms = */ 0, + /* .MaxTessControlImageUniforms = */ 0, + /* .MaxTessEvaluationImageUniforms = */ 0, + /* .MaxGeometryImageUniforms = */ 0, + /* .MaxFragmentImageUniforms = */ 0, + /* .MaxCombinedImageUniforms = */ 0, + /* .MaxGeometryTextureImageUnits = */ 0, + /* .MaxGeometryOutputVertices = */ 256, + /* .MaxGeometryTotalOutputComponents = */ 1024, + /* .MaxGeometryUniformComponents = */ 1024, + /* .MaxGeometryVaryingComponents = */ 64, + /* .MaxTessControlInputComponents = */ 128, + /* .MaxTessControlOutputComponents = */ 128, + /* .MaxTessControlTextureImageUnits = */ 0, + /* .MaxTessControlUniformComponents = */ 1024, + /* .MaxTessControlTotalOutputComponents = */ 4096, + /* .MaxTessEvaluationInputComponents = */ 128, + /* .MaxTessEvaluationOutputComponents = */ 128, + /* .MaxTessEvaluationTextureImageUnits = */ 16, + /* .MaxTessEvaluationUniformComponents = */ 1024, + /* .MaxTessPatchComponents = */ 120, + /* .MaxPatchVertices = */ 32, + /* .MaxTessGenLevel = */ 64, + /* .MaxViewports = */ 16, + /* .MaxVertexAtomicCounters = */ 0, + /* .MaxTessControlAtomicCounters = */ 0, + /* .MaxTessEvaluationAtomicCounters = */ 0, + /* .MaxGeometryAtomicCounters = */ 0, + /* .MaxFragmentAtomicCounters = */ 0, + /* .MaxCombinedAtomicCounters = */ 8, + /* .MaxAtomicCounterBindings = */ 1, + /* .MaxVertexAtomicCounterBuffers = */ 0, + /* .MaxTessControlAtomicCounterBuffers = */ 0, + /* .MaxTessEvaluationAtomicCounterBuffers = */ 0, + /* .MaxGeometryAtomicCounterBuffers = */ 0, + /* .MaxFragmentAtomicCounterBuffers = */ 0, + /* .MaxCombinedAtomicCounterBuffers = */ 1, + /* .MaxAtomicCounterBufferSize = */ 16384, + /* .MaxTransformFeedbackBuffers = */ 4, + /* .MaxTransformFeedbackInterleavedComponents = */ 64, + /* .MaxCullDistances = */ 8, + /* .MaxCombinedClipAndCullDistances = */ 8, + /* .MaxSamples = */ 4, + /* .maxMeshOutputVerticesNV = */ 256, + /* .maxMeshOutputPrimitivesNV = */ 512, + /* .maxMeshWorkGroupSizeX_NV = */ 32, + /* .maxMeshWorkGroupSizeY_NV = */ 1, + /* .maxMeshWorkGroupSizeZ_NV = */ 1, + /* .maxTaskWorkGroupSizeX_NV = */ 32, + /* .maxTaskWorkGroupSizeY_NV = */ 1, + /* .maxTaskWorkGroupSizeZ_NV = */ 1, + /* .maxMeshViewCountNV = */ 4, + /* .maxDualSourceDrawBuffersEXT = */ 1, + + /* .limits = */ { + /* .nonInductiveForLoops = */ 1, + /* .whileLoops = */ 1, + /* .doWhileLoops = */ 1, + /* .generalUniformIndexing = */ 1, + /* .generalAttributeMatrixVectorIndexing = */ 1, + /* .generalVaryingIndexing = */ 1, + /* .generalSamplerIndexing = */ 1, + /* .generalVariableIndexing = */ 1, + /* .generalConstantMatrixVectorIndexing = */ 1, + }}; }; } #endif // DKOMPUTE_DISABLE_SHADER_UTILS From ff63fe7a2d6f88a9d98e60cdc8c7990eba1495f0 Mon Sep 17 00:00:00 2001 From: aliPMPAINT Date: Sat, 27 Feb 2021 11:49:03 +0330 Subject: [PATCH 6/6] took the defaultResource outside of the Shader class --- single_include/kompute/Kompute.hpp | 221 ++++++++++++++-------------- src/include/kompute/Shader.hpp | 223 +++++++++++++++-------------- 2 files changed, 224 insertions(+), 220 deletions(-) diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index 1d58810b7..c77f72d3b 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -120,6 +120,116 @@ extern py::object kp_debug, kp_info, kp_warning, kp_error; namespace kp { +// The default resource limit for the GLSL compiler, can be overwritten +// Has been adobted by: +// https://github.com/KhronosGroup/glslang/blob/master/StandAlone/ResourceLimits.cpp +const TBuiltInResource defaultResource = { +/* .MaxLights = */ 0, +/* .MaxClipPlanes = */ 0, +/* .MaxTextureUnits = */ 0, +/* .MaxTextureCoords = */ 0, +/* .MaxVertexAttribs = */ 64, +/* .MaxVertexUniformComponents = */ 4096, +/* .MaxVaryingFloats = */ 64, +/* .MaxVertexTextureImageUnits = */ 0, +/* .MaxCombinedTextureImageUnits = */ 0, +/* .MaxTextureImageUnits = */ 0, +/* .MaxFragmentUniformComponents = */ 0, +/* .MaxDrawBuffers = */ 0, +/* .MaxVertexUniformVectors = */ 128, +/* .MaxVaryingVectors = */ 8, +/* .MaxFragmentUniformVectors = */ 0, +/* .MaxVertexOutputVectors = */ 16, +/* .MaxFragmentInputVectors = */ 0, +/* .MinProgramTexelOffset = */ -8, +/* .MaxProgramTexelOffset = */ 7, +/* .MaxClipDistances = */ 8, +/* .MaxComputeWorkGroupCountX = */ 65535, +/* .MaxComputeWorkGroupCountY = */ 65535, +/* .MaxComputeWorkGroupCountZ = */ 65535, +/* .MaxComputeWorkGroupSizeX = */ 1024, +/* .MaxComputeWorkGroupSizeY = */ 1024, +/* .MaxComputeWorkGroupSizeZ = */ 64, +/* .MaxComputeUniformComponents = */ 1024, +/* .MaxComputeTextureImageUnits = */ 16, +/* .MaxComputeImageUniforms = */ 8, +/* .MaxComputeAtomicCounters = */ 8, +/* .MaxComputeAtomicCounterBuffers = */ 1, +/* .MaxVaryingComponents = */ 60, +/* .MaxVertexOutputComponents = */ 64, +/* .MaxGeometryInputComponents = */ 64, +/* .MaxGeometryOutputComponents = */ 128, +/* .MaxFragmentInputComponents = */ 0, +/* .MaxImageUnits = */ 0, +/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 0, +/* .MaxCombinedShaderOutputResources = */ 8, +/* .MaxImageSamples = */ 0, +/* .MaxVertexImageUniforms = */ 0, +/* .MaxTessControlImageUniforms = */ 0, +/* .MaxTessEvaluationImageUniforms = */ 0, +/* .MaxGeometryImageUniforms = */ 0, +/* .MaxFragmentImageUniforms = */ 0, +/* .MaxCombinedImageUniforms = */ 0, +/* .MaxGeometryTextureImageUnits = */ 0, +/* .MaxGeometryOutputVertices = */ 256, +/* .MaxGeometryTotalOutputComponents = */ 1024, +/* .MaxGeometryUniformComponents = */ 1024, +/* .MaxGeometryVaryingComponents = */ 64, +/* .MaxTessControlInputComponents = */ 128, +/* .MaxTessControlOutputComponents = */ 128, +/* .MaxTessControlTextureImageUnits = */ 0, +/* .MaxTessControlUniformComponents = */ 1024, +/* .MaxTessControlTotalOutputComponents = */ 4096, +/* .MaxTessEvaluationInputComponents = */ 128, +/* .MaxTessEvaluationOutputComponents = */ 128, +/* .MaxTessEvaluationTextureImageUnits = */ 16, +/* .MaxTessEvaluationUniformComponents = */ 1024, +/* .MaxTessPatchComponents = */ 120, +/* .MaxPatchVertices = */ 32, +/* .MaxTessGenLevel = */ 64, +/* .MaxViewports = */ 16, +/* .MaxVertexAtomicCounters = */ 0, +/* .MaxTessControlAtomicCounters = */ 0, +/* .MaxTessEvaluationAtomicCounters = */ 0, +/* .MaxGeometryAtomicCounters = */ 0, +/* .MaxFragmentAtomicCounters = */ 0, +/* .MaxCombinedAtomicCounters = */ 8, +/* .MaxAtomicCounterBindings = */ 1, +/* .MaxVertexAtomicCounterBuffers = */ 0, +/* .MaxTessControlAtomicCounterBuffers = */ 0, +/* .MaxTessEvaluationAtomicCounterBuffers = */ 0, +/* .MaxGeometryAtomicCounterBuffers = */ 0, +/* .MaxFragmentAtomicCounterBuffers = */ 0, +/* .MaxCombinedAtomicCounterBuffers = */ 1, +/* .MaxAtomicCounterBufferSize = */ 16384, +/* .MaxTransformFeedbackBuffers = */ 4, +/* .MaxTransformFeedbackInterleavedComponents = */ 64, +/* .MaxCullDistances = */ 8, +/* .MaxCombinedClipAndCullDistances = */ 8, +/* .MaxSamples = */ 4, +/* .maxMeshOutputVerticesNV = */ 256, +/* .maxMeshOutputPrimitivesNV = */ 512, +/* .maxMeshWorkGroupSizeX_NV = */ 32, +/* .maxMeshWorkGroupSizeY_NV = */ 1, +/* .maxMeshWorkGroupSizeZ_NV = */ 1, +/* .maxTaskWorkGroupSizeX_NV = */ 32, +/* .maxTaskWorkGroupSizeY_NV = */ 1, +/* .maxTaskWorkGroupSizeZ_NV = */ 1, +/* .maxMeshViewCountNV = */ 4, +/* .maxDualSourceDrawBuffersEXT = */ 1, + +/* .limits = */ { + /* .nonInductiveForLoops = */ 1, + /* .whileLoops = */ 1, + /* .doWhileLoops = */ 1, + /* .generalUniformIndexing = */ 1, + /* .generalAttributeMatrixVectorIndexing = */ 1, + /* .generalVaryingIndexing = */ 1, + /* .generalSamplerIndexing = */ 1, + /* .generalVariableIndexing = */ 1, + /* .generalConstantMatrixVectorIndexing = */ 1, +}}; + /** Shader utily class with functions to compile and process glsl files. */ @@ -165,117 +275,8 @@ public: std::vector> definitions = {}, const TBuiltInResource& resources = defaultResource); -private: - // The default resource limit for the GLSL compiler, can be overwritten - // Has been adobted by: - // https://github.com/KhronosGroup/glslang/blob/master/StandAlone/ResourceLimits.cpp - static constexpr TBuiltInResource defaultResource = { - /* .MaxLights = */ 0, - /* .MaxClipPlanes = */ 0, - /* .MaxTextureUnits = */ 0, - /* .MaxTextureCoords = */ 0, - /* .MaxVertexAttribs = */ 64, - /* .MaxVertexUniformComponents = */ 4096, - /* .MaxVaryingFloats = */ 64, - /* .MaxVertexTextureImageUnits = */ 0, - /* .MaxCombinedTextureImageUnits = */ 0, - /* .MaxTextureImageUnits = */ 0, - /* .MaxFragmentUniformComponents = */ 0, - /* .MaxDrawBuffers = */ 0, - /* .MaxVertexUniformVectors = */ 128, - /* .MaxVaryingVectors = */ 8, - /* .MaxFragmentUniformVectors = */ 0, - /* .MaxVertexOutputVectors = */ 16, - /* .MaxFragmentInputVectors = */ 0, - /* .MinProgramTexelOffset = */ -8, - /* .MaxProgramTexelOffset = */ 7, - /* .MaxClipDistances = */ 8, - /* .MaxComputeWorkGroupCountX = */ 65535, - /* .MaxComputeWorkGroupCountY = */ 65535, - /* .MaxComputeWorkGroupCountZ = */ 65535, - /* .MaxComputeWorkGroupSizeX = */ 1024, - /* .MaxComputeWorkGroupSizeY = */ 1024, - /* .MaxComputeWorkGroupSizeZ = */ 64, - /* .MaxComputeUniformComponents = */ 1024, - /* .MaxComputeTextureImageUnits = */ 16, - /* .MaxComputeImageUniforms = */ 8, - /* .MaxComputeAtomicCounters = */ 8, - /* .MaxComputeAtomicCounterBuffers = */ 1, - /* .MaxVaryingComponents = */ 60, - /* .MaxVertexOutputComponents = */ 64, - /* .MaxGeometryInputComponents = */ 64, - /* .MaxGeometryOutputComponents = */ 128, - /* .MaxFragmentInputComponents = */ 0, - /* .MaxImageUnits = */ 0, - /* .MaxCombinedImageUnitsAndFragmentOutputs = */ 0, - /* .MaxCombinedShaderOutputResources = */ 8, - /* .MaxImageSamples = */ 0, - /* .MaxVertexImageUniforms = */ 0, - /* .MaxTessControlImageUniforms = */ 0, - /* .MaxTessEvaluationImageUniforms = */ 0, - /* .MaxGeometryImageUniforms = */ 0, - /* .MaxFragmentImageUniforms = */ 0, - /* .MaxCombinedImageUniforms = */ 0, - /* .MaxGeometryTextureImageUnits = */ 0, - /* .MaxGeometryOutputVertices = */ 256, - /* .MaxGeometryTotalOutputComponents = */ 1024, - /* .MaxGeometryUniformComponents = */ 1024, - /* .MaxGeometryVaryingComponents = */ 64, - /* .MaxTessControlInputComponents = */ 128, - /* .MaxTessControlOutputComponents = */ 128, - /* .MaxTessControlTextureImageUnits = */ 0, - /* .MaxTessControlUniformComponents = */ 1024, - /* .MaxTessControlTotalOutputComponents = */ 4096, - /* .MaxTessEvaluationInputComponents = */ 128, - /* .MaxTessEvaluationOutputComponents = */ 128, - /* .MaxTessEvaluationTextureImageUnits = */ 16, - /* .MaxTessEvaluationUniformComponents = */ 1024, - /* .MaxTessPatchComponents = */ 120, - /* .MaxPatchVertices = */ 32, - /* .MaxTessGenLevel = */ 64, - /* .MaxViewports = */ 16, - /* .MaxVertexAtomicCounters = */ 0, - /* .MaxTessControlAtomicCounters = */ 0, - /* .MaxTessEvaluationAtomicCounters = */ 0, - /* .MaxGeometryAtomicCounters = */ 0, - /* .MaxFragmentAtomicCounters = */ 0, - /* .MaxCombinedAtomicCounters = */ 8, - /* .MaxAtomicCounterBindings = */ 1, - /* .MaxVertexAtomicCounterBuffers = */ 0, - /* .MaxTessControlAtomicCounterBuffers = */ 0, - /* .MaxTessEvaluationAtomicCounterBuffers = */ 0, - /* .MaxGeometryAtomicCounterBuffers = */ 0, - /* .MaxFragmentAtomicCounterBuffers = */ 0, - /* .MaxCombinedAtomicCounterBuffers = */ 1, - /* .MaxAtomicCounterBufferSize = */ 16384, - /* .MaxTransformFeedbackBuffers = */ 4, - /* .MaxTransformFeedbackInterleavedComponents = */ 64, - /* .MaxCullDistances = */ 8, - /* .MaxCombinedClipAndCullDistances = */ 8, - /* .MaxSamples = */ 4, - /* .maxMeshOutputVerticesNV = */ 256, - /* .maxMeshOutputPrimitivesNV = */ 512, - /* .maxMeshWorkGroupSizeX_NV = */ 32, - /* .maxMeshWorkGroupSizeY_NV = */ 1, - /* .maxMeshWorkGroupSizeZ_NV = */ 1, - /* .maxTaskWorkGroupSizeX_NV = */ 32, - /* .maxTaskWorkGroupSizeY_NV = */ 1, - /* .maxTaskWorkGroupSizeZ_NV = */ 1, - /* .maxMeshViewCountNV = */ 4, - /* .maxDualSourceDrawBuffersEXT = */ 1, - - /* .limits = */ { - /* .nonInductiveForLoops = */ 1, - /* .whileLoops = */ 1, - /* .doWhileLoops = */ 1, - /* .generalUniformIndexing = */ 1, - /* .generalAttributeMatrixVectorIndexing = */ 1, - /* .generalVaryingIndexing = */ 1, - /* .generalSamplerIndexing = */ 1, - /* .generalVariableIndexing = */ 1, - /* .generalConstantMatrixVectorIndexing = */ 1, - }}; }; + } #endif // DKOMPUTE_DISABLE_SHADER_UTILS diff --git a/src/include/kompute/Shader.hpp b/src/include/kompute/Shader.hpp index bb76dbbef..8c9a14c83 100644 --- a/src/include/kompute/Shader.hpp +++ b/src/include/kompute/Shader.hpp @@ -12,6 +12,116 @@ namespace kp { +// The default resource limit for the GLSL compiler, can be overwritten +// Has been adobted by: +// https://github.com/KhronosGroup/glslang/blob/master/StandAlone/ResourceLimits.cpp +const TBuiltInResource defaultResource = { +/* .MaxLights = */ 0, +/* .MaxClipPlanes = */ 0, +/* .MaxTextureUnits = */ 0, +/* .MaxTextureCoords = */ 0, +/* .MaxVertexAttribs = */ 64, +/* .MaxVertexUniformComponents = */ 4096, +/* .MaxVaryingFloats = */ 64, +/* .MaxVertexTextureImageUnits = */ 0, +/* .MaxCombinedTextureImageUnits = */ 0, +/* .MaxTextureImageUnits = */ 0, +/* .MaxFragmentUniformComponents = */ 0, +/* .MaxDrawBuffers = */ 0, +/* .MaxVertexUniformVectors = */ 128, +/* .MaxVaryingVectors = */ 8, +/* .MaxFragmentUniformVectors = */ 0, +/* .MaxVertexOutputVectors = */ 16, +/* .MaxFragmentInputVectors = */ 0, +/* .MinProgramTexelOffset = */ -8, +/* .MaxProgramTexelOffset = */ 7, +/* .MaxClipDistances = */ 8, +/* .MaxComputeWorkGroupCountX = */ 65535, +/* .MaxComputeWorkGroupCountY = */ 65535, +/* .MaxComputeWorkGroupCountZ = */ 65535, +/* .MaxComputeWorkGroupSizeX = */ 1024, +/* .MaxComputeWorkGroupSizeY = */ 1024, +/* .MaxComputeWorkGroupSizeZ = */ 64, +/* .MaxComputeUniformComponents = */ 1024, +/* .MaxComputeTextureImageUnits = */ 16, +/* .MaxComputeImageUniforms = */ 8, +/* .MaxComputeAtomicCounters = */ 8, +/* .MaxComputeAtomicCounterBuffers = */ 1, +/* .MaxVaryingComponents = */ 60, +/* .MaxVertexOutputComponents = */ 64, +/* .MaxGeometryInputComponents = */ 64, +/* .MaxGeometryOutputComponents = */ 128, +/* .MaxFragmentInputComponents = */ 0, +/* .MaxImageUnits = */ 0, +/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 0, +/* .MaxCombinedShaderOutputResources = */ 8, +/* .MaxImageSamples = */ 0, +/* .MaxVertexImageUniforms = */ 0, +/* .MaxTessControlImageUniforms = */ 0, +/* .MaxTessEvaluationImageUniforms = */ 0, +/* .MaxGeometryImageUniforms = */ 0, +/* .MaxFragmentImageUniforms = */ 0, +/* .MaxCombinedImageUniforms = */ 0, +/* .MaxGeometryTextureImageUnits = */ 0, +/* .MaxGeometryOutputVertices = */ 256, +/* .MaxGeometryTotalOutputComponents = */ 1024, +/* .MaxGeometryUniformComponents = */ 1024, +/* .MaxGeometryVaryingComponents = */ 64, +/* .MaxTessControlInputComponents = */ 128, +/* .MaxTessControlOutputComponents = */ 128, +/* .MaxTessControlTextureImageUnits = */ 0, +/* .MaxTessControlUniformComponents = */ 1024, +/* .MaxTessControlTotalOutputComponents = */ 4096, +/* .MaxTessEvaluationInputComponents = */ 128, +/* .MaxTessEvaluationOutputComponents = */ 128, +/* .MaxTessEvaluationTextureImageUnits = */ 16, +/* .MaxTessEvaluationUniformComponents = */ 1024, +/* .MaxTessPatchComponents = */ 120, +/* .MaxPatchVertices = */ 32, +/* .MaxTessGenLevel = */ 64, +/* .MaxViewports = */ 16, +/* .MaxVertexAtomicCounters = */ 0, +/* .MaxTessControlAtomicCounters = */ 0, +/* .MaxTessEvaluationAtomicCounters = */ 0, +/* .MaxGeometryAtomicCounters = */ 0, +/* .MaxFragmentAtomicCounters = */ 0, +/* .MaxCombinedAtomicCounters = */ 8, +/* .MaxAtomicCounterBindings = */ 1, +/* .MaxVertexAtomicCounterBuffers = */ 0, +/* .MaxTessControlAtomicCounterBuffers = */ 0, +/* .MaxTessEvaluationAtomicCounterBuffers = */ 0, +/* .MaxGeometryAtomicCounterBuffers = */ 0, +/* .MaxFragmentAtomicCounterBuffers = */ 0, +/* .MaxCombinedAtomicCounterBuffers = */ 1, +/* .MaxAtomicCounterBufferSize = */ 16384, +/* .MaxTransformFeedbackBuffers = */ 4, +/* .MaxTransformFeedbackInterleavedComponents = */ 64, +/* .MaxCullDistances = */ 8, +/* .MaxCombinedClipAndCullDistances = */ 8, +/* .MaxSamples = */ 4, +/* .maxMeshOutputVerticesNV = */ 256, +/* .maxMeshOutputPrimitivesNV = */ 512, +/* .maxMeshWorkGroupSizeX_NV = */ 32, +/* .maxMeshWorkGroupSizeY_NV = */ 1, +/* .maxMeshWorkGroupSizeZ_NV = */ 1, +/* .maxTaskWorkGroupSizeX_NV = */ 32, +/* .maxTaskWorkGroupSizeY_NV = */ 1, +/* .maxTaskWorkGroupSizeZ_NV = */ 1, +/* .maxMeshViewCountNV = */ 4, +/* .maxDualSourceDrawBuffersEXT = */ 1, + +/* .limits = */ { + /* .nonInductiveForLoops = */ 1, + /* .whileLoops = */ 1, + /* .doWhileLoops = */ 1, + /* .generalUniformIndexing = */ 1, + /* .generalAttributeMatrixVectorIndexing = */ 1, + /* .generalVaryingIndexing = */ 1, + /* .generalSamplerIndexing = */ 1, + /* .generalVariableIndexing = */ 1, + /* .generalConstantMatrixVectorIndexing = */ 1, +}}; + /** Shader utily class with functions to compile and process glsl files. */ @@ -57,117 +167,10 @@ public: std::vector> definitions = {}, const TBuiltInResource& resources = defaultResource); -private: - // The default resource limit for the GLSL compiler, can be overwritten - // Has been adobted by: - // https://github.com/KhronosGroup/glslang/blob/master/StandAlone/ResourceLimits.cpp - static constexpr TBuiltInResource defaultResource = { - /* .MaxLights = */ 0, - /* .MaxClipPlanes = */ 0, - /* .MaxTextureUnits = */ 0, - /* .MaxTextureCoords = */ 0, - /* .MaxVertexAttribs = */ 64, - /* .MaxVertexUniformComponents = */ 4096, - /* .MaxVaryingFloats = */ 64, - /* .MaxVertexTextureImageUnits = */ 0, - /* .MaxCombinedTextureImageUnits = */ 0, - /* .MaxTextureImageUnits = */ 0, - /* .MaxFragmentUniformComponents = */ 0, - /* .MaxDrawBuffers = */ 0, - /* .MaxVertexUniformVectors = */ 128, - /* .MaxVaryingVectors = */ 8, - /* .MaxFragmentUniformVectors = */ 0, - /* .MaxVertexOutputVectors = */ 16, - /* .MaxFragmentInputVectors = */ 0, - /* .MinProgramTexelOffset = */ -8, - /* .MaxProgramTexelOffset = */ 7, - /* .MaxClipDistances = */ 8, - /* .MaxComputeWorkGroupCountX = */ 65535, - /* .MaxComputeWorkGroupCountY = */ 65535, - /* .MaxComputeWorkGroupCountZ = */ 65535, - /* .MaxComputeWorkGroupSizeX = */ 1024, - /* .MaxComputeWorkGroupSizeY = */ 1024, - /* .MaxComputeWorkGroupSizeZ = */ 64, - /* .MaxComputeUniformComponents = */ 1024, - /* .MaxComputeTextureImageUnits = */ 16, - /* .MaxComputeImageUniforms = */ 8, - /* .MaxComputeAtomicCounters = */ 8, - /* .MaxComputeAtomicCounterBuffers = */ 1, - /* .MaxVaryingComponents = */ 60, - /* .MaxVertexOutputComponents = */ 64, - /* .MaxGeometryInputComponents = */ 64, - /* .MaxGeometryOutputComponents = */ 128, - /* .MaxFragmentInputComponents = */ 0, - /* .MaxImageUnits = */ 0, - /* .MaxCombinedImageUnitsAndFragmentOutputs = */ 0, - /* .MaxCombinedShaderOutputResources = */ 8, - /* .MaxImageSamples = */ 0, - /* .MaxVertexImageUniforms = */ 0, - /* .MaxTessControlImageUniforms = */ 0, - /* .MaxTessEvaluationImageUniforms = */ 0, - /* .MaxGeometryImageUniforms = */ 0, - /* .MaxFragmentImageUniforms = */ 0, - /* .MaxCombinedImageUniforms = */ 0, - /* .MaxGeometryTextureImageUnits = */ 0, - /* .MaxGeometryOutputVertices = */ 256, - /* .MaxGeometryTotalOutputComponents = */ 1024, - /* .MaxGeometryUniformComponents = */ 1024, - /* .MaxGeometryVaryingComponents = */ 64, - /* .MaxTessControlInputComponents = */ 128, - /* .MaxTessControlOutputComponents = */ 128, - /* .MaxTessControlTextureImageUnits = */ 0, - /* .MaxTessControlUniformComponents = */ 1024, - /* .MaxTessControlTotalOutputComponents = */ 4096, - /* .MaxTessEvaluationInputComponents = */ 128, - /* .MaxTessEvaluationOutputComponents = */ 128, - /* .MaxTessEvaluationTextureImageUnits = */ 16, - /* .MaxTessEvaluationUniformComponents = */ 1024, - /* .MaxTessPatchComponents = */ 120, - /* .MaxPatchVertices = */ 32, - /* .MaxTessGenLevel = */ 64, - /* .MaxViewports = */ 16, - /* .MaxVertexAtomicCounters = */ 0, - /* .MaxTessControlAtomicCounters = */ 0, - /* .MaxTessEvaluationAtomicCounters = */ 0, - /* .MaxGeometryAtomicCounters = */ 0, - /* .MaxFragmentAtomicCounters = */ 0, - /* .MaxCombinedAtomicCounters = */ 8, - /* .MaxAtomicCounterBindings = */ 1, - /* .MaxVertexAtomicCounterBuffers = */ 0, - /* .MaxTessControlAtomicCounterBuffers = */ 0, - /* .MaxTessEvaluationAtomicCounterBuffers = */ 0, - /* .MaxGeometryAtomicCounterBuffers = */ 0, - /* .MaxFragmentAtomicCounterBuffers = */ 0, - /* .MaxCombinedAtomicCounterBuffers = */ 1, - /* .MaxAtomicCounterBufferSize = */ 16384, - /* .MaxTransformFeedbackBuffers = */ 4, - /* .MaxTransformFeedbackInterleavedComponents = */ 64, - /* .MaxCullDistances = */ 8, - /* .MaxCombinedClipAndCullDistances = */ 8, - /* .MaxSamples = */ 4, - /* .maxMeshOutputVerticesNV = */ 256, - /* .maxMeshOutputPrimitivesNV = */ 512, - /* .maxMeshWorkGroupSizeX_NV = */ 32, - /* .maxMeshWorkGroupSizeY_NV = */ 1, - /* .maxMeshWorkGroupSizeZ_NV = */ 1, - /* .maxTaskWorkGroupSizeX_NV = */ 32, - /* .maxTaskWorkGroupSizeY_NV = */ 1, - /* .maxTaskWorkGroupSizeZ_NV = */ 1, - /* .maxMeshViewCountNV = */ 4, - /* .maxDualSourceDrawBuffersEXT = */ 1, - - /* .limits = */ { - /* .nonInductiveForLoops = */ 1, - /* .whileLoops = */ 1, - /* .doWhileLoops = */ 1, - /* .generalUniformIndexing = */ 1, - /* .generalAttributeMatrixVectorIndexing = */ 1, - /* .generalVaryingIndexing = */ 1, - /* .generalSamplerIndexing = */ 1, - /* .generalVariableIndexing = */ 1, - /* .generalConstantMatrixVectorIndexing = */ 1, - }}; }; + + + } #endif // DKOMPUTE_DISABLE_SHADER_UTILS