aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-08-12 13:50:00 -0400
committerMarek Olšák <[email protected]>2019-08-19 17:23:38 -0400
commit43f8b5642b14f77c4028c72e685e61feba29a3d4 (patch)
treeaa93b144749ff6bcf8262e0271110df0ec19d437 /src/gallium/drivers
parentc315cb509dfd13cfc6ae7a620f50a8552609bf42 (diff)
radeonsi: allocate and resize global_buffers as needed
Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/radeonsi/si_compute.c23
-rw-r--r--src/gallium/drivers/radeonsi/si_compute.h6
2 files changed, 24 insertions, 5 deletions
diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c
index 624b99022cd..ad211ec0a41 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -318,7 +318,22 @@ static void si_set_global_binding(
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++) {
@@ -912,7 +927,7 @@ static void si_launch_grid(
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) {
@@ -952,6 +967,10 @@ void si_destroy_compute(struct si_compute *program)
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);
diff --git a/src/gallium/drivers/radeonsi/si_compute.h b/src/gallium/drivers/radeonsi/si_compute.h
index 86021178533..5e2883d9e83 100644
--- a/src/gallium/drivers/radeonsi/si_compute.h
+++ b/src/gallium/drivers/radeonsi/si_compute.h
@@ -29,8 +29,6 @@
#include "si_shader.h"
-#define MAX_GLOBAL_BUFFERS 32
-
struct si_compute {
struct si_shader_selector sel;
struct si_shader shader;
@@ -40,7 +38,9 @@ struct si_compute {
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;
};