Add initial support for shader binding sets (WIP)
This commit is contained in:
@@ -29,6 +29,7 @@ namespace Nz
|
||||
Layout, //< Struct layout (struct only) - has argument style
|
||||
Location, //< Location (struct member only) - has argument index
|
||||
Option, //< Conditional compilation option - has argument expr
|
||||
Set, //< Binding set (external var only) - has argument index
|
||||
};
|
||||
|
||||
enum class BinaryType
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Nz::ShaderAst
|
||||
struct StructMember
|
||||
{
|
||||
std::optional<BuiltinEntry> builtin;
|
||||
std::optional<unsigned int> locationIndex;
|
||||
std::optional<UInt32> locationIndex;
|
||||
std::string name;
|
||||
ExpressionType type;
|
||||
};
|
||||
|
||||
@@ -252,7 +252,8 @@ namespace Nz::ShaderAst
|
||||
|
||||
struct ExternalVar
|
||||
{
|
||||
std::optional<unsigned int> bindingIndex;
|
||||
std::optional<UInt32> bindingIndex;
|
||||
std::optional<UInt32> bindingSet;
|
||||
std::string name;
|
||||
ExpressionType type;
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Nz
|
||||
class NAZARA_SHADER_API GlslWriter : public ShaderWriter, public ShaderAst::ExpressionVisitorExcept, public ShaderAst::StatementVisitorExcept
|
||||
{
|
||||
public:
|
||||
using BindingMapping = std::unordered_map<UInt64 /* set | binding */, unsigned /*glBinding*/>;
|
||||
struct Environment;
|
||||
using ExtSupportCallback = std::function<bool(const std::string_view& name)>;
|
||||
|
||||
@@ -30,8 +31,8 @@ namespace Nz
|
||||
GlslWriter(GlslWriter&&) = delete;
|
||||
~GlslWriter() = default;
|
||||
|
||||
inline std::string Generate(ShaderAst::Statement& shader, const States& states = {});
|
||||
std::string Generate(std::optional<ShaderStageType> shaderStage, ShaderAst::Statement& shader, const States& states = {});
|
||||
inline std::string Generate(ShaderAst::Statement& shader, const BindingMapping& bindingMapping, const States& states = {});
|
||||
std::string Generate(std::optional<ShaderStageType> shaderStage, ShaderAst::Statement& shader, const BindingMapping& bindingMapping, const States& states = {});
|
||||
|
||||
void SetEnv(Environment environment);
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
inline std::string GlslWriter::Generate(ShaderAst::Statement& shader, const States& states)
|
||||
inline std::string GlslWriter::Generate(ShaderAst::Statement& shader, const BindingMapping& bindingMapping, const States& states)
|
||||
{
|
||||
return Generate(std::nullopt, shader, states);
|
||||
return Generate(std::nullopt, shader, bindingMapping, states);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Nz
|
||||
struct EntryAttribute;
|
||||
struct LayoutAttribute;
|
||||
struct LocationAttribute;
|
||||
struct SetAttribute;
|
||||
|
||||
void Append(const ShaderAst::ExpressionType& type);
|
||||
void Append(const ShaderAst::IdentifierType& identifierType);
|
||||
@@ -57,6 +58,8 @@ namespace Nz
|
||||
template<typename T> void Append(const T& param);
|
||||
template<typename T1, typename T2, typename... Args> void Append(const T1& firstParam, const T2& secondParam, Args&&... params);
|
||||
template<typename... Args> void AppendAttributes(bool appendLine, Args&&... params);
|
||||
template<typename T> void AppendAttributesInternal(bool& first, const T& param);
|
||||
template<typename T1, typename T2, typename... Rest> void AppendAttributesInternal(bool& first, const T1& firstParam, const T2& secondParam, Rest&&... params);
|
||||
void AppendAttribute(BindingAttribute binding);
|
||||
void AppendAttribute(BuiltinAttribute builtin);
|
||||
void AppendAttribute(DepthWriteAttribute depthWrite);
|
||||
@@ -64,6 +67,7 @@ namespace Nz
|
||||
void AppendAttribute(EntryAttribute entry);
|
||||
void AppendAttribute(LayoutAttribute layout);
|
||||
void AppendAttribute(LocationAttribute location);
|
||||
void AppendAttribute(SetAttribute location);
|
||||
void AppendCommentSection(const std::string& section);
|
||||
void AppendField(std::size_t structIndex, const ShaderAst::ExpressionPtr* memberIndices, std::size_t remainingMembers);
|
||||
void AppendHeader();
|
||||
|
||||
Reference in New Issue
Block a user