Shader: Rework Swizzle and add support for swizzle store in SPIRV

This commit is contained in:
Jérôme Leclercq
2021-12-21 14:30:47 +01:00
parent e43a638112
commit 837b72f68e
11 changed files with 151 additions and 102 deletions

View File

@@ -11,6 +11,7 @@
#include <Nazara/Shader/Config.hpp>
#include <Nazara/Shader/SpirvData.hpp>
#include <Nazara/Shader/Ast/AstExpressionVisitorExcept.hpp>
#include <Nazara/Shader/Ast/Enums.hpp>
namespace Nz
{
@@ -37,21 +38,23 @@ namespace Nz
SpirvExpressionStore& operator=(SpirvExpressionStore&&) = delete;
private:
struct LocalVar
{
std::string varName;
};
struct Pointer
{
SpirvStorageClass storage;
UInt32 pointerId;
};
struct SwizzledPointer : Pointer
{
ShaderAst::VectorType swizzledType;
std::array<UInt32, 4> swizzleIndices;
std::size_t componentCount;
};
SpirvAstVisitor& m_visitor;
SpirvBlock& m_block;
SpirvWriter& m_writer;
std::variant<std::monostate, LocalVar, Pointer> m_value;
std::variant<std::monostate, Pointer, SwizzledPointer> m_value;
};
}