Skip to content

Commit

Permalink
Fix transform feedback and storage buffers not being updated in some …
Browse files Browse the repository at this point in the history
…cases
  • Loading branch information
gdkchan committed May 28, 2023
1 parent aa304d7 commit 152d0f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
Expand Up @@ -47,6 +47,7 @@ class StateUpdater
private IndexType _prevIndexType;
private uint _prevFirstVertex;
private bool _prevTfEnable;
private bool _prevShaderHasTf;

private uint _prevRtNoAlphaMask;

Expand Down Expand Up @@ -1363,6 +1364,22 @@ private void UpdateShaderState()
_vsUsesDrawParameters = gs.Shaders[1]?.Info.UsesDrawParameters ?? false;
_vsClipDistancesWritten = gs.Shaders[1]?.Info.ClipDistancesWritten ?? 0;

bool hasTransformFeedback = gs.SpecializationState.TransformFeedbackDescriptors != null;
if (hasTransformFeedback != _prevShaderHasTf)
{
if (!_context.Capabilities.SupportsTransformFeedback)
{
// If host does not support transform feedback, and the shader changed,
// we might need to update bindings as transform feedback emulation
// uses storage buffer bindings that might have been used for something
// else in a previous draw.

_channel.BufferManager.ForceTransformFeedbackAndStorageBuffersDirty();
}

_prevShaderHasTf = hasTransformFeedback;
}

if (oldVsClipDistancesWritten != _vsClipDistancesWritten)
{
UpdateUserClipState();
Expand Down
9 changes: 9 additions & 0 deletions src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
Expand Up @@ -359,6 +359,15 @@ public void SetInstancedDrawVertexCount(int vertexCount)
}
}

/// <summary>
/// Forces transform feedback and storage buffers to be updated on the next draw.
/// </summary>
public void ForceTransformFeedbackAndStorageBuffersDirty()
{
_transformFeedbackBuffersDirty = true;
_gpStorageBuffersDirty = true;
}

/// <summary>
/// Sets the binding points for the storage buffers bound on the compute pipeline.
/// </summary>
Expand Down

0 comments on commit 152d0f4

Please sign in to comment.