mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-28 03:10:25 +01:00
amd/common: extract ac_parse_shader_binary_config
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
de8a919702
commit
2e96c01073
2 changed files with 47 additions and 34 deletions
|
|
@ -206,43 +206,16 @@ const unsigned char *ac_shader_binary_config_start(
|
|||
return binary->config;
|
||||
}
|
||||
|
||||
|
||||
static const char *scratch_rsrc_dword0_symbol =
|
||||
"SCRATCH_RSRC_DWORD0";
|
||||
|
||||
static const char *scratch_rsrc_dword1_symbol =
|
||||
"SCRATCH_RSRC_DWORD1";
|
||||
|
||||
void ac_shader_binary_read_config(struct ac_shader_binary *binary,
|
||||
struct ac_shader_config *conf,
|
||||
unsigned symbol_offset,
|
||||
bool supports_spill)
|
||||
/* Parse configuration data in .AMDGPU.config section format. */
|
||||
void ac_parse_shader_binary_config(const char *data, size_t nbytes,
|
||||
bool really_needs_scratch,
|
||||
struct ac_shader_config *conf)
|
||||
{
|
||||
unsigned i;
|
||||
const unsigned char *config =
|
||||
ac_shader_binary_config_start(binary, symbol_offset);
|
||||
bool really_needs_scratch = false;
|
||||
uint32_t wavesize = 0;
|
||||
/* LLVM adds SGPR spills to the scratch size.
|
||||
* Find out if we really need the scratch buffer.
|
||||
*/
|
||||
if (supports_spill) {
|
||||
really_needs_scratch = true;
|
||||
} else {
|
||||
for (i = 0; i < binary->reloc_count; i++) {
|
||||
const struct ac_shader_reloc *reloc = &binary->relocs[i];
|
||||
|
||||
if (!strcmp(scratch_rsrc_dword0_symbol, reloc->name) ||
|
||||
!strcmp(scratch_rsrc_dword1_symbol, reloc->name)) {
|
||||
really_needs_scratch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < binary->config_size_per_symbol; i+= 8) {
|
||||
unsigned reg = util_le32_to_cpu(*(uint32_t*)(config + i));
|
||||
unsigned value = util_le32_to_cpu(*(uint32_t*)(config + i + 4));
|
||||
for (size_t i = 0; i < nbytes; i += 8) {
|
||||
unsigned reg = util_le32_to_cpu(*(uint32_t*)(data + i));
|
||||
unsigned value = util_le32_to_cpu(*(uint32_t*)(data + i + 4));
|
||||
switch (reg) {
|
||||
case R_00B028_SPI_SHADER_PGM_RSRC1_PS:
|
||||
case R_00B128_SPI_SHADER_PGM_RSRC1_VS:
|
||||
|
|
@ -299,6 +272,42 @@ void ac_shader_binary_read_config(struct ac_shader_binary *binary,
|
|||
}
|
||||
}
|
||||
|
||||
static const char *scratch_rsrc_dword0_symbol =
|
||||
"SCRATCH_RSRC_DWORD0";
|
||||
|
||||
static const char *scratch_rsrc_dword1_symbol =
|
||||
"SCRATCH_RSRC_DWORD1";
|
||||
|
||||
void ac_shader_binary_read_config(struct ac_shader_binary *binary,
|
||||
struct ac_shader_config *conf,
|
||||
unsigned symbol_offset,
|
||||
bool supports_spill)
|
||||
{
|
||||
unsigned i;
|
||||
const char *config =
|
||||
(const char *)ac_shader_binary_config_start(binary, symbol_offset);
|
||||
bool really_needs_scratch = false;
|
||||
/* LLVM adds SGPR spills to the scratch size.
|
||||
* Find out if we really need the scratch buffer.
|
||||
*/
|
||||
if (supports_spill) {
|
||||
really_needs_scratch = true;
|
||||
} else {
|
||||
for (i = 0; i < binary->reloc_count; i++) {
|
||||
const struct ac_shader_reloc *reloc = &binary->relocs[i];
|
||||
|
||||
if (!strcmp(scratch_rsrc_dword0_symbol, reloc->name) ||
|
||||
!strcmp(scratch_rsrc_dword1_symbol, reloc->name)) {
|
||||
really_needs_scratch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ac_parse_shader_binary_config(config, binary->config_size_per_symbol,
|
||||
really_needs_scratch, conf);
|
||||
}
|
||||
|
||||
void ac_shader_binary_clean(struct ac_shader_binary *b)
|
||||
{
|
||||
if (!b)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#ifndef AC_BINARY_H
|
||||
#define AC_BINARY_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
|
@ -96,6 +97,9 @@ const unsigned char *ac_shader_binary_config_start(
|
|||
const struct ac_shader_binary *binary,
|
||||
uint64_t symbol_offset);
|
||||
|
||||
void ac_parse_shader_binary_config(const char *data, size_t nbytes,
|
||||
bool really_needs_scratch,
|
||||
struct ac_shader_config *conf);
|
||||
void ac_shader_binary_read_config(struct ac_shader_binary *binary,
|
||||
struct ac_shader_config *conf,
|
||||
unsigned symbol_offset,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue