A triangle has 3 sides. Each one takes 13,000 lines of code to draw. The amount of code to draw stuff always seems daunting regardless of the tech stack chosen. Excellent vid!
@contextfree Жыл бұрын
Thanks! Helper libraries are useful for this, and presumably some already exist out there for webgpu.h (though I haven't gone looking much). I also plan to have easy mode apis just for taca to make direct coding much shorter and more fun and for smaller wasm binaries.
@volodumurkalunyak4651 Жыл бұрын
It doesnt take 13 000 × 2 lines of code to render 2 triangles, but somewhere in 13002 - 13006 range. 100 triangles - 13 010-13 100 lines of code, NOT 1 300 000.
@binary132 Жыл бұрын
99.9% of that is just setup, a little bit of abstraction goes a long way
@somebody_on_the_internetz Жыл бұрын
🎉 nice stuff. Fascinating how you were able to glue that all together
@rolandinnamorato1953 Жыл бұрын
The absolute state of modern native software development
@bandaloo7776 Жыл бұрын
i think it’s totally fine to inline the GLSL source code directly in the binary! seems to be a game dev tradition at this point. i really like the simplicity of it - shaders are (usually) simple and it makes ad-hoc metaprogramming of shaders easy, which imo is appropriate for shader code
@nathanfranck5822 Жыл бұрын
This looks fun! If you ever get to making a launcher and customizable installer for this (think gog galaxy) I would totally throw my hat in the ring to make a gimicky arcade game for this platform
@kualta Жыл бұрын
this looks interesting, great work!
@kenneth_romero Жыл бұрын
can't wait for flash games to comeback as webgpu games. Hopefully they get the API dead simple for people to make the applications they want
@irishbruse Жыл бұрын
Webgpu is intended for more 3d intensive games we already have webgl and flash is so completely different that every flash game has to be rebuilt from scratch
@tidus4400 Жыл бұрын
Yeah I’ve read somewhere that the api won’t be simpler simply because it’s not intended to be used by “us” but I may be mixing things up with webgl
@shalokshalom Жыл бұрын
There is something like that
@maximumcockage6503 Жыл бұрын
On Newgrounds they have wasm converters so Flash still works, but everyone pretty much moved to javascript and webGL or ports of their games in WASM. There's actually more choices for games than ever on the browser thanks to Flash emulation through wasm.
@AmericanJeff Жыл бұрын
In the demo I notice that the rotation seems to be janking a little bit here and there. Can't tell if that's from the way it's captured or if it's also happening live. Any idea what's causing it?
@contextfree Жыл бұрын
I'm afraid some of it is from the original, as it takes careful observation, but I'm afraid some of it might be. If so, I'm not sure what's causing it. I think the rendering calls I've borrowed from the tutorial are supposed to avoid that kind of thing. I'll have to do closer analysis sometime.
@contextfree Жыл бұрын
I checked, and I'm supposedly on auto vsync. I had some extra manual delays happening that might have been trouble. I removed that now, and it still seems occasionally a touch janky but maybe improved? Using 6% CPU, so that should be ok, at least.
@michaelscofield4524 Жыл бұрын
Love the videos man, keep it up!
@edgeeffect10 ай бұрын
I've always aimed at 100 - 200 SLOC per file... so I find describing 1400 lines as "relatively large" kinda funny. When playing the game of "our codebase is worse than your codebase" with colleagues, I often quote our 1000+ SLOC files as one of the "awful" things I have to contend with. :)
@xade8381 Жыл бұрын
Nim also support WASM, waiting for it to get seamless
@contextfree Жыл бұрын
I'd love to get a Nim demo going for this for sure.
@spotandjake1008 Жыл бұрын
looks cool, cant wait to play with webgpu from grain.
@contextfree Жыл бұрын
Yeah, I really want to build demos for more languages, especially ones that are less like C.
@contextfree Жыл бұрын
Would it be easy to write bindings in Grain to match these header file definitions?
@spotandjake1008 Жыл бұрын
@@contextfree I havent looked over the header file's personaly but cant imagine it would be too hard. you could probably write wit bindings and generate them to some degree, as things get more complex.
@spotandjake1008 Жыл бұрын
Looked a little closer at this, you are going to have a slightly issue where grain doesnt let you export the function table but with a single line compiler change that can be fixed. the rest seems pretty straight forward the hard part is interoping between the higher level grain types and the lower level wasm types but its pretty easy. I might play arround with it a bit more later and see if i can get anything useable.
@contextfree Жыл бұрын
Thanks for looking closer! And yeah, the function table export is pretty vital here. I was surprised how hard it was for me to find the right compiler switch to enable that in Zig. (Though the switch is fairly well named, it turns out.)
@jeremycoleman3282 Жыл бұрын
hey, just wanted to say that imo size doesnt really matter, like at all, for wasm, even if its web focused. Consider that, for desktops with fast network nothing matters its going to be fast af anyway and for slow mobile devices the consideration (compared to javascript) is parsing time not dl time - and wasm parsing is super fast. also, size optimized wasm usually runs slower, sometimes way slower, especially some of the rust tooling really deoptimizes your code. so, i'd suggest looking at other metrics than just code size. thanks for all the great content, hoping to maybe save you some frustration and time with the above info.
@pixelusion23117 ай бұрын
Is it possible to use WebGPU without webpack and node.js stuff? Just pure WebGPU and browser?
@contextfree7 ай бұрын
Yes, that works, although I didn't do any browser nor js stuff here.
@AlleBalle54 Жыл бұрын
really cool, great work
@porky1118 Жыл бұрын
0:50 WGPU is made by Mozilla? I thought it was created when rust gamedevs used gfx-rs as a graphics library, which wasn't low level enough, so they created gfx-hal, but then they created wgpu instead and not sure if gfx-hal still exists.
@contextfree Жыл бұрын
Digging in docs and contributors, Firefox uses it, but they still officially call it "independent", so formally, I think you're correct. The top contributor, Dzmitry Malyshau, used to work for Mozilla but seems to have left 1 1/2 years ago. 2nd has no Mozilla affiliation. 3rd/4th (depending on how you count) works for Mozilla. So, while Mozilla has/had some influence, I think you're right that I overstated this in the video.
@contextfree Жыл бұрын
Dzmitry also seems to have stopped working on the project, though I didn't compare dates carefully. The other two I mentioned seem to be the top contributors today.
@linkernick5379 Жыл бұрын
I like that euphemism "Brrrr" 😊
@MrAbrazildo Жыл бұрын
0:40, Tomb Raider 2023, running straight from your web browser! 3:25, you don't need to attribute all values, since enum does it for you, increasing by 1 each of them. I just use the 1st value, since I don't trust this default (it already changed in the past), and some value which runs away from the sequence, like your bits mask.
@contextfree Жыл бұрын
Yeah, I felt like being explicit here, even though it increments by default. And I'm not sure I like the "Force32" thing. I was copying that idea from webgpu.h just to see how I felt about it.
@VictorRodriguez-zp2do Жыл бұрын
4:06 - D has nice C interop but you can't just include C header files, you have to first compile the C code, then link it and write bindings for the functions you need. It's easier than it sounds but it still requires you to use a C compiler in your build process
@contextfree Жыл бұрын
There's the relatively new ImportC feature, which is still a work in progress. I'm not sure of the current state. Have you tried it out? I haven't, so I can't speak well to it. forum.dlang.org/thread/u2el6n$1tee$1@digitalmars.com
@contextfree Жыл бұрын
And I'm not sure the official docs are caught up with the latest status. It's unclear to me. dlang.org/spec/importc.html
@asandax6 Жыл бұрын
I think many languages have ffi for linking with C.
@VictorRodriguez-zp2do Жыл бұрын
@@contextfreeI had never used importC until you mentioned. That said importC only works with `.c` and `.i` files. That said you can easily make a wrapper c file like somelib.c that only contains: `# include ` Then you run it with `dmd somelib.c` and at least on my testing (trying a small sdl + OpenGL application) it works fine. That being said the documentation still lacks a lot of important details and on my tests it fails on complex C projects that use the pre-processor a lot (in DMD). But if you use the `gdc` compiler everything seems to work perfectly. I tested it with all the C projects in my computer (I do a lot of OpenGL stuff) and it all worked perfectly with the gdc compiler 👍
@VictorRodriguez-zp2do Жыл бұрын
Which is unsurprising considering gdc is pretty much GCC for D
@justafreak15able Жыл бұрын
I've no idea what i just saw but this is very interesting. I am also intrigued by webgpu and it's capabilities. But don't know much about system programming languages or sharder programming or gpu programming. And I am still amazed by how you have inter op the Rust and Zig+C code. How is does that work? And also how can start doing cool shit like this? Where should I start can you give me a roadmap?
@contextfree Жыл бұрын
WebAssembly or Wasm is a binary format designed originally to run in browsers. You can compile various languages to it. But various Wasm engines exist outside browsers as well, like the one I'm using here. If you just want Rust calling Zig, you don't need it. You could compile either to a C-like library and use it from the other. Are you most interested in running code in a Wasm engine or most interested in just learning a systems language or most interested in interop?
@BenjaminAster Жыл бұрын
CodyJasonBennett's shaderkit has a WGSL minifier.
@contextfree Жыл бұрын
Thanks much!
@trainerprecious1218 Жыл бұрын
why we needed C again? didn’t quite get that part
@109Rage Жыл бұрын
The C in here is just used as an interface-Dawn and wgpu are written in C++ and Rust, but each expose a C api, so that applications written in other languages can use them. Some languages make it easier to use that C api than others, tho.
@LuizMoraes-xb7qj Жыл бұрын
Cool, I am also starting a web gpu project now. I just didn't understand why did you choose to run it outside of the browser. Isn't that the whole point of webgpu? From what I understood, with your approach you could write a single code that would work both on the browser and outside of it?
@contextfree Жыл бұрын
My idea is not to need the browser, yeah. Because browsers are big and bulky. This should have a lot lower overhead (and currently does if you notice the ram usage numbers in the video). But I hope to create an implementation for browser as well at some point. And the same wasm app file should just load in the client either way once that is done.
@antifa_communist Жыл бұрын
@@contextfreebut why do you need WebGPU to run not on the web?
@ZhilBear Жыл бұрын
@@antifa_communist universal code, same reason why WebAssembly might actually become more popular outside the browser than in
@chewbaccarampage Жыл бұрын
@@ZhilBear So true, I'm at a company that maintains a desktop app using DirectX, but a third-party vendor provides their libraries in OpenGL. Having the two interface is a big pain. The third-party is now moving to WebGPU to help reduce the pain.
@dynamite-bud Жыл бұрын
Looks Amazing 💥
@principleshipcoleoid8095 Жыл бұрын
Will there be blueberd video?
@contextfree Жыл бұрын
I'm not sure I've heard of it. Got a link?
@happyman_smiling Жыл бұрын
waiting for you to create video about ada programming language
@12crenshaw3 ай бұрын
Mad lad
@Jianju69 Жыл бұрын
When you say, "running *outside* a browser," don't you actually mean running in headless mode?
@contextfree Жыл бұрын
Well, I have a window, so it's not headless, but it's also not a web browser at all. It's a separate native app.
@whatthefunction9140 Жыл бұрын
23mb?
@contextfree Жыл бұрын
It includes a wasm engine that compiles to native. Plus all the GPU stuff. But I think I tried some additional options including LTO (link time optimization), and it got several MB smaller. LTO is super slow, though, so not fun for dev time, just for releases.
@naranyala_dev Жыл бұрын
latest and greatest
@rabingaire Жыл бұрын
wow this is cool
@dkaraush10 ай бұрын
absence of mobile though is a deal breaker for me :(
@Pariatech Жыл бұрын
"It takes alot of code to display something with webgpu" laugh in 1k lines vulkan triangle😂
@metamodern7648 Жыл бұрын
Why am I watching this, I don't even know C or Rust damn..
@contextfree Жыл бұрын
But is the video fun still?
@metamodern7648 Жыл бұрын
@@contextfree of course it is:)
@anasouardini Жыл бұрын
I hope this doesn't make it out of draft; the last thing I need is a 3d site with million lines of code (rendering my old laptop useless) when I request a simple recipe site!
@contextfree Жыл бұрын
Helper libraries make a huge difference. But I need to implement the things that helper libraries expect.
@contextfree Жыл бұрын
It's also a bit simpler from js.
@youtubelisk Жыл бұрын
That is the thing i want the most. I want to see that recipe ray-traced on my screen. I want more from the future than pngs; the web we have now can not be the end of the line.