iris: have more than one const_offset
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 6 Jun 2018 21:14:31 +0000 (14:14 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:06 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_state.c

index 90230e8705af0c71b9cf2a2ee84bb883b786007d..bf0724b9a6a0d68c1e3cfdde9c7abe6d19e553b8 100644 (file)
@@ -169,10 +169,13 @@ struct iris_compiled_shader {
    uint8_t derived_data[0];
 };
 
+struct iris_const_buffer {
+   struct pipe_resource *res;
+   unsigned offset;
+};
+
 struct iris_shader_state {
-   struct pipe_constant_buffer constbuf[PIPE_MAX_CONSTANT_BUFFERS];
-   struct pipe_resource *const_resources[PIPE_MAX_CONSTANT_BUFFERS];
-   unsigned const_offset;
+   struct iris_const_buffer constbuf[PIPE_MAX_CONSTANT_BUFFERS];
 };
 
 struct iris_vtable {
index e0000c1988796f463d357683e313488845a1f8b6..3e81cd958422b03e232b59428c1284185152e409 100644 (file)
@@ -1345,17 +1345,17 @@ iris_set_constant_buffer(struct pipe_context *ctx,
    struct iris_context *ice = (struct iris_context *) ctx;
    gl_shader_stage stage = stage_from_pipe(p_stage);
    struct iris_shader_state *shs = &ice->shaders.state[stage];
+   struct iris_const_buffer *cbuf = &shs->constbuf[index];
 
    if (input && (input->buffer || input->user_buffer)) {
       if (input->user_buffer) {
          u_upload_data(ctx->const_uploader, 0, input->buffer_size, 32,
-                       input->user_buffer, &shs->const_offset,
-                       &shs->const_resources[index]);
+                       input->user_buffer, &cbuf->offset, &cbuf->res);
       } else {
-         pipe_resource_reference(&shs->const_resources[index], input->buffer);
+         pipe_resource_reference(&cbuf->res, input->buffer);
       }
    } else {
-      pipe_resource_reference(&shs->const_resources[index], NULL);
+      pipe_resource_reference(&cbuf->res, NULL);
    }
 }
 
@@ -2260,14 +2260,14 @@ iris_upload_render_state(struct iris_context *ice,
                   continue;
 
                // XXX: is range->block a constbuf index?  it would be nice
-               struct iris_resource *res =
-                  (void *) shs->const_resources[range->block];
+               struct iris_const_buffer *cbuf = &shs->constbuf[range->block];
+               struct iris_resource *res = (void *) cbuf->res;
 
-               assert(shs->const_offset % 32 == 0);
+               assert(cbuf->offset % 32 == 0);
 
                pkt.ConstantBody.ReadLength[n] = range->length;
                pkt.ConstantBody.Buffer[n] =
-                  ro_bo(res->bo, range->start * 32 + shs->const_offset);
+                  ro_bo(res->bo, range->start * 32 + cbuf->offset);
                n--;
             }
          }