mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
add the count of compilations of shaders to avoid recompiling them if ot needed
This commit is contained in:
parent
7aa5ef3de7
commit
f044cf76d6
5 changed files with 11 additions and 2 deletions
|
@ -398,7 +398,6 @@ void HmdDisplayPlugin::HUDRenderer::updatePipeline() {
|
|||
auto vs = gpu::Shader::createVertex(std::string(hmd_ui_vert));
|
||||
auto ps = gpu::Shader::createPixel(std::string(hmd_ui_frag));
|
||||
auto program = gpu::Shader::createProgram(vs, ps);
|
||||
// gpu::gl::GLBackend::makeProgram(*program, gpu::Shader::BindingSet());
|
||||
gpu::Shader::makeProgram(*program, gpu::Shader::BindingSet());
|
||||
uniformsLocation = program->getUniformBuffers().findLocation("hudBuffer");
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ GLShader* GLBackend::compileBackendShader(const Shader& shader, Shader::Compilat
|
|||
GLenum shaderDomain = SHADER_DOMAINS[shader.getType()];
|
||||
GLShader::ShaderObjects shaderObjects;
|
||||
Shader::CompilationLogs compilationLogs(GLShader::NumVersions);
|
||||
shader.incrementCompilationAttempt();
|
||||
|
||||
for (int version = 0; version < GLShader::NumVersions; version++) {
|
||||
auto& shaderObject = shaderObjects[version];
|
||||
|
@ -108,6 +109,7 @@ GLShader* GLBackend::compileBackendProgram(const Shader& program, Shader::Compil
|
|||
|
||||
GLShader::ShaderObjects programObjects;
|
||||
|
||||
program.incrementCompilationAttempt();
|
||||
Shader::CompilationLogs compilationLogs(GLShader::NumVersions);
|
||||
|
||||
for (int version = 0; version < GLShader::NumVersions; version++) {
|
||||
|
|
|
@ -95,3 +95,7 @@ void Shader::setCompilationLogs(const CompilationLogs& logs) const {
|
|||
_compilationLogs.emplace_back(CompilationLog(log));
|
||||
}
|
||||
}
|
||||
|
||||
void Shader::incrementCompilationAttempt() const {
|
||||
_numCompilationAttempts++;
|
||||
}
|
|
@ -185,10 +185,12 @@ public:
|
|||
// Check the compilation state
|
||||
bool compilationHasFailed() const { return _compilationHasFailed; }
|
||||
const CompilationLogs& getCompilationLogs() const { return _compilationLogs; }
|
||||
uint32_t getNumCompilationAttempts() const { return _numCompilationAttempts; }
|
||||
|
||||
// Set COmpilation logs can only be called by the Backend layers
|
||||
void setCompilationHasFailed(bool compilationHasFailed) { _compilationHasFailed = compilationHasFailed; }
|
||||
void setCompilationLogs(const CompilationLogs& logs) const;
|
||||
void incrementCompilationAttempt() const;
|
||||
|
||||
|
||||
const GPUObjectPointer gpuObject {};
|
||||
|
@ -219,6 +221,8 @@ protected:
|
|||
// The type of the shader, the master key
|
||||
Type _type;
|
||||
|
||||
// Number of attempts to compile the shader
|
||||
mutable uint32_t _numCompilationAttempts{ 0 };
|
||||
// Compilation logs (one for each versions generated)
|
||||
mutable CompilationLogs _compilationLogs;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
|
|||
BatchSetter batchSetter, ItemSetter itemSetter) {
|
||||
ShapeKey key{ filter._flags };
|
||||
|
||||
if (program->getInputs().empty()) {
|
||||
if (program->getNumCompilationAttempts() < 1) {
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("lightingModelBuffer"), Slot::BUFFER::LIGHTING_MODEL));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("skinClusterBuffer"), Slot::BUFFER::SKINNING));
|
||||
|
|
Loading…
Reference in a new issue