mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-23 20:36:58 +02:00
Honor explicit gather LOD with shared image mip selection
Co-authored-by: YuhiAida <21134775+YuhiAida@users.noreply.github.com> Co-authored-by: BlackCAT <52720489+psnwd@users.noreply.github.com> Co-authored-by: shadowbeat070 <70843316+shadowbeat070@users.noreply.github.com> Co-authored-by: Senaxx <michelbeld@gmail.com> Co-authored-by: Mac <me@itsmemac.com> Co-authored-by: Ali Almohaya <AliAlmohaya@gmail.com>
This commit is contained in:
@@ -2032,6 +2032,58 @@ void TestFmaskLoadSpecialization() {
|
||||
"rebinding FMASK as a texture reused the metadata specialization");
|
||||
}
|
||||
|
||||
void TestGatherLodSamplerValidation() {
|
||||
for (const bool explicit_lod : {false, true}) {
|
||||
for (const bool reverse : {false, true}) {
|
||||
Fixture fixture;
|
||||
std::array<Value, 8> image_words;
|
||||
std::array<Value, 4> sampler_words;
|
||||
for (uint32_t i = 0; i < image_words.size(); i++)
|
||||
image_words[i] = fixture.UserData(i);
|
||||
for (uint32_t i = 0; i < sampler_words.size(); i++)
|
||||
sampler_words[i] = fixture.UserData(i + 8);
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
const bool lod = explicit_lod && i == (reverse ? 0u : 1u);
|
||||
MemoryInfo memory;
|
||||
memory.kind = ResourceKind::Image;
|
||||
memory.image_dimension = Decoder::ImageDimension::Dim2D;
|
||||
memory.image_sample_flags = lod ? Decoder::ImageSampleFlagLod
|
||||
: Decoder::ImageSampleFlagLevelZero;
|
||||
fixture.Emit(ValueOpcode::ImageGatherRaw,
|
||||
{fixture.Image(image_words), fixture.Sampler(sampler_words),
|
||||
fixture.ImageAddress(), image_words[1], image_words[3],
|
||||
sampler_words[1], sampler_words[2]},
|
||||
fixture.AddMemory(memory, i * 4));
|
||||
}
|
||||
fixture.PlanAndTrack();
|
||||
auto plan = ExtractResourcePlan(fixture.program);
|
||||
Check(plan.info.samplers.size() == 1 &&
|
||||
plan.info.samplers[0].gather_lod == explicit_lod,
|
||||
"shared sampler lost explicit gather validation or restricted LZ gather");
|
||||
std::array<uint32_t, 12> user_data{};
|
||||
user_data[0] = 0x1000u;
|
||||
user_data[1] = static_cast<uint32_t>(
|
||||
Libs::Graphics::Prospero::BufferFormat::k32Float) << 20u;
|
||||
user_data[3] = Libs::Graphics::DstSel(4, 5, 6, 7) |
|
||||
(static_cast<uint32_t>(Libs::Graphics::Prospero::ImageType::kColor2D) << 28u);
|
||||
user_data[9] = 0xfff000u;
|
||||
constexpr std::array sampler_controls{
|
||||
0u, 0x4001u, 1u << 26u, (1u << 26u) | 256u,
|
||||
(1u << 26u) | (1u << 14u), 2u << 26u, 3u << 26u};
|
||||
for (const auto control : sampler_controls) {
|
||||
user_data[10] = control;
|
||||
ResourceSnapshot snapshot;
|
||||
ResourceSpecialization specialization;
|
||||
const bool supported = !explicit_lod || (control >> 26u) == 0 ||
|
||||
control == (1u << 26u);
|
||||
Check(MaterializeResources(plan, {.user_data = user_data}, snapshot,
|
||||
specialization) == supported,
|
||||
"explicit gather accepted an unsupported sampler or rejected a valid one");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestDynamicStorageMipTracking() {
|
||||
Fixture fixture;
|
||||
std::array<Value, 8> image_words;
|
||||
@@ -2067,7 +2119,7 @@ void TestDynamicStorageMipTracking() {
|
||||
const auto &images = fixture.program.info.images;
|
||||
Check(images.size() == 2 && images[0].mip_mode == ImageMipMode::None &&
|
||||
images[0].mip_count == 1 &&
|
||||
images[1].mip_mode == ImageMipMode::DynamicStorage &&
|
||||
images[1].mip_mode == ImageMipMode::Dynamic &&
|
||||
images[1].mip_count == 1,
|
||||
"storage mip writes did not share one dynamic logical resource");
|
||||
Check(plain.first.Instruction()->Flags<uint32_t>() == 0 &&
|
||||
@@ -3412,6 +3464,7 @@ int main() {
|
||||
Run("images and samplers", TestImagesSamplersAndAliases);
|
||||
Run("SampleAdjust sampler scratch", TestSampleAdjustSamplerScratch);
|
||||
Run("FMASK load specialization", TestFmaskLoadSpecialization);
|
||||
Run("gather LOD sampler validation", TestGatherLodSamplerValidation);
|
||||
Run("dynamic storage mips", TestDynamicStorageMipTracking);
|
||||
Run("invariant indirect images", TestInvariantIndirectImageMaterialization);
|
||||
Run("guarded direct image table", TestGuardedDirectImageTable);
|
||||
|
||||
Reference in New Issue
Block a user