M lib/tukan/GUI.sc +1 -1
@@ 52,7 52,7 @@ fn _init (glmain)
io.ConfigFlags |=
do #|
- ImGuiConfigFlags_NavEnableKeyboard
+ GuiConfigFlags_NavEnableKeyboard
#ImGuiConfigFlags_ViewportsEnable
# ImGuiConfigFlags_NavEnableKeyboard
M lib/tukan/bitmap.sc +1 -1
@@ 29,7 29,7 @@ let stbi =
#include "tukan/stb_image_ex.h"
#include "tukan/stb_image_write.h"
-using stbi.extern filter "^(stbi(.+)|STBI(.+))$"
+using stbi.extern filter "^stbi.+|STBI.+$"
fn init-bitmap (bmp count)
let cls = (typeof bmp)
M lib/tukan/gl.sc +36 -27
@@ 1,5 1,7 @@
+using import slice print
+
import .core
-using import .libc
+using import C.stdio
using import .globals
using import glsl
using import glm
@@ 7,6 9,8 @@ using import glm
using import itertools
using import chaining
+using import compiler.target.SPIR-V
+
#if (operating-system == 'windows)
load-library "opengl32.dll"
#else
@@ 16,16 20,14 @@ vvv bind _GL
include "glad.h"
fn translate-gl-symbols (scope source)
+ pattern := str"^gl([A-Z].*)|GL_(.*)|GL([a-z].*)$"
fold (GL = scope) for k v in source
let k = (k as Symbol as string)
- let s = (k as rawstring)
- if ((countof k) < 3)
- continue;
- let c0 c1 = (s @ 0) (s @ 1)
- let gl? = (((c0 == 103) & (c1 == 108)) | ((c0 == 71) & (c1 == 76)))
+ gl? i := ('match? pattern k)
if gl?
- let k = (rslice k (? ((s @ 2) == 95) 3 2))
- 'bind GL (Symbol k) v
+ let k = (rslice k i)
+ GL := 'bind GL (Symbol k) v
+ GL
else GL
--> (Scope)
@@ 104,7 106,7 @@ spice process-framebuffer-options (id op
sc_expression_append block
`(glNamedFramebufferRenderbuffer id GL_DEPTH_ATTACHMENT GL_RENDERBUFFER arg)
else
- error (.. "unknown key for argument: " (repr key))
+ error (.. str"unknown key for argument: " ((repr key) as string))
sc_expression_append block
`(_ i target-idx color-layer depth-layer)
block
@@ 171,7 173,7 @@ typedef GLobject < immutable
#-------------------------------------------------------------------------------
-using GL filter "^(Create|Delete)Textures$"
+using GL filter "^(CreateTextures|DeleteTextures)$"
typedef GLtexture < GLobject :: GLuint
inline __typecall (cls target)
@@ 186,7 188,7 @@ typedef GLtexture < GLobject :: GLuint
#-------------------------------------------------------------------------------
-using GL filter "^(Create|Delete)Queries$"
+using GL filter "^(CreateQueries|DeleteQueries)$"
typedef GLquery < GLobject :: GLuint
inline __typecall (cls target)
@@ 201,7 203,7 @@ typedef GLquery < GLobject :: GLuint
#-------------------------------------------------------------------------------
-using GL filter "^(Create|Delete)Buffers$"
+using GL filter "^(CreateBuffers|DeleteBuffers)$"
typedef GLbuffer < GLobject :: GLuint
inline __typecall (cls target)
@@ 212,7 214,7 @@ typedef GLbuffer < GLobject :: GLuint
#-------------------------------------------------------------------------------
-using GL filter "^(Create|Delete)VertexArrays$"
+using GL filter "^(CreateVertexArrays|DeleteVertexArrays)$"
typedef GLvertexarray < GLobject :: GLuint
inline __typecall (cls target)
@@ 223,9 225,10 @@ typedef GLvertexarray < GLobject :: GLui
#-------------------------------------------------------------------------------
-using GL filter "^(Create|Delete)Program$"
+using GL filter "^(CreateProgram|DeleteProgram)$"
typedef GLprogram < GLobject :: GLuint
+
inline __typecall (cls target)
bitcast (CreateProgram) this-type
@@ 234,7 237,7 @@ typedef GLprogram < GLobject :: GLuint
#-------------------------------------------------------------------------------
-using GL filter "^(Create|Delete)Framebuffers$"
+using GL filter "^(CreateFramebuffers|DeleteFramebuffers)$"
typedef GLframebuffer < GLobject :: GLuint
inline __typecall (cls)
@@ 245,7 248,7 @@ typedef GLframebuffer < GLobject :: GLui
#-------------------------------------------------------------------------------
-using GL filter "^(Create|Delete)Renderbuffers$"
+using GL filter "^(CreateRenderbuffers|DeleteRenderbuffers)$"
typedef GLrenderbuffer < GLobject :: GLuint
inline __typecall (cls)
@@ 345,7 348,7 @@ inline attach-shaders (program opts...)
let source =
static-if ((typeof source) == string) source
else
- static-compile-glsl 0 stage
+ static-compile-glsl SPV_ENV_OPENGL_4_2 stage
static-typify source
#'no-debug-info
static-if (va-option debug opts... false)
@@ 824,8 827,9 @@ fn setup-framebuffer (id opts...)
glNamedFramebufferDrawBuffers id target-idx buffers
let status = (glCheckNamedFramebufferStatus id GL_FRAMEBUFFER)
- assert (status == GL_FRAMEBUFFER_COMPLETE)
- .. "Framebuffer incomplete: " (framebuffer-status status)
+ if (status != GL_FRAMEBUFFER_COMPLETE)
+ print "Framebuffer incomplete: " (framebuffer-status status)
+ assert false "framebuffer incomplete"
id
@@ 894,18 898,23 @@ fn get-uniform-dispatch-by-element-type
case mat4 `[(mat-type-uniform-func GL.UniformMatrix4fv)]
default
error
- .. "unsupported uniform type: " (repr ET)
+ .. "unsupported uniform type: "
+ (repr ET) as string
spice Uniform (glxvar value)
let location = (sc_global_location glxvar)
assert (location >= 0) "uniform needs a location attribute"
let storage-class = (sc_global_storage_class glxvar)
if (storage-class != 'UniformConstant)
- hide-traceback;
- error@ ('anchor glxvar) "while checking glUniform call"
- .. "storage class " (repr 'UniformConstant) " expected, got " (repr storage-class)
+ #hide-traceback;
+ trace-checking-argument glxvar
+ trace-error "while checking glUniform call"
+ .. "storage class "
+ (repr 'UniformConstant) as string
+ " expected, got "
+ (repr storage-class) as string
let f = (get-uniform-dispatch-by-element-type ('typeof glxvar))
- 'tag `(f location value) ('anchor args)
+ `(f location value)
#-------------------------------------------------------------------------------
@@ 954,14 963,14 @@ fn hook-gl-debug ()
fn gl-debug-callback (source type_ id_ severity length message userparams)
#void <- (GLenum GLenum GLuint GLenum GLsizei GLchar* void*)
- fflush (stdout)
- fprintf (stderr) "%s:%s:%x:%s:%s\n"
+ fflush stdout
+ fprintf stderr "%s:%s:%x:%s:%s\n"
(gl-debug-source source) as rawstring
(gl-debug-type type_) as rawstring
id_
(gl-debug-severity severity) as rawstring
message
- fflush (stderr)
+ fflush stderr
if (type_ == GL.DEBUG_TYPE_ERROR)
sc_set_signal_abort true
sc_abort;
M lib/tukan/hash.sc +1 -0
@@ 141,6 141,7 @@ inline... hpop (a : u64, b : u64)
################################################################################
do
+ let triple32
let f32hash f32hashuv vec2hash vec2hashuv vec3hash vec3hashuv
let wang-hash hpush hpop
locals;
M lib/tukan/imgui/cimgui.sc +3 -3
@@ 17,9 17,9 @@ include
#include <stdio.h>
do
- using lib.typedef filter "^(ig(.+)|Im(.+))$"
- using lib.extern filter "^(ig(.+)|Im(.+))$"
- using lib.const filter "^(ig(.+)|Im(.+))$"
+ using lib.typedef filter "^ig.+|Im.+$"
+ using lib.extern filter "^ig.+|Im.+$"
+ using lib.const filter "^ig.+|Im.+$"
locals;
R lib/tukan/libc.sc => +0 -26
@@ 1,26 0,0 @@
-
-vvv bind C
-include
- """"#include <stdint.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- FILE *get_stdout () {
- return stdout;
- }
- FILE *get_stderr () {
- return stderr;
- }
-
-do
- using C.extern filter
- "^(f?printf|fflush|get_std(.+)|abort|strlen|memcpy|memcmp|memset)$"
-
- let
- stdout = get_stdout
- stderr = get_stderr
-
- let abort = (bitcast abort (@ (function noreturn)))
-
- locals;
M lib/tukan/pcg.sc +1 -1
@@ 14,7 14,7 @@ spice type-error (T types...)
return `()
error
.. "illegal input type. try one of"
- fold (a = "") for b in ('args types...)
+ fold (a = str"") for b in ('args types...)
.. a " " (repr (b as type))
run-stage;
M lib/tukan/sdl.sc +4 -4
@@ 30,10 30,10 @@ include
}
do
- using SDL.define filter "^(SDL(.+))$"
- using SDL.const filter "^(SDL(.+)|KMOD(.+))$"
- using SDL.typedef filter "^(SDL(.+))$"
- using SDL.extern filter "^(_wrap_SDL(.+)|SDL(.+)|ImGui_Impl(.+))$"
+ using SDL.define filter "^SDL.+$"
+ using SDL.const filter "^SDL.+|KMOD.+$"
+ using SDL.typedef filter "^SDL.+$"
+ using SDL.extern filter "^_wrap_SDL.+|SDL.+|ImGui_Impl.+$"
let SDL_CreateThread = _wrap_SDL_CreateThread
M testing/test_cascade_dmc_cc_vvf.sc +10 -10
@@ 4,6 4,8 @@
VVF -> volumetric vertex field
+ with hierarchical Z-buffer
+
define-infix< 40 , _
using import glm
@@ 13,7 15,6 @@ using import Array
using import Box
using import struct
using import Option
-import ..lib.tukan.use
import tukan.voxel
let voxel = tukan.voxel
@@ 1538,7 1539,7 @@ inout matdata : vec4
fn rasterize-vert ()
#let vertex-index = ((deref gl_VertexID) as u32)
vertex-index := gl_InstanceID * InstanceVertexCount + gl_VertexID
- let vin = (deref (vertex-in.entries @ vertex-index))
+ let vin = (vertex-in.entries @ vertex-index)
let coord = (vec3 vin.pos.xyz)
let lod = (vin.pos.w as f32)
@@ 2080,8 2081,7 @@ inline main ()
if ((frame % 60) == 0)
print-in-count "all" vertex_buffer
- vvv bind setup-draw-arrays exec-draw-arrays
- indirect-draw-arrays-setup
+ ida := static IndirectDrawArrays
inline ()
_
InstanceVertexCount
@@ 2095,7 2095,7 @@ inline main ()
BINDING_BUF_VERTEX_IN
vertex_buffer
\ 0:i64 (i64 vertex_buffer_sz)
- setup-draw-arrays;
+ 'setup ida
struct HZB
framebuffer : GL.Framebuffer
@@ 2140,7 2140,7 @@ inline main ()
GL.UseProgram pg-rasterize-hzb
GL.BindVertexArray vao-empty
- exec-draw-arrays GL.TRIANGLE_FAN
+ 'execute ida GL.TRIANGLE_FAN
GL.Disable GL.DEPTH_TEST
GL.Disable GL.CULL_FACE
@@ 2284,7 2284,7 @@ inline main ()
BINDING_BUF_VERTEX_IN
frame_vertex_buffer
\ 0:i64 (i64 vertex_buffer_sz)
- setup-draw-arrays;
+ 'setup ida
do
GL.BindFramebuffer GL.FRAMEBUFFER fb-scene
@@ 2307,11 2307,11 @@ inline main ()
GL.UseProgram pg-rasterize
GL.BindVertexArray vao-empty
- #exec-draw-arrays GL.TRIANGLES
+ #execute ida GL.TRIANGLES
static-if DRAW_LINES
- exec-draw-arrays GL.LINE_LOOP
+ 'execute ida GL.LINE_LOOP
else
- exec-draw-arrays GL.TRIANGLE_FAN
+ 'execute ida GL.TRIANGLE_FAN
GL.Disable GL.DEPTH_TEST
GL.Disable GL.CULL_FACE
GL.BindFramebuffer GL.FRAMEBUFFER 0
M testing/testfragment.sc +1 -1
@@ 6,7 6,7 @@ using import Capture
using import tukan.GLMain
using import tukan.Screen
-using import tukan.GUI
+#using import tukan.GUI
using import tukan.gl
using import tukan.sdl