diff options
author | Kenneth Graunke <[email protected]> | 2017-03-02 23:28:42 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2017-03-04 22:46:50 -0800 |
commit | 6f71d9adc1209795d523ebcd8007a90619d85104 (patch) | |
tree | 06678a104ba6427b2ac948ee26a6d32473ed6db2 /src/mesa/drivers | |
parent | eaf4a106bdcf476078ef4f84c81329034a226650 (diff) |
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 <[email protected]>
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 8ffbc0a5fd5..e48b1e1d2d1 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -695,6 +695,24 @@ brw_update_buffer_texture_surface(struct gl_context *ctx, bo = intel_bufferobj_buffer(brw, intel_obj, tObj->BufferOffset, size); } + /* The ARB_texture_buffer_specification says: + * + * "The number of texels in the buffer texture's texel array is given by + * + * floor(<buffer_size> / (<components> * sizeof(<base_type>)), + * + * where <buffer_size> is the size of the buffer object, in basic + * machine units and <components> and <base_type> are the element count + * and base data type for elements, as specified in Table X.1. The + * number of texels in the texel array is then clamped to the + * implementation-dependent limit MAX_TEXTURE_BUFFER_SIZE_ARB." + * + * We need to clamp the size in bytes to MAX_TEXTURE_BUFFER_SIZE * stride, + * so that when ISL divides by stride to obtain the number of texels, that + * texel count is clamped to MAX_TEXTURE_BUFFER_SIZE. + */ + size = MIN2(size, ctx->Const.MaxTextureBufferSize * (unsigned) texel_size); + if (brw_format == 0 && format != MESA_FORMAT_RGBA_FLOAT32) { _mesa_problem(NULL, "bad format %s for texture buffer\n", _mesa_get_format_name(format)); |