2022-04-12 20:28:04 +00:00
|
|
|
using Ryujinx.Common.Logging;
|
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 13:49:44 +00:00
|
|
|
using Ryujinx.Graphics.GAL;
|
|
|
|
using Ryujinx.Graphics.Gpu.Engine.Threed;
|
2020-11-12 23:15:34 +00:00
|
|
|
using Ryujinx.Graphics.Gpu.Image;
|
|
|
|
using Ryujinx.Graphics.Shader;
|
2021-08-12 06:09:56 +00:00
|
|
|
using Ryujinx.Graphics.Shader.Translation;
|
2020-11-12 23:15:34 +00:00
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gpu.Shader
|
|
|
|
{
|
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 13:49:44 +00:00
|
|
|
/// <summary>
|
|
|
|
/// GPU accessor.
|
|
|
|
/// </summary>
|
|
|
|
class GpuAccessorBase
|
2020-11-12 23:15:34 +00:00
|
|
|
{
|
2021-08-11 21:56:59 +00:00
|
|
|
private readonly GpuContext _context;
|
2021-08-12 06:09:56 +00:00
|
|
|
private readonly ResourceCounts _resourceCounts;
|
|
|
|
private readonly int _stageIndex;
|
2021-08-11 21:56:59 +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 13:49:44 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new GPU accessor.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="context">GPU context</param>
|
2021-08-12 06:09:56 +00:00
|
|
|
public GpuAccessorBase(GpuContext context, ResourceCounts resourceCounts, int stageIndex)
|
2021-08-11 21:01:06 +00:00
|
|
|
{
|
2021-08-11 21:56:59 +00:00
|
|
|
_context = context;
|
2021-08-12 06:09:56 +00:00
|
|
|
_resourceCounts = resourceCounts;
|
|
|
|
_stageIndex = stageIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public int QueryBindingConstantBuffer(int index)
|
|
|
|
{
|
|
|
|
if (_context.Capabilities.Api == TargetApi.Vulkan)
|
|
|
|
{
|
2022-04-12 20:28:04 +00:00
|
|
|
return 1 + GetBindingFromIndex(index, _context.Capabilities.MaximumUniformBuffersPerStage, "Uniform buffer");
|
2021-08-12 06:09:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return _resourceCounts.UniformBuffersCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public int QueryBindingStorageBuffer(int index)
|
|
|
|
{
|
|
|
|
if (_context.Capabilities.Api == TargetApi.Vulkan)
|
|
|
|
{
|
2022-04-12 20:28:04 +00:00
|
|
|
return GetBindingFromIndex(index, _context.Capabilities.MaximumStorageBuffersPerStage, "Storage buffer");
|
2021-08-12 06:09:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return _resourceCounts.StorageBuffersCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2022-06-03 02:51:27 +00:00
|
|
|
public int QueryBindingTexture(int index, bool isBuffer)
|
2021-08-12 06:09:56 +00:00
|
|
|
{
|
|
|
|
if (_context.Capabilities.Api == TargetApi.Vulkan)
|
|
|
|
{
|
2022-06-03 02:51:27 +00:00
|
|
|
if (isBuffer)
|
|
|
|
{
|
|
|
|
index += (int)_context.Capabilities.MaximumTexturesPerStage;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetBindingFromIndex(index, _context.Capabilities.MaximumTexturesPerStage * 2, "Texture");
|
2021-08-12 06:09:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return _resourceCounts.TexturesCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2022-06-03 02:51:27 +00:00
|
|
|
public int QueryBindingImage(int index, bool isBuffer)
|
2021-08-12 06:09:56 +00:00
|
|
|
{
|
|
|
|
if (_context.Capabilities.Api == TargetApi.Vulkan)
|
|
|
|
{
|
2022-06-03 02:51:27 +00:00
|
|
|
if (isBuffer)
|
|
|
|
{
|
|
|
|
index += (int)_context.Capabilities.MaximumImagesPerStage;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetBindingFromIndex(index, _context.Capabilities.MaximumImagesPerStage * 2, "Image");
|
2021-08-12 06:09:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return _resourceCounts.ImagesCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-12 20:28:04 +00:00
|
|
|
private int GetBindingFromIndex(int index, uint maxPerStage, string resourceName)
|
|
|
|
{
|
|
|
|
if ((uint)index >= maxPerStage)
|
|
|
|
{
|
|
|
|
Logger.Error?.Print(LogClass.Gpu, $"{resourceName} index {index} exceeds per stage limit of {maxPerStage}.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetStageIndex() * (int)maxPerStage + index;
|
|
|
|
}
|
|
|
|
|
2021-08-12 06:09:56 +00:00
|
|
|
private int GetStageIndex()
|
|
|
|
{
|
|
|
|
// This is just a simple remapping to ensure that most frequently used shader stages
|
|
|
|
// have the lowest binding numbers.
|
|
|
|
// This is useful because if we need to run on a system with a low limit on the bindings,
|
|
|
|
// then we can still get most games working as the most common shaders will have low binding numbers.
|
|
|
|
return _stageIndex switch
|
|
|
|
{
|
|
|
|
4 => 1, // Fragment
|
|
|
|
3 => 2, // Geometry
|
|
|
|
1 => 3, // Tessellation control
|
|
|
|
2 => 4, // Tessellation evaluation
|
|
|
|
_ => 0 // Vertex/Compute
|
|
|
|
};
|
2021-08-11 21:01:06 +00:00
|
|
|
}
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2021-08-11 21:56:59 +00:00
|
|
|
public bool QueryHostHasFrontFacingBug() => _context.Capabilities.HasFrontFacingBug;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2021-08-11 21:56:59 +00:00
|
|
|
public bool QueryHostHasVectorIndexingBug() => _context.Capabilities.HasVectorIndexingBug;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2021-08-11 21:56:59 +00:00
|
|
|
public int QueryHostStorageBufferOffsetAlignment() => _context.Capabilities.StorageBufferOffsetAlignment;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2022-01-20 11:37:21 +00:00
|
|
|
public bool QueryHostSupportsBgraFormat() => _context.Capabilities.SupportsBgraFormat;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2021-10-28 22:53:12 +00:00
|
|
|
public bool QueryHostSupportsFragmentShaderInterlock() => _context.Capabilities.SupportsFragmentShaderInterlock;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2021-10-28 22:53:12 +00:00
|
|
|
public bool QueryHostSupportsFragmentShaderOrderingIntel() => _context.Capabilities.SupportsFragmentShaderOrderingIntel;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
|
|
|
public bool QueryHostSupportsGeometryShaderPassthrough() => _context.Capabilities.SupportsGeometryShaderPassthrough;
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2021-08-11 21:56:59 +00:00
|
|
|
public bool QueryHostSupportsImageLoadFormatted() => _context.Capabilities.SupportsImageLoadFormatted;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2021-08-11 21:56:59 +00:00
|
|
|
public bool QueryHostSupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2021-09-19 12:38:39 +00:00
|
|
|
public bool QueryHostSupportsShaderBallot() => _context.Capabilities.SupportsShaderBallot;
|
|
|
|
|
2022-04-15 01:30:54 +00:00
|
|
|
/// <inheritdoc/>
|
2021-08-11 21:56:59 +00:00
|
|
|
public bool QueryHostSupportsTextureShadowLod() => _context.Capabilities.SupportsTextureShadowLod;
|
|
|
|
|
2020-11-12 23:15:34 +00:00
|
|
|
/// <summary>
|
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 13:49:44 +00:00
|
|
|
/// Converts a packed Maxwell texture format to the shader translator texture format.
|
2020-11-12 23:15:34 +00:00
|
|
|
/// </summary>
|
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 13:49:44 +00:00
|
|
|
/// <param name="format">Packed maxwell format</param>
|
|
|
|
/// <param name="formatSrgb">Indicates if the format is sRGB</param>
|
|
|
|
/// <returns>Shader translator texture format</returns>
|
|
|
|
protected static TextureFormat ConvertToTextureFormat(uint format, bool formatSrgb)
|
2020-11-12 23:15:34 +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 13:49:44 +00:00
|
|
|
if (!FormatTable.TryGetTextureFormat(format, formatSrgb, out FormatInfo formatInfo))
|
2020-11-12 23:15:34 +00:00
|
|
|
{
|
|
|
|
return TextureFormat.Unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
return formatInfo.Format switch
|
|
|
|
{
|
|
|
|
Format.R8Unorm => TextureFormat.R8Unorm,
|
|
|
|
Format.R8Snorm => TextureFormat.R8Snorm,
|
|
|
|
Format.R8Uint => TextureFormat.R8Uint,
|
|
|
|
Format.R8Sint => TextureFormat.R8Sint,
|
|
|
|
Format.R16Float => TextureFormat.R16Float,
|
|
|
|
Format.R16Unorm => TextureFormat.R16Unorm,
|
|
|
|
Format.R16Snorm => TextureFormat.R16Snorm,
|
|
|
|
Format.R16Uint => TextureFormat.R16Uint,
|
|
|
|
Format.R16Sint => TextureFormat.R16Sint,
|
|
|
|
Format.R32Float => TextureFormat.R32Float,
|
|
|
|
Format.R32Uint => TextureFormat.R32Uint,
|
|
|
|
Format.R32Sint => TextureFormat.R32Sint,
|
|
|
|
Format.R8G8Unorm => TextureFormat.R8G8Unorm,
|
|
|
|
Format.R8G8Snorm => TextureFormat.R8G8Snorm,
|
|
|
|
Format.R8G8Uint => TextureFormat.R8G8Uint,
|
|
|
|
Format.R8G8Sint => TextureFormat.R8G8Sint,
|
|
|
|
Format.R16G16Float => TextureFormat.R16G16Float,
|
|
|
|
Format.R16G16Unorm => TextureFormat.R16G16Unorm,
|
|
|
|
Format.R16G16Snorm => TextureFormat.R16G16Snorm,
|
|
|
|
Format.R16G16Uint => TextureFormat.R16G16Uint,
|
|
|
|
Format.R16G16Sint => TextureFormat.R16G16Sint,
|
|
|
|
Format.R32G32Float => TextureFormat.R32G32Float,
|
|
|
|
Format.R32G32Uint => TextureFormat.R32G32Uint,
|
|
|
|
Format.R32G32Sint => TextureFormat.R32G32Sint,
|
|
|
|
Format.R8G8B8A8Unorm => TextureFormat.R8G8B8A8Unorm,
|
|
|
|
Format.R8G8B8A8Snorm => TextureFormat.R8G8B8A8Snorm,
|
|
|
|
Format.R8G8B8A8Uint => TextureFormat.R8G8B8A8Uint,
|
|
|
|
Format.R8G8B8A8Sint => TextureFormat.R8G8B8A8Sint,
|
|
|
|
Format.R8G8B8A8Srgb => TextureFormat.R8G8B8A8Unorm,
|
|
|
|
Format.R16G16B16A16Float => TextureFormat.R16G16B16A16Float,
|
|
|
|
Format.R16G16B16A16Unorm => TextureFormat.R16G16B16A16Unorm,
|
|
|
|
Format.R16G16B16A16Snorm => TextureFormat.R16G16B16A16Snorm,
|
|
|
|
Format.R16G16B16A16Uint => TextureFormat.R16G16B16A16Uint,
|
|
|
|
Format.R16G16B16A16Sint => TextureFormat.R16G16B16A16Sint,
|
|
|
|
Format.R32G32B32A32Float => TextureFormat.R32G32B32A32Float,
|
|
|
|
Format.R32G32B32A32Uint => TextureFormat.R32G32B32A32Uint,
|
|
|
|
Format.R32G32B32A32Sint => TextureFormat.R32G32B32A32Sint,
|
|
|
|
Format.R10G10B10A2Unorm => TextureFormat.R10G10B10A2Unorm,
|
|
|
|
Format.R10G10B10A2Uint => TextureFormat.R10G10B10A2Uint,
|
|
|
|
Format.R11G11B10Float => TextureFormat.R11G11B10Float,
|
|
|
|
_ => TextureFormat.Unknown
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
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 13:49:44 +00:00
|
|
|
/// Converts the Maxwell primitive topology to the shader translator topology.
|
2020-11-12 23:15:34 +00:00
|
|
|
/// </summary>
|
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 13:49:44 +00:00
|
|
|
/// <param name="topology">Maxwell primitive topology</param>
|
|
|
|
/// <param name="tessellationMode">Maxwell tessellation mode</param>
|
|
|
|
/// <returns>Shader translator topology</returns>
|
|
|
|
protected static InputTopology ConvertToInputTopology(PrimitiveTopology topology, TessMode tessellationMode)
|
2020-11-12 23:15:34 +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 13:49:44 +00:00
|
|
|
return topology switch
|
|
|
|
{
|
|
|
|
PrimitiveTopology.Points => InputTopology.Points,
|
|
|
|
PrimitiveTopology.Lines or
|
|
|
|
PrimitiveTopology.LineLoop or
|
|
|
|
PrimitiveTopology.LineStrip => InputTopology.Lines,
|
|
|
|
PrimitiveTopology.LinesAdjacency or
|
|
|
|
PrimitiveTopology.LineStripAdjacency => InputTopology.LinesAdjacency,
|
|
|
|
PrimitiveTopology.Triangles or
|
|
|
|
PrimitiveTopology.TriangleStrip or
|
|
|
|
PrimitiveTopology.TriangleFan => InputTopology.Triangles,
|
|
|
|
PrimitiveTopology.TrianglesAdjacency or
|
|
|
|
PrimitiveTopology.TriangleStripAdjacency => InputTopology.TrianglesAdjacency,
|
|
|
|
PrimitiveTopology.Patches => tessellationMode.UnpackPatchType() == TessPatchType.Isolines
|
|
|
|
? InputTopology.Lines
|
|
|
|
: InputTopology.Triangles,
|
|
|
|
_ => InputTopology.Points
|
|
|
|
};
|
2020-11-12 23:15:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|