aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan/radv_shader.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2018-06-27 10:39:51 +0200
committerSamuel Pitoiset <[email protected]>2018-07-02 10:42:17 +0200
commit939e5a3823399b94fb47f1264a199ede0763a5cf (patch)
treec63fbdeba4f48161722729de00f8a4de5606646e /src/amd/vulkan/radv_shader.c
parent91f48cdfe5c817158c533a8f67c60e9aabbe4479 (diff)
radv: add padding for the UMR disassembler
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan/radv_shader.c')
-rw-r--r--src/amd/vulkan/radv_shader.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index c7ffd47c0b8..9470c4907c2 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -385,6 +385,16 @@ radv_destroy_shader_slabs(struct radv_device *device)
mtx_destroy(&device->shader_slab_mutex);
}
+/* For the UMR disassembler. */
+#define DEBUGGER_END_OF_CODE_MARKER 0xbf9f0000 /* invalid instruction */
+#define DEBUGGER_NUM_MARKERS 5
+
+static unsigned
+radv_get_shader_binary_size(struct ac_shader_binary *binary)
+{
+ return binary->code_size + DEBUGGER_NUM_MARKERS * 4;
+}
+
static void
radv_fill_shader_variant(struct radv_device *device,
struct radv_shader_variant *variant,
@@ -395,7 +405,7 @@ radv_fill_shader_variant(struct radv_device *device,
struct radv_shader_info *info = &variant->info.info;
unsigned vgpr_comp_cnt = 0;
- variant->code_size = binary->code_size;
+ variant->code_size = radv_get_shader_binary_size(binary);
variant->rsrc2 = S_00B12C_USER_SGPR(variant->info.num_user_sgprs) |
S_00B12C_SCRATCH_EN(scratch_enabled);
@@ -475,6 +485,12 @@ radv_fill_shader_variant(struct radv_device *device,
void *ptr = radv_alloc_shader_memory(device, variant);
memcpy(ptr, binary->code, binary->code_size);
+
+ /* Add end-of-code markers for the UMR disassembler. */
+ uint32_t *ptr32 = (uint32_t *)ptr + binary->code_size / 4;
+ for (unsigned i = 0; i < DEBUGGER_NUM_MARKERS; i++)
+ ptr32[i] = DEBUGGER_END_OF_CODE_MARKER;
+
}
static void radv_init_llvm_target()
@@ -607,7 +623,7 @@ shader_variant_create(struct radv_device *device,
if (code_out) {
*code_out = binary.code;
- *code_size_out = binary.code_size;
+ *code_size_out = variant->code_size;
} else
free(binary.code);
free(binary.config);