Skip to content

Commit

Permalink
Update syntax highlighting
Browse files Browse the repository at this point in the history
This Cl switches to the `rouge` highlighter which matches the Vulkan
spec. The `rouge-extended-css.rb` file is copied in from the Vulkan-Docs
repo.

The code examples are updated to use `source,glsl` instead of
`source,c++`. This means when mousing over the code blocks in the HTML
version the syntax will correctly be identified as GLSL.
  • Loading branch information
dj2 committed Sep 14, 2024
1 parent d1b8788 commit c2e1856
Show file tree
Hide file tree
Showing 11 changed files with 302 additions and 241 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ ADOCEXTS = -r $(CURDIR)/config/vulkan-macros.rb
ADOCOPTS = -d book $(ATTRIBOPTS) $(NOTEOPTS) $(VERBOSE) $(ADOCEXTS)

# This uses KaTeX for latexmath: blocks in HTML output instead of MathJax
ADOCHTMLEXTS = -r $(CURDIR)/config/katex_replace.rb
ADOCHTMLEXTS = -r $(CURDIR)/config/katex_replace.rb \
-r $(CURDIR)/config/rouge-extend-css.rb
ADOCHTMLOPTS = $(ADOCHTMLEXTS) -a katexpath=../katex

ADOCPDFEXTS = -r $(ADOCPDF) -r asciidoctor-mathematical
Expand Down
38 changes: 19 additions & 19 deletions chapters/basics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ That is, a single token could be formed by the concatenation by taking the
characters at the end of one line concatenating them with the characters at
the beginning of the next line.

[source,c++]
[source,glsl]
----
float f\
oo;
Expand All @@ -143,7 +143,7 @@ Shaders must declare the version of the language they are written to.
The version is specified in the first line of a shader by a character
string:

[source,c++]
[source,glsl]
----
#version number es
----
Expand Down Expand Up @@ -358,7 +358,7 @@ endif::ESSL[]

The *defined* operator can be used in either of the following ways:

[source,c++]
[source,glsl]
----
defined identifier
defined ( identifier )
Expand Down Expand Up @@ -415,7 +415,7 @@ If an implementation does not recognize the tokens following *#pragma*, then
it will ignore that pragma.
The following pragmas are defined as part of the language.

[source,c++]
[source,glsl]
----
#pragma STDGL
----
Expand All @@ -424,7 +424,7 @@ The *STDGL* pragma is used to reserve pragmas for use by future revisions of
this language.
No implementation may use a pragma whose first token is *STDGL*.

[source,c++]
[source,glsl]
----
#pragma optimize(on)
#pragma optimize(off)
Expand All @@ -436,7 +436,7 @@ It can only be used outside function definitions.
By default, optimization is turned on for all shaders.
The debug pragma

[source,c++]
[source,glsl]
----
#pragma debug(on)
#pragma debug(off)
Expand All @@ -451,7 +451,7 @@ ifdef::GLSL[]
Shaders should declare the version of the language they are written to.
The language version a shader is written to is specified by

[source,c++]
[source,glsl]
----
#version number profile_opt
----
Expand All @@ -476,7 +476,7 @@ If the optional _profile_ argument is provided, it must be the name of an
{apiname} profile.
Currently, there are three choices:

[source,c++]
[source,glsl]
----
core
compatibility
Expand Down Expand Up @@ -513,22 +513,22 @@ There is a built-in macro definition for each profile the implementation
supports.
All implementations provide the following macro:

[source,c++]
[source,glsl]
----
#define GL_core_profile 1
----

Implementations providing the *compatibility* profile provide the following
macro:

[source,c++]
[source,glsl]
----
#define GL_compatibility_profile 1
----

Implementations providing the *es* profile provide the following macro:

[source,c++]
[source,glsl]
----
#define GL_es_profile 1
----
Expand All @@ -549,7 +549,7 @@ Any extended behavior must first be enabled.
Directives to control the behavior of the compiler with respect to
extensions are declared with the *#extension* directive

[source,c++]
[source,glsl]
----
#extension extension_name : behavior
#extension all : behavior
Expand Down Expand Up @@ -602,7 +602,7 @@ previously issued *extension* directives, but only for the _behaviors_

The initial state of the compiler is as if the directive

[source,c++]
[source,glsl]
----
#extension all : disable
----
Expand All @@ -627,7 +627,7 @@ The macro is always defined in an implementation that supports the
extension.
This allows the following construct to be used:

[source,c++]
[source,glsl]
----
#ifdef OES_extension_name
#extension OES_extension_name : enable
Expand All @@ -640,7 +640,7 @@ endif::ESSL[]

*#line* must have, after macro substitution, one of the following forms:

[source,c++]
[source,glsl]
----
#line line
#line line source-string-number
Expand Down Expand Up @@ -669,15 +669,15 @@ ifdef::GLSL[]
When shaders are compiled for {apiname} SPIR-V, the following predefined
macro is available:

[source,c++]
[source,glsl]
----
#define GL_SPIRV 100
----
endif::GLSL[]

When targeting Vulkan, the following predefined macro is available:

[source,c++]
[source,glsl]
----
#define VULKAN 100
----
Expand Down Expand Up @@ -713,7 +713,7 @@ occurs before comments are processed.
That is, a single-line comment ending in the line-continuation character
(*+\+*) includes the next line in the comment.

[source,c++]
[source,glsl]
----
// a single-line comment containing the next line \
a = b; // this is still in the first comment
Expand Down Expand Up @@ -993,7 +993,7 @@ loop, then control flow reconverges to be uniform.

For example:

[source,c++]
[source,glsl]
----
main()
{
Expand Down
8 changes: 4 additions & 4 deletions chapters/builtinfunctions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ For the texture sampling and image load functions, the
precision of the return type matches the precision of the
image or texture-combined sampler type:

[source,c++]
[source,glsl]
----
uniform lowp sampler2D texSampler;
highp vec2 coord;
Expand Down Expand Up @@ -421,7 +421,7 @@ endif::GLSL[]
a smooth transition.
This is equivalent to:
--
[source,c++]
[source,glsl]
----
genFType t;
t = clamp ((x - edge0) / (edge1 - edge0), 0, 1);
Expand Down Expand Up @@ -1107,7 +1107,7 @@ fractional part of the computed and clamped level-of-detail.

The algorithm used is given by the following pseudo-code:

[source,c++]
[source,glsl]
----
float ComputeAccessedLod(float computedLod)
{
Expand Down Expand Up @@ -1687,7 +1687,7 @@ ifdef::GLSL[]
endif::GLSL[]
a| Returns the value +
--
[source,c++]
[source,glsl]
----
vec4(Sample_i0_j1(P, base).comp,
Sample_i1_j1(P, base).comp,
Expand Down
Loading

0 comments on commit c2e1856

Please sign in to comment.