2021-05-19 22:15:26 +01:00
|
|
|
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
|
|
|
using System;
|
2020-11-12 23:15:34 +00:00
|
|
|
using System.Collections.Generic;
|
2021-05-19 22:15:26 +01:00
|
|
|
using System.Linq;
|
|
|
|
using System.Numerics;
|
2020-11-12 23:15:34 +00:00
|
|
|
|
2019-12-29 17:41:50 +00:00
|
|
|
namespace Ryujinx.Graphics.Shader.Translation
|
2019-10-13 07:02:07 +01:00
|
|
|
{
|
2020-07-30 06:53:23 +01:00
|
|
|
class ShaderConfig
|
2019-10-13 07:02:07 +01:00
|
|
|
{
|
2021-05-19 22:15:26 +01:00
|
|
|
// TODO: Non-hardcoded array size.
|
|
|
|
public const int SamplerArraySize = 4;
|
|
|
|
|
2019-10-13 07:02:07 +01:00
|
|
|
public ShaderStage Stage { get; }
|
|
|
|
|
2021-01-29 03:38:51 +00:00
|
|
|
public bool GpPassthrough { get; }
|
2022-05-12 14:47:13 +01:00
|
|
|
public bool LastInVertexPipeline { get; private set; }
|
2021-01-29 03:38:51 +00:00
|
|
|
|
2021-10-18 22:38:04 +01:00
|
|
|
public int ThreadsPerInputPrimitive { get; }
|
|
|
|
|
2019-12-16 04:59:46 +00:00
|
|
|
public OutputTopology OutputTopology { get; }
|
|
|
|
|
|
|
|
public int MaxOutputVertices { get; }
|
|
|
|
|
2020-02-02 03:25:52 +00:00
|
|
|
public int LocalMemorySize { get; }
|
|
|
|
|
2020-04-03 01:20:47 +01:00
|
|
|
public ImapPixelType[] ImapTypes { get; }
|
|
|
|
|
2022-02-16 22:15:39 +00:00
|
|
|
public int OmapTargets { get; }
|
|
|
|
public bool OmapSampleMask { get; }
|
|
|
|
public bool OmapDepth { get; }
|
2019-12-01 02:53:09 +00:00
|
|
|
|
2020-05-06 02:02:28 +01:00
|
|
|
public IGpuAccessor GpuAccessor { get; }
|
2019-10-13 07:02:07 +01:00
|
|
|
|
2021-07-06 20:20:06 +01:00
|
|
|
public TranslationOptions Options { get; }
|
2019-10-13 07:02:07 +01:00
|
|
|
|
2022-01-21 15:35:21 +00:00
|
|
|
public bool TransformFeedbackEnabled { get; }
|
|
|
|
|
2020-07-30 06:53:23 +01:00
|
|
|
public int Size { get; private set; }
|
|
|
|
|
2021-04-20 11:33:54 +01:00
|
|
|
public byte ClipDistancesWritten { get; private set; }
|
|
|
|
|
2020-07-30 06:53:23 +01:00
|
|
|
public FeatureFlags UsedFeatures { get; private set; }
|
2020-07-07 03:41:07 +01:00
|
|
|
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
public int Cb1DataSize { get; private set; }
|
2021-05-19 22:15:26 +01:00
|
|
|
|
2021-11-08 16:18:46 +00:00
|
|
|
public bool NextUsesFixedFuncAttributes { get; private set; }
|
2021-08-11 21:27:00 +01:00
|
|
|
public int UsedInputAttributes { get; private set; }
|
|
|
|
public int UsedOutputAttributes { get; private set; }
|
2021-11-08 16:18:46 +00:00
|
|
|
public int UsedInputAttributesPerPatch { get; private set; }
|
2021-10-18 22:38:04 +01:00
|
|
|
public int UsedOutputAttributesPerPatch { get; private set; }
|
2021-08-11 21:27:00 +01:00
|
|
|
public int PassthroughAttributes { get; private set; }
|
2021-11-08 16:18:46 +00:00
|
|
|
private int _nextUsedInputAttributes;
|
|
|
|
private int _thisUsedInputAttributes;
|
2021-08-11 21:27:00 +01:00
|
|
|
|
2022-03-06 19:42:13 +00:00
|
|
|
public UInt128 NextInputAttributesComponents { get; private set; }
|
|
|
|
public UInt128 ThisInputAttributesComponents { get; private set; }
|
|
|
|
public UInt128 NextInputAttributesPerPatchComponents { get; private set; }
|
|
|
|
public UInt128 ThisInputAttributesPerPatchComponents { get; private set; }
|
|
|
|
|
2021-05-19 22:15:26 +01:00
|
|
|
private int _usedConstantBuffers;
|
|
|
|
private int _usedStorageBuffers;
|
|
|
|
private int _usedStorageBuffersWrite;
|
|
|
|
|
|
|
|
private struct TextureInfo : IEquatable<TextureInfo>
|
|
|
|
{
|
|
|
|
public int CbufSlot { get; }
|
|
|
|
public int Handle { get; }
|
|
|
|
public bool Indexed { get; }
|
|
|
|
public TextureFormat Format { get; }
|
|
|
|
|
|
|
|
public TextureInfo(int cbufSlot, int handle, bool indexed, TextureFormat format)
|
|
|
|
{
|
|
|
|
CbufSlot = cbufSlot;
|
|
|
|
Handle = handle;
|
|
|
|
Indexed = indexed;
|
|
|
|
Format = format;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
|
|
|
return obj is TextureInfo other && Equals(other);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool Equals(TextureInfo other)
|
|
|
|
{
|
|
|
|
return CbufSlot == other.CbufSlot && Handle == other.Handle && Indexed == other.Indexed && Format == other.Format;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
|
|
|
return HashCode.Combine(CbufSlot, Handle, Indexed, Format);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private struct TextureMeta
|
|
|
|
{
|
|
|
|
public bool AccurateType;
|
|
|
|
public SamplerType Type;
|
|
|
|
public TextureUsageFlags UsageFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
private readonly Dictionary<TextureInfo, TextureMeta> _usedTextures;
|
|
|
|
private readonly Dictionary<TextureInfo, TextureMeta> _usedImages;
|
|
|
|
|
|
|
|
private BufferDescriptor[] _cachedConstantBufferDescriptors;
|
|
|
|
private BufferDescriptor[] _cachedStorageBufferDescriptors;
|
|
|
|
private TextureDescriptor[] _cachedTextureDescriptors;
|
|
|
|
private TextureDescriptor[] _cachedImageDescriptors;
|
|
|
|
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
private int _firstConstantBufferBinding;
|
|
|
|
private int _firstStorageBufferBinding;
|
|
|
|
|
|
|
|
public int FirstConstantBufferBinding => _firstConstantBufferBinding;
|
|
|
|
public int FirstStorageBufferBinding => _firstStorageBufferBinding;
|
2021-05-20 19:12:15 +01:00
|
|
|
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
public ShaderConfig(IGpuAccessor gpuAccessor, TranslationOptions options)
|
2019-12-16 04:59:46 +00:00
|
|
|
{
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
Stage = ShaderStage.Compute;
|
|
|
|
GpuAccessor = gpuAccessor;
|
|
|
|
Options = options;
|
|
|
|
_usedTextures = new Dictionary<TextureInfo, TextureMeta>();
|
|
|
|
_usedImages = new Dictionary<TextureInfo, TextureMeta>();
|
2019-12-16 04:59:46 +00:00
|
|
|
}
|
|
|
|
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationOptions options) : this(gpuAccessor, options)
|
2019-12-16 04:59:46 +00:00
|
|
|
{
|
2021-10-18 22:38:04 +01:00
|
|
|
Stage = header.Stage;
|
|
|
|
GpPassthrough = header.Stage == ShaderStage.Geometry && header.GpPassthrough;
|
|
|
|
ThreadsPerInputPrimitive = header.ThreadsPerInputPrimitive;
|
|
|
|
OutputTopology = header.OutputTopology;
|
|
|
|
MaxOutputVertices = header.MaxOutputVertexCount;
|
|
|
|
LocalMemorySize = header.ShaderLocalMemoryLowSize + header.ShaderLocalMemoryHighSize;
|
|
|
|
ImapTypes = header.ImapTypes;
|
|
|
|
OmapTargets = header.OmapTargets;
|
|
|
|
OmapSampleMask = header.OmapSampleMask;
|
|
|
|
OmapDepth = header.OmapDepth;
|
2022-01-21 15:35:21 +00:00
|
|
|
TransformFeedbackEnabled = gpuAccessor.QueryTransformFeedbackEnabled();
|
2022-05-12 14:47:13 +01:00
|
|
|
LastInVertexPipeline = header.Stage < ShaderStage.Fragment;
|
2019-12-16 04:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int GetDepthRegister()
|
|
|
|
{
|
|
|
|
// The depth register is always two registers after the last color output.
|
2022-02-16 22:15:39 +00:00
|
|
|
return BitOperations.PopCount((uint)OmapTargets) + 1;
|
2019-12-16 04:59:46 +00:00
|
|
|
}
|
2020-07-04 00:48:44 +01:00
|
|
|
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
public uint ConstantBuffer1Read(int offset)
|
|
|
|
{
|
|
|
|
if (Cb1DataSize < offset + 4)
|
|
|
|
{
|
|
|
|
Cb1DataSize = offset + 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GpuAccessor.ConstantBuffer1Read(offset);
|
|
|
|
}
|
|
|
|
|
2021-05-19 19:05:43 +01:00
|
|
|
public TextureFormat GetTextureFormat(int handle, int cbufSlot = -1)
|
2020-07-04 00:48:44 +01:00
|
|
|
{
|
|
|
|
// When the formatted load extension is supported, we don't need to
|
|
|
|
// specify a format, we can just declare it without a format and the GPU will handle it.
|
2021-08-11 22:01:06 +01:00
|
|
|
if (GpuAccessor.QueryHostSupportsImageLoadFormatted())
|
2020-07-04 00:48:44 +01:00
|
|
|
{
|
|
|
|
return TextureFormat.Unknown;
|
|
|
|
}
|
|
|
|
|
2021-05-19 19:05:43 +01:00
|
|
|
var format = GpuAccessor.QueryTextureFormat(handle, cbufSlot);
|
2020-07-04 00:48:44 +01:00
|
|
|
|
|
|
|
if (format == TextureFormat.Unknown)
|
|
|
|
{
|
|
|
|
GpuAccessor.Log($"Unknown format for texture {handle}.");
|
|
|
|
|
|
|
|
format = TextureFormat.R8G8B8A8Unorm;
|
|
|
|
}
|
|
|
|
|
|
|
|
return format;
|
|
|
|
}
|
2020-07-30 06:53:23 +01:00
|
|
|
|
2021-08-31 06:51:57 +01:00
|
|
|
private bool FormatSupportsAtomic(TextureFormat format)
|
|
|
|
{
|
|
|
|
return format == TextureFormat.R32Sint || format == TextureFormat.R32Uint;
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextureFormat GetTextureFormatAtomic(int handle, int cbufSlot = -1)
|
|
|
|
{
|
2021-10-18 22:38:04 +01:00
|
|
|
// Atomic image instructions do not support GL_EXT_shader_image_load_formatted,
|
2021-08-31 06:51:57 +01:00
|
|
|
// and must have a type specified. Default to R32Sint if not available.
|
|
|
|
|
|
|
|
var format = GpuAccessor.QueryTextureFormat(handle, cbufSlot);
|
|
|
|
|
|
|
|
if (!FormatSupportsAtomic(format))
|
|
|
|
{
|
|
|
|
GpuAccessor.Log($"Unsupported format for texture {handle}: {format}.");
|
|
|
|
|
|
|
|
format = TextureFormat.R32Sint;
|
|
|
|
}
|
|
|
|
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
2020-07-30 06:53:23 +01:00
|
|
|
public void SizeAdd(int size)
|
|
|
|
{
|
|
|
|
Size += size;
|
|
|
|
}
|
|
|
|
|
2021-05-20 20:43:23 +01:00
|
|
|
public void InheritFrom(ShaderConfig other)
|
|
|
|
{
|
|
|
|
ClipDistancesWritten |= other.ClipDistancesWritten;
|
|
|
|
UsedFeatures |= other.UsedFeatures;
|
|
|
|
|
2021-08-11 21:27:00 +01:00
|
|
|
UsedInputAttributes |= other.UsedInputAttributes;
|
|
|
|
UsedOutputAttributes |= other.UsedOutputAttributes;
|
2021-05-20 20:43:23 +01:00
|
|
|
_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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 16:18:46 +00:00
|
|
|
public void SetInputUserAttributeFixedFunc(int index)
|
|
|
|
{
|
|
|
|
UsedInputAttributes |= 1 << index;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetOutputUserAttributeFixedFunc(int index)
|
|
|
|
{
|
|
|
|
UsedOutputAttributes |= 1 << index;
|
|
|
|
}
|
|
|
|
|
2022-03-06 19:42:13 +00:00
|
|
|
public void SetInputUserAttribute(int index, int component, bool perPatch)
|
2021-08-11 21:27:00 +01:00
|
|
|
{
|
2021-10-18 22:38:04 +01:00
|
|
|
if (perPatch)
|
|
|
|
{
|
|
|
|
UsedInputAttributesPerPatch |= 1 << index;
|
2022-03-06 19:42:13 +00:00
|
|
|
ThisInputAttributesPerPatchComponents |= UInt128.Pow2(index * 4 + component);
|
2021-10-18 22:38:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-08 16:18:46 +00:00
|
|
|
int mask = 1 << index;
|
|
|
|
|
|
|
|
UsedInputAttributes |= mask;
|
|
|
|
_thisUsedInputAttributes |= mask;
|
2022-03-06 19:42:13 +00:00
|
|
|
ThisInputAttributesComponents |= UInt128.Pow2(index * 4 + component);
|
2021-10-18 22:38:04 +01:00
|
|
|
}
|
2021-08-11 21:27:00 +01:00
|
|
|
}
|
|
|
|
|
2021-10-18 22:38:04 +01:00
|
|
|
public void SetOutputUserAttribute(int index, bool perPatch)
|
2021-08-11 21:27:00 +01:00
|
|
|
{
|
2021-10-18 22:38:04 +01:00
|
|
|
if (perPatch)
|
|
|
|
{
|
|
|
|
UsedOutputAttributesPerPatch |= 1 << index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UsedOutputAttributes |= 1 << index;
|
|
|
|
}
|
2021-08-11 21:27:00 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 16:18:46 +00:00
|
|
|
public void MergeFromtNextStage(ShaderConfig config)
|
|
|
|
{
|
2022-03-06 19:42:13 +00:00
|
|
|
NextInputAttributesComponents = config.ThisInputAttributesComponents;
|
|
|
|
NextInputAttributesPerPatchComponents = config.ThisInputAttributesPerPatchComponents;
|
2021-11-08 16:18:46 +00:00
|
|
|
NextUsesFixedFuncAttributes = config.UsedFeatures.HasFlag(FeatureFlags.FixedFuncAttr);
|
|
|
|
MergeOutputUserAttributes(config.UsedInputAttributes, config.UsedInputAttributesPerPatch);
|
2022-05-12 14:47:13 +01:00
|
|
|
|
|
|
|
if (config.Stage != ShaderStage.Fragment)
|
|
|
|
{
|
|
|
|
LastInVertexPipeline = false;
|
|
|
|
}
|
2021-11-08 16:18:46 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 22:38:04 +01:00
|
|
|
public void MergeOutputUserAttributes(int mask, int maskPerPatch)
|
2021-08-11 21:27:00 +01:00
|
|
|
{
|
2021-11-08 16:18:46 +00:00
|
|
|
_nextUsedInputAttributes = mask;
|
|
|
|
|
2021-08-11 21:27:00 +01:00
|
|
|
if (GpPassthrough)
|
|
|
|
{
|
|
|
|
PassthroughAttributes = mask & ~UsedOutputAttributes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UsedOutputAttributes |= mask;
|
2021-10-18 22:38:04 +01:00
|
|
|
UsedOutputAttributesPerPatch |= maskPerPatch;
|
2021-08-11 21:27:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 16:18:46 +00:00
|
|
|
public bool IsUsedOutputAttribute(int attr)
|
|
|
|
{
|
|
|
|
// The check for fixed function attributes on the next stage is conservative,
|
|
|
|
// returning false if the output is just not used by the next stage is also valid.
|
|
|
|
if (NextUsesFixedFuncAttributes &&
|
|
|
|
attr >= AttributeConsts.UserAttributeBase &&
|
|
|
|
attr < AttributeConsts.UserAttributeEnd)
|
|
|
|
{
|
|
|
|
int index = (attr - AttributeConsts.UserAttributeBase) >> 4;
|
|
|
|
return (_nextUsedInputAttributes & (1 << index)) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int GetFreeUserAttribute(bool isOutput, int index)
|
|
|
|
{
|
|
|
|
int useMask = isOutput ? _nextUsedInputAttributes : _thisUsedInputAttributes;
|
|
|
|
int bit = -1;
|
|
|
|
|
|
|
|
while (useMask != -1)
|
|
|
|
{
|
|
|
|
bit = BitOperations.TrailingZeroCount(~useMask);
|
|
|
|
|
|
|
|
if (bit == 32)
|
|
|
|
{
|
|
|
|
bit = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (index < 1)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
useMask |= 1 << bit;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bit;
|
|
|
|
}
|
|
|
|
|
2021-08-27 00:44:47 +01:00
|
|
|
public void SetAllInputUserAttributes()
|
|
|
|
{
|
|
|
|
UsedInputAttributes |= Constants.AllAttributesMask;
|
2022-03-14 23:02:50 +00:00
|
|
|
ThisInputAttributesComponents |= ~UInt128.Zero >> (128 - Constants.MaxAttributes * 4);
|
2021-08-27 00:44:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetAllOutputUserAttributes()
|
|
|
|
{
|
|
|
|
UsedOutputAttributes |= Constants.AllAttributesMask;
|
|
|
|
}
|
|
|
|
|
2021-04-20 11:33:54 +01:00
|
|
|
public void SetClipDistanceWritten(int index)
|
|
|
|
{
|
|
|
|
ClipDistancesWritten |= (byte)(1 << index);
|
|
|
|
}
|
|
|
|
|
2020-07-30 06:53:23 +01:00
|
|
|
public void SetUsedFeature(FeatureFlags flags)
|
|
|
|
{
|
|
|
|
UsedFeatures |= flags;
|
|
|
|
}
|
2021-05-19 22:15:26 +01:00
|
|
|
|
|
|
|
public Operand CreateCbuf(int slot, int offset)
|
|
|
|
{
|
|
|
|
SetUsedConstantBuffer(slot);
|
|
|
|
return OperandHelper.Cbuf(slot, offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetUsedConstantBuffer(int slot)
|
|
|
|
{
|
|
|
|
_usedConstantBuffers |= 1 << slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetUsedStorageBuffer(int slot, bool write)
|
|
|
|
{
|
|
|
|
int mask = 1 << slot;
|
|
|
|
_usedStorageBuffers |= mask;
|
|
|
|
|
|
|
|
if (write)
|
|
|
|
{
|
|
|
|
_usedStorageBuffersWrite |= mask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetUsedTexture(
|
|
|
|
Instruction inst,
|
|
|
|
SamplerType type,
|
|
|
|
TextureFormat format,
|
|
|
|
TextureFlags flags,
|
|
|
|
int cbufSlot,
|
|
|
|
int handle)
|
|
|
|
{
|
|
|
|
inst &= Instruction.Mask;
|
2021-08-31 06:51:57 +01:00
|
|
|
bool isImage = inst == Instruction.ImageLoad || inst == Instruction.ImageStore || inst == Instruction.ImageAtomic;
|
|
|
|
bool isWrite = inst == Instruction.ImageStore || inst == Instruction.ImageAtomic;
|
2022-02-18 01:44:46 +00:00
|
|
|
bool accurateType = inst != Instruction.Lod && inst != Instruction.TextureSize;
|
2021-10-28 23:53:12 +01:00
|
|
|
bool coherent = flags.HasFlag(TextureFlags.Coherent);
|
2021-05-19 22:15:26 +01:00
|
|
|
|
|
|
|
if (isImage)
|
|
|
|
{
|
2021-10-28 23:53:12 +01:00
|
|
|
SetUsedTextureOrImage(_usedImages, cbufSlot, handle, type, format, true, isWrite, false, coherent);
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-09 04:09:07 +01:00
|
|
|
bool intCoords = flags.HasFlag(TextureFlags.IntCoords) || inst == Instruction.TextureSize;
|
2021-10-28 23:53:12 +01:00
|
|
|
SetUsedTextureOrImage(_usedTextures, cbufSlot, handle, type, TextureFormat.Unknown, intCoords, false, accurateType, coherent);
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
|
|
|
|
GpuAccessor.RegisterTexture(handle, cbufSlot);
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
|
|
|
|
2021-05-20 19:12:15 +01:00
|
|
|
private void SetUsedTextureOrImage(
|
2021-05-19 22:15:26 +01:00
|
|
|
Dictionary<TextureInfo, TextureMeta> dict,
|
|
|
|
int cbufSlot,
|
|
|
|
int handle,
|
|
|
|
SamplerType type,
|
|
|
|
TextureFormat format,
|
|
|
|
bool intCoords,
|
|
|
|
bool write,
|
2021-10-28 23:53:12 +01:00
|
|
|
bool accurateType,
|
|
|
|
bool coherent)
|
2021-05-19 22:15:26 +01:00
|
|
|
{
|
|
|
|
var dimensions = type.GetDimensions();
|
|
|
|
var isIndexed = type.HasFlag(SamplerType.Indexed);
|
|
|
|
|
|
|
|
var usageFlags = TextureUsageFlags.None;
|
|
|
|
|
|
|
|
if (intCoords)
|
|
|
|
{
|
|
|
|
usageFlags |= TextureUsageFlags.NeedsScaleValue;
|
|
|
|
|
2022-01-08 17:48:48 +00:00
|
|
|
var canScale = Stage.SupportsRenderScale() && !isIndexed && !write && dimensions == 2;
|
2021-05-20 19:12:15 +01:00
|
|
|
|
2021-05-19 22:15:26 +01:00
|
|
|
if (!canScale)
|
|
|
|
{
|
|
|
|
// Resolution scaling cannot be applied to this texture right now.
|
|
|
|
// Flag so that we know to blacklist scaling on related textures when binding them.
|
|
|
|
usageFlags |= TextureUsageFlags.ResScaleUnsupported;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (write)
|
|
|
|
{
|
|
|
|
usageFlags |= TextureUsageFlags.ImageStore;
|
|
|
|
}
|
|
|
|
|
2021-10-28 23:53:12 +01:00
|
|
|
if (coherent)
|
|
|
|
{
|
|
|
|
usageFlags |= TextureUsageFlags.ImageCoherent;
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:15:26 +01:00
|
|
|
int arraySize = isIndexed ? SamplerArraySize : 1;
|
|
|
|
|
|
|
|
for (int layer = 0; layer < arraySize; layer++)
|
|
|
|
{
|
|
|
|
var info = new TextureInfo(cbufSlot, handle + layer * 2, isIndexed, format);
|
|
|
|
var meta = new TextureMeta()
|
|
|
|
{
|
|
|
|
AccurateType = accurateType,
|
|
|
|
Type = type,
|
|
|
|
UsageFlags = usageFlags
|
|
|
|
};
|
|
|
|
|
|
|
|
if (dict.TryGetValue(info, out var existingMeta))
|
|
|
|
{
|
2021-05-20 20:43:23 +01:00
|
|
|
dict[info] = MergeTextureMeta(meta, existingMeta);
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dict.Add(info, meta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-20 20:43:23 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:15:26 +01:00
|
|
|
public BufferDescriptor[] GetConstantBufferDescriptors()
|
|
|
|
{
|
|
|
|
if (_cachedConstantBufferDescriptors != null)
|
|
|
|
{
|
|
|
|
return _cachedConstantBufferDescriptors;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usedMask = _usedConstantBuffers;
|
|
|
|
|
|
|
|
if (UsedFeatures.HasFlag(FeatureFlags.CbIndexing))
|
|
|
|
{
|
2021-05-20 19:12:15 +01:00
|
|
|
usedMask |= (int)GpuAccessor.QueryConstantBufferUse();
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
|
|
|
|
2021-05-20 19:12:15 +01:00
|
|
|
return _cachedConstantBufferDescriptors = GetBufferDescriptors(
|
|
|
|
usedMask,
|
|
|
|
0,
|
|
|
|
UsedFeatures.HasFlag(FeatureFlags.CbIndexing),
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
out _firstConstantBufferBinding,
|
|
|
|
GpuAccessor.QueryBindingConstantBuffer);
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public BufferDescriptor[] GetStorageBufferDescriptors()
|
|
|
|
{
|
2021-05-20 19:12:15 +01:00
|
|
|
if (_cachedStorageBufferDescriptors != null)
|
|
|
|
{
|
|
|
|
return _cachedStorageBufferDescriptors;
|
|
|
|
}
|
2021-05-19 22:15:26 +01:00
|
|
|
|
2021-05-20 19:12:15 +01:00
|
|
|
return _cachedStorageBufferDescriptors = GetBufferDescriptors(
|
|
|
|
_usedStorageBuffers,
|
|
|
|
_usedStorageBuffersWrite,
|
|
|
|
true,
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
out _firstStorageBufferBinding,
|
|
|
|
GpuAccessor.QueryBindingStorageBuffer);
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
|
|
|
|
2021-05-20 19:12:15 +01:00
|
|
|
private static BufferDescriptor[] GetBufferDescriptors(
|
|
|
|
int usedMask,
|
|
|
|
int writtenMask,
|
|
|
|
bool isArray,
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
out int firstBinding,
|
|
|
|
Func<int, int> getBindingCallback)
|
2021-05-19 22:15:26 +01:00
|
|
|
{
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
firstBinding = 0;
|
|
|
|
bool hasFirstBinding = false;
|
2021-05-19 22:15:26 +01:00
|
|
|
var descriptors = new BufferDescriptor[BitOperations.PopCount((uint)usedMask)];
|
|
|
|
|
2021-05-20 19:12:15 +01:00
|
|
|
int lastSlot = -1;
|
|
|
|
|
2021-05-19 22:15:26 +01:00
|
|
|
for (int i = 0; i < descriptors.Length; i++)
|
|
|
|
{
|
|
|
|
int slot = BitOperations.TrailingZeroCount(usedMask);
|
|
|
|
|
2021-05-20 19:12:15 +01:00
|
|
|
if (isArray)
|
|
|
|
{
|
|
|
|
// The next array entries also consumes bindings, even if they are unused.
|
|
|
|
for (int j = lastSlot + 1; j < slot; j++)
|
|
|
|
{
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
int binding = getBindingCallback(j);
|
|
|
|
|
|
|
|
if (!hasFirstBinding)
|
|
|
|
{
|
|
|
|
firstBinding = binding;
|
|
|
|
hasFirstBinding = true;
|
|
|
|
}
|
2021-05-20 19:12:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lastSlot = slot;
|
|
|
|
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
descriptors[i] = new BufferDescriptor(getBindingCallback(slot), slot);
|
|
|
|
|
|
|
|
if (!hasFirstBinding)
|
|
|
|
{
|
|
|
|
firstBinding = descriptors[i].Binding;
|
|
|
|
hasFirstBinding = true;
|
|
|
|
}
|
2021-05-19 22:15:26 +01:00
|
|
|
|
|
|
|
if ((writtenMask & (1 << slot)) != 0)
|
|
|
|
{
|
|
|
|
descriptors[i].SetFlag(BufferUsageFlags.Write);
|
|
|
|
}
|
|
|
|
|
|
|
|
usedMask &= ~(1 << slot);
|
|
|
|
}
|
|
|
|
|
|
|
|
return descriptors;
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextureDescriptor[] GetTextureDescriptors()
|
|
|
|
{
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
return _cachedTextureDescriptors ??= GetTextureOrImageDescriptors(_usedTextures, GpuAccessor.QueryBindingTexture);
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public TextureDescriptor[] GetImageDescriptors()
|
|
|
|
{
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
return _cachedImageDescriptors ??= GetTextureOrImageDescriptors(_usedImages, GpuAccessor.QueryBindingImage);
|
2021-05-19 22:15:26 +01:00
|
|
|
}
|
|
|
|
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
private static TextureDescriptor[] GetTextureOrImageDescriptors(Dictionary<TextureInfo, TextureMeta> dict, Func<int, int> getBindingCallback)
|
2021-05-19 22:15:26 +01:00
|
|
|
{
|
|
|
|
var descriptors = new TextureDescriptor[dict.Count];
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
foreach (var kv in dict.OrderBy(x => x.Key.Indexed).OrderBy(x => x.Key.Handle))
|
|
|
|
{
|
|
|
|
var info = kv.Key;
|
|
|
|
var meta = kv.Value;
|
|
|
|
|
New shader cache implementation (#3194)
* New shader cache implementation
* Remove some debug code
* Take transform feedback varying count into account
* Create shader cache directory if it does not exist + fragment output map related fixes
* Remove debug code
* Only check texture descriptors if the constant buffer is bound
* Also check CPU VA on GetSpanMapped
* Remove more unused code and move cache related code
* XML docs + remove more unused methods
* Better codegen for TransformFeedbackDescriptor.AsSpan
* Support migration from old cache format, remove more unused code
Shader cache rebuild now also rewrites the shared toc and data files
* Fix migration error with BRX shaders
* Add a limit to the async translation queue
Avoid async translation threads not being able to keep up and the queue growing very large
* Re-create specialization state on recompile
This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access
* Make shader cache more error resilient
* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc
* Address early PR feedback
* Fix rebase
* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly
* Handle some missing exceptions
* Make shader cache purge delete both old and new shader caches
* Register textures on new specialization state
* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)
* Limit in-flight shader compilation to the maximum number of compilation threads
* Replace ParallelDiskCacheLoader state changed event with a callback function
* Better handling for invalid constant buffer 1 data length
* Do not create the old cache directory structure if the old cache does not exist
* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)
* Replace rectangle texture with just coordinate normalization
* Skip incompatible shaders that are missing texture information, instead of crashing
This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable
* Fix coordinates normalization on cubemap textures
* Check if title ID is null before combining shader cache path
* More robust constant buffer address validation on spec state
* More robust constant buffer address validation on spec state (2)
* Regenerate shader cache with one stream, rather than one per shader.
* Only create shader cache directory during initialization
* Logging improvements
* Proper shader program disposal
* PR feedback, and add a comment on serialized structs
* XML docs for RegisterTexture
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 14:49:44 +01:00
|
|
|
int binding = getBindingCallback(i);
|
2021-05-19 22:15:26 +01:00
|
|
|
|
|
|
|
descriptors[i] = new TextureDescriptor(binding, meta.Type, info.Format, info.CbufSlot, info.Handle);
|
|
|
|
descriptors[i].SetFlag(meta.UsageFlags);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return descriptors;
|
|
|
|
}
|
2019-10-13 07:02:07 +01:00
|
|
|
}
|
|
|
|
}
|