summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/tgsi/tgsi_text.c
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-01-21 05:36:14 +0100
committerLuca Barbieri <luca@luca-barbieri.com>2010-01-29 14:13:14 +0100
commit73317139a4f78126af0dc4ddaef8206352740727 (patch)
tree0775bf5e5e8228b5ae276d4b3ff61afe7b39df0a /src/gallium/auxiliary/tgsi/tgsi_text.c
parent3cea5525d0b59c7dadb4be634cc244948cd634e6 (diff)
tgsi: add properties for fragment coord conventions (v3)
Changes in v3: - Documented the new properties - Added comments for property values - Rebased to current master 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.
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_text.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index f74b56bfb5..96be353e26 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -1129,7 +1129,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[] =
@@ -1146,6 +1148,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 )
{
@@ -1163,6 +1178,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 )
{
@@ -1204,6 +1253,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!" );