How do I create a Texture2D array in SlimDX ? Or alternatively, can I use photoshops dds exporter to create a dds texture array to load into the Texture2d as i do for normal Textured2D's ?
I have looked at using CopySubresource region() which looks like a good candidate for copying a texture into a texture array because i can select the destination subresource. But there seems to be a catch : MapSubresource requires CPUAccessFlags.Write, so that excludes Default and Immutable, leaving Staging which must be BindFlags.None so i then cant use it as a resource and Dynamic which cannot have an array size of anything but [1]. So it appeares to me as though CopySubresource cant be used for texture arrays !! That seems really weird to me.
What I'm after is :
Texture2D.FromFile(SlimDXDirect3D11.Device device, List<String> sourceFiles);
I know I wont get it, because GOD ! that would be just too easy wouldn't it. No one would dare write a texture loading method so straight forward.
Anyway ...
... I now have the following code, (which will compile but i only see black)
// texture2DArray_G1Brushes ===========================================================
ImageLoadInformation loadInfo = new ImageLoadInformation();
loadInfo.CpuAccessFlags = CpuAccessFlags.Read;
loadInfo.BindFlags = BindFlags.None;
loadInfo.Depth = 1;
loadInfo.FilterFlags = FilterFlags.Point;
loadInfo.FirstMipLevel = 1;
loadInfo.Format = Format.R8G8B8A8_UNorm;
loadInfo.Height = 220;
loadInfo.MipFilterFlags = FilterFlags.None;
loadInfo.MipLevels = 1;
loadInfo.OptionFlags = ResourceOptionFlags.None;
loadInfo.Usage = ResourceUsage.Staging;
loadInfo.Width = 200;
DataRectangle[] dataRectangleArray = new DataRectangle[2];
Texture2D tex1 = Texture2D.FromFile(SDXForm.Device11,"Resources/Logo1.dds",loadInfo);
Single[] fArray = new Single[200*220*4];
DataStream dataStream = new DataStream(fArray, true, true);
Texture2D.ToStream(SDXForm.Device11.ImmediateContext, tex1, ImageFileFormat.Dds, dataStream);
dataRectangleArray[0] = new DataRectangle(200*4, dataStream);
Texture2D tex2 = Texture2D.FromFile(SDXForm.Device11, "Resources/Logo2.dds", loadInfo);
Texture2D.ToStream(SDXForm.Device11.ImmediateContext, tex2, ImageFileFormat.Dds, dataStream);
dataRectangleArray[1] = new DataRectangle(200 * 4, dataStream);
Texture2DDescription textureDescription = new Texture2DDescription()
{
ArraySize = 2,
BindFlags = BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm,
Height = 220,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
Usage = ResourceUsage.Immutable,
Width = 200
};
texture2DArray_G1Brushes = new Texture2D(SDXForm.Device11, textureDescription, dataRectangleArray);
AddResource("texture2DArray_G1Brushes", texture2DArray_G1Brushes);
// srv_G1BrushesArray =================================================================
ShaderResourceViewDescription shaderResourceDesc = new ShaderResourceViewDescription()
{
ArraySize = 2,
Format = Format.R8G8B8A8_UNorm,
Dimension = ShaderResourceViewDimension.Texture2DArray,
MostDetailedMip = 0,
MipLevels = 1
};
srv_G1BrushesArray = new ShaderResourceView(SDXForm.Device11, texture2DArray_G1Brushes, shaderResourceDesc);
AddResource("srv_G1BrushesArray", srv_G1BrushesArray);
Edited by Gavin Williams, 14 June 2012 - 01:29 PM.






