blob: 063fda74e341a0f15fdb9e08c385866421b3df19 [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 Lang8bc361e2014-11-20 16:23:31 -050014#include "libANGLE/export.h"
Geoff Langfe28ca02013-06-04 10:10:48 -040015
Geoff Lang0b7eef72014-06-12 14:10:47 -040016#include "angle_gl.h"
17
Geoff Lang86846e22014-06-03 15:48:54 -040018#include <cstddef>
Geoff Lang0b7eef72014-06-12 14:10:47 -040019#include <cstdint>
Geoff Lang86846e22014-06-03 15:48:54 -040020
Geoff Lang57f9b6d2014-06-04 16:46:37 -040021typedef 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.orgb8490f32013-05-30 00:08:00 +000024
Geoff Lang86846e22014-06-03 15:48:54 -040025typedef 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.orgb8490f32013-05-30 00:08:00 +000028
Geoff Lang86846e22014-06-03 15:48:54 -040029typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
30 uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
Geoff Lang0c99b1b2013-09-30 15:07:43 -040031
Geoff Lang268b6bc2014-07-09 16:22:55 -040032typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
33typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
34typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
Geoff Langfe28ca02013-06-04 10:10:48 -040035
Geoff Lang45965b12014-07-09 15:54:46 -040036typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
Jamie Madill7ab02fa2014-02-04 16:04:08 -050037
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000038namespace gl
39{
40
Geoff Lang8bc361e2014-11-20 16:23:31 -050041struct ANGLE_EXPORT FormatType
Geoff Lang5d601382014-07-22 15:14:06 -040042{
43 FormatType();
44
45 GLenum internalFormat;
46 ColorWriteFunction colorWriteFunction;
47};
Geoff Lang8bc361e2014-11-20 16:23:31 -050048ANGLE_EXPORT const FormatType &GetFormatTypeInfo(GLenum format, GLenum type);
Geoff Lang5d601382014-07-22 15:14:06 -040049
Geoff Lang8bc361e2014-11-20 16:23:31 -050050struct ANGLE_EXPORT Type
Geoff Lang5d601382014-07-22 15:14:06 -040051{
52 Type();
53
54 GLuint bytes;
55 bool specialInterpretation;
56};
Geoff Lang8bc361e2014-11-20 16:23:31 -050057ANGLE_EXPORT const Type &GetTypeInfo(GLenum type);
Geoff Lang5d601382014-07-22 15:14:06 -040058
Geoff Lang8bc361e2014-11-20 16:23:31 -050059struct ANGLE_EXPORT InternalFormat
Geoff Lang5d601382014-07-22 15:14:06 -040060{
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 Lang8bc361e2014-11-20 16:23:31 -050098ANGLE_EXPORT const InternalFormat &GetInternalFormatInfo(GLenum internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -040099
Geoff Lang8bc361e2014-11-20 16:23:31 -0500100ANGLE_EXPORT GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type);
Geoff Lang5d601382014-07-22 15:14:06 -0400101
Geoff Langcec35902014-04-16 10:52:36 -0400102typedef std::set<GLenum> FormatSet;
Geoff Lange4a492b2014-06-19 14:14:41 -0400103const FormatSet &GetAllSizedInternalFormats();
Geoff Langcec35902014-04-16 10:52:36 -0400104
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000105}
106
Geoff Lang0a73dd82014-11-19 16:18:08 -0500107#endif // LIBANGLE_FORMATUTILS_H_