Skip to content

Instantly share code, notes, and snippets.

@ds-hwang
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ds-hwang/26e765892240aeb6e56b to your computer and use it in GitHub Desktop.
Save ds-hwang/26e765892240aeb6e56b to your computer and use it in GitHub Desktop.
Data and code to measure CopyTextureChromium vs CopyTexImage2D
Measure time of coping texture by 1000x times between CopyTextureChromium (i.e. GL Drawing) and CopyTexImage2D
Linux (Intel IvyBridge i7-3520M)
GL Drawing TexImage2D
14060 5107
14110 5568
14837 5614
14963 5636
14997 5713
15015 5726
15205 5786
15434 5807
15541 5810
15927 5850
16029 5884
16140 5892
16141 6076
16458 6084
16459 6086
16501 6120
16699 6188
16967 6267
17018 6298
17144 6732
17370 6736
17538 7041
17616 7555
avg. us 16007.347826087 6068.5217391304
one call takes 16 us vs 6 us. -> 260% faster
Android (Nexus 5)
GL Drawing TexImage2D
208616 157685
212839 163109
213974 167021
240559 186774
283695 187070
307009 191004
309751 191648
311740 196643
316058 197462
318250 218105
325146 237101
325744 237386
326661 257562
329559 268138
330081 274138
331468 274971
333304 276210
343436 286782
348705 295076
356014 295269
363481 301604
373549 303562
398441 312742
403329 318381
440969 334829
451194 345659
457643 347749
avg. us 331896.851851852 252728.888888889
one call takes 331.8 us vs 252.7 us. -> 31% faster
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 9ebaaae..04b9f93 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -533,6 +533,17 @@ bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
false);
+ uint32 dummy_texture = web_graphics_context->createTexture();
+ web_graphics_context->bindTexture(GL_TEXTURE_2D, dummy_texture);
+ web_graphics_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ web_graphics_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ web_graphics_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ web_graphics_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture,
+ dummy_texture, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE);
+ web_graphics_context->deleteTexture(dummy_texture);
+
if (mailbox_holder->texture_target == GL_TEXTURE_EXTERNAL_OES)
web_graphics_context->bindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
else
diff --git a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
index ab5491e..d823c0d 100644
--- a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
+++ b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
@@ -307,7 +307,9 @@ void CopyTextureCHROMIUMResourceManager::Destroy() {
glDeleteBuffersARB(1, &buffer_id_);
buffer_id_ = 0;
}
-
+}
+#include "base/time/time.h"
+namespace gpu {
void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
const gles2::GLES2Decoder* decoder,
GLenum source_target,
@@ -320,10 +322,14 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha) {
+ static int tick = 1;
+ tick++;
bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
// GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2,
// so restrict this to TEXTURE_2D.
- if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change) {
+ if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && (tick % 2)) {
+ base::TimeTicks begin_time = base::TimeTicks::Now();
+ for (int i = 0; i< 1000; i++) {
DoCopyTexImage2D(decoder,
source_target,
source_id,
@@ -333,6 +339,9 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
width,
height,
framebuffer_);
+ }
+ base::TimeDelta delta = base::TimeTicks::Now() - begin_time;
+ LOG(ERROR)<<"DoCopyTexImage2D us:"<<delta.InMicroseconds();
return;
}
@@ -341,9 +350,14 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
+ base::TimeTicks begin_time = base::TimeTicks::Now();
+ for (int i = 0; i< 1000; i++) {
DoCopyTextureWithTransform(decoder, source_target, source_id, dest_id,
level, internal_format, width, height, flip_y, premultiply_alpha,
unpremultiply_alpha, default_matrix);
+ }
+ base::TimeDelta delta = base::TimeTicks::Now() - begin_time;
+ LOG(ERROR)<<"DoCopyTexture us:"<<delta.InMicroseconds();
}
void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment