Skip to content

Commit

Permalink
remove remapping and just print the errors as they are, this avoids n…
Browse files Browse the repository at this point in the history
…eeding to
  • Loading branch information
douira committed Nov 27, 2024
1 parent f2b3a8f commit fe2cf33
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public GlShader(ShaderType type, ResourceLocation name, ShaderParser.ParsedShade
String log = GL20C.glGetShaderInfoLog(handle);

if (!log.isEmpty()) {
LOGGER.warn("Shader compilation log for " + this.name + ": " + parsedShader.remapShaderErrorLog(name, log));
LOGGER.warn("Include table: " + Arrays.toString(parsedShader.includeIds()));
LOGGER.warn("Shader compilation log for {}: {}", this.name, log);
LOGGER.warn("Include table: {}", Arrays.toString(parsedShader.includeIds()));
}

int result = GlStateManager.glGetShaderi(handle, GL20C.GL_COMPILE_STATUS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,6 @@

public class ShaderParser {
public record ParsedShader(String src, String[] includeIds) {
private static final Pattern LINE_REF_PATTERN = Pattern.compile("(?<source>\\d+):(?<line>\\d+):");

public String remapShaderErrorLog(ResourceLocation name, String log) {
// remap all line references with the include id table
Matcher matcher = LINE_REF_PATTERN.matcher(log);
StringBuilder builder = new StringBuilder();

while (matcher.find()) {
String source = matcher.group("source");
var line = matcher.group("line");
var id = Integer.parseInt(source);

if (id >= this.includeIds.length) {
matcher.appendReplacement(builder, "unknown_source" + "(#" + id + "):" + line + ":");
continue;
}

String includeName = id == 0 ? name.toString() : this.includeIds[id];

matcher.appendReplacement(builder, includeName + "(#" + id + "):" + line + ":");
}

matcher.appendTail(builder);
return builder.toString();
}
}

public static ParsedShader parseShader(String src, ShaderConstants constants) {
Expand Down

0 comments on commit fe2cf33

Please sign in to comment.