-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
made changes for include paths for complete installation #163
Changes from 5 commits
c132f90
eafcd04
f60e71d
3cad95c
bb7893b
ff63fe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
#include <iostream> | ||
#include <vector> | ||
|
||
#include <glslang/Include/ResourceLimits.h> | ||
#include <glslang/Public/ShaderLang.h> | ||
#include <StandAlone/ResourceLimits.h> | ||
#include <SPIRV/GlslangToSpv.h> | ||
|
||
#include "kompute/Core.hpp" | ||
|
@@ -28,13 +28,15 @@ class Shader { | |
* @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<uint32_t> compile_sources( | ||
const std::vector<std::string>& sources, | ||
const std::vector<std::string>& files = {}, | ||
const std::string& entryPoint = "main", | ||
std::vector<std::pair<std::string,std::string>> definitions = {}); | ||
std::vector<std::pair<std::string,std::string>> definitions = {}, | ||
const TBuiltInResource& resources = defaultResource); | ||
|
||
/** | ||
* Compile a single glslang source from string value. Currently this function | ||
|
@@ -46,13 +48,125 @@ class Shader { | |
* @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<uint32_t> compile_source( | ||
const std::string& source, | ||
const std::string& entryPoint = "main", | ||
std::vector<std::pair<std::string,std::string>> definitions = {}); | ||
std::vector<std::pair<std::string,std::string>> definitions = {}, | ||
const TBuiltInResource& resources = defaultResource); | ||
|
||
private: | ||
// The default resource limit for the GLSL compiler, can be overwritten | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is everythign else except max-lights the same as the standalone file? May be worth adding a comment also linking to the github file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I was about to write an explanation for it. It's actually not complete, as I don't know which ones are exactly required and which it's not required in our usage, like I'm sure we won't need
Yeah sure |
||
// 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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you can just call it
const
as that is the same asconstexpr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It yielded me an error, this:
constexpr' needed for in-class initialization of static data member
more on this here:
https://stackoverflow.com/questions/9141950/initializing-const-member-within-class-declaration-in-c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok i see, although not clear why it would error being static inside a class, may be worth having a deeper look, as the rest of the functions are within the Shader scope so would be best to have this variable also within
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm trying to do so for hours. The closet thing I have come into is
static constexpr TBuiltInResource const& defaultResource
(got it from here), but instead of the undefined reference I got ismultiple definition of '_ZGRN2kp6Shader15defaultResourceE_'; CMakeFiles/test_kompute.dir/TestAsyncOperations.cpp.o:(.rodata+0x0): first defined her
. Any ideas?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ok I see, I think given this is taking too long let's just get it as global and we can move it (we an open an issue separate)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sounds good