The fastest way to display a picture

Started by
2 comments, last by MJP 15 years, 7 months ago
I am searching for the fastest way to display a picture. The format of the picture is not significant (whatever you prefer, or better what would be the best). Source of the image should be considered like the format of the picture. DirectX Version is also free to choose. I think D3DXSprite is very slow? Besides:Are the D3DX functions faster/slower than doing it by hand anyway? Can anyone tell me what the fastest way to display a picture is? Everyones experience, knowledge and opinion is welcome. Thx Vertex
Advertisement
Quote:Original post by Vertex333
I am searching for the fastest way to display a picture. The format of the picture is not significant (whatever you prefer, or better what would be the best). Source of the image should be considered like the format of the picture. DirectX Version is also free to choose. I think D3DXSprite is very slow? Besides:Are the D3DX functions faster/slower than doing it by hand anyway?
Nope, far from it. The D3DX functions are optimised to use advanced CPU features wherever possible (E.g. SIMD, 3DNow!). Admittedly I don't know if that's done for image loading functions; I know it is for the matrix functions.
ID3DXSprite is a general purpose sprite class. Internally it works as a dynamic vertex buffer, which means it's certainly possible to be at least as performant as it in your own code. It's designed for conveniance, not performance, but it does pretty well as it is.

Quote:Original post by Vertex333
Can anyone tell me what the fastest way to display a picture is?

Everyones experience, knowledge and opinion is welcome.
The fastest way to load an image is to either decode it in a thread, or not to use a compressed format at all, then load it into a texture. Ideally you'd do that at load time so the time taken to do that doesn't really matter.
For the fastest way to render it, just make sure it's loaded into a texture, then render it with DrawPrimitive using a static vertex buffer. If the position is to change, then you can either use a matrix to move it, or use a dynamic vertex buffer. Using a matrix is probably faster, but means you need a DrawPrimitive() call for every image to draw - which will quickly become a problem with more than a few images.
Quote:Original post by Evil Steve
Quote:Original post by Vertex333
I am searching for the fastest way to display a picture. The format of the picture is not significant (whatever you prefer, or better what would be the best). Source of the image should be considered like the format of the picture. DirectX Version is also free to choose. I think D3DXSprite is very slow? Besides:Are the D3DX functions faster/slower than doing it by hand anyway?
Nope, far from it. The D3DX functions are optimised to use advanced CPU features wherever possible (E.g. SIMD, 3DNow!). Admittedly I don't know if that's done for image loading functions; I know it is for the matrix functions.
ID3DXSprite is a general purpose sprite class. Internally it works as a dynamic vertex buffer, which means it's certainly possible to be at least as performant as it in your own code. It's designed for conveniance, not performance, but it does pretty well as it is.

Quote:Original post by Vertex333
Can anyone tell me what the fastest way to display a picture is?

Everyones experience, knowledge and opinion is welcome.
The fastest way to load an image is to either decode it in a thread, or not to use a compressed format at all, then load it into a texture. Ideally you'd do that at load time so the time taken to do that doesn't really matter.
For the fastest way to render it, just make sure it's loaded into a texture, then render it with DrawPrimitive using a static vertex buffer. If the position is to change, then you can either use a matrix to move it, or use a dynamic vertex buffer. Using a matrix is probably faster, but means you need a DrawPrimitive() call for every image to draw - which will quickly become a problem with more than a few images.
Thx!

I have some questions that rose with your answers:
1. Would a static vertex buffer perform better than ID3DXSprite, like you state later? Lets say I want to display the image always on the same position.
2. Am I right that I should decompress or load into memory in another thread and afterwards into a texture instead of making a texture in another thread? I know that the D3D multithread flag is no option at all. Do I need it for that? Or is there a middleway?
3. Is there a format for normal images that can be decoded hardware accelerated on the graphics hardware? So quite a bit compression without speed loss. I think PS decode would also be possible, but I don't think that this is trivial and can achieve high performance.
4. Is it very "expensive" (however you can compare this) to load a picture from file (png,bmp,...) and...
5. Is it very "expensive" (however you can compare this) to load a picture from memory into... lets say pool of the graphic card.

Thx,
Vertex
Quote:Original post by Vertex333
1. Would a static vertex buffer perform better than ID3DXSprite, like you state later? Lets say I want to display the image always on the same position.
2. Am I right that I should decompress or load into memory in another thread and afterwards into a texture instead of making a texture in another thread? I know that the D3D multithread flag is no option at all. Do I need it for that? Or is there a middleway?
3. Is there a format for normal images that can be decoded hardware accelerated on the graphics hardware? So quite a bit compression without speed loss. I think PS decode would also be possible, but I don't think that this is trivial and can achieve high performance.
4. Is it very "expensive" (however you can compare this) to load a picture from file (png,bmp,...) and...
5. Is it very "expensive" (however you can compare this) to load a picture from memory into... lets say pool of the graphic card.


1. A static vertex buffer will be faster if you can get away with it. ID3DXSprite uses a dynamic vertex buffer so that it can batch together a bunch of sprites into one draw call, with the amount or size of the sprites potentially changing each frame. If you're always rendering the same image/images, you don't need a dynamic VB.

2. If you dont' use the MULTITHREADED flag then you'll need to always access the device from the same thread. This typically means you'll have one worker thread reading all the data from the HDD, and your main rendering thread will actually create the textures.

3. If you use the DDS file format, you can store your image in a format identical to the surface formats used by GPU's. This can be plain old R8G8B8A8, or even a compressed format like DXT1.

4. Yes, the file I/O is the expensive part of loading an image and will very expensive compared to normal graphics operations.

5. Creating the texture and filling the data won't be quick, but it definitely won't be nearly as slow as the file I/O.

This topic is closed to new replies.

Advertisement