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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2945673002: Allow creating GLImage-backed textures with glTexStorage2D. (Closed)
Patch Set: add test Created 3 years, 6 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/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 53a6acc9fa917a0f0a8bda372564c0c810b804b0..a407a21c0d1852c0342b4271b28b76af035c0ee1 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -2839,7 +2839,7 @@ bool BackTexture::AllocateNativeGpuMemoryBuffer(const gfx::Size& size,
size,
format == GL_RGB ? gfx::BufferFormat::RGBX_8888
: gfx::BufferFormat::RGBA_8888,
- format);
+ gfx::BufferUsage::SCANOUT, format);
if (!image || !image->BindTexImage(Target()))
return false;
@@ -17392,6 +17392,62 @@ void GLES2DecoderImpl::TexStorageImpl(GLenum target,
return;
}
+ if (texture->buffer_usage() != GL_NONE) {
+ ScopedGLErrorSuppressor suppressor("GLES2CmdDecoder::TexStorageImpl",
+ state_.GetErrorState());
+ gfx::Size size(width, height);
+ gfx::BufferFormat buffer_format;
+ GLint real_internal_format;
+ switch (internal_format) {
+ case GL_RGBA8_OES:
+ buffer_format = gfx::BufferFormat::RGBA_8888;
+ real_internal_format = GL_RGBA;
+ break;
+ case GL_BGRA8_EXT:
+ buffer_format = gfx::BufferFormat::BGRA_8888;
+ real_internal_format = GL_BGRA_EXT;
+ break;
+ case GL_RGBA16F_EXT:
+ buffer_format = gfx::BufferFormat::RGBA_F16;
+ real_internal_format = GL_RGBA;
+ break;
+ default:
+ LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, function_name,
+ "Invalid buffer format");
+ return;
+ }
+
+ if (levels != 1) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
+ "Levels != 1 for buffer");
+ return;
+ }
+ if (depth > 1) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
+ "depth > 1 for buffer");
+ return;
+ }
+ DCHECK_EQ(GL_TEXTURE_BUFFER_SCANOUT_CHROMIUM, texture->buffer_usage());
+
+ gfx::BufferUsage buffer_usage = gfx::BufferUsage::SCANOUT;
+ scoped_refptr<gl::GLImage> image =
+ GetContextGroup()->image_factory()->CreateAnonymousImage(
+ gfx::Size(width, height), buffer_format, buffer_usage,
+ real_internal_format);
+ if (!image || !image->BindTexImage(target)) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
+ "Cannot create GL Image");
+ return;
+ }
+
+ texture_manager()->SetLevelInfo(
+ texture_ref, target, 0, image->GetInternalFormat(), width, height, 1, 0,
+ image->GetInternalFormat(), GL_UNSIGNED_BYTE, gfx::Rect(size));
+ texture_manager()->SetLevelImage(texture_ref, target, 0, image.get(),
+ Texture::BOUND);
+ return;
+ }
+
GLenum format = TextureManager::ExtractFormatFromStorageFormat(
internal_format);
GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format);

Powered by Google App Engine
This is Rietveld 408576698