Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Seat Safety Switch
May 27, 2008

MY RELIGION IS THE SMALL BLOCK V8 AND COMMANDMENTS ONE THROUGH TEN ARE NEVER LIFT.

Pillbug
I'm using SlimDX with Direct3D 10.1 and I created a 2D 32x32 texture of format A8_UNorm set up for usage as a shader resource and flagged for write access. When I map the texture to get at a stream to write into it (using WriteDiscard and mip level 0), the stream's stated Length is 2048 bytes long which doesn't make any sense to me (assuming that the 8 in A8_UNorm means 8 bits, 32 * 32 * 1 = 1024).

The DataRectangle that I get from the mapping says that the pitch is 64 as well. It does the same thing if I use R8_UNorm. R32_Float says 4 bytes per texel, which is correct.

Any idea why the stream seems to be twice as long as it should be when I'm using one of the *8_UNorm formats? I'm relatively new to SlimDX (and D3D in general) so perhaps I've made some bad decisions here.

code:
Texture2DDescription textureDescription = new Texture2DDescription
{
  Width = 32,
  Height = 32,
  Format = SlimDX.DXGI.Format.A8_UNorm,
  MipLevels = 1,
  ArraySize = 1,
  SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
  Usage = ResourceUsage.Dynamic,
  CpuAccessFlags = CpuAccessFlags.Write,
  BindFlags = BindFlags.ShaderResource,
  OptionFlags = ResourceOptionFlags.None
};
_texture = new Texture2D(_device, textureDescription);
code:
textureStream = _texture.Map(0, MapMode.WriteDiscard, MapFlags.None).Data;

Adbot
ADBOT LOVES YOU

Seat Safety Switch
May 27, 2008

MY RELIGION IS THE SMALL BLOCK V8 AND COMMANDMENTS ONE THROUGH TEN ARE NEVER LIFT.

Pillbug
I tried the identical code on my ATI card at home as opposed to my Quadro at work, and it returns a stream of the proper size and pitch. I'm really confused, so I'm just using R32_Float for now. Thanks anyway :)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply