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 | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp index 9da4da331..7b95505e2 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | |||
| @@ -40,52 +40,51 @@ struct ScopedRegister { | |||
| 40 | Register reg; | 40 | Register reg; |
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | std::string Texture([[maybe_unused]] EmitContext& ctx, IR::TextureInstInfo info, | 43 | std::string Texture(EmitContext& ctx, IR::TextureInstInfo info, |
| 44 | [[maybe_unused]] const IR::Value& index) { | 44 | [[maybe_unused]] const IR::Value& index) { |
| 45 | // FIXME | 45 | // FIXME: indexed reads |
| 46 | return fmt::format("texture[{}]", info.descriptor_index); | 46 | return fmt::format("texture[{}]", ctx.texture_bindings.at(info.descriptor_index)); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | std::string_view TextureType(IR::TextureInstInfo info) { | 49 | std::string_view TextureType(IR::TextureInstInfo info) { |
| 50 | switch (info.type) { | 50 | if (info.is_depth) { |
| 51 | case TextureType::Color1D: | 51 | switch (info.type) { |
| 52 | return "1D"; | 52 | case TextureType::Color1D: |
| 53 | case TextureType::ColorArray1D: | 53 | return "SHADOW1D"; |
| 54 | return "ARRAY1D"; | 54 | case TextureType::ColorArray1D: |
| 55 | case TextureType::Color2D: | 55 | return "SHADOWARRAY1D"; |
| 56 | return "2D"; | 56 | case TextureType::Color2D: |
| 57 | case TextureType::ColorArray2D: | 57 | return "SHADOW2D"; |
| 58 | return "ARRAY2D"; | 58 | case TextureType::ColorArray2D: |
| 59 | case TextureType::Color3D: | 59 | return "SHADOWARRAY2D"; |
| 60 | return "3D"; | 60 | case TextureType::Color3D: |
| 61 | case TextureType::ColorCube: | 61 | return "SHADOW3D"; |
| 62 | return "CUBE"; | 62 | case TextureType::ColorCube: |
| 63 | case TextureType::ColorArrayCube: | 63 | return "SHADOWCUBE"; |
| 64 | return "ARRAYCUBE"; | 64 | case TextureType::ColorArrayCube: |
| 65 | case TextureType::Buffer: | 65 | return "SHADOWARRAYCUBE"; |
| 66 | return "BUFFER"; | 66 | case TextureType::Buffer: |
| 67 | } | 67 | return "SHADOWBUFFER"; |
| 68 | throw InvalidArgument("Invalid texture type {}", info.type.Value()); | 68 | } |
| 69 | } | 69 | } else { |
| 70 | 70 | switch (info.type) { | |
| 71 | std::string_view ShadowTextureType(IR::TextureInstInfo info) { | 71 | case TextureType::Color1D: |
| 72 | switch (info.type) { | 72 | return "1D"; |
| 73 | case TextureType::Color1D: | 73 | case TextureType::ColorArray1D: |
| 74 | return "SHADOW1D"; | 74 | return "ARRAY1D"; |
| 75 | case TextureType::ColorArray1D: | 75 | case TextureType::Color2D: |
| 76 | return "SHADOWARRAY1D"; | 76 | return "2D"; |
| 77 | case TextureType::Color2D: | 77 | case TextureType::ColorArray2D: |
| 78 | return "SHADOW2D"; | 78 | return "ARRAY2D"; |
| 79 | case TextureType::ColorArray2D: | 79 | case TextureType::Color3D: |
| 80 | return "SHADOWARRAY2D"; | 80 | return "3D"; |
| 81 | case TextureType::Color3D: | 81 | case TextureType::ColorCube: |
| 82 | return "SHADOW3D"; | 82 | return "CUBE"; |
| 83 | case TextureType::ColorCube: | 83 | case TextureType::ColorArrayCube: |
| 84 | return "SHADOWCUBE"; | 84 | return "ARRAYCUBE"; |
| 85 | case TextureType::ColorArrayCube: | 85 | case TextureType::Buffer: |
| 86 | return "SHADOWARRAYCUBE"; | 86 | return "BUFFER"; |
| 87 | case TextureType::Buffer: | 87 | } |
| 88 | return "SHADOWBUFFER"; | ||
| 89 | } | 88 | } |
| 90 | throw InvalidArgument("Invalid texture type {}", info.type.Value()); | 89 | throw InvalidArgument("Invalid texture type {}", info.type.Value()); |
| 91 | } | 90 | } |
| @@ -217,7 +216,7 @@ void EmitImageSampleDrefImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR:: | |||
| 217 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 216 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 218 | const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; | 217 | const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; |
| 219 | const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""}; | 218 | const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""}; |
| 220 | const std::string_view type{ShadowTextureType(info)}; | 219 | const std::string_view type{TextureType(info)}; |
| 221 | const std::string texture{Texture(ctx, info, index)}; | 220 | const std::string texture{Texture(ctx, info, index)}; |
| 222 | const std::string offset_vec{Offset(ctx, offset)}; | 221 | const std::string offset_vec{Offset(ctx, offset)}; |
| 223 | const auto [coord_vec, coord_alloc]{Coord(ctx, coord)}; | 222 | const auto [coord_vec, coord_alloc]{Coord(ctx, coord)}; |
| @@ -319,7 +318,7 @@ void EmitImageSampleDrefExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR:: | |||
| 319 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 318 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 320 | const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; | 319 | const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; |
| 321 | const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""}; | 320 | const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""}; |
| 322 | const std::string_view type{ShadowTextureType(info)}; | 321 | const std::string_view type{TextureType(info)}; |
| 323 | const std::string texture{Texture(ctx, info, index)}; | 322 | const std::string texture{Texture(ctx, info, index)}; |
| 324 | const std::string offset_vec{Offset(ctx, offset)}; | 323 | const std::string offset_vec{Offset(ctx, offset)}; |
| 325 | const auto [coord_vec, coord_alloc]{Coord(ctx, coord)}; | 324 | const auto [coord_vec, coord_alloc]{Coord(ctx, coord)}; |
| @@ -389,7 +388,7 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde | |||
| 389 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 388 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 390 | const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; | 389 | const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; |
| 391 | const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""}; | 390 | const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""}; |
| 392 | const std::string_view type{ShadowTextureType(info)}; | 391 | const std::string_view type{TextureType(info)}; |
| 393 | const std::string texture{Texture(ctx, info, index)}; | 392 | const std::string texture{Texture(ctx, info, index)}; |
| 394 | const Register coord_vec{ctx.reg_alloc.Consume(coord)}; | 393 | const Register coord_vec{ctx.reg_alloc.Consume(coord)}; |
| 395 | const ScalarF32 dref_value{ctx.reg_alloc.Consume(dref)}; | 394 | const ScalarF32 dref_value{ctx.reg_alloc.Consume(dref)}; |
| @@ -429,10 +428,12 @@ void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst | |||
| 429 | throw NotImplementedException("GLASM instruction"); | 428 | throw NotImplementedException("GLASM instruction"); |
| 430 | } | 429 | } |
| 431 | 430 | ||
| 432 | void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 431 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 433 | [[maybe_unused]] const IR::Value& index, | 432 | ScalarF32 lod) { |
| 434 | [[maybe_unused]] Register lod) { | 433 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 435 | throw NotImplementedException("GLASM instruction"); | 434 | const std::string texture{Texture(ctx, info, index)}; |
| 435 | const std::string_view type{TextureType(info)}; | ||
| 436 | ctx.Add("TXQ {},{},{},{};", inst, lod, texture, type); | ||
| 436 | } | 437 | } |
| 437 | 438 | ||
| 438 | void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 439 | void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, |