summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorsheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-03 23:39:50 +0000
committersheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-03 23:39:50 +0000
commitdf41e253e6918cd035c36936761734f2ac694466 (patch)
tree9f92ab76398898bbd0f880d821e39a433018526c /gpu
parent3a48972e78af233d570818d21f426afa8c51c2ff (diff)
downloadchromium_src-df41e253e6918cd035c36936761734f2ac694466.zip
chromium_src-df41e253e6918cd035c36936761734f2ac694466.tar.gz
chromium_src-df41e253e6918cd035c36936761734f2ac694466.tar.bz2
Add gpu::MailboxHolder to hold state for a gpu::Mailbox
gpu::Mailbox by itself can hold only a texture id, but in common usage it comes with texture target and syncpoint information for cross-context sharing. To reduce repetition of this pattern, gpu::MailboxHolder holds: * a gpu::Mailbox * a GL texture target * a syncpoint index Refactor other classes to use a gpu::MailboxHolder instead of separate gpu::Mailbox and associated state. Syncpoints are created with uint32 indices; make sure all uses of syncpoints use the appropriate type. BUG=None TEST=local build, unittests on CrOS snow, desktop Linux TBR=piman@chromium.org, enn@chromium.orge, cevans@chromium.org, scherkus@chromium.org Review URL: https://codereview.chromium.org/132233041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/common/mailbox_holder.cc18
-rw-r--r--gpu/command_buffer/common/mailbox_holder.h28
-rw-r--r--gpu/command_buffer_common.gypi10
-rw-r--r--gpu/ipc/gpu_command_buffer_traits.cc22
-rw-r--r--gpu/ipc/gpu_command_buffer_traits.h9
5 files changed, 82 insertions, 5 deletions
diff --git a/gpu/command_buffer/common/mailbox_holder.cc b/gpu/command_buffer/common/mailbox_holder.cc
new file mode 100644
index 0000000..a8cb6fb
--- /dev/null
+++ b/gpu/command_buffer/common/mailbox_holder.cc
@@ -0,0 +1,18 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/common/mailbox_holder.h"
+
+namespace gpu {
+
+MailboxHolder::MailboxHolder() : texture_target(0), sync_point(0) {}
+
+MailboxHolder::MailboxHolder(const Mailbox& mailbox,
+ uint32 texture_target,
+ uint32 sync_point)
+ : mailbox(mailbox),
+ texture_target(texture_target),
+ sync_point(sync_point) {}
+
+} // namespace gpu
diff --git a/gpu/command_buffer/common/mailbox_holder.h b/gpu/command_buffer/common/mailbox_holder.h
new file mode 100644
index 0000000..a17d8d3
--- /dev/null
+++ b/gpu/command_buffer/common/mailbox_holder.h
@@ -0,0 +1,28 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_MAILBOX_HOLDER_H_
+#define GPU_COMMAND_BUFFER_MAILBOX_HOLDER_H_
+
+#include <string.h>
+
+#include "gpu/command_buffer/common/mailbox.h"
+#include "gpu/command_buffer/common/types.h"
+#include "gpu/gpu_export.h"
+
+namespace gpu {
+
+struct GPU_EXPORT MailboxHolder {
+ MailboxHolder();
+ MailboxHolder(const gpu::Mailbox& mailbox,
+ uint32 texture_target,
+ uint32 sync_point);
+ gpu::Mailbox mailbox;
+ uint32 texture_target;
+ uint32 sync_point;
+};
+
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_MAILBOX_HOLDER_H_
diff --git a/gpu/command_buffer_common.gypi b/gpu/command_buffer_common.gypi
index 87eeb5b..b983119b 100644
--- a/gpu/command_buffer_common.gypi
+++ b/gpu/command_buffer_common.gypi
@@ -11,22 +11,24 @@
'command_buffer/common/buffer.h',
'command_buffer/common/capabilities.cc',
'command_buffer/common/capabilities.h',
- 'command_buffer/common/cmd_buffer_common.h',
'command_buffer/common/cmd_buffer_common.cc',
+ 'command_buffer/common/cmd_buffer_common.h',
'command_buffer/common/command_buffer.h',
'command_buffer/common/constants.h',
'command_buffer/common/debug_marker_manager.cc',
'command_buffer/common/debug_marker_manager.h',
- 'command_buffer/common/gles2_cmd_ids_autogen.h',
- 'command_buffer/common/gles2_cmd_ids.h',
- 'command_buffer/common/gles2_cmd_format_autogen.h',
'command_buffer/common/gles2_cmd_format.cc',
'command_buffer/common/gles2_cmd_format.h',
+ 'command_buffer/common/gles2_cmd_format_autogen.h',
+ 'command_buffer/common/gles2_cmd_ids.h',
+ 'command_buffer/common/gles2_cmd_ids_autogen.h',
'command_buffer/common/gpu_control.h',
'command_buffer/common/id_allocator.cc',
'command_buffer/common/id_allocator.h',
'command_buffer/common/mailbox.cc',
'command_buffer/common/mailbox.h',
+ 'command_buffer/common/mailbox_holder.cc',
+ 'command_buffer/common/mailbox_holder.h',
'command_buffer/common/thread_local.h',
'command_buffer/common/time.h',
'command_buffer/common/types.h',
diff --git a/gpu/ipc/gpu_command_buffer_traits.cc b/gpu/ipc/gpu_command_buffer_traits.cc
index d9fc17d..db482a9 100644
--- a/gpu/ipc/gpu_command_buffer_traits.cc
+++ b/gpu/ipc/gpu_command_buffer_traits.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "gpu/ipc/gpu_command_buffer_traits.h"
-#include "gpu/command_buffer/common/mailbox.h"
+#include "gpu/command_buffer/common/mailbox_holder.h"
namespace IPC {
@@ -59,5 +59,25 @@ void ParamTraits<gpu::Mailbox>::Log(const param_type& p, std::string* l) {
*l += base::StringPrintf("%02x", p.name[i]);
}
+void ParamTraits<gpu::MailboxHolder>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.mailbox);
+ WriteParam(m, p.texture_target);
+ WriteParam(m, p.sync_point);
+}
+
+bool ParamTraits<gpu::MailboxHolder>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ if (!ReadParam(m, iter, &p->mailbox) ||
+ !ReadParam(m, iter, &p->texture_target) ||
+ !ReadParam(m, iter, &p->sync_point))
+ return false;
+ return true;
+}
+
+void ParamTraits<gpu::MailboxHolder>::Log(const param_type& p, std::string* l) {
+ ParamTraits<gpu::Mailbox>::Log(p.mailbox, l);
+ *l += base::StringPrintf(":%04x@%d", p.texture_target, p.sync_point);
+}
} // namespace IPC
diff --git a/gpu/ipc/gpu_command_buffer_traits.h b/gpu/ipc/gpu_command_buffer_traits.h
index 6b2531f..ce854d2 100644
--- a/gpu/ipc/gpu_command_buffer_traits.h
+++ b/gpu/ipc/gpu_command_buffer_traits.h
@@ -11,6 +11,7 @@
namespace gpu {
struct Mailbox;
+struct MailboxHolder;
}
namespace IPC {
@@ -31,6 +32,14 @@ struct GPU_EXPORT ParamTraits<gpu::Mailbox> {
static void Log(const param_type& p, std::string* l);
};
+template <>
+struct GPU_EXPORT ParamTraits<gpu::MailboxHolder> {
+ typedef gpu::MailboxHolder param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, PickleIterator* iter, param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
} // namespace IPC
#endif // GPU_IPC_GPU_PARAM_TRAITS_H_