Last nzsl version update
This commit is contained in:
parent
510ef8c41e
commit
c7b6d83bbc
|
|
@ -11,7 +11,6 @@ external
|
|||
|
||||
struct FragIn
|
||||
{
|
||||
[builtin(fragcoord)] fragcoord: vec4[f32],
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ external
|
|||
|
||||
struct FragIn
|
||||
{
|
||||
[builtin(fragcoord)] fragcoord: vec4[f32]
|
||||
[builtin(frag_coord)] fragcoord: vec4[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct VertOut
|
|||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32],
|
||||
[builtin(fragdepth)] depth: f32
|
||||
[builtin(frag_depth)] depth: f32
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NZSL/FieldOffsets.hpp>
|
||||
#include <NZSL/ShaderLangParser.hpp>
|
||||
#include <NZSL/Parser.hpp>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <Nazara/Renderer.hpp>
|
||||
#include <NZSL/FilesystemModuleResolver.hpp>
|
||||
#include <NZSL/LangWriter.hpp>
|
||||
#include <NZSL/ShaderLangParser.hpp>
|
||||
#include <NZSL/Parser.hpp>
|
||||
#include <NZSL/Ast/SanitizeVisitor.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <array>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderPipeline.hpp>
|
||||
#include <Nazara/Utils/Signal.hpp>
|
||||
#include <NZSL/ShaderModuleResolver.hpp>
|
||||
#include <NZSL/ModuleResolver.hpp>
|
||||
#include <NZSL/Ast/Module.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ namespace Nz
|
|||
using ConfigCallback = std::function<void(Config& config, const std::vector<RenderPipelineInfo::VertexBufferData>& vertexBuffers)>;
|
||||
|
||||
UberShader(nzsl::ShaderStageTypeFlags shaderStages, std::string moduleName);
|
||||
UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::ShaderModuleResolver& moduleResolver, std::string moduleName);
|
||||
UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::ModuleResolver& moduleResolver, std::string moduleName);
|
||||
UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::Ast::ModulePtr shaderModule);
|
||||
~UberShader() = default;
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ namespace Nz
|
|||
private:
|
||||
nzsl::Ast::ModulePtr Validate(const nzsl::Ast::Module& module, std::unordered_map<std::string, Option>* options);
|
||||
|
||||
NazaraSlot(nzsl::ShaderModuleResolver, OnModuleUpdated, m_onShaderModuleUpdated);
|
||||
NazaraSlot(nzsl::ModuleResolver, OnModuleUpdated, m_onShaderModuleUpdated);
|
||||
|
||||
std::unordered_map<Config, std::shared_ptr<ShaderModule>, ConfigHasher, ConfigEqual> m_combinations;
|
||||
std::unordered_map<std::string, Option> m_optionIndexByName;
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLch
|
|||
cb(glUniform3iv, PFNGLUNIFORM3IVPROC) \
|
||||
cb(glUniform4fv, PFNGLUNIFORM4FVPROC) \
|
||||
cb(glUniform4iv, PFNGLUNIFORM4IVPROC) \
|
||||
cb(glUniformBlockBinding, PFNGLUNIFORMBLOCKBINDINGPROC) \
|
||||
cb(glUniformMatrix4fv, PFNGLUNIFORMMATRIX4FVPROC) \
|
||||
cb(glUnmapBuffer, PFNGLUNMAPBUFFERPROC) \
|
||||
cb(glUseProgram, PFNGLUSEPROGRAMPROC) \
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace Nz::GL
|
|||
inline void Link();
|
||||
|
||||
inline void Uniform(GLint uniformLocation, float value) const;
|
||||
inline void UniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) const;
|
||||
|
||||
Program& operator=(const Program&) = delete;
|
||||
Program& operator=(Program&&) noexcept = default;
|
||||
|
|
|
|||
|
|
@ -203,6 +203,14 @@ namespace Nz::GL
|
|||
context.glUniform1f(uniformLocation, value);
|
||||
}
|
||||
|
||||
inline void Program::UniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.glUniformBlockBinding(m_objectId, uniformBlockIndex, uniformBlockBinding);
|
||||
}
|
||||
|
||||
inline GLuint Program::CreateHelper(OpenGLDevice& /*device*/, const Context& context)
|
||||
{
|
||||
return context.glCreateProgram();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <Nazara/Utility/BufferMapper.hpp>
|
||||
#include <Nazara/Utility/MaterialData.hpp>
|
||||
#include <NZSL/FieldOffsets.hpp>
|
||||
#include <NZSL/ShaderLangParser.hpp>
|
||||
#include <NZSL/Parser.hpp>
|
||||
#include <cassert>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <Nazara/Graphics/DepthMaterial.hpp>
|
||||
#include <NZSL/FieldOffsets.hpp>
|
||||
#include <NZSL/ShaderLangParser.hpp>
|
||||
#include <NZSL/Parser.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <Nazara/Utility/BufferMapper.hpp>
|
||||
#include <Nazara/Utility/MaterialData.hpp>
|
||||
#include <NZSL/FieldOffsets.hpp>
|
||||
#include <NZSL/ShaderLangParser.hpp>
|
||||
#include <NZSL/Parser.hpp>
|
||||
#include <cassert>
|
||||
#include <filesystem>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
|||
{
|
||||
}
|
||||
|
||||
UberShader::UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::ShaderModuleResolver& moduleResolver, std::string moduleName) :
|
||||
UberShader::UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::ModuleResolver& moduleResolver, std::string moduleName) :
|
||||
m_shaderStages(shaderStages)
|
||||
{
|
||||
m_shaderModule = moduleResolver.Resolve(moduleName);
|
||||
|
|
@ -27,7 +27,7 @@ namespace Nz
|
|||
|
||||
m_shaderModule = Validate(*m_shaderModule, &m_optionIndexByName);
|
||||
|
||||
m_onShaderModuleUpdated.Connect(moduleResolver.OnModuleUpdated, [this, name = std::move(moduleName)](nzsl::ShaderModuleResolver* resolver, const std::string& updatedModuleName)
|
||||
m_onShaderModuleUpdated.Connect(moduleResolver.OnModuleUpdated, [this, name = std::move(moduleName)](nzsl::ModuleResolver* resolver, const std::string& updatedModuleName)
|
||||
{
|
||||
if (updatedModuleName != name)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace Nz
|
|||
if (!m_program.GetLinkStatus(&errLog))
|
||||
throw std::runtime_error("failed to link program: " + errLog);
|
||||
|
||||
m_flipYUniformLocation = m_program.GetUniformLocation(nzsl::GlslWriter::GetFlipYUniformName());
|
||||
m_flipYUniformLocation = m_program.GetUniformLocation(nzsl::GlslWriter::GetFlipYUniformName().data());
|
||||
if (m_flipYUniformLocation != -1)
|
||||
m_program.Uniform(m_flipYUniformLocation, 1.f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
#include <Nazara/OpenGLRenderer/OpenGLShaderModule.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Utils.hpp>
|
||||
#include <NZSL/ShaderLangLexer.hpp>
|
||||
#include <NZSL/ShaderLangParser.hpp>
|
||||
#include <NZSL/Lexer.hpp>
|
||||
#include <NZSL/Parser.hpp>
|
||||
#include <NZSL/Ast/AstSerializer.hpp>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
|
@ -117,8 +117,17 @@ namespace Nz
|
|||
shader.SetSource(arg.sourceCode.data(), GLint(arg.sourceCode.size()));
|
||||
else if constexpr (std::is_same_v<T, ShaderStatement>)
|
||||
{
|
||||
std::string code = writer.Generate(shaderEntry.stage, *arg.ast, bindingMapping, m_states);
|
||||
shader.SetSource(code.data(), GLint(code.size()));
|
||||
nzsl::GlslWriter::Output output = writer.Generate(shaderEntry.stage, *arg.ast, bindingMapping, m_states);
|
||||
shader.SetSource(output.code.data(), GLint(output.code.size()));
|
||||
|
||||
for (const auto& [name, bindingPoint] : output.explicitUniformBlockBinding)
|
||||
{
|
||||
GLuint blockIndex = program.GetUniformBlockIndex(name);
|
||||
if (blockIndex == GL_INVALID_INDEX)
|
||||
continue;
|
||||
|
||||
program.UniformBlockBinding(blockIndex, bindingPoint);
|
||||
}
|
||||
}
|
||||
else
|
||||
static_assert(AlwaysFalse<T>::value, "non-exhaustive visitor");
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanShaderModule.hpp>
|
||||
#include <NZSL/ShaderLangLexer.hpp>
|
||||
#include <NZSL/ShaderLangParser.hpp>
|
||||
#include <NZSL/Lexer.hpp>
|
||||
#include <NZSL/Parser.hpp>
|
||||
#include <NZSL/SpirvDecoder.hpp>
|
||||
#include <NZSL/SpirvWriter.hpp>
|
||||
#include <NZSL/Ast/AstSerializer.hpp>
|
||||
|
|
|
|||
Loading…
Reference in New Issue