sirit/src/instructions/group.cpp
comex ab567491e1 Add support for OpGroupNonUniform{All,Any,AllEqual,Ballot}, and fix OpGroupNonUniformShuffleXor.
These Vulkan 1.1 operations can be used in place of
`OpSubgroup{All,Any,AllEqual,Ballot}KHR`, among other things.

For `OpGroupNonUniformShuffleXor`, which was already implemented, turns
out the scope argument needs to be encoded not as an immediate, but as
an id that points to a constant integer.
2020-11-26 17:20:01 -03:00

66 lines
2.2 KiB
C++

/* This file is part of the sirit project.
* Copyright (c) 2019 sirit
* This software may be used and distributed according to the terms of the
* 3-Clause BSD License
*/
#include "sirit/sirit.h"
#include "stream.h"
namespace Sirit {
Id Module::OpSubgroupBallotKHR(Id result_type, Id predicate) {
code->Reserve(4);
return *code << OpId{spv::Op::OpSubgroupBallotKHR, result_type} << predicate << EndOp{};
}
Id Module::OpSubgroupReadInvocationKHR(Id result_type, Id value, Id index) {
code->Reserve(5);
return *code << OpId{spv::Op::OpSubgroupReadInvocationKHR, result_type} << value << index
<< EndOp{};
}
Id Module::OpSubgroupAllKHR(Id result_type, Id predicate) {
code->Reserve(4);
return *code << OpId{spv::Op::OpSubgroupAllKHR, result_type} << predicate << EndOp{};
}
Id Module::OpSubgroupAnyKHR(Id result_type, Id predicate) {
code->Reserve(4);
return *code << OpId{spv::Op::OpSubgroupAnyKHR, result_type} << predicate << EndOp{};
}
Id Module::OpSubgroupAllEqualKHR(Id result_type, Id predicate) {
code->Reserve(4);
return *code << OpId{spv::Op::OpSubgroupAllEqualKHR, result_type} << predicate << EndOp{};
}
Id Module::OpGroupNonUniformShuffleXor(Id result_type, Id scope, Id value, Id mask) {
code->Reserve(6);
return *code << OpId{spv::Op::OpGroupNonUniformShuffleXor, result_type} << scope << value
<< mask << EndOp{};
}
Id Module::OpGroupNonUniformAll(Id result_type, Id scope, Id predicate) {
code->Reserve(5);
return *code << OpId{spv::Op::OpGroupNonUniformAll, result_type} << scope << predicate << EndOp{};
}
Id Module::OpGroupNonUniformAny(Id result_type, Id scope, Id predicate) {
code->Reserve(5);
return *code << OpId{spv::Op::OpGroupNonUniformAny, result_type} << scope << predicate << EndOp{};
}
Id Module::OpGroupNonUniformAllEqual(Id result_type, Id scope, Id value) {
code->Reserve(5);
return *code << OpId{spv::Op::OpGroupNonUniformAllEqual, result_type} << scope << value << EndOp{};
}
Id Module::OpGroupNonUniformBallot(Id result_type, Id scope, Id predicate) {
code->Reserve(5);
return *code << OpId{spv::Op::OpGroupNonUniformBallot, result_type} << scope << predicate << EndOp{};
}
} // namespace Sirit