Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions builtin-programs/gpu/page-shader.folk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
set cc [C]
$cc include <string.h>
$cc include <openssl/sha.h>
$cc proc sha1 {char* d} Jim_Obj* {
unsigned char md[20];
SHA1((unsigned char *)d, strlen(d), md);
return Jim_NewStringObj(interp, (char *)md, 20);
}
$cc endcflags -lssl -lcrypto
set sha1Lib [$cc compile]


When /someone/ wishes /p/ draws shader /shaderCode/ {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue has the example "draws pixel shader." I like the specificity. We could also call it "fragment shader"

binary scan [$sha1Lib sha1 $shaderCode] H* sha1

Wish the GPU compiles pipeline $sha1 [list \
{vec2 viewport mat3 surfaceToClip} {
vec2 vertices[6] = vec2[6](
vec2(0.0, 0.0), vec2(1.0, 0.0), vec2(1.0, 1.0),
vec2(0.0, 0.0), vec2(1.0, 1.0), vec2(0.0, 1.0)
);
vec3 v = surfaceToClip * vec3(vertices[gl_VertexIndex], 1.0);
return vec4(v.xy/v.z, 0.0, 1.0);
} $shaderCode]

When the GPU compiles pipeline $sha1 to /anything/ & \
$p has canvas /id/ with /...wiOptions/ & \
$p has canvas projection /surfaceToClip/ {
puts "the GPU compiled the pipeline"
set wiResolution [list [dict get $wiOptions width] [dict get $wiOptions height]]

Wish the GPU draws pipeline $sha1 onto canvas $id \
with arguments [list $wiResolution $surfaceToClip ]
}
}