1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // utilities.h: Conversion functions and other utility routines. 16 17 #ifndef LIBGLES_CM_UTILITIES_H 18 #define LIBGLES_CM_UTILITIES_H 19 20 #include "Device.hpp" 21 #include "common/Image.hpp" 22 #include "Texture.h" 23 24 #include <GLES/gl.h> 25 #include <GLES/glext.h> 26 27 #include <string> 28 29 namespace es1 30 { 31 struct Color; 32 33 bool IsCompressed(GLenum format); 34 GLenum ValidateSubImageParams(bool compressed, bool copy, GLenum target, GLint level, GLint xoffset, GLint yoffset, 35 GLsizei width, GLsizei height, GLenum format, GLenum type, Texture *texture); 36 bool IsDepthTexture(GLenum format); 37 bool IsStencilTexture(GLenum format); 38 bool IsCubemapTextureTarget(GLenum target); 39 int CubeFaceIndex(GLenum cubeTarget); 40 bool IsTextureTarget(GLenum target); 41 GLenum ValidateTextureFormatType(GLenum format, GLenum type, GLint internalformat, GLenum target); 42 43 bool IsColorRenderable(GLint internalformat); 44 bool IsDepthRenderable(GLint internalformat); 45 bool IsStencilRenderable(GLint internalformat); 46 47 GLuint GetAlphaSize(GLint internalformat); 48 GLuint GetRedSize(GLint internalformat); 49 GLuint GetGreenSize(GLint internalformat); 50 GLuint GetBlueSize(GLint internalformat); 51 GLuint GetDepthSize(GLint internalformat); 52 GLuint GetStencilSize(GLint internalformat); 53 54 bool IsAlpha(GLint texFormat); 55 bool IsRGB(GLint texFormat); 56 bool IsRGBA(GLint texFormat); 57 } 58 59 namespace es2sw 60 { 61 sw::DepthCompareMode ConvertDepthComparison(GLenum comparison); 62 sw::StencilCompareMode ConvertStencilComparison(GLenum comparison); 63 sw::AlphaCompareMode ConvertAlphaComparison(GLenum comparison); 64 sw::Color<float> ConvertColor(es1::Color color); 65 sw::BlendFactor ConvertBlendFunc(GLenum blend); 66 sw::BlendOperation ConvertBlendOp(GLenum blendOp); 67 sw::LogicalOperation ConvertLogicalOperation(GLenum logicalOperation); 68 sw::StencilOperation ConvertStencilOp(GLenum stencilOp); 69 sw::AddressingMode ConvertTextureWrap(GLenum wrap); 70 sw::CullMode ConvertCullMode(GLenum cullFace, GLenum frontFace); 71 unsigned int ConvertColorMask(bool red, bool green, bool blue, bool alpha); 72 sw::MipmapType ConvertMipMapFilter(GLenum minFilter); 73 sw::FilterType ConvertTextureFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy); 74 bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, GLenum elementType, sw::DrawType &swPrimitiveType, int &primitiveCount); 75 sw::TextureStage::StageOperation ConvertCombineOperation(GLenum operation); 76 sw::TextureStage::SourceArgument ConvertSourceArgument(GLenum argument); 77 sw::TextureStage::ArgumentModifier ConvertSourceOperand(GLenum operand); 78 } 79 80 namespace sw2es 81 { 82 GLenum ConvertBackBufferFormat(sw::Format format); 83 GLenum ConvertDepthStencilFormat(sw::Format format); 84 } 85 86 #endif // LIBGLES_CM_UTILITIES_H 87