tools/null_state_gen: add macro to emit commands with null state
PATCH 1/3 tools/null_state_gen: add macro to emit commands with null state
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.
--- tools/null_state_gen/intel_batchbuffer.c | 12 ++++++++++++ tools/null_state_gen/intel_batchbuffer.h | 6 +++++- tools/null_state_gen/intel_null_state_gen.c | 12 +++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-)
tools/null_state_gen/intel_batchbuffer.c +12 -0
@@ -274,3 +274,15 @@ 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 char *str) +{ +int i; + +assert (len >1 ); + +bb_area_emit (batch->cmds, (cmd | (len -2 )),CMD , str); + +for (i =1 ; i < len; i++) +OUT_BATCH (0 ); +}
tools/null_state_gen/intel_batchbuffer.h +5 -1
@@ -34,7 +34,7 @@#include <stdint.h> #define MAX_RELOCS 64 -#define MAX_ITEMS 4096 +#define MAX_ITEMS 1024#define MAX_STRLEN 256#define ALIGN (x, y) (((x) + (y)-1) & ~((y)-1))
@@ -69,6 +69,7 @@ struct intel_batchbuffer {struct intel_batchbuffer *intel_batchbuffer_create (void ); +#define OUT_CMD (cmd, len) intel_batch_cmd_emit_null(batch, cmd, len, #cmd " " #len)#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)
@@ -81,6 +82,7 @@ uint32_t intel_batch_state_copy(struct intel_batchbuffer *batch, void *d, unsign const char *name);uint32_t intel_batch_state_alloc (struct intel_batchbuffer *batch,unsigned bytes,unsigned align,const char *name); +uint32_t intel_batch_state_offset (struct intel_batchbuffer *batch,unsigned align);unsigned intel_batch_num_cmds (struct intel_batchbuffer *batch);
@@ -94,4 +96,6 @@ 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 char *str); +#endif
tools/null_state_gen/intel_null_state_gen.c +11 -1
@@ -23,6 +23,9 @@ static void print_usage(char *s)static int print_state (int gen,struct intel_batchbuffer *batch) {int i; +unsigned long cmds; + +fprintf (stderr,"Generating for gen%d\n" , gen);printf ("#include \"intel_renderstate.h\"\n\n" );
@@ -43,8 +46,10 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("\t /* 0x%08x %s '%s' */" , i *4 ,intel_batch_type_as_str (cmd), cmd->str); -if (i *4 == batch->cmds_end_offset) +if (i *4 == batch->cmds_end_offset) { + cmds = i +1 ;printf ("\t /* cmds end */" ); + }if (intel_batch_is_reloc (batch, i))printf ("\t /* reloc */" );
@@ -60,6 +65,11 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("};\n\nRO_RENDERSTATE(%d);\n" , gen); +fprintf (stderr,"Commands %lu (%lu bytes)\n" , cmds, cmds *4 ); +fprintf (stderr,"State %lu (%lu bytes)\n" , batch->state->num_items, batch->state->num_items *4 ); +fprintf (stderr,"Total %lu (%lu bytes)\n" , batch->cmds->num_items, batch->cmds->num_items *4 ); +fprintf (stderr,"\n" ); +return 0 ; }
Signature · 1 line
1.9.1
PATCH 2/3 tools/null_state_gen: gen8 golden state
Previously we didn't have a clear understanding what is necessary for a pipeline state to be properly initialized. So we had to improvise and use a stripped out render copy.
Now we have a more clear understanding so switch out render copy based frankenstate to state we can call golden state.
--- lib/gen6_render.h | 5 +- lib/gen8_render.h | 24 + tools/null_state_gen/intel_renderstate_gen8.c | 842 ++++++++------------------ 3 files changed, 295 insertions(+), 576 deletions(-)
lib/gen6_render.h +3 -2
@@ -41,7 +41,7 @@/* These two are BLC and CTG only, not BW or CL */ #define GEN6_3DSTATE_AA_LINE_PARAMS GEN6_3D(3, 1, 0xa)#define GEN6_3DSTATE_GS_SVB_INDEX GEN6_3D(3, 1, 0xb) - +#define GEN6_3DSTATE_MONOFILTER_SIZE GEN6_3D(3, 1, 0x11)#define GEN6_3DPRIMITIVE GEN6_3D(3, 3, 0)#define GEN6_3DSTATE_CLEAR_PARAMS GEN6_3D(3, 1, 0x10)
@@ -91,6 +91,7 @@# define GEN6_3DSTATE_SF_TRI_PROVOKE_SHIFT 29# define GEN6_3DSTATE_SF_LINE_PROVOKE_SHIFT 27# define GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT 25 +# define GEN6_3DSTATE_SF_VERTEX_SUB_PIXEL_PRECISION_SHIFT 12#define GEN6_3DSTATE_WM GEN6_3D(3, 0, 0x14)/* DW2 */
@@ -303,7 +304,6 @@#define GEN6_EU_ATT_CLR_1 0x8834#define GEN6_EU_RDATA 0x8840 -#define GEN6_PIPE_CONTROL GEN6_3D(3, 2, 0)#define GEN6_3DPRIMITIVE GEN6_3D(3, 3, 0)
@@ -411,6 +411,7 @@/* for GEN6_STATE_BASE_ADDRESS */ #define BASE_ADDRESS_MODIFY (1 << 0) +#define BUFFER_SIZE_MODIFY (1 << 0)/* for GEN6_3DSTATE_PIPELINED_POINTERS */ #define GEN6_GS_DISABLE 0
lib/gen8_render.h +24 -0
@@ -8,6 +8,8 @@#define GEN7_3DSTATE_URB_DS (0x7832 << 16)#define GEN7_3DSTATE_URB_GS (0x7833 << 16) +# define GEN7_WM_LEGACY_DIAMOND_LINE_RASTERIZATION (1 << 26) +#define GEN6_3DSTATE_SCISSOR_STATE_POINTERS GEN6_3D(3, 0, 0xf)#define GEN7_3DSTATE_CLEAR_PARAMS GEN6_3D(3, 0, 0x04)#define GEN7_3DSTATE_DEPTH_BUFFER GEN6_3D(3, 0, 0x05)
@@ -29,6 +31,7 @@#define GEN7_3DSTATE_CONSTANT_GS GEN6_3D(3, 0, 0x16)#define GEN7_3DSTATE_CONSTANT_HS GEN6_3D(3, 0, 0x19)#define GEN7_3DSTATE_CONSTANT_DS GEN6_3D(3, 0, 0x1a) +#define GEN7_3DSTATE_CONSTANT_PS GEN6_3D(3, 0, 0x17)#define GEN7_3DSTATE_HS GEN6_3D(3, 0, 0x1b)#define GEN7_3DSTATE_TE GEN6_3D(3, 0, 0x1c)#define GEN7_3DSTATE_DS GEN6_3D(3, 0, 0x1d)
@@ -44,6 +47,12 @@# define GEN8_RASTER_FRONT_WINDING_CCW (1 << 21)# define GEN8_RASTER_CULL_NONE (1 << 16)#define GEN7_3DSTATE_PS GEN6_3D(3, 0, 0x20) +# define GEN7_PS_SPF_MODE (1 << 31) + +# define GEN7_SF_POINT_WIDTH_FROM_SOURCE (1 << 11) + +# define GEN7_VS_FLOATING_POINT_MODE_ALTERNATE (1 << 16) +#define GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP \ GEN6_3D(3, 0, 0x21)#define GEN8_3DSTATE_PS_BLEND GEN6_3D(3, 0, 0x4d)
@@ -68,14 +77,26 @@#define GEN7_3DSTATE_SAMPLER_STATE_POINTERS_GS GEN6_3D(3, 0, 0x2e)#define GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS GEN6_3D(3, 0, 0x2f) +#define GEN8_3DSTATE_VF GEN6_3D(3, 0, 0x0c)#define GEN8_3DSTATE_VF_TOPOLOGY GEN6_3D(3, 0, 0x4b) +#define GEN8_3DSTATE_BIND_TABLE_POOL_ALLOC GEN6_3D(3, 1, 0x19) +#define GEN8_3DSTATE_GATHER_POOL_ALLOC GEN6_3D(3, 1, 0x1a) +#define GEN8_3DSTATE_DX9_CONSTANT_BUFFER_POOL_ALLOC GEN6_3D(3, 1, 0x1b)#define GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_VS GEN6_3D(3, 1, 0x12)#define GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_HS GEN6_3D(3, 1, 0x13)#define GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_DS GEN6_3D(3, 1, 0x14)#define GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_GS GEN6_3D(3, 1, 0x15)#define GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS GEN6_3D(3, 1, 0x16) +#define GEN8_3DSTATE_VF_SGVS GEN6_3D(3, 0, 0x4a) +#define GEN8_3DSTATE_SO_DECL_LIST GEN6_3D(3, 1, 0x17) +#define GEN8_3DSTATE_SO_BUFFER GEN6_3D(3, 1, 0x18) +#define GEN8_3DSTATE_POLY_STIPPLE_OFFSET GEN6_3D(3, 1, 0x06) +#define GEN8_3DSTATE_POLY_STIPPLE_PATTERN GEN6_3D(3, 1, 0x07) +#define GEN8_3DSTATE_SAMPLER_PALETTE_LOAD0 GEN6_3D(3, 1, 0x02) +#define GEN8_3DSTATE_SAMPLER_PALETTE_LOAD1 GEN6_3D(3, 1, 0x0c) +/* Some random bits that we care about */ #define GEN7_VB0_BUFFER_ADDR_MOD_EN (1 << 14)#define GEN7_3DSTATE_PS_PERSPECTIVE_PIXEL_BARYCENTRIC (1 << 11)
@@ -84,6 +105,9 @@/* Random shifts */ #define GEN8_3DSTATE_PS_MAX_THREADS_SHIFT 23 +/* STATE_BASE_ADDRESS state size in pages*/ +#define GEN8_STATE_SIZE_PAGES (x) ((x) << 12) +/* Shamelessly ripped from mesa */ struct gen8_surface_state {
tools/null_state_gen/intel_renderstate_gen8.c +268 -574
976 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 3/3 tools/null_state_gen: Add GEN9 golden context batch buffer creation
In reply to Mika KuoppalaFrom: Armin Reese <[email protected]>
Modifications to 'null_state_gen' so it can generate GEN9 golden context batch buffer source for SKL.
v2: - rebased on top of gen8 changes (Mika)
- fixed state base address command size (Mika)
- base address size macro as pages (Mika)
--- lib/gen9_render.h | 8 + tools/null_state_gen/Makefile.am | 3 +- tools/null_state_gen/intel_null_state_gen.c | 34 +- tools/null_state_gen/intel_renderstate_gen9.c | 442 ++++++++++++++++++++++++++ 4 files changed, 476 insertions(+), 11 deletions(-) create mode 100644 lib/gen9_render.h create mode 100644 tools/null_state_gen/intel_renderstate_gen9.c
lib/gen9_render.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef GEN9_RENDER_H +#define GEN9_RENDER_H + +#include "gen8_render.h" + +#define GEN9_PIPELINE_SELECT (GEN6_3D(1, 1, 4) | (3 << 8)) + +#endif /* GEN9_RENDER_H */
tools/null_state_gen/Makefile.am +2 -1
@@ -8,9 +8,10 @@ intel_null_state_gen_SOURCES = \ intel_renderstate_gen6.c \ intel_renderstate_gen7.c \ intel_renderstate_gen8.c \ + intel_renderstate_gen9.c \ intel_null_state_gen.c -gens := 6 7 8 +gens := 6 7 8 9 h = /tmp/intel_renderstate_gen$$gen.c state_headers: intel_null_state_gen
tools/null_state_gen/intel_null_state_gen.c +24 -10
@@ -5,21 +5,23 @@#include "intel_batchbuffer.h" -#define STATE_ALIGN 64 -extern int gen6_setup_null_render_state (struct intel_batchbuffer *batch);extern int gen7_setup_null_render_state (struct intel_batchbuffer *batch);extern int gen8_setup_null_render_state (struct intel_batchbuffer *batch); +extern int gen9_setup_null_render_state (struct intel_batchbuffer *batch);static int debug =0 ;static void print_usage (char *s) {fprintf (stderr,"%s: <gen>\n" -" gen: gen to generate for (6,7,8)\n" , - s); +" gen: gen to generate for (6,7,8,9)\n" , + s); } +/* Creates the intel_renderstate_genX.c file for the particular +* GEN product +*/ static int print_state (int gen,struct intel_batchbuffer *batch) {int i;
@@ -29,24 +31,32 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("#include \"intel_renderstate.h\"\n\n" ); +/* Relocation offsets. These are byte offsets in the golden context +* batch buffer where the BB graphics address will be added to +* the indirect state offset already stored in those locations. The +* resulting value will inform the GPU where the indirect states are. +*/ printf ("static const u32 gen%d_null_state_relocs[] = {\n" , gen);for (i =0 ; i < batch->cmds->num_items; i++) {if (intel_batch_is_reloc (batch, i))printf ("\t0x%08x,\n" , i *4 ); } -printf ("\t%d,\n" ,-1 ); -printf ("};\n\n" ); +printf ("\t-1,\n};\n\n" ); +/* GPU commands to execute to set up the RCS golden state. This +* state will become the default config. +*/ printf ("static const u32 gen%d_null_state_batch[] = {\n" , gen);for (i =0 ; i <intel_batch_num_cmds (batch); i++) { +const int offset = i *4 ;const struct bb_item *cmd =intel_batch_cmd_get (batch, i);printf ("\t0x%08x," , cmd->data);if (debug) -printf ("\t /* 0x%08x %s '%s' */" , i *4 , -intel_batch_type_as_str (cmd), cmd->str); +printf ("\t /* 0x%08x %s '%s' */" , offset, +intel_batch_type_as_str (cmd), cmd->str); -if (i *4 == batch->cmds_end_offset) { +if (offset == batch->cmds_end_offset) { cmds = i +1 ;printf ("\t /* cmds end */" ); }
@@ -54,7 +64,7 @@ static int print_state(int gen, struct intel_batchbuffer *batch)if (intel_batch_is_reloc (batch, i))printf ("\t /* reloc */" ); -if (i *4 == batch->state_start_offset) +if (offset == batch->state_start_offset)printf ("\t /* state start */" );if (i ==intel_batch_num_cmds (batch) -1 )
@@ -73,6 +83,7 @@ static int print_state(int gen, struct intel_batchbuffer *batch)return 0 ; } +/* Selects generator function for the given product and executes it. */ static int do_generate (int gen) {struct intel_batchbuffer *batch;
@@ -95,6 +106,9 @@ static int do_generate(int gen)case 8 : null_state_gen = gen8_setup_null_render_state;break ; +case 9 : + null_state_gen = gen9_setup_null_render_state; +break ; }if (null_state_gen ==NULL ) {
tools/null_state_gen/intel_renderstate_gen9.c new file +442 -0
442 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH 3/3] tools/null_state_gen: Add GEN9 golden context batch buffer creation
I went through and compared this against both the spec (the state commands listed in 3D-Media-GPGPU chapter 3D Pipeline Stages section) and the other information I've seen on recommended setup, and as far as I can tell this looks good. It still might be worth getting another set of eyes on this, but it is
Quoted 602 lines · Mika Kuoppala
From: Armin Reese <[email protected]>
Modifications to '
null_state_gen' so it can generate GEN9 golden context batch buffer source for SKL.v2: - rebased on top of gen8 changes (Mika)
- fixed state base address command size (Mika)
- base address size macro as pages (Mika)Signed-off-by Armin Reese <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>--- lib/gen9_render.h | 8 + tools/null_state_gen/Makefile.am | 3 +- tools/null_state_gen/intel_null_state_gen.c | 34 +- tools/null_state_gen/intel_renderstate_gen9.c | 442 ++++++++++++++++++++++++++ 4 files changed, 476 insertions(+), 11 deletions(-) create mode 100644 lib/gen9_render.h create mode 100644 tools/null_state_gen/intel_renderstate_gen9.clib/gen9_render.h new file +8
-0@@ -0,0 +1,8 @@ +#ifndef GEN9_RENDER_H +#define GEN9_RENDER_H + +#include "gen8_render.h" + +#define GEN9_PIPELINE_SELECT (GEN6_3D(1, 1, 4) | (3 << 8)) + +#endif /* GEN9_RENDER_H */ tools/null_state_gen/Makefile.am +2
-1@@ -8,9 +8,10 @@ intel_null_state_gen_SOURCES = \ intel_renderstate_gen6.c \ intel_renderstate_gen7.c \ intel_renderstate_gen8.c \ + intel_renderstate_gen9.c \ intel_null_state_gen.c -gens := 6 7 8 +gens := 6 7 8 9 h = /tmp/intel_renderstate_gen$$gen.c state_headers: intel_null_state_gentools/null_state_gen/intel_null_state_gen.c +24
-10@@ -5,21 +5,23 @@#include "intel_batchbuffer.h" -#define STATE_ALIGN 64 -extern int gen6_setup_null_render_state (struct intel_batchbuffer *batch);extern int gen7_setup_null_render_state (struct intel_batchbuffer *batch);extern int gen8_setup_null_render_state (struct intel_batchbuffer *batch); +extern int gen9_setup_null_render_state (struct intel_batchbuffer *batch);static int debug =0 ;static void print_usage (char *s) {fprintf (stderr,"%s: <gen>\n" -" gen: gen to generate for (6,7,8)\n" , - s); +" gen: gen to generate for (6,7,8,9)\n" , + s); } +/* Creates the intel_renderstate_genX.c file for the particular +* GEN product +*/ static int print_state (int gen,struct intel_batchbuffer *batch) {int i;@@ -29,24 +31,32 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("#include \"intel_renderstate.h\"\n\n" ); +/* Relocation offsets. These are byte offsets in the golden context +* batch buffer where the BB graphics address will be added to +* the indirect state offset already stored in those locations. The +* resulting value will inform the GPU where the indirect states are. +*/ printf ("static const u32 gen%d_null_state_relocs[] = {\n" , gen);for (i =0 ; i < batch->cmds->num_items; i++) {if (intel_batch_is_reloc (batch, i))printf ("\t0x%08x,\n" , i *4 ); } -printf ("\t%d,\n" ,-1 ); -printf ("};\n\n" ); +printf ("\t-1,\n};\n\n" ); +/* GPU commands to execute to set up the RCS golden state. This +* state will become the default config. +*/ printf ("static const u32 gen%d_null_state_batch[] = {\n" , gen);for (i =0 ; i <intel_batch_num_cmds (batch); i++) { +const int offset = i *4 ;const struct bb_item *cmd =intel_batch_cmd_get (batch, i);printf ("\t0x%08x," , cmd->data);if (debug) -printf ("\t /* 0x%08x %s '%s' */" , i *4 , -intel_batch_type_as_str (cmd), cmd->str); +printf ("\t /* 0x%08x %s '%s' */" , offset, +intel_batch_type_as_str (cmd), cmd->str); -if (i *4 == batch->cmds_end_offset) { +if (offset == batch->cmds_end_offset) { cmds = i +1 ;printf ("\t /* cmds end */" ); }@@ -54,7 +64,7 @@ static int print_state(int gen, struct intel_batchbuffer *batch)if (intel_batch_is_reloc (batch, i))printf ("\t /* reloc */" ); -if (i *4 == batch->state_start_offset) +if (offset == batch->state_start_offset)printf ("\t /* state start */" );if (i ==intel_batch_num_cmds (batch) -1 )@@ -73,6 +83,7 @@ static int print_state(int gen, struct intel_batchbuffer *batch)return 0 ; } +/* Selects generator function for the given product and executes it. */ static int do_generate (int gen) {struct intel_batchbuffer *batch;@@ -95,6 +106,9 @@ static int do_generate(int gen)case 8 : null_state_gen = gen8_setup_null_render_state;break ; +case 9 : + null_state_gen = gen9_setup_null_render_state; +break ; }if (null_state_gen ==NULL ) {tools/null_state_gen/intel_renderstate_gen9.c new file +442
-0@@ -0,0 +1,442 @@ +#include <string.h> +#include <stdio.h> + +#include "intel_batchbuffer.h" +#include <lib/gen9_render.h> +#include <lib/intel_reg.h> + +static void gen8_emit_wm (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN6_3DSTATE_WM | (2 -2 )); +OUT_BATCH (GEN7_WM_LEGACY_DIAMOND_LINE_RASTERIZATION ); +} + +static void gen8_emit_ps (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN7_3DSTATE_PS | (12 -2 )); +OUT_BATCH (0 ); +OUT_BATCH (0 );/* kernel hi */ +OUT_BATCH (GEN7_PS_SPF_MODE ); +OUT_BATCH (0 );/* scratch space stuff */ +OUT_BATCH (0 );/* scratch hi */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 );// kernel 1 +OUT_BATCH (0 );/* kernel 1 hi */ +OUT_BATCH (0 );// kernel 2 +OUT_BATCH (0 );/* kernel 2 hi */ +} + +static void gen8_emit_sf (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN6_3DSTATE_SF | (4 -2 )); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (1 <<GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT | +1 <<GEN6_3DSTATE_SF_VERTEX_SUB_PIXEL_PRECISION_SHIFT | +GEN7_SF_POINT_WIDTH_FROM_SOURCE | +8 ); +} + +static void gen8_emit_vs (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN6_3DSTATE_VS | (9 -2 )); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (GEN7_VS_FLOATING_POINT_MODE_ALTERNATE ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +} + +static void gen8_emit_hs (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN7_3DSTATE_HS | (9 -2 )); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (1 <<GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT ); +OUT_BATCH (0 ); +} + +static void gen8_emit_urb (struct intel_batchbuffer *batch) +{ +const int vs_entries =64 ; +const int vs_size =2 ; +const int vs_start =4 ; + +OUT_BATCH (GEN7_3DSTATE_URB_VS ); +OUT_BATCH (vs_entries | ((vs_size -1 ) <<16 ) | (vs_start <<25 )); + +OUT_BATCH (GEN7_3DSTATE_URB_HS ); +OUT_BATCH (0x0f <<25 ); + +OUT_BATCH (GEN7_3DSTATE_URB_DS ); +OUT_BATCH (0x0f <<25 ); + +OUT_BATCH (GEN7_3DSTATE_URB_GS ); +OUT_BATCH (0x0f <<25 ); +} + +static void gen8_emit_vf_topology (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN8_3DSTATE_VF_TOPOLOGY ); +OUT_BATCH (_3DPRIM_TRILIST); +} + +static void gen8_emit_so_decl_list (struct intel_batchbuffer *batch) +{ +const int num_decls =128 ; +int i; + +OUT_BATCH (GEN8_3DSTATE_SO_DECL_LIST | + (((2 * num_decls) +3 ) -2 )/* DWORD count - 2 */ ); +OUT_BATCH (0 ); +OUT_BATCH (num_decls); + +for (i =0 ; i < num_decls; i++) { +OUT_BATCH (0 ); +OUT_BATCH (0 ); + } +} + +static void gen8_emit_so_buffer (struct intel_batchbuffer *batch,const int index) +{ +OUT_BATCH (GEN8_3DSTATE_SO_BUFFER | (8 -2 )); +OUT_BATCH (index <<29 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +} + +static void gen8_emit_chroma_key (struct intel_batchbuffer *batch,const int index) +{ +OUT_BATCH (GEN6_3DSTATE_CHROMA_KEY | (4 -2 )); +OUT_BATCH (index <<30 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +} + +static void gen8_emit_vertex_buffers (struct intel_batchbuffer *batch) +{ +const int buffers =33 ; +int i; + +OUT_BATCH (GEN6_3DSTATE_VERTEX_BUFFERS | + (((4 * buffers) +1 )-2 )/* DWORD count - 2 */ ); + +for (i =0 ; i < buffers; i++) { +OUT_BATCH (i <<VB0_BUFFER_INDEX_SHIFT | +GEN7_VB0_BUFFER_ADDR_MOD_EN ); +OUT_BATCH (0 );/* Address */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); + } +} + +static void gen8_emit_vertex_elements (struct intel_batchbuffer *batch) +{ +const int elements =34 ; +int i; + +OUT_BATCH (GEN6_3DSTATE_VERTEX_ELEMENTS | + (((2 * elements) +1 ) -2 )/* DWORD count - 2 */ ); + +/* Element 0 */ +OUT_BATCH (VE0_VALID ); +OUT_BATCH ( +GEN6_VFCOMPONENT_STORE_0 <<VE1_VFCOMPONENT_0_SHIFT | +GEN6_VFCOMPONENT_STORE_0 <<VE1_VFCOMPONENT_1_SHIFT | +GEN6_VFCOMPONENT_STORE_0 <<VE1_VFCOMPONENT_2_SHIFT | +GEN6_VFCOMPONENT_STORE_0 <<VE1_VFCOMPONENT_3_SHIFT ); +/* Elements 1 -> 33 */ +for (i =1 ; i < elements; i++) { +OUT_BATCH (0 ); +OUT_BATCH (0 ); + } +} + +static void gen8_emit_cc_state_pointers (struct intel_batchbuffer *batch) +{ +union { +float fval; +uint32_t uval; + } u; + +unsigned offset; + + u.fval =1.0f ; + + offset =intel_batch_state_offset (batch,64 ); +OUT_STATE (0 ); +OUT_STATE (0 );/* Alpha reference value */ +OUT_STATE (u.uval);/* Blend constant color RED */ +OUT_STATE (u.uval);/* Blend constant color BLUE */ +OUT_STATE (u.uval);/* Blend constant color GREEN */ +OUT_STATE (u.uval);/* Blend constant color ALPHA */ + +OUT_BATCH (GEN6_3DSTATE_CC_STATE_POINTERS ); +OUT_BATCH_STATE_OFFSET (offset |1 ); +} + +static void gen8_emit_blend_state_pointers (struct intel_batchbuffer *batch) +{ +unsigned offset; +int i; + + offset =intel_batch_state_offset (batch,64 ); + +for (i =0 ; i <17 ; i++) +OUT_STATE (0 ); + +OUT_BATCH (GEN7_3DSTATE_BLEND_STATE_POINTERS | (2 -2 )); +OUT_BATCH_STATE_OFFSET (offset |1 ); +} + +static void gen8_emit_ps_extra (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN8_3DSTATE_PS_EXTRA | (2 -2 )); +OUT_BATCH (GEN8_PSX_PIXEL_SHADER_VALID | +GEN8_PSX_ATTRIBUTE_ENABLE ); + +} + +static void gen8_emit_ps_blend (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN8_3DSTATE_PS_BLEND | (2 -2 )); +OUT_BATCH (GEN8_PS_BLEND_HAS_WRITEABLE_RT ); +} + +static void gen8_emit_viewport_state_pointers_cc (struct intel_batchbuffer *batch) +{ +unsigned offset; + + offset =intel_batch_state_offset (batch,32 ); + +OUT_STATE ((uint32_t )0.0f );/* Minimum depth */ +OUT_STATE ((uint32_t )0.0f );/* Maximum depth */ + +OUT_BATCH (GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC | (2 -2 )); +OUT_BATCH_STATE_OFFSET (offset); +} + +static void gen8_emit_viewport_state_pointers_sf_clip (struct intel_batchbuffer *batch) +{ +unsigned offset; +int i; + + offset =intel_batch_state_offset (batch,64 ); + +for (i =0 ; i <16 ; i++) +OUT_STATE (0 ); + +OUT_BATCH (GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP | (2 -2 )); +OUT_BATCH_STATE_OFFSET (offset); +} + +static void gen8_emit_primitive (struct intel_batchbuffer *batch) +{ +OUT_BATCH (GEN6_3DPRIMITIVE | (7 -2 )); +OUT_BATCH (4 );/* gen8+ ignore the topology type field */ +OUT_BATCH (1 );/* vertex count */ +OUT_BATCH (0 ); +OUT_BATCH (1 );/* single instance */ +OUT_BATCH (0 );/* start instance location */ +OUT_BATCH (0 );/* index buffer offset, ignored */ +} + +static void gen9_emit_state_base_address (struct intel_batchbuffer *batch) { +const unsigned offset =0 ; +OUT_BATCH (GEN6_STATE_BASE_ADDRESS | + (19 -2 )/* DWORD count - 2 */ ); + +/* general state base address - requires BB address +* added to state offset to be stored in this location +*/ +OUT_RELOC (batch,0 ,0 , offset |BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); + +/* stateless data port */ +OUT_BATCH (0 ); + +/* surface state base address - requires BB address +* added to state offset to be stored in this location +*/ +OUT_RELOC (batch,0 ,0 , offset |BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); + +/* dynamic state base address - requires BB address +* added to state offset to be stored in this location +*/ +OUT_RELOC (batch,0 ,0 , offset |BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); + +/* indirect state base address */ +OUT_BATCH (BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); + +/* instruction state base address - requires BB address +* added to state offset to be stored in this location +*/ +OUT_RELOC (batch,0 ,0 , offset |BASE_ADDRESS_MODIFY ); +OUT_BATCH (0 ); + +/* general state buffer size */ +OUT_BATCH (GEN8_STATE_SIZE_PAGES (1 ) |BUFFER_SIZE_MODIFY ); +/* dynamic state buffer size */ +OUT_BATCH (GEN8_STATE_SIZE_PAGES (1 ) |BUFFER_SIZE_MODIFY ); +/* indirect object buffer size */ +OUT_BATCH (0x0 |BUFFER_SIZE_MODIFY ); +/* intruction buffer size */ +OUT_BATCH (GEN8_STATE_SIZE_PAGES (1 ) |BUFFER_SIZE_MODIFY ); + +/* bindless surface state base address */ +OUT_BATCH (0 ); +OUT_BATCH (0 ); +/* bindless surface state size */ +OUT_BATCH (0 ); +} + +/* +* Generate the batch buffer commands needed to initialize the 3D engine +* to its "golden state". +*/ +int gen9_setup_null_render_state (struct intel_batchbuffer *batch) +{ +int ret; +int i; + +#define GEN8_PIPE_CONTROL_GLOBAL_GTT (1 << 24) +/* PIPE_CONTROL */ +OUT_BATCH (GEN6_PIPE_CONTROL | + (6 -2 ));/* DWORD count - 2 */ +OUT_BATCH (GEN8_PIPE_CONTROL_GLOBAL_GTT ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); +OUT_BATCH (0 ); + +/* PIPELINE_SELECT */ +OUT_BATCH (GEN9_PIPELINE_SELECT |PIPELINE_SELECT_3D ); + +gen8_emit_wm (batch); +gen8_emit_ps (batch); +gen8_emit_sf (batch); + +OUT_CMD (GEN7_3DSTATE_SBE ,6 );/* Check w/ Gen8 code */ +OUT_CMD (GEN8_3DSTATE_SBE_SWIZ ,11 ); + +gen8_emit_vs (batch); +gen8_emit_hs (batch); + +OUT_CMD (GEN7_3DSTATE_GS ,10 ); +OUT_CMD (GEN7_3DSTATE_STREAMOUT ,5 ); +OUT_CMD (GEN7_3DSTATE_DS ,11 );/* Check w/ Gen8 code */ +OUT_CMD (GEN6_3DSTATE_CLIP ,4 ); +OUT_CMD (GEN7_3DSTATE_TE ,4 ); +OUT_CMD (GEN8_3DSTATE_VF ,2 ); +OUT_CMD (GEN8_3DSTATE_WM_HZ_OP ,5 ); + +/* URB States */ +gen8_emit_urb (batch); + +OUT_CMD (GEN8_3DSTATE_BIND_TABLE_POOL_ALLOC ,4 ); +OUT_CMD (GEN8_3DSTATE_GATHER_POOL_ALLOC ,4 ); +OUT_CMD (GEN8_3DSTATE_DX9_CONSTANT_BUFFER_POOL_ALLOC ,4 ); + +/* Push Constants */ +OUT_CMD (GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_VS ,2 ); +OUT_CMD (GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_HS ,2 ); +OUT_CMD (GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_DS ,2 ); +OUT_CMD (GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_GS ,2 ); +OUT_CMD (GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS ,2 ); + +/* Constants */ +OUT_CMD (GEN6_3DSTATE_CONSTANT_VS ,11 ); +OUT_CMD (GEN7_3DSTATE_CONSTANT_HS ,11 ); +OUT_CMD (GEN7_3DSTATE_CONSTANT_DS ,11 ); +OUT_CMD (GEN7_3DSTATE_CONSTANT_GS ,11 ); +OUT_CMD (GEN7_3DSTATE_CONSTANT_PS ,11 ); + +OUT_CMD (GEN8_3DSTATE_VF_INSTANCING ,3 ); +OUT_CMD (GEN8_3DSTATE_VF_SGVS ,2 ); +gen8_emit_vf_topology (batch); + +/* Streamer out declaration list */ +gen8_emit_so_decl_list (batch); + +/* Streamer out buffers */ +for (i =0 ; i <4 ; i++) { +gen8_emit_so_buffer (batch, i); + } + +/* State base addresses */ +gen9_emit_state_base_address (batch); + +OUT_CMD (GEN6_STATE_SIP ,3 ); +OUT_CMD (GEN6_3DSTATE_DRAWING_RECTANGLE ,4 ); +OUT_CMD (GEN7_3DSTATE_DEPTH_BUFFER ,8 ); + +/* Chroma key */ +for (i =0 ; i <4 ; i++) { +gen8_emit_chroma_key (batch, i); + } + +OUT_CMD (GEN6_3DSTATE_LINE_STIPPLE ,3 ); +OUT_CMD (GEN6_3DSTATE_AA_LINE_PARAMS ,3 ); +OUT_CMD (GEN7_3DSTATE_STENCIL_BUFFER ,5 ); +OUT_CMD (GEN7_3DSTATE_HIER_DEPTH_BUFFER ,5 ); +OUT_CMD (GEN7_3DSTATE_CLEAR_PARAMS ,3 ); +OUT_CMD (GEN6_3DSTATE_MONOFILTER_SIZE ,2 ); +OUT_CMD (GEN8_3DSTATE_MULTISAMPLE ,2 ); +OUT_CMD (GEN8_3DSTATE_POLY_STIPPLE_OFFSET ,2 ); +OUT_CMD (GEN8_3DSTATE_POLY_STIPPLE_PATTERN ,1 +32 ); +OUT_CMD (GEN8_3DSTATE_SAMPLER_PALETTE_LOAD0 ,1 +16 ); +OUT_CMD (GEN8_3DSTATE_SAMPLER_PALETTE_LOAD1 ,1 +16 ); +OUT_CMD (GEN6_3DSTATE_INDEX_BUFFER ,5 ); + +/* Vertex buffers */ +gen8_emit_vertex_buffers (batch); +gen8_emit_vertex_elements (batch); + +OUT_BATCH (GEN6_3DSTATE_VF_STATISTICS |1 /* Enable */ ); + +gen8_emit_cc_state_pointers (batch); +gen8_emit_blend_state_pointers (batch); +gen8_emit_ps_extra (batch); +gen8_emit_ps_blend (batch); + +/* 3D state sampler state pointers */ +OUT_CMD (GEN7_3DSTATE_SAMPLER_STATE_POINTERS_VS ,2 ); +OUT_CMD (GEN7_3DSTATE_SAMPLER_STATE_POINTERS_HS ,2 ); +OUT_CMD (GEN7_3DSTATE_SAMPLER_STATE_POINTERS_DS ,2 ); +OUT_CMD (GEN7_3DSTATE_SAMPLER_STATE_POINTERS_GS ,2 ); +OUT_CMD (GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS ,2 ); + +OUT_CMD (GEN6_3DSTATE_SCISSOR_STATE_POINTERS ,2 ); + +gen8_emit_viewport_state_pointers_cc (batch); +gen8_emit_viewport_state_pointers_sf_clip (batch); + +/* 3D state binding table pointers */ +OUT_CMD (GEN7_3DSTATE_BINDING_TABLE_POINTERS_VS ,2 ); +OUT_CMD (GEN7_3DSTATE_BINDING_TABLE_POINTERS_HS ,2 ); +OUT_CMD (GEN7_3DSTATE_BINDING_TABLE_POINTERS_DS ,2 ); +OUT_CMD (GEN7_3DSTATE_BINDING_TABLE_POINTERS_GS ,2 ); +OUT_CMD (GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS ,2 ); + +/* Launch 3D operation */ +gen8_emit_primitive (batch); + +OUT_BATCH (MI_BATCH_BUFFER_END ); + +return ret; +}Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 17 lines · Mika Kuoppala
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.
Signed-off-by Mika Kuoppala <[email protected]>--- tools/null_state_gen/intel_batchbuffer.c | 12 ++++++++++++ tools/null_state_gen/intel_batchbuffer.h | 6 +++++- tools/null_state_gen/intel_null_state_gen.c | 12 +++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-)tools/null_state_gen/intel_batchbuffer.c +0
-0@@ -274,3 +274,15 @@ const char *intel_batch_type_as_str(const struct bb_item *item)
tools/null_state_gen/intel_batchbuffer.c const char *intel_batch_type_as_str(const struct bb_item *item) · line 284
Quoted 10 lines
tools/null_state_gen/intel_batchbuffer.c +8
-0return "UNKNOWN" ; } + +void intel_batch_cmd_emit_null (struct intel_batchbuffer *batch,const int cmd,const int len,const char *str) +{ +int i; + +assert (len >1 ); + +bb_area_emit (batch->cmds, (cmd | (len -2 )),CMD , str);
I'm a little hesitant about the (len - 2) here just because there are a number of commands for which those bits are not the length field, and one or two where the length field is (len - 1). I think we're unlikely to use those commands in a null batch, so maybe it's not something to worry about.
Quoted 26 lines
tools/null_state_gen/intel_batchbuffer.c +4
-0+ +for (i =1 ; i < len; i++) +OUT_BATCH (0 ); +}tools/null_state_gen/intel_batchbuffer.h +2
-1@@ -34,7 +34,7 @@#include <stdint.h> #define MAX_RELOCS 64 -#define MAX_ITEMS 4096 +#define MAX_ITEMS 1024#define MAX_STRLEN 256#define ALIGN (x, y) (((x) + (y)-1) & ~((y)-1))@@ -69,6 +69,7 @@ struct intel_batchbuffer {struct intel_batchbuffer *intel_batchbuffer_create (void ); +#define OUT_CMD (cmd, len) intel_batch_cmd_emit_null(batch, cmd, len, #cmd " " #len)#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)
tools/null_state_gen/intel_batchbuffer.h uint32_t intel_batch_state_copy(struct intel_batchbuffer *batch, void *d, unsign · line 85
Quoted 4 lines
tools/null_state_gen/intel_batchbuffer.h +1
-0@@ -81,6 +82,7 @@ uint32_t intel_batch_state_copy(struct intel_batchbuffer *batch, void *d, unsign const char *name);uint32_t intel_batch_state_alloc (struct intel_batchbuffer *batch,unsigned bytes,unsigned align,const char *name); +uint32_t intel_batch_state_offset (struct intel_batchbuffer *batch,unsigned align);
I see that at least patch 2 uses this function outside of intel_batchbuffer.c but I wasn't expecting this change based on the commit title or message.
Thanks,
Brad
Quoted 55 lines
tools/null_state_gen/intel_batchbuffer.h +2
-0unsigned intel_batch_num_cmds (struct intel_batchbuffer *batch);@@ -94,4 +96,6 @@ 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 char *str); +#endif tools/null_state_gen/intel_null_state_gen.c +11
-1@@ -23,6 +23,9 @@ static void print_usage(char *s)static int print_state (int gen,struct intel_batchbuffer *batch) {int i; +unsigned long cmds; + +fprintf (stderr,"Generating for gen%d\n" , gen);printf ("#include \"intel_renderstate.h\"\n\n" );@@ -43,8 +46,10 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("\t /* 0x%08x %s '%s' */" , i *4 ,intel_batch_type_as_str (cmd), cmd->str); -if (i *4 == batch->cmds_end_offset) +if (i *4 == batch->cmds_end_offset) { + cmds = i +1 ;printf ("\t /* cmds end */" ); + }if (intel_batch_is_reloc (batch, i))printf ("\t /* reloc */" );@@ -60,6 +65,11 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("};\n\nRO_RENDERSTATE(%d);\n" , gen); +fprintf (stderr,"Commands %lu (%lu bytes)\n" , cmds, cmds *4 ); +fprintf (stderr,"State %lu (%lu bytes)\n" , batch->state->num_items, batch->state->num_items *4 ); +fprintf (stderr,"Total %lu (%lu bytes)\n" , batch->cmds->num_items, batch->cmds->num_items *4 ); +fprintf (stderr,"\n" ); +return 0 ; }Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 18 lines · Bradley D
Quoted 17 lines · Mika Kuoppala
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.
Signed-off-by Mika Kuoppala <[email protected]>--- tools/null_state_gen/intel_batchbuffer.c | 12 ++++++++++++ tools/null_state_gen/intel_batchbuffer.h | 6 +++++- tools/null_state_gen/intel_null_state_gen.c | 12 +++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-)tools/null_state_gen/intel_batchbuffer.c +0
-0@@ -274,3 +274,15 @@ const char *intel_batch_type_as_str(const struct bb_item *item)
Quoted 17 lines
tools/null_state_gen/intel_batchbuffer.c const char *intel_batch_type_as_str(const struct bb_item *item) · line 284
Quoted 10 lines
tools/null_state_gen/intel_batchbuffer.c +8
-0return "UNKNOWN" ; } + +void intel_batch_cmd_emit_null (struct intel_batchbuffer *batch,const int cmd,const int len,const char *str) +{ +int i; + +assert (len >1 ); + +bb_area_emit (batch->cmds, (cmd | (len -2 )),CMD , str);I'm a little hesitant about the (len - 2) here just because there are a number of commands for which those bits are not the length field, and one or two where the length field is (len - 1). I think we're unlikely to use those commands in a null batch, so maybe it's not something to worry about.
Noted. Perhaps this could be encoded into the macro name so that it would clear that it is for a len 2 bias null setup.
Quoted 21 lines
Quoted 21 lines
tools/null_state_gen/intel_batchbuffer.c +4
-0+ +for (i =1 ; i < len; i++) +OUT_BATCH (0 ); +}tools/null_state_gen/intel_batchbuffer.h +1
-1@@ -34,7 +34,7 @@#include <stdint.h> #define MAX_RELOCS 64 -#define MAX_ITEMS 4096 +#define MAX_ITEMS 1024#define MAX_STRLEN 256#define ALIGN (x, y) (((x) + (y)-1) & ~((y)-1))@@ -69,6 +69,7 @@ struct intel_batchbuffer {struct intel_batchbuffer *intel_batchbuffer_create (void );
Quoted 12 lines
tools/null_state_gen/intel_batchbuffer.h uint32_t intel_batch_state_copy(struct intel_batchbuffer *batch, void *d, unsign · line 85
Quoted 9 lines
tools/null_state_gen/intel_batchbuffer.h +2
-0+#define OUT_CMD (cmd, len) intel_batch_cmd_emit_null(batch, cmd, len, #cmd " " #len)#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)@@ -81,6 +82,7 @@ uint32_t intel_batch_state_copy(struct intel_batchbuffer *batch, void *d, unsign const char *name);uint32_t intel_batch_state_alloc (struct intel_batchbuffer *batch,unsigned bytes,unsigned align,const char *name); +uint32_t intel_batch_state_offset (struct intel_batchbuffer *batch,unsigned align);I see that at least patch 2 uses this function outside of
intel_batchbuffer.cbut I wasn't expecting this change based on the commit title or message.
This should have been in included in the second patch, jumped here by mistake. The second patch is missing s-o-b also.
Thanks,
-Mika
Quoted 58 lines
Thanks,
BradQuoted 55 lines
tools/null_state_gen/intel_batchbuffer.h +2
-0unsigned intel_batch_num_cmds (struct intel_batchbuffer *batch);@@ -94,4 +96,6 @@ 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 char *str); +#endif tools/null_state_gen/intel_null_state_gen.c +11
-1@@ -23,6 +23,9 @@ static void print_usage(char *s)static int print_state (int gen,struct intel_batchbuffer *batch) {int i; +unsigned long cmds; + +fprintf (stderr,"Generating for gen%d\n" , gen);printf ("#include \"intel_renderstate.h\"\n\n" );@@ -43,8 +46,10 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("\t /* 0x%08x %s '%s' */" , i *4 ,intel_batch_type_as_str (cmd), cmd->str); -if (i *4 == batch->cmds_end_offset) +if (i *4 == batch->cmds_end_offset) { + cmds = i +1 ;printf ("\t /* cmds end */" ); + }if (intel_batch_is_reloc (batch, i))printf ("\t /* reloc */" );@@ -60,6 +65,11 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("};\n\nRO_RENDERSTATE(%d);\n" , gen); +fprintf (stderr,"Commands %lu (%lu bytes)\n" , cmds, cmds *4 ); +fprintf (stderr,"State %lu (%lu bytes)\n" , batch->state->num_items, batch->state->num_items *4 ); +fprintf (stderr,"Total %lu (%lu bytes)\n" , batch->cmds->num_items, batch->cmds->num_items *4 ); +fprintf (stderr,"\n" ); +return 0 ; }Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
As far as I can tell, the patch series (1->3) looks good. I was wondering how the copyright header will be handled. Is that to be added manually later on?
Thanks,
Armin
-----Original Message-----
From: Mika Kuoppala [mailto:[email protected]]
Sent: Wednesday, September 24, 2014 5:51 AM
To: [email protected]
Cc: Reese, Armin C; [email protected]
Subject: [PATCH 1/3] tools/null_state_gen: add macro to emit commands with null state
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.
--- tools/null_state_gen/intel_batchbuffer.c | 12 ++++++++++++ tools/null_state_gen/intel_batchbuffer.h | 6 +++++- tools/null_state_gen/intel_null_state_gen.c | 12 +++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-)
tools/null_state_gen/intel_batchbuffer.c +12 -0
@@ -274,3 +274,15 @@ 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 char *str) { +int i; + +assert (len >1 ); + +bb_area_emit (batch->cmds, (cmd | (len -2 )),CMD , str); + +for (i =1 ; i < len; i++) +OUT_BATCH (0 ); +}
tools/null_state_gen/intel_batchbuffer.h +1 -1
@@ -34,7 +34,7 @@#include <stdint.h> #define MAX_RELOCS 64 -#define MAX_ITEMS 4096 +#define MAX_ITEMS 1024#define MAX_STRLEN 256#define ALIGN (x, y) (((x) + (y)-1) & ~((y)-1)) @@ -69,6 +69,7 @@ struct intel_batchbuffer {
struct intel_batchbuffer *intel_batchbuffer_create(void);
+#define OUT_CMD(cmd, len) intel_batch_cmd_emit_null(batch, cmd, len,
+#cmd " " #len)
#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) @@ -81,6 +82,7 @@ uint32_t intel_batch_state_copy(struct intel_batchbuffer *batch, void *d, unsign
const char *name);
uint32_t intel_batch_state_alloc(struct intel_batchbuffer *batch, unsigned bytes, unsigned align,
const char *name);
+uint32_t intel_batch_state_offset(struct intel_batchbuffer *batch,
+unsigned align);
unsigned intel_batch_num_cmds(struct intel_batchbuffer *batch);
@@ -94,4 +96,6 @@ 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 char *str);
+
#endif
tools/null_state_gen/intel_null_state_gen.c +11 -1
@@ -23,6 +23,9 @@ static void print_usage(char *s) static int print_state(int gen, struct intel_batchbuffer *batch) {int i; +unsigned long cmds; + +fprintf (stderr,"Generating for gen%d\n" , gen);printf ("#include \"intel_renderstate.h\"\n\n" );
@@ -43,8 +46,10 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("\t /* 0x%08x %s '%s' */" , i *4 ,intel_batch_type_as_str (cmd), cmd->str); -if (i *4 == batch->cmds_end_offset) +if (i *4 == batch->cmds_end_offset) { + cmds = i +1 ;printf ("\t /* cmds end */" ); + }if (intel_batch_is_reloc (batch, i))printf ("\t /* reloc */" );
@@ -60,6 +65,11 @@ static int print_state(int gen, struct intel_batchbuffer *batch)printf ("};\n\nRO_RENDERSTATE(%d);\n" , gen); +fprintf (stderr,"Commands %lu (%lu bytes)\n" , cmds, cmds *4 ); +fprintf (stderr,"State %lu (%lu bytes)\n" , batch->state->num_items, batch->state->num_items *4 ); +fprintf (stderr,"Total %lu (%lu bytes)\n" , batch->cmds->num_items, batch->cmds->num_items *4 ); +fprintf (stderr,"\n" ); +return 0 ; }
--
1.9.1