Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a fragment shader which needs lots of semi-random access to 32x32 texture patch. Fortunately, the patch is constant for each poly, so there should be no issue storing the whole thing to the texture cache.

So my question is, is there any way in GLSL to prefetch texture patches? Normally, I would be fine letting the FS load the texture naturally, but with the nondeterministic access pattern, I'm afraid that could be producing a ton of unnecessary thrashing while it sorts itself out.

share|improve this question

No, there isn't.

while it sorts itself out

Which will, for a 32x32 texture require... 128 memory accesses. Assuming a 32-byte cache line size and GL_RGBA8 format for the texture. It's only 4KB in size. Unless the cache is microscopic, there won't be any cache misses after it touches all of those 128 memory accesses. And if the cache is smaller than 4KB, there's no "prefetching" that can make a small cache big enough for your data.

Just let the GPU do its job.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.