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

Unified Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 299043003: Adding bindless variants mailbox produce/consume (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
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 470ff299c2515234dc08f8f2acc21156b2812dfe..6dc2da59d97275a6e8209d9dd9dbad8f0b720d44 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1383,6 +1383,17 @@ _FUNCTION_INFO = {
'chromium': True,
'trace_level': 1,
},
+ 'CreateAndConsumeTextureCHROMIUM': {
+ 'decoder_func': 'DoCreateAndConsumeTextureCHROMIUM',
+ 'impl_func': False,
+ 'type': 'CreateAndConsume',
piman 2014/05/22 21:53:58 I'm not convinced it's worth creating a new type j
+ 'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
+ 'unit_test': False,
+ 'client_test': False,
+ 'extension': True,
+ 'chromium': True,
+ 'trace_level': 1,
+ },
'ClearStencil': {
'type': 'StateSet',
'state': 'ClearStencil',
@@ -1976,6 +1987,17 @@ _FUNCTION_INFO = {
'chromium': True,
'trace_level': 1,
},
+ 'ProduceTextureBindlessCHROMIUM': {
+ 'decoder_func': 'DoProduceTextureBindlessCHROMIUM',
+ 'impl_func': False,
+ 'type': 'PUT',
+ 'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
+ 'unit_test': False,
+ 'client_test': False,
+ 'extension': True,
+ 'chromium': True,
+ 'trace_level': 1,
+ },
'RenderbufferStorage': {
'decoder_func': 'DoRenderbufferStorage',
'gl_test_func': 'glRenderbufferStorageEXT',
@@ -4240,12 +4262,37 @@ TEST_P(%(test_name)s, %(name)sInvalidArgs) {
file.Write("\n")
-class CreateHandler(TypeHandler):
- """Handler for glCreate___ type functions."""
+class ArrayArgTypeHandler(TypeHandler):
+ """Base class for type handlers that handle args that are arrays"""
def __init__(self):
TypeHandler.__init__(self)
+ def GetArrayType(self, func):
+ """Returns the type of the element in the element array being PUT to."""
+ for arg in func.GetOriginalArgs():
+ if arg.IsPointer():
+ element_type = arg.GetPointedType()
+ return element_type
+
+ # Special case: array type handler is used for a function that is forwarded
+ # to the actual array type implementation
+ element_type = func.GetOriginalArgs()[-1].type
+ assert all(arg.type == element_type \
+ for arg in func.GetOriginalArgs()[-self.GetArrayCount(func):])
+ return element_type
+
+ def GetArrayCount(self, func):
+ """Returns the count of the elements in the array being PUT to."""
+ return func.GetInfo('count')
+
+
+class CreateHandler(ArrayArgTypeHandler):
+ """Handler for glCreate___ type functions."""
+
+ def __init__(self):
+ ArrayArgTypeHandler.__init__(self)
+
def InitFunction(self, func):
"""Overrriden from TypeHandler."""
func.AddCmdArg(Argument("client_id", 'uint32_t'))
@@ -4315,6 +4362,127 @@ TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
file.Write("\n")
+class CreateAndConsumeHandler(CreateHandler):
+ """Handler for glCreateAndConsumeTextureCHROMIUM."""
+
+ def __init__(self):
+ CreateHandler.__init__(self)
+
+ def WriteGLES2Implementation(self, func, file):
+ """Overrriden from TypeHandler."""
+ pass
+
+ def WriteHandlerImplementation (self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write(" uint32_t client_id = c.client_id;\n")
+ file.Write(" %s(%s, client_id);\n" %
+ (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
+
+ def WriteImmediateHandlerImplementation (self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write(" uint32_t client_id = c.client_id;\n")
+ file.Write(" %s(%s, client_id);\n" %
+ (func.GetGLFunctionName(), func.MakeOriginalArgString("")))
+
+ def WriteImmediateServiceImplementation(self, func, file):
+ """Writes the service implementation for an immediate version of command."""
+ file.Write(
+ "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
+ file.Write(
+ " uint32_t immediate_data_size, const gles2::cmds::%s& c) {\n" %
+ func.name)
+ self.WriteHandlerExtensionCheck(func, file)
+ self.WriteHandlerDeferReadWrite(func, file);
+ last_arg = func.GetLastOriginalArg()
+ all_but_last_arg = func.GetOriginalArgs()[:-1]
+ for arg in all_but_last_arg:
+ arg.WriteGetCode(file)
+ self.WriteGetDataSizeCode(func, file)
+ last_arg.WriteGetCode(file)
+ func.WriteHandlerValidation(file)
+ func.WriteHandlerImplementation(file)
+ file.Write(" return error::kNoError;\n")
+ file.Write("}\n")
+ file.Write("\n")
+
+ def WriteGetDataSizeCode(self, func, file):
+ """Overrriden from TypeHandler."""
+ code = """ uint32_t data_size;
+ if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) {
+ return error::kOutOfBounds;
+ }
+"""
+ file.Write(code % (self.GetArrayType(func), self.GetArrayCount(func)))
+ if func.IsImmediate():
+ file.Write(" if (data_size > immediate_data_size) {\n")
+ file.Write(" return error::kOutOfBounds;\n")
+ file.Write(" }\n")
+
+ def WriteImmediateCmdComputeSize(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write(" static uint32_t ComputeDataSize() {\n")
+ file.Write(" return static_cast<uint32_t>(\n")
+ file.Write(" sizeof(%s) * %d); // NOLINT\n" %
+ (self.GetArrayType(func), self.GetArrayCount(func)))
+ file.Write(" }\n")
+ file.Write("\n")
+ file.Write(" static uint32_t ComputeSize() {\n")
+ file.Write(" return static_cast<uint32_t>(\n")
+ file.Write(
+ " sizeof(ValueType) + ComputeDataSize()); // NOLINT\n")
+ file.Write(" }\n")
+ file.Write("\n")
+
+ def WriteImmediateCmdInit(self, func, file):
+ """Overrriden from TypeHandler."""
+ last_arg = func.GetLastOriginalArg()
+ file.Write(" void Init(%s, %s _%s) {\n" %
+ (func.MakeTypedCmdArgString("_"),
+ last_arg.type, last_arg.name))
+ file.Write(" SetHeader(ComputeSize());\n")
+ args = func.GetCmdArgs()
+ for arg in args:
+ file.Write(" %s = _%s;\n" % (arg.name, arg.name))
+ file.Write(" memcpy(ImmediateDataAddress(this),\n")
+ file.Write(" _%s, ComputeDataSize());\n" % last_arg.name)
+ file.Write(" }\n")
+ file.Write("\n")
+
+ def WriteImmediateCmdSet(self, func, file):
+ """Overrriden from TypeHandler."""
+ last_arg = func.GetLastOriginalArg()
+ copy_args = func.MakeCmdArgString("_", False)
+ file.Write(" void* Set(void* cmd%s, %s _%s) {\n" %
+ (func.MakeTypedCmdArgString("_", True),
+ last_arg.type, last_arg.name))
+ file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" %
+ (copy_args, last_arg.name))
+ file.Write(" const uint32_t size = ComputeSize();\n")
+ file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
+ "cmd, size);\n")
+ file.Write(" }\n")
+ file.Write("\n")
+
+ def WriteImmediateCmdHelper(self, func, file):
+ """Writes the cmd helper definition for the immediate version of a cmd."""
+ code = """ void %(name)s(%(typed_args)s) {
+ const uint32_t size = gles2::cmds::%(name)s::ComputeSize();
+ gles2::cmds::%(name)s* c =
+ GetImmediateCmdSpaceTotalSize<gles2::cmds::%(name)s>(size);
+ if (c) {
+ c->Init(%(args)s);
+ }
+ }
+
+"""
+ last_arg = func.GetLastOriginalArg()
+ file.Write(code % {
+ "name": func.name,
+ "typed_args": '%s, %s _%s' % (func.MakeTypedCmdArgString(""),
+ last_arg.type, last_arg.name),
+ "args": '%s, _%s' % (func.MakeCmdArgString(""), last_arg.name),
+ })
+
class DeleteHandler(TypeHandler):
"""Handler for glDelete___ single resource type functions."""
@@ -4790,29 +4958,6 @@ TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
"""
self.WriteInvalidUnitTest(func, file, invalid_test)
-class ArrayArgTypeHandler(TypeHandler):
- """Base class for type handlers that handle args that are arrays"""
-
- def __init__(self):
- TypeHandler.__init__(self)
-
- def GetArrayType(self, func):
- """Returns the type of the element in the element array being PUT to."""
- for arg in func.GetOriginalArgs():
- if arg.IsPointer():
- element_type = arg.GetPointedType()
- return element_type
-
- # Special case: array type handler is used for a function that is forwarded
- # to the actual array type implementation
- element_type = func.GetOriginalArgs()[-1].type
- assert all(arg.type == element_type \
- for arg in func.GetOriginalArgs()[-self.GetArrayCount(func):])
- return element_type
-
- def GetArrayCount(self, func):
- """Returns the count of the elements in the array being PUT to."""
- return func.GetInfo('count')
class PUTHandler(ArrayArgTypeHandler):
"""Handler for glTexParameter_v, glVertexAttrib_v functions."""
@@ -6607,6 +6752,7 @@ class Function(object):
'': TypeHandler(),
'Bind': BindHandler(),
'Create': CreateHandler(),
+ 'CreateAndConsume': CreateAndConsumeHandler(),
'Custom': CustomHandler(),
'Data': DataHandler(),
'Delete': DeleteHandler(),

Powered by Google App Engine
This is Rietveld 408576698