3Dickulus / FragM

Derived from https://github.com/Syntopia/Fragmentarium/
GNU General Public License v3.0
344 stars 30 forks source link

error line off-by-one #157

Closed claudeha closed 3 years ago

claudeha commented 3 years ago

Describe the bug Sometimes (not always) the error line reported by the shader compiler is off by one.

To Reproduce Steps to reproduce the behavior:

  1. Load attached off-by-one/main.frag
  2. See error reported one line after the error text

Expected behavior Error line matches the error text.

Desktop (please complete the following information):

Additional context It doesn't always occur. May be driver dependent?

Attachments This one works as expected: not-off-by-one.zip This one has error off by one: off-by-one.zip

claudeha commented 3 years ago

Adding an empty line at the start of the file switches the direction of this off-by-one: after.frag.txt before.frag.txt

3Dickulus commented 3 years ago

insert #line 2 at line 2 corrects off-by-one frag

my attempt to get this sorted out is in void Preprocessor::parseSource() roughly the first 200 lines

3Dickulus commented 3 years ago

Found the cause...

case: hasIncludes, !hasVertexCode, vers > 200, the inserted #line directive must account for how many #include statements

See commit

if the value is less than 0 it will prepend, if the value is greater than line count it will append.

Here is my error line test suite, after making the adjustment these tests all get the right line numbers testing errors in vertex and fragment parts of main shader and buffershader...

Error-Line-Tests.zip

the script is hardcoded for paths but not hard to figure out, in Fragmentarium folder I have FragMTestSuite/Error-Line-Tests/ that contains all of the frags and the script so in my setup I cd to where Fragmentarium executable lives and run the script like...

sh ./FragMTestSuite/Error-Line-Tests/errorLineTest.sh ./Fragmentarium-2.5.4

...passing it the name of the executable I want to test.