summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_image.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_image.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
index 6962f2b91..68701ee52 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
@@ -26,8 +26,8 @@ std::string CastToIntVec(std::string_view value, const IR::TextureInstInfo& info
26 return fmt::format("int({})", value); 26 return fmt::format("int({})", value);
27 case TextureType::ColorArray1D: 27 case TextureType::ColorArray1D:
28 case TextureType::Color2D: 28 case TextureType::Color2D:
29 return fmt::format("ivec2({})", value);
30 case TextureType::ColorArray2D: 29 case TextureType::ColorArray2D:
30 return fmt::format("ivec2({})", value);
31 case TextureType::Color3D: 31 case TextureType::Color3D:
32 case TextureType::ColorCube: 32 case TextureType::ColorCube:
33 return fmt::format("ivec3({})", value); 33 return fmt::format("ivec3({})", value);
@@ -65,7 +65,11 @@ void EmitImageSampleImplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unuse
65 ctx.Add("{}=textureOffset({},{},{}{});", texel, texture, coords, 65 ctx.Add("{}=textureOffset({},{},{}{});", texel, texture, coords,
66 CastToIntVec(ctx.reg_alloc.Consume(offset), info), bias); 66 CastToIntVec(ctx.reg_alloc.Consume(offset), info), bias);
67 } else { 67 } else {
68 ctx.Add("{}=texture({},{}{});", texel, texture, coords, bias); 68 if (ctx.stage == Stage::Fragment) {
69 ctx.Add("{}=texture({},{}{});", texel, texture, coords, bias);
70 } else {
71 ctx.Add("{}=textureLod({},{},0.0);", texel, texture, coords);
72 }
69 } 73 }
70 return; 74 return;
71 } 75 }
@@ -104,6 +108,7 @@ void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unuse
104 } 108 }
105 return; 109 return;
106 } 110 }
111 // TODO: Query sparseTexels extension support
107 if (!offset.IsEmpty()) { 112 if (!offset.IsEmpty()) {
108 ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));", 113 ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));",
109 *sparse_inst, texture, CastToIntVec(coords, info), lod_lc, 114 *sparse_inst, texture, CastToIntVec(coords, info), lod_lc,
@@ -121,17 +126,7 @@ void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx,
121 [[maybe_unused]] std::string_view dref, 126 [[maybe_unused]] std::string_view dref,
122 [[maybe_unused]] std::string_view bias_lc, 127 [[maybe_unused]] std::string_view bias_lc,
123 [[maybe_unused]] const IR::Value& offset) { 128 [[maybe_unused]] const IR::Value& offset) {
124 const auto info{inst.Flags<IR::TextureInstInfo>()}; 129 throw NotImplementedException("GLSL Instruction");
125 if (info.has_bias) {
126 throw NotImplementedException("Bias texture samples");
127 }
128 if (info.has_lod_clamp) {
129 throw NotImplementedException("Lod clamp samples");
130 }
131 const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""};
132 const auto texture{Texture(ctx, info, index)};
133 const auto vec_cast{info.type == TextureType::ColorArrayCube ? "vec4" : "vec3"};
134 ctx.AddF32("{}=texture({},{}({},{}){});", inst, texture, vec_cast, dref, coords, bias);
135} 130}
136 131
137void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, 132void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx,
@@ -148,6 +143,9 @@ void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx,
148 if (info.has_lod_clamp) { 143 if (info.has_lod_clamp) {
149 throw NotImplementedException("Lod clamp samples"); 144 throw NotImplementedException("Lod clamp samples");
150 } 145 }
146 if (!offset.IsEmpty()) {
147 throw NotImplementedException("textureLodOffset");
148 }
151 const auto texture{Texture(ctx, info, index)}; 149 const auto texture{Texture(ctx, info, index)};
152 if (info.type == TextureType::ColorArrayCube) { 150 if (info.type == TextureType::ColorArrayCube) {
153 ctx.AddF32("{}=textureLod({},{},{},{});", inst, texture, coords, dref, lod_lc); 151 ctx.AddF32("{}=textureLod({},{},{},{});", inst, texture, coords, dref, lod_lc);