Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/libs/prx/libSceAgcDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1804,10 +1804,11 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test(NAME agc_driver_undithered_alpha_to_coverage_state COMMAND agc_driver_graphics_tests --undithered-alpha-to-coverage-state)
add_test(NAME agc_driver_depth_bounds_state COMMAND agc_driver_graphics_tests --depth-bounds-state)
add_test(NAME agc_driver_msaa_dcc_state COMMAND agc_driver_graphics_tests --multisample-dcc-state)
add_test(NAME agc_driver_unused_viewport_depth COMMAND agc_driver_graphics_tests --unused-viewport-depth)
set_tests_properties(agc_driver_unused_viewport_depth PROPERTIES TIMEOUT 30)
set_tests_properties(agc_driver_undithered_alpha_to_coverage_state PROPERTIES
set_tests_properties(agc_driver_undithered_alpha_to_coverage_state agc_driver_depth_bounds_state PROPERTIES
ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" TIMEOUT 30 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
add_test(NAME agc_driver_alpha_to_coverage_state COMMAND agc_driver_graphics_tests --alpha-to-coverage-state)
set_tests_properties(agc_driver_alpha_to_coverage_state PROPERTIES
Expand All @@ -1825,7 +1826,7 @@ if(BUILD_TESTING)
set_tests_properties(agc_driver_dithered_alpha_to_coverage PROPERTIES
ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 TIMEOUT 30 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
if(WIN32)
set_tests_properties(agc_driver_alpha_to_coverage_state agc_driver_undithered_alpha_to_coverage_state agc_driver_msaa_dcc_state agc_driver_unused_viewport_depth PROPERTIES ENVIRONMENT_MODIFICATION
set_tests_properties(agc_driver_alpha_to_coverage_state agc_driver_undithered_alpha_to_coverage_state agc_driver_depth_bounds_state agc_driver_msaa_dcc_state agc_driver_unused_viewport_depth PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
set_tests_properties(agc_driver_dithered_alpha_to_coverage ${multisampledDccClearTests} PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
Expand Down
10 changes: 8 additions & 2 deletions core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ float readFloat(const Registers& registers, std::uint32_t offset) {
return value;
}

float readDepthBound(const Registers& registers, std::uint32_t offset) {
const auto value = std::bit_cast<float>(read(registers, offset));
if (std::isnan(value)) Require(false, "NaN depth bound at DWORD " + std::to_string(offset));
return value;
}

std::string zeroMessage(std::uint32_t offset, std::uint32_t value, const char* name) {
char detail[64];
std::snprintf(detail, sizeof(detail), " (register 0x%x = 0x%08x)", offset, value);
Expand Down Expand Up @@ -349,8 +355,8 @@ void decodeDepth(const Registers& cx, std::uint32_t depthControl, bool testValEx
result.depthBoundsTest = (depthControl & 8u) != 0;
if (result.depthBoundsTest) {
Require(zFormat != 0, "depth bounds without a depth plane");
result.minDepthBounds = readFloat(cx, 0x008);
result.maxDepthBounds = readFloat(cx, 0x009);
result.minDepthBounds = readDepthBound(cx, 0x008);
result.maxDepthBounds = readDepthBound(cx, 0x009);
}
if (depthClear) {
result.depthTest = true;
Expand Down
28 changes: 28 additions & 0 deletions core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include <random>
#include <initializer_list>
#include <iostream>
#include <limits>
#include <map>
#include <optional>
#include <set>
Expand Down Expand Up @@ -2577,6 +2578,28 @@ void DepthBoundsBiasTests() {
queue.context[0x009] = bits(0.75f);
auto state = AgcDriver::Graphics::DecodeState(queue);
Require(state.depthTest && state.depthBoundsTest && state.minDepthBounds == 0.25f && state.maxDepthBounds == 0.75f, "depth bounds decode changed");
const auto infinity = std::numeric_limits<float>::infinity();
for (const auto bounds : {std::array{0.0f, infinity}, std::array{-infinity, 1.0f}, std::array{-infinity, infinity}}) {
queue.context[0x008] = bits(bounds[0]);
queue.context[0x009] = bits(bounds[1]);
state = AgcDriver::Graphics::DecodeState(queue);
Require(state.depthBoundsTest && state.minDepthBounds == bounds[0] && state.maxDepthBounds == bounds[1], "infinite depth bounds changed");
AgcDriver::Graphics::Context context{};
expectFailure([&] { AgcDriver::Graphics::ValidateDepthBounds(context, state); }, "depth bounds outside [0, 1]");
context.depthRangeUnrestricted = true;
AgcDriver::Graphics::ValidateDepthBounds(context, state);
}
for (const auto offset : {0x008u, 0x009u}) {
queue.context[0x008] = bits(0.25f);
queue.context[0x009] = bits(0.75f);
queue.context[offset] = bits(std::numeric_limits<float>::quiet_NaN());
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "NaN depth bound");
}
queue.context[0x008] = bits(0.25f);
queue.context[0x009] = bits(0.75f);
queue.context[0x00b] = bits(infinity);
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "non-finite register");
queue.context[0x00b] = bits(0.0f);
queue.context[0x1b3] = 2;
queue.context[0x1b4] = 2;
const auto rejection = AgcDriver::Graphics::DrawRejection(queue, false);
Expand Down Expand Up @@ -9815,6 +9838,11 @@ int main(int argc, char** argv) {
std::cout << "Multisampled DCC state checks passed\n";
return 0;
}
if (argc == 2 && std::string_view(argv[1]) == "--depth-bounds-state") {
DepthBoundsBiasTests();
std::cout << "Depth bounds state checks passed\n";
return 0;
}
{
const AgcDriver::Graphics::Context context{};
const AgcDriver::Graphics::State state{};
Expand Down
Loading