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

Unified Diff: cc/debug/test_web_graphics_context_3d.cc

Issue 49163004: cc: Reduce command buffer flushes related to creating texture ids. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add LayerTreeSettings::texture_id_allocation_chunk_size Created 7 years, 2 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: cc/debug/test_web_graphics_context_3d.cc
diff --git a/cc/debug/test_web_graphics_context_3d.cc b/cc/debug/test_web_graphics_context_3d.cc
index 74a6abc06e6ea661104cb36b94e7ab95931eea2f..67561a0d23e46fe403239353257e2cf65bb0ef17 100644
--- a/cc/debug/test_web_graphics_context_3d.cc
+++ b/cc/debug/test_web_graphics_context_3d.cc
@@ -216,13 +216,8 @@ void TestWebGraphicsContext3D::genTextures(WGC3Dsizei count, WebGLId* ids) {
}
void TestWebGraphicsContext3D::deleteBuffers(WGC3Dsizei count, WebGLId* ids) {
- base::AutoLock lock(namespace_->lock);
- for (int i = 0; i < count; ++i) {
- unsigned context_id = ids[i] >> 17;
- unsigned buffer_id = ids[i] & 0x1ffff;
- DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id);
- DCHECK_EQ(context_id, context_id_);
- }
+ for (int i = 0; i < count; ++i)
+ RetireBufferId(ids[i]);
}
void TestWebGraphicsContext3D::deleteFramebuffers(
@@ -238,6 +233,8 @@ void TestWebGraphicsContext3D::deleteRenderbuffers(
}
void TestWebGraphicsContext3D::deleteTextures(WGC3Dsizei count, WebGLId* ids) {
+ for (int i = 0; i < count; ++i)
+ RetireTextureId(ids[i]);
base::AutoLock lock(namespace_->lock);
for (int i = 0; i < count; ++i) {
namespace_->textures.Remove(ids[i]);
@@ -471,10 +468,11 @@ void TestWebGraphicsContext3D::bindBuffer(WebKit::WGC3Denum target,
bound_buffer_ = buffer;
if (!bound_buffer_)
return;
- unsigned context_id = buffer >> 17;
- unsigned buffer_id = buffer & 0x1ffff;
+ unsigned context_id = buffer >> 16;
+ unsigned buffer_id = buffer & 0xffff;
base::AutoLock lock(namespace_->lock);
- DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id);
+ DCHECK(buffer_id);
+ DCHECK_LT(buffer_id, namespace_->next_buffer_id);
DCHECK_EQ(context_id, context_id_);
base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers;
@@ -543,11 +541,7 @@ WebKit::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM(
void TestWebGraphicsContext3D::destroyImageCHROMIUM(
WebKit::WGC3Duint id) {
- base::AutoLock lock(namespace_->lock);
- unsigned context_id = id >> 17;
- unsigned image_id = id & 0x1ffff;
- DCHECK(image_id && image_id < namespace_->next_image_id);
- DCHECK_EQ(context_id, context_id_);
+ RetireImageId(id);
}
void TestWebGraphicsContext3D::getImageParameterivCHROMIUM(
@@ -598,22 +592,49 @@ WebGLId TestWebGraphicsContext3D::NextTextureId() {
return texture_id;
}
+void TestWebGraphicsContext3D::RetireTextureId(WebGLId id) {
+ base::AutoLock lock(namespace_->lock);
+ unsigned context_id = id >> 16;
+ unsigned texture_id = id & 0xffff;
+ DCHECK(texture_id);
+ DCHECK_LT(texture_id, namespace_->next_texture_id);
+ DCHECK_EQ(context_id, context_id_);
+}
+
WebGLId TestWebGraphicsContext3D::NextBufferId() {
base::AutoLock lock(namespace_->lock);
WebGLId buffer_id = namespace_->next_buffer_id++;
- DCHECK(buffer_id < (1 << 17));
- buffer_id |= context_id_ << 17;
+ DCHECK(buffer_id < (1 << 16));
+ buffer_id |= context_id_ << 16;
return buffer_id;
}
+void TestWebGraphicsContext3D::RetireBufferId(WebGLId id) {
+ base::AutoLock lock(namespace_->lock);
+ unsigned context_id = id >> 16;
+ unsigned buffer_id = id & 0xffff;
+ DCHECK(buffer_id);
+ DCHECK_LT(buffer_id, namespace_->next_buffer_id);
+ DCHECK_EQ(context_id, context_id_);
+}
+
WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() {
base::AutoLock lock(namespace_->lock);
WGC3Duint image_id = namespace_->next_image_id++;
- DCHECK(image_id < (1 << 17));
- image_id |= context_id_ << 17;
+ DCHECK(image_id < (1 << 16));
+ image_id |= context_id_ << 16;
return image_id;
}
+void TestWebGraphicsContext3D::RetireImageId(WebGLId id) {
+ base::AutoLock lock(namespace_->lock);
+ unsigned context_id = id >> 16;
+ unsigned image_id = id & 0xffff;
+ DCHECK(image_id);
+ DCHECK_LT(image_id, namespace_->next_image_id);
+ DCHECK_EQ(context_id, context_id_);
+}
+
size_t TestWebGraphicsContext3D::GetTransferBufferMemoryUsedBytes() const {
size_t total_bytes = 0;
base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers;

Powered by Google App Engine
This is Rietveld 408576698