aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-05-29 01:53:32 -0400
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 21:51:36 -0400
commit7619b7d427437cb58df0f9fc57a7d6b3f5c45f9c (patch)
treecaf39be4349d41c6992691d2d4660501827ed6b0 /src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
parent55e0211a5e520482246273f2cc64388c4b4eff1c (diff)
glsl: Implement TEX depth functions
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_image.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_image.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
index 71eb3ac2b8..4381ed3517 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
@@ -120,7 +120,17 @@ void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] std::string_view dref,
[[maybe_unused]] std::string_view bias_lc,
[[maybe_unused]] const IR::Value& offset) {
- throw NotImplementedException("GLSL Instruction");
+ const auto info{inst.Flags<IR::TextureInstInfo>()};
+ if (info.has_bias) {
+ throw NotImplementedException("Bias texture samples");
+ }
+ if (info.has_lod_clamp) {
+ throw NotImplementedException("Lod clamp samples");
+ }
+ const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""};
+ const auto texture{Texture(ctx, info, index)};
+ const auto vec_cast{info.type == TextureType::ColorArrayCube ? "vec4" : "vec3"};
+ ctx.AddF32("{}=texture({},{}({},{}){});", inst, texture, vec_cast, dref, coords, bias);
}
void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx,
@@ -130,7 +140,19 @@ void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx,
[[maybe_unused]] std::string_view dref,
[[maybe_unused]] std::string_view lod_lc,
[[maybe_unused]] const IR::Value& offset) {
- throw NotImplementedException("GLSL Instruction");
+ const auto info{inst.Flags<IR::TextureInstInfo>()};
+ if (info.has_bias) {
+ throw NotImplementedException("Bias texture samples");
+ }
+ if (info.has_lod_clamp) {
+ throw NotImplementedException("Lod clamp samples");
+ }
+ const auto texture{Texture(ctx, info, index)};
+ if (info.type == TextureType::ColorArrayCube) {
+ ctx.AddF32("{}=textureLod({},{},{},{});", inst, texture, coords, dref, lod_lc);
+ } else {
+ ctx.AddF32("{}=textureLod({},vec3({},{}),{});", inst, texture, coords, dref, lod_lc);
+ }
}
void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,