Luca Barbieri wrote: > Changes in v2: > - Caps are added in a separate, subsequent patch > > This adds two TGSI fragment program properties that indicate the > fragment coord conventions. > > The properties behave as described in the extension spec for > GL_ARB_fragment_coord_conventions, but the default origin in > upper left instead of lower left as in OpenGL. > > The syntax is: > PROPERTY FS_COORD_ORIGIN [UPPER_LEFT|LOWER_LEFT] > PROPERTY FS_COORD_PIXEL_CENTER [HALF_INTEGER|INTEGER] > > The names have been chosen for consistency with the GS properties > and the OpenGL extension spec. > > The defaults are of course the previously assumed conventions: > UPPER_LEFT and HALF_INTEGER.
Sorry for the slow reply on this. It looks like you've solved the fragcoord problems in a clean/logical way. I haven't seen any objections, so I think we can move forward with this. This patch looks good, just a minor comment below. > --- > src/gallium/auxiliary/tgsi/tgsi_dump.c | 22 +++++++++- > src/gallium/auxiliary/tgsi/tgsi_text.c | 63 > +++++++++++++++++++++++++++- > src/gallium/auxiliary/tgsi/tgsi_ureg.c | 32 ++++++++++++++ > src/gallium/auxiliary/tgsi/tgsi_ureg.h | 7 +++ > src/gallium/include/pipe/p_shader_tokens.h | 10 ++++- > 5 files changed, 131 insertions(+), 3 deletions(-) > > diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c > b/src/gallium/auxiliary/tgsi/tgsi_dump.c > index c254a72..307d1f7 100644 > --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c > +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c > @@ -159,7 +159,9 @@ static const char *property_names[] = > { > "GS_INPUT_PRIMITIVE", > "GS_OUTPUT_PRIMITIVE", > - "GS_MAX_OUTPUT_VERTICES" > + "GS_MAX_OUTPUT_VERTICES", > + "FS_COORD_ORIGIN", > + "FS_COORD_PIXEL_CENTER" > }; > > static const char *primitive_names[] = > @@ -176,6 +178,18 @@ static const char *primitive_names[] = > "POLYGON" > }; > > +static const char *fs_coord_origin_names[] = > +{ > + "UPPER_LEFT", > + "LOWER_LEFT" > +}; > + > +static const char *fs_coord_pixel_center_names[] = > +{ > + "HALF_INTEGER", > + "INTEGER" > +}; > + > > static void > _dump_register_decl( > @@ -372,6 +386,12 @@ iter_property( > case TGSI_PROPERTY_GS_OUTPUT_PRIM: > ENM(prop->u[i].Data, primitive_names); > break; > + case TGSI_PROPERTY_FS_COORD_ORIGIN: > + ENM(prop->u[i].Data, fs_coord_origin_names); > + break; > + case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER: > + ENM(prop->u[i].Data, fs_coord_pixel_center_names); > + break; > default: > SID( prop->u[i].Data ); > break; > diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c > b/src/gallium/auxiliary/tgsi/tgsi_text.c > index 7fe5dad..0062e9d 100644 > --- a/src/gallium/auxiliary/tgsi/tgsi_text.c > +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c > @@ -1117,7 +1117,9 @@ static const char *property_names[] = > { > "GS_INPUT_PRIMITIVE", > "GS_OUTPUT_PRIMITIVE", > - "GS_MAX_OUTPUT_VERTICES" > + "GS_MAX_OUTPUT_VERTICES", > + "FS_COORD_ORIGIN", > + "FS_COORD_PIXEL_CENTER" > }; > > static const char *primitive_names[] = > @@ -1134,6 +1136,19 @@ static const char *primitive_names[] = > "POLYGON" > }; > > +static const char *fs_coord_origin_names[] = > +{ > + "UPPER_LEFT", > + "LOWER_LEFT" > +}; > + > +static const char *fs_coord_pixel_center_names[] = > +{ > + "HALF_INTEGER", > + "INTEGER" > +}; > + > + > static boolean > parse_primitive( const char **pcur, uint *primitive ) > { > @@ -1151,6 +1166,40 @@ parse_primitive( const char **pcur, uint *primitive ) > return FALSE; > } > > +static boolean > +parse_fs_coord_origin( const char **pcur, uint *fs_coord_origin ) > +{ > + uint i; > + > + for (i = 0; i < sizeof(fs_coord_origin_names) / > sizeof(fs_coord_origin_names[0]); i++) { > + const char *cur = *pcur; > + > + if (str_match_no_case( &cur, fs_coord_origin_names[i])) { > + *fs_coord_origin = i; > + *pcur = cur; > + return TRUE; > + } > + } > + return FALSE; > +} > + > +static boolean > +parse_fs_coord_pixel_center( const char **pcur, uint *fs_coord_pixel_center ) > +{ > + uint i; > + > + for (i = 0; i < sizeof(fs_coord_pixel_center_names) / > sizeof(fs_coord_pixel_center_names[0]); i++) { > + const char *cur = *pcur; > + > + if (str_match_no_case( &cur, fs_coord_pixel_center_names[i])) { > + *fs_coord_pixel_center = i; > + *pcur = cur; > + return TRUE; > + } > + } > + return FALSE; > +} > + > > static boolean parse_property( struct translate_ctx *ctx ) > { > @@ -1192,6 +1241,18 @@ static boolean parse_property( struct translate_ctx > *ctx ) > ctx->implied_array_size = u_vertices_per_prim(values[0]); > } > break; > + case TGSI_PROPERTY_FS_COORD_ORIGIN: > + if (!parse_fs_coord_origin(&ctx->cur, &values[0] )) { > + report_error( ctx, "Unknown coord origin as property: must be > UPPER_LEFT or LOWER_LEFT!" ); > + return FALSE; > + } > + break; > + case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER: > + if (!parse_fs_coord_pixel_center(&ctx->cur, &values[0] )) { > + report_error( ctx, "Unknown coord pixel center as property: must be > HALF_INTEGER or INTEGER!" ); > + return FALSE; > + } > + break; > default: > if (!parse_uint(&ctx->cur, &values[0] )) { > report_error( ctx, "Expected unsigned integer as property!" ); > diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c > b/src/gallium/auxiliary/tgsi/tgsi_ureg.c > index ab557a2..9d314d4 100644 > --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c > +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c > @@ -134,6 +134,8 @@ struct ureg_program > unsigned nr_constant_ranges; > > unsigned property_gs_input_prim; > + unsigned char property_fs_coord_origin; > + unsigned char property_fs_coord_pixel_center; Do these fields take the values TGSI_FS_COORD_ORIGIN_UPPER/LOWER_LEFT and TGSI_FS_COORD_PIXEL_CENTER_x? If so, comments would be good. > > unsigned nr_addrs; > unsigned nr_preds; > @@ -268,6 +270,20 @@ ureg_property_gs_input_prim(struct ureg_program *ureg, > ureg->property_gs_input_prim = gs_input_prim; > } > > +void > +ureg_property_fs_coord_origin(struct ureg_program *ureg, > + unsigned fs_coord_origin) > +{ > + ureg->property_fs_coord_origin = fs_coord_origin; > +} > + > +void > +ureg_property_fs_coord_pixel_center(struct ureg_program *ureg, > + unsigned fs_coord_pixel_center) > +{ > + ureg->property_fs_coord_pixel_center = fs_coord_pixel_center; > +} > + > > > struct ureg_src > @@ -1134,6 +1150,22 @@ static void emit_decls( struct ureg_program *ureg ) > ureg->property_gs_input_prim); > } > > + if (ureg->property_fs_coord_origin) { > + assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT); > + > + emit_property(ureg, > + TGSI_PROPERTY_FS_COORD_ORIGIN, > + ureg->property_fs_coord_origin); > + } > + > + if (ureg->property_fs_coord_pixel_center) { > + assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT); > + > + emit_property(ureg, > + TGSI_PROPERTY_FS_COORD_PIXEL_CENTER, > + ureg->property_fs_coord_pixel_center); > + } > + > if (ureg->processor == TGSI_PROCESSOR_VERTEX) { > for (i = 0; i < UREG_MAX_INPUT; i++) { > if (ureg->vs_inputs[i/32] & (1 << (i%32))) { > diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h > b/src/gallium/auxiliary/tgsi/tgsi_ureg.h > index 8c8a6bb..5bade4b 100644 > --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h > +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h > @@ -128,6 +128,13 @@ void > ureg_property_gs_input_prim(struct ureg_program *ureg, > unsigned gs_input_prim); > > +void > +ureg_property_fs_coord_origin(struct ureg_program *ureg, > + unsigned fs_coord_origin); > + > +void > +ureg_property_fs_coord_pixel_center(struct ureg_program *ureg, > + unsigned fs_coord_pixel_center); > > /*********************************************************************** > * Build shader declarations: > diff --git a/src/gallium/include/pipe/p_shader_tokens.h > b/src/gallium/include/pipe/p_shader_tokens.h > index b489b04..4134c70 100644 > --- a/src/gallium/include/pipe/p_shader_tokens.h > +++ b/src/gallium/include/pipe/p_shader_tokens.h > @@ -163,7 +163,9 @@ union tgsi_immediate_data > #define TGSI_PROPERTY_GS_INPUT_PRIM 0 > #define TGSI_PROPERTY_GS_OUTPUT_PRIM 1 > #define TGSI_PROPERTY_GS_MAX_VERTICES 2 > -#define TGSI_PROPERTY_COUNT 3 > +#define TGSI_PROPERTY_FS_COORD_ORIGIN 3 > +#define TGSI_PROPERTY_FS_COORD_PIXEL_CENTER 4 > +#define TGSI_PROPERTY_COUNT 5 > > struct tgsi_property { > unsigned Type : 4; /**< TGSI_TOKEN_TYPE_PROPERTY */ > @@ -172,6 +174,12 @@ struct tgsi_property { > unsigned Padding : 12; > }; > > +#define TGSI_FS_COORD_ORIGIN_UPPER_LEFT 0 > +#define TGSI_FS_COORD_ORIGIN_LOWER_LEFT 1 > + > +#define TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER 0 > +#define TGSI_FS_COORD_PIXEL_CENTER_INTEGER 1 > + > struct tgsi_property_data { > unsigned Data; > }; > -- > 1.6.6.1.476.g01ddb > > > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > _______________________________________________ > Mesa3d-dev mailing list > Mesa3d-dev@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mesa3d-dev > . > ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Mesa3d-dev mailing list Mesa3d-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mesa3d-dev