shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // formatutils.h: Queries for GL image formats. |
| 8 | |
| 9 | #ifndef LIBGLESV2_FORMATUTILS_H_ |
| 10 | #define LIBGLESV2_FORMATUTILS_H_ |
| 11 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 12 | #include "libGLESv2/Caps.h" |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 13 | #include "libGLESv2/angletypes.h" |
| 14 | |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 15 | #include "angle_gl.h" |
| 16 | |
Geoff Lang | 86846e2 | 2014-06-03 15:48:54 -0400 | [diff] [blame] | 17 | #include <cstddef> |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 18 | #include <cstdint> |
Geoff Lang | 86846e2 | 2014-06-03 15:48:54 -0400 | [diff] [blame] | 19 | |
Geoff Lang | 57f9b6d | 2014-06-04 16:46:37 -0400 | [diff] [blame] | 20 | typedef void (*MipGenerationFunction)(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth, |
| 21 | const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch, |
| 22 | uint8_t *destData, size_t destRowPitch, size_t destDepthPitch); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 23 | |
Geoff Lang | 86846e2 | 2014-06-03 15:48:54 -0400 | [diff] [blame] | 24 | typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth, |
| 25 | const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, |
| 26 | uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 27 | |
Geoff Lang | 86846e2 | 2014-06-03 15:48:54 -0400 | [diff] [blame] | 28 | typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth, |
| 29 | uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch); |
Geoff Lang | 0c99b1b | 2013-09-30 15:07:43 -0400 | [diff] [blame] | 30 | |
Geoff Lang | 268b6bc | 2014-07-09 16:22:55 -0400 | [diff] [blame] | 31 | typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest); |
| 32 | typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest); |
| 33 | typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest); |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 34 | |
Geoff Lang | 45965b1 | 2014-07-09 15:54:46 -0400 | [diff] [blame] | 35 | typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output); |
Jamie Madill | 7ab02fa | 2014-02-04 16:04:08 -0500 | [diff] [blame] | 36 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 37 | namespace gl |
| 38 | { |
| 39 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 40 | struct FormatType |
| 41 | { |
| 42 | FormatType(); |
| 43 | |
| 44 | GLenum internalFormat; |
| 45 | ColorWriteFunction colorWriteFunction; |
| 46 | }; |
| 47 | const FormatType &GetFormatTypeInfo(GLenum format, GLenum type); |
| 48 | |
| 49 | struct Type |
| 50 | { |
| 51 | Type(); |
| 52 | |
| 53 | GLuint bytes; |
| 54 | bool specialInterpretation; |
| 55 | }; |
| 56 | const Type &GetTypeInfo(GLenum type); |
| 57 | |
| 58 | struct InternalFormat |
| 59 | { |
| 60 | InternalFormat(); |
| 61 | |
| 62 | GLuint redBits; |
| 63 | GLuint greenBits; |
| 64 | GLuint blueBits; |
| 65 | |
| 66 | GLuint luminanceBits; |
| 67 | |
| 68 | GLuint alphaBits; |
| 69 | GLuint sharedBits; |
| 70 | |
| 71 | GLuint depthBits; |
| 72 | GLuint stencilBits; |
| 73 | |
| 74 | GLuint pixelBytes; |
| 75 | |
| 76 | GLuint componentCount; |
| 77 | |
| 78 | bool compressed; |
| 79 | GLuint compressedBlockWidth; |
| 80 | GLuint compressedBlockHeight; |
| 81 | |
| 82 | GLenum format; |
| 83 | GLenum type; |
| 84 | |
| 85 | GLenum componentType; |
| 86 | GLenum colorEncoding; |
| 87 | |
| 88 | typedef bool (*SupportCheckFunction)(GLuint, const Extensions &); |
| 89 | SupportCheckFunction textureSupport; |
| 90 | SupportCheckFunction renderSupport; |
| 91 | SupportCheckFunction filterSupport; |
| 92 | |
| 93 | GLuint computeRowPitch(GLenum type, GLsizei width, GLint alignment) const; |
| 94 | GLuint computeDepthPitch(GLenum type, GLsizei width, GLsizei height, GLint alignment) const; |
| 95 | GLuint computeBlockSize(GLenum type, GLsizei width, GLsizei height) const; |
| 96 | }; |
| 97 | const InternalFormat &GetInternalFormatInfo(GLenum internalFormat); |
| 98 | |
| 99 | GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type); |
| 100 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 101 | typedef std::set<GLenum> FormatSet; |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 102 | const FormatSet &GetAllSizedInternalFormats(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 103 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Andrew Knight | 08a59f8 | 2014-09-16 23:19:39 +0300 | [diff] [blame] | 106 | #endif // LIBGLESV2_FORMATUTILS_H_ |