Add option to enable/disable shader cache

This commit is contained in:
PabloG02 2023-01-13 16:50:43 +01:00 committed by Billy Laws
parent 8bfda0d84d
commit 8b9d6f79ab
10 changed files with 23 additions and 3 deletions

View File

@ -45,6 +45,7 @@ namespace skyline {
useDirectMemoryImport = ktSettings.GetBool("useDirectMemoryImport");
forceMaxGpuClocks = ktSettings.GetBool("forceMaxGpuClocks");
enableFastGpuReadbackHack = ktSettings.GetBool("enableFastGpuReadbackHack");
disableShaderCache = ktSettings.GetBool("disableShaderCache");
isAudioOutputDisabled = ktSettings.GetBool("isAudioOutputDisabled");
validationLayer = ktSettings.GetBool("validationLayer");
};

View File

@ -68,6 +68,7 @@ namespace skyline {
// Display
Setting<bool> forceTripleBuffering; //!< If the presentation engine should always triple buffer even if the swapchain supports double buffering
Setting<bool> disableFrameThrottling; //!< Allow the guest to submit frames without any blocking calls
Setting<bool> disableShaderCache; //!< Prevents cached shaders from being loaded and disables caching of new shaders
// GPU
Setting<std::string> gpuDriver; //!< The label of the GPU driver to use

View File

@ -400,6 +400,7 @@ namespace skyline::gpu {
buffer(*this),
megaBufferAllocator(*this),
descriptor(*this),
shader(state, *this),
helperShaders(*this, state.os->assetFileSystem),
graphicsPipelineCache(*this),
renderPassCache(*this),
@ -410,8 +411,9 @@ namespace skyline::gpu {
shader.emplace(state, *this,
state.os->publicAppFilesPath + "shader_replacements/" + titleId,
state.os->publicAppFilesPath + "shader_dumps/" + titleId);
graphicsPipelineCacheManager.emplace(state,
state.os->publicAppFilesPath + "graphics_pipeline_cache/" + titleId);
if (!*state.settings->disableShaderCache)
graphicsPipelineCacheManager.emplace(state,
state.os->publicAppFilesPath + "graphics_pipeline_cache/" + titleId);
graphicsPipelineManager.emplace(*this);
}
}

View File

@ -32,6 +32,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
}
void RuntimeGraphicsPipelineStateAccessor::MarkComplete() {
ctx.gpu.graphicsPipelineCacheManager->QueueWrite(std::move(bundle));
if (ctx.gpu.graphicsPipelineCacheManager)
ctx.gpu.graphicsPipelineCacheManager->QueueWrite(std::move(bundle));
}
}

View File

@ -881,6 +881,9 @@ namespace skyline::gpu::interconnect::maxwell3d {
}
PipelineManager::PipelineManager(GPU &gpu) {
if (!gpu.graphicsPipelineCacheManager)
return;
std::ifstream stream{gpu.graphicsPipelineCacheManager->OpenReadStream()};
i64 lastKnownGoodOffset{stream.tellg()};
try {

View File

@ -22,6 +22,7 @@ class NativeSettings(context : Context, pref : PreferenceSettings) {
// Display
var forceTripleBuffering : Boolean = pref.forceTripleBuffering
var disableFrameThrottling : Boolean = pref.disableFrameThrottling
var disableShaderCache : Boolean = pref.disableShaderCache
// GPU
var gpuDriver : String = if (pref.gpuDriver == PreferenceSettings.SYSTEM_GPU_DRIVER) "" else pref.gpuDriver

View File

@ -38,6 +38,7 @@ class PreferenceSettings @Inject constructor(@ApplicationContext private val con
var aspectRatio by sharedPreferences(context, 0)
var orientation by sharedPreferences(context, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
var respectDisplayCutout by sharedPreferences(context, false)
var disableShaderCache by sharedPreferences(context, false)
// GPU
var gpuDriver by sharedPreferences(context, SYSTEM_GPU_DRIVER)

View File

@ -120,6 +120,7 @@
android:textColor="?attr/colorAccent"
app:icon="@drawable/ic_add_home"
app:iconGravity="textStart"
android:padding="0dp"
app:iconPadding="0dp" />
</com.google.android.flexbox.FlexboxLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -38,8 +38,11 @@
<string name="select_action_desc_on">Game information will be shown on clicking a game</string>
<string name="select_action_desc_off">Game information will only be shown on long-clicking a game</string>
<string name="perf_stats">Show Performance Statistics</string>
<string name="shader_cache">Disable shader cache</string>
<string name="perf_stats_desc_off">Performance Statistics will not be shown</string>
<string name="perf_stats_desc_on">Performance Statistics will be shown in the top-left corner</string>
<string name="shader_cache_disabled">Cached shaders won\'t be loaded, will cause stutters</string>
<string name="shader_cache_enabled">Cached shaders will be loaded, can heavily reduce stuttering</string>
<string name="log_level">Log Level</string>
<string name="gpu_driver_config">GPU Driver Configuration</string>
<string name="gpu_driver_config_desc">Active driver: %1$s</string>

View File

@ -170,6 +170,12 @@
android:summary="@string/force_max_gpu_clocks_desc"
app:key="force_max_gpu_clocks"
app:title="@string/force_max_gpu_clocks" />
<CheckBoxPreference
android:defaultValue="false"
android:summaryOff="@string/shader_cache_enabled"
android:summaryOn="@string/shader_cache_disabled"
app:key="disable_shader_cache"
app:title="@string/shader_cache" />
</PreferenceCategory>
<PreferenceCategory
android:key="category_hacks"