blob: 25106a52e5624d6a28193aab0b5ac30123128c10 [file] [log] [blame]
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001//
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 Langcec35902014-04-16 10:52:36 -040012#include "libGLESv2/Caps.h"
Geoff Langfe28ca02013-06-04 10:10:48 -040013#include "libGLESv2/angletypes.h"
14
Geoff Lang0b7eef72014-06-12 14:10:47 -040015#include "angle_gl.h"
16
Geoff Lang86846e22014-06-03 15:48:54 -040017#include <cstddef>
Geoff Lang0b7eef72014-06-12 14:10:47 -040018#include <cstdint>
Geoff Lang86846e22014-06-03 15:48:54 -040019
Geoff Lang57f9b6d2014-06-04 16:46:37 -040020typedef 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.orgb8490f32013-05-30 00:08:00 +000023
Geoff Lang86846e22014-06-03 15:48:54 -040024typedef 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.orgb8490f32013-05-30 00:08:00 +000027
Geoff Lang86846e22014-06-03 15:48:54 -040028typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
29 uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
Geoff Lang0c99b1b2013-09-30 15:07:43 -040030
Geoff Lang268b6bc2014-07-09 16:22:55 -040031typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
32typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
33typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
Geoff Langfe28ca02013-06-04 10:10:48 -040034
Geoff Lang45965b12014-07-09 15:54:46 -040035typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
Jamie Madill7ab02fa2014-02-04 16:04:08 -050036
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000037namespace gl
38{
39
Geoff Lang5d601382014-07-22 15:14:06 -040040struct FormatType
41{
42 FormatType();
43
44 GLenum internalFormat;
45 ColorWriteFunction colorWriteFunction;
46};
47const FormatType &GetFormatTypeInfo(GLenum format, GLenum type);
48
49struct Type
50{
51 Type();
52
53 GLuint bytes;
54 bool specialInterpretation;
55};
56const Type &GetTypeInfo(GLenum type);
57
58struct 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};
97const InternalFormat &GetInternalFormatInfo(GLenum internalFormat);
98
99GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type);
100
Geoff Langcec35902014-04-16 10:52:36 -0400101typedef std::set<GLenum> FormatSet;
Geoff Lange4a492b2014-06-19 14:14:41 -0400102const FormatSet &GetAllSizedInternalFormats();
Geoff Langcec35902014-04-16 10:52:36 -0400103
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000104}
105
Andrew Knight08a59f82014-09-16 23:19:39 +0300106#endif // LIBGLESV2_FORMATUTILS_H_