Handle mixed samples attachments (V2) (#3667)

* video_core: Refactor render target bind to allow disabling MSAA

* video_core: Implement swapping of backing samples

* clang format

* video_core: Better implementation

Instead of downgrading to 1 sample, always try to match depth samples. This avoids needing to copy depth-stencil attachment and copying multisampled stencil is not possible on some vendors

* video_core: Small bugfixes

* image: Add null check

* vk_rasterizer: Swap backing samples on resolve dst

* vk_presenter: Reset backing samples before present

* video_core: Small refactor to make this implementation better

* reinterpret: Fix channel check for degamma

Seems this was simpler than I thought, hardware doesn't apply degamma on the W channel regardless of swizzle

* image: Add missing end rendering call

* blit_helper: Fix bug in old reinterpret path

* blit_helper: Remove unused layer vertex

Should be used in the future if copying many layers is needed

* vk_rasterizer: Apply suggestion

* vk_rasterizer: More bind refactor

* vk_instance: Re-enable extensions
This commit is contained in:
TheTurtle
2025-09-29 16:27:39 +03:00
committed by GitHub
parent cad027845f
commit a35c9f3586
32 changed files with 1166 additions and 847 deletions

View File

@@ -1022,7 +1022,7 @@ void PatchImageSampleArgs(IR::Block& block, IR::Inst& inst, Info& info,
auto converted = ApplyReadNumberConversionVec4(ir, texel, image.GetNumberConversion());
if (sampler.force_degamma && image.GetNumberFmt() != AmdGpu::NumberFormat::Srgb) {
converted = ApplyForceDegamma(ir, texel, image.DstSelect());
converted = ApplyForceDegamma(ir, texel);
}
inst.ReplaceUsesWith(converted);
}

View File

@@ -29,25 +29,15 @@ inline F32 ApplyGammaToLinear(IREmitter& ir, const F32& c) {
return IR::F32{ir.Select(ir.FPGreaterThan(c, ir.Imm32(0.04045f)), a, b)};
}
inline Value ApplyForceDegamma(IREmitter& ir, const Value& value,
const AmdGpu::CompMapping& mapping) {
inline Value ApplyForceDegamma(IREmitter& ir, const Value& value) {
auto x = F32{ir.CompositeExtract(value, 0)};
auto y = F32{ir.CompositeExtract(value, 1)};
auto z = F32{ir.CompositeExtract(value, 2)};
auto w = F32{ir.CompositeExtract(value, 3)};
// Gamma correction is only applied to RGB components
if (AmdGpu::IsRgb(mapping.r)) {
x = ApplyGammaToLinear(ir, x);
}
if (AmdGpu::IsRgb(mapping.g)) {
y = ApplyGammaToLinear(ir, y);
}
if (AmdGpu::IsRgb(mapping.b)) {
z = ApplyGammaToLinear(ir, z);
}
if (AmdGpu::IsRgb(mapping.a)) {
w = ApplyGammaToLinear(ir, w);
}
x = ApplyGammaToLinear(ir, x);
y = ApplyGammaToLinear(ir, y);
z = ApplyGammaToLinear(ir, z);
return ir.CompositeConstruct(x, y, z, w);
}