1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-14 03:06:39 +00:00

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
This commit is contained in:
gdkchan 2021-05-20 16:43:23 -03:00 committed by GitHub
parent b34c0a47b4
commit 12533e5c9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 15 deletions

View file

@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary> /// <summary>
/// Version of the codegen (to be changed when codegen or guest format change). /// Version of the codegen (to be changed when codegen or guest format change).
/// </summary> /// </summary>
private const ulong ShaderCodeGenVersion = 2298; private const ulong ShaderCodeGenVersion = 2300;
// Progress reporting helpers // Progress reporting helpers
private volatile int _shaderCount; private volatile int _shaderCount;

View file

@ -163,6 +163,34 @@ namespace Ryujinx.Graphics.Shader.Translation
Size += size; 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) public void SetClipDistanceWritten(int index)
{ {
ClipDistancesWritten |= (byte)(1 << index); ClipDistancesWritten |= (byte)(1 << index);
@ -268,6 +296,17 @@ namespace Ryujinx.Graphics.Shader.Translation
}; };
if (dict.TryGetValue(info, out var existingMeta)) if (dict.TryGetValue(info, out var existingMeta))
{
dict[info] = MergeTextureMeta(meta, existingMeta);
}
else
{
dict.Add(info, meta);
}
}
}
private static TextureMeta MergeTextureMeta(TextureMeta meta, TextureMeta existingMeta)
{ {
meta.UsageFlags |= existingMeta.UsageFlags; meta.UsageFlags |= existingMeta.UsageFlags;
@ -279,13 +318,7 @@ namespace Ryujinx.Graphics.Shader.Translation
meta.Type = existingMeta.Type; meta.Type = existingMeta.Type;
} }
dict[info] = meta; return meta;
}
else
{
dict.Add(info, meta);
}
}
} }
public BufferDescriptor[] GetConstantBufferDescriptors() public BufferDescriptor[] GetConstantBufferDescriptors()

View file

@ -132,10 +132,9 @@ namespace Ryujinx.Graphics.Shader.Translation
if (other != null) if (other != null)
{ {
_config.SetUsedFeature(other._config.UsedFeatures);
TextureHandlesForCache.UnionWith(other.TextureHandlesForCache);
code = Combine(EmitShader(other._cfg, other._config), code); code = Combine(EmitShader(other._cfg, other._config), code);
_config.InheritFrom(other._config);
} }
return Translator.Translate(code, _config, out shaderProgramInfo); return Translator.Translate(code, _config, out shaderProgramInfo);