intel/decoder: Add ELK support

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27563>
This commit is contained in:
Caio Oliveira
2024-01-25 12:36:06 -08:00
committed by Marge Bot
parent 80cfc3d712
commit 0669210ef4
18 changed files with 244 additions and 82 deletions

View File

@@ -252,10 +252,10 @@ crocus_init_batch(struct crocus_context *ice,
const unsigned decode_flags = INTEL_BATCH_DECODE_DEFAULT_FLAGS |
(INTEL_DEBUG(DEBUG_COLOR) ? INTEL_BATCH_DECODE_IN_COLOR : 0);
intel_batch_decode_ctx_init(&batch->decoder, &screen->compiler->isa,
&screen->devinfo, stderr,
decode_flags, NULL, decode_get_bo,
decode_get_state_size, batch);
intel_batch_decode_ctx_init_brw(&batch->decoder, &screen->compiler->isa,
&screen->devinfo, stderr,
decode_flags, NULL, decode_get_bo,
decode_get_state_size, batch);
batch->decoder.max_vbo_decoded_lines = 32;
}

View File

@@ -83,7 +83,7 @@ libcrocus = static_library(
dependencies : [
dep_libdrm, dep_valgrind, idep_genxml,
idep_libintel_common, idep_nir_headers,
idep_intel_dev, idep_intel_blorp, idep_intel_decoder,
idep_intel_dev, idep_intel_blorp, idep_intel_decoder_brw,
],
link_with : [
crocus_per_hw_ver_libs, libintel_compiler, libisl,

View File

@@ -232,10 +232,10 @@ iris_init_batch(struct iris_context *ice,
const unsigned decode_flags = INTEL_BATCH_DECODE_DEFAULT_FLAGS |
(INTEL_DEBUG(DEBUG_COLOR) ? INTEL_BATCH_DECODE_IN_COLOR : 0);
intel_batch_decode_ctx_init(&batch->decoder, &screen->compiler->isa,
screen->devinfo,
stderr, decode_flags, NULL,
decode_get_bo, decode_get_state_size, batch);
intel_batch_decode_ctx_init_brw(&batch->decoder, &screen->compiler->isa,
screen->devinfo,
stderr, decode_flags, NULL,
decode_get_bo, decode_get_state_size, batch);
batch->decoder.dynamic_base = IRIS_MEMZONE_DYNAMIC_START;
batch->decoder.instruction_base = IRIS_MEMZONE_SHADER_START;
batch->decoder.surface_base = IRIS_MEMZONE_BINDER_START;

View File

@@ -101,7 +101,7 @@ libiris = static_library(
gnu_symbol_visibility : 'hidden',
dependencies : [dep_libdrm, dep_valgrind, idep_genxml, idep_nir_headers,
idep_libintel_common, idep_intel_driver_ds, idep_intel_dev,
idep_intel_blorp, idep_intel_decoder],
idep_intel_blorp, idep_intel_decoder_brw],
link_with : [
iris_per_hw_ver_libs, libintel_compiler, libisl,
libintel_perf

View File

@@ -22,8 +22,8 @@
*/
#include "intel_decoder.h"
#include "intel_decoder_private.h"
#include "compiler/brw_disasm.h"
#include "util/macros.h"
#include "util/u_debug.h"
#include "util/u_dynarray.h"
@@ -44,7 +44,6 @@ static const struct debug_control debug_control[] = {
void
intel_batch_decode_ctx_init(struct intel_batch_decode_ctx *ctx,
const struct brw_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
@@ -57,7 +56,6 @@ intel_batch_decode_ctx_init(struct intel_batch_decode_ctx *ctx,
{
memset(ctx, 0, sizeof(*ctx));
ctx->isa = isa;
ctx->devinfo = *devinfo;
ctx->get_bo = get_bo;
ctx->get_state_size = get_state_size;
@@ -101,7 +99,7 @@ ctx_print_group(struct intel_batch_decode_ctx *ctx,
(ctx->flags & INTEL_BATCH_DECODE_IN_COLOR) != 0);
}
static struct intel_batch_decode_bo
struct intel_batch_decode_bo
ctx_get_bo(struct intel_batch_decode_ctx *ctx, bool ppgtt, uint64_t addr)
{
if (intel_spec_get_gen(ctx->spec) >= intel_make_gen(8,0)) {
@@ -150,26 +148,13 @@ update_count(struct intel_batch_decode_ctx *ctx,
return guess;
}
static void
static inline void
ctx_disassemble_program(struct intel_batch_decode_ctx *ctx,
uint32_t ksp,
const char *short_name,
const char *name)
{
uint64_t addr = ctx->instruction_base + ksp;
struct intel_batch_decode_bo bo = ctx_get_bo(ctx, true, addr);
if (!bo.map)
return;
fprintf(ctx->fp, "\nReferenced %s:\n", name);
brw_disassemble_with_errors(ctx->isa, bo.map, 0, ctx->fp);
if (ctx->shader_binary) {
int size = brw_disassemble_find_end(ctx->isa, bo.map, 0);
ctx->shader_binary(ctx->user_data, short_name, addr,
bo.map, size);
}
ctx->disassemble_program(ctx, ksp, short_name, name);
}
/* Heuristic to determine whether a uint32_t is probably actually a float

View File

@@ -0,0 +1,51 @@
/*
* Copyright © 2017 Intel Corporation
* SPDX-License-Identifier: MIT
*/
#include "intel_decoder.h"
#include "intel_decoder_private.h"
#include "compiler/brw_disasm.h"
static void
ctx_disassemble_program_brw(struct intel_batch_decode_ctx *ctx,
uint32_t ksp,
const char *short_name,
const char *name)
{
uint64_t addr = ctx->instruction_base + ksp;
struct intel_batch_decode_bo bo = ctx_get_bo(ctx, true, addr);
if (!bo.map)
return;
fprintf(ctx->fp, "\nReferenced %s:\n", name);
brw_disassemble_with_errors(ctx->brw, bo.map, 0, ctx->fp);
if (ctx->shader_binary) {
int size = brw_disassemble_find_end(ctx->brw, bo.map, 0);
ctx->shader_binary(ctx->user_data, short_name, addr,
bo.map, size);
}
}
void
intel_batch_decode_ctx_init_brw(struct intel_batch_decode_ctx *ctx,
const struct brw_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data)
{
intel_batch_decode_ctx_init(ctx, devinfo, fp, flags, xml_path,
get_bo, get_state_size, user_data);
ctx->brw = isa;
ctx->disassemble_program = ctx_disassemble_program_brw;
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright © 2017 Intel Corporation
* SPDX-License-Identifier: MIT
*/
#include "intel_decoder.h"
#include "intel_decoder_private.h"
#include "compiler/elk/elk_disasm.h"
static void
ctx_disassemble_program_elk(struct intel_batch_decode_ctx *ctx,
uint32_t ksp,
const char *short_name,
const char *name)
{
uint64_t addr = ctx->instruction_base + ksp;
struct intel_batch_decode_bo bo = ctx_get_bo(ctx, true, addr);
if (!bo.map)
return;
fprintf(ctx->fp, "\nReferenced %s:\n", name);
elk_disassemble_with_errors(ctx->elk, bo.map, 0, ctx->fp);
if (ctx->shader_binary) {
int size = elk_disassemble_find_end(ctx->elk, bo.map, 0);
ctx->shader_binary(ctx->user_data, short_name, addr,
bo.map, size);
}
}
void
intel_batch_decode_ctx_init_elk(struct intel_batch_decode_ctx *ctx,
const struct elk_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data)
{
intel_batch_decode_ctx_init(ctx, devinfo, fp, flags, xml_path,
get_bo, get_state_size, user_data);
ctx->elk = isa;
ctx->disassemble_program = ctx_disassemble_program_elk;
}

View File

@@ -25,17 +25,34 @@
#include "util/log.h"
void
intel_batch_decode_ctx_init(struct intel_batch_decode_ctx *ctx,
const struct brw_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data)
intel_batch_decode_ctx_init_brw(struct intel_batch_decode_ctx *ctx,
const struct brw_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data)
{
/* Clear ctx to play safe. */
memset(ctx, 0, sizeof(*ctx));
}
void
intel_batch_decode_ctx_init_elk(struct intel_batch_decode_ctx *ctx,
const struct elk_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data)
{
/* Clear ctx to play safe. */
memset(ctx, 0, sizeof(*ctx));

View File

@@ -270,7 +270,8 @@ struct intel_batch_decode_ctx {
void *user_data;
FILE *fp;
const struct brw_isa_info *isa;
const struct brw_isa_info *brw;
const struct elk_isa_info *elk;
struct intel_device_info devinfo;
struct intel_spec *spec;
enum intel_batch_decode_flags flags;
@@ -290,19 +291,35 @@ struct intel_batch_decode_ctx {
struct hash_table *commands;
struct hash_table *stats;
void (*disassemble_program)(struct intel_batch_decode_ctx *ctx,
uint32_t ksp,
const char *short_name,
const char *name);
};
void intel_batch_decode_ctx_init(struct intel_batch_decode_ctx *ctx,
const struct brw_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data);
void intel_batch_decode_ctx_init_brw(struct intel_batch_decode_ctx *ctx,
const struct brw_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data);
void intel_batch_decode_ctx_init_elk(struct intel_batch_decode_ctx *ctx,
const struct elk_isa_info *isa,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data);
void intel_batch_decode_ctx_finish(struct intel_batch_decode_ctx *ctx);

View File

@@ -0,0 +1,25 @@
/*
* Copyright © 2017 Intel Corporation
* SPDX-License-Identifier: MIT
*/
#ifndef INTEL_DECODER_PRIVATE_H
#define INTEL_DECODER_PRIVATE_H
#include "intel_decoder.h"
void intel_batch_decode_ctx_init(struct intel_batch_decode_ctx *ctx,
const struct intel_device_info *devinfo,
FILE *fp, enum intel_batch_decode_flags flags,
const char *xml_path,
struct intel_batch_decode_bo (*get_bo)(void *,
bool,
uint64_t),
unsigned (*get_state_size)(void *, uint64_t,
uint64_t),
void *user_data);
struct intel_batch_decode_bo
ctx_get_bo(struct intel_batch_decode_ctx *ctx, bool ppgtt, uint64_t addr);
#endif /* INTEL_DECODER_PRIVATE_H */

View File

@@ -21,17 +21,33 @@ else
)
endif
libintel_decoder = static_library(
'intel_decoder',
[libintel_decoder_files, genX_xml_h, sha1_h],
libintel_decoder_brw = static_library(
'intel_decoder_brw',
[libintel_decoder_files, 'intel_batch_decoder_brw.c', genX_xml_h, sha1_h],
include_directories : [inc_include, inc_src, inc_intel],
c_args : [no_override_init_args, sse2_args],
gnu_symbol_visibility : 'hidden',
dependencies : libintel_decoder_deps,
build_by_default : false,
)
idep_intel_decoder = declare_dependency(
link_with : [libintel_decoder],
idep_intel_decoder_brw = declare_dependency(
link_with : [libintel_decoder_brw],
dependencies : libintel_decoder_deps,
)
libintel_decoder_elk = static_library(
'intel_decoder_elk',
[libintel_decoder_files, 'intel_batch_decoder_elk.c', genX_xml_h, sha1_h],
include_directories : [inc_include, inc_src, inc_intel],
c_args : [no_override_init_args, sse2_args],
gnu_symbol_visibility : 'hidden',
dependencies : libintel_decoder_deps,
build_by_default : false,
)
idep_intel_decoder_elk = declare_dependency(
link_with : [libintel_decoder_elk],
dependencies : libintel_decoder_deps,
)
@@ -62,7 +78,8 @@ if with_tests and not with_platform_android
],
dependencies : [
idep_libintel_common,
idep_intel_decoder,
idep_intel_decoder_brw,
idep_intel_decoder_elk,
idep_mesautil,
idep_intel_dev,
idep_genxml,
@@ -76,4 +93,3 @@ if with_tests and not with_platform_android
suite : ['intel'],
)
endif

View File

@@ -101,8 +101,8 @@ aubinator_init(void *user_data, int aub_pci_id, const char *app_name)
batch_flags |= INTEL_BATCH_DECODE_OFFSETS;
batch_flags |= INTEL_BATCH_DECODE_FLOATS;
intel_batch_decode_ctx_init(&batch_ctx, &isa, &devinfo, outfile,
batch_flags, xml_path, NULL, NULL, NULL);
intel_batch_decode_ctx_init_brw(&batch_ctx, &isa, &devinfo, outfile,
batch_flags, xml_path, NULL, NULL, NULL);
/* Check for valid spec instance, if wrong xml_path is passed then spec
* instance is not initialized properly

View File

@@ -737,9 +737,9 @@ read_i915_data_file(FILE *file)
batch_flags |= INTEL_BATCH_DECODE_FLOATS;
struct intel_batch_decode_ctx batch_ctx;
intel_batch_decode_ctx_init(&batch_ctx, &isa, &devinfo, stdout,
batch_flags, xml_path, get_intel_batch_bo,
NULL, NULL);
intel_batch_decode_ctx_init_brw(&batch_ctx, &isa, &devinfo, stdout,
batch_flags, xml_path, get_intel_batch_bo,
NULL, NULL);
batch_ctx.acthd = acthd;
if (option_dump_kernels)

View File

@@ -22,7 +22,7 @@ libaub = static_library(
'aub',
files('aub_read.c', 'aub_mem.c'),
include_directories : [inc_include, inc_src, inc_intel],
dependencies : [idep_mesautil, idep_intel_dev, idep_intel_decoder],
dependencies : [idep_mesautil, idep_intel_dev, idep_intel_decoder_brw],
link_with : [libintel_common],
c_args : [no_override_init_args],
gnu_symbol_visibility : 'hidden',
@@ -32,7 +32,7 @@ libaub = static_library(
aubinator = executable(
'aubinator',
files('aubinator.c'),
dependencies : [idep_mesautil, dep_expat, dep_zlib, dep_dl, dep_thread, dep_m, idep_intel_dev, idep_intel_decoder],
dependencies : [idep_mesautil, dep_expat, dep_zlib, dep_dl, dep_thread, dep_m, idep_intel_dev, idep_intel_decoder_brw],
include_directories : [inc_include, inc_src, inc_intel],
link_with : [libintel_common, libintel_compiler, libaub],
c_args : [no_override_init_args],
@@ -45,7 +45,7 @@ aubinator_error_decode = executable(
files('aubinator_error_decode.c',
'aubinator_error_decode_xe.c',
'aubinator_error_decode_xe.h'),
dependencies : [idep_mesautil, dep_zlib, dep_thread, idep_intel_dev, idep_intel_decoder],
dependencies : [idep_mesautil, dep_zlib, dep_thread, idep_intel_dev, idep_intel_decoder_brw],
include_directories : [inc_include, inc_src, inc_intel],
link_with : [libintel_common, libintel_compiler],
c_args : [no_override_init_args],
@@ -182,7 +182,7 @@ if with_tools.contains('intel-ui')
libintel_imgui_gtk_dep,
idep_intel_dev,
idep_libintel_common,
idep_intel_decoder,
idep_intel_decoder_brw,
],
include_directories : [inc_include, inc_src, inc_intel],
link_with : [libintel_compiler],

View File

@@ -3183,11 +3183,11 @@ VkResult anv_CreateDevice(
const unsigned decode_flags = INTEL_BATCH_DECODE_DEFAULT_FLAGS;
intel_batch_decode_ctx_init(decoder,
&physical_device->compiler->isa,
&physical_device->info,
stderr, decode_flags, NULL,
decode_get_bo, NULL, device);
intel_batch_decode_ctx_init_brw(decoder,
&physical_device->compiler->isa,
&physical_device->info,
stderr, decode_flags, NULL,
decode_get_bo, NULL, device);
intel_batch_stats_reset(decoder);
decoder->engine = physical_device->queue.families[i].engine_class;

View File

@@ -262,7 +262,7 @@ libvulkan_intel = shared_library(
idep_nir, idep_genxml, idep_vulkan_util, idep_vulkan_wsi,
idep_vulkan_runtime, idep_mesautil, idep_xmlconfig,
idep_intel_driver_ds, idep_intel_dev, idep_intel_blorp,
idep_intel_decoder,
idep_intel_decoder_brw,
],
c_args : anv_flags,
gnu_symbol_visibility : 'hidden',
@@ -300,7 +300,7 @@ if with_tests
dep_thread, dep_dl, dep_m, anv_deps,
idep_nir, idep_vulkan_util, idep_vulkan_wsi, idep_vulkan_runtime,
idep_mesautil, idep_intel_dev, idep_intel_shaders, idep_intel_blorp,
idep_intel_decoder,
idep_intel_decoder_brw,
],
c_args : anv_flags,
gnu_symbol_visibility : 'hidden',

View File

@@ -2514,11 +2514,11 @@ VkResult anv_CreateDevice(
if (INTEL_DEBUG(DEBUG_BATCH)) {
const unsigned decode_flags = INTEL_BATCH_DECODE_DEFAULT_FLAGS;
intel_batch_decode_ctx_init(&device->decoder_ctx,
&physical_device->compiler->isa,
&physical_device->info,
stderr, decode_flags, NULL,
decode_get_bo, NULL, device);
intel_batch_decode_ctx_init_brw(&device->decoder_ctx,
&physical_device->compiler->isa,
&physical_device->info,
stderr, decode_flags, NULL,
decode_get_bo, NULL, device);
device->decoder_ctx.dynamic_base = DYNAMIC_STATE_POOL_MIN_ADDRESS;
device->decoder_ctx.surface_base = SURFACE_STATE_POOL_MIN_ADDRESS;

View File

@@ -197,7 +197,7 @@ libvulkan_intel_hasvk = shared_library(
idep_nir, idep_genxml, idep_vulkan_util, idep_vulkan_wsi,
idep_vulkan_runtime, idep_mesautil, idep_xmlconfig,
idep_intel_driver_ds, idep_intel_dev, idep_intel_blorp,
idep_intel_decoder,
idep_intel_decoder_brw,
],
c_args : anv_flags,
gnu_symbol_visibility : 'hidden',
@@ -236,7 +236,7 @@ if with_tests
dep_thread, dep_dl, dep_m, anv_deps,
idep_nir, idep_vulkan_util, idep_vulkan_wsi, idep_vulkan_runtime,
idep_mesautil, idep_intel_dev, idep_intel_blorp,
idep_intel_decoder,
idep_intel_decoder_brw,
],
c_args : anv_flags,
gnu_symbol_visibility : 'hidden',