diff options
author | Marek Olšák <[email protected]> | 2015-07-10 23:35:55 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2015-07-23 00:59:24 +0200 |
commit | 50a957c5de842b18e10c361f7b0310aa46bb483f (patch) | |
tree | 54e006649c152a7654008bd1c18efcb36edc3e80 /src/gallium/drivers/radeonsi/si_shader.c | |
parent | e4d738f6c6b98a78830c10ab7b89704d847637a5 (diff) |
radeonsi: upload shader rodata after updating scratch relocations
Cc: 10.5 10.6 <[email protected]>
Reviewed-by: Tom Stellard <[email protected]>
Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_shader.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index b988f6d2c10..955e780faf2 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -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; } |