Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
GrayScott Reloaded - Rust practical
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
GRASLAND Hadrien
GrayScott Reloaded - Rust practical
Commits
5f2791a2
Commit
5f2791a2
authored
9 months ago
by
Hadrien Grasland
Browse files
Options
Downloads
Patches
Plain Diff
Review chapter 22
parent
1bee23fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
handouts/src/22-shady-business.md
+18
-17
18 additions, 17 deletions
handouts/src/22-shady-business.md
with
18 additions
and
17 deletions
handouts/src/22-shady-business.md
+
18
−
17
View file @
5f2791a2
...
...
@@ -19,10 +19,10 @@ programming language you like to write the GPU-side code. All you need is a new
compiler backend that emits SPIR-V instead of machine code.
Sadly, compiler backends are big pieces of work, so Rust is not quite there yet.
All we have today is
[
a promising prototype
around
called
All we have today is
[
a promising prototype called
`rust-gpu`
](
https://github.com/EmbarkStudios/rust-gpu
)
. I hope to introduce it
in a future edition of this course[^1], but
what I read in its bugtracker, it
felt a bit too experimental for
this year's edition.
in a future edition of this course[^1], but
it felt a bit too experimental for
this year's edition.
Therefore, we will prefer the tried and true alternative of Khronos' standard
GPU programming language: the OpenGL Shading Language, or GLSL for short.
...
...
@@ -54,19 +54,19 @@ To give some examples, in GLSL you can easily...
-
Allow the value of a compilation constant to be specified before the shader's
SPIR-V is compiled into a device binary, to improve configurability and
compiler optimizations.
-
A more extensive library of built-in functions than C could ever dream of.
-
Enjoy a more extensive library of built-in math functions than C could ever
dream of.
-
...and many other things revolving around the high-speed drawing of textured
triangles that we will not care much about in everyday numerical
computing.[^4]
As you can see, this opens quite a few interesting possibilities. And that's
part of why
`rust-gpu`
is still experimental in spite of having been in
development for quite a while. Making a new GPU programming language is actually
not only a matter of adding a SPIR-V backend to the compiler (which is already
quite a piece of work), it's also a matter of extending the source programming
language (possibly via a library of functions implemented in SPIR-V "assembly")
to expose all the GPU features that GPU-specific programming languages have been
supporting forever.[^5]
development for quite a while. Making a _good_ new GPU programming language is
actually not only a matter of adding a SPIR-V backend to the compiler (which is
already a large amount of work), it's also a matter of extending the source
programming language and its standard library to expose all the GPU features
that GPU-specific programming languages have been exposing forever.[^5]
## Our first GLSL Gray-Scott
...
...
@@ -127,9 +127,8 @@ There is a fair bit to unpack here:
-
`params`
is a struct that lets us pass simulation parameters to the GPU code.
Notice that unlike the CPU code, the GPU code does not know about some
computation parameters at compile time, which puts it at a slight performance
disadvantage. By using specialization constants, we could reverse this
situation and let the GPU compiler know about
**all**
simulation parameters at
compile time using specialization constants.
disadvantage. By using specialization constants, we could reverse this and let
the GPU code know about
**all**
simulation parameters at compile time.
-
All variables introduced so far are
`uniform`
s, which means that all
work-items (same thing as CUDA threads) in a given shader execution agree on
their value. This greatly improves GPU code performance by letting the GPU
...
...
@@ -137,12 +136,12 @@ There is a fair bit to unpack here:
computations, and is in fact mandatory for images and samplers.
-
To enable binding associated resources from the CPU side, each of these inputs
and outputs is assigned a set and binding number. Here, we have made all
inputs and outputs part of set 0, and parameters part of set 1.
Here the two
layer
set-
>
binding hierarchy lets us flip simulation inputs
and
outputs
without needing to rebind unchanging
simulation
parameters.
inputs and outputs part of set 0, and
all
parameters part of set 1.
Thi
set-binding hierarchy lets us flip simulation inputs
/
outputs
in a single API
transaction,
without needing to rebind unchanging parameters.
-
Finally, we specify the work-group size, which is Vulkan's equivalent of
CUDA's thread-block size. For now, we hardcode it in the shader code, but
later we c
an
make it runtime-configurable using specialization constants.
later we c
ould
make it runtime-configurable using specialization constants.
---
...
...
@@ -307,6 +306,8 @@ version of each type from the input GLSL code. All we need to do is to
expose it so other code can use it:
```
rust,ignore
/// Simulation parameters, in a GPU-friendly layout
///
/// This syntax lets you re-export a type defined in another module as if you
/// defined said type yourself
pub
use
shader
::
Parameters
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment