shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1 | #include "precompiled.h" |
| 2 | // |
| 3 | // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style license that can be |
| 5 | // found in the LICENSE file. |
| 6 | // |
| 7 | |
| 8 | // formatutils.cpp: Queries for GL image formats. |
| 9 | |
| 10 | #include "libGLESv2/formatutils.h" |
| 11 | #include "libGLESv2/Context.h" |
shannonwoods@chromium.org | a2ecfcc | 2013-05-30 00:11:59 +0000 | [diff] [blame] | 12 | #include "common/mathutil.h" |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 13 | #include "libGLESv2/renderer/Renderer.h" |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 14 | #include "libGLESv2/renderer/imageformats.h" |
| 15 | #include "libGLESv2/renderer/copyimage.h" |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 16 | |
| 17 | namespace gl |
| 18 | { |
| 19 | |
| 20 | // ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the implementation |
| 21 | // can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid |
| 22 | // format and type combinations. |
| 23 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 24 | struct FormatTypeInfo |
| 25 | { |
| 26 | GLint mInternalFormat; |
| 27 | ColorWriteFunction mColorWriteFunction; |
| 28 | |
| 29 | FormatTypeInfo(GLint internalFormat, ColorWriteFunction writeFunc) |
| 30 | : mInternalFormat(internalFormat), mColorWriteFunction(writeFunc) |
| 31 | { } |
| 32 | }; |
| 33 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 34 | typedef std::pair<GLenum, GLenum> FormatTypePair; |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 35 | typedef std::pair<FormatTypePair, FormatTypeInfo> FormatPair; |
| 36 | typedef std::map<FormatTypePair, FormatTypeInfo> FormatMap; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 37 | |
Jamie Madill | 89a0bf5 | 2013-09-18 14:36:24 -0400 | [diff] [blame] | 38 | // A helper function to insert data into the format map with fewer characters. |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 39 | static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLint internalFormat, ColorWriteFunction writeFunc) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 40 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 41 | map->insert(FormatPair(FormatTypePair(format, type), FormatTypeInfo(internalFormat, writeFunc))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 42 | } |
| 43 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 44 | FormatMap BuildES2FormatMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 45 | { |
| 46 | FormatMap map; |
| 47 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 48 | using namespace rx; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 49 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 50 | // | Format | Type | Internal format | Color write function | |
| 51 | InsertFormatMapping(&map, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA8_EXT, WriteColor<A8, GLfloat> ); |
| 52 | InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT, WriteColor<A32F, GLfloat> ); |
| 53 | InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA16F_EXT, WriteColor<A16F, GLfloat> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 54 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 55 | InsertFormatMapping(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE8_EXT, WriteColor<L8, GLfloat> ); |
| 56 | InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT, WriteColor<L32F, GLfloat> ); |
| 57 | InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE16F_EXT, WriteColor<L16F, GLfloat> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 58 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 59 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE8_ALPHA8_EXT, WriteColor<L8A8, GLfloat> ); |
| 60 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_EXT, WriteColor<L32A32F, GLfloat> ); |
| 61 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA16F_EXT, WriteColor<L16A16F, GLfloat> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 62 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 63 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8_OES, WriteColor<R8G8B8, GLfloat> ); |
| 64 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB565, WriteColor<R5G6B5, GLfloat> ); |
| 65 | InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F_EXT, WriteColor<R32G32B32F, GLfloat> ); |
| 66 | InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB16F_EXT, WriteColor<R16G16B16F, GLfloat> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 67 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 68 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8_OES, WriteColor<R8G8B8A8, GLfloat> ); |
| 69 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4, WriteColor<R4G4B4A4, GLfloat> ); |
| 70 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGB5_A1, WriteColor<R5G5B5A1, GLfloat> ); |
| 71 | InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F_EXT, WriteColor<R32G32B32A32F, GLfloat>); |
| 72 | InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA16F_EXT, WriteColor<R16G16B16A16F, GLfloat>); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 73 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 74 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT, WriteColor<B8G8R8A8, GLfloat> ); |
| 75 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX, WriteColor<B4G4R4A4, GLfloat> ); |
| 76 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX, WriteColor<B5G5R5A1, GLfloat> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 77 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 78 | InsertFormatMapping(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, NULL ); |
| 79 | InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, NULL ); |
| 80 | InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, NULL ); |
| 81 | InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, NULL ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 82 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 83 | InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_DEPTH_COMPONENT16, NULL ); |
| 84 | InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_DEPTH_COMPONENT32_OES, NULL ); |
| 85 | |
| 86 | InsertFormatMapping(&map, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, GL_DEPTH24_STENCIL8_OES, NULL ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 87 | |
| 88 | return map; |
| 89 | } |
| 90 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 91 | FormatMap BuildES3FormatMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 92 | { |
| 93 | FormatMap map; |
| 94 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 95 | using namespace rx; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 96 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 97 | // | Format | Type | Internal format | Color write function | |
| 98 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8, WriteColor<R8G8B8A8, GLfloat> ); |
| 99 | InsertFormatMapping(&map, GL_RGBA, GL_BYTE, GL_RGBA8_SNORM, WriteColor<R8G8B8A8S, GLfloat> ); |
| 100 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4, WriteColor<R4G4B4A4, GLfloat> ); |
| 101 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGB5_A1, WriteColor<R5G5B5A1, GLfloat> ); |
| 102 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2, WriteColor<R10G10B10A2, GLfloat> ); |
| 103 | InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F, WriteColor<R32G32B32A32F, GLfloat>); |
| 104 | InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT, GL_RGBA16F, WriteColor<R16G16B16A16F, GLfloat>); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 105 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 106 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_RGBA8UI, WriteColor<R8G8B8A8, GLuint> ); |
| 107 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_BYTE, GL_RGBA8I, WriteColor<R8G8B8A8S, GLint> ); |
| 108 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_RGBA16UI, WriteColor<R16G16B16A16, GLuint> ); |
| 109 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_SHORT, GL_RGBA16I, WriteColor<R16G16B16A16S, GLint> ); |
| 110 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_RGBA32UI, WriteColor<R32G32B32A32, GLuint> ); |
| 111 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_INT, GL_RGBA32I, WriteColor<R32G32B32A32S, GLint> ); |
Jamie Madill | 18a4470 | 2013-09-09 16:24:04 -0400 | [diff] [blame] | 112 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2UI, WriteColor<R10G10B10A2, GLuint> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 113 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 114 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8, WriteColor<R8G8B8, GLfloat> ); |
| 115 | InsertFormatMapping(&map, GL_RGB, GL_BYTE, GL_RGB8_SNORM, WriteColor<R8G8B8S, GLfloat> ); |
| 116 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB565, WriteColor<R5G6B5, GLfloat> ); |
| 117 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_R11F_G11F_B10F, WriteColor<R11G11B10F, GLfloat> ); |
| 118 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_RGB9_E5, WriteColor<R9G9B9E5, GLfloat> ); |
| 119 | InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F, WriteColor<R32G32B32F, GLfloat> ); |
| 120 | InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT, GL_RGB16F, WriteColor<R16G16B16F, GLfloat> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 121 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 122 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_RGB8UI, WriteColor<R8G8B8, GLuint> ); |
| 123 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_BYTE, GL_RGB8I, WriteColor<R8G8B8S, GLint> ); |
| 124 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_RGB16UI, WriteColor<R16G16B16, GLuint> ); |
| 125 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_SHORT, GL_RGB16I, WriteColor<R16G16B16S, GLint> ); |
| 126 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_RGB32UI, WriteColor<R32G32B32, GLuint> ); |
| 127 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_INT, GL_RGB32I, WriteColor<R32G32B32S, GLint> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 128 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 129 | InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_BYTE, GL_RG8, WriteColor<R8G8, GLfloat> ); |
| 130 | InsertFormatMapping(&map, GL_RG, GL_BYTE, GL_RG8_SNORM, WriteColor<R8G8S, GLfloat> ); |
| 131 | InsertFormatMapping(&map, GL_RG, GL_FLOAT, GL_RG32F, WriteColor<R32G32F, GLfloat> ); |
| 132 | InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT, GL_RG16F, WriteColor<R16G16F, GLfloat> ); |
| 133 | |
| 134 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_RG8UI, WriteColor<R8G8, GLuint> ); |
| 135 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_BYTE, GL_RG8I, WriteColor<R8G8S, GLint> ); |
| 136 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_RG16UI, WriteColor<R16G16, GLuint> ); |
| 137 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_SHORT, GL_RG16I, WriteColor<R16G16S, GLint> ); |
| 138 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_RG32UI, WriteColor<R32G32, GLuint> ); |
| 139 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_INT, GL_RG32I, WriteColor<R32G32S, GLint> ); |
| 140 | |
| 141 | InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_BYTE, GL_R8, WriteColor<R8, GLfloat> ); |
| 142 | InsertFormatMapping(&map, GL_RED, GL_BYTE, GL_R8_SNORM, WriteColor<R8S, GLfloat> ); |
| 143 | InsertFormatMapping(&map, GL_RED, GL_FLOAT, GL_R32F, WriteColor<R32F, GLfloat> ); |
| 144 | InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT, GL_R16F, WriteColor<R16F, GLfloat> ); |
| 145 | |
| 146 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_R8UI, WriteColor<R8, GLuint> ); |
| 147 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_BYTE, GL_R8I, WriteColor<R8S, GLint> ); |
| 148 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_R16UI, WriteColor<R16, GLuint> ); |
| 149 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_SHORT, GL_R16I, WriteColor<R16S, GLint> ); |
| 150 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_R32UI, WriteColor<R32, GLuint> ); |
| 151 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_INT, GL_R32I, WriteColor<R32S, GLint> ); |
| 152 | |
| 153 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE8_ALPHA8_EXT, WriteColor<L8A8, GLfloat> ); |
| 154 | InsertFormatMapping(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE8_EXT, WriteColor<L8, GLfloat> ); |
| 155 | InsertFormatMapping(&map, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA8_EXT, WriteColor<A8, GLfloat> ); |
| 156 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_EXT, WriteColor<L32A32F, GLfloat> ); |
| 157 | InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT, WriteColor<L32F, GLfloat> ); |
| 158 | InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT, WriteColor<A32F, GLfloat> ); |
| 159 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_LUMINANCE_ALPHA16F_EXT, WriteColor<L16A16F, GLfloat> ); |
| 160 | InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT, GL_LUMINANCE16F_EXT, WriteColor<L16F, GLfloat> ); |
| 161 | InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT, GL_ALPHA16F_EXT, WriteColor<A16F, GLfloat> ); |
| 162 | |
| 163 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT, WriteColor<B8G8R8A8, GLfloat> ); |
| 164 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX, WriteColor<B4G4R4A4, GLfloat> ); |
| 165 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX, WriteColor<B5G5R5A1, GLfloat> ); |
| 166 | |
| 167 | InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_DEPTH_COMPONENT16, NULL ); |
| 168 | InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_DEPTH_COMPONENT24, NULL ); |
| 169 | InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F, NULL ); |
| 170 | |
| 171 | InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8, NULL ); |
| 172 | InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_DEPTH32F_STENCIL8, NULL ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 173 | |
| 174 | return map; |
| 175 | } |
| 176 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 177 | static const FormatMap &GetFormatMap(GLuint clientVersion) |
| 178 | { |
| 179 | if (clientVersion == 2) |
| 180 | { |
| 181 | static const FormatMap formats = BuildES2FormatMap(); |
| 182 | return formats; |
| 183 | } |
| 184 | else if (clientVersion == 3) |
| 185 | { |
| 186 | static const FormatMap formats = BuildES3FormatMap(); |
| 187 | return formats; |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | UNREACHABLE(); |
| 192 | static FormatMap emptyMap; |
| 193 | return emptyMap; |
| 194 | } |
| 195 | } |
| 196 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 197 | struct FormatInfo |
| 198 | { |
| 199 | GLint mInternalformat; |
| 200 | GLenum mFormat; |
| 201 | GLenum mType; |
| 202 | |
| 203 | FormatInfo(GLint internalformat, GLenum format, GLenum type) |
| 204 | : mInternalformat(internalformat), mFormat(format), mType(type) { } |
| 205 | |
| 206 | bool operator<(const FormatInfo& other) const |
| 207 | { |
| 208 | return memcmp(this, &other, sizeof(FormatInfo)) < 0; |
| 209 | } |
| 210 | }; |
| 211 | |
| 212 | // ES3 has a specific set of permutations of internal formats, formats and types which are acceptable. |
| 213 | typedef std::set<FormatInfo> ES3FormatSet; |
| 214 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 215 | ES3FormatSet BuildES3FormatSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 216 | { |
| 217 | ES3FormatSet set; |
| 218 | |
| 219 | // Format combinations from ES 3.0.1 spec, table 3.2 |
| 220 | |
| 221 | // | Internal format | Format | Type | |
| 222 | // | | | | |
| 223 | set.insert(FormatInfo(GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE )); |
| 224 | set.insert(FormatInfo(GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_BYTE )); |
| 225 | set.insert(FormatInfo(GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE )); |
| 226 | set.insert(FormatInfo(GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE )); |
| 227 | set.insert(FormatInfo(GL_RGBA8_SNORM, GL_RGBA, GL_BYTE )); |
| 228 | set.insert(FormatInfo(GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 )); |
| 229 | set.insert(FormatInfo(GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV )); |
| 230 | set.insert(FormatInfo(GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV )); |
shannonwoods@chromium.org | d03f897 | 2013-05-30 00:17:07 +0000 | [diff] [blame] | 231 | set.insert(FormatInfo(GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 )); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 232 | set.insert(FormatInfo(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT )); |
| 233 | set.insert(FormatInfo(GL_RGBA32F, GL_RGBA, GL_FLOAT )); |
| 234 | set.insert(FormatInfo(GL_RGBA16F, GL_RGBA, GL_FLOAT )); |
| 235 | set.insert(FormatInfo(GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE )); |
| 236 | set.insert(FormatInfo(GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE )); |
| 237 | set.insert(FormatInfo(GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT )); |
| 238 | set.insert(FormatInfo(GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT )); |
| 239 | set.insert(FormatInfo(GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT )); |
| 240 | set.insert(FormatInfo(GL_RGBA32I, GL_RGBA_INTEGER, GL_INT )); |
| 241 | set.insert(FormatInfo(GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV )); |
| 242 | set.insert(FormatInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE )); |
| 243 | set.insert(FormatInfo(GL_RGB565, GL_RGB, GL_UNSIGNED_BYTE )); |
| 244 | set.insert(FormatInfo(GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE )); |
| 245 | set.insert(FormatInfo(GL_RGB8_SNORM, GL_RGB, GL_BYTE )); |
| 246 | set.insert(FormatInfo(GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 )); |
| 247 | set.insert(FormatInfo(GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV )); |
| 248 | set.insert(FormatInfo(GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV )); |
| 249 | set.insert(FormatInfo(GL_RGB16F, GL_RGB, GL_HALF_FLOAT )); |
| 250 | set.insert(FormatInfo(GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT )); |
| 251 | set.insert(FormatInfo(GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT )); |
| 252 | set.insert(FormatInfo(GL_RGB32F, GL_RGB, GL_FLOAT )); |
| 253 | set.insert(FormatInfo(GL_RGB16F, GL_RGB, GL_FLOAT )); |
| 254 | set.insert(FormatInfo(GL_R11F_G11F_B10F, GL_RGB, GL_FLOAT )); |
| 255 | set.insert(FormatInfo(GL_RGB9_E5, GL_RGB, GL_FLOAT )); |
| 256 | set.insert(FormatInfo(GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE )); |
| 257 | set.insert(FormatInfo(GL_RGB8I, GL_RGB_INTEGER, GL_BYTE )); |
| 258 | set.insert(FormatInfo(GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT )); |
| 259 | set.insert(FormatInfo(GL_RGB16I, GL_RGB_INTEGER, GL_SHORT )); |
| 260 | set.insert(FormatInfo(GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT )); |
| 261 | set.insert(FormatInfo(GL_RGB32I, GL_RGB_INTEGER, GL_INT )); |
| 262 | set.insert(FormatInfo(GL_RG8, GL_RG, GL_UNSIGNED_BYTE )); |
| 263 | set.insert(FormatInfo(GL_RG8_SNORM, GL_RG, GL_BYTE )); |
| 264 | set.insert(FormatInfo(GL_RG16F, GL_RG, GL_HALF_FLOAT )); |
| 265 | set.insert(FormatInfo(GL_RG32F, GL_RG, GL_FLOAT )); |
| 266 | set.insert(FormatInfo(GL_RG16F, GL_RG, GL_FLOAT )); |
| 267 | set.insert(FormatInfo(GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE )); |
| 268 | set.insert(FormatInfo(GL_RG8I, GL_RG_INTEGER, GL_BYTE )); |
| 269 | set.insert(FormatInfo(GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT )); |
| 270 | set.insert(FormatInfo(GL_RG16I, GL_RG_INTEGER, GL_SHORT )); |
| 271 | set.insert(FormatInfo(GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT )); |
| 272 | set.insert(FormatInfo(GL_RG32I, GL_RG_INTEGER, GL_INT )); |
| 273 | set.insert(FormatInfo(GL_R8, GL_RED, GL_UNSIGNED_BYTE )); |
| 274 | set.insert(FormatInfo(GL_R8_SNORM, GL_RED, GL_BYTE )); |
| 275 | set.insert(FormatInfo(GL_R16F, GL_RED, GL_HALF_FLOAT )); |
| 276 | set.insert(FormatInfo(GL_R32F, GL_RED, GL_FLOAT )); |
| 277 | set.insert(FormatInfo(GL_R16F, GL_RED, GL_FLOAT )); |
| 278 | set.insert(FormatInfo(GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE )); |
| 279 | set.insert(FormatInfo(GL_R8I, GL_RED_INTEGER, GL_BYTE )); |
| 280 | set.insert(FormatInfo(GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT )); |
| 281 | set.insert(FormatInfo(GL_R16I, GL_RED_INTEGER, GL_SHORT )); |
| 282 | set.insert(FormatInfo(GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT )); |
| 283 | set.insert(FormatInfo(GL_R32I, GL_RED_INTEGER, GL_INT )); |
| 284 | |
| 285 | // Unsized formats |
| 286 | set.insert(FormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE )); |
| 287 | set.insert(FormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 )); |
| 288 | set.insert(FormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 )); |
| 289 | set.insert(FormatInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE )); |
| 290 | set.insert(FormatInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 )); |
| 291 | set.insert(FormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE )); |
| 292 | set.insert(FormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE )); |
| 293 | set.insert(FormatInfo(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE )); |
| 294 | |
| 295 | // Depth stencil formats |
| 296 | set.insert(FormatInfo(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT )); |
| 297 | set.insert(FormatInfo(GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT )); |
| 298 | set.insert(FormatInfo(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT )); |
| 299 | set.insert(FormatInfo(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT )); |
| 300 | set.insert(FormatInfo(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 )); |
| 301 | set.insert(FormatInfo(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV)); |
| 302 | |
| 303 | // From GL_OES_texture_float |
| 304 | set.insert(FormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_FLOAT )); |
| 305 | set.insert(FormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_FLOAT )); |
| 306 | set.insert(FormatInfo(GL_ALPHA, GL_ALPHA, GL_FLOAT )); |
| 307 | |
| 308 | // From GL_OES_texture_half_float |
| 309 | set.insert(FormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT )); |
| 310 | set.insert(FormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_HALF_FLOAT )); |
| 311 | set.insert(FormatInfo(GL_ALPHA, GL_ALPHA, GL_HALF_FLOAT )); |
| 312 | |
| 313 | // From GL_EXT_texture_storage |
| 314 | // | Internal format | Format | Type | |
| 315 | // | | | | |
| 316 | set.insert(FormatInfo(GL_ALPHA8_EXT, GL_ALPHA, GL_UNSIGNED_BYTE )); |
| 317 | set.insert(FormatInfo(GL_LUMINANCE8_EXT, GL_LUMINANCE, GL_UNSIGNED_BYTE )); |
| 318 | set.insert(FormatInfo(GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE )); |
| 319 | set.insert(FormatInfo(GL_ALPHA32F_EXT, GL_ALPHA, GL_FLOAT )); |
| 320 | set.insert(FormatInfo(GL_LUMINANCE32F_EXT, GL_LUMINANCE, GL_FLOAT )); |
| 321 | set.insert(FormatInfo(GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE_ALPHA, GL_FLOAT )); |
| 322 | set.insert(FormatInfo(GL_ALPHA16F_EXT, GL_ALPHA, GL_HALF_FLOAT )); |
| 323 | set.insert(FormatInfo(GL_LUMINANCE16F_EXT, GL_LUMINANCE, GL_HALF_FLOAT )); |
| 324 | set.insert(FormatInfo(GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT )); |
| 325 | |
| 326 | set.insert(FormatInfo(GL_BGRA8_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE )); |
| 327 | set.insert(FormatInfo(GL_BGRA4_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT)); |
| 328 | set.insert(FormatInfo(GL_BGRA4_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_BYTE )); |
| 329 | set.insert(FormatInfo(GL_BGR5_A1_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT)); |
| 330 | set.insert(FormatInfo(GL_BGR5_A1_ANGLEX, GL_BGRA_EXT, GL_UNSIGNED_BYTE )); |
| 331 | |
| 332 | // From GL_ANGLE_depth_texture |
| 333 | set.insert(FormatInfo(GL_DEPTH_COMPONENT32_OES, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8_OES )); |
| 334 | |
| 335 | // Compressed formats |
| 336 | // From ES 3.0.1 spec, table 3.16 |
| 337 | // | Internal format | Format | Type | |
| 338 | // | | | | |
| 339 | set.insert(FormatInfo(GL_COMPRESSED_R11_EAC, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE)); |
| 340 | set.insert(FormatInfo(GL_COMPRESSED_R11_EAC, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE)); |
| 341 | set.insert(FormatInfo(GL_COMPRESSED_SIGNED_R11_EAC, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE)); |
| 342 | set.insert(FormatInfo(GL_COMPRESSED_RG11_EAC, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE)); |
| 343 | set.insert(FormatInfo(GL_COMPRESSED_SIGNED_RG11_EAC, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE)); |
| 344 | set.insert(FormatInfo(GL_COMPRESSED_RGB8_ETC2, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE)); |
| 345 | set.insert(FormatInfo(GL_COMPRESSED_SRGB8_ETC2, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE)); |
| 346 | set.insert(FormatInfo(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE)); |
| 347 | set.insert(FormatInfo(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE)); |
| 348 | set.insert(FormatInfo(GL_COMPRESSED_RGBA8_ETC2_EAC, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE)); |
| 349 | set.insert(FormatInfo(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE)); |
| 350 | |
| 351 | |
| 352 | // From GL_EXT_texture_compression_dxt1 |
| 353 | set.insert(FormatInfo(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE)); |
| 354 | set.insert(FormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE)); |
| 355 | |
| 356 | // From GL_ANGLE_texture_compression_dxt3 |
| 357 | set.insert(FormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE)); |
| 358 | |
| 359 | // From GL_ANGLE_texture_compression_dxt5 |
| 360 | set.insert(FormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE)); |
| 361 | |
| 362 | return set; |
| 363 | } |
| 364 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 365 | static const ES3FormatSet &GetES3FormatSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 366 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 367 | static const ES3FormatSet es3FormatSet = BuildES3FormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 368 | return es3FormatSet; |
| 369 | } |
| 370 | |
| 371 | // Map of sizes of input types |
| 372 | struct TypeInfo |
| 373 | { |
| 374 | GLuint mTypeBytes; |
| 375 | bool mSpecialInterpretation; |
| 376 | |
| 377 | TypeInfo() |
| 378 | : mTypeBytes(0), mSpecialInterpretation(false) { } |
| 379 | |
| 380 | TypeInfo(GLuint typeBytes, bool specialInterpretation) |
| 381 | : mTypeBytes(typeBytes), mSpecialInterpretation(specialInterpretation) { } |
| 382 | |
| 383 | bool operator<(const TypeInfo& other) const |
| 384 | { |
| 385 | return memcmp(this, &other, sizeof(TypeInfo)) < 0; |
| 386 | } |
| 387 | }; |
| 388 | |
| 389 | typedef std::pair<GLenum, TypeInfo> TypeInfoPair; |
| 390 | typedef std::map<GLenum, TypeInfo> TypeInfoMap; |
| 391 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 392 | static TypeInfoMap BuildTypeInfoMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 393 | { |
| 394 | TypeInfoMap map; |
| 395 | |
| 396 | map.insert(TypeInfoPair(GL_UNSIGNED_BYTE, TypeInfo( 1, false))); |
| 397 | map.insert(TypeInfoPair(GL_BYTE, TypeInfo( 1, false))); |
| 398 | map.insert(TypeInfoPair(GL_UNSIGNED_SHORT, TypeInfo( 2, false))); |
| 399 | map.insert(TypeInfoPair(GL_SHORT, TypeInfo( 2, false))); |
| 400 | map.insert(TypeInfoPair(GL_UNSIGNED_INT, TypeInfo( 4, false))); |
| 401 | map.insert(TypeInfoPair(GL_INT, TypeInfo( 4, false))); |
| 402 | map.insert(TypeInfoPair(GL_HALF_FLOAT, TypeInfo( 2, false))); |
Jamie Madill | a940ae4 | 2013-07-08 17:48:34 -0400 | [diff] [blame] | 403 | map.insert(TypeInfoPair(GL_HALF_FLOAT_OES, TypeInfo( 2, false))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 404 | map.insert(TypeInfoPair(GL_FLOAT, TypeInfo( 4, false))); |
| 405 | map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_5_6_5, TypeInfo( 2, true ))); |
| 406 | map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_4_4_4_4, TypeInfo( 2, true ))); |
| 407 | map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_5_5_5_1, TypeInfo( 2, true ))); |
| 408 | map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, TypeInfo( 2, true ))); |
| 409 | map.insert(TypeInfoPair(GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, TypeInfo( 2, true ))); |
| 410 | map.insert(TypeInfoPair(GL_UNSIGNED_INT_2_10_10_10_REV, TypeInfo( 4, true ))); |
| 411 | map.insert(TypeInfoPair(GL_UNSIGNED_INT_24_8, TypeInfo( 4, true ))); |
| 412 | map.insert(TypeInfoPair(GL_UNSIGNED_INT_10F_11F_11F_REV, TypeInfo( 4, true ))); |
| 413 | map.insert(TypeInfoPair(GL_UNSIGNED_INT_5_9_9_9_REV, TypeInfo( 4, true ))); |
| 414 | map.insert(TypeInfoPair(GL_FLOAT_32_UNSIGNED_INT_24_8_REV, TypeInfo( 4, true ))); |
| 415 | map.insert(TypeInfoPair(GL_UNSIGNED_INT_24_8_OES, TypeInfo( 4, true ))); |
| 416 | |
| 417 | return map; |
| 418 | } |
| 419 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 420 | static bool GetTypeInfo(GLenum type, TypeInfo *outTypeInfo) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 421 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 422 | static const TypeInfoMap infoMap = BuildTypeInfoMap(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 423 | TypeInfoMap::const_iterator iter = infoMap.find(type); |
| 424 | if (iter != infoMap.end()) |
| 425 | { |
| 426 | if (outTypeInfo) |
| 427 | { |
| 428 | *outTypeInfo = iter->second; |
| 429 | } |
| 430 | return true; |
| 431 | } |
| 432 | else |
| 433 | { |
| 434 | return false; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | // Information about internal formats |
| 439 | typedef bool ((Context::*ContextSupportCheckMemberFunction)(void) const); |
| 440 | typedef bool (*ContextSupportCheckFunction)(const Context *context); |
| 441 | |
| 442 | typedef bool ((rx::Renderer::*RendererSupportCheckMemberFunction)(void) const); |
| 443 | typedef bool (*ContextRendererSupportCheckFunction)(const Context *context, const rx::Renderer *renderer); |
| 444 | |
| 445 | template <ContextSupportCheckMemberFunction func> |
| 446 | bool CheckSupport(const Context *context) |
| 447 | { |
| 448 | return (context->*func)(); |
| 449 | } |
| 450 | |
| 451 | template <ContextSupportCheckMemberFunction contextFunc, RendererSupportCheckMemberFunction rendererFunc> |
| 452 | bool CheckSupport(const Context *context, const rx::Renderer *renderer) |
| 453 | { |
| 454 | if (context) |
| 455 | { |
| 456 | return (context->*contextFunc)(); |
| 457 | } |
| 458 | else if (renderer) |
| 459 | { |
| 460 | return (renderer->*rendererFunc)(); |
| 461 | } |
| 462 | else |
| 463 | { |
| 464 | UNREACHABLE(); |
| 465 | return false; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | template <typename objectType> |
| 470 | bool AlwaysSupported(const objectType*) |
| 471 | { |
| 472 | return true; |
| 473 | } |
| 474 | |
| 475 | template <typename objectTypeA, typename objectTypeB> |
| 476 | bool AlwaysSupported(const objectTypeA*, const objectTypeB*) |
| 477 | { |
| 478 | return true; |
| 479 | } |
| 480 | |
| 481 | template <typename objectType> |
| 482 | bool NeverSupported(const objectType*) |
| 483 | { |
| 484 | return false; |
| 485 | } |
| 486 | |
| 487 | template <typename objectTypeA, typename objectTypeB> |
| 488 | bool NeverSupported(const objectTypeA *, const objectTypeB *) |
| 489 | { |
| 490 | return false; |
| 491 | } |
| 492 | |
| 493 | template <typename objectType> |
| 494 | bool UnimplementedSupport(const objectType*) |
| 495 | { |
| 496 | UNIMPLEMENTED(); |
| 497 | return false; |
| 498 | } |
| 499 | |
| 500 | template <typename objectTypeA, typename objectTypeB> |
| 501 | bool UnimplementedSupport(const objectTypeA*, const objectTypeB*) |
| 502 | { |
| 503 | UNIMPLEMENTED(); |
| 504 | return false; |
| 505 | } |
| 506 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 507 | struct InternalFormatInfo |
| 508 | { |
| 509 | GLuint mRedBits; |
| 510 | GLuint mGreenBits; |
| 511 | GLuint mBlueBits; |
| 512 | |
| 513 | GLuint mLuminanceBits; |
| 514 | |
| 515 | GLuint mAlphaBits; |
| 516 | GLuint mSharedBits; |
| 517 | |
| 518 | GLuint mDepthBits; |
| 519 | GLuint mStencilBits; |
| 520 | |
| 521 | GLuint mPixelBits; |
| 522 | |
| 523 | GLuint mComponentCount; |
| 524 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 525 | GLuint mCompressedBlockWidth; |
| 526 | GLuint mCompressedBlockHeight; |
| 527 | |
| 528 | GLenum mFormat; |
| 529 | GLenum mType; |
| 530 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 531 | GLenum mComponentType; |
| 532 | GLenum mColorEncoding; |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 533 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 534 | bool mIsCompressed; |
shannonwoods@chromium.org | e81ea50 | 2013-05-30 00:16:53 +0000 | [diff] [blame] | 535 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 536 | ContextRendererSupportCheckFunction mIsColorRenderable; |
| 537 | ContextRendererSupportCheckFunction mIsDepthRenderable; |
| 538 | ContextRendererSupportCheckFunction mIsStencilRenderable; |
| 539 | ContextRendererSupportCheckFunction mIsTextureFilterable; |
| 540 | |
| 541 | ContextSupportCheckFunction mSupportFunction; |
| 542 | |
| 543 | InternalFormatInfo() : mRedBits(0), mGreenBits(0), mBlueBits(0), mLuminanceBits(0), mAlphaBits(0), mSharedBits(0), mDepthBits(0), mStencilBits(0), |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 544 | mPixelBits(0), mComponentCount(0), mCompressedBlockWidth(0), mCompressedBlockHeight(0), mFormat(GL_NONE), mType(GL_NONE), |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 545 | mComponentType(GL_NONE), mColorEncoding(GL_NONE), mIsCompressed(false), mIsColorRenderable(NeverSupported), |
| 546 | mIsDepthRenderable(NeverSupported), mIsStencilRenderable(NeverSupported), mIsTextureFilterable(NeverSupported), |
| 547 | mSupportFunction(NeverSupported) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 548 | { |
| 549 | } |
| 550 | |
| 551 | static InternalFormatInfo UnsizedFormat(GLenum format, ContextSupportCheckFunction supportFunction) |
| 552 | { |
| 553 | InternalFormatInfo formatInfo; |
| 554 | formatInfo.mFormat = format; |
| 555 | formatInfo.mSupportFunction = supportFunction; |
Shannon Woods | 9e73b21 | 2013-07-08 10:32:19 -0400 | [diff] [blame] | 556 | |
| 557 | if (format == GL_RGB || format == GL_RGBA) |
| 558 | formatInfo.mIsColorRenderable = AlwaysSupported; |
| 559 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 560 | return formatInfo; |
| 561 | } |
| 562 | |
| 563 | static InternalFormatInfo RGBAFormat(GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint shared, |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 564 | GLenum format, GLenum type, GLenum componentType, bool srgb, |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 565 | ContextRendererSupportCheckFunction colorRenderable, |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 566 | ContextRendererSupportCheckFunction textureFilterable, |
| 567 | ContextSupportCheckFunction supportFunction) |
| 568 | { |
| 569 | InternalFormatInfo formatInfo; |
| 570 | formatInfo.mRedBits = red; |
| 571 | formatInfo.mGreenBits = green; |
| 572 | formatInfo.mBlueBits = blue; |
| 573 | formatInfo.mAlphaBits = alpha; |
| 574 | formatInfo.mSharedBits = shared; |
| 575 | formatInfo.mPixelBits = red + green + blue + alpha + shared; |
| 576 | formatInfo.mComponentCount = ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0); |
| 577 | formatInfo.mFormat = format; |
| 578 | formatInfo.mType = type; |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 579 | formatInfo.mComponentType = componentType; |
| 580 | formatInfo.mColorEncoding = (srgb ? GL_SRGB : GL_LINEAR); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 581 | formatInfo.mIsColorRenderable = colorRenderable; |
| 582 | formatInfo.mIsTextureFilterable = textureFilterable; |
| 583 | formatInfo.mSupportFunction = supportFunction; |
| 584 | return formatInfo; |
| 585 | } |
| 586 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 587 | static InternalFormatInfo LUMAFormat(GLuint luminance, GLuint alpha, GLenum format, GLenum type, GLenum componentType, |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 588 | ContextSupportCheckFunction supportFunction) |
| 589 | { |
| 590 | InternalFormatInfo formatInfo; |
| 591 | formatInfo.mLuminanceBits = luminance; |
| 592 | formatInfo.mAlphaBits = alpha; |
| 593 | formatInfo.mPixelBits = luminance + alpha; |
| 594 | formatInfo.mComponentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0); |
| 595 | formatInfo.mFormat = format; |
| 596 | formatInfo.mType = type; |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 597 | formatInfo.mComponentType = componentType; |
| 598 | formatInfo.mColorEncoding = GL_LINEAR; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 599 | formatInfo.mIsTextureFilterable = AlwaysSupported; |
| 600 | formatInfo.mSupportFunction = supportFunction; |
| 601 | return formatInfo; |
| 602 | } |
| 603 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 604 | static InternalFormatInfo DepthStencilFormat(GLuint depth, GLuint stencil, GLenum format, GLenum type, GLenum componentType, |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 605 | ContextRendererSupportCheckFunction depthRenderable, |
| 606 | ContextRendererSupportCheckFunction stencilRenderable, |
| 607 | ContextSupportCheckFunction supportFunction) |
| 608 | { |
| 609 | InternalFormatInfo formatInfo; |
| 610 | formatInfo.mDepthBits = depth; |
| 611 | formatInfo.mStencilBits = stencil; |
| 612 | formatInfo.mPixelBits = depth + stencil; |
| 613 | formatInfo.mComponentCount = ((depth > 0) ? 1 : 0) + ((stencil > 0) ? 1 : 0); |
| 614 | formatInfo.mFormat = format; |
| 615 | formatInfo.mType = type; |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 616 | formatInfo.mComponentType = componentType; |
| 617 | formatInfo.mColorEncoding = GL_LINEAR; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 618 | formatInfo.mIsDepthRenderable = depthRenderable; |
| 619 | formatInfo.mIsStencilRenderable = stencilRenderable; |
Nicolas Capens | 08be89d | 2013-07-16 16:17:31 -0400 | [diff] [blame] | 620 | formatInfo.mIsTextureFilterable = AlwaysSupported; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 621 | formatInfo.mSupportFunction = supportFunction; |
| 622 | return formatInfo; |
| 623 | } |
| 624 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 625 | static InternalFormatInfo CompressedFormat(GLuint compressedBlockWidth, GLuint compressedBlockHeight, GLuint compressedBlockSize, |
| 626 | GLuint componentCount, GLenum format, GLenum type, bool srgb, |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 627 | ContextSupportCheckFunction supportFunction) |
| 628 | { |
| 629 | InternalFormatInfo formatInfo; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 630 | formatInfo.mCompressedBlockWidth = compressedBlockWidth; |
| 631 | formatInfo.mCompressedBlockHeight = compressedBlockHeight; |
| 632 | formatInfo.mPixelBits = compressedBlockSize; |
| 633 | formatInfo.mComponentCount = componentCount; |
| 634 | formatInfo.mFormat = format; |
| 635 | formatInfo.mType = type; |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 636 | formatInfo.mComponentType = GL_UNSIGNED_NORMALIZED; |
| 637 | formatInfo.mColorEncoding = (srgb ? GL_SRGB : GL_LINEAR); |
| 638 | formatInfo.mIsCompressed = true; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 639 | formatInfo.mIsTextureFilterable = AlwaysSupported; |
| 640 | formatInfo.mSupportFunction = supportFunction; |
| 641 | return formatInfo; |
| 642 | } |
| 643 | }; |
| 644 | |
| 645 | typedef std::pair<GLuint, InternalFormatInfo> InternalFormatInfoPair; |
| 646 | typedef std::map<GLuint, InternalFormatInfo> InternalFormatInfoMap; |
| 647 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 648 | static InternalFormatInfoMap BuildES3InternalFormatInfoMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 649 | { |
| 650 | InternalFormatInfoMap map; |
| 651 | |
| 652 | // From ES 3.0.1 spec, table 3.12 |
| 653 | map.insert(InternalFormatInfoPair(GL_NONE, InternalFormatInfo())); |
| 654 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 655 | // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Color | Texture | Supported | |
| 656 | // | | | | | | | | | | | | renderable | filterable | | |
| 657 | map.insert(InternalFormatInfoPair(GL_R8, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 658 | map.insert(InternalFormatInfoPair(GL_R8_SNORM, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); |
| 659 | map.insert(InternalFormatInfoPair(GL_RG8, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 660 | map.insert(InternalFormatInfoPair(GL_RG8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); |
| 661 | map.insert(InternalFormatInfoPair(GL_RGB8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 662 | map.insert(InternalFormatInfoPair(GL_RGB8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); |
Jamie Madill | 1d855fe | 2013-09-09 16:24:05 -0400 | [diff] [blame] | 663 | map.insert(InternalFormatInfoPair(GL_RGB565, InternalFormatInfo::RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 664 | map.insert(InternalFormatInfoPair(GL_RGBA4, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 665 | map.insert(InternalFormatInfoPair(GL_RGB5_A1, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 666 | map.insert(InternalFormatInfoPair(GL_RGBA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 667 | map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); |
| 668 | map.insert(InternalFormatInfoPair(GL_RGB10_A2, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
Jamie Madill | 18a4470 | 2013-09-09 16:24:04 -0400 | [diff] [blame] | 669 | map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, InternalFormatInfo::RGBAFormat(10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 670 | map.insert(InternalFormatInfoPair(GL_SRGB8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, NeverSupported, AlwaysSupported, AlwaysSupported ))); |
| 671 | map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 672 | map.insert(InternalFormatInfoPair(GL_R11F_G11F_B10F, InternalFormatInfo::RGBAFormat(11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); |
| 673 | map.insert(InternalFormatInfoPair(GL_RGB9_E5, InternalFormatInfo::RGBAFormat( 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, NeverSupported, AlwaysSupported, AlwaysSupported ))); |
| 674 | map.insert(InternalFormatInfoPair(GL_R8I, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 675 | map.insert(InternalFormatInfoPair(GL_R8UI, InternalFormatInfo::RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 676 | map.insert(InternalFormatInfoPair(GL_R16I, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 677 | map.insert(InternalFormatInfoPair(GL_R16UI, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 678 | map.insert(InternalFormatInfoPair(GL_R32I, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 679 | map.insert(InternalFormatInfoPair(GL_R32UI, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 680 | map.insert(InternalFormatInfoPair(GL_RG8I, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 681 | map.insert(InternalFormatInfoPair(GL_RG8UI, InternalFormatInfo::RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 682 | map.insert(InternalFormatInfoPair(GL_RG16I, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 683 | map.insert(InternalFormatInfoPair(GL_RG16UI, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 684 | map.insert(InternalFormatInfoPair(GL_RG32I, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 685 | map.insert(InternalFormatInfoPair(GL_RG32UI, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 686 | map.insert(InternalFormatInfoPair(GL_RGB8I, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); |
| 687 | map.insert(InternalFormatInfoPair(GL_RGB8UI, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); |
| 688 | map.insert(InternalFormatInfoPair(GL_RGB16I, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); |
| 689 | map.insert(InternalFormatInfoPair(GL_RGB16UI, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); |
| 690 | map.insert(InternalFormatInfoPair(GL_RGB32I, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); |
| 691 | map.insert(InternalFormatInfoPair(GL_RGB32UI, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, NeverSupported, NeverSupported, AlwaysSupported ))); |
| 692 | map.insert(InternalFormatInfoPair(GL_RGBA8I, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 693 | map.insert(InternalFormatInfoPair(GL_RGBA8UI, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 694 | map.insert(InternalFormatInfoPair(GL_RGBA16I, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 695 | map.insert(InternalFormatInfoPair(GL_RGBA16UI, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 696 | map.insert(InternalFormatInfoPair(GL_RGBA32I, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
| 697 | map.insert(InternalFormatInfoPair(GL_RGBA32UI, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, AlwaysSupported, NeverSupported, AlwaysSupported ))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 698 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 699 | map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 700 | map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
| 701 | map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported ))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 702 | |
| 703 | // Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 704 | // | Internal format | | D |S | Format | Type | Comp | SRGB | Color renderable | Texture filterable | Supported | |
| 705 | // | | | | | | | type | | | | | |
| 706 | map.insert(InternalFormatInfoPair(GL_R16F, InternalFormatInfo::RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); |
| 707 | map.insert(InternalFormatInfoPair(GL_RG16F, InternalFormatInfo::RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); |
| 708 | map.insert(InternalFormatInfoPair(GL_RGB16F, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); |
| 709 | map.insert(InternalFormatInfoPair(GL_RGBA16F, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, AlwaysSupported ))); |
| 710 | map.insert(InternalFormatInfoPair(GL_R32F, InternalFormatInfo::RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, AlwaysSupported ))); |
| 711 | map.insert(InternalFormatInfoPair(GL_RG32F, InternalFormatInfo::RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, AlwaysSupported ))); |
| 712 | map.insert(InternalFormatInfoPair(GL_RGB32F, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, AlwaysSupported ))); |
| 713 | map.insert(InternalFormatInfoPair(GL_RGBA32F, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, AlwaysSupported ))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 714 | |
| 715 | // Depth stencil formats |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 716 | // | Internal format | | D |S | Format | Type | Component type | Depth | Stencil | Supported | |
| 717 | // | | | | | | | | renderable | renderable | | |
| 718 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, InternalFormatInfo::DepthStencilFormat(16, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); |
| 719 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT24, InternalFormatInfo::DepthStencilFormat(24, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); |
| 720 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32F, InternalFormatInfo::DepthStencilFormat(32, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, AlwaysSupported, NeverSupported, AlwaysSupported))); |
| 721 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, InternalFormatInfo::DepthStencilFormat(32, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); |
| 722 | map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8, InternalFormatInfo::DepthStencilFormat(24, 8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, AlwaysSupported))); |
| 723 | map.insert(InternalFormatInfoPair(GL_DEPTH32F_STENCIL8, InternalFormatInfo::DepthStencilFormat(32, 8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, AlwaysSupported, AlwaysSupported, AlwaysSupported))); |
| 724 | map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, InternalFormatInfo::DepthStencilFormat( 0, 8, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, NeverSupported, AlwaysSupported, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 725 | |
| 726 | // Luminance alpha formats |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 727 | // | Internal format | | L | A | Format | Type | Component type | Supported | |
| 728 | map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 729 | map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, InternalFormatInfo::LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 730 | map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 731 | map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, InternalFormatInfo::LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 732 | map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 733 | map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, InternalFormatInfo::LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 734 | map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 735 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 736 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_FLOAT, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 737 | |
| 738 | // Unsized formats |
| 739 | // | Internal format | | Format | Supported | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 740 | map.insert(InternalFormatInfoPair(GL_ALPHA, InternalFormatInfo::UnsizedFormat(GL_ALPHA, AlwaysSupported))); |
| 741 | map.insert(InternalFormatInfoPair(GL_LUMINANCE, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE, AlwaysSupported))); |
| 742 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE_ALPHA, AlwaysSupported))); |
Geoff Lang | d1e9a9a | 2013-09-30 15:22:57 -0400 | [diff] [blame] | 743 | map.insert(InternalFormatInfoPair(GL_RED, InternalFormatInfo::UnsizedFormat(GL_RED, AlwaysSupported))); |
| 744 | map.insert(InternalFormatInfoPair(GL_RG, InternalFormatInfo::UnsizedFormat(GL_RG, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 745 | map.insert(InternalFormatInfoPair(GL_RGB, InternalFormatInfo::UnsizedFormat(GL_RGB, AlwaysSupported))); |
| 746 | map.insert(InternalFormatInfoPair(GL_RGBA, InternalFormatInfo::UnsizedFormat(GL_RGBA, AlwaysSupported))); |
Geoff Lang | d1e9a9a | 2013-09-30 15:22:57 -0400 | [diff] [blame] | 747 | map.insert(InternalFormatInfoPair(GL_RED_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RED_INTEGER, AlwaysSupported))); |
| 748 | map.insert(InternalFormatInfoPair(GL_RG_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RG_INTEGER, AlwaysSupported))); |
| 749 | map.insert(InternalFormatInfoPair(GL_RGB_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RGB_INTEGER, AlwaysSupported))); |
| 750 | map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER, InternalFormatInfo::UnsizedFormat(GL_RGBA_INTEGER, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 751 | map.insert(InternalFormatInfoPair(GL_BGRA_EXT, InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT, AlwaysSupported))); |
| 752 | |
| 753 | // Compressed formats, From ES 3.0.1 spec, table 3.16 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 754 | // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | |
| 755 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_R11_EAC, InternalFormatInfo::CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 756 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_R11_EAC, InternalFormatInfo::CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 757 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RG11_EAC, InternalFormatInfo::CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 758 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_RG11_EAC, InternalFormatInfo::CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 759 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_ETC2, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 760 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ETC2, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, true, UnimplementedSupport))); |
| 761 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 762 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, true, UnimplementedSupport))); |
| 763 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA8_ETC2_EAC, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 764 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, true, UnimplementedSupport))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 765 | |
| 766 | // From GL_EXT_texture_compression_dxt1 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 767 | // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | |
| 768 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, AlwaysSupported))); |
| 769 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 770 | |
| 771 | // From GL_ANGLE_texture_compression_dxt3 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 772 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 773 | |
| 774 | // From GL_ANGLE_texture_compression_dxt5 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 775 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 776 | |
| 777 | return map; |
| 778 | } |
| 779 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 780 | static InternalFormatInfoMap BuildES2InternalFormatInfoMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 781 | { |
| 782 | InternalFormatInfoMap map; |
| 783 | |
| 784 | // From ES 2.0.25 table 4.5 |
| 785 | map.insert(InternalFormatInfoPair(GL_NONE, InternalFormatInfo())); |
| 786 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 787 | // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Color | Texture | Supported | |
| 788 | // | | | | | | | | | | | | renderable | filterable | | |
| 789 | map.insert(InternalFormatInfoPair(GL_RGBA4, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); |
| 790 | map.insert(InternalFormatInfoPair(GL_RGB5_A1, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); |
| 791 | map.insert(InternalFormatInfoPair(GL_RGB565, InternalFormatInfo::RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 792 | |
| 793 | // Extension formats |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 794 | map.insert(InternalFormatInfoPair(GL_RGB8_OES, InternalFormatInfo::RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); |
| 795 | map.insert(InternalFormatInfoPair(GL_RGBA8_OES, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); |
| 796 | map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, InternalFormatInfo::RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported))); |
| 797 | map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, InternalFormatInfo::RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported))); |
| 798 | map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, InternalFormatInfo::RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 799 | |
| 800 | // Floating point formats have to query the renderer for support |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 801 | // | Internal format | | R | G | B | A |S | Format | Type | Comp | SRGB | Color renderable | Texture filterable | Supported | |
| 802 | // | | | | | | | | | | type | | | | | |
| 803 | map.insert(InternalFormatInfoPair(GL_RGB16F_EXT, InternalFormatInfo::RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT_OES, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, CheckSupport<&Context::supportsFloat16Textures>))); |
| 804 | map.insert(InternalFormatInfoPair(GL_RGB32F_EXT, InternalFormatInfo::RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, CheckSupport<&Context::supportsFloat32Textures>))); |
| 805 | map.insert(InternalFormatInfoPair(GL_RGBA16F_EXT, InternalFormatInfo::RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES, GL_FLOAT, false, CheckSupport<&Context::supportsFloat16RenderableTextures, &rx::Renderer::getFloat16TextureRenderingSupport>, CheckSupport<&Context::supportsFloat16LinearFilter, &rx::Renderer::getFloat16TextureFilteringSupport>, CheckSupport<&Context::supportsFloat16Textures>))); |
| 806 | map.insert(InternalFormatInfoPair(GL_RGBA32F_EXT, InternalFormatInfo::RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, CheckSupport<&Context::supportsFloat32RenderableTextures, &rx::Renderer::getFloat32TextureRenderingSupport>, CheckSupport<&Context::supportsFloat32LinearFilter, &rx::Renderer::getFloat32TextureFilteringSupport>, CheckSupport<&Context::supportsFloat32Textures>))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 807 | |
| 808 | // Depth and stencil formats |
Shannon Woods | 9e73b21 | 2013-07-08 10:32:19 -0400 | [diff] [blame] | 809 | // | Internal format | | D |S | Format | Type | Internal format | Depth | Stencil | Supported | |
| 810 | // | | | | | | | type | renderable | renderable | | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 811 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES,InternalFormatInfo::DepthStencilFormat(32, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, CheckSupport<&Context::supportsDepthTextures>))); |
| 812 | map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8_OES, InternalFormatInfo::DepthStencilFormat(24, 8, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, CheckSupport<&Context::supportsDepthTextures>))); |
| 813 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, InternalFormatInfo::DepthStencilFormat(16, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); |
| 814 | map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, InternalFormatInfo::DepthStencilFormat( 0, 8, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, NeverSupported, AlwaysSupported, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 815 | |
| 816 | // Unsized formats |
| 817 | // | Internal format | | Format | Supported | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 818 | map.insert(InternalFormatInfoPair(GL_ALPHA, InternalFormatInfo::UnsizedFormat(GL_ALPHA, AlwaysSupported))); |
| 819 | map.insert(InternalFormatInfoPair(GL_LUMINANCE, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE, AlwaysSupported))); |
| 820 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE_ALPHA, AlwaysSupported))); |
| 821 | map.insert(InternalFormatInfoPair(GL_RGB, InternalFormatInfo::UnsizedFormat(GL_RGB, AlwaysSupported))); |
| 822 | map.insert(InternalFormatInfoPair(GL_RGBA, InternalFormatInfo::UnsizedFormat(GL_RGBA, AlwaysSupported))); |
| 823 | map.insert(InternalFormatInfoPair(GL_BGRA_EXT, InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT, AlwaysSupported))); |
| 824 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, InternalFormatInfo::UnsizedFormat(GL_DEPTH_COMPONENT, AlwaysSupported))); |
| 825 | map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL_OES, InternalFormatInfo::UnsizedFormat(GL_DEPTH_STENCIL_OES, AlwaysSupported))); |
| 826 | |
| 827 | // Luminance alpha formats from GL_EXT_texture_storage |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 828 | // | Internal format | | L | A | Format | Type | Component type | Supported | |
| 829 | map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 830 | map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, InternalFormatInfo::LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 831 | map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 832 | map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, InternalFormatInfo::LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 833 | map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, AlwaysSupported))); |
| 834 | map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, InternalFormatInfo::LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, AlwaysSupported))); |
| 835 | map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 836 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 837 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 838 | |
| 839 | // From GL_EXT_texture_compression_dxt1 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 840 | // | Internal format | |W |H | BS |CC|Format | Type | SRGB | Supported | |
| 841 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, CheckSupport<&Context::supportsDXT1Textures>))); |
| 842 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, InternalFormatInfo::CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, CheckSupport<&Context::supportsDXT1Textures>))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 843 | |
| 844 | // From GL_ANGLE_texture_compression_dxt3 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 845 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, CheckSupport<&Context::supportsDXT3Textures>))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 846 | |
| 847 | // From GL_ANGLE_texture_compression_dxt5 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 848 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, CheckSupport<&Context::supportsDXT5Textures>))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 849 | |
| 850 | return map; |
| 851 | } |
| 852 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 853 | static bool GetInternalFormatInfo(GLint internalFormat, GLuint clientVersion, InternalFormatInfo *outFormatInfo) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 854 | { |
| 855 | const InternalFormatInfoMap* map = NULL; |
| 856 | |
| 857 | if (clientVersion == 2) |
| 858 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 859 | static const InternalFormatInfoMap formatMap = BuildES2InternalFormatInfoMap(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 860 | map = &formatMap; |
| 861 | } |
| 862 | else if (clientVersion == 3) |
| 863 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 864 | static const InternalFormatInfoMap formatMap = BuildES3InternalFormatInfoMap(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 865 | map = &formatMap; |
| 866 | } |
| 867 | else |
| 868 | { |
| 869 | UNREACHABLE(); |
| 870 | } |
| 871 | |
| 872 | InternalFormatInfoMap::const_iterator iter = map->find(internalFormat); |
| 873 | if (iter != map->end()) |
| 874 | { |
| 875 | if (outFormatInfo) |
| 876 | { |
| 877 | *outFormatInfo = iter->second; |
| 878 | } |
| 879 | return true; |
| 880 | } |
| 881 | else |
| 882 | { |
| 883 | return false; |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | typedef std::set<GLenum> FormatSet; |
| 888 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 889 | static FormatSet BuildES2ValidFormatSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 890 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 891 | static const FormatMap &formatMap = GetFormatMap(2); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 892 | |
| 893 | FormatSet set; |
| 894 | |
| 895 | for (FormatMap::const_iterator i = formatMap.begin(); i != formatMap.end(); i++) |
| 896 | { |
| 897 | const FormatTypePair& formatPair = i->first; |
| 898 | set.insert(formatPair.first); |
| 899 | } |
| 900 | |
| 901 | return set; |
| 902 | } |
| 903 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 904 | static FormatSet BuildES3ValidFormatSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 905 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 906 | static const ES3FormatSet &formatSet = GetES3FormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 907 | |
| 908 | FormatSet set; |
| 909 | |
| 910 | for (ES3FormatSet::const_iterator i = formatSet.begin(); i != formatSet.end(); i++) |
| 911 | { |
| 912 | const FormatInfo& formatInfo = *i; |
| 913 | set.insert(formatInfo.mFormat); |
| 914 | } |
| 915 | |
| 916 | return set; |
| 917 | } |
| 918 | |
| 919 | typedef std::set<GLenum> TypeSet; |
| 920 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 921 | static TypeSet BuildES2ValidTypeSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 922 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 923 | static const FormatMap &formatMap = GetFormatMap(2); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 924 | |
| 925 | TypeSet set; |
| 926 | |
| 927 | for (FormatMap::const_iterator i = formatMap.begin(); i != formatMap.end(); i++) |
| 928 | { |
| 929 | const FormatTypePair& formatPair = i->first; |
| 930 | set.insert(formatPair.second); |
| 931 | } |
| 932 | |
| 933 | return set; |
| 934 | } |
| 935 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 936 | static TypeSet BuildES3ValidTypeSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 937 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 938 | static const ES3FormatSet &formatSet = GetES3FormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 939 | |
| 940 | TypeSet set; |
| 941 | |
| 942 | for (ES3FormatSet::const_iterator i = formatSet.begin(); i != formatSet.end(); i++) |
| 943 | { |
| 944 | const FormatInfo& formatInfo = *i; |
| 945 | set.insert(formatInfo.mType); |
| 946 | } |
| 947 | |
| 948 | return set; |
| 949 | } |
| 950 | |
| 951 | struct CopyConversion |
| 952 | { |
| 953 | GLenum mTextureFormat; |
| 954 | GLenum mFramebufferFormat; |
| 955 | |
| 956 | CopyConversion(GLenum textureFormat, GLenum framebufferFormat) |
| 957 | : mTextureFormat(textureFormat), mFramebufferFormat(framebufferFormat) { } |
| 958 | |
| 959 | bool operator<(const CopyConversion& other) const |
| 960 | { |
| 961 | return memcmp(this, &other, sizeof(CopyConversion)) < 0; |
| 962 | } |
| 963 | }; |
| 964 | |
| 965 | typedef std::set<CopyConversion> CopyConversionSet; |
| 966 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 967 | static CopyConversionSet BuildValidES3CopyTexImageCombinations() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 968 | { |
| 969 | CopyConversionSet set; |
| 970 | |
| 971 | // From ES 3.0.1 spec, table 3.15 |
| 972 | set.insert(CopyConversion(GL_ALPHA, GL_RGBA)); |
| 973 | set.insert(CopyConversion(GL_LUMINANCE, GL_RED)); |
| 974 | set.insert(CopyConversion(GL_LUMINANCE, GL_RG)); |
| 975 | set.insert(CopyConversion(GL_LUMINANCE, GL_RGB)); |
| 976 | set.insert(CopyConversion(GL_LUMINANCE, GL_RGBA)); |
| 977 | set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_RGBA)); |
| 978 | set.insert(CopyConversion(GL_RED, GL_RED)); |
| 979 | set.insert(CopyConversion(GL_RED, GL_RG)); |
| 980 | set.insert(CopyConversion(GL_RED, GL_RGB)); |
| 981 | set.insert(CopyConversion(GL_RED, GL_RGBA)); |
| 982 | set.insert(CopyConversion(GL_RG, GL_RG)); |
| 983 | set.insert(CopyConversion(GL_RG, GL_RGB)); |
| 984 | set.insert(CopyConversion(GL_RG, GL_RGBA)); |
| 985 | set.insert(CopyConversion(GL_RGB, GL_RGB)); |
| 986 | set.insert(CopyConversion(GL_RGB, GL_RGBA)); |
| 987 | set.insert(CopyConversion(GL_RGBA, GL_RGBA)); |
| 988 | |
Jamie Madill | b70e5f7 | 2013-07-10 16:57:52 -0400 | [diff] [blame] | 989 | // Necessary for ANGLE back-buffers |
| 990 | set.insert(CopyConversion(GL_ALPHA, GL_BGRA_EXT)); |
| 991 | set.insert(CopyConversion(GL_LUMINANCE, GL_BGRA_EXT)); |
| 992 | set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_BGRA_EXT)); |
| 993 | set.insert(CopyConversion(GL_RED, GL_BGRA_EXT)); |
| 994 | set.insert(CopyConversion(GL_RG, GL_BGRA_EXT)); |
| 995 | set.insert(CopyConversion(GL_RGB, GL_BGRA_EXT)); |
| 996 | set.insert(CopyConversion(GL_RGBA, GL_BGRA_EXT)); |
| 997 | |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 998 | set.insert(CopyConversion(GL_RED_INTEGER, GL_RED_INTEGER)); |
| 999 | set.insert(CopyConversion(GL_RED_INTEGER, GL_RG_INTEGER)); |
| 1000 | set.insert(CopyConversion(GL_RED_INTEGER, GL_RGB_INTEGER)); |
| 1001 | set.insert(CopyConversion(GL_RED_INTEGER, GL_RGBA_INTEGER)); |
| 1002 | set.insert(CopyConversion(GL_RG_INTEGER, GL_RG_INTEGER)); |
| 1003 | set.insert(CopyConversion(GL_RG_INTEGER, GL_RGB_INTEGER)); |
| 1004 | set.insert(CopyConversion(GL_RG_INTEGER, GL_RGBA_INTEGER)); |
| 1005 | set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGB_INTEGER)); |
| 1006 | set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGBA_INTEGER)); |
| 1007 | set.insert(CopyConversion(GL_RGBA_INTEGER, GL_RGBA_INTEGER)); |
| 1008 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1009 | return set; |
| 1010 | } |
| 1011 | |
| 1012 | bool IsValidInternalFormat(GLint internalFormat, const Context *context) |
| 1013 | { |
| 1014 | if (!context) |
| 1015 | { |
| 1016 | return false; |
| 1017 | } |
| 1018 | |
| 1019 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1020 | if (GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1021 | { |
| 1022 | ASSERT(internalFormatInfo.mSupportFunction != NULL); |
| 1023 | return internalFormatInfo.mSupportFunction(context); |
| 1024 | } |
| 1025 | else |
| 1026 | { |
| 1027 | return false; |
| 1028 | } |
| 1029 | } |
| 1030 | |
| 1031 | bool IsValidFormat(GLenum format, GLuint clientVersion) |
| 1032 | { |
| 1033 | if (clientVersion == 2) |
| 1034 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1035 | static const FormatSet formatSet = BuildES2ValidFormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1036 | return formatSet.find(format) != formatSet.end(); |
| 1037 | } |
| 1038 | else if (clientVersion == 3) |
| 1039 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1040 | static const FormatSet formatSet = BuildES3ValidFormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1041 | return formatSet.find(format) != formatSet.end(); |
| 1042 | } |
| 1043 | else |
| 1044 | { |
| 1045 | UNREACHABLE(); |
| 1046 | return false; |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | bool IsValidType(GLenum type, GLuint clientVersion) |
| 1051 | { |
| 1052 | if (clientVersion == 2) |
| 1053 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1054 | static const TypeSet typeSet = BuildES2ValidTypeSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1055 | return typeSet.find(type) != typeSet.end(); |
| 1056 | } |
| 1057 | else if (clientVersion == 3) |
| 1058 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1059 | static const TypeSet typeSet = BuildES3ValidTypeSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1060 | return typeSet.find(type) != typeSet.end(); |
| 1061 | } |
| 1062 | else |
| 1063 | { |
| 1064 | UNREACHABLE(); |
| 1065 | return false; |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | bool IsValidFormatCombination(GLint internalFormat, GLenum format, GLenum type, GLuint clientVersion) |
| 1070 | { |
| 1071 | if (clientVersion == 2) |
| 1072 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 1073 | static const FormatMap &formats = GetFormatMap(clientVersion); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1074 | FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); |
| 1075 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 1076 | return (iter != formats.end()) && ((internalFormat == (GLint)type) || (internalFormat == iter->second.mInternalFormat)); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1077 | } |
| 1078 | else if (clientVersion == 3) |
| 1079 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1080 | static const ES3FormatSet &formats = GetES3FormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1081 | return formats.find(FormatInfo(internalFormat, format, type)) != formats.end(); |
| 1082 | } |
| 1083 | else |
| 1084 | { |
| 1085 | UNREACHABLE(); |
| 1086 | return false; |
| 1087 | } |
| 1088 | } |
| 1089 | |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1090 | bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint clientVersion) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1091 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1092 | InternalFormatInfo textureInternalFormatInfo; |
| 1093 | InternalFormatInfo framebufferInternalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1094 | if (GetInternalFormatInfo(textureInternalFormat, clientVersion, &textureInternalFormatInfo) && |
| 1095 | GetInternalFormatInfo(frameBufferInternalFormat, clientVersion, &framebufferInternalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1096 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1097 | if (clientVersion == 2) |
| 1098 | { |
| 1099 | UNIMPLEMENTED(); |
| 1100 | return false; |
| 1101 | } |
| 1102 | else if (clientVersion == 3) |
| 1103 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1104 | static const CopyConversionSet conversionSet = BuildValidES3CopyTexImageCombinations(); |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1105 | const CopyConversion conversion = CopyConversion(textureInternalFormatInfo.mFormat, |
| 1106 | framebufferInternalFormatInfo.mFormat); |
| 1107 | if (conversionSet.find(conversion) != conversionSet.end()) |
| 1108 | { |
| 1109 | // Section 3.8.5 of the GLES3 3.0.2 spec states that source and destination formats |
shannonwoods@chromium.org | 96c6291 | 2013-05-30 00:17:00 +0000 | [diff] [blame] | 1110 | // must both be signed or unsigned or fixed/floating point and both source and destinations |
| 1111 | // must be either both SRGB or both not SRGB |
| 1112 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1113 | if ((textureInternalFormatInfo.mColorEncoding == GL_SRGB) != (framebufferInternalFormatInfo.mColorEncoding == GL_SRGB)) |
shannonwoods@chromium.org | 96c6291 | 2013-05-30 00:17:00 +0000 | [diff] [blame] | 1114 | { |
| 1115 | return false; |
| 1116 | } |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1117 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1118 | if ((textureInternalFormatInfo.mComponentType == GL_INT && framebufferInternalFormatInfo.mComponentType == GL_INT ) || |
| 1119 | (textureInternalFormatInfo.mComponentType == GL_UNSIGNED_INT && framebufferInternalFormatInfo.mComponentType == GL_UNSIGNED_INT)) |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1120 | { |
| 1121 | return true; |
| 1122 | } |
| 1123 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1124 | if ((textureInternalFormatInfo.mComponentType == GL_UNSIGNED_NORMALIZED || |
| 1125 | textureInternalFormatInfo.mComponentType == GL_SIGNED_NORMALIZED || |
| 1126 | textureInternalFormatInfo.mComponentType == GL_FLOAT ) && |
| 1127 | (framebufferInternalFormatInfo.mComponentType == GL_UNSIGNED_NORMALIZED || |
| 1128 | framebufferInternalFormatInfo.mComponentType == GL_SIGNED_NORMALIZED || |
| 1129 | framebufferInternalFormatInfo.mComponentType == GL_FLOAT )) |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1130 | { |
| 1131 | return true; |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | return false; |
| 1136 | } |
| 1137 | else |
| 1138 | { |
| 1139 | UNREACHABLE(); |
| 1140 | return false; |
| 1141 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1142 | } |
| 1143 | else |
| 1144 | { |
| 1145 | UNREACHABLE(); |
| 1146 | return false; |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | bool IsSizedInternalFormat(GLint internalFormat, GLuint clientVersion) |
| 1151 | { |
| 1152 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1153 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1154 | { |
| 1155 | return internalFormatInfo.mPixelBits > 0; |
| 1156 | } |
| 1157 | else |
| 1158 | { |
| 1159 | UNREACHABLE(); |
| 1160 | return false; |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | GLint GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion) |
| 1165 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 1166 | const FormatMap &formats = GetFormatMap(clientVersion); |
| 1167 | FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); |
| 1168 | return (iter != formats.end()) ? iter->second.mInternalFormat : GL_NONE; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1169 | } |
| 1170 | |
| 1171 | GLuint GetPixelBytes(GLint internalFormat, GLuint clientVersion) |
| 1172 | { |
| 1173 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1174 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1175 | { |
| 1176 | return internalFormatInfo.mPixelBits / 8; |
| 1177 | } |
| 1178 | else |
| 1179 | { |
| 1180 | UNREACHABLE(); |
| 1181 | return 0; |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | GLuint GetAlphaBits(GLint internalFormat, GLuint clientVersion) |
| 1186 | { |
| 1187 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1188 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1189 | { |
| 1190 | return internalFormatInfo.mAlphaBits; |
| 1191 | } |
| 1192 | else |
| 1193 | { |
| 1194 | UNREACHABLE(); |
| 1195 | return 0; |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | GLuint GetRedBits(GLint internalFormat, GLuint clientVersion) |
| 1200 | { |
| 1201 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1202 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1203 | { |
| 1204 | return internalFormatInfo.mRedBits; |
| 1205 | } |
| 1206 | else |
| 1207 | { |
| 1208 | UNREACHABLE(); |
| 1209 | return 0; |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | GLuint GetGreenBits(GLint internalFormat, GLuint clientVersion) |
| 1214 | { |
| 1215 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1216 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1217 | { |
| 1218 | return internalFormatInfo.mGreenBits; |
| 1219 | } |
| 1220 | else |
| 1221 | { |
| 1222 | UNREACHABLE(); |
| 1223 | return 0; |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | GLuint GetBlueBits(GLint internalFormat, GLuint clientVersion) |
| 1228 | { |
| 1229 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1230 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1231 | { |
Geoff Lang | 2415922 | 2013-06-05 14:56:32 -0400 | [diff] [blame] | 1232 | return internalFormatInfo.mBlueBits; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1233 | } |
| 1234 | else |
| 1235 | { |
| 1236 | UNREACHABLE(); |
| 1237 | return 0; |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | GLuint GetLuminanceBits(GLint internalFormat, GLuint clientVersion) |
| 1242 | { |
| 1243 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1244 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1245 | { |
| 1246 | return internalFormatInfo.mLuminanceBits; |
| 1247 | } |
| 1248 | else |
| 1249 | { |
| 1250 | UNREACHABLE(); |
| 1251 | return 0; |
| 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | GLuint GetDepthBits(GLint internalFormat, GLuint clientVersion) |
| 1256 | { |
| 1257 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1258 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1259 | { |
| 1260 | return internalFormatInfo.mDepthBits; |
| 1261 | } |
| 1262 | else |
| 1263 | { |
| 1264 | UNREACHABLE(); |
| 1265 | return 0; |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | GLuint GetStencilBits(GLint internalFormat, GLuint clientVersion) |
| 1270 | { |
| 1271 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1272 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1273 | { |
| 1274 | return internalFormatInfo.mStencilBits; |
| 1275 | } |
| 1276 | else |
| 1277 | { |
| 1278 | UNREACHABLE(); |
| 1279 | return 0; |
| 1280 | } |
| 1281 | } |
| 1282 | |
Geoff Lang | f23eb28 | 2013-07-22 10:52:19 -0400 | [diff] [blame] | 1283 | GLuint GetTypeBytes(GLenum type) |
| 1284 | { |
| 1285 | TypeInfo typeInfo; |
| 1286 | if (GetTypeInfo(type, &typeInfo)) |
| 1287 | { |
| 1288 | return typeInfo.mTypeBytes; |
| 1289 | } |
| 1290 | else |
| 1291 | { |
| 1292 | UNREACHABLE(); |
| 1293 | return 0; |
| 1294 | } |
| 1295 | } |
| 1296 | |
| 1297 | bool IsSpecialInterpretationType(GLenum type) |
| 1298 | { |
| 1299 | TypeInfo typeInfo; |
| 1300 | if (GetTypeInfo(type, &typeInfo)) |
| 1301 | { |
| 1302 | return typeInfo.mSpecialInterpretation; |
| 1303 | } |
| 1304 | else |
| 1305 | { |
| 1306 | UNREACHABLE(); |
| 1307 | return false; |
| 1308 | } |
| 1309 | } |
| 1310 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1311 | GLenum GetFormat(GLint internalFormat, GLuint clientVersion) |
| 1312 | { |
| 1313 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1314 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1315 | { |
| 1316 | return internalFormatInfo.mFormat; |
| 1317 | } |
| 1318 | else |
| 1319 | { |
| 1320 | UNREACHABLE(); |
| 1321 | return GL_NONE; |
| 1322 | } |
| 1323 | } |
| 1324 | |
| 1325 | GLenum GetType(GLint internalFormat, GLuint clientVersion) |
| 1326 | { |
| 1327 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1328 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1329 | { |
| 1330 | return internalFormatInfo.mType; |
| 1331 | } |
| 1332 | else |
| 1333 | { |
| 1334 | UNREACHABLE(); |
| 1335 | return GL_NONE; |
| 1336 | } |
| 1337 | } |
| 1338 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1339 | GLuint GetComponentType(GLint internalFormat, GLuint clientVersion) |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1340 | { |
| 1341 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1342 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1343 | { |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1344 | return internalFormatInfo.mComponentType; |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1345 | } |
| 1346 | else |
| 1347 | { |
| 1348 | UNREACHABLE(); |
| 1349 | return false; |
| 1350 | } |
| 1351 | } |
| 1352 | |
Jamie Madill | 3466a4d | 2013-09-18 14:36:20 -0400 | [diff] [blame] | 1353 | GLuint GetComponentCount(GLint internalFormat, GLuint clientVersion) |
| 1354 | { |
| 1355 | InternalFormatInfo internalFormatInfo; |
| 1356 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
| 1357 | { |
| 1358 | return internalFormatInfo.mComponentCount; |
| 1359 | } |
| 1360 | else |
| 1361 | { |
| 1362 | UNREACHABLE(); |
| 1363 | return false; |
| 1364 | } |
| 1365 | } |
| 1366 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1367 | GLenum GetColorEncoding(GLint internalFormat, GLuint clientVersion) |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1368 | { |
| 1369 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1370 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1371 | { |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1372 | return internalFormatInfo.mColorEncoding; |
shannonwoods@chromium.org | e81ea50 | 2013-05-30 00:16:53 +0000 | [diff] [blame] | 1373 | } |
| 1374 | else |
| 1375 | { |
| 1376 | UNREACHABLE(); |
| 1377 | return false; |
| 1378 | } |
| 1379 | } |
| 1380 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1381 | bool IsColorRenderingSupported(GLint internalFormat, const rx::Renderer *renderer) |
| 1382 | { |
| 1383 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1384 | if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1385 | { |
| 1386 | return internalFormatInfo.mIsColorRenderable(NULL, renderer); |
| 1387 | } |
| 1388 | else |
| 1389 | { |
| 1390 | UNREACHABLE(); |
| 1391 | return false; |
| 1392 | } |
| 1393 | } |
| 1394 | |
| 1395 | bool IsColorRenderingSupported(GLint internalFormat, const Context *context) |
| 1396 | { |
| 1397 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1398 | if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1399 | { |
| 1400 | return internalFormatInfo.mIsColorRenderable(context, NULL); |
| 1401 | } |
| 1402 | else |
| 1403 | { |
| 1404 | UNREACHABLE(); |
| 1405 | return false; |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | bool IsTextureFilteringSupported(GLint internalFormat, const rx::Renderer *renderer) |
| 1410 | { |
| 1411 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1412 | if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1413 | { |
| 1414 | return internalFormatInfo.mIsTextureFilterable(NULL, renderer); |
| 1415 | } |
| 1416 | else |
| 1417 | { |
| 1418 | UNREACHABLE(); |
| 1419 | return false; |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | bool IsTextureFilteringSupported(GLint internalFormat, const Context *context) |
| 1424 | { |
| 1425 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1426 | if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1427 | { |
| 1428 | return internalFormatInfo.mIsTextureFilterable(context, NULL); |
| 1429 | } |
| 1430 | else |
| 1431 | { |
| 1432 | UNREACHABLE(); |
| 1433 | return false; |
| 1434 | } |
| 1435 | } |
| 1436 | |
| 1437 | bool IsDepthRenderingSupported(GLint internalFormat, const rx::Renderer *renderer) |
| 1438 | { |
| 1439 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1440 | if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1441 | { |
| 1442 | return internalFormatInfo.mIsDepthRenderable(NULL, renderer); |
| 1443 | } |
| 1444 | else |
| 1445 | { |
| 1446 | UNREACHABLE(); |
| 1447 | return false; |
| 1448 | } |
| 1449 | } |
| 1450 | |
| 1451 | bool IsDepthRenderingSupported(GLint internalFormat, const Context *context) |
| 1452 | { |
| 1453 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1454 | if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1455 | { |
| 1456 | return internalFormatInfo.mIsDepthRenderable(context, NULL); |
| 1457 | } |
| 1458 | else |
| 1459 | { |
| 1460 | UNREACHABLE(); |
| 1461 | return false; |
| 1462 | } |
| 1463 | } |
| 1464 | |
| 1465 | bool IsStencilRenderingSupported(GLint internalFormat, const rx::Renderer *renderer) |
| 1466 | { |
| 1467 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1468 | if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1469 | { |
| 1470 | return internalFormatInfo.mIsStencilRenderable(NULL, renderer); |
| 1471 | } |
| 1472 | else |
| 1473 | { |
| 1474 | UNREACHABLE(); |
| 1475 | return false; |
| 1476 | } |
| 1477 | } |
| 1478 | |
| 1479 | bool IsStencilRenderingSupported(GLint internalFormat, const Context *context) |
| 1480 | { |
| 1481 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1482 | if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1483 | { |
| 1484 | return internalFormatInfo.mIsStencilRenderable(context, NULL); |
| 1485 | } |
| 1486 | else |
| 1487 | { |
| 1488 | UNREACHABLE(); |
| 1489 | return false; |
| 1490 | } |
| 1491 | } |
| 1492 | |
| 1493 | GLuint GetRowPitch(GLint internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment) |
| 1494 | { |
| 1495 | ASSERT(alignment > 0 && isPow2(alignment)); |
| 1496 | return (GetBlockSize(internalFormat, type, clientVersion, width, 1) + alignment - 1) & ~(alignment - 1); |
| 1497 | } |
| 1498 | |
| 1499 | GLuint GetDepthPitch(GLint internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment) |
| 1500 | { |
Jamie Madill | 666e286 | 2013-09-10 12:04:29 -0400 | [diff] [blame] | 1501 | return GetRowPitch(internalFormat, type, clientVersion, width, alignment) * height; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1502 | } |
| 1503 | |
| 1504 | GLuint GetBlockSize(GLint internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height) |
| 1505 | { |
| 1506 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1507 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1508 | { |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1509 | if (internalFormatInfo.mIsCompressed) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1510 | { |
| 1511 | GLsizei numBlocksWide = (width + internalFormatInfo.mCompressedBlockWidth - 1) / internalFormatInfo.mCompressedBlockWidth; |
| 1512 | GLsizei numBlocksHight = (height + internalFormatInfo.mCompressedBlockHeight - 1) / internalFormatInfo.mCompressedBlockHeight; |
| 1513 | |
| 1514 | return (internalFormatInfo.mPixelBits * numBlocksWide * numBlocksHight) / 8; |
| 1515 | } |
| 1516 | else |
| 1517 | { |
| 1518 | TypeInfo typeInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1519 | if (GetTypeInfo(type, &typeInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1520 | { |
| 1521 | if (typeInfo.mSpecialInterpretation) |
| 1522 | { |
| 1523 | return typeInfo.mTypeBytes * width * height; |
| 1524 | } |
| 1525 | else |
| 1526 | { |
| 1527 | return internalFormatInfo.mComponentCount * typeInfo.mTypeBytes * width * height; |
| 1528 | } |
| 1529 | } |
| 1530 | else |
| 1531 | { |
| 1532 | UNREACHABLE(); |
| 1533 | return 0; |
| 1534 | } |
| 1535 | } |
| 1536 | } |
| 1537 | else |
| 1538 | { |
| 1539 | UNREACHABLE(); |
| 1540 | return 0; |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | bool IsFormatCompressed(GLint internalFormat, GLuint clientVersion) |
| 1545 | { |
| 1546 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1547 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1548 | { |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1549 | return internalFormatInfo.mIsCompressed; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1550 | } |
| 1551 | else |
| 1552 | { |
| 1553 | UNREACHABLE(); |
| 1554 | return false; |
| 1555 | } |
| 1556 | } |
| 1557 | |
| 1558 | GLuint GetCompressedBlockWidth(GLint internalFormat, GLuint clientVersion) |
| 1559 | { |
| 1560 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1561 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1562 | { |
| 1563 | return internalFormatInfo.mCompressedBlockWidth; |
| 1564 | } |
| 1565 | else |
| 1566 | { |
| 1567 | UNREACHABLE(); |
| 1568 | return 0; |
| 1569 | } |
| 1570 | } |
| 1571 | |
| 1572 | GLuint GetCompressedBlockHeight(GLint internalFormat, GLuint clientVersion) |
| 1573 | { |
| 1574 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1575 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1576 | { |
| 1577 | return internalFormatInfo.mCompressedBlockHeight; |
| 1578 | } |
| 1579 | else |
| 1580 | { |
| 1581 | UNREACHABLE(); |
| 1582 | return 0; |
| 1583 | } |
| 1584 | } |
| 1585 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 1586 | ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion) |
| 1587 | { |
| 1588 | static const FormatMap &formats = GetFormatMap(clientVersion); |
| 1589 | FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); |
| 1590 | return (iter != formats.end()) ? iter->second.mColorWriteFunction : NULL; |
| 1591 | } |
| 1592 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1593 | } |