Commit 2afcc800 by Nicolas Capens

Implement missing state and queries.

Change-Id: I4858980fc32df435ffc0fc0917905116bea54aa8 Reviewed-on: https://swiftshader-review.googlesource.com/3790Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent d62eca33
......@@ -319,6 +319,7 @@ void Context::markAllStateDirty()
mSampleStateDirty = true;
mDitherStateDirty = true;
mFrontFaceDirty = true;
mColorLogicOperatorDirty = true;
}
void Context::setClearColor(float red, float green, float blue, float alpha)
......@@ -3630,7 +3631,11 @@ bool Context::isColorLogicOpEnabled()
void Context::setLogicalOperation(GLenum logicalOperation)
{
mState.logicalOperation = logicalOperation;
if(mState.logicalOperation != logicalOperation)
{
mState.logicalOperation = logicalOperation;
mColorLogicOperatorDirty = true;
}
}
void Context::setColorMaterialEnabled(bool enable)
......
......@@ -513,22 +513,22 @@ namespace es2sw
{
switch(logicalOperation)
{
case GL_CLEAR: return sw::LOGICALOP_CLEAR;
case GL_SET: return sw::LOGICALOP_SET;
case GL_COPY: return sw::LOGICALOP_COPY;
case GL_COPY_INVERTED: return sw::LOGICALOP_COPY_INVERTED;
case GL_NOOP: return sw::LOGICALOP_NOOP;
case GL_INVERT: return sw::LOGICALOP_INVERT;
case GL_AND: return sw::LOGICALOP_AND;
case GL_NAND: return sw::LOGICALOP_NAND;
case GL_OR: return sw::LOGICALOP_OR;
case GL_NOR: return sw::LOGICALOP_NOR;
case GL_XOR: return sw::LOGICALOP_XOR;
case GL_EQUIV: return sw::LOGICALOP_EQUIV;
case GL_AND_REVERSE: return sw::LOGICALOP_AND_REVERSE;
case GL_AND_INVERTED: return sw::LOGICALOP_AND_INVERTED;
case GL_OR_REVERSE: return sw::LOGICALOP_OR_REVERSE;
case GL_OR_INVERTED: return sw::LOGICALOP_OR_INVERTED;
case GL_CLEAR: return sw::LOGICALOP_CLEAR;
case GL_SET: return sw::LOGICALOP_SET;
case GL_COPY: return sw::LOGICALOP_COPY;
case GL_COPY_INVERTED: return sw::LOGICALOP_COPY_INVERTED;
case GL_NOOP: return sw::LOGICALOP_NOOP;
case GL_INVERT: return sw::LOGICALOP_INVERT;
case GL_AND: return sw::LOGICALOP_AND;
case GL_NAND: return sw::LOGICALOP_NAND;
case GL_OR: return sw::LOGICALOP_OR;
case GL_NOR: return sw::LOGICALOP_NOR;
case GL_XOR: return sw::LOGICALOP_XOR;
case GL_EQUIV: return sw::LOGICALOP_EQUIV;
case GL_AND_REVERSE: return sw::LOGICALOP_AND_REVERSE;
case GL_AND_INVERTED: return sw::LOGICALOP_AND_INVERTED;
case GL_OR_REVERSE: return sw::LOGICALOP_OR_REVERSE;
case GL_OR_INVERTED: return sw::LOGICALOP_OR_INVERTED;
default: UNREACHABLE(logicalOperation);
}
......
......@@ -86,6 +86,10 @@ const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;
const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;
const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f;
const float ALIASED_POINT_SIZE_RANGE_MAX = 8192.0f;
const float SMOOTH_LINE_WIDTH_RANGE_MIN = 1.0f;
const float SMOOTH_LINE_WIDTH_RANGE_MAX = 1.0f;
const float SMOOTH_POINT_SIZE_RANGE_MIN = 0.125f;
const float SMOOTH_POINT_SIZE_RANGE_MAX = 8192.0f;
const float MAX_TEXTURE_MAX_ANISOTROPY = 16.0f;
struct Color
......@@ -127,12 +131,14 @@ struct Light
Point position;
Vector direction;
Attenuation attenuation;
float spotExponent;
float spotCutoffAngle;
};
// Helper structure describing a single vertex attribute
class VertexAttribute
{
public:
public:
VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false)
{
mCurrentValue[0] = 0.0f;
......@@ -237,13 +243,12 @@ struct State
bool scissorTestEnabled;
bool ditherEnabled;
GLenum shadeModel;
bool colorLogicOpEnabled;
GLenum logicalOperation;
GLfloat lineWidth;
GLenum generateMipmapHint;
GLenum perspectiveCorrectionHint;
GLenum fogHint;
GLint viewportX;
GLint viewportY;
......@@ -332,7 +337,9 @@ public:
void setDitherEnabled(bool enabled);
bool isDitherEnabled() const;
void setLightingEnabled(bool enabled);
bool isLightingEnabled() const;
void setLightEnabled(int index, bool enable);
bool isLightEnabled(int index) const;
void setLightAmbient(int index, float r, float g, float b, float a);
void setLightDiffuse(int index, float r, float g, float b, float a);
void setLightSpecular(int index, float r, float g, float b, float a);
......@@ -341,6 +348,8 @@ public:
void setLightAttenuationConstant(int index, float constant);
void setLightAttenuationLinear(int index, float linear);
void setLightAttenuationQuadratic(int index, float quadratic);
void setSpotLightExponent(int index, float exponent);
void setSpotLightCutoff(int index, float cutoff);
void setGlobalAmbient(float red, float green, float blue, float alpha);
void setMaterialAmbient(float red, float green, float blue, float alpha);
......@@ -348,8 +357,10 @@ public:
void setMaterialSpecular(float red, float green, float blue, float alpha);
void setMaterialEmission(float red, float green, float blue, float alpha);
void setMaterialShininess(float shininess);
void setLightModelTwoSide(bool enable);
void setFogEnabled(bool enabled);
bool isFogEnabled() const;
void setFogMode(GLenum mode);
void setFogDensity(float fogDensity);
void setFogStart(float fogStart);
......@@ -357,7 +368,9 @@ public:
void setFogColor(float r, float g, float b, float a);
void setTexture2Denabled(bool enabled);
bool isTexture2Denabled() const;
void setTextureExternalEnabled(bool enabled);
bool isTextureExternalEnabled() const;
void clientActiveTexture(GLenum texture);
GLenum getClientActiveTexture() const;
unsigned int getActiveTexture() const;
......@@ -383,6 +396,7 @@ public:
void setGenerateMipmapHint(GLenum hint);
void setPerspectiveCorrectionHint(GLenum hint);
void setFogHint(GLenum hint);
void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);
......@@ -414,7 +428,7 @@ public:
void setPackAlignment(GLint alignment);
GLint getPackAlignment() const;
// These create and destroy methods are merely pass-throughs to
// These create and destroy methods are merely pass-throughs to
// ResourceManager, which owns these object types
GLuint createBuffer();
GLuint createTexture();
......@@ -461,6 +475,7 @@ public:
bool isQueryParameterInt(GLenum pname);
bool isQueryParameterFloat(GLenum pname);
bool isQueryParameterBool(GLenum pname);
bool isQueryParameterPointer(GLenum pname);
void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
void clear(GLbitfield mask);
......@@ -504,6 +519,53 @@ public:
void setClipPlaneEnabled(int index, bool enable);
bool isClipPlaneEnabled(int index) const;
void setColorLogicOpEnabled(bool enable);
bool isColorLogicOpEnabled() const;
void setLogicalOperation(GLenum logicOp);
void setPointSmoothEnabled(bool enable);
bool isPointSmoothEnabled() const;
void setLineSmoothEnabled(bool enable);
bool isLineSmoothEnabled() const;
void setColorMaterialEnabled(bool enable);
bool isColorMaterialEnabled() const;
void setNormalizeEnabled(bool enable);
bool isNormalizeEnabled() const;
void setRescaleNormalEnabled(bool enable);
bool isRescaleNormalEnabled() const;
void setVertexArrayEnabled(bool enable);
bool isVertexArrayEnabled() const;
void setNormalArrayEnabled(bool enable);
bool isNormalArrayEnabled() const;
void setColorArrayEnabled(bool enable);
bool isColorArrayEnabled() const;
void setPointSizeArrayEnabled(bool enable);
bool isPointSizeArrayEnabled() const;
void setTextureCoordArrayEnabled(bool enable);
bool isTextureCoordArrayEnabled() const;
void setMultisampleEnabled(bool enable);
bool isMultisampleEnabled() const;
void setSampleAlphaToOneEnabled(bool enable);
bool isSampleAlphaToOneEnabled() const;
void setPointSpriteEnabled(bool enable);
bool isPointSpriteEnabled() const;
void setPointSizeMin(float min);
void setPointSizeMax(float max);
void setPointDistanceAttenuation(float a, float b, float c);
void setPointFadeThresholdSize(float threshold);
private:
virtual ~Context();
......@@ -542,6 +604,7 @@ private:
Color materialSpecular;
Color materialEmission;
GLfloat materialShininess;
bool lightModelTwoSide;
// Recorded errors
bool mInvalidEnum;
......@@ -582,6 +645,30 @@ private:
GLenum alphaTestFunc;
float alphaTestRef;
bool fogEnabled;
GLenum fogMode;
float fogDensity;
float fogStart;
float fogEnd;
Color fogColor;
bool lineSmoothEnabled;
bool colorMaterialEnabled;
bool normalizeEnabled;
bool rescaleNormalEnabled;
bool multisampleEnabled;
bool sampleAlphaToOneEnabled;
bool pointSpriteEnabled;
bool pointSmoothEnabled;
float pointSizeMin;
float pointSizeMax;
Attenuation pointDistanceAttenuation;
float pointFadeThresholdSize;
bool colorLogicOpEnabled;
GLenum logicalOperation;
Device *device;
ResourceManager *mResourceManager;
};
......
......@@ -87,8 +87,6 @@ namespace es1
setDestBlendFactorAlpha(BLEND_ZERO);
setBlendOperationAlpha(BLENDOP_ADD);
setPointSpriteEnable(true);
setColorLogicOpEnabled(false);
setLogicalOperation(LOGICALOP_COPY);
for(int i = 0; i < 16; i++)
{
......
......@@ -174,7 +174,7 @@ namespace es1
switch(texFormat)
{
case GL_LUMINANCE:
case GL_RGB:
case GL_RGB:
case GL_RGB565_OES: // GL_OES_framebuffer_object
case GL_RGB8_OES: // GL_OES_rgb8_rgba8
return true;
......@@ -190,7 +190,7 @@ namespace es1
case GL_LUMINANCE_ALPHA:
case GL_RGBA:
case GL_BGRA_EXT: // GL_EXT_texture_format_BGRA8888
case GL_RGBA4_OES: // GL_OES_framebuffer_object
case GL_RGBA4_OES: // GL_OES_framebuffer_object
case GL_RGB5_A1_OES: // GL_OES_framebuffer_object
case GL_RGBA8_OES: // GL_OES_rgb8_rgba8
return true;
......@@ -297,6 +297,32 @@ namespace es2sw
return sw::BLENDOP_ADD;
}
sw::LogicalOperation ConvertLogicalOperation(GLenum logicalOperation)
{
switch(logicalOperation)
{
case GL_CLEAR: return sw::LOGICALOP_CLEAR;
case GL_SET: return sw::LOGICALOP_SET;
case GL_COPY: return sw::LOGICALOP_COPY;
case GL_COPY_INVERTED: return sw::LOGICALOP_COPY_INVERTED;
case GL_NOOP: return sw::LOGICALOP_NOOP;
case GL_INVERT: return sw::LOGICALOP_INVERT;
case GL_AND: return sw::LOGICALOP_AND;
case GL_NAND: return sw::LOGICALOP_NAND;
case GL_OR: return sw::LOGICALOP_OR;
case GL_NOR: return sw::LOGICALOP_NOR;
case GL_XOR: return sw::LOGICALOP_XOR;
case GL_EQUIV: return sw::LOGICALOP_EQUIV;
case GL_AND_REVERSE: return sw::LOGICALOP_AND_REVERSE;
case GL_AND_INVERTED: return sw::LOGICALOP_AND_INVERTED;
case GL_OR_REVERSE: return sw::LOGICALOP_OR_REVERSE;
case GL_OR_INVERTED: return sw::LOGICALOP_OR_INVERTED;
default: UNREACHABLE(logicalOperation);
}
return sw::LOGICALOP_COPY;
}
sw::StencilOperation ConvertStencilOp(GLenum stencilOp)
{
switch(stencilOp)
......
......@@ -304,7 +304,7 @@ namespace sw
sampleMask = 0xFFFFFFFF;
colorLogicOpEnabled = false;
logicalOperation = LogicalOperation::LOGICALOP_COPY;
logicalOperation = LOGICALOP_COPY;
}
const float &Context::exp2Bias()
......@@ -750,7 +750,7 @@ namespace sw
LogicalOperation Context::colorLogicOp()
{
return colorLogicOpEnabled ? logicalOperation : LogicalOperation::LOGICALOP_COPY;
return colorLogicOpEnabled ? logicalOperation : LOGICALOP_COPY;
}
BlendFactor Context::sourceBlendFactor()
......
......@@ -1285,7 +1285,7 @@ namespace sw
void PixelRoutine::logicOperation(Registers &r, int index, Pointer<Byte> &cBuffer, Vector4s &current, Int &x)
{
if(state.logicalOperation == LogicalOperation::LOGICALOP_COPY)
if(state.logicalOperation == LOGICALOP_COPY)
{
return;
}
......@@ -1303,9 +1303,9 @@ namespace sw
current.z = 0;
break;
case LOGICALOP_SET:
current.x = 0xFFFF;
current.y = 0xFFFF;
current.z = 0xFFFF;
current.x = 0xFFFFu;
current.y = 0xFFFFu;
current.z = 0xFFFFu;
break;
case LOGICALOP_COPY:
ASSERT(false); // Optimized out
......
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