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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """code generator for GLES2 command buffers.""" 6 """code generator for GLES2 command buffers."""
7 7
8 import itertools 8 import itertools
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 'LineWidth': { 418 'LineWidth': {
419 'type': 'Normal', 419 'type': 'Normal',
420 'func': 'LineWidth', 420 'func': 'LineWidth',
421 'enum': 'GL_LINE_WIDTH', 421 'enum': 'GL_LINE_WIDTH',
422 'states': [ 422 'states': [
423 { 423 {
424 'name': 'line_width', 424 'name': 'line_width',
425 'type': 'GLfloat', 425 'type': 'GLfloat',
426 'default': '1.0f', 426 'default': '1.0f',
427 'range_checks': [{'check': "<= 0.0f", 'test_value': "0.0f"}], 427 'range_checks': [{'check': "<= 0.0f", 'test_value': "0.0f"}],
428 'nan_check': True,
428 }], 429 }],
429 }, 430 },
430 'DepthMask': { 431 'DepthMask': {
431 'type': 'Normal', 432 'type': 'Normal',
432 'func': 'DepthMask', 433 'func': 'DepthMask',
433 'enum': 'GL_DEPTH_WRITEMASK', 434 'enum': 'GL_DEPTH_WRITEMASK',
434 'states': [ 435 'states': [
435 { 436 {
436 'name': 'depth_mask', 437 'name': 'depth_mask',
437 'type': 'GLboolean', 438 'type': 'GLboolean',
(...skipping 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after
3317 3318
3318 def __init__(self): 3319 def __init__(self):
3319 TypeHandler.__init__(self) 3320 TypeHandler.__init__(self)
3320 3321
3321 def WriteHandlerImplementation(self, func, file): 3322 def WriteHandlerImplementation(self, func, file):
3322 """Overrriden from TypeHandler.""" 3323 """Overrriden from TypeHandler."""
3323 state_name = func.GetInfo('state') 3324 state_name = func.GetInfo('state')
3324 state = _STATES[state_name] 3325 state = _STATES[state_name]
3325 states = state['states'] 3326 states = state['states']
3326 args = func.GetOriginalArgs() 3327 args = func.GetOriginalArgs()
3327 code = []
3328 for ndx,item in enumerate(states): 3328 for ndx,item in enumerate(states):
3329 code = []
3329 if 'range_checks' in item: 3330 if 'range_checks' in item:
3330 for range_check in item['range_checks']: 3331 for range_check in item['range_checks']:
3331 code.append("%s %s" % (args[ndx].name, range_check['check'])) 3332 code.append("%s %s" % (args[ndx].name, range_check['check']))
3332 if len(code): 3333 if 'nan_check' in item:
3333 file.Write(" if (%s) {\n" % " ||\n ".join(code)) 3334 # Drivers might generate an INVALID_VALUE error when a value is set
3334 file.Write( 3335 # to NaN. This is allowed behavior under GLES 3.0 section 2.1.1 or
3335 ' LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,' 3336 # OpenGL 4.5 section 2.3.4.1 - providing NaN allows undefined results.
3336 ' "%s", "%s out of range");\n' % 3337 # Make this behavior consistent within Chromium, and avoid leaking GL
3337 (func.name, args[ndx].name)) 3338 # errors by generating the error in the command buffer instead of
3338 file.Write(" return error::kNoError;\n") 3339 # letting the GL driver generate it.
3339 file.Write(" }\n") 3340 code.append("base::IsNaN(%s)" % args[ndx].name)
3341 if len(code):
3342 file.Write(" if (%s) {\n" % " ||\n ".join(code))
3343 file.Write(
3344 ' LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,'
3345 ' "%s", "%s out of range");\n' %
3346 (func.name, args[ndx].name))
3347 file.Write(" return error::kNoError;\n")
3348 file.Write(" }\n")
3340 code = [] 3349 code = []
3341 for ndx,item in enumerate(states): 3350 for ndx,item in enumerate(states):
3342 code.append("state_.%s != %s" % (item['name'], args[ndx].name)) 3351 code.append("state_.%s != %s" % (item['name'], args[ndx].name))
3343 file.Write(" if (%s) {\n" % " ||\n ".join(code)) 3352 file.Write(" if (%s) {\n" % " ||\n ".join(code))
3344 for ndx,item in enumerate(states): 3353 for ndx,item in enumerate(states):
3345 file.Write(" state_.%s = %s;\n" % (item['name'], args[ndx].name)) 3354 file.Write(" state_.%s = %s;\n" % (item['name'], args[ndx].name))
3346 if 'state_flag' in state: 3355 if 'state_flag' in state:
3347 file.Write(" %s = true;\n" % state['state_flag']) 3356 file.Write(" %s = true;\n" % state['state_flag'])
3348 if not func.GetInfo("no_gl"): 3357 if not func.GetInfo("no_gl"):
3349 for ndx,item in enumerate(states): 3358 for ndx,item in enumerate(states):
(...skipping 30 matching lines...) Expand all
3380 3389
3381 arg_strings[ndx] = range_check['test_value'] 3390 arg_strings[ndx] = range_check['test_value']
3382 vars = { 3391 vars = {
3383 'test_name': 'GLES2DecoderTest%d' % file.file_num, 3392 'test_name': 'GLES2DecoderTest%d' % file.file_num,
3384 'name': name, 3393 'name': name,
3385 'ndx': ndx, 3394 'ndx': ndx,
3386 'check_ndx': check_ndx, 3395 'check_ndx': check_ndx,
3387 'args': ", ".join(arg_strings), 3396 'args': ", ".join(arg_strings),
3388 } 3397 }
3389 file.Write(valid_test % vars) 3398 file.Write(valid_test % vars)
3399 if 'nan_check' in item:
3400 valid_test = """
3401 TEST_P(%(test_name)s, %(name)sNaNValue%(ndx)d) {
3402 SpecializedSetup<cmds::%(name)s, 0>(false);
3403 cmds::%(name)s cmd;
3404 cmd.Init(%(args)s);
3405 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3406 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
3407 }
3408 """
3409 name = func.name
3410 arg_strings = [
3411 arg.GetValidArg(func) \
3412 for arg in func.GetOriginalArgs() if not arg.IsConstant()
3413 ]
3414
3415 arg_strings[ndx] = 'nanf("")'
3416 vars = {
3417 'test_name': 'GLES2DecoderTest%d' % file.file_num,
3418 'name': name,
3419 'ndx': ndx,
3420 'args': ", ".join(arg_strings),
3421 }
3422 file.Write(valid_test % vars)
3390 3423
3391 3424
3392 class StateSetRGBAlphaHandler(TypeHandler): 3425 class StateSetRGBAlphaHandler(TypeHandler):
3393 """Handler for commands that simply set state that have rgb/alpha.""" 3426 """Handler for commands that simply set state that have rgb/alpha."""
3394 3427
3395 def __init__(self): 3428 def __init__(self):
3396 TypeHandler.__init__(self) 3429 TypeHandler.__init__(self)
3397 3430
3398 def WriteHandlerImplementation(self, func, file): 3431 def WriteHandlerImplementation(self, func, file):
3399 """Overrriden from TypeHandler.""" 3432 """Overrriden from TypeHandler."""
(...skipping 4946 matching lines...) Expand 10 before | Expand all | Expand 10 after
8346 "ppapi/shared_impl/ppb_opengles2_shared.cc"]) 8379 "ppapi/shared_impl/ppb_opengles2_shared.cc"])
8347 8380
8348 if gen.errors > 0: 8381 if gen.errors > 0:
8349 print "%d errors" % gen.errors 8382 print "%d errors" % gen.errors
8350 return 1 8383 return 1
8351 return 0 8384 return 0
8352 8385
8353 8386
8354 if __name__ == '__main__': 8387 if __name__ == '__main__':
8355 sys.exit(main(sys.argv[1:])) 8388 sys.exit(main(sys.argv[1:]))
OLDNEW
« 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