diff options
author | dcastagna <dcastagna@chromium.org> | 2015-04-08 13:52:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-08 20:53:26 +0000 |
commit | 51f60b27d0a7c8f1d39674fec24f73e9b55f04e6 (patch) | |
tree | 6f0d74c878e12c750fc01f5168234ea8b1f7fa0b /gpu | |
parent | 1abe5b4643edb113d9ce3ac58c69d40967d74cc5 (diff) | |
download | chromium_src-51f60b27d0a7c8f1d39674fec24f73e9b55f04e6.zip chromium_src-51f60b27d0a7c8f1d39674fec24f73e9b55f04e6.tar.gz chromium_src-51f60b27d0a7c8f1d39674fec24f73e9b55f04e6.tar.bz2 |
Add R_8 GPU memory buffers format.
GpuMemoryBuffer::Format::R_8 should be used to represent textures with
only one channel, the associated image should have GL_R8/GL_R8_EXT
as internal format.
With this CL the only implementation of GpuMemoryBuffer that supports
R_8 is GLImageMemory, it expects a 4 bytes row alignment (4 is the
default value for GL_PACK_ALIGNMENT).
BUG=
Review URL: https://codereview.chromium.org/1051503003
Cr-Commit-Position: refs/heads/master@{#324281}
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/GLES2/extensions/CHROMIUM/CHROMIUM_image.txt | 13 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 1 | ||||
-rw-r--r-- | gpu/command_buffer/service/feature_info.cc | 2 | ||||
-rw-r--r-- | gpu/command_buffer/service/image_factory.cc | 5 | ||||
-rw-r--r-- | gpu/command_buffer/service/in_process_command_buffer.cc | 2 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc | 12 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_manager.cc | 4 |
7 files changed, 35 insertions, 4 deletions
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_image.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_image.txt index 645a3f4..e0ba066 100644 --- a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_image.txt +++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_image.txt @@ -15,6 +15,7 @@ Dependencies OpenGL ES 2.0 is required. EXT_texture_format_BGRA8888 affects the definition of this extension. + ARB_texture_rg affects the definition of this extension. Overview @@ -45,7 +46,7 @@ New Procedures and Functions INVALID_VALUE is generated if <width> or <height> is nonpositive. INVALID_ENUM is generated if <internalformat> is not one of - RGB, RGBA or GL_BGRA_EXT. + R8, RGB, RGBA or BGRA_EXT. void DestroyImageCHROMIUM(GLuint image_id) @@ -56,7 +57,12 @@ New Procedures and Functions Dependencies on EXT_texture_format_BGRA8888 If EXT_texture_format_BGRA8888 is not supported: - * delete any reference to the GL_BGRA_EXT format. + * delete any reference to the BGRA_EXT format. + +Dependencies on ARB_texture_rg + + If ARB_texture_rg is not supported: + * delete any reference to the R8 format. Errors @@ -71,4 +77,5 @@ Revision History 5/9/2013 Documented the extension 4/30/2014 Moved usage flag to creation function. 10/7/2014 Remove map/unmap API. - 4/6/2015 Add GL_BGRA_EXT format. + 4/6/2015 Add BGRA_EXT format. + 2/7/2015 Add R8 format. diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index c93017c..1327826 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -4829,6 +4829,7 @@ namespace { bool ValidImageFormat(GLenum internalformat) { switch (internalformat) { + case GL_R8: case GL_RGB: case GL_RGBA: case GL_BGRA_EXT: diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index dcbdb8f..5003ea8 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -1070,7 +1070,9 @@ void FeatureInfo::InitializeFeatures() { validators_.texture_format.AddValue(GL_RED_EXT); validators_.texture_format.AddValue(GL_RG_EXT); validators_.texture_internal_format.AddValue(GL_RED_EXT); + validators_.texture_internal_format.AddValue(GL_R8_EXT); validators_.texture_internal_format.AddValue(GL_RG_EXT); + validators_.texture_internal_format.AddValue(GL_RG8_EXT); validators_.read_pixel_format.AddValue(GL_RED_EXT); validators_.read_pixel_format.AddValue(GL_RG_EXT); validators_.render_buffer_format.AddValue(GL_R8_EXT); diff --git a/gpu/command_buffer/service/image_factory.cc b/gpu/command_buffer/service/image_factory.cc index f09cfb8..74994ff 100644 --- a/gpu/command_buffer/service/image_factory.cc +++ b/gpu/command_buffer/service/image_factory.cc @@ -19,6 +19,8 @@ ImageFactory::~ImageFactory() { gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat( unsigned internalformat) { switch (internalformat) { + case GL_R8: + return gfx::GpuMemoryBuffer::R_8; case GL_RGB: return gfx::GpuMemoryBuffer::RGBX_8888; case GL_RGBA: @@ -78,6 +80,8 @@ bool ImageFactory::IsGpuMemoryBufferFormatSupported( return capabilities.texture_format_dxt5; case gfx::GpuMemoryBuffer::ETC1: return capabilities.texture_format_etc1; + case gfx::GpuMemoryBuffer::R_8: + return capabilities.texture_rg; case gfx::GpuMemoryBuffer::RGBA_8888: case gfx::GpuMemoryBuffer::RGBX_8888: case gfx::GpuMemoryBuffer::YUV_420: @@ -101,6 +105,7 @@ bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( // Compressed images must have a width and height that's evenly divisible // by the block size. return size.width() % 4 == 0 && size.height() % 4 == 0; + case gfx::GpuMemoryBuffer::R_8: case gfx::GpuMemoryBuffer::RGBA_8888: case gfx::GpuMemoryBuffer::BGRA_8888: case gfx::GpuMemoryBuffer::RGBX_8888: diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc index 65986f8..71a6532 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.cc +++ b/gpu/command_buffer/service/in_process_command_buffer.cc @@ -713,6 +713,8 @@ int32 InProcessCommandBuffer::CreateImage(ClientBuffer buffer, int32 new_id = next_image_id_.GetNext(); + DCHECK(gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( + gpu_memory_buffer->GetFormat(), capabilities_)); DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( internalformat, gpu_memory_buffer->GetFormat())); diff --git a/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc b/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc index 9368da5..51b3640 100644 --- a/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc +++ b/gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc @@ -80,6 +80,9 @@ SHADER( std::vector<uint8> GetTexturePixel(const gfx::GpuMemoryBuffer::Format format) { std::vector<uint8> pixel; switch (format) { + case gfx::GpuMemoryBuffer::R_8: + pixel.push_back(255u); + return pixel; case gfx::GpuMemoryBuffer::RGBA_8888: pixel.push_back(255u); pixel.push_back(0u); @@ -111,6 +114,7 @@ std::vector<uint8> GetFramebufferPixel( const gfx::GpuMemoryBuffer::Format format) { std::vector<uint8> pixel; switch (format) { + case gfx::GpuMemoryBuffer::R_8: case gfx::GpuMemoryBuffer::RGBA_8888: case gfx::GpuMemoryBuffer::BGRA_8888: pixel.push_back(255u); @@ -135,6 +139,8 @@ std::vector<uint8> GetFramebufferPixel( GLenum InternalFormat(gfx::GpuMemoryBuffer::Format format) { switch (format) { + case gfx::GpuMemoryBuffer::R_8: + return GL_R8; case gfx::GpuMemoryBuffer::RGBA_8888: return GL_RGBA; case gfx::GpuMemoryBuffer::BGRA_8888: @@ -158,6 +164,9 @@ GLenum InternalFormat(gfx::GpuMemoryBuffer::Format format) { // An end to end test that tests the whole GpuMemoryBuffer lifecycle. TEST_P(GpuMemoryBufferTest, Lifecycle) { + ASSERT_TRUE((GetParam() != gfx::GpuMemoryBuffer::R_8) || + gl_.GetCapabilities().texture_rg); + GLuint texture_id = 0; glGenTextures(1, &texture_id); ASSERT_NE(0u, texture_id); @@ -243,7 +252,8 @@ TEST_P(GpuMemoryBufferTest, Lifecycle) { INSTANTIATE_TEST_CASE_P(GpuMemoryBufferTests, GpuMemoryBufferTest, - ::testing::Values(gfx::GpuMemoryBuffer::RGBA_8888, + ::testing::Values(gfx::GpuMemoryBuffer::R_8, + gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::BGRA_8888)); } // namespace gles2 diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc index 3a3d7e9..2b6d06d 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -46,6 +46,7 @@ size_t NumberOfPlanesForGpuMemoryBufferFormat( case gfx::GpuMemoryBuffer::Format::DXT1: case gfx::GpuMemoryBuffer::Format::DXT5: case gfx::GpuMemoryBuffer::Format::ETC1: + case gfx::GpuMemoryBuffer::Format::R_8: case gfx::GpuMemoryBuffer::Format::RGBA_8888: case gfx::GpuMemoryBuffer::Format::RGBX_8888: case gfx::GpuMemoryBuffer::Format::BGRA_8888: @@ -64,6 +65,7 @@ size_t SubsamplingFactor(gfx::GpuMemoryBuffer::Format format, int plane) { case gfx::GpuMemoryBuffer::DXT1: case gfx::GpuMemoryBuffer::DXT5: case gfx::GpuMemoryBuffer::ETC1: + case gfx::GpuMemoryBuffer::R_8: case gfx::GpuMemoryBuffer::RGBA_8888: case gfx::GpuMemoryBuffer::RGBX_8888: case gfx::GpuMemoryBuffer::BGRA_8888: @@ -92,6 +94,8 @@ size_t StrideInBytes(size_t width, DCHECK_EQ(plane, 0); DCHECK_EQ(width % 2, 0U); return width / 2; + case gfx::GpuMemoryBuffer::R_8: + return (width + 3) & ~0x3; case gfx::GpuMemoryBuffer::RGBA_8888: case gfx::GpuMemoryBuffer::BGRA_8888: DCHECK_EQ(plane, 0); |