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

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 11412262: gpu: Defer reads from default framebuffer when needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: do it in the generator Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_implementation.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 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 'decoder_func': 'DoBindTexture', 1177 'decoder_func': 'DoBindTexture',
1178 'gen_func': 'GenTextures', 1178 'gen_func': 'GenTextures',
1179 # TODO(gman): remove this once client side caching works. 1179 # TODO(gman): remove this once client side caching works.
1180 'client_test': False, 1180 'client_test': False,
1181 }, 1181 },
1182 'BlitFramebufferEXT': { 1182 'BlitFramebufferEXT': {
1183 'decoder_func': 'DoBlitFramebufferEXT', 1183 'decoder_func': 'DoBlitFramebufferEXT',
1184 'unit_test': False, 1184 'unit_test': False,
1185 'extension': True, 1185 'extension': True,
1186 'pepper_interface': 'FramebufferBlit', 1186 'pepper_interface': 'FramebufferBlit',
1187 'defer_reads': True,
1188 'defer_draws': True,
1187 }, 1189 },
1188 'BufferData': { 1190 'BufferData': {
1189 'type': 'Manual', 1191 'type': 'Manual',
1190 'immediate': True, 1192 'immediate': True,
1191 'client_test': False, 1193 'client_test': False,
1192 }, 1194 },
1193 'BufferSubData': { 1195 'BufferSubData': {
1194 'type': 'Data', 1196 'type': 'Data',
1195 'client_test': False, 1197 'client_test': False,
1196 'decoder_func': 'DoBufferSubData', 1198 'decoder_func': 'DoBufferSubData',
1197 }, 1199 },
1198 'CheckFramebufferStatus': { 1200 'CheckFramebufferStatus': {
1199 'type': 'Is', 1201 'type': 'Is',
1200 'decoder_func': 'DoCheckFramebufferStatus', 1202 'decoder_func': 'DoCheckFramebufferStatus',
1201 'gl_test_func': 'glCheckFramebufferStatusEXT', 1203 'gl_test_func': 'glCheckFramebufferStatusEXT',
1202 'error_value': 'GL_FRAMEBUFFER_UNSUPPORTED', 1204 'error_value': 'GL_FRAMEBUFFER_UNSUPPORTED',
1203 'result': ['GLenum'], 1205 'result': ['GLenum'],
1204 }, 1206 },
1205 'Clear': { 1207 'Clear': {
1206 'type': 'Manual', 1208 'decoder_func': 'DoClear',
1207 'cmd_args': 'GLbitfield mask' 1209 'defer_draws': True,
1208 }, 1210 },
1209 'ClearColor': { 1211 'ClearColor': {
1210 'type': 'StateSet', 1212 'type': 'StateSet',
1211 'state': 'ClearColor', 1213 'state': 'ClearColor',
1212 }, 1214 },
1213 'ClearDepthf': { 1215 'ClearDepthf': {
1214 'type': 'StateSet', 1216 'type': 'StateSet',
1215 'state': 'ClearDepthf', 1217 'state': 'ClearDepthf',
1216 'decoder_func': 'glClearDepth', 1218 'decoder_func': 'glClearDepth',
1217 'gl_test_func': 'glClearDepth', 1219 'gl_test_func': 'glClearDepth',
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 'bucket': True, 1258 'bucket': True,
1257 }, 1259 },
1258 'CompressedTexSubImage2D': { 1260 'CompressedTexSubImage2D': {
1259 'type': 'Data', 1261 'type': 'Data',
1260 'bucket': True, 1262 'bucket': True,
1261 'decoder_func': 'DoCompressedTexSubImage2D', 1263 'decoder_func': 'DoCompressedTexSubImage2D',
1262 }, 1264 },
1263 'CopyTexImage2D': { 1265 'CopyTexImage2D': {
1264 'decoder_func': 'DoCopyTexImage2D', 1266 'decoder_func': 'DoCopyTexImage2D',
1265 'unit_test': False, 1267 'unit_test': False,
1268 'defer_reads': True,
1266 }, 1269 },
1267 'CopyTexSubImage2D': { 1270 'CopyTexSubImage2D': {
1268 'decoder_func': 'DoCopyTexSubImage2D', 1271 'decoder_func': 'DoCopyTexSubImage2D',
1272 'defer_reads': True,
1269 }, 1273 },
1270 'CreateProgram': { 1274 'CreateProgram': {
1271 'type': 'Create', 1275 'type': 'Create',
1272 'client_test': False, 1276 'client_test': False,
1273 }, 1277 },
1274 'CreateShader': { 1278 'CreateShader': {
1275 'type': 'Create', 1279 'type': 'Create',
1276 'client_test': False, 1280 'client_test': False,
1277 }, 1281 },
1278 'BlendColor': { 1282 'BlendColor': {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 'impl_func': False, 1393 'impl_func': False,
1390 'client_test': False, 1394 'client_test': False,
1391 }, 1395 },
1392 'DisableVertexAttribArray': { 1396 'DisableVertexAttribArray': {
1393 'decoder_func': 'DoDisableVertexAttribArray', 1397 'decoder_func': 'DoDisableVertexAttribArray',
1394 'impl_decl': False, 1398 'impl_decl': False,
1395 }, 1399 },
1396 'DrawArrays': { 1400 'DrawArrays': {
1397 'type': 'Manual', 1401 'type': 'Manual',
1398 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count', 1402 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count',
1403 'defer_draws': True,
1399 }, 1404 },
1400 'DrawElements': { 1405 'DrawElements': {
1401 'type': 'Manual', 1406 'type': 'Manual',
1402 'cmd_args': 'GLenumDrawMode mode, GLsizei count, ' 1407 'cmd_args': 'GLenumDrawMode mode, GLsizei count, '
1403 'GLenumIndexType type, GLuint index_offset', 1408 'GLenumIndexType type, GLuint index_offset',
1404 'client_test': False 1409 'client_test': False,
1410 'defer_draws': True,
1405 }, 1411 },
1406 'Enable': { 1412 'Enable': {
1407 'decoder_func': 'DoEnable', 1413 'decoder_func': 'DoEnable',
1408 'impl_func': False, 1414 'impl_func': False,
1409 'client_test': False, 1415 'client_test': False,
1410 }, 1416 },
1411 'EnableVertexAttribArray': { 1417 'EnableVertexAttribArray': {
1412 'decoder_func': 'DoEnableVertexAttribArray', 1418 'decoder_func': 'DoEnableVertexAttribArray',
1413 'impl_decl': False, 1419 'impl_decl': False,
1414 }, 1420 },
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 'type': 'Custom', 1793 'type': 'Custom',
1788 'immediate': False, 1794 'immediate': False,
1789 'impl_func': False, 1795 'impl_func': False,
1790 'client_test': False, 1796 'client_test': False,
1791 'cmd_args': 1797 'cmd_args':
1792 'GLint x, GLint y, GLsizei width, GLsizei height, ' 1798 'GLint x, GLint y, GLsizei width, GLsizei height, '
1793 'GLenumReadPixelFormat format, GLenumReadPixelType type, ' 1799 'GLenumReadPixelFormat format, GLenumReadPixelType type, '
1794 'uint32 pixels_shm_id, uint32 pixels_shm_offset, ' 1800 'uint32 pixels_shm_id, uint32 pixels_shm_offset, '
1795 'uint32 result_shm_id, uint32 result_shm_offset', 1801 'uint32 result_shm_id, uint32 result_shm_offset',
1796 'result': ['uint32'], 1802 'result': ['uint32'],
1803 'defer_reads': True,
1797 }, 1804 },
1798 'RegisterSharedIdsCHROMIUM': { 1805 'RegisterSharedIdsCHROMIUM': {
1799 'type': 'Custom', 1806 'type': 'Custom',
1800 'decoder_func': 'DoRegisterSharedIdsCHROMIUM', 1807 'decoder_func': 'DoRegisterSharedIdsCHROMIUM',
1801 'impl_func': False, 1808 'impl_func': False,
1802 'expectation': False, 1809 'expectation': False,
1803 'immediate': False, 1810 'immediate': False,
1804 'extension': True, 1811 'extension': True,
1805 'chromium': True, 1812 'chromium': True,
1806 }, 1813 },
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 'extension': True, 2097 'extension': True,
2091 'decoder_func': 'DoTexStorage2DEXT', 2098 'decoder_func': 'DoTexStorage2DEXT',
2092 }, 2099 },
2093 'DrawArraysInstancedANGLE': { 2100 'DrawArraysInstancedANGLE': {
2094 'type': 'Manual', 2101 'type': 'Manual',
2095 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count, ' 2102 'cmd_args': 'GLenumDrawMode mode, GLint first, GLsizei count, '
2096 'GLsizei primcount', 2103 'GLsizei primcount',
2097 'extension': True, 2104 'extension': True,
2098 'unit_test': False, 2105 'unit_test': False,
2099 'pepper_interface': 'InstancedArrays', 2106 'pepper_interface': 'InstancedArrays',
2107 'defer_draws': True,
2100 }, 2108 },
2101 'DrawElementsInstancedANGLE': { 2109 'DrawElementsInstancedANGLE': {
2102 'type': 'Manual', 2110 'type': 'Manual',
2103 'cmd_args': 'GLenumDrawMode mode, GLsizei count, ' 2111 'cmd_args': 'GLenumDrawMode mode, GLsizei count, '
2104 'GLenumIndexType type, GLuint index_offset, GLsizei primcount', 2112 'GLenumIndexType type, GLuint index_offset, GLsizei primcount',
2105 'extension': True, 2113 'extension': True,
2106 'unit_test': False, 2114 'unit_test': False,
2107 'client_test': False, 2115 'client_test': False,
2108 'pepper_interface': 'InstancedArrays', 2116 'pepper_interface': 'InstancedArrays',
2117 'defer_draws': True,
2109 }, 2118 },
2110 'VertexAttribDivisorANGLE': { 2119 'VertexAttribDivisorANGLE': {
2111 'type': 'Manual', 2120 'type': 'Manual',
2112 'cmd_args': 'GLuint index, GLuint divisor', 2121 'cmd_args': 'GLuint index, GLuint divisor',
2113 'extension': True, 2122 'extension': True,
2114 'unit_test': False, 2123 'unit_test': False,
2115 'pepper_interface': 'InstancedArrays', 2124 'pepper_interface': 'InstancedArrays',
2116 }, 2125 },
2117 'GenQueriesEXT': { 2126 'GenQueriesEXT': {
2118 'type': 'GENn', 2127 'type': 'GENn',
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 """Writes the handler impl for the bucket version of a command.""" 2568 """Writes the handler impl for the bucket version of a command."""
2560 file.Write(" %s(%s);\n" % 2569 file.Write(" %s(%s);\n" %
2561 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) 2570 (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
2562 2571
2563 def WriteServiceImplementation(self, func, file): 2572 def WriteServiceImplementation(self, func, file):
2564 """Writes the service implementation for a command.""" 2573 """Writes the service implementation for a command."""
2565 file.Write( 2574 file.Write(
2566 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name) 2575 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
2567 file.Write( 2576 file.Write(
2568 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name) 2577 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
2578 self.WriteHandlerDeferReadWrite(func, file);
2569 if len(func.GetOriginalArgs()) > 0: 2579 if len(func.GetOriginalArgs()) > 0:
2570 last_arg = func.GetLastOriginalArg() 2580 last_arg = func.GetLastOriginalArg()
2571 all_but_last_arg = func.GetOriginalArgs()[:-1] 2581 all_but_last_arg = func.GetOriginalArgs()[:-1]
2572 for arg in all_but_last_arg: 2582 for arg in all_but_last_arg:
2573 arg.WriteGetCode(file) 2583 arg.WriteGetCode(file)
2574 self.WriteGetDataSizeCode(func, file) 2584 self.WriteGetDataSizeCode(func, file)
2575 last_arg.WriteGetCode(file) 2585 last_arg.WriteGetCode(file)
2576 func.WriteHandlerValidation(file) 2586 func.WriteHandlerValidation(file)
2577 func.WriteHandlerImplementation(file) 2587 func.WriteHandlerImplementation(file)
2578 file.Write(" return error::kNoError;\n") 2588 file.Write(" return error::kNoError;\n")
2579 file.Write("}\n") 2589 file.Write("}\n")
2580 file.Write("\n") 2590 file.Write("\n")
2581 2591
2582 def WriteImmediateServiceImplementation(self, func, file): 2592 def WriteImmediateServiceImplementation(self, func, file):
2583 """Writes the service implementation for an immediate version of command.""" 2593 """Writes the service implementation for an immediate version of command."""
2584 file.Write( 2594 file.Write(
2585 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name) 2595 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
2586 file.Write( 2596 file.Write(
2587 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name) 2597 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
2598 self.WriteHandlerDeferReadWrite(func, file);
2588 last_arg = func.GetLastOriginalArg() 2599 last_arg = func.GetLastOriginalArg()
2589 all_but_last_arg = func.GetOriginalArgs()[:-1] 2600 all_but_last_arg = func.GetOriginalArgs()[:-1]
2590 for arg in all_but_last_arg: 2601 for arg in all_but_last_arg:
2591 arg.WriteGetCode(file) 2602 arg.WriteGetCode(file)
2592 self.WriteGetDataSizeCode(func, file) 2603 self.WriteGetDataSizeCode(func, file)
2593 last_arg.WriteGetCode(file) 2604 last_arg.WriteGetCode(file)
2594 func.WriteHandlerValidation(file) 2605 func.WriteHandlerValidation(file)
2595 func.WriteHandlerImplementation(file) 2606 func.WriteHandlerImplementation(file)
2596 file.Write(" return error::kNoError;\n") 2607 file.Write(" return error::kNoError;\n")
2597 file.Write("}\n") 2608 file.Write("}\n")
2598 file.Write("\n") 2609 file.Write("\n")
2599 2610
2600 def WriteBucketServiceImplementation(self, func, file): 2611 def WriteBucketServiceImplementation(self, func, file):
2601 """Writes the service implementation for a bucket version of command.""" 2612 """Writes the service implementation for a bucket version of command."""
2602 file.Write( 2613 file.Write(
2603 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name) 2614 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
2604 file.Write( 2615 file.Write(
2605 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name) 2616 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
2617 self.WriteHandlerDeferReadWrite(func, file);
2606 last_arg = func.GetLastOriginalArg() 2618 last_arg = func.GetLastOriginalArg()
2607 all_but_last_arg = func.GetOriginalArgs()[:-1] 2619 all_but_last_arg = func.GetOriginalArgs()[:-1]
2608 for arg in all_but_last_arg: 2620 for arg in all_but_last_arg:
2609 arg.WriteGetCode(file) 2621 arg.WriteGetCode(file)
2610 self.WriteGetDataSizeCode(func, file) 2622 self.WriteGetDataSizeCode(func, file)
2611 last_arg.WriteGetCode(file) 2623 last_arg.WriteGetCode(file)
2612 func.WriteHandlerValidation(file) 2624 func.WriteHandlerValidation(file)
2613 func.WriteHandlerImplementation(file) 2625 func.WriteHandlerImplementation(file)
2614 file.Write(" return error::kNoError;\n") 2626 file.Write(" return error::kNoError;\n")
2615 file.Write("}\n") 2627 file.Write("}\n")
2616 file.Write("\n") 2628 file.Write("\n")
2617 2629
2630 def WriteHandlerDeferReadWrite(self, func, file):
2631 """Writes the code to handle deferring reads or writes."""
2632 defer_reads = func.GetInfo('defer_reads')
2633 defer_draws = func.GetInfo('defer_draws')
2634 conditions = []
2635 if defer_draws:
2636 conditions.append('ShouldDeferDraws()');
2637 if defer_reads:
2638 conditions.append('ShouldDeferReads()');
2639 if not conditions:
2640 return
2641 file.Write(" if (%s)\n" % ' || '.join(conditions))
2642 file.Write(" return error::kDeferCommandUntilLater;\n")
2643
2618 def WriteValidUnitTest(self, func, file, test, extra = {}): 2644 def WriteValidUnitTest(self, func, file, test, extra = {}):
2619 """Writes a valid unit test.""" 2645 """Writes a valid unit test."""
2620 if func.GetInfo('expectation') == False: 2646 if func.GetInfo('expectation') == False:
2621 test = self._remove_expected_call_re.sub('', test) 2647 test = self._remove_expected_call_re.sub('', test)
2622 name = func.name 2648 name = func.name
2623 arg_strings = [] 2649 arg_strings = []
2624 for count, arg in enumerate(func.GetOriginalArgs()): 2650 for count, arg in enumerate(func.GetOriginalArgs()):
2625 arg_strings.append(arg.GetValidArg(func, count, 0)) 2651 arg_strings.append(arg.GetValidArg(func, count, 0))
2626 gl_arg_strings = [] 2652 gl_arg_strings = []
2627 for count, arg in enumerate(func.GetOriginalArgs()): 2653 for count, arg in enumerate(func.GetOriginalArgs()):
(...skipping 4797 matching lines...) Expand 10 before | Expand all | Expand 10 after
7425 gen.WriteGLES2Header("../../third_party/khronos/GLES2/gl2chromium.h") 7451 gen.WriteGLES2Header("../../third_party/khronos/GLES2/gl2chromium.h")
7426 7452
7427 if gen.errors > 0: 7453 if gen.errors > 0:
7428 print "%d errors" % gen.errors 7454 print "%d errors" % gen.errors
7429 return 1 7455 return 1
7430 return 0 7456 return 0
7431 7457
7432 7458
7433 if __name__ == '__main__': 7459 if __name__ == '__main__':
7434 sys.exit(main(sys.argv[1:])) 7460 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698