Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window) : state(std::make_u
#endif
deviceExtensions.push_back(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME);
#ifndef _WIN32
state->dmaBufImport = hasExtension(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) && hasExtension(VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
state->dmaBufImport = Graphics::DmaBufImportUsable(selected, state->InstanceFunction<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2"), availableExtensions);
if (state->dmaBufImport) {
deviceExtensions.push_back(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
deviceExtensions.push_back(VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "prx/libc/include/GuestAllocations.hpp"
#include <memory>
#include <optional>
#include <span>
#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -46,6 +47,7 @@ struct ImportProbe {

ImportProbe ProbeImportWriteProtection(const Context& context);
ImportProbe ProbeDmaBufImportWriteProtection(const Context& context);
bool DmaBufImportUsable(VkPhysicalDevice physical, PFN_vkGetPhysicalDeviceProperties2 query, std::span<const VkExtensionProperties> extensions);
ImportWatch PrepareImportWatch(const Context& context);
void SetImportWatch(const Context& context, ImportWatch watch);

Expand Down
18 changes: 18 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,24 @@ ImportProbe ProbeDmaBufImportWriteProtection(const Context& context) {
#endif
}

bool DmaBufImportUsable(VkPhysicalDevice physical, PFN_vkGetPhysicalDeviceProperties2 query, std::span<const VkExtensionProperties> extensions) {
#ifdef _WIN32
static_cast<void>(physical);
static_cast<void>(query);
static_cast<void>(extensions);
return false;
#else
const auto hasExtension = [&](const char* name) { return std::any_of(extensions.begin(), extensions.end(), [&](const auto& extension) { return std::strcmp(extension.extensionName, name) == 0; }); };
if (!hasExtension(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) || !hasExtension(VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME)) return false;
if (!hasExtension(VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME)) return true;
Require(query != nullptr, "missing Vulkan property query");
VkPhysicalDeviceDriverProperties driver{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES};
VkPhysicalDeviceProperties2 properties{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &driver};
query(physical, &properties);
return driver.driverID != VK_DRIVER_ID_NVIDIA_PROPRIETARY;
#endif
}

ImportWatch PrepareImportWatch(const Context& context) {
auto& state = Imports();
std::lock_guard lock(state.mutex);
Expand Down
2 changes: 1 addition & 1 deletion core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Device {
function<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2")(context.physical, &properties);
context.hostImportAlignment = hostProperties.minImportedHostPointerAlignment;
}
if (hasExtension(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) && hasExtension(VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME)) {
if (DmaBufImportUsable(context.physical, function<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2"), available)) {
extensionsEnabled.push_back(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
extensionsEnabled.push_back(VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
context.dmaBufImport = true;
Expand Down
1 change: 1 addition & 0 deletions docs/dev/TechnicalDebt.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,4 @@ Throughout the project, every function at every stage either **does exactly what
- [sceFontOpenFontSet](../../core/libs/prx/libSceFont/src/SystemFont.cpp) (libSceFont) opens only the primary file of a system font set. Characters the console takes from the set's other files (Hangul, Thai and Arabic in Japanese and Chinese sets, Arabic in European sets) are reported as unsupported glyphs. The console file names are those of the PS4 firmware; the names of the PS5-only JG2 sets (`0x1A......`) are unknown, so they use the SSTJpPro files. When a console file is missing, an openly licensed substitute (Noto Sans, Noto Sans Mono, Noto Sans Thai, Noto Sans CJK) is loaded instead. It is not the system font: its metrics differ, so text width, line height and wrapping differ from the console. System font faces are loaded by FreeType in host memory, not in the font memory the title passes to the library: FreeType needs about 1 MiB per CJK face, which the title's font memory is not sized for.
- [Font writing lines](../../core/libs/prx/libSceFont/src/WritingLine.cpp) (libSceFont) - `sceFontCreateWritingLine`, `sceFontWritingLineWritesOrder`, `sceFontWritingLineRefersRenderStep`, `sceFontWritingLineGetRenderMetrics` and `sceFontWritingLineClear` follow [KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/main/src/libs/libFont.cpp): runs are placed left to right, each at the line's advance so far, with no spacing or adjustment. Only horizontal and left-to-right lines, writing attribute 0 and non-null run metrics are modelled; other values, the metrics of an empty line and unknown or null handles throw, since no reference gives their result or error code. `sceFontWritingLineGetOrderingSpace` still throws (KytyPS5's values are placeholders). Lines are allocated on the host, not in the font memory
- [sceImeKeyboardGetResourceId](../../core/libs/prx/libSceIme/Export.cpp) (libSceIme) reports that no USB keyboard is connected (`0x80bc0004`, as [shadPS4](https://github.com/shadps4-emu/shadPS4) does) because IME keyboard events are not delivered to the handler, although [libSceKeyboard](../../core/libs/prx/libSceKeyboard/src/keyboard_impl.cpp) exposes the host keyboard
- [dma-buf import](../../core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp) (libSceAgcDriver) is off on the NVIDIA proprietary driver (`VK_DRIVER_ID_NVIDIA_PROPRIETARY`), so guest ranges are imported there only through a host pointer, as before dma-buf import. On that driver an import of a udmabuf fails with `VK_ERROR_OUT_OF_DEVICE_MEMORY` and every later allocation on the device then fails (driver 580.178.04, #1289); why is unknown, and whether a newer driver imports it was not tested. A driver without `VK_KHR_driver_properties` is not checked.