From 4bcf58a19205067c18869eaf1912090a7a8e984a Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 19 May 2015 11:26:35 -0700 Subject: [PATCH] vk/glsl_scraper: Use the line number from the end of the macro We used to use the line number from the start of the macro but this doesn't seem to match the c preprocessor --- src/vulkan/glsl_scraper.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/vulkan/glsl_scraper.py b/src/vulkan/glsl_scraper.py index fa62daf5a2b..55885b4bdbf 100644 --- a/src/vulkan/glsl_scraper.py +++ b/src/vulkan/glsl_scraper.py @@ -19,10 +19,9 @@ Options: import os, sys, re, cStringIO, tempfile, subprocess, struct, shutil class Shader: - def __init__(self, stage, line): + def __init__(self, stage): self.stream = cStringIO.StringIO() self.stage = stage - self.line = line if self.stage == 'VERTEX': self.ext = 'vert' @@ -42,6 +41,9 @@ class Shader: def add_text(self, s): self.stream.write(s) + def finish_text(self, line): + self.line = line + def glsl_source(self): return self.stream.getvalue() @@ -153,8 +155,6 @@ class Parser: self.current_shader.add_text(t) def handle_macro(self): - line_number = self.line_number - t = self.token_iter.next() assert t == '(' t = self.token_iter.next() @@ -166,9 +166,12 @@ class Parser: t = self.token_iter.next() assert t == ',' - self.current_shader = Shader(stage, line_number) + self.current_shader = Shader(stage) self.handle_shader_src() + self.current_shader.finish_text(self.line_number) + self.shaders.append(self.current_shader) + self.current_shader = None def run(self): for t in self.token_iter: -- 2.30.2