aboutsummaryrefslogtreecommitdiff
path: root/src/libGLESv2/renderer/d3d
diff options
context:
space:
mode:
authorJamie Madill <jmadill@chromium.org>2014-09-05 10:38:05 -0400
committerJamie Madill <jmadill@chromium.org>2014-09-05 17:01:42 +0000
commit3f2e61dea6c447ed7b98483fa0ce9ccc3cb5cc3c (patch)
treec628a2e3e23f0367b5baa2a8c24b3353561373ae /src/libGLESv2/renderer/d3d
parentaef95dec1cb82857fbe0dd88ad92eb3451e482f2 (diff)
downloadangle-3f2e61dea6c447ed7b98483fa0ce9ccc3cb5cc3c.tar.gz
Enable MRT pixel shader rewriting.
Writing to all 8 pixel outputs was causing performance problems on Intel and AMD. Enabling Geoff's work to rewrite our pixel shaders solves the regression. This patch also includes a workaround to the nVidia driver bug where it would ignore NULL RT values in OMSetRenderTargets, by compacting the RT list to skip NULL values. BUG=angle:705 BUG=365078 Change-Id: Ia68af6f0ccd5f10c484d6f76297a0bec694948f0 Reviewed-on: https://chromium-review.googlesource.com/214852 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Diffstat (limited to 'src/libGLESv2/renderer/d3d')
-rw-r--r--src/libGLESv2/renderer/d3d/DynamicHLSL.cpp41
-rw-r--r--src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp9
2 files changed, 36 insertions, 14 deletions
diff --git a/src/libGLESv2/renderer/d3d/DynamicHLSL.cpp b/src/libGLESv2/renderer/d3d/DynamicHLSL.cpp
index 6aa0d137..cd2b1a85 100644
--- a/src/libGLESv2/renderer/d3d/DynamicHLSL.cpp
+++ b/src/libGLESv2/renderer/d3d/DynamicHLSL.cpp
@@ -22,7 +22,7 @@ META_ASSERT(GL_INVALID_INDEX == UINT_MAX);
using namespace gl;
-namespace gl_d3d
+namespace
{
std::string HLSLComponentTypeString(GLenum componentType)
@@ -70,6 +70,21 @@ std::string HLSLTypeString(GLenum type)
return HLSLComponentTypeString(gl::VariableComponentType(type), gl::VariableComponentCount(type));
}
+const rx::PixelShaderOuputVariable &GetOutputAtLocation(const std::vector<rx::PixelShaderOuputVariable> &outputVariables,
+ unsigned int location)
+{
+ for (size_t variableIndex = 0; variableIndex < outputVariables.size(); ++variableIndex)
+ {
+ if (outputVariables[variableIndex].outputIndex == location)
+ {
+ return outputVariables[variableIndex];
+ }
+ }
+
+ UNREACHABLE();
+ return outputVariables[0];
+}
+
}
namespace rx
@@ -328,7 +343,7 @@ std::string DynamicHLSL::generateVaryingHLSL(const ShaderD3D *shader) const
{
GLenum componentType = VariableComponentType(transposedType);
int columnCount = VariableColumnCount(transposedType);
- typeString = gl_d3d::HLSLComponentTypeString(componentType, columnCount);
+ typeString = HLSLComponentTypeString(componentType, columnCount);
}
varyingHLSL += typeString + " v" + n + " : " + varyingSemantic + n + ";\n";
}
@@ -361,12 +376,12 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s
if (IsMatrixType(shaderAttribute.type))
{
// Matrix types are always transposed
- structHLSL += " " + gl_d3d::HLSLMatrixTypeString(TransposeMatrixType(shaderAttribute.type));
+ structHLSL += " " + HLSLMatrixTypeString(TransposeMatrixType(shaderAttribute.type));
}
else
{
GLenum componentType = mRenderer->getVertexComponentType(vertexFormat);
- structHLSL += " " + gl_d3d::HLSLComponentTypeString(componentType, VariableComponentCount(shaderAttribute.type));
+ structHLSL += " " + HLSLComponentTypeString(componentType, VariableComponentCount(shaderAttribute.type));
}
structHLSL += " " + decorateVariable(shaderAttribute.name) + " : TEXCOORD" + Str(semanticIndex) + ";\n";
@@ -421,17 +436,19 @@ std::string DynamicHLSL::generatePixelShaderForOutputSignature(const std::string
std::string declarationHLSL;
std::string copyHLSL;
- for (size_t i = 0; i < outputVariables.size(); i++)
+
+ for (size_t layoutIndex = 0; layoutIndex < outputLayout.size(); ++layoutIndex)
{
- const PixelShaderOuputVariable& outputVariable = outputVariables[i];
- ASSERT(outputLayout.size() > outputVariable.outputIndex);
+ GLenum binding = outputLayout[layoutIndex];
- // FIXME(geofflang): Work around NVIDIA driver bug by repacking buffers
- bool outputIndexEnabled = true; // outputLayout[outputVariable.outputIndex] != GL_NONE
- if (outputIndexEnabled)
+ if (binding != GL_NONE)
{
- declarationHLSL += " " + gl_d3d::HLSLTypeString(outputVariable.type) + " " + outputVariable.name +
- " : " + targetSemantic + Str(outputVariable.outputIndex) + ";\n";
+ unsigned int location = (binding - GL_COLOR_ATTACHMENT0);
+
+ const PixelShaderOuputVariable &outputVariable = GetOutputAtLocation(outputVariables, location);
+
+ declarationHLSL += " " + HLSLTypeString(outputVariable.type) + " " + outputVariable.name +
+ " : " + targetSemantic + Str(layoutIndex) + ";\n";
copyHLSL += " output." + outputVariable.name + " = " + outputVariable.source + ";\n";
}
diff --git a/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp b/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp
index c021e2ab..bb2e5362 100644
--- a/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.cpp
@@ -9,6 +9,7 @@
#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
+#include "libGLESv2/ProgramBinary.h"
#include "common/debug.h"
@@ -392,9 +393,13 @@ static size_t GetMaximumSimultaneousRenderTargets(D3D_FEATURE_LEVEL featureLevel
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0: return D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT;
- // FIXME(geofflang): Work around NVIDIA driver bug by repacking buffers
case D3D_FEATURE_LEVEL_10_1:
- case D3D_FEATURE_LEVEL_10_0: return 1; /* D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; */
+ case D3D_FEATURE_LEVEL_10_0:
+#if (ANGLE_MRT_PERF_WORKAROUND == ANGLE_WORKAROUND_ENABLED)
+ return D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT;
+#else
+ return 1;
+#endif
case D3D_FEATURE_LEVEL_9_3: return D3D_FL9_3_SIMULTANEOUS_RENDER_TARGET_COUNT;
case D3D_FEATURE_LEVEL_9_2: