nmzik
2026-09-17 08:39:57 +04:00
parent fa913ec1a7
commit e0ecffed70
6 changed files with 47 additions and 3 deletions
+33 -3
View File
@@ -12271,7 +12271,7 @@ public:
return ret;
}
vk::Sampler CreateNearestSampler(const char *shader_name) {
vk::Sampler CreateNearestSampler(const char *shader_name, u32 mip_levels = 1) {
vk::SamplerCreateInfo sampler_info{};
sampler_info.sType = vk::StructureType::eSamplerCreateInfo;
sampler_info.magFilter = vk::Filter::eNearest;
@@ -12281,7 +12281,7 @@ public:
sampler_info.addressModeV = vk::SamplerAddressMode::eClampToEdge;
sampler_info.addressModeW = vk::SamplerAddressMode::eClampToEdge;
sampler_info.minLod = 0.0f;
sampler_info.maxLod = 0.0f;
sampler_info.maxLod = static_cast<float>(mip_levels - 1u);
vk::Sampler sampler = nullptr;
RequireVk(shader_name, "dispatch",
m_device.createSampler(&sampler_info, nullptr, &sampler),
@@ -15484,7 +15484,7 @@ void RunCase(VulkanHarness *vulkan, const TestCase &test) {
vk::ImageLayout::eGeneral);
}
if (needs_sampler) {
sampler = vulkan->CreateNearestSampler(test.name);
sampler = vulkan->CreateNearestSampler(test.name, sampled_image.mip_levels);
}
vulkan->Dispatch(test, compiled, buffer, needs_gds ? &gds_buffer : nullptr,
@@ -25001,6 +25001,34 @@ TestCase ImageSampleAndGather() {
return test;
}
TestCase ImageGatherLodApproximatesLevelZero() {
using O = ShaderOpcode;
std::vector<u32> code;
AppendVMovLiteral(&code, 20, 0x3f000000u);
AppendVMovLiteral(&code, 21, 0x3f000000u);
AppendVMovLiteral(&code, 22, 0x3f800000u);
code.push_back(EncodeMimg0(0x44, 0x1));
code.push_back(EncodeMimg1(0, 20));
code.push_back(EncodeMimg0(0x24, 0x1));
code.push_back(EncodeMimg1(4, 20));
for (u32 i = 0; i < 5u; i++) {
AppendStoreVgpr(&code, i, i);
}
AppendEnd(&code);
TestCase test;
test.name = "ImageGatherLodApproximatesLevelZero";
test.code = std::move(code);
test.opcodes = {O::V_MOV_B32, O::IMAGE_GATHER4_L, O::IMAGE_SAMPLE,
O::BUFFER_STORE_DWORD, O::S_ENDPGM};
// Explicit sampling proves mip 1 is accessible; the gather must still read mip 0.
test.expected = {0x3f800000u, 0x3f800000u, 0x3f800000u, 0x3f800000u, 0x41000000u};
test.sampled_image_rgba_mips = {std::vector<u32>(4 * 4 * 4, 0x3f800000u),
std::vector<u32>(2 * 2 * 4, 0x41000000u)};
test.required_spirv = {"OpImageGather", "OpImageSampleExplicitLod"};
return test;
}
TestCase ImageD16GatherPacksHalfPairs() {
using O = ShaderOpcode;
@@ -26575,6 +26603,7 @@ std::vector<TestCase> MakeCases() {
AddCase(ImageGetResinfoDmaskWidthHeight);
AddCase(ImageGetResinfoDmaskMipLevels);
AddCase(ImageSampleAndGather);
AddCase(ImageGatherLodApproximatesLevelZero);
AddCase(ImageD16GatherPacksHalfPairs);
AddCase(ImageSampleA16SamplerCoordsOnGpu);
AddCase(ImageSampleOpcodeAliasUsesNormalCoords);
@@ -31166,6 +31195,7 @@ int main(int argc, char **argv) {
RunCase(&vulkan, BranchVccnzUsesWaveMask());
RunCase(&vulkan, BranchVccnzUsesCarryProducedWaveMask());
RunCase(&vulkan, ImageSampleAndGather());
RunCase(&vulkan, ImageGatherLodApproximatesLevelZero());
RunCase(&vulkan, SharedReturnKeepsSelectedValues());
return 0;
}