Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


AMD APU 6520g fails on texture map from size


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 ucfchuck   Members   -  Reputation: 139

Like
0Likes
Like

Posted 19 September 2012 - 03:11 PM

i have a texture of some random size, usually a base 2 but recently i have had to accommodate random sizes like 128x455 instead of 128x512. in the hardware it wants some multiple of 32 or else it will wrap around and mess up the image so i rearranged the sizing


the texture is still only xsize*ysize (ie 128 x 455)

newtdesc.Width = xsize;
newtdesc.Height = ysize;
...
pTexture = new SlimDX.Direct3D10.Texture2D(g_pd3dDevice, newtdesc);

i map the texture and fill with new data like normal but if i am using the actual size of the texture on the new data it will wrap when it is not a 32 multiple


DataRectangle mappedTex = null;
mappedTex = pTexture.Map(0, D3D10.MapMode.WriteDiscard, D3D10.MapFlags.None);
mappedTex.Data.WriteRange<byte>(NewData);
pTexture.Unmap(0);


so i have to pad the new data with zeros to get the multiple of 32 for the total new data size even though the texture is smaller

int texsizefix = ysize + (32 - (ysize % 32));
Byte[] NewData = new Byte[(int)((texsizefix * xsize) * 4)]; // * 4 due to r8g8b8a8
(ie 128x480 zero padded on each line)


so now this all works fine on several cards, im running a gtx 460m, a gtx 560m, and an amd 6750m but now i picked up a bottom end amd apu with a 6520g integrated gpu and it will not work, it gives me an 'attempted to read past the end of stream' error from this size difference between the texture and the NewData on the map instruction. i tried upgrading drivers and slimdx/directx versions etc but nothing seems to change it. i know i am being a little lazy about it in that i could force all the textures to be some multiple of 32 and handle some stretching in the shaders/vertex mapping but it will set me back significantly if i have to recalculate everything involved with that. am i missing something obvious that fixes the wrapping bug in slimdx/directx or is this just an issue with the new chips not having mature enough drivers to handle this.

Edited by ucfchuck, 19 September 2012 - 03:16 PM.


Sponsor:

#2 MJP   Moderators   -  Reputation: 11781

Like
2Likes
Like

Posted 19 September 2012 - 06:49 PM

I'm not super-familiar with SlimDX so I wouldn't know for sure, but perhaps you need to account for the pitch of the mapped texture when writing the new data? This is what you normally have to do in native DX. The pitch will change for different hardware/drivers, so it would account for the strange behavior you're experiencing. There shouldn't be any limitations regarding power-of-2 textures or dimensions being a multiple of 32, so I'm thinking that was the same problem.

#3 Mike.Popoloski   Crossbones+   -  Reputation: 2931

Like
2Likes
Like

Posted 19 September 2012 - 08:15 PM

Yes, the returned DataRectangle object will tell you the pitch so that you don't have to guess at the amount of padding, like you're currently doing. Take that into account when writing the data and you should be good.
Mike Popoloski | Journal | SlimDX

#4 ucfchuck   Members   -  Reputation: 139

Like
0Likes
Like

Posted 20 September 2012 - 10:34 AM

ok cool i moved texsizefix to a global and plugged this in everywhere i change the dimensions of the texture, to try and minimize the locking time on the texture resource, and it works great.

DataRectangle tempTex = null;
tempTex = pTexture.Map(0, D3D10.MapMode.WriteDiscard, D3D10.MapFlags.None);
pTexture.Unmap(0);
texsizefix = tempTex.Pitch / 4; // div by 4 as the returned value is for r8g8b8a8

thanks guys

#5 Nik02   Crossbones+   -  Reputation: 2925

Like
0Likes
Like

Posted 22 September 2012 - 06:47 AM

The pitch could be potentially different every time you map the resource. This is because the driver can relocate the physical memory for the resource when it deems it necessary. To your application, this is a completely transparent operation.

GPU resource virtualization - as implemented in DXGI - can cause very frequent physical GPU memory relocations.

If you map a resource for writing, it is generally not the map/unmap operation itself that causes performance loss. The true reason for performance drop is usually the fact that the GPU may have to wait for access to the resource, if it is - for example - used in a rendering operation at the same time. Of course, large copies will also consume bus bandwidth, which is a separate potential performance hog.

Edited by Nik02, 22 September 2012 - 06:54 AM.

Niko Suni





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS