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 | |
| 38 | // A helper function to insert data into the D3D11LoadFunctionMap 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))); |
| 743 | map.insert(InternalFormatInfoPair(GL_RGB, InternalFormatInfo::UnsizedFormat(GL_RGB, AlwaysSupported))); |
| 744 | map.insert(InternalFormatInfoPair(GL_RGBA, InternalFormatInfo::UnsizedFormat(GL_RGBA, AlwaysSupported))); |
| 745 | map.insert(InternalFormatInfoPair(GL_BGRA_EXT, InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT, AlwaysSupported))); |
| 746 | |
| 747 | // Compressed formats, From ES 3.0.1 spec, table 3.16 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 748 | // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | |
| 749 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_R11_EAC, InternalFormatInfo::CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 750 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_R11_EAC, InternalFormatInfo::CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 751 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RG11_EAC, InternalFormatInfo::CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 752 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_RG11_EAC, InternalFormatInfo::CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 753 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_ETC2, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 754 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ETC2, InternalFormatInfo::CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, true, UnimplementedSupport))); |
| 755 | 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))); |
| 756 | 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))); |
| 757 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA8_ETC2_EAC, InternalFormatInfo::CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport))); |
| 758 | 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] | 759 | |
| 760 | // From GL_EXT_texture_compression_dxt1 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 761 | // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | |
| 762 | 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))); |
| 763 | 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] | 764 | |
| 765 | // From GL_ANGLE_texture_compression_dxt3 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 766 | 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] | 767 | |
| 768 | // From GL_ANGLE_texture_compression_dxt5 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 769 | 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] | 770 | |
| 771 | return map; |
| 772 | } |
| 773 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 774 | static InternalFormatInfoMap BuildES2InternalFormatInfoMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 775 | { |
| 776 | InternalFormatInfoMap map; |
| 777 | |
| 778 | // From ES 2.0.25 table 4.5 |
| 779 | map.insert(InternalFormatInfoPair(GL_NONE, InternalFormatInfo())); |
| 780 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 781 | // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Color | Texture | Supported | |
| 782 | // | | | | | | | | | | | | renderable | filterable | | |
| 783 | 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))); |
| 784 | 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))); |
| 785 | 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] | 786 | |
| 787 | // Extension formats |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 788 | 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))); |
| 789 | 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))); |
| 790 | 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))); |
| 791 | 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))); |
| 792 | 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] | 793 | |
| 794 | // Floating point formats have to query the renderer for support |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 795 | // | Internal format | | R | G | B | A |S | Format | Type | Comp | SRGB | Color renderable | Texture filterable | Supported | |
| 796 | // | | | | | | | | | | type | | | | | |
| 797 | 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>))); |
| 798 | 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>))); |
| 799 | 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>))); |
| 800 | 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] | 801 | |
| 802 | // Depth and stencil formats |
Shannon Woods | 9e73b21 | 2013-07-08 10:32:19 -0400 | [diff] [blame] | 803 | // | Internal format | | D |S | Format | Type | Internal format | Depth | Stencil | Supported | |
| 804 | // | | | | | | | type | renderable | renderable | | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 805 | 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>))); |
| 806 | 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>))); |
| 807 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, InternalFormatInfo::DepthStencilFormat(16, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, AlwaysSupported, NeverSupported, AlwaysSupported))); |
| 808 | 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] | 809 | |
| 810 | // Unsized formats |
| 811 | // | Internal format | | Format | Supported | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 812 | map.insert(InternalFormatInfoPair(GL_ALPHA, InternalFormatInfo::UnsizedFormat(GL_ALPHA, AlwaysSupported))); |
| 813 | map.insert(InternalFormatInfoPair(GL_LUMINANCE, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE, AlwaysSupported))); |
| 814 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, InternalFormatInfo::UnsizedFormat(GL_LUMINANCE_ALPHA, AlwaysSupported))); |
| 815 | map.insert(InternalFormatInfoPair(GL_RGB, InternalFormatInfo::UnsizedFormat(GL_RGB, AlwaysSupported))); |
| 816 | map.insert(InternalFormatInfoPair(GL_RGBA, InternalFormatInfo::UnsizedFormat(GL_RGBA, AlwaysSupported))); |
| 817 | map.insert(InternalFormatInfoPair(GL_BGRA_EXT, InternalFormatInfo::UnsizedFormat(GL_BGRA_EXT, AlwaysSupported))); |
| 818 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, InternalFormatInfo::UnsizedFormat(GL_DEPTH_COMPONENT, AlwaysSupported))); |
| 819 | map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL_OES, InternalFormatInfo::UnsizedFormat(GL_DEPTH_STENCIL_OES, AlwaysSupported))); |
| 820 | |
| 821 | // Luminance alpha formats from GL_EXT_texture_storage |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 822 | // | Internal format | | L | A | Format | Type | Component type | Supported | |
| 823 | map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 824 | map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, InternalFormatInfo::LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 825 | map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 826 | map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, InternalFormatInfo::LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 827 | map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, InternalFormatInfo::LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, AlwaysSupported))); |
| 828 | map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, InternalFormatInfo::LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, AlwaysSupported))); |
| 829 | map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, InternalFormatInfo::LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported))); |
| 830 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, InternalFormatInfo::LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, AlwaysSupported))); |
| 831 | 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] | 832 | |
| 833 | // From GL_EXT_texture_compression_dxt1 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 834 | // | Internal format | |W |H | BS |CC|Format | Type | SRGB | Supported | |
| 835 | 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>))); |
| 836 | 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] | 837 | |
| 838 | // From GL_ANGLE_texture_compression_dxt3 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 839 | 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] | 840 | |
| 841 | // From GL_ANGLE_texture_compression_dxt5 |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 842 | 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] | 843 | |
| 844 | return map; |
| 845 | } |
| 846 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 847 | static bool GetInternalFormatInfo(GLint internalFormat, GLuint clientVersion, InternalFormatInfo *outFormatInfo) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 848 | { |
| 849 | const InternalFormatInfoMap* map = NULL; |
| 850 | |
| 851 | if (clientVersion == 2) |
| 852 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 853 | static const InternalFormatInfoMap formatMap = BuildES2InternalFormatInfoMap(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 854 | map = &formatMap; |
| 855 | } |
| 856 | else if (clientVersion == 3) |
| 857 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 858 | static const InternalFormatInfoMap formatMap = BuildES3InternalFormatInfoMap(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 859 | map = &formatMap; |
| 860 | } |
| 861 | else |
| 862 | { |
| 863 | UNREACHABLE(); |
| 864 | } |
| 865 | |
| 866 | InternalFormatInfoMap::const_iterator iter = map->find(internalFormat); |
| 867 | if (iter != map->end()) |
| 868 | { |
| 869 | if (outFormatInfo) |
| 870 | { |
| 871 | *outFormatInfo = iter->second; |
| 872 | } |
| 873 | return true; |
| 874 | } |
| 875 | else |
| 876 | { |
| 877 | return false; |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | typedef std::set<GLenum> FormatSet; |
| 882 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 883 | static FormatSet BuildES2ValidFormatSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 884 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 885 | static const FormatMap &formatMap = GetFormatMap(2); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 886 | |
| 887 | FormatSet set; |
| 888 | |
| 889 | for (FormatMap::const_iterator i = formatMap.begin(); i != formatMap.end(); i++) |
| 890 | { |
| 891 | const FormatTypePair& formatPair = i->first; |
| 892 | set.insert(formatPair.first); |
| 893 | } |
| 894 | |
| 895 | return set; |
| 896 | } |
| 897 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 898 | static FormatSet BuildES3ValidFormatSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 899 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 900 | static const ES3FormatSet &formatSet = GetES3FormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 901 | |
| 902 | FormatSet set; |
| 903 | |
| 904 | for (ES3FormatSet::const_iterator i = formatSet.begin(); i != formatSet.end(); i++) |
| 905 | { |
| 906 | const FormatInfo& formatInfo = *i; |
| 907 | set.insert(formatInfo.mFormat); |
| 908 | } |
| 909 | |
| 910 | return set; |
| 911 | } |
| 912 | |
| 913 | typedef std::set<GLenum> TypeSet; |
| 914 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 915 | static TypeSet BuildES2ValidTypeSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 916 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 917 | static const FormatMap &formatMap = GetFormatMap(2); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 918 | |
| 919 | TypeSet set; |
| 920 | |
| 921 | for (FormatMap::const_iterator i = formatMap.begin(); i != formatMap.end(); i++) |
| 922 | { |
| 923 | const FormatTypePair& formatPair = i->first; |
| 924 | set.insert(formatPair.second); |
| 925 | } |
| 926 | |
| 927 | return set; |
| 928 | } |
| 929 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 930 | static TypeSet BuildES3ValidTypeSet() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 931 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 932 | static const ES3FormatSet &formatSet = GetES3FormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 933 | |
| 934 | TypeSet set; |
| 935 | |
| 936 | for (ES3FormatSet::const_iterator i = formatSet.begin(); i != formatSet.end(); i++) |
| 937 | { |
| 938 | const FormatInfo& formatInfo = *i; |
| 939 | set.insert(formatInfo.mType); |
| 940 | } |
| 941 | |
| 942 | return set; |
| 943 | } |
| 944 | |
| 945 | struct CopyConversion |
| 946 | { |
| 947 | GLenum mTextureFormat; |
| 948 | GLenum mFramebufferFormat; |
| 949 | |
| 950 | CopyConversion(GLenum textureFormat, GLenum framebufferFormat) |
| 951 | : mTextureFormat(textureFormat), mFramebufferFormat(framebufferFormat) { } |
| 952 | |
| 953 | bool operator<(const CopyConversion& other) const |
| 954 | { |
| 955 | return memcmp(this, &other, sizeof(CopyConversion)) < 0; |
| 956 | } |
| 957 | }; |
| 958 | |
| 959 | typedef std::set<CopyConversion> CopyConversionSet; |
| 960 | |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 961 | static CopyConversionSet BuildValidES3CopyTexImageCombinations() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 962 | { |
| 963 | CopyConversionSet set; |
| 964 | |
| 965 | // From ES 3.0.1 spec, table 3.15 |
| 966 | set.insert(CopyConversion(GL_ALPHA, GL_RGBA)); |
| 967 | set.insert(CopyConversion(GL_LUMINANCE, GL_RED)); |
| 968 | set.insert(CopyConversion(GL_LUMINANCE, GL_RG)); |
| 969 | set.insert(CopyConversion(GL_LUMINANCE, GL_RGB)); |
| 970 | set.insert(CopyConversion(GL_LUMINANCE, GL_RGBA)); |
| 971 | set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_RGBA)); |
| 972 | set.insert(CopyConversion(GL_RED, GL_RED)); |
| 973 | set.insert(CopyConversion(GL_RED, GL_RG)); |
| 974 | set.insert(CopyConversion(GL_RED, GL_RGB)); |
| 975 | set.insert(CopyConversion(GL_RED, GL_RGBA)); |
| 976 | set.insert(CopyConversion(GL_RG, GL_RG)); |
| 977 | set.insert(CopyConversion(GL_RG, GL_RGB)); |
| 978 | set.insert(CopyConversion(GL_RG, GL_RGBA)); |
| 979 | set.insert(CopyConversion(GL_RGB, GL_RGB)); |
| 980 | set.insert(CopyConversion(GL_RGB, GL_RGBA)); |
| 981 | set.insert(CopyConversion(GL_RGBA, GL_RGBA)); |
| 982 | |
Jamie Madill | b70e5f7 | 2013-07-10 16:57:52 -0400 | [diff] [blame] | 983 | // Necessary for ANGLE back-buffers |
| 984 | set.insert(CopyConversion(GL_ALPHA, GL_BGRA_EXT)); |
| 985 | set.insert(CopyConversion(GL_LUMINANCE, GL_BGRA_EXT)); |
| 986 | set.insert(CopyConversion(GL_LUMINANCE_ALPHA, GL_BGRA_EXT)); |
| 987 | set.insert(CopyConversion(GL_RED, GL_BGRA_EXT)); |
| 988 | set.insert(CopyConversion(GL_RG, GL_BGRA_EXT)); |
| 989 | set.insert(CopyConversion(GL_RGB, GL_BGRA_EXT)); |
| 990 | set.insert(CopyConversion(GL_RGBA, GL_BGRA_EXT)); |
| 991 | |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 992 | set.insert(CopyConversion(GL_RED_INTEGER, GL_RED_INTEGER)); |
| 993 | set.insert(CopyConversion(GL_RED_INTEGER, GL_RG_INTEGER)); |
| 994 | set.insert(CopyConversion(GL_RED_INTEGER, GL_RGB_INTEGER)); |
| 995 | set.insert(CopyConversion(GL_RED_INTEGER, GL_RGBA_INTEGER)); |
| 996 | set.insert(CopyConversion(GL_RG_INTEGER, GL_RG_INTEGER)); |
| 997 | set.insert(CopyConversion(GL_RG_INTEGER, GL_RGB_INTEGER)); |
| 998 | set.insert(CopyConversion(GL_RG_INTEGER, GL_RGBA_INTEGER)); |
| 999 | set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGB_INTEGER)); |
| 1000 | set.insert(CopyConversion(GL_RGB_INTEGER, GL_RGBA_INTEGER)); |
| 1001 | set.insert(CopyConversion(GL_RGBA_INTEGER, GL_RGBA_INTEGER)); |
| 1002 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1003 | return set; |
| 1004 | } |
| 1005 | |
| 1006 | bool IsValidInternalFormat(GLint internalFormat, const Context *context) |
| 1007 | { |
| 1008 | if (!context) |
| 1009 | { |
| 1010 | return false; |
| 1011 | } |
| 1012 | |
| 1013 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1014 | if (GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1015 | { |
| 1016 | ASSERT(internalFormatInfo.mSupportFunction != NULL); |
| 1017 | return internalFormatInfo.mSupportFunction(context); |
| 1018 | } |
| 1019 | else |
| 1020 | { |
| 1021 | return false; |
| 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | bool IsValidFormat(GLenum format, GLuint clientVersion) |
| 1026 | { |
| 1027 | if (clientVersion == 2) |
| 1028 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1029 | static const FormatSet formatSet = BuildES2ValidFormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1030 | return formatSet.find(format) != formatSet.end(); |
| 1031 | } |
| 1032 | else if (clientVersion == 3) |
| 1033 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1034 | static const FormatSet formatSet = BuildES3ValidFormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1035 | return formatSet.find(format) != formatSet.end(); |
| 1036 | } |
| 1037 | else |
| 1038 | { |
| 1039 | UNREACHABLE(); |
| 1040 | return false; |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | bool IsValidType(GLenum type, GLuint clientVersion) |
| 1045 | { |
| 1046 | if (clientVersion == 2) |
| 1047 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1048 | static const TypeSet typeSet = BuildES2ValidTypeSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1049 | return typeSet.find(type) != typeSet.end(); |
| 1050 | } |
| 1051 | else if (clientVersion == 3) |
| 1052 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1053 | static const TypeSet typeSet = BuildES3ValidTypeSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1054 | return typeSet.find(type) != typeSet.end(); |
| 1055 | } |
| 1056 | else |
| 1057 | { |
| 1058 | UNREACHABLE(); |
| 1059 | return false; |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | bool IsValidFormatCombination(GLint internalFormat, GLenum format, GLenum type, GLuint clientVersion) |
| 1064 | { |
| 1065 | if (clientVersion == 2) |
| 1066 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 1067 | static const FormatMap &formats = GetFormatMap(clientVersion); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1068 | FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); |
| 1069 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 1070 | return (iter != formats.end()) && ((internalFormat == (GLint)type) || (internalFormat == iter->second.mInternalFormat)); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1071 | } |
| 1072 | else if (clientVersion == 3) |
| 1073 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1074 | static const ES3FormatSet &formats = GetES3FormatSet(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1075 | return formats.find(FormatInfo(internalFormat, format, type)) != formats.end(); |
| 1076 | } |
| 1077 | else |
| 1078 | { |
| 1079 | UNREACHABLE(); |
| 1080 | return false; |
| 1081 | } |
| 1082 | } |
| 1083 | |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1084 | bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint clientVersion) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1085 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1086 | InternalFormatInfo textureInternalFormatInfo; |
| 1087 | InternalFormatInfo framebufferInternalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1088 | if (GetInternalFormatInfo(textureInternalFormat, clientVersion, &textureInternalFormatInfo) && |
| 1089 | GetInternalFormatInfo(frameBufferInternalFormat, clientVersion, &framebufferInternalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1090 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1091 | if (clientVersion == 2) |
| 1092 | { |
| 1093 | UNIMPLEMENTED(); |
| 1094 | return false; |
| 1095 | } |
| 1096 | else if (clientVersion == 3) |
| 1097 | { |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1098 | static const CopyConversionSet conversionSet = BuildValidES3CopyTexImageCombinations(); |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1099 | const CopyConversion conversion = CopyConversion(textureInternalFormatInfo.mFormat, |
| 1100 | framebufferInternalFormatInfo.mFormat); |
| 1101 | if (conversionSet.find(conversion) != conversionSet.end()) |
| 1102 | { |
| 1103 | // 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] | 1104 | // must both be signed or unsigned or fixed/floating point and both source and destinations |
| 1105 | // must be either both SRGB or both not SRGB |
| 1106 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1107 | if ((textureInternalFormatInfo.mColorEncoding == GL_SRGB) != (framebufferInternalFormatInfo.mColorEncoding == GL_SRGB)) |
shannonwoods@chromium.org | 96c6291 | 2013-05-30 00:17:00 +0000 | [diff] [blame] | 1108 | { |
| 1109 | return false; |
| 1110 | } |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1111 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1112 | if ((textureInternalFormatInfo.mComponentType == GL_INT && framebufferInternalFormatInfo.mComponentType == GL_INT ) || |
| 1113 | (textureInternalFormatInfo.mComponentType == GL_UNSIGNED_INT && framebufferInternalFormatInfo.mComponentType == GL_UNSIGNED_INT)) |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1114 | { |
| 1115 | return true; |
| 1116 | } |
| 1117 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1118 | if ((textureInternalFormatInfo.mComponentType == GL_UNSIGNED_NORMALIZED || |
| 1119 | textureInternalFormatInfo.mComponentType == GL_SIGNED_NORMALIZED || |
| 1120 | textureInternalFormatInfo.mComponentType == GL_FLOAT ) && |
| 1121 | (framebufferInternalFormatInfo.mComponentType == GL_UNSIGNED_NORMALIZED || |
| 1122 | framebufferInternalFormatInfo.mComponentType == GL_SIGNED_NORMALIZED || |
| 1123 | framebufferInternalFormatInfo.mComponentType == GL_FLOAT )) |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1124 | { |
| 1125 | return true; |
| 1126 | } |
| 1127 | } |
| 1128 | |
| 1129 | return false; |
| 1130 | } |
| 1131 | else |
| 1132 | { |
| 1133 | UNREACHABLE(); |
| 1134 | return false; |
| 1135 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1136 | } |
| 1137 | else |
| 1138 | { |
| 1139 | UNREACHABLE(); |
| 1140 | return false; |
| 1141 | } |
| 1142 | } |
| 1143 | |
| 1144 | bool IsSizedInternalFormat(GLint internalFormat, GLuint clientVersion) |
| 1145 | { |
| 1146 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1147 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1148 | { |
| 1149 | return internalFormatInfo.mPixelBits > 0; |
| 1150 | } |
| 1151 | else |
| 1152 | { |
| 1153 | UNREACHABLE(); |
| 1154 | return false; |
| 1155 | } |
| 1156 | } |
| 1157 | |
| 1158 | GLint GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion) |
| 1159 | { |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 1160 | const FormatMap &formats = GetFormatMap(clientVersion); |
| 1161 | FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); |
| 1162 | return (iter != formats.end()) ? iter->second.mInternalFormat : GL_NONE; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
| 1165 | GLuint GetPixelBytes(GLint internalFormat, GLuint clientVersion) |
| 1166 | { |
| 1167 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1168 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1169 | { |
| 1170 | return internalFormatInfo.mPixelBits / 8; |
| 1171 | } |
| 1172 | else |
| 1173 | { |
| 1174 | UNREACHABLE(); |
| 1175 | return 0; |
| 1176 | } |
| 1177 | } |
| 1178 | |
| 1179 | GLuint GetAlphaBits(GLint internalFormat, GLuint clientVersion) |
| 1180 | { |
| 1181 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1182 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1183 | { |
| 1184 | return internalFormatInfo.mAlphaBits; |
| 1185 | } |
| 1186 | else |
| 1187 | { |
| 1188 | UNREACHABLE(); |
| 1189 | return 0; |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | GLuint GetRedBits(GLint internalFormat, GLuint clientVersion) |
| 1194 | { |
| 1195 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1196 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1197 | { |
| 1198 | return internalFormatInfo.mRedBits; |
| 1199 | } |
| 1200 | else |
| 1201 | { |
| 1202 | UNREACHABLE(); |
| 1203 | return 0; |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | GLuint GetGreenBits(GLint internalFormat, GLuint clientVersion) |
| 1208 | { |
| 1209 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1210 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1211 | { |
| 1212 | return internalFormatInfo.mGreenBits; |
| 1213 | } |
| 1214 | else |
| 1215 | { |
| 1216 | UNREACHABLE(); |
| 1217 | return 0; |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | GLuint GetBlueBits(GLint internalFormat, GLuint clientVersion) |
| 1222 | { |
| 1223 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1224 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1225 | { |
Geoff Lang | 2415922 | 2013-06-05 14:56:32 -0400 | [diff] [blame] | 1226 | return internalFormatInfo.mBlueBits; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1227 | } |
| 1228 | else |
| 1229 | { |
| 1230 | UNREACHABLE(); |
| 1231 | return 0; |
| 1232 | } |
| 1233 | } |
| 1234 | |
| 1235 | GLuint GetLuminanceBits(GLint internalFormat, GLuint clientVersion) |
| 1236 | { |
| 1237 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1238 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1239 | { |
| 1240 | return internalFormatInfo.mLuminanceBits; |
| 1241 | } |
| 1242 | else |
| 1243 | { |
| 1244 | UNREACHABLE(); |
| 1245 | return 0; |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | GLuint GetDepthBits(GLint internalFormat, GLuint clientVersion) |
| 1250 | { |
| 1251 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1252 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1253 | { |
| 1254 | return internalFormatInfo.mDepthBits; |
| 1255 | } |
| 1256 | else |
| 1257 | { |
| 1258 | UNREACHABLE(); |
| 1259 | return 0; |
| 1260 | } |
| 1261 | } |
| 1262 | |
| 1263 | GLuint GetStencilBits(GLint internalFormat, GLuint clientVersion) |
| 1264 | { |
| 1265 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1266 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1267 | { |
| 1268 | return internalFormatInfo.mStencilBits; |
| 1269 | } |
| 1270 | else |
| 1271 | { |
| 1272 | UNREACHABLE(); |
| 1273 | return 0; |
| 1274 | } |
| 1275 | } |
| 1276 | |
Geoff Lang | f23eb28 | 2013-07-22 10:52:19 -0400 | [diff] [blame] | 1277 | GLuint GetTypeBytes(GLenum type) |
| 1278 | { |
| 1279 | TypeInfo typeInfo; |
| 1280 | if (GetTypeInfo(type, &typeInfo)) |
| 1281 | { |
| 1282 | return typeInfo.mTypeBytes; |
| 1283 | } |
| 1284 | else |
| 1285 | { |
| 1286 | UNREACHABLE(); |
| 1287 | return 0; |
| 1288 | } |
| 1289 | } |
| 1290 | |
| 1291 | bool IsSpecialInterpretationType(GLenum type) |
| 1292 | { |
| 1293 | TypeInfo typeInfo; |
| 1294 | if (GetTypeInfo(type, &typeInfo)) |
| 1295 | { |
| 1296 | return typeInfo.mSpecialInterpretation; |
| 1297 | } |
| 1298 | else |
| 1299 | { |
| 1300 | UNREACHABLE(); |
| 1301 | return false; |
| 1302 | } |
| 1303 | } |
| 1304 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1305 | GLenum GetFormat(GLint internalFormat, GLuint clientVersion) |
| 1306 | { |
| 1307 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1308 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1309 | { |
| 1310 | return internalFormatInfo.mFormat; |
| 1311 | } |
| 1312 | else |
| 1313 | { |
| 1314 | UNREACHABLE(); |
| 1315 | return GL_NONE; |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | GLenum GetType(GLint internalFormat, GLuint clientVersion) |
| 1320 | { |
| 1321 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1322 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1323 | { |
| 1324 | return internalFormatInfo.mType; |
| 1325 | } |
| 1326 | else |
| 1327 | { |
| 1328 | UNREACHABLE(); |
| 1329 | return GL_NONE; |
| 1330 | } |
| 1331 | } |
| 1332 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1333 | GLuint GetComponentType(GLint internalFormat, GLuint clientVersion) |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1334 | { |
| 1335 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1336 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1337 | { |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1338 | return internalFormatInfo.mComponentType; |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1339 | } |
| 1340 | else |
| 1341 | { |
| 1342 | UNREACHABLE(); |
| 1343 | return false; |
| 1344 | } |
| 1345 | } |
| 1346 | |
Jamie Madill | 3466a4d | 2013-09-18 14:36:20 -0400 | [diff] [blame] | 1347 | GLuint GetComponentCount(GLint internalFormat, GLuint clientVersion) |
| 1348 | { |
| 1349 | InternalFormatInfo internalFormatInfo; |
| 1350 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
| 1351 | { |
| 1352 | return internalFormatInfo.mComponentCount; |
| 1353 | } |
| 1354 | else |
| 1355 | { |
| 1356 | UNREACHABLE(); |
| 1357 | return false; |
| 1358 | } |
| 1359 | } |
| 1360 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1361 | GLenum GetColorEncoding(GLint internalFormat, GLuint clientVersion) |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1362 | { |
| 1363 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1364 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | e19409b | 2013-05-30 00:16:15 +0000 | [diff] [blame] | 1365 | { |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1366 | return internalFormatInfo.mColorEncoding; |
shannonwoods@chromium.org | e81ea50 | 2013-05-30 00:16:53 +0000 | [diff] [blame] | 1367 | } |
| 1368 | else |
| 1369 | { |
| 1370 | UNREACHABLE(); |
| 1371 | return false; |
| 1372 | } |
| 1373 | } |
| 1374 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1375 | bool IsColorRenderingSupported(GLint internalFormat, const rx::Renderer *renderer) |
| 1376 | { |
| 1377 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1378 | if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1379 | { |
| 1380 | return internalFormatInfo.mIsColorRenderable(NULL, renderer); |
| 1381 | } |
| 1382 | else |
| 1383 | { |
| 1384 | UNREACHABLE(); |
| 1385 | return false; |
| 1386 | } |
| 1387 | } |
| 1388 | |
| 1389 | bool IsColorRenderingSupported(GLint internalFormat, const Context *context) |
| 1390 | { |
| 1391 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1392 | if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1393 | { |
| 1394 | return internalFormatInfo.mIsColorRenderable(context, NULL); |
| 1395 | } |
| 1396 | else |
| 1397 | { |
| 1398 | UNREACHABLE(); |
| 1399 | return false; |
| 1400 | } |
| 1401 | } |
| 1402 | |
| 1403 | bool IsTextureFilteringSupported(GLint internalFormat, const rx::Renderer *renderer) |
| 1404 | { |
| 1405 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1406 | if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1407 | { |
| 1408 | return internalFormatInfo.mIsTextureFilterable(NULL, renderer); |
| 1409 | } |
| 1410 | else |
| 1411 | { |
| 1412 | UNREACHABLE(); |
| 1413 | return false; |
| 1414 | } |
| 1415 | } |
| 1416 | |
| 1417 | bool IsTextureFilteringSupported(GLint internalFormat, const Context *context) |
| 1418 | { |
| 1419 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1420 | if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1421 | { |
| 1422 | return internalFormatInfo.mIsTextureFilterable(context, NULL); |
| 1423 | } |
| 1424 | else |
| 1425 | { |
| 1426 | UNREACHABLE(); |
| 1427 | return false; |
| 1428 | } |
| 1429 | } |
| 1430 | |
| 1431 | bool IsDepthRenderingSupported(GLint internalFormat, const rx::Renderer *renderer) |
| 1432 | { |
| 1433 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1434 | if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1435 | { |
| 1436 | return internalFormatInfo.mIsDepthRenderable(NULL, renderer); |
| 1437 | } |
| 1438 | else |
| 1439 | { |
| 1440 | UNREACHABLE(); |
| 1441 | return false; |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | bool IsDepthRenderingSupported(GLint internalFormat, const Context *context) |
| 1446 | { |
| 1447 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1448 | if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1449 | { |
| 1450 | return internalFormatInfo.mIsDepthRenderable(context, NULL); |
| 1451 | } |
| 1452 | else |
| 1453 | { |
| 1454 | UNREACHABLE(); |
| 1455 | return false; |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | bool IsStencilRenderingSupported(GLint internalFormat, const rx::Renderer *renderer) |
| 1460 | { |
| 1461 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1462 | if (renderer && GetInternalFormatInfo(internalFormat, renderer->getCurrentClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1463 | { |
| 1464 | return internalFormatInfo.mIsStencilRenderable(NULL, renderer); |
| 1465 | } |
| 1466 | else |
| 1467 | { |
| 1468 | UNREACHABLE(); |
| 1469 | return false; |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | bool IsStencilRenderingSupported(GLint internalFormat, const Context *context) |
| 1474 | { |
| 1475 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1476 | if (context && GetInternalFormatInfo(internalFormat, context->getClientVersion(), &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1477 | { |
| 1478 | return internalFormatInfo.mIsStencilRenderable(context, NULL); |
| 1479 | } |
| 1480 | else |
| 1481 | { |
| 1482 | UNREACHABLE(); |
| 1483 | return false; |
| 1484 | } |
| 1485 | } |
| 1486 | |
| 1487 | GLuint GetRowPitch(GLint internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment) |
| 1488 | { |
| 1489 | ASSERT(alignment > 0 && isPow2(alignment)); |
| 1490 | return (GetBlockSize(internalFormat, type, clientVersion, width, 1) + alignment - 1) & ~(alignment - 1); |
| 1491 | } |
| 1492 | |
| 1493 | GLuint GetDepthPitch(GLint internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment) |
| 1494 | { |
Jamie Madill | 666e286 | 2013-09-10 12:04:29 -0400 | [diff] [blame] | 1495 | return GetRowPitch(internalFormat, type, clientVersion, width, alignment) * height; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1496 | } |
| 1497 | |
| 1498 | GLuint GetBlockSize(GLint internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height) |
| 1499 | { |
| 1500 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1501 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1502 | { |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1503 | if (internalFormatInfo.mIsCompressed) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1504 | { |
| 1505 | GLsizei numBlocksWide = (width + internalFormatInfo.mCompressedBlockWidth - 1) / internalFormatInfo.mCompressedBlockWidth; |
| 1506 | GLsizei numBlocksHight = (height + internalFormatInfo.mCompressedBlockHeight - 1) / internalFormatInfo.mCompressedBlockHeight; |
| 1507 | |
| 1508 | return (internalFormatInfo.mPixelBits * numBlocksWide * numBlocksHight) / 8; |
| 1509 | } |
| 1510 | else |
| 1511 | { |
| 1512 | TypeInfo typeInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1513 | if (GetTypeInfo(type, &typeInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1514 | { |
| 1515 | if (typeInfo.mSpecialInterpretation) |
| 1516 | { |
| 1517 | return typeInfo.mTypeBytes * width * height; |
| 1518 | } |
| 1519 | else |
| 1520 | { |
| 1521 | return internalFormatInfo.mComponentCount * typeInfo.mTypeBytes * width * height; |
| 1522 | } |
| 1523 | } |
| 1524 | else |
| 1525 | { |
| 1526 | UNREACHABLE(); |
| 1527 | return 0; |
| 1528 | } |
| 1529 | } |
| 1530 | } |
| 1531 | else |
| 1532 | { |
| 1533 | UNREACHABLE(); |
| 1534 | return 0; |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | bool IsFormatCompressed(GLint internalFormat, GLuint clientVersion) |
| 1539 | { |
| 1540 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1541 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1542 | { |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 1543 | return internalFormatInfo.mIsCompressed; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1544 | } |
| 1545 | else |
| 1546 | { |
| 1547 | UNREACHABLE(); |
| 1548 | return false; |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | GLuint GetCompressedBlockWidth(GLint internalFormat, GLuint clientVersion) |
| 1553 | { |
| 1554 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1555 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1556 | { |
| 1557 | return internalFormatInfo.mCompressedBlockWidth; |
| 1558 | } |
| 1559 | else |
| 1560 | { |
| 1561 | UNREACHABLE(); |
| 1562 | return 0; |
| 1563 | } |
| 1564 | } |
| 1565 | |
| 1566 | GLuint GetCompressedBlockHeight(GLint internalFormat, GLuint clientVersion) |
| 1567 | { |
| 1568 | InternalFormatInfo internalFormatInfo; |
Geoff Lang | 18591b7 | 2013-06-07 12:00:15 -0400 | [diff] [blame] | 1569 | if (GetInternalFormatInfo(internalFormat, clientVersion, &internalFormatInfo)) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1570 | { |
| 1571 | return internalFormatInfo.mCompressedBlockHeight; |
| 1572 | } |
| 1573 | else |
| 1574 | { |
| 1575 | UNREACHABLE(); |
| 1576 | return 0; |
| 1577 | } |
| 1578 | } |
| 1579 | |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 1580 | ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion) |
| 1581 | { |
| 1582 | static const FormatMap &formats = GetFormatMap(clientVersion); |
| 1583 | FormatMap::const_iterator iter = formats.find(FormatTypePair(format, type)); |
| 1584 | return (iter != formats.end()) ? iter->second.mColorWriteFunction : NULL; |
| 1585 | } |
| 1586 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1587 | } |