OpenGL Shading Language: Difference between revisions

Content deleted Content added
Fixed "inveresqrt" typo
Monkbot (talk | contribs)
m Task 18 (cosmetic): eval 26 templates: del empty params (4×); hyphenate params (3×);
Line 62:
|}
 
The two languages are related but not directly compatible. They can be interconverted through [[Standard Portable Intermediate Representation|SPIR-Cross]].<ref>{{Citation|last=|first=|title=KhronosGroup/SPIRV-Cross|date=2019-09-06|url=https://github.com/KhronosGroup/SPIRV-Cross|volume=|pages=|publisher=The Khronos Group|access-date=2019-09-08}}</ref>
 
== Language ==
Line 76:
GLSL defines a subset of the [[C preprocessor]] (CPP), combined with its own special directives for specifying versions and OpenGL extensions. The parts removed from CPP are those relating to file names such as {{code|#include}} and {{code|__FILE__}}.<ref>{{cite book |title=OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition |url=https://www.oreilly.com/library/view/opengl-programming-guide/9780132748445/ch02lev2sec5.html |language=en |chapter=Shader Preprocessor}}</ref>
 
The {{code|GL_ARB_shading_language_include}} extension<ref>{{cite web |title=ARB_shading_language_include |url=https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shading_language_include.txt |website=Khronos.org |accessdateaccess-date=2020-05-31}}</ref> (implemented for example in Nvidia drivers<ref>{{cite web |title=NVIDIA driver 265.90 WHQL Quadro |url=https://forums.laptopvideo2go.com/topic/27639-nvidia-driver-26590-whql-quadro/?tab=comments#comment-134520 |website=LaptopVideo2Go Forums}}</ref> on Windows and Linux, and all Mesa 20.0.0<ref>{{cite web |title=Mesa 20.0.0 Release Notes / 2020-02-19 |url=https://www.mesa3d.org/relnotes/20.0.0.html |website=www.mesa3d.org |accessdateaccess-date=2020-05-31}}</ref> drivers on Linux, FreeBSD and Android) implements ability to use {{code|#include}} in source code, allowing easier sharing of code and definitions between many shaders without extra manual pre-processing. Similar extension {{code|GL_GOOGLE_include_directive}} and {{code|GL_GOOGLE_cpp_style_line_directive}} exist for using GLSL with Vulkan, and are supported in reference SPIR-V compiler ({{code|glslang}} aka glslangValidator).<ref>{{cite web |title=#include directive support by antiagainst · Pull Request #46 · KhronosGroup/glslang |url=https://github.com/KhronosGroup/glslang/pull/46 |website=GitHub |accessdateaccess-date=2020-05-31 |language=en}}</ref><ref>{{cite web |title=Preprocessing line number handling by antiagainst · Pull Request #38 · KhronosGroup/glslang |url=https://github.com/KhronosGroup/glslang/pull/38 |website=GitHub |language=en}}</ref><ref>{{cite web |title=Extend the syntax of #line and __FILE__ to support filename strings by antiagainst · Pull Request #43 · KhronosGroup/glslang |url=https://github.com/KhronosGroup/glslang/pull/43 |website=GitHub |language=en}}</ref>
 
==Compilation and execution==