mirror of
https://github.com/yuzu-emu/sirit.git
synced 2024-12-22 14:35:29 +00:00
Merge pull request #2 from GPUCode/master
Implement required ops for Citra
This commit is contained in:
commit
4ab79a8c02
|
@ -256,6 +256,12 @@ public:
|
||||||
*/
|
*/
|
||||||
Id OpPhi(Id result_type, std::span<const Id> operands);
|
Id OpPhi(Id result_type, std::span<const Id> operands);
|
||||||
|
|
||||||
|
template <typename... Ts>
|
||||||
|
requires(...&& std::is_convertible_v<Ts, Id>) Id
|
||||||
|
OpPhi(Id result_type, Ts&&... operands) {
|
||||||
|
return OpPhi(result_type, std::span<const Id>({operands...}));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SSA phi function. This instruction will be revisited when patching phi nodes.
|
* The SSA phi function. This instruction will be revisited when patching phi nodes.
|
||||||
*
|
*
|
||||||
|
@ -365,6 +371,17 @@ public:
|
||||||
/// Make a copy of a vector, with a single, variably selected, component modified.
|
/// Make a copy of a vector, with a single, variably selected, component modified.
|
||||||
Id OpVectorInsertDynamic(Id result_type, Id vector, Id component, Id index);
|
Id OpVectorInsertDynamic(Id result_type, Id vector, Id component, Id index);
|
||||||
|
|
||||||
|
/// Select arbitrary components from two vectors to make a new vector.
|
||||||
|
Id OpVectorShuffle(Id result_type, Id vector_1, Id vector_2, std::span<const Literal> components);
|
||||||
|
|
||||||
|
/// Select arbitrary components from two vectors to make a new vector.
|
||||||
|
template <typename... Ts>
|
||||||
|
requires(...&& std::is_convertible_v<Ts, Literal>) Id
|
||||||
|
OpVectorShuffle(Id result_type, Id vector_1, Id vector_2, Ts&&... components) {
|
||||||
|
const Literal stack_literals[] = {std::forward<Ts>(components)...};
|
||||||
|
return OpVectorShuffle(result_type, vector_1, vector_2, std::span<const Literal>{stack_literals});
|
||||||
|
}
|
||||||
|
|
||||||
/// Make a copy of a composite object, while modifying one part of it.
|
/// Make a copy of a composite object, while modifying one part of it.
|
||||||
Id OpCompositeInsert(Id result_type, Id object, Id composite,
|
Id OpCompositeInsert(Id result_type, Id object, Id composite,
|
||||||
std::span<const Literal> indexes = {});
|
std::span<const Literal> indexes = {});
|
||||||
|
@ -686,6 +703,12 @@ public:
|
||||||
/// Result is the unsigned integer addition of Operand 1 and Operand 2, including its carry.
|
/// Result is the unsigned integer addition of Operand 1 and Operand 2, including its carry.
|
||||||
Id OpIAddCarry(Id result_type, Id operand_1, Id operand_2);
|
Id OpIAddCarry(Id result_type, Id operand_1, Id operand_2);
|
||||||
|
|
||||||
|
/// Multiplication of floating-point vector Operand 1 with scalar Operand 2.
|
||||||
|
Id OpVectorTimesScalar(Id result_type, Id operand_1, Id operand_2);
|
||||||
|
|
||||||
|
/// Dot product of floating-point vector Operand 1 and vector Operand 2.
|
||||||
|
Id OpDot(Id result_type, Id operand_1, Id operand_2);
|
||||||
|
|
||||||
// Extensions
|
// Extensions
|
||||||
|
|
||||||
/// Execute an instruction in an imported set of extended instructions.
|
/// Execute an instruction in an imported set of extended instructions.
|
||||||
|
@ -837,6 +860,18 @@ public:
|
||||||
/// of the pixel specified by offset.
|
/// of the pixel specified by offset.
|
||||||
Id OpInterpolateAtOffset(Id result_type, Id interpolant, Id offset);
|
Id OpInterpolateAtOffset(Id result_type, Id interpolant, Id offset);
|
||||||
|
|
||||||
|
/// Result is the vector in the same direction as x but with a length of 1.
|
||||||
|
Id OpNormalize(Id result_type, Id x);
|
||||||
|
|
||||||
|
/// Result is the cross product of x and y.
|
||||||
|
Id OpCross(Id result_type, Id x, Id y);
|
||||||
|
|
||||||
|
/// Result is the length of vector x.
|
||||||
|
Id OpLength(Id result_type, Id x);
|
||||||
|
|
||||||
|
/// Result is the linear blend of x and y i.e x * (1 - a) + y * a
|
||||||
|
Id OpFMix(Id result_type, Id x, Id y, Id a);
|
||||||
|
|
||||||
// Derivatives
|
// Derivatives
|
||||||
|
|
||||||
/// Same result as either OpDPdxFine or OpDPdxCoarse on the input.
|
/// Same result as either OpDPdxFine or OpDPdxCoarse on the input.
|
||||||
|
|
|
@ -40,5 +40,7 @@ DEFINE_BINARY(OpFMod, spv::Op::OpFMod)
|
||||||
DEFINE_BINARY(OpSRem, spv::Op::OpSRem)
|
DEFINE_BINARY(OpSRem, spv::Op::OpSRem)
|
||||||
DEFINE_BINARY(OpFRem, spv::Op::OpFRem)
|
DEFINE_BINARY(OpFRem, spv::Op::OpFRem)
|
||||||
DEFINE_BINARY(OpIAddCarry, spv::Op::OpIAddCarry)
|
DEFINE_BINARY(OpIAddCarry, spv::Op::OpIAddCarry)
|
||||||
|
DEFINE_BINARY(OpVectorTimesScalar, spv::Op::OpVectorTimesScalar)
|
||||||
|
DEFINE_BINARY(OpDot, spv::Op::OpDot)
|
||||||
|
|
||||||
} // namespace Sirit
|
} // namespace Sirit
|
||||||
|
|
|
@ -72,5 +72,9 @@ DEFINE_UNARY(OpFindUMsb, GLSLstd450FindUMsb)
|
||||||
DEFINE_UNARY(OpInterpolateAtCentroid, GLSLstd450InterpolateAtCentroid)
|
DEFINE_UNARY(OpInterpolateAtCentroid, GLSLstd450InterpolateAtCentroid)
|
||||||
DEFINE_BINARY(OpInterpolateAtSample, GLSLstd450InterpolateAtSample)
|
DEFINE_BINARY(OpInterpolateAtSample, GLSLstd450InterpolateAtSample)
|
||||||
DEFINE_BINARY(OpInterpolateAtOffset, GLSLstd450InterpolateAtOffset)
|
DEFINE_BINARY(OpInterpolateAtOffset, GLSLstd450InterpolateAtOffset)
|
||||||
|
DEFINE_UNARY(OpNormalize, GLSLstd450Normalize)
|
||||||
|
DEFINE_BINARY(OpCross, GLSLstd450Cross)
|
||||||
|
DEFINE_UNARY(OpLength, GLSLstd450Length)
|
||||||
|
DEFINE_TRINARY(OpFMix, GLSLstd450FMix)
|
||||||
|
|
||||||
} // namespace Sirit
|
} // namespace Sirit
|
||||||
|
|
|
@ -46,6 +46,12 @@ Id Module::OpVectorInsertDynamic(Id result_type, Id vector, Id component, Id ind
|
||||||
<< index << EndOp{};
|
<< index << EndOp{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Id Module::OpVectorShuffle(Id result_type, Id vector_1, Id vector_2, std::span<const Literal> components) {
|
||||||
|
code->Reserve(5 + components.size());
|
||||||
|
return *code << OpId{spv::Op::OpVectorShuffle, result_type} << vector_1 << vector_2
|
||||||
|
<< components << EndOp{};
|
||||||
|
}
|
||||||
|
|
||||||
Id Module::OpCompositeInsert(Id result_type, Id object, Id composite,
|
Id Module::OpCompositeInsert(Id result_type, Id object, Id composite,
|
||||||
std::span<const Literal> indexes) {
|
std::span<const Literal> indexes) {
|
||||||
code->Reserve(5 + indexes.size());
|
code->Reserve(5 + indexes.size());
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <span>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
Loading…
Reference in a new issue