mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 02:53:04 +00:00
Fix null resources breaking arg buffer alignment
This commit is contained in:
parent
a968ec71fd
commit
6a46943af9
1 changed files with 183 additions and 132 deletions
|
@ -1147,11 +1147,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
var autoBuffer = buffer.Buffer;
|
var autoBuffer = buffer.Buffer;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
|
|
||||||
if (autoBuffer == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (autoBuffer != null)
|
||||||
|
{
|
||||||
MTLBuffer mtlBuffer;
|
MTLBuffer mtlBuffer;
|
||||||
|
|
||||||
if (range.HasValue)
|
if (range.HasValue)
|
||||||
|
@ -1165,11 +1165,15 @@ namespace Ryujinx.Graphics.Metal
|
||||||
mtlBuffer = autoBuffer.Get(_pipeline.Cbs).Value;
|
mtlBuffer = autoBuffer.Get(_pipeline.Cbs).Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpuAddress = mtlBuffer.GpuAddress + (ulong)offset;
|
||||||
|
nativePtr = mtlBuffer.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
MTLRenderStages renderStages = 0;
|
MTLRenderStages renderStages = 0;
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||||
{
|
{
|
||||||
vertResourceIds[vertResourceIdIndex] = mtlBuffer.GpuAddress + (ulong)offset;
|
vertResourceIds[vertResourceIdIndex] = gpuAddress;
|
||||||
vertResourceIdIndex++;
|
vertResourceIdIndex++;
|
||||||
|
|
||||||
renderStages |= MTLRenderStages.RenderStageVertex;
|
renderStages |= MTLRenderStages.RenderStageVertex;
|
||||||
|
@ -1177,13 +1181,13 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||||
{
|
{
|
||||||
fragResourceIds[fragResourceIdIndex] = mtlBuffer.GpuAddress + (ulong)offset;
|
fragResourceIds[fragResourceIdIndex] = gpuAddress;
|
||||||
fragResourceIdIndex++;
|
fragResourceIdIndex++;
|
||||||
|
|
||||||
renderStages |= MTLRenderStages.RenderStageFragment;
|
renderStages |= MTLRenderStages.RenderStageFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlBuffer.NativePtr), MTLResourceUsage.Read, renderStages));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, renderStages));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constants.StorageBuffersSetIndex:
|
case Constants.StorageBuffersSetIndex:
|
||||||
|
@ -1197,11 +1201,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
var autoBuffer = buffer.Buffer;
|
var autoBuffer = buffer.Buffer;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
|
|
||||||
if (autoBuffer == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (autoBuffer != null)
|
||||||
|
{
|
||||||
MTLBuffer mtlBuffer;
|
MTLBuffer mtlBuffer;
|
||||||
|
|
||||||
if (range.HasValue)
|
if (range.HasValue)
|
||||||
|
@ -1215,11 +1219,15 @@ namespace Ryujinx.Graphics.Metal
|
||||||
mtlBuffer = autoBuffer.Get(_pipeline.Cbs).Value;
|
mtlBuffer = autoBuffer.Get(_pipeline.Cbs).Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpuAddress = mtlBuffer.GpuAddress + (ulong)offset;
|
||||||
|
nativePtr = mtlBuffer.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
MTLRenderStages renderStages = 0;
|
MTLRenderStages renderStages = 0;
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||||
{
|
{
|
||||||
vertResourceIds[vertResourceIdIndex] = mtlBuffer.GpuAddress + (ulong)offset;
|
vertResourceIds[vertResourceIdIndex] = gpuAddress;
|
||||||
vertResourceIdIndex++;
|
vertResourceIdIndex++;
|
||||||
|
|
||||||
renderStages |= MTLRenderStages.RenderStageVertex;
|
renderStages |= MTLRenderStages.RenderStageVertex;
|
||||||
|
@ -1227,13 +1235,13 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||||
{
|
{
|
||||||
fragResourceIds[fragResourceIdIndex] = mtlBuffer.GpuAddress + (ulong)offset;
|
fragResourceIds[fragResourceIdIndex] = gpuAddress;
|
||||||
fragResourceIdIndex++;
|
fragResourceIdIndex++;
|
||||||
|
|
||||||
renderStages |= MTLRenderStages.RenderStageFragment;
|
renderStages |= MTLRenderStages.RenderStageFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlBuffer.NativePtr), MTLResourceUsage.Read, renderStages));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, renderStages));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constants.TexturesSetIndex:
|
case Constants.TexturesSetIndex:
|
||||||
|
@ -1247,11 +1255,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
var storage = texture.Storage;
|
var storage = texture.Storage;
|
||||||
|
|
||||||
if (storage == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (storage != null)
|
||||||
|
{
|
||||||
if (storage is TextureBuffer textureBuffer)
|
if (storage is TextureBuffer textureBuffer)
|
||||||
{
|
{
|
||||||
textureBuffer.RebuildStorage(false);
|
textureBuffer.RebuildStorage(false);
|
||||||
|
@ -1259,11 +1267,15 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
var mtlTexture = storage.GetHandle();
|
var mtlTexture = storage.GetHandle();
|
||||||
|
|
||||||
|
gpuAddress = mtlTexture.GpuResourceID._impl;
|
||||||
|
nativePtr = mtlTexture.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
MTLRenderStages renderStages = 0;
|
MTLRenderStages renderStages = 0;
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||||
{
|
{
|
||||||
vertResourceIds[vertResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
vertResourceIds[vertResourceIdIndex] = gpuAddress;
|
||||||
vertResourceIdIndex++;
|
vertResourceIdIndex++;
|
||||||
|
|
||||||
if (texture.Sampler != null)
|
if (texture.Sampler != null)
|
||||||
|
@ -1277,7 +1289,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||||
{
|
{
|
||||||
fragResourceIds[fragResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
fragResourceIds[fragResourceIdIndex] = gpuAddress;
|
||||||
fragResourceIdIndex++;
|
fragResourceIdIndex++;
|
||||||
|
|
||||||
if (texture.Sampler != null)
|
if (texture.Sampler != null)
|
||||||
|
@ -1289,7 +1301,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
renderStages |= MTLRenderStages.RenderStageFragment;
|
renderStages |= MTLRenderStages.RenderStageFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read, renderStages));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, renderStages));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1305,19 +1317,24 @@ namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
TextureRef texture = textures[i];
|
TextureRef texture = textures[i];
|
||||||
|
|
||||||
if (texture.Storage == null)
|
ulong gpuAddress = 0;
|
||||||
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
|
|
||||||
|
if (texture.Storage != null)
|
||||||
{
|
{
|
||||||
continue;
|
var mtlTexture = texture.Storage.GetHandle();
|
||||||
|
|
||||||
|
gpuAddress = mtlTexture.GpuResourceID._impl;
|
||||||
|
nativePtr = mtlTexture.NativePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mtlTexture = texture.Storage.GetHandle();
|
|
||||||
samplers[i] = texture.Sampler;
|
samplers[i] = texture.Sampler;
|
||||||
|
|
||||||
MTLRenderStages renderStages = 0;
|
MTLRenderStages renderStages = 0;
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||||
{
|
{
|
||||||
vertResourceIds[vertResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
vertResourceIds[vertResourceIdIndex] = gpuAddress;
|
||||||
vertResourceIdIndex++;
|
vertResourceIdIndex++;
|
||||||
|
|
||||||
renderStages |= MTLRenderStages.RenderStageVertex;
|
renderStages |= MTLRenderStages.RenderStageVertex;
|
||||||
|
@ -1325,31 +1342,33 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||||
{
|
{
|
||||||
fragResourceIds[fragResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
fragResourceIds[fragResourceIdIndex] = gpuAddress;
|
||||||
fragResourceIdIndex++;
|
fragResourceIdIndex++;
|
||||||
|
|
||||||
renderStages |= MTLRenderStages.RenderStageFragment;
|
renderStages |= MTLRenderStages.RenderStageFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read, renderStages));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, renderStages));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var sampler in samplers)
|
foreach (var sampler in samplers)
|
||||||
{
|
{
|
||||||
if (sampler == null)
|
ulong gpuAddress = 0;
|
||||||
|
|
||||||
|
if (sampler != null)
|
||||||
{
|
{
|
||||||
continue;
|
gpuAddress = sampler.GetSampler().GpuResourceID._impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||||
{
|
{
|
||||||
vertResourceIds[vertResourceIdIndex] = sampler.GetSampler().GpuResourceID._impl;
|
vertResourceIds[vertResourceIdIndex] = gpuAddress;
|
||||||
vertResourceIdIndex++;
|
vertResourceIdIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||||
{
|
{
|
||||||
fragResourceIds[fragResourceIdIndex] = sampler.GetSampler().GpuResourceID._impl;
|
fragResourceIds[fragResourceIdIndex] = gpuAddress;
|
||||||
fragResourceIdIndex++;
|
fragResourceIdIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1360,20 +1379,24 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
foreach (TextureBuffer bufferTexture in bufferTextures)
|
foreach (TextureBuffer bufferTexture in bufferTextures)
|
||||||
{
|
{
|
||||||
if (bufferTexture == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (bufferTexture != null)
|
||||||
|
{
|
||||||
bufferTexture.RebuildStorage(false);
|
bufferTexture.RebuildStorage(false);
|
||||||
|
|
||||||
var mtlTexture = bufferTexture.GetHandle();
|
var mtlTexture = bufferTexture.GetHandle();
|
||||||
|
|
||||||
|
gpuAddress = mtlTexture.GpuResourceID._impl;
|
||||||
|
nativePtr = mtlTexture.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
MTLRenderStages renderStages = 0;
|
MTLRenderStages renderStages = 0;
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||||
{
|
{
|
||||||
vertResourceIds[vertResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
vertResourceIds[vertResourceIdIndex] = gpuAddress;
|
||||||
vertResourceIdIndex++;
|
vertResourceIdIndex++;
|
||||||
|
|
||||||
renderStages |= MTLRenderStages.RenderStageVertex;
|
renderStages |= MTLRenderStages.RenderStageVertex;
|
||||||
|
@ -1381,13 +1404,13 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||||
{
|
{
|
||||||
fragResourceIds[fragResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
fragResourceIds[fragResourceIdIndex] = gpuAddress;
|
||||||
fragResourceIdIndex++;
|
fragResourceIdIndex++;
|
||||||
|
|
||||||
renderStages |= MTLRenderStages.RenderStageFragment;
|
renderStages |= MTLRenderStages.RenderStageFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read, renderStages));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, renderStages));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1403,30 +1426,34 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
var storage = image.Storage;
|
var storage = image.Storage;
|
||||||
|
|
||||||
if (storage == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (storage != null)
|
||||||
|
{
|
||||||
var mtlTexture = storage.GetHandle();
|
var mtlTexture = storage.GetHandle();
|
||||||
|
|
||||||
|
gpuAddress = mtlTexture.GpuResourceID._impl;
|
||||||
|
nativePtr = mtlTexture.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
MTLRenderStages renderStages = 0;
|
MTLRenderStages renderStages = 0;
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
if ((segment.Stages & ResourceStages.Vertex) != 0)
|
||||||
{
|
{
|
||||||
vertResourceIds[vertResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
vertResourceIds[vertResourceIdIndex] = gpuAddress;
|
||||||
vertResourceIdIndex++;
|
vertResourceIdIndex++;
|
||||||
renderStages |= MTLRenderStages.RenderStageVertex;
|
renderStages |= MTLRenderStages.RenderStageVertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
if ((segment.Stages & ResourceStages.Fragment) != 0)
|
||||||
{
|
{
|
||||||
fragResourceIds[fragResourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
fragResourceIds[fragResourceIdIndex] = gpuAddress;
|
||||||
fragResourceIdIndex++;
|
fragResourceIdIndex++;
|
||||||
renderStages |= MTLRenderStages.RenderStageFragment;
|
renderStages |= MTLRenderStages.RenderStageFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read | MTLResourceUsage.Write, renderStages));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read | MTLResourceUsage.Write, renderStages));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1485,11 +1512,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
var autoBuffer = buffer.Buffer;
|
var autoBuffer = buffer.Buffer;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
|
|
||||||
if (autoBuffer == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (autoBuffer != null)
|
||||||
|
{
|
||||||
MTLBuffer mtlBuffer;
|
MTLBuffer mtlBuffer;
|
||||||
|
|
||||||
if (range.HasValue)
|
if (range.HasValue)
|
||||||
|
@ -1503,10 +1530,14 @@ namespace Ryujinx.Graphics.Metal
|
||||||
mtlBuffer = autoBuffer.Get(_pipeline.Cbs).Value;
|
mtlBuffer = autoBuffer.Get(_pipeline.Cbs).Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpuAddress = mtlBuffer.GpuAddress + (ulong)offset;
|
||||||
|
nativePtr = mtlBuffer.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Compute) != 0)
|
if ((segment.Stages & ResourceStages.Compute) != 0)
|
||||||
{
|
{
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlBuffer.NativePtr), MTLResourceUsage.Read, 0));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, 0));
|
||||||
resourceIds[resourceIdIndex] = mtlBuffer.GpuAddress + (ulong)offset;
|
resourceIds[resourceIdIndex] = gpuAddress;
|
||||||
resourceIdIndex++;
|
resourceIdIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1522,11 +1553,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
var autoBuffer = buffer.Buffer;
|
var autoBuffer = buffer.Buffer;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
|
|
||||||
if (autoBuffer == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (autoBuffer != null)
|
||||||
|
{
|
||||||
MTLBuffer mtlBuffer;
|
MTLBuffer mtlBuffer;
|
||||||
|
|
||||||
if (range.HasValue)
|
if (range.HasValue)
|
||||||
|
@ -1540,10 +1571,14 @@ namespace Ryujinx.Graphics.Metal
|
||||||
mtlBuffer = autoBuffer.Get(_pipeline.Cbs).Value;
|
mtlBuffer = autoBuffer.Get(_pipeline.Cbs).Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpuAddress = mtlBuffer.GpuAddress + (ulong)offset;
|
||||||
|
nativePtr = mtlBuffer.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Compute) != 0)
|
if ((segment.Stages & ResourceStages.Compute) != 0)
|
||||||
{
|
{
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlBuffer.NativePtr), MTLResourceUsage.Read | MTLResourceUsage.Write, 0));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read | MTLResourceUsage.Write, 0));
|
||||||
resourceIds[resourceIdIndex] = mtlBuffer.GpuAddress + (ulong)offset;
|
resourceIds[resourceIdIndex] = gpuAddress;
|
||||||
resourceIdIndex++;
|
resourceIdIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1559,11 +1594,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
var storage = texture.Storage;
|
var storage = texture.Storage;
|
||||||
|
|
||||||
if (storage == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (storage != null)
|
||||||
|
{
|
||||||
if (storage is TextureBuffer textureBuffer)
|
if (storage is TextureBuffer textureBuffer)
|
||||||
{
|
{
|
||||||
textureBuffer.RebuildStorage(false);
|
textureBuffer.RebuildStorage(false);
|
||||||
|
@ -1571,10 +1606,14 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
var mtlTexture = storage.GetHandle();
|
var mtlTexture = storage.GetHandle();
|
||||||
|
|
||||||
|
gpuAddress = mtlTexture.GpuResourceID._impl;
|
||||||
|
nativePtr = mtlTexture.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Compute) != 0)
|
if ((segment.Stages & ResourceStages.Compute) != 0)
|
||||||
{
|
{
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read, 0));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, 0));
|
||||||
resourceIds[resourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
resourceIds[resourceIdIndex] = gpuAddress;
|
||||||
resourceIdIndex++;
|
resourceIdIndex++;
|
||||||
|
|
||||||
if (texture.Sampler != null)
|
if (texture.Sampler != null)
|
||||||
|
@ -1598,17 +1637,21 @@ namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
TextureRef texture = textures[i];
|
TextureRef texture = textures[i];
|
||||||
|
|
||||||
if (texture.Storage == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (texture.Storage != null)
|
||||||
|
{
|
||||||
var mtlTexture = texture.Storage.GetHandle();
|
var mtlTexture = texture.Storage.GetHandle();
|
||||||
|
|
||||||
|
gpuAddress = mtlTexture.GpuResourceID._impl;
|
||||||
|
nativePtr = mtlTexture.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Compute) != 0)
|
if ((segment.Stages & ResourceStages.Compute) != 0)
|
||||||
{
|
{
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read, 0));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, 0));
|
||||||
resourceIds[resourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
resourceIds[resourceIdIndex] = gpuAddress;
|
||||||
resourceIdIndex++;
|
resourceIdIndex++;
|
||||||
|
|
||||||
samplers[i] = texture.Sampler;
|
samplers[i] = texture.Sampler;
|
||||||
|
@ -1630,19 +1673,23 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
foreach (TextureBuffer bufferTexture in bufferTextures)
|
foreach (TextureBuffer bufferTexture in bufferTextures)
|
||||||
{
|
{
|
||||||
if (bufferTexture == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (bufferTexture != null)
|
||||||
|
{
|
||||||
bufferTexture.RebuildStorage(false);
|
bufferTexture.RebuildStorage(false);
|
||||||
|
|
||||||
var mtlTexture = bufferTexture.GetHandle();
|
var mtlTexture = bufferTexture.GetHandle();
|
||||||
|
|
||||||
|
gpuAddress = mtlTexture.GpuResourceID._impl;
|
||||||
|
nativePtr = mtlTexture.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Compute) != 0)
|
if ((segment.Stages & ResourceStages.Compute) != 0)
|
||||||
{
|
{
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read, 0));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read, 0));
|
||||||
resourceIds[resourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
resourceIds[resourceIdIndex] = gpuAddress;
|
||||||
resourceIdIndex++;
|
resourceIdIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1662,17 +1709,21 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
var storage = image.Storage;
|
var storage = image.Storage;
|
||||||
|
|
||||||
if (storage == null)
|
ulong gpuAddress = 0;
|
||||||
{
|
IntPtr nativePtr = IntPtr.Zero;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (storage != null)
|
||||||
|
{
|
||||||
var mtlTexture = storage.GetHandle();
|
var mtlTexture = storage.GetHandle();
|
||||||
|
|
||||||
|
gpuAddress = mtlTexture.GpuResourceID._impl;
|
||||||
|
nativePtr = mtlTexture.NativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
if ((segment.Stages & ResourceStages.Compute) != 0)
|
if ((segment.Stages & ResourceStages.Compute) != 0)
|
||||||
{
|
{
|
||||||
resources.Resources.Add(new Resource(new MTLResource(mtlTexture.NativePtr), MTLResourceUsage.Read | MTLResourceUsage.Write, 0));
|
resources.Resources.Add(new Resource(new MTLResource(nativePtr), MTLResourceUsage.Read | MTLResourceUsage.Write, 0));
|
||||||
resourceIds[resourceIdIndex] = mtlTexture.GpuResourceID._impl;
|
resourceIds[resourceIdIndex] = gpuAddress;
|
||||||
resourceIdIndex++;
|
resourceIdIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue