OSDN Git Service

51ec56c6fa885fc27ec47a57310755ca12660640
[android-x86/external-swiftshader.git] / src / Radiance / libRAD / utilities.h
1 // SwiftShader Software Renderer\r
2 //\r
3 // Copyright(c) 2005-2013 TransGaming Inc.\r
4 //\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,\r
6 // transcribed, stored in a retrieval system, translated into any human or computer\r
7 // language by any means, or disclosed to third parties without the explicit written\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express\r
9 // or implied, including but not limited to any patent rights, are granted to you.\r
10 //\r
11 \r
12 // utilities.h: Conversion functions and other utility routines.\r
13 \r
14 #ifndef LIBGLESV2_UTILITIES_H\r
15 #define LIBGLESV2_UTILITIES_H\r
16 \r
17 #include "Device.hpp"\r
18 #include "Image.hpp"\r
19 #include "Texture.h"\r
20 \r
21 #define GL_APICALL\r
22 #include <GLES2/gl2.h>\r
23 #include <GLES2/gl2ext.h>\r
24 \r
25 #include <string>\r
26 \r
27 namespace rad\r
28 {\r
29         struct Color;\r
30 \r
31         int UniformComponentCount(GLenum type);\r
32         GLenum UniformComponentType(GLenum type);\r
33         size_t UniformTypeSize(GLenum type);\r
34         int VariableRowCount(GLenum type);\r
35         int VariableColumnCount(GLenum type);\r
36 \r
37         int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);\r
38 \r
39         int ComputePixelSize(GLenum format, GLenum type);\r
40         GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment);\r
41         GLsizei ComputeCompressedPitch(GLsizei width, GLenum format);\r
42         GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format);\r
43         bool IsCompressed(GLenum format);\r
44         bool IsDepthTexture(GLenum format);\r
45         bool IsStencilTexture(GLenum format);\r
46         bool IsCubemapTextureTarget(GLenum target);\r
47         int CubeFaceIndex(GLenum cubeTarget);\r
48         bool IsTextureTarget(GLenum target);\r
49         bool CheckTextureFormatType(GLenum format, GLenum type);\r
50 \r
51         bool IsColorRenderable(GLenum internalformat);\r
52         bool IsDepthRenderable(GLenum internalformat);\r
53         bool IsStencilRenderable(GLenum internalformat);\r
54 }\r
55 \r
56 namespace rad2sw\r
57 {\r
58         sw::DepthCompareMode ConvertDepthComparison(GLenum comparison);\r
59         sw::StencilCompareMode ConvertStencilComparison(GLenum comparison);\r
60         sw::Color<float> ConvertColor(rad::Color color);\r
61         sw::BlendFactor ConvertBlendFunc(GLenum blend);\r
62         sw::BlendOperation ConvertBlendOp(GLenum blendOp);\r
63         sw::StencilOperation ConvertStencilOp(GLenum stencilOp);\r
64         sw::AddressingMode ConvertTextureWrap(GLenum wrap);\r
65         sw::CullMode ConvertCullMode(GLenum cullFace, GLenum frontFace);\r
66         unsigned int ConvertColorMask(bool red, bool green, bool blue, bool alpha);\r
67         sw::FilterType ConvertMagFilter(GLenum magFilter);\r
68         void ConvertMinFilter(GLenum texFilter, sw::FilterType *minFilter, sw::MipmapType *mipFilter, float maxAnisotropy);\r
69         bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount,  rad::PrimitiveType &swPrimitiveType, int &primitiveCount);\r
70         sw::Format ConvertRenderbufferFormat(GLenum format);\r
71 }\r
72 \r
73 namespace sw2rad\r
74 {\r
75         GLuint GetAlphaSize(sw::Format colorFormat);\r
76         GLuint GetRedSize(sw::Format colorFormat);\r
77         GLuint GetGreenSize(sw::Format colorFormat);\r
78         GLuint GetBlueSize(sw::Format colorFormat);\r
79         GLuint GetDepthSize(sw::Format depthFormat);\r
80         GLuint GetStencilSize(sw::Format stencilFormat);\r
81 \r
82         GLenum ConvertBackBufferFormat(sw::Format format);\r
83         GLenum ConvertDepthStencilFormat(sw::Format format);\r
84 }\r
85 \r
86 #endif  // LIBGLESV2_UTILITIES_H\r