/// <summary> /// Initializes a new instance of the <see cref="UnorderedAccessViewDescription1"/> struct. /// </summary> /// <param name="texture"></param> /// <param name="viewDimension"></param> /// <param name="format"></param> /// <param name="mipSlice"></param> /// <param name="firstWSlice"></param> /// <param name="wSize"></param> public UnorderedAccessViewDescription1( ID3D11Texture3D texture, UnorderedAccessViewDimension viewDimension, Format format = Format.Unknown, int mipSlice = 0, int firstWSlice = 0, int wSize = -1) : this() { ViewDimension = viewDimension; if (format == Format.Unknown || wSize == -1) { var textureDesc = texture.Description; if (format == Format.Unknown) { format = textureDesc.Format; } if (wSize == -1) { wSize = textureDesc.Depth - firstWSlice; } } Format = format; Texture3D.MipSlice = mipSlice; Texture3D.FirstWSlice = firstWSlice; Texture3D.WSize = wSize; }
/// <summary> /// Initializes a new instance of the <see cref="UnorderedAccessViewDescription1"/> struct. /// </summary> /// <param name="viewDimension">The <see cref="UnorderedAccessViewDimension"/></param> /// <param name="format">The <see cref="DXGI.Format"/> to use or <see cref="Format.Unknown"/>.</param> /// <param name="mipSlice">The index of the mipmap level to use mip slice or FirstElement for BUFFER.</param> /// <param name="firstArraySlice">The index of the first texture to use in an array of textures or NumElements for BUFFER or FirstWSlice for TEXTURE3D.</param> /// <param name="arraySize">Number of textures in the array or WSize for TEXTURE3D.</param> /// <param name="flags"><see cref="BufferUnorderedAccessViewFlag"/> options flags for the resource.</param> /// <param name="planeSlice"></param> public UnorderedAccessViewDescription1( UnorderedAccessViewDimension viewDimension, Format format = Format.Unknown, int mipSlice = 0, int firstArraySlice = 0, int arraySize = -1, BufferUnorderedAccessViewFlag flags = BufferUnorderedAccessViewFlag.None, int planeSlice = 0) : this() { Format = format; ViewDimension = viewDimension; switch (viewDimension) { case UnorderedAccessViewDimension.Buffer: Buffer.FirstElement = mipSlice; Buffer.NumElements = firstArraySlice; Buffer.Flags = flags; break; case UnorderedAccessViewDimension.Texture1D: Texture1D.MipSlice = mipSlice; break; case UnorderedAccessViewDimension.Texture1DArray: Texture1DArray.MipSlice = mipSlice; Texture1DArray.FirstArraySlice = firstArraySlice; Texture1DArray.ArraySize = arraySize; break; case UnorderedAccessViewDimension.Texture2D: Texture2D.MipSlice = mipSlice; Texture2D.PlaneSlice = planeSlice; break; case UnorderedAccessViewDimension.Texture2DArray: Texture2DArray.MipSlice = mipSlice; Texture2DArray.FirstArraySlice = firstArraySlice; Texture2DArray.ArraySize = arraySize; Texture2DArray.PlaneSlice = planeSlice; break; case UnorderedAccessViewDimension.Texture3D: Texture3D.MipSlice = mipSlice; Texture3D.FirstWSlice = firstArraySlice; Texture3D.WSize = arraySize; break; } }
/// <summary> /// Initializes a new instance of the <see cref="UnorderedAccessViewDescription1"/> struct. /// </summary> /// <param name="texture"></param> /// <param name="viewDimension"></param> /// <param name="format"></param> /// <param name="mipSlice"></param> /// <param name="firstArraySlice"></param> /// <param name="arraySize"></param> /// <param name="planeSlice"></param> public UnorderedAccessViewDescription1( ID3D11Texture2D texture, UnorderedAccessViewDimension viewDimension, Format format = Format.Unknown, int mipSlice = 0, int firstArraySlice = 0, int arraySize = -1, int planeSlice = 0) : this() { ViewDimension = viewDimension; if (format == Format.Unknown || (-1 == arraySize && (viewDimension == UnorderedAccessViewDimension.Texture2DArray))) { var textureDesc = texture.Description; if (format == Format.Unknown) { format = textureDesc.Format; } if (arraySize == -1) { arraySize = textureDesc.ArraySize - firstArraySlice; } } Format = format; switch (viewDimension) { case UnorderedAccessViewDimension.Texture2D: Texture2D.MipSlice = mipSlice; Texture2D.PlaneSlice = planeSlice; break; case UnorderedAccessViewDimension.Texture2DArray: Texture2DArray.MipSlice = mipSlice; Texture2DArray.FirstArraySlice = firstArraySlice; Texture2DArray.ArraySize = arraySize; Texture2DArray.PlaneSlice = planeSlice; break; } }
public static UnorderedAccessView CreateUnorderedAccessView(Device device, Resource resource, Format format, UnorderedAccessViewDimension viewDimension, int firstElement, int numElements, UnorderedAccessViewBufferFlags flags, int mipSlice) { UnorderedAccessViewDescription uavd = new UnorderedAccessViewDescription(); uavd.Format = format; uavd.Dimension = viewDimension; switch (viewDimension) { case UnorderedAccessViewDimension.Texture1D: uavd.Texture1D.MipSlice = mipSlice; break; case UnorderedAccessViewDimension.Texture1DArray: uavd.Texture1DArray.MipSlice = mipSlice; uavd.Texture1DArray.ArraySize = numElements; uavd.Texture1DArray.FirstArraySlice = firstElement; break; case UnorderedAccessViewDimension.Texture2D: uavd.Texture2D.MipSlice = mipSlice; break; case UnorderedAccessViewDimension.Texture2DArray: uavd.Texture2DArray.MipSlice = mipSlice; uavd.Texture2DArray.ArraySize = numElements; uavd.Texture2DArray.FirstArraySlice = firstElement; break; case UnorderedAccessViewDimension.Texture3D: uavd.Texture3D.MipSlice = mipSlice; uavd.Texture3D.WSize = numElements; uavd.Texture3D.FirstWSlice = firstElement; break; case UnorderedAccessViewDimension.Buffer: uavd.Buffer.ElementCount = numElements; uavd.Buffer.FirstElement = firstElement; uavd.Buffer.Flags = flags; break; case UnorderedAccessViewDimension.Unknown: default: return(null); } var uav = new UnorderedAccessView(device, resource, uavd); return(uav); }