3 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_DIRECT3D
27 using SharpDX.Direct3D;
28 using SharpDX.Direct3D11;
31 namespace SiliconStudio.
Paradox.Graphics
38 protected readonly SharpDX.Direct3D11.Texture3D
Resource;
39 private SharpDX.DXGI.Surface dxgiSurface;
40 protected internal readonly Texture3DDescription NativeDescription;
48 protected internal Texture3D(GraphicsDevice device, TextureDescription description3D, DataBox[] dataBoxes = null) : base(device, description3D,
ViewType.
Full, 0, 0)
50 NativeDescription = ConvertToNativeDescription(description3D);
51 Resource =
new SharpDX.Direct3D11.Texture3D(device.NativeDevice, NativeDescription, ConvertDataBoxes(dataBoxes));
53 NativeShaderResourceView = GetShaderResourceView(
ViewType, ArraySlice, MipLevel);
54 NativeUnorderedAccessView = GetUnorderedAccessView(ArraySlice, MipLevel);
62 protected internal Texture3D(GraphicsDevice device, Texture3D texture,
ViewType viewType,
int arraySlice,
int mipMapSlice,
PixelFormat viewFormat =
PixelFormat.None) : base(device, texture, viewType, arraySlice, mipMapSlice, viewFormat)
65 _nativeDeviceChild = texture._nativeDeviceChild;
67 NativeDescription = texture.NativeDescription;
68 dxgiSurface = texture.dxgiSurface;
69 NativeShaderResourceView = GetShaderResourceView(
ViewType, ArraySlice, MipLevel);
70 NativeUnorderedAccessView = GetUnorderedAccessView(ArraySlice, MipLevel);
73 public override Texture ToTexture(
ViewType viewType,
int arraySlice,
int mipMapSlice)
75 return new Texture3D(GraphicsDevice,
this, viewType, arraySlice, mipMapSlice);
80 if ((this.NativeDescription.BindFlags & BindFlags.ShaderResource) == 0)
85 GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);
88 var srvDescription =
new ShaderResourceViewDescription {
89 Format = (Format)this.Description.Format,
90 Dimension = ShaderResourceViewDimension.Texture3D,
93 MostDetailedMip = mipIndex
97 return new ShaderResourceView(this.GraphicsDevice.NativeDevice,
this.Resource, srvDescription);
102 if ((this.NativeDescription.BindFlags & BindFlags.UnorderedAccess) == 0)
107 GetViewSliceBounds(
ViewType.Single, ref zSlice, ref mipIndex, out sliceCount, out mipCount);
109 var uavIndex = GetViewIndex(
ViewType.Single, zSlice, mipIndex);
111 var uavDescription =
new UnorderedAccessViewDescription() {
112 Format = (Format)this.Description.Format,
113 Dimension = UnorderedAccessViewDimension.Texture3D,
115 FirstWSlice = zSlice,
124 protected static Texture3DDescription ConvertToNativeDescription(TextureDescription description)
126 var desc =
new Texture3DDescription()
128 Width = description.Width,
129 Height = description.Height,
130 Depth = description.Depth,
131 BindFlags = GetBindFlagsFromTextureFlags(description.Flags),
132 Format = (Format)description.Format,
133 MipLevels = description.MipLevels,
134 Usage = (ResourceUsage)description.Usage,
135 CpuAccessFlags = GetCpuAccessFlagsFromUsage(description.Usage),
136 OptionFlags = ResourceOptionFlags.None
141 internal override RenderTargetView GetRenderTargetView(
ViewType viewType,
int arrayOrDepthSlice,
int mipIndex)
143 if ((this.NativeDescription.BindFlags & BindFlags.RenderTarget) == 0)
147 throw new NotSupportedException(
"ViewSlice.MipBand is not supported for render targets");
151 GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);
154 var rtvDescription =
new RenderTargetViewDescription()
156 Format = this.NativeDescription.Format,
157 Dimension = RenderTargetViewDimension.Texture3D,
160 DepthSliceCount = arrayCount,
161 FirstDepthSlice = arrayOrDepthSlice,
166 return new RenderTargetView(GraphicsDevice.NativeDevice, Resource, rtvDescription);
ViewType
Defines how a view is selected from a resource.
Same as Deferred mode, except sprites are sorted by texture prior to drawing. This can improve perfor...
Gets a texture view for the whole texture for all mips/arrays dimensions.
The texture dimension is 3D.
PixelFormat
Defines various types of pixel formats.