Commit 53a94a82 by Shannon Woods

Refactors State to be a fully-qualified class

BUG=angle:685 Change-Id: I36cff2da985a12c7180fe2850ccd471f4cebbaad Reviewed-on: https://chromium-review.googlesource.com/206634Tested-by: 's avatarShannon Woods <shannonwoods@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 1da3cf63
......@@ -335,6 +335,8 @@ if (is_win) {
"src/libGLESv2/Sampler.h",
"src/libGLESv2/Shader.cpp",
"src/libGLESv2/Shader.h",
"src/libGLESv2/State.cpp",
"src/libGLESv2/State.h",
"src/libGLESv2/Texture.cpp",
"src/libGLESv2/Texture.h",
"src/libGLESv2/TransformFeedback.cpp",
......
......@@ -141,7 +141,6 @@
<ClInclude Include="..\..\src\libGLESv2\ProgramBinary.h"/>
<ClInclude Include="..\..\src\libGLESv2\constants.h"/>
<ClInclude Include="..\..\src\libGLESv2\FramebufferAttachment.h"/>
<ClInclude Include="..\..\src\libGLESv2\Buffer.h"/>
<ClInclude Include="..\..\src\libGLESv2\Renderbuffer.h"/>
<ClInclude Include="..\..\src\libGLESv2\queryconversions.h"/>
<ClInclude Include="..\..\src\libGLESv2\validationES3.h"/>
......@@ -156,6 +155,8 @@
<ClInclude Include="..\..\src\libGLESv2\main.h"/>
<ClInclude Include="..\..\src\libGLESv2\Framebuffer.h"/>
<ClInclude Include="..\..\src\libGLESv2\formatutils.h"/>
<ClInclude Include="..\..\src\libGLESv2\Buffer.h"/>
<ClInclude Include="..\..\src\libGLESv2\State.h"/>
<ClInclude Include="..\..\src\libGLESv2\validationES.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\Renderer.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\ShaderExecutable.h"/>
......@@ -318,6 +319,7 @@
<ClCompile Include="..\..\src\libGLESv2\Query.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\TransformFeedback.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\libGLESv2.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\State.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\ProgramBinary.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\VertexAttribute.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\Context.cpp"/>
......
......@@ -165,9 +165,9 @@
<ClCompile Include="..\..\src\libGLESv2\libGLESv2.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\Buffer.h">
<ClCompile Include="..\..\src\libGLESv2\State.cpp">
<Filter>src\libGLESv2</Filter>
</ClInclude>
</ClCompile>
<ClCompile Include="..\..\src\libGLESv2\ProgramBinary.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
......@@ -243,6 +243,12 @@
<ClCompile Include="..\..\src\libGLESv2\Caps.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\Buffer.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClInclude Include="..\..\src\libGLESv2\State.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\Framebuffer.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
......
......@@ -26,6 +26,7 @@
#include "libGLESv2/angletypes.h"
#include "libGLESv2/Constants.h"
#include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/State.h"
namespace rx
{
......@@ -64,66 +65,6 @@ class VertexArray;
class Sampler;
class TransformFeedback;
// Helper structure to store all raw state
struct State
{
ColorF colorClearValue;
GLclampf depthClearValue;
int stencilClearValue;
RasterizerState rasterizer;
bool scissorTest;
Rectangle scissor;
BlendState blend;
ColorF blendColor;
bool sampleCoverage;
GLclampf sampleCoverageValue;
bool sampleCoverageInvert;
DepthStencilState depthStencil;
GLint stencilRef;
GLint stencilBackRef;
GLfloat lineWidth;
GLenum generateMipmapHint;
GLenum fragmentShaderDerivativeHint;
Rectangle viewport;
float zNear;
float zFar;
unsigned int activeSampler; // Active texture unit selector - GL_TEXTURE0
BindingPointer<Buffer> arrayBuffer;
Framebuffer *drawFramebuffer;
Framebuffer *readFramebuffer;
BindingPointer<Renderbuffer> renderbuffer;
GLuint currentProgram;
VertexAttribCurrentValueData vertexAttribCurrentValues[MAX_VERTEX_ATTRIBS]; // From glVertexAttrib
VertexArray *vertexArray;
BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
GLuint samplers[IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS];
typedef std::map< GLenum, BindingPointer<Query> > ActiveQueryMap;
ActiveQueryMap activeQueries;
BindingPointer<Buffer> genericUniformBuffer;
OffsetBindingPointer<Buffer> uniformBuffers[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS];
BindingPointer<TransformFeedback> transformFeedback;
BindingPointer<Buffer> genericTransformFeedbackBuffer;
OffsetBindingPointer<Buffer> transformFeedbackBuffers[IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
BindingPointer<Buffer> copyReadBuffer;
BindingPointer<Buffer> copyWriteBuffer;
PixelUnpackState unpack;
PixelPackState pack;
};
class Context
{
public:
......@@ -136,118 +77,6 @@ class Context
virtual void markContextLost();
bool isContextLost();
// State manipulation
void setCap(GLenum cap, bool enabled);
bool getCap(GLenum cap);
void setClearColor(float red, float green, float blue, float alpha);
void setClearDepth(float depth);
void setClearStencil(int stencil);
void setRasterizerDiscard(bool enabled);
bool isRasterizerDiscardEnabled() const;
void setCullFace(bool enabled);
bool isCullFaceEnabled() const;
void setCullMode(GLenum mode);
void setFrontFace(GLenum front);
void setDepthTest(bool enabled);
bool isDepthTestEnabled() const;
void setDepthFunc(GLenum depthFunc);
void setDepthRange(float zNear, float zFar);
void setBlend(bool enabled);
bool isBlendEnabled() const;
void setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha);
void setBlendColor(float red, float green, float blue, float alpha);
void setBlendEquation(GLenum rgbEquation, GLenum alphaEquation);
void setStencilTest(bool enabled);
bool isStencilTestEnabled() const;
void setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask);
void setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask);
void setStencilWritemask(GLuint stencilWritemask);
void setStencilBackWritemask(GLuint stencilBackWritemask);
void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass);
void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass);
const gl::DepthStencilState &getDepthStencilState() const;
GLint getStencilRef() const;
GLint getStencilBackRef() const;
void setPolygonOffsetFill(bool enabled);
bool isPolygonOffsetFillEnabled() const;
void setPolygonOffsetParams(GLfloat factor, GLfloat units);
void setSampleAlphaToCoverage(bool enabled);
bool isSampleAlphaToCoverageEnabled() const;
void setSampleCoverage(bool enabled);
bool isSampleCoverageEnabled() const;
void setSampleCoverageParams(GLclampf value, bool invert);
void setScissorTest(bool enabled);
bool isScissorTestEnabled() const;
void setDither(bool enabled);
bool isDitherEnabled() const;
void setLineWidth(GLfloat width);
void setGenerateMipmapHint(GLenum hint);
void setFragmentShaderDerivativeHint(GLenum hint);
void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);
void setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height);
void getScissorParams(GLint *x, GLint *y, GLsizei *width, GLsizei *height);
void setColorMask(bool red, bool green, bool blue, bool alpha);
void setDepthMask(bool mask);
void setActiveSampler(unsigned int active);
GLuint getReadFramebufferHandle() const;
GLuint getDrawFramebufferHandle() const;
GLuint getRenderbufferHandle() const;
GLuint getVertexArrayHandle() const;
GLuint getSamplerHandle(GLuint textureUnit) const;
unsigned int getActiveSampler() const;
GLuint getArrayBufferHandle() const;
bool isQueryActive() const;
const Query *getActiveQuery(GLenum target) const;
GLuint getActiveQueryId(GLenum target) const;
void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);
const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
const VertexAttribCurrentValueData &getVertexAttribCurrentValue(unsigned int attribNum) const;
void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
const void *getVertexAttribPointer(unsigned int attribNum) const;
void setUnpackAlignment(GLint alignment);
GLint getUnpackAlignment() const;
const PixelUnpackState &getUnpackState() const;
void setPackAlignment(GLint alignment);
GLint getPackAlignment() const;
const PixelPackState &getPackState() const;
void setPackReverseRowOrder(bool reverseRowOrder);
bool getPackReverseRowOrder() const;
// These create and destroy methods are merely pass-throughs to
// ResourceManager, which owns these object types
GLuint createBuffer();
......@@ -306,7 +135,6 @@ class Context
void useProgram(GLuint program);
void linkProgram(GLuint program);
void setProgramBinary(GLuint program, const void *binary, GLint length);
GLuint getCurrentProgram() const;
void bindTransformFeedback(GLuint transformFeedback);
void beginQuery(GLenum target, GLuint query);
......@@ -316,9 +144,6 @@ class Context
void setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples);
void setVertexAttribf(GLuint index, const GLfloat values[4]);
void setVertexAttribu(GLuint index, const GLuint values[4]);
void setVertexAttribi(GLuint index, const GLint values[4]);
void setVertexAttribDivisor(GLuint index, GLuint divisor);
void samplerParameteri(GLuint sampler, GLenum pname, GLint param);
......@@ -339,33 +164,14 @@ class Context
Query *getQuery(GLuint handle, bool create, GLenum type);
TransformFeedback *getTransformFeedback(GLuint handle) const;
Buffer *getTargetBuffer(GLenum target) const;
Buffer *getArrayBuffer();
Buffer *getElementArrayBuffer() const;
ProgramBinary *getCurrentProgramBinary() const;
Texture *getTargetTexture(GLenum target) const;
Texture2D *getTexture2D() const;
TextureCubeMap *getTextureCubeMap() const;
Texture3D *getTexture3D() const;
Texture2DArray *getTexture2DArray() const;
Buffer *getGenericUniformBuffer();
Buffer *getGenericTransformFeedbackBuffer();
Buffer *getCopyReadBuffer();
Buffer *getCopyWriteBuffer();
Buffer *getPixelPackBuffer();
Buffer *getPixelUnpackBuffer();
Texture *getSamplerTexture(unsigned int sampler, TextureType type) const;
Framebuffer *getTargetFramebuffer(GLenum target) const;
GLuint getTargetFramebufferHandle(GLenum target) const;
Framebuffer *getReadFramebuffer() const;
Framebuffer *getDrawFramebuffer();
const Framebuffer *getDrawFramebuffer() const;
VertexArray *getCurrentVertexArray() const;
TransformFeedback *getCurrentTransformFeedback() const;
bool isSampler(GLuint samplerName) const;
void getBooleanv(GLenum pname, GLboolean *params);
......@@ -433,6 +239,9 @@ class Context
rx::Renderer *getRenderer() { return mRenderer; }
State &getState() { return mState; }
const State &getState() const { return mState; }
private:
DISALLOW_COPY_AND_ASSIGN(Context);
......@@ -475,11 +284,10 @@ class Context
Extensions mExtensions;
rx::Renderer *const mRenderer;
State mState;
int mClientVersion;
State mState;
BindingPointer<Texture2D> mTexture2DZero;
BindingPointer<TextureCubeMap> mTextureCubeMapZero;
BindingPointer<Texture3D> mTexture3DZero;
......@@ -526,8 +334,6 @@ class Context
GLenum mResetStrategy;
bool mRobustAccess;
BindingPointer<ProgramBinary> mCurrentProgramBinary;
int mMajorShaderModel;
bool mSupportsVertexTexture;
int mNumCompressedTextureFormats;
......
......@@ -16,6 +16,7 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/Constants.h"
#include "libGLESv2/ProgramBinary.h"
namespace rx
{
......@@ -27,7 +28,6 @@ namespace gl
class ResourceManager;
class FragmentShader;
class VertexShader;
class ProgramBinary;
class Shader;
extern const char * const g_fakepath;
......
......@@ -124,7 +124,7 @@ class Renderer
bool rasterizerDiscard, bool transformFeedbackActive) = 0;
virtual void applyUniforms(const gl::ProgramBinary &programBinary) = 0;
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0;
virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances) = 0;
virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) = 0;
virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]) = 0;
......
......@@ -939,7 +939,7 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
return true;
}
GLenum Renderer11::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
GLenum Renderer11::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances)
{
TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS];
......
......@@ -80,7 +80,7 @@ class Renderer11 : public Renderer
virtual void applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive);
virtual void applyUniforms(const gl::ProgramBinary &programBinary);
virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances);
virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]);
......
......@@ -1268,7 +1268,7 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer)
return true;
}
GLenum Renderer9::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
GLenum Renderer9::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances)
{
TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS];
......
......@@ -80,7 +80,7 @@ class Renderer9 : public Renderer
bool rasterizerDiscard, bool transformFeedbackActive);
virtual void applyUniforms(const gl::ProgramBinary &programBinary);
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount);
virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances);
virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
......
......@@ -473,7 +473,7 @@ bool ValidateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLin
return false;
}
gl::Framebuffer *framebuffer = context->getReadFramebuffer();
gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
GLenum textureFormat = gl::GetFormat(textureInternalFormat);
......
......@@ -254,7 +254,7 @@ bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint le
}
// Check for pixel unpack buffer related API errors
gl::Buffer *pixelUnpackBuffer = context->getPixelUnpackBuffer();
gl::Buffer *pixelUnpackBuffer = context->getState().getTargetBuffer(GL_PIXEL_UNPACK_BUFFER);
if (pixelUnpackBuffer != NULL)
{
// ...the data would be unpacked from the buffer object such that the memory reads required
......@@ -316,14 +316,14 @@ bool ValidateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
return false;
}
gl::Framebuffer *framebuffer = context->getReadFramebuffer();
gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
}
if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
if (context->getState().getReadFramebuffer()->id() != 0 && framebuffer->getSamples() != 0)
{
return gl::error(GL_INVALID_OPERATION, false);
}
......@@ -334,7 +334,7 @@ bool ValidateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
if (isSubImage)
{
if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat,
context->getReadFramebufferHandle(),
context->getState().getReadFramebuffer()->id(),
context->getClientVersion()))
{
return gl::error(GL_INVALID_OPERATION, false);
......@@ -343,7 +343,7 @@ bool ValidateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLin
else
{
if (!gl::IsValidCopyTexImageCombination(internalformat, colorbufferInternalFormat,
context->getReadFramebufferHandle(),
context->getState().getReadFramebuffer()->id(),
context->getClientVersion()))
{
return gl::error(GL_INVALID_OPERATION, false);
......@@ -611,10 +611,10 @@ bool ValidateInvalidateFramebufferParameters(gl::Context *context, GLenum target
{
case GL_DRAW_FRAMEBUFFER:
case GL_FRAMEBUFFER:
defaultFramebuffer = context->getDrawFramebufferHandle() == 0;
defaultFramebuffer = context->getState().getDrawFramebuffer()->id() == 0;
break;
case GL_READ_FRAMEBUFFER:
defaultFramebuffer = context->getReadFramebufferHandle() == 0;
defaultFramebuffer = context->getState().getReadFramebuffer()->id() == 0;
break;
default:
return gl::error(GL_INVALID_ENUM, false);
......@@ -670,7 +670,7 @@ bool ValidateClearBuffer(const gl::Context *context)
return gl::error(GL_INVALID_OPERATION, false);
}
const gl::Framebuffer *fbo = context->getDrawFramebuffer();
const gl::Framebuffer *fbo = context->getState().getDrawFramebuffer();
if (!fbo || fbo->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
......
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