# HG changeset patch # User Leonard Ritter # Date 1696957893 -7200 # Tue Oct 10 19:11:33 2023 +0200 # Node ID 16d5d835453c702a5395be1222b612c6c6f6b7e1 # Parent be318e37013f5d4ab4b659e31a5b9ce410928b16 * fixed code for recent scopes updates diff --git a/lib/tukan/GUI.sc b/lib/tukan/GUI.sc --- a/lib/tukan/GUI.sc +++ b/lib/tukan/GUI.sc @@ -52,7 +52,7 @@ io.ConfigFlags |= do #| - ImGuiConfigFlags_NavEnableKeyboard + GuiConfigFlags_NavEnableKeyboard #ImGuiConfigFlags_ViewportsEnable # ImGuiConfigFlags_NavEnableKeyboard diff --git a/lib/tukan/bitmap.sc b/lib/tukan/bitmap.sc --- a/lib/tukan/bitmap.sc +++ b/lib/tukan/bitmap.sc @@ -29,7 +29,7 @@ #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) diff --git a/lib/tukan/gl.sc b/lib/tukan/gl.sc --- a/lib/tukan/gl.sc +++ b/lib/tukan/gl.sc @@ -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 itertools using import chaining +using import compiler.target.SPIR-V + #if (operating-system == 'windows) load-library "opengl32.dll" #else @@ -16,16 +20,14 @@ 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 @@ 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 @@ #------------------------------------------------------------------------------- -using GL filter "^(Create|Delete)Textures$" +using GL filter "^(CreateTextures|DeleteTextures)$" typedef GLtexture < GLobject :: GLuint inline __typecall (cls target) @@ -186,7 +188,7 @@ #------------------------------------------------------------------------------- -using GL filter "^(Create|Delete)Queries$" +using GL filter "^(CreateQueries|DeleteQueries)$" typedef GLquery < GLobject :: GLuint inline __typecall (cls target) @@ -201,7 +203,7 @@ #------------------------------------------------------------------------------- -using GL filter "^(Create|Delete)Buffers$" +using GL filter "^(CreateBuffers|DeleteBuffers)$" typedef GLbuffer < GLobject :: GLuint inline __typecall (cls target) @@ -212,7 +214,7 @@ #------------------------------------------------------------------------------- -using GL filter "^(Create|Delete)VertexArrays$" +using GL filter "^(CreateVertexArrays|DeleteVertexArrays)$" typedef GLvertexarray < GLobject :: GLuint inline __typecall (cls target) @@ -223,9 +225,10 @@ #------------------------------------------------------------------------------- -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 @@ #------------------------------------------------------------------------------- -using GL filter "^(Create|Delete)Framebuffers$" +using GL filter "^(CreateFramebuffers|DeleteFramebuffers)$" typedef GLframebuffer < GLobject :: GLuint inline __typecall (cls) @@ -245,7 +248,7 @@ #------------------------------------------------------------------------------- -using GL filter "^(Create|Delete)Renderbuffers$" +using GL filter "^(CreateRenderbuffers|DeleteRenderbuffers)$" typedef GLrenderbuffer < GLobject :: GLuint inline __typecall (cls) @@ -345,7 +348,7 @@ 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 @@ 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 @@ 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 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; diff --git a/lib/tukan/hash.sc b/lib/tukan/hash.sc --- a/lib/tukan/hash.sc +++ b/lib/tukan/hash.sc @@ -141,6 +141,7 @@ ################################################################################ do + let triple32 let f32hash f32hashuv vec2hash vec2hashuv vec3hash vec3hashuv let wang-hash hpush hpop locals; diff --git a/lib/tukan/imgui/cimgui.sc b/lib/tukan/imgui/cimgui.sc --- a/lib/tukan/imgui/cimgui.sc +++ b/lib/tukan/imgui/cimgui.sc @@ -17,9 +17,9 @@ #include 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; diff --git a/lib/tukan/libc.sc b/lib/tukan/libc.sc deleted file mode 100644 --- a/lib/tukan/libc.sc +++ /dev/null @@ -1,26 +0,0 @@ - -vvv bind C -include - """"#include - #include - #include - #include - - 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; diff --git a/lib/tukan/pcg.sc b/lib/tukan/pcg.sc --- a/lib/tukan/pcg.sc +++ b/lib/tukan/pcg.sc @@ -14,7 +14,7 @@ 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; diff --git a/lib/tukan/sdl.sc b/lib/tukan/sdl.sc --- a/lib/tukan/sdl.sc +++ b/lib/tukan/sdl.sc @@ -30,10 +30,10 @@ } 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 diff --git a/testing/test_cascade_dmc_cc_vvf.sc b/testing/test_cascade_dmc_cc_vvf.sc --- a/testing/test_cascade_dmc_cc_vvf.sc +++ b/testing/test_cascade_dmc_cc_vvf.sc @@ -4,6 +4,8 @@ VVF -> volumetric vertex field + with hierarchical Z-buffer + define-infix< 40 , _ using import glm @@ -13,7 +15,6 @@ using import Box using import struct using import Option -import ..lib.tukan.use import tukan.voxel let voxel = tukan.voxel @@ -1538,7 +1539,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 diff --git a/testing/testfragment.sc b/testing/testfragment.sc --- a/testing/testfragment.sc +++ b/testing/testfragment.sc @@ -6,7 +6,7 @@ using import tukan.GLMain using import tukan.Screen -using import tukan.GUI +#using import tukan.GUI using import tukan.gl using import tukan.sdl