summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2018-12-07 10:31:41 +0100
committerMarek Olšák <marek.olsak@amd.com>2019-06-19 20:30:32 -0400
commit1ee0f0d315546766c584f7af3ca1974d18e8f3e4 (patch)
tree5bcc0f04170e81a511e525eb7afea2e2836b11d8
parent87182200c7dc3528ccb10b5da97cf49545403503 (diff)
radeonsi: add s_sethalt to shaders for debugging
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
-rw-r--r--src/amd/common/ac_rtld.c9
-rw-r--r--src/amd/common/ac_rtld.h9
-rw-r--r--src/gallium/drivers/radeonsi/si_debug_options.h1
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.c3
4 files changed, 22 insertions, 0 deletions
diff --git a/src/amd/common/ac_rtld.c b/src/amd/common/ac_rtld.c
index 92020c5f0dd..c750dbfa9cb 100644
--- a/src/amd/common/ac_rtld.c
+++ b/src/amd/common/ac_rtld.c
@@ -243,6 +243,7 @@ bool ac_rtld_open(struct ac_rtld_binary *binary,
elf_version(EV_CURRENT);
memset(binary, 0, sizeof(*binary));
+ memcpy(&binary->options, &i.options, sizeof(binary->options));
binary->num_parts = i.num_parts;
binary->parts = calloc(sizeof(*binary->parts), i.num_parts);
if (!binary->parts)
@@ -290,6 +291,9 @@ bool ac_rtld_open(struct ac_rtld_binary *binary,
* sections in the memory image, and collect and layout private LDS symbols. */
uint32_t lds_end_align = 0;
+ if (binary->options.halt_at_entry)
+ pasted_text_size += 4;
+
for (unsigned part_idx = 0; part_idx < i.num_parts; ++part_idx) {
struct ac_rtld_part *part = &binary->parts[part_idx];
unsigned part_lds_symbols_begin =
@@ -692,6 +696,11 @@ bool ac_rtld_upload(struct ac_rtld_upload_info *u)
} \
} while (false)
+ if (u->binary->options.halt_at_entry) {
+ /* s_sethalt 1 */
+ *(uint32_t *)u->rx_ptr = util_cpu_to_le32(0xbf8d0001);
+ }
+
/* First pass: upload raw section data and lay out private LDS symbols. */
for (unsigned i = 0; i < u->binary->num_parts; ++i) {
struct ac_rtld_part *part = &u->binary->parts[i];
diff --git a/src/amd/common/ac_rtld.h b/src/amd/common/ac_rtld.h
index 01c29b50817..b13270b181d 100644
--- a/src/amd/common/ac_rtld.h
+++ b/src/amd/common/ac_rtld.h
@@ -42,8 +42,16 @@ struct ac_rtld_symbol {
unsigned part_idx; /* shader part in which this symbol appears */
};
+struct ac_rtld_options {
+ /* Loader will insert an s_sethalt 1 instruction as the
+ * first instruction. */
+ bool halt_at_entry:1;
+};
+
/* Lightweight wrapper around underlying ELF objects. */
struct ac_rtld_binary {
+ struct ac_rtld_options options;
+
/* Required buffer sizes, currently read/executable only. */
uint64_t rx_size;
@@ -75,6 +83,7 @@ typedef bool (*ac_rtld_get_external_symbol_cb)(
*/
struct ac_rtld_open_info {
const struct radeon_info *info;
+ struct ac_rtld_options options;
unsigned num_parts;
const char * const *elf_ptrs; /* in-memory ELF objects of each part */
diff --git a/src/gallium/drivers/radeonsi/si_debug_options.h b/src/gallium/drivers/radeonsi/si_debug_options.h
index aa8d64e1b88..d6cb3157632 100644
--- a/src/gallium/drivers/radeonsi/si_debug_options.h
+++ b/src/gallium/drivers/radeonsi/si_debug_options.h
@@ -4,6 +4,7 @@ OPT_BOOL(aux_debug, false, "Generate ddebug_dumps for the auxiliary context")
OPT_BOOL(sync_compile, false, "Always compile synchronously (will cause stalls)")
OPT_BOOL(dump_shader_binary, false, "Dump shader binary as part of ddebug_dumps")
OPT_BOOL(debug_disassembly, false, "Report shader disassembly as part of driver debug messages (for shader db)")
+OPT_BOOL(halt_shaders, false, "Halt shaders at the start (will hang)")
OPT_BOOL(vs_fetch_always_opencode, false, "Always open code vertex fetches (less efficient, purely for testing)")
OPT_BOOL(prim_restart_tri_strips_only, false, "Only enable primitive restart for triangle strips")
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 1f4954c43bf..231cb8c1cd1 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5133,6 +5133,9 @@ static bool si_shader_binary_open(struct si_screen *screen,
bool ok = ac_rtld_open(rtld, (struct ac_rtld_open_info){
.info = &screen->info,
+ .options = {
+ .halt_at_entry = screen->options.halt_shaders,
+ },
.num_parts = num_parts,
.elf_ptrs = part_elfs,
.elf_sizes = part_sizes,