Commit e01baafc authored by Sunny Sachanandani's avatar Sunny Sachanandani Committed by Chromium LUCI CQ

viz: Add RG_16 resource format

This is needed for importing the UV plane of a P010/P016 texture into
GL/ANGLE.

Bug: 1116101
Change-Id: I32a008ddc0350858372d764de14998c930d48683
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2626100
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843532}
parent ad7c7bc0
......@@ -38,6 +38,7 @@ bool IsSupportedPlaybackToMemoryFormat(viz::ResourceFormat format) {
case viz::RED_8:
case viz::LUMINANCE_F16:
case viz::R16_EXT:
case viz::RG16_EXT:
case viz::BGR_565:
case viz::RG_88:
case viz::RGBX_8888:
......@@ -137,6 +138,7 @@ void RasterBufferProvider::PlaybackToMemory(
case viz::RED_8:
case viz::LUMINANCE_F16:
case viz::R16_EXT:
case viz::RG16_EXT:
case viz::BGR_565:
case viz::RG_88:
case viz::RGBX_8888:
......
......@@ -23,6 +23,7 @@ enum ResourceFormat {
LUMINANCE_F16,
RGBA_F16,
R16_EXT,
RG16_EXT,
RGBX_8888,
BGRX_8888,
RGBA_1010102,
......
......@@ -58,6 +58,7 @@ SkColorType ResourceFormatToClosestSkColorType(bool gpu_compositing,
return kGray_8_SkColorType;
case LUMINANCE_F16:
case R16_EXT:
case RG16_EXT:
case BGR_565:
return kN32_SkColorType;
case RG_88:
......@@ -82,6 +83,7 @@ int BitsPerPixel(ResourceFormat format) {
case RGBA_1010102:
case BGRA_1010102:
case P010:
case RG16_EXT:
return 32;
case RGBA_4444:
case RGB_565:
......@@ -120,6 +122,7 @@ bool HasAlpha(ResourceFormat format) {
case RG_88:
case LUMINANCE_F16:
case R16_EXT:
case RG16_EXT:
case RGBX_8888:
case BGRX_8888:
case RGBA_1010102:
......@@ -149,6 +152,7 @@ unsigned int GLDataType(ResourceFormat format) {
GL_HALF_FLOAT_OES, // LUMINANCE_F16
GL_HALF_FLOAT_OES, // RGBA_F16
GL_UNSIGNED_SHORT, // R16_EXT
GL_UNSIGNED_SHORT, // RG16_EXT
GL_UNSIGNED_BYTE, // RGBX_8888
GL_ZERO, // BGRX_8888
GL_UNSIGNED_INT_2_10_10_10_REV_EXT, // RGBA_1010102
......@@ -179,6 +183,7 @@ unsigned int GLDataFormat(ResourceFormat format) {
GL_LUMINANCE, // LUMINANCE_F16
GL_RGBA, // RGBA_F16
GL_RED_EXT, // R16_EXT
GL_RG_EXT, // RG16_EXT
GL_RGB, // RGBX_8888
GL_ZERO, // BGRX_8888
GL_RGBA, // RGBA_1010102
......@@ -198,16 +203,21 @@ unsigned int GLInternalFormat(ResourceFormat format) {
// is true in GLES3, however it still holds for the BGRA extension.)
// GL_EXT_texture_norm16 follows GLES3 semantics and only exposes a sized
// internal format (GL_R16_EXT).
if (format == R16_EXT)
switch (format) {
case R16_EXT:
return GL_R16_EXT;
else if (format == RG_88)
case RG_88:
return GL_RG8_EXT;
else if (format == ETC1)
case RG16_EXT:
return GL_RG16_EXT;
case ETC1:
return GL_ETC1_RGB8_OES;
else if (format == RGBA_1010102 || format == BGRA_1010102)
case RGBA_1010102:
case BGRA_1010102:
return GL_RGB10_A2_EXT;
default:
return GLDataFormat(format);
}
}
unsigned int GLCopyTextureInternalFormat(ResourceFormat format) {
......@@ -232,6 +242,7 @@ unsigned int GLCopyTextureInternalFormat(ResourceFormat format) {
GL_LUMINANCE, // LUMINANCE_F16
GL_RGBA, // RGBA_F16
GL_LUMINANCE, // R16_EXT
GL_RGBA, // RG16_EXT
GL_RGB, // RGBX_8888
GL_RGB, // BGRX_8888
GL_ZERO, // RGBA_1010102
......@@ -284,6 +295,7 @@ gfx::BufferFormat BufferFormat(ResourceFormat format) {
case LUMINANCE_8:
case RGB_565:
case LUMINANCE_F16:
case RG16_EXT:
// These types not allowed by IsGpuMemoryBufferFormatSupported(), so
// give a default value that will not be used.
break;
......@@ -319,6 +331,8 @@ unsigned int TextureStorageFormat(ResourceFormat format) {
return GL_LUMINANCE16F_EXT;
case R16_EXT:
return GL_R16_EXT;
case RG16_EXT:
return GL_RG16_EXT;
case RGBX_8888:
case ETC1:
return GL_RGB8_OES;
......@@ -342,6 +356,7 @@ bool IsGpuMemoryBufferFormatSupported(ResourceFormat format) {
case BGRA_8888:
case RED_8:
case R16_EXT:
case RG16_EXT:
case RGBA_4444:
case RGBA_8888:
case RGBA_1010102:
......@@ -382,6 +397,7 @@ bool IsBitmapFormatSupported(ResourceFormat format) {
case LUMINANCE_F16:
case RGBA_F16:
case R16_EXT:
case RG16_EXT:
case BGR_565:
case RG_88:
case RGBX_8888:
......@@ -459,6 +475,7 @@ bool HasVkFormat(ResourceFormat format) {
case RG_88:
case RGBA_F16:
case R16_EXT:
case RG16_EXT:
case RGBX_8888:
case BGRX_8888:
case RGBA_1010102:
......@@ -494,6 +511,8 @@ VkFormat ToVkFormat(ResourceFormat format) {
return VK_FORMAT_R16G16B16A16_SFLOAT;
case R16_EXT:
return VK_FORMAT_R16_UNORM;
case RG16_EXT:
return VK_FORMAT_R16G16_UNORM;
case RGBX_8888:
return VK_FORMAT_R8G8B8A8_UNORM;
case BGRX_8888:
......@@ -543,6 +562,7 @@ wgpu::TextureFormat ToDawnFormat(ResourceFormat format) {
case RGB_565:
case BGR_565:
case R16_EXT:
case RG16_EXT:
case BGRA_1010102:
case YVU_420:
case YUV_420_BIPLANAR:
......
......@@ -70,6 +70,7 @@ static const struct {
{GL_RED, GL_HALF_FLOAT_OES, 2}, // LUMINANCE_F16
{GL_RGBA, GL_HALF_FLOAT_OES, 8}, // RGBA_F16
{GL_RED, GL_UNSIGNED_SHORT, 2}, // R16_EXT
{GL_RG, GL_UNSIGNED_SHORT, 4}, // RG16_EXT
{GL_RGBA, GL_UNSIGNED_BYTE, 4}, // RGBX_8888
{GL_BGRA, GL_UNSIGNED_BYTE, 4}, // BGRX_8888
{GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4}, // RGBA_1010102
......
......@@ -29,7 +29,9 @@ unsigned GLImage::GetDataFormat() {
unsigned internalformat = GetInternalFormat();
switch (internalformat) {
case GL_R16_EXT:
return GL_RED;
return GL_RED_EXT;
case GL_RG16_EXT:
return GL_RG_EXT;
case GL_RGB10_A2_EXT:
return GL_RGBA;
case GL_RGB_YCRCB_420_CHROMIUM:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment