blob: 1fc1c1f42f22deb826a0ad1481948a1e7144e2e1 [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
Jamie Madillf51639a2014-06-25 16:04:57 -040012#include "angle_gl.h"
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000013
Geoff Langcec35902014-04-16 10:52:36 -040014#include "libGLESv2/Caps.h"
Geoff Langfe28ca02013-06-04 10:10:48 -040015#include "libGLESv2/angletypes.h"
16
Geoff Lang86846e22014-06-03 15:48:54 -040017#include <cstddef>
18
Geoff Lang57f9b6d2014-06-04 16:46:37 -040019typedef 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.orgb8490f32013-05-30 00:08:00 +000022
Geoff Lang86846e22014-06-03 15:48:54 -040023typedef 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.orgb8490f32013-05-30 00:08:00 +000026
Geoff Lang86846e22014-06-03 15:48:54 -040027typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
28 uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
Geoff Lang0c99b1b2013-09-30 15:07:43 -040029
Geoff Langfe28ca02013-06-04 10:10:48 -040030typedef void (*ColorReadFunction)(const void *source, void *dest);
31typedef void (*ColorWriteFunction)(const void *source, void *dest);
32typedef void (*ColorCopyFunction)(const void *source, void *dest);
33
Jamie Madill7ab02fa2014-02-04 16:04:08 -050034typedef void (*VertexCopyFunction)(const void *input, size_t stride, size_t count, void *output);
35
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000036namespace gl
37{
38
Geoff Lang5d601382014-07-22 15:14:06 -040039struct FormatType
40{
41 FormatType();
42
43 GLenum internalFormat;
44 ColorWriteFunction colorWriteFunction;
45};
46const FormatType &GetFormatTypeInfo(GLenum format, GLenum type);
47
48struct Type
49{
50 Type();
51
52 GLuint bytes;
53 bool specialInterpretation;
54};
55const Type &GetTypeInfo(GLenum type);
56
57struct 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};
96const InternalFormat &GetInternalFormatInfo(GLenum internalFormat);
97
98GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type);
99
Geoff Langcec35902014-04-16 10:52:36 -0400100typedef std::set<GLenum> FormatSet;
Geoff Lange4a492b2014-06-19 14:14:41 -0400101const FormatSet &GetAllSizedInternalFormats();
Geoff Langcec35902014-04-16 10:52:36 -0400102
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000103}
104
105#endif LIBGLESV2_FORMATUTILS_H_