aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-05-20 16:43:23 -0300
committerGitHub <noreply@github.com>2021-05-20 21:43:23 +0200
commit12533e5c9de779a76fb9c1b8406cef33ab0e4ba0 (patch)
tree4ac5e0942a800f55153c3c742d745d01109245ee
parentb34c0a47b4d5d9cc4b3a6b51fbc76fe2b493b07d (diff)
Fix buffer and texture uses not being propagated for vertex A/B shaders (#2300)
* Fix buffer and texture uses not being propagated for vertex A/B shaders * Shader cache version bump
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs2
-rw-r--r--Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs55
-rw-r--r--Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs5
3 files changed, 47 insertions, 15 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index 158b791a..d752b1b0 100644
--- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>
/// Version of the codegen (to be changed when codegen or guest format change).
/// </summary>
- private const ulong ShaderCodeGenVersion = 2298;
+ private const ulong ShaderCodeGenVersion = 2300;
// Progress reporting helpers
private volatile int _shaderCount;
diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
index 8004e313..b193d61e 100644
--- a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
+++ b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
@@ -163,6 +163,34 @@ namespace Ryujinx.Graphics.Shader.Translation
Size += size;
}
+ public void InheritFrom(ShaderConfig other)
+ {
+ ClipDistancesWritten |= other.ClipDistancesWritten;
+ UsedFeatures |= other.UsedFeatures;
+
+ TextureHandlesForCache.UnionWith(other.TextureHandlesForCache);
+
+ _usedConstantBuffers |= other._usedConstantBuffers;
+ _usedStorageBuffers |= other._usedStorageBuffers;
+ _usedStorageBuffersWrite |= other._usedStorageBuffersWrite;
+
+ foreach (var kv in other._usedTextures)
+ {
+ if (!_usedTextures.TryAdd(kv.Key, kv.Value))
+ {
+ _usedTextures[kv.Key] = MergeTextureMeta(kv.Value, _usedTextures[kv.Key]);
+ }
+ }
+
+ foreach (var kv in other._usedImages)
+ {
+ if (!_usedImages.TryAdd(kv.Key, kv.Value))
+ {
+ _usedImages[kv.Key] = MergeTextureMeta(kv.Value, _usedImages[kv.Key]);
+ }
+ }
+ }
+
public void SetClipDistanceWritten(int index)
{
ClipDistancesWritten |= (byte)(1 << index);
@@ -269,17 +297,7 @@ namespace Ryujinx.Graphics.Shader.Translation
if (dict.TryGetValue(info, out var existingMeta))
{
- meta.UsageFlags |= existingMeta.UsageFlags;
-
- // If the texture we have has inaccurate type information, then
- // we prefer the most accurate one.
- if (existingMeta.AccurateType)
- {
- meta.AccurateType = true;
- meta.Type = existingMeta.Type;
- }
-
- dict[info] = meta;
+ dict[info] = MergeTextureMeta(meta, existingMeta);
}
else
{
@@ -288,6 +306,21 @@ namespace Ryujinx.Graphics.Shader.Translation
}
}
+ private static TextureMeta MergeTextureMeta(TextureMeta meta, TextureMeta existingMeta)
+ {
+ meta.UsageFlags |= existingMeta.UsageFlags;
+
+ // If the texture we have has inaccurate type information, then
+ // we prefer the most accurate one.
+ if (existingMeta.AccurateType)
+ {
+ meta.AccurateType = true;
+ meta.Type = existingMeta.Type;
+ }
+
+ return meta;
+ }
+
public BufferDescriptor[] GetConstantBufferDescriptors()
{
if (_cachedConstantBufferDescriptors != null)
diff --git a/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs b/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs
index 649911a2..ab74d039 100644
--- a/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs
+++ b/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs
@@ -132,10 +132,9 @@ namespace Ryujinx.Graphics.Shader.Translation
if (other != null)
{
- _config.SetUsedFeature(other._config.UsedFeatures);
- TextureHandlesForCache.UnionWith(other.TextureHandlesForCache);
-
code = Combine(EmitShader(other._cfg, other._config), code);
+
+ _config.InheritFrom(other._config);
}
return Translator.Translate(code, _config, out shaderProgramInfo);