Compare commits
3 commits
a285136c1b
...
f6f4c3829a
Author | SHA1 | Date | |
---|---|---|---|
|
f6f4c3829a | ||
|
e194f91245 | ||
|
564e82edd7 |
3 changed files with 65 additions and 141 deletions
|
@ -54,10 +54,10 @@ namespace Ryujinx.Graphics.Metal
|
||||||
record struct TextureRef
|
record struct TextureRef
|
||||||
{
|
{
|
||||||
public ShaderStage Stage;
|
public ShaderStage Stage;
|
||||||
public Texture Storage;
|
public TextureBase Storage;
|
||||||
public Sampler Sampler;
|
public Sampler Sampler;
|
||||||
|
|
||||||
public TextureRef(ShaderStage stage, Texture storage, Sampler sampler)
|
public TextureRef(ShaderStage stage, TextureBase storage, Sampler sampler)
|
||||||
{
|
{
|
||||||
Stage = stage;
|
Stage = stage;
|
||||||
Storage = storage;
|
Storage = storage;
|
||||||
|
|
|
@ -805,13 +805,9 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public readonly void UpdateTextureAndSampler(ShaderStage stage, ulong binding, TextureBase texture, Sampler sampler)
|
public readonly void UpdateTextureAndSampler(ShaderStage stage, ulong binding, TextureBase texture, Sampler sampler)
|
||||||
{
|
{
|
||||||
if (texture is TextureBuffer)
|
if (texture != null)
|
||||||
{
|
{
|
||||||
// TODO: Texture buffers
|
_currentState.TextureRefs[binding] = new(stage, texture, sampler);
|
||||||
}
|
|
||||||
else if (texture is Texture view)
|
|
||||||
{
|
|
||||||
_currentState.TextureRefs[binding] = new(stage, view, sampler);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1123,8 +1119,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
break;
|
break;
|
||||||
case MetalRenderer.TextureSetIndex:
|
case MetalRenderer.TextureSetIndex:
|
||||||
if (!segment.IsArray)
|
if (!segment.IsArray)
|
||||||
{
|
|
||||||
if (segment.Type != ResourceType.BufferTexture)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -1175,11 +1169,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// TODO: Buffer textures
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// TODO: Texture arrays
|
// TODO: Texture arrays
|
||||||
}
|
}
|
||||||
|
@ -1342,8 +1331,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
break;
|
break;
|
||||||
case MetalRenderer.TextureSetIndex:
|
case MetalRenderer.TextureSetIndex:
|
||||||
if (!segment.IsArray)
|
if (!segment.IsArray)
|
||||||
{
|
|
||||||
if (segment.Type != ResourceType.BufferTexture)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -1375,11 +1362,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// TODO: Buffer textures
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// TODO: Texture arrays
|
// TODO: Texture arrays
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
private MTLComputePipelineState? _computePipelineCache;
|
private MTLComputePipelineState? _computePipelineCache;
|
||||||
private bool _firstBackgroundUse;
|
private bool _firstBackgroundUse;
|
||||||
|
|
||||||
public ResourceBindingSegment[][] ClearSegments { get; }
|
|
||||||
public ResourceBindingSegment[][] BindingSegments { get; }
|
public ResourceBindingSegment[][] BindingSegments { get; }
|
||||||
// Argument buffer sizes for Vertex or Compute stages
|
// Argument buffer sizes for Vertex or Compute stages
|
||||||
public int[] ArgumentBufferSizes { get; }
|
public int[] ArgumentBufferSizes { get; }
|
||||||
|
@ -53,7 +52,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
_handles[i] = device.NewLibrary(StringHelper.NSString(shader.Code), compileOptions, (library, error) => CompilationResultHandler(library, error, index));
|
_handles[i] = device.NewLibrary(StringHelper.NSString(shader.Code), compileOptions, (library, error) => CompilationResultHandler(library, error, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearSegments = BuildClearSegments(resourceLayout.Sets);
|
|
||||||
(BindingSegments, ArgumentBufferSizes, FragArgumentBufferSizes) = BuildBindingSegments(resourceLayout.SetUsages);
|
(BindingSegments, ArgumentBufferSizes, FragArgumentBufferSizes) = BuildBindingSegments(resourceLayout.SetUsages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,62 +96,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ResourceBindingSegment[][] BuildClearSegments(ReadOnlyCollection<ResourceDescriptorCollection> sets)
|
|
||||||
{
|
|
||||||
ResourceBindingSegment[][] segments = new ResourceBindingSegment[sets.Count][];
|
|
||||||
|
|
||||||
for (int setIndex = 0; setIndex < sets.Count; setIndex++)
|
|
||||||
{
|
|
||||||
List<ResourceBindingSegment> currentSegments = new();
|
|
||||||
|
|
||||||
ResourceDescriptor currentDescriptor = default;
|
|
||||||
int currentCount = 0;
|
|
||||||
|
|
||||||
for (int index = 0; index < sets[setIndex].Descriptors.Count; index++)
|
|
||||||
{
|
|
||||||
ResourceDescriptor descriptor = sets[setIndex].Descriptors[index];
|
|
||||||
|
|
||||||
if (currentDescriptor.Binding + currentCount != descriptor.Binding ||
|
|
||||||
currentDescriptor.Type != descriptor.Type ||
|
|
||||||
currentDescriptor.Stages != descriptor.Stages ||
|
|
||||||
currentDescriptor.Count > 1 ||
|
|
||||||
descriptor.Count > 1)
|
|
||||||
{
|
|
||||||
if (currentCount != 0)
|
|
||||||
{
|
|
||||||
currentSegments.Add(new ResourceBindingSegment(
|
|
||||||
currentDescriptor.Binding,
|
|
||||||
currentCount,
|
|
||||||
currentDescriptor.Type,
|
|
||||||
currentDescriptor.Stages,
|
|
||||||
currentDescriptor.Count > 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
currentDescriptor = descriptor;
|
|
||||||
currentCount = descriptor.Count;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentCount += descriptor.Count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentCount != 0)
|
|
||||||
{
|
|
||||||
currentSegments.Add(new ResourceBindingSegment(
|
|
||||||
currentDescriptor.Binding,
|
|
||||||
currentCount,
|
|
||||||
currentDescriptor.Type,
|
|
||||||
currentDescriptor.Stages,
|
|
||||||
currentDescriptor.Count > 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
segments[setIndex] = currentSegments.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
return segments;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static (ResourceBindingSegment[][], int[], int[]) BuildBindingSegments(ReadOnlyCollection<ResourceUsageCollection> setUsages)
|
private static (ResourceBindingSegment[][], int[], int[]) BuildBindingSegments(ReadOnlyCollection<ResourceUsageCollection> setUsages)
|
||||||
{
|
{
|
||||||
ResourceBindingSegment[][] segments = new ResourceBindingSegment[setUsages.Count][];
|
ResourceBindingSegment[][] segments = new ResourceBindingSegment[setUsages.Count][];
|
||||||
|
|
Loading…
Add table
Reference in a new issue