Address Feedback Part 1

This commit is contained in:
riperiperi 2022-06-16 00:32:53 +01:00
parent 2ca07804f7
commit dfb905b269
7 changed files with 26 additions and 21 deletions

View file

@ -188,8 +188,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
_channel.BufferManager.SetComputeStorageBufferBindings(info.SBuffers);
_channel.BufferManager.SetComputeUniformBufferBindings(info.CBuffers);
int maxTextureBinding = 0;
int maxImageBinding = 0;
int maxTextureBinding = -1;
int maxImageBinding = -1;
TextureBindingInfo[] textureBindings = _channel.TextureManager.RentComputeTextureBindings(info.Textures.Count);

View file

@ -1153,8 +1153,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
return;
}
int maxTextureBinding = 0;
int maxImageBinding = 0;
int maxTextureBinding = -1;
int maxImageBinding = -1;
Span<TextureBindingInfo> textureBindings = _channel.TextureManager.RentGraphicsTextureBindings(stage, info.Textures.Count);

View file

@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
class TextureBindingsManager : IDisposable
{
private const int InitialTextureStateSize = 32; // Should match binding range for host.
private const int InitialTextureStateSize = 32;
private const int InitialImageStateSize = 8;
private readonly GpuContext _context;
@ -484,7 +484,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
else
{
samplerId = UnpackSamplerId(packedId);
samplerId = TextureHandle.UnpackSamplerId(packedId);
}
ref TextureStatePerStage state = ref _textureState[bindingInfo.Binding];
@ -749,16 +749,6 @@ namespace Ryujinx.Graphics.Gpu.Image
return handle;
}
/// <summary>
/// Unpacks the sampler ID from the real texture handle.
/// </summary>
/// <param name="packedId">The real texture handle</param>
/// <returns>The sampler ID</returns>
private static int UnpackSamplerId(int packedId)
{
return (packedId >> 20) & 0xfff;
}
/// <summary>
/// Force all bound textures and images to be rebound the next time CommitBindings is called.
/// </summary>

View file

@ -361,7 +361,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Commits bindings on the compute pipeline.
/// </summary>
/// <param name="specState">Specialization state for the bound shader</param>
/// <returns>True if all bound textures match the current shader specialiation state, false otherwise</returns>
/// <returns>True if all bound textures match the current shader specialization state, false otherwise</returns>
public bool CommitComputeBindings(ShaderSpecializationState specState)
{
// Every time we switch between graphics and compute work,
@ -379,7 +379,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Commits bindings on the graphics pipeline.
/// </summary>
/// <param name="specState">Specialization state for the bound shader</param>
/// <returns>True if all bound textures match the current shader specialiation state, false otherwise</returns>
/// <returns>True if all bound textures match the current shader specialization state, false otherwise</returns>
public bool CommitGraphicsBindings(ShaderSpecializationState specState)
{
bool result = _gpBindingsManager.CommitBindings(specState);

View file

@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="id">ID of the texture. This is effectively a zero-based index</param>
/// <param name="texture">The texture with the given ID</param>
/// <returns>The texture descriptor with the given ID</returns>
public ref readonly TextureDescriptor GetInternal(int id, out Texture texture)
private ref readonly TextureDescriptor GetInternal(int id, out Texture texture)
{
texture = Items[id];

View file

@ -216,7 +216,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
for (int i = 0; i < stages.Length; i++)
{
CachedShaderStage stage = stages[i];
if (stage != null && stage.Info != null)
if (stage?.Info != null)
{
var textures = stage.Info.Textures;
var images = stage.Info.Images;
@ -600,7 +600,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="specializationState">Texture specialization state</param>
/// <param name="descriptor">Texture descriptor</param>
/// <returns>True if the state matches, false otherwise</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool MatchesTexture(Box<TextureSpecializationState> specializationState, in Image.TextureDescriptor descriptor)
{

View file

@ -52,12 +52,28 @@ namespace Ryujinx.Graphics.Shader
return (handle & 0x3fff, (handle >> 14) & 0x3fff, (TextureHandleType)((uint)handle >> 28));
}
/// <summary>
/// Unpacks the texture ID from the real texture handle.
/// </summary>
/// <param name="packedId">The real texture handle</param>
/// <returns>The texture ID</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int UnpackTextureId(int packedId)
{
return (packedId >> 0) & 0xfffff;
}
/// <summary>
/// Unpacks the sampler ID from the real texture handle.
/// </summary>
/// <param name="packedId">The real texture handle</param>
/// <returns>The sampler ID</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int UnpackSamplerId(int packedId)
{
return (packedId >> 20) & 0xfff;
}
/// <summary>
/// Reads a packed texture and sampler ID (basically, the real texture handle)
/// from a given texture/sampler constant buffer.