1 /* 2 * Copyright © 2017 Intel Corporation 3 * SPDX-License-Identifier: MIT 4 */ 5 6 #include "intel_decoder.h" 7 #include "intel_decoder_private.h" 8 9 #include "compiler/brw_disasm.h" 10 11 static void ctx_disassemble_program_brw(struct intel_batch_decode_ctx * ctx,uint32_t ksp,const char * short_name,const char * name)12 ctx_disassemble_program_brw(struct intel_batch_decode_ctx *ctx, 13 uint32_t ksp, 14 const char *short_name, 15 const char *name) 16 { 17 uint64_t addr = ctx->instruction_base + ksp; 18 struct intel_batch_decode_bo bo = ctx_get_bo(ctx, true, addr); 19 if (!bo.map) 20 return; 21 22 fprintf(ctx->fp, "\nReferenced %s:\n", name); 23 brw_disassemble_with_errors(ctx->brw, bo.map, 0, ctx->fp); 24 25 if (ctx->shader_binary) { 26 int size = brw_disassemble_find_end(ctx->brw, bo.map, 0); 27 28 ctx->shader_binary(ctx->user_data, short_name, addr, 29 bo.map, size); 30 } 31 } 32 33 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)34 intel_batch_decode_ctx_init_brw(struct intel_batch_decode_ctx *ctx, 35 const struct brw_isa_info *isa, 36 const struct intel_device_info *devinfo, 37 FILE *fp, enum intel_batch_decode_flags flags, 38 const char *xml_path, 39 struct intel_batch_decode_bo (*get_bo)(void *, 40 bool, 41 uint64_t), 42 unsigned (*get_state_size)(void *, uint64_t, 43 uint64_t), 44 void *user_data) 45 { 46 intel_batch_decode_ctx_init(ctx, devinfo, fp, flags, xml_path, 47 get_bo, get_state_size, user_data); 48 ctx->brw = isa; 49 ctx->disassemble_program = ctx_disassemble_program_brw; 50 } 51 52