summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authordyen <dyen@chromium.org>2015-10-14 10:26:11 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-14 17:27:32 +0000
commit55719a12b75e7057574a81d83117a0dfeed6f858 (patch)
tree8edf41815f20296f121fce90692db017df89fa9a /gpu
parentd0e06a58f51ee83a670829425cd65a5693909eee (diff)
downloadchromium_src-55719a12b75e7057574a81d83117a0dfeed6f858.zip
chromium_src-55719a12b75e7057574a81d83117a0dfeed6f858.tar.gz
chromium_src-55719a12b75e7057574a81d83117a0dfeed6f858.tar.bz2
Added method to wait on fence syncs which do not need to be flushed.
With streams from the same channel, we do not need to flush before we can wait on the fence sync. I've added a new method which generates a sync token for unflushed fences (glGenUnverifiedSyncTokenCHROMIUM). Sync tokens generated using this function will be validated when glWaitSyncTokenCHROMIUM is called to validate that it did not need to be flushed and validated. R=jam@chromium.org, piman@chromium.org, rjkroege@chromium.org BUG=514815 Review URL: https://codereview.chromium.org/1401463004 Cr-Commit-Position: refs/heads/master@{#354051}
Diffstat (limited to 'gpu')
-rw-r--r--gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt30
-rw-r--r--gpu/GLES2/gl2chromium_autogen.h2
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py6
-rw-r--r--gpu/command_buffer/client/client_test_helper.h2
-rw-r--r--gpu/command_buffer/client/gles2_c_lib_autogen.h9
-rw-r--r--gpu/command_buffer/client/gles2_cmd_helper_autogen.h10
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc31
-rw-r--r--gpu/command_buffer/client/gles2_implementation_autogen.h3
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest.cc61
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest_autogen.h1
-rw-r--r--gpu/command_buffer/client/gles2_interface_autogen.h2
-rw-r--r--gpu/command_buffer/client/gles2_interface_stub_autogen.h2
-rw-r--r--gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h3
-rw-r--r--gpu/command_buffer/client/gles2_trace_implementation_autogen.h2
-rw-r--r--gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h8
-rw-r--r--gpu/command_buffer/client/gpu_control.h13
-rw-r--r--gpu/command_buffer/cmd_buffer_functions.txt1
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_autogen.h40
-rw-r--r--gpu/command_buffer/common/gles2_cmd_ids_autogen.h47
-rw-r--r--gpu/command_buffer/common/sync_token.h12
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc6
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h2
-rw-r--r--gpu/command_buffer/service/in_process_command_buffer.cc9
-rw-r--r--gpu/command_buffer/service/in_process_command_buffer.h2
-rw-r--r--gpu/command_buffer/tests/gl_manager.cc8
-rw-r--r--gpu/command_buffer/tests/gl_manager.h2
-rw-r--r--gpu/gles2_conform_support/egl/display.cc8
-rw-r--r--gpu/gles2_conform_support/egl/display.h2
28 files changed, 290 insertions, 34 deletions
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt
index 80df38e..3ec5e1e 100644
--- a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt
+++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt
@@ -67,13 +67,31 @@ New Procedures and Functions
The command
+ void GenUnverifiedSyncTokenCHROMIUM(uint64 fence_sync,
+ GLbyte *sync_token)
+
+ converts <fence_sync> which is only visible to the current context to a
+ sync token which may be waited upon by a context which only needs flush
+ order guarantee with respect to the fence sync context. For example, if
+ the two contexts are on the same channel but on different streams, flush
+ order guarantee is enough to guarantee that the server will receive the
+ release command before the wait command. The <fence_sync> command must be
+ flushed before this function may be called, otherwise an INVALID_OPERATION
+ error is generated. The generated <sync_token> must be generated on the
+ same context as when InsertSyncPointCHROMIUM was called.
+
+ The command
+
void WaitSyncTokenCHROMIUM(const GLbyte *sync_token)
causes the current context to stop submitting commands until the specified
fence sync becomes signaled. This is implemented as a server-side wait.
<sync_token> is a sync token generated by GenSyncPointCHROMIUM. If
- <sync_token> isn't a valid sync token returned by GenSyncPointCHROMIUM, the
- command is equivalent to a no-op and no error is generated.
+ <sync_token> was generated by GenUnverifiedSyncTokenCHROMIUM and the
+ corresponding fence sync context required more than just flush ordering
+ to guarantee synchronization, a INVALID_OPERATION error is generated. If
+ <sync_token> isn't a valid sync token returned by GenSyncPointCHROMIUM or
+ GenUnverifiedSyncTokenCHROMIUM, the result is undefined.
New Tokens
@@ -89,6 +107,10 @@ Errors
INVALID_OPERATION is generated if the <fence_sync> parameter of
GenSyncPointCHROMIUM has not been flushed to the server.
+ INVALID_OPERATION is generated if the <sync_token> parameter of
+ WaitSyncTokenCHROMIUM was generated using GenUnverifiedSyncTokenCHROMIUM
+ but the two contexts must be synchronized with more than just flush order.
+
New State
None.
@@ -97,5 +119,7 @@ Revision History
2/25/2013 Documented the extension
- 9/8/2015 Modified functions to InsertFenceSyncCHROMIUM,
+ 9/8/2015 Modified functions InsertFenceSyncCHROMIUM,
GenSyncTokenCHROMIUM, and WaitSyncTokenCHROMIUM.
+
+ 10/12/2015 Added function GenUnverifiedSyncTokenCHROMIUM.
diff --git a/gpu/GLES2/gl2chromium_autogen.h b/gpu/GLES2/gl2chromium_autogen.h
index 3b30b9b..901c753 100644
--- a/gpu/GLES2/gl2chromium_autogen.h
+++ b/gpu/GLES2/gl2chromium_autogen.h
@@ -329,6 +329,8 @@
#define glWaitSyncPointCHROMIUM GLES2_GET_FUN(WaitSyncPointCHROMIUM)
#define glInsertFenceSyncCHROMIUM GLES2_GET_FUN(InsertFenceSyncCHROMIUM)
#define glGenSyncTokenCHROMIUM GLES2_GET_FUN(GenSyncTokenCHROMIUM)
+#define glGenUnverifiedSyncTokenCHROMIUM \
+ GLES2_GET_FUN(GenUnverifiedSyncTokenCHROMIUM)
#define glWaitSyncTokenCHROMIUM GLES2_GET_FUN(WaitSyncTokenCHROMIUM)
#define glDrawBuffersEXT GLES2_GET_FUN(DrawBuffersEXT)
#define glDiscardBackbufferCHROMIUM GLES2_GET_FUN(DiscardBackbufferCHROMIUM)
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 5affdcb..8a32238 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -4096,6 +4096,12 @@ _FUNCTION_INFO = {
'extension': "CHROMIUM_sync_point",
'chromium': True,
},
+ 'GenUnverifiedSyncTokenCHROMIUM': {
+ 'type': 'Custom',
+ 'impl_func': False,
+ 'extension': "CHROMIUM_sync_point",
+ 'chromium': True,
+ },
'WaitSyncTokenCHROMIUM': {
'type': 'Custom',
'impl_func': False,
diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h
index a0733b5..a5b9bf6 100644
--- a/gpu/command_buffer/client/client_test_helper.h
+++ b/gpu/command_buffer/client/client_test_helper.h
@@ -117,6 +117,8 @@ class MockClientGpuControl : public GpuControl {
MOCK_METHOD0(GenerateFenceSyncRelease, uint64_t());
MOCK_METHOD1(IsFenceSyncRelease, bool(uint64_t release));
MOCK_METHOD1(IsFenceSyncFlushed, bool(uint64_t release));
+ MOCK_METHOD1(IsFenceSyncFlushReceived, bool(uint64_t release));
+ MOCK_METHOD1(CanWaitUnverifiedSyncToken, bool(const SyncToken*));
private:
DISALLOW_COPY_AND_ASSIGN(MockClientGpuControl);
diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h
index 4b2ee2b..284f00d 100644
--- a/gpu/command_buffer/client/gles2_c_lib_autogen.h
+++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h
@@ -1488,6 +1488,10 @@ void GL_APIENTRY GLES2GenSyncTokenCHROMIUM(GLuint64 fence_sync,
GLbyte* sync_token) {
gles2::GetGLContext()->GenSyncTokenCHROMIUM(fence_sync, sync_token);
}
+void GL_APIENTRY GLES2GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
+ GLbyte* sync_token) {
+ gles2::GetGLContext()->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token);
+}
void GL_APIENTRY GLES2WaitSyncTokenCHROMIUM(const GLbyte* sync_token) {
gles2::GetGLContext()->WaitSyncTokenCHROMIUM(sync_token);
}
@@ -2738,6 +2742,11 @@ extern const NameToFunc g_gles2_function_table[] = {
reinterpret_cast<GLES2FunctionPointer>(glGenSyncTokenCHROMIUM),
},
{
+ "glGenUnverifiedSyncTokenCHROMIUM",
+ reinterpret_cast<GLES2FunctionPointer>(
+ glGenUnverifiedSyncTokenCHROMIUM),
+ },
+ {
"glWaitSyncTokenCHROMIUM",
reinterpret_cast<GLES2FunctionPointer>(glWaitSyncTokenCHROMIUM),
},
diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
index b722d6e..ec5b9f8 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
@@ -2775,6 +2775,16 @@ void GenSyncTokenCHROMIUMImmediate(GLuint64 fence_sync) {
}
}
+void GenUnverifiedSyncTokenCHROMIUMImmediate(GLuint64 fence_sync) {
+ const uint32_t s = 0; // TODO(gman): compute correct size
+ gles2::cmds::GenUnverifiedSyncTokenCHROMIUMImmediate* c =
+ GetImmediateCmdSpaceTotalSize<
+ gles2::cmds::GenUnverifiedSyncTokenCHROMIUMImmediate>(s);
+ if (c) {
+ c->Init(fence_sync);
+ }
+}
+
void WaitSyncTokenCHROMIUM(GLuint namespace_id,
GLuint64 command_buffer_id,
GLuint64 release_count) {
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index b1a2aa8..e91bbd6 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -5380,6 +5380,29 @@ void GLES2Implementation::GenSyncTokenCHROMIUM(GLuint64 fence_sync,
SetGLError(GL_INVALID_VALUE, "glGenSyncTokenCHROMIUM",
"invalid fence sync");
return;
+ } else if (!gpu_control_->IsFenceSyncFlushReceived(fence_sync)) {
+ SetGLError(GL_INVALID_OPERATION, "glGenSyncTokenCHROMIUM",
+ "fence sync must be flushed before generating sync token");
+ return;
+ }
+
+ // Copy the data over after setting the data to ensure alignment.
+ SyncToken sync_token_data(gpu_control_->GetNamespaceID(),
+ gpu_control_->GetCommandBufferID(), fence_sync);
+ sync_token_data.SetVerifyFlush();
+ memcpy(sync_token, &sync_token_data, sizeof(sync_token_data));
+}
+
+void GLES2Implementation::GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
+ GLbyte* sync_token) {
+ if (!sync_token) {
+ SetGLError(GL_INVALID_VALUE, "glGenNonFlushedSyncTokenCHROMIUM",
+ "empty sync_token");
+ return;
+ } else if (!gpu_control_->IsFenceSyncRelease(fence_sync)) {
+ SetGLError(GL_INVALID_VALUE, "glGenNonFlushedSyncTokenCHROMIUM",
+ "invalid fence sync");
+ return;
} else if (!gpu_control_->IsFenceSyncFlushed(fence_sync)) {
SetGLError(GL_INVALID_OPERATION, "glGenSyncTokenCHROMIUM",
"fence sync must be flushed before generating sync token");
@@ -5401,6 +5424,14 @@ void GLES2Implementation::WaitSyncTokenCHROMIUM(const GLbyte* sync_token) {
// Copy the data over before data access to ensure alignment.
SyncToken sync_token_data;
memcpy(&sync_token_data, sync_token, sizeof(SyncToken));
+
+ if (!sync_token_data.verified_flush() &&
+ !gpu_control_->CanWaitUnverifiedSyncToken(&sync_token_data)) {
+ SetGLError(GL_INVALID_VALUE, "glWaitSyncTokenCHROMIUM",
+ "Cannot wait on sync_token which has not been verified");
+ return;
+ }
+
helper_->WaitSyncTokenCHROMIUM(sync_token_data.namespace_id(),
sync_token_data.command_buffer_id(),
sync_token_data.release_count());
diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h
index 3d551a9..2e09d49 100644
--- a/gpu/command_buffer/client/gles2_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -1031,6 +1031,9 @@ GLuint64 InsertFenceSyncCHROMIUM() override;
void GenSyncTokenCHROMIUM(GLuint64 fence_sync, GLbyte* sync_token) override;
+void GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
+ GLbyte* sync_token) override;
+
void WaitSyncTokenCHROMIUM(const GLbyte* sync_token) override;
void DrawBuffersEXT(GLsizei count, const GLenum* bufs) override;
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index d53e647..8ff533d 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -18,6 +18,7 @@
#include "gpu/command_buffer/client/ring_buffer.h"
#include "gpu/command_buffer/client/transfer_buffer.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/sync_token.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -3761,7 +3762,7 @@ TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) {
const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
const GLuint64 kCommandBufferId = 234u;
const GLuint64 kFenceSync = 123u;
- GLbyte sync_token[GL_SYNC_TOKEN_SIZE_CHROMIUM];
+ GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM];
EXPECT_CALL(*gpu_control_, GetNamespaceID())
.WillRepeatedly(testing::Return(kNamespaceId));
@@ -3773,14 +3774,57 @@ TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) {
EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
.WillOnce(testing::Return(false));
- gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token);
+ gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token_data);
+ EXPECT_EQ(GL_INVALID_VALUE, CheckError());
+
+ EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
+ .WillOnce(testing::Return(true));
+ EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync))
+ .WillOnce(testing::Return(false));
+ gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token_data);
+ EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
+
+ EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
+ .WillOnce(testing::Return(true));
+ EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync))
+ .WillOnce(testing::Return(true));
+ ClearCommands();
+ gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token_data);
+ EXPECT_TRUE(NoCommandsWritten());
+ EXPECT_EQ(GL_NO_ERROR, CheckError());
+
+ SyncToken sync_token;
+ memcpy(&sync_token, sync_token_data, sizeof(SyncToken));
+ EXPECT_TRUE(sync_token.verified_flush());
+ EXPECT_EQ(kNamespaceId, sync_token.namespace_id());
+ EXPECT_EQ(kCommandBufferId, sync_token.command_buffer_id());
+ EXPECT_EQ(kFenceSync, sync_token.release_count());
+}
+
+TEST_F(GLES2ImplementationTest, GenUnverifiedSyncTokenCHROMIUM) {
+ const CommandBufferNamespace kNamespaceId = CommandBufferNamespace::GPU_IO;
+ const GLuint64 kCommandBufferId = 234u;
+ const GLuint64 kFenceSync = 123u;
+ GLbyte sync_token_data[GL_SYNC_TOKEN_SIZE_CHROMIUM];
+
+ EXPECT_CALL(*gpu_control_, GetNamespaceID())
+ .WillRepeatedly(testing::Return(kNamespaceId));
+ EXPECT_CALL(*gpu_control_, GetCommandBufferID())
+ .WillRepeatedly(testing::Return(kCommandBufferId));
+
+ gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync, nullptr);
+ EXPECT_EQ(GL_INVALID_VALUE, CheckError());
+
+ EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
+ .WillOnce(testing::Return(false));
+ gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync, sync_token_data);
EXPECT_EQ(GL_INVALID_VALUE, CheckError());
EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
.WillOnce(testing::Return(true));
EXPECT_CALL(*gpu_control_, IsFenceSyncFlushed(kFenceSync))
.WillOnce(testing::Return(false));
- gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token);
+ gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync, sync_token_data);
EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
@@ -3788,9 +3832,16 @@ TEST_F(GLES2ImplementationTest, GenSyncTokenCHROMIUM) {
EXPECT_CALL(*gpu_control_, IsFenceSyncFlushed(kFenceSync))
.WillOnce(testing::Return(true));
ClearCommands();
- gl_->GenSyncTokenCHROMIUM(kFenceSync, sync_token);
+ gl_->GenUnverifiedSyncTokenCHROMIUM(kFenceSync, sync_token_data);
EXPECT_TRUE(NoCommandsWritten());
EXPECT_EQ(GL_NO_ERROR, CheckError());
+
+ SyncToken sync_token;
+ memcpy(&sync_token, sync_token_data, sizeof(SyncToken));
+ EXPECT_FALSE(sync_token.verified_flush());
+ EXPECT_EQ(kNamespaceId, sync_token.namespace_id());
+ EXPECT_EQ(kCommandBufferId, sync_token.command_buffer_id());
+ EXPECT_EQ(kFenceSync, sync_token.release_count());
}
TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) {
@@ -3801,7 +3852,7 @@ TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) {
EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(kFenceSync))
.WillOnce(testing::Return(true));
- EXPECT_CALL(*gpu_control_, IsFenceSyncFlushed(kFenceSync))
+ EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(kFenceSync))
.WillOnce(testing::Return(true));
EXPECT_CALL(*gpu_control_, GetNamespaceID())
.WillOnce(testing::Return(kNamespaceId));
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
index 3f96294..b737e5c 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
@@ -3095,6 +3095,7 @@ TEST_F(GLES2ImplementationTest, WaitSyncPointCHROMIUM) {
}
// TODO(zmo): Implement unit test for InsertFenceSyncCHROMIUM
// TODO(zmo): Implement unit test for GenSyncTokenCHROMIUM
+// TODO(zmo): Implement unit test for GenUnverifiedSyncTokenCHROMIUM
TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
GLenum data[1][1] = {{0}};
diff --git a/gpu/command_buffer/client/gles2_interface_autogen.h b/gpu/command_buffer/client/gles2_interface_autogen.h
index 9b97beb..2671b0b 100644
--- a/gpu/command_buffer/client/gles2_interface_autogen.h
+++ b/gpu/command_buffer/client/gles2_interface_autogen.h
@@ -764,6 +764,8 @@ virtual GLuint InsertSyncPointCHROMIUM() = 0;
virtual void WaitSyncPointCHROMIUM(GLuint sync_point) = 0;
virtual GLuint64 InsertFenceSyncCHROMIUM() = 0;
virtual void GenSyncTokenCHROMIUM(GLuint64 fence_sync, GLbyte* sync_token) = 0;
+virtual void GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
+ GLbyte* sync_token) = 0;
virtual void WaitSyncTokenCHROMIUM(const GLbyte* sync_token) = 0;
virtual void DrawBuffersEXT(GLsizei count, const GLenum* bufs) = 0;
virtual void DiscardBackbufferCHROMIUM() = 0;
diff --git a/gpu/command_buffer/client/gles2_interface_stub_autogen.h b/gpu/command_buffer/client/gles2_interface_stub_autogen.h
index e795738..ee4e044e 100644
--- a/gpu/command_buffer/client/gles2_interface_stub_autogen.h
+++ b/gpu/command_buffer/client/gles2_interface_stub_autogen.h
@@ -740,6 +740,8 @@ GLuint InsertSyncPointCHROMIUM() override;
void WaitSyncPointCHROMIUM(GLuint sync_point) override;
GLuint64 InsertFenceSyncCHROMIUM() override;
void GenSyncTokenCHROMIUM(GLuint64 fence_sync, GLbyte* sync_token) override;
+void GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
+ GLbyte* sync_token) override;
void WaitSyncTokenCHROMIUM(const GLbyte* sync_token) override;
void DrawBuffersEXT(GLsizei count, const GLenum* bufs) override;
void DiscardBackbufferCHROMIUM() override;
diff --git a/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h b/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
index e7511e4..6bdbb54 100644
--- a/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
+++ b/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
@@ -1016,6 +1016,9 @@ GLuint64 GLES2InterfaceStub::InsertFenceSyncCHROMIUM() {
}
void GLES2InterfaceStub::GenSyncTokenCHROMIUM(GLuint64 /* fence_sync */,
GLbyte* /* sync_token */) {}
+void GLES2InterfaceStub::GenUnverifiedSyncTokenCHROMIUM(
+ GLuint64 /* fence_sync */,
+ GLbyte* /* sync_token */) {}
void GLES2InterfaceStub::WaitSyncTokenCHROMIUM(const GLbyte* /* sync_token */) {
}
void GLES2InterfaceStub::DrawBuffersEXT(GLsizei /* count */,
diff --git a/gpu/command_buffer/client/gles2_trace_implementation_autogen.h b/gpu/command_buffer/client/gles2_trace_implementation_autogen.h
index f9580d0..c918a5f 100644
--- a/gpu/command_buffer/client/gles2_trace_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_trace_implementation_autogen.h
@@ -740,6 +740,8 @@ GLuint InsertSyncPointCHROMIUM() override;
void WaitSyncPointCHROMIUM(GLuint sync_point) override;
GLuint64 InsertFenceSyncCHROMIUM() override;
void GenSyncTokenCHROMIUM(GLuint64 fence_sync, GLbyte* sync_token) override;
+void GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
+ GLbyte* sync_token) override;
void WaitSyncTokenCHROMIUM(const GLbyte* sync_token) override;
void DrawBuffersEXT(GLsizei count, const GLenum* bufs) override;
void DiscardBackbufferCHROMIUM() override;
diff --git a/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h
index 86c547d..f0855dc5 100644
--- a/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h
+++ b/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h
@@ -2171,6 +2171,14 @@ void GLES2TraceImplementation::GenSyncTokenCHROMIUM(GLuint64 fence_sync,
gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token);
}
+void GLES2TraceImplementation::GenUnverifiedSyncTokenCHROMIUM(
+ GLuint64 fence_sync,
+ GLbyte* sync_token) {
+ TRACE_EVENT_BINARY_EFFICIENT0("gpu",
+ "GLES2Trace::GenUnverifiedSyncTokenCHROMIUM");
+ gl_->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token);
+}
+
void GLES2TraceImplementation::WaitSyncTokenCHROMIUM(const GLbyte* sync_token) {
TRACE_EVENT_BINARY_EFFICIENT0("gpu", "GLES2Trace::WaitSyncTokenCHROMIUM");
gl_->WaitSyncTokenCHROMIUM(sync_token);
diff --git a/gpu/command_buffer/client/gpu_control.h b/gpu/command_buffer/client/gpu_control.h
index 7000152..6730e80 100644
--- a/gpu/command_buffer/client/gpu_control.h
+++ b/gpu/command_buffer/client/gpu_control.h
@@ -27,6 +27,7 @@ class GpuMemoryBuffer;
}
namespace gpu {
+struct SyncToken;
// Common interface for GpuControl implementations.
class GPU_EXPORT GpuControl {
@@ -99,10 +100,20 @@ class GPU_EXPORT GpuControl {
// Fence Syncs use release counters at a context level, these fence syncs
// need to be flushed before they can be shared with other contexts across
// channels. Subclasses should implement these functions and take care of
- // figuring out when a fence sync has been flushed.
+ // figuring out when a fence sync has been flushed. The difference between
+ // IsFenceSyncFlushed and IsFenceSyncFlushReceived, one is testing is the
+ // client has issued the flush, and the other is testing if the service
+ // has received the flush.
virtual uint64_t GenerateFenceSyncRelease() = 0;
virtual bool IsFenceSyncRelease(uint64_t release) = 0;
virtual bool IsFenceSyncFlushed(uint64_t release) = 0;
+ virtual bool IsFenceSyncFlushReceived(uint64_t release) = 0;
+
+ // Under some circumstances a sync token may be used which has not been
+ // verified to have been flushed. For example, fence syncs queued on the
+ // same channel as the wait command guarantee that the fence sync will
+ // be enqueued first so does not need to be flushed.
+ virtual bool CanWaitUnverifiedSyncToken(const SyncToken* sync_token) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(GpuControl);
diff --git a/gpu/command_buffer/cmd_buffer_functions.txt b/gpu/command_buffer/cmd_buffer_functions.txt
index 9e97d6e..f6ef278 100644
--- a/gpu/command_buffer/cmd_buffer_functions.txt
+++ b/gpu/command_buffer/cmd_buffer_functions.txt
@@ -309,6 +309,7 @@ GL_APICALL GLuint GL_APIENTRY glInsertSyncPointCHROMIUM (void);
GL_APICALL void GL_APIENTRY glWaitSyncPointCHROMIUM (GLuint sync_point);
GL_APICALL GLuint64 GL_APIENTRY glInsertFenceSyncCHROMIUM (void);
GL_APICALL void GL_APIENTRY glGenSyncTokenCHROMIUM (GLuint64 fence_sync, GLbyte* sync_token);
+GL_APICALL void GL_APIENTRY glGenUnverifiedSyncTokenCHROMIUM (GLuint64 fence_sync, GLbyte* sync_token);
GL_APICALL void GL_APIENTRY glWaitSyncTokenCHROMIUM (const GLbyte* sync_token);
GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei count, const GLenum* bufs);
GL_APICALL void GL_APIENTRY glDiscardBackbufferCHROMIUM (void);
diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
index 7dea6b5..85b44ef 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -13539,6 +13539,46 @@ static_assert(offsetof(GenSyncTokenCHROMIUMImmediate, header) == 0,
static_assert(offsetof(GenSyncTokenCHROMIUMImmediate, fence_sync) == 4,
"offset of GenSyncTokenCHROMIUMImmediate fence_sync should be 4");
+struct GenUnverifiedSyncTokenCHROMIUMImmediate {
+ typedef GenUnverifiedSyncTokenCHROMIUMImmediate ValueType;
+ static const CommandId kCmdId = kGenUnverifiedSyncTokenCHROMIUMImmediate;
+ static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
+ static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
+
+ static uint32_t ComputeSize(uint32_t size_in_bytes) {
+ return static_cast<uint32_t>(sizeof(ValueType) + // NOLINT
+ RoundSizeToMultipleOfEntries(size_in_bytes));
+ }
+
+ void SetHeader(uint32_t size_in_bytes) {
+ header.SetCmdByTotalSize<ValueType>(size_in_bytes);
+ }
+
+ void Init(GLuint64 _fence_sync) {
+ uint32_t total_size = 0; // TODO(gman): get correct size.
+ SetHeader(total_size);
+ fence_sync = _fence_sync;
+ }
+
+ void* Set(void* cmd, GLuint64 _fence_sync) {
+ uint32_t total_size = 0; // TODO(gman): get correct size.
+ static_cast<ValueType*>(cmd)->Init(_fence_sync);
+ return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size);
+ }
+
+ gpu::CommandHeader header;
+ uint32_t fence_sync;
+};
+
+static_assert(sizeof(GenUnverifiedSyncTokenCHROMIUMImmediate) == 8,
+ "size of GenUnverifiedSyncTokenCHROMIUMImmediate should be 8");
+static_assert(
+ offsetof(GenUnverifiedSyncTokenCHROMIUMImmediate, header) == 0,
+ "offset of GenUnverifiedSyncTokenCHROMIUMImmediate header should be 0");
+static_assert(
+ offsetof(GenUnverifiedSyncTokenCHROMIUMImmediate, fence_sync) == 4,
+ "offset of GenUnverifiedSyncTokenCHROMIUMImmediate fence_sync should be 4");
+
struct WaitSyncTokenCHROMIUM {
typedef WaitSyncTokenCHROMIUM ValueType;
static const CommandId kCmdId = kWaitSyncTokenCHROMIUM;
diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
index 39e1705..471460c 100644
--- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
@@ -298,29 +298,30 @@
OP(WaitSyncPointCHROMIUM) /* 539 */ \
OP(InsertFenceSyncCHROMIUM) /* 540 */ \
OP(GenSyncTokenCHROMIUMImmediate) /* 541 */ \
- OP(WaitSyncTokenCHROMIUM) /* 542 */ \
- OP(DrawBuffersEXTImmediate) /* 543 */ \
- OP(DiscardBackbufferCHROMIUM) /* 544 */ \
- OP(ScheduleOverlayPlaneCHROMIUM) /* 545 */ \
- OP(SwapInterval) /* 546 */ \
- OP(FlushDriverCachesCHROMIUM) /* 547 */ \
- OP(MatrixLoadfCHROMIUMImmediate) /* 548 */ \
- OP(MatrixLoadIdentityCHROMIUM) /* 549 */ \
- OP(GenPathsCHROMIUM) /* 550 */ \
- OP(DeletePathsCHROMIUM) /* 551 */ \
- OP(IsPathCHROMIUM) /* 552 */ \
- OP(PathCommandsCHROMIUM) /* 553 */ \
- OP(PathParameterfCHROMIUM) /* 554 */ \
- OP(PathParameteriCHROMIUM) /* 555 */ \
- OP(PathStencilFuncCHROMIUM) /* 556 */ \
- OP(StencilFillPathCHROMIUM) /* 557 */ \
- OP(StencilStrokePathCHROMIUM) /* 558 */ \
- OP(CoverFillPathCHROMIUM) /* 559 */ \
- OP(CoverStrokePathCHROMIUM) /* 560 */ \
- OP(StencilThenCoverFillPathCHROMIUM) /* 561 */ \
- OP(StencilThenCoverStrokePathCHROMIUM) /* 562 */ \
- OP(BlendBarrierKHR) /* 563 */ \
- OP(ApplyScreenSpaceAntialiasingCHROMIUM) /* 564 */
+ OP(GenUnverifiedSyncTokenCHROMIUMImmediate) /* 542 */ \
+ OP(WaitSyncTokenCHROMIUM) /* 543 */ \
+ OP(DrawBuffersEXTImmediate) /* 544 */ \
+ OP(DiscardBackbufferCHROMIUM) /* 545 */ \
+ OP(ScheduleOverlayPlaneCHROMIUM) /* 546 */ \
+ OP(SwapInterval) /* 547 */ \
+ OP(FlushDriverCachesCHROMIUM) /* 548 */ \
+ OP(MatrixLoadfCHROMIUMImmediate) /* 549 */ \
+ OP(MatrixLoadIdentityCHROMIUM) /* 550 */ \
+ OP(GenPathsCHROMIUM) /* 551 */ \
+ OP(DeletePathsCHROMIUM) /* 552 */ \
+ OP(IsPathCHROMIUM) /* 553 */ \
+ OP(PathCommandsCHROMIUM) /* 554 */ \
+ OP(PathParameterfCHROMIUM) /* 555 */ \
+ OP(PathParameteriCHROMIUM) /* 556 */ \
+ OP(PathStencilFuncCHROMIUM) /* 557 */ \
+ OP(StencilFillPathCHROMIUM) /* 558 */ \
+ OP(StencilStrokePathCHROMIUM) /* 559 */ \
+ OP(CoverFillPathCHROMIUM) /* 560 */ \
+ OP(CoverStrokePathCHROMIUM) /* 561 */ \
+ OP(StencilThenCoverFillPathCHROMIUM) /* 562 */ \
+ OP(StencilThenCoverStrokePathCHROMIUM) /* 563 */ \
+ OP(BlendBarrierKHR) /* 564 */ \
+ OP(ApplyScreenSpaceAntialiasingCHROMIUM) /* 565 */
enum CommandId {
kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this.
diff --git a/gpu/command_buffer/common/sync_token.h b/gpu/command_buffer/common/sync_token.h
index 76fdc1c..cceb44e 100644
--- a/gpu/command_buffer/common/sync_token.h
+++ b/gpu/command_buffer/common/sync_token.h
@@ -24,14 +24,16 @@ namespace gpu {
// details.
struct GPU_EXPORT SyncToken {
SyncToken()
- : namespace_id_(CommandBufferNamespace::INVALID),
+ : verified_flush_(false),
+ namespace_id_(CommandBufferNamespace::INVALID),
command_buffer_id_(0),
release_count_(0) {}
SyncToken(CommandBufferNamespace namespace_id,
uint64_t command_buffer_id,
uint64_t release_count)
- : namespace_id_(namespace_id),
+ : verified_flush_(false),
+ namespace_id_(namespace_id),
command_buffer_id_(command_buffer_id),
release_count_(release_count) {}
@@ -43,12 +45,17 @@ struct GPU_EXPORT SyncToken {
release_count_ = release_count;
}
+ void SetVerifyFlush() {
+ verified_flush_ = true;
+ }
+
int8_t* GetData() { return reinterpret_cast<int8_t*>(this); }
const int8_t* GetConstData() const {
return reinterpret_cast<const int8_t*>(this);
}
+ bool verified_flush() const { return verified_flush_; }
CommandBufferNamespace namespace_id() const { return namespace_id_; }
uint64_t command_buffer_id() const { return command_buffer_id_; }
uint64_t release_count() const { return release_count_; }
@@ -64,6 +71,7 @@ struct GPU_EXPORT SyncToken {
}
private:
+ bool verified_flush_;
CommandBufferNamespace namespace_id_;
uint64_t command_buffer_id_;
uint64_t release_count_;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 626e362..10550fa 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -12499,6 +12499,12 @@ error::Error GLES2DecoderImpl::HandleGenSyncTokenCHROMIUMImmediate(
return error::kUnknownCommand;
}
+error::Error GLES2DecoderImpl::HandleGenUnverifiedSyncTokenCHROMIUMImmediate(
+ uint32 immediate_data_size,
+ const void* cmd_data) {
+ return error::kUnknownCommand;
+}
+
error::Error GLES2DecoderImpl::HandleWaitSyncTokenCHROMIUM(
uint32 immediate_data_size,
const void* cmd_data) {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
index 691c9dcc..1e54d41 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
@@ -465,6 +465,8 @@ TEST_P(GLES2DecoderTest3, IsValuebufferCHROMIUMInvalidArgsBadSharedMemoryId) {
// TODO(gman): GenSyncTokenCHROMIUMImmediate
+// TODO(gman): GenUnverifiedSyncTokenCHROMIUMImmediate
+
// TODO(gman): WaitSyncTokenCHROMIUM
// TODO(gman): DrawBuffersEXTImmediate
diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc
index 17f087e..60bb39e 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.cc
+++ b/gpu/command_buffer/service/in_process_command_buffer.cc
@@ -967,6 +967,15 @@ bool InProcessCommandBuffer::IsFenceSyncFlushed(uint64_t release) {
return release <= flushed_fence_sync_release_;
}
+bool InProcessCommandBuffer::IsFenceSyncFlushReceived(uint64_t release) {
+ return IsFenceSyncFlushed(release);
+}
+
+bool InProcessCommandBuffer::CanWaitUnverifiedSyncToken(
+ const SyncToken* sync_token) {
+ return false;
+}
+
uint32 InProcessCommandBuffer::CreateStreamTextureOnGpuThread(
uint32 client_texture_id) {
#if defined(OS_ANDROID)
diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h
index 7843aa3..3cac88e 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.h
+++ b/gpu/command_buffer/service/in_process_command_buffer.h
@@ -133,6 +133,8 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
bool IsFenceSyncFlushed(uint64_t release) override;
+ bool IsFenceSyncFlushReceived(uint64_t release) override;
+ bool CanWaitUnverifiedSyncToken(const SyncToken* sync_token) override;
// The serializer interface to the GPU service (i.e. thread).
class Service {
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc
index b0414cd..bb803bb 100644
--- a/gpu/command_buffer/tests/gl_manager.cc
+++ b/gpu/command_buffer/tests/gl_manager.cc
@@ -520,4 +520,12 @@ bool GLManager::IsFenceSyncFlushed(uint64_t release) {
return IsFenceSyncRelease(release);
}
+bool GLManager::IsFenceSyncFlushReceived(uint64_t release) {
+ return IsFenceSyncRelease(release);
+}
+
+bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
+ return false;
+}
+
} // namespace gpu
diff --git a/gpu/command_buffer/tests/gl_manager.h b/gpu/command_buffer/tests/gl_manager.h
index 901bae8..0140198 100644
--- a/gpu/command_buffer/tests/gl_manager.h
+++ b/gpu/command_buffer/tests/gl_manager.h
@@ -135,6 +135,8 @@ class GLManager : private GpuControl {
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
bool IsFenceSyncFlushed(uint64_t release) override;
+ bool IsFenceSyncFlushReceived(uint64_t release) override;
+ bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override;
private:
void PumpCommands();
diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc
index 3168fa9..f139f09 100644
--- a/gpu/gles2_conform_support/egl/display.cc
+++ b/gpu/gles2_conform_support/egl/display.cc
@@ -365,4 +365,12 @@ bool Display::IsFenceSyncFlushed(uint64_t release) {
return IsFenceSyncRelease(release);
}
+bool Display::IsFenceSyncFlushReceived(uint64_t release) {
+ return IsFenceSyncRelease(release);
+}
+
+bool Display::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
+ return false;
+}
+
} // namespace egl
diff --git a/gpu/gles2_conform_support/egl/display.h b/gpu/gles2_conform_support/egl/display.h
index a3c69ab..d1953cf 100644
--- a/gpu/gles2_conform_support/egl/display.h
+++ b/gpu/gles2_conform_support/egl/display.h
@@ -103,6 +103,8 @@ class Display : private gpu::GpuControl {
uint64_t GenerateFenceSyncRelease() override;
bool IsFenceSyncRelease(uint64_t release) override;
bool IsFenceSyncFlushed(uint64_t release) override;
+ bool IsFenceSyncFlushReceived(uint64_t release) override;
+ bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override;
private:
EGLNativeDisplayType display_id_;