summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-08-19 00:21:34 -0700
committerKenneth Graunke <[email protected]>2019-02-21 10:26:08 -0800
commit93c1921ce2c0dcfebbf5c908886fb21c030ad01b (patch)
tree90f5f1a1fc412e36de0d9177e1e441f37edfc62e /src/gallium
parent5e30b1083bb7b0020cf1c7ed07deb474e48d896a (diff)
iris: proper cache tracking
this is copied from the i965 aux resolve stuff...minus the aux resolves
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/iris/iris_context.h6
-rw-r--r--src/gallium/drivers/iris/iris_draw.c20
-rw-r--r--src/gallium/drivers/iris/iris_resolve.c114
3 files changed, 123 insertions, 17 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h
index d540d3934ef..92e55173993 100644
--- a/src/gallium/drivers/iris/iris_context.h
+++ b/src/gallium/drivers/iris/iris_context.h
@@ -488,6 +488,12 @@ bool iris_blorp_upload_shader(struct blorp_batch *blorp_batch,
/* iris_resolve.c */
+void iris_predraw_resolve_inputs(struct iris_context *ice,
+ struct iris_batch *batch);
+void iris_predraw_resolve_framebuffer(struct iris_context *ice,
+ struct iris_batch *batch);
+void iris_postdraw_update_resolve_tracking(struct iris_context *ice,
+ struct iris_batch *batch);
void iris_cache_sets_clear(struct iris_batch *batch);
void iris_flush_depth_and_render_caches(struct iris_batch *batch);
void iris_cache_flush_for_read(struct iris_batch *batch, struct iris_bo *bo);
diff --git a/src/gallium/drivers/iris/iris_draw.c b/src/gallium/drivers/iris/iris_draw.c
index cecf6b181ca..20a3cce6657 100644
--- a/src/gallium/drivers/iris/iris_draw.c
+++ b/src/gallium/drivers/iris/iris_draw.c
@@ -51,22 +51,11 @@ iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
iris_batch_maybe_flush(batch, 1500);
- // XXX: actually do brw_cache_flush_for_*
- // XXX: CS stall is really expensive
- iris_emit_pipe_control_flush(batch,
- PIPE_CONTROL_DEPTH_CACHE_FLUSH |
- PIPE_CONTROL_RENDER_TARGET_FLUSH |
- PIPE_CONTROL_CS_STALL);
-
- iris_emit_pipe_control_flush(batch,
- PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
- PIPE_CONTROL_CONST_CACHE_INVALIDATE);
-
- iris_cache_sets_clear(batch);
- // XXX: ^^^
-
iris_update_compiled_shaders(ice);
+ iris_predraw_resolve_inputs(ice, batch);
+ iris_predraw_resolve_framebuffer(ice, batch);
+
if (iris_binder_is_empty(&batch->binder)) {
ice->state.dirty |= IRIS_DIRTY_BINDINGS_VS |
IRIS_DIRTY_BINDINGS_TCS |
@@ -81,6 +70,5 @@ iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
ice->state.dirty = 0ull;
- // XXX: don't flush always
- //iris_batch_flush(batch);
+ iris_postdraw_update_resolve_tracking(ice, batch);
}
diff --git a/src/gallium/drivers/iris/iris_resolve.c b/src/gallium/drivers/iris/iris_resolve.c
index 380456ed9c9..20b25c7b76b 100644
--- a/src/gallium/drivers/iris/iris_resolve.c
+++ b/src/gallium/drivers/iris/iris_resolve.c
@@ -31,9 +31,121 @@
* render-to-texture, format reinterpretation issues, and other situations.
*/
-#include "iris_context.h"
#include "util/hash_table.h"
#include "util/set.h"
+#include "iris_context.h"
+
+static void
+resolve_sampler_views(struct iris_batch *batch,
+ struct iris_shader_state *shs)
+{
+ for (int i = 0; i < shs->num_textures; i++) {
+ struct iris_sampler_view *isv = shs->textures[i];
+ if (!isv)
+ continue;
+
+ struct iris_resource *res = (void *) isv->base.texture;
+
+ // XXX: aux tracking
+ iris_cache_flush_for_read(batch, res->bo);
+ }
+}
+
+/**
+ * \brief Resolve buffers before drawing.
+ *
+ * Resolve the depth buffer's HiZ buffer, resolve the depth buffer of each
+ * enabled depth texture, and flush the render cache for any dirty textures.
+ */
+void
+iris_predraw_resolve_inputs(struct iris_context *ice,
+ struct iris_batch *batch)
+{
+ for (gl_shader_stage stage = 0; stage < MESA_SHADER_STAGES; stage++) {
+ struct iris_shader_state *shs = &ice->state.shaders[stage];
+ resolve_sampler_views(batch, shs);
+ }
+
+ // XXX: storage images
+}
+
+void
+iris_predraw_resolve_framebuffer(struct iris_context *ice,
+ struct iris_batch *batch)
+{
+ struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
+ struct pipe_surface *zs_surf = cso_fb->zsbuf;
+
+ if (zs_surf) {
+ // XXX: HiZ resolves
+ }
+
+ for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
+ struct iris_surface *surf = (void *) cso_fb->cbufs[i];
+ if (!surf)
+ continue;
+
+ struct iris_resource *res = (void *) surf->base.texture;
+
+ // XXX: aux tracking
+
+ iris_cache_flush_for_render(batch, res->bo, surf->view.format,
+ ISL_AUX_USAGE_NONE);
+ }
+}
+
+/**
+ * \brief Call this after drawing to mark which buffers need resolving
+ *
+ * If the depth buffer was written to and if it has an accompanying HiZ
+ * buffer, then mark that it needs a depth resolve.
+ *
+ * If the color buffer is a multisample window system buffer, then
+ * mark that it needs a downsample.
+ *
+ * Also mark any render targets which will be textured as needing a render
+ * cache flush.
+ */
+void
+iris_postdraw_update_resolve_tracking(struct iris_context *ice,
+ struct iris_batch *batch)
+{
+ struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
+ struct pipe_surface *zs_surf = cso_fb->zsbuf;
+
+ // XXX: front buffer drawing?
+
+ if (zs_surf) {
+ struct iris_resource *z_res, *s_res;
+ iris_get_depth_stencil_resources(zs_surf->texture, &z_res, &s_res);
+
+ if (z_res) {
+ // XXX: aux tracking
+
+ if (ice->state.depth_writes_enabled)
+ iris_depth_cache_add_bo(batch, z_res->bo);
+ }
+
+ if (s_res) {
+ // XXX: aux tracking
+
+ if (ice->state.stencil_writes_enabled)
+ iris_depth_cache_add_bo(batch, z_res->bo);
+ }
+ }
+
+ for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
+ struct iris_surface *surf = (void *) cso_fb->cbufs[i];
+ if (!surf)
+ continue;
+
+ struct iris_resource *res = (void *) surf->base.texture;
+
+ // XXX: aux tracking
+ iris_render_cache_add_bo(batch, res->bo, surf->view.format,
+ ISL_AUX_USAGE_NONE);
+ }
+}
/**
* Clear the cache-tracking sets.