From 665882aa5a97d76dc29dea06bf0cf47f812cdeac Mon Sep 17 00:00:00 2001 From: slopgobblercobbler <336610228+slopgobblercobbler@users.noreply.github.com> Date: Fri, 27 Nov 2026 00:06:24 +0100 Subject: [PATCH] fix(kyty): allow descriptor sets above default pool sampled-image size --- .../host_gpu/renderer/pipeline/shaders.cpp | 7 +- .../KytyShim/tests/CMakeLists.txt | 16 +++ .../KytyShim/tests/DescriptorPoolOversize.cpp | 107 ++++++++++++++++++ 3 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 core/libs/prx/libSceAgcDriver/KytyShim/tests/DescriptorPoolOversize.cpp diff --git a/core/kyty/graphics/host_gpu/renderer/pipeline/shaders.cpp b/core/kyty/graphics/host_gpu/renderer/pipeline/shaders.cpp index 731912b5c9c..bcba478fce5 100644 --- a/core/kyty/graphics/host_gpu/renderer/pipeline/shaders.cpp +++ b/core/kyty/graphics/host_gpu/renderer/pipeline/shaders.cpp @@ -229,12 +229,11 @@ static void CreateLayouts(GraphicContext& graphics, PipelineCache::Pipeline& pip } const auto max_stage_sampled = *std::ranges::max_element(stage_sampled); if (sampled_images > limits.maxDescriptorSetSampledImages || - max_stage_sampled > limits.maxPerStageDescriptorSampledImages || - sampled_images > DescriptorHeap::MaxSampledImages) { + max_stage_sampled > limits.maxPerStageDescriptorSampledImages) { EXIT("pipeline needs %" PRIu64 " sampled images (%" PRIu64 " in one stage); the device allows " - "%u per set and %u per stage, a descriptor pool holds %u\n", + "%u per set and %u per stage\n", sampled_images, max_stage_sampled, limits.maxDescriptorSetSampledImages, - limits.maxPerStageDescriptorSampledImages, DescriptorHeap::MaxSampledImages); + limits.maxPerStageDescriptorSampledImages); } pipeline.uses_push_descriptors = !pipeline.native_bindings && descriptor_count <= graphics.max_push_descriptors; diff --git a/core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt b/core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt index 1b0d00aae5c..4a46effd613 100644 --- a/core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt +++ b/core/libs/prx/libSceAgcDriver/KytyShim/tests/CMakeLists.txt @@ -928,3 +928,19 @@ set_tests_properties(kyty_shim_hw_oracle PROPERTIES TIMEOUT 60 add_test(NAME kyty_shim_hw_oracle_rows COMMAND kyty_shim_hw_oracle_tests rows) set_tests_properties(kyty_shim_hw_oracle_rows PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77 PASS_REGULAR_EXPRESSION "kyty_shim_hw_oracle_rows: ok" FAIL_REGULAR_EXPRESSION "terminate called|FAILED") + +if(NOT ANYPS5_KYTY_DLL) +add_test_executable(kyty_shim_descriptor_pool_oversize_tests + ${CMAKE_CURRENT_SOURCE_DIR}/DescriptorPoolOversize.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../src/Log.cpp) +target_include_directories(kyty_shim_descriptor_pool_oversize_tests PRIVATE ${LIBS_INCLUDE_DIR}) +configure_host_test_executable(kyty_shim_descriptor_pool_oversize_tests) +if(MINGW) + target_link_libraries(kyty_shim_descriptor_pool_oversize_tests PRIVATE stdc++ gcc_eh) +endif() +target_link_libraries(kyty_shim_descriptor_pool_oversize_tests PRIVATE + "$>" + Kyty::gpu libkernel libc) +add_test(NAME kyty_shim_descriptor_pool_oversize COMMAND kyty_shim_descriptor_pool_oversize_tests) +set_tests_properties(kyty_shim_descriptor_pool_oversize PROPERTIES TIMEOUT 30 SKIP_RETURN_CODE 77) +endif() diff --git a/core/libs/prx/libSceAgcDriver/KytyShim/tests/DescriptorPoolOversize.cpp b/core/libs/prx/libSceAgcDriver/KytyShim/tests/DescriptorPoolOversize.cpp new file mode 100644 index 00000000000..a13977f432e --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/KytyShim/tests/DescriptorPoolOversize.cpp @@ -0,0 +1,107 @@ +#include "TestVulkanDevice.h" +#include "graphics/host_gpu/renderer/masterSemaphore.h" +#include "graphics/host_gpu/renderer/pipeline/descriptorHeap.h" + +#include +#include +#include +#include + +namespace { + +bool RequireVulkan() { + const char* value = std::getenv("ANYPS5_REQUIRE_VULKAN"); + return value != nullptr && value[0] != '\0' && value[0] != '0'; +} + +int SkipOrFail(const char* reason) { + std::fprintf(stderr, "kyty_shim_descriptor_pool_oversize: %s\n", reason); + return RequireVulkan() ? 1 : 77; +} + +} + +int main() { + KytyShimTests::TestVulkanDevice vulkan; + if (const char* reason = vulkan.Initialize(); reason != nullptr) { + return SkipOrFail(reason); + } + + const auto& limits = vulkan.graphics.GetPhysicalDeviceProperties().limits; + constexpr uint32_t ExtraSampledImages = 16; + constexpr uint32_t OversizeCount = + Libs::Graphics::DescriptorHeap::MaxSampledImages + ExtraSampledImages; + if (limits.maxDescriptorSetSampledImages < OversizeCount || + limits.maxPerStageDescriptorSampledImages < OversizeCount) { + std::fprintf(stderr, + "kyty_shim_descriptor_pool_oversize: device sampled image limit (%u / %u) below %u\n", + limits.maxDescriptorSetSampledImages, limits.maxPerStageDescriptorSampledImages, + OversizeCount); + return 77; + } + + const std::array bindings { + vk::DescriptorSetLayoutBinding { + .binding = 0, + .descriptorType = vk::DescriptorType::eSampledImage, + .descriptorCount = OversizeCount, + .stageFlags = vk::ShaderStageFlagBits::eCompute, + }, + vk::DescriptorSetLayoutBinding { + .binding = 1, + .descriptorType = vk::DescriptorType::eStorageBuffer, + .descriptorCount = 1, + .stageFlags = vk::ShaderStageFlagBits::eCompute, + }, + }; + + const vk::DescriptorSetLayoutCreateInfo layout_info { + .bindingCount = static_cast(bindings.size()), + .pBindings = bindings.data(), + }; + vk::DescriptorSetLayout layout; + if (vulkan.graphics.device.createDescriptorSetLayout(&layout_info, nullptr, &layout) != + vk::Result::eSuccess) { + std::fprintf(stderr, + "kyty_shim_descriptor_pool_oversize: FAILED createDescriptorSetLayout\n"); + return 1; + } + + Libs::Graphics::DescriptorHeap::RegisterLayout(layout, bindings); + + int status = 0; + { + Libs::Graphics::MasterSemaphore master_semaphore(vulkan.graphics); + Libs::Graphics::DescriptorHeap heap(vulkan.graphics, master_semaphore); + + const auto regular_set = heap.Commit(layout); + if (!regular_set) { + std::fprintf(stderr, + "kyty_shim_descriptor_pool_oversize: FAILED Commit returned null set\n"); + status = 1; + } + + const auto persistent_set = heap.CommitPersistent(layout); + if (!persistent_set) { + std::fprintf(stderr, + "kyty_shim_descriptor_pool_oversize: FAILED CommitPersistent returned null set\n"); + status = 1; + } + + const vk::SemaphoreSignalInfo signal_info { + .semaphore = master_semaphore.Handle(), + .value = master_semaphore.CurrentTick(), + }; + if (vulkan.graphics.device.signalSemaphore(&signal_info) != vk::Result::eSuccess) { + std::fprintf(stderr, + "kyty_shim_descriptor_pool_oversize: FAILED signalSemaphore\n"); + status = 1; + } + } + + vulkan.graphics.device.destroyDescriptorSetLayout(layout, nullptr); + if (status == 0) { + std::printf("kyty_shim_descriptor_pool_oversize: ok\n"); + } + return status; +}