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