diff options
author | Kenneth Graunke <[email protected]> | 2017-11-03 14:52:05 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2017-11-15 09:37:32 -0800 |
commit | 0704702972376fbd6fa414c3a404ec276bd5f0d3 (patch) | |
tree | ee9b2e45966edabeb0c91fb1344a4233db3eeb84 /src | |
parent | ff964916dc5424495a3e884e02c3b2c8f285b78b (diff) |
i965: Fold ABO state upload code into the SSBO/UBO state upload code.
Having this separate could potentially make programs that rebind atomics
but no other surfaces ever so slightly faster. But it's a tiny amount
of code to add to the existing UBO/SSBO atom, and very related.
The extra atoms have a cost on every draw call, and so dropping some of
them would be nice. This also reclaims a dirty bit.
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_gs_surface_state.c | 22 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_state.h | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_state_upload.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_tcs_surface_state.c | 23 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_tes_surface_state.c | 23 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 22 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 87 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/genX_state_upload.c | 11 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_buffer_objects.c | 2 |
10 files changed, 16 insertions, 189 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 72a81a0ec1a..66483fbf7d0 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -195,7 +195,6 @@ enum brw_state_id { BRW_STATE_RASTERIZER_DISCARD, BRW_STATE_STATS_WM, BRW_STATE_UNIFORM_BUFFER, - BRW_STATE_ATOMIC_BUFFER, BRW_STATE_IMAGE_UNITS, BRW_STATE_META_IN_PROGRESS, BRW_STATE_PUSH_CONSTANT_ALLOCATION, @@ -288,7 +287,6 @@ enum brw_state_id { #define BRW_NEW_RASTERIZER_DISCARD (1ull << BRW_STATE_RASTERIZER_DISCARD) #define BRW_NEW_STATS_WM (1ull << BRW_STATE_STATS_WM) #define BRW_NEW_UNIFORM_BUFFER (1ull << BRW_STATE_UNIFORM_BUFFER) -#define BRW_NEW_ATOMIC_BUFFER (1ull << BRW_STATE_ATOMIC_BUFFER) #define BRW_NEW_IMAGE_UNITS (1ull << BRW_STATE_IMAGE_UNITS) #define BRW_NEW_META_IN_PROGRESS (1ull << BRW_STATE_META_IN_PROGRESS) #define BRW_NEW_PUSH_CONSTANT_ALLOCATION (1ull << BRW_STATE_PUSH_CONSTANT_ALLOCATION) @@ -1413,10 +1411,6 @@ brw_update_sol_surface(struct brw_context *brw, void brw_upload_ubo_surfaces(struct brw_context *brw, struct gl_program *prog, struct brw_stage_state *stage_state, struct brw_stage_prog_data *prog_data); -void brw_upload_abo_surfaces(struct brw_context *brw, - const struct gl_program *prog, - struct brw_stage_state *stage_state, - struct brw_stage_prog_data *prog_data); void brw_upload_image_surfaces(struct brw_context *brw, const struct gl_program *prog, struct brw_stage_state *stage_state, diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c index 570f3fb4dd2..6f2629eb29d 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c @@ -92,28 +92,6 @@ const struct brw_tracked_state brw_gs_ubo_surfaces = { }; static void -brw_upload_gs_abo_surfaces(struct brw_context *brw) -{ - /* _NEW_PROGRAM */ - const struct gl_program *gp = brw->programs[MESA_SHADER_GEOMETRY]; - - if (gp) { - /* BRW_NEW_GS_PROG_DATA */ - brw_upload_abo_surfaces(brw, gp, &brw->gs.base, brw->gs.base.prog_data); - } -} - -const struct brw_tracked_state brw_gs_abo_surfaces = { - .dirty = { - .mesa = _NEW_PROGRAM, - .brw = BRW_NEW_ATOMIC_BUFFER | - BRW_NEW_BATCH | - BRW_NEW_GS_PROG_DATA, - }, - .emit = brw_upload_gs_abo_surfaces, -}; - -static void brw_upload_gs_image_surfaces(struct brw_context *brw) { /* BRW_NEW_GEOMETRY_PROGRAM */ diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 397dfc9aa50..cf13eca3438 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -58,16 +58,12 @@ extern const struct brw_tracked_state brw_recalculate_urb_fence; extern const struct brw_tracked_state brw_sf_vp; extern const struct brw_tracked_state brw_cs_texture_surfaces; extern const struct brw_tracked_state brw_vs_ubo_surfaces; -extern const struct brw_tracked_state brw_vs_abo_surfaces; extern const struct brw_tracked_state brw_vs_image_surfaces; extern const struct brw_tracked_state brw_tcs_ubo_surfaces; -extern const struct brw_tracked_state brw_tcs_abo_surfaces; extern const struct brw_tracked_state brw_tcs_image_surfaces; extern const struct brw_tracked_state brw_tes_ubo_surfaces; -extern const struct brw_tracked_state brw_tes_abo_surfaces; extern const struct brw_tracked_state brw_tes_image_surfaces; extern const struct brw_tracked_state brw_gs_ubo_surfaces; -extern const struct brw_tracked_state brw_gs_abo_surfaces; extern const struct brw_tracked_state brw_gs_image_surfaces; extern const struct brw_tracked_state brw_renderbuffer_surfaces; extern const struct brw_tracked_state brw_renderbuffer_read_surfaces; @@ -78,10 +74,8 @@ extern const struct brw_tracked_state brw_tes_binding_table; extern const struct brw_tracked_state brw_tcs_binding_table; extern const struct brw_tracked_state brw_vs_binding_table; extern const struct brw_tracked_state brw_wm_ubo_surfaces; -extern const struct brw_tracked_state brw_wm_abo_surfaces; extern const struct brw_tracked_state brw_wm_image_surfaces; extern const struct brw_tracked_state brw_cs_ubo_surfaces; -extern const struct brw_tracked_state brw_cs_abo_surfaces; extern const struct brw_tracked_state brw_cs_image_surfaces; extern const struct brw_tracked_state brw_psp_urb_cbs; diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index da464ef7b14..20c59c6e9dc 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -204,7 +204,7 @@ void brw_init_state( struct brw_context *brw ) ctx->DriverFlags.NewUniformBuffer = BRW_NEW_UNIFORM_BUFFER; ctx->DriverFlags.NewShaderStorageBuffer = BRW_NEW_UNIFORM_BUFFER; ctx->DriverFlags.NewTextureBuffer = BRW_NEW_TEXTURE_BUFFER; - ctx->DriverFlags.NewAtomicBuffer = BRW_NEW_ATOMIC_BUFFER; + ctx->DriverFlags.NewAtomicBuffer = BRW_NEW_UNIFORM_BUFFER; ctx->DriverFlags.NewImageUnits = BRW_NEW_IMAGE_UNITS; ctx->DriverFlags.NewDefaultTessLevels = BRW_NEW_DEFAULT_TESS_LEVELS; ctx->DriverFlags.NewIntelConservativeRasterization = BRW_NEW_CONSERVATIVE_RASTERIZATION; @@ -323,7 +323,6 @@ static struct dirty_bit_map brw_bits[] = { DEFINE_BIT(BRW_NEW_RASTERIZER_DISCARD), DEFINE_BIT(BRW_NEW_STATS_WM), DEFINE_BIT(BRW_NEW_UNIFORM_BUFFER), - DEFINE_BIT(BRW_NEW_ATOMIC_BUFFER), DEFINE_BIT(BRW_NEW_IMAGE_UNITS), DEFINE_BIT(BRW_NEW_META_IN_PROGRESS), DEFINE_BIT(BRW_NEW_PUSH_CONSTANT_ALLOCATION), diff --git a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c index f4f9abc0620..73179c006a0 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c @@ -92,29 +92,6 @@ const struct brw_tracked_state brw_tcs_ubo_surfaces = { }; static void -brw_upload_tcs_abo_surfaces(struct brw_context *brw) -{ - /* _NEW_PROGRAM */ - const struct gl_program *tcp = brw->programs[MESA_SHADER_TESS_CTRL]; - - if (tcp) { - /* BRW_NEW_TCS_PROG_DATA */ - brw_upload_abo_surfaces(brw, tcp, &brw->tcs.base, - brw->tcs.base.prog_data); - } -} - -const struct brw_tracked_state brw_tcs_abo_surfaces = { - .dirty = { - .mesa = _NEW_PROGRAM, - .brw = BRW_NEW_ATOMIC_BUFFER | - BRW_NEW_BATCH | - BRW_NEW_TCS_PROG_DATA, - }, - .emit = brw_upload_tcs_abo_surfaces, -}; - -static void brw_upload_tcs_image_surfaces(struct brw_context *brw) { /* BRW_NEW_TESS_PROGRAMS */ diff --git a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c index 85b285d8688..6e9e58a4f17 100644 --- a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c @@ -92,29 +92,6 @@ const struct brw_tracked_state brw_tes_ubo_surfaces = { }; static void -brw_upload_tes_abo_surfaces(struct brw_context *brw) -{ - /* _NEW_PROGRAM */ - const struct gl_program *tep = brw->programs[MESA_SHADER_TESS_EVAL]; - - if (tep) { - /* BRW_NEW_TES_PROG_DATA */ - brw_upload_abo_surfaces(brw, tep, &brw->tes.base, - brw->tes.base.prog_data); - } -} - -const struct brw_tracked_state brw_tes_abo_surfaces = { - .dirty = { - .mesa = _NEW_PROGRAM, - .brw = BRW_NEW_ATOMIC_BUFFER | - BRW_NEW_BATCH | - BRW_NEW_TES_PROG_DATA, - }, - .emit = brw_upload_tes_abo_surfaces, -}; - -static void brw_upload_tes_image_surfaces(struct brw_context *brw) { /* BRW_NEW_TESS_PROGRAMS */ diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index 24c22e087d9..289c791b872 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -94,28 +94,6 @@ const struct brw_tracked_state brw_vs_ubo_surfaces = { }; static void -brw_upload_vs_abo_surfaces(struct brw_context *brw) -{ - /* _NEW_PROGRAM */ - const struct gl_program *vp = brw->programs[MESA_SHADER_VERTEX]; - - if (vp) { - /* BRW_NEW_VS_PROG_DATA */ - brw_upload_abo_surfaces(brw, vp, &brw->vs.base, brw->vs.base.prog_data); - } -} - -const struct brw_tracked_state brw_vs_abo_surfaces = { - .dirty = { - .mesa = _NEW_PROGRAM, - .brw = BRW_NEW_ATOMIC_BUFFER | - BRW_NEW_BATCH | - BRW_NEW_VS_PROG_DATA, - }, - .emit = brw_upload_vs_abo_surfaces, -}; - -static void brw_upload_vs_image_surfaces(struct brw_context *brw) { /* BRW_NEW_VERTEX_PROGRAM */ diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index a4804401fc5..adf60a840b0 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -1270,7 +1270,9 @@ brw_upload_ubo_surfaces(struct brw_context *brw, struct gl_program *prog, { struct gl_context *ctx = &brw->ctx; - if (!prog) + if (!prog || (prog->info.num_ubos == 0 && + prog->info.num_ssbos == 0 && + prog->info.num_abos == 0)) return; uint32_t *ubo_surf_offsets = @@ -1283,9 +1285,16 @@ brw_upload_ubo_surfaces(struct brw_context *brw, struct gl_program *prog, ISL_FORMAT_R32G32B32A32_FLOAT, 0); } - uint32_t *ssbo_surf_offsets = - &stage_state->surf_offset[prog_data->binding_table.ssbo_start] + - prog->info.num_abos; + uint32_t *abo_surf_offsets = + &stage_state->surf_offset[prog_data->binding_table.ssbo_start]; + uint32_t *ssbo_surf_offsets = abo_surf_offsets + prog->info.num_abos; + + for (int i = 0; i < prog->info.num_abos; i++) { + struct gl_buffer_binding *binding = + &ctx->AtomicBufferBindings[prog->sh.AtomicBuffers[i]->Binding]; + upload_buffer_surface(brw, binding, &abo_surf_offsets[i], + ISL_FORMAT_RAW, RELOC_WRITE); + } for (int i = 0; i < prog->info.num_ssbos; i++) { struct gl_buffer_binding *binding = @@ -1296,9 +1305,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw, struct gl_program *prog, } stage_state->push_constants_dirty = true; - - if (prog->info.num_ubos || prog->info.num_ssbos) - brw->ctx.NewDriverState |= BRW_NEW_SURFACES; + brw->ctx.NewDriverState |= BRW_NEW_SURFACES; } static void @@ -1344,72 +1351,6 @@ const struct brw_tracked_state brw_cs_ubo_surfaces = { .emit = brw_upload_cs_ubo_surfaces, }; -void -brw_upload_abo_surfaces(struct brw_context *brw, - const struct gl_program *prog, - struct brw_stage_state *stage_state, - struct brw_stage_prog_data *prog_data) -{ - struct gl_context *ctx = &brw->ctx; - uint32_t *surf_offsets = - &stage_state->surf_offset[prog_data->binding_table.ssbo_start]; - - if (prog->info.num_abos) { - for (unsigned i = 0; i < prog->info.num_abos; i++) { - struct gl_buffer_binding *binding = - &ctx->AtomicBufferBindings[prog->sh.AtomicBuffers[i]->Binding]; - upload_buffer_surface(brw, binding, &surf_offsets[i], - ISL_FORMAT_RAW, RELOC_WRITE); - } - - brw->ctx.NewDriverState |= BRW_NEW_SURFACES; - } -} - -static void -brw_upload_wm_abo_surfaces(struct brw_context *brw) -{ - /* _NEW_PROGRAM */ - const struct gl_program *wm = brw->programs[MESA_SHADER_FRAGMENT]; - - if (wm) { - /* BRW_NEW_FS_PROG_DATA */ - brw_upload_abo_surfaces(brw, wm, &brw->wm.base, brw->wm.base.prog_data); - } -} - -const struct brw_tracked_state brw_wm_abo_surfaces = { - .dirty = { - .mesa = _NEW_PROGRAM, - .brw = BRW_NEW_ATOMIC_BUFFER | - BRW_NEW_BATCH | - BRW_NEW_FS_PROG_DATA, - }, - .emit = brw_upload_wm_abo_surfaces, -}; - -static void -brw_upload_cs_abo_surfaces(struct brw_context *brw) -{ - /* _NEW_PROGRAM */ - const struct gl_program *cp = brw->programs[MESA_SHADER_COMPUTE]; - - if (cp) { - /* BRW_NEW_CS_PROG_DATA */ - brw_upload_abo_surfaces(brw, cp, &brw->cs.base, brw->cs.base.prog_data); - } -} - -const struct brw_tracked_state brw_cs_abo_surfaces = { - .dirty = { - .mesa = _NEW_PROGRAM, - .brw = BRW_NEW_ATOMIC_BUFFER | - BRW_NEW_BATCH | - BRW_NEW_CS_PROG_DATA, - }, - .emit = brw_upload_cs_abo_surfaces, -}; - static void brw_upload_cs_image_surfaces(struct brw_context *brw) { diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c index 453b8e4adda..d4b0de850c9 100644 --- a/src/mesa/drivers/dri/i965/genX_state_upload.c +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c @@ -5483,19 +5483,14 @@ genX(init_atoms)(struct brw_context *brw) */ &brw_vs_pull_constants, &brw_vs_ubo_surfaces, - &brw_vs_abo_surfaces, &brw_tcs_pull_constants, &brw_tcs_ubo_surfaces, - &brw_tcs_abo_surfaces, &brw_tes_pull_constants, &brw_tes_ubo_surfaces, - &brw_tes_abo_surfaces, &brw_gs_pull_constants, &brw_gs_ubo_surfaces, - &brw_gs_abo_surfaces, &brw_wm_pull_constants, &brw_wm_ubo_surfaces, - &brw_wm_abo_surfaces, &gen6_renderbuffer_surfaces, &brw_renderbuffer_read_surfaces, &brw_texture_surfaces, @@ -5575,19 +5570,14 @@ genX(init_atoms)(struct brw_context *brw) */ &brw_vs_pull_constants, &brw_vs_ubo_surfaces, - &brw_vs_abo_surfaces, &brw_tcs_pull_constants, &brw_tcs_ubo_surfaces, - &brw_tcs_abo_surfaces, &brw_tes_pull_constants, &brw_tes_ubo_surfaces, - &brw_tes_abo_surfaces, &brw_gs_pull_constants, &brw_gs_ubo_surfaces, - &brw_gs_abo_surfaces, &brw_wm_pull_constants, &brw_wm_ubo_surfaces, - &brw_wm_abo_surfaces, &gen6_renderbuffer_surfaces, &brw_renderbuffer_read_surfaces, &brw_texture_surfaces, @@ -5657,7 +5647,6 @@ genX(init_atoms)(struct brw_context *brw) &genX(cs_push_constants), &genX(cs_pull_constants), &brw_cs_ubo_surfaces, - &brw_cs_abo_surfaces, &brw_cs_texture_surfaces, &brw_cs_work_groups_surface, &genX(cs_samplers), diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/src/mesa/drivers/dri/i965/intel_buffer_objects.c index 49e68bd7392..8268040911a 100644 --- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c @@ -107,7 +107,7 @@ alloc_buffer_object(struct brw_context *brw, if (intel_obj->Base.UsageHistory & USAGE_TEXTURE_BUFFER) brw->ctx.NewDriverState |= BRW_NEW_TEXTURE_BUFFER; if (intel_obj->Base.UsageHistory & USAGE_ATOMIC_COUNTER_BUFFER) - brw->ctx.NewDriverState |= BRW_NEW_ATOMIC_BUFFER; + brw->ctx.NewDriverState |= BRW_NEW_UNIFORM_BUFFER; mark_buffer_inactive(intel_obj); mark_buffer_invalid(intel_obj); |