Unverified Commit 579ccece by John Kessenich Committed by GitHub

Merge pull request #1583 from TiemoJung/fix_dot_int

[HLSL/Spir-V] fix for incorrect spir-v on int dot(int, int)
parents 1bc601c6 b16bea80
......@@ -6914,6 +6914,17 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
// We might need the remaining arguments, e.g. in the EOpFrexp case.
std::vector<spv::Id> callArguments(operands.begin(), operands.begin() + consumedOperands);
id = builder.createBuiltinCall(typeId, extBuiltins >= 0 ? extBuiltins : stdBuiltins, libCall, callArguments);
} else if (opCode == spv::OpDot && !isFloat) {
// int dot(int, int)
// NOTE: never called for scalar/vector1, this is turned into simple mul before this can be reached
const int componentCount = builder.getNumComponents(operands[0]);
spv::Id mulOp = builder.createBinOp(spv::OpIMul, builder.getTypeId(operands[0]), operands[0], operands[1]);
builder.setPrecision(mulOp, precision);
id = builder.createCompositeExtract(mulOp, typeId, 0);
for (int i = 1; i < componentCount; ++i) {
builder.setPrecision(id, precision);
id = builder.createBinOp(spv::OpIAdd, typeId, id, builder.createCompositeExtract(operands[0], typeId, i));
}
} else {
switch (consumedOperands) {
case 0:
......
float4 main() : SV_Target {
int i = 1;
int1 i2 = 2;
int2 i3 = 3;
int3 i4 = 4;
int4 i5 = 5;
i = dot(i, i);
i2 = dot(i2, i2);
i3 = dot(i3, i3);
i4 = dot(i4, i4);
i5 = dot(i5, i5);
return i + i2.xxxx + i3.xyxy + i4.xyzx + i5;
}
\ No newline at end of file
......@@ -400,7 +400,8 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.wavequery.frag", "PixelShaderFunction"},
{"hlsl.wavereduction.comp", "CSMain"},
{"hlsl.wavevote.comp", "CSMain"},
{ "hlsl.type.type.conversion.valid.frag", "main" }
{ "hlsl.type.type.conversion.valid.frag", "main" },
{"hlsl.int.dot.frag", "main"}
}),
FileNameAsCustomTestSuffix
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment