Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.