emit_glsl_image: Fix ImageFetch for MSAA textures

This commit is contained in:
ameerj 2023-01-28 14:39:27 -05:00
parent 0f795603fc
commit c0cedbae94

View file

@ -414,7 +414,7 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde
void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view coords, std::string_view offset, std::string_view lod, std::string_view coords, std::string_view offset, std::string_view lod,
[[maybe_unused]] std::string_view ms) { std::string_view ms) {
const auto info{inst.Flags<IR::TextureInstInfo>()}; const auto info{inst.Flags<IR::TextureInstInfo>()};
if (info.has_bias) { if (info.has_bias) {
throw NotImplementedException("EmitImageFetch Bias texture samples"); throw NotImplementedException("EmitImageFetch Bias texture samples");
@ -431,19 +431,24 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
ctx.AddU1("{}=true;", *sparse_inst); ctx.AddU1("{}=true;", *sparse_inst);
} }
if (!sparse_inst || !supports_sparse) { if (!sparse_inst || !supports_sparse) {
if (!offset.empty()) { const auto int_coords{CoordsCastToInt(coords, info)};
ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture, if (!ms.empty()) {
CoordsCastToInt(coords, info), lod, CoordsCastToInt(offset, info)); ctx.Add("{}=texelFetch({},{},int({}));", texel, texture, int_coords, ms);
} else if (!offset.empty()) {
ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture, int_coords, lod,
CoordsCastToInt(offset, info));
} else { } else {
if (info.type == TextureType::Buffer) { if (info.type == TextureType::Buffer) {
ctx.Add("{}=texelFetch({},int({}));", texel, texture, coords); ctx.Add("{}=texelFetch({},int({}));", texel, texture, coords);
} else { } else {
ctx.Add("{}=texelFetch({},{},int({}));", texel, texture, ctx.Add("{}=texelFetch({},{},int({}));", texel, texture, int_coords, lod);
CoordsCastToInt(coords, info), lod);
} }
} }
return; return;
} }
if (!ms.empty()) {
throw NotImplementedException("EmitImageFetch Sparse MSAA samples");
}
if (!offset.empty()) { if (!offset.empty()) {
ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));", ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));",
*sparse_inst, texture, CastToIntVec(coords, info), lod, *sparse_inst, texture, CastToIntVec(coords, info), lod,