Initialize hardware stipple states on bound instead of on emission.
#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"
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
}
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)
}
+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,
*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;
+}
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,
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 */
if (ilo_dev_gen(r->dev) == ILO_GEN(6))
gen6_wa_pre_non_pipelined(r);
- gen6_3DSTATE_POLY_STIPPLE_PATTERN(r->builder,
- &vec->poly_stipple);
-
- gen6_3DSTATE_POLY_STIPPLE_OFFSET(r->builder, 0, 0);
+ gen6_3DSTATE_POLY_STIPPLE_PATTERN(r->builder, &vec->poly_stipple);
+ gen6_3DSTATE_POLY_STIPPLE_OFFSET(r->builder, &vec->poly_stipple);
}
/* 3DSTATE_LINE_STIPPLE */
if (ilo_dev_gen(r->dev) == ILO_GEN(6))
gen6_wa_pre_non_pipelined(r);
- gen6_3DSTATE_LINE_STIPPLE(r->builder,
- vec->rasterizer->state.line_stipple_pattern,
- vec->rasterizer->state.line_stipple_factor + 1);
+ gen6_3DSTATE_LINE_STIPPLE(r->builder, &vec->line_stipple);
}
/* 3DSTATE_AA_LINE_PARAMETERS */
static void
ilo_bind_rasterizer_state(struct pipe_context *pipe, void *state)
{
+ const struct ilo_dev *dev = ilo_context(pipe)->dev;
struct ilo_state_vector *vec = &ilo_context(pipe)->state_vector;
vec->rasterizer = state;
+ if (vec->rasterizer) {
+ struct ilo_state_line_stipple_info info;
+
+ info.pattern = vec->rasterizer->state.line_stipple_pattern;
+ info.repeat_count = vec->rasterizer->state.line_stipple_factor + 1;
+
+ ilo_state_line_stipple_set_info(&vec->line_stipple, dev, &info);
+ }
+
vec->dirty |= ILO_DIRTY_RASTERIZER;
}
ilo_set_polygon_stipple(struct pipe_context *pipe,
const struct pipe_poly_stipple *state)
{
+ const struct ilo_dev *dev = ilo_context(pipe)->dev;
struct ilo_state_vector *vec = &ilo_context(pipe)->state_vector;
+ struct ilo_state_poly_stipple_info info;
+ int i;
+
+ for (i = 0; i < 32; i++)
+ info.pattern[i] = state->stipple[i];
- vec->poly_stipple = *state;
+ ilo_state_poly_stipple_set_info(&vec->poly_stipple, dev, &info);
vec->dirty |= ILO_DIRTY_POLY_STIPPLE;
}
struct ilo_rasterizer_state *rasterizer;
- struct pipe_poly_stipple poly_stipple;
+ struct ilo_state_line_stipple line_stipple;
+ struct ilo_state_poly_stipple poly_stipple;
unsigned sample_mask;
struct ilo_shader_state *fs;