blob: f3211302a38a42d6e9fb5bc01efac83b4efb2202 [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
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000017typedef void (*MipGenerationFunction)(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
18 const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
19 unsigned char *destData, int destRowPitch, int destDepthPitch);
20
21typedef void (*LoadImageFunction)(int width, int height, int depth,
22 const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
23 void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
24
Geoff Lang0c99b1b2013-09-30 15:07:43 -040025typedef void (*InitializeTextureDataFunction)(int width, int height, int depth,
26 void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
27
Geoff Langfe28ca02013-06-04 10:10:48 -040028typedef void (*ColorReadFunction)(const void *source, void *dest);
29typedef void (*ColorWriteFunction)(const void *source, void *dest);
30typedef void (*ColorCopyFunction)(const void *source, void *dest);
31
Jamie Madill7ab02fa2014-02-04 16:04:08 -050032typedef void (*VertexCopyFunction)(const void *input, size_t stride, size_t count, void *output);
33
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000034namespace gl
35{
36
Geoff Langcec35902014-04-16 10:52:36 -040037typedef std::set<GLenum> FormatSet;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000038
Geoff Langcec35902014-04-16 10:52:36 -040039bool IsValidInternalFormat(GLenum internalFormat, const Extensions &extensions, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000040bool IsValidFormat(GLenum format, GLuint clientVersion);
41bool IsValidType(GLenum type, GLuint clientVersion);
42
Geoff Lang005df412013-10-16 14:12:50 -040043bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, GLuint clientVersion);
Shannon Woods4d161ba2014-03-17 18:13:30 -040044bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000045
Geoff Lang005df412013-10-16 14:12:50 -040046bool IsSizedInternalFormat(GLenum internalFormat, GLuint clientVersion);
47GLenum GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000048
Geoff Lang005df412013-10-16 14:12:50 -040049GLuint GetPixelBytes(GLenum internalFormat, GLuint clientVersion);
50GLuint GetAlphaBits(GLenum internalFormat, GLuint clientVersion);
51GLuint GetRedBits(GLenum internalFormat, GLuint clientVersion);
52GLuint GetGreenBits(GLenum internalFormat, GLuint clientVersion);
53GLuint GetBlueBits(GLenum internalFormat, GLuint clientVersion);
54GLuint GetLuminanceBits(GLenum internalFormat, GLuint clientVersion);
55GLuint GetDepthBits(GLenum internalFormat, GLuint clientVersion);
56GLuint GetStencilBits(GLenum internalFormat, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000057
Geoff Langf23eb282013-07-22 10:52:19 -040058GLuint GetTypeBytes(GLenum type);
59bool IsSpecialInterpretationType(GLenum type);
Shannon Woods4d161ba2014-03-17 18:13:30 -040060bool IsFloatOrFixedComponentType(GLenum type);
Geoff Langf23eb282013-07-22 10:52:19 -040061
Geoff Lang005df412013-10-16 14:12:50 -040062GLenum GetFormat(GLenum internalFormat, GLuint clientVersion);
63GLenum GetType(GLenum internalFormat, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000064
Geoff Lang005df412013-10-16 14:12:50 -040065GLenum GetComponentType(GLenum internalFormat, GLuint clientVersion);
66GLuint GetComponentCount(GLenum internalFormat, GLuint clientVersion);
67GLenum GetColorEncoding(GLenum internalFormat, GLuint clientVersion);
shannonwoods@chromium.orge81ea502013-05-30 00:16:53 +000068
Geoff Lang005df412013-10-16 14:12:50 -040069GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment);
70GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment);
71GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000072
Geoff Lang005df412013-10-16 14:12:50 -040073bool IsFormatCompressed(GLenum internalFormat, GLuint clientVersion);
74GLuint GetCompressedBlockWidth(GLenum internalFormat, GLuint clientVersion);
75GLuint GetCompressedBlockHeight(GLenum internalFormat, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000076
Geoff Langcec35902014-04-16 10:52:36 -040077const FormatSet &GetAllSizedInternalFormats(GLuint clientVersion);
78
Geoff Langfe28ca02013-06-04 10:10:48 -040079ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion);
80
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000081}
82
83#endif LIBGLESV2_FORMATUTILS_H_