Fix multi-sample state management.

Issue=160 TRAC #16817 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@681 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent d6e74da1
#define MAJOR_VERSION 0 #define MAJOR_VERSION 0
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 680 #define BUILD_REVISION 681
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -1869,6 +1869,7 @@ void Context::applyState(GLenum drawMode) ...@@ -1869,6 +1869,7 @@ void Context::applyState(GLenum drawMode)
} }
mStencilStateDirty = false; mStencilStateDirty = false;
mFrontFaceDirty = false;
} }
if (mMaskStateDirty) if (mMaskStateDirty)
...@@ -1903,48 +1904,41 @@ void Context::applyState(GLenum drawMode) ...@@ -1903,48 +1904,41 @@ void Context::applyState(GLenum drawMode)
if (mSampleStateDirty) if (mSampleStateDirty)
{ {
if (framebufferObject->isMultisample()) if (mState.sampleAlphaToCoverage)
{ {
if (mState.sampleAlphaToCoverage) FIXME("Sample alpha to coverage is unimplemented.");
{ }
FIXME("Sample alpha to coverage is unimplemented.");
}
device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE); device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
if (mState.sampleCoverage) if (mState.sampleCoverage)
{
unsigned int mask = 0;
if (mState.sampleCoverageValue != 0)
{ {
unsigned int mask = 0; float threshold = 0.5f;
if (mState.sampleCoverageValue != 0)
for (int i = 0; i < framebufferObject->getSamples(); ++i)
{ {
float threshold = 0.5f; mask <<= 1;
for (int i = 0; i < framebufferObject->getSamples(); ++i) if ((i + 1) * mState.sampleCoverageValue >= threshold)
{ {
mask <<= 1; threshold += 1.0f;
mask |= 1;
if ((i + 1) * mState.sampleCoverageValue >= threshold)
{
threshold += 1.0f;
mask |= 1;
}
} }
} }
if (mState.sampleCoverageInvert)
{
mask = ~mask;
}
device->SetRenderState(D3DRS_MULTISAMPLEMASK, mask);
} }
else
if (mState.sampleCoverageInvert)
{ {
device->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF); mask = ~mask;
} }
device->SetRenderState(D3DRS_MULTISAMPLEMASK, mask);
} }
else else
{ {
device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE); device->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
} }
mSampleStateDirty = false; mSampleStateDirty = false;
...@@ -1956,8 +1950,6 @@ void Context::applyState(GLenum drawMode) ...@@ -1956,8 +1950,6 @@ void Context::applyState(GLenum drawMode)
mDitherStateDirty = false; mDitherStateDirty = false;
} }
mFrontFaceDirty = false;
} }
GLenum Context::applyVertexBuffer(GLint first, GLsizei count) GLenum Context::applyVertexBuffer(GLint first, GLsizei count)
......
...@@ -268,23 +268,6 @@ bool Framebuffer::hasStencil() ...@@ -268,23 +268,6 @@ bool Framebuffer::hasStencil()
return false; return false;
} }
bool Framebuffer::isMultisample()
{
// If the framebuffer is not complete, attachment samples may be mismatched, and it
// cannot be used as a multisample framebuffer. If it is complete, it is required to
// have a color attachment, and all its attachments must have the same number of samples,
// so the number of samples for the colorbuffer will indicate whether the framebuffer is
// multisampled.
if (completeness() == GL_FRAMEBUFFER_COMPLETE && getColorbuffer()->getSamples() > 0)
{
return true;
}
else
{
return false;
}
}
GLenum Framebuffer::completeness() GLenum Framebuffer::completeness()
{ {
int width = 0; int width = 0;
......
...@@ -59,7 +59,6 @@ class Framebuffer ...@@ -59,7 +59,6 @@ class Framebuffer
GLuint getStencilbufferHandle(); GLuint getStencilbufferHandle();
bool hasStencil(); bool hasStencil();
bool isMultisample();
int getSamples(); int getSamples();
virtual GLenum completeness(); virtual GLenum completeness();
......
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