From d223b316ad7feb2a29a2772392527013f3173b9a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 16 Jul 2018 16:21:22 -0700 Subject: [PATCH] iris: NOS mechanics --- src/gallium/drivers/iris/iris_context.h | 17 +++++++++++++++++ src/gallium/drivers/iris/iris_program.c | 10 ++++++++++ src/gallium/drivers/iris/iris_state.c | 5 +++++ 3 files changed, 32 insertions(+) diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 6ea3706fdef..6bcfd1ca99a 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -97,6 +97,22 @@ struct blorp_params; #define IRIS_DIRTY_SO_DECL_LIST (1ull << 49) #define IRIS_DIRTY_STREAMOUT (1ull << 50) +/** + * Non-orthogonal state (NOS) dependency flags. + * + * Shader programs may depend on non-orthogonal state. These flags are + * used to indicate that a shader's key depends on the state provided by + * a certain Gallium CSO. + */ +enum iris_nos_dep { + IRIS_NOS_FRAMEBUFFER, + IRIS_NOS_DEPTH_STENCIL_ALPHA, + IRIS_NOS_RASTERIZER, + IRIS_NOS_BLEND, + + IRIS_NOS_COUNT, +}; + struct iris_depth_stencil_alpha_state; enum iris_program_cache_id { @@ -264,6 +280,7 @@ struct iris_context { struct { uint64_t dirty; + uint64_t dirty_for_nos[IRIS_NOS_COUNT]; unsigned num_viewports; unsigned sample_mask; struct iris_blend_state *cso_blend; diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 3d3b80bf5fb..36b15cee395 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -42,6 +42,9 @@ get_new_program_id(struct iris_screen *screen) struct iris_uncompiled_shader { struct pipe_shader_state base; unsigned program_id; + + /** Bitfield of (1 << IRIS_NOS_*) flags. */ + unsigned nos; }; // XXX: need unify_interfaces() at link time... @@ -91,6 +94,13 @@ bind_state(struct iris_context *ice, ice->shaders.uncompiled[stage] = ish; ice->state.dirty |= dirty_bit; + + for (int i = 0; i < IRIS_NOS_COUNT; i++) { + if (ish->nos & (1 << i)) + ice->state.dirty_for_nos[i] |= dirty_bit; + else + ice->state.dirty_for_nos[i] &= ~dirty_bit; + } } static void diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 59562a49fed..1b7abc9f82e 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -532,6 +532,7 @@ iris_bind_blend_state(struct pipe_context *ctx, void *state) ice->state.cso_blend = state; ice->state.dirty |= IRIS_DIRTY_PS_BLEND; ice->state.dirty |= IRIS_DIRTY_BLEND_STATE; + ice->state.dirty |= ice->state.dirty_for_nos[IRIS_NOS_BLEND]; } struct iris_depth_stencil_alpha_state { @@ -603,6 +604,7 @@ iris_bind_zsa_state(struct pipe_context *ctx, void *state) ice->state.cso_zsa = new_cso; ice->state.dirty |= IRIS_DIRTY_CC_VIEWPORT; ice->state.dirty |= IRIS_DIRTY_WM_DEPTH_STENCIL; + ice->state.dirty |= ice->state.dirty_for_nos[IRIS_NOS_DEPTH_STENCIL_ALPHA]; } struct iris_rasterizer_state { @@ -784,6 +786,7 @@ iris_bind_rasterizer_state(struct pipe_context *ctx, void *state) ice->state.cso_rast = new_cso; ice->state.dirty |= IRIS_DIRTY_RASTER; ice->state.dirty |= IRIS_DIRTY_CLIP; + ice->state.dirty |= ice->state.dirty_for_nos[IRIS_NOS_RASTERIZER]; } static uint32_t @@ -1410,6 +1413,8 @@ iris_set_framebuffer_state(struct pipe_context *ctx, /* Render target change */ ice->state.dirty |= IRIS_DIRTY_BINDINGS_FS; + + ice->state.dirty |= ice->state.dirty_for_nos[IRIS_NOS_FRAMEBUFFER]; } static void -- 2.30.2