blob: be8921ed46aba13c3bf4c457431a3c5e59a0472b [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
Geoff Lang0a73dd82014-11-19 16:18:08 -05009#ifndef LIBANGLE_FORMATUTILS_H_
10#define LIBANGLE_FORMATUTILS_H_
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000011
Geoff Lang2b5420c2014-11-19 14:20:15 -050012#include "libANGLE/Caps.h"
13#include "libANGLE/angletypes.h"
Geoff Langfe28ca02013-06-04 10:10:48 -040014
Geoff Lang0b7eef72014-06-12 14:10:47 -040015#include "angle_gl.h"
16
Geoff Lang86846e22014-06-03 15:48:54 -040017#include <cstddef>
Jamie Madill47e156c2015-01-05 13:15:13 -050018#include <stdint.h>
Geoff Lang86846e22014-06-03 15:48:54 -040019
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000020namespace gl
21{
22
Geoff Lang9d9132d2014-12-03 14:46:48 -050023struct Type
Geoff Lang5d601382014-07-22 15:14:06 -040024{
25 Type();
26
27 GLuint bytes;
28 bool specialInterpretation;
29};
Geoff Lang9d9132d2014-12-03 14:46:48 -050030const Type &GetTypeInfo(GLenum type);
Geoff Lang5d601382014-07-22 15:14:06 -040031
Geoff Lang9d9132d2014-12-03 14:46:48 -050032struct InternalFormat
Geoff Lang5d601382014-07-22 15:14:06 -040033{
34 InternalFormat();
35
36 GLuint redBits;
37 GLuint greenBits;
38 GLuint blueBits;
39
40 GLuint luminanceBits;
41
42 GLuint alphaBits;
43 GLuint sharedBits;
44
45 GLuint depthBits;
46 GLuint stencilBits;
47
48 GLuint pixelBytes;
49
50 GLuint componentCount;
51
52 bool compressed;
53 GLuint compressedBlockWidth;
54 GLuint compressedBlockHeight;
55
56 GLenum format;
57 GLenum type;
58
59 GLenum componentType;
60 GLenum colorEncoding;
61
62 typedef bool (*SupportCheckFunction)(GLuint, const Extensions &);
63 SupportCheckFunction textureSupport;
64 SupportCheckFunction renderSupport;
65 SupportCheckFunction filterSupport;
66
Austin Kinrossc67e6e92015-01-21 16:01:07 -080067 GLuint computeRowPitch(GLenum formatType, GLsizei width, GLint alignment) const;
68 GLuint computeDepthPitch(GLenum formatType, GLsizei width, GLsizei height, GLint alignment) const;
69 GLuint computeBlockSize(GLenum formatType, GLsizei width, GLsizei height) const;
Geoff Lang5d601382014-07-22 15:14:06 -040070};
Geoff Lang9d9132d2014-12-03 14:46:48 -050071const InternalFormat &GetInternalFormatInfo(GLenum internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -040072
Geoff Lang9d9132d2014-12-03 14:46:48 -050073GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type);
Geoff Lang5d601382014-07-22 15:14:06 -040074
Geoff Langcec35902014-04-16 10:52:36 -040075typedef std::set<GLenum> FormatSet;
Geoff Lange4a492b2014-06-19 14:14:41 -040076const FormatSet &GetAllSizedInternalFormats();
Geoff Langcec35902014-04-16 10:52:36 -040077
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000078}
79
Geoff Lang0a73dd82014-11-19 16:18:08 -050080#endif // LIBANGLE_FORMATUTILS_H_