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.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
index 68701ee52..d721b018b 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
@@ -38,6 +38,17 @@ std::string CastToIntVec(std::string_view value, const IR::TextureInstInfo& info
38 } 38 }
39} 39}
40 40
41std::string ShadowSamplerVecCast(TextureType type) {
42 switch (type) {
43 case TextureType::ColorArray2D:
44 case TextureType::ColorCube:
45 case TextureType::ColorArrayCube:
46 return "vec4";
47 default:
48 return "vec3";
49 }
50}
51
41IR::Inst* PrepareSparse(IR::Inst& inst) { 52IR::Inst* PrepareSparse(IR::Inst& inst) {
42 const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)}; 53 const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
43 if (sparse_inst) { 54 if (sparse_inst) {
@@ -126,7 +137,24 @@ void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx,
126 [[maybe_unused]] std::string_view dref, 137 [[maybe_unused]] std::string_view dref,
127 [[maybe_unused]] std::string_view bias_lc, 138 [[maybe_unused]] std::string_view bias_lc,
128 [[maybe_unused]] const IR::Value& offset) { 139 [[maybe_unused]] const IR::Value& offset) {
129 throw NotImplementedException("GLSL Instruction"); 140 const auto info{inst.Flags<IR::TextureInstInfo>()};
141 if (info.has_bias) {
142 throw NotImplementedException("Bias texture samples");
143 }
144 if (info.has_lod_clamp) {
145 throw NotImplementedException("Lod clamp samples");
146 }
147 if (!offset.IsEmpty()) {
148 throw NotImplementedException("textureLodOffset");
149 }
150 const auto texture{Texture(ctx, info, index)};
151 const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""};
152 const auto cast{ShadowSamplerVecCast(info.type)};
153 if (ctx.stage == Stage::Fragment) {
154 ctx.AddF32("{}=texture({},{}({},{}){});", inst, texture, cast, coords, dref, bias);
155 } else {
156 ctx.AddF32("{}=textureLod({},{}({},{}),0.0);", inst, texture, cast, coords, dref);
157 }
130} 158}
131 159
132void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, 160void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx,