<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 24, 2019 at 9:14 AM Nicolai Hähnle <<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Nicolai Hähnle <<a href="mailto:nicolai.haehnle@amd.com" target="_blank">nicolai.haehnle@amd.com</a>><br>
<br>
Move the definition of radeonsi_clear_db_cache_before_clear there,<br>
as well as radeonsi_enable_nir.<br>
<br>
This removes the AMD_DEBUG=nir option.<br>
<br>
We currently still have two places for options: the driconf machinery<br>
and AMD_DEBUG/R600_DEBUG. If we are to have a single place for options,<br>
then the driconf machinery should be preferred since it's more flexible.<br>
<br>
The only downside of the driconf machinery was that adding new options<br>
was quite inconvenient. With this change, a simple boolean option can<br>
be added with a single line of code, same as for AMD_DEBUG.<br>
<br>
One technical limitation of this particular implementation is that while<br>
almost all driconf features are available, the translation machinery doesn't<br>
pick up the description strings for options added in si_debvug_options. In<br>
practice, translations haven't been provided anyway, and this is intended<br>
for developer options, so I'm not too worried. It could always be added<br>
later if anybody really cares.<br>
---<br>
.../drivers/radeonsi/driinfo_radeonsi.h | 12 +++-<br>
src/gallium/drivers/radeonsi/si_clear.c | 2 +-<br>
.../drivers/radeonsi/si_debug_options.inc | 4 ++<br>
src/gallium/drivers/radeonsi/si_get.c | 6 +-<br>
src/gallium/drivers/radeonsi/si_pipe.c | 22 ++++---<br>
src/gallium/drivers/radeonsi/si_pipe.h | 7 ++-<br>
src/util/merge_driinfo.py | 58 +++++++++++++++++--<br>
src/util/xmlpool/t_options.h | 9 ---<br>
8 files changed, 89 insertions(+), 31 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/radeonsi/driinfo_radeonsi.h b/src/gallium/drivers/radeonsi/driinfo_radeonsi.h<br>
index edf8edba035..d92883b9c38 100644<br>
--- a/src/gallium/drivers/radeonsi/driinfo_radeonsi.h<br>
+++ b/src/gallium/drivers/radeonsi/driinfo_radeonsi.h<br>
@@ -4,13 +4,21 @@ DRI_CONF_SECTION_QUALITY<br>
DRI_CONF_SECTION_END<br>
<br>
DRI_CONF_SECTION_PERFORMANCE<br>
DRI_CONF_RADEONSI_ENABLE_SISCHED("false")<br>
DRI_CONF_RADEONSI_ASSUME_NO_Z_FIGHTS("false")<br>
DRI_CONF_RADEONSI_COMMUTATIVE_BLEND_ADD("false")<br>
DRI_CONF_RADEONSI_ZERO_ALL_VRAM_ALLOCS("false")<br>
DRI_CONF_SECTION_END<br>
<br>
DRI_CONF_SECTION_DEBUG<br>
- DRI_CONF_RADEONSI_CLEAR_DB_CACHE_BEFORE_CLEAR("false")<br>
- DRI_CONF_RADEONSI_ENABLE_NIR("false")<br>
+<br>
+//= BEGIN VERBATIM<br>
+#define OPT_BOOL(name, dflt, description) \<br>
+ DRI_CONF_OPT_BEGIN_B(radeonsi_##name, #dflt) \<br>
+ DRI_CONF_DESC(en, description) \<br>
+ DRI_CONF_OPT_END<br>
+<br>
+#include "radeonsi/si_debug_options.inc"<br>
+//= END VERBATIM<br>
+<br>
DRI_CONF_SECTION_END<br>
diff --git a/src/gallium/drivers/radeonsi/si_clear.c b/src/gallium/drivers/radeonsi/si_clear.c<br>
index e1805f2a1c9..a4ebd5cf2a5 100644<br>
--- a/src/gallium/drivers/radeonsi/si_clear.c<br>
+++ b/src/gallium/drivers/radeonsi/si_clear.c<br>
@@ -631,21 +631,21 @@ static void si_clear(struct pipe_context *ctx, unsigned buffers,<br>
* a coincidence and the root cause is elsewhere.<br>
*<br>
* The corruption can be fixed by putting the DB flush before<br>
* or after the depth clear. (surprisingly)<br>
*<br>
* <a href="https://bugs.freedesktop.org/show_bug.cgi?id=102955" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=102955</a> (apitrace)<br>
*<br>
* This hack decreases back-to-back ClearDepth performance.<br>
*/<br>
if ((sctx->db_depth_clear || sctx->db_stencil_clear) &&<br>
- sctx->screen->clear_db_cache_before_clear)<br>
+ sctx->screen->options.clear_db_cache_before_clear)<br>
sctx->flags |= SI_CONTEXT_FLUSH_AND_INV_DB;<br>
}<br>
<br>
si_blitter_begin(sctx, SI_CLEAR);<br>
util_blitter_clear(sctx->blitter, fb->width, fb->height,<br>
util_framebuffer_get_num_layers(fb),<br>
buffers, color, depth, stencil);<br>
si_blitter_end(sctx);<br>
<br>
if (sctx->db_depth_clear) {<br>
diff --git a/src/gallium/drivers/radeonsi/si_debug_options.inc b/src/gallium/drivers/radeonsi/si_debug_options.inc<br>
new file mode 100644<br>
index 00000000000..165dba8baf5<br>
--- /dev/null<br>
+++ b/src/gallium/drivers/radeonsi/si_debug_options.inc<br>
@@ -0,0 +1,4 @@<br>
+OPT_BOOL(clear_db_cache_before_clear, false, "Clear DB cache before fast depth clear")<br>
+OPT_BOOL(enable_nir, false, "Enable NIR")<br>
+<br>
+#undef OPT_BOOL<br>
diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c<br>
index 67fbc50998b..fda71da16e6 100644<br>
--- a/src/gallium/drivers/radeonsi/si_get.c<br>
+++ b/src/gallium/drivers/radeonsi/si_get.c<br>
@@ -203,21 +203,21 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param)<br>
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:<br>
case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:<br>
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:<br>
return !sscreen->info.has_unaligned_shader_loads;<br>
<br>
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:<br>
return sscreen->info.has_sparse_vm_mappings ?<br>
RADEON_SPARSE_PAGE_SIZE : 0;<br>
<br>
case PIPE_CAP_PACKED_UNIFORMS:<br>
- if (sscreen->debug_flags & DBG(NIR))<br>
+ if (sscreen->options.enable_nir)<br>
return 1;<br>
return 0;<br>
<br>
/* Unsupported features. */<br>
case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:<br>
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:<br>
case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:<br>
case PIPE_CAP_USER_VERTEX_BUFFERS:<br>
case PIPE_CAP_FAKE_SW_MSAA:<br>
case PIPE_CAP_TEXTURE_GATHER_OFFSETS:<br>
@@ -418,25 +418,25 @@ static int si_get_shader_param(struct pipe_screen* pscreen,<br>
case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:<br>
return SI_NUM_CONST_BUFFERS;<br>
case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:<br>
case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:<br>
return SI_NUM_SAMPLERS;<br>
case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS:<br>
return SI_NUM_SHADER_BUFFERS;<br>
case PIPE_SHADER_CAP_MAX_SHADER_IMAGES:<br>
return SI_NUM_IMAGES;<br>
case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:<br>
- if (sscreen->debug_flags & DBG(NIR))<br>
+ if (sscreen->options.enable_nir)<br>
return 0;<br>
return 32;<br>
case PIPE_SHADER_CAP_PREFERRED_IR:<br>
- if (sscreen->debug_flags & DBG(NIR))<br>
+ if (sscreen->options.enable_nir)<br>
return PIPE_SHADER_IR_NIR;<br>
return PIPE_SHADER_IR_TGSI;<br>
case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD:<br>
return 4;<br>
<br>
/* Supported boolean features. */<br>
case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:<br>
case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:<br>
case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:<br>
case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:<br>
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c<br>
index 5caeb575623..9f8bd2039ee 100644<br>
--- a/src/gallium/drivers/radeonsi/si_pipe.c<br>
+++ b/src/gallium/drivers/radeonsi/si_pipe.c<br>
@@ -55,21 +55,20 @@ static const struct debug_named_value debug_options[] = {<br>
{ "noasm", DBG(NO_ASM), "Don't print disassembled shaders"},<br>
{ "preoptir", DBG(PREOPT_IR), "Print the LLVM IR before initial optimizations" },<br>
<br>
/* Shader compiler options the shader cache should be aware of: */<br>
{ "unsafemath", DBG(UNSAFE_MATH), "Enable unsafe math shader optimizations" },<br>
{ "sisched", DBG(SI_SCHED), "Enable LLVM SI Machine Instruction Scheduler." },<br>
{ "gisel", DBG(GISEL), "Enable LLVM global instruction selector." },<br>
<br>
/* Shader compiler options (with no effect on the shader cache): */<br>
{ "checkir", DBG(CHECK_IR), "Enable additional sanity checks on shader IR" },<br>
- { "nir", DBG(NIR), "Enable experimental NIR shaders" },<br>
{ "mono", DBG(MONOLITHIC_SHADERS), "Use old-style monolithic shaders compiled on demand" },<br>
{ "nooptvariant", DBG(NO_OPT_VARIANT), "Disable compiling optimized shader variants." },<br>
<br>
/* Information logging options: */<br>
{ "info", DBG(INFO), "Print driver information" },<br>
{ "tex", DBG(TEX), "Print texture info" },<br>
{ "compute", DBG(COMPUTE), "Print compute info" },<br>
{ "vm", DBG(VM), "Print virtual addresses when creating resources" },<br>
<br>
/* Driver options: */<br>
@@ -825,30 +824,33 @@ static void si_disk_cache_create(struct si_screen *sscreen)<br>
&ctx))<br>
return;<br>
<br>
_mesa_sha1_final(&ctx, sha1);<br>
disk_cache_format_hex_id(cache_id, sha1, 20 * 2);<br>
<br>
/* These flags affect shader compilation. */<br>
#define ALL_FLAGS (DBG(FS_CORRECT_DERIVS_AFTER_KILL) | \<br>
DBG(SI_SCHED) | \<br>
DBG(GISEL) | \<br>
- DBG(UNSAFE_MATH) | \<br>
- DBG(NIR))<br>
+ DBG(UNSAFE_MATH))<br>
uint64_t shader_debug_flags = sscreen->debug_flags &<br>
ALL_FLAGS;<br>
<br>
/* Add the high bits of 32-bit addresses, which affects<br>
* how 32-bit addresses are expanded to 64 bits.<br>
*/<br>
STATIC_ASSERT(ALL_FLAGS <= UINT_MAX);<br>
- shader_debug_flags |= (uint64_t)sscreen->info.address32_hi << 32;<br>
+ assert((int16_t)sscreen->info.address32_hi == (int32_t)sscreen->info.address32_hi);<br>
+ shader_debug_flags |= (uint64_t)(sscreen->info.address32_hi & 0xffff) << 32;<br>
+<br>
+ if (sscreen->options.enable_nir)<br>
+ shader_debug_flags |= 1ull << 48;<br>
<br>
sscreen->disk_shader_cache =<br>
disk_cache_create(sscreen-><a href="http://info.name" rel="noreferrer" target="_blank">info.name</a>,<br>
cache_id,<br>
shader_debug_flags);<br>
}<br>
<br>
static void si_set_max_shader_compiler_threads(struct pipe_screen *screen,<br>
unsigned max_threads)<br>
{<br>
@@ -918,22 +920,20 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,<br>
si_init_screen_query_functions(sscreen);<br>
<br>
/* Set these flags in debug_flags early, so that the shader cache takes<br>
* them into account.<br>
*/<br>
if (driQueryOptionb(config->options,<br>
"glsl_correct_derivatives_after_discard"))<br>
sscreen->debug_flags |= DBG(FS_CORRECT_DERIVS_AFTER_KILL);<br>
if (driQueryOptionb(config->options, "radeonsi_enable_sisched"))<br>
sscreen->debug_flags |= DBG(SI_SCHED);<br>
- if (driQueryOptionb(config->options, "radeonsi_enable_nir"))<br>
- sscreen->debug_flags |= DBG(NIR);<br>
<br>
if (sscreen->debug_flags & DBG(INFO))<br>
ac_print_gpu_info(&sscreen->info);<br>
<br>
slab_create_parent(&sscreen->pool_transfers,<br>
sizeof(struct si_transfer), 64);<br>
<br>
sscreen->force_aniso = MIN2(16, debug_get_num_option("R600_TEX_ANISO", -1));<br>
if (sscreen->force_aniso >= 0) {<br>
printf("radeonsi: Forcing anisotropy filter to %ix\n",<br>
@@ -1067,22 +1067,28 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,<br>
sscreen->info.pfp_fw_version >= 79 &&<br>
sscreen->info.me_fw_version >= 142);<br>
<br>
sscreen->has_out_of_order_rast = sscreen->info.chip_class >= VI &&<br>
sscreen->info.max_se >= 2 &&<br>
!(sscreen->debug_flags & DBG(NO_OUT_OF_ORDER));<br>
sscreen->assume_no_z_fights =<br>
driQueryOptionb(config->options, "radeonsi_assume_no_z_fights");<br>
sscreen->commutative_blend_add =<br>
driQueryOptionb(config->options, "radeonsi_commutative_blend_add");<br>
- sscreen->clear_db_cache_before_clear =<br>
- driQueryOptionb(config->options, "radeonsi_clear_db_cache_before_clear");<br>
+<br>
+ {<br>
+#define OPT_BOOL(name, dflt, description) \<br>
+ sscreen-><a href="http://options.name" rel="noreferrer" target="_blank">options.name</a> = \<br>
+ driQueryOptionb(config->options, "radeonsi_"#name);<br>
+#include "si_debug_options.inc"<br>
+ }<br>
+<br>
sscreen->has_msaa_sample_loc_bug = (sscreen->info.family >= CHIP_POLARIS10 &&<br>
sscreen->info.family <= CHIP_POLARIS12) ||<br>
sscreen->info.family == CHIP_VEGA10 ||<br>
sscreen->info.family == CHIP_RAVEN;<br>
sscreen->has_ls_vgpr_init_bug = sscreen->info.family == CHIP_VEGA10 ||<br>
sscreen->info.family == CHIP_RAVEN;<br>
sscreen->has_dcc_constant_encode = sscreen->info.family == CHIP_RAVEN2;<br>
<br>
/* Only enable primitive binning on APUs by default. */<br>
sscreen->dpbb_allowed = sscreen->info.family == CHIP_RAVEN ||<br>
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h<br>
index 301d38649bf..accc11ca769 100644<br>
--- a/src/gallium/drivers/radeonsi/si_pipe.h<br>
+++ b/src/gallium/drivers/radeonsi/si_pipe.h<br>
@@ -140,21 +140,20 @@ enum {<br>
DBG_PREOPT_IR,<br>
<br>
/* Shader compiler options the shader cache should be aware of: */<br>
DBG_FS_CORRECT_DERIVS_AFTER_KILL,<br>
DBG_UNSAFE_MATH,<br>
DBG_SI_SCHED,<br>
DBG_GISEL,<br>
<br>
/* Shader compiler options (with no effect on the shader cache): */<br>
DBG_CHECK_IR,<br>
- DBG_NIR,<br>
DBG_MONOLITHIC_SHADERS,<br>
DBG_NO_OPT_VARIANT,<br>
<br>
/* Information logging options: */<br>
DBG_INFO,<br>
DBG_TEX,<br>
DBG_COMPUTE,<br>
DBG_VM,<br>
<br>
/* Driver options: */<br>
@@ -462,28 +461,32 @@ struct si_screen {<br>
unsigned vgt_hs_offchip_param;<br>
unsigned eqaa_force_coverage_samples;<br>
unsigned eqaa_force_z_samples;<br>
unsigned eqaa_force_color_samples;<br>
bool has_clear_state;<br>
bool has_distributed_tess;<br>
bool has_draw_indirect_multi;<br>
bool has_out_of_order_rast;<br>
bool assume_no_z_fights;<br>
bool commutative_blend_add;<br>
- bool clear_db_cache_before_clear;<br>
bool has_msaa_sample_loc_bug;<br>
bool has_ls_vgpr_init_bug;<br>
bool has_dcc_constant_encode;<br>
bool dpbb_allowed;<br>
bool dfsm_allowed;<br>
bool llvm_has_working_vgpr_indexing;<br>
<br>
+ struct {<br>
+#define OPT_BOOL(name, dflt, description) uint8_t name:1;<br></blockquote><div><br></div><div>Why not bool instead of uint8_t?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+#include "si_debug_options.inc"<br></blockquote><div><br></div><div>Why not use the .h file extension?</div><div><br></div><div>Other than those, this is:</div><div><br></div><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br></div><div><br></div><div>Marek</div><br></div></div>