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

Unified Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 15792007: gpu: Autogenerate glHint state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch-case instead of if-series. Created 7 years, 7 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/common/gles2_cmd_utils_implementation_autogen.h » ('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 435d13ab0d8370140871ec17766318909dc1e551..9bc5823a1b9311ffd3917da1cfdff543f8ed3ac8 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -342,8 +342,26 @@ _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',
+ 'extension_flag': 'oes_standard_derivatives'
+ }
+ ],
+ },
# TODO: Consider implemenenting these states
- # GL_GENERATE_MIPMAP_HINT
# GL_ACTIVE_TEXTURE,
# GL_PACK_ALIGNMENT,
# GL_UNPACK_ALIGNMENT
@@ -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,36 @@ 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):
+ """Overridden 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
+ file.Write(" switch (%s) {\n" % args[0].name)
+ for state in states:
+ file.Write(" case %s:\n" % state['enum'])
+ file.Write(" if (state_.%s != %s) {\n" %
+ (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")
+ file.Write(" break;\n")
+ file.Write(" default:\n")
+ file.Write(" NOTREACHED();\n")
+ file.Write(" }\n")
+
+
class CustomHandler(TypeHandler):
"""Handler for commands that are auto-generated but require minor tweaks."""
@@ -6739,6 +6790,7 @@ class GLGenerator(object):
'StateSetRGBAlpha': StateSetRGBAlphaHandler(),
'StateSetFrontBack': StateSetFrontBackHandler(),
'StateSetFrontBackSeparate': StateSetFrontBackSeparateHandler(),
+ 'StateSetNamedParameter': StateSetNamedParameter(),
'STRn': STRnHandler(),
'Todo': TodoHandler(),
}
@@ -7058,6 +7110,13 @@ 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']:
+ if 'extension_flag' in item:
+ file.Write(" if (feature_info_->feature_flags().%s)\n " %
+ item['extension_flag'])
+ file.Write(" gl%s(%s, %s);\n" %
+ (state['func'], item['enum'], item['name']))
else:
args = []
for item in state['states']:
@@ -7225,6 +7284,15 @@ 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']:
+ if 'extension_flag' in item:
+ continue
+ 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']:
@@ -7638,6 +7706,8 @@ def main(argv):
_ENUM_LISTS['GLState']['valid'].append(state['enum'])
else:
for item in state['states']:
+ if 'extension_flag' in item:
+ continue
_ENUM_LISTS['GLState']['valid'].append(item['enum'])
for capability in _CAPABILITY_FLAGS:
_ENUM_LISTS['GLState']['valid'].append("GL_%s" % capability['name'].upper())
« no previous file with comments | « no previous file | gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698