diff --git a/libraries/gpu/src/gpu/Shader.cpp b/libraries/gpu/src/gpu/Shader.cpp index 6fef768a08..dcdbff56d2 100755 --- a/libraries/gpu/src/gpu/Shader.cpp +++ b/libraries/gpu/src/gpu/Shader.cpp @@ -64,6 +64,25 @@ Shader::Reflection Shader::getReflection(shader::Dialect dialect, shader::Varian return _source.getReflection(dialect, variant); } + +Shader::Reflection Shader::getReflection() const { + + // FOr sake of convenience i would like to be able to use a "default" dialect that represents the reflection + // of the source of the shader + // What i really want, is a reflection that is designed for the gpu lib interface but we don;t have that yet (glsl45 is the closest to that) + // Until we have an implementation for this, we will return such default reflection from the one available and platform specific + +#if defined(USE_GLES) + auto defaultDialect = shader::Dialect::glsl310es; +#elif defined(Q_OS_MAC) + // Mac only supports 4.1 + auto defaultDialect = shader::Dialect::glsl410; +#else + auto defaultDialect = shader::Dialect::glsl450; +#endif + return getReflection(defaultDialect, shader::Variant::Mono); +} + Shader::~Shader() { } diff --git a/libraries/gpu/src/gpu/Shader.h b/libraries/gpu/src/gpu/Shader.h index 6461437971..f4f37b1815 100755 --- a/libraries/gpu/src/gpu/Shader.h +++ b/libraries/gpu/src/gpu/Shader.h @@ -92,6 +92,7 @@ public: const Shaders& getShaders() const { return _shaders; } Reflection getReflection(shader::Dialect dialect, shader::Variant variant) const; + Reflection getReflection() const; // get the default version of the reflection // Compilation Handler can be passed while compiling a shader (in the makeProgram call) to be able to give the hand to // the caller thread if the compilation fails and to provide a different version of the source for it diff --git a/libraries/render/src/render/ShapePipeline.cpp b/libraries/render/src/render/ShapePipeline.cpp index 9942f1a46c..048e08e959 100644 --- a/libraries/render/src/render/ShapePipeline.cpp +++ b/libraries/render/src/render/ShapePipeline.cpp @@ -86,7 +86,7 @@ void ShapePlumber::addPipeline(const Key& key, const gpu::ShaderPointer& program void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& program, const gpu::StatePointer& state, BatchSetter batchSetter, ItemSetter itemSetter) { ShapeKey key{ filter._flags }; - auto reflection = program->getReflection(shader::Dialect::glsl450, shader::Variant::Mono); + auto reflection = program->getReflection(); auto locations = std::make_shared(); locations->albedoTextureUnit = reflection.validTexture(graphics::slot::texture::MaterialAlbedo); locations->roughnessTextureUnit = reflection.validTexture(graphics::slot::texture::MaterialRoughness);