fixed SPIR-V int->uint conversion
Bug: skia: Change-Id: I31c035ac5839d60521ee9d8f73c879776ef5d22d Reviewed-on: https://skia-review.googlesource.com/24621 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
fc26f3ca5f
commit
925f52d03b
@ -1519,7 +1519,7 @@ SpvId SPIRVCodeGenerator::writeIntConstructor(const Constructor& c, OutputStream
|
||||
this->writeInstruction(SpvOpConvertFToS, this->getType(c.fType), result, parameter,
|
||||
out);
|
||||
} else if (c.fArguments[0]->fType == *fContext.fUInt_Type) {
|
||||
this->writeInstruction(SpvOpSatConvertUToS, this->getType(c.fType), result, parameter,
|
||||
this->writeInstruction(SpvOpBitcast, this->getType(c.fType), result, parameter,
|
||||
out);
|
||||
} else if (c.fArguments[0]->fType == *fContext.fInt_Type) {
|
||||
return parameter;
|
||||
@ -1527,6 +1527,24 @@ SpvId SPIRVCodeGenerator::writeIntConstructor(const Constructor& c, OutputStream
|
||||
return result;
|
||||
}
|
||||
|
||||
SpvId SPIRVCodeGenerator::writeUIntConstructor(const Constructor& c, OutputStream& out) {
|
||||
ASSERT(c.fType == *fContext.fUInt_Type);
|
||||
ASSERT(c.fArguments.size() == 1);
|
||||
ASSERT(c.fArguments[0]->fType.isNumber());
|
||||
SpvId result = this->nextId();
|
||||
SpvId parameter = this->writeExpression(*c.fArguments[0], out);
|
||||
if (c.fArguments[0]->fType == *fContext.fFloat_Type) {
|
||||
this->writeInstruction(SpvOpConvertFToU, this->getType(c.fType), result, parameter,
|
||||
out);
|
||||
} else if (c.fArguments[0]->fType == *fContext.fInt_Type) {
|
||||
this->writeInstruction(SpvOpBitcast, this->getType(c.fType), result, parameter,
|
||||
out);
|
||||
} else if (c.fArguments[0]->fType == *fContext.fUInt_Type) {
|
||||
return parameter;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void SPIRVCodeGenerator::writeUniformScaleMatrix(SpvId id, SpvId diagonal, const Type& type,
|
||||
OutputStream& out) {
|
||||
FloatLiteral zero(fContext, Position(), 0);
|
||||
@ -1642,6 +1660,8 @@ SpvId SPIRVCodeGenerator::writeConstructor(const Constructor& c, OutputStream& o
|
||||
return this->writeFloatConstructor(c, out);
|
||||
} else if (c.fType == *fContext.fInt_Type) {
|
||||
return this->writeIntConstructor(c, out);
|
||||
} else if (c.fType == *fContext.fUInt_Type) {
|
||||
return this->writeUIntConstructor(c, out);
|
||||
}
|
||||
switch (c.fType.kind()) {
|
||||
case Type::kVector_Kind:
|
||||
|
@ -153,6 +153,8 @@ private:
|
||||
|
||||
SpvId writeIntConstructor(const Constructor& c, OutputStream& out);
|
||||
|
||||
SpvId writeUIntConstructor(const Constructor& c, OutputStream& out);
|
||||
|
||||
/**
|
||||
* Writes a matrix with the diagonal entries all equal to the provided expression, and all other
|
||||
* entries equal to zero.
|
||||
|
Loading…
Reference in New Issue
Block a user