radeonsi: upload shader rodata after updating scratch relocations
Cc: 10.5 10.6 <mesa-stable@lists.freedesktop.org> Reviewed-by: Tom Stellard <thomas.stellard@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
This commit is contained in:
parent
e4d738f6c6
commit
50a957c5de
|
@ -2686,16 +2686,41 @@ void si_shader_apply_scratch_relocs(struct si_context *sctx,
|
|||
}
|
||||
}
|
||||
|
||||
int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
|
||||
{
|
||||
const struct radeon_shader_binary *binary = &shader->binary;
|
||||
unsigned code_size = binary->code_size + binary->rodata_size;
|
||||
unsigned char *ptr;
|
||||
|
||||
r600_resource_reference(&shader->bo, NULL);
|
||||
shader->bo = si_resource_create_custom(&sscreen->b.b,
|
||||
PIPE_USAGE_IMMUTABLE,
|
||||
code_size);
|
||||
if (!shader->bo)
|
||||
return -ENOMEM;
|
||||
|
||||
ptr = sscreen->b.ws->buffer_map(shader->bo->cs_buf, NULL,
|
||||
PIPE_TRANSFER_READ_WRITE);
|
||||
util_memcpy_cpu_to_le32(ptr, binary->code, binary->code_size);
|
||||
if (binary->rodata_size > 0) {
|
||||
ptr += binary->code_size;
|
||||
util_memcpy_cpu_to_le32(ptr, binary->rodata,
|
||||
binary->rodata_size);
|
||||
}
|
||||
|
||||
sscreen->b.ws->buffer_unmap(shader->bo->cs_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int si_shader_binary_read(struct si_screen *sscreen, struct si_shader *shader)
|
||||
{
|
||||
const struct radeon_shader_binary *binary = &shader->binary;
|
||||
unsigned i;
|
||||
unsigned code_size;
|
||||
unsigned char *ptr;
|
||||
bool dump = r600_can_dump_shader(&sscreen->b,
|
||||
shader->selector ? shader->selector->tokens : NULL);
|
||||
|
||||
si_shader_binary_read_config(sscreen, shader, 0);
|
||||
si_shader_binary_upload(sscreen, shader);
|
||||
|
||||
if (dump) {
|
||||
if (!binary->disassembled) {
|
||||
|
@ -2713,26 +2738,6 @@ int si_shader_binary_read(struct si_screen *sscreen, struct si_shader *shader)
|
|||
shader->num_sgprs, shader->num_vgprs, binary->code_size,
|
||||
shader->lds_size, shader->scratch_bytes_per_wave);
|
||||
}
|
||||
|
||||
/* copy new shader */
|
||||
code_size = binary->code_size + binary->rodata_size;
|
||||
r600_resource_reference(&shader->bo, NULL);
|
||||
shader->bo = si_resource_create_custom(&sscreen->b.b, PIPE_USAGE_IMMUTABLE,
|
||||
code_size);
|
||||
if (shader->bo == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
||||
ptr = sscreen->b.ws->buffer_map(shader->bo->cs_buf, NULL, PIPE_TRANSFER_READ_WRITE);
|
||||
util_memcpy_cpu_to_le32(ptr, binary->code, binary->code_size);
|
||||
if (binary->rodata_size > 0) {
|
||||
ptr += binary->code_size;
|
||||
util_memcpy_cpu_to_le32(ptr, binary->rodata, binary->rodata_size);
|
||||
}
|
||||
|
||||
sscreen->b.ws->buffer_unmap(shader->bo->cs_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,6 +191,7 @@ int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader,
|
|||
LLVMTargetMachineRef tm, LLVMModuleRef mod);
|
||||
void si_shader_destroy(struct pipe_context *ctx, struct si_shader *shader);
|
||||
unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index);
|
||||
int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);
|
||||
int si_shader_binary_read(struct si_screen *sscreen, struct si_shader *shader);
|
||||
void si_shader_apply_scratch_relocs(struct si_context *sctx,
|
||||
struct si_shader *shader,
|
||||
|
|
|
@ -749,7 +749,6 @@ static unsigned si_update_scratch_buffer(struct si_context *sctx,
|
|||
{
|
||||
struct si_shader *shader;
|
||||
uint64_t scratch_va = sctx->scratch_buffer->gpu_address;
|
||||
unsigned char *ptr;
|
||||
|
||||
if (!sel)
|
||||
return 0;
|
||||
|
@ -770,12 +769,7 @@ static unsigned si_update_scratch_buffer(struct si_context *sctx,
|
|||
si_shader_apply_scratch_relocs(sctx, shader, scratch_va);
|
||||
|
||||
/* Replace the shader bo with a new bo that has the relocs applied. */
|
||||
r600_resource_reference(&shader->bo, NULL);
|
||||
shader->bo = si_resource_create_custom(&sctx->screen->b.b, PIPE_USAGE_IMMUTABLE,
|
||||
shader->binary.code_size);
|
||||
ptr = sctx->screen->b.ws->buffer_map(shader->bo->cs_buf, NULL, PIPE_TRANSFER_WRITE);
|
||||
util_memcpy_cpu_to_le32(ptr, shader->binary.code, shader->binary.code_size);
|
||||
sctx->screen->b.ws->buffer_unmap(shader->bo->cs_buf);
|
||||
si_shader_binary_upload(sctx->screen, shader);
|
||||
|
||||
/* Update the shader state to use the new shader bo. */
|
||||
si_shader_init_pm4_state(shader);
|
||||
|
|
Loading…
Reference in New Issue