diff options
author | Chia-I Wu <[email protected]> | 2015-06-15 11:24:47 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2015-06-15 15:06:11 +0800 |
commit | 94ab56367169ba2902e83aded409db2df3d25eb1 (patch) | |
tree | 311dce1b6dcc154649cfb6981b971847a337f367 /src/gallium/drivers/ilo/core | |
parent | 7cb853d52ae795b76adec41c98870166b41c9e6f (diff) |
ilo: add ilo_state_raster_{line,poly}_stipple
Initialize hardware stipple states on bound instead of on emission.
Diffstat (limited to 'src/gallium/drivers/ilo/core')
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_builder_3d_bottom.h | 44 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_state_raster.c | 80 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_state_raster.h | 26 |
3 files changed, 116 insertions, 34 deletions
diff --git a/src/gallium/drivers/ilo/core/ilo_builder_3d_bottom.h b/src/gallium/drivers/ilo/core/ilo_builder_3d_bottom.h index cc1ece3ed14..f7f95f493b7 100644 --- a/src/gallium/drivers/ilo/core/ilo_builder_3d_bottom.h +++ b/src/gallium/drivers/ilo/core/ilo_builder_3d_bottom.h @@ -33,7 +33,6 @@ #include "ilo_core.h" #include "ilo_dev.h" -#include "ilo_format.h" #include "ilo_state_cc.h" #include "ilo_state_raster.h" #include "ilo_state_sbe.h" @@ -576,74 +575,51 @@ gen6_3DSTATE_DRAWING_RECTANGLE(struct ilo_builder *builder, static inline void gen6_3DSTATE_POLY_STIPPLE_OFFSET(struct ilo_builder *builder, - int x_offset, int y_offset) + const struct ilo_state_poly_stipple *stipple) { const uint8_t cmd_len = 2; uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 8); - assert(x_offset >= 0 && x_offset <= 31); - assert(y_offset >= 0 && y_offset <= 31); - ilo_builder_batch_pointer(builder, cmd_len, &dw); dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_POLY_STIPPLE_OFFSET) | (cmd_len - 2); - dw[1] = x_offset << 8 | y_offset; + /* constant */ + dw[1] = 0; } static inline void gen6_3DSTATE_POLY_STIPPLE_PATTERN(struct ilo_builder *builder, - const struct pipe_poly_stipple *pattern) + const struct ilo_state_poly_stipple *stipple) { const uint8_t cmd_len = 33; uint32_t *dw; - int i; ILO_DEV_ASSERT(builder->dev, 6, 8); ilo_builder_batch_pointer(builder, cmd_len, &dw); 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]; + /* see poly_stipple_set_gen6_3DSTATE_POLY_STIPPLE_PATTERN() */ + memcpy(&dw[1], stipple->stipple, sizeof(stipple->stipple)); } static inline void gen6_3DSTATE_LINE_STIPPLE(struct ilo_builder *builder, - unsigned pattern, unsigned factor) + const struct ilo_state_line_stipple *stipple) { const uint8_t cmd_len = 3; - unsigned inverse; uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 8); - assert((pattern & 0xffff) == pattern); - assert(factor >= 1 && factor <= 256); - ilo_builder_batch_pointer(builder, cmd_len, &dw); 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 = 65536 / factor; - - dw[2] = inverse << GEN7_LINE_STIPPLE_DW2_INVERSE_REPEAT_COUNT__SHIFT | - factor; - } - else { - /* in U1.13 */ - inverse = 8192 / factor; - - dw[2] = inverse << GEN6_LINE_STIPPLE_DW2_INVERSE_REPEAT_COUNT__SHIFT | - factor; - } + /* see line_stipple_set_gen6_3DSTATE_LINE_STIPPLE() */ + dw[1] = stipple->stipple[0]; + dw[2] = stipple->stipple[1]; } static inline void diff --git a/src/gallium/drivers/ilo/core/ilo_state_raster.c b/src/gallium/drivers/ilo/core/ilo_state_raster.c index a93eaad154c..ed64a1f0d3c 100644 --- a/src/gallium/drivers/ilo/core/ilo_state_raster.c +++ b/src/gallium/drivers/ilo/core/ilo_state_raster.c @@ -900,6 +900,37 @@ sample_pattern_get_gen6_packed_offsets(const struct ilo_dev *dev, } static bool +line_stipple_set_gen6_3DSTATE_LINE_STIPPLE(struct ilo_state_line_stipple *stipple, + const struct ilo_dev *dev, + const struct ilo_state_line_stipple_info *info) +{ + uint32_t dw1, dw2; + + ILO_DEV_ASSERT(dev, 6, 8); + + assert(info->repeat_count >= 1 && info->repeat_count <= 256); + + dw1 = info->pattern; + if (ilo_dev_gen(dev) >= ILO_GEN(7)) { + /* in U1.16 */ + const uint32_t inverse = 65536 / info->repeat_count; + dw2 = inverse << GEN7_LINE_STIPPLE_DW2_INVERSE_REPEAT_COUNT__SHIFT | + info->repeat_count << GEN6_LINE_STIPPLE_DW2_REPEAT_COUNT__SHIFT; + } else { + /* in U1.13 */ + const uint16_t inverse = 8192 / info->repeat_count; + dw2 = inverse << GEN6_LINE_STIPPLE_DW2_INVERSE_REPEAT_COUNT__SHIFT | + info->repeat_count << GEN6_LINE_STIPPLE_DW2_REPEAT_COUNT__SHIFT; + } + + STATIC_ASSERT(ARRAY_SIZE(stipple->stipple) >= 2); + stipple->stipple[0] = dw1; + stipple->stipple[1] = dw2; + + return true; +} + +static bool sample_pattern_set_gen8_3DSTATE_SAMPLE_PATTERN(struct ilo_state_sample_pattern *pattern, const struct ilo_dev *dev, const struct ilo_state_sample_pattern_info *info) @@ -925,6 +956,19 @@ sample_pattern_set_gen8_3DSTATE_SAMPLE_PATTERN(struct ilo_state_sample_pattern * } +static bool +poly_stipple_set_gen6_3DSTATE_POLY_STIPPLE_PATTERN(struct ilo_state_poly_stipple *stipple, + const struct ilo_dev *dev, + const struct ilo_state_poly_stipple_info *info) +{ + ILO_DEV_ASSERT(dev, 6, 8); + + STATIC_ASSERT(ARRAY_SIZE(stipple->stipple) >= 32); + memcpy(stipple->stipple, info->pattern, sizeof(info->pattern)); + + return true; +} + bool ilo_state_raster_init(struct ilo_state_raster *rs, const struct ilo_dev *dev, @@ -1170,3 +1214,39 @@ ilo_state_sample_pattern_get_offset(const struct ilo_state_sample_pattern *patte *x = (packed[sample_index] >> 4) & 0xf; *y = packed[sample_index] & 0xf; } + +/** + * No need to initialize first. + */ +bool +ilo_state_line_stipple_set_info(struct ilo_state_line_stipple *stipple, + const struct ilo_dev *dev, + const struct ilo_state_line_stipple_info *info) +{ + bool ret = true; + + ret &= line_stipple_set_gen6_3DSTATE_LINE_STIPPLE(stipple, + dev, info); + + assert(ret); + + return ret; +} + +/** + * No need to initialize first. + */ +bool +ilo_state_poly_stipple_set_info(struct ilo_state_poly_stipple *stipple, + const struct ilo_dev *dev, + const struct ilo_state_poly_stipple_info *info) +{ + bool ret = true; + + ret &= poly_stipple_set_gen6_3DSTATE_POLY_STIPPLE_PATTERN(stipple, + dev, info); + + assert(ret); + + return ret; +} diff --git a/src/gallium/drivers/ilo/core/ilo_state_raster.h b/src/gallium/drivers/ilo/core/ilo_state_raster.h index e4697bc383f..fc90b49cfc3 100644 --- a/src/gallium/drivers/ilo/core/ilo_state_raster.h +++ b/src/gallium/drivers/ilo/core/ilo_state_raster.h @@ -219,6 +219,23 @@ struct ilo_state_sample_pattern { uint8_t pattern_16x[16]; }; +struct ilo_state_line_stipple_info { + uint16_t pattern; + uint16_t repeat_count; +}; + +struct ilo_state_line_stipple { + uint32_t stipple[2]; +}; + +struct ilo_state_poly_stipple_info { + uint32_t pattern[32]; +}; + +struct ilo_state_poly_stipple { + uint32_t stipple[32]; +}; + bool ilo_state_raster_init(struct ilo_state_raster *rs, const struct ilo_dev *dev, @@ -271,5 +288,14 @@ ilo_state_sample_pattern_get_offset(const struct ilo_state_sample_pattern *patte const struct ilo_dev *dev, uint8_t sample_count, uint8_t sample_index, uint8_t *x, uint8_t *y); +bool +ilo_state_line_stipple_set_info(struct ilo_state_line_stipple *stipple, + const struct ilo_dev *dev, + const struct ilo_state_line_stipple_info *info); + +bool +ilo_state_poly_stipple_set_info(struct ilo_state_poly_stipple *stipple, + const struct ilo_dev *dev, + const struct ilo_state_poly_stipple_info *info); #endif /* ILO_STATE_RASTER_H */ |