Jump to content

  • Log In with Google      Sign In   
  • Create Account


SlimDX (D3D10) Texture2PNG


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
2 replies to this topic

#1 Ivan Peric   Members   -  Reputation: 105

Like
0Likes
Like

Posted 20 May 2014 - 09:29 AM

I have a performance problem with converting Texture2D to PNG. Since I am a total noob at DirectX, I used the Texture2D.ToStream method to map texure data to png data, and it looks kinda slow to me.

 

All application does is draws 1000 random lines to texture and then exports that texture to stream (byte array is the final product). The proces is repeated many times (~100) to get a collection of different images and exporting texture to stream takes ~98% of application run time.

Is there an alternative way to map texture data to image data that will be faster?


 



Sponsor:

#2 tonemgub   Members   -  Reputation: 617

Like
1Likes
Like

Posted 20 May 2014 - 09:56 AM

Image format conversion is not supposed to be a real-time operation (maybe except for the DXT format?), if that's what you're expecting. This conversion is also done on the CPU, which means that the texture is first copied from video memory to system memory, making it even slower. Even without the compression, copying the texture to a stream in system-memory or in a file is going to be slow.

Video games usually have special algorithms to predict when they have to pre-load extra textures from disk or from cached memory. You have to do the reverse of that: delay copying all of your data to memory/disk, until you know that somethign has actually changed. Combine that with saving your data as DXT, and you might get some speed improvements, though I can't promise anything spectacular.



#3 Ivan Peric   Members   -  Reputation: 105

Like
0Likes
Like

Posted 21 May 2014 - 07:59 AM

Thank you for your answer,

but I managed to speed things up on my own by writing my own method which does the following:

1) Creates Staging resource with CPU Read access
2) Copies resource from original Default resource to staging resource

3) Maps Staging resource and uses it's DataPointer to create BitmapResource

4) Creates the png with PngBitmapEncoder and created Bitmap resource.

This improved application run time ~60%.

 






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