3 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_DIRECT3D
26 using SharpDX.Direct3D;
27 using SharpDX.Direct3D11;
29 namespace SiliconStudio.
Paradox.Graphics
36 protected internal readonly SharpDX.Direct3D11.Texture1D
Resource;
37 protected internal SharpDX.DXGI.Surface dxgiSurface;
38 protected internal readonly Texture1DDescription NativeDescription;
45 protected internal Texture1D(GraphicsDevice device, TextureDescription description1D, DataBox[] dataBox = null) : base(device, description1D,
ViewType.
Full, 0, 0)
47 NativeDescription = ConvertToNativeDescription(description1D);
48 Resource =
new SharpDX.Direct3D11.Texture1D(device.NativeDevice, NativeDescription, ConvertDataBoxes(dataBox));
50 NativeShaderResourceView = GetShaderResourceView(
ViewType, ArraySlice, MipLevel);
51 NativeUnorderedAccessView = GetUnorderedAccessView(ArraySlice, MipLevel);
59 protected internal Texture1D(GraphicsDevice device, Texture1D texture,
ViewType viewType,
int arraySlice,
int mipMapSlice,
PixelFormat viewFormat =
PixelFormat.None) : base(device, texture, viewType, arraySlice, mipMapSlice, viewFormat)
62 _nativeDeviceChild = texture._nativeDeviceChild;
64 NativeDescription = texture.NativeDescription;
65 dxgiSurface = texture.dxgiSurface;
66 NativeShaderResourceView = GetShaderResourceView(
ViewType, ArraySlice, MipLevel);
67 NativeUnorderedAccessView = GetUnorderedAccessView(ArraySlice, MipLevel);
70 public override Texture ToTexture(
ViewType viewType,
int arraySlice,
int mipMapSlice)
72 return new Texture1D(GraphicsDevice,
this, viewType, arraySlice, mipMapSlice);
77 if ((this.NativeDescription.BindFlags & BindFlags.ShaderResource) == 0)
82 GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);
85 var srvDescription =
new ShaderResourceViewDescription() { Format = (Format)this.Description.Format };
88 if (this.Description.ArraySize > 1)
91 srvDescription.Dimension = ShaderResourceViewDimension.Texture1DArray;
92 srvDescription.Texture1DArray.ArraySize = arrayCount;
93 srvDescription.Texture1DArray.FirstArraySlice = arrayOrDepthSlice;
94 srvDescription.Texture1DArray.MipLevels = mipCount;
95 srvDescription.Texture1DArray.MostDetailedMip = mipIndex;
99 srvDescription.Dimension = ShaderResourceViewDimension.Texture1D;
100 srvDescription.Texture1D.MipLevels = mipCount;
101 srvDescription.Texture1D.MostDetailedMip = mipIndex;
104 return new ShaderResourceView(this.GraphicsDevice.NativeDevice,
this.Resource, srvDescription);
107 internal override UnorderedAccessView GetUnorderedAccessView(
int arrayOrDepthSlice,
int mipIndex)
109 if ((this.NativeDescription.BindFlags & BindFlags.UnorderedAccess) == 0)
114 GetViewSliceBounds(
ViewType.Single, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);
116 var uavDescription =
new UnorderedAccessViewDescription() {
117 Format = (Format)this.Description.Format,
118 Dimension =
this.Description.ArraySize > 1 ? UnorderedAccessViewDimension.Texture1DArray : UnorderedAccessViewDimension.Texture1D
121 if (this.Description.ArraySize > 1)
123 uavDescription.Texture1DArray.ArraySize = arrayCount;
124 uavDescription.Texture1DArray.FirstArraySlice = arrayOrDepthSlice;
125 uavDescription.Texture1DArray.MipSlice = mipIndex;
129 uavDescription.Texture1D.MipSlice = mipIndex;
135 internal override RenderTargetView GetRenderTargetView(
ViewType viewType,
int arrayOrDepthSlice,
int mipIndex)
137 if ((this.NativeDescription.BindFlags & BindFlags.RenderTarget) == 0)
141 throw new NotSupportedException(
"ViewSlice.MipBand is not supported for render targets");
145 GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);
148 var rtvDescription =
new RenderTargetViewDescription() { Format = this.NativeDescription.Format };
150 if (this.Description.ArraySize > 1)
152 rtvDescription.Dimension = RenderTargetViewDimension.Texture1DArray;
153 rtvDescription.Texture1DArray.ArraySize = arrayCount;
154 rtvDescription.Texture1DArray.FirstArraySlice = arrayOrDepthSlice;
155 rtvDescription.Texture1DArray.MipSlice = mipIndex;
159 rtvDescription.Dimension = RenderTargetViewDimension.Texture1D;
160 rtvDescription.Texture1D.MipSlice = mipIndex;
163 return new RenderTargetView(GraphicsDevice.NativeDevice, Resource, rtvDescription);
166 protected static Texture1DDescription ConvertToNativeDescription(TextureDescription description)
168 var desc =
new Texture1DDescription()
170 Width = description.Width,
172 BindFlags = GetBindFlagsFromTextureFlags(description.Flags),
173 Format = (Format)description.Format,
174 MipLevels = description.MipLevels,
175 Usage = (ResourceUsage)description.Usage,
176 CpuAccessFlags = GetCpuAccessFlagsFromUsage(description.Usage),
177 OptionFlags = ResourceOptionFlags.None
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 1D.
PixelFormat
Defines various types of pixel formats.