fix(libSceHmd2): report the PS VR2 runtime as unavailable again

Since #7323 sceHmd2Initialize succeeds and sceHmd2Open returns a handle,
so PPSA01317 runs its PS VR2 set-up and aborts on
sceHmd2ReprojectionQueryBufferSizeAlign, which is not implemented
(reported in #6350). AnyPS5 has no PS VR2 or PC VR support, so
initialization returns libSceHmd's UNSUPPORTED_FEATURE (0x81110016)
again, as before #7323, and titles skip their VR set-up. sceHmd2Open
then returns NotInitialized. The reprojection size queries stay
unimplemented.

Refs #6350
This commit is contained in:
MontyMcK committed 2026-10-19 19:25:30 +13:00
1 parent 3ddbc4accc
commit b378541e79
3 files changed
+12 -87

No files matched your search

+3 -5
View File
@@ -1,6 +1,7 @@
#include "Hmd2.hpp"
#include "prx/libc/include/ApplicationHeap.hpp"
#include "prx/libc/include/General.hpp"
#include "prx/libSceHmd/Hmd.hpp"
#include "prx/libSceUserService/UserService.hpp"
#include "SceTypes.hpp"
@@ -53,11 +54,8 @@ int APS5_VABI sceHmd2ReprojectionQuerySeeThroughBufferSizeAlign() {
}
std::int32_t APS5_VABI sceHmd2Initialize(const void* param) {
std::lock_guard lock(stateMutex);
if (initialized) return Hmd2::AlreadyInitialized;
if (!param) return Hmd2::ParameterNull;
initialized = true;
return 0;
(void)param;
return Hmd::UnsupportedFeature;
}
std::int32_t APS5_VABI sceHmd2GetFieldOfView(std::int32_t handle, Hmd2::FieldOfView* fieldOfView) {
+8 -81
View File
@@ -1,4 +1,5 @@
#include "ProcessParametersFixture.hpp"
#include "prx/libSceHmd/Hmd.hpp"
#include "prx/libSceHmd2/Hmd2.hpp"
#include "prx/libSceUserService/UserService.hpp"
@@ -7,7 +8,6 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stdexcept>
namespace {
@@ -20,10 +20,6 @@ void Require(bool condition, const char* message) {
}
}
void SetSdkVersion(std::uint32_t version) {
std::memcpy(process.data() + 0x10, &version, sizeof(version));
}
void InstallProcessParameters() {
const std::uint64_t size = process.size();
const std::uint32_t magic = 0x4942524f;
@@ -32,21 +28,6 @@ void InstallProcessParameters() {
Require(ProcessParametersFixture::Install(process.data(), process.size()), "process parameters were not installed");
}
bool IsDefaultFieldOfView(const Hmd2::FieldOfView& fieldOfView) {
return fieldOfView.tanOut == 1.84177089f && fieldOfView.tanIn == 0.947190642f &&
fieldOfView.tanTop == 1.32898104f && fieldOfView.tanBottom == 1.32898104f;
}
void RequireNotDetected(const Hmd2::DeviceInformation& info, std::int32_t userId) {
Require(info.status == Hmd2::DeviceStatus::NotDetected, "device status is not NOT_DETECTED");
Require(info.userId == userId, "device user does not match the SDK version");
Require(info.panelWidth == 4000 && info.panelHeight == 2040, "panel resolution differs from the firmware");
Require(info.latency90Hz == 5555 && info.latency120Hz == 4160, "flip latencies differ from the firmware");
Require(info.hmuMount == 0 && info.lensSeparationDistance == 0, "a missing headset reported a mount or lens separation");
Require(info.reserved[0] == 0 && info.reserved[1] == 0, "reserved bytes were not cleared");
Require(info.virtualImageDistance == 2.0f, "virtual image distance differs from the firmware");
}
void TestBeforeInitialize() {
Hmd2::DeviceInformation info;
std::memset(&info, 0xcc, sizeof(info));
@@ -64,68 +45,14 @@ void TestBeforeInitialize() {
Require(sceHmd2SetVibration(0, 0) == 0, "vibration of the unopened handle 0 failed");
}
void TestInitialized() {
void TestWithoutHeadset() {
const std::uint8_t param[16]{};
Require(sceHmd2Initialize(nullptr) == Hmd2::ParameterNull, "initialization without a param");
Require(sceHmd2Initialize(param) == 0, "initialization failed");
Require(sceHmd2Initialize(param) == Hmd2::AlreadyInitialized, "second initialization");
Require(sceHmd2Initialize(param) == Hmd::UnsupportedFeature, "initialization without a headset did not fail");
Require(sceHmd2Initialize(nullptr) == Hmd::UnsupportedFeature, "initialization without a param did not fail as unsupported");
Require(sceHmd2Open(USER_SERVICE_INITIAL_USER_ID, 0, 0, nullptr) == Hmd2::NotInitialized, "open without a headset did not fail");
Hmd2::DeviceInformation info;
std::memset(&info, 0xcc, sizeof(info));
SetSdkVersion(0x06000000);
Require(sceHmd2GetDeviceInformation(&info) == 0, "device information failed");
RequireNotDetected(info, -1);
SetSdkVersion(0x07590001);
std::memset(&info, 0xcc, sizeof(info));
Require(sceHmd2GetDeviceInformation(&info) == 0, "device information for SDK 7.59 failed");
RequireNotDetected(info, 0);
Hmd2::FieldOfView fieldOfView{};
Require(sceHmd2GetFieldOfViewWithoutHandle(&fieldOfView) == 0 && IsDefaultFieldOfView(fieldOfView), "default field of view");
Require(sceHmd2GetFieldOfViewWithoutHandle(nullptr) == Hmd2::ParameterNull, "null field of view");
Require(sceHmd2GetFieldOfView(12345, &fieldOfView) == Hmd2::InvalidHandle, "field of view of an unknown handle");
Require(sceHmd2GetFieldOfView(12345, nullptr) == Hmd2::ParameterNull, "null field of view of an unknown handle");
Require(sceHmd2GetDeviceInformationByHandle(12345, &info) == Hmd2::InvalidHandle, "device information of an unknown handle");
Require(sceHmd2SetVibration(12345, 0) == Hmd2::InvalidHandle, "vibration of an unknown handle");
Require(sceHmd2Close(12345) == Hmd2::InvalidHandle, "close of an unknown handle");
Require(sceHmd2Open(USER_SERVICE_INITIAL_USER_ID, 1, 0, nullptr) == Hmd2::ParameterInvalid, "open with a device type");
Require(sceHmd2Open(USER_SERVICE_INITIAL_USER_ID, 0, 1, nullptr) == Hmd2::ParameterInvalid, "open with a device index");
Require(sceHmd2Open(USER_SERVICE_INITIAL_USER_ID, 0, 0, param) == Hmd2::ParameterInvalid, "open with a param");
Require(sceHmd2Open(USER_SERVICE_INITIAL_USER_ID + 1, 0, 0, nullptr) == Hmd2::ParameterInvalid, "open for another user on SDK 7.59");
const auto handle = sceHmd2Open(USER_SERVICE_INITIAL_USER_ID, 0, 0, nullptr);
Require(handle > 0, "open without a headset failed");
Require(sceHmd2Open(USER_SERVICE_INITIAL_USER_ID, 0, 0, nullptr) == Hmd2::AlreadyOpened, "second open");
std::memset(&info, 0xcc, sizeof(info));
Require(sceHmd2GetDeviceInformationByHandle(handle, &info) == 0, "device information by handle failed");
RequireNotDetected(info, 0);
fieldOfView = {};
Require(sceHmd2GetFieldOfView(handle, &fieldOfView) == 0 && IsDefaultFieldOfView(fieldOfView), "field of view by handle");
Require(sceHmd2SetVibration(handle, 26) == 0, "vibration of a disconnected headset failed");
Require(sceHmd2Close(handle) == 0, "close failed");
Require(sceHmd2Close(handle) == Hmd2::InvalidHandle, "second close");
Require(sceHmd2Close(0) == 0, "close of the unopened handle 0 failed");
const auto kept = sceHmd2Open(USER_SERVICE_INITIAL_USER_ID, 0, 0, nullptr);
Require(kept > 0, "reopen failed");
Require(sceHmd2Terminate() == 0, "terminate failed");
Require(sceHmd2Terminate() == Hmd2::NotInitialized, "second terminate");
Require(sceHmd2GetFieldOfView(kept, &fieldOfView) == Hmd2::NotInitialized, "field of view after terminate");
Require(sceHmd2Close(kept) == Hmd2::NotInitialized, "close after terminate");
Require(sceHmd2Initialize(param) == 0, "reinitialization failed");
Require(sceHmd2Open(USER_SERVICE_INITIAL_USER_ID, 0, 0, nullptr) == Hmd2::AlreadyOpened, "terminate closed the open handle");
Require(sceHmd2Close(kept) == 0, "close after reinitialization failed");
SetSdkVersion(0x06000000);
bool threw = false;
try {
sceHmd2Open(USER_SERVICE_INITIAL_USER_ID + 1, 0, 0, nullptr);
} catch (const std::runtime_error&) {
threw = true;
}
Require(threw, "open for another user before SDK 7.00 did not throw");
Require(sceHmd2Terminate() == 0, "final terminate failed");
Require(sceHmd2GetDeviceInformation(&info) == Hmd2::NotInitialized, "device information without a headset");
Require(sceHmd2Terminate() == Hmd2::NotInitialized, "terminate after the failed initialization");
}
}
@@ -133,7 +60,7 @@ void TestInitialized() {
int main() {
InstallProcessParameters();
TestBeforeInitialize();
TestInitialized();
TestWithoutHeadset();
std::puts("HMD2 tests passed");
return 0;
}
+1 -1
View File
@@ -2,7 +2,7 @@
### Silent stubs
- [libSceHmd2](../../../core/libs/prx/libSceHmd2/Export.cpp) reports a console without a PS VR2 headset, as firmware 13.20's libSceHmd2 does with the `/dev/hmd2_cmd` state measured on a retail PS5 with none connected (connected flag 0, status 2, user -1): initialization succeeds, `sceHmd2Open` returns a handle, device information reports `NotDetected` with the firmware's fixed panel, latency and image distance values, both field-of-view calls return the firmware's default tangents and `sceHmd2SetVibration` succeeds without vibrating. The reprojection and gaze exports and every [libSceVrTracker2](../../../core/libs/prx/libSceVrTracker2/Export.cpp) export throw. PPSA01317, PPSA07411, PPSA09030, PPSA15878 and PPSA29866, which skipped their VR set-up while initialization failed, have not been run with initialization succeeding
- [libSceHmd2](../../../core/libs/prx/libSceHmd2/Export.cpp) has no PS VR2 runtime: `sceHmd2Initialize` returns libSceHmd's `UNSUPPORTED_FEATURE` (0x81110016) for any param, so the other calls answer as before initialization and `sceHmd2Open` returns `NotInitialized` (0x8a720002). These results are restored from the behaviour before #7323 and are not measured on hardware: firmware 13.20's libSceHmd2, with the `/dev/hmd2_cmd` state measured on a retail PS5 with no headset connected (connected flag 0, status 2, user -1), initializes, returns a handle from `sceHmd2Open` and reports `NotDetected`, which the code past the initialization check models but no title reaches. PPSA01317 passes a pointer to 16 zeroed bytes, only tests the result for non-zero and then skips its VR set-up; with initialization succeeding it stopped on `sceHmd2ReprojectionQueryBufferSizeAlign` (#6350). That export, `sceHmd2ReprojectionQueryDisplayBufferSizeAlign` and `sceHmd2ReprojectionQuerySeeThroughBufferSizeAlign` stay unimplemented and throw pending console measurements of their sizes and alignments. The other reprojection and gaze exports and every [libSceVrTracker2](../../../core/libs/prx/libSceVrTracker2/Export.cpp) export throw
### Unknown function info