diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2023-06-10 18:31:38 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-10 18:31:38 -0300 |
| commit | eb0bb36bbfc3a4f5f2ac1c8721e192239f899a1d (patch) | |
| tree | e43650855d28e8d49d7ad2d82466647263c3fe16 /src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs | |
| parent | 0e95a8271ac96b2c54907858140e2511a25a2b10 (diff) | |
Implement transform feedback emulation for hardware without native support (#5080)
* Implement transform feedback emulation for hardware without native support
* Stop doing some useless buffer updates and account for non-zero base instance
* Reduce redundant updates even more
* Update descriptor init logic to account for ResourceLayout
* Fix transform feedback and storage buffers not being updated in some cases
* Shader cache version bump
* PR feedback
* SetInstancedDrawVertexCount must be always called after UpdateState
* Minor typo
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs')
| -rw-r--r-- | src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs index 41558dc3..534bda70 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs @@ -132,6 +132,11 @@ namespace Ryujinx.Graphics.Shader.Translation _transformFeedbackDefinitions = new Dictionary<TransformFeedbackVariable, TransformFeedbackOutput>(); + TransformFeedbackEnabled = + stage != ShaderStage.Compute && + gpuAccessor.QueryTransformFeedbackEnabled() && + gpuAccessor.QueryHostSupportsTransformFeedback(); + UsedInputAttributesPerPatch = new HashSet<int>(); UsedOutputAttributesPerPatch = new HashSet<int>(); @@ -139,6 +144,31 @@ namespace Ryujinx.Graphics.Shader.Translation _usedImages = new Dictionary<TextureInfo, TextureMeta>(); ResourceManager = new ResourceManager(stage, gpuAccessor, new ShaderProperties()); + + if (!gpuAccessor.QueryHostSupportsTransformFeedback() && gpuAccessor.QueryTransformFeedbackEnabled()) + { + StructureType tfeInfoStruct = new StructureType(new StructureField[] + { + new StructureField(AggregateType.Array | AggregateType.U32, "base_offset", 4), + new StructureField(AggregateType.U32, "vertex_count") + }); + + BufferDefinition tfeInfoBuffer = new BufferDefinition(BufferLayout.Std430, 1, Constants.TfeInfoBinding, "tfe_info", tfeInfoStruct); + + Properties.AddStorageBuffer(Constants.TfeInfoBinding, tfeInfoBuffer); + + StructureType tfeDataStruct = new StructureType(new StructureField[] + { + new StructureField(AggregateType.Array | AggregateType.U32, "data", 0) + }); + + for (int i = 0; i < Constants.TfeBuffersCount; i++) + { + int binding = Constants.TfeBufferBaseBinding + i; + BufferDefinition tfeDataBuffer = new BufferDefinition(BufferLayout.Std430, 1, binding, $"tfe_data{i}", tfeDataStruct); + Properties.AddStorageBuffer(binding, tfeDataBuffer); + } + } } public ShaderConfig( @@ -151,7 +181,6 @@ namespace Ryujinx.Graphics.Shader.Translation ThreadsPerInputPrimitive = 1; OutputTopology = outputTopology; MaxOutputVertices = maxOutputVertices; - TransformFeedbackEnabled = gpuAccessor.QueryTransformFeedbackEnabled(); } public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationOptions options) : this(header.Stage, gpuAccessor, options) @@ -165,7 +194,6 @@ namespace Ryujinx.Graphics.Shader.Translation OmapTargets = header.OmapTargets; OmapSampleMask = header.OmapSampleMask; OmapDepth = header.OmapDepth; - TransformFeedbackEnabled = gpuAccessor.QueryTransformFeedbackEnabled(); LastInVertexPipeline = header.Stage < ShaderStage.Fragment; } |
