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.cpp6
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.h1
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.inc3
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp8
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/texture_query.cpp76
5 files changed, 86 insertions, 8 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
index 0296f8773..f281c023f 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
@@ -1493,6 +1493,12 @@ Value IREmitter::ImageFetch(const Value& handle, const Value& coords, const Valu
1493 return Inst(op, Flags{info}, handle, coords, offset, lod, multisampling); 1493 return Inst(op, Flags{info}, handle, coords, offset, lod, multisampling);
1494} 1494}
1495 1495
1496Value IREmitter::ImageQueryDimension(const Value& handle, const IR::U32& lod) {
1497 const Opcode op{handle.IsImmediate() ? Opcode::BoundImageQueryDimensions
1498 : Opcode::BindlessImageQueryDimensions};
1499 return Inst(op, handle, lod);
1500}
1501
1496U1 IREmitter::VoteAll(const U1& value) { 1502U1 IREmitter::VoteAll(const U1& value) {
1497 return Inst<U1>(Opcode::VoteAll, value); 1503 return Inst<U1>(Opcode::VoteAll, value);
1498} 1504}
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h
index 446fd7785..771c186d4 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.h
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.h
@@ -239,6 +239,7 @@ public:
239 const F32& dref, const F32& lod, 239 const F32& dref, const F32& lod,
240 const Value& offset, const F32& lod_clamp, 240 const Value& offset, const F32& lod_clamp,
241 TextureInstInfo info); 241 TextureInstInfo info);
242 [[nodiscard]] Value ImageQueryDimension(const Value& handle, const IR::U32& lod);
242 243
243 [[nodiscard]] Value ImageGather(const Value& handle, const Value& coords, const Value& offset, 244 [[nodiscard]] Value ImageGather(const Value& handle, const Value& coords, const Value& offset,
244 const Value& offset2, TextureInstInfo info); 245 const Value& offset2, TextureInstInfo info);
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index e12b92c47..5d7462d76 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -356,6 +356,7 @@ OPCODE(BindlessImageSampleDrefExplicitLod, F32, U32,
356OPCODE(BindlessImageGather, F32x4, U32, Opaque, Opaque, Opaque, ) 356OPCODE(BindlessImageGather, F32x4, U32, Opaque, Opaque, Opaque, )
357OPCODE(BindlessImageGatherDref, F32x4, U32, Opaque, Opaque, Opaque, F32, ) 357OPCODE(BindlessImageGatherDref, F32x4, U32, Opaque, Opaque, Opaque, F32, )
358OPCODE(BindlessImageFetch, F32x4, U32, Opaque, U32, U32, ) 358OPCODE(BindlessImageFetch, F32x4, U32, Opaque, U32, U32, )
359OPCODE(BindlessImageQueryDimensions, U32x4, U32, U32, )
359 360
360OPCODE(BoundImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) 361OPCODE(BoundImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, )
361OPCODE(BoundImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) 362OPCODE(BoundImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, )
@@ -364,6 +365,7 @@ OPCODE(BoundImageSampleDrefExplicitLod, F32, U32,
364OPCODE(BoundImageGather, F32x4, U32, Opaque, Opaque, Opaque, ) 365OPCODE(BoundImageGather, F32x4, U32, Opaque, Opaque, Opaque, )
365OPCODE(BoundImageGatherDref, F32x4, U32, Opaque, Opaque, Opaque, F32, ) 366OPCODE(BoundImageGatherDref, F32x4, U32, Opaque, Opaque, Opaque, F32, )
366OPCODE(BoundImageFetch, F32x4, U32, Opaque, U32, U32, ) 367OPCODE(BoundImageFetch, F32x4, U32, Opaque, U32, U32, )
368OPCODE(BoundImageQueryDimensions, U32x4, U32, U32, )
367 369
368OPCODE(ImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) 370OPCODE(ImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, )
369OPCODE(ImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, ) 371OPCODE(ImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, )
@@ -372,6 +374,7 @@ OPCODE(ImageSampleDrefExplicitLod, F32, U32,
372OPCODE(ImageGather, F32x4, U32, Opaque, Opaque, Opaque, ) 374OPCODE(ImageGather, F32x4, U32, Opaque, Opaque, Opaque, )
373OPCODE(ImageGatherDref, F32x4, U32, Opaque, Opaque, Opaque, F32, ) 375OPCODE(ImageGatherDref, F32x4, U32, Opaque, Opaque, Opaque, F32, )
374OPCODE(ImageFetch, F32x4, U32, Opaque, U32, U32, ) 376OPCODE(ImageFetch, F32x4, U32, Opaque, U32, U32, )
377OPCODE(ImageQueryDimensions, U32x4, U32, U32, )
375 378
376// Warp operations 379// Warp operations
377OPCODE(VoteAll, U1, U1, ) 380OPCODE(VoteAll, U1, U1, )
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
index 788765c21..96ee2e741 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
@@ -373,14 +373,6 @@ void TranslatorVisitor::TXD_b(u64) {
373 ThrowNotImplemented(Opcode::TXD_b); 373 ThrowNotImplemented(Opcode::TXD_b);
374} 374}
375 375
376void TranslatorVisitor::TXQ(u64) {
377 ThrowNotImplemented(Opcode::TXQ);
378}
379
380void TranslatorVisitor::TXQ_b(u64) {
381 ThrowNotImplemented(Opcode::TXQ_b);
382}
383
384void TranslatorVisitor::VABSDIFF(u64) { 376void TranslatorVisitor::VABSDIFF(u64) {
385 ThrowNotImplemented(Opcode::VABSDIFF); 377 ThrowNotImplemented(Opcode::VABSDIFF);
386} 378}
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/texture_query.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_query.cpp
new file mode 100644
index 000000000..e8ea8faeb
--- /dev/null
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/texture_query.cpp
@@ -0,0 +1,76 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <optional>
6
7#include "common/bit_field.h"
8#include "common/common_types.h"
9#include "shader_recompiler/frontend/ir/modifiers.h"
10#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
11
12namespace Shader::Maxwell {
13namespace {
14enum class Mode : u64 {
15 Dimension = 1,
16 TextureType = 2,
17 SamplePos = 5,
18};
19
20IR::Value Query(TranslatorVisitor& v, const IR::U32& handle, Mode mode, IR::Reg src_reg) {
21 switch (mode) {
22 case Mode::Dimension: {
23 const IR::U32 lod{v.X(src_reg)};
24 return v.ir.ImageQueryDimension(handle, lod);
25 }
26 case Mode::TextureType:
27 case Mode::SamplePos:
28 default:
29 throw NotImplementedException("Mode {}", mode);
30 }
31}
32
33void Impl(TranslatorVisitor& v, u64 insn, std::optional<u32> cbuf_offset) {
34 union {
35 u64 raw;
36 BitField<49, 1, u64> nodep;
37 BitField<0, 8, IR::Reg> dest_reg;
38 BitField<8, 8, IR::Reg> src_reg;
39 BitField<22, 3, Mode> mode;
40 BitField<31, 4, u64> mask;
41 } const txq{insn};
42
43 IR::Reg src_reg{txq.src_reg};
44 IR::U32 handle;
45 if (cbuf_offset) {
46 handle = v.ir.Imm32(*cbuf_offset);
47 } else {
48 handle = v.X(src_reg);
49 ++src_reg;
50 }
51 const IR::Value query{Query(v, handle, txq.mode, src_reg)};
52 IR::Reg dest_reg{txq.dest_reg};
53 for (int element = 0; element < 4; ++element) {
54 if (((txq.mask >> element) & 1) == 0) {
55 continue;
56 }
57 v.X(dest_reg, IR::U32{v.ir.CompositeExtract(query, element)});
58 ++dest_reg;
59 }
60}
61} // Anonymous namespace
62
63void TranslatorVisitor::TXQ(u64 insn) {
64 union {
65 u64 raw;
66 BitField<36, 13, u64> cbuf_offset;
67 } const txq{insn};
68
69 Impl(*this, insn, static_cast<u32>(txq.cbuf_offset));
70}
71
72void TranslatorVisitor::TXQ_b(u64 insn) {
73 Impl(*this, insn, std::nullopt);
74}
75
76} // namespace Shader::Maxwell