mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:17:45 +02:00
Refining the declaraion signatures and adding the binary capture
This commit is contained in:
parent
d5e52834ef
commit
f078ff611a
11 changed files with 20 additions and 15 deletions
|
@ -398,7 +398,8 @@ void HmdDisplayPlugin::HUDRenderer::updatePipeline() {
|
||||||
auto vs = gpu::Shader::createVertex(std::string(hmd_ui_vert));
|
auto vs = gpu::Shader::createVertex(std::string(hmd_ui_vert));
|
||||||
auto ps = gpu::Shader::createPixel(std::string(hmd_ui_frag));
|
auto ps = gpu::Shader::createPixel(std::string(hmd_ui_frag));
|
||||||
auto program = gpu::Shader::createProgram(vs, ps);
|
auto program = gpu::Shader::createProgram(vs, ps);
|
||||||
gpu::gl::GLBackend::makeProgram(*program, gpu::Shader::BindingSet());
|
// gpu::gl::GLBackend::makeProgram(*program, gpu::Shader::BindingSet());
|
||||||
|
gpu::Shader::makeProgram(*program, gpu::Shader::BindingSet());
|
||||||
uniformsLocation = program->getUniformBuffers().findLocation("hudBuffer");
|
uniformsLocation = program->getUniformBuffers().findLocation("hudBuffer");
|
||||||
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
||||||
explicit GLBackend(bool syncCache);
|
explicit GLBackend(bool syncCache);
|
||||||
GLBackend();
|
GLBackend();
|
||||||
public:
|
public:
|
||||||
static bool makeProgram(Shader& shader, const Shader::BindingSet& slotBindings = Shader::BindingSet(), Shader::CompilationHandler handler = nullptr);
|
static bool makeProgram(Shader& shader, const Shader::BindingSet& slotBindings, Shader::CompilationHandler handler);
|
||||||
|
|
||||||
virtual ~GLBackend();
|
virtual ~GLBackend();
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ protected:
|
||||||
} _pipeline;
|
} _pipeline;
|
||||||
|
|
||||||
// Backend dependant compilation of the shader
|
// Backend dependant compilation of the shader
|
||||||
virtual GLShader* compileBackendProgram(const Shader& program);
|
virtual GLShader* compileBackendProgram(const Shader& program, Shader::CompilationHandler handler);
|
||||||
virtual GLShader* compileBackendShader(const Shader& shader, Shader::CompilationHandler handler);
|
virtual GLShader* compileBackendShader(const Shader& shader, Shader::CompilationHandler handler);
|
||||||
virtual std::string getBackendShaderHeader() const;
|
virtual std::string getBackendShaderHeader() const;
|
||||||
virtual void makeProgramBindings(ShaderObject& shaderObject);
|
virtual void makeProgramBindings(ShaderObject& shaderObject);
|
||||||
|
|
|
@ -101,7 +101,7 @@ GLShader* GLBackend::compileBackendShader(const Shader& shader, Shader::Compilat
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShader* GLBackend::compileBackendProgram(const Shader& program) {
|
GLShader* GLBackend::compileBackendProgram(const Shader& program, Shader::CompilationHandler handler) {
|
||||||
if (!program.isProgram()) {
|
if (!program.isProgram()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -116,11 +116,13 @@ GLShader* GLBackend::compileBackendProgram(const Shader& program) {
|
||||||
// Let's go through every shaders and make sure they are ready to go
|
// Let's go through every shaders and make sure they are ready to go
|
||||||
std::vector< GLuint > shaderGLObjects;
|
std::vector< GLuint > shaderGLObjects;
|
||||||
for (auto subShader : program.getShaders()) {
|
for (auto subShader : program.getShaders()) {
|
||||||
auto object = GLShader::sync((*this), *subShader);
|
auto object = GLShader::sync((*this), *subShader, handler);
|
||||||
if (object) {
|
if (object) {
|
||||||
shaderGLObjects.push_back(object->_shaderObjects[version].glshader);
|
shaderGLObjects.push_back(object->_shaderObjects[version].glshader);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(gpugllogging) << "GLBackend::compileBackendProgram - One of the shaders of the program is not compiled?";
|
qCWarning(gpugllogging) << "GLBackend::compileBackendProgram - One of the shaders of the program is not compiled?";
|
||||||
|
compilationLogs[version].compiled = false;
|
||||||
|
compilationLogs[version].message = std::string("Failed to compile, one of the shaders of the program is not compiled ?");
|
||||||
program.setCompilationLogs(compilationLogs);
|
program.setCompilationLogs(compilationLogs);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +134,7 @@ GLShader* GLBackend::compileBackendProgram(const Shader& program) {
|
||||||
program.setCompilationLogs(compilationLogs);
|
program.setCompilationLogs(compilationLogs);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
compilationLogs[version].compiled = true;
|
||||||
programObject.glprogram = glprogram;
|
programObject.glprogram = glprogram;
|
||||||
|
|
||||||
makeProgramBindings(programObject);
|
makeProgramBindings(programObject);
|
||||||
|
|
|
@ -39,7 +39,7 @@ GLShader* GLShader::sync(GLBackend& backend, const Shader& shader, Shader::Compi
|
||||||
}
|
}
|
||||||
// need to have a gpu object?
|
// need to have a gpu object?
|
||||||
if (shader.isProgram()) {
|
if (shader.isProgram()) {
|
||||||
GLShader* tempObject = backend.compileBackendProgram(shader);
|
GLShader* tempObject = backend.compileBackendProgram(shader, handler);
|
||||||
if (tempObject) {
|
if (tempObject) {
|
||||||
object = tempObject;
|
object = tempObject;
|
||||||
Backend::setGPUObject(shader, object);
|
Backend::setGPUObject(shader, object);
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct ShaderObject {
|
||||||
class GLShader : public GPUObject {
|
class GLShader : public GPUObject {
|
||||||
public:
|
public:
|
||||||
static GLShader* sync(GLBackend& backend, const Shader& shader, Shader::CompilationHandler handler = nullptr);
|
static GLShader* sync(GLBackend& backend, const Shader& shader, Shader::CompilationHandler handler = nullptr);
|
||||||
static bool makeProgram(GLBackend& backend, Shader& shader, const Shader::BindingSet& slotBindings, Shader::CompilationHandler handler = nullptr);
|
static bool makeProgram(GLBackend& backend, Shader& shader, const Shader::BindingSet& slotBindings, Shader::CompilationHandler handler);
|
||||||
|
|
||||||
enum Version {
|
enum Version {
|
||||||
Mono = 0,
|
Mono = 0,
|
||||||
|
|
|
@ -420,7 +420,7 @@ protected:
|
||||||
} _pipeline;
|
} _pipeline;
|
||||||
|
|
||||||
// Backend dependant compilation of the shader
|
// Backend dependant compilation of the shader
|
||||||
virtual GLShader* compileBackendProgram(const Shader& program);
|
virtual GLShader* compileBackendProgram(const Shader& program, Shader::CompilationHandler handler);
|
||||||
virtual GLShader* compileBackendShader(const Shader& shader, Shader::CompilationHandler handler);
|
virtual GLShader* compileBackendShader(const Shader& shader, Shader::CompilationHandler handler);
|
||||||
virtual std::string getBackendShaderHeader() const;
|
virtual std::string getBackendShaderHeader() const;
|
||||||
virtual void makeProgramBindings(ShaderObject& shaderObject);
|
virtual void makeProgramBindings(ShaderObject& shaderObject);
|
||||||
|
|
|
@ -140,7 +140,7 @@ GLShader* GLBackend::compileBackendShader(const Shader& shader, Shader::Compilat
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShader* GLBackend::compileBackendProgram(const Shader& program) {
|
GLShader* GLBackend::compileBackendProgram(const Shader& program, Shader::CompilationHandler handler) {
|
||||||
if (!program.isProgram()) {
|
if (!program.isProgram()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ GLShader* GLBackend::compileBackendProgram(const Shader& program) {
|
||||||
// Let's go through every shaders and make sure they are ready to go
|
// Let's go through every shaders and make sure they are ready to go
|
||||||
std::vector< GLuint > shaderGLObjects;
|
std::vector< GLuint > shaderGLObjects;
|
||||||
for (auto subShader : program.getShaders()) {
|
for (auto subShader : program.getShaders()) {
|
||||||
auto object = GLShader::sync((*this), *subShader);
|
auto object = GLShader::sync((*this), *subShader, handler);
|
||||||
if (object) {
|
if (object) {
|
||||||
shaderGLObjects.push_back(object->_shaderObjects[version].glshader);
|
shaderGLObjects.push_back(object->_shaderObjects[version].glshader);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -262,7 +262,7 @@ protected:
|
||||||
// makeProgramShader(...) make a program shader ready to be used in a Batch.
|
// makeProgramShader(...) make a program shader ready to be used in a Batch.
|
||||||
// It compiles the sub shaders, link them and defines the Slots and their bindings.
|
// It compiles the sub shaders, link them and defines the Slots and their bindings.
|
||||||
// If the shader passed is not a program, nothing happens.
|
// If the shader passed is not a program, nothing happens.
|
||||||
static bool makeProgram(Shader& shader, const Shader::BindingSet& bindings, Shader::CompilationHandler handler = nullptr);
|
static bool makeProgram(Shader& shader, const Shader::BindingSet& bindings, Shader::CompilationHandler handler);
|
||||||
|
|
||||||
static CreateBackend _createBackendCallback;
|
static CreateBackend _createBackendCallback;
|
||||||
static MakeProgram _makeProgramCallback;
|
static MakeProgram _makeProgramCallback;
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Backend : public gpu::Backend {
|
||||||
friend class gpu::Context;
|
friend class gpu::Context;
|
||||||
static void init() {}
|
static void init() {}
|
||||||
static gpu::Backend* createBackend() { return new Backend(); }
|
static gpu::Backend* createBackend() { return new Backend(); }
|
||||||
static bool makeProgram(Shader& shader, const Shader::BindingSet& slotBindings) { return true; }
|
static bool makeProgram(Shader& shader, const Shader::BindingSet& slotBindings, Shader::CompilationHandler handler) { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Backend(bool syncCache) : Parent() { }
|
explicit Backend(bool syncCache) : Parent() { }
|
||||||
|
|
|
@ -200,9 +200,10 @@ public:
|
||||||
std::string fsSource = HMD_REPROJECTION_FRAG;
|
std::string fsSource = HMD_REPROJECTION_FRAG;
|
||||||
GLuint vertexShader { 0 }, fragmentShader { 0 };
|
GLuint vertexShader { 0 }, fragmentShader { 0 };
|
||||||
std::string error;
|
std::string error;
|
||||||
|
std::vector<char> binary;
|
||||||
::gl::compileShader(GL_VERTEX_SHADER, vsSource, "", vertexShader, error);
|
::gl::compileShader(GL_VERTEX_SHADER, vsSource, "", vertexShader, error);
|
||||||
::gl::compileShader(GL_FRAGMENT_SHADER, fsSource, "", fragmentShader, error);
|
::gl::compileShader(GL_FRAGMENT_SHADER, fsSource, "", fragmentShader, error);
|
||||||
_program = ::gl::compileProgram({ { vertexShader, fragmentShader } }, error);
|
_program = ::gl::compileProgram({ { vertexShader, fragmentShader } }, error, binary);
|
||||||
glDeleteShader(vertexShader);
|
glDeleteShader(vertexShader);
|
||||||
glDeleteShader(fragmentShader);
|
glDeleteShader(fragmentShader);
|
||||||
qDebug() << "Rebuild proigram";
|
qDebug() << "Rebuild proigram";
|
||||||
|
|
|
@ -137,12 +137,13 @@ const std::string PIXEL_SHADER_DEFINES{ R"GLSL(
|
||||||
|
|
||||||
void testShaderBuild(const char* vs_src, const char * fs_src) {
|
void testShaderBuild(const char* vs_src, const char * fs_src) {
|
||||||
std::string error;
|
std::string error;
|
||||||
|
std::vector<char> binary;
|
||||||
GLuint vs, fs;
|
GLuint vs, fs;
|
||||||
if (!gl::compileShader(GL_VERTEX_SHADER, vs_src, VERTEX_SHADER_DEFINES, vs, error) ||
|
if (!gl::compileShader(GL_VERTEX_SHADER, vs_src, VERTEX_SHADER_DEFINES, vs, error) ||
|
||||||
!gl::compileShader(GL_FRAGMENT_SHADER, fs_src, PIXEL_SHADER_DEFINES, fs, error)) {
|
!gl::compileShader(GL_FRAGMENT_SHADER, fs_src, PIXEL_SHADER_DEFINES, fs, error)) {
|
||||||
throw std::runtime_error("Failed to compile shader");
|
throw std::runtime_error("Failed to compile shader");
|
||||||
}
|
}
|
||||||
auto pr = gl::compileProgram({ vs, fs }, error);
|
auto pr = gl::compileProgram({ vs, fs }, error, binary);
|
||||||
if (!pr) {
|
if (!pr) {
|
||||||
throw std::runtime_error("Failed to link shader");
|
throw std::runtime_error("Failed to link shader");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue