shader: Refactor PTP and other minor changes
This commit is contained in:
parent
b5db38f50e
commit
d9c5bd9509
14 changed files with 67 additions and 123 deletions
|
@ -398,16 +398,15 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2) {
|
|||
if (e1.Type() != e2.Type()) {
|
||||
throw InvalidArgument("Mismatching types {} and {}", e1.Type(), e2.Type());
|
||||
}
|
||||
CompositeDecoration decor{};
|
||||
switch (e1.Type()) {
|
||||
case Type::U32:
|
||||
return Inst(Opcode::CompositeConstructU32x2, Flags{decor}, e1, e2);
|
||||
return Inst(Opcode::CompositeConstructU32x2, e1, e2);
|
||||
case Type::F16:
|
||||
return Inst(Opcode::CompositeConstructF16x2, Flags{decor}, e1, e2);
|
||||
return Inst(Opcode::CompositeConstructF16x2, e1, e2);
|
||||
case Type::F32:
|
||||
return Inst(Opcode::CompositeConstructF32x2, Flags{decor}, e1, e2);
|
||||
return Inst(Opcode::CompositeConstructF32x2, e1, e2);
|
||||
case Type::F64:
|
||||
return Inst(Opcode::CompositeConstructF64x2, Flags{decor}, e1, e2);
|
||||
return Inst(Opcode::CompositeConstructF64x2, e1, e2);
|
||||
default:
|
||||
ThrowInvalidType(e1.Type());
|
||||
}
|
||||
|
@ -437,7 +436,6 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2, const Valu
|
|||
throw InvalidArgument("Mismatching types {}, {}, {}, and {}", e1.Type(), e2.Type(),
|
||||
e3.Type(), e4.Type());
|
||||
}
|
||||
CompositeDecoration decor{};
|
||||
switch (e1.Type()) {
|
||||
case Type::U32:
|
||||
return Inst(Opcode::CompositeConstructU32x4, e1, e2, e3, e4);
|
||||
|
@ -447,8 +445,6 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2, const Valu
|
|||
return Inst(Opcode::CompositeConstructF32x4, e1, e2, e3, e4);
|
||||
case Type::F64:
|
||||
return Inst(Opcode::CompositeConstructF64x4, e1, e2, e3, e4);
|
||||
case Type::U32x2:
|
||||
return Inst(Opcode::CompositeConstructArrayU32x2, Flags{decor}, e1, e2, e3, e4);
|
||||
default:
|
||||
ThrowInvalidType(e1.Type());
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ public:
|
|||
|
||||
template <typename FlagsType>
|
||||
requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>)
|
||||
[[nodiscard]] void SetFlags(FlagsType& new_val) noexcept {
|
||||
std::memcpy(&flags, &new_val, sizeof(new_val));
|
||||
[[nodiscard]] void SetFlags(FlagsType value) noexcept {
|
||||
std::memcpy(&flags, &value, sizeof(value));
|
||||
}
|
||||
|
||||
/// Intrusively store the host definition of this instruction.
|
||||
|
|
|
@ -32,11 +32,6 @@ struct FpControl {
|
|||
};
|
||||
static_assert(sizeof(FpControl) <= sizeof(u32));
|
||||
|
||||
struct CompositeDecoration {
|
||||
bool is_constant{false};
|
||||
};
|
||||
static_assert(sizeof(CompositeDecoration) <= sizeof(u32));
|
||||
|
||||
union TextureInstInfo {
|
||||
u32 raw;
|
||||
BitField<0, 8, TextureType> type;
|
||||
|
|
|
@ -126,7 +126,6 @@ OPCODE(CompositeExtractF64x4, F64, F64x
|
|||
OPCODE(CompositeInsertF64x2, F64x2, F64x2, F64, U32, )
|
||||
OPCODE(CompositeInsertF64x3, F64x3, F64x3, F64, U32, )
|
||||
OPCODE(CompositeInsertF64x4, F64x4, F64x4, F64, U32, )
|
||||
OPCODE(CompositeConstructArrayU32x2, Opaque, U32x2, U32x2, U32x2, U32x2, )
|
||||
|
||||
// Select operations
|
||||
OPCODE(SelectU1, U1, U1, U1, U1, )
|
||||
|
|
|
@ -44,20 +44,6 @@ bool Value::IsEmpty() const noexcept {
|
|||
return type == Type::Void;
|
||||
}
|
||||
|
||||
bool Value::IsConstantContainer() const {
|
||||
if (IsImmediate()) {
|
||||
return true;
|
||||
}
|
||||
ValidateAccess(Type::Opaque);
|
||||
auto num_args = inst->NumArgs();
|
||||
for (size_t i = 0; i < num_args; i++) {
|
||||
if (!inst->Arg(i).IsConstantContainer()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Value::IsImmediate() const noexcept {
|
||||
if (IsIdentity()) {
|
||||
return inst->Arg(0).IsImmediate();
|
||||
|
|
|
@ -38,7 +38,6 @@ public:
|
|||
[[nodiscard]] bool IsImmediate() const noexcept;
|
||||
[[nodiscard]] bool IsLabel() const noexcept;
|
||||
[[nodiscard]] IR::Type Type() const noexcept;
|
||||
[[nodiscard]] bool IsConstantContainer() const;
|
||||
|
||||
[[nodiscard]] IR::Inst* Inst() const;
|
||||
[[nodiscard]] IR::Block* Label() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue