So basically, in September-October 2021 I wrote a purely ray traced Vulkan engine. By November, I decided to recycle a lot of the code but restart with what I had learned. So with that, Krypton was born. By March I had sold my RTX 2080 which meant I was a Mac user. I then decided to create a RHI to cover Metal and Vulkan, which turned out to be the biggest waste of time ever (Though I grew to very much like Metal, especially MSL). While it was very interesting to do, I never had much motivation because you'd essentially have to write two implementations next to your rendering code. This is why in mid-November 2022 I deleted the RHI and decided to start over again. As of writing this I now have a functioning render loop again, and we'll now see where the journey takes me.
#Krypton - C++ Vulkan Engine
294 messages · Page 1 of 1 (latest)
and now I've created this thread so I can put some updates here, if anyone should care.
brilliant; apart from a single validation error about my descriptor sets everything now runs and works. lovely to see
Following along for the ride 
welcome back 🙂
only one hazard sync error but I don't think its right
colours are fucked
but it's working
call it "night theme"
combined length of 1100 loc, with some builder files that are like 450 loc
the RHI on the other hand was 10500 loc and could do the same
lol
@quiet stag this looks right, no?
I removed the sRGB adjustment in the shader
ahh I know why
because I told ImGui with a flag that I support sRGB now
ah
yes that looks like the real deal
if you set classic color sceme you should get that ugly purple and washed out red
ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
hmm
classic color scheme?
yes
the one you have tehre is the new default one, "Dark" or what its called
just pick from the top there
dark, light and classic
it seems like ImGuiConfigFlags_IsSRGB will have the vertex colours not be encoded as sRGB
so I don't have to decode them in the shader
(if I remember correctly that pow(col, 2.2) was decoding)
i have not touched proper colorspaceisms yet, at all
I love my shader compiler tool that I made
compiles everything at compile time into these library files that I can then extract SPIR-V from at runtime
ok what to do next
volume cluster renderer
anyone have any font recommendations
I just tried Roboto but it looks weird and not very clean
do I have to change anything?
Perhaps I just have to slap some MSAA onto it?
don't wanna configure msaa right now because I would have to restructure a bit of my ImGui renderer
also I'll have to figure out a good way to have a graph based pass thing going on soon
wanna have something like that
Kufam looks like Ubuntu
and wtf is Mali
looks like that old Samsung font
heh
i think settled with RobotoCondensed
the other two look not bad either with large fontsize
7800 deletions 🙂
I think I will look into fiber task libs on thursday/friday so that I can load multiple assets at once and use multiple threads at will
and ill then go to graph based rendering
should be fun
are you looking at other engines while dinglefarting around?
nope
never have actually
tbh I also think my biggest issue is that I don't know any good ways to structure large code
so I get lost quickly usually
I've never worked on a large code base and I taught all of this to myself using common sense and stackoverflow
sure, but I still think it would help
im not happy with most engines i look at, from a structural point of view
probably due to my c# background and oopisms
many engines are also "just" modelviewers
so I tested enkiTS out yesterday, and it’s quite simple and works right away
found a funny thing though: running the task that creates a command pool, records a command buffer to copy the staging buffer of a texture to the actual texture, submit that buffer, and then wait on that to complete is all faster than vkGetPhysicalDeviceSurfaceCapabilitiesKHR. And that function isn’t even the slowest of all the swapchain creation stuff
… however I had a good look at entt yesterday. So when my exams end I’ll try and use entt and implement a basic scene graph, after which I will add a threaded model loading queue to fill that scene graph
hope that works out
hmm I wonder if making some sort of custom thread scheduler is actually worth it
so my nvidia gpu has 2 dedicated transfer queues, so the naive solution would be to use 2 CPU threads to submit any work onto those queues
however, I am allowed to submit commands from any CPU thread, as long as the submit call is synchronized with a mutex or similar
which probably also means that I can have n CPU threads that all just submit, as long as I have that mutex in place
so no custom thread scheduler is not worth it, ok
though I am still interested to see how one would manage all the command pools for all the threads that might submit something.
like should I have a globally accessible struct that contains all the VkQueue handles and their mutexes, together with a array of VkCommandPools so that one pool is always available to a threadß
ok well then
the worm in the brain never stops eating
These are my favorites
is that causing my headaches right now?
absolutely
ooh those are definitely nice ones. might even use source code pro for intellij
i love and hate multithreading in c++
running with scissors
the camera quality of that gif is so shit
unfortunately
you could redo it
2023: deep learning magic to improve all discord gifs to high quality
yay my first issue with ECS
entt::entity root;
{
auto lock = std::scoped_lock(editor->registryMutex);
root = registry.create();
auto& rootRelationship = registry.emplace<NodeRelationship>(root);
I do create a NodeRelationship component for my root entity
ah fuck
I can't read
nvm
I was reading the wrong entity
yay
sweet
font is ugly af tho :>
i have like 300loc just to display some things with imgui in my thing
super annoying
yeah it’s getting longer for me too
i’m somewhat considering a header that includes RAII imgui stuff and more stuff for stdlib or my stuff
ye im also considering to wrap that shit somehow behind some Window/Control isms
well first im gonna cook this lasagna
then i’ll continue with adding a file menu to select gltf files to add
because currently i just click a button and it’ll always load mcsponza.gltf
I still want to look into other fonts & themes
might kindly steal your theme later on
and then look into fonts again someday
its someone's
oi, 31 stars Oo
there are a few more
its kinda scattered across various ocornut/imgui issues and single imgui styles in various github repos
if you find other cool ones, please send a PR to this repo, in the same style if possible
where is yours in here
haha
dougbinks (the last one) doesn't even compile
and dougbinks is from here: https://github.com/ocornut/imgui/pull/511#issuecomment-175719267
and its ancient
ye some might need a little massage
mine is not in thre, but you can grab mine from deccer/EngineKit/src/UIRenderer/UIRenderer.cs
daaaaamn
oi thats neat 😄 looks like alot new entries
fun
fuck yeah
do you hide something behind the collapsed primitive nodes?
wdym?
ah
now to some cleanups
and then I can render stuff
though I already really like the look of this
yeah it's a quat
ye
dunno how to change that
maybe for display reasons it makes sense to go to euler angles
but that's definitely something I could change
yeah
whaaaat
clion actually displays it as a quaternion
how funny is that
I think I might just butcher this thread briefly to just dump stuff about my MoltenVK PR right now
so MoltenVK doesn't properly report that some formats that the M1 and M2 do support with Metal
and so, for example, it says M1 and M2 on macOS don't support ASTC and they don't support 4-bit and packed formats like e.g. R4G4B4A4
though if you run that M1 on an iOS/iPadOS device it suddenly does support those, but doesn't support BC
this is just because the current madness that MoltenVK has here differentiates between iOS and macOS and just assumes that some requirement is always a thing on some platform
so it hardcodes that ASTC and those 4-bit formats are not available on macOS
and hardcodes that BC isn't supported on iOS
but that should depend entirely on the GPU that it's running on, not the OS
especially since Metal 3, as the drivers are nearly exactly the same now and the same GPUs are available on both platforms
so I have this massive urge to just Ctrl+A, Del this whole thing
because it's also just littered with macros everywhere, when you could instead use some virtual class to handle every format generically
this is just hard to read
however, as I have to put my PR in before Friday, I might just hack this together quickly
like, this whole thing should just connect the Vulkan format with the Metal format, give it some basic information , and then put a requirement on that format based on a lambda, or a generic one that checks the MTLFeatureSet or MTLGPUFamily
according to the docs all formats are introduced by GPU Family
so say I want to check for the M1, I would get every format that is supported by Apple7 and Mac2 (and before, support has never been removed, yet)
so that format would just go and do [device supportsFamily:MTLGPUFamilyApple7] and then advertise the according Vulkan format as supported
also funny bug, VulkanCapsViewer and vkconfig error out saying "no ICD found", but the vulkaninfo in vkconfig still reports the device and all the features properly
the GPU capabilities are directly tied to the platform, which is a plain wrong assumption
oh no
addFormatCustom(MTLPixelFormatA8Unorm, MVKMTLViewClass::Color8, [](MVKMTLFormatDesc desc, id<MTLDevice> device) { return ([device supportsFamily:MTLGPUFamilyApple6]) ? kMVKMTLFmtCapsRF : kMVKMTLFmtCapsRF; });
would it be a good idea to 'streamline' all vertex formats because I use glTF anyway?
like say I will convert everything to some specific format
like if you don't use float3 for your position idk what else I'm supposed to use
at least for the geometry pass(es)
you might want some debug pass which just has PositionColor and imgui has PositionUv and Color as uint iirc
and one for FSTs PositionUv
not sure what you mean?
literally just this currently
though I essentially want to make an editor for a 2D game I want to make
something like stardew valley
but for now I might want to load glTF models for fun
also because I kinda want to write some PBR shaders and whatnot
gltf kinda describes your vertexformat already indeed
what i meant is, when you render debug cubes or shapes for whatever ... visualize light fixtures or other objects
you might want to use a different vertexformat
or just disable unused attributes from the thing you used for your gltfisms ?
uhh
still no idea what i mean?
no not really

I've done a minor restructuring to how this all works and have something new going
essentially, I'm just gonna try and make a simple game now which I'll try and build on as much as I can
my current concept has this ECS for every entity and gives that some properties here and there
though I now want to allow scripting through Lua so I can change the behaviour and tweak everything while the game is running
still not quite sure how to efficiently have multiple Lua scripts, but what I'm aiming at is, for example, the InputSystem and that will iterate over the View with some Input component which will then contain some reference to some Lua function which will then be executed
like a 2d dungeon type of game
while you're here do you have any resources on how to design the systems for ECSes? Using entt::dispatcher for example? Or how should I handle these events
noice
i am not familiar with entt really
but dispatcher just sounds like an event emitter, which others can subscribe to
like, when you step on a trapdoor tile of sorts
other tiles in the room could disintegrate or dispensers in various corners could shoot arrows at you
or some music is played
rather than having a 100k line long if else block in your OnPlayerMove function
... instead I have what?
a messagebus/eventdispatcher and evensubscribers
how do the subscribers look like though
like i said, i have no clue in the context of entt
but a subscriber could be anything
let me try to create a little shrimple
class Bus
{
Dictionary<TEvent, List<Callback>> _subscriptions;
void PublishEvent(TEvent event)
{
if (_subscriptions.TryGet(event, out var callbacks))
{
foreach (var callback in callbacks)
{
callback(event);
}
}
}
int Subscribe<TEvent>(Callback callback)
{
if (_subscriptions.TryGet(event, out var callbacks))
{
_subscriptions.Add(TEvent, callback);
}
else
{
_subscriuptions.Add(Event, new List<Callback> { callback });
}
}
};
class Producer
{
ctor(Bus bus)
void OnFoo()
{
bus.PublishEvent(new FooEvent{ payload });
}
}
class Consumer
{
ctor(Bus bus)
{
us.Subscribe<FooEvent>(handleFoo);
}
void handleFoo(FooEvent fooEvent)
{
//... use fooEvent payload to pay yo mama
}
}
I think for the first part I'm just gonna have my GLFW callbacks act as the "systems"
so the key callback will do everything related to updating the player position
or text input (in the future)
will also have to look and see how I will do text rendering and UI
also should I make every tile an actual entity? Or just the entities that have some behaviour connected to them?
there is a very neat talk about that
let me try to find it
from a well known person whos name i cant remember atm, let me find it
bob nystrom
Talk from the Roguelike Celebration 2018 - http://roguelike.club
this yt channel has a lot of cool shit in it, not just this one
hehe seeing this again makes me want to resurrect my other 2004384 dungeon crawler trial and errors XD
thanks for that video, gonna watxh it tomorrow
that presentation is made so well lol
ok I think my problem is not knowing how the game loop of a game works
in the sense that if my player attacks, does it instantly take away HP of the enemy? or how does that work?
I can imagine that becoming recursive or being really expensive
so... how does that work?
you would have a HealthSystem for instance
or a Fight/AttackSystem
the fight system takes care of hit and block, when hit, you could create a damagecomponent, which the healthsystem/damagesystem picks up and reduces your health by the value in damagecomponent and then you remove the damagecomponent again
say I would use GLFW callbacks for my systems
couldn't I have some weird desyncs?
where if the mouse input comes before the movement input, it could be attacking from the old position in that frame
and there would not be any guarantee about the order of the input
or would that even matter at all?
because otherwise I would just do what most other people in the examples with SDL did, where they just essentially do glfwGetKey in an UpdateMovement function
and the order would always be the same
Another thing, is it an antipattern if I store a entt::entity handle in my Game class that would represent the player or the camera? Because then I wouldn't have the system that just updates all entities with certain components, but would always assume there's only one player and only one camera.
... writing an AI in Python to play 2048 trial 1
Over 1000 runs the highest score was 2704, with an average score of 695
so ive decided to write a simple 2d game and get it as far as I can (i have a rather good idea)
but then when I have it in a pretty good state I will try and factor out a few things that I will then call my „engine“ that I will try and reuse across revisions of my game(s)
because I have in fact never written a game
so I was going in quite blind
I think that should help significantly
still not quite sure how I wanna go about scripting
because in the end I want to have a simple level editor I can use to efficiently design my map
and optimally I would want to use a simple scripting framework I could use so I can quickly write scripts to get custom behaviour quickly
I was thinking about Lua but it seems quite limited to me
not sure how one would actually have a large scale Lua codebasw
don’t think I want to do my own language, thats something for much later
ss13 clone? 😄