mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-02 19:15:41 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fceaaf5aa9 | ||
|
|
c6cec01b1d |
No files matched your search
@@ -363,10 +363,23 @@ public final class LinuxRuntime {
|
||||
};
|
||||
|
||||
public static String gpuStandIn(Context context) {
|
||||
if (new File(KGSL_DEVICE).exists()) return KGSL_DEVICE;
|
||||
if (com.droiddeck.launcher.core.DeviceSupport.INSTANCE.openDriverActive(context) && new File(MALI_DEVICE).exists()) return MALI_DEVICE;
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.INSTANCE.vkBridge(context)) return null;
|
||||
return bridgeStandIn(path -> new File(path).exists());
|
||||
return gpuStandIn(path -> new File(path).exists(),
|
||||
() -> maliGuestDriver(com.droiddeck.launcher.core.DeviceSupport.INSTANCE.openDriverActive(context),
|
||||
() -> com.droiddeck.launcher.session.VenusComponent.wanted(context),
|
||||
com.droiddeck.launcher.session.SessionState.INSTANCE.getMode()),
|
||||
() -> com.droiddeck.launcher.core.DeviceSupport.INSTANCE.vkBridge(context));
|
||||
}
|
||||
|
||||
static boolean maliGuestDriver(boolean openDriver, java.util.function.BooleanSupplier venus, String sessionMode) {
|
||||
return openDriver || (com.droiddeck.launcher.session.SessionService.MODE_DESKTOP.equals(sessionMode) && venus.getAsBoolean());
|
||||
}
|
||||
|
||||
static String gpuStandIn(java.util.function.Predicate<String> exists, java.util.function.BooleanSupplier maliGuestDriver,
|
||||
java.util.function.BooleanSupplier bridge) {
|
||||
if (exists.test(KGSL_DEVICE)) return KGSL_DEVICE;
|
||||
if (maliGuestDriver.getAsBoolean() && exists.test(MALI_DEVICE)) return MALI_DEVICE;
|
||||
if (!bridge.getAsBoolean()) return null;
|
||||
return bridgeStandIn(exists);
|
||||
}
|
||||
|
||||
static String bridgeStandIn(java.util.function.Predicate<String> exists) {
|
||||
|
||||
@@ -1066,8 +1066,8 @@ class SessionService : Service() {
|
||||
Log.i(TAG, "steam: software web compositing for the open driver pair (GPU raster kept)")
|
||||
}
|
||||
guest.add("DD_OPEN_DRIVER=1")
|
||||
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("DD_DRM_STANDIN=$it") }
|
||||
}
|
||||
if (!bridge) LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("DD_DRM_STANDIN=$it") }
|
||||
val tuOverride = tuDebugOverride()
|
||||
val tuDriver = sysmemDriver(linuxDriverId)
|
||||
if (!venus && com.droiddeck.launcher.core.DeviceSupport.adreno()) (tuOverride ?: "sysmem".takeIf { tuDriver || SessionPrefs.tuSysmem(this) })?.let { guest.add("TU_DEBUG=$it") }
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import android.app.Application
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33], manifest = Config.NONE, application = Application::class)
|
||||
class LinuxRuntimeGpuStandInTest {
|
||||
private val kgsl = "/dev/kgsl-3d0"
|
||||
|
||||
private fun standIn(nodes: Set<String>, maliGuestDriver: Boolean, bridge: Boolean): String? =
|
||||
LinuxRuntime.gpuStandIn({ it in nodes }, { maliGuestDriver }, { bridge })
|
||||
|
||||
@Test fun maliGuestDriverGetsTheMaliNode() {
|
||||
assertEquals(LinuxRuntime.MALI_DEVICE, standIn(setOf(LinuxRuntime.MALI_DEVICE), maliGuestDriver = true, bridge = false))
|
||||
}
|
||||
|
||||
@Test fun maliWithoutAGuestDriverOrBridgeGetsNoNode() {
|
||||
assertNull(standIn(setOf(LinuxRuntime.MALI_DEVICE, "/dev/dri/renderD128"), maliGuestDriver = false, bridge = false))
|
||||
}
|
||||
|
||||
@Test fun maliGuestDriverWithoutTheMaliNodeGetsNoNode() {
|
||||
assertNull(standIn(setOf("/dev/dri/renderD128"), maliGuestDriver = true, bridge = false))
|
||||
}
|
||||
|
||||
@Test fun kgslStaysTheStandInWheneverItExists() {
|
||||
assertEquals(kgsl, standIn(setOf(kgsl, LinuxRuntime.MALI_DEVICE), maliGuestDriver = true, bridge = true))
|
||||
assertEquals(kgsl, standIn(setOf(kgsl), maliGuestDriver = false, bridge = false))
|
||||
}
|
||||
|
||||
@Test fun bridgeKeepsItsOwnNodeChoice() {
|
||||
assertEquals("/dev/dri/renderD129", standIn(setOf("/dev/dri/renderD129"), maliGuestDriver = false, bridge = true))
|
||||
assertEquals(LinuxRuntime.MALI_DEVICE, standIn(setOf(LinuxRuntime.MALI_DEVICE), maliGuestDriver = false, bridge = true))
|
||||
}
|
||||
|
||||
@Test fun guestDriverIsNotAskedWhenKgslExists() {
|
||||
var asked = false
|
||||
LinuxRuntime.gpuStandIn({ it == kgsl }, { asked = true; true }, { asked = true; true })
|
||||
assertEquals(false, asked)
|
||||
}
|
||||
|
||||
@Test fun venusGetsTheMaliNodeOnlyOnDesktop() {
|
||||
assertTrue(LinuxRuntime.maliGuestDriver(false, { true }, SessionService.MODE_DESKTOP))
|
||||
assertFalse(LinuxRuntime.maliGuestDriver(false, { true }, SessionService.MODE_STEAM))
|
||||
assertFalse(LinuxRuntime.maliGuestDriver(false, { true }, SessionService.MODE_RUN))
|
||||
assertFalse(LinuxRuntime.maliGuestDriver(false, { false }, SessionService.MODE_DESKTOP))
|
||||
}
|
||||
|
||||
@Test fun openDriverPairGetsTheMaliNodeInEveryMode() {
|
||||
for (mode in listOf(SessionService.MODE_STEAM, SessionService.MODE_DESKTOP, SessionService.MODE_RUN)) {
|
||||
assertTrue(LinuxRuntime.maliGuestDriver(true, { false }, mode))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun venusIsNotAskedOutsideDesktop() {
|
||||
var asked = false
|
||||
LinuxRuntime.maliGuestDriver(false, { asked = true; true }, SessionService.MODE_STEAM)
|
||||
assertFalse(asked)
|
||||
}
|
||||
}
|
||||
@@ -149,6 +149,14 @@ The SPIR-V version the driver gets:
|
||||
only taken out where the layer emulates them. `DROIDDECK_MALI_COMPAT=0` turns both off.
|
||||
- This is what Dawn ("Disable SPIR-V 1.4 on Android ARM"), ANGLE (`supportsSPIRV14`) and naga
|
||||
(`AVOID_SPIRV_COPY_LOGICAL`) do for a proprietary compiler they cannot trust.
|
||||
- Render node: Zink binds a GBM or DRI screen (KWin, Xwayland's glamor) to the Vulkan device
|
||||
whose `VkPhysicalDeviceDrmPropertiesEXT` render node matches the screen's DRM fd. Venus over
|
||||
vtest reports none, so KWin 6.8, which has no QPainter compositor, drew nothing on Desktop.
|
||||
When the driver reports no render node, the layer reports the stand-in node's numbers
|
||||
(`DD_DRM_STANDIN=/dev/mali0`, bound into the guest as `/dev/dri/renderD<minor>`). The
|
||||
extension stays unlisted, and the layer is off in gamescope, so gamescope keeps its no-DRM path.
|
||||
Venus gets the stand-in node only in Desktop sessions. Steam and program sessions keep running
|
||||
without one, so their Xwayland, Zink and gamescope paths stay as they were.
|
||||
|
||||
Files:
|
||||
- `layer.c`: loader plumbing, feature and limit reporting, device creation, the hook table.
|
||||
|
||||
@@ -44,8 +44,9 @@ through `kwin_wayland_wrapper`. The package's `kwin-compositor` marker selects O
|
||||
Zink for KWin 6.8, which removed QPainter. Older packages retain their software compositor.
|
||||
KWin runs without Gallium's threaded context and without overlay layers. With the threaded context, KWin crashed
|
||||
uploading windows' shared-memory buffers by reading past their end, and the host shows only a single buffer.
|
||||
On Android the launcher explicitly selects the KGSL render node; the nested backend can use it
|
||||
when the host's dmabuf feedback cannot name a DRM device. Games and emulators from the menu go
|
||||
On Android the launcher explicitly selects the GPU's render node (KGSL, or `/dev/mali0` as a
|
||||
stand-in for the Mali open driver, and for Venus in Desktop sessions); the nested backend can use it when the host's dmabuf
|
||||
feedback cannot name a DRM device. Without one, KWin 6.8 has no compositor and the desktop stays black. Games and emulators from the menu go
|
||||
through `droiddeck-gpu`, and Steam goes back to the app as a Steam session.
|
||||
|
||||
`kwin.env` pins the KWin version shared by the build and packaging jobs. `build-kwin.sh` builds that version's
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *interface);
|
||||
|
||||
@@ -240,6 +242,16 @@ static void VKAPI_CALL mock_properties(VkPhysicalDevice physical, VkPhysicalDevi
|
||||
static void VKAPI_CALL mock_properties2(VkPhysicalDevice physical, VkPhysicalDeviceProperties2 *properties)
|
||||
{
|
||||
mock_properties(physical, &properties->properties);
|
||||
for (VkBaseOutStructure *s = properties->pNext; s; s = s->pNext) {
|
||||
if (s->sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT)
|
||||
continue;
|
||||
VkPhysicalDeviceDrmPropertiesEXT *drm = (VkPhysicalDeviceDrmPropertiesEXT *)s;
|
||||
bool own = physical == (VkPhysicalDevice)&mock_capable;
|
||||
drm->hasPrimary = drm->hasRender = own;
|
||||
drm->primaryMajor = drm->renderMajor = own ? 226 : 0;
|
||||
drm->primaryMinor = 0;
|
||||
drm->renderMinor = own ? 128 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void VKAPI_CALL mock_memory_properties(VkPhysicalDevice physical, VkPhysicalDeviceMemoryProperties *properties)
|
||||
@@ -567,6 +579,46 @@ static void test_depth_compare_op(void)
|
||||
destroy_device(device);
|
||||
}
|
||||
|
||||
static VkPhysicalDeviceDrmPropertiesEXT query_drm(VkPhysicalDevice physical)
|
||||
{
|
||||
VkPhysicalDeviceDrmPropertiesEXT drm = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT};
|
||||
VkPhysicalDeviceProperties2 properties = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &drm, {0}};
|
||||
((PFN_vkGetPhysicalDeviceProperties2)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceProperties2"))(
|
||||
physical, &properties);
|
||||
return drm;
|
||||
}
|
||||
|
||||
static void test_render_node(void)
|
||||
{
|
||||
VkPhysicalDevice lacking = (VkPhysicalDevice)&mock_lacking, capable = (VkPhysicalDevice)&mock_capable;
|
||||
struct stat node;
|
||||
assert(stat("/dev/null", &node) == 0 && S_ISCHR(node.st_mode));
|
||||
|
||||
unsetenv("DD_DRM_STANDIN");
|
||||
VkPhysicalDeviceDrmPropertiesEXT drm = query_drm(lacking);
|
||||
assert(!drm.hasRender && !drm.renderMajor && !drm.renderMinor);
|
||||
|
||||
setenv("DD_DRM_STANDIN", "/dev/null", 1);
|
||||
drm = query_drm(lacking);
|
||||
assert(drm.hasRender && !drm.hasPrimary);
|
||||
assert(drm.renderMajor == (int64_t)major(node.st_rdev) && drm.renderMinor == (int64_t)minor(node.st_rdev));
|
||||
|
||||
drm = query_drm(capable);
|
||||
assert(drm.hasRender && drm.hasPrimary && drm.renderMajor == 226 && drm.renderMinor == 128);
|
||||
|
||||
VkPhysicalDeviceProperties2 plain = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, NULL, {0}};
|
||||
((PFN_vkGetPhysicalDeviceProperties2)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceProperties2"))(
|
||||
lacking, &plain);
|
||||
|
||||
const char *not_devices[] = {"", "/", "/nonexistent/renderD128"};
|
||||
for (size_t i = 0; i < sizeof(not_devices) / sizeof(not_devices[0]); i++) {
|
||||
setenv("DD_DRM_STANDIN", not_devices[i], 1);
|
||||
drm = query_drm(lacking);
|
||||
assert(!drm.hasRender && !drm.renderMajor && !drm.renderMinor);
|
||||
}
|
||||
unsetenv("DD_DRM_STANDIN");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_spirv(argc > 1 ? argv[1] : NULL);
|
||||
@@ -590,6 +642,7 @@ int main(int argc, char **argv)
|
||||
test_lacking_device();
|
||||
test_capable_device();
|
||||
test_depth_compare_op();
|
||||
test_render_node();
|
||||
|
||||
((PFN_vkDestroyInstance)layer_gipa(instance, "vkDestroyInstance"))(instance, NULL);
|
||||
free(driver_code);
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
#define LAYER_NAME "VK_LAYER_DROIDDECK_mali_compat"
|
||||
|
||||
@@ -389,12 +391,29 @@ static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties(VkPhysicalDevice p
|
||||
report_limits(&properties->limits, physical_device_gaps(inst, physical_device));
|
||||
}
|
||||
|
||||
static void report_render_node(VkPhysicalDeviceProperties2 *properties)
|
||||
{
|
||||
VkPhysicalDeviceDrmPropertiesEXT *drm = NULL;
|
||||
for (VkBaseOutStructure *s = properties->pNext; s && !drm; s = s->pNext) {
|
||||
if (s->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT)
|
||||
drm = (VkPhysicalDeviceDrmPropertiesEXT *)s;
|
||||
}
|
||||
const char *node = getenv("DD_DRM_STANDIN");
|
||||
struct stat st;
|
||||
if (!drm || drm->hasRender || !node || !*node || stat(node, &st) != 0 || !S_ISCHR(st.st_mode))
|
||||
return;
|
||||
drm->hasRender = VK_TRUE;
|
||||
drm->renderMajor = major(st.st_rdev);
|
||||
drm->renderMinor = minor(st.st_rdev);
|
||||
}
|
||||
|
||||
static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties2(VkPhysicalDevice physical_device,
|
||||
VkPhysicalDeviceProperties2 *properties)
|
||||
{
|
||||
struct instance *inst = instance_from_handle(physical_device);
|
||||
inst->GetPhysicalDeviceProperties2(physical_device, properties);
|
||||
report_limits(&properties->properties.limits, physical_device_gaps(inst, physical_device));
|
||||
report_render_node(properties);
|
||||
if (tracing())
|
||||
layer_log("trace: vkGetPhysicalDeviceProperties2: %s, Vulkan %u.%u.%u, type %d", properties->properties.deviceName,
|
||||
VK_API_VERSION_MAJOR(properties->properties.apiVersion), VK_API_VERSION_MINOR(properties->properties.apiVersion),
|
||||
|
||||
Reference in new issue
Block a user