Commit 847638a6 by Jamie Madill

Re-land "D3D: Generate more shader debug info by default."

Re-land with fix for shader size query. 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: I812b2c9ba98cb8c9d5ec95721441c70e8990b626 Reviewed-on: https://chromium-review.googlesource.com/313600 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 451cb838
......@@ -170,6 +170,17 @@ int Shader::getTranslatedSourceLength() const
return (static_cast<int>(mData.mTranslatedSource.length()) + 1);
}
int Shader::getTranslatedSourceWithDebugInfoLength() const
{
const std::string &debugInfo = mImplementation->getDebugInfo();
if (debugInfo.empty())
{
return 0;
}
return (static_cast<int>(debugInfo.length()) + 1);
}
void Shader::getSourceImpl(const std::string &source, GLsizei bufSize, GLsizei *length, char *buffer)
{
int index = 0;
......@@ -200,7 +211,7 @@ void Shader::getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer)
void Shader::getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, char *buffer) const
{
std::string debugInfo(mImplementation->getDebugInfo());
const std::string &debugInfo = mImplementation->getDebugInfo();
getSourceImpl(debugInfo, bufSize, length, buffer);
}
......
......@@ -98,6 +98,7 @@ class Shader : angle::NonCopyable
int getSourceLength() const;
void getSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
int getTranslatedSourceLength() const;
int getTranslatedSourceWithDebugInfoLength() const;
const std::string &getTranslatedSource() const { return mData.getTranslatedSource(); }
void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
void getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length, char *buffer) const;
......
......@@ -32,10 +32,14 @@
#define ANGLE_PROGRAM_BINARY_LOAD ANGLE_ENABLED
#endif
// Shader debug info
#if !defined(ANGLE_SHADER_DEBUG_INFO)
#define ANGLE_SHADER_DEBUG_INFO ANGLE_DISABLED
#endif
// Append HLSL assembly to shader debug info. Defaults to enabled in Debug and off in Release.
#if !defined(ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO)
#if !defined(NDEBUG)
#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
// requested by developers to allow non-conformant shaders to be used which
......
......@@ -12,12 +12,9 @@
#include "libANGLE/histogram_macros.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
{
#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
#ifdef CREATE_COMPILER_FLAG_INFO
#undef CREATE_COMPILER_FLAG_INFO
#endif
......@@ -78,10 +75,8 @@ bool IsCompilerFlagSet(UINT mask, UINT flag)
return isFlagSet;
}
}
#endif
}
} // anonymous namespace
#endif // ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
namespace rx
{
......@@ -247,8 +242,9 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string
{
*outCompiledBlob = binary;
#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
(*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) += "// Compiler configuration: " + configs[i].name + "\n// Flags:\n";
for (size_t fIx = 0; fIx < ArraySize(CompilerFlagInfos); ++fIx)
......@@ -279,7 +275,7 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string
return error;
}
(*outDebugInfo) += "\n" + disassembly + "\n// ASSEMBLY END\n";
#endif
#endif // ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
return gl::Error(GL_NO_ERROR);
}
......@@ -333,4 +329,4 @@ gl::Error HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary, std::string *d
return gl::Error(GL_NO_ERROR);
}
}
} // namespace rx
......@@ -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.
ShaderExecutableD3D *pointGS = nullptr;
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());
if (usesGeometryShader() && mGeometryExecutable)
if (usesGeometryShader(GL_POINTS) && pointGS)
{
// 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
// the vertex shader.
vertexShaderD3D->appendDebugInfo("// GEOMETRY SHADER BEGIN\n\n");
vertexShaderD3D->appendDebugInfo(mGeometryExecutable->getDebugInfo());
vertexShaderD3D->appendDebugInfo(pointGS->getDebugInfo());
vertexShaderD3D->appendDebugInfo("\nGEOMETRY SHADER END\n\n\n");
}
......@@ -1322,11 +1323,9 @@ LinkResult ProgramD3D::compileProgramExecutables(const gl::Data &data, gl::InfoL
GetImplAs<ShaderD3D>(mData.getAttachedFragmentShader());
fragmentShaderD3D->appendDebugInfo(defaultPixelExecutable->getDebugInfo());
}
#endif
bool linkSuccess =
(defaultVertexExecutable && defaultPixelExecutable &&
(!usesGeometryShader(GL_POINTS) || mGeometryExecutables[gl::PRIMITIVE_POINTS]));
bool linkSuccess = (defaultVertexExecutable && defaultPixelExecutable &&
(!usesGeometryShader(GL_POINTS) || pointGS));
return LinkResult(linkSuccess, gl::Error(GL_NO_ERROR));
}
......
......@@ -192,15 +192,11 @@ bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLo
}
}
#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
mDebugInfo +=
std::string("// ") + GetShaderTypeString(mData->getShaderType()) + " SHADER BEGIN\n";
mDebugInfo += "\n// GLSL BEGIN\n\n" + source + "\n\n// GLSL END\n\n\n";
std::string("// ") + GetShaderTypeString(mData.getShaderType()) + " SHADER BEGIN\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";
// Successive steps will append more info
#else
mDebugInfo += translatedSource;
#endif
return true;
}
......
......@@ -2246,7 +2246,7 @@ void GL_APIENTRY GetShaderiv(GLuint shader, GLenum pname, GLint* params)
*params = shaderObject->getSourceLength();
return;
case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
*params = shaderObject->getTranslatedSourceLength();
*params = shaderObject->getTranslatedSourceWithDebugInfoLength();
return;
default:
......
......@@ -390,7 +390,6 @@ void GL_APIENTRY GetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize,
return;
}
// Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
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