public unsafe void Allocate_Uninitialized_Ok(Device device, Type bufferType, AllocationMode allocationMode) { using TransferTexture3D <float> texture = device.Get().AllocateTransferTexture3D <float>(bufferType, 128, 256, 32, allocationMode); Assert.IsNotNull(texture); Assert.AreEqual(texture.Width, 128); Assert.AreEqual(texture.Height, 256); Assert.AreEqual(texture.Depth, 32); Assert.AreEqual(texture.View.Width, 128); Assert.AreEqual(texture.View.Height, 256); Assert.AreEqual(texture.View.Depth, 32); Assert.AreSame(texture.GraphicsDevice, device.Get()); if (allocationMode == AllocationMode.Clear) { for (int z = 0; z < texture.Depth; z++) { for (int y = 0; y < texture.Height; y++) { foreach (float x in texture.View.GetRowSpan(y, z)) { Assert.AreEqual(x, 0f); } } } } }
public void UsageAfterDispose(Device device, Type bufferType) { using TransferTexture3D <float> buffer = device.Get().AllocateTransferTexture3D <float>(bufferType, 32, 32, 16); buffer.Dispose(); _ = buffer.View; }
public void UsageAfterDispose(Device device, Type textureType) { using TransferTexture3D <float> texture = device.Get().AllocateTransferTexture3D <float>(textureType, 32, 32, 16); texture.Dispose(); _ = texture.View; }
public unsafe void Allocate_Uninitialized_Ok(Device device, Type bufferType) { using TransferTexture3D <float> buffer = device.Get().AllocateTransferTexture3D <float>(bufferType, 128, 256, 32); Assert.IsNotNull(buffer); Assert.AreEqual(buffer.Width, 128); Assert.AreEqual(buffer.Height, 256); Assert.AreEqual(buffer.Depth, 32); Assert.AreEqual(buffer.View.Width, 128); Assert.AreEqual(buffer.View.Height, 256); Assert.AreEqual(buffer.View.Depth, 32); Assert.AreSame(buffer.GraphicsDevice, device.Get()); }
public void ResourceFromTransferTexture3D(Device device, Type bufferType) { using TransferTexture3D <float> buffer = device.Get().AllocateTransferTexture3D <float>(bufferType, 16, 16, 4); using ComPtr <ID3D12Resource> d3D12Resource = default; InteropServices.GetID3D12Resource(buffer, Windows.__uuidof <ID3D12Resource>(), (void **)d3D12Resource.GetAddressOf()); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); d3D12Resource.Dispose(); int hResult = InteropServices.TryGetID3D12Resource(buffer, Windows.__uuidof <ID3D12Resource>(), (void **)d3D12Resource.GetAddressOf()); Assert.AreEqual(hResult, S.S_OK); Assert.IsTrue(d3D12Resource.Get() != null); Assert.AreEqual(d3D12Resource.Get()->GetDesc().Dimension, D3D12_RESOURCE_DIMENSION_BUFFER); }
public void DisposeAfterDevice(Device device, Type textureType) { GraphicsDevice?gpu = device switch { Device.Discrete => GraphicsDevice.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(), Device.Warp => GraphicsDevice.QueryDevices(info => !info.IsHardwareAccelerated).First(), _ => throw new ArgumentException(nameof(device)) }; if (gpu is null) { Assert.Inconclusive(); return; } TransferTexture3D <float> texture = gpu.AllocateTransferTexture3D <float>(textureType, 32, 32, 16); gpu.Dispose(); texture.Dispose(); }
/// <summary> /// Tries to get the underlying COM object for a given resource, as a specified interface. This method invokes /// <see href="https://docs.microsoft.com/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)">IUnknown::QueryInterface</see>. /// </summary> /// <typeparam name="T">The type of items stored on the texture.</typeparam> /// <param name="texture">The input <see cref="TransferTexture3D{T}"/> instance in use.</param> /// <param name="riid">A reference to the interface identifier (IID) of the resource interface being queried for.</param> /// <param name="ppvObject">The address of a pointer to an interface with the IID specified in <paramref name="riid"/>.</param> /// <returns> /// <c>S_OK</c> if the interface is supported, and <c>E_NOINTERFACE</c> otherwise. /// If ppvObject (the address) is nullptr, then this method returns <c>E_POINTER</c>. /// </returns> public static int TryGetID3D12Resource <T>(TransferTexture3D <T> texture, Guid *riid, void **ppvObject) where T : unmanaged { return(texture.D3D12Resource->QueryInterface(riid, ppvObject)); }
/// <summary> /// Gets the underlying COM object for a given resource, as a specified interface. This method invokes /// <see href="https://docs.microsoft.com/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)">IUnknown::QueryInterface</see>. /// </summary> /// <typeparam name="T">The type of items stored on the texture.</typeparam> /// <param name="texture">The input <see cref="TransferTexture3D{T}"/> instance in use.</param> /// <param name="riid">A reference to the interface identifier (IID) of the resource interface being queried for.</param> /// <param name="ppvObject">The address of a pointer to an interface with the IID specified in <paramref name="riid"/>.</param> /// <exception cref="Win32Exception">Thrown if the <c>IUnknown::QueryInterface</c> call doesn't return <c>S_OK</c>.</exception> public static void GetID3D12Resource <T>(TransferTexture3D <T> texture, Guid *riid, void **ppvObject) where T : unmanaged { texture.D3D12Resource->QueryInterface(riid, ppvObject).Assert(); }
public void Allocate_Uninitialized_Fail(Device device, Type bufferType, int width, int height, int depth) { using TransferTexture3D <float> buffer = device.Get().AllocateTransferTexture3D <float>(bufferType, width, height, depth); }
/// <summary> /// Initializes a new instance of the <see cref="TransferTexture3DDebugView{T}"/> class with the specified parameters. /// </summary> /// <param name="texture">The input <see cref="TransferTexture3D{T}"/> instance with the items to display.</param> public TransferTexture3DDebugView(TransferTexture3D <T>?texture) { Items = texture?.View.ToArray(); }
/// <summary> /// Throws a new <see cref="GraphicsDeviceMismatchException"/> instance from the specified parameters. /// </summary> /// <typeparam name="T">The type of values in the input buffer.</typeparam> /// <param name="texture">The input <see cref="TransferTexture3D{T}"/> that was used.</param> /// <param name="device">The target <see cref="GraphicsDevice"/> instance that was used.</param> internal static void Throw <T>(TransferTexture3D <T> texture, GraphicsDevice device) where T : unmanaged { throw Create(texture, texture.GraphicsDevice, device); }