reloc->va[i] = slab_va + slab_offset;
void *dest_ptr = slab_ptr + slab_offset;
- memcpy(dest_ptr, shader->code_ptr, shader->code_size);
+ memcpy(dest_ptr, shader->code, shader->code_size);
slab_offset += align(shader->code_size, RADV_SHADER_ALLOC_ALIGNMENT);
}
free(record);
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
- memcpy(code, shader->code_ptr, shader->code_size);
+ memcpy(code, shader->code, shader->code_size);
va = radv_sqtt_shader_get_va_reloc(pipeline, i);
#include "util/memstream.h"
#include "util/mesa-sha1.h"
#include "util/u_atomic.h"
+#include "util/streaming-load-memcpy.h"
#include "radv_debug.h"
#include "radv_meta.h"
#include "radv_private.h"
dest_ptr = shader->alloc->arena->ptr + shader->alloc->offset;
+ if (device->thread_trace.bo) {
+ shader->code = calloc(shader->code_size, 1);
+ if (!shader->code) {
+ radv_shader_unref(device, shader);
+ return false;
+ }
+ }
+
if (binary->type == RADV_BINARY_TYPE_RTLD) {
#if !defined(USE_LIBELF)
return false;
return false;
}
- shader->code_ptr = dest_ptr;
ac_rtld_close(&rtld_binary);
+
+ if (shader->code) {
+ /* Instead of running RTLD twice, just copy the relocated binary back from VRAM.
+ * Use streaming memcpy to reduce penalty of copying from uncachable memory.
+ */
+ util_streaming_load_memcpy(shader->code, dest_ptr, shader->code_size);
+ }
#endif
} else {
struct radv_shader_binary_legacy *bin = (struct radv_shader_binary_legacy *)binary;
for (unsigned i = 0; i < DEBUGGER_NUM_MARKERS; i++)
ptr32[i] = DEBUGGER_END_OF_CODE_MARKER;
- shader->code_ptr = dest_ptr;
+ if (shader->code) {
+ memcpy(shader->code, bin->data + bin->stats_size, bin->code_size);
+ }
}
return true;
radv_free_shader_memory(device, shader->alloc);
+ free(shader->code);
free(shader->spirv);
free(shader->nir_string);
free(shader->disasm_string);