summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/frontend')
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.cpp12
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.h4
-rw-r--r--src/shader_recompiler/frontend/ir/modifiers.h5
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.inc1
-rw-r--r--src/shader_recompiler/frontend/ir/value.cpp14
-rw-r--r--src/shader_recompiler/frontend/ir/value.h1
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp28
7 files changed, 19 insertions, 46 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
index b8d36f362..0296f8773 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
@@ -398,16 +398,15 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2) {
398 if (e1.Type() != e2.Type()) { 398 if (e1.Type() != e2.Type()) {
399 throw InvalidArgument("Mismatching types {} and {}", e1.Type(), e2.Type()); 399 throw InvalidArgument("Mismatching types {} and {}", e1.Type(), e2.Type());
400 } 400 }
401 CompositeDecoration decor{};
402 switch (e1.Type()) { 401 switch (e1.Type()) {
403 case Type::U32: 402 case Type::U32:
404 return Inst(Opcode::CompositeConstructU32x2, Flags{decor}, e1, e2); 403 return Inst(Opcode::CompositeConstructU32x2, e1, e2);
405 case Type::F16: 404 case Type::F16:
406 return Inst(Opcode::CompositeConstructF16x2, Flags{decor}, e1, e2); 405 return Inst(Opcode::CompositeConstructF16x2, e1, e2);
407 case Type::F32: 406 case Type::F32:
408 return Inst(Opcode::CompositeConstructF32x2, Flags{decor}, e1, e2); 407 return Inst(Opcode::CompositeConstructF32x2, e1, e2);
409 case Type::F64: 408 case Type::F64:
410 return Inst(Opcode::CompositeConstructF64x2, Flags{decor}, e1, e2); 409 return Inst(Opcode::CompositeConstructF64x2, e1, e2);
411 default: 410 default:
412 ThrowInvalidType(e1.Type()); 411 ThrowInvalidType(e1.Type());
413 } 412 }
@@ -437,7 +436,6 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2, const Valu
437 throw InvalidArgument("Mismatching types {}, {}, {}, and {}", e1.Type(), e2.Type(), 436 throw InvalidArgument("Mismatching types {}, {}, {}, and {}", e1.Type(), e2.Type(),
438 e3.Type(), e4.Type()); 437 e3.Type(), e4.Type());
439 } 438 }
440 CompositeDecoration decor{};
441 switch (e1.Type()) { 439 switch (e1.Type()) {
442 case Type::U32: 440 case Type::U32:
443 return Inst(Opcode::CompositeConstructU32x4, e1, e2, e3, e4); 441 return Inst(Opcode::CompositeConstructU32x4, e1, e2, e3, e4);
@@ -447,8 +445,6 @@ Value IREmitter::CompositeConstruct(const Value& e1, const Value& e2, const Valu
447 return Inst(Opcode::CompositeConstructF32x4, e1, e2, e3, e4); 445 return Inst(Opcode::CompositeConstructF32x4, e1, e2, e3, e4);
448 case Type::F64: 446 case Type::F64:
449 return Inst(Opcode::CompositeConstructF64x4, e1, e2, e3, e4); 447 return Inst(Opcode::CompositeConstructF64x4, e1, e2, e3, e4);
450 case Type::U32x2:
451 return Inst(Opcode::CompositeConstructArrayU32x2, Flags{decor}, e1, e2, e3, e4);
452 default: 448 default:
453 ThrowInvalidType(e1.Type()); 449 ThrowInvalidType(e1.Type());
454 } 450 }
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.h b/src/shader_recompiler/frontend/ir/microinstruction.h
index 77296cfa4..6658dc674 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.h
+++ b/src/shader_recompiler/frontend/ir/microinstruction.h
@@ -101,8 +101,8 @@ public:
101 101
102 template <typename FlagsType> 102 template <typename FlagsType>
103 requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>) 103 requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>)
104 [[nodiscard]] void SetFlags(FlagsType& new_val) noexcept { 104 [[nodiscard]] void SetFlags(FlagsType value) noexcept {
105 std::memcpy(&flags, &new_val, sizeof(new_val)); 105 std::memcpy(&flags, &value, sizeof(value));
106 } 106 }
107 107
108 /// Intrusively store the host definition of this instruction. 108 /// Intrusively store the host definition of this instruction.
diff --git a/src/shader_recompiler/frontend/ir/modifiers.h b/src/shader_recompiler/frontend/ir/modifiers.h
index 20fb14fea..4f09a4b39 100644
--- a/src/shader_recompiler/frontend/ir/modifiers.h
+++ b/src/shader_recompiler/frontend/ir/modifiers.h
@@ -32,11 +32,6 @@ struct FpControl {
32}; 32};
33static_assert(sizeof(FpControl) <= sizeof(u32)); 33static_assert(sizeof(FpControl) <= sizeof(u32));
34 34
35struct CompositeDecoration {
36 bool is_constant{false};
37};
38static_assert(sizeof(CompositeDecoration) <= sizeof(u32));
39
40union TextureInstInfo { 35union TextureInstInfo {
41 u32 raw; 36 u32 raw;
42 BitField<0, 8, TextureType> type; 37 BitField<0, 8, TextureType> type;
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index 3dacd7b6b..e12b92c47 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -126,7 +126,6 @@ OPCODE(CompositeExtractF64x4, F64, F64x
126OPCODE(CompositeInsertF64x2, F64x2, F64x2, F64, U32, ) 126OPCODE(CompositeInsertF64x2, F64x2, F64x2, F64, U32, )
127OPCODE(CompositeInsertF64x3, F64x3, F64x3, F64, U32, ) 127OPCODE(CompositeInsertF64x3, F64x3, F64x3, F64, U32, )
128OPCODE(CompositeInsertF64x4, F64x4, F64x4, F64, U32, ) 128OPCODE(CompositeInsertF64x4, F64x4, F64x4, F64, U32, )
129OPCODE(CompositeConstructArrayU32x2, Opaque, U32x2, U32x2, U32x2, U32x2, )
130 129
131// Select operations 130// Select operations
132OPCODE(SelectU1, U1, U1, U1, U1, ) 131OPCODE(SelectU1, U1, U1, U1, U1, )
diff --git a/src/shader_recompiler/frontend/ir/value.cpp b/src/shader_recompiler/frontend/ir/value.cpp
index 7671fc3d8..e8e4662e7 100644
--- a/src/shader_recompiler/frontend/ir/value.cpp
+++ b/src/shader_recompiler/frontend/ir/value.cpp
@@ -44,20 +44,6 @@ bool Value::IsEmpty() const noexcept {
44 return type == Type::Void; 44 return type == Type::Void;
45} 45}
46 46
47bool Value::IsConstantContainer() const {
48 if (IsImmediate()) {
49 return true;
50 }
51 ValidateAccess(Type::Opaque);
52 auto num_args = inst->NumArgs();
53 for (size_t i = 0; i < num_args; i++) {
54 if (!inst->Arg(i).IsConstantContainer()) {
55 return false;
56 }
57 }
58 return true;
59}
60
61bool Value::IsImmediate() const noexcept { 47bool Value::IsImmediate() const noexcept {
62 if (IsIdentity()) { 48 if (IsIdentity()) {
63 return inst->Arg(0).IsImmediate(); 49 return inst->Arg(0).IsImmediate();
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h
index 5d6e74c14..b27601e70 100644
--- a/src/shader_recompiler/frontend/ir/value.h
+++ b/src/shader_recompiler/frontend/ir/value.h
@@ -38,7 +38,6 @@ public:
38 [[nodiscard]] bool IsImmediate() const noexcept; 38 [[nodiscard]] bool IsImmediate() const noexcept;
39 [[nodiscard]] bool IsLabel() const noexcept; 39 [[nodiscard]] bool IsLabel() const noexcept;
40 [[nodiscard]] IR::Type Type() const noexcept; 40 [[nodiscard]] IR::Type Type() const noexcept;
41 [[nodiscard]] bool IsConstantContainer() const;
42 41
43 [[nodiscard]] IR::Inst* Inst() const; 42 [[nodiscard]] IR::Inst* Inst() const;
44 [[nodiscard]] IR::Block* Label() const; 43 [[nodiscard]] IR::Block* Label() const;
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp
index cdf5cb5c4..b2f9cda46 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_gather.cpp
@@ -106,17 +106,17 @@ IR::Value MakeOffset(TranslatorVisitor& v, IR::Reg& reg, TextureType type) {
106 throw NotImplementedException("Invalid texture type {}", type); 106 throw NotImplementedException("Invalid texture type {}", type);
107} 107}
108 108
109IR::Value MakeOffsetPTP(TranslatorVisitor& v, IR::Reg& reg) { 109std::pair<IR::Value, IR::Value> MakeOffsetPTP(TranslatorVisitor& v, IR::Reg& reg) {
110 const IR::U32 value1{v.X(reg++)}; 110 const IR::U32 value1{v.X(reg++)};
111 const IR::U32 value2{v.X(reg++)}; 111 const IR::U32 value2{v.X(reg++)};
112 const IR::U32 bitsize = v.ir.Imm32(6); 112 const IR::U32 bitsize{v.ir.Imm32(6)};
113 const auto getVector = ([&v, &bitsize](const IR::U32& value, u32 base) { 113 const auto make_vector{[&v, &bitsize](const IR::U32& value) {
114 return v.ir.CompositeConstruct( 114 return v.ir.CompositeConstruct(v.ir.BitFieldExtract(value, v.ir.Imm32(0), bitsize, true),
115 v.ir.BitFieldExtract(value, v.ir.Imm32(base + 0), bitsize, true), 115 v.ir.BitFieldExtract(value, v.ir.Imm32(8), bitsize, true),
116 v.ir.BitFieldExtract(value, v.ir.Imm32(base + 8), bitsize, true)); 116 v.ir.BitFieldExtract(value, v.ir.Imm32(16), bitsize, true),
117 }); 117 v.ir.BitFieldExtract(value, v.ir.Imm32(24), bitsize, true));
118 return v.ir.CompositeConstruct(getVector(value1, 0), getVector(value1, 16), 118 }};
119 getVector(value2, 0), getVector(value2, 16)); 119 return {make_vector(value1), make_vector(value2)};
120} 120}
121 121
122void Impl(TranslatorVisitor& v, u64 insn, ComponentType component_type, OffsetType offset_type, 122void Impl(TranslatorVisitor& v, u64 insn, ComponentType component_type, OffsetType offset_type,
@@ -150,14 +150,12 @@ void Impl(TranslatorVisitor& v, u64 insn, ComponentType component_type, OffsetTy
150 switch (offset_type) { 150 switch (offset_type) {
151 case OffsetType::None: 151 case OffsetType::None:
152 break; 152 break;
153 case OffsetType::AOFFI: { 153 case OffsetType::AOFFI:
154 offset = MakeOffset(v, meta_reg, tld4.type); 154 offset = MakeOffset(v, meta_reg, tld4.type);
155 break; 155 break;
156 } 156 case OffsetType::PTP:
157 case OffsetType::PTP: { 157 std::tie(offset, offset2) = MakeOffsetPTP(v, meta_reg);
158 offset2 = MakeOffsetPTP(v, meta_reg);
159 break; 158 break;
160 }
161 default: 159 default:
162 throw NotImplementedException("Invalid offset type {}", offset_type); 160 throw NotImplementedException("Invalid offset type {}", offset_type);
163 } 161 }
@@ -167,7 +165,7 @@ void Impl(TranslatorVisitor& v, u64 insn, ComponentType component_type, OffsetTy
167 IR::TextureInstInfo info{}; 165 IR::TextureInstInfo info{};
168 info.type.Assign(GetType(tld4.type, tld4.dc != 0)); 166 info.type.Assign(GetType(tld4.type, tld4.dc != 0));
169 info.gather_component.Assign(static_cast<u32>(component_type)); 167 info.gather_component.Assign(static_cast<u32>(component_type));
170 const IR::Value sample{[&]() -> IR::Value { 168 const IR::Value sample{[&] {
171 if (tld4.dc == 0) { 169 if (tld4.dc == 0) {
172 return v.ir.ImageGather(handle, coords, offset, offset2, info); 170 return v.ir.ImageGather(handle, coords, offset, offset2, info);
173 } 171 }