Mesa (master): ARB_fp: accept duplicate precision options
Chris Forbes
chrisf at kemper.freedesktop.org
Thu May 23 08:00:25 UTC 2013
Module: Mesa
Branch: master
Commit: a3d8e7c57c87da58b3594cecd4ac328847552477
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a3d8e7c57c87da58b3594cecd4ac328847552477
Author: Chris Forbes <chrisf at ijw.co.nz>
Date: Thu May 16 21:21:05 2013 +1200
ARB_fp: accept duplicate precision options
Relaxes the validation of
OPTION ARB_precision_hint_{nicest,fastest};
to allow duplicate options. The spec says that both /nicest/ and
/fastest/ cannot be specified together, but could be interpreted
either way for respecification of the same option.
Other drivers (NVIDIA etc) accept this, and at least one Unity3D game
expects it to succeed (Kerbal Space Program).
V2: Add spec quote.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/program/program_parse_extra.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/mesa/program/program_parse_extra.c b/src/mesa/program/program_parse_extra.c
index 4d92848..e8e1912 100644
--- a/src/mesa/program/program_parse_extra.c
+++ b/src/mesa/program/program_parse_extra.c
@@ -194,15 +194,21 @@ _mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option)
} else if (strncmp(option, "precision_hint_", 15) == 0) {
option += 15;
- if (state->option.PrecisionHint == OPTION_NONE) {
- if (strcmp(option, "nicest") == 0) {
- state->option.PrecisionHint = OPTION_NICEST;
- return 1;
- } else if (strcmp(option, "fastest") == 0) {
- state->option.PrecisionHint = OPTION_FASTEST;
- return 1;
- }
- }
+ /* The ARB_fragment_program spec, 3.11.4.5.2 says:
+ *
+ * "Only one precision control option may be specified by any given
+ * fragment program. A fragment program that specifies both the
+ * "ARB_precision_hint_fastest" and "ARB_precision_hint_nicest"
+ * program options will fail to load.
+ */
+
+ if (strcmp(option, "nicest") == 0 && state->option.PrecisionHint != OPTION_FASTEST) {
+ state->option.PrecisionHint = OPTION_NICEST;
+ return 1;
+ } else if (strcmp(option, "fastest") == 0 && state->option.PrecisionHint != OPTION_NICEST) {
+ state->option.PrecisionHint = OPTION_FASTEST;
+ return 1;
+ }
return 0;
} else if (strcmp(option, "draw_buffers") == 0) {
More information about the mesa-commit
mailing list