ilo: construct SCISSOR_RECT in set_scissor_states()
This allows us to memcpy() the state in draw_vbo(). Add ilo_init_states() and ilo_cleanup_states() that are called when contexts are created and destroyed respectively, and properly set the initial scissor state in ilo_init_states().
This commit is contained in:
@@ -839,7 +839,7 @@ gen6_pipeline_state_scissors(struct ilo_3d_pipeline *p,
|
||||
if (DIRTY(SCISSOR) || DIRTY(VIEWPORT)) {
|
||||
/* there should be as many scissors as there are viewports */
|
||||
p->state.SCISSOR_RECT = p->gen6_SCISSOR_RECT(p->dev,
|
||||
ilo->scissor.states, ilo->viewport.count, p->cp);
|
||||
&ilo->scissor, ilo->viewport.count, p->cp);
|
||||
|
||||
session->scissor_state_changed = true;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ ilo_context_destroy(struct pipe_context *pipe)
|
||||
{
|
||||
struct ilo_context *ilo = ilo_context(pipe);
|
||||
|
||||
ilo_cleanup_states(ilo);
|
||||
|
||||
if (ilo->last_cp_bo)
|
||||
ilo->last_cp_bo->unreference(ilo->last_cp_bo);
|
||||
|
||||
@@ -148,6 +150,8 @@ ilo_context_create(struct pipe_screen *screen, void *priv)
|
||||
ilo_init_video_functions(ilo);
|
||||
ilo_init_gpgpu_functions(ilo);
|
||||
|
||||
ilo_init_states(ilo);
|
||||
|
||||
/* this must be called last as u_blitter is a client of the pipe context */
|
||||
ilo->blitter = util_blitter_create(&ilo->base);
|
||||
if (!ilo->blitter) {
|
||||
|
||||
@@ -95,7 +95,8 @@ struct ilo_viewport_state {
|
||||
};
|
||||
|
||||
struct ilo_scissor_state {
|
||||
struct pipe_scissor_state states[ILO_MAX_VIEWPORTS];
|
||||
/* SCISSOR_RECT */
|
||||
uint32_t payload[ILO_MAX_VIEWPORTS * 2];
|
||||
};
|
||||
|
||||
struct ilo_rasterizer_state {
|
||||
@@ -163,4 +164,15 @@ ilo_gpe_set_viewport_cso(const struct ilo_dev_info *dev,
|
||||
const struct pipe_viewport_state *state,
|
||||
struct ilo_viewport_cso *vp);
|
||||
|
||||
void
|
||||
ilo_gpe_set_scissor(const struct ilo_dev_info *dev,
|
||||
unsigned start_slot,
|
||||
unsigned num_states,
|
||||
const struct pipe_scissor_state *states,
|
||||
struct ilo_scissor_state *scissor);
|
||||
|
||||
void
|
||||
ilo_gpe_set_scissor_null(const struct ilo_dev_info *dev,
|
||||
struct ilo_scissor_state *scissor);
|
||||
|
||||
#endif /* ILO_GPE_H */
|
||||
|
||||
@@ -3502,16 +3502,63 @@ gen6_emit_DEPTH_STENCIL_STATE(const struct ilo_dev_info *dev,
|
||||
return state_offset;
|
||||
}
|
||||
|
||||
void
|
||||
ilo_gpe_set_scissor(const struct ilo_dev_info *dev,
|
||||
unsigned start_slot,
|
||||
unsigned num_states,
|
||||
const struct pipe_scissor_state *states,
|
||||
struct ilo_scissor_state *scissor)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
ILO_GPE_VALID_GEN(dev, 6, 7);
|
||||
|
||||
for (i = 0; i < num_states; i++) {
|
||||
uint16_t min_x, min_y, max_x, max_y;
|
||||
|
||||
/* both max and min are inclusive in SCISSOR_RECT */
|
||||
if (states[i].minx < states[i].maxx &&
|
||||
states[i].miny < states[i].maxy) {
|
||||
min_x = states[i].minx;
|
||||
min_y = states[i].miny;
|
||||
max_x = states[i].maxx - 1;
|
||||
max_y = states[i].maxy - 1;
|
||||
}
|
||||
else {
|
||||
/* we have to make min greater than max */
|
||||
min_x = 1;
|
||||
min_y = 1;
|
||||
max_x = 0;
|
||||
max_y = 0;
|
||||
}
|
||||
|
||||
scissor->payload[start_slot * 2 + 0] = min_y << 16 | min_x;
|
||||
scissor->payload[start_slot * 2 + 1] = max_y << 16 | max_x;
|
||||
start_slot++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ilo_gpe_set_scissor_null(const struct ilo_dev_info *dev,
|
||||
struct ilo_scissor_state *scissor)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < Elements(scissor->payload); i += 2) {
|
||||
scissor->payload[i + 0] = 1 << 16 | 1;
|
||||
scissor->payload[i + 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
gen6_emit_SCISSOR_RECT(const struct ilo_dev_info *dev,
|
||||
const struct pipe_scissor_state *scissors,
|
||||
int num_scissors,
|
||||
const struct ilo_scissor_state *scissor,
|
||||
unsigned num_viewports,
|
||||
struct ilo_cp *cp)
|
||||
{
|
||||
const int state_align = 32 / 4;
|
||||
const int state_len = 2 * num_scissors;
|
||||
const int state_len = 2 * num_viewports;
|
||||
uint32_t state_offset, *dw;
|
||||
int i;
|
||||
|
||||
ILO_GPE_VALID_GEN(dev, 6, 7);
|
||||
|
||||
@@ -3521,25 +3568,12 @@ gen6_emit_SCISSOR_RECT(const struct ilo_dev_info *dev,
|
||||
* "The viewport-specific state used by the SF unit (SCISSOR_RECT) is
|
||||
* stored as an array of up to 16 elements..."
|
||||
*/
|
||||
assert(num_scissors && num_scissors <= 16);
|
||||
assert(num_viewports && num_viewports <= 16);
|
||||
|
||||
dw = ilo_cp_steal_ptr(cp, "SCISSOR_RECT",
|
||||
state_len, state_align, &state_offset);
|
||||
|
||||
for (i = 0; i < num_scissors; i++) {
|
||||
if (scissors[i].minx < scissors[i].maxx &&
|
||||
scissors[i].miny < scissors[i].maxy) {
|
||||
dw[0] = scissors[i].miny << 16 | scissors[i].minx;
|
||||
dw[1] = (scissors[i].maxy - 1) << 16 | (scissors[i].maxx - 1);
|
||||
}
|
||||
else {
|
||||
/* we have to make min greater than max as they are both inclusive */
|
||||
dw[0] = 1 << 16 | 1;
|
||||
dw[1] = 0;
|
||||
}
|
||||
|
||||
dw += 2;
|
||||
}
|
||||
memcpy(dw, scissor->payload, state_len * 4);
|
||||
|
||||
return state_offset;
|
||||
}
|
||||
|
||||
@@ -414,8 +414,8 @@ typedef uint32_t
|
||||
|
||||
typedef uint32_t
|
||||
(*ilo_gpe_gen6_SCISSOR_RECT)(const struct ilo_dev_info *dev,
|
||||
const struct pipe_scissor_state *scissors,
|
||||
int num_scissors,
|
||||
const struct ilo_scissor_state *scissor,
|
||||
unsigned num_viewports,
|
||||
struct ilo_cp *cp);
|
||||
|
||||
typedef uint32_t
|
||||
|
||||
@@ -581,10 +581,9 @@ ilo_set_scissor_states(struct pipe_context *pipe,
|
||||
const struct pipe_scissor_state *scissors)
|
||||
{
|
||||
struct ilo_context *ilo = ilo_context(pipe);
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < num_scissors; i++)
|
||||
ilo->scissor.states[start_slot + i] = scissors[i];
|
||||
ilo_gpe_set_scissor(ilo->dev, start_slot, num_scissors,
|
||||
scissors, &ilo->scissor);
|
||||
|
||||
ilo->dirty |= ILO_DIRTY_SCISSOR;
|
||||
}
|
||||
@@ -1056,3 +1055,14 @@ ilo_init_state_functions(struct ilo_context *ilo)
|
||||
ilo->base.set_compute_resources = ilo_set_compute_resources;
|
||||
ilo->base.set_global_binding = ilo_set_global_binding;
|
||||
}
|
||||
|
||||
void
|
||||
ilo_init_states(struct ilo_context *ilo)
|
||||
{
|
||||
ilo_gpe_set_scissor_null(ilo->dev, &ilo->scissor);
|
||||
}
|
||||
|
||||
void
|
||||
ilo_cleanup_states(struct ilo_context *ilo)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -118,6 +118,12 @@ struct ilo_context;
|
||||
void
|
||||
ilo_init_state_functions(struct ilo_context *ilo);
|
||||
|
||||
void
|
||||
ilo_init_states(struct ilo_context *ilo);
|
||||
|
||||
void
|
||||
ilo_cleanup_states(struct ilo_context *ilo);
|
||||
|
||||
void
|
||||
ilo_finalize_states(struct ilo_context *ilo);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user