diff options
author | Rafael Antognolli <[email protected]> | 2017-06-07 13:03:43 -0700 |
---|---|---|
committer | Rafael Antognolli <[email protected]> | 2017-07-13 15:39:49 -0700 |
commit | 9a9c7e452bc35d0bea1808bcc4caf936a35749cb (patch) | |
tree | 33f0b366490e325e3f8d002b49edc39731a463a1 | |
parent | 29363882057dadbf8d536d214253a49908b29a85 (diff) |
i965: Convert GS_STATE to genxml.
Merge the code with gen6+ 3DSTATE_GS, and delete brw_gs_state.c,
together with brw_gs_unit_state.
Signed-off-by: Rafael Antognolli <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/Makefile.sources | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_gs_state.c | 101 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_state.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_structs.h | 44 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/genX_state_upload.c | 79 |
5 files changed, 54 insertions, 172 deletions
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index 552710db95a..fc46645c8ed 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 bc3d2e5961a..00000000000 --- 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 <[email protected]> - */ - - - -#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 8f78b047e80..b9fa19cf107 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -52,7 +52,6 @@ extern const struct brw_tracked_state brw_cs_pull_constants; 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_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 12f3024bfbb..6feab0dadc4 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 2a5b3648102..baa296192b3 100644 --- a/src/mesa/drivers/dri/i965/genX_state_upload.c +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c @@ -2339,18 +2339,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 = @@ -2384,7 +2384,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); @@ -2435,7 +2442,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; @@ -2469,33 +2475,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 @@ -2503,6 +2517,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 @@ -2512,17 +2536,22 @@ 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_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), }, .emit = genX(upload_gs_state), }; -#endif /* ---------------------------------------------------------------------- */ @@ -5037,7 +5066,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: */ |