зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1697187 - Print the shader when encountering glslopt errors. r=jnicol
glslopt error messages typically look like: 314(15): error: syntax error, unexpected NEW_IDENTIFIER, expecting ',' or ';' Which would be fine if we had a way to see what is at line 314, however we don't store the concatenated shader string on disk so it's a bit hard to guess where in the source a typo led to a an unknown identifier. This patch makes the build script print the shader source with line numbers when glslopt throws an error. Differential Revision: https://phabricator.services.mozilla.com/D107655
This commit is contained in:
Родитель
7a49598d75
Коммит
1066800f50
|
@ -94,6 +94,16 @@ struct ShaderOptimizationError {
|
||||||
message: String,
|
message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_shader_source(shader_src: &str) {
|
||||||
|
// For some reason the glsl-opt errors are offset by 1 compared
|
||||||
|
// to the provided shader source string.
|
||||||
|
println!("0\t|");
|
||||||
|
for (n, line) in shader_src.split('\n').enumerate() {
|
||||||
|
let line_number = n + 1;
|
||||||
|
println!("{}\t|{}", line_number, line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn write_optimized_shaders(shader_dir: &Path, shader_file: &mut File, out_dir: &str) -> Result<(), std::io::Error> {
|
fn write_optimized_shaders(shader_dir: &Path, shader_file: &mut File, out_dir: &str) -> Result<(), std::io::Error> {
|
||||||
writeln!(
|
writeln!(
|
||||||
shader_file,
|
shader_file,
|
||||||
|
@ -155,15 +165,17 @@ fn write_optimized_shaders(shader_dir: &Path, shader_file: &mut File, out_dir: &
|
||||||
format!("{}_{}", shader.shader_name, shader.config.replace(",", "_"))
|
format!("{}_{}", shader.shader_name, shader.config.replace(",", "_"))
|
||||||
};
|
};
|
||||||
|
|
||||||
let vert = glslopt_ctx.optimize(glslopt::ShaderType::Vertex, vert_src);
|
let vert = glslopt_ctx.optimize(glslopt::ShaderType::Vertex, vert_src.clone());
|
||||||
if !vert.get_status() {
|
if !vert.get_status() {
|
||||||
|
print_shader_source(&vert_src);
|
||||||
return Err(ShaderOptimizationError {
|
return Err(ShaderOptimizationError {
|
||||||
shader: shader.clone(),
|
shader: shader.clone(),
|
||||||
message: vert.get_log().to_string(),
|
message: vert.get_log().to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let frag = glslopt_ctx.optimize(glslopt::ShaderType::Fragment, frag_src);
|
let frag = glslopt_ctx.optimize(glslopt::ShaderType::Fragment, frag_src.clone());
|
||||||
if !frag.get_status() {
|
if !frag.get_status() {
|
||||||
|
print_shader_source(&frag_src);
|
||||||
return Err(ShaderOptimizationError {
|
return Err(ShaderOptimizationError {
|
||||||
shader: shader.clone(),
|
shader: shader.clone(),
|
||||||
message: frag.get_log().to_string(),
|
message: frag.get_log().to_string(),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче