Shader: Fix SpirV generation for Swizzle expressions
+ fix OpSampledImage
This commit is contained in:
parent
bfb93bc925
commit
eb67990b7b
|
|
@ -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<ShaderAst::PrimitiveType>(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<ShaderAst::VectorType>(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<ShaderAst::PrimitiveType>(targetExprType);
|
||||
|
||||
// Extract a single component from the vector
|
||||
assert(node.componentCount == 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue