From: Mika Kuoppala Subject: [PATCH 4/6] tools/null_state_gen: Add macro to emit commands with null state Date: Thu, 9 Oct 2014 19:54:37 +0300 Message-ID: <1412873679-7895-4-git-send-email-mika.kuoppala@intel.com> References: <1412873679-7895-1-git-send-email-mika.kuoppala@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id D68816E3A9 for ; Thu, 9 Oct 2014 09:57:28 -0700 (PDT) In-Reply-To: <1412873679-7895-1-git-send-email-mika.kuoppala@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org In null/golden context there are multiple state commands where the actual state is always zero. For more compact batch representation add a macro which just emits command and the rest of the state as zero. v2: - Be more verbose about length bias (Bradley Volkin) - strip out unrelated state_offset declaration (Bradley Volkin) Cc: Volkin, Bradley D Signed-off-by: Mika Kuoppala --- tools/null_state_gen/intel_batchbuffer.c | 15 +++++++++++++++ tools/null_state_gen/intel_batchbuffer.h | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/tools/null_state_gen/intel_batchbuffer.c b/tools/null_state_gen/intel_batchbuffer.c index 2a0b340..a31ea38 100644 --- a/tools/null_state_gen/intel_batchbuffer.c +++ b/tools/null_state_gen/intel_batchbuffer.c @@ -274,3 +274,18 @@ const char *intel_batch_type_as_str(const struct bb_item *item) return "UNKNOWN"; } + +void intel_batch_cmd_emit_null(struct intel_batchbuffer *batch, + const int cmd, const int len, const int len_bias, + const char *str) +{ + int i; + + assert(len > 1); + assert((len - len_bias) >= 0); + + bb_area_emit(batch->cmds, (cmd | (len - len_bias)), CMD, str); + + for (i = len_bias-1; i < len; i++) + OUT_BATCH(0); +} diff --git a/tools/null_state_gen/intel_batchbuffer.h b/tools/null_state_gen/intel_batchbuffer.h index f10831c..f85f31d 100644 --- a/tools/null_state_gen/intel_batchbuffer.h +++ b/tools/null_state_gen/intel_batchbuffer.h @@ -69,6 +69,9 @@ struct intel_batchbuffer { struct intel_batchbuffer *intel_batchbuffer_create(void); +#define OUT_CMD_B(cmd, len, bias) intel_batch_cmd_emit_null(batch, (cmd), (len), (bias), #cmd " " #len) +#define OUT_CMD(cmd, len) OUT_CMD_B(cmd, len, 2) + #define OUT_BATCH(d) bb_area_emit(batch->cmds, d, CMD, #d) #define OUT_BATCH_STATE_OFFSET(d) bb_area_emit(batch->cmds, d, STATE_OFFSET, #d) #define OUT_RELOC(batch, read_domain, write_domain, d) bb_area_emit(batch->cmds, d, RELOC, #d) @@ -94,4 +97,8 @@ const char *intel_batch_type_as_str(const struct bb_item *item); void bb_area_emit(struct bb_area *a, uint32_t dword, item_type type, const char *str); void bb_area_emit_offset(struct bb_area *a, unsigned i, uint32_t dword, item_type type, const char *str); +void intel_batch_cmd_emit_null(struct intel_batchbuffer *batch, + const int cmd, + const int len, const int len_bias, + const char *str); #endif -- 1.9.1