Skip to content

Commit

Permalink
Implement sample shading option
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishan09811 authored Jul 30, 2024
1 parent 0dd6c15 commit 9458e12
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/src/main/cpp/skyline/common/android_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace skyline {
useDirectMemoryImport = ktSettings.GetBool("useDirectMemoryImport");
forceMaxGpuClocks = ktSettings.GetBool("forceMaxGpuClocks");
disableShaderCache = ktSettings.GetBool("disableShaderCache");
enableSampleShading = ktSetting.GetBool("enableSampleShading");
freeGuestTextureMemory = ktSettings.GetBool("freeGuestTextureMemory");
enableFastGpuReadbackHack = ktSettings.GetBool("enableFastGpuReadbackHack");
enableFastReadbackWrites = ktSettings.GetBool("enableFastReadbackWrites");
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/skyline/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace skyline {
Setting<bool> useDirectMemoryImport; //!< If buffer emulation should be done by importing guest buffer mappings
Setting<bool> forceMaxGpuClocks; //!< If the GPU should be forced to run at maximum clocks
Setting<bool> freeGuestTextureMemory; //!< If guest textrue memory should be freed when the owning texture is GPU dirty
Setting<bool> enableSampleShading;

// Hacks
Setting<bool> enableFastGpuReadbackHack; //!< If the CPU texture readback skipping hack should be used
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/skyline/gpu/shaders/helper_shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace skyline::gpu {

constexpr static vk::PipelineMultisampleStateCreateInfo multisampleState{
.rasterizationSamples = vk::SampleCountFlagBits::e1,
.sampleShadingEnable = false,
.sampleShadingEnable = *state.settings->enableSampleShading,
.minSampleShading = 1.0f,
.alphaToCoverageEnable = false,
.alphaToOneEnable = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class EmulationSettings private constructor(context : Context, prefName : String
var freeGuestTextureMemory by sharedPreferences(context, true, prefName = prefName)
var disableShaderCache by sharedPreferences(context, false, prefName = prefName)
var enableDynamicResolution by sharedPreferences(context, false, prefName = prefName)
var enableSampleShading by sharedPreferences(context, false, prefName = prefName)

// Hacks
var enableFastGpuReadbackHack by sharedPreferences(context, false, prefName = prefName)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/emu/skyline/settings/NativeSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ data class NativeSettings(
var forceMaxGpuClocks : Boolean,
var freeGuestTextureMemory : Boolean,
var disableShaderCache : Boolean,
var enableSampleShading : Boolean,

// Hacks
var enableFastGpuReadbackHack : Boolean,
Expand Down Expand Up @@ -66,6 +67,7 @@ data class NativeSettings(
pref.forceMaxGpuClocks,
pref.freeGuestTextureMemory,
pref.disableShaderCache,
pref.enableSampleShading,
pref.enableFastGpuReadbackHack,
pref.enableFastReadbackWrites,
pref.disableSubgroupShuffle,
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@
<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="enable_dynamic_resolution">Enable Dynamic Resolution</string>
<string name="enable_dynamic_resolution_enabled">the emulator will allow the GPU to dynamically adjust the resolution based on the current load. This can help maintain performance by lowering the resolution during high-load scenarios</string>
<string name="enable_dynamic_resolution_disabled">the emulator will report less elapsed GPU time than actually passed. This prevents the GPU from lowering the resolution, maintaining a consistent resolution regardless of load. This can result in smoother and more consistent visuals at the cost of potentially higher performance requirements</string>
<string name="enable_dynamic_resolution_enabled">The emulator will allow the GPU to dynamically adjust the resolution based on the current load. This can help maintain performance by lowering the resolution during high-load scenarios</string>
<string name="enable_dynamic_resolution_disabled">The emulator will report less elapsed GPU time than actually passed. This prevents the GPU from lowering the resolution, maintaining a consistent resolution regardless of load. This can result in smoother and more consistent visuals at the cost of potentially higher performance requirements</string>
<string name="enable_sample_shading">Enable Sample Shading</string>
<string name="enable_sample_shading_desc">May improve the quality of rendering at the cost of performance</string>
<!-- Settings - Hacks -->
<string name="hacks">Hacks</string>
<string name="enable_fast_gpu_readback">Enable Fast GPU Readback</string>
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/res/xml/emulation_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@
android:summaryOn="@string/shader_cache_disabled"
app:key="disable_shader_cache"
app:title="@string/shader_cache" />

<SwitchPreferenceCompat
android:defaultValue="false"
android:summaryOff="@string/enable_dynamic_resolution_disabled"
android:summaryOn="@string/enable_dynamic_resolution_enabled"
app:key="enable_dynamic_resolution"
app:title="@string/enable_dynamic_resolution" />

<SwitchPreferenceCompat
android:defaultValue="false"
android:summary="@string/enable_sample_shading_desc"
app:key="enable_sample_shading"
app:title="@string/enable_sample_shading" />
</PreferenceCategory>
<PreferenceCategory
android:key="category_hacks"
Expand Down

0 comments on commit 9458e12

Please sign in to comment.