blob: fb4d2a3a572769c9b21deaeb3d8ec6edee4bed97 [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 Langcec35902014-04-16 10:52:36 -040039typedef std::set<GLenum> FormatSet;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000040
Geoff Langcec35902014-04-16 10:52:36 -040041bool IsValidInternalFormat(GLenum internalFormat, const Extensions &extensions, GLuint clientVersion);
Geoff Lange4a492b2014-06-19 14:14:41 -040042bool IsValidFormat(GLenum format, const Extensions &extensions, GLuint clientVersion);
43bool IsValidType(GLenum type, const Extensions &extensions, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000044
Geoff Lange4a492b2014-06-19 14:14:41 -040045bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, const Extensions &extensions, GLuint clientVersion);
Shannon Woods4d161ba2014-03-17 18:13:30 -040046bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000047
Geoff Lang493daf52014-07-03 13:38:44 -040048bool IsRenderingSupported(GLenum internalFormat, const Extensions &extensions, GLuint clientVersion);
49bool IsFilteringSupported(GLenum internalFormat, const Extensions &extensions, GLuint clientVersion);
50
Geoff Lange4a492b2014-06-19 14:14:41 -040051bool IsSizedInternalFormat(GLenum internalFormat);
52GLenum GetSizedInternalFormat(GLenum format, GLenum type);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000053
Geoff Lange4a492b2014-06-19 14:14:41 -040054GLuint GetPixelBytes(GLenum internalFormat);
55GLuint GetAlphaBits(GLenum internalFormat);
56GLuint GetRedBits(GLenum internalFormat);
57GLuint GetGreenBits(GLenum internalFormat);
58GLuint GetBlueBits(GLenum internalFormat);
59GLuint GetLuminanceBits(GLenum internalFormat);
60GLuint GetDepthBits(GLenum internalFormat);
61GLuint GetStencilBits(GLenum internalFormat);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000062
Geoff Langf23eb282013-07-22 10:52:19 -040063GLuint GetTypeBytes(GLenum type);
64bool IsSpecialInterpretationType(GLenum type);
Shannon Woods4d161ba2014-03-17 18:13:30 -040065bool IsFloatOrFixedComponentType(GLenum type);
Geoff Langf23eb282013-07-22 10:52:19 -040066
Geoff Lange4a492b2014-06-19 14:14:41 -040067GLenum GetFormat(GLenum internalFormat);
68GLenum GetType(GLenum internalFormat);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000069
Geoff Lange4a492b2014-06-19 14:14:41 -040070GLenum GetComponentType(GLenum internalFormat);
71GLuint GetComponentCount(GLenum internalFormat);
72GLenum GetColorEncoding(GLenum internalFormat);
shannonwoods@chromium.orge81ea502013-05-30 00:16:53 +000073
Geoff Lange4a492b2014-06-19 14:14:41 -040074GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLsizei width, GLint alignment);
75GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLsizei width, GLsizei height, GLint alignment);
76GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLsizei width, GLsizei height);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000077
Geoff Lange4a492b2014-06-19 14:14:41 -040078bool IsFormatCompressed(GLenum internalFormat);
79GLuint GetCompressedBlockWidth(GLenum internalFormat);
80GLuint GetCompressedBlockHeight(GLenum internalFormat);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000081
Geoff Lange4a492b2014-06-19 14:14:41 -040082const FormatSet &GetAllSizedInternalFormats();
Geoff Langcec35902014-04-16 10:52:36 -040083
Geoff Lange4a492b2014-06-19 14:14:41 -040084ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type);
Geoff Langfe28ca02013-06-04 10:10:48 -040085
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000086}
87
88#endif LIBGLESV2_FORMATUTILS_H_