Skip drawing points when gl_PointSize isn't written.

Trac #21574 Bug=365 Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/trunk@1277 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 6bc4a146
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1275 #define BUILD_REVISION 1277
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -3051,7 +3051,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan ...@@ -3051,7 +3051,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if (!cullSkipsDraw(mode)) if (!skipDraw(mode))
{ {
mDisplay->startScene(); mDisplay->startScene();
...@@ -3141,7 +3141,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid ...@@ -3141,7 +3141,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if (!cullSkipsDraw(mode)) if (!skipDraw(mode))
{ {
mDisplay->startScene(); mDisplay->startScene();
...@@ -3733,9 +3733,31 @@ Texture *Context::getIncompleteTexture(TextureType type) ...@@ -3733,9 +3733,31 @@ Texture *Context::getIncompleteTexture(TextureType type)
return t; return t;
} }
bool Context::cullSkipsDraw(GLenum drawMode) bool Context::skipDraw(GLenum drawMode)
{ {
return mState.cullFace && mState.cullMode == GL_FRONT_AND_BACK && isTriangleMode(drawMode); if (drawMode == GL_POINTS)
{
// ProgramBinary assumes non-point rendering if gl_PointSize isn't written,
// which affects varying interpolation. Since the value of gl_PointSize is
// undefined when not written, just skip drawing to avoid unexpected results.
if (!getCurrentProgramBinary()->usesPointSize())
{
// This is stictly speaking not an error, but developers should be
// notified of risking undefined behavior.
ERR("Point rendering without writing to gl_PointSize.");
return true;
}
}
else if (isTriangleMode(drawMode))
{
if (mState.cullFace && mState.cullMode == GL_FRONT_AND_BACK)
{
return true;
}
}
return false;
} }
bool Context::isTriangleMode(GLenum drawMode) bool Context::isTriangleMode(GLenum drawMode)
......
...@@ -538,7 +538,7 @@ class Context ...@@ -538,7 +538,7 @@ class Context
Texture *getIncompleteTexture(TextureType type); Texture *getIncompleteTexture(TextureType type);
bool cullSkipsDraw(GLenum drawMode); bool skipDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode); bool isTriangleMode(GLenum drawMode);
void initExtensionString(); void initExtensionString();
......
...@@ -176,6 +176,11 @@ GLint ProgramBinary::getUsedSamplerRange(SamplerType type) ...@@ -176,6 +176,11 @@ GLint ProgramBinary::getUsedSamplerRange(SamplerType type)
} }
} }
bool ProgramBinary::usesPointSize() const
{
return mUsesPointSize;
}
// Returns the index of the texture image unit (0-19) corresponding to a Direct3D 9 sampler // Returns the index of the texture image unit (0-19) corresponding to a Direct3D 9 sampler
// index (0-15 for the pixel shader and 0-3 for the vertex shader). // index (0-15 for the pixel shader and 0-3 for the vertex shader).
GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerIndex) GLint ProgramBinary::getSamplerMapping(SamplerType type, unsigned int samplerIndex)
...@@ -1319,7 +1324,8 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std:: ...@@ -1319,7 +1324,8 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std::
} }
} }
std::string varyingSemantic = (vertexShader->mUsesPointSize && sm3 ? "COLOR" : "TEXCOORD"); mUsesPointSize = vertexShader->mUsesPointSize;
std::string varyingSemantic = (mUsesPointSize && sm3) ? "COLOR" : "TEXCOORD";
vertexHLSL += "struct VS_INPUT\n" vertexHLSL += "struct VS_INPUT\n"
"{\n"; "{\n";
......
...@@ -110,6 +110,7 @@ class ProgramBinary : public RefCountObject ...@@ -110,6 +110,7 @@ class ProgramBinary : public RefCountObject
GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex); GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex);
TextureType getSamplerTextureType(SamplerType type, unsigned int samplerIndex); TextureType getSamplerTextureType(SamplerType type, unsigned int samplerIndex);
GLint getUsedSamplerRange(SamplerType type); GLint getUsedSamplerRange(SamplerType type);
bool usesPointSize() const;
GLint getUniformLocation(std::string name); GLint getUniformLocation(std::string name);
bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v); bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
...@@ -208,6 +209,7 @@ class ProgramBinary : public RefCountObject ...@@ -208,6 +209,7 @@ class ProgramBinary : public RefCountObject
Sampler mSamplersVS[MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF]; Sampler mSamplersVS[MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF];
GLuint mUsedVertexSamplerRange; GLuint mUsedVertexSamplerRange;
GLuint mUsedPixelSamplerRange; GLuint mUsedPixelSamplerRange;
bool mUsesPointSize;
typedef std::vector<Uniform*> UniformArray; typedef std::vector<Uniform*> UniformArray;
UniformArray mUniforms; UniformArray mUniforms;
......
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