iris: bindings dirty tracking

This commit is contained in:
Kenneth Graunke 2018-06-15 12:33:58 -07:00
parent bbc6d15b59
commit ccf37c7da9
5 changed files with 39 additions and 8 deletions

View File

@ -90,13 +90,22 @@ iris_binder_reserve_3d(struct iris_batch *batch,
}
}
/* Avoid using offset 0, tools consider it NULL */
#define INIT_INSERT_POINT 64
void
iris_init_binder(struct iris_binder *binder, struct iris_bufmgr *bufmgr)
{
binder->bo =
iris_bo_alloc(bufmgr, "binder", BINDER_SIZE, IRIS_MEMZONE_BINDER);
binder->map = iris_bo_map(NULL, binder->bo, MAP_WRITE);
binder->insert_point = 64; // XXX: avoid null pointer, it confuses tools
binder->insert_point = INIT_INSERT_POINT;
}
bool
iris_binder_is_empty(struct iris_binder *binder)
{
return binder->insert_point <= INIT_INSERT_POINT;
}
void

View File

@ -49,6 +49,7 @@ struct iris_binder
};
void iris_init_binder(struct iris_binder *binder, struct iris_bufmgr *bufmgr);
bool iris_binder_is_empty(struct iris_binder *binder);
void iris_destroy_binder(struct iris_binder *binder);
uint32_t iris_binder_reserve(struct iris_batch *batch, unsigned size);
void iris_binder_reserve_3d(struct iris_batch *batch,

View File

@ -86,6 +86,12 @@ struct blorp_params;
#define IRIS_DIRTY_CONSTANTS_FS (1ull << 39)
#define IRIS_DIRTY_DEPTH_BUFFER (1ull << 40)
#define IRIS_DIRTY_WM (1ull << 41)
#define IRIS_DIRTY_BINDINGS_VS (1ull << 42)
#define IRIS_DIRTY_BINDINGS_TCS (1ull << 43)
#define IRIS_DIRTY_BINDINGS_TES (1ull << 44)
#define IRIS_DIRTY_BINDINGS_GS (1ull << 45)
#define IRIS_DIRTY_BINDINGS_FS (1ull << 46)
#define IRIS_DIRTY_BINDINGS_CS (1ull << 47)
struct iris_depth_stencil_alpha_state;

View File

@ -54,6 +54,15 @@ iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
// XXX: ^^^
iris_update_compiled_shaders(ice);
if (iris_binder_is_empty(&batch->binder)) {
ice->state.dirty |= IRIS_DIRTY_BINDINGS_VS |
IRIS_DIRTY_BINDINGS_TCS |
IRIS_DIRTY_BINDINGS_TES |
IRIS_DIRTY_BINDINGS_GS |
IRIS_DIRTY_BINDINGS_FS;
}
iris_binder_reserve_3d(batch, ice->shaders.prog);
ice->vtbl.upload_render_state(ice, batch, info);

View File

@ -984,8 +984,6 @@ struct iris_surface {
/** The resource (BO) holding our SURFACE_STATE. */
struct pipe_resource *surface_state_resource;
unsigned surface_state_offset;
// uint32_t surface_state[GENX(RENDER_SURFACE_STATE_length)];
};
static struct pipe_surface *
@ -1079,7 +1077,7 @@ iris_set_sampler_views(struct pipe_context *ctx,
ice->state.num_textures[stage] = count;
// XXX: ice->state.dirty |= (IRIS_DIRTY_BINDING_TABLE_VS << stage);
ice->state.dirty |= (IRIS_DIRTY_BINDINGS_VS << stage);
}
static void
@ -1349,6 +1347,9 @@ iris_set_framebuffer_state(struct pipe_context *ctx,
ice->state.cso_depthbuffer = cso_z;
ice->state.dirty |= IRIS_DIRTY_DEPTH_BUFFER;
/* Render target change */
ice->state.dirty |= IRIS_DIRTY_BINDINGS_FS;
}
static void
@ -1396,6 +1397,9 @@ iris_set_constant_buffer(struct pipe_context *ctx,
pipe_resource_reference(&cbuf->resource, NULL);
pipe_resource_reference(&cbuf->surface_state_resource, NULL);
}
// XXX: maybe not necessary all the time...?
ice->state.dirty |= IRIS_DIRTY_BINDINGS_VS << stage;
}
static void
@ -2458,17 +2462,19 @@ iris_upload_render_state(struct iris_context *ice,
}
}
if (1) { // XXX: DIRTY BINDINGS
const struct iris_binder *binder = &batch->binder;
struct iris_binder *binder = &batch->binder;
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
if (dirty & (IRIS_DIRTY_BINDINGS_VS << stage)) {
iris_emit_cmd(batch, GENX(3DSTATE_BINDING_TABLE_POINTERS_VS), ptr) {
ptr._3DCommandSubOpcode = 38 + stage;
ptr.PointertoVSBindingTable = binder->bt_offset[stage];
}
}
}
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
if (dirty & (IRIS_DIRTY_BINDINGS_VS << stage)) {
iris_populate_binding_table(ice, batch, stage);
}
}