[Mesa-dev] [PATCH 2/4] radeonsi: Use winsys pb_buffer for scratch buffers.
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Tue Apr 19 22:50:44 UTC 2016
Allows allocation of >= 4 GiB.
Signed-off-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
---
src/gallium/drivers/radeonsi/si_compute.c | 23 +++++++++++------------
src/gallium/drivers/radeonsi/si_pipe.c | 4 ++--
src/gallium/drivers/radeonsi/si_pipe.h | 4 ++--
src/gallium/drivers/radeonsi/si_shader.c | 2 +-
src/gallium/drivers/radeonsi/si_shader.h | 2 +-
src/gallium/drivers/radeonsi/si_state_draw.c | 6 +++---
src/gallium/drivers/radeonsi/si_state_shaders.c | 18 +++++++++---------
7 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c
index 905c169..b4981b4 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -203,30 +203,29 @@ static bool si_setup_compute_scratch_buffer(struct si_context *sctx,
scratch_bo_size = 0;
scratch_needed = config->scratch_bytes_per_wave * sctx->scratch_waves;
if (sctx->compute_scratch_buffer)
- scratch_bo_size = sctx->compute_scratch_buffer->b.b.width0;
+ scratch_bo_size = sctx->compute_scratch_buffer->size;
if (scratch_bo_size < scratch_needed) {
- pipe_resource_reference(
- (struct pipe_resource**)&sctx->compute_scratch_buffer,
- NULL);
+ pb_reference(&sctx->compute_scratch_buffer, NULL);
- sctx->compute_scratch_buffer =
- si_resource_create_custom(&sctx->screen->b.b,
- PIPE_USAGE_DEFAULT, scratch_needed);
+ sctx->compute_scratch_buffer = sctx->b.ws->buffer_create(sctx->b.ws,
+ scratch_needed, 256, false, RADEON_DOMAIN_VRAM,
+ RADEON_FLAG_NO_CPU_ACCESS);
if (!sctx->compute_scratch_buffer)
return false;
}
if (sctx->compute_scratch_buffer != shader->scratch_bo && scratch_needed) {
- uint64_t scratch_va = sctx->compute_scratch_buffer->gpu_address;
+ uint64_t scratch_va = sctx->b.ws->buffer_get_virtual_address(
+ sctx->compute_scratch_buffer);
si_shader_apply_scratch_relocs(sctx, shader, scratch_va);
if (si_shader_binary_upload(sctx->screen, shader))
return false;
- r600_resource_reference(&shader->scratch_bo,
+ pb_reference(&shader->scratch_bo,
sctx->compute_scratch_buffer);
}
@@ -282,9 +281,9 @@ static bool si_switch_compute_shader(struct si_context *sctx,
config->scratch_bytes_per_wave *
sctx->scratch_waves);
- radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx,
- shader->scratch_bo, RADEON_USAGE_READWRITE,
- RADEON_PRIO_SCRATCH_BUFFER);
+ sctx->b.ws->cs_add_buffer(sctx->b.gfx.cs, shader->scratch_bo,
+ RADEON_USAGE_READWRITE, RADEON_DOMAIN_VRAM,
+ RADEON_PRIO_SCRATCH_BUFFER);
}
shader_va = shader->bo->gpu_address + offset;
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 17d59b6..89df7db 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -51,8 +51,8 @@ static void si_destroy_context(struct pipe_context *context)
pipe_resource_reference(&sctx->null_const_buf.buffer, NULL);
r600_resource_reference(&sctx->border_color_buffer, NULL);
free(sctx->border_color_table);
- r600_resource_reference(&sctx->scratch_buffer, NULL);
- r600_resource_reference(&sctx->compute_scratch_buffer, NULL);
+ pb_reference(&sctx->scratch_buffer, NULL);
+ pb_reference(&sctx->compute_scratch_buffer, NULL);
sctx->b.ws->fence_reference(&sctx->last_gfx_fence, NULL);
si_pm4_free_state(sctx, sctx->init_config, ~0);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index a28c7d70..6ff6c3e 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -300,12 +300,12 @@ struct si_context {
unsigned last_gsvs_itemsize;
/* Scratch buffer */
- struct r600_resource *scratch_buffer;
+ struct pb_buffer *scratch_buffer;
boolean emit_scratch_reloc;
unsigned scratch_waves;
unsigned spi_tmpring_size;
- struct r600_resource *compute_scratch_buffer;
+ struct pb_buffer *compute_scratch_buffer;
/* Emitted derived tessellation state. */
struct si_shader *last_ls; /* local shader (VS) */
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 3bf68eb..a77392d 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -7119,7 +7119,7 @@ void si_shader_destroy(struct si_shader *shader)
}
if (shader->scratch_bo)
- r600_resource_reference(&shader->scratch_bo, NULL);
+ pb_reference(&shader->scratch_bo, NULL);
r600_resource_reference(&shader->bo, NULL);
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index 6ea849d..197e67d 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -402,7 +402,7 @@ struct si_shader {
struct si_shader *gs_copy_shader;
struct si_pm4_state *pm4;
struct r600_resource *bo;
- struct r600_resource *scratch_bo;
+ struct pb_buffer *scratch_bo;
union si_shader_key key;
bool is_binary_shared;
unsigned z_order;
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
index b61c05a..758ffd2 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -359,9 +359,9 @@ static void si_emit_scratch_reloc(struct si_context *sctx)
sctx->spi_tmpring_size);
if (sctx->scratch_buffer) {
- radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx,
- sctx->scratch_buffer, RADEON_USAGE_READWRITE,
- RADEON_PRIO_SCRATCH_BUFFER);
+ sctx->b.ws->cs_add_buffer(sctx->b.gfx.cs, sctx->scratch_buffer,
+ RADEON_USAGE_READWRITE, RADEON_DOMAIN_VRAM,
+ RADEON_PRIO_SCRATCH_BUFFER);
}
sctx->emit_scratch_reloc = false;
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index d560aae..412a4c9 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1617,7 +1617,8 @@ static void si_update_gsvs_ring_bindings(struct si_context *sctx)
static int si_update_scratch_buffer(struct si_context *sctx,
struct si_shader *shader)
{
- uint64_t scratch_va = sctx->scratch_buffer->gpu_address;
+ uint64_t scratch_va = sctx->b.ws->buffer_get_virtual_address(
+ sctx->scratch_buffer);
int r;
if (!shader)
@@ -1644,14 +1645,14 @@ static int si_update_scratch_buffer(struct si_context *sctx,
/* Update the shader state to use the new shader bo. */
si_shader_init_pm4_state(shader);
- r600_resource_reference(&shader->scratch_bo, sctx->scratch_buffer);
+ pb_reference(&shader->scratch_bo, sctx->scratch_buffer);
return 1;
}
static unsigned si_get_current_scratch_buffer_size(struct si_context *sctx)
{
- return sctx->scratch_buffer ? sctx->scratch_buffer->b.b.width0 : 0;
+ return sctx->scratch_buffer ? sctx->scratch_buffer->size : 0;
}
static unsigned si_get_scratch_buffer_bytes_per_wave(struct si_shader *shader)
@@ -1685,13 +1686,12 @@ static bool si_update_spi_tmpring_size(struct si_context *sctx)
if (scratch_needed_size > 0) {
if (scratch_needed_size > current_scratch_buffer_size) {
/* Create a bigger scratch buffer */
- pipe_resource_reference(
- (struct pipe_resource**)&sctx->scratch_buffer,
- NULL);
+ pb_reference(&sctx->scratch_buffer, NULL);
- sctx->scratch_buffer =
- si_resource_create_custom(&sctx->screen->b.b,
- PIPE_USAGE_DEFAULT, scratch_needed_size);
+ sctx->scratch_buffer = sctx->b.ws->buffer_create(sctx->b.ws,
+ scratch_needed_size, 256, false,
+ RADEON_DOMAIN_VRAM,
+ RADEON_FLAG_NO_CPU_ACCESS);
if (!sctx->scratch_buffer)
return false;
sctx->emit_scratch_reloc = true;
--
2.8.0
More information about the mesa-dev
mailing list