OSDN Git Service

Implement GL_COMBINE.
authorNicolas Capens <capn@google.com>
Mon, 25 May 2015 14:01:46 +0000 (10:01 -0400)
committerNicolas Capens <capn@google.com>
Mon, 25 May 2015 14:36:28 +0000 (14:36 +0000)
Bug 21278131

Change-Id: If0cf8aa09b582e0252c4cedd73426764fd4dff53
Reviewed-on: https://swiftshader-review.googlesource.com/3232
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
src/OpenGL/libGLES_CM/Context.cpp
src/OpenGL/libGLES_CM/utilities.cpp
src/OpenGL/libGLES_CM/utilities.h

index df0731e..764f7d4 100644 (file)
@@ -1984,7 +1984,23 @@ void Context::applyTextures()
                        }\r
                        else   // GL_COMBINE\r
                        {\r
-                               \r
+                               device->setFirstArgument(unit, es2sw::ConvertSourceArgument(mState.textureUnit[unit].src0RGB));\r
+                               device->setFirstModifier(unit, es2sw::ConvertSourceOperand(mState.textureUnit[unit].operand0RGB));\r
+                               device->setSecondArgument(unit, es2sw::ConvertSourceArgument(mState.textureUnit[unit].src1RGB));\r
+                               device->setSecondModifier(unit, es2sw::ConvertSourceOperand(mState.textureUnit[unit].operand1RGB));\r
+                               device->setThirdArgument(unit, es2sw::ConvertSourceArgument(mState.textureUnit[unit].src2RGB));\r
+                               device->setThirdModifier(unit, es2sw::ConvertSourceOperand(mState.textureUnit[unit].operand2RGB));\r
+\r
+                               device->setStageOperation(unit, es2sw::ConvertCombineOperation(mState.textureUnit[unit].combineRGB));\r
+\r
+                               device->setFirstArgumentAlpha(unit, es2sw::ConvertSourceArgument(mState.textureUnit[unit].src0Alpha));\r
+                               device->setFirstModifierAlpha(unit, es2sw::ConvertSourceOperand(mState.textureUnit[unit].operand0Alpha));\r
+                               device->setSecondArgumentAlpha(unit, es2sw::ConvertSourceArgument(mState.textureUnit[unit].src1Alpha));\r
+                               device->setSecondModifierAlpha(unit, es2sw::ConvertSourceOperand(mState.textureUnit[unit].operand1Alpha));\r
+                               device->setThirdArgumentAlpha(unit, es2sw::ConvertSourceArgument(mState.textureUnit[unit].src2Alpha));\r
+                               device->setThirdModifierAlpha(unit, es2sw::ConvertSourceOperand(mState.textureUnit[unit].operand2Alpha));\r
+\r
+                               device->setStageOperationAlpha(unit, es2sw::ConvertCombineOperation(mState.textureUnit[unit].combineAlpha));\r
                        }\r
         }\r
         else\r
index fb49505..0fb1e98 100644 (file)
@@ -399,6 +399,46 @@ namespace es2sw
                default: UNREACHABLE();       return sw::FORMAT_A8B8G8R8;\r
                }\r
        }\r
+\r
+       sw::TextureStage::StageOperation ConvertCombineOperation(GLenum operation)\r
+       {\r
+               switch(operation)\r
+               {\r
+               case GL_REPLACE:        return sw::TextureStage::STAGE_SELECTARG1;\r
+               case GL_MODULATE:       return sw::TextureStage::STAGE_MODULATE;\r
+               case GL_ADD:            return sw::TextureStage::STAGE_ADD;\r
+               case GL_ADD_SIGNED:     return sw::TextureStage::STAGE_ADDSIGNED;\r
+               case GL_INTERPOLATE:    return sw::TextureStage::STAGE_LERP;\r
+               case GL_SUBTRACT:       return sw::TextureStage::STAGE_SUBTRACT;\r
+               case GL_DOT3_RGB:       return sw::TextureStage::STAGE_DOT3;\r
+               case GL_DOT3_RGBA:      return sw::TextureStage::STAGE_DOT3;\r
+               default: UNREACHABLE(); return sw::TextureStage::STAGE_SELECTARG1;\r
+               }\r
+       }\r
+\r
+       sw::TextureStage::SourceArgument ConvertSourceArgument(GLenum argument)\r
+       {\r
+               switch(argument)\r
+               {\r
+               case GL_TEXTURE:        return sw::TextureStage::SOURCE_TEXTURE;\r
+               case GL_CONSTANT:       return sw::TextureStage::SOURCE_CONSTANT;\r
+               case GL_PRIMARY_COLOR:  return sw::TextureStage::SOURCE_DIFFUSE;\r
+               case GL_PREVIOUS:       return sw::TextureStage::SOURCE_CURRENT;\r
+               default: UNREACHABLE(); return sw::TextureStage::SOURCE_CURRENT;\r
+               }\r
+       }\r
+\r
+       sw::TextureStage::ArgumentModifier ConvertSourceOperand(GLenum operand)\r
+       {\r
+               switch(operand)\r
+               {\r
+               case GL_SRC_COLOR:           return sw::TextureStage::MODIFIER_COLOR;\r
+               case GL_ONE_MINUS_SRC_COLOR: return sw::TextureStage::MODIFIER_INVCOLOR;\r
+               case GL_SRC_ALPHA:           return sw::TextureStage::MODIFIER_ALPHA;\r
+               case GL_ONE_MINUS_SRC_ALPHA: return sw::TextureStage::MODIFIER_INVALPHA;\r
+               default: UNREACHABLE();      return sw::TextureStage::MODIFIER_COLOR;\r
+               }\r
+       }\r
 }\r
 \r
 namespace sw2es\r
index 6d2151d..c2f7ea9 100644 (file)
@@ -55,6 +55,9 @@ namespace es2sw
        void ConvertMinFilter(GLenum texFilter, sw::FilterType *minFilter, sw::MipmapType *mipFilter, float maxAnisotropy);\r
        bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount,  es1::PrimitiveType &swPrimitiveType, int &primitiveCount);\r
        sw::Format ConvertRenderbufferFormat(GLenum format);\r
+       sw::TextureStage::StageOperation ConvertCombineOperation(GLenum operation);\r
+       sw::TextureStage::SourceArgument ConvertSourceArgument(GLenum argument);\r
+       sw::TextureStage::ArgumentModifier ConvertSourceOperand(GLenum operand);\r
 }\r
 \r
 namespace sw2es\r