[Mesa-dev] [PATCH 5/7] ac/rtld: check correct LDS max size

Marek Olšák maraeo at gmail.com
Thu Jun 13 00:40:39 UTC 2019


From: Marek Olšák <marek.olsak at amd.com>

---
 src/amd/common/ac_rtld.c                 | 8 +++++++-
 src/amd/common/ac_rtld.h                 | 2 ++
 src/gallium/drivers/radeonsi/si_shader.c | 3 +++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/amd/common/ac_rtld.c b/src/amd/common/ac_rtld.c
index c750dbfa9cb..18f198f8af2 100644
--- a/src/amd/common/ac_rtld.c
+++ b/src/amd/common/ac_rtld.c
@@ -273,21 +273,27 @@ bool ac_rtld_open(struct ac_rtld_binary *binary,
 		if (!util_dynarray_resize(&binary->lds_symbols, struct ac_rtld_symbol,
 					  i.num_shared_lds_symbols))
 			goto fail;
 
 		memcpy(binary->lds_symbols.data, i.shared_lds_symbols, binary->lds_symbols.size);
 	}
 
 	util_dynarray_foreach(&binary->lds_symbols, struct ac_rtld_symbol, symbol)
 		symbol->part_idx = ~0u;
 
-	unsigned max_lds_size = i.info->chip_class >= GFX7 ? 64 * 1024 : 32 * 1024;
+	unsigned max_lds_size = 64 * 1024;
+
+	if (i.info->chip_class == GFX6 ||
+	    (i.shader_type != MESA_SHADER_COMPUTE &&
+	     i.shader_type != MESA_SHADER_FRAGMENT))
+		max_lds_size = 32 * 1024;
+
 	uint64_t shared_lds_size = 0;
 	if (!layout_symbols(binary->lds_symbols.data, i.num_shared_lds_symbols, &shared_lds_size))
 		goto fail;
 	report_if(shared_lds_size > max_lds_size);
 	binary->lds_size = shared_lds_size;
 
 	/* First pass over all parts: open ELFs, pre-determine the placement of
 	 * sections in the memory image, and collect and layout private LDS symbols. */
 	uint32_t lds_end_align = 0;
 
diff --git a/src/amd/common/ac_rtld.h b/src/amd/common/ac_rtld.h
index b13270b181d..3f60444f85e 100644
--- a/src/amd/common/ac_rtld.h
+++ b/src/amd/common/ac_rtld.h
@@ -22,20 +22,21 @@
  */
 
 #ifndef AC_RTLD_H
 #define AC_RTLD_H
 
 #include <stdbool.h>
 #include <stdint.h>
 #include <stddef.h>
 
 #include "util/u_dynarray.h"
+#include "compiler/shader_enums.h"
 
 struct ac_rtld_part;
 struct ac_shader_config;
 struct radeon_info;
 
 struct ac_rtld_symbol {
 	const char *name;
 	uint32_t size;
 	uint32_t align;
 	uint64_t offset; /* filled in by ac_rtld_open */
@@ -77,20 +78,21 @@ typedef bool (*ac_rtld_get_external_symbol_cb)(
 	void *cb_data, const char *symbol, uint64_t *value);
 
 /**
  * Lifetimes of \ref info, in-memory ELF objects, and the names of
  * \ref shared_lds_symbols must extend until \ref ac_rtld_close is called on
  * the opened binary.
  */
 struct ac_rtld_open_info {
 	const struct radeon_info *info;
 	struct ac_rtld_options options;
+	gl_shader_stage shader_type;
 
 	unsigned num_parts;
 	const char * const *elf_ptrs; /* in-memory ELF objects of each part */
 	const size_t *elf_sizes; /* sizes of corresponding in-memory ELF objects in bytes */
 
 	/* Shared LDS symbols are layouted such that they are accessible from
 	 * all shader parts. Non-shared (private) LDS symbols of one part may
 	 * overlap private LDS symbols of another shader part.
 	 */
 	unsigned num_shared_lds_symbols;
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 3c3d74ce7af..88d32582799 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -21,20 +21,21 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #include "util/u_memory.h"
 #include "util/u_string.h"
 #include "tgsi/tgsi_build.h"
 #include "tgsi/tgsi_strings.h"
 #include "tgsi/tgsi_util.h"
 #include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_from_mesa.h"
 
 #include "ac_binary.h"
 #include "ac_exp_param.h"
 #include "ac_shader_util.h"
 #include "ac_rtld.h"
 #include "ac_llvm_util.h"
 #include "si_shader_internal.h"
 #include "si_pipe.h"
 #include "sid.h"
 
@@ -5091,20 +5092,21 @@ static void si_llvm_emit_polygon_stipple(struct si_shader_context *ctx,
 
 /* For the UMR disassembler. */
 #define DEBUGGER_END_OF_CODE_MARKER	0xbf9f0000 /* invalid instruction */
 #define DEBUGGER_NUM_MARKERS		5
 
 static bool si_shader_binary_open(struct si_screen *screen,
 				  struct si_shader *shader,
 				  struct ac_rtld_binary *rtld)
 {
 	const struct si_shader_selector *sel = shader->selector;
+	enum pipe_shader_type shader_type = sel ? sel->type : PIPE_SHADER_COMPUTE;
 	const char *part_elfs[5];
 	size_t part_sizes[5];
 	unsigned num_parts = 0;
 
 #define add_part(shader_or_part) \
 	if (shader_or_part) { \
 		part_elfs[num_parts] = (shader_or_part)->binary.elf_buffer; \
 		part_sizes[num_parts] = (shader_or_part)->binary.elf_size; \
 		num_parts++; \
 	}
@@ -5129,20 +5131,21 @@ static bool si_shader_binary_open(struct si_screen *screen,
 		sym->name = "esgs_ring";
 		sym->size = shader->gs_info.esgs_ring_size;
 		sym->align = 64 * 1024;
 	}
 
 	bool ok = ac_rtld_open(rtld, (struct ac_rtld_open_info){
 			.info = &screen->info,
 			.options = {
 				.halt_at_entry = screen->options.halt_shaders,
 			},
+			.shader_type = tgsi_processor_to_shader_stage(shader_type),
 			.num_parts = num_parts,
 			.elf_ptrs = part_elfs,
 			.elf_sizes = part_sizes,
 			.num_shared_lds_symbols = num_lds_symbols,
 			.shared_lds_symbols = lds_symbols });
 
 	if (rtld->lds_size > 0) {
 		unsigned alloc_granularity = screen->info.chip_class >= GFX7 ? 512 : 256;
 		shader->config.lds_size =
 			align(rtld->lds_size, alloc_granularity) / alloc_granularity;
-- 
2.17.1



More information about the mesa-dev mailing list