OpenGLRenderer: Fix explicit texture/block binding (fixes GLSL ES 3.0 support)
This commit is contained in:
@@ -22,17 +22,28 @@ namespace Nz
|
||||
class NAZARA_OPENGLRENDERER_API OpenGLShaderModule : public ShaderModule
|
||||
{
|
||||
public:
|
||||
struct ExplicitBinding;
|
||||
|
||||
OpenGLShaderModule(OpenGLDevice& device, nzsl::ShaderStageTypeFlags shaderStages, const nzsl::Ast::Module& shaderModule, const nzsl::ShaderWriter::States& states = {});
|
||||
OpenGLShaderModule(OpenGLDevice& device, nzsl::ShaderStageTypeFlags shaderStages, ShaderLanguage lang, const void* source, std::size_t sourceSize, const nzsl::ShaderWriter::States& states = {});
|
||||
OpenGLShaderModule(const OpenGLShaderModule&) = delete;
|
||||
OpenGLShaderModule(OpenGLShaderModule&&) noexcept = default;
|
||||
~OpenGLShaderModule() = default;
|
||||
|
||||
nzsl::ShaderStageTypeFlags Attach(GL::Program& program, const nzsl::GlslWriter::BindingMapping& bindingMapping) const;
|
||||
nzsl::ShaderStageTypeFlags Attach(GL::Program& program, const nzsl::GlslWriter::BindingMapping& bindingMapping, std::vector<ExplicitBinding>* explicitBindings) const;
|
||||
|
||||
inline const std::vector<ExplicitBinding>& GetExplicitBindings() const;
|
||||
|
||||
OpenGLShaderModule& operator=(const OpenGLShaderModule&) = delete;
|
||||
OpenGLShaderModule& operator=(OpenGLShaderModule&&) noexcept = default;
|
||||
|
||||
struct ExplicitBinding
|
||||
{
|
||||
std::string name;
|
||||
unsigned int binding;
|
||||
bool isBlock;
|
||||
};
|
||||
|
||||
private:
|
||||
void Create(OpenGLDevice& device, nzsl::ShaderStageTypeFlags shaderStages, const nzsl::Ast::Module& shaderModule, const nzsl::ShaderWriter::States& states);
|
||||
|
||||
@@ -56,6 +67,7 @@ namespace Nz
|
||||
|
||||
OpenGLDevice& m_device;
|
||||
nzsl::ShaderWriter::States m_states;
|
||||
std::vector<ExplicitBinding> m_explicitBindings;
|
||||
std::vector<Shader> m_shaders;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline auto OpenGLShaderModule::GetExplicitBindings() const -> const std::vector<ExplicitBinding>&
|
||||
{
|
||||
return m_explicitBindings;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Nz::GL
|
||||
inline void Link();
|
||||
|
||||
inline void Uniform(GLint uniformLocation, float value) const;
|
||||
inline void Uniform(GLint uniformLocation, int value) const;
|
||||
inline void UniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) const;
|
||||
|
||||
Program& operator=(const Program&) = delete;
|
||||
|
||||
@@ -203,6 +203,15 @@ namespace Nz::GL
|
||||
context.glUniform1f(uniformLocation, value);
|
||||
}
|
||||
|
||||
inline void Program::Uniform(GLint uniformLocation, int value) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.BindProgram(m_objectId);
|
||||
context.glUniform1i(uniformLocation, value);
|
||||
}
|
||||
|
||||
inline void Program::UniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
|
||||
Reference in New Issue
Block a user