diff options
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_glasm_image.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp index 4d146d34e..7f2cf052a 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | |||
| @@ -112,24 +112,46 @@ static std::string Texture([[maybe_unused]] EmitContext& ctx, IR::TextureInstInf | |||
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 114 | void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 115 | Register coords, Register bias_lc, | 115 | const IR::Value& coord, Register bias_lc, |
| 116 | [[maybe_unused]] const IR::Value& offset) { | 116 | [[maybe_unused]] const IR::Value& offset) { |
| 117 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 117 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 118 | const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; | 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" : ""}; | 119 | const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""}; |
| 120 | const std::string_view lod_clamp_mod{info.has_lod_clamp ? ".LODCLAMP" : ""}; | ||
| 121 | const std::string_view type{"2D"}; // FIXME | ||
| 122 | const std::string texture{Texture(ctx, info, index)}; | 122 | const std::string texture{Texture(ctx, info, index)}; |
| 123 | |||
| 124 | std::string coord_vec{fmt::to_string(Register{ctx.reg_alloc.Consume(coord)})}; | ||
| 125 | if (coord.InstRecursive()->HasUses()) { | ||
| 126 | // Move non-dead coords to a separate register, although this should never happen because | ||
| 127 | // vectors are only assembled for immediate texture instructions | ||
| 128 | ctx.Add("MOV.F RC,{};", coord_vec); | ||
| 129 | coord_vec = "RC"; | ||
| 130 | } | ||
| 123 | const Register ret{ctx.reg_alloc.Define(inst)}; | 131 | const Register ret{ctx.reg_alloc.Define(inst)}; |
| 124 | // FIXME | 132 | if (info.has_bias) { |
| 125 | const bool separate{info.type == TextureType::ColorArrayCube}; | 133 | if (info.type == TextureType::ColorArrayCube) { |
| 126 | if (separate) { | 134 | ctx.Add("TXB.F{}{} {},{},{},{},ARRAYCUBE;", lod_clamp_mod, sparse_mod, ret, coord_vec, |
| 127 | ctx.Add("{}.F{}{} {},{},{},{},2D;", op, lod_clamp, sparse_mod, ret, coords, bias_lc, | 135 | bias_lc, texture); |
| 128 | texture); | 136 | } else { |
| 137 | if (info.has_lod_clamp) { | ||
| 138 | ctx.Add("MOV.F {}.w,{}.x;" | ||
| 139 | "TXB.F.LODCLAMP{} {},{},{}.y,{},{};", | ||
| 140 | coord_vec, bias_lc, sparse_mod, ret, coord_vec, bias_lc, texture, type); | ||
| 141 | } else { | ||
| 142 | ctx.Add("MOV.F {}.w,{}.x;" | ||
| 143 | "TXB.F{} {},{},{},{};", | ||
| 144 | coord_vec, bias_lc, sparse_mod, ret, coord_vec, texture, type); | ||
| 145 | } | ||
| 146 | } | ||
| 129 | } else { | 147 | } else { |
| 130 | ctx.Add("MOV.F {}.w,{}.x;" | 148 | if (info.has_lod_clamp && info.type == TextureType::ColorArrayCube) { |
| 131 | "{}.F{}{} {},{},{},2D;", | 149 | ctx.Add("TEX.F.LODCLAMP{} {},{},{},{},ARRAYCUBE;", sparse_mod, ret, coord_vec, bias_lc, |
| 132 | coords, bias_lc, op, lod_clamp, sparse_mod, ret, coords, texture); | 150 | texture); |
| 151 | } else { | ||
| 152 | ctx.Add("TEX.F{}{} {},{},{},{};", lod_clamp_mod, sparse_mod, ret, coord_vec, texture, | ||
| 153 | type); | ||
| 154 | } | ||
| 133 | } | 155 | } |
| 134 | if (sparse_inst) { | 156 | if (sparse_inst) { |
| 135 | const Register sparse_ret{ctx.reg_alloc.Define(*sparse_inst)}; | 157 | const Register sparse_ret{ctx.reg_alloc.Define(*sparse_inst)}; |
| @@ -142,7 +164,7 @@ void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Valu | |||
| 142 | 164 | ||
| 143 | void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 165 | void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 144 | [[maybe_unused]] const IR::Value& index, | 166 | [[maybe_unused]] const IR::Value& index, |
| 145 | [[maybe_unused]] Register coords, [[maybe_unused]] Register lod_lc, | 167 | [[maybe_unused]] Register coord, [[maybe_unused]] Register lod_lc, |
| 146 | [[maybe_unused]] const IR::Value& offset) { | 168 | [[maybe_unused]] const IR::Value& offset) { |
| 147 | throw NotImplementedException("GLASM instruction"); | 169 | throw NotImplementedException("GLASM instruction"); |
| 148 | } | 170 | } |
| @@ -150,8 +172,7 @@ void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unuse | |||
| 150 | void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx, | 172 | void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx, |
| 151 | [[maybe_unused]] IR::Inst& inst, | 173 | [[maybe_unused]] IR::Inst& inst, |
| 152 | [[maybe_unused]] const IR::Value& index, | 174 | [[maybe_unused]] const IR::Value& index, |
| 153 | [[maybe_unused]] Register coords, | 175 | [[maybe_unused]] Register coord, [[maybe_unused]] Register dref, |
| 154 | [[maybe_unused]] Register dref, | ||
| 155 | [[maybe_unused]] Register bias_lc, | 176 | [[maybe_unused]] Register bias_lc, |
| 156 | [[maybe_unused]] const IR::Value& offset) { | 177 | [[maybe_unused]] const IR::Value& offset) { |
| 157 | throw NotImplementedException("GLASM instruction"); | 178 | throw NotImplementedException("GLASM instruction"); |
| @@ -160,22 +181,21 @@ void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx, | |||
| 160 | void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, | 181 | void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, |
| 161 | [[maybe_unused]] IR::Inst& inst, | 182 | [[maybe_unused]] IR::Inst& inst, |
| 162 | [[maybe_unused]] const IR::Value& index, | 183 | [[maybe_unused]] const IR::Value& index, |
| 163 | [[maybe_unused]] Register coords, | 184 | [[maybe_unused]] Register coord, [[maybe_unused]] Register dref, |
| 164 | [[maybe_unused]] Register dref, | ||
| 165 | [[maybe_unused]] Register lod_lc, | 185 | [[maybe_unused]] Register lod_lc, |
| 166 | [[maybe_unused]] const IR::Value& offset) { | 186 | [[maybe_unused]] const IR::Value& offset) { |
| 167 | throw NotImplementedException("GLASM instruction"); | 187 | throw NotImplementedException("GLASM instruction"); |
| 168 | } | 188 | } |
| 169 | 189 | ||
| 170 | void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 190 | void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 171 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | 191 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord, |
| 172 | [[maybe_unused]] const IR::Value& offset, | 192 | [[maybe_unused]] const IR::Value& offset, |
| 173 | [[maybe_unused]] const IR::Value& offset2) { | 193 | [[maybe_unused]] const IR::Value& offset2) { |
| 174 | throw NotImplementedException("GLASM instruction"); | 194 | throw NotImplementedException("GLASM instruction"); |
| 175 | } | 195 | } |
| 176 | 196 | ||
| 177 | void EmitImageGatherDref([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 197 | void EmitImageGatherDref([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 178 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | 198 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord, |
| 179 | [[maybe_unused]] const IR::Value& offset, | 199 | [[maybe_unused]] const IR::Value& offset, |
| 180 | [[maybe_unused]] const IR::Value& offset2, | 200 | [[maybe_unused]] const IR::Value& offset2, |
| 181 | [[maybe_unused]] Register dref) { | 201 | [[maybe_unused]] Register dref) { |
| @@ -183,7 +203,7 @@ void EmitImageGatherDref([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR: | |||
| 183 | } | 203 | } |
| 184 | 204 | ||
| 185 | void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 205 | void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 186 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | 206 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord, |
| 187 | [[maybe_unused]] Register offset, [[maybe_unused]] Register lod, | 207 | [[maybe_unused]] Register offset, [[maybe_unused]] Register lod, |
| 188 | [[maybe_unused]] Register ms) { | 208 | [[maybe_unused]] Register ms) { |
| 189 | throw NotImplementedException("GLASM instruction"); | 209 | throw NotImplementedException("GLASM instruction"); |
| @@ -196,24 +216,24 @@ void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused] | |||
| 196 | } | 216 | } |
| 197 | 217 | ||
| 198 | void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 218 | void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 199 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords) { | 219 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord) { |
| 200 | throw NotImplementedException("GLASM instruction"); | 220 | throw NotImplementedException("GLASM instruction"); |
| 201 | } | 221 | } |
| 202 | 222 | ||
| 203 | void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 223 | void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 204 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | 224 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord, |
| 205 | [[maybe_unused]] Register derivates, [[maybe_unused]] Register offset, | 225 | [[maybe_unused]] Register derivates, [[maybe_unused]] Register offset, |
| 206 | [[maybe_unused]] Register lod_clamp) { | 226 | [[maybe_unused]] Register lod_clamp) { |
| 207 | throw NotImplementedException("GLASM instruction"); | 227 | throw NotImplementedException("GLASM instruction"); |
| 208 | } | 228 | } |
| 209 | 229 | ||
| 210 | void EmitImageRead([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 230 | void EmitImageRead([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 211 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords) { | 231 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord) { |
| 212 | throw NotImplementedException("GLASM instruction"); | 232 | throw NotImplementedException("GLASM instruction"); |
| 213 | } | 233 | } |
| 214 | 234 | ||
| 215 | void EmitImageWrite([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 235 | void EmitImageWrite([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |
| 216 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coords, | 236 | [[maybe_unused]] const IR::Value& index, [[maybe_unused]] Register coord, |
| 217 | [[maybe_unused]] Register color) { | 237 | [[maybe_unused]] Register color) { |
| 218 | throw NotImplementedException("GLASM instruction"); | 238 | throw NotImplementedException("GLASM instruction"); |
| 219 | } | 239 | } |