mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-11-28 03:40:50 +01:00
Bind TextureBuffers
This commit is contained in:
parent
62602e58b7
commit
3214a4cf8e
@ -54,10 +54,10 @@ namespace Ryujinx.Graphics.Metal
|
||||
record struct TextureRef
|
||||
{
|
||||
public ShaderStage Stage;
|
||||
public Texture Storage;
|
||||
public TextureBase Storage;
|
||||
public Sampler Sampler;
|
||||
|
||||
public TextureRef(ShaderStage stage, Texture storage, Sampler sampler)
|
||||
public TextureRef(ShaderStage stage, TextureBase storage, Sampler sampler)
|
||||
{
|
||||
Stage = stage;
|
||||
Storage = storage;
|
||||
|
@ -805,13 +805,9 @@ namespace Ryujinx.Graphics.Metal
|
||||
|
||||
public readonly void UpdateTextureAndSampler(ShaderStage stage, ulong binding, TextureBase texture, Sampler sampler)
|
||||
{
|
||||
if (texture is TextureBuffer)
|
||||
if (texture != null)
|
||||
{
|
||||
// TODO: Texture buffers
|
||||
}
|
||||
else if (texture is Texture view)
|
||||
{
|
||||
_currentState.TextureRefs[binding] = new(stage, view, sampler);
|
||||
_currentState.TextureRefs[binding] = new(stage, texture, sampler);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1124,59 +1120,52 @@ namespace Ryujinx.Graphics.Metal
|
||||
case MetalRenderer.TextureSetIndex:
|
||||
if (!segment.IsArray)
|
||||
{
|
||||
if (segment.Type != ResourceType.BufferTexture)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
int index = binding + i;
|
||||
|
||||
ref var texture = ref _currentState.TextureRefs[index];
|
||||
|
||||
var storage = texture.Storage;
|
||||
|
||||
if (storage == null)
|
||||
{
|
||||
int index = binding + i;
|
||||
|
||||
ref var texture = ref _currentState.TextureRefs[index];
|
||||
|
||||
var storage = texture.Storage;
|
||||
|
||||
if (storage == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var mtlTexture = storage.GetHandle();
|
||||
|
||||
MTLRenderStages renderStages = 0;
|
||||
|
||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||
{
|
||||
vertResourceIds[vertResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
||||
vertResourceIdIndex++;
|
||||
|
||||
if (texture.Sampler != null)
|
||||
{
|
||||
vertResourceIds[vertResourceIdIndex] = texture.Sampler.GetSampler().GpuResourceID._impl;
|
||||
vertResourceIdIndex++;
|
||||
}
|
||||
|
||||
renderStages |= MTLRenderStages.RenderStageVertex;
|
||||
}
|
||||
|
||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||
{
|
||||
fragResourceIds[fragResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
||||
fragResourceIdIndex++;
|
||||
|
||||
if (texture.Sampler != null)
|
||||
{
|
||||
fragResourceIds[fragResourceIdIndex] = texture.Sampler.GetSampler().GpuResourceID._impl;
|
||||
fragResourceIdIndex++;
|
||||
}
|
||||
|
||||
renderStages |= MTLRenderStages.RenderStageFragment;
|
||||
}
|
||||
|
||||
renderCommandEncoder.UseResource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read, renderStages);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Buffer textures
|
||||
|
||||
var mtlTexture = storage.GetHandle();
|
||||
|
||||
MTLRenderStages renderStages = 0;
|
||||
|
||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||
{
|
||||
vertResourceIds[vertResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
||||
vertResourceIdIndex++;
|
||||
|
||||
if (texture.Sampler != null)
|
||||
{
|
||||
vertResourceIds[vertResourceIdIndex] = texture.Sampler.GetSampler().GpuResourceID._impl;
|
||||
vertResourceIdIndex++;
|
||||
}
|
||||
|
||||
renderStages |= MTLRenderStages.RenderStageVertex;
|
||||
}
|
||||
|
||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||
{
|
||||
fragResourceIds[fragResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
||||
fragResourceIdIndex++;
|
||||
|
||||
if (texture.Sampler != null)
|
||||
{
|
||||
fragResourceIds[fragResourceIdIndex] = texture.Sampler.GetSampler().GpuResourceID._impl;
|
||||
fragResourceIdIndex++;
|
||||
}
|
||||
|
||||
renderStages |= MTLRenderStages.RenderStageFragment;
|
||||
}
|
||||
|
||||
renderCommandEncoder.UseResource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read, renderStages);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1343,41 +1332,34 @@ namespace Ryujinx.Graphics.Metal
|
||||
case MetalRenderer.TextureSetIndex:
|
||||
if (!segment.IsArray)
|
||||
{
|
||||
if (segment.Type != ResourceType.BufferTexture)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
int index = binding + i;
|
||||
|
||||
ref var texture = ref _currentState.TextureRefs[index];
|
||||
|
||||
var storage = texture.Storage;
|
||||
|
||||
if (storage == null)
|
||||
{
|
||||
int index = binding + i;
|
||||
continue;
|
||||
}
|
||||
|
||||
ref var texture = ref _currentState.TextureRefs[index];
|
||||
var mtlTexture = storage.GetHandle();
|
||||
|
||||
var storage = texture.Storage;
|
||||
if (segment.Stages.HasFlag(ResourceStages.Compute))
|
||||
{
|
||||
computeCommandEncoder.UseResource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read);
|
||||
resourceIds[resourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
||||
resourceIdIndex++;
|
||||
|
||||
if (storage == null)
|
||||
if (texture.Sampler != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var mtlTexture = storage.GetHandle();
|
||||
|
||||
if (segment.Stages.HasFlag(ResourceStages.Compute))
|
||||
{
|
||||
computeCommandEncoder.UseResource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read);
|
||||
resourceIds[resourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
||||
resourceIds[resourceIdIndex] = texture.Sampler.GetSampler().GpuResourceID._impl;
|
||||
resourceIdIndex++;
|
||||
|
||||
if (texture.Sampler != null)
|
||||
{
|
||||
resourceIds[resourceIdIndex] = texture.Sampler.GetSampler().GpuResourceID._impl;
|
||||
resourceIdIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Buffer textures
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user