From: Alyssa Rosenzweig Date: Sat, 18 Mar 2023 21:34:17 +0000 (-0400) Subject: asahi: Clamp texture buffer sizes X-Git-Tag: upstream/23.3.3~10327 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13b3da822b4cc9a8496757caeb18629714789efe;p=platform%2Fupstream%2Fmesa.git asahi: Clamp texture buffer sizes Per the spec / freedreno. Fixes arb_texture_buffer_object-texture-buffer-size-clamp Fixes: 6b22a02f908 ("asahi,agx: Implement buffer textures with gnarly NIR") Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 3822b3d..74aac88 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -1425,9 +1425,8 @@ agx_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: return 16; - /* Texel buffers lowered to (at most) 1024x16384 2D textures */ case PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT: - return 1024 * 16384; + return AGX_TEXTURE_BUFFER_MAX_SIZE; case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: return 64; diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 2211763..b85a290 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -702,7 +702,7 @@ agx_pack_texture(void *out, struct agx_resource *rsrc, if (state->target == PIPE_BUFFER) { unsigned size_el = - state->u.buf.size / util_format_get_blocksize(format); + agx_texture_buffer_size_el(format, state->u.buf.size); /* Use a 2D texture to increase the maximum size */ cfg.width = 1024; diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index b9c23f9..78185e5 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -693,4 +693,18 @@ agx_render_condition_check(struct agx_context *ctx) return agx_render_condition_check_inner(ctx); } +/* Texel buffers lowered to (at most) 1024x16384 2D textures */ +#define AGX_TEXTURE_BUFFER_WIDTH 1024 +#define AGX_TEXTURE_BUFFER_MAX_HEIGHT 16384 +#define AGX_TEXTURE_BUFFER_MAX_SIZE \ + (AGX_TEXTURE_BUFFER_WIDTH * AGX_TEXTURE_BUFFER_MAX_HEIGHT) + +static inline uint32_t +agx_texture_buffer_size_el(enum pipe_format format, uint32_t size) +{ + unsigned blocksize = util_format_get_blocksize(format); + + return MIN2(AGX_TEXTURE_BUFFER_MAX_SIZE, size / blocksize); +} + #endif