3
\$\begingroup\$

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.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .