summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-03-26 22:45:38 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:24 +0200
commit17063d16a3cfe6542e74265739191e1d018fc456 (patch)
tree3dc74c85c9be19183f4c889306458c9a6307b108 /src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
parentshader: Refactor PTP and other minor changes (diff)
downloadyuzu-17063d16a3cfe6542e74265739191e1d018fc456.tar
yuzu-17063d16a3cfe6542e74265739191e1d018fc456.tar.gz
yuzu-17063d16a3cfe6542e74265739191e1d018fc456.tar.bz2
yuzu-17063d16a3cfe6542e74265739191e1d018fc456.tar.lz
yuzu-17063d16a3cfe6542e74265739191e1d018fc456.tar.xz
yuzu-17063d16a3cfe6542e74265739191e1d018fc456.tar.zst
yuzu-17063d16a3cfe6542e74265739191e1d018fc456.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_image.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
index b6e9d3c0c..3ea0011aa 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
@@ -91,7 +91,15 @@ private:
Id Texture(EmitContext& ctx, const IR::Value& index) {
if (index.IsImmediate()) {
const TextureDefinition def{ctx.textures.at(index.U32())};
- return ctx.OpLoad(def.type, def.id);
+ return ctx.OpLoad(def.sampled_type, def.id);
+ }
+ throw NotImplementedException("Indirect texture sample");
+}
+
+Id TextureImage(EmitContext& ctx, const IR::Value& index) {
+ if (index.IsImmediate()) {
+ const TextureDefinition def{ctx.textures.at(index.U32())};
+ return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, def.id));
}
throw NotImplementedException("Indirect texture sample");
}
@@ -149,6 +157,10 @@ Id EmitBindlessImageFetch(EmitContext&) {
throw LogicError("Unreachable instruction");
}
+Id EmitBindlessImageQueryDimensions(EmitContext&) {
+ throw LogicError("Unreachable instruction");
+}
+
Id EmitBoundImageSampleImplicitLod(EmitContext&) {
throw LogicError("Unreachable instruction");
}
@@ -177,6 +189,10 @@ Id EmitBoundImageFetch(EmitContext&) {
throw LogicError("Unreachable instruction");
}
+Id EmitBoundImageQueryDimensions(EmitContext&) {
+ throw LogicError("Unreachable instruction");
+}
+
Id EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
Id bias_lc, Id offset) {
const auto info{inst->Flags<IR::TextureInstInfo>()};
@@ -241,4 +257,34 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c
Texture(ctx, index), coords, operands.Mask(), operands.Span());
}
+Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod) {
+ const auto info{inst->Flags<IR::TextureInstInfo>()};
+ const Id image{TextureImage(ctx, index)};
+ const Id zero{ctx.u32_zero_value};
+ const auto mips{[&] { return ctx.OpImageQueryLevels(ctx.U32[1], image); }};
+ switch (info.type) {
+ case TextureType::Color1D:
+ case TextureType::Shadow1D:
+ return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[1], image, lod),
+ zero, zero, mips());
+ case TextureType::ColorArray1D:
+ case TextureType::Color2D:
+ case TextureType::ColorCube:
+ case TextureType::ShadowArray1D:
+ case TextureType::Shadow2D:
+ case TextureType::ShadowCube:
+ return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[2], image, lod),
+ zero, mips());
+ case TextureType::ColorArray2D:
+ case TextureType::Color3D:
+ case TextureType::ColorArrayCube:
+ case TextureType::ShadowArray2D:
+ case TextureType::Shadow3D:
+ case TextureType::ShadowArrayCube:
+ return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[3], image, lod),
+ mips());
+ }
+ throw LogicError("Unspecified image type {}", info.type.Value());
+}
+
} // namespace Shader::Backend::SPIRV