shader: merge typed image candidates as raw vectors with shared sampler variants

This commit is contained in:
nmzik
2026-10-12 18:54:54 +02:00
parent 49ebbfd627
commit 652154aead
5 changed files with 238 additions and 99 deletions
+47
View File
@@ -1210,6 +1210,52 @@ void TestDescendingImageRange() {
}
}
void TestMixedIndirectImageSamplers() {
auto fixture = MakeIndirectImageFixture(false, 32u, 0u, 0u);
fixture->PlanAndTrack();
auto& samplers = fixture->program.info.samplers;
samplers.resize(3u, samplers[0]);
samplers[0].indirect_resources = {1u, 2u};
const auto plan = ExtractResourcePlan(fixture->program);
std::array<uint32_t, 8> data {0x3000u, 16u << 16u, 1u, 0u,
0x2000u, 32u << 16u, 3u, 0u};
LinearTestMemory memory;
using F = Libs::Graphics::Prospero::BufferFormat;
for (uint32_t record = 0; record < 3u; ++record) {
const auto offset = (0x1000u + record * 32u) / 4u;
memory.words[offset] = 0x100u + record;
memory.words[offset + 1u] = static_cast<uint32_t>(
record == 0u ? F::k32_32_32_32Float : F::k32_32_32_32UInt) << 20u;
memory.words[offset + 3u] = Libs::Graphics::DstSel(4, 5, 6, 7) |
(uint32_t(Libs::Graphics::Prospero::ImageType::kColor2D) << 28u);
}
const SrtRuntime runtime {.user_data = data, .userdata = &memory,
.read_specialization_memory = ReadLinearTestMemory};
ResourceSnapshot snapshot;
ResourceSpecialization specialization;
Check(MaterializeResources(plan, runtime, snapshot, specialization) && snapshot.images.size() == 4u,
"mixed float/uint image table failed materialization");
ApplyResourceSpecialization(fixture->program, specialization);
const auto& info = fixture->program.info;
Check(info.sampled_pairs.size() == 2u && info.samplers.size() == 6u,
"indirect image candidates duplicated sampler pairs or lost finite class variants");
for (const auto& pair : info.sampled_pairs) {
const auto integer = info.images[pair.image].numeric_class ==
Libs::Graphics::Prospero::TextureNumericClass::Uint;
const auto& sampler = info.samplers[pair.sampler];
Check(sampler.snapshot_index == 0u && sampler.integer_border == integer &&
sampler.force_point_filtering == integer && sampler.indirect_resources.size() == 2u &&
pair.first_use_pc == 0x10f0u,
"mixed image class changed native sampler identity or integer-border semantics");
for (uint32_t ordinal = 0; ordinal < sampler.indirect_resources.size(); ++ordinal) {
const auto& candidate = info.samplers[sampler.indirect_resources[ordinal]];
Check(candidate.snapshot_index == ordinal + 1u &&
candidate.integer_border == integer && candidate.force_point_filtering == integer,
"mixed image class mapped a finite sampler choice to the wrong variant");
}
}
}
void TestUniformizedMaterialImageKeys() {
namespace CFG = Libs::Graphics::ShaderRecompiler::CFG;
enum class Variant {
@@ -4086,6 +4132,7 @@ int main() {
Run("draw-uniform scalar image", TestUniformScalarBufferImage);
Run("scalar buffer selector domain", TestScalarBufferSelectorDomain);
Run("descending image range", TestDescendingImageRange);
Run("mixed indirect image samplers", TestMixedIndirectImageSamplers);
Run("SRT runtime", TestSrtFlatteningAndRuntimeMemoization);
Run("dynamic SRT", TestDynamicSrtReadRemainsExplicit);
Run("writable descriptor phi", TestWritableDescriptorPhi);