summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-05-15 18:16:39 -0300
committerGravatar ameerj2021-07-22 21:51:31 -0400
commit9fb2ea08e84f7194136f5a2f320dd3de04e8ca5d (patch)
treefe1fd5c571c684cd92cffeaef5768a58feae2500 /src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
parentglasm: Implement some graphics instructions on GLASM (diff)
downloadyuzu-9fb2ea08e84f7194136f5a2f320dd3de04e8ca5d.tar.gz
yuzu-9fb2ea08e84f7194136f5a2f320dd3de04e8ca5d.tar.xz
yuzu-9fb2ea08e84f7194136f5a2f320dd3de04e8ca5d.zip
glasm: Initial (broken) implementation of TEX on GLASM
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_glasm_image.cpp')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_image.cpp221
1 files changed, 221 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
index e69de29bb..a32d01925 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp
@@ -0,0 +1,221 @@
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 "shader_recompiler/backend/glasm/emit_context.h"
6#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
7#include "shader_recompiler/frontend/ir/modifiers.h"
8#include "shader_recompiler/frontend/ir/value.h"
9
10namespace Shader::Backend::GLASM {
11
12void EmitBindlessImageSampleImplicitLod(EmitContext&) {
13 throw LogicError("Unreachable instruction");
14}
15
16void EmitBindlessImageSampleExplicitLod(EmitContext&) {
17 throw LogicError("Unreachable instruction");
18}
19
20void EmitBindlessImageSampleDrefImplicitLod(EmitContext&) {
21 throw LogicError("Unreachable instruction");
22}
23
24void EmitBindlessImageSampleDrefExplicitLod(EmitContext&) {
25 throw LogicError("Unreachable instruction");
26}
27
28void EmitBindlessImageGather(EmitContext&) {
29 throw LogicError("Unreachable instruction");
30}
31
32void EmitBindlessImageGatherDref(EmitContext&) {
33 throw LogicError("Unreachable instruction");
34}
35
36void EmitBindlessImageFetch(EmitContext&) {
37 throw LogicError("Unreachable instruction");
38}
39
40void EmitBindlessImageQueryDimensions(EmitContext&) {
41 throw LogicError("Unreachable instruction");
42}
43
44void EmitBindlessImageQueryLod(EmitContext&) {
45 throw LogicError("Unreachable instruction");
46}
47
48void EmitBindlessImageGradient(EmitContext&) {
49 throw LogicError("Unreachable instruction");
50}
51
52void EmitBindlessImageRead(EmitContext&) {
53 throw LogicError("Unreachable instruction");
54}
55
56void EmitBindlessImageWrite(EmitContext&) {
57 throw LogicError("Unreachable instruction");
58}
59
60void EmitBoundImageSampleImplicitLod(EmitContext&) {
61 throw LogicError("Unreachable instruction");
62}
63
64void EmitBoundImageSampleExplicitLod(EmitContext&) {
65 throw LogicError("Unreachable instruction");
66}
67
68void EmitBoundImageSampleDrefImplicitLod(EmitContext&) {
69 throw LogicError("Unreachable instruction");
70}
71
72void EmitBoundImageSampleDrefExplicitLod(EmitContext&) {
73 throw LogicError("Unreachable instruction");
74}
75
76void EmitBoundImageGather(EmitContext&) {
77 throw LogicError("Unreachable instruction");
78}
79
80void EmitBoundImageGatherDref(EmitContext&) {
81 throw LogicError("Unreachable instruction");
82}
83
84void EmitBoundImageFetch(EmitContext&) {
85 throw LogicError("Unreachable instruction");
86}
87
88void EmitBoundImageQueryDimensions(EmitContext&) {
89 throw LogicError("Unreachable instruction");
90}
91
92void EmitBoundImageQueryLod(EmitContext&) {
93 throw LogicError("Unreachable instruction");
94}
95
96void EmitBoundImageGradient(EmitContext&) {
97 throw LogicError("Unreachable instruction");
98}
99
100void EmitBoundImageRead(EmitContext&) {
101 throw LogicError("Unreachable instruction");
102}
103
104void EmitBoundImageWrite(EmitContext&) {
105 throw LogicError("Unreachable instruction");
106}
107
108std::string Texture([[maybe_unused]] EmitContext& ctx, IR::TextureInstInfo info,
109 [[maybe_unused]] const IR::Value& index) {
110 // FIXME
111 return fmt::format("texture[{}]", info.descriptor_index);
112}
113
114void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
115 Register coords, Register bias_lc,
116 [[maybe_unused]] const IR::Value& offset) {
117 const auto info{inst.Flags<IR::TextureInstInfo>()};
118 const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
119 const std::string_view op{info.has_bias ? "TXB" : "TEX"};
120 const std::string_view lod_clamp{info.has_lod_clamp ? ".LODCLAMP" : ""};
121 const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
122 const std::string texture{Texture(ctx, info, index)};
123 const Register ret{ctx.reg_alloc.Define(inst)};
124 // FIXME
125 const bool separate{info.type == TextureType::ColorArrayCube};
126 if (separate) {
127 ctx.Add("{}.F{}{} {},{},{},{},2D;", op, lod_clamp, sparse_mod, ret, coords, bias_lc,
128 texture);
129 } else {
130 ctx.Add("MOV.F {}.w,{}.x;"
131 "{}.F{}{} {},{},{},2D;",
132 coords, bias_lc, op, lod_clamp, sparse_mod, ret, coords, texture);
133 }
134 if (sparse_inst) {
135 const Register sparse_ret{ctx.reg_alloc.Define(*sparse_inst)};
136 ctx.Add("MOV.S {},-1;"
137 "MOV.S {}(NONRESIDENT),0;",
138 sparse_ret, sparse_ret);
139 sparse_inst->Invalidate();
140 }
141}
142
143void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
144 [[maybe_unused]] const IR::Value& index,
145 [[maybe_unused]] Register coords, [[maybe_unused]] Register lod_lc,
146 [[maybe_unused]] const IR::Value& offset) {
147 throw NotImplementedException("GLASM instruction");
148}
149
150void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx,
151 [[maybe_unused]] IR::Inst& inst,
152 [[maybe_unused]] const IR::Value& index,
153 [[maybe_unused]] Register coords,
154 [[maybe_unused]] Register dref,
155 [[maybe_unused]] Register bias_lc,
156 [[maybe_unused]] const IR::Value& offset) {
157 throw NotImplementedException("GLASM instruction");
158}
159
160void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx,
161 [[maybe_unused]] IR::Inst& inst,
162 [[maybe_unused]] const IR::Value& index,
163 [[maybe_unused]] Register coords,
164 [[maybe_unused]] Register dref,
165 [[maybe_unused]] Register lod_lc,
166 [[maybe_unused]] const IR::Value& offset) {
167 throw NotImplementedException("GLASM instruction");
168}
169
170void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
171 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
172 [[maybe_unused]] const IR::Value& offset,
173 [[maybe_unused]] const IR::Value& offset2) {
174 throw NotImplementedException("GLASM instruction");
175}
176
177void EmitImageGatherDref([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
178 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
179 [[maybe_unused]] const IR::Value& offset,
180 [[maybe_unused]] const IR::Value& offset2,
181 [[maybe_unused]] Register dref) {
182 throw NotImplementedException("GLASM instruction");
183}
184
185void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
186 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
187 [[maybe_unused]] Register offset, [[maybe_unused]] Register lod,
188 [[maybe_unused]] Register ms) {
189 throw NotImplementedException("GLASM instruction");
190}
191
192void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
193 [[maybe_unused]] const IR::Value& index,
194 [[maybe_unused]] Register lod) {
195 throw NotImplementedException("GLASM instruction");
196}
197
198void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
199 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords) {
200 throw NotImplementedException("GLASM instruction");
201}
202
203void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
204 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
205 [[maybe_unused]] Register derivates, [[maybe_unused]] Register offset,
206 [[maybe_unused]] Register lod_clamp) {
207 throw NotImplementedException("GLASM instruction");
208}
209
210void EmitImageRead([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
211 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords) {
212 throw NotImplementedException("GLASM instruction");
213}
214
215void EmitImageWrite([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
216 [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords,
217 [[maybe_unused]] Register color) {
218 throw NotImplementedException("GLASM instruction");
219}
220
221} // namespace Shader::Backend::GLASM