Jump to content
  • Advertisement

jsedlak

Member
  • Content Count

    4
  • Joined

  • Last visited

Everything posted by jsedlak

  1. How do you map a subresource into a position in an array of another? [/quote]Sorry, I don't understand the question - do you mean mapping a texture subresource to another texture array subresource? If so, then for mapping you just map the two subresources and then copy the data directly. With UpdateSubResource you more or less specify the locations in the parameter arguments and the function does the copying for you. [/quote] I'm probably not asking the right question... (and yes, sorry for the hijack) http://www.gamedev.net/topic/618817-using-texture2darray-and-shaderresourceview/
  2. How do you map a subresource into a position in an array of another?
  3. I updated the code - something with how I am trying to copy the textures is not working... var box = App.Device.ImmediateContext.MapSubresource(stagingTexture, 0, i, MapMode.Write, MapFlags.None); App.Device.ImmediateContext.UpdateSubresource(box, tileset.Texture, 0); App.Device.ImmediateContext.UnmapSubresource(stagingTexture, 0);
  4. I'm working on a shader that utilizes a Texture2DArray<float4> variable, but am having trouble setting it up in the C# code. I have a list of textures I want to load into the array, but am not sure how to proceed with actually putting them in the resource. Right now I have the following. Log.BeginSection("Level.LoadTextureArray"); int mipLevels = tilesets[0].Texture.Description.MipLevels; SlimDX.DXGI.Format format = tilesets[0].Texture.Description.Format; Log.WriteLine("Mip Levels: {0}", mipLevels); Log.WriteLine("Format: {0}", format); Texture2DDescription stagingDescription = new Texture2DDescription { ArraySize = tilesets.Count, Width = 512, Height = 512, BindFlags = BindFlags.None, CpuAccessFlags = CpuAccessFlags.Write, Format = format, Usage = ResourceUsage.Staging, MipLevels = mipLevels, SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0) }; //TextureCache = new Texture2D(App.Device, desc); var stagingTexture = new Texture2D(App.Device, stagingDescription); Log.BeginSection("Tileset Loop"); for (int i = 0; i < tilesets.Count; i++) { Tileset tileset = tilesets; Log.WriteLine("Loading tileset {1} ({0})", tileset.Filename, i); tileset.EnsureAssets(); var box = App.Device.ImmediateContext.MapSubresource(stagingTexture, 0, i, MapMode.Write, MapFlags.None); App.Device.ImmediateContext.UpdateSubresource(box, tileset.Texture, 0); App.Device.ImmediateContext.UnmapSubresource(stagingTexture, 0); tileset.DisposeAssets(); } Log.EndSection("Tileset Loop"); var destinationDescription = new Texture2DDescription { ArraySize = tilesets.Count, MipLevels = mipLevels, Format = format, Width = 512, Height = 512, Usage = ResourceUsage.Default, BindFlags = SlimDX.Direct3D11.BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0) }; TextureCache = new Texture2D(App.Device, destinationDescription); App.Device.ImmediateContext.CopyResource(stagingTexture, TextureCache); TextureCacheView = new ShaderResourceView(App.Device, TextureCache); Log.EndSection("Level.LoadTextureArray"); This returns a "A first chance exception of type 'SlimDX.Direct3D11.Direct3D11Exception' occurred in SlimDX.dll" when I create the ShaderResourceView. Am I missing something, or doing something very wrong? TIA.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!