Commit 6de4d494 by Jamie Madill

D3D: Generate more shader debug info by default.

The debug info can be very useful to WebGL developers. Instead of hiding the feature behind an unsupported and broken flag, always enable it so that WebGL devs can access the useful translated info. Change the debug info policy to build the full info (including generated assembly) in Debug, and all info excepth the assembly in Release. BUG=angleproject:1179 Change-Id: I25656b76b8437cb2edc9d88cd33f2c4d19b6a3f0 Reviewed-on: https://chromium-review.googlesource.com/313160 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent c22fef94
...@@ -32,10 +32,14 @@ ...@@ -32,10 +32,14 @@
#define ANGLE_PROGRAM_BINARY_LOAD ANGLE_ENABLED #define ANGLE_PROGRAM_BINARY_LOAD ANGLE_ENABLED
#endif #endif
// Shader debug info // Append HLSL assembly to shader debug info. Defaults to enabled in Debug and off in Release.
#if !defined(ANGLE_SHADER_DEBUG_INFO) #if !defined(ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO)
#define ANGLE_SHADER_DEBUG_INFO ANGLE_DISABLED #if !defined(NDEBUG)
#endif #define ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO ANGLE_ENABLED
#else
#define ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO ANGLE_DISABLED
#endif // !defined(NDEBUG)
#endif // !defined(ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO)
// Program link validation of precisions for uniforms. This feature was // Program link validation of precisions for uniforms. This feature was
// requested by developers to allow non-conformant shaders to be used which // requested by developers to allow non-conformant shaders to be used which
......
...@@ -12,12 +12,9 @@ ...@@ -12,12 +12,9 @@
#include "libANGLE/histogram_macros.h" #include "libANGLE/histogram_macros.h"
#include "third_party/trace_event/trace_event.h" #include "third_party/trace_event/trace_event.h"
// Definitions local to the translation unit #if ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
namespace namespace
{ {
#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
#ifdef CREATE_COMPILER_FLAG_INFO #ifdef CREATE_COMPILER_FLAG_INFO
#undef CREATE_COMPILER_FLAG_INFO #undef CREATE_COMPILER_FLAG_INFO
#endif #endif
...@@ -78,10 +75,8 @@ bool IsCompilerFlagSet(UINT mask, UINT flag) ...@@ -78,10 +75,8 @@ bool IsCompilerFlagSet(UINT mask, UINT flag)
return isFlagSet; return isFlagSet;
} }
} }
} // anonymous namespace
#endif #endif // ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
}
namespace rx namespace rx
{ {
...@@ -247,8 +242,9 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string ...@@ -247,8 +242,9 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string
{ {
*outCompiledBlob = binary; *outCompiledBlob = binary;
#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
(*outDebugInfo) += "// COMPILER INPUT HLSL BEGIN\n\n" + hlsl + "\n// COMPILER INPUT HLSL END\n"; (*outDebugInfo) += "// COMPILER INPUT HLSL BEGIN\n\n" + hlsl + "\n// COMPILER INPUT HLSL END\n";
#if ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
(*outDebugInfo) += "\n\n// ASSEMBLY BEGIN\n\n"; (*outDebugInfo) += "\n\n// ASSEMBLY BEGIN\n\n";
(*outDebugInfo) += "// Compiler configuration: " + configs[i].name + "\n// Flags:\n"; (*outDebugInfo) += "// Compiler configuration: " + configs[i].name + "\n// Flags:\n";
for (size_t fIx = 0; fIx < ArraySize(CompilerFlagInfos); ++fIx) for (size_t fIx = 0; fIx < ArraySize(CompilerFlagInfos); ++fIx)
...@@ -279,7 +275,7 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string ...@@ -279,7 +275,7 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string
return error; return error;
} }
(*outDebugInfo) += "\n" + disassembly + "\n// ASSEMBLY END\n"; (*outDebugInfo) += "\n" + disassembly + "\n// ASSEMBLY END\n";
#endif #endif // ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
...@@ -333,4 +329,4 @@ gl::Error HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary, std::string *d ...@@ -333,4 +329,4 @@ gl::Error HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary, std::string *d
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
} } // namespace rx
...@@ -1294,20 +1294,21 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoL ...@@ -1294,20 +1294,21 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoL
} }
// Auto-generate the geometry shader here, if we expect to be using point rendering in D3D11. // Auto-generate the geometry shader here, if we expect to be using point rendering in D3D11.
ShaderExecutableD3D *pointGS = nullptr;
if (usesGeometryShader(GL_POINTS)) if (usesGeometryShader(GL_POINTS))
{ {
getGeometryExecutableForPrimitiveType(data, GL_POINTS, nullptr, &infoLog); getGeometryExecutableForPrimitiveType(data, GL_POINTS, &pointGS, &infoLog);
} }
#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedVertexShader()); const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedVertexShader());
if (usesGeometryShader() && mGeometryExecutable)
if (usesGeometryShader(GL_POINTS) && pointGS)
{ {
// Geometry shaders are currently only used internally, so there is no corresponding shader // Geometry shaders are currently only used internally, so there is no corresponding shader
// object at the interface level. For now the geometry shader debug info is prepended to // object at the interface level. For now the geometry shader debug info is prepended to
// the vertex shader. // the vertex shader.
vertexShaderD3D->appendDebugInfo("// GEOMETRY SHADER BEGIN\n\n"); vertexShaderD3D->appendDebugInfo("// GEOMETRY SHADER BEGIN\n\n");
vertexShaderD3D->appendDebugInfo(mGeometryExecutable->getDebugInfo()); vertexShaderD3D->appendDebugInfo(pointGS->getDebugInfo());
vertexShaderD3D->appendDebugInfo("\nGEOMETRY SHADER END\n\n\n"); vertexShaderD3D->appendDebugInfo("\nGEOMETRY SHADER END\n\n\n");
} }
...@@ -1322,11 +1323,9 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoL ...@@ -1322,11 +1323,9 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoL
GetImplAs<ShaderD3D>(mData.getAttachedFragmentShader()); GetImplAs<ShaderD3D>(mData.getAttachedFragmentShader());
fragmentShaderD3D->appendDebugInfo(defaultPixelExecutable->getDebugInfo()); fragmentShaderD3D->appendDebugInfo(defaultPixelExecutable->getDebugInfo());
} }
#endif
bool linkSuccess = bool linkSuccess = (defaultVertexExecutable && defaultPixelExecutable &&
(defaultVertexExecutable && defaultPixelExecutable && (!usesGeometryShader(GL_POINTS) || pointGS));
(!usesGeometryShader(GL_POINTS) || mGeometryExecutables[gl::PRIMITIVE_POINTS]));
return LinkResult(linkSuccess, gl::Error(GL_NO_ERROR)); return LinkResult(linkSuccess, gl::Error(GL_NO_ERROR));
} }
......
...@@ -192,15 +192,11 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo ...@@ -192,15 +192,11 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo
} }
} }
#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
mDebugInfo += mDebugInfo +=
std::string("// ") + GetShaderTypeString(mData->getShaderType()) + " SHADER BEGIN\n"; std::string("// ") + GetShaderTypeString(mData.getShaderType()) + " SHADER BEGIN\n";
mDebugInfo += "\n// GLSL BEGIN\n\n" + source + "\n\n// GLSL END\n\n\n"; mDebugInfo += "\n// GLSL BEGIN\n\n" + mData.getSource() + "\n\n// GLSL END\n\n\n";
mDebugInfo += "// INITIAL HLSL BEGIN\n\n" + translatedSource + "\n// INITIAL HLSL END\n\n\n"; mDebugInfo += "// INITIAL HLSL BEGIN\n\n" + translatedSource + "\n// INITIAL HLSL END\n\n\n";
// Successive steps will append more info // Successive steps will append more info
#else
mDebugInfo += translatedSource;
#endif
return true; return true;
} }
......
...@@ -390,7 +390,6 @@ void GL_APIENTRY GetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, ...@@ -390,7 +390,6 @@ void GL_APIENTRY GetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize,
return; return;
} }
// Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source); shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
} }
} }
......
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