16 constexpr size_t g_validationBufferMaxSize = 64 * 1024;
29 if (!g_sValidationQueue.try_dequeue(s_validationOutputCache))
35 if (g_deletionSet.find(s_validationOutputCache._handle) != std::cend(g_deletionSet))
43 gl46core::glValidateProgramPipeline(s_validationOutputCache._handle);
45 gl46core::GLint status = 1;
46 if (s_validationOutputCache._stageMask != gl46core::UseProgramStageMask::GL_COMPUTE_SHADER_BIT)
48 gl46core::glGetProgramPipelineiv(s_validationOutputCache._handle, gl46core::GL_VALIDATE_STATUS, &status);
57 gl46core::GLint length = 0;
58 gl46core::glGetProgramPipelineiv(s_validationOutputCache._handle, gl46core::GL_INFO_LOG_LENGTH, &length);
62 string validationBuffer;
63 validationBuffer.resize(length);
64 gl46core::glGetProgramPipelineInfoLog(s_validationOutputCache._handle, length,
nullptr, &validationBuffer[0]);
67 if (validationBuffer.size() > g_validationBufferMaxSize)
70 validationBuffer.resize(std::strlen(
LOCALE_STR(
"GLSL_LINK_PROGRAM_LOG")) + g_validationBufferMaxSize);
72 validationBuffer.append(
" ... ");
75 Console::errorfn(
LOCALE_STR(
"GLSL_VALIDATING_PROGRAM"), s_validationOutputCache._handle, s_validationOutputCache._name.c_str(), validationBuffer.c_str());
79 Console::errorfn(
LOCALE_STR(
"GLSL_VALIDATING_PROGRAM"), s_validationOutputCache._handle, s_validationOutputCache._name.c_str(),
"[ Couldn't retrieve info log! ]");
84 Console::d_printfn(
LOCALE_STR(
"GLSL_VALIDATING_PROGRAM"), s_validationOutputCache._handle, s_validationOutputCache._name.c_str(),
"[ OK! ]");
114 gl46core::glDeleteProgramPipelines(1, &
_glHandle);
120 shader._shader->deregisterParent(
this );
139 gl46core::UseProgramStageMask stageMask = gl46core::UseProgramStageMask::GL_NONE_BIT;
142 if (!shader._shader->valid())
147 shader._shader->onParentValidation();
148 stageMask |= shader._shader->stageMask();
153 g_sValidationQueue.enqueue({ resourceName(),
_glHandle, stageMask});
168 gl46core::glCreateProgramPipelines(1, &
_glHandle);
171 gl46core::glObjectLabel( gl46core::GL_PROGRAM_PIPELINE,
174 resourceName().c_str() );
187 ret = shader._shader->uploadToGPU();
194 gl46core::glUseProgramStages(
_glHandle, shader._shader->stageMask(), shader._shader->handle());
217 for (
auto& [fileHash, loadDataPerFile] : fileData)
219 assert(!loadDataPerFile._modules.empty());
222 U32 targetGeneration = 0u;
225 if ( stage._fileHash ==
_ID ( loadDataPerFile._programName.c_str()) )
227 targetGeneration = overwrite ? stage._generation + 1u : stage._generation;
269 if (pushConstants.
set())
273 if (!shader._shader->valid())
278 shader._shader->uploadPushConstants(pushConstants);
#define PROFILE_SCOPE_AUTO(CATEGORY)
static GLStateTracker & GetStateTracker() noexcept
ResourceState getState() const noexcept
virtual ShaderResult validatePreBind(bool rebind=true)
virtual bool loadInternal(hashMap< U64, PerFileShaderData > &fileData, bool overwrite)
static glShaderEntry LoadShader(GFXDevice &context, glShaderProgram *parent, const std::string_view name, U32 targetGeneration, ShaderProgram::ShaderLoadData &data)
Add or refresh a shader from the cache.
~glShaderProgram() override
ShaderResult validatePreBind(bool rebind=true) override
void uploadPushConstants(const PushConstantsStruct &pushConstants)
bool unload() override
Make sure this program is ready for deletion.
bool loadInternal(hashMap< U64, PerFileShaderData > &fileData, bool overwrite) override
Returns true if at least one shader linked successfully.
glShaderProgram(PlatformContext &context, const ResourceDescriptor< ShaderProgram > &descriptor)
gl46core::GLuint _glHandle
static void Idle(PlatformContext &platformContext)
ShaderResult bind()
Bind this shader program (returns false if the program failed validation)
constexpr bool ENABLE_GPU_VALIDATION
Error callbacks, validations, buffer checks, etc. are controlled by this flag. Heavy performance impa...
constexpr Optick::Category::Type Graphics
SharedMutex g_deletionSetLock
NO_DESTROY eastl::set< gl46core::GLuint > g_deletionSet
NO_DESTROY moodycamel::BlockingConcurrentQueue< ValidationEntry > g_sValidationQueue
Handle console commands that start with a forward slash.
std::lock_guard< mutex > LockGuard
@ RES_LOADED
The resource is available for usage.
std::shared_mutex SharedMutex
constexpr gl46core::GLuint GL_NULL_HANDLE
Invalid object value. Used to compare handles and determine if they were properly created.
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
std::shared_lock< mutex > SharedLock
constexpr U64 _ID(const char *const str, const U64 value=val_64_const) noexcept
static NO_INLINE void d_printfn(const char *format, T &&... args)
static NO_INLINE void errorfn(const char *format, T &&... args)
bool set() const noexcept