diff --git a/src/Nazara/Shader/SpirvAstVisitor.cpp b/src/Nazara/Shader/SpirvAstVisitor.cpp index d34e7fcfd..54f37d4fa 100644 --- a/src/Nazara/Shader/SpirvAstVisitor.cpp +++ b/src/Nazara/Shader/SpirvAstVisitor.cpp @@ -727,16 +727,17 @@ namespace Nz void SpirvAstVisitor::Visit(ShaderAst::SwizzleExpression& node) { - const ShaderAst::ExpressionType& targetExprType = GetExpressionType(node); - assert(IsPrimitiveType(targetExprType)); - - ShaderAst::PrimitiveType targetType = std::get(targetExprType); - UInt32 exprResultId = EvaluateExpression(node.expression); UInt32 resultId = m_writer.AllocateResultId(); + const ShaderAst::ExpressionType& targetExprType = GetExpressionType(node); + if (node.componentCount > 1) { + assert(IsVectorType(targetExprType)); + + const ShaderAst::VectorType& targetType = std::get(targetExprType); + // Swizzling is implemented via SpirvOp::OpVectorShuffle using the same vector twice as operands m_currentBlock->AppendVariadic(SpirvOp::OpVectorShuffle, [&](const auto& appender) { @@ -751,6 +752,10 @@ namespace Nz } else { + assert(IsPrimitiveType(targetExprType)); + + ShaderAst::PrimitiveType targetType = std::get(targetExprType); + // Extract a single component from the vector assert(node.componentCount == 1); diff --git a/src/Nazara/Shader/SpirvConstantCache.cpp b/src/Nazara/Shader/SpirvConstantCache.cpp index e4dd5ad9c..73b9ad522 100644 --- a/src/Nazara/Shader/SpirvConstantCache.cpp +++ b/src/Nazara/Shader/SpirvConstantCache.cpp @@ -546,7 +546,7 @@ namespace Nz auto imageType = Image{ {}, //< qualifier {}, //< depth - {}, //< sampled + true, //< sampled SpirvDim::Dim2D, //< dim SpirvImageFormat::Unknown, //< format BuildType(ShaderAst::PrimitiveType::Float32), //< sampledType @@ -791,9 +791,9 @@ namespace Nz UInt32 sampled; if (arg.sampled.has_value()) - sampled = (*arg.sampled) ? 1 : 0; + sampled = (*arg.sampled) ? 1 : 2; //< Yes/No else - sampled = 2; + sampled = 0; //< Dunno constants.AppendVariadic(SpirvOp::OpTypeImage, [&](const auto& appender) {