mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
Fix multisample texture fetch
This commit is contained in:
parent
a8d2684929
commit
9e2d21f887
@ -176,6 +176,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, u32 handle, Id coords, const
|
|||||||
ImageOperands operands;
|
ImageOperands operands;
|
||||||
operands.AddOffset(ctx, offset);
|
operands.AddOffset(ctx, offset);
|
||||||
operands.Add(spv::ImageOperandsMask::Lod, lod);
|
operands.Add(spv::ImageOperandsMask::Lod, lod);
|
||||||
|
operands.Add(spv::ImageOperandsMask::Sample, ms);
|
||||||
const Id texel =
|
const Id texel =
|
||||||
texture.is_storage
|
texture.is_storage
|
||||||
? ctx.OpImageRead(result_type, image, coords, operands.mask, operands.operands)
|
? ctx.OpImageRead(result_type, image, coords, operands.mask, operands.operands)
|
||||||
|
@ -685,24 +685,24 @@ void PatchImageInstruction(IR::Block& block, IR::Inst& inst, Info& info, Descrip
|
|||||||
|
|
||||||
// Now that we know the image type, adjust texture coordinate vector.
|
// Now that we know the image type, adjust texture coordinate vector.
|
||||||
IR::Inst* body = inst.Arg(1).InstRecursive();
|
IR::Inst* body = inst.Arg(1).InstRecursive();
|
||||||
const auto [coords, arg] = [&] -> std::pair<IR::Value, IR::Value> {
|
const auto [coords, arg1, arg2] = [&] -> std::tuple<IR::Value, IR::Value, IR::Value> {
|
||||||
switch (image.GetType()) {
|
switch (image.GetType()) {
|
||||||
case AmdGpu::ImageType::Color1D: // x
|
case AmdGpu::ImageType::Color1D: // x
|
||||||
return {body->Arg(0), body->Arg(1)};
|
return {body->Arg(0), body->Arg(1), body->Arg(2)};
|
||||||
case AmdGpu::ImageType::Color1DArray: // x, slice
|
case AmdGpu::ImageType::Color1DArray: // x, slice
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case AmdGpu::ImageType::Color2D: // x, y
|
case AmdGpu::ImageType::Color2D: // x, y
|
||||||
return {ir.CompositeConstruct(body->Arg(0), body->Arg(1)), body->Arg(2)};
|
[[fallthrough]];
|
||||||
|
case AmdGpu::ImageType::Color2DMsaa: //x, y. (sample is passed on different argument)
|
||||||
|
return {ir.CompositeConstruct(body->Arg(0), body->Arg(1)), body->Arg(2), body->Arg(3)};
|
||||||
case AmdGpu::ImageType::Color2DArray: // x, y, slice
|
case AmdGpu::ImageType::Color2DArray: // x, y, slice
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case AmdGpu::ImageType::Color2DMsaa: // x, y, frag
|
|
||||||
[[fallthrough]];
|
|
||||||
case AmdGpu::ImageType::Color3D: // x, y, z
|
case AmdGpu::ImageType::Color3D: // x, y, z
|
||||||
return {ir.CompositeConstruct(body->Arg(0), body->Arg(1), body->Arg(2)), body->Arg(3)};
|
return {ir.CompositeConstruct(body->Arg(0), body->Arg(1), body->Arg(2)), body->Arg(3), body->Arg(4)};
|
||||||
case AmdGpu::ImageType::Cube: // x, y, face
|
case AmdGpu::ImageType::Cube: // x, y, face
|
||||||
return {PatchCubeCoord(ir, body->Arg(0), body->Arg(1), body->Arg(2), is_storage,
|
return {PatchCubeCoord(ir, body->Arg(0), body->Arg(1), body->Arg(2), is_storage,
|
||||||
inst_info.is_array),
|
inst_info.is_array),
|
||||||
body->Arg(3)};
|
body->Arg(3), body->Arg(4)};
|
||||||
default:
|
default:
|
||||||
UNREACHABLE_MSG("Unknown image type {}", image.GetType());
|
UNREACHABLE_MSG("Unknown image type {}", image.GetType());
|
||||||
}
|
}
|
||||||
@ -711,7 +711,12 @@ void PatchImageInstruction(IR::Block& block, IR::Inst& inst, Info& info, Descrip
|
|||||||
|
|
||||||
if (inst_info.has_lod) {
|
if (inst_info.has_lod) {
|
||||||
ASSERT(inst.GetOpcode() == IR::Opcode::ImageFetch);
|
ASSERT(inst.GetOpcode() == IR::Opcode::ImageFetch);
|
||||||
inst.SetArg(3, arg);
|
inst.SetArg(3, arg1);
|
||||||
|
if (image.GetType() == AmdGpu::ImageType::Color2DMsaa) {
|
||||||
|
inst.SetArg(4, arg2);
|
||||||
|
}
|
||||||
|
} else if (image.GetType() == AmdGpu::ImageType::Color2DMsaa) {
|
||||||
|
inst.SetArg(4, arg1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user