[spirv] Implement constfReplicant helper

This commit is contained in:
Joshua Ashton 2019-04-27 15:26:37 +01:00 committed by Philip Rebohle
parent 7a956ef8c8
commit e144c17363
2 changed files with 22 additions and 0 deletions

View File

@ -342,6 +342,24 @@ namespace dxvk {
return this->constComposite(vectorTypeId, args.size(), args.data());
}
uint32_t SpirvModule::constfReplicant(
float replicant,
uint32_t count) {
uint32_t value = this->constf32(replicant);
std::array<uint32_t, 4> args = { value, value, value, value };
// Can't make a scalar composite.
if (count == 1)
return args[0];
uint32_t scalarTypeId = this->defFloatType(32);
uint32_t vectorTypeId = this->defVectorType(scalarTypeId, count);
return this->constComposite(vectorTypeId, count, args.data());
}
uint32_t SpirvModule::constComposite(

View File

@ -160,6 +160,10 @@ namespace dxvk {
float y,
float z,
float w);
uint32_t constfReplicant(
float replicant,
uint32_t count);
uint32_t constComposite(
uint32_t typeId,