| 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 435d13ab0d8370140871ec17766318909dc1e551..ffc3770ca23de536d8eb6ed2fda5cc7f6552618a 100755
|
| --- a/gpu/command_buffer/build_gles2_cmd_buffer.py
|
| +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
|
| @@ -342,8 +342,25 @@ _STATES = {
|
| },
|
| ],
|
| },
|
| + 'Hint': {
|
| + 'type': 'NamedParameter',
|
| + 'func': 'Hint',
|
| + 'states': [
|
| + {
|
| + 'name': 'hint_generate_mipmap',
|
| + 'type': 'GLenum',
|
| + 'enum': 'GL_GENERATE_MIPMAP_HINT',
|
| + 'default': 'GL_DONT_CARE'
|
| + },
|
| + {
|
| + 'name': 'hint_fragment_shader_derivative',
|
| + 'type': 'GLenum',
|
| + 'enum': 'GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES',
|
| + 'default': 'GL_DONT_CARE'
|
| + }
|
| + ],
|
| + },
|
| # TODO: Consider implemenenting these states
|
| - # GL_GENERATE_MIPMAP_HINT
|
| # GL_ACTIVE_TEXTURE,
|
| # GL_PACK_ALIGNMENT,
|
| # GL_UNPACK_ALIGNMENT
|
| @@ -917,6 +934,7 @@ _ENUM_LISTS = {
|
| 'type': 'GLenum',
|
| 'valid': [
|
| 'GL_GENERATE_MIPMAP_HINT',
|
| + 'GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES',
|
| ],
|
| 'invalid': [
|
| 'GL_PERSPECTIVE_CORRECTION_HINT',
|
| @@ -1389,7 +1407,10 @@ _FUNCTION_INFO = {
|
| '1': 'GL_INCR'
|
| },
|
| },
|
| - 'Hint': {'decoder_func': 'DoHint'},
|
| + 'Hint': {
|
| + 'type': 'StateSetNamedParameter',
|
| + 'state': 'Hint',
|
| + },
|
| 'CullFace': {'type': 'StateSet', 'state': 'CullFace'},
|
| 'FrontFace': {'type': 'StateSet', 'state': 'FrontFace'},
|
| 'DepthFunc': {'type': 'StateSet', 'state': 'DepthFunc'},
|
| @@ -3278,6 +3299,32 @@ class StateSetFrontBackHandler(TypeHandler):
|
| file.Write(" }\n")
|
|
|
|
|
| +class StateSetNamedParameter(TypeHandler):
|
| + """Handler for commands that set a state chosen with an enum parameter."""
|
| +
|
| + def __init__(self):
|
| + TypeHandler.__init__(self)
|
| +
|
| + def WriteHandlerImplementation(self, func, file):
|
| + """Overriden from TypeHandler."""
|
| + state_name = func.GetInfo('state')
|
| + state = _STATES[state_name]
|
| + states = state['states']
|
| + args = func.GetOriginalArgs()
|
| + num_args = len(args)
|
| + assert num_args == 2
|
| + for state in states:
|
| + file.Write(" " if state is states[0] else " } else ")
|
| + file.Write("if (%s == %s &&\n state_.%s != %s) {\n" %
|
| + (args[0].name, state['enum'], state['name'], args[1].name))
|
| + file.Write(" state_.%s = %s;\n" %
|
| + (state['name'], args[1].name))
|
| + if not func.GetInfo("no_gl"):
|
| + file.Write(" %s(%s);\n" %
|
| + (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
|
| + file.Write(" }\n")
|
| +
|
| +
|
| class CustomHandler(TypeHandler):
|
| """Handler for commands that are auto-generated but require minor tweaks."""
|
|
|
| @@ -6739,6 +6786,7 @@ class GLGenerator(object):
|
| 'StateSetRGBAlpha': StateSetRGBAlphaHandler(),
|
| 'StateSetFrontBack': StateSetFrontBackHandler(),
|
| 'StateSetFrontBackSeparate': StateSetFrontBackSeparateHandler(),
|
| + 'StateSetNamedParameter': StateSetNamedParameter(),
|
| 'STRn': STRnHandler(),
|
| 'Todo': TodoHandler(),
|
| }
|
| @@ -7058,6 +7106,10 @@ void ContextState::InitState() const {
|
| file.Write(
|
| " gl%s(%s, %s);\n" %
|
| (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args)))
|
| + elif state['type'] == 'NamedParameter':
|
| + for item in state['states']:
|
| + file.Write(" gl%s(%s, %s);\n" %
|
| + (state['func'], item['enum'], item['name']))
|
| else:
|
| args = []
|
| for item in state['states']:
|
| @@ -7225,6 +7277,13 @@ void GLES2DecoderTestBase::SetupInitStateExpectations() {
|
| (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args)))
|
| file.Write(" .Times(1)\n")
|
| file.Write(" .RetiresOnSaturation();\n")
|
| + elif state['type'] == 'NamedParameter':
|
| + for item in state['states']:
|
| + file.Write(
|
| + " EXPECT_CALL(*gl_, %s(%s, %s))\n" %
|
| + (state['func'], item['enum'], item['default']))
|
| + file.Write(" .Times(1)\n")
|
| + file.Write(" .RetiresOnSaturation();\n")
|
| else:
|
| args = []
|
| for item in state['states']:
|
|
|