blob: 2a991a67f9ed477aec58ad86ab65f5a080187ebd [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
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000012#include <GLES3/gl3.h>
13#include <GLES2/gl2.h>
14#include <GLES2/gl2ext.h>
15
Geoff Langcec35902014-04-16 10:52:36 -040016#include "libGLESv2/Caps.h"
Geoff Langfe28ca02013-06-04 10:10:48 -040017#include "libGLESv2/angletypes.h"
18
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000019typedef void (*MipGenerationFunction)(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
20 const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
21 unsigned char *destData, int destRowPitch, int destDepthPitch);
22
23typedef void (*LoadImageFunction)(int width, int height, int depth,
24 const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
25 void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
26
Geoff Lang0c99b1b2013-09-30 15:07:43 -040027typedef void (*InitializeTextureDataFunction)(int width, int height, int depth,
28 void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
29
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);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000042bool IsValidFormat(GLenum format, GLuint clientVersion);
43bool IsValidType(GLenum type, GLuint clientVersion);
44
Geoff Lang005df412013-10-16 14:12:50 -040045bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, 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 Lang005df412013-10-16 14:12:50 -040048bool IsSizedInternalFormat(GLenum internalFormat, GLuint clientVersion);
49GLenum GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000050
Geoff Lang005df412013-10-16 14:12:50 -040051GLuint GetPixelBytes(GLenum internalFormat, GLuint clientVersion);
52GLuint GetAlphaBits(GLenum internalFormat, GLuint clientVersion);
53GLuint GetRedBits(GLenum internalFormat, GLuint clientVersion);
54GLuint GetGreenBits(GLenum internalFormat, GLuint clientVersion);
55GLuint GetBlueBits(GLenum internalFormat, GLuint clientVersion);
56GLuint GetLuminanceBits(GLenum internalFormat, GLuint clientVersion);
57GLuint GetDepthBits(GLenum internalFormat, GLuint clientVersion);
58GLuint GetStencilBits(GLenum internalFormat, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000059
Geoff Langf23eb282013-07-22 10:52:19 -040060GLuint GetTypeBytes(GLenum type);
61bool IsSpecialInterpretationType(GLenum type);
Shannon Woods4d161ba2014-03-17 18:13:30 -040062bool IsFloatOrFixedComponentType(GLenum type);
Geoff Langf23eb282013-07-22 10:52:19 -040063
Geoff Lang005df412013-10-16 14:12:50 -040064GLenum GetFormat(GLenum internalFormat, GLuint clientVersion);
65GLenum GetType(GLenum internalFormat, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000066
Geoff Lang005df412013-10-16 14:12:50 -040067GLenum GetComponentType(GLenum internalFormat, GLuint clientVersion);
68GLuint GetComponentCount(GLenum internalFormat, GLuint clientVersion);
69GLenum GetColorEncoding(GLenum internalFormat, GLuint clientVersion);
shannonwoods@chromium.orge81ea502013-05-30 00:16:53 +000070
Geoff Lang005df412013-10-16 14:12:50 -040071GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment);
72GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment);
73GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000074
Geoff Lang005df412013-10-16 14:12:50 -040075bool IsFormatCompressed(GLenum internalFormat, GLuint clientVersion);
76GLuint GetCompressedBlockWidth(GLenum internalFormat, GLuint clientVersion);
77GLuint GetCompressedBlockHeight(GLenum internalFormat, GLuint clientVersion);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000078
Geoff Langcec35902014-04-16 10:52:36 -040079const FormatSet &GetAllSizedInternalFormats(GLuint clientVersion);
80
Geoff Langfe28ca02013-06-04 10:10:48 -040081ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion);
82
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000083}
84
85#endif LIBGLESV2_FORMATUTILS_H_