struct si_context *sctx = (struct si_context*)ctx;
struct si_compute *program = sctx->cs_shader_state.program;
- assert(first + n <= MAX_GLOBAL_BUFFERS);
+ if (first + n > program->max_global_buffers) {
+ unsigned old_max = program->max_global_buffers;
+ program->max_global_buffers = first + n;
+ program->global_buffers =
+ realloc(program->global_buffers,
+ program->max_global_buffers *
+ sizeof(program->global_buffers[0]));
+ if (!program->global_buffers) {
+ fprintf(stderr, "radeonsi: failed to allocate compute global_buffers\n");
+ return;
+ }
+
+ memset(&program->global_buffers[old_max], 0,
+ (program->max_global_buffers - old_max) *
+ sizeof(program->global_buffers[0]));
+ }
if (!resources) {
for (i = 0; i < n; i++) {
return;
/* Global buffers */
- for (i = 0; i < MAX_GLOBAL_BUFFERS; i++) {
+ for (i = 0; i < program->max_global_buffers; i++) {
struct si_resource *buffer =
si_resource(program->global_buffers[i]);
if (!buffer) {
util_queue_fence_destroy(&sel->ready);
}
+ for (unsigned i = 0; i < program->max_global_buffers; i++)
+ pipe_resource_reference(&program->global_buffers[i], NULL);
+ FREE(program->global_buffers);
+
si_shader_destroy(&program->shader);
ralloc_free(program->sel.nir);
FREE(program);
#include "si_shader.h"
-#define MAX_GLOBAL_BUFFERS 32
-
struct si_compute {
struct si_shader_selector sel;
struct si_shader shader;
unsigned private_size;
unsigned input_size;
- struct pipe_resource *global_buffers[MAX_GLOBAL_BUFFERS];
+ int max_global_buffers;
+ struct pipe_resource **global_buffers;
+
bool reads_variable_block_size;
unsigned num_cs_user_data_dwords;
};