Jump to content
  • Advertisement
Sign in to follow this  
daVinci

Why is sampling from large textures so slow?

This topic is 3015 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

Hello.

I have a pixel shader which just samples from a texture and return the value.
Depending from size of the texture, performance is degraded dramatically (sure, the output size is constant). I used 640x480px and 3800x2800px textures.

Why? And how I can improve the performance?

P.S. I have tried to generate mipmaps, but it doesn't helps.
Thanks, Daniel

Share this post


Link to post
Share on other sites
Advertisement
What kind of sampling pattern does your shader use? Does each pixel sample a different part of the texture? Are the samples randomly distributed? Is there a 1-to-1 mapping between pixels and texture-samples?

What format is your texture? Is it compressed (e.g. DXT)?


It's possibly to do with the texture cache. When you fetch a texel, a section of that texture (nearby the fetched texel) is pulled into the texture cache. If you subsequently fetch the same texel, or nearby texels, it's much faster as they're already in the cache.

When using smaller textures, you're much more likely to get a cache-hit, because a larger percentage of the texture will be resident in the cache at any one time.

Share this post


Link to post
Share on other sites
I use the following shader:

// Input image
Texture2D inputImage : register(t0);
SamplerState inputImageSampler : register(s0);

float4 main(float2 nonused : TEXCOORD0, float2 uv : TEXCOORD1) : COLOR
{
return inputImage.Sample(inputImageSampler, uv);
}

This is 1-to-1 mapping between pixels and texture-samples (uv are calculated to make it). Format is BGRA 32bit, not compressed.

Can it occur due to large amount of GPU memory.. I mean maybe GPU has to move the texture in memory in case of large textures before sampling?

Share this post


Link to post
Share on other sites
It's based on two things. One is the cache as mentioned previously and the other is the dimensions. Non pow2 dimensions are stored in a linear fashion that is also not at all cache friendly, especially when bilnear is filtering them.

There's a good chance that if you round them up and make them bigger then you'd see a small win, but the best thing to do is use smaller pow2 textures

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!