emit_glsl_image: Use inlined texelFetch offsets

This commit is contained in:
Ameer J 2023-12-20 19:24:11 -05:00
parent b4b301d22e
commit a5b2b8b91b
2 changed files with 7 additions and 7 deletions

View file

@ -449,7 +449,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, const IR::Value& offset, std::string_view lod,
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) {
@ -470,9 +470,9 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
const auto int_coords{CoordsCastToInt(coords, info)}; const auto int_coords{CoordsCastToInt(coords, info)};
if (!ms.empty()) { if (!ms.empty()) {
ctx.Add("{}=texelFetch({},{},int({}));", texel, texture, int_coords, ms); ctx.Add("{}=texelFetch({},{},int({}));", texel, texture, int_coords, ms);
} else if (!offset.empty()) { } else if (!offset.IsEmpty()) {
ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture, int_coords, lod, ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture, int_coords, lod,
CoordsCastToInt(offset, info)); GetOffsetVec(ctx, offset));
} 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);
@ -485,10 +485,10 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
if (!ms.empty()) { if (!ms.empty()) {
throw NotImplementedException("EmitImageFetch Sparse MSAA samples"); throw NotImplementedException("EmitImageFetch Sparse MSAA samples");
} }
if (!offset.empty()) { if (!offset.IsEmpty()) {
ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));", ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchOffsetARB({},{},int({}),{},{}));",
*sparse_inst, texture, CastToIntVec(coords, info), lod, *sparse_inst, texture, CastToIntVec(coords, info), lod, GetOffsetVec(ctx, offset),
CastToIntVec(offset, info), texel); texel);
} else { } else {
ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchARB({},{},int({}),{}));", ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchARB({},{},int({}),{}));",
*sparse_inst, texture, CastToIntVec(coords, info), lod, texel); *sparse_inst, texture, CastToIntVec(coords, info), lod, texel);

View file

@ -651,7 +651,7 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde
std::string_view coords, const IR::Value& offset, const IR::Value& offset2, std::string_view coords, const IR::Value& offset, const IR::Value& offset2,
std::string_view dref); std::string_view dref);
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, const IR::Value& offset, std::string_view lod,
std::string_view ms); std::string_view ms);
void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
std::string_view lod, const IR::Value& skip_mips); std::string_view lod, const IR::Value& skip_mips);