mirror of
https://github.com/yuzu-emu/yuzu-mainline
synced 2024-11-25 13:58:50 +00:00
Merge pull request #13026 from liamwhite/scale-this-mf
shader_recompiler: fix non-const offset for arrayed image types
This commit is contained in:
commit
8b0fb98a11
2 changed files with 44 additions and 7 deletions
|
@ -60,11 +60,10 @@ public:
|
||||||
Add(spv::ImageOperandsMask::ConstOffsets, offsets);
|
Add(spv::ImageOperandsMask::ConstOffsets, offsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit ImageOperands(EmitContext& ctx, const IR::Value& offset, Id lod, Id ms) {
|
explicit ImageOperands(Id lod, Id ms) {
|
||||||
if (Sirit::ValidId(lod)) {
|
if (Sirit::ValidId(lod)) {
|
||||||
Add(spv::ImageOperandsMask::Lod, lod);
|
Add(spv::ImageOperandsMask::Lod, lod);
|
||||||
}
|
}
|
||||||
AddOffset(ctx, offset, ImageFetchOffsetAllowed);
|
|
||||||
if (Sirit::ValidId(ms)) {
|
if (Sirit::ValidId(ms)) {
|
||||||
Add(spv::ImageOperandsMask::Sample, ms);
|
Add(spv::ImageOperandsMask::Sample, ms);
|
||||||
}
|
}
|
||||||
|
@ -312,6 +311,43 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info,
|
||||||
return coords;
|
return coords;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, Id& coords,
|
||||||
|
Id offset) {
|
||||||
|
if (!Sirit::ValidId(offset)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Id result_type{};
|
||||||
|
switch (info.type) {
|
||||||
|
case TextureType::Buffer:
|
||||||
|
case TextureType::Color1D: {
|
||||||
|
result_type = ctx.U32[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TextureType::ColorArray1D:
|
||||||
|
offset = ctx.OpCompositeConstruct(ctx.U32[2], offset, ctx.u32_zero_value);
|
||||||
|
[[fallthrough]];
|
||||||
|
case TextureType::Color2D:
|
||||||
|
case TextureType::Color2DRect: {
|
||||||
|
result_type = ctx.U32[2];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TextureType::ColorArray2D:
|
||||||
|
offset = ctx.OpCompositeConstruct(ctx.U32[3], ctx.OpCompositeExtract(ctx.U32[1], coords, 0),
|
||||||
|
ctx.OpCompositeExtract(ctx.U32[1], coords, 1),
|
||||||
|
ctx.u32_zero_value);
|
||||||
|
[[fallthrough]];
|
||||||
|
case TextureType::Color3D: {
|
||||||
|
result_type = ctx.U32[3];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TextureType::ColorCube:
|
||||||
|
case TextureType::ColorArrayCube:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
coords = ctx.OpIAdd(result_type, coords, offset);
|
||||||
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
Id EmitBindlessImageSampleImplicitLod(EmitContext&) {
|
Id EmitBindlessImageSampleImplicitLod(EmitContext&) {
|
||||||
|
@ -494,9 +530,10 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index,
|
||||||
operands.Span());
|
operands.Span());
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
|
Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset,
|
||||||
const IR::Value& offset, Id lod, Id ms) {
|
Id lod, Id ms) {
|
||||||
const auto info{inst->Flags<IR::TextureInstInfo>()};
|
const auto info{inst->Flags<IR::TextureInstInfo>()};
|
||||||
|
AddOffsetToCoordinates(ctx, info, coords, offset);
|
||||||
if (info.type == TextureType::Buffer) {
|
if (info.type == TextureType::Buffer) {
|
||||||
lod = Id{};
|
lod = Id{};
|
||||||
}
|
}
|
||||||
|
@ -504,7 +541,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c
|
||||||
// This image is multisampled, lod must be implicit
|
// This image is multisampled, lod must be implicit
|
||||||
lod = Id{};
|
lod = Id{};
|
||||||
}
|
}
|
||||||
const ImageOperands operands(ctx, offset, lod, ms);
|
const ImageOperands operands(lod, ms);
|
||||||
return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4],
|
return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4],
|
||||||
TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span());
|
TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span());
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,8 +537,8 @@ Id EmitImageGather(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id
|
||||||
const IR::Value& offset, const IR::Value& offset2);
|
const IR::Value& offset, const IR::Value& offset2);
|
||||||
Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
|
Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
|
||||||
const IR::Value& offset, const IR::Value& offset2, Id dref);
|
const IR::Value& offset, const IR::Value& offset2, Id dref);
|
||||||
Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
|
Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset,
|
||||||
const IR::Value& offset, Id lod, Id ms);
|
Id lod, Id ms);
|
||||||
Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod,
|
Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod,
|
||||||
const IR::Value& skip_mips);
|
const IR::Value& skip_mips);
|
||||||
Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords);
|
Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords);
|
||||||
|
|
Loading…
Reference in a new issue