Implements multisample fragment operations

TRAC #12711 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/trunk@391 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 1f135d86
...@@ -1806,7 +1806,7 @@ void Context::applyState(GLenum drawMode) ...@@ -1806,7 +1806,7 @@ void Context::applyState(GLenum drawMode)
mPolygonOffsetStateDirty = false; mPolygonOffsetStateDirty = false;
} }
if (mConfig->mMultiSample != 0 && mSampleStateDirty) if (framebufferObject->isMultisample() && mSampleStateDirty)
{ {
if (mState.sampleAlphaToCoverage) if (mState.sampleAlphaToCoverage)
{ {
...@@ -1815,7 +1815,34 @@ void Context::applyState(GLenum drawMode) ...@@ -1815,7 +1815,34 @@ void Context::applyState(GLenum drawMode)
if (mState.sampleCoverage) if (mState.sampleCoverage)
{ {
FIXME("Sample coverage is unimplemented."); device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
unsigned int mask = 0;
if (mState.sampleCoverageValue != 0)
{
float threshold = 0.5f;
for (int i = 0; i < framebufferObject->getSamples(); ++i)
{
mask <<= 1;
if ((i + 1) * mState.sampleCoverageValue >= threshold)
{
threshold += 1.0f;
mask |= 1;
}
}
}
if (mState.sampleCoverageInvert)
{
mask = ~mask;
}
device->SetRenderState(D3DRS_MULTISAMPLEMASK, mask);
}
else
{
device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);
} }
mSampleStateDirty = false; mSampleStateDirty = false;
...@@ -2929,6 +2956,7 @@ void Context::initExtensionString() ...@@ -2929,6 +2956,7 @@ void Context::initExtensionString()
mExtensionString += "GL_EXT_read_format_bgra "; mExtensionString += "GL_EXT_read_format_bgra ";
mExtensionString += "GL_ANGLE_framebuffer_blit "; mExtensionString += "GL_ANGLE_framebuffer_blit ";
if (getMaxSupportedSamples() == 0) if (getMaxSupportedSamples() == 0)
{ {
mExtensionString += "GL_ANGLE_framebuffer_multisample "; mExtensionString += "GL_ANGLE_framebuffer_multisample ";
......
...@@ -268,6 +268,23 @@ bool Framebuffer::hasStencil() ...@@ -268,6 +268,23 @@ 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,6 +59,7 @@ class Framebuffer ...@@ -59,6 +59,7 @@ 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