mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 23:38:37 +00:00
From Eden/Yuzu's driver-bug list, which the Blueshell renderer in Hookshot runs into: - NVIDIA's proprietary driver does not handle a pipeline barrier recorded inside a conditional rendering scope. With barriers_outside_predication (on for that driver, LEONIDA_BARRIERS_OUTSIDE_PREDICATION=0/1 overrides), emit ends the title's predicate scope around each barrier and begins it again (detail::outside_predication). A D3D12 barrier is never predicated. - vkCmdClearAttachments on a multisampled attachment can lock NVIDIA's GPU up. A rect clear of a multisampled view that covers the whole mip and every layer, with no predicate open, is now the image clear (same result). A partial one is logged once. predication_barrier_test is new. replay_query_predication_test, replay_clear_gate_test, replay_texture_barrier_test and vk_command_replay_test pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.9 KiB
C++
68 lines
2.9 KiB
C++
// detail::outside_predication (ReplayFunctions::barriers_outside_predication, NVIDIA's driver and barriers inside a
|
|
// conditional rendering scope): with the flag set and a scope open on the command buffer, a barrier is recorded between
|
|
// an end and a begin of that scope; otherwise it is recorded as it is. Fake Vulkan entry points, no GPU.
|
|
|
|
#include "../src/vulkan_replay.h"
|
|
|
|
#include <cstdio>
|
|
#include <string>
|
|
|
|
#define EXPECT(condition) do { \
|
|
if (!(condition)) { std::fprintf(stderr, "predication_barrier_test line %d: %s\n", __LINE__, #condition); return 1; } \
|
|
} while (0)
|
|
|
|
namespace {
|
|
|
|
std::string calls;
|
|
const VkConditionalRenderingBeginInfoEXT* begun_with = nullptr;
|
|
|
|
VKAPI_ATTR void VKAPI_CALL fake_barrier(VkCommandBuffer, VkPipelineStageFlags, VkPipelineStageFlags, VkDependencyFlags,
|
|
uint32_t, const VkMemoryBarrier*, uint32_t, const VkBufferMemoryBarrier*,
|
|
uint32_t, const VkImageMemoryBarrier*) {
|
|
calls += "B";
|
|
}
|
|
VKAPI_ATTR void VKAPI_CALL fake_end(VkCommandBuffer) { calls += "E"; }
|
|
VKAPI_ATTR void VKAPI_CALL fake_begin(VkCommandBuffer, const VkConditionalRenderingBeginInfoEXT* info) {
|
|
calls += "C";
|
|
begun_with = info;
|
|
}
|
|
|
|
leonida::ReplayFunctions functions(bool outside) {
|
|
leonida::ReplayFunctions vk{};
|
|
vk.pipeline_barrier = fake_barrier;
|
|
vk.begin_conditional_rendering = fake_begin;
|
|
vk.end_conditional_rendering = fake_end;
|
|
vk.barriers_outside_predication = outside;
|
|
return vk;
|
|
}
|
|
|
|
VkCommandBuffer handle(std::uintptr_t n) { return reinterpret_cast<VkCommandBuffer>(n); }
|
|
|
|
int run(bool outside, bool open, VkCommandBuffer recorded_on, const char* want) {
|
|
calls.clear();
|
|
begun_with = nullptr;
|
|
const leonida::ReplayFunctions vk = functions(outside);
|
|
VkConditionalRenderingBeginInfoEXT info{VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT};
|
|
info.buffer = open ? reinterpret_cast<VkBuffer>(std::uintptr_t{0x10}) : VK_NULL_HANDLE;
|
|
const leonida::detail::ActivePredicate active{handle(1), &info};
|
|
leonida::detail::active_predicate = &active;
|
|
leonida::detail::memory_barrier(vk, recorded_on, VK_ACCESS_SHADER_WRITE_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
|
VK_ACCESS_SHADER_READ_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
leonida::detail::active_predicate = nullptr;
|
|
EXPECT(calls == want);
|
|
if (calls == "EBC") EXPECT(begun_with == &info); // the same predicate begins again
|
|
return 0;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
if (run(true, true, handle(1), "EBC") || // NVIDIA, a scope open: the barrier goes outside it
|
|
run(false, true, handle(1), "B") || // another driver: as it is
|
|
run(true, false, handle(1), "B") || // no predicate set
|
|
run(true, true, handle(2), "B")) // the scope is another command buffer's
|
|
return 1;
|
|
std::printf("predication_barrier_test: ok\n");
|
|
return 0;
|
|
}
|