blob: 692ab884c372f4d73b58123a9c1e0fc5dad5a4f9 [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);
Geoff Lange4a492b2014-06-19 14:14:41 -040040bool IsValidFormat(GLenum format, const Extensions &extensions, GLuint clientVersion);
41bool IsValidType(GLenum type, const Extensions &extensions, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000042
Geoff Lange4a492b2014-06-19 14:14:41 -040043bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, const Extensions &extensions, 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 Lange4a492b2014-06-19 14:14:41 -040046bool IsSizedInternalFormat(GLenum internalFormat);
47GLenum GetSizedInternalFormat(GLenum format, GLenum type);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000048
Geoff Lange4a492b2014-06-19 14:14:41 -040049GLuint GetPixelBytes(GLenum internalFormat);
50GLuint GetAlphaBits(GLenum internalFormat);
51GLuint GetRedBits(GLenum internalFormat);
52GLuint GetGreenBits(GLenum internalFormat);
53GLuint GetBlueBits(GLenum internalFormat);
54GLuint GetLuminanceBits(GLenum internalFormat);
55GLuint GetDepthBits(GLenum internalFormat);
56GLuint GetStencilBits(GLenum internalFormat);
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 Lange4a492b2014-06-19 14:14:41 -040062GLenum GetFormat(GLenum internalFormat);
63GLenum GetType(GLenum internalFormat);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000064
Geoff Lange4a492b2014-06-19 14:14:41 -040065GLenum GetComponentType(GLenum internalFormat);
66GLuint GetComponentCount(GLenum internalFormat);
67GLenum GetColorEncoding(GLenum internalFormat);
shannonwoods@chromium.orge81ea502013-05-30 00:16:53 +000068
Geoff Lange4a492b2014-06-19 14:14:41 -040069GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLsizei width, GLint alignment);
70GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLsizei width, GLsizei height, GLint alignment);
71GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLsizei width, GLsizei height);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000072
Geoff Lange4a492b2014-06-19 14:14:41 -040073bool IsFormatCompressed(GLenum internalFormat);
74GLuint GetCompressedBlockWidth(GLenum internalFormat);
75GLuint GetCompressedBlockHeight(GLenum internalFormat);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000076
Geoff Lange4a492b2014-06-19 14:14:41 -040077const FormatSet &GetAllSizedInternalFormats();
Geoff Langcec35902014-04-16 10:52:36 -040078
Geoff Lange4a492b2014-06-19 14:14:41 -040079ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type);
Geoff Langfe28ca02013-06-04 10:10:48 -040080
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000081}
82
83#endif LIBGLESV2_FORMATUTILS_H_