On Friday, June 16, 2017 4:31:29 PM PDT Rafael Antognolli wrote: > Merge the code with gen6+ 3DSTATE_GS, and delete brw_gs_state.c, > together with brw_gs_unit_state. > > Signed-off-by: Rafael Antognolli <rafael.antogno...@intel.com> > --- > src/mesa/drivers/dri/i965/Makefile.sources | 1 - > src/mesa/drivers/dri/i965/brw_gs_state.c | 101 > -------------------------- > src/mesa/drivers/dri/i965/brw_state.h | 1 - > src/mesa/drivers/dri/i965/brw_structs.h | 44 ----------- > src/mesa/drivers/dri/i965/genX_state_upload.c | 80 +++++++++++++------- > 5 files changed, 55 insertions(+), 172 deletions(-) > delete mode 100644 src/mesa/drivers/dri/i965/brw_gs_state.c > > diff --git a/src/mesa/drivers/dri/i965/Makefile.sources > b/src/mesa/drivers/dri/i965/Makefile.sources > index 8af9a7c..a06a8c1 100644 > --- a/src/mesa/drivers/dri/i965/Makefile.sources > +++ b/src/mesa/drivers/dri/i965/Makefile.sources > @@ -24,7 +24,6 @@ i965_FILES = \ > brw_formatquery.c \ > brw_gs.c \ > brw_gs.h \ > - brw_gs_state.c \ > brw_gs_surface_state.c \ > brw_link.cpp \ > brw_meta_util.c \ > diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c > b/src/mesa/drivers/dri/i965/brw_gs_state.c > deleted file mode 100644 > index bc3d2e5..0000000 > --- a/src/mesa/drivers/dri/i965/brw_gs_state.c > +++ /dev/null > @@ -1,101 +0,0 @@ > -/* > - Copyright (C) Intel Corp. 2006. All Rights Reserved. > - Intel funded Tungsten Graphics to > - develop this 3D driver. > - > - Permission is hereby granted, free of charge, to any person obtaining > - a copy of this software and associated documentation files (the > - "Software"), to deal in the Software without restriction, including > - without limitation the rights to use, copy, modify, merge, publish, > - distribute, sublicense, and/or sell copies of the Software, and to > - permit persons to whom the Software is furnished to do so, subject to > - the following conditions: > - > - The above copyright notice and this permission notice (including the > - next paragraph) shall be included in all copies or substantial > - portions of the Software. > - > - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. > - IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE > - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION > - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION > - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. > - > - **********************************************************************/ > - /* > - * Authors: > - * Keith Whitwell <kei...@vmware.com> > - */ > - > - > - > -#include "brw_context.h" > -#include "brw_state.h" > -#include "brw_defines.h" > -#include "intel_batchbuffer.h" > - > -static void > -brw_upload_gs_unit(struct brw_context *brw) > -{ > - struct brw_gs_unit_state *gs; > - > - gs = brw_state_batch(brw, sizeof(*gs), 32, &brw->ff_gs.state_offset); > - > - memset(gs, 0, sizeof(*gs)); > - > - /* BRW_NEW_PROGRAM_CACHE | BRW_NEW_GS_PROG_DATA */ > - if (brw->ff_gs.prog_active) { > - gs->thread0.grf_reg_count = (ALIGN(brw->ff_gs.prog_data->total_grf, > 16) / > - 16 - 1); > - > - gs->thread0.kernel_start_pointer = > - brw_program_reloc(brw, > - brw->ff_gs.state_offset + > - offsetof(struct brw_gs_unit_state, thread0), > - brw->ff_gs.prog_offset + > - (gs->thread0.grf_reg_count << 1)) >> 6; > - > - gs->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754; > - gs->thread1.single_program_flow = 1; > - > - gs->thread3.dispatch_grf_start_reg = 1; > - gs->thread3.const_urb_entry_read_offset = 0; > - gs->thread3.const_urb_entry_read_length = 0; > - gs->thread3.urb_entry_read_offset = 0; > - gs->thread3.urb_entry_read_length = > - brw->ff_gs.prog_data->urb_read_length; > - > - /* BRW_NEW_URB_FENCE */ > - gs->thread4.nr_urb_entries = brw->urb.nr_gs_entries; > - gs->thread4.urb_entry_allocation_size = brw->urb.vsize - 1; > - > - if (brw->urb.nr_gs_entries >= 8) > - gs->thread4.max_threads = 1; > - else > - gs->thread4.max_threads = 0; > - } > - > - if (brw->gen == 5) > - gs->thread4.rendering_enable = 1; > - > - /* BRW_NEW_VIEWPORT_COUNT */ > - gs->gs6.max_vp_index = brw->clip.viewport_count - 1; > - > - brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE; > -} > - > -const struct brw_tracked_state brw_gs_unit = { > - .dirty = { > - .mesa = 0, > - .brw = BRW_NEW_BATCH | > - BRW_NEW_BLORP | > - BRW_NEW_PUSH_CONSTANT_ALLOCATION | > - BRW_NEW_FF_GS_PROG_DATA | > - BRW_NEW_PROGRAM_CACHE | > - BRW_NEW_URB_FENCE | > - BRW_NEW_VIEWPORT_COUNT, > - }, > - .emit = brw_upload_gs_unit, > -}; > diff --git a/src/mesa/drivers/dri/i965/brw_state.h > b/src/mesa/drivers/dri/i965/brw_state.h > index af70464..8f3bd7f 100644 > --- a/src/mesa/drivers/dri/i965/brw_state.h > +++ b/src/mesa/drivers/dri/i965/brw_state.h > @@ -53,7 +53,6 @@ extern const struct brw_tracked_state brw_constant_buffer; > extern const struct brw_tracked_state brw_curbe_offsets; > extern const struct brw_tracked_state brw_invariant_state; > extern const struct brw_tracked_state brw_fs_samplers; > -extern const struct brw_tracked_state brw_gs_unit; > extern const struct brw_tracked_state brw_binding_table_pointers; > extern const struct brw_tracked_state brw_depthbuffer; > extern const struct brw_tracked_state brw_recalculate_urb_fence; > diff --git a/src/mesa/drivers/dri/i965/brw_structs.h > b/src/mesa/drivers/dri/i965/brw_structs.h > index 12f3024..6feab0d 100644 > --- a/src/mesa/drivers/dri/i965/brw_structs.h > +++ b/src/mesa/drivers/dri/i965/brw_structs.h > @@ -180,50 +180,6 @@ struct brw_clip_unit_state > float viewport_ymax; > }; > > -struct brw_gs_unit_state > -{ > - struct thread0 thread0; > - struct thread1 thread1; > - struct thread2 thread2; > - struct thread3 thread3; > - > - struct > - { > - unsigned pad0:8; > - unsigned rendering_enable:1; /* for Ironlake */ > - unsigned pad4:1; > - unsigned stats_enable:1; > - unsigned nr_urb_entries:7; > - unsigned pad1:1; > - unsigned urb_entry_allocation_size:5; > - unsigned pad2:1; > - unsigned max_threads:5; > - unsigned pad3:2; > - } thread4; > - > - struct > - { > - unsigned sampler_count:3; > - unsigned pad0:2; > - unsigned sampler_state_pointer:27; > - } gs5; > - > - > - struct > - { > - unsigned max_vp_index:4; > - unsigned pad0:12; > - unsigned svbi_post_inc_value:10; > - unsigned pad1:1; > - unsigned svbi_post_inc_enable:1; > - unsigned svbi_payload:1; > - unsigned discard_adjaceny:1; > - unsigned reorder_enable:1; > - unsigned pad2:1; > - } gs6; > -}; > - > - > struct brw_wm_unit_state > { > struct thread0 thread0; > diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c > b/src/mesa/drivers/dri/i965/genX_state_upload.c > index 3666f68..424d2f8 100644 > --- a/src/mesa/drivers/dri/i965/genX_state_upload.c > +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c > @@ -2338,18 +2338,18 @@ static const struct brw_tracked_state > genX(sf_clip_viewport) = { > > /* ---------------------------------------------------------------------- */ > > -#if GEN_GEN >= 6 > static void > genX(upload_gs_state)(struct brw_context *brw) > { > - const struct gen_device_info *devinfo = &brw->screen->devinfo; > + UNUSED struct gl_context *ctx = &brw->ctx; > + UNUSED const struct gen_device_info *devinfo = &brw->screen->devinfo; > const struct brw_stage_state *stage_state = &brw->gs.base; > /* BRW_NEW_GEOMETRY_PROGRAM */ > - bool active = brw->geometry_program; > + bool active = GEN_GEN >= 6 && brw->geometry_program; > > /* BRW_NEW_GS_PROG_DATA */ > struct brw_stage_prog_data *stage_prog_data = stage_state->prog_data; > - const struct brw_vue_prog_data *vue_prog_data = > + UNUSED const struct brw_vue_prog_data *vue_prog_data = > brw_vue_prog_data(stage_prog_data); > #if GEN_GEN >= 7 > const struct brw_gs_prog_data *gs_prog_data = > @@ -2383,7 +2383,14 @@ genX(upload_gs_state)(struct brw_context *brw) > gen7_emit_cs_stall_flush(brw); > #endif > > +#if GEN_GEN >= 6 > brw_batch_emit(brw, GENX(3DSTATE_GS), gs) { > +#else > + ctx->NewDriverState |= BRW_NEW_GEN4_UNIT_STATE; > + brw_state_emit(brw, GENX(GS_STATE), 32, &brw->ff_gs.state_offset, gs) { > +#endif > + > +#if GEN_GEN >= 6 > if (active) { > INIT_THREAD_DISPATCH_FIELDS(gs, Vertex); > > @@ -2434,7 +2441,6 @@ genX(upload_gs_state)(struct brw_context *brw) > > #if GEN_GEN < 7 > gs.SOStatisticsEnable = true; > - gs.RenderingEnabled = 1; > if (brw->geometry_program->info.has_transform_feedback_varyings) > gs.SVBIPayloadEnable = true; > > @@ -2468,33 +2474,41 @@ genX(upload_gs_state)(struct brw_context *brw) > gs.VertexURBEntryOutputReadOffset = urb_entry_write_offset; > gs.VertexURBEntryOutputLength = MAX2(urb_entry_output_length, 1); > #endif > -#if GEN_GEN < 7 > - } else if (brw->ff_gs.prog_active) { > + } > +#endif > + > +#if GEN_GEN <= 6 > + if (!active && brw->ff_gs.prog_active) { > /* In gen6, transform feedback for the VS stage is done with an > * ad-hoc GS program. This function provides the needed 3DSTATE_GS > * for this. > */ > gs.KernelStartPointer = KSP(brw, brw->ff_gs.prog_offset); > gs.SingleProgramFlow = true; > - gs.VectorMaskEnable = true; > - gs.DispatchGRFStartRegisterForURBData = 2; > + gs.DispatchGRFStartRegisterForURBData = GEN_GEN == 6 ? 2 : 1; > gs.VertexURBEntryReadLength = brw->ff_gs.prog_data->urb_read_length; > - gs.MaximumNumberofThreads = devinfo->max_gs_threads - 1; > - gs.StatisticsEnable = true; > - gs.SOStatisticsEnable = true; > - gs.RenderingEnabled = true; > + > +#if GEN_GEN <= 5 > + gs.GRFRegisterCount = > + DIV_ROUND_UP(brw->ff_gs.prog_data->total_grf, 16) - 1; > + /* BRW_NEW_URB_FENCE */ > + gs.NumberofURBEntries = brw->urb.nr_gs_entries; > + gs.URBEntryAllocationSize = brw->urb.vsize - 1; > + gs.MaximumNumberofThreads = brw->urb.nr_gs_entries >= 8 ? 1 : 0; > + gs.FloatingPointMode = FLOATING_POINT_MODE_Alternate; > +#else > + gs.Enable = true; > + gs.VectorMaskEnable = true; > gs.SVBIPayloadEnable = true; > gs.SVBIPostIncrementEnable = true; > gs.SVBIPostIncrementValue = > brw->ff_gs.prog_data->svbi_postincrement_value; > - gs.Enable = true; > + gs.SOStatisticsEnable = true; > + gs.MaximumNumberofThreads = devinfo->max_gs_threads - 1; > #endif > - } else { > - gs.StatisticsEnable = true; > -#if GEN_GEN < 7 > - gs.RenderingEnabled = true; > + } > #endif > - > + if (!active && !brw->ff_gs.prog_active) { > #if GEN_GEN < 8 > gs.DispatchGRFStartRegisterForURBData = 1; > #if GEN_GEN >= 7 > @@ -2502,6 +2516,16 @@ genX(upload_gs_state)(struct brw_context *brw) > #endif > #endif > } > + > +#if GEN_GEN >= 6 > + gs.StatisticsEnable = true; > +#endif > +#if GEN_GEN == 5 || GEN_GEN == 6 > + gs.RenderingEnabled = true; > +#endif > +#if GEN_GEN <= 5 > + gs.MaximumVPIndex = brw->clip.viewport_count - 1; > +#endif > } > > #if GEN_GEN == 6 > @@ -2511,17 +2535,23 @@ genX(upload_gs_state)(struct brw_context *brw) > > static const struct brw_tracked_state genX(gs_state) = { > .dirty = { > - .mesa = (GEN_GEN < 7 ? _NEW_PROGRAM_CONSTANTS : 0), > + .mesa = (GEN_GEN == 6 ? _NEW_PROGRAM_CONSTANTS : 0), > .brw = BRW_NEW_BATCH | > BRW_NEW_BLORP | > - BRW_NEW_CONTEXT | > - BRW_NEW_GEOMETRY_PROGRAM | > - BRW_NEW_GS_PROG_DATA | > + (GEN_GEN <= 5 ? BRW_NEW_PUSH_CONSTANT_ALLOCATION | > + BRW_NEW_FF_GS_PROG_DATA |
You don't need BRW_NEW_FF_GS_PROG_DATA here, because... > + BRW_NEW_PROGRAM_CACHE | > + BRW_NEW_URB_FENCE | > + BRW_NEW_VIEWPORT_COUNT > + : 0) | > + (GEN_GEN >= 6 ? BRW_NEW_CONTEXT | > + BRW_NEW_GEOMETRY_PROGRAM | > + BRW_NEW_GS_PROG_DATA > + : 0) | > (GEN_GEN < 7 ? BRW_NEW_FF_GS_PROG_DATA : 0), ...you already have it here. Otherwise, Reviewed-by: Kenneth Graunke <kenn...@whitecape.org> > }, > .emit = genX(upload_gs_state), > }; > -#endif > > /* ---------------------------------------------------------------------- */ > > @@ -4376,7 +4406,7 @@ genX(init_atoms)(struct brw_context *brw) > &genX(sf_state), > &genX(vs_state), /* always required, enabled or not */ > &brw_clip_unit, > - &brw_gs_unit, > + &genX(gs_state), > > /* Command packets: > */ >
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev