On 22 August 2013 13:58, Kenneth Graunke <kenn...@whitecape.org> wrote:
> On 08/20/2013 11:30 AM, Paul Berry wrote: > >> From: Eric Anholt <e...@anholt.net> >> >> All but two of the piglit GLSL 1.50/uniform_buffer tests work, and >> maxuniformblocksize and referenced-by-shader work. >> >> v2 (Paul Berry <stereotype...@gmail.com>): Account for Ken's recent >> binding table re-work. Use brw->vec4_gs.bind_bo_offset instead of >> brw->gs.bind_bo_offset. >> --- >> src/mesa/drivers/dri/i965/**Makefile.sources | 1 + >> src/mesa/drivers/dri/i965/brw_**context.h | 17 ++- >> src/mesa/drivers/dri/i965/brw_**gs_emit.c | 2 +- >> src/mesa/drivers/dri/i965/brw_**gs_surface_state.c | 182 >> +++++++++++++++++++++++ >> src/mesa/drivers/dri/i965/brw_**state.h | 3 + >> src/mesa/drivers/dri/i965/brw_**state_upload.c | 3 + >> src/mesa/drivers/dri/i965/**gen6_sol.c | 6 +- >> 7 files changed, 208 insertions(+), 6 deletions(-) >> create mode 100644 src/mesa/drivers/dri/i965/brw_**gs_surface_state.c >> >> diff --git a/src/mesa/drivers/dri/i965/**Makefile.sources >> b/src/mesa/drivers/dri/i965/**Makefile.sources >> index 290cd93..81a16ff 100644 >> --- a/src/mesa/drivers/dri/i965/**Makefile.sources >> +++ b/src/mesa/drivers/dri/i965/**Makefile.sources >> @@ -63,6 +63,7 @@ i965_FILES = \ >> brw_gs.c \ >> brw_gs_emit.c \ >> brw_gs_state.c \ >> + brw_gs_surface_state.c \ >> brw_interpolation_map.c \ >> brw_lower_texture_gradients.**cpp \ >> brw_misc_state.c \ >> diff --git a/src/mesa/drivers/dri/i965/**brw_context.h >> b/src/mesa/drivers/dri/i965/**brw_context.h >> index 4f6c767..a6d0786 100644 >> --- a/src/mesa/drivers/dri/i965/**brw_context.h >> +++ b/src/mesa/drivers/dri/i965/**brw_context.h >> @@ -148,6 +148,7 @@ enum brw_state_id { >> BRW_STATE_BATCH, >> BRW_STATE_INDEX_BUFFER, >> BRW_STATE_VS_CONSTBUF, >> + BRW_STATE_GS_CONSTBUF, >> BRW_STATE_PROGRAM_CACHE, >> BRW_STATE_STATE_BASE_ADDRESS, >> BRW_STATE_VUE_MAP_VS, >> @@ -184,6 +185,7 @@ enum brw_state_id { >> /** \see brw.state.depth_region */ >> #define BRW_NEW_INDEX_BUFFER (1 << BRW_STATE_INDEX_BUFFER) >> #define BRW_NEW_VS_CONSTBUF (1 << BRW_STATE_VS_CONSTBUF) >> +#define BRW_NEW_GS_CONSTBUF (1 << BRW_STATE_GS_CONSTBUF) >> #define BRW_NEW_PROGRAM_CACHE (1 << BRW_STATE_PROGRAM_CACHE) >> #define BRW_NEW_STATE_BASE_ADDRESS (1 << >> BRW_STATE_STATE_BASE_ADDRESS) >> #define BRW_NEW_VUE_MAP_VS (1 << BRW_STATE_VUE_MAP_VS) >> @@ -654,8 +656,19 @@ struct brw_vec4_gs_prog_data >> #define SURF_INDEX_VS_SHADER_TIME (SURF_INDEX_VS_UBO(12)) >> #define BRW_MAX_VS_SURFACES (SURF_INDEX_VS_SHADER_TIME + 1) >> >> -#define SURF_INDEX_SOL_BINDING(t) ((t)) >> -#define BRW_MAX_GS_SURFACES SURF_INDEX_SOL_BINDING(BRW_** >> MAX_SOL_BINDINGS) >> +#define SURF_INDEX_GEN6_SOL_BINDING(t) (t) >> +#define BRW_MAX_GEN6_GS_SURFACES SURF_INDEX_GEN6_SOL_BINDING(** >> BRW_MAX_SOL_BINDINGS) >> > > It's not a big deal, but it would be nice to do the SURF_INDEX_SOL_BINDING > renames in a separate patch. Good point. > > > +#define SURF_INDEX_GS_GEN6_SOL_BUFFER 0 >> +#define SURF_INDEX_GS_CONST_BUFFER (SURF_INDEX_GS_GEN6_SOL_**BUFFER) >> + >> +#define SURF_INDEX_GS_TEXTURE(t) (SURF_INDEX_GS_CONST_BUFFER + 1 + >> (t)) >> +#define SURF_INDEX_GS_UBO(u) >> (SURF_INDEX_GS_TEXTURE(BRW_**MAX_TEX_UNIT) >> + u) >> +#define SURF_INDEX_GS_SHADER_TIME (SURF_INDEX_GS_UBO(12)) >> +#define BRW_MAX_GEN7_GS_SURFACES (SURF_INDEX_GS_SHADER_TIME + 1) >> + >> +#define BRW_MAX_GS_SURFACES MAX2(BRW_MAX_GEN6_GS_SURFACES, \ >> + BRW_MAX_GEN7_GS_SURFACES) >> >> /** >> * Stride in bytes between shader_time entries. >> diff --git a/src/mesa/drivers/dri/i965/**brw_gs_emit.c >> b/src/mesa/drivers/dri/i965/**brw_gs_emit.c >> index fff3585..f576a81 100644 >> --- a/src/mesa/drivers/dri/i965/**brw_gs_emit.c >> +++ b/src/mesa/drivers/dri/i965/**brw_gs_emit.c >> @@ -432,7 +432,7 @@ gen6_sol_program(struct brw_gs_compile *c, struct >> brw_gs_prog_key *key, >> final_write ? c->reg.temp : brw_null_reg(), >> /* dest */ >> 1, /* msg_reg_nr */ >> c->reg.header, /* src0 */ >> - SURF_INDEX_SOL_BINDING(**binding), /* >> binding_table_index */ >> + SURF_INDEX_GEN6_SOL_BINDING(**binding), /* >> binding_table_index */ >> final_write); /* send_commit_msg */ >> } >> } >> diff --git a/src/mesa/drivers/dri/i965/**brw_gs_surface_state.c >> b/src/mesa/drivers/dri/i965/**brw_gs_surface_state.c >> new file mode 100644 >> index 0000000..ed99d65 >> --- /dev/null >> +++ b/src/mesa/drivers/dri/i965/**brw_gs_surface_state.c >> @@ -0,0 +1,182 @@ >> +/* >> + * Copyright © 2013 Intel Corporation >> + * >> + * 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 AUTHORS OR COPYRIGHT HOLDERS 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. >> + */ >> + >> +#include "main/mtypes.h" >> +#include "program/prog_parameter.h" >> + >> +#include "brw_context.h" >> +#include "brw_state.h" >> + >> +/* Creates a new GS constant buffer reflecting the current GS program's >> + * constants, if needed by the GS program. >> + * >> + * Otherwise, constants go through the CURBEs using the >> brw_constant_buffer >> + * state atom. >> + */ >> > > This is a lot of code duplication, and I'd really like to avoid that. > (Avoiding it should help even more when we add tesselation shaders.) > > Paul and I had talked briefly about creating a new structure type to hold > some of the fields that are common between vs, gs, and wm: > > - scratch_bo > - const_bo > - prog_offset > - state_offset > - push_const_offset > - push_const_size > - bind_bo_offset > - surf_offset > (the size varies slightly, but we can probably take the largest) > - sampler_count > - sampler_offset > - sdc_offset > > Then vs, gs, and wm could use instances of that structure, rather than > containing those fields directly. This would allow us to pass around that > "shader stage data" (pipeline stage data?) struct, rather than inspecting > vs or gs directly. > > I think we could create a function for at least VS/GS binding tables that > takes that struct, struct gl_program, and brw_vec4_prog_data, which would > work for both. Very good point. I think you'll like how I've re-worked the series (I hope to publish it later today). I mostly took your advice, except that at the moment I've only consolidated the vs and gs code--wm is still separate (I figure merging the wm stuff can be done as follow-on work).
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev