Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1202)

Unified Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 469673003: Consistently generate INVALID_VALUE on NaN line width (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/build_gles2_cmd_buffer.py
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 1216a7f45ae9e4c6f4f4034afa4eeb2e9583f050..5cfe6dc44a77918d332d380179e9fddeceb3a1ba 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -425,6 +425,7 @@ _STATES = {
'type': 'GLfloat',
'default': '1.0f',
'range_checks': [{'check': "<= 0.0f", 'test_value': "0.0f"}],
+ 'nan_check': True,
}],
},
'DepthMask': {
@@ -3324,19 +3325,27 @@ class StateSetHandler(TypeHandler):
state = _STATES[state_name]
states = state['states']
args = func.GetOriginalArgs()
- code = []
for ndx,item in enumerate(states):
+ code = []
if 'range_checks' in item:
for range_check in item['range_checks']:
code.append("%s %s" % (args[ndx].name, range_check['check']))
- if len(code):
- file.Write(" if (%s) {\n" % " ||\n ".join(code))
- file.Write(
- ' LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,'
- ' "%s", "%s out of range");\n' %
- (func.name, args[ndx].name))
- file.Write(" return error::kNoError;\n")
- file.Write(" }\n")
+ if 'nan_check' in item:
+ # Drivers might generate an INVALID_VALUE error when a value is set
+ # to NaN. This is allowed behavior under GLES 3.0 section 2.1.1 or
+ # OpenGL 4.5 section 2.3.4.1 - providing NaN allows undefined results.
+ # Make this behavior consistent within Chromium, and avoid leaking GL
+ # errors by generating the error in the command buffer instead of
+ # letting the GL driver generate it.
+ code.append("base::IsNaN(%s)" % args[ndx].name)
+ if len(code):
+ file.Write(" if (%s) {\n" % " ||\n ".join(code))
+ file.Write(
+ ' LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,'
+ ' "%s", "%s out of range");\n' %
+ (func.name, args[ndx].name))
+ file.Write(" return error::kNoError;\n")
+ file.Write(" }\n")
code = []
for ndx,item in enumerate(states):
code.append("state_.%s != %s" % (item['name'], args[ndx].name))
@@ -3387,6 +3396,30 @@ TEST_P(%(test_name)s, %(name)sInvalidValue%(ndx)d_%(check_ndx)d) {
'args': ", ".join(arg_strings),
}
file.Write(valid_test % vars)
+ if 'nan_check' in item:
+ valid_test = """
+TEST_P(%(test_name)s, %(name)sNaNValue%(ndx)d) {
+ SpecializedSetup<cmds::%(name)s, 0>(false);
+ cmds::%(name)s cmd;
+ cmd.Init(%(args)s);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+}
+"""
+ name = func.name
+ arg_strings = [
+ arg.GetValidArg(func) \
+ for arg in func.GetOriginalArgs() if not arg.IsConstant()
+ ]
+
+ arg_strings[ndx] = 'nanf("")'
+ vars = {
+ 'test_name': 'GLES2DecoderTest%d' % file.file_num,
+ 'name': name,
+ 'ndx': ndx,
+ 'args': ", ".join(arg_strings),
+ }
+ file.Write(valid_test % vars)
class StateSetRGBAlphaHandler(TypeHandler):
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698