Add support for multiple render targets in glClear.

TRAC #22659 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@2019 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 25aab4f9
......@@ -1892,8 +1892,7 @@ void Context::clear(GLbitfield mask)
{
mask &= ~GL_COLOR_BUFFER_BIT;
// TODO: MRT clear
if (framebufferObject->getColorbufferType(0) != GL_NONE)
if (framebufferObject->hasEnabledColorAttachment())
{
finalMask |= GL_COLOR_BUFFER_BIT;
}
......
......@@ -264,6 +264,24 @@ void Framebuffer::setDrawBufferState(unsigned int colorAttachment, GLenum drawBu
mDrawBufferStates[colorAttachment] = drawBuffer;
}
bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const
{
return (mColorbufferTypes[colorAttachment] != GL_NONE && mDrawBufferStates[colorAttachment] != GL_NONE);
}
bool Framebuffer::hasEnabledColorAttachment() const
{
for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
if (isEnabledColorAttachment(colorAttachment))
{
return true;
}
}
return false;
}
bool Framebuffer::hasStencil() const
{
if (mStencilbufferType != GL_NONE)
......
......@@ -63,6 +63,8 @@ class Framebuffer
GLenum getDrawBufferState(unsigned int colorAttachment) const;
void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
bool isEnabledColorAttachment(unsigned int colorAttachment) const;
bool hasEnabledColorAttachment() const;
bool hasStencil() const;
int getSamples() const;
......
......@@ -1468,32 +1468,37 @@ void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *
{
if (clearParams.mask & GL_COLOR_BUFFER_BIT)
{
// TODO: mrt clear
gl::Renderbuffer *renderbufferObject = frameBuffer->getColorbuffer(0);
if (renderbufferObject)
for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbufferObject->getRenderTarget());
if (!renderTarget)
{
ERR("render target pointer unexpectedly null.");
return;
}
ID3D11RenderTargetView *framebufferRTV = renderTarget->getRenderTargetView();
if (!framebufferRTV)
{
ERR("render target view pointer unexpectedly null.");
return;
}
const float clearValues[4] = { clearParams.colorClearValue.red,
clearParams.colorClearValue.green,
clearParams.colorClearValue.blue,
clearParams.colorClearValue.alpha };
mDeviceContext->ClearRenderTargetView(framebufferRTV, clearValues);
framebufferRTV->Release();
}
if (frameBuffer->isEnabledColorAttachment(colorAttachment))
{
gl::Renderbuffer *renderbufferObject = frameBuffer->getColorbuffer(colorAttachment);
if (renderbufferObject)
{
RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbufferObject->getRenderTarget());
if (!renderTarget)
{
ERR("render target pointer unexpectedly null.");
return;
}
ID3D11RenderTargetView *framebufferRTV = renderTarget->getRenderTargetView();
if (!framebufferRTV)
{
ERR("render target view pointer unexpectedly null.");
return;
}
const float clearValues[4] = { clearParams.colorClearValue.red,
clearParams.colorClearValue.green,
clearParams.colorClearValue.blue,
clearParams.colorClearValue.alpha };
mDeviceContext->ClearRenderTargetView(framebufferRTV, clearValues);
framebufferRTV->Release();
}
}
}
}
if (clearParams.mask & GL_DEPTH_BUFFER_BIT || clearParams.mask & GL_STENCIL_BUFFER_BIT)
{
......
......@@ -5,7 +5,29 @@ void VS_Clear( in float3 inPosition : POSITION, in float4 inColor : COLOR,
outColor = inColor;
}
float4 PS_Clear(in float4 inPosition : SV_POSITION, in float4 inColor : COLOR) : SV_TARGET0
// Assume we are in SM4+, which has 8 color outputs
struct PS_Output
{
return inColor;
float4 color0 : SV_TARGET0;
float4 color1 : SV_TARGET1;
float4 color2 : SV_TARGET2;
float4 color3 : SV_TARGET3;
float4 color4 : SV_TARGET4;
float4 color5 : SV_TARGET5;
float4 color6 : SV_TARGET6;
float4 color7 : SV_TARGET7;
};
PS_Output PS_Clear(in float4 inPosition : SV_POSITION, in float4 inColor : COLOR)
{
PS_Output outColor;
outColor.color0 = inColor;
outColor.color1 = inColor;
outColor.color2 = inColor;
outColor.color3 = inColor;
outColor.color4 = inColor;
outColor.color5 = inColor;
outColor.color6 = inColor;
outColor.color7 = inColor;
return outColor;
}
......@@ -20,26 +20,47 @@
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_TARGET 0 xyzw 0 TARGET float xyzw
// SV_TARGET 1 xyzw 1 TARGET float xyzw
// SV_TARGET 2 xyzw 2 TARGET float xyzw
// SV_TARGET 3 xyzw 3 TARGET float xyzw
// SV_TARGET 4 xyzw 4 TARGET float xyzw
// SV_TARGET 5 xyzw 5 TARGET float xyzw
// SV_TARGET 6 xyzw 6 TARGET float xyzw
// SV_TARGET 7 xyzw 7 TARGET float xyzw
//
ps_4_0
dcl_input_ps linear v1.xyzw
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_output o5.xyzw
dcl_output o6.xyzw
dcl_output o7.xyzw
mov o0.xyzw, v1.xyzw
mov o1.xyzw, v1.xyzw
mov o2.xyzw, v1.xyzw
mov o3.xyzw, v1.xyzw
mov o4.xyzw, v1.xyzw
mov o5.xyzw, v1.xyzw
mov o6.xyzw, v1.xyzw
mov o7.xyzw, v1.xyzw
ret
// Approximately 2 instruction slots used
// Approximately 9 instruction slots used
#endif
const BYTE g_PS_Clear[] =
{
68, 88, 66, 67, 206, 120,
117, 238, 118, 127, 10, 87,
80, 75, 114, 198, 95, 2,
120, 102, 1, 0, 0, 0,
208, 1, 0, 0, 5, 0,
68, 88, 66, 67, 146, 246,
236, 240, 50, 40, 87, 55,
73, 140, 251, 200, 8, 22,
173, 117, 1, 0, 0, 0,
88, 3, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
140, 0, 0, 0, 224, 0,
0, 0, 20, 1, 0, 0,
84, 1, 0, 0, 82, 68,
0, 0, 188, 1, 0, 0,
220, 2, 0, 0, 82, 68,
69, 70, 80, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
......@@ -69,44 +90,109 @@ const BYTE g_PS_Clear[] =
73, 84, 73, 79, 78, 0,
67, 79, 76, 79, 82, 0,
171, 171, 79, 83, 71, 78,
44, 0, 0, 0, 1, 0,
212, 0, 0, 0, 8, 0,
0, 0, 8, 0, 0, 0,
32, 0, 0, 0, 0, 0,
200, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
200, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 15, 0, 0, 0,
200, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 2, 0,
0, 0, 15, 0, 0, 0,
200, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 3, 0,
0, 0, 15, 0, 0, 0,
200, 0, 0, 0, 4, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 4, 0,
0, 0, 15, 0, 0, 0,
200, 0, 0, 0, 5, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 5, 0,
0, 0, 15, 0, 0, 0,
200, 0, 0, 0, 6, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 6, 0,
0, 0, 15, 0, 0, 0,
200, 0, 0, 0, 7, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 7, 0,
0, 0, 15, 0, 0, 0,
83, 86, 95, 84, 65, 82,
71, 69, 84, 0, 171, 171,
83, 72, 68, 82, 56, 0,
83, 72, 68, 82, 24, 1,
0, 0, 64, 0, 0, 0,
14, 0, 0, 0, 98, 16,
70, 0, 0, 0, 98, 16,
0, 3, 242, 16, 16, 0,
1, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
0, 0, 0, 0, 54, 0,
0, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
1, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
2, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
3, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
4, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
5, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
6, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
7, 0, 0, 0, 54, 0,
0, 5, 242, 32, 16, 0,
0, 0, 0, 0, 70, 30,
16, 0, 1, 0, 0, 0,
62, 0, 0, 1, 83, 84,
65, 84, 116, 0, 0, 0,
2, 0, 0, 0, 0, 0,
54, 0, 0, 5, 242, 32,
16, 0, 1, 0, 0, 0,
70, 30, 16, 0, 1, 0,
0, 0, 54, 0, 0, 5,
242, 32, 16, 0, 2, 0,
0, 0, 70, 30, 16, 0,
1, 0, 0, 0, 54, 0,
0, 5, 242, 32, 16, 0,
3, 0, 0, 0, 70, 30,
16, 0, 1, 0, 0, 0,
54, 0, 0, 5, 242, 32,
16, 0, 4, 0, 0, 0,
70, 30, 16, 0, 1, 0,
0, 0, 54, 0, 0, 5,
242, 32, 16, 0, 5, 0,
0, 0, 70, 30, 16, 0,
1, 0, 0, 0, 54, 0,
0, 5, 242, 32, 16, 0,
6, 0, 0, 0, 70, 30,
16, 0, 1, 0, 0, 0,
54, 0, 0, 5, 242, 32,
16, 0, 7, 0, 0, 0,
70, 30, 16, 0, 1, 0,
0, 0, 62, 0, 0, 1,
83, 84, 65, 84, 116, 0,
0, 0, 9, 0, 0, 0,
0, 0, 0, 0, 0, 0,
2, 0, 0, 0, 0, 0,
0, 0, 9, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0
0, 0, 0, 0
};
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