Fix step & smoothstep on Vulkan

Both of these have variants with mixed scalar/vector parameters. Ensure
that all parameters are vectorized, or we fail SPIR-V validation.

Bug: skia:10913
Change-Id: I1a5be7fc02695e4c7047b5b9c3c08d12b2071e21
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334896
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
Brian Osman 2020-11-13 16:32:52 -05:00 committed by Skia Commit-Bot
parent 053739dfa8
commit 6ba3be1d96
2 changed files with 18 additions and 2 deletions

View File

@ -77,8 +77,8 @@ void SPIRVCodeGenerator::setupIntrinsics() {
fIntrinsicMap[String("dot")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDot,
SpvOpUndef, SpvOpUndef, SpvOpUndef);
fIntrinsicMap[String("mix")] = SPECIAL(Mix);
fIntrinsicMap[String("step")] = ALL_GLSL(Step);
fIntrinsicMap[String("smoothstep")] = ALL_GLSL(SmoothStep);
fIntrinsicMap[String("step")] = SPECIAL(Step);
fIntrinsicMap[String("smoothstep")] = SPECIAL(SmoothStep);
fIntrinsicMap[String("fma")] = ALL_GLSL(Fma);
fIntrinsicMap[String("frexp")] = ALL_GLSL(Frexp);
fIntrinsicMap[String("ldexp")] = ALL_GLSL(Ldexp);
@ -1019,6 +1019,20 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
GLSLstd450UClamp, spvArgs, out);
break;
}
case kSmoothStep_SpecialIntrinsic: {
std::vector<SpvId> args = this->vectorize(arguments, out);
SkASSERT(args.size() == 3);
this->writeGLSLExtendedInstruction(callType, result, GLSLstd450SmoothStep, SpvOpUndef,
SpvOpUndef, args, out);
break;
}
case kStep_SpecialIntrinsic: {
std::vector<SpvId> args = this->vectorize(arguments, out);
SkASSERT(args.size() == 2);
this->writeGLSLExtendedInstruction(callType, result, GLSLstd450Step, SpvOpUndef,
SpvOpUndef, args, out);
break;
}
}
return result;
}

View File

@ -140,6 +140,8 @@ private:
kDFdy_SpecialIntrinsic,
kSaturate_SpecialIntrinsic,
kSampledImage_SpecialIntrinsic,
kSmoothStep_SpecialIntrinsic,
kStep_SpecialIntrinsic,
kSubpassLoad_SpecialIntrinsic,
kTexture_SpecialIntrinsic,
};