iris: fix viewport counts and settings
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 20 Jun 2018 22:45:48 +0000 (15:45 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:07 +0000 (10:26 -0800)
seeing

   set_viewport_state 0 1
   set_viewport_state 1 15

which gives us a total of 16 viewports, updated incrementally
so keep old values around and update them...

src/gallium/drivers/iris/iris_state.c

index 9496162ebcc11b9087fa9b8048cf6e13e7cd88db..794e46fc80585ecaa4bf70d6e3ccc52c44079ebe 100644 (file)
@@ -1227,16 +1227,15 @@ calculate_guardband_size(uint32_t fb_width, uint32_t fb_height,
 static void
 iris_set_viewport_states(struct pipe_context *ctx,
                          unsigned start_slot,
-                         unsigned num_viewports,
+                         unsigned count,
                          const struct pipe_viewport_state *state)
 {
    struct iris_context *ice = (struct iris_context *) ctx;
-   struct iris_viewport_state *cso =
-      malloc(sizeof(struct iris_viewport_state));
+   struct iris_viewport_state *cso = ice->state.cso_vp;
    uint32_t *vp_map = &cso->sf_cl_vp[start_slot];
 
    // XXX: sf_cl_vp is only big enough for one slot, we don't iterate right
-   for (unsigned i = 0; i < num_viewports; i++) {
+   for (unsigned i = start_slot; i < count; i++) {
       iris_pack_state(GENX(SF_CLIP_VIEWPORT), vp_map, vp) {
          vp.ViewportMatrixElementm00 = state[i].scale[0];
          vp.ViewportMatrixElementm11 = state[i].scale[1];
@@ -1260,8 +1259,7 @@ iris_set_viewport_states(struct pipe_context *ctx,
       vp_map += GENX(SF_CLIP_VIEWPORT_length);
    }
 
-   free(ice->state.cso_vp);
-   ice->state.cso_vp = cso;
+   unsigned num_viewports = start_slot + count;
 
    if (num_viewports != ice->state.num_viewports) {
       ice->state.num_viewports = num_viewports;
@@ -3354,6 +3352,7 @@ genX(init_state)(struct iris_context *ice)
 
    ice->state.dirty = ~0ull;
 
+   ice->state.cso_vp = calloc(1, sizeof(struct iris_viewport_state));
    ice->state.cso_vertex_buffers =
       calloc(1, sizeof(struct iris_vertex_buffer_state));
 }