Home | History | Annotate | Download | only in libGLES_CM
      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 	bool IsDepthTexture(GLenum format);
     35 	bool IsStencilTexture(GLenum format);
     36 	bool IsCubemapTextureTarget(GLenum target);
     37 	int CubeFaceIndex(GLenum cubeTarget);
     38 	bool IsTextureTarget(GLenum target);
     39 	bool CheckTextureFormatType(GLenum format, GLenum type);
     40 
     41 	bool IsColorRenderable(GLenum internalformat);
     42 	bool IsDepthRenderable(GLenum internalformat);
     43 	bool IsStencilRenderable(GLenum internalformat);
     44 
     45 	bool IsAlpha(GLenum texFormat);
     46 	bool IsRGB(GLenum texFormat);
     47 	bool IsRGBA(GLenum texFormat);
     48 }
     49 
     50 namespace es2sw
     51 {
     52 	sw::DepthCompareMode ConvertDepthComparison(GLenum comparison);
     53 	sw::StencilCompareMode ConvertStencilComparison(GLenum comparison);
     54 	sw::AlphaCompareMode ConvertAlphaComparison(GLenum comparison);
     55 	sw::Color<float> ConvertColor(es1::Color color);
     56 	sw::BlendFactor ConvertBlendFunc(GLenum blend);
     57 	sw::BlendOperation ConvertBlendOp(GLenum blendOp);
     58 	sw::LogicalOperation ConvertLogicalOperation(GLenum logicalOperation);
     59 	sw::StencilOperation ConvertStencilOp(GLenum stencilOp);
     60 	sw::AddressingMode ConvertTextureWrap(GLenum wrap);
     61 	sw::CullMode ConvertCullMode(GLenum cullFace, GLenum frontFace);
     62 	unsigned int ConvertColorMask(bool red, bool green, bool blue, bool alpha);
     63 	sw::MipmapType ConvertMipMapFilter(GLenum minFilter);
     64 	sw::FilterType ConvertTextureFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy);
     65 	bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount,  GLenum elementType, sw::DrawType &swPrimitiveType, int &primitiveCount);
     66 	sw::Format ConvertRenderbufferFormat(GLenum format);
     67 	sw::TextureStage::StageOperation ConvertCombineOperation(GLenum operation);
     68 	sw::TextureStage::SourceArgument ConvertSourceArgument(GLenum argument);
     69 	sw::TextureStage::ArgumentModifier ConvertSourceOperand(GLenum operand);
     70 }
     71 
     72 namespace sw2es
     73 {
     74 	GLuint GetAlphaSize(sw::Format colorFormat);
     75 	GLuint GetRedSize(sw::Format colorFormat);
     76 	GLuint GetGreenSize(sw::Format colorFormat);
     77 	GLuint GetBlueSize(sw::Format colorFormat);
     78 	GLuint GetDepthSize(sw::Format depthFormat);
     79 	GLuint GetStencilSize(sw::Format stencilFormat);
     80 
     81 	GLenum ConvertBackBufferFormat(sw::Format format);
     82 	GLenum ConvertDepthStencilFormat(sw::Format format);
     83 }
     84 
     85 #endif  // LIBGLES_CM_UTILITIES_H
     86