Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
gpu: Expose internal format R8 instead of RED.
Browse files Browse the repository at this point in the history
As noted in crrev.com/1703153002 GL_R8 sized internalformat should be preferred to
GL_RED.

This CL lets the users of the command buffer use GL_R8, and it takes care of
converting it to GL_RED when not supported by the underlying GL context.

BUG=
CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel

Review URL: https://codereview.chromium.org/1708263002

Cr-Commit-Position: refs/heads/master@{#377222}
  • Loading branch information
DCastagna authored and Commit bot committed Feb 24, 2016
1 parent 6f75e94 commit 7b277c5
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cc/resources/resource_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ GLenum GLDataFormat(ResourceFormat format) {
}

GLenum GLInternalFormat(ResourceFormat format) {
return GLDataFormat(format);
return (format == RED_8) ? GL_R8_EXT : GLDataFormat(format);
}

gfx::BufferFormat BufferFormat(ResourceFormat format) {
Expand Down
5 changes: 3 additions & 2 deletions gpu/GLES2/extensions/CHROMIUM/CHROMIUM_image.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ New Procedures and Functions
INVALID_VALUE is generated if <width> or <height> is nonpositive.

INVALID_VALUE is generated if <internalformat> is not one of
RED, RGB, RGBA, BGRA_EXT, ATC_RGB_AMD, ATC_RGBA_INTERPOLATED_ALPHA_AMD,
R8, RGB, RGBA, BGRA_EXT, ATC_RGB_AMD, ATC_RGBA_INTERPOLATED_ALPHA_AMD,
COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT5_EXT or
ETC1_RGB8_OES.

Expand All @@ -64,7 +64,7 @@ Dependencies on EXT_texture_format_BGRA8888
Dependencies on ARB_texture_rg

If ARB_texture_rg is not supported:
* delete any reference to the RED format.
* delete any reference to the R8 format.

Dependencies on AMD_compressed_ATC_texture

Expand Down Expand Up @@ -100,3 +100,4 @@ Revision History
2/7/2015 Add R8 format.
5/13/2015 Add compressed formats.
11/5/2015 Change R8 format to RED.
2/18/2016 Change back RED internal format to R8.
2 changes: 1 addition & 1 deletion gpu/command_buffer/client/gles2_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5686,7 +5686,7 @@ bool ValidImageFormat(GLenum internalformat,
return capabilities.texture_format_dxt5;
case GL_ETC1_RGB8_OES:
return capabilities.texture_format_etc1;
case GL_RED:
case GL_R8:
case GL_RGB:
case GL_RGBA:
case GL_RGB_YCBCR_422_CHROMIUM:
Expand Down
2 changes: 1 addition & 1 deletion gpu/command_buffer/service/gles2_cmd_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13356,7 +13356,7 @@ bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
dest_internal_format == GL_RGBA ||
dest_internal_format == GL_BGRA_EXT;
bool valid_source_format =
source_internal_format == GL_RED || source_internal_format == GL_ALPHA ||
source_internal_format == GL_R8 || source_internal_format == GL_ALPHA ||
source_internal_format == GL_RGB || source_internal_format == GL_RGBA ||
source_internal_format == GL_LUMINANCE ||
source_internal_format == GL_LUMINANCE_ALPHA ||
Expand Down
2 changes: 1 addition & 1 deletion gpu/command_buffer/service/image_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ImageFactory::~ImageFactory() {
gfx::BufferFormat ImageFactory::DefaultBufferFormatForImageFormat(
unsigned internalformat) {
switch (internalformat) {
case GL_RED:
case GL_R8:
return gfx::BufferFormat::R_8;
case GL_RGB:
return gfx::BufferFormat::BGRX_8888;
Expand Down
2 changes: 1 addition & 1 deletion gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void SetRow(gfx::BufferFormat format,
GLenum InternalFormat(gfx::BufferFormat format) {
switch (format) {
case gfx::BufferFormat::R_8:
return GL_RED;
return GL_R8;
case gfx::BufferFormat::RGBA_4444:
case gfx::BufferFormat::RGBA_8888:
return GL_RGBA;
Expand Down
2 changes: 1 addition & 1 deletion media/video/gpu_memory_buffer_video_frame_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ unsigned ImageInternalFormat(VideoPixelFormat format, size_t plane) {
switch (format) {
case PIXEL_FORMAT_I420:
DCHECK_LE(plane, 2u);
return GL_RED_EXT;
return GL_R8_EXT;
case PIXEL_FORMAT_NV12:
DCHECK_LE(plane, 1u);
return GL_RGB_YCBCR_420V_CHROMIUM;
Expand Down
7 changes: 5 additions & 2 deletions ui/gl/gl_image_io_surface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_helper.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/scoped_binders.h"

// Note that this must be included after gl_bindings.h to avoid conflicts.
Expand Down Expand Up @@ -68,7 +69,7 @@ void main() {

bool ValidInternalFormat(unsigned internalformat) {
switch (internalformat) {
case GL_RED:
case GL_R8:
case GL_BGRA_EXT:
case GL_RGB:
case GL_RGB_YCBCR_420V_CHROMIUM:
Expand Down Expand Up @@ -107,7 +108,9 @@ bool ValidFormat(BufferFormat format) {
GLenum TextureFormat(BufferFormat format) {
switch (format) {
case BufferFormat::R_8:
return GL_RED;
return gfx::GLContext::GetCurrent()->GetVersionInfo()->IsES3Capable()
? GL_R8
: GL_RED;
case BufferFormat::BGRA_8888:
case BufferFormat::RGBA_8888:
return GL_RGBA;
Expand Down
9 changes: 6 additions & 3 deletions ui/gl/gl_image_memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool ValidInternalFormat(unsigned internalformat) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_ETC1_RGB8_OES:
case GL_RED:
case GL_R8:
case GL_RGB:
case GL_RGBA:
case GL_BGRA_EXT:
Expand Down Expand Up @@ -99,7 +99,9 @@ GLenum TextureFormat(BufferFormat format) {
case BufferFormat::ETC1:
return GL_ETC1_RGB8_OES;
case BufferFormat::R_8:
return GL_RED;
return gfx::GLContext::GetCurrent()->GetVersionInfo()->IsES3Capable()
? GL_R8
: GL_RED;
case BufferFormat::RGBA_4444:
case BufferFormat::RGBA_8888:
return GL_RGBA;
Expand All @@ -125,10 +127,11 @@ GLenum DataFormat(BufferFormat format) {
return GL_RGBA;
case BufferFormat::BGRX_8888:
return GL_BGRA_EXT;
case BufferFormat::R_8:
return GL_RED;
case BufferFormat::RGBA_4444:
case BufferFormat::RGBA_8888:
case BufferFormat::BGRA_8888:
case BufferFormat::R_8:
case BufferFormat::ATC:
case BufferFormat::ATCIA:
case BufferFormat::DXT1:
Expand Down

0 comments on commit 7b277c5

Please sign in to comment.