mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
radeonsi: clamp against MAX_TEXEL_BUFFER_ELEMENTS correctly
Reviewed-by: Mihai Preda <mhpreda@gmail.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16901>
This commit is contained in:
parent
91e533c6aa
commit
c1adb33a93
5 changed files with 13 additions and 15 deletions
|
|
@ -755,10 +755,10 @@ static void si_set_shader_image_desc(struct si_context *ctx, const struct pipe_i
|
|||
if (res->b.b.target == PIPE_BUFFER) {
|
||||
if (view->access & PIPE_IMAGE_ACCESS_WRITE)
|
||||
si_mark_image_range_valid(view);
|
||||
uint32_t size = si_clamp_texture_texel_count(screen->max_texture_buffer_size,
|
||||
view->format, view->u.buf.size);
|
||||
uint32_t elements = si_clamp_texture_texel_count(screen->max_texel_buffer_elements,
|
||||
view->format, view->u.buf.size);
|
||||
|
||||
si_make_buffer_descriptor(screen, res, view->format, view->u.buf.offset, size,
|
||||
si_make_buffer_descriptor(screen, res, view->format, view->u.buf.offset, elements,
|
||||
desc);
|
||||
si_set_buf_desc_address(res, view->u.buf.offset, desc + 4);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1159,7 +1159,7 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
|||
si_init_screen_query_functions(sscreen);
|
||||
si_init_screen_live_shader_cache(sscreen);
|
||||
|
||||
sscreen->max_texture_buffer_size = sscreen->b.get_param(
|
||||
sscreen->max_texel_buffer_elements = sscreen->b.get_param(
|
||||
&sscreen->b, PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT);
|
||||
|
||||
/* Set these flags in debug_flags early, so that the shader cache takes
|
||||
|
|
|
|||
|
|
@ -604,7 +604,7 @@ struct si_screen {
|
|||
/* Texture filter settings. */
|
||||
int force_aniso; /* -1 = disabled */
|
||||
|
||||
unsigned max_texture_buffer_size;
|
||||
unsigned max_texel_buffer_elements;
|
||||
|
||||
/* Auxiliary context. Mainly used to initialize resources.
|
||||
* It must be locked prior to using and flushed before unlocking. */
|
||||
|
|
|
|||
|
|
@ -3916,7 +3916,7 @@ static void si_set_min_samples(struct pipe_context *ctx, unsigned min_samples)
|
|||
* @param state 256-bit descriptor; only the high 128 bits are filled in
|
||||
*/
|
||||
void si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf,
|
||||
enum pipe_format format, unsigned offset, unsigned size,
|
||||
enum pipe_format format, unsigned offset, unsigned num_elements,
|
||||
uint32_t *state)
|
||||
{
|
||||
const struct util_format_description *desc;
|
||||
|
|
@ -3926,7 +3926,7 @@ void si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf
|
|||
desc = util_format_description(format);
|
||||
stride = desc->block.bits / 8;
|
||||
|
||||
num_records = size / stride;
|
||||
num_records = num_elements;
|
||||
num_records = MIN2(num_records, (buf->b.b.width0 - offset) / stride);
|
||||
|
||||
/* The NUM_RECORDS field has a different meaning depending on the chip,
|
||||
|
|
@ -4567,11 +4567,11 @@ static struct pipe_sampler_view *si_create_sampler_view(struct pipe_context *ctx
|
|||
|
||||
/* Buffer resource. */
|
||||
if (texture->target == PIPE_BUFFER) {
|
||||
uint32_t size = si_clamp_texture_texel_count(sctx->screen->max_texture_buffer_size,
|
||||
state->format, state->u.buf.size);
|
||||
uint32_t elements = si_clamp_texture_texel_count(sctx->screen->max_texel_buffer_elements,
|
||||
state->format, state->u.buf.size);
|
||||
|
||||
si_make_buffer_descriptor(sctx->screen, si_resource(texture), state->format,
|
||||
state->u.buf.offset, size, view->state);
|
||||
state->u.buf.offset, elements, view->state);
|
||||
return &view->base;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -535,7 +535,7 @@ void si_init_state_functions(struct si_context *sctx);
|
|||
void si_init_screen_state_functions(struct si_screen *sscreen);
|
||||
void si_init_cs_preamble_state(struct si_context *sctx, bool uses_reg_shadowing);
|
||||
void si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf,
|
||||
enum pipe_format format, unsigned offset, unsigned size,
|
||||
enum pipe_format format, unsigned offset, unsigned num_elements,
|
||||
uint32_t *state);
|
||||
void si_set_sampler_depth_decompress_mask(struct si_context *sctx, struct si_texture *tex);
|
||||
void si_update_fb_dirtiness_after_rendering(struct si_context *sctx);
|
||||
|
|
@ -650,7 +650,7 @@ static inline unsigned si_get_image_slot(unsigned slot)
|
|||
return SI_NUM_IMAGE_SLOTS - 1 - slot;
|
||||
}
|
||||
|
||||
static inline unsigned si_clamp_texture_texel_count(unsigned max_texture_buffer_size,
|
||||
static inline unsigned si_clamp_texture_texel_count(unsigned max_texel_buffer_elements,
|
||||
enum pipe_format format,
|
||||
uint32_t size)
|
||||
{
|
||||
|
|
@ -661,9 +661,7 @@ static inline unsigned si_clamp_texture_texel_count(unsigned max_texture_buffer_
|
|||
* So compute the number of texels, compare to GL_MAX_TEXTURE_BUFFER_SIZE and update it.
|
||||
*/
|
||||
unsigned stride = util_format_get_blocksize(format);
|
||||
unsigned num_texels = MIN2(max_texture_buffer_size,
|
||||
size / stride);
|
||||
return num_texels * stride;
|
||||
return MIN2(max_texel_buffer_elements, size / stride);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue