Implemented GetData and SetData for Metro Rendersystem too. Together with commit 32081, this implements patch 15996.
This commit is contained in:
parent
252e337375
commit
a7fb23b599
@ -1,8 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using ANX.Framework.Graphics;
|
using ANX.Framework.Graphics;
|
||||||
using ANX.Framework.NonXNA.RenderSystem;
|
using ANX.Framework.NonXNA.RenderSystem;
|
||||||
using Dx11 = SharpDX.Direct3D11;
|
using Dx = SharpDX.Direct3D11;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using SharpDX;
|
||||||
|
|
||||||
// This file is part of the ANX.Framework created by the
|
// This file is part of the ANX.Framework created by the
|
||||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||||
@ -10,121 +11,161 @@ using System.IO;
|
|||||||
|
|
||||||
namespace ANX.RenderSystem.Windows.Metro
|
namespace ANX.RenderSystem.Windows.Metro
|
||||||
{
|
{
|
||||||
public class IndexBuffer_Metro : INativeIndexBuffer, IDisposable
|
public class IndexBuffer_Metro : INativeIndexBuffer, IDisposable
|
||||||
{
|
{
|
||||||
#region Private
|
#region Private
|
||||||
private int indexSizeInBytes;
|
private int indexSizeInBytes;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public
|
#region Public
|
||||||
public Dx11.Buffer NativeBuffer
|
public Dx.Buffer NativeBuffer
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
public IndexBuffer_Metro(GraphicsDevice graphics, IndexElementSize size,
|
public IndexBuffer_Metro(GraphicsDevice graphics, IndexElementSize size,
|
||||||
int indexCount, BufferUsage usage)
|
int indexCount, BufferUsage usage)
|
||||||
{
|
{
|
||||||
indexSizeInBytes = size == IndexElementSize.SixteenBits ? 2 : 4;
|
indexSizeInBytes = size == IndexElementSize.SixteenBits ? 2 : 4;
|
||||||
|
|
||||||
GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro;
|
GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro;
|
||||||
var device = gdMetro.NativeDevice.NativeDevice;
|
var device = gdMetro.NativeDevice.NativeDevice;
|
||||||
|
|
||||||
InitializeBuffer(device, indexCount, usage);
|
InitializeBuffer(device, indexCount, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IndexBuffer_Metro(Dx11.Device device, IndexElementSize size,
|
internal IndexBuffer_Metro(Dx.Device device, IndexElementSize size,
|
||||||
int indexCount, BufferUsage usage)
|
int indexCount, BufferUsage usage)
|
||||||
{
|
{
|
||||||
indexSizeInBytes = size == IndexElementSize.SixteenBits ? 2 : 4;
|
indexSizeInBytes = size == IndexElementSize.SixteenBits ? 2 : 4;
|
||||||
InitializeBuffer(device, indexCount, usage);
|
InitializeBuffer(device, indexCount, usage);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region InitializeBuffer
|
#region InitializeBuffer
|
||||||
private void InitializeBuffer(Dx11.Device device,
|
private void InitializeBuffer(Dx.Device device,
|
||||||
int indexCount, BufferUsage usage)
|
int indexCount, BufferUsage usage)
|
||||||
{
|
{
|
||||||
var description = new Dx11.BufferDescription()
|
var description = new Dx.BufferDescription()
|
||||||
{
|
{
|
||||||
Usage = FormatConverter.Translate(usage),
|
Usage = FormatConverter.Translate(usage),
|
||||||
SizeInBytes = indexSizeInBytes * indexCount,
|
SizeInBytes = indexSizeInBytes * indexCount,
|
||||||
BindFlags = Dx11.BindFlags.IndexBuffer,
|
BindFlags = Dx.BindFlags.IndexBuffer,
|
||||||
CpuAccessFlags = Dx11.CpuAccessFlags.Write,
|
CpuAccessFlags = Dx.CpuAccessFlags.Write,
|
||||||
OptionFlags = Dx11.ResourceOptionFlags.None
|
OptionFlags = Dx.ResourceOptionFlags.None
|
||||||
};
|
};
|
||||||
|
|
||||||
NativeBuffer = new Dx11.Buffer(device, description);
|
NativeBuffer = new Dx.Buffer(device, description);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SetData
|
#region SetData
|
||||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||||
{
|
{
|
||||||
SetData<T>(graphicsDevice, data, 0, data.Length);
|
SetData<T>(graphicsDevice, data, 0, data.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex,
|
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex,
|
||||||
int elementCount) where T : struct
|
int elementCount) where T : struct
|
||||||
{
|
{
|
||||||
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data,
|
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data,
|
||||||
int startIndex, int elementCount) where T : struct
|
int startIndex, int elementCount) where T : struct
|
||||||
{
|
{
|
||||||
GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
|
GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
|
||||||
var device = gdMetro.NativeDevice;
|
var device = gdMetro.NativeDevice;
|
||||||
|
|
||||||
//TODO: check offsetInBytes parameter for bounds etc.
|
//TODO: check offsetInBytes parameter for bounds etc.
|
||||||
|
|
||||||
SharpDX.DataStream stream = device.MapSubresource(NativeBuffer);
|
SharpDX.DataStream stream = device.MapSubresource(NativeBuffer);
|
||||||
|
|
||||||
if (offsetInBytes > 0)
|
if (offsetInBytes > 0)
|
||||||
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
||||||
|
|
||||||
if (startIndex > 0 || elementCount < data.Length)
|
if (startIndex > 0 || elementCount < data.Length)
|
||||||
for (int i = startIndex; i < startIndex + elementCount; i++)
|
for (int i = startIndex; i < startIndex + elementCount; i++)
|
||||||
stream.Write<T>(data[i]);
|
stream.Write<T>(data[i]);
|
||||||
else
|
else
|
||||||
for (int i = 0; i < data.Length; i++)
|
for (int i = 0; i < data.Length; i++)
|
||||||
stream.Write<T>(data[i]);
|
stream.Write<T>(data[i]);
|
||||||
|
|
||||||
device.UnmapSubresource(NativeBuffer, 0);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region GetData (TODO)
|
|
||||||
public void GetData<T>(int offsetInBytes, T[] data, int startIndex,
|
|
||||||
int elementCount) where T : struct
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GetData<T>(T[] data) where T : struct
|
device.UnmapSubresource(NativeBuffer, 0);
|
||||||
{
|
}
|
||||||
throw new NotImplementedException();
|
#endregion
|
||||||
}
|
|
||||||
|
#region GetData
|
||||||
|
public void GetData<S>(S[] data) where S : struct
|
||||||
|
{
|
||||||
|
GetData(0, data, 0, data.Length);
|
||||||
|
}
|
||||||
|
|
||||||
public void GetData<T>(T[] data, int startIndex, int elementCount)
|
public void GetData<S>(S[] data, int startIndex, int elementCount) where S : struct
|
||||||
where T : struct
|
{
|
||||||
{
|
GetData(0, data, 0, data.Length);
|
||||||
throw new NotImplementedException();
|
}
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Dispose
|
public void GetData<S>(int offsetInBytes, S[] data, int startIndex, int elementCount) where S : struct
|
||||||
public void Dispose()
|
{
|
||||||
{
|
Dx.Buffer stagingBuffer = CreateStagingBuffer(indexSizeInBytes * elementCount);
|
||||||
if (NativeBuffer != null)
|
CopySubresource(NativeBuffer, stagingBuffer);
|
||||||
{
|
|
||||||
NativeBuffer.Dispose();
|
using (var stream = MapBufferRead(stagingBuffer))
|
||||||
NativeBuffer = null;
|
{
|
||||||
}
|
if (offsetInBytes > 0)
|
||||||
}
|
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
||||||
#endregion
|
|
||||||
}
|
stream.ReadRange(data, startIndex, elementCount);
|
||||||
|
UnmapBuffer(stagingBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private SharpDX.DataStream MapBufferRead(Dx.Buffer buffer)
|
||||||
|
{
|
||||||
|
Dx.DeviceContext context = buffer.Device.ImmediateContext;
|
||||||
|
DataStream stream;
|
||||||
|
context.MapSubresource(buffer, Dx.MapMode.Read, Dx.MapFlags.None, out stream);
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnmapBuffer(Dx.Buffer buffer)
|
||||||
|
{
|
||||||
|
Dx.DeviceContext context = buffer.Device.ImmediateContext;
|
||||||
|
context.UnmapSubresource(buffer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CopySubresource(Dx.Buffer source, Dx.Buffer destination)
|
||||||
|
{
|
||||||
|
this.NativeBuffer.Device.ImmediateContext.CopyResource(source, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dx.Buffer CreateStagingBuffer(int sizeInBytes)
|
||||||
|
{
|
||||||
|
var description = new Dx.BufferDescription()
|
||||||
|
{
|
||||||
|
Usage = Dx.ResourceUsage.Staging,
|
||||||
|
SizeInBytes = sizeInBytes,
|
||||||
|
CpuAccessFlags = Dx.CpuAccessFlags.Read,
|
||||||
|
OptionFlags = Dx.ResourceOptionFlags.None,
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Dx.Buffer(NativeBuffer.Device, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Dispose
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (NativeBuffer != null)
|
||||||
|
{
|
||||||
|
NativeBuffer.Dispose();
|
||||||
|
NativeBuffer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using ANX.Framework.Graphics;
|
using ANX.Framework.Graphics;
|
||||||
using ANX.Framework.NonXNA.RenderSystem;
|
using ANX.Framework.NonXNA.RenderSystem;
|
||||||
using Dx11 = SharpDX.Direct3D11;
|
using Dx = SharpDX.Direct3D11;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// This file is part of the ANX.Framework created by the
|
// This file is part of the ANX.Framework created by the
|
||||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||||
@ -10,129 +11,168 @@ using Dx11 = SharpDX.Direct3D11;
|
|||||||
|
|
||||||
namespace ANX.RenderSystem.Windows.Metro
|
namespace ANX.RenderSystem.Windows.Metro
|
||||||
{
|
{
|
||||||
public class VertexBuffer_Metro : INativeVertexBuffer, IDisposable
|
public class VertexBuffer_Metro : INativeVertexBuffer, IDisposable
|
||||||
{
|
{
|
||||||
#region Private
|
#region Private
|
||||||
private int vertexStride;
|
private int vertexStride;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public
|
#region Public
|
||||||
public Dx11.Buffer NativeBuffer
|
public Dx.Buffer NativeBuffer
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
public VertexBuffer_Metro(GraphicsDevice graphics, VertexDeclaration vertexDeclaration,
|
public VertexBuffer_Metro(GraphicsDevice graphics, VertexDeclaration vertexDeclaration,
|
||||||
int vertexCount, BufferUsage usage)
|
int vertexCount, BufferUsage usage)
|
||||||
{
|
{
|
||||||
GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro;
|
GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro;
|
||||||
var device = gdMetro.NativeDevice.NativeDevice;
|
var device = gdMetro.NativeDevice.NativeDevice;
|
||||||
|
|
||||||
vertexStride = vertexDeclaration.VertexStride;
|
vertexStride = vertexDeclaration.VertexStride;
|
||||||
InitializeBuffer(device, vertexCount, usage);
|
InitializeBuffer(device, vertexCount, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal VertexBuffer_Metro(Dx11.Device device, VertexDeclaration vertexDeclaration,
|
internal VertexBuffer_Metro(Dx.Device device, VertexDeclaration vertexDeclaration,
|
||||||
int vertexCount, BufferUsage usage)
|
int vertexCount, BufferUsage usage)
|
||||||
{
|
{
|
||||||
vertexStride = vertexDeclaration.VertexStride;
|
vertexStride = vertexDeclaration.VertexStride;
|
||||||
InitializeBuffer(device, vertexCount, usage);
|
InitializeBuffer(device, vertexCount, usage);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region InitializeBuffer
|
#region InitializeBuffer
|
||||||
private void InitializeBuffer(Dx11.Device device, int vertexCount,
|
private void InitializeBuffer(Dx.Device device, int vertexCount,
|
||||||
BufferUsage usage)
|
BufferUsage usage)
|
||||||
{
|
{
|
||||||
if (device != null)
|
if (device != null)
|
||||||
{
|
{
|
||||||
var description = new Dx11.BufferDescription()
|
var description = new Dx.BufferDescription()
|
||||||
{
|
{
|
||||||
Usage = FormatConverter.Translate(usage),
|
Usage = FormatConverter.Translate(usage),
|
||||||
SizeInBytes = vertexStride * vertexCount,
|
SizeInBytes = vertexStride * vertexCount,
|
||||||
BindFlags = Dx11.BindFlags.VertexBuffer,
|
BindFlags = Dx.BindFlags.VertexBuffer,
|
||||||
CpuAccessFlags = Dx11.CpuAccessFlags.Write,
|
CpuAccessFlags = Dx.CpuAccessFlags.Write,
|
||||||
OptionFlags = Dx11.ResourceOptionFlags.None
|
OptionFlags = Dx.ResourceOptionFlags.None
|
||||||
};
|
};
|
||||||
|
|
||||||
NativeBuffer = new Dx11.Buffer(device, description);
|
NativeBuffer = new Dx.Buffer(device, description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SetData
|
#region SetData
|
||||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes,
|
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes,
|
||||||
T[] data, int startIndex, int elementCount) where T : struct
|
T[] data, int startIndex, int elementCount) where T : struct
|
||||||
{
|
{
|
||||||
SetData<T>(graphicsDevice, offsetInBytes, data, startIndex, elementCount, vertexStride);
|
SetData<T>(graphicsDevice, offsetInBytes, data, startIndex, elementCount, vertexStride);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||||
{
|
{
|
||||||
SetData<T>(graphicsDevice, data, 0, data.Length);
|
SetData<T>(graphicsDevice, data, 0, data.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex,
|
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex,
|
||||||
int elementCount) where T : struct
|
int elementCount) where T : struct
|
||||||
{
|
{
|
||||||
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data,
|
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data,
|
||||||
int startIndex, int elementCount, int vertexStride) where T : struct
|
int startIndex, int elementCount, int vertexStride) where T : struct
|
||||||
{
|
{
|
||||||
GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
|
if (offsetInBytes + elementCount * Marshal.SizeOf(typeof(T)) > NativeBuffer.Description.SizeInBytes)
|
||||||
var device = gdMetro.NativeDevice;
|
throw new ArgumentOutOfRangeException(string.Format("The offset by \"{0}\" plus the byte length described by \"{1}\" is over the bounds of the buffer.", "offsetInBytes", "elementCount"));
|
||||||
|
|
||||||
//TODO: check offsetInBytes parameter for bounds etc.
|
if (startIndex + elementCount > data.Length)
|
||||||
|
throw new ArgumentOutOfRangeException(string.Format("The parameters {0} + {1} must be smaller than {2}.", "startIndex", "elementCount", "data.Length"));
|
||||||
|
|
||||||
SharpDX.DataStream stream = device.MapSubresource(NativeBuffer);
|
GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
|
||||||
|
var device = gdMetro.NativeDevice;
|
||||||
|
|
||||||
if (offsetInBytes > 0)
|
SharpDX.DataStream stream = device.MapSubresource(NativeBuffer);
|
||||||
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
|
||||||
|
|
||||||
if (startIndex > 0 || elementCount < data.Length)
|
if (offsetInBytes > 0)
|
||||||
for (int i = startIndex; i < startIndex + elementCount; i++)
|
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
||||||
stream.Write<T>(data[i]);
|
|
||||||
else
|
|
||||||
for (int i = 0; i < data.Length; i++)
|
|
||||||
stream.Write<T>(data[i]);
|
|
||||||
|
|
||||||
device.UnmapSubresource(NativeBuffer, 0);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region GetData (TODO)
|
for (int i = startIndex; i < startIndex + elementCount; i++)
|
||||||
public void GetData<T>(int offsetInBytes, T[] data, int startIndex,
|
stream.Write<T>(data[i]);
|
||||||
int elementCount, int vertexStride) where T : struct
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GetData<T>(T[] data) where T : struct
|
device.UnmapSubresource(NativeBuffer, 0);
|
||||||
{
|
}
|
||||||
throw new NotImplementedException();
|
#endregion
|
||||||
}
|
|
||||||
|
|
||||||
public void GetData<T>(T[] data, int startIndex, int elementCount)
|
#region GetData
|
||||||
where T : struct
|
public void GetData<T>(T[] data) where T : struct
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
GetData(data, 0, data.Length);
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Dispose
|
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||||
public void Dispose()
|
{
|
||||||
{
|
GetData(0, data, startIndex, elementCount, vertexStride);
|
||||||
if (NativeBuffer != null)
|
}
|
||||||
{
|
|
||||||
NativeBuffer.Dispose();
|
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride)
|
||||||
NativeBuffer = null;
|
where T : struct
|
||||||
}
|
{
|
||||||
}
|
Dx.Buffer stagingBuffer = CreateStagingBuffer(elementCount * vertexStride);
|
||||||
#endregion
|
CopySubresource(NativeBuffer, stagingBuffer);
|
||||||
}
|
|
||||||
|
using (var stream = MapBufferRead(stagingBuffer))
|
||||||
|
{
|
||||||
|
if (offsetInBytes > 0)
|
||||||
|
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
||||||
|
|
||||||
|
stream.ReadRange(data, startIndex, elementCount);
|
||||||
|
UnmapBuffer(stagingBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private SharpDX.DataStream MapBufferRead(Dx.Resource buffer)
|
||||||
|
{
|
||||||
|
SharpDX.DataStream stream;
|
||||||
|
buffer.Device.ImmediateContext.MapSubresource(buffer, 0, Dx.MapMode.Read, Dx.MapFlags.None, out stream);
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CopySubresource(Dx.Buffer source, Dx.Buffer destination)
|
||||||
|
{
|
||||||
|
this.NativeBuffer.Device.ImmediateContext.CopyResource(source, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnmapBuffer(Dx.Resource buffer)
|
||||||
|
{
|
||||||
|
buffer.Device.ImmediateContext.UnmapSubresource(buffer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dx.Buffer CreateStagingBuffer(int sizeInBytes)
|
||||||
|
{
|
||||||
|
var description = new Dx.BufferDescription()
|
||||||
|
{
|
||||||
|
Usage = Dx.ResourceUsage.Staging,
|
||||||
|
SizeInBytes = sizeInBytes,
|
||||||
|
CpuAccessFlags = Dx.CpuAccessFlags.Read,
|
||||||
|
OptionFlags = Dx.ResourceOptionFlags.None,
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Dx.Buffer(NativeBuffer.Device, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Dispose
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (NativeBuffer != null)
|
||||||
|
{
|
||||||
|
NativeBuffer.Dispose();
|
||||||
|
NativeBuffer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user