Commit f6c1d96d by Nicolas Capens

Implement texture environment src, operand, and color.

Change-Id: I8c683a783f0a7f8a82206de77ae9d139f4b1bb10 Reviewed-on: https://swiftshader-review.googlesource.com/3762Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent d15c3ea9
...@@ -111,6 +111,7 @@ Context::Context(const egl::Config *config, const Context *shareContext) ...@@ -111,6 +111,7 @@ Context::Context(const egl::Config *config, const Context *shareContext)
for(int i = 0; i < MAX_TEXTURE_UNITS; i++) for(int i = 0; i < MAX_TEXTURE_UNITS; i++)
{ {
mState.textureUnit[i].color = {0, 0, 0, 0};
mState.textureUnit[i].environmentMode = GL_MODULATE; mState.textureUnit[i].environmentMode = GL_MODULATE;
mState.textureUnit[i].combineRGB = GL_MODULATE; mState.textureUnit[i].combineRGB = GL_MODULATE;
mState.textureUnit[i].combineAlpha = GL_MODULATE; mState.textureUnit[i].combineAlpha = GL_MODULATE;
...@@ -1938,6 +1939,8 @@ void Context::applyTextures() ...@@ -1938,6 +1939,8 @@ void Context::applyTextures()
applyTexture(unit, texture); applyTexture(unit, texture);
device->setConstantColor(unit, sw::Color<float>(mState.textureUnit[unit].color.red, mState.textureUnit[unit].color.green, mState.textureUnit[unit].color.blue, mState.textureUnit[unit].color.alpha));
if(mState.textureUnit[unit].environmentMode != GL_COMBINE) if(mState.textureUnit[unit].environmentMode != GL_COMBINE)
{ {
device->setFirstArgument(unit, sw::TextureStage::SOURCE_TEXTURE); // Cs device->setFirstArgument(unit, sw::TextureStage::SOURCE_TEXTURE); // Cs
...@@ -2110,6 +2113,11 @@ void Context::setTextureEnvMode(GLenum texEnvMode) ...@@ -2110,6 +2113,11 @@ void Context::setTextureEnvMode(GLenum texEnvMode)
mState.textureUnit[mState.activeSampler].environmentMode = texEnvMode; mState.textureUnit[mState.activeSampler].environmentMode = texEnvMode;
} }
void Context::setTextureEnvColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{
mState.textureUnit[mState.activeSampler].color = {red, green, blue, alpha};
}
void Context::setCombineRGB(GLenum combineRGB) void Context::setCombineRGB(GLenum combineRGB)
{ {
mState.textureUnit[mState.activeSampler].combineRGB = combineRGB; mState.textureUnit[mState.activeSampler].combineRGB = combineRGB;
...@@ -2120,6 +2128,66 @@ void Context::setCombineAlpha(GLenum combineAlpha) ...@@ -2120,6 +2128,66 @@ void Context::setCombineAlpha(GLenum combineAlpha)
mState.textureUnit[mState.activeSampler].combineAlpha = combineAlpha; mState.textureUnit[mState.activeSampler].combineAlpha = combineAlpha;
} }
void Context::setOperand0RGB(GLenum operand)
{
mState.textureUnit[mState.activeSampler].operand0RGB = operand;
}
void Context::setOperand1RGB(GLenum operand)
{
mState.textureUnit[mState.activeSampler].operand1RGB = operand;
}
void Context::setOperand2RGB(GLenum operand)
{
mState.textureUnit[mState.activeSampler].operand2RGB = operand;
}
void Context::setOperand0Alpha(GLenum operand)
{
mState.textureUnit[mState.activeSampler].operand0Alpha = operand;
}
void Context::setOperand1Alpha(GLenum operand)
{
mState.textureUnit[mState.activeSampler].operand1Alpha = operand;
}
void Context::setOperand2Alpha(GLenum operand)
{
mState.textureUnit[mState.activeSampler].operand2Alpha = operand;
}
void Context::setSrc0RGB(GLenum src)
{
mState.textureUnit[mState.activeSampler].src0RGB = src;
}
void Context::setSrc1RGB(GLenum src)
{
mState.textureUnit[mState.activeSampler].src1RGB = src;
}
void Context::setSrc2RGB(GLenum src)
{
mState.textureUnit[mState.activeSampler].src2RGB = src;
}
void Context::setSrc0Alpha(GLenum src)
{
mState.textureUnit[mState.activeSampler].src0Alpha = src;
}
void Context::setSrc1Alpha(GLenum src)
{
mState.textureUnit[mState.activeSampler].src1Alpha = src;
}
void Context::setSrc2Alpha(GLenum src)
{
mState.textureUnit[mState.activeSampler].src2Alpha = src;
}
void Context::applyTexture(int index, Texture *baseTexture) void Context::applyTexture(int index, Texture *baseTexture)
{ {
sw::Resource *resource = 0; sw::Resource *resource = 0;
......
...@@ -182,6 +182,7 @@ typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS]; ...@@ -182,6 +182,7 @@ typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS];
struct TextureUnit struct TextureUnit
{ {
Color color;
GLenum environmentMode; GLenum environmentMode;
GLenum combineRGB; GLenum combineRGB;
GLenum combineAlpha; GLenum combineAlpha;
...@@ -362,8 +363,21 @@ public: ...@@ -362,8 +363,21 @@ public:
unsigned int getActiveTexture() const; unsigned int getActiveTexture() const;
void setTextureEnvMode(GLenum texEnvMode); void setTextureEnvMode(GLenum texEnvMode);
void setTextureEnvColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void setCombineRGB(GLenum combineRGB); void setCombineRGB(GLenum combineRGB);
void setCombineAlpha(GLenum combineAlpha); void setCombineAlpha(GLenum combineAlpha);
void setOperand0RGB(GLenum operand);
void setOperand1RGB(GLenum operand);
void setOperand2RGB(GLenum operand);
void setOperand0Alpha(GLenum operand);
void setOperand1Alpha(GLenum operand);
void setOperand2Alpha(GLenum operand);
void setSrc0RGB(GLenum src);
void setSrc1RGB(GLenum src);
void setSrc2RGB(GLenum src);
void setSrc0Alpha(GLenum src);
void setSrc1Alpha(GLenum src);
void setSrc2Alpha(GLenum src);
void setLineWidth(GLfloat width); void setLineWidth(GLfloat width);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment