[Mesa-dev] [PATCH 00/22] RFC: Batchbuffer Logger for Intel GPU

kevin.rogovin at intel.com kevin.rogovin at intel.com
Mon Sep 25 10:34:00 UTC 2017


From: Kevin Rogovin <kevin.rogovin at intel.com>

This patch series defines and implements a BatchbufferLogger
for Intel GEN. The main purpose of the BatchbufferLogger is
to strongly correlate API calls to data added to a batchbuffer.
In addition to this function, the BatchbufferLogger also tracks
GPU state (respecting HW context as well). The logger intercepts
drmIoctl recording the information needed to decode a bachbuffer
(such as GEM BO creation/deletion, HW context create/delete,
and most importantly execbuffer2). When the execbuffer2 returns
from the kernel, the BatchbufferLogger will log information
in its log of what was added when and in addition log the
GPU state (at the point in the batchbuffer) of 3DPRIMITIVE and
GPGPU_WALKER commands.

It is an application's requirment to tell the BatchbufferLogger
just before and just after an API call. Because of the need
to intercept drmIoctl, having an application link against
BatchbufferLogger is not robust. Instead, an application is
to use dlsym to fetch the correction a function pointer that
returns the BatchbufferLogger's application interface. The
interface of the BatchbufferLogger is defined in patch 0002.
A script is also provided to use the BatchbufferLogger in
an easier way than needing to set environmental variables.

On the subject of application integration, I have a -very-
small patch series that enabled BatchbufferLogger for
apitrace. I can share these patches if anyone asks, but I
cannot submit them to apitrace until atleast the BatchbufferLogger
is in Mesa with a stable application interface.

The log emitted by the BatchbufferLogger is a sequence of blocks
with possibility of blocks being elements of blocks. The top level
blocks are the API call markers created from the calls into the
BatchbufferLogger from the application. The format of the log
is defined in a dedicated header (from patch 0003). Tools are
included to convert the log to JSON, XML and text. The simple
file format should allow others to be able to take the data and
use it however they see fit. The JSON output alone can be quite
illuminating to use when debugging/enhancing the i965 driver
for a single frame of a troublesome application.

The patch series is organized into the following blocks:

0001-0003: Define the BatchbufferLogger interfaces
0004-0005: Minor fixes to i965 driver
0006-0006: Hooking of BatchbufferLogger into i965
0007-0015: Fixes and enhancements to intel/compiler,
           intel/tools and intel/common.
0016-0018: Implementation of BatchBufferLogger
0019-0021: Tools to decode log to JSON, XML and text
0022-0022: Command line tool for disassembling shader
           binaries.

Kevin Rogovin (22):
  intel/tools: define BatchBufferLogger driver interface
  intel/tools: define BatchbufferLogger application interface
  intel/tools: BatchBufferLogger define output file format of tool
  i965: assign BindingTableEntryCount of INTERFACE_DESCRIPTOR_DATA
  i965: correctly assign SamplerCount of INTERFACE_DESCRIPTOR_DATA
  i965: Enable BatchbufferLogger in i965 driver
  intel/common/gen_decoder: make useable from C++ source
  intel/compiler: brw_validate_instructions to take const void* instead
    of void*
  intel/compiler: fix for memmove argument on annotating error
  intel/compiler:add function to give option to print offsets into
    assembly
  intel/tools/disasm: correctly observe FILE *out parameter
  intel/tools/disasm: make useable from C++ sources
  intel/tools/disasm: gen_disasm_disassemble to take const void* instead
    of void*
  intel/tools/disasm: add gen_disasm_assembly_length function
  intel/tools/disasm: make sure that entire range is disassembled
  intel/tools/BatchbufferLogger: first implementation
  intel/tools/BatchbufferLogger: install i965_batchbuffer non-driver
    interface headers
  inte/tools/BatchbufferLogger : add shell script for batchbuffer logger
  intel/tools/BatchbufferLogger (txt-output): example txt dumper
  intel/tools/BatchbufferLogger (output-xml): add outputter to XML
  intel/tools/BatchbufferLogger (output-json): add json outputter
  intel/tools: add command line GEN shader disassembler tool

 src/intel/Makefile.tools.am                        |   71 +
 src/intel/common/gen_decoder.h                     |    7 +
 src/intel/common/gen_device_info.h                 |    8 +
 src/intel/compiler/brw_eu.c                        |   11 +-
 src/intel/compiler/brw_eu.h                        |    5 +-
 src/intel/compiler/brw_eu_validate.c               |    2 +-
 src/intel/compiler/intel_asm_annotation.c          |    5 +-
 src/intel/tools/.gitignore                         |    5 +
 src/intel/tools/disasm.c                           |   28 +-
 src/intel/tools/gen_disasm.h                       |   12 +-
 src/intel/tools/gen_shader_disassembler.c          |  218 +
 src/intel/tools/i965_batchbuffer_dump_show.c       |  129 +
 .../tools/i965_batchbuffer_dump_show_json.cpp      |  251 ++
 src/intel/tools/i965_batchbuffer_dump_show_xml.cpp |  215 +
 src/intel/tools/i965_batchbuffer_logger.cpp        | 4221 ++++++++++++++++++++
 src/intel/tools/i965_batchbuffer_logger.h          |  117 +
 src/intel/tools/i965_batchbuffer_logger_app.h      |   84 +
 .../tools/i965_batchbuffer_logger_instructions.h   |  131 +
 src/intel/tools/i965_batchbuffer_logger_output.h   |   74 +
 src/intel/tools/i965_batchbuffer_logger_sh.in      |  107 +
 src/mesa/drivers/dri/i965/brw_bufmgr.c             |   22 +-
 src/mesa/drivers/dri/i965/brw_bufmgr.h             |    8 +-
 src/mesa/drivers/dri/i965/brw_context.c            |    2 +
 src/mesa/drivers/dri/i965/brw_context.h            |    6 +
 src/mesa/drivers/dri/i965/genX_state_upload.c      |    3 +-
 src/mesa/drivers/dri/i965/intel_screen.c           |   55 +-
 src/mesa/drivers/dri/i965/intel_screen.h           |    3 +
 27 files changed, 5780 insertions(+), 20 deletions(-)
 create mode 100644 src/intel/tools/gen_shader_disassembler.c
 create mode 100644 src/intel/tools/i965_batchbuffer_dump_show.c
 create mode 100644 src/intel/tools/i965_batchbuffer_dump_show_json.cpp
 create mode 100644 src/intel/tools/i965_batchbuffer_dump_show_xml.cpp
 create mode 100644 src/intel/tools/i965_batchbuffer_logger.cpp
 create mode 100644 src/intel/tools/i965_batchbuffer_logger.h
 create mode 100644 src/intel/tools/i965_batchbuffer_logger_app.h
 create mode 100644 src/intel/tools/i965_batchbuffer_logger_instructions.h
 create mode 100644 src/intel/tools/i965_batchbuffer_logger_output.h
 create mode 100644 src/intel/tools/i965_batchbuffer_logger_sh.in

-- 
2.7.4



More information about the mesa-dev mailing list