summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-06-06 14:37:38 -0700
committerKenneth Graunke <[email protected]>2019-02-21 10:26:06 -0800
commit90046b43cced1468e04830db0f1cbc0b54b03731 (patch)
tree260b08af4ec8571fad46af1e210445a9e1379711
parent4e007dbb3097e965b736f35ccfdd00ebf025423b (diff)
iris: make surface states for cbufs
-rw-r--r--src/gallium/drivers/iris/iris_context.h7
-rw-r--r--src/gallium/drivers/iris/iris_state.c33
2 files changed, 35 insertions, 5 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h
index bf0724b9a6a..e5b25fdec4e 100644
--- a/src/gallium/drivers/iris/iris_context.h
+++ b/src/gallium/drivers/iris/iris_context.h
@@ -170,8 +170,13 @@ struct iris_compiled_shader {
};
struct iris_const_buffer {
- struct pipe_resource *res;
+ /** The resource and offset for the actual constant data */
+ struct pipe_resource *resource;
unsigned offset;
+
+ /** The resource and offset for the SURFACE_STATE for pull access. */
+ struct pipe_resource *surface_state_resource;
+ unsigned surface_state_offset;
};
struct iris_shader_state {
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 3e81cd95842..a993739690b 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -1343,6 +1343,7 @@ iris_set_constant_buffer(struct pipe_context *ctx,
const struct pipe_constant_buffer *input)
{
struct iris_context *ice = (struct iris_context *) ctx;
+ struct iris_screen *screen = (struct iris_screen *)ctx->screen;
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];
@@ -1350,12 +1351,36 @@ iris_set_constant_buffer(struct pipe_context *ctx,
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, &cbuf->offset, &cbuf->res);
+ input->user_buffer, &cbuf->offset, &cbuf->resource);
} else {
- pipe_resource_reference(&cbuf->res, input->buffer);
+ pipe_resource_reference(&cbuf->resource, input->buffer);
+ }
+
+ void *map = NULL;
+ // XXX: these are not retained forever, use a separate uploader?
+ u_upload_alloc(ice->state.surface_uploader, 0,
+ 4 * GENX(RENDER_SURFACE_STATE_length), 64,
+ &cbuf->surface_state_offset,
+ &cbuf->surface_state_resource,
+ &map);
+ if (!unlikely(map)) {
+ pipe_resource_reference(&cbuf->resource, NULL);
+ return;
}
+
+ struct iris_resource *res = (void *) cbuf->resource;
+ struct iris_bo *surf_bo = iris_resource_bo(cbuf->surface_state_resource);
+ cbuf->surface_state_offset += iris_bo_offset_from_base_address(surf_bo);
+
+ isl_buffer_fill_state(&screen->isl_dev, map,
+ .address = res->bo->gtt_offset,
+ .size_B = input->buffer_size,
+ .format = ISL_FORMAT_R32G32B32A32_FLOAT,
+ .stride_B = 1,
+ .mocs = MOCS_WB)
} else {
- pipe_resource_reference(&cbuf->res, NULL);
+ pipe_resource_reference(&cbuf->resource, NULL);
+ pipe_resource_reference(&cbuf->surface_state_resource, NULL);
}
}
@@ -2261,7 +2286,7 @@ iris_upload_render_state(struct iris_context *ice,
// XXX: is range->block a constbuf index? it would be nice
struct iris_const_buffer *cbuf = &shs->constbuf[range->block];
- struct iris_resource *res = (void *) cbuf->res;
+ struct iris_resource *res = (void *) cbuf->resource;
assert(cbuf->offset % 32 == 0);