i965: Clamp texture buffer size to GL_MAX_TEXTURE_BUFFER_SIZE.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 3 Mar 2017 07:28:42 +0000 (23:28 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 5 Mar 2017 06:46:50 +0000 (22:46 -0800)
commit6f71d9adc1209795d523ebcd8007a90619d85104
tree06678a104ba6427b2ac948ee26a6d32473ed6db2
parenteaf4a106bdcf476078ef4f84c81329034a226650
i965: Clamp texture buffer size to GL_MAX_TEXTURE_BUFFER_SIZE.

The OpenGL 4.5 specification's description of TexBuffer says:

"The number of texels in the texture image is then clamped to an
 implementation-dependent limit, the value of MAX_TEXTURE_BUFFER_SIZE."

We set GL_MAX_TEXTURE_BUFFER_SIZE to 2^27.  For buffers with a byte
element size, this is the maximum possible size we can encode in
SURFACE_STATE.  If you bind a buffer object larger than this as a
texture buffer object, we'll exceed that limit and hit an isl assert:

   assert(num_elements <= (1ull << 27));

To fix this, clamp the size in bytes to MaxTextureSize / texel_size.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c