Skip to content
19 changes: 15 additions & 4 deletions core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@ class DepthSurface {
std::exception_ptr publicationFailure;

void capturePublication() {
if ((target.format != VK_FORMAT_D32_SFLOAT_S8_UINT && !bareDepthTarget(target)) || context.detiler == nullptr) return;
if ((target.format != VK_FORMAT_D32_SFLOAT && target.format != VK_FORMAT_D32_SFLOAT_S8_UINT) || context.detiler == nullptr) return;
try {
const auto lease = GuestAllocations::GuestAllocationsAcquireAll_nid_postfix();
CheckCurrent();
Expand Down Expand Up @@ -3240,6 +3240,7 @@ std::uint32_t expandedHtileWord(std::uint32_t word, bool stencilInHtile, VkImage
}

bool DepthSurface::PublishToGuest(DepthReadCause cause) {
const bool stencil = target.format == VK_FORMAT_D32_SFLOAT_S8_UINT;
Require(!Recorder::InCompletion(), "native multisample depth publication inside a GPU completion is not implemented");
Require(!publicationInProgress, "recursive native multisample depth publication is not implemented");
Require(!publicationFailed, "a previous native multisample depth publication store did not complete");
Expand All @@ -3251,10 +3252,17 @@ bool DepthSurface::PublishToGuest(DepthReadCause cause) {
if (publicationFailure) std::rethrow_exception(publicationFailure);
const bool bare = bareDepthTarget(target);
const bool htile = !uniformPlaneTarget(target) && !bare;
const bool publishable = bare ? publication.size() == 1u : target.format == VK_FORMAT_D32_SFLOAT_S8_UINT && publication.size() == (htile ? 3u : 2u);
if (!stencil && !bare) {
Require(target.format != VK_FORMAT_D16_UNORM, "guest publication of a written native multisample D16 depth is not implemented");
Require(target.format == VK_FORMAT_D32_SFLOAT && hostFormat == target.format, "sample-preserving guest publication of a written native multisample depth that the device stores in another format is not implemented");
Require(sampleable, "guest publication of a written native multisample depth the device cannot sample is not implemented");
Require(context.detiler != nullptr, "guest publication of a written native multisample depth needs the texture detiler");
ApplyFastClear();
}
const bool publishable = bare ? publication.size() == 1u : publication.size() == (stencil && htile ? 3u : 2u);
Require(publishable && hostFormat == target.format, "sample-preserving guest publication of native multisample depth is not implemented for this owner");
Require(sampling.refusal.empty(), sampling.refusal);
RequireStencilProven();
if (stencil) RequireStencilProven();
Require(!clearPending && clearGeneration == 0u && stencilClearGeneration == 0u && pendingClear == 0u, "native multisample depth publication with an unapplied clear is not implemented");
Require(sampleable && context.detiler != nullptr, "sample-preserving guest publication of native multisample depth requires sampled readback support");
const auto lease = GuestAllocations::GuestAllocationsAcquireAll_nid_postfix();
Expand Down Expand Up @@ -3306,7 +3314,7 @@ bool DepthSurface::PublishToGuest(DepthReadCause cause) {
for (std::size_t offset = 0u; offset < result[1].size(); offset += 4u) {
std::uint32_t word;
std::memcpy(&word, result[1].data() + offset, 4u);
word = expandedHtileWord(word, !target.htileDepthOnly, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
word = expandedHtileWord(word, !target.htileDepthOnly, VK_IMAGE_ASPECT_DEPTH_BIT | (stencil ? VK_IMAGE_ASPECT_STENCIL_BIT : 0u));
std::memcpy(result[1].data() + offset, &word, 4u);
}
}
Expand Down Expand Up @@ -3380,6 +3388,9 @@ bool DepthSurface::PublishToGuest(DepthReadCause cause) {
publication.clear();
if (superseded[0]) RetireMultisampleColorTarget(sampling.depthAlias->active);
if (superseded[2]) RetireMultisampleColorTarget(sampling.stencilAlias->active);
if (!stencil && !bare) {
active->store(false, std::memory_order_release);
}
return std::ranges::find(tookGuest, true) != tookGuest.end();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7956,7 +7956,7 @@ void GuestBufferMemory::recordGpuCopies(std::span<Region* const> copies, bool ad
for (const auto* region : copies) reads.emplace_back(region->begin, region->end);
recorder->NoteAccess(Recorder::CommandClass::StagingIn, Recorder::Access{reads, {}, {}, VK_PIPELINE_STAGE_TRANSFER_BIT});
}
constexpr BarrierMask leading{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_HOST_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT};
constexpr BarrierMask leading{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_HOST_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT};
if (!inRun && !Recorder::ElideCovered(Recorder::CommandClass::StagingIn, leading, covered)) {
RecordMemoryBarrier(context, commands, leading.srcStage, leading.dstStage, leading.srcAccess, leading.dstAccess);
Recorder::CountBarriers(Recorder::CommandClass::StagingIn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4597,6 +4597,7 @@ bool ShaderResources::Revalidate(std::span<const CompiledShader> shaders, ProofR
provedEpoch = 0;
return false;
}
requireGuestBuffers();
if (EpochProofs()) {
const auto epoch = GuestMemory::CollectEpoch();
const auto proof = GuestMemory::ProofSerial();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ if(BUILD_TESTING)
if(WIN32)
set_tests_properties(agc_driver_native_depth_pending_units PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test(NAME agc_driver_native_depth_buffer_publication COMMAND agc_driver_native_multisample_depth_tests --buffer-publication)
add_test(NAME agc_driver_native_depth_buffer_publication_items COMMAND agc_driver_native_multisample_depth_tests --buffer-publication)
add_test(NAME agc_driver_native_depth_cached_draw_publication COMMAND agc_driver_native_multisample_depth_tests --cached-draw-publication)
set_tests_properties(agc_driver_native_depth_buffer_publication agc_driver_native_depth_buffer_publication_items agc_driver_native_depth_cached_draw_publication PROPERTIES TIMEOUT 30 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
set_property(TEST agc_driver_native_depth_buffer_publication_items APPEND PROPERTY ENVIRONMENT "APS5_PIPELINE_DISPATCH=1")
set_property(TEST agc_driver_native_depth_cached_draw_publication APPEND PROPERTY ENVIRONMENT "APS5_DRAW_PIPELINE=1")
if(WIN32)
set_tests_properties(agc_driver_native_depth_buffer_publication agc_driver_native_depth_buffer_publication_items agc_driver_native_depth_cached_draw_publication PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test(NAME agc_driver_native_depth_colour_import COMMAND agc_driver_native_multisample_depth_tests --colour-over-owner)
set_tests_properties(agc_driver_native_depth_colour_import PROPERTIES TIMEOUT 30 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
if(WIN32)
Expand Down
Loading
Loading