With el-gpu one can draw on the GPU from GNU Emacs and Emacs Lisp.
For example, to draw a cube at coordinates
x = 0,
y = 0, and
z = 4000
with a dimension
d = 2000, evaluate
(el-cube 0 0 4000 2000)el-gpuold 2D Elisp with new 3D C/GLSLinstances for drawing effects
random access
instances for speed with indirect drawing
el-shell is an Emacs script (a file with
a hash-bang to an Emacs binary followed by Elisp code) that executes
a command as if it was a one-shot terminal emulator - it will run
a command, and the gpu outputs the result with or without graphics, or,
for testing purposes, here it does both, in randomized order, to compare
fairly. With graphics it typically takes 1.5x the time, so ~4.5 ms.
At the point when the GPU renders the text, the chars are textures, so
to the GPU, and us, they are graphics as well. The term is
glyph.
Here is a collection of execution
stats. It is
measured, not approximated, from the previous run and outputted to
stdout by the application. OpenGL has features so one can clamp it tight
around a singular call to track GPU time,
i.e., shader work with GLSL, code that is uploaded to the GPU by
the driver, then compiled and linked there, and thereafter will execute
exclusively on the GPU. This is real 3D rendering; a GPU can also render
stuff that is prepared on the CPU - useful, sometimes - but a sideshow,
this is the real deal. And also, of course, much better. In the stats
we see that we are spending some
11 213 quality
milliseconds with the GPU drawing
44 318 720 instances of
688 628 triangles, each triangle - the triangle being
the pixel of 3D graphics - consisting of 3 vertices, each vertex - the
vertex being the singular point of 3D geometry - with a position in x,
y, z space, something we can express in Elisp with a vector,
`[,x ,y ,z ] or
(vector x y z); in C we can typedef a
float [3] array or use types provided by the SDL. On the
GPU, if we return to GLSL, there are
mat3 and
mat4 (3x3 and 4x4 matrices) and
vec2,
vec3, and
vec4 for vectors
- so yes, GLSL is a language for a specific purpose, and it
comes prepared.
meta programming
4K resolution is big, and known as UHD, in Japan 🇯🇵
In the reddit post, what is referred to as a "glyph atlas" - a data
structure solution for drawing text on the GPU - is actually a
texture array (okay) the difference being that the glyph atlas
consists of a single consecutive chunk of data, and at one point in time
this was preferred as there was an overhead implied to any swapping
between textures. This isn't a problem anymore which is why the texture
array with individual textures for each letter is considered
more modern.
To be 100% correct, while true that swapping isn't a problem
anymore, it also doesn't happen with texture arrays, because all
tho the textures are uploaded one glyph at a time, the array itself is
aligned. So it is better because textures are individual
and together.