Refactored the ClearParameters type and moved Renderer11's clear logic into a Clear11 helper class.
TRAC #23475
Author: Geoff Lang
Signed-off-by: Jamie Madill
Signed-off-by: Shannon Woods
diff --git a/src/build_angle.gypi b/src/build_angle.gypi
index 57c8d69..012a6a9 100644
--- a/src/build_angle.gypi
+++ b/src/build_angle.gypi
@@ -291,6 +291,8 @@
'libGLESv2/renderer/BufferStorage9.h',
'libGLESv2/renderer/BufferStorage11.cpp',
'libGLESv2/renderer/BufferStorage11.h',
+ 'libGLESv2/renderer/Clear11.cpp',
+ 'libGLESv2/renderer/Clear11.h',
'libGLESv2/renderer/FenceImpl.h',
'libGLESv2/renderer/Fence9.cpp',
'libGLESv2/renderer/Fence9.h',
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 31e75bd..69d2b23 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -2466,8 +2466,25 @@
return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
}
- DWORD flags = 0;
- GLbitfield finalMask = 0;
+ ClearParameters clearParams = { 0 };
+
+ for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
+ {
+ clearParams.clearColor[i] = false;
+ }
+ clearParams.colorFClearValue = mState.colorClearValue;
+ clearParams.colorClearType = GL_FLOAT;
+ clearParams.colorMaskRed = mState.blend.colorMaskRed;
+ clearParams.colorMaskGreen = mState.blend.colorMaskGreen;
+ clearParams.colorMaskBlue = mState.blend.colorMaskBlue;
+ clearParams.colorMaskAlpha = mState.blend.colorMaskAlpha;
+ clearParams.clearDepth = false;
+ clearParams.depthClearValue = mState.depthClearValue;
+ clearParams.clearStencil = false;
+ clearParams.stencilClearValue = mState.stencilClearValue;
+ clearParams.stencilWriteMask = mState.depthStencil.stencilWritemask;
+ clearParams.scissorEnabled = mState.scissorTest;
+ clearParams.scissor = mState.scissor;
if (mask & GL_COLOR_BUFFER_BIT)
{
@@ -2475,7 +2492,10 @@
if (framebufferObject->hasEnabledColorAttachment())
{
- finalMask |= GL_COLOR_BUFFER_BIT;
+ for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
+ {
+ clearParams.clearColor[i] = true;
+ }
}
}
@@ -2484,7 +2504,7 @@
mask &= ~GL_DEPTH_BUFFER_BIT;
if (mState.depthStencil.depthMask && framebufferObject->getDepthbufferType() != GL_NONE)
{
- finalMask |= GL_DEPTH_BUFFER_BIT;
+ clearParams.clearDepth = true;
}
}
@@ -2502,7 +2522,7 @@
if (gl::GetStencilBits(depthStencil->getActualFormat(), mClientVersion) > 0)
{
- finalMask |= GL_STENCIL_BUFFER_BIT;
+ clearParams.clearStencil = true;
}
}
}
@@ -2517,17 +2537,6 @@
return;
}
- ClearParameters clearParams;
- clearParams.mask = finalMask;
- clearParams.colorClearValue = mState.colorClearValue;
- clearParams.colorMaskRed = mState.blend.colorMaskRed;
- clearParams.colorMaskGreen = mState.blend.colorMaskGreen;
- clearParams.colorMaskBlue = mState.blend.colorMaskBlue;
- clearParams.colorMaskAlpha = mState.blend.colorMaskAlpha;
- clearParams.depthClearValue = mState.depthClearValue;
- clearParams.stencilClearValue = mState.stencilClearValue;
- clearParams.stencilWriteMask = mState.depthStencil.stencilWritemask;
-
mRenderer->clear(clearParams, framebufferObject);
}
diff --git a/src/libGLESv2/angletypes.h b/src/libGLESv2/angletypes.h
index 4bbad24..c377f4e 100644
--- a/src/libGLESv2/angletypes.h
+++ b/src/libGLESv2/angletypes.h
@@ -9,6 +9,8 @@
#ifndef LIBGLESV2_ANGLETYPES_H_
#define LIBGLESV2_ANGLETYPES_H_
+#include "libGLESv2/constants.h"
+
namespace gl
{
@@ -150,18 +152,25 @@
struct ClearParameters
{
- GLbitfield mask;
-
- ColorF colorClearValue;
+ bool clearColor[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS];
+ ColorF colorFClearValue;
+ ColorI colorIClearValue;
+ ColorUI colorUIClearValue;
+ GLenum colorClearType;
bool colorMaskRed;
bool colorMaskGreen;
bool colorMaskBlue;
bool colorMaskAlpha;
+ bool clearDepth;
float depthClearValue;
+ bool clearStencil;
GLint stencilClearValue;
GLuint stencilWriteMask;
+
+ bool scissorEnabled;
+ Rectangle scissor;
};
}
diff --git a/src/libGLESv2/libGLESv2.vcxproj b/src/libGLESv2/libGLESv2.vcxproj
index ca2e145..366824b 100644
--- a/src/libGLESv2/libGLESv2.vcxproj
+++ b/src/libGLESv2/libGLESv2.vcxproj
@@ -270,6 +270,7 @@
<ClCompile Include="RenderbufferProxySet.cpp" />
<ClCompile Include="renderer\Blit11.cpp" />
<ClCompile Include="renderer\Blit9.cpp" />
+ <ClCompile Include="renderer\Clear11.cpp" />
<ClCompile Include="renderer\copyimage.cpp" />
<ClCompile Include="renderer\Fence11.cpp" />
<ClCompile Include="renderer\Fence9.cpp" />
@@ -353,6 +354,7 @@
<ClInclude Include="RenderbufferProxySet.h" />
<ClInclude Include="renderer\Blit11.h" />
<ClInclude Include="renderer\Blit9.h" />
+ <ClInclude Include="renderer\Clear11.h" />
<ClInclude Include="renderer\copyimage.h" />
<ClInclude Include="renderer\Fence11.h" />
<ClInclude Include="renderer\Fence9.h" />
@@ -390,9 +392,12 @@
<ClInclude Include="renderer\ShaderExecutable.h" />
<ClInclude Include="renderer\ShaderExecutable11.h" />
<ClInclude Include="renderer\ShaderExecutable9.h" />
- <ClInclude Include="renderer\shaders\compiled\clear11vs.h" />
- <ClInclude Include="renderer\shaders\compiled\clearmultiple11ps.h" />
- <ClInclude Include="renderer\shaders\compiled\clearsingle11ps.h" />
+ <ClInclude Include="renderer\shaders\compiled\clearfloat11ps.h" />
+ <ClInclude Include="renderer\shaders\compiled\clearfloat11vs.h" />
+ <ClInclude Include="renderer\shaders\compiled\clearsint11ps.h" />
+ <ClInclude Include="renderer\shaders\compiled\clearsint11vs.h" />
+ <ClInclude Include="renderer\shaders\compiled\clearuint11ps.h" />
+ <ClInclude Include="renderer\shaders\compiled\clearuint11vs.h" />
<ClInclude Include="renderer\shaders\compiled\componentmaskps.h" />
<ClInclude Include="renderer\shaders\compiled\flipyvs.h" />
<ClInclude Include="renderer\shaders\compiled\luminanceps.h" />
@@ -405,6 +410,7 @@
<ClInclude Include="renderer\shaders\compiled\passthroughlumalpha2d11ps.h" />
<ClInclude Include="renderer\shaders\compiled\passthroughlumalpha3d11ps.h" />
<ClInclude Include="renderer\shaders\compiled\passthroughps.h" />
+ <ClInclude Include="renderer\shaders\compiled\passthroughr2d11ps.h" />
<ClInclude Include="renderer\shaders\compiled\passthroughr2di11ps.h" />
<ClInclude Include="renderer\shaders\compiled\passthroughr2dui11ps.h" />
<ClInclude Include="renderer\shaders\compiled\passthroughr3d11ps.h" />
diff --git a/src/libGLESv2/libGLESv2.vcxproj.filters b/src/libGLESv2/libGLESv2.vcxproj.filters
index f46b31a..eb29d3a 100644
--- a/src/libGLESv2/libGLESv2.vcxproj.filters
+++ b/src/libGLESv2/libGLESv2.vcxproj.filters
@@ -260,6 +260,9 @@
<ClCompile Include="validationES.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="renderer\Clear11.cpp">
+ <Filter>Source Files\Renderer11</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BinaryStream.h">
@@ -322,24 +325,6 @@
<ClInclude Include="Uniform.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\standardvs.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\componentmaskps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\flipyvs.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\luminanceps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\clear11vs.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
<ClInclude Include="..\common\system.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -505,12 +490,6 @@
<ClInclude Include="..\..\include\GLES2\gl2.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="renderer\shaders\compiled\clearmultiple11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\clearsingle11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
<ClInclude Include="renderer\loadimage.h">
<Filter>Header Files\Renderer</Filter>
</ClInclude>
@@ -532,39 +511,6 @@
<ClInclude Include="..\common\angleutils.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthrough2d11vs.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthrough3d11gs.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthrough3d11vs.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughlum2d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughlum3d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughlumalpha2d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughlumalpha3d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgb2d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgb3d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgba2d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgba3d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
<ClInclude Include="renderer\imageformats.h">
<Filter>Header Files\Renderer</Filter>
</ClInclude>
@@ -577,66 +523,6 @@
<ClInclude Include="renderer\Blit11.h">
<Filter>Header Files\Renderer11</Filter>
</ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrg2di11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrg2dui11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrg3d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrg3di11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrg3dui11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgb2di11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgb2dui11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgb3di11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgb3dui11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgba2di11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgba2dui11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgba3di11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrgba3dui11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughr2di11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughr2dui11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughr3d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughr3di11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughr3dui11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughrg2d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
- <ClInclude Include="renderer\shaders\compiled\passthroughdepth2d11ps.h">
- <Filter>Shaders\Compiled</Filter>
- </ClInclude>
<ClInclude Include="VertexAttribute.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -661,6 +547,138 @@
<ClInclude Include="validationES.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="renderer\Clear11.h">
+ <Filter>Header Files\Renderer11</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\clearsint11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\clearsint11vs.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\clearuint11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\clearuint11vs.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\componentmaskps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\flipyvs.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\luminanceps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthrough2d11vs.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthrough3d11gs.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthrough3d11vs.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughdepth2d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughlum2d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughlum3d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughlumalpha2d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughlumalpha3d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughr2d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughr2di11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughr2dui11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughr3d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughr3di11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughr3dui11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrg2d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrg2di11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrg2dui11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrg3d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrg3di11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrg3dui11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgb2d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgb2di11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgb2dui11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgb3d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgb3di11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgb3dui11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgba2d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgba2di11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgba2dui11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgba3d11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgba3di11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\passthroughrgba3dui11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\standardvs.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\clearfloat11ps.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
+ <ClInclude Include="renderer\shaders\compiled\clearfloat11vs.h">
+ <Filter>Shaders\Compiled</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="renderer\shaders\Blit.ps">
diff --git a/src/libGLESv2/renderer/Clear11.cpp b/src/libGLESv2/renderer/Clear11.cpp
new file mode 100644
index 0000000..d6c717e
--- /dev/null
+++ b/src/libGLESv2/renderer/Clear11.cpp
@@ -0,0 +1,525 @@
+#include "precompiled.h"
+//
+// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// Clear11.cpp: Framebuffer clear utility class.
+
+#include "libGLESv2/renderer/Clear11.h"
+#include "libGLESv2/renderer/Renderer11.h"
+#include "libGLESv2/renderer/renderer11_utils.h"
+#include "libGLESv2/renderer/RenderTarget11.h"
+
+#include "libGLESv2/formatutils.h"
+#include "libGLESv2/Framebuffer.h"
+#include "libGLESv2/Renderbuffer.h"
+
+#include "libGLESv2/renderer/shaders/compiled/clearfloat11vs.h"
+#include "libGLESv2/renderer/shaders/compiled/clearfloat11ps.h"
+
+#include "libGLESv2/renderer/shaders/compiled/clearuint11vs.h"
+#include "libGLESv2/renderer/shaders/compiled/clearuint11ps.h"
+
+#include "libGLESv2/renderer/shaders/compiled/clearsint11vs.h"
+#include "libGLESv2/renderer/shaders/compiled/clearsint11ps.h"
+
+namespace rx
+{
+
+// Provide a less-than function for comparing states in the caches
+template <typename T>
+static bool CompareStates(const T &a, const T &b)
+{
+ return memcmp(&a, &b, sizeof(T)) < 0;
+}
+
+template <typename T>
+static void ApplyVertices(const gl::Extents &framebufferSize, const gl::Rectangle *scissor, const gl::Color<T> &color, float depth, void *buffer)
+{
+ d3d11::PositionDepthColorVertex<T> *vertices = reinterpret_cast<d3d11::PositionDepthColorVertex<T>*>(buffer);
+
+ float depthClear = gl::clamp01(depth);
+ float left = -1.0f;
+ float right = 1.0f;
+ float top = -1.0f;
+ float bottom = 1.0f;
+
+ // Clip the quad coordinates to the scissor if needed
+ if (scissor != NULL)
+ {
+ left = std::max(left, (scissor->x / float(framebufferSize.width)) * 2.0f - 1.0f);
+ right = std::min(right, ((scissor->x + scissor->width) / float(framebufferSize.width)) * 2.0f - 1.0f);
+ top = std::max(top, ((framebufferSize.height - scissor->y - scissor->height) / float(framebufferSize.height)) * 2.0f - 1.0f);
+ bottom = std::min(bottom, ((framebufferSize.height - scissor->y) / float(framebufferSize.height)) * 2.0f - 1.0f);
+ }
+
+ d3d11::SetPositionDepthColorVertex<T>(vertices + 0, left, bottom, depthClear, color);
+ d3d11::SetPositionDepthColorVertex<T>(vertices + 1, left, top, depthClear, color);
+ d3d11::SetPositionDepthColorVertex<T>(vertices + 2, right, bottom, depthClear, color);
+ d3d11::SetPositionDepthColorVertex<T>(vertices + 3, right, top, depthClear, color);
+}
+
+template <unsigned int vsSize, unsigned int psSize>
+Clear11::ClearShader Clear11::CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize])
+{
+ HRESULT result;
+
+ ClearShader shader = { 0 };
+
+ D3D11_INPUT_ELEMENT_DESC quadLayout[] =
+ {
+ { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, colorType, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ };
+
+ result = device->CreateInputLayout(quadLayout, ArraySize(quadLayout), vsByteCode, vsSize, &shader.inputLayout);
+ ASSERT(SUCCEEDED(result));
+
+ result = device->CreateVertexShader(vsByteCode, vsSize, NULL, &shader.vertexShader);
+ ASSERT(SUCCEEDED(result));
+
+ result = device->CreatePixelShader(psByteCode, psSize, NULL, &shader.pixelShader);
+ ASSERT(SUCCEEDED(result));
+
+ return shader;
+}
+
+Clear11::Clear11(Renderer11 *renderer)
+ : mRenderer(renderer), mClearBlendStates(CompareStates<ClearBlendInfo>), mClearDepthStencilStates(CompareStates<ClearDepthStencilInfo>),
+ mVertexBuffer(NULL), mRasterizerState(NULL)
+{
+ HRESULT result;
+ ID3D11Device *device = renderer->getDevice();
+
+ D3D11_BUFFER_DESC vbDesc;
+ vbDesc.ByteWidth = sizeof(d3d11::PositionDepthColorVertex<float>) * 4;
+ vbDesc.Usage = D3D11_USAGE_DYNAMIC;
+ vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
+ vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ vbDesc.MiscFlags = 0;
+ vbDesc.StructureByteStride = 0;
+
+ result = device->CreateBuffer(&vbDesc, NULL, &mVertexBuffer);
+ ASSERT(SUCCEEDED(result));
+ d3d11::SetDebugName(mVertexBuffer, "Clear11 masked clear vertex buffer");
+
+ D3D11_RASTERIZER_DESC rsDesc;
+ rsDesc.FillMode = D3D11_FILL_SOLID;
+ rsDesc.CullMode = D3D11_CULL_NONE;
+ rsDesc.FrontCounterClockwise = FALSE;
+ rsDesc.DepthBias = 0;
+ rsDesc.DepthBiasClamp = 0.0f;
+ rsDesc.SlopeScaledDepthBias = 0.0f;
+ rsDesc.DepthClipEnable = FALSE;
+ rsDesc.ScissorEnable = FALSE;
+ rsDesc.MultisampleEnable = FALSE;
+ rsDesc.AntialiasedLineEnable = FALSE;
+
+ result = device->CreateRasterizerState(&rsDesc, &mRasterizerState);
+ ASSERT(SUCCEEDED(result));
+ d3d11::SetDebugName(mRasterizerState, "Clear11 masked clear rasterizer state");
+
+ mFloatClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_FLOAT, g_VS_ClearFloat, g_PS_ClearFloat);
+ mUintClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_UINT, g_VS_ClearUint, g_PS_ClearUint );
+ mIntClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_SINT, g_VS_ClearSint, g_PS_ClearSint );
+}
+
+Clear11::~Clear11()
+{
+ for (ClearBlendStateMap::iterator i = mClearBlendStates.begin(); i != mClearBlendStates.end(); i++)
+ {
+ SafeRelease(i->second);
+ }
+ mClearBlendStates.clear();
+
+ SafeRelease(mFloatClearShader.inputLayout);
+ SafeRelease(mFloatClearShader.vertexShader);
+ SafeRelease(mFloatClearShader.pixelShader);
+
+ SafeRelease(mUintClearShader.inputLayout);
+ SafeRelease(mUintClearShader.vertexShader);
+ SafeRelease(mUintClearShader.pixelShader);
+
+ SafeRelease(mIntClearShader.inputLayout);
+ SafeRelease(mIntClearShader.vertexShader);
+ SafeRelease(mIntClearShader.pixelShader);
+
+ for (ClearDepthStencilStateMap::iterator i = mClearDepthStencilStates.begin(); i != mClearDepthStencilStates.end(); i++)
+ {
+ SafeRelease(i->second);
+ }
+ mClearDepthStencilStates.clear();
+
+ SafeRelease(mVertexBuffer);
+ SafeRelease(mRasterizerState);
+}
+
+void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer)
+{
+ // First determine if a scissored clear is needed, this will always require drawing a quad.
+ //
+ // Otherwise, iterate over the color buffers which require clearing and determine if they can be
+ // cleared with ID3D11DeviceContext::ClearRenderTargetView... This requires:
+ // 1) The render target is being cleared to a float value (will be cast to integer when clearing integer
+ // render targets as expected but does not work the other way around)
+ // 2) The format of the render target has no color channels that are currently masked out.
+ // Clear the easy-to-clear buffers on the spot and accumulate the ones that require special work.
+ //
+ // Also determine if the depth stencil can be cleared with ID3D11DeviceContext::ClearDepthStencilView
+ // by checking if the stencil write mask covers the entire stencil.
+ //
+ // To clear the remaining buffers, quads must be drawn containing an int, uint or float vertex color
+ // attribute.
+
+ gl::Extents framebufferSize;
+ if (frameBuffer->getFirstColorbuffer() != NULL)
+ {
+ gl::Renderbuffer *renderBuffer = frameBuffer->getFirstColorbuffer();
+ framebufferSize.width = renderBuffer->getWidth();
+ framebufferSize.height = renderBuffer->getHeight();
+ framebufferSize.depth = 1;
+ }
+ else if (frameBuffer->getDepthOrStencilbuffer() != NULL)
+ {
+ gl::Renderbuffer *renderBuffer = frameBuffer->getDepthOrStencilbuffer();
+ framebufferSize.width = renderBuffer->getWidth();
+ framebufferSize.height = renderBuffer->getHeight();
+ framebufferSize.depth = 1;
+ }
+ else
+ {
+ UNREACHABLE();
+ return;
+ }
+
+ if (clearParams.scissorEnabled && (clearParams.scissor.x >= framebufferSize.width ||
+ clearParams.scissor.y >= framebufferSize.height ||
+ clearParams.scissor.x + clearParams.scissor.width <= 0 ||
+ clearParams.scissor.y + clearParams.scissor.height <= 0))
+ {
+ // Scissor is enabled and the scissor rectangle is outside the renderbuffer
+ return;
+ }
+
+ bool needScissoredClear = clearParams.scissorEnabled && (clearParams.scissor.x > 0 || clearParams.scissor.y > 0 ||
+ clearParams.scissor.x + clearParams.scissor.width < framebufferSize.width ||
+ clearParams.scissor.y + clearParams.scissor.height < framebufferSize.height);
+
+ GLuint clientVersion = mRenderer->getCurrentClientVersion();
+
+ std::vector<RenderTarget11*> maskedClearRenderTargets;
+ RenderTarget11* maskedClearDepthStencil = NULL;
+
+ ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+
+ for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
+ {
+ if (clearParams.clearColor[colorAttachment] && frameBuffer->isEnabledColorAttachment(colorAttachment))
+ {
+ gl::Renderbuffer *renderbuffer = frameBuffer->getColorbuffer(colorAttachment);
+ if (renderbuffer)
+ {
+ RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbuffer->getRenderTarget());
+ if (!renderTarget)
+ {
+ ERR("Render target pointer unexpectedly null.");
+ return;
+ }
+
+ GLint internalFormat = renderbuffer->getInternalFormat();
+ GLenum componentType = gl::GetComponentType(internalFormat, clientVersion);
+ if (clearParams.colorClearType == GL_FLOAT &&
+ !(componentType == GL_FLOAT || componentType == GL_UNSIGNED_NORMALIZED || componentType == GL_SIGNED_NORMALIZED))
+ {
+ ERR("It is undefined behaviour to clear a render buffer which is not normalized fixed point or floating-"
+ "point to floating point values (color attachment %u has internal format 0x%X).", colorAttachment, internalFormat);
+ }
+
+ if ((gl::GetRedBits(internalFormat, clientVersion) == 0 || !clearParams.colorMaskRed ) &&
+ (gl::GetGreenBits(internalFormat, clientVersion) == 0 || !clearParams.colorMaskGreen) &&
+ (gl::GetBlueBits(internalFormat, clientVersion) == 0 || !clearParams.colorMaskBlue ) &&
+ (gl::GetAlphaBits(internalFormat, clientVersion) == 0 || !clearParams.colorMaskAlpha))
+ {
+ // Every channel either does not exist in the render target or is masked out
+ continue;
+ }
+ else if (needScissoredClear || clearParams.colorClearType != GL_FLOAT ||
+ (gl::GetRedBits(internalFormat, clientVersion) > 0 && !clearParams.colorMaskRed ) ||
+ (gl::GetGreenBits(internalFormat, clientVersion) > 0 && !clearParams.colorMaskGreen) ||
+ (gl::GetBlueBits(internalFormat, clientVersion) > 0 && !clearParams.colorMaskBlue ) ||
+ (gl::GetAlphaBits(internalFormat, clientVersion) > 0 && !clearParams.colorMaskAlpha))
+ {
+ // A scissored or masked clear is required
+ maskedClearRenderTargets.push_back(renderTarget);
+ }
+ else
+ {
+ // ID3D11DeviceContext::ClearRenderTargetView is possible
+ ID3D11RenderTargetView *framebufferRTV = renderTarget->getRenderTargetView();
+ if (!framebufferRTV)
+ {
+ ERR("Render target view pointer unexpectedly null.");
+ return;
+ }
+
+ const float clearValues[4] = { clearParams.colorFClearValue.red,
+ clearParams.colorFClearValue.green,
+ clearParams.colorFClearValue.blue,
+ clearParams.colorFClearValue.alpha };
+ deviceContext->ClearRenderTargetView(framebufferRTV, clearValues);
+ }
+ }
+ }
+ }
+
+ if (clearParams.clearDepth || clearParams.clearStencil)
+ {
+ gl::Renderbuffer *renderbuffer = frameBuffer->getDepthOrStencilbuffer();
+ if (renderbuffer)
+ {
+ RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbuffer->getDepthStencil());
+ if (!renderTarget)
+ {
+ ERR("Depth stencil render target pointer unexpectedly null.");
+ return;
+ }
+
+ GLuint actualFormat = renderbuffer->getActualFormat();
+
+ unsigned int stencilUnmasked = frameBuffer->hasStencil() ? (1 << gl::GetStencilBits(actualFormat, clientVersion)) - 1 : 0;
+ bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
+
+ if (needScissoredClear || needMaskedStencilClear)
+ {
+ maskedClearDepthStencil = renderTarget;
+ }
+ else
+ {
+ ID3D11DepthStencilView *framebufferDSV = renderTarget->getDepthStencilView();
+ if (!framebufferDSV)
+ {
+ ERR("Depth stencil view pointer unexpectedly null.");
+ return;
+ }
+
+ UINT clearFlags = (clearParams.clearDepth ? D3D11_CLEAR_DEPTH : 0) |
+ (clearParams.clearStencil ? D3D11_CLEAR_STENCIL : 0);
+ FLOAT depthClear = gl::clamp01(clearParams.depthClearValue);
+ UINT8 stencilClear = clearParams.stencilClearValue & 0xFF;
+
+ deviceContext->ClearDepthStencilView(framebufferDSV, clearFlags, depthClear, stencilClear);
+ }
+ }
+ }
+
+ if (maskedClearRenderTargets.size() > 0 || maskedClearDepthStencil)
+ {
+ // To clear the render targets and depth stencil in one pass:
+ //
+ // Render a quad clipped to the scissor rectangle which draws the clear color and a blend
+ // state that will perform the required color masking.
+ //
+ // The quad's depth is equal to the depth clear value with a depth stencil state that
+ // will enable or disable depth test/writes if the depth buffer should be cleared or not.
+ //
+ // The rasterizer state's stencil is set to always pass or fail based on if the stencil
+ // should be cleared or not with a stencil write mask of the stencil clear value.
+ //
+ // ======================================================================================
+ //
+ // Luckily, the gl spec (ES 3.0.2 pg 183) states that the results of clearing a render-
+ // buffer that is not normalized fixed point or floating point with floating point values
+ // are undefined so we can just write floats to them and D3D11 will bit cast them to
+ // integers.
+ //
+ // Also, we don't have to worry about attempting to clear a normalized fixed/floating point
+ // buffer with integer values because there is no gl API call which would allow it,
+ // glClearBuffer* calls only clear a single renderbuffer at a time which is verified to
+ // be a compatible clear type.
+
+ // Bind all the render targets which need clearing
+ ASSERT(maskedClearRenderTargets.size() <= mRenderer->getMaxRenderTargets());
+ std::vector<ID3D11RenderTargetView*> rtvs(maskedClearRenderTargets.size());
+ for (unsigned int i = 0; i < maskedClearRenderTargets.size(); i++)
+ {
+ ID3D11RenderTargetView *renderTarget = maskedClearRenderTargets[i]->getRenderTargetView();
+ if (!renderTarget)
+ {
+ ERR("Render target pointer unexpectedly null.");
+ return;
+ }
+
+ rtvs[i] = renderTarget;
+ }
+ ID3D11DepthStencilView *dsv = maskedClearDepthStencil ? maskedClearDepthStencil->getDepthStencilView() : NULL;
+
+ ID3D11BlendState *blendState = getBlendState(clearParams);
+ const FLOAT blendFactors[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ const UINT sampleMask = 0xFFFFFFFF;
+
+ ID3D11DepthStencilState *dsState = getDepthStencilState(clearParams);
+ const UINT stencilClear = clearParams.stencilClearValue & 0xFF;
+
+ // Set the vertices
+ UINT vertexStride = 0;
+ const UINT startIdx = 0;
+ const ClearShader* shader = NULL;
+ D3D11_MAPPED_SUBRESOURCE mappedResource;
+ HRESULT result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+ if (FAILED(result))
+ {
+ ERR("Failed to map masked clear vertex buffer, HRESULT: 0x%X.", result);
+ return;
+ }
+
+ const gl::Rectangle *scissorPtr = clearParams.scissorEnabled ? &clearParams.scissor : NULL;
+ switch (clearParams.colorClearType)
+ {
+ case GL_FLOAT:
+ ApplyVertices(framebufferSize, scissorPtr, clearParams.colorFClearValue, clearParams.depthClearValue, mappedResource.pData);
+ vertexStride = sizeof(d3d11::PositionDepthColorVertex<float>);
+ shader = &mFloatClearShader;
+ break;
+
+ case GL_UNSIGNED_INT:
+ ApplyVertices(framebufferSize, scissorPtr, clearParams.colorUIClearValue, clearParams.depthClearValue, mappedResource.pData);
+ vertexStride = sizeof(d3d11::PositionDepthColorVertex<unsigned int>);
+ shader = &mUintClearShader;
+ break;
+
+ case GL_INT:
+ ApplyVertices(framebufferSize, scissorPtr, clearParams.colorIClearValue, clearParams.depthClearValue, mappedResource.pData);
+ vertexStride = sizeof(d3d11::PositionDepthColorVertex<int>);
+ shader = &mIntClearShader;
+ break;
+
+ default:
+ UNREACHABLE();
+ break;
+ }
+
+ deviceContext->Unmap(mVertexBuffer, 0);
+
+ // Set the viewport to be the same size as the framebuffer
+ D3D11_VIEWPORT viewport;
+ viewport.TopLeftX = 0;
+ viewport.TopLeftY = 0;
+ viewport.Width = framebufferSize.width;
+ viewport.Height = framebufferSize.height;
+ viewport.MinDepth = 0;
+ viewport.MaxDepth = 1;
+ deviceContext->RSSetViewports(1, &viewport);
+
+ // Apply state
+ deviceContext->OMSetBlendState(blendState, blendFactors, sampleMask);
+ deviceContext->OMSetDepthStencilState(dsState, stencilClear);
+ deviceContext->RSSetState(mRasterizerState);
+
+ // Apply shaders
+ deviceContext->IASetInputLayout(shader->inputLayout);
+ deviceContext->VSSetShader(shader->vertexShader, NULL, 0);
+ deviceContext->PSSetShader(shader->pixelShader, NULL, 0);
+ deviceContext->GSSetShader(NULL, NULL, 0);
+
+ // Apply vertex buffer
+ deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &vertexStride, &startIdx);
+ deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+
+ // Apply render targets
+ deviceContext->OMSetRenderTargets(rtvs.size(), &rtvs[0], dsv);
+
+ // Draw the clear quad
+ deviceContext->Draw(4, 0);
+
+ // Clean up
+ mRenderer->markAllStateDirty();
+ }
+}
+
+ID3D11BlendState *Clear11::getBlendState(const gl::ClearParameters &clearParams)
+{
+ ClearBlendInfo blendKey = { 0 };
+ blendKey.maskRed = clearParams.clearColor ? clearParams.colorMaskRed : false;
+ blendKey.maskGreen = clearParams.clearColor ? clearParams.colorMaskGreen : false;
+ blendKey.maskBlue = clearParams.clearColor ? clearParams.colorMaskBlue : false;
+ blendKey.maskAlpha = clearParams.clearColor ? clearParams.colorMaskAlpha : false;
+
+ ClearBlendStateMap::const_iterator i = mClearBlendStates.find(blendKey);
+ if (i != mClearBlendStates.end())
+ {
+ return i->second;
+ }
+ else
+ {
+ D3D11_BLEND_DESC blendDesc = { 0 };
+ blendDesc.AlphaToCoverageEnable = FALSE;
+ blendDesc.IndependentBlendEnable = FALSE;
+ blendDesc.RenderTarget[0].BlendEnable = FALSE;
+ blendDesc.RenderTarget[0].RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendKey.maskRed,
+ blendKey.maskGreen,
+ blendKey.maskBlue,
+ blendKey.maskAlpha);
+
+ ID3D11Device *device = mRenderer->getDevice();
+ ID3D11BlendState* blendState = NULL;
+ HRESULT result = device->CreateBlendState(&blendDesc, &blendState);
+ if (FAILED(result) || !blendState)
+ {
+ ERR("Unable to create a ID3D11BlendState, HRESULT: 0x%X.", result);
+ return NULL;
+ }
+
+ mClearBlendStates[blendKey] = blendState;
+
+ return blendState;
+ }
+}
+
+ID3D11DepthStencilState *Clear11::getDepthStencilState(const gl::ClearParameters &clearParams)
+{
+ ClearDepthStencilInfo dsKey = { 0 };
+ dsKey.clearDepth = clearParams.clearDepth;
+ dsKey.clearStencil = clearParams.clearStencil;
+ dsKey.stencilWriteMask = clearParams.stencilWriteMask & 0xFF;
+
+ ClearDepthStencilStateMap::const_iterator i = mClearDepthStencilStates.find(dsKey);
+ if (i != mClearDepthStencilStates.end())
+ {
+ return i->second;
+ }
+ else
+ {
+ D3D11_DEPTH_STENCIL_DESC dsDesc = { 0 };
+ dsDesc.DepthEnable = dsKey.clearDepth ? TRUE : FALSE;
+ dsDesc.DepthWriteMask = dsKey.clearDepth ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
+ dsDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
+ dsDesc.StencilEnable = dsKey.clearStencil ? TRUE : FALSE;
+ dsDesc.StencilReadMask = 0;
+ dsDesc.StencilWriteMask = dsKey.stencilWriteMask;
+ dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE;
+ dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE;
+ dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE;
+ dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+ dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE;
+ dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE;
+ dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE;
+ dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+
+ ID3D11Device *device = mRenderer->getDevice();
+ ID3D11DepthStencilState* dsState = NULL;
+ HRESULT result = device->CreateDepthStencilState(&dsDesc, &dsState);
+ if (FAILED(result) || !dsState)
+ {
+ ERR("Unable to create a ID3D11DepthStencilState, HRESULT: 0x%X.", result);
+ return NULL;
+ }
+
+ mClearDepthStencilStates[dsKey] = dsState;
+
+ return dsState;
+ }
+}
+
+}
diff --git a/src/libGLESv2/renderer/Clear11.h b/src/libGLESv2/renderer/Clear11.h
new file mode 100644
index 0000000..c46a2df
--- /dev/null
+++ b/src/libGLESv2/renderer/Clear11.h
@@ -0,0 +1,79 @@
+//
+// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// Clear11.h: Framebuffer clear utility class.
+
+#ifndef LIBGLESV2_RENDERER_CLEAR11_H_
+#define LIBGLESV2_RENDERER_CLEAR11_H_
+
+#include "libGLESv2/angletypes.h"
+
+namespace gl
+{
+class Framebuffer;
+}
+
+namespace rx
+{
+class Renderer11;
+
+class Clear11
+{
+ public:
+ explicit Clear11(Renderer11 *renderer);
+ ~Clear11();
+
+ // Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied.
+ void clearFramebuffer(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer);
+
+ private:
+ Renderer11 *mRenderer;
+
+ struct ClearBlendInfo
+ {
+ bool maskRed;
+ bool maskGreen;
+ bool maskBlue;
+ bool maskAlpha;
+ };
+ typedef bool (*ClearBlendInfoComparisonFunction)(const ClearBlendInfo&, const ClearBlendInfo &);
+ typedef std::map<ClearBlendInfo, ID3D11BlendState*, ClearBlendInfoComparisonFunction> ClearBlendStateMap;
+ ClearBlendStateMap mClearBlendStates;
+
+ ID3D11BlendState *getBlendState(const gl::ClearParameters &clearParams);
+
+ struct ClearShader
+ {
+ ID3D11InputLayout *inputLayout;
+ ID3D11VertexShader *vertexShader;
+ ID3D11PixelShader *pixelShader;
+ };
+ ClearShader mFloatClearShader;
+ ClearShader mUintClearShader;
+ ClearShader mIntClearShader;
+
+ template <unsigned int vsSize, unsigned int psSize>
+ static ClearShader CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize]);
+
+ struct ClearDepthStencilInfo
+ {
+ bool clearDepth;
+ bool clearStencil;
+ UINT8 stencilWriteMask;
+ };
+ typedef bool (*ClearDepthStencilInfoComparisonFunction)(const ClearDepthStencilInfo&, const ClearDepthStencilInfo &);
+ typedef std::map<ClearDepthStencilInfo, ID3D11DepthStencilState*, ClearDepthStencilInfoComparisonFunction> ClearDepthStencilStateMap;
+ ClearDepthStencilStateMap mClearDepthStencilStates;
+
+ ID3D11DepthStencilState *getDepthStencilState(const gl::ClearParameters &clearParams);
+
+ ID3D11Buffer *mVertexBuffer;
+ ID3D11RasterizerState *mRasterizerState;
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_CLEAR11_H_
diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp
index 3b8f428..837be4b 100644
--- a/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/libGLESv2/renderer/Renderer11.cpp
@@ -29,10 +29,7 @@
#include "libGLESv2/renderer/Query11.h"
#include "libGLESv2/renderer/Fence11.h"
#include "libGLESv2/renderer/Blit11.h"
-
-#include "libGLESv2/renderer/shaders/compiled/clear11vs.h"
-#include "libGLESv2/renderer/shaders/compiled/clearsingle11ps.h"
-#include "libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h"
+#include "libGLESv2/renderer/Clear11.h"
#include "libEGL/Display.h"
@@ -72,14 +69,7 @@
mBlit = NULL;
- mClearResourcesInitialized = false;
- mClearVB = NULL;
- mClearIL = NULL;
- mClearVS = NULL;
- mClearSinglePS = NULL;
- mClearMultiplePS = NULL;
- mClearScissorRS = NULL;
- mClearNoScissorRS = NULL;
+ mClear = NULL;
mSyncQuery = NULL;
@@ -398,6 +388,9 @@
ASSERT(!mBlit);
mBlit = new Blit11(this);
+ ASSERT(!mClear);
+ mClear = new Clear11(this);
+
markAllStateDirty();
}
@@ -1546,267 +1539,7 @@
void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer)
{
- bool alphaUnmasked = gl::GetAlphaBits(mRenderTargetDesc.format, getCurrentClientVersion()) == 0 ||
- clearParams.colorMaskAlpha;
- bool needMaskedColorClear = (clearParams.mask & GL_COLOR_BUFFER_BIT) &&
- !(clearParams.colorMaskRed && clearParams.colorMaskGreen &&
- clearParams.colorMaskBlue && alphaUnmasked);
-
- unsigned int stencilUnmasked = 0x0;
- if (frameBuffer->hasStencil())
- {
- unsigned int stencilSize = gl::GetStencilBits(frameBuffer->getStencilbuffer()->getActualFormat(),
- getCurrentClientVersion());
- stencilUnmasked = (0x1 << stencilSize) - 1;
- }
- bool needMaskedStencilClear = (clearParams.mask & GL_STENCIL_BUFFER_BIT) &&
- (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
-
- bool needScissoredClear = mScissorEnabled && (mCurScissor.x > 0 || mCurScissor.y > 0 ||
- mCurScissor.x + mCurScissor.width < mRenderTargetDesc.width ||
- mCurScissor.y + mCurScissor.height < mRenderTargetDesc.height);
-
- if (needMaskedColorClear || needMaskedStencilClear || needScissoredClear)
- {
- maskedClear(clearParams, frameBuffer->usingExtendedDrawBuffers());
- }
- else
- {
- if (clearParams.mask & GL_COLOR_BUFFER_BIT)
- {
- for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
- {
- 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);
- }
- }
- }
- }
- if (clearParams.mask & GL_DEPTH_BUFFER_BIT || clearParams.mask & GL_STENCIL_BUFFER_BIT)
- {
- gl::Renderbuffer *renderbufferObject = frameBuffer->getDepthOrStencilbuffer();
- if (renderbufferObject)
- {
- RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbufferObject->getDepthStencil());
- if (!renderTarget)
- {
- ERR("render target pointer unexpectedly null.");
- return;
- }
-
- ID3D11DepthStencilView *framebufferDSV = renderTarget->getDepthStencilView();
- if (!framebufferDSV)
- {
- ERR("depth stencil view pointer unexpectedly null.");
- return;
- }
-
- UINT clearFlags = 0;
- if (clearParams.mask & GL_DEPTH_BUFFER_BIT)
- {
- clearFlags |= D3D11_CLEAR_DEPTH;
- }
- if (clearParams.mask & GL_STENCIL_BUFFER_BIT)
- {
- clearFlags |= D3D11_CLEAR_STENCIL;
- }
-
- float depthClear = gl::clamp01(clearParams.depthClearValue);
- UINT8 stencilClear = clearParams.stencilClearValue & 0x000000FF;
-
- mDeviceContext->ClearDepthStencilView(framebufferDSV, clearFlags, depthClear, stencilClear);
- }
- }
- }
-}
-
-void Renderer11::maskedClear(const gl::ClearParameters &clearParams, bool usingExtendedDrawBuffers)
-{
- HRESULT result;
-
- if (!mClearResourcesInitialized)
- {
- ASSERT(!mClearVB && !mClearVS && !mClearSinglePS && !mClearMultiplePS && !mClearScissorRS && !mClearNoScissorRS);
-
- D3D11_BUFFER_DESC vbDesc;
- vbDesc.ByteWidth = sizeof(d3d11::PositionDepthColorVertex) * 4;
- vbDesc.Usage = D3D11_USAGE_DYNAMIC;
- vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
- vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- vbDesc.MiscFlags = 0;
- vbDesc.StructureByteStride = 0;
-
- result = mDevice->CreateBuffer(&vbDesc, NULL, &mClearVB);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mClearVB, "Renderer11 masked clear vertex buffer");
-
- D3D11_INPUT_ELEMENT_DESC quadLayout[] =
- {
- { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- };
-
- result = mDevice->CreateInputLayout(quadLayout, 2, g_VS_Clear, sizeof(g_VS_Clear), &mClearIL);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mClearIL, "Renderer11 masked clear input layout");
-
- result = mDevice->CreateVertexShader(g_VS_Clear, sizeof(g_VS_Clear), NULL, &mClearVS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mClearVS, "Renderer11 masked clear vertex shader");
-
- result = mDevice->CreatePixelShader(g_PS_ClearSingle, sizeof(g_PS_ClearSingle), NULL, &mClearSinglePS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mClearSinglePS, "Renderer11 masked clear pixel shader (1 RT)");
-
- result = mDevice->CreatePixelShader(g_PS_ClearMultiple, sizeof(g_PS_ClearMultiple), NULL, &mClearMultiplePS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mClearMultiplePS, "Renderer11 masked clear pixel shader (MRT)");
-
- D3D11_RASTERIZER_DESC rsScissorDesc;
- rsScissorDesc.FillMode = D3D11_FILL_SOLID;
- rsScissorDesc.CullMode = D3D11_CULL_NONE;
- rsScissorDesc.FrontCounterClockwise = FALSE;
- rsScissorDesc.DepthBias = 0;
- rsScissorDesc.DepthBiasClamp = 0.0f;
- rsScissorDesc.SlopeScaledDepthBias = 0.0f;
- rsScissorDesc.DepthClipEnable = FALSE;
- rsScissorDesc.ScissorEnable = TRUE;
- rsScissorDesc.MultisampleEnable = FALSE;
- rsScissorDesc.AntialiasedLineEnable = FALSE;
-
- result = mDevice->CreateRasterizerState(&rsScissorDesc, &mClearScissorRS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mClearScissorRS, "Renderer11 masked clear scissor rasterizer state");
-
- D3D11_RASTERIZER_DESC rsNoScissorDesc;
- rsNoScissorDesc.FillMode = D3D11_FILL_SOLID;
- rsNoScissorDesc.CullMode = D3D11_CULL_NONE;
- rsNoScissorDesc.FrontCounterClockwise = FALSE;
- rsNoScissorDesc.DepthBias = 0;
- rsNoScissorDesc.DepthBiasClamp = 0.0f;
- rsNoScissorDesc.SlopeScaledDepthBias = 0.0f;
- rsNoScissorDesc.DepthClipEnable = FALSE;
- rsNoScissorDesc.ScissorEnable = FALSE;
- rsNoScissorDesc.MultisampleEnable = FALSE;
- rsNoScissorDesc.AntialiasedLineEnable = FALSE;
-
- result = mDevice->CreateRasterizerState(&rsNoScissorDesc, &mClearNoScissorRS);
- ASSERT(SUCCEEDED(result));
- d3d11::SetDebugName(mClearNoScissorRS, "Renderer11 masked clear no scissor rasterizer state");
-
- mClearResourcesInitialized = true;
- }
-
- // Prepare the depth stencil state to write depth values if the depth should be cleared
- // and stencil values if the stencil should be cleared
- gl::DepthStencilState glDSState;
- glDSState.depthTest = (clearParams.mask & GL_DEPTH_BUFFER_BIT) != 0;
- glDSState.depthFunc = GL_ALWAYS;
- glDSState.depthMask = (clearParams.mask & GL_DEPTH_BUFFER_BIT) != 0;
- glDSState.stencilTest = (clearParams.mask & GL_STENCIL_BUFFER_BIT) != 0;
- glDSState.stencilFunc = GL_ALWAYS;
- glDSState.stencilMask = 0;
- glDSState.stencilFail = GL_REPLACE;
- glDSState.stencilPassDepthFail = GL_REPLACE;
- glDSState.stencilPassDepthPass = GL_REPLACE;
- glDSState.stencilWritemask = clearParams.stencilWriteMask;
- glDSState.stencilBackFunc = GL_ALWAYS;
- glDSState.stencilBackMask = 0;
- glDSState.stencilBackFail = GL_REPLACE;
- glDSState.stencilBackPassDepthFail = GL_REPLACE;
- glDSState.stencilBackPassDepthPass = GL_REPLACE;
- glDSState.stencilBackWritemask = clearParams.stencilWriteMask;
-
- int stencilClear = clearParams.stencilClearValue & 0x000000FF;
-
- ID3D11DepthStencilState *dsState = mStateCache.getDepthStencilState(glDSState);
-
- // Prepare the blend state to use a write mask if the color buffer should be cleared
- gl::BlendState glBlendState;
- glBlendState.blend = false;
- glBlendState.sourceBlendRGB = GL_ONE;
- glBlendState.destBlendRGB = GL_ZERO;
- glBlendState.sourceBlendAlpha = GL_ONE;
- glBlendState.destBlendAlpha = GL_ZERO;
- glBlendState.blendEquationRGB = GL_FUNC_ADD;
- glBlendState.blendEquationAlpha = GL_FUNC_ADD;
- glBlendState.colorMaskRed = (clearParams.mask & GL_COLOR_BUFFER_BIT) ? clearParams.colorMaskRed : false;
- glBlendState.colorMaskGreen = (clearParams.mask & GL_COLOR_BUFFER_BIT) ? clearParams.colorMaskGreen : false;
- glBlendState.colorMaskBlue = (clearParams.mask & GL_COLOR_BUFFER_BIT) ? clearParams.colorMaskBlue : false;
- glBlendState.colorMaskAlpha = (clearParams.mask & GL_COLOR_BUFFER_BIT) ? clearParams.colorMaskAlpha : false;
- glBlendState.sampleAlphaToCoverage = false;
- glBlendState.dither = false;
-
- static const float blendFactors[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
- static const UINT sampleMask = 0xFFFFFFFF;
-
- ID3D11BlendState *blendState = mStateCache.getBlendState(glBlendState);
-
- // Set the vertices
- D3D11_MAPPED_SUBRESOURCE mappedResource;
- result = mDeviceContext->Map(mClearVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
- if (FAILED(result))
- {
- ERR("Failed to map masked clear vertex buffer, HRESULT: 0x%X.", result);
- return;
- }
-
- d3d11::PositionDepthColorVertex *vertices = reinterpret_cast<d3d11::PositionDepthColorVertex*>(mappedResource.pData);
-
- float depthClear = gl::clamp01(clearParams.depthClearValue);
- d3d11::SetPositionDepthColorVertex(&vertices[0], -1.0f, 1.0f, depthClear, clearParams.colorClearValue);
- d3d11::SetPositionDepthColorVertex(&vertices[1], -1.0f, -1.0f, depthClear, clearParams.colorClearValue);
- d3d11::SetPositionDepthColorVertex(&vertices[2], 1.0f, 1.0f, depthClear, clearParams.colorClearValue);
- d3d11::SetPositionDepthColorVertex(&vertices[3], 1.0f, -1.0f, depthClear, clearParams.colorClearValue);
-
- mDeviceContext->Unmap(mClearVB, 0);
-
- // Apply state
- mDeviceContext->OMSetBlendState(blendState, blendFactors, sampleMask);
- mDeviceContext->OMSetDepthStencilState(dsState, stencilClear);
- mDeviceContext->RSSetState(mScissorEnabled ? mClearScissorRS : mClearNoScissorRS);
-
- // Apply shaders
- ID3D11PixelShader *pixelShader = usingExtendedDrawBuffers ? mClearMultiplePS : mClearSinglePS;
-
- mDeviceContext->IASetInputLayout(mClearIL);
- mDeviceContext->VSSetShader(mClearVS, NULL, 0);
- mDeviceContext->PSSetShader(pixelShader, NULL, 0);
- mDeviceContext->GSSetShader(NULL, NULL, 0);
-
- // Apply vertex buffer
- static UINT stride = sizeof(d3d11::PositionDepthColorVertex);
- static UINT startIdx = 0;
- mDeviceContext->IASetVertexBuffers(0, 1, &mClearVB, &stride, &startIdx);
- mDeviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-
- // Draw the clear quad
- mDeviceContext->Draw(4, 0);
-
- // Clean up
- markAllStateDirty();
+ mClear->clearFramebuffer(clearParams, frameBuffer);
}
void Renderer11::markAllStateDirty()
@@ -1870,16 +1603,7 @@
SafeDelete(mLineLoopIB);
SafeDelete(mTriangleFanIB);
SafeDelete(mBlit);
-
- SafeRelease(mClearVB);
- SafeRelease(mClearIL);
- SafeRelease(mClearVS);
- SafeRelease(mClearSinglePS);
- SafeRelease(mClearMultiplePS);
- SafeRelease(mClearScissorRS);
- SafeRelease(mClearNoScissorRS);
-
- mClearResourcesInitialized = false;
+ SafeDelete(mClear);
SafeRelease(mDriverConstantBufferVS);
SafeRelease(mDriverConstantBufferPS);
diff --git a/src/libGLESv2/renderer/Renderer11.h b/src/libGLESv2/renderer/Renderer11.h
index 4ff16b0..e41b12a 100644
--- a/src/libGLESv2/renderer/Renderer11.h
+++ b/src/libGLESv2/renderer/Renderer11.h
@@ -30,6 +30,7 @@
class IndexDataManager;
class StreamingIndexBufferInterface;
class Blit11;
+class Clear11;
enum
{
@@ -221,7 +222,6 @@
GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder,
GLint packAlignment, void *pixels);
- void maskedClear(const gl::ClearParameters &clearParams, bool usingExtendedDrawBuffers);
rx::Range getViewportBounds() const;
bool blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget,
@@ -353,14 +353,7 @@
Blit11 *mBlit;
// Masked clear resources
- bool mClearResourcesInitialized;
- ID3D11Buffer *mClearVB;
- ID3D11InputLayout *mClearIL;
- ID3D11VertexShader *mClearVS;
- ID3D11PixelShader *mClearSinglePS;
- ID3D11PixelShader *mClearMultiplePS;
- ID3D11RasterizerState *mClearScissorRS;
- ID3D11RasterizerState *mClearNoScissorRS;
+ Clear11 *mClear;
// Sync query
ID3D11Query *mSyncQuery;
diff --git a/src/libGLESv2/renderer/Renderer9.cpp b/src/libGLESv2/renderer/Renderer9.cpp
index 927e2e5..522700b 100644
--- a/src/libGLESv2/renderer/Renderer9.cpp
+++ b/src/libGLESv2/renderer/Renderer9.cpp
@@ -1761,15 +1761,33 @@
void Renderer9::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer)
{
- D3DCOLOR color = D3DCOLOR_ARGB(gl::unorm<8>(clearParams.colorClearValue.alpha),
- gl::unorm<8>(clearParams.colorClearValue.red),
- gl::unorm<8>(clearParams.colorClearValue.green),
- gl::unorm<8>(clearParams.colorClearValue.blue));
+ if (clearParams.colorClearType != GL_FLOAT)
+ {
+ // Clearing buffers with non-float values is not supported by Renderer9 and ES 2.0
+ UNREACHABLE();
+ return;
+ }
+
+ bool clearColor = clearParams.clearColor[0];
+ for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
+ {
+ if (clearParams.clearColor[i] != clearColor)
+ {
+ // Clearing individual buffers other than buffer zero is not supported by Renderer9 and ES 2.0
+ UNREACHABLE();
+ return;
+ }
+ }
+
+ D3DCOLOR color = D3DCOLOR_ARGB(gl::unorm<8>(clearParams.colorFClearValue.alpha),
+ gl::unorm<8>(clearParams.colorFClearValue.red),
+ gl::unorm<8>(clearParams.colorFClearValue.green),
+ gl::unorm<8>(clearParams.colorFClearValue.blue));
float depth = gl::clamp01(clearParams.depthClearValue);
int stencil = clearParams.stencilClearValue & 0x000000FF;
unsigned int stencilUnmasked = 0x0;
- if ((clearParams.mask & GL_STENCIL_BUFFER_BIT) && frameBuffer->hasStencil())
+ if (clearParams.clearStencil && frameBuffer->hasStencil())
{
unsigned int stencilSize = gl::GetStencilBits(frameBuffer->getStencilbuffer()->getActualFormat(),
getCurrentClientVersion());
@@ -1779,11 +1797,10 @@
bool alphaUnmasked = gl::GetAlphaBits(mRenderTargetDesc.format, getCurrentClientVersion()) == 0 ||
clearParams.colorMaskAlpha;
- const bool needMaskedStencilClear = (clearParams.mask & GL_STENCIL_BUFFER_BIT) &&
+ const bool needMaskedStencilClear = clearParams.clearStencil &&
(clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
- const bool needMaskedColorClear = (clearParams.mask & GL_COLOR_BUFFER_BIT) &&
- !(clearParams.colorMaskRed && clearParams.colorMaskGreen &&
- clearParams.colorMaskBlue && alphaUnmasked);
+ const bool needMaskedColorClear = clearColor && !(clearParams.colorMaskRed && clearParams.colorMaskGreen &&
+ clearParams.colorMaskBlue && alphaUnmasked);
if (needMaskedColorClear || needMaskedStencilClear)
{
@@ -1844,7 +1861,7 @@
mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
mDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
- if (clearParams.mask & GL_COLOR_BUFFER_BIT)
+ if (clearColor)
{
mDevice->SetRenderState(D3DRS_COLORWRITEENABLE,
gl_d3d9::ConvertColorMask(clearParams.colorMaskRed,
@@ -1857,7 +1874,7 @@
mDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
}
- if (stencilUnmasked != 0x0 && (clearParams.mask & GL_STENCIL_BUFFER_BIT))
+ if (stencilUnmasked != 0x0 && clearParams.clearStencil)
{
mDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
mDevice->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, FALSE);
@@ -1913,7 +1930,7 @@
startScene();
mDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float[4]));
- if (clearParams.mask & GL_DEPTH_BUFFER_BIT)
+ if (clearParams.clearDepth)
{
mDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
mDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
@@ -1925,18 +1942,18 @@
mMaskedClearSavedState->Apply();
}
}
- else if (clearParams.mask)
+ else if (clearColor || clearParams.clearDepth || clearParams.clearStencil)
{
DWORD dxClearFlags = 0;
- if (clearParams.mask & GL_COLOR_BUFFER_BIT)
+ if (clearColor)
{
dxClearFlags |= D3DCLEAR_TARGET;
}
- if (clearParams.mask & GL_DEPTH_BUFFER_BIT)
+ if (clearParams.clearDepth)
{
dxClearFlags |= D3DCLEAR_ZBUFFER;
}
- if (clearParams.mask & GL_STENCIL_BUFFER_BIT)
+ if (clearParams.clearStencil)
{
dxClearFlags |= D3DCLEAR_STENCIL;
}
diff --git a/src/libGLESv2/renderer/renderer11_utils.cpp b/src/libGLESv2/renderer/renderer11_utils.cpp
index 68792ee..3f098f2 100644
--- a/src/libGLESv2/renderer/renderer11_utils.cpp
+++ b/src/libGLESv2/renderer/renderer11_utils.cpp
@@ -237,18 +237,6 @@
vertex->s = s;
}
-void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z,
- const gl::ColorF &color)
-{
- vertex->x = x;
- vertex->y = y;
- vertex->z = z;
- vertex->r = color.red;
- vertex->g = color.green;
- vertex->b = color.blue;
- vertex->a = color.alpha;
-}
-
HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
{
#if defined(_DEBUG)
diff --git a/src/libGLESv2/renderer/renderer11_utils.h b/src/libGLESv2/renderer/renderer11_utils.h
index c06060e..11bedee 100644
--- a/src/libGLESv2/renderer/renderer11_utils.h
+++ b/src/libGLESv2/renderer/renderer11_utils.h
@@ -55,13 +55,25 @@
void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, float x, float y,
unsigned int layer, float u, float v, float s);
+template <typename T>
struct PositionDepthColorVertex
{
float x, y, z;
- float r, g, b, a;
+ T r, g, b, a;
};
-void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z,
- const gl::ColorF &color);
+
+template <typename T>
+void SetPositionDepthColorVertex(PositionDepthColorVertex<T>* vertex, float x, float y, float z,
+ const gl::Color<T> &color)
+{
+ vertex->x = x;
+ vertex->y = y;
+ vertex->z = z;
+ vertex->r = color.red;
+ vertex->g = color.green;
+ vertex->b = color.blue;
+ vertex->a = color.alpha;
+}
HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name);
diff --git a/src/libGLESv2/renderer/shaders/Clear11.hlsl b/src/libGLESv2/renderer/shaders/Clear11.hlsl
index 042ac69..6deef2b 100644
--- a/src/libGLESv2/renderer/shaders/Clear11.hlsl
+++ b/src/libGLESv2/renderer/shaders/Clear11.hlsl
@@ -1,38 +1,102 @@
-void VS_Clear( in float3 inPosition : POSITION, in float4 inColor : COLOR,
- out float4 outPosition : SV_POSITION, out float4 outColor : COLOR)
+// Assume we are in SM4+, which has 8 color outputs
+
+void VS_ClearFloat( in float3 inPosition : POSITION, in float4 inColor : COLOR,
+ out float4 outPosition : SV_POSITION, out float4 outColor : COLOR)
{
outPosition = float4(inPosition, 1.0f);
outColor = inColor;
}
-// Assume we are in SM4+, which has 8 color outputs
-struct PS_OutputMultiple
+struct PS_OutputFloat
{
- 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;
+ 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_OutputMultiple PS_ClearMultiple(in float4 inPosition : SV_POSITION, in float4 inColor : COLOR)
+PS_OutputFloat PS_ClearFloat(in float4 inPosition : SV_POSITION, in float4 inColor : COLOR)
{
- PS_OutputMultiple 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;
+ PS_OutputFloat 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;
}
-float4 PS_ClearSingle(in float4 inPosition : SV_Position, in float4 inColor : COLOR) : SV_Target0
+
+void VS_ClearUint( in float3 inPosition : POSITION, in uint4 inColor : COLOR,
+ out float4 outPosition : SV_POSITION, out uint4 outColor : COLOR)
{
- return inColor;
+ outPosition = float4(inPosition, 1.0f);
+ outColor = inColor;
+}
+
+struct PS_OutputUint
+{
+ uint4 color0 : SV_TARGET0;
+ uint4 color1 : SV_TARGET1;
+ uint4 color2 : SV_TARGET2;
+ uint4 color3 : SV_TARGET3;
+ uint4 color4 : SV_TARGET4;
+ uint4 color5 : SV_TARGET5;
+ uint4 color6 : SV_TARGET6;
+ uint4 color7 : SV_TARGET7;
+};
+
+PS_OutputUint PS_ClearUint(in float4 inPosition : SV_POSITION, in uint4 inColor : COLOR)
+{
+ PS_OutputUint 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;
+}
+
+
+void VS_ClearSint( in float3 inPosition : POSITION, in int4 inColor : COLOR,
+ out float4 outPosition : SV_POSITION, out int4 outColor : COLOR)
+{
+ outPosition = float4(inPosition, 1.0f);
+ outColor = inColor;
+}
+
+struct PS_OutputSint
+{
+ int4 color0 : SV_TARGET0;
+ int4 color1 : SV_TARGET1;
+ int4 color2 : SV_TARGET2;
+ int4 color3 : SV_TARGET3;
+ int4 color4 : SV_TARGET4;
+ int4 color5 : SV_TARGET5;
+ int4 color6 : SV_TARGET6;
+ int4 color7 : SV_TARGET7;
+};
+
+PS_OutputSint PS_ClearSint(in float4 inPosition : SV_POSITION, in int4 inColor : COLOR)
+{
+ PS_OutputSint 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;
}
diff --git a/src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h b/src/libGLESv2/renderer/shaders/compiled/clearfloat11ps.h
similarity index 97%
rename from src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h
rename to src/libGLESv2/renderer/shaders/compiled/clearfloat11ps.h
index c70eebb..a834fab 100644
--- a/src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h
+++ b/src/libGLESv2/renderer/shaders/compiled/clearfloat11ps.h
@@ -3,8 +3,7 @@
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
-// fxc /E PS_ClearMultiple /T ps_4_0 /Fh compiled/clearmultiple11ps.h
-// Clear11.hlsl
+// fxc /E PS_ClearFloat /T ps_4_0 /Fh compiled/clearfloat11ps.h Clear11.hlsl
//
//
//
@@ -51,7 +50,7 @@
// Approximately 9 instruction slots used
#endif
-const BYTE g_PS_ClearMultiple[] =
+const BYTE g_PS_ClearFloat[] =
{
68, 88, 66, 67, 146, 246,
236, 240, 50, 40, 87, 55,
diff --git a/src/libGLESv2/renderer/shaders/compiled/clear11vs.h b/src/libGLESv2/renderer/shaders/compiled/clearfloat11vs.h
similarity index 97%
rename from src/libGLESv2/renderer/shaders/compiled/clear11vs.h
rename to src/libGLESv2/renderer/shaders/compiled/clearfloat11vs.h
index 9f9c701..47b06a6 100644
--- a/src/libGLESv2/renderer/shaders/compiled/clear11vs.h
+++ b/src/libGLESv2/renderer/shaders/compiled/clearfloat11vs.h
@@ -3,7 +3,7 @@
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
-// fxc /E VS_Clear /T vs_4_0 /Fh compiled/clear11vs.h Clear11.hlsl
+// fxc /E VS_ClearFloat /T vs_4_0 /Fh compiled/clearfloat11vs.h Clear11.hlsl
//
//
//
@@ -34,7 +34,7 @@
// Approximately 4 instruction slots used
#endif
-const BYTE g_VS_Clear[] =
+const BYTE g_VS_ClearFloat[] =
{
68, 88, 66, 67, 109, 138,
105, 83, 86, 190, 83, 125,
diff --git a/src/libGLESv2/renderer/shaders/compiled/clearsingle11ps.h b/src/libGLESv2/renderer/shaders/compiled/clearsingle11ps.h
deleted file mode 100644
index 20395e2..0000000
--- a/src/libGLESv2/renderer/shaders/compiled/clearsingle11ps.h
+++ /dev/null
@@ -1,113 +0,0 @@
-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
-//
-//
-// fxc /E PS_ClearSingle /T ps_4_0 /Fh compiled/clearsingle11ps.h
-// Clear11.hlsl
-//
-//
-//
-// Input signature:
-//
-// Name Index Mask Register SysValue Format Used
-// -------------------- ----- ------ -------- -------- ------ ------
-// SV_Position 0 xyzw 0 POS float
-// COLOR 0 xyzw 1 NONE float xyzw
-//
-//
-// Output signature:
-//
-// Name Index Mask Register SysValue Format Used
-// -------------------- ----- ------ -------- -------- ------ ------
-// SV_Target 0 xyzw 0 TARGET float xyzw
-//
-ps_4_0
-dcl_input_ps linear v1.xyzw
-dcl_output o0.xyzw
-mov o0.xyzw, v1.xyzw
-ret
-// Approximately 2 instruction slots used
-#endif
-
-const BYTE g_PS_ClearSingle[] =
-{
- 68, 88, 66, 67, 11, 49,
- 220, 157, 35, 106, 175, 161,
- 180, 178, 147, 150, 134, 162,
- 222, 79, 1, 0, 0, 0,
- 208, 1, 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,
- 69, 70, 80, 0, 0, 0,
- 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0,
- 28, 0, 0, 0, 0, 4,
- 255, 255, 0, 1, 0, 0,
- 28, 0, 0, 0, 77, 105,
- 99, 114, 111, 115, 111, 102,
- 116, 32, 40, 82, 41, 32,
- 72, 76, 83, 76, 32, 83,
- 104, 97, 100, 101, 114, 32,
- 67, 111, 109, 112, 105, 108,
- 101, 114, 32, 57, 46, 50,
- 57, 46, 57, 53, 50, 46,
- 51, 49, 49, 49, 0, 171,
- 171, 171, 73, 83, 71, 78,
- 76, 0, 0, 0, 2, 0,
- 0, 0, 8, 0, 0, 0,
- 56, 0, 0, 0, 0, 0,
- 0, 0, 1, 0, 0, 0,
- 3, 0, 0, 0, 0, 0,
- 0, 0, 15, 0, 0, 0,
- 68, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 1, 0,
- 0, 0, 15, 15, 0, 0,
- 83, 86, 95, 80, 111, 115,
- 105, 116, 105, 111, 110, 0,
- 67, 79, 76, 79, 82, 0,
- 171, 171, 79, 83, 71, 78,
- 44, 0, 0, 0, 1, 0,
- 0, 0, 8, 0, 0, 0,
- 32, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 0, 0,
- 0, 0, 15, 0, 0, 0,
- 83, 86, 95, 84, 97, 114,
- 103, 101, 116, 0, 171, 171,
- 83, 72, 68, 82, 56, 0,
- 0, 0, 64, 0, 0, 0,
- 14, 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, 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,
- 0, 0, 0, 0, 0, 0,
- 2, 0, 0, 0, 0, 0,
- 0, 0, 0, 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, 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
-};
diff --git a/src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h b/src/libGLESv2/renderer/shaders/compiled/clearsint11ps.h
similarity index 81%
copy from src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h
copy to src/libGLESv2/renderer/shaders/compiled/clearsint11ps.h
index c70eebb..55e146b 100644
--- a/src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h
+++ b/src/libGLESv2/renderer/shaders/compiled/clearsint11ps.h
@@ -3,8 +3,7 @@
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
-// fxc /E PS_ClearMultiple /T ps_4_0 /Fh compiled/clearmultiple11ps.h
-// Clear11.hlsl
+// fxc /E PS_ClearSint /T ps_4_0 /Fh compiled/clearsint11ps.h Clear11.hlsl
//
//
//
@@ -13,24 +12,24 @@
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
-// COLOR 0 xyzw 1 NONE float xyzw
+// COLOR 0 xyzw 1 NONE int xyzw
//
//
// Output signature:
//
// 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
+// SV_TARGET 0 xyzw 0 TARGET int xyzw
+// SV_TARGET 1 xyzw 1 TARGET int xyzw
+// SV_TARGET 2 xyzw 2 TARGET int xyzw
+// SV_TARGET 3 xyzw 3 TARGET int xyzw
+// SV_TARGET 4 xyzw 4 TARGET int xyzw
+// SV_TARGET 5 xyzw 5 TARGET int xyzw
+// SV_TARGET 6 xyzw 6 TARGET int xyzw
+// SV_TARGET 7 xyzw 7 TARGET int xyzw
//
ps_4_0
-dcl_input_ps linear v1.xyzw
+dcl_input_ps constant v1.xyzw
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_output o2.xyzw
@@ -51,12 +50,12 @@
// Approximately 9 instruction slots used
#endif
-const BYTE g_PS_ClearMultiple[] =
+const BYTE g_PS_ClearSint[] =
{
- 68, 88, 66, 67, 146, 246,
- 236, 240, 50, 40, 87, 55,
- 73, 140, 251, 200, 8, 22,
- 173, 117, 1, 0, 0, 0,
+ 68, 88, 66, 67, 112, 6,
+ 161, 37, 1, 215, 22, 223,
+ 242, 200, 187, 209, 1, 11,
+ 54, 202, 1, 0, 0, 0,
88, 3, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
140, 0, 0, 0, 224, 0,
@@ -85,7 +84,7 @@
0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 1, 0,
+ 2, 0, 0, 0, 1, 0,
0, 0, 15, 15, 0, 0,
83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0,
@@ -95,41 +94,41 @@
0, 0, 8, 0, 0, 0,
200, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 0, 0,
+ 2, 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,
+ 2, 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,
+ 2, 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,
+ 2, 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,
+ 2, 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,
+ 2, 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,
+ 2, 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,
+ 2, 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, 24, 1,
0, 0, 64, 0, 0, 0,
- 70, 0, 0, 0, 98, 16,
+ 70, 0, 0, 0, 98, 8,
0, 3, 242, 16, 16, 0,
1, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
diff --git a/src/libGLESv2/renderer/shaders/compiled/clear11vs.h b/src/libGLESv2/renderer/shaders/compiled/clearsint11vs.h
similarity index 89%
copy from src/libGLESv2/renderer/shaders/compiled/clear11vs.h
copy to src/libGLESv2/renderer/shaders/compiled/clearsint11vs.h
index 9f9c701..d84400b 100644
--- a/src/libGLESv2/renderer/shaders/compiled/clear11vs.h
+++ b/src/libGLESv2/renderer/shaders/compiled/clearsint11vs.h
@@ -3,7 +3,7 @@
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
-// fxc /E VS_Clear /T vs_4_0 /Fh compiled/clear11vs.h Clear11.hlsl
+// fxc /E VS_ClearSint /T vs_4_0 /Fh compiled/clearsint11vs.h Clear11.hlsl
//
//
//
@@ -12,7 +12,7 @@
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// POSITION 0 xyz 0 NONE float xyz
-// COLOR 0 xyzw 1 NONE float xyzw
+// COLOR 0 xyzw 1 NONE int xyzw
//
//
// Output signature:
@@ -20,7 +20,7 @@
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float xyzw
-// COLOR 0 xyzw 1 NONE float xyzw
+// COLOR 0 xyzw 1 NONE int xyzw
//
vs_4_0
dcl_input v0.xyz
@@ -34,12 +34,12 @@
// Approximately 4 instruction slots used
#endif
-const BYTE g_VS_Clear[] =
+const BYTE g_VS_ClearSint[] =
{
- 68, 88, 66, 67, 109, 138,
- 105, 83, 86, 190, 83, 125,
- 72, 102, 194, 136, 46, 69,
- 17, 121, 1, 0, 0, 0,
+ 68, 88, 66, 67, 70, 247,
+ 203, 223, 152, 212, 204, 15,
+ 1, 237, 13, 201, 108, 151,
+ 0, 23, 1, 0, 0, 0,
48, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
140, 0, 0, 0, 220, 0,
@@ -68,7 +68,7 @@
0, 0, 7, 7, 0, 0,
65, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 1, 0,
+ 2, 0, 0, 0, 1, 0,
0, 0, 15, 15, 0, 0,
80, 79, 83, 73, 84, 73,
79, 78, 0, 67, 79, 76,
@@ -81,7 +81,7 @@
0, 0, 0, 0, 15, 0,
0, 0, 68, 0, 0, 0,
0, 0, 0, 0, 0, 0,
- 0, 0, 3, 0, 0, 0,
+ 0, 0, 2, 0, 0, 0,
1, 0, 0, 0, 15, 0,
0, 0, 83, 86, 95, 80,
79, 83, 73, 84, 73, 79,
diff --git a/src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h b/src/libGLESv2/renderer/shaders/compiled/clearuint11ps.h
similarity index 81%
copy from src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h
copy to src/libGLESv2/renderer/shaders/compiled/clearuint11ps.h
index c70eebb..d7e2224 100644
--- a/src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h
+++ b/src/libGLESv2/renderer/shaders/compiled/clearuint11ps.h
@@ -3,8 +3,7 @@
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
-// fxc /E PS_ClearMultiple /T ps_4_0 /Fh compiled/clearmultiple11ps.h
-// Clear11.hlsl
+// fxc /E PS_ClearUint /T ps_4_0 /Fh compiled/clearuint11ps.h Clear11.hlsl
//
//
//
@@ -13,24 +12,24 @@
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float
-// COLOR 0 xyzw 1 NONE float xyzw
+// COLOR 0 xyzw 1 NONE uint xyzw
//
//
// Output signature:
//
// 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
+// SV_TARGET 0 xyzw 0 TARGET uint xyzw
+// SV_TARGET 1 xyzw 1 TARGET uint xyzw
+// SV_TARGET 2 xyzw 2 TARGET uint xyzw
+// SV_TARGET 3 xyzw 3 TARGET uint xyzw
+// SV_TARGET 4 xyzw 4 TARGET uint xyzw
+// SV_TARGET 5 xyzw 5 TARGET uint xyzw
+// SV_TARGET 6 xyzw 6 TARGET uint xyzw
+// SV_TARGET 7 xyzw 7 TARGET uint xyzw
//
ps_4_0
-dcl_input_ps linear v1.xyzw
+dcl_input_ps constant v1.xyzw
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_output o2.xyzw
@@ -51,12 +50,12 @@
// Approximately 9 instruction slots used
#endif
-const BYTE g_PS_ClearMultiple[] =
+const BYTE g_PS_ClearUint[] =
{
- 68, 88, 66, 67, 146, 246,
- 236, 240, 50, 40, 87, 55,
- 73, 140, 251, 200, 8, 22,
- 173, 117, 1, 0, 0, 0,
+ 68, 88, 66, 67, 160, 0,
+ 119, 124, 89, 230, 58, 176,
+ 111, 216, 39, 247, 181, 152,
+ 98, 80, 1, 0, 0, 0,
88, 3, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
140, 0, 0, 0, 224, 0,
@@ -85,7 +84,7 @@
0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 1, 0,
+ 1, 0, 0, 0, 1, 0,
0, 0, 15, 15, 0, 0,
83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0,
@@ -95,41 +94,41 @@
0, 0, 8, 0, 0, 0,
200, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 0, 0,
+ 1, 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,
+ 1, 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,
+ 1, 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,
+ 1, 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,
+ 1, 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,
+ 1, 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,
+ 1, 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,
+ 1, 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, 24, 1,
0, 0, 64, 0, 0, 0,
- 70, 0, 0, 0, 98, 16,
+ 70, 0, 0, 0, 98, 8,
0, 3, 242, 16, 16, 0,
1, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
diff --git a/src/libGLESv2/renderer/shaders/compiled/clear11vs.h b/src/libGLESv2/renderer/shaders/compiled/clearuint11vs.h
similarity index 89%
copy from src/libGLESv2/renderer/shaders/compiled/clear11vs.h
copy to src/libGLESv2/renderer/shaders/compiled/clearuint11vs.h
index 9f9c701..3c06170 100644
--- a/src/libGLESv2/renderer/shaders/compiled/clear11vs.h
+++ b/src/libGLESv2/renderer/shaders/compiled/clearuint11vs.h
@@ -3,7 +3,7 @@
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
-// fxc /E VS_Clear /T vs_4_0 /Fh compiled/clear11vs.h Clear11.hlsl
+// fxc /E VS_ClearUint /T vs_4_0 /Fh compiled/clearuint11vs.h Clear11.hlsl
//
//
//
@@ -12,7 +12,7 @@
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// POSITION 0 xyz 0 NONE float xyz
-// COLOR 0 xyzw 1 NONE float xyzw
+// COLOR 0 xyzw 1 NONE uint xyzw
//
//
// Output signature:
@@ -20,7 +20,7 @@
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION 0 xyzw 0 POS float xyzw
-// COLOR 0 xyzw 1 NONE float xyzw
+// COLOR 0 xyzw 1 NONE uint xyzw
//
vs_4_0
dcl_input v0.xyz
@@ -34,12 +34,12 @@
// Approximately 4 instruction slots used
#endif
-const BYTE g_VS_Clear[] =
+const BYTE g_VS_ClearUint[] =
{
- 68, 88, 66, 67, 109, 138,
- 105, 83, 86, 190, 83, 125,
- 72, 102, 194, 136, 46, 69,
- 17, 121, 1, 0, 0, 0,
+ 68, 88, 66, 67, 225, 95,
+ 94, 158, 52, 154, 110, 112,
+ 150, 230, 100, 6, 119, 67,
+ 189, 150, 1, 0, 0, 0,
48, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
140, 0, 0, 0, 220, 0,
@@ -68,7 +68,7 @@
0, 0, 7, 7, 0, 0,
65, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
- 3, 0, 0, 0, 1, 0,
+ 1, 0, 0, 0, 1, 0,
0, 0, 15, 15, 0, 0,
80, 79, 83, 73, 84, 73,
79, 78, 0, 67, 79, 76,
@@ -81,7 +81,7 @@
0, 0, 0, 0, 15, 0,
0, 0, 68, 0, 0, 0,
0, 0, 0, 0, 0, 0,
- 0, 0, 3, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 15, 0,
0, 0, 83, 86, 95, 80,
79, 83, 73, 84, 73, 79,
diff --git a/src/libGLESv2/renderer/shaders/generate_shaders.bat b/src/libGLESv2/renderer/shaders/generate_shaders.bat
index 5b65741..405203b 100644
--- a/src/libGLESv2/renderer/shaders/generate_shaders.bat
+++ b/src/libGLESv2/renderer/shaders/generate_shaders.bat
@@ -47,6 +47,11 @@
fxc /E PS_PassthroughLum3D /T ps_4_0 /Fh compiled/passthroughlum3d11ps.h Passthrough3D11.hlsl
fxc /E PS_PassthroughLumAlpha3D /T ps_4_0 /Fh compiled/passthroughlumalpha3d11ps.h Passthrough3D11.hlsl
-fxc /E VS_Clear /T vs_4_0 /Fh compiled/clear11vs.h Clear11.hlsl
-fxc /E PS_ClearSingle /T ps_4_0 /Fh compiled/clearsingle11ps.h Clear11.hlsl
-fxc /E PS_ClearMultiple /T ps_4_0 /Fh compiled/clearmultiple11ps.h Clear11.hlsl
+fxc /E VS_ClearFloat /T vs_4_0 /Fh compiled/clearfloat11vs.h Clear11.hlsl
+fxc /E PS_ClearFloat /T ps_4_0 /Fh compiled/clearfloat11ps.h Clear11.hlsl
+
+fxc /E VS_ClearUint /T vs_4_0 /Fh compiled/clearuint11vs.h Clear11.hlsl
+fxc /E PS_ClearUint /T ps_4_0 /Fh compiled/clearuint11ps.h Clear11.hlsl
+
+fxc /E VS_ClearSint /T vs_4_0 /Fh compiled/clearsint11vs.h Clear11.hlsl
+fxc /E PS_ClearSint /T ps_4_0 /Fh compiled/clearsint11ps.h Clear11.hlsl