From: Chia-I Wu Date: Mon, 15 Sep 2014 01:09:54 +0000 (+0800) Subject: ilo: clean up 3D/media functions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce50a61d3659582d18957b4c953904ad92c417ec;p=mesa.git ilo: clean up 3D/media functions Mostly style changes to set dw[0] directly. --- diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h index 4d68acd7253..27279b332d1 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h @@ -45,7 +45,6 @@ gen6_3DSTATE_CLIP(struct ilo_builder *builder, int num_viewports) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CLIP) | (cmd_len - 2); uint32_t dw1, dw2, dw3, *dw; ILO_DEV_ASSERT(builder->dev, 6, 7.5); @@ -78,7 +77,8 @@ gen6_3DSTATE_CLIP(struct ilo_builder *builder, } ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CLIP) | (cmd_len - 2); dw[1] = dw1; dw[2] = dw2; dw[3] = dw3; @@ -213,7 +213,6 @@ gen6_3DSTATE_SF(struct ilo_builder *builder, const struct ilo_shader_state *fs) { const uint8_t cmd_len = 20; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SF) | (cmd_len - 2); uint32_t payload_raster[6], payload_sbe[13], *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); @@ -224,7 +223,8 @@ gen6_3DSTATE_SF(struct ilo_builder *builder, fs, payload_sbe, Elements(payload_sbe)); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SF) | (cmd_len - 2); dw[1] = payload_sbe[0]; memcpy(&dw[2], payload_raster, sizeof(payload_raster)); memcpy(&dw[8], &payload_sbe[1], sizeof(payload_sbe) - 4); @@ -236,7 +236,6 @@ gen7_3DSTATE_SF(struct ilo_builder *builder, enum pipe_format zs_format) { const uint8_t cmd_len = 7; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SF) | (cmd_len - 2); const int num_samples = 1; uint32_t payload[6], *dw; @@ -247,7 +246,8 @@ gen7_3DSTATE_SF(struct ilo_builder *builder, payload, Elements(payload)); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SF) | (cmd_len - 2); memcpy(&dw[1], payload, sizeof(payload)); } @@ -257,7 +257,6 @@ gen7_3DSTATE_SBE(struct ilo_builder *builder, const struct ilo_shader_state *fs) { const uint8_t cmd_len = 14; - const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) | (cmd_len - 2); uint32_t payload[13], *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); @@ -266,7 +265,8 @@ gen7_3DSTATE_SBE(struct ilo_builder *builder, rasterizer, fs, payload, Elements(payload)); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) | (cmd_len - 2); memcpy(&dw[1], payload, sizeof(payload)); } @@ -469,7 +469,7 @@ gen6_3DSTATE_CONSTANT_PS(struct ilo_builder *builder, { const uint8_t cmd_len = 5; uint32_t buf_dw[4], buf_enabled; - uint32_t dw0, *dw; + uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); assert(num_bufs <= 4); @@ -483,12 +483,11 @@ gen6_3DSTATE_CONSTANT_PS(struct ilo_builder *builder, buf_enabled = gen6_fill_3dstate_constant(builder->dev, bufs, sizes, num_bufs, 64, buf_dw, Elements(buf_dw)); - dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_PS) | - buf_enabled << 12 | - (cmd_len - 2); - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_PS) | + buf_enabled << 12 | + (cmd_len - 2); memcpy(&dw[1], buf_dw, sizeof(buf_dw)); } @@ -526,14 +525,12 @@ gen6_3DSTATE_MULTISAMPLE(struct ilo_builder *builder, bool pixel_location_center) { const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? 4 : 3; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_MULTISAMPLE) | - (cmd_len - 2); uint32_t dw1, dw2, dw3, *dw; ILO_DEV_ASSERT(builder->dev, 6, 7.5); - dw1 = (pixel_location_center) ? - GEN6_MULTISAMPLE_DW1_PIXLOC_CENTER : GEN6_MULTISAMPLE_DW1_PIXLOC_UL_CORNER; + dw1 = (pixel_location_center) ? GEN6_MULTISAMPLE_DW1_PIXLOC_CENTER : + GEN6_MULTISAMPLE_DW1_PIXLOC_UL_CORNER; switch (num_samples) { case 0: @@ -562,7 +559,8 @@ gen6_3DSTATE_MULTISAMPLE(struct ilo_builder *builder, } ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_MULTISAMPLE) | (cmd_len - 2); dw[1] = dw1; dw[2] = dw2; if (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) @@ -574,8 +572,6 @@ gen6_3DSTATE_SAMPLE_MASK(struct ilo_builder *builder, unsigned sample_mask) { const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK) | - (cmd_len - 2); const unsigned valid_mask = 0xf; uint32_t *dw; @@ -584,7 +580,8 @@ gen6_3DSTATE_SAMPLE_MASK(struct ilo_builder *builder, sample_mask &= valid_mask; ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK) | (cmd_len - 2); dw[1] = sample_mask; } @@ -595,8 +592,6 @@ gen7_3DSTATE_SAMPLE_MASK(struct ilo_builder *builder, { const uint8_t cmd_len = 2; const unsigned valid_mask = ((1 << num_samples) - 1) | 0x1; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK) | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); @@ -613,7 +608,8 @@ gen7_3DSTATE_SAMPLE_MASK(struct ilo_builder *builder, sample_mask &= valid_mask; ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK) | (cmd_len - 2); dw[1] = sample_mask; } @@ -623,11 +619,9 @@ gen6_3DSTATE_DRAWING_RECTANGLE(struct ilo_builder *builder, unsigned width, unsigned height) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_DRAWING_RECTANGLE) | - (cmd_len - 2); unsigned xmax = x + width - 1; unsigned ymax = y + height - 1; - int rect_limit; + unsigned rect_limit; uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 7.5); @@ -654,10 +648,9 @@ gen6_3DSTATE_DRAWING_RECTANGLE(struct ilo_builder *builder, ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_DRAWING_RECTANGLE) | (cmd_len - 2); dw[1] = y << 16 | x; dw[2] = ymax << 16 | xmax; - /* * There is no need to set the origin. It is intended to support front * buffer rendering. @@ -670,16 +663,16 @@ gen6_3DSTATE_POLY_STIPPLE_OFFSET(struct ilo_builder *builder, int x_offset, int y_offset) { const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_POLY_STIPPLE_OFFSET) | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 7.5); + assert(x_offset >= 0 && x_offset <= 31); assert(y_offset >= 0 && y_offset <= 31); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_POLY_STIPPLE_OFFSET) | (cmd_len - 2); dw[1] = x_offset << 8 | y_offset; } @@ -688,18 +681,17 @@ gen6_3DSTATE_POLY_STIPPLE_PATTERN(struct ilo_builder *builder, const struct pipe_poly_stipple *pattern) { const uint8_t cmd_len = 33; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_POLY_STIPPLE_PATTERN) | - (cmd_len - 2); uint32_t *dw; int i; ILO_DEV_ASSERT(builder->dev, 6, 7.5); - STATIC_ASSERT(Elements(pattern->stipple) == 32); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_POLY_STIPPLE_PATTERN) | (cmd_len - 2); dw++; + STATIC_ASSERT(Elements(pattern->stipple) == 32); for (i = 0; i < 32; i++) dw[i] = pattern->stipple[i]; } @@ -709,28 +701,32 @@ gen6_3DSTATE_LINE_STIPPLE(struct ilo_builder *builder, unsigned pattern, unsigned factor) { const uint8_t cmd_len = 3; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_LINE_STIPPLE) | - (cmd_len - 2); - uint32_t *dw; unsigned inverse; + uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 7.5); + assert((pattern & 0xffff) == pattern); assert(factor >= 1 && factor <= 256); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_LINE_STIPPLE) | (cmd_len - 2); dw[1] = pattern; if (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) { /* in U1.16 */ - inverse = (unsigned) (65536.0f / factor); - dw[2] = inverse << 15 | factor; + inverse = 65536 / factor; + + dw[2] = inverse << GEN7_LINE_STIPPLE_DW2_INVERSE_REPEAT_COUNT__SHIFT | + factor; } else { /* in U1.13 */ - inverse = (unsigned) (8192.0f / factor); - dw[2] = inverse << 16 | factor; + inverse = 8192 / factor; + + dw[2] = inverse << GEN6_LINE_STIPPLE_DW2_INVERSE_REPEAT_COUNT__SHIFT | + factor; } } @@ -738,36 +734,38 @@ static inline void gen6_3DSTATE_AA_LINE_PARAMETERS(struct ilo_builder *builder) { const uint8_t cmd_len = 3; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_AA_LINE_PARAMETERS) | - (cmd_len - 2); - uint32_t *dw; + const uint32_t dw[3] = { + GEN6_RENDER_CMD(3D, 3DSTATE_AA_LINE_PARAMETERS) | (cmd_len - 2), + 0 << GEN6_AA_LINE_DW1_BIAS__SHIFT | 0, + 0 << GEN6_AA_LINE_DW2_CAP_BIAS__SHIFT | 0, + }; ILO_DEV_ASSERT(builder->dev, 6, 7.5); - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; - dw[1] = 0 << 16 | 0; - dw[2] = 0 << 16 | 0; + ilo_builder_batch_write(builder, cmd_len, dw); } static inline void gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder, const struct ilo_zs_surface *zs) { + const uint32_t cmd = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? + GEN7_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER) : + GEN6_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER); const uint8_t cmd_len = 7; + uint32_t *dw; unsigned pos; - uint32_t dw0, *dw; ILO_DEV_ASSERT(builder->dev, 6, 7.5); - dw0 = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? - GEN7_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER) : - GEN6_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER); - dw0 |= (cmd_len - 2); - pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = cmd | (cmd_len - 2); dw[1] = zs->payload[0]; + dw[3] = zs->payload[2]; + dw[4] = zs->payload[3]; + dw[5] = zs->payload[4]; + dw[6] = zs->payload[5]; if (zs->bo) { ilo_builder_batch_reloc(builder, pos + 2, @@ -775,30 +773,24 @@ gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder, } else { dw[2] = 0; } - - dw[3] = zs->payload[2]; - dw[4] = zs->payload[3]; - dw[5] = zs->payload[4]; - dw[6] = zs->payload[5]; } static inline void gen6_3DSTATE_STENCIL_BUFFER(struct ilo_builder *builder, const struct ilo_zs_surface *zs) { + const uint32_t cmd = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? + GEN7_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER) : + GEN6_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER); const uint8_t cmd_len = 3; - uint32_t dw0, *dw; + uint32_t *dw; unsigned pos; ILO_DEV_ASSERT(builder->dev, 6, 7.5); - dw0 = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? - GEN7_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER) : - GEN6_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER); - dw0 |= (cmd_len - 2); - pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = cmd | (cmd_len - 2); /* see ilo_gpe_init_zs_surface() */ dw[1] = zs->payload[6]; @@ -814,19 +806,18 @@ static inline void gen6_3DSTATE_HIER_DEPTH_BUFFER(struct ilo_builder *builder, const struct ilo_zs_surface *zs) { + const uint32_t cmd = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? + GEN7_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER) : + GEN6_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER); const uint8_t cmd_len = 3; - uint32_t dw0, *dw; + uint32_t *dw; unsigned pos; ILO_DEV_ASSERT(builder->dev, 6, 7.5); - dw0 = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? - GEN7_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER) : - GEN6_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER); - dw0 |= (cmd_len - 2); - pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = cmd | (cmd_len - 2); /* see ilo_gpe_init_zs_surface() */ dw[1] = zs->payload[8]; @@ -843,15 +834,15 @@ gen6_3DSTATE_CLEAR_PARAMS(struct ilo_builder *builder, uint32_t clear_val) { const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) | - GEN6_CLEAR_PARAMS_DW0_VALID | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) | + GEN6_CLEAR_PARAMS_DW0_VALID | + (cmd_len - 2); dw[1] = clear_val; } @@ -860,16 +851,15 @@ gen7_3DSTATE_CLEAR_PARAMS(struct ilo_builder *builder, uint32_t clear_val) { const uint8_t cmd_len = 3; - const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) | (cmd_len - 2); dw[1] = clear_val; - dw[2] = 1; + dw[2] = GEN7_CLEAR_PARAMS_DW2_VALID; } static inline void @@ -879,17 +869,17 @@ gen6_3DSTATE_VIEWPORT_STATE_POINTERS(struct ilo_builder *builder, uint32_t cc_viewport) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_VIEWPORT_STATE_POINTERS) | - GEN6_PTR_VP_DW0_CLIP_CHANGED | - GEN6_PTR_VP_DW0_SF_CHANGED | - GEN6_PTR_VP_DW0_CC_CHANGED | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VIEWPORT_STATE_POINTERS) | + GEN6_PTR_VP_DW0_CLIP_CHANGED | + GEN6_PTR_VP_DW0_SF_CHANGED | + GEN6_PTR_VP_DW0_CC_CHANGED | + (cmd_len - 2); dw[1] = clip_viewport; dw[2] = sf_viewport; dw[3] = cc_viewport; @@ -900,14 +890,14 @@ gen6_3DSTATE_SCISSOR_STATE_POINTERS(struct ilo_builder *builder, uint32_t scissor_rect) { const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SCISSOR_STATE_POINTERS) | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 7.5); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SCISSOR_STATE_POINTERS) | + (cmd_len - 2); dw[1] = scissor_rect; } @@ -918,17 +908,16 @@ gen6_3DSTATE_CC_STATE_POINTERS(struct ilo_builder *builder, uint32_t color_calc_state) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CC_STATE_POINTERS) | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; - dw[1] = blend_state | 1; - dw[2] = depth_stencil_state | 1; - dw[3] = color_calc_state | 1; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CC_STATE_POINTERS) | (cmd_len - 2); + dw[1] = blend_state | GEN6_PTR_CC_DW1_BLEND_CHANGED; + dw[2] = depth_stencil_state | GEN6_PTR_CC_DW2_ZS_CHANGED; + dw[3] = color_calc_state | GEN6_PTR_CC_DW3_CC_CHANGED; } static inline void diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/ilo_builder_3d_top.h index 4e3dcff3c03..8bce317bc33 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_top.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_top.h @@ -43,7 +43,6 @@ gen6_3DSTATE_URB(struct ilo_builder *builder, int vs_entry_size, int gs_entry_size) { const uint8_t cmd_len = 3; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_URB) | (cmd_len - 2); const int row_size = 128; /* 1024 bits */ int vs_alloc_size, gs_alloc_size; int vs_num_entries, gs_num_entries; @@ -74,7 +73,8 @@ gen6_3DSTATE_URB(struct ilo_builder *builder, gs_num_entries = 256; ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_URB) | (cmd_len - 2); dw[1] = (vs_alloc_size - 1) << GEN6_URB_DW1_VS_ENTRY_SIZE__SHIFT | vs_num_entries << GEN6_URB_DW1_VS_ENTRY_COUNT__SHIFT; dw[2] = gs_num_entries << GEN6_URB_DW2_GS_ENTRY_COUNT__SHIFT | @@ -85,10 +85,10 @@ static inline void gen7_3dstate_push_constant_alloc(struct ilo_builder *builder, int subop, int offset, int size) { - const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER | + const uint32_t cmd = GEN6_RENDER_TYPE_RENDER | GEN6_RENDER_SUBTYPE_3D | - subop | (cmd_len - 2); + subop; + const uint8_t cmd_len = 2; uint32_t *dw; int end; @@ -137,7 +137,8 @@ gen7_3dstate_push_constant_alloc(struct ilo_builder *builder, } ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = cmd | (cmd_len - 2); dw[1] = offset << GEN7_PCB_ALLOC_ANY_DW1_OFFSET__SHIFT | size; } @@ -187,10 +188,10 @@ gen7_3dstate_urb(struct ilo_builder *builder, int subop, int offset, int size, int entry_size) { - const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER | + const uint32_t cmd = GEN6_RENDER_TYPE_RENDER | GEN6_RENDER_SUBTYPE_3D | - subop | (cmd_len - 2); + subop; + const uint8_t cmd_len = 2; const int row_size = 64; /* 512 bits */ int alloc_size, num_entries, min_entries, max_entries; uint32_t *dw; @@ -269,7 +270,8 @@ gen7_3dstate_urb(struct ilo_builder *builder, } ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = cmd | (cmd_len - 2); dw[1] = offset << GEN7_URB_ANY_DW1_OFFSET__SHIFT | (alloc_size - 1) << GEN7_URB_ANY_DW1_ENTRY_SIZE__SHIFT | num_entries; @@ -313,16 +315,16 @@ gen7_3DSTATE_VF(struct ilo_builder *builder, uint32_t cut_index) { const uint8_t cmd_len = 2; - uint32_t dw0 = GEN75_RENDER_CMD(3D, 3DSTATE_VF) | (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7.5, 7.5); + ilo_builder_batch_pointer(builder, cmd_len, &dw); + + dw[0] = GEN75_RENDER_CMD(3D, 3DSTATE_VF) | (cmd_len - 2); if (enable_cut_index) - dw0 |= GEN75_VF_DW0_CUT_INDEX_ENABLE; + dw[0] |= GEN75_VF_DW0_CUT_INDEX_ENABLE; - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; dw[1] = cut_index; } @@ -345,8 +347,8 @@ gen6_3DSTATE_VERTEX_BUFFERS(struct ilo_builder *builder, const struct ilo_vb_state *vb) { uint8_t cmd_len; - uint32_t dw0, *dw; - unsigned hw_idx, pos; + uint32_t *dw; + unsigned pos, hw_idx; ILO_DEV_ASSERT(builder->dev, 6, 7.5); @@ -361,14 +363,12 @@ gen6_3DSTATE_VERTEX_BUFFERS(struct ilo_builder *builder, return; cmd_len = 1 + 4 * ve->vb_count; - dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_BUFFERS) | - (cmd_len - 2); - pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_BUFFERS) | (cmd_len - 2); dw++; pos++; + for (hw_idx = 0; hw_idx < ve->vb_count; hw_idx++) { const unsigned instance_divisor = ve->instance_divisors[hw_idx]; const unsigned pipe_idx = ve->vb_mapping[hw_idx]; @@ -480,7 +480,7 @@ gen6_3DSTATE_VERTEX_ELEMENTS(struct ilo_builder *builder, bool prepend_generated_ids) { uint8_t cmd_len; - uint32_t dw0, *dw; + uint32_t *dw; unsigned i; ILO_DEV_ASSERT(builder->dev, 6, 7.5); @@ -505,22 +505,18 @@ gen6_3DSTATE_VERTEX_ELEMENTS(struct ilo_builder *builder, &dummy); cmd_len = 3; - dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) | - (cmd_len - 2); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) | (cmd_len - 2); memcpy(&dw[1], dummy.payload, sizeof(dummy.payload)); return; } cmd_len = 2 * (ve->count + prepend_generated_ids) + 1; - dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) | - (cmd_len - 2); - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) | (cmd_len - 2); dw++; if (prepend_generated_ids) { @@ -561,8 +557,8 @@ gen6_3DSTATE_INDEX_BUFFER(struct ilo_builder *builder, struct ilo_buffer *buf = ilo_buffer(ib->hw_resource); uint32_t start_offset, end_offset; int format; + uint32_t *dw; unsigned pos; - uint32_t dw0, *dw; ILO_DEV_ASSERT(builder->dev, 6, 7.5); @@ -600,14 +596,14 @@ gen6_3DSTATE_INDEX_BUFFER(struct ilo_builder *builder, end_offset -= (end_offset % ib->hw_index_size); end_offset--; - dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_INDEX_BUFFER) | - format | - (cmd_len - 2); + pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_INDEX_BUFFER) | + format | + (cmd_len - 2); if (enable_cut_index) - dw0 |= GEN6_IB_DW0_CUT_INDEX_ENABLE; + dw[0] |= GEN6_IB_DW0_CUT_INDEX_ENABLE; - pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; ilo_builder_batch_reloc(builder, pos + 1, buf->bo, start_offset, 0); ilo_builder_batch_reloc(builder, pos + 2, buf->bo, end_offset, 0); } @@ -658,7 +654,6 @@ gen7_3DSTATE_HS(struct ilo_builder *builder, int num_samplers) { const uint8_t cmd_len = 7; - const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_HS) | (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); @@ -666,7 +661,8 @@ gen7_3DSTATE_HS(struct ilo_builder *builder, assert(!hs); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_HS) | (cmd_len - 2); dw[1] = 0; dw[2] = 0; dw[3] = 0; @@ -679,13 +675,13 @@ static inline void gen7_3DSTATE_TE(struct ilo_builder *builder) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_TE) | (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_TE) | (cmd_len - 2); dw[1] = 0; dw[2] = 0; dw[3] = 0; @@ -697,7 +693,6 @@ gen7_3DSTATE_DS(struct ilo_builder *builder, int num_samplers) { const uint8_t cmd_len = 6; - const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_DS) | (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); @@ -705,7 +700,8 @@ gen7_3DSTATE_DS(struct ilo_builder *builder, assert(!ds); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_DS) | (cmd_len - 2); dw[1] = 0; dw[2] = 0; dw[3] = 0; @@ -720,7 +716,6 @@ gen6_3DSTATE_GS(struct ilo_builder *builder, int verts_per_prim) { const uint8_t cmd_len = 7; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_GS) | (cmd_len - 2); uint32_t dw1, dw2, dw4, dw5, dw6, *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); @@ -771,7 +766,8 @@ gen6_3DSTATE_GS(struct ilo_builder *builder, } ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_GS) | (cmd_len - 2); dw[1] = dw1; dw[2] = dw2; dw[3] = 0; @@ -787,20 +783,19 @@ gen6_3DSTATE_GS_SVB_INDEX(struct ilo_builder *builder, bool load_vertex_count) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_GS_SVB_INDEX) | - (cmd_len - 2); - uint32_t dw1, *dw; + uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); assert(index >= 0 && index < 4); - dw1 = index << GEN6_SVBI_DW1_INDEX__SHIFT; + ilo_builder_batch_pointer(builder, cmd_len, &dw); + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_GS_SVB_INDEX) | (cmd_len - 2); + + dw[1] = index << GEN6_SVBI_DW1_INDEX__SHIFT; if (load_vertex_count) - dw1 |= GEN6_SVBI_DW1_LOAD_INTERNAL_VERTEX_COUNT; + dw[1] |= GEN6_SVBI_DW1_LOAD_INTERNAL_VERTEX_COUNT; - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; - dw[1] = dw1; dw[2] = svbi; dw[3] = max_svbi; } @@ -837,6 +832,7 @@ gen7_3DSTATE_GS(struct ilo_builder *builder, dw2 |= ((num_samplers + 3) / 4) << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT; ilo_builder_batch_pointer(builder, cmd_len, &dw); + dw[0] = dw0; dw[1] = ilo_shader_get_kernel_offset(gs); dw[2] = dw2; @@ -901,6 +897,7 @@ gen7_3DSTATE_STREAMOUT(struct ilo_builder *builder, (read_len - 1) << GEN7_SO_DW2_STREAM0_READ_LEN__SHIFT; ilo_builder_batch_pointer(builder, cmd_len, &dw); + dw[0] = dw0; dw[1] = dw1; dw[2] = dw2; @@ -911,9 +908,9 @@ gen7_3DSTATE_SO_DECL_LIST(struct ilo_builder *builder, const struct pipe_stream_output_info *so_info) { uint16_t cmd_len; - uint32_t dw0, *dw; int buffer_selects, num_entries, i; uint16_t so_decls[128]; + uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); @@ -972,10 +969,10 @@ gen7_3DSTATE_SO_DECL_LIST(struct ilo_builder *builder, * of cmd_len is thus uint16_t. */ cmd_len = 2 * 128 + 3; - dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_SO_DECL_LIST) | (cmd_len - 2); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SO_DECL_LIST) | (cmd_len - 2); dw[1] = 0 << GEN7_SO_DECL_DW1_STREAM3_BUFFER_SELECTS__SHIFT | 0 << GEN7_SO_DECL_DW1_STREAM2_BUFFER_SELECTS__SHIFT | 0 << GEN7_SO_DECL_DW1_STREAM1_BUFFER_SELECTS__SHIFT | @@ -1008,8 +1005,8 @@ gen7_3DSTATE_SO_BUFFER(struct ilo_builder *builder, (cmd_len - 2); struct ilo_buffer *buf; int end; - unsigned pos; uint32_t *dw; + unsigned pos; ILO_DEV_ASSERT(builder->dev, 7, 7.5); @@ -1034,6 +1031,7 @@ gen7_3DSTATE_SO_BUFFER(struct ilo_builder *builder, end = (base + so_target->buffer_size) & ~3; pos = ilo_builder_batch_pointer(builder, cmd_len, &dw); + dw[0] = dw0; dw[1] = index << GEN7_SO_BUF_DW1_INDEX__SHIFT | stride; @@ -1051,17 +1049,17 @@ gen6_3DSTATE_BINDING_TABLE_POINTERS(struct ilo_builder *builder, uint32_t ps_binding_table) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_BINDING_TABLE_POINTERS) | - GEN6_PTR_BINDING_TABLE_DW0_VS_CHANGED | - GEN6_PTR_BINDING_TABLE_DW0_GS_CHANGED | - GEN6_PTR_BINDING_TABLE_DW0_PS_CHANGED | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_BINDING_TABLE_POINTERS) | + GEN6_PTR_BINDING_TABLE_DW0_VS_CHANGED | + GEN6_PTR_BINDING_TABLE_DW0_GS_CHANGED | + GEN6_PTR_BINDING_TABLE_DW0_PS_CHANGED | + (cmd_len - 2); dw[1] = vs_binding_table; dw[2] = gs_binding_table; dw[3] = ps_binding_table; @@ -1074,17 +1072,17 @@ gen6_3DSTATE_SAMPLER_STATE_POINTERS(struct ilo_builder *builder, uint32_t ps_sampler_state) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLER_STATE_POINTERS) | - GEN6_PTR_SAMPLER_DW0_VS_CHANGED | - GEN6_PTR_SAMPLER_DW0_GS_CHANGED | - GEN6_PTR_SAMPLER_DW0_PS_CHANGED | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLER_STATE_POINTERS) | + GEN6_PTR_SAMPLER_DW0_VS_CHANGED | + GEN6_PTR_SAMPLER_DW0_GS_CHANGED | + GEN6_PTR_SAMPLER_DW0_PS_CHANGED | + (cmd_len - 2); dw[1] = vs_sampler_state; dw[2] = gs_sampler_state; dw[3] = ps_sampler_state; @@ -1094,16 +1092,17 @@ static inline void gen7_3dstate_pointer(struct ilo_builder *builder, int subop, uint32_t pointer) { - const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER | + const uint32_t cmd = GEN6_RENDER_TYPE_RENDER | GEN6_RENDER_SUBTYPE_3D | - subop | (cmd_len - 2); + subop; + const uint8_t cmd_len = 2; uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = cmd | (cmd_len - 2); dw[1] = pointer; } @@ -1220,10 +1219,10 @@ gen6_3DSTATE_CONSTANT_VS(struct ilo_builder *builder, int num_bufs) { const uint8_t cmd_len = 5; - uint32_t buf_dw[4], buf_enabled; - uint32_t dw0, *dw; + uint32_t buf_dw[4], buf_enabled, *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); + assert(num_bufs <= 4); /* @@ -1235,12 +1234,11 @@ gen6_3DSTATE_CONSTANT_VS(struct ilo_builder *builder, buf_enabled = gen6_fill_3dstate_constant(builder->dev, bufs, sizes, num_bufs, 32, buf_dw, Elements(buf_dw)); - dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_VS) | - buf_enabled << 12 | - (cmd_len - 2); - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_VS) | + buf_enabled << 12 | + (cmd_len - 2); memcpy(&dw[1], buf_dw, sizeof(buf_dw)); } @@ -1250,10 +1248,10 @@ gen6_3DSTATE_CONSTANT_GS(struct ilo_builder *builder, int num_bufs) { const uint8_t cmd_len = 5; - uint32_t buf_dw[4], buf_enabled; - uint32_t dw0, *dw; + uint32_t buf_dw[4], buf_enabled, *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); + assert(num_bufs <= 4); /* @@ -1265,12 +1263,11 @@ gen6_3DSTATE_CONSTANT_GS(struct ilo_builder *builder, buf_enabled = gen6_fill_3dstate_constant(builder->dev, bufs, sizes, num_bufs, 64, buf_dw, Elements(buf_dw)); - dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_GS) | - buf_enabled << 12 | - (cmd_len - 2); - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_GS) | + buf_enabled << 12 | + (cmd_len - 2); memcpy(&dw[1], buf_dw, sizeof(buf_dw)); } @@ -1280,10 +1277,10 @@ gen7_3dstate_constant(struct ilo_builder *builder, const uint32_t *bufs, const int *sizes, int num_bufs) { - const uint8_t cmd_len = 7; - const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER | + const uint32_t cmd = GEN6_RENDER_TYPE_RENDER | GEN6_RENDER_SUBTYPE_3D | - subop | (cmd_len - 2); + subop; + const uint8_t cmd_len = 7; uint32_t payload[6], *dw; int total_read_length, i; @@ -1340,7 +1337,8 @@ gen7_3dstate_constant(struct ilo_builder *builder, assert(total_read_length <= 64); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = cmd | (cmd_len - 2); memcpy(&dw[1], payload, sizeof(payload)); } diff --git a/src/gallium/drivers/ilo/ilo_builder_media.h b/src/gallium/drivers/ilo/ilo_builder_media.h index 8b296331977..3a326318144 100644 --- a/src/gallium/drivers/ilo/ilo_builder_media.h +++ b/src/gallium/drivers/ilo/ilo_builder_media.h @@ -40,8 +40,6 @@ gen6_MEDIA_VFE_STATE(struct ilo_builder *builder, int urb_entry_size) { const uint8_t cmd_len = 8; - const uint32_t dw0 = GEN6_RENDER_CMD(MEDIA, MEDIA_VFE_STATE) | - (cmd_len - 2); uint32_t dw2, dw4, *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); @@ -55,7 +53,8 @@ gen6_MEDIA_VFE_STATE(struct ilo_builder *builder, 480; /* CURBE Allocation Size */ ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(MEDIA, MEDIA_VFE_STATE) | (cmd_len - 2); dw[1] = 0; /* scratch */ dw[2] = dw2; dw[3] = 0; /* MBZ */ @@ -70,8 +69,6 @@ gen6_MEDIA_CURBE_LOAD(struct ilo_builder *builder, uint32_t buf, int size) { const uint8_t cmd_len = 4; - const uint32_t dw0 = GEN6_RENDER_CMD(MEDIA, MEDIA_CURBE_LOAD) | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); @@ -81,7 +78,8 @@ gen6_MEDIA_CURBE_LOAD(struct ilo_builder *builder, size = align(size, 32); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(MEDIA, MEDIA_CURBE_LOAD) | (cmd_len - 2); dw[1] = 0; /* MBZ */ dw[2] = size; dw[3] = buf; @@ -92,8 +90,6 @@ gen6_MEDIA_INTERFACE_DESCRIPTOR_LOAD(struct ilo_builder *builder, uint32_t offset, int num_ids) { const uint8_t cmd_len = 4; - const uint32_t dw0 = - GEN6_RENDER_CMD(MEDIA, MEDIA_INTERFACE_DESCRIPTOR_LOAD) | (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); @@ -101,7 +97,9 @@ gen6_MEDIA_INTERFACE_DESCRIPTOR_LOAD(struct ilo_builder *builder, assert(offset % 32 == 0); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(MEDIA, MEDIA_INTERFACE_DESCRIPTOR_LOAD) | + (cmd_len - 2); dw[1] = 0; /* MBZ */ /* every ID has 8 DWords */ dw[2] = num_ids * 8 * 4; @@ -113,14 +111,13 @@ gen6_MEDIA_GATEWAY_STATE(struct ilo_builder *builder, int id, int byte, int thread_count) { const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_CMD(MEDIA, MEDIA_GATEWAY_STATE) | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(MEDIA, MEDIA_GATEWAY_STATE) | (cmd_len - 2); dw[1] = id << 16 | byte << 8 | thread_count; @@ -132,14 +129,13 @@ gen6_MEDIA_STATE_FLUSH(struct ilo_builder *builder, int barrier_mask) { const uint8_t cmd_len = 2; - const uint32_t dw0 = GEN6_RENDER_CMD(MEDIA, MEDIA_STATE_FLUSH) | - (cmd_len - 2); uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(MEDIA, MEDIA_STATE_FLUSH) | (cmd_len - 2); dw[1] = thread_count_water_mark << 16 | barrier_mask; }