Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Add #line directive for glsl #insert

Open VReaperV opened this issue 1 year ago • 5 comments

Shader code added with #insert will use lines 10000, 10001, 10002; 20000, 20001 etc, each inserted shader adding 10000, as suggested by @illwieckz in https://github.com/DaemonEngine/Daemon/pull/1124#issuecomment-2122679583.

VReaperV avatar Jun 16 '24 11:06 VReaperV

I changed a bit how this works because #line 0 before #insert was making the line count wrong.

Now instead #line -1 is treated as a marker, where PrintShaderSource() will keep the correct line count with it.

VReaperV avatar Jun 23 '24 08:06 VReaperV

I tested and the line numbering for the main file was off. After using 3 #inserts, the line numbers were too high by 3. For example the real line 48 was labeled as 51.

Just my personal taste and not a required change, but I would rather not have lines saying #LINE_MARKER_END and #LINE_MARKER_START. Showing the filename there could be useful though.

slipher avatar Jun 26 '24 10:06 slipher

Just my personal taste and not a required change, but I would rather not have lines saying #LINE_MARKER_END and #LINE_MARKER_START.

To me it's useful because it stands out when looking at a shader source in a frame capture.

Showing the filename there could be useful though.

I like that idea. It would be useful to have these for vertex/fragment libs too.

VReaperV avatar Jun 26 '24 13:06 VReaperV

Showing the filename there could be useful though.

I like that idea. It would be useful to have these for vertex/fragment libs too.

Hopefully we can nuke those and replace them with #insert

slipher avatar Jun 26 '24 16:06 slipher

Hopefully we can nuke those and replace them with #insert

I thought of that too, should be pretty easily doable. It would also allow dropping more of the forced vp/fp/cp suffixes.

VReaperV avatar Jun 27 '24 14:06 VReaperV

I tested and the line numbering for the main file was off. After using 3 #inserts, the line numbers were too high by 3. For example the real line 48 was labeled as 51.

Fixed.

Just my personal taste and not a required change, but I would rather not have lines saying #LINE_MARKER_END and #LINE_MARKER_START. Showing the filename there could be useful though.

This now shows the file name/path.

VReaperV avatar Jul 03 '24 22:07 VReaperV

LGTM

slipher avatar Jul 05 '24 21:07 slipher