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