Commit d2c52e3b by Jamie Madill

Fix debug annotations and shaders.

The Program refactor inadvertantly broken Debug annotations. Fix this by correctly passing the path to the temporary shader source in the first "C" string argument to ShCompile, instead of as the first part of the source string. BUG=angleproject:1177 TEST=manual testing with MSVS Change-Id: Ie77bb11b51645a474b542ddd2ae0f391e019e341 Reviewed-on: https://chromium-review.googlesource.com/306210 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 27746966
...@@ -219,7 +219,9 @@ void Shader::compile(Compiler *compiler) ...@@ -219,7 +219,9 @@ void Shader::compile(Compiler *compiler)
std::stringstream sourceStream; std::stringstream sourceStream;
int additionalOptions = mImplementation->prepareSourceAndReturnOptions(&sourceStream); std::string sourcePath;
int additionalOptions =
mImplementation->prepareSourceAndReturnOptions(&sourceStream, &sourcePath);
int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES | additionalOptions); int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES | additionalOptions);
// Some targets (eg D3D11 Feature Level 9_3 and below) do not support non-constant loop indexes // Some targets (eg D3D11 Feature Level 9_3 and below) do not support non-constant loop indexes
...@@ -231,8 +233,17 @@ void Shader::compile(Compiler *compiler) ...@@ -231,8 +233,17 @@ void Shader::compile(Compiler *compiler)
} }
std::string sourceString = sourceStream.str(); std::string sourceString = sourceStream.str();
const char *sourceCString = sourceString.c_str(); std::vector<const char *> sourceCStrings;
bool result = ShCompile(compilerHandle, &sourceCString, 1, compileOptions);
if (!sourcePath.empty())
{
sourceCStrings.push_back(sourcePath.c_str());
}
sourceCStrings.push_back(sourceString.c_str());
bool result =
ShCompile(compilerHandle, &sourceCStrings[0], sourceCStrings.size(), compileOptions);
if (!result) if (!result)
{ {
......
...@@ -22,7 +22,8 @@ class ShaderImpl : angle::NonCopyable ...@@ -22,7 +22,8 @@ class ShaderImpl : angle::NonCopyable
virtual ~ShaderImpl() { } virtual ~ShaderImpl() { }
// Returns additional ShCompile options. // Returns additional ShCompile options.
virtual int prepareSourceAndReturnOptions(std::stringstream *sourceStream) = 0; virtual int prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) = 0;
// Returns success for compiling on the driver. Returns success. // Returns success for compiling on the driver. Returns success.
virtual bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) = 0; virtual bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) = 0;
......
...@@ -117,7 +117,8 @@ ShShaderOutput ShaderD3D::getCompilerOutputType() const ...@@ -117,7 +117,8 @@ ShShaderOutput ShaderD3D::getCompilerOutputType() const
return mCompilerOutputType; return mCompilerOutputType;
} }
int ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStream) int ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStream,
std::string *sourcePath)
{ {
uncompile(); uncompile();
...@@ -128,10 +129,9 @@ int ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStre ...@@ -128,10 +129,9 @@ int ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStre
#if !defined(ANGLE_ENABLE_WINDOWS_STORE) #if !defined(ANGLE_ENABLE_WINDOWS_STORE)
if (gl::DebugAnnotationsActive()) if (gl::DebugAnnotationsActive())
{ {
std::string sourcePath = getTempPath(); *sourcePath = getTempPath();
writeFile(sourcePath.c_str(), source.c_str(), source.length()); writeFile(sourcePath->c_str(), source.c_str(), source.length());
additionalOptions |= SH_LINE_DIRECTIVES | SH_SOURCE_PATH; additionalOptions |= SH_LINE_DIRECTIVES | SH_SOURCE_PATH;
*shaderSourceStream << sourcePath;
} }
#endif #endif
......
...@@ -28,7 +28,8 @@ class ShaderD3D : public ShaderImpl ...@@ -28,7 +28,8 @@ class ShaderD3D : public ShaderImpl
virtual ~ShaderD3D(); virtual ~ShaderD3D();
// ShaderImpl implementation // ShaderImpl implementation
int prepareSourceAndReturnOptions(std::stringstream *sourceStream) override; int prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) override;
bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override;
std::string getDebugInfo() const override; std::string getDebugInfo() const override;
......
...@@ -36,7 +36,8 @@ ShaderGL::~ShaderGL() ...@@ -36,7 +36,8 @@ ShaderGL::~ShaderGL()
} }
} }
int ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream) int ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string * /*sourcePath*/)
{ {
// Reset the previous state // Reset the previous state
if (mShaderID != 0) if (mShaderID != 0)
......
...@@ -25,7 +25,8 @@ class ShaderGL : public ShaderImpl ...@@ -25,7 +25,8 @@ class ShaderGL : public ShaderImpl
~ShaderGL() override; ~ShaderGL() override;
// ShaderImpl implementation // ShaderImpl implementation
int prepareSourceAndReturnOptions(std::stringstream *sourceStream) override; int prepareSourceAndReturnOptions(std::stringstream *sourceStream,
std::string *sourcePath) override;
bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override; bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override;
std::string getDebugInfo() const override; std::string getDebugInfo() const override;
......
...@@ -122,10 +122,17 @@ GLuint ANGLETest::compileShader(GLenum type, const std::string &source) ...@@ -122,10 +122,17 @@ GLuint ANGLETest::compileShader(GLenum type, const std::string &source)
GLint infoLogLength; GLint infoLogLength;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
std::vector<GLchar> infoLog(infoLogLength); if (infoLogLength == 0)
glGetShaderInfoLog(shader, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]); {
std::cerr << "shader compilation failed with empty log." << std::endl;
}
else
{
std::vector<GLchar> infoLog(infoLogLength);
glGetShaderInfoLog(shader, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]);
std::cerr << "shader compilation failed: " << &infoLog[0]; std::cerr << "shader compilation failed: " << &infoLog[0];
}
glDeleteShader(shader); glDeleteShader(shader);
shader = 0; shader = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment