diff options
author | reveman <reveman@chromium.org> | 2015-10-26 13:27:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-26 20:28:42 +0000 |
commit | eb0fda21bf0fc43f591dfe2a6302fc014c425118 (patch) | |
tree | bb053cf4e4557a8c94910f48a4dbe118988e5a1f /ui | |
parent | b65cfea2a48ce74ac98e2b10006e9d8b868d4553 (diff) | |
download | chromium_src-eb0fda21bf0fc43f591dfe2a6302fc014c425118.zip chromium_src-eb0fda21bf0fc43f591dfe2a6302fc014c425118.tar.gz chromium_src-eb0fda21bf0fc43f591dfe2a6302fc014c425118.tar.bz2 |
ui: Rename gfx::BufferUsage enum values and add BufferUsage::GPU_READ.
The problem with the current usage modes is that we currently use
SCANOUT for anything that doesn't require CPU access. When importing
a buffer we typically don't care about anything but having the GPU
be able to read from it. SCANOUT is not a good description of that
and currently means GPU read/write support.
This patch attempts to make usage more explicit and it solves the
use case where a buffer type can only provide GPU read and not GPU
write support (e.g. SHM fallback). Here are the new usage modes:
- GPU_READ
- GPU_READ_WRITE
- GPU_READ_CPU_READ_WRITE
GPU_READ is useful when importing a buffer and all you care about is
being able to use it for sampling and optionally scanout.
GPU_READ_WRITE is useful for things like WebGL or GPU raster where
we want the ability to write to the buffer using GL and potentially
use it for scanout.
GPU_READ_CPU_READ_WRITE is the usage mode that allows CPU access and
is used for one-copy and zero-copy texture initialization. There's
nothing preventing this mode from also supporting scanout.
- GPU_READ_CPU_READ_WRITE_PERSISTENT
This usage mode indicates that the data will be persistent across
Unmap()/Map() calls but will likely become part of the normal
GPU_READ_CPU_READ_WRITE usage once all buffer types support this.
BUG=538325
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1420923005
Cr-Commit-Position: refs/heads/master@{#356108}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/compositor/compositor.cc | 10 | ||||
-rw-r--r-- | ui/gfx/buffer_types.h | 19 | ||||
-rw-r--r-- | ui/gl/gl_bindings.h | 3 | ||||
-rw-r--r-- | ui/gl/gl_enums_implementation_autogen.h | 26 | ||||
-rw-r--r-- | ui/gl/gl_surface_ozone.cc | 2 | ||||
-rw-r--r-- | ui/ozone/demo/surfaceless_gl_renderer.cc | 2 | ||||
-rw-r--r-- | ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc | 14 | ||||
-rw-r--r-- | ui/ozone/platform/drm/gpu/drm_thread.cc | 2 | ||||
-rw-r--r-- | ui/ozone/platform/drm/gpu/gbm_buffer.cc | 16 | ||||
-rw-r--r-- | ui/ozone/platform/drm/gpu/gbm_surface_factory.cc | 3 |
10 files changed, 52 insertions, 45 deletions
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index ed80f62..e278394 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -144,10 +144,12 @@ Compositor::Compositor(ui::ContextFactory* context_factory, // doesn't currently support partial raster. settings.use_partial_raster = !settings.use_zero_copy; - // Use PERSISTENT_MAP memory buffers to support partial tile raster if needed. - gfx::BufferUsage usage = settings.use_partial_raster - ? gfx::BufferUsage::PERSISTENT_MAP - : gfx::BufferUsage::MAP; + // Use CPU_READ_WRITE_PERSISTENT memory buffers to support partial tile + // raster if needed. + gfx::BufferUsage usage = + settings.use_partial_raster + ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT + : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; for (size_t format = 0; format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { diff --git a/ui/gfx/buffer_types.h b/ui/gfx/buffer_types.h index aabfb41..2c87905 100644 --- a/ui/gfx/buffer_types.h +++ b/ui/gfx/buffer_types.h @@ -29,11 +29,20 @@ enum class BufferFormat { }; // The usage mode affects how a buffer can be used. Only buffers created with -// MAP can be mapped into the client's address space and accessed by the CPU. -// PERSISTENT_MAP adds the additional condition that successive Map() calls -// (with Unmap() calls between) will return a pointer to the same memory -// contents. -enum class BufferUsage { MAP, PERSISTENT_MAP, SCANOUT, LAST = SCANOUT }; +// *_CPU_READ_WRITE_* can be mapped into the client's address space and accessed +// by the CPU. *_CPU_READ_WRITE_PERSISTENT adds the additional condition that +// successive Map() calls (with Unmap() calls between) will return a pointer to +// the same memory contents. +enum class BufferUsage { + GPU_READ, + GPU_READ_WRITE, + GPU_READ_CPU_READ_WRITE, + // TODO(reveman): Merge this with GPU_READ_CPU_READ_WRITE when SurfaceTexture + // backed buffers are single buffered and support it. + GPU_READ_CPU_READ_WRITE_PERSISTENT, + + LAST = GPU_READ_CPU_READ_WRITE_PERSISTENT +}; } // namespace gfx diff --git a/ui/gl/gl_bindings.h b/ui/gl/gl_bindings.h index c1ad779..f043bef 100644 --- a/ui/gl/gl_bindings.h +++ b/ui/gl/gl_bindings.h @@ -127,8 +127,7 @@ #define GL_COMMANDS_COMPLETED_CHROMIUM 0x84F7 // GL_CHROMIUM_gpu_memory_buffer_image -#define GL_MAP_CHROMIUM 0x78F1 -#define GL_SCANOUT_CHROMIUM 0x78F2 +#define GL_READ_WRITE_CHROMIUM 0x78F2 // GL_CHROMIUM_yuv_420_image #define GL_RGB_YUV_420_CHROMIUM 0x78FA diff --git a/ui/gl/gl_enums_implementation_autogen.h b/ui/gl/gl_enums_implementation_autogen.h index 54dea5a..e6d7c36 100644 --- a/ui/gl/gl_enums_implementation_autogen.h +++ b/ui/gl/gl_enums_implementation_autogen.h @@ -46,9 +46,6 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x0BC2, "GL_ALPHA_TEST_REF_QCOM", }, { - 0x78EF, "GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM", - }, - { 0x884D, "GL_TEXTURE_COMPARE_FUNC_EXT", }, { @@ -97,7 +94,7 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x9500, "GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL", }, { - 0x78F2, "GL_SCANOUT_CHROMIUM", + 0x78F2, "GL_READ_WRITE_CHROMIUM", }, { 0x9138, "GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG", @@ -1165,9 +1162,6 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x8A44, "GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER", }, { - 0x6000, "GL_TEXTURE_POOL_CHROMIUM", - }, - { 0x0B74, "GL_DEPTH_FUNC", }, { @@ -1495,7 +1489,7 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x04, "GL_LINE_TO_CHROMIUM", }, { - 0x0BA7, "GL_PATH_PROJECTION_MATRIX_CHROMIUM", + 0x8905, "GL_MAX_PROGRAM_TEXEL_OFFSET", }, { 0x00080000, "GL_STENCIL_BUFFER_BIT3_QCOM", @@ -1906,6 +1900,9 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x8CD9, "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS", }, { + 24, "GL_SYNC_TOKEN_SIZE_CHROMIUM", + }, + { 0x84CC, "GL_TEXTURE12", }, { @@ -1915,7 +1912,7 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x84CA, "GL_TEXTURE10", }, { - 0x78F1, "GL_MAP_CHROMIUM", + 0x0BA7, "GL_PATH_PROJECTION_MATRIX_CHROMIUM", }, { 0x84CF, "GL_TEXTURE15", @@ -2269,9 +2266,6 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x84DC, "GL_TEXTURE28", }, { - 0x6002, "GL_TEXTURE_POOL_UNMANAGED_CHROMIUM", - }, - { 0x84DA, "GL_TEXTURE26", }, { @@ -2845,7 +2839,7 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x78EE, "GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM", }, { - 0x6001, "GL_TEXTURE_POOL_MANAGED_CHROMIUM", + 0x78EF, "GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM", }, { 0x0B45, "GL_CULL_FACE_MODE", @@ -2857,9 +2851,6 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x00100000, "GL_STENCIL_BUFFER_BIT4_QCOM", }, { - 24, "GL_SYNC_TOKEN_SIZE_CHROMIUM", - }, - { 0x8E4E, "GL_LAST_VERTEX_CONVENTION_EXT", }, { @@ -3001,9 +2992,6 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x0A, "GL_QUADRATIC_CURVE_TO_CHROMIUM", }, { - 0x8905, "GL_MAX_PROGRAM_TEXEL_OFFSET", - }, - { 0x8508, "GL_DECR_WRAP", }, { diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc index ad264cc..377597d 100644 --- a/ui/gl/gl_surface_ozone.cc +++ b/ui/gl/gl_surface_ozone.cc @@ -565,7 +565,7 @@ bool GLSurfaceOzoneSurfacelessSurfaceImpl::CreatePixmaps() { ->GetSurfaceFactoryOzone() ->CreateNativePixmap(widget_, GetSize(), gfx::BufferFormat::BGRA_8888, - gfx::BufferUsage::SCANOUT); + gfx::BufferUsage::GPU_READ_WRITE); if (!pixmap) return false; scoped_refptr<GLImageOzoneNativePixmap> image = diff --git a/ui/ozone/demo/surfaceless_gl_renderer.cc b/ui/ozone/demo/surfaceless_gl_renderer.cc index 60575d6..4b3d555 100644 --- a/ui/ozone/demo/surfaceless_gl_renderer.cc +++ b/ui/ozone/demo/surfaceless_gl_renderer.cc @@ -40,7 +40,7 @@ bool SurfacelessGlRenderer::BufferWrapper::Initialize( OzonePlatform::GetInstance() ->GetSurfaceFactoryOzone() ->CreateNativePixmap(widget, size, gfx::BufferFormat::BGRX_8888, - gfx::BufferUsage::SCANOUT); + gfx::BufferUsage::GPU_READ_WRITE); scoped_refptr<gfx::GLImageOzoneNativePixmap> image( new gfx::GLImageOzoneNativePixmap(size, GL_RGB)); if (!image->Initialize(pixmap.get(), gfx::BufferFormat::BGRX_8888)) { diff --git a/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc b/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc index ec832cb..d8c701c 100644 --- a/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc +++ b/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc @@ -47,12 +47,13 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { bool IsConfigurationSupported(gfx::BufferFormat format, gfx::BufferUsage usage) const override { switch (usage) { - case gfx::BufferUsage::SCANOUT: + case gfx::BufferUsage::GPU_READ: + case gfx::BufferUsage::GPU_READ_WRITE: return format == gfx::BufferFormat::RGBA_8888 || format == gfx::BufferFormat::BGRA_8888 || format == gfx::BufferFormat::BGRX_8888; - case gfx::BufferUsage::MAP: - case gfx::BufferUsage::PERSISTENT_MAP: { + case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: + case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: { #if defined(USE_VGEM_MAP) return vgem_fd_.is_valid() && format == gfx::BufferFormat::BGRA_8888; #else @@ -70,8 +71,8 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { base::ScopedFD scoped_fd(handle.fd.fd); switch (usage) { - case gfx::BufferUsage::MAP: - case gfx::BufferUsage::PERSISTENT_MAP: + case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: + case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: #if defined(USE_VGEM_MAP) // A valid |vgem_fd_| is required to acquire a VGEM bo. |vgem_fd_| is // set before a widget is created. @@ -81,7 +82,8 @@ class ClientNativePixmapFactoryGbm : public ClientNativePixmapFactory { #endif NOTREACHED(); return nullptr; - case gfx::BufferUsage::SCANOUT: + case gfx::BufferUsage::GPU_READ: + case gfx::BufferUsage::GPU_READ_WRITE: return make_scoped_ptr<ClientNativePixmapGbm>( new ClientNativePixmapGbm); } diff --git a/ui/ozone/platform/drm/gpu/drm_thread.cc b/ui/ozone/platform/drm/gpu/drm_thread.cc index 901dedb..19ecdfb 100644 --- a/ui/ozone/platform/drm/gpu/drm_thread.cc +++ b/ui/ozone/platform/drm/gpu/drm_thread.cc @@ -34,7 +34,7 @@ class GbmBufferGenerator : public ScanoutBufferGenerator { const gfx::Size& size) override { scoped_refptr<GbmDevice> gbm(static_cast<GbmDevice*>(drm.get())); return GbmBuffer::CreateBuffer(gbm, format, size, - gfx::BufferUsage::SCANOUT); + gfx::BufferUsage::GPU_READ_WRITE); } protected: diff --git a/ui/ozone/platform/drm/gpu/gbm_buffer.cc b/ui/ozone/platform/drm/gpu/gbm_buffer.cc index 8c3c396..b94164d 100644 --- a/ui/ozone/platform/drm/gpu/gbm_buffer.cc +++ b/ui/ozone/platform/drm/gpu/gbm_buffer.cc @@ -25,7 +25,10 @@ namespace ui { GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm, gbm_bo* bo, gfx::BufferUsage usage) - : GbmBufferBase(gbm, bo, usage == gfx::BufferUsage::SCANOUT), + : GbmBufferBase(gbm, + bo, + usage == gfx::BufferUsage::GPU_READ || + usage == gfx::BufferUsage::GPU_READ_WRITE), usage_(usage) {} GbmBuffer::~GbmBuffer() { @@ -41,10 +44,12 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( gfx::BufferUsage usage) { TRACE_EVENT2("drm", "GbmBuffer::CreateBuffer", "device", gbm->device_path().value(), "size", size.ToString()); - bool use_scanout = (usage == gfx::BufferUsage::SCANOUT); + bool with_cpu_access = + usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE || + usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT; unsigned flags = 0; // GBM_BO_USE_SCANOUT is the hint of x-tiling. - if (use_scanout) + if (!with_cpu_access) flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), GetFourCCFormatFromBufferFormat(format), flags); @@ -52,7 +57,7 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( return nullptr; scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, usage)); - if (use_scanout && !buffer->GetFramebufferId()) + if (!with_cpu_access && !buffer->GetFramebufferId()) return nullptr; return buffer; @@ -140,7 +145,8 @@ bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, return false; } - DCHECK(buffer_->GetUsage() == gfx::BufferUsage::SCANOUT); + DCHECK(buffer_->GetUsage() == gfx::BufferUsage::GPU_READ || + buffer_->GetUsage() == gfx::BufferUsage::GPU_READ_WRITE); surface_manager_->GetSurface(widget)->QueueOverlayPlane(OverlayPlane( buffer_, plane_z_order, plane_transform, display_bounds, crop_rect)); return true; diff --git a/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc b/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc index 42be306..f140f82 100644 --- a/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc +++ b/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc @@ -110,7 +110,8 @@ scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( #if !defined(OS_CHROMEOS) // Support for memory mapping accelerated buffers requires some // CrOS-specific patches (using vgem). - DCHECK(gfx::BufferUsage::SCANOUT == usage); + DCHECK(gfx::BufferUsage::GPU_READ == usage || + gfx::BufferUsage::GPU_READ_WRITE == usage); #endif scoped_refptr<GbmBuffer> buffer = |