Jump to content
  • Advertisement
Sign in to follow this  
Haiduk

Arbitrarily Sized Textures working as indended?

This topic is 4592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a simple GUI class I'm building, I am intending to render the windows to render target textures when these windows change. It would seem more efficient to display them as pre-rendered textured quads when they don't change rather than render them with all of their objects (and slowish text) every frame. Now when I check the CAPS the D3DPTEXTURECAPS_POW2 flag is set with my device, which I assume to mean "All textures must have widths and heights specified as powers of two." However, I am able to size these "render target textures" to the size of the gui window objects and they still work on my system. I am using D3DXCreateTexture() with arbitrary widths and heights (not powers of two and not square) using the D3DUSAGE_RENDERTARGET and D3DPOOL_DEFAULT flags to create these textures. The texture dimentions are actually the size of the gui window that the user can resize by dragging. The render targets are working on my system without distortions and the speed boost over rendering the windows and their controls each frame is tremendous. The odd sized textures are working. My questions are: Does the D3DXCreateTexture() function handle the oddball texture sizes internally? Why is this working if the CAPS say the texures must be power of 2 and they are not? Should I worry about compatability with other users systems? (I am using DirectX9.0 with VC6)

Share this post


Link to post
Share on other sites
Advertisement
Most cards support a feature that has another caps bit called D3DPTEXTURECAPS_NONPOW2CONDITIONAL. Basically, if you have no mips, use clamp addressing mode, and don't use DXT1-5, you can use it. Great for HUDs, titles, render targets, etc. These textures also cannot be used for dependant reads, ie: they cannot be read using pixel shader instructions that calculate coordinates, such as texbem, texm3x3.

Note that D3DXCreateTextureFromFileEx() automatically resizes images to POW2 sizes unless you specify a flag telling that nonpow2 is okay. When loading HUD or title images, and the card supports non-pow2, or non-pow2 conditionally, specify this flag to ensure you aren't wasting graphics memory.

Some cards don't require pow2, but take a speed hit from using such textures, which is why you should stick to pow2 sizes for general rendering, even if the card doesn't strictly require it.

Share this post


Link to post
Share on other sites
From what you say, it sounds to me like what im doing here is okay then.

How worried should I be about the D3DPTEXTURECAPS_NONPOW2CONDITIONAL caps?

I could easily disable the "render to texture" feature of the gui for cards that dont support it, but I assume those cards would be quite old and not able to run many games anyway. Isn't this kind of like the old "software renderer" catch-22? (if a video card is so old the feature isn't available in hardware, what chance does it have of rendering via software with a playable framerate?)

BTW thanks for the response.

Share this post


Link to post
Share on other sites
I don't have a recent SDK on my home machine, so I can't check right now, but the newer SDKs contain an excel spreadsheet of all the caps on all DX9 cards, and would be an excellent way to tell which cards are missing this caps bit. I'm pretty sure even my ancient DX7 ATI RagePro Turbo/XPert98 card supported it. No idea when nVidia, Matrox, or onboard cards started to support it, but I'd guess you're probably fairly safe assuming the feature is available.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!