Use the correct type for the constant for matrix/scalar division
authorNeil Roberts <nroberts@igalia.com>
Tue, 13 Mar 2018 09:57:59 +0000 (10:57 +0100)
committerNeil Roberts <nroberts@igalia.com>
Tue, 13 Mar 2018 12:50:56 +0000 (13:50 +0100)
commiteddb1318ae125d5d963bec1c00d762fa62a9529a
tree4881336848f99d955efdcf23bd739a28f8c1875a
parent2ad4737dc2bde938a0d121fca040af66b7b8a35d
Use the correct type for the constant for matrix/scalar division

When a matrix is divided by a scalar it tries to take the reciprocal
of the scalar to convert the operation into a multiply. However it was
always doing this by making a 32-bit constant. If the scalar is a
double then this would end up making an FDiv instruction with
different types in the operands.

This patch adds a helper method called makeFpConstant which makes a
floating-point constant of the given type. The code to take the
reciprocal now uses it to make the same type as the result.

Fixes https://github.com/KhronosGroup/glslang/issues/1278
SPIRV/GlslangToSpv.cpp
SPIRV/SpvBuilder.cpp
SPIRV/SpvBuilder.h