Skip to content
Open
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
Binary file not shown.
30 changes: 30 additions & 0 deletions app/src/main/feature/library/GameSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ class GameSettingsStateHolder {
val gfxSelectedBcnEmulationType = mutableIntStateOf(0)
val gfxBcnEmulationCacheEntries = mutableStateOf<List<String>>(emptyList())
val gfxSelectedBcnEmulationCache = mutableIntStateOf(0)
val gfxTranscoderEntries = mutableStateOf<List<String>>(emptyList())
val gfxSelectedTranscoder = mutableIntStateOf(0)
val gfxQualityEntries = mutableStateOf<List<String>>(emptyList())
val gfxSelectedQuality = mutableIntStateOf(0)
val gfxSyncFrame = mutableStateOf(false)
val gfxDisablePresentWait = mutableStateOf(false)

Expand Down Expand Up @@ -1671,6 +1675,32 @@ private fun GraphicsDriverConfigCard(
}
}

val gamenativeWrapperActive = state.graphicsDriverEntries.value
.getOrElse(state.selectedGraphicsDriver.intValue) { "" }
.equals("Wrapper-Gamenative", ignoreCase = true)
if (gamenativeWrapperActive) {
Spacer(Modifier.height(SettingItemGap))

Row(horizontalArrangement = Arrangement.spacedBy(SettingItemGap)) {
Box(Modifier.weight(1f)) {
SettingDropdown(
label = stringResource(R.string.container_graphics_transcoder),
entries = state.gfxTranscoderEntries.value,
selectedIndex = state.gfxSelectedTranscoder.intValue,
onSelected = { state.gfxSelectedTranscoder.intValue = it }
)
}
Box(Modifier.weight(1f)) {
SettingDropdown(
label = stringResource(R.string.container_graphics_quality),
entries = state.gfxQualityEntries.value,
selectedIndex = state.gfxSelectedQuality.intValue,
onSelected = { state.gfxSelectedQuality.intValue = it }
)
}
}
}

Spacer(Modifier.height(SettingItemGap))

Row(horizontalArrangement = Arrangement.spacedBy(SettingItemGap)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@ class ContainerSettingsComposeDialog @JvmOverloads constructor(
context.resources.getStringArray(R.array.bcn_emulation_type_entries).toList()
state.gfxBcnEmulationCacheEntries.value =
context.resources.getStringArray(R.array.bcn_emulation_cache_entries).toList()
state.gfxTranscoderEntries.value =
context.resources.getStringArray(R.array.wrapper_transcoder_entries).toList()
state.gfxQualityEntries.value =
context.resources.getStringArray(R.array.wrapper_quality_entries).toList()

val gpuNames = mutableListOf("Device")
try {
Expand All @@ -1125,6 +1129,8 @@ class ContainerSettingsComposeDialog @JvmOverloads constructor(
selectByValue(state.gfxBcnEmulationEntries.value, config.get("bcnEmulation") ?: "none", state.gfxSelectedBcnEmulation)
selectByValue(state.gfxBcnEmulationTypeEntries.value, config.get("bcnEmulationType") ?: "compute", state.gfxSelectedBcnEmulationType)
selectByValue(state.gfxBcnEmulationCacheEntries.value, config.get("bcnEmulationCache") ?: "0", state.gfxSelectedBcnEmulationCache)
selectByValue(state.gfxTranscoderEntries.value, config.get("transcoder") ?: "cpu", state.gfxSelectedTranscoder)
selectByValue(state.gfxQualityEntries.value, config.get("quality") ?: "low", state.gfxSelectedQuality)
state.gfxSyncFrame.value = config.get("syncFrame") == "1"
state.gfxDisablePresentWait.value = config.get("disablePresentWait") == "1"
state.graphicsDriverVersion.value = config.get("version") ?: ""
Expand Down Expand Up @@ -1286,12 +1292,15 @@ class ContainerSettingsComposeDialog @JvmOverloads constructor(
val bcnEmulation = state.gfxBcnEmulationEntries.value.getOrElse(state.gfxSelectedBcnEmulation.intValue) { "none" }
val bcnEmulationType = state.gfxBcnEmulationTypeEntries.value.getOrElse(state.gfxSelectedBcnEmulationType.intValue) { "compute" }
val bcnEmulationCache = state.gfxBcnEmulationCacheEntries.value.getOrElse(state.gfxSelectedBcnEmulationCache.intValue) { "0" }
val transcoder = state.gfxTranscoderEntries.value.getOrElse(state.gfxSelectedTranscoder.intValue) { "cpu" }
val quality = state.gfxQualityEntries.value.getOrElse(state.gfxSelectedQuality.intValue) { "low" }
return "vulkanVersion=$vulkanVersion;version=$version;blacklistedExtensions=$blacklisted;" +
"maxDeviceMemory=$maxDeviceMemory;presentMode=$presentMode;syncFrame=$syncFrame;" +
"disablePresentWait=$disablePresentWait;resourceType=$resourceType;" +
"bcnEmulation=$bcnEmulation;bcnEmulationType=$bcnEmulationType;" +
"bcnEmulationCache=$bcnEmulationCache;gpuName=$gpuName;" +
"compositorPresentMode=$compositorPresentMode"
"compositorPresentMode=$compositorPresentMode;" +
"transcoder=$transcoder;quality=$quality"
}

private fun buildDxvkConfigFromState(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1815,13 +1815,16 @@ class ShortcutSettingsComposeDialog private constructor(
val bcnEmulation = state.gfxBcnEmulationEntries.value.getOrElse(state.gfxSelectedBcnEmulation.intValue) { "auto" }
val bcnEmulationType = state.gfxBcnEmulationTypeEntries.value.getOrElse(state.gfxSelectedBcnEmulationType.intValue) { "compute" }
val bcnEmulationCache = state.gfxBcnEmulationCacheEntries.value.getOrElse(state.gfxSelectedBcnEmulationCache.intValue) { "0" }
val transcoder = state.gfxTranscoderEntries.value.getOrElse(state.gfxSelectedTranscoder.intValue) { "cpu" }
val quality = state.gfxQualityEntries.value.getOrElse(state.gfxSelectedQuality.intValue) { "low" }

return "vulkanVersion=$vulkanVersion;version=$version;blacklistedExtensions=$blacklisted;" +
"maxDeviceMemory=$maxDeviceMemory;presentMode=$presentMode;syncFrame=$syncFrame;" +
"disablePresentWait=$disablePresentWait;resourceType=$resourceType;" +
"bcnEmulation=$bcnEmulation;bcnEmulationType=$bcnEmulationType;" +
"bcnEmulationCache=$bcnEmulationCache;gpuName=$gpuName;" +
"compositorPresentMode=$compositorPresentMode"
"compositorPresentMode=$compositorPresentMode;" +
"transcoder=$transcoder;quality=$quality"
}

private fun buildDxvkConfigFromState(): String {
Expand Down Expand Up @@ -1861,6 +1864,8 @@ class ShortcutSettingsComposeDialog private constructor(
state.gfxBcnEmulationEntries.value = context.resources.getStringArray(R.array.bcn_emulation_entries).toList()
state.gfxBcnEmulationTypeEntries.value = context.resources.getStringArray(R.array.bcn_emulation_type_entries).toList()
state.gfxBcnEmulationCacheEntries.value = context.resources.getStringArray(R.array.bcn_emulation_cache_entries).toList()
state.gfxTranscoderEntries.value = context.resources.getStringArray(R.array.wrapper_transcoder_entries).toList()
state.gfxQualityEntries.value = context.resources.getStringArray(R.array.wrapper_quality_entries).toList()

val gpuNames = mutableListOf("Device")
try {
Expand Down Expand Up @@ -1888,6 +1893,8 @@ class ShortcutSettingsComposeDialog private constructor(
selectByValue(state.gfxBcnEmulationEntries.value, config["bcnEmulation"] ?: "none", state.gfxSelectedBcnEmulation)
selectByValue(state.gfxBcnEmulationTypeEntries.value, config["bcnEmulationType"] ?: "compute", state.gfxSelectedBcnEmulationType)
selectByValue(state.gfxBcnEmulationCacheEntries.value, config["bcnEmulationCache"] ?: "0", state.gfxSelectedBcnEmulationCache)
selectByValue(state.gfxTranscoderEntries.value, config["transcoder"] ?: "cpu", state.gfxSelectedTranscoder)
selectByValue(state.gfxQualityEntries.value, config["quality"] ?: "low", state.gfxSelectedQuality)

state.gfxSyncFrame.value = config["syncFrame"] == "1"
state.gfxDisablePresentWait.value = config["disablePresentWait"] == "1"
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<string-array name="graphics_driver_entries">
<item>Wrapper</item>
<item>Wrapper-Leegao</item>
<item>Wrapper-Gamenative</item>
</string-array>
<string-array name="wrapper_graphics_driver_version_entries">
<item>System</item>
Expand Down Expand Up @@ -98,6 +99,14 @@
<item>0</item>
<item>1</item>
</string-array>
<string-array name="wrapper_transcoder_entries">
<item>cpu</item>
<item>gpu</item>
</string-array>
<string-array name="wrapper_quality_entries">
<item>low</item>
<item>high</item>
</string-array>
<string-array name="video_memory_size_entries">
<item>32 MB</item>
<item>64 MB</item>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@
<string name="container_graphics_bcn_emulation">BCn Emulation</string>
<string name="container_graphics_bcn_emulation_type">BCn Emulation Type</string>
<string name="container_graphics_bcn_emulation_cache">BCn Emulation Cache</string>
<string name="container_graphics_transcoder">BCn Transcoder</string>
<string name="container_graphics_quality">BCn Quality</string>
<string name="shortcuts_graphics_sgsr_full_title">Snapdragon™ Game Super Resolution 1</string>
<!-- Container > Presets -->
<string name="container_presets_confirm_duplicate">Do you want to duplicate this preset?</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/runtime/container/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Container {
public static final String DEFAULT_DXWRAPPER = "dxvk+vkd3d";
public static final String DEFAULT_DXWRAPPERCONFIG = "version=,async=1,asyncCache=1" + ",vkd3dVersion=None,vkd3dLevel=12_1" + ",ddrawrapper=" + Container.DEFAULT_DDRAWRAPPER + ",csmt=3" + ",gpuName=NVIDIA GeForce GTX 480" + ",videoMemorySize=4096" + ",strict_shader_math=1" + ",OffscreenRenderingMode=fbo" + ",renderer=gl";
public static final String DEFAULT_GRAPHICSDRIVERCONFIG =
"vulkanVersion=1.3" + ";version=" + ";blacklistedExtensions=" + ";maxDeviceMemory=0" + ";presentMode=mailbox" + ";syncFrame=0" + ";disablePresentWait=1" + ";resourceType=auto" + ";bcnEmulation=auto" + ";bcnEmulationType=compute" + ";bcnEmulationCache=0" + ";gpuName=Device";
"vulkanVersion=1.3" + ";version=" + ";blacklistedExtensions=" + ";maxDeviceMemory=0" + ";presentMode=mailbox" + ";syncFrame=0" + ";disablePresentWait=1" + ";resourceType=auto" + ";bcnEmulation=auto" + ";bcnEmulationType=compute" + ";bcnEmulationCache=0" + ";gpuName=Device" + ";transcoder=cpu" + ";quality=low";
public static final String DEFAULT_DDRAWRAPPER = "none";
public static final String DEFAULT_WINCOMPONENTS = "direct3d=1,directsound=0,directmusic=0,directshow=0,directplay=0,xaudio=0,dinput8=1,vcrun2010=1";
public static final String FALLBACK_WINCOMPONENTS = "direct3d=1,directsound=1,directmusic=1,directshow=1,directplay=1,xaudio=1,dinput8=1,vcrun2010=1";
Expand Down
25 changes: 22 additions & 3 deletions app/src/main/runtime/display/XServerDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7574,14 +7574,22 @@ private void extractGraphicsDriverFiles() {
}

boolean wantLeegao = "wrapper-leegao".equals(graphicsDriver);
boolean wantGamenative = "wrapper-gamenative".equals(graphicsDriver);
File leegaoMarker = new File(rootDir, "usr/lib/.wrapper_leegao");
File gamenativeMarker = new File(rootDir, "usr/lib/.wrapper_gamenative");
if (wantLeegao) {
TarCompressorUtils.extract(TarCompressorUtils.Type.ZSTD, this, "graphics_driver/wrapper-leegao.tzst", rootDir);
try { leegaoMarker.createNewFile(); } catch (IOException ignored) {}
} else if (leegaoMarker.exists()) {
gamenativeMarker.delete();
} else if (wantGamenative) {
TarCompressorUtils.extract(TarCompressorUtils.Type.ZSTD, this, "graphics_driver/wrapper-gamenative.tzst", rootDir);
try { gamenativeMarker.createNewFile(); } catch (IOException ignored) {}
leegaoMarker.delete();
} else if (leegaoMarker.exists() || gamenativeMarker.exists()) {
TarCompressorUtils.extract(TarCompressorUtils.Type.ZSTD, this, "graphics_driver/wrapper" + ".tzst", rootDir);
TarCompressorUtils.extract(TarCompressorUtils.Type.ZSTD, this, "layers" + ".tzst", rootDir);
leegaoMarker.delete();
gamenativeMarker.delete();
}

if (adrenoToolsDriverId != null && !adrenoToolsDriverId.isEmpty()
Expand Down Expand Up @@ -7664,16 +7672,20 @@ private void extractGraphicsDriverFiles() {
String bcnEmulation = graphicsDriverConfig.get("bcnEmulation");
String bcnEmulationType = graphicsDriverConfig.get("bcnEmulationType");

int gpuVendorId = GPUInformation.getVendorID(null, null);
// BCn compute shaders are unsupported on Adreno and crash on Xclipse with this wrapper
boolean excludeBcnCompute = gpuVendorId == 20803 || (wantGamenative && gpuVendorId == 0x144D);

switch (bcnEmulation) {
case "auto" -> {
if ("compute".equals(bcnEmulationType) && GPUInformation.getVendorID(null, null) != 20803) {
if ("compute".equals(bcnEmulationType) && !excludeBcnCompute) {
envVars.put("ENABLE_BCN_COMPUTE", "1");
envVars.put("BCN_COMPUTE_AUTO", "1");
}
envVars.put("WRAPPER_EMULATE_BCN", "3");
}
case "full" -> {
if ("compute".equals(bcnEmulationType) && GPUInformation.getVendorID(null, null) != 20803) {
if ("compute".equals(bcnEmulationType) && !excludeBcnCompute) {
envVars.put("ENABLE_BCN_COMPUTE", "1");
envVars.put("BCN_COMPUTE_AUTO", "0");
}
Expand All @@ -7683,6 +7695,13 @@ private void extractGraphicsDriverFiles() {
default -> envVars.put("WRAPPER_EMULATE_BCN", "1");
}

if (wantGamenative) {
String transcoder = graphicsDriverConfig.get("transcoder");
envVars.put("WRAPPER_BCN_GPU", "gpu".equalsIgnoreCase(transcoder) ? "1" : "0");
String wrapperQuality = graphicsDriverConfig.get("quality");
envVars.put("WRAPPER_ASTC_BLOCK", "high".equalsIgnoreCase(wrapperQuality) ? "4x4" : "8x8");
}

String bcnEmulationCache = graphicsDriverConfig.get("bcnEmulationCache");
envVars.put("WRAPPER_USE_BCN_CACHE", bcnEmulationCache);

Expand Down