#Phobos - Vulkan abstraction library in Rust

1 messages · Page 4 of 1

hybrid pilot
#

Mthere's the partially bound flag

limber rapids
#

Saving it into a free list or something

hybrid pilot
#

So you can just leave then empty

#

Wau what do you mean

limber rapids
#

I mean when you release a resource, you can mark the index of that descriptor as "free"

#

Like a free list allocator

hybrid pilot
#

If you return an object to the pool that slot will be overwirttene eventually yes

hybrid pilot
limber rapids
#

epic

#

I look forward to seeing your impl

hybrid pilot
#

Versioning the induces would be cool but

#

Dunno if it is actually needed

#

Since the object you get from the pool owns the index

limber rapids
#

I think free list makes more sense

hybrid pilot
#

That said I will take a look at how daxa allocates indices

#

Maybe there is something cool there

languid fern
#

Also when you bind a graphics pipeline (with a common pipeline layout) and then bind a common descriptor set (set = 0), would it need to dispatch a new vkCmdDescriptorSets?

#

Iirc bindless allows you to just reutilize the same pipeline layout multiple times which can save from submitting that call

night charm
#

if they are at the same set index the layouts are called compatible and the set binding is not changed at that index

#

iirc

languid fern
#

Oh so the pipeline layouts don't need to be the same, just compatible?

night charm
#

the layout changes

#

but if the sets at 0..n are the same, those dont get unbound when changing to a new pipeline

languid fern
#

Yes alright makes sense

#

Thansk

iron shadow
#

phobos user base rn: 📈

#

NOOO POENGUIN NOT VALORANT

#

he's fallen 🫡

languid fern
#

You do not know how I angry I was yesterday after playing valorant

night charm
#

same

night charm
languid fern
# iron shadow phobos user base rn: 📈

I rlly want to switch because wgpu is giving me a headache but I also don't want to fall into my canon event of having to rewrite my graphics engine for the nth time

iron shadow
languid fern
#

Yea it should

#

If I do I'll have to figure out what's stopping me from using renderdoc

night charm
#

check the log file

iron shadow
#

So what does it mean

#

when the image view's image u64 is negative

#

does it mean it's invalid?

limber rapids
#

u64?

iron shadow
#

I'm debugging the image phobos image struct

#

and the vk::Image is defined as a u64

hybrid pilot
#

it's a vulkan handle

#

which is probalbly a pointer

iron shadow
#

Yeah and if it is negative, would that imply it has been deleted?

hybrid pilot
#

so try dereferencing it in the debugger

hybrid pilot
#

an unsigned integer can't be negative

limber rapids
#

Also this lol

hybrid pilot
#

you are casting it I guess

#

but it doesn't mean it is negativr

#

just >= 2^63

iron shadow
#

can you input a regular buffer as a storage buffer? Phobos removed all flags so I'm not sure

languid fern
#

Tbh I don't know if removing those flags was a good idea I mean yea it does simplify the interface but I do feel like they have some significance

iron shadow
#

eh not really in terms of performance

#

however it makes it really annoying

#

if you wanted to add some specific features

#

like allow buffers to become storage buffers

#

which I cannot in the current state

#

I think optional flags would be a nice compromise

night charm
#

Every buffer is a storage buffer if you want to use it as such

iron shadow
#

🗿 Oh no crashes KEKW

night charm
#

i despise databases and everything web related

#

just connect frogdelet

limber rapids
#

Same

#

But I like my prof

#

He would usually make statements like:
The death day of someone is a totally available attribute, but it is unfortunately unknown

night charm
#

It’d be nice if it was just a class

#

This is a horrible codebase bleakekw

iron shadow
#

Does phobos have a way to do mock tests?

night charm
#

Mock vk calls? Not really no

iron shadow
#

wanted a way to test out my buffer asset

night charm
#

gitlab is so much better than github honeslty

#

im using it for work and its 10x better lmfao

torn kettle
#

oo work? anything nice?

night charm
#

my uni is developing an online platform to teach highschool kids python and im working on it for a few weeks

#

its not too bad

hybrid pilot
#

Teach vulkan to the kids 😈

night charm
#

sneaking in easter eggs to draw them to the graphics side bleakekw

hybrid pilot
#

I haven't had that much time for the bindless stuff

#

I did start typing though

night charm
torn kettle
hybrid pilot
#

"Looks at those nice triangles"
loads of maths, low level stuff and gpu hangs around the corner

languid fern
#

(I am proof of that)

hybrid pilot
night charm
#

time to work on automated tests

night charm
#
#[test]
pub fn use_entire_scratch_allocator() -> Result<()> {
    // Try allocating the entire scratch allocator's memory for a single buffer
    let mut context = framework::make_context()?;
    let mut scratch_allocator =
        ScratchAllocator::new(context.device.clone(), &mut context.allocator, 1024 as u64)?;
    let _buffer = scratch_allocator.allocate(1024 as u64)?;
    Ok(())
}

first bug squashed because of tests

iron shadow
#

yooo

#

how did you get the vulkan stuff to work with tests?

night charm
#

framework::make_context creates a headless phobos context

#

it doesnt work on github actions, fails to load vk

#

i cannot be bothered to figure out if this is a gh actions limitation or just me not installing the sdk in the runner

iron shadow
#

Thanks for letting me know. I'll probably integrate that into my engine

#

most of the code is untested bleakekw because I couldn't figure out a way to get testing to work without having 900 windows pop open

night charm
#

yeah i wont write tests for stuff that requires a window

#

but most things dont so

iron shadow
#

mhm

hybrid pilot
night charm
#

oh yeah that is true

languid fern
#

For tests, do you actually create a vulkan context or is it "emulated"?

night charm
#

not sure how to set that up but might be worth it

#

i create a full context yeah

languid fern
#

O

#

Yea I didn't scroll down sorry

#

Lol

night charm
#

not efficient but i dont want to set up mocking of vk calls

languid fern
#

Nah nah fair plus it lets you catch validation errors as well

hybrid pilot
#

I think it will work ootb

#

Oh and the lavapipe driver

#

Which distro is it running?

night charm
#

ubuntu

#

sudo apt-get install -y mesa-vulkan-drivers libvulkan1 vulkan-tools vulkan-validationlayers found this in an issue

#

might give that a try

hybrid pilot
#

Nice

night charm
#

Next commit will be the 500th

hybrid pilot
#

Uh that's really nice!

#

Congrats for the project

hybrid pilot
#

Penguin last time I came across the descriptorcache thing

#

But couldn't figure out what holds an instance to it

#

Because for the bibdless stuff I need to keep a ds around

#

But in order to allocate it I need a pool which is stored inside that struct

night charm
#

making some kind of BindlessPool that manages the bindless set might work, we can keep that inside the ResourcePool as well

hybrid pilot
#

I was working on it the other day and just remembered this us something I stumbled upon

#

I'm not pouring many hours into this unfortunately

night charm
#

yeah you can do that for now

#

thats fine lol

#

me neither

#

coding at works leaves me little motivation to do more afterwards

#

the soulless webdev work

#

it drains energy

#

if you have something feel free to open a draft PR, it doesnt need to be completed at all but its easier to give thoughts that way

hybrid pilot
#

Riip

night charm
#

thats fine

hybrid pilot
#

Now I do cool stuff

night charm
#

This is only temporary luckily

#

I hope I dont end up like this KEKW

hybrid pilot
#

The thing is that in the Sumner I don't spend all day in from of my pc

night charm
#

Fair enough

#

Healthy behaviour

hybrid pilot
night charm
#

Thats the plan

hybrid pilot
night charm
#

Im just taking a summer job at uni to earn some money now

hybrid pilot
#

So

#

Lol

night charm
hybrid pilot
#

I guess I'll be able to do more stuff in the winter

#

But yeah it is definetly possible to bring hobby projects forward while having a fulltime job

night charm
#

div div div div div

hybrid pilot
#

During my internship they asked me to make a scraper

#

And I made a temporary HTML ui to demo it

#

Expecting they'd make somebody else do the frontend

#

But no they asked me to do it like their other internal apps

#

And I, someone who knows nothing about webstufd, did something that looked close to it (from scratch)

#

Then they weren't happy

night charm
#

lmao

hybrid pilot
#

And asked me to redo it with the tech they used

#

Which was like angular

night charm
#

at least i have an existing frontend to improve on but its not very nice

hybrid pilot
#

and bootstrap I think?

night charm
#

ye this uses angular

#

im working on a platform to teach highschool kids python programming

hybrid pilot
#

But at least someone did the graphical stuff for me

night charm
#

some implementation details are very questionable though lmao

hybrid pilot
#

Because I'm totally incapable of making pretty UIs

#

I like 90s ui

night charm
#

it sends the solutions to the exercises with the problems to the frontend KEKW

hybrid pilot
#

They felt like computery things

night charm
hybrid pilot
#

I find 90s to be pretty their own way

night charm
# hybrid pilot Lol

yeah so if youre somewhat adept you can just look at incoming traffic and copy over the solutions lmao

hybrid pilot
#

Lol

#

Fantastic

night charm
#

i think at least for test questions it doesnt but thats very incomplete atm

hybrid pilot
#

They'd blame the kids if they did it anyway I guess

#

It's a feature

#

Your testing their honesty

night charm
#

i mean

#

if they can figure that out they can probably solve it too

#

the questions are really basic

hybrid pilot
#

Mmm

#

Is it like a job at uni?

night charm
#

yeah

hybrid pilot
#

I see

night charm
#

i was first in a programming contest for some class, and at the end the professor offered some summer jobs to the first 3

hybrid pilot
#

Nice

night charm
#

huge

#

ill check it out

hybrid pilot
#

I'm sure I've done many things in a non phobos-way so please do point out such things

#

It's still untested and incomplete

#

But I'm sure there are things that need to change

#

so I'd rather get them right first

night charm
#

Yep that makes sense

#

I added some comments

#

Some are really quick fixes

#

In general, looks pretty good

hybrid pilot
night charm
hybrid pilot
#

Penguin I wanted to discuss with you how you think the layout thing in CimbinedImageSampler should be handled. If it is entirely the responsibility of the user to make sure it is in the right layout is it reasonable to have a default?

#

(That's why I didn't write a constructor, my thought was that if the layout should always be provided to it then it makes no sense to have it as an Option)

night charm
#

Hmm so I can't exactly see a reason why it shouldnt be in ShaderReadOnlyOptimal

#

Its the only layout that makes sense besides General but that is discouraged

#

I think its probably reasonable to enforce ShaderReadOnlyOptimal unless you can think of a case where you really wouldnt want this

#

(And then not have the field at all and hardcode it in)

torn kettle
#

there is also read only optimal

night charm
#

Does that make sense for combined image samplers?

torn kettle
#

unless combined has a special meaning in phobos

night charm
#

no its just the same as a vk::DescriptorType::CombinedImageSampler

torn kettle
#

then it would make sense under sync2

hybrid pilot
#

Though if you think it is OK as it is I don't really have a problem with it, this is nit picking.
So just make sure we'd have a new co steuctor that only takes an ImageView and a Sampler, then maybe a with_layout method if the usrr wants to specify one

night charm
#

as it already does for regular bindings

hybrid pilot
# night charm That's a good idea

Great! I'll see when I have some more time to work on it (hopefully I can do this simple thing today). One thing that I need to address before I can begin to actually try using it is introducing a way of binding the bindless pool.

night charm
#

Yeah, I think it makes sense to have this on IncompleteCommandBuffer

hybrid pilot
#

I added some documentation

#

Only thing left is a way of binding it

night charm
#
pub fn with_layout(self, image_layout: Option<vk::ImageLayout>) -> Self {
        Self { image_layout, .. self }
    }

I have never seen this syntax but it looks awesome

hybrid pilot
#

Yeah really useful for things like that one

night charm
#

true

languid fern
#

Alr time for me to contribute to phobos again gotta rust myself again

#

@night charm what would be a good issue for me to tackle in your opinion?

night charm
#

let me see

languid fern
#

Oh tbh even the scratch mem issue doesn't sound too bad

#

How is it actually implemented internally? Is it just a persistent VMA allocation?
(I just took a peek at the code and yep that's what it seems to do)

night charm
#

yes exactly

#

its not too bad no

iron shadow
night charm
#

order 66

languid fern
#

Just make the allocator allocate in like "chunks" to remove the need to re-allocate

#

And each of those chunks could be 128kb or something like that

night charm
#

thats a much better solution than what i was trying to come up with

#

it does need a way to handle allocations larger than a single chunk

languid fern
#

Right

#

My only question is what's the "max" size one could possibly allocate

#

Cause I wouldn't expect users to allocate like 1gb each frame lol

#

Inner Alloc 1: 0..1 (128kb)
Inner Alloc 2: 1..3 (256kb)
Inner Alloc 1: 3..6 (384kb)

#

We could store a u128 bitmask containing the ranges of "used" allocations. Whenever a user allocates memory, it would look for the first free bits within that mask that would be able to store the whole allocation of the user (so like, the bitmask acts like a range "searcher")

#

Tbh I don't even think that's needed

#

Considering the fact that you can only reset the whole scratch allocator as a whole and not each allocation separately

#

Just make a simple vec with the inner allocations then kek

night charm
#

The whole point of this is that allocations are supposed to be very fast

#

There should be no performance issue with allocating a small buffer for every drawcall

#

You could also do something like

  • When the allocation exceeds the current available memory, allocate a new block for it
  • When resetting, allocate another new block that would fit all allocations for this frame
  • Next frame, when the same allocation happens, we no longer need a new block because the allocator is bigger now
languid fern
#

So you'd be fine with having excess memory for the sake of the possibility that it will get reused next frame?

languid fern
#

Ok I implemented it

#

I'm a bit confused by whatever this does

// Part of the buffer that is over the min alignment
let unaligned_part = size % self.alignment;

// Amount of padding bytes to insert. This is zero if there are no unaligned bytes
let padding = if unaligned_part == 0 {
0
} else {
self.alignment - unaligned_part
};
let padded_size = size + padding;
#

I understand it's for alignment but wot's padded_size?

night charm
night charm
#

padded_size should be called aligned_size maybe

languid fern
#

So doing something like

let padded_size = ((size as f32) / (self.alignment as f32)).ceil() as u64 * 256;
#

Would give the same result?

night charm
#

It might

languid fern
#

Testing time

night charm
#

Make sure it doesnt add extra bytes if the size is already a multiple of the alignment

#

But I think that should be fine here

languid fern
#

Seems okay

#

There's probably an even cleaner way to do this

torn kettle
#
// Aligns given value up to nearest multiply of align value. For example: VmaAlignUp(11, 8) = 16.
// Use types like uint32_t, uint64_t as T.
template<typename T>
static inline T VmaAlignUp(T val, T align) {
    return (val + align - 1) / align * align;
}

here is something better

languid fern
#

Yep kek

torn kettle
#

ceiled integer division * divisor

languid fern
#

Yea unfortunately in rust it's behind the experimental int_roundings feature

night charm
#

Wat

torn kettle
#

lmao

night charm
#

Is that not a thing

#

Lmao

#

No way rust has no stable integer division

languid fern
#

Even next_multiple_of is still in nightly lol

night charm
#

cant you just write the expression above instead of using div_ceil

torn kettle
#

there is integer division though, of course

languid fern
#

Oh no I'm not saying you can't

#

I'm saying that there's already a feature that does it for you but it's hidden away atm

night charm
#

i see

languid fern
#

Holy moly

#
fn test_bitwise(size: u64) -> u64 {
    (size + 255) & !255u64
}
#

Least cursed align_to calculation

#

(it actually works as well)

torn kettle
#

the above works for npot alignments

languid fern
#

I'm bikeshedding too much lol back to allocator stuff

torn kettle
#

if you only have pot alignments, you could write something more brainwormed

night charm
#

tbf

#

I think I just pass 256 as the alignment everywhere

#

lmao

torn kettle
#

that sufficient for all vulkan alignments, yes

languid fern
#

Also, is there a reason to use 800 as u64 instead of 800u64 in the allocator tests?

night charm
#

not really

languid fern
#

Understandable

#

Alright I think I'm done with the dynamically growing scratch alloc

#

I currently made the min chunk size 32kb internally, could very easily make it external if you wish as well

night charm
#

ill take a look

#

(once you make a PR :P)

languid fern
#

Oh also if you don't mind I added a conditional flag for compiling the 04_fsr2 example

#

I don't have fsr2 installed (nor the feature enabled) so the errors kept bugging me lol

night charm
#

Huh that's weird that it compiled it at all

#

Use cargo test --tests to run the tests if thats what you were doing

#

its fine though

#

I added some (mostly minor) comments

hybrid pilot
#

fixed my dumb mistakes on the doc comments lol

languid fern
#

I should prob do the same when I get back too lol

night charm
#

There’s no hurry dw

languid fern
#

@night charm So how exactly would you want the shrink method to work?

#

Should it just deallocate all extra buffers (other than the initial one)?

night charm
#

It doesnt really work with the way you implemented things so I think it's fine to leave it out

#

Though I think there's an argument for trying to "compress" the allocator by merging all buffers into a bigger one when it resets

#

This way you need less binding new buffers potentially

#
  • it helps suballocating a single buffer more instead of allocating many buffers
languid fern
#

Right

#

I can implement that if you want

#

Shouldn't be too hard tbh

night charm
#

Yeah the contents of the buffer dont matter at that point

languid fern
#

Yea so I can just discard of them

#

So the shrink method would have to execute after the reset method, or is that not a requirement?

night charm
#

I think we dont have the shrink method and just compress on reset

#

It should stabilize after a few frames

languid fern
#

Aight gotchu

night charm
#

Or, shrink() simply sets the size to compress to

#

Which then happens next time you reset

#

Might be a bit unclear though

languid fern
#

Yea at that point just pass it as an arg

night charm
#

Yeah but make it an Option<> then

languid fern
#

Yep alright

#

So now the fn def is reset(&mut self, compressed_size: Option<vk::DeviceSize>) -> Result<()>

#

Should be ok for the most part

night charm
#

looks good

night charm
#

i am a very competent web developer yes

hybrid pilot
#

Efficient utilization of space

night charm
#

That it is

limber rapids
#

Rust's syntax doesn't help in the understanding bleakekw

night charm
#

lol

#

the only function to use publicly is alloc and alloc_items

#

(and new ofc)

#

But as for this line fn update_descriptor_set<'a>(&'a mut self, r: impl Iterator<Item = (u32, &'a R)>

#

You pass it an iterator over (u32, R), but the last element in each pair is a reference that has the same lifetime as self

limber rapids
#

hm

#

Do you have example usage for alloc_items

night charm
#

no

#

wip PR

#

let me see

#
// once
let pool = BindlessPool::new(...);
let images: Vec<ImageView> = get_all_textures();
let handles: Vec<_> = pool.alloc_items(images.iter()).collect();

// every frame

let cmd = create_command_buffer();
cmd.bind_bindless_pool(&pool);
// Send index of first image to shader
cmd.push_constant(0, 4, handles[0].index());
#

@limber rapids should be something like this

limber rapids
#

Uh

#

Am I reading this wrong or does this still update all the textures? thonk

night charm
#

no it shouldnt

#

you only alloc when adding a new texture

#

Which updates the modified region

limber rapids
#

Huh I see

#

What about erasing/evicting/updating?

night charm
#

no erasing yet i think

hybrid pilot
# limber rapids What about erasing/evicting/updating?

When you alloc you get a BindlessHandle, when it Drops it calls back into the pool which adds the index to the free list. Next time you alloc that index will be recycled and the descriptor for that index gets overwritten

hybrid pilot
limber rapids
#

hm

#

Do you hash things or is it just indices

hybrid pilot
#

Indices

#

Same indices that you'd send to the gpu

#

There is no other internal Id

limber rapids
#

alright

hybrid pilot
#

I though of adding a generation counter but so long as you take the index from the handle it must be valid so I couldn't see the point

hybrid pilot
#

I'll see when I can get back to that PR and actually add a function to bind the pool so I can start using it in my project (for which I also need yo find the time) and validate that things work. Though being a simple api I don't see much that could go wrong

iron shadow
#

Does the dynamic scratch allocator work off the bat?

night charm
#

yes

iron shadow
#

Oh yeah penguin

#

is there a way to add support for multiple different types of samplers

#

in one descriptor array?

night charm
#

In new system yes

#

That makes me realise smth actually

#

@hybrid pilot I added another comment

hybrid pilot
night charm
#

I dont really see a way around it but it's fine imo

#

samplers are readonly objects anyway and sharing them makes a lot of sense

hybrid pilot
#

The way around it would be with traits I guess but it gets messy for no good reason

night charm
#

yeah

hybrid pilot
#

Yeah it only makes sense to hard code arc for this

iron shadow
#

Penguin is there a way for me to create a custom debug callback?

#

mainly for the shader printf

night charm
#

Seems like a reasonable request

#

Open an issue and I'll get to it tomorrow

iron shadow
#

Not the end of the world as vkconfig always exists

night charm
#

@hybrid pilot i think we need to implement pipeline layout compatibility

#

i added a comment on github with a short explanation of my idea but it might not be entirely clear

hybrid pilot
night charm
#

Exactly

hybrid pilot
#

Good idea, I'll work on it

iron shadow
#

iirc the rendergraph does not do memory sychronization?

#

nvm i am stupid

#
The pass graph system is a powerful abstraction that allows you to automatically manage synchronization within a single queue, and automatically transition image layouts based on usage.
iron shadow
#

Stupid question, but things that only affect rendering of the final image only belong on the render graph so image loading is a no go and should it’s commands should just be submitted to the exec manager.

#

What about updating stuff like BLAS + TLAS?

night charm
#

you can choose

#

updating tlas is typically done every frame so you can easily put that in a render graph pass

quiet star
#

Why not just have everything always in a mega set you can bind at will

night charm
#

that is an old message lmao

#

because enforcing shader descriptor set layours for users seems a bit annoying

#

it is nice to go full bindless though

quiet star
#

🧓

night charm
#

New bindless system is a step in that direction

#

Register resources into the bindless set, bind the set and forget about it

quiet star
#

🤓 why have desceiptor set layouts and pipelinr layouts exposed

night charm
#

theyre not

quiet star
#

froge_bleak those ugly objects belong in the gutter

night charm
#

but you'd still need to write your shaders to consume this "mega set"

quiet star
#

yes. I am happy with supplying a header for the user for these things

night charm
#

Yeah thats fair

quiet star
#

it can be get really quite simple with that. In daxa you never care about any binding or sets even in shaders. you can just do daxa_SOME_GLSL_IMAGE_TYPE(ID) for example daxa_texture2D(id) and it gives you the glsl type in place. You can do that for anything just by including the header with bo additional work. Makes bindles extreamly simple

night charm
#

thats quite neat yeah

hybrid pilot
#

reads conversation
Ah so my code is now useless

#

/s

iron shadow
#

Dear penguin,
Does phobos use renderpasses or use dynamic rendering

Sincerely
Danny "i hate renderpasses" Le

#
features_1_3.dynamic_rendering = vk::TRUE;

He's sane. We making out of the Vulkan specification with this one 🔥

night charm
iron shadow
#

i learnt why the hard way bleakekw

night charm
#

Renderpasses are for mobile nerds

iron shadow
#

Penguin

#

we have a problem

#

I need to enable the VK_KHR_shader_clock extension but the issue is that

#

I uh

#

kinda need to link the feature in a p_next

#

but that isn't possible

#
        let shader_clock_feature = vk::PhysicalDeviceShaderClockFeaturesKHR {
            s_type: vk::StructureType::PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR,
            p_next: ptr::null_mut(),
            shader_subgroup_clock: vk::TRUE,
            shader_device_clock: vk::TRUE,
        };
        let mut settings = phobos::AppBuilder::new()
            .version((1, 0, 0))
            .name(name)
            .validation(true)
            .present_mode(phobos::vk::PresentModeKHR::MAILBOX)
            .scratch_chunk_size(1 * 1024u64)
            .gpu(phobos::GPURequirements {
                dedicated: false,
                min_video_memory: 4 * 1024 * 1024 * 1024, // 1 GiB
                min_dedicated_video_memory: 4 * 1024 * 1024 * 1024,
                queues: vec![
                    phobos::QueueRequest {
                        dedicated: false,
                        queue_type: phobos::QueueType::Graphics,
                    },
                    phobos::QueueRequest {
                        dedicated: true,
                        queue_type: phobos::QueueType::Transfer,
                    },
                    phobos::QueueRequest {
                        dedicated: true,
                        queue_type: phobos::QueueType::Compute,
                    },
                ],
                features: vk::PhysicalDeviceFeatures::builder()
                    .shader_int64(true)
                    .build(),
                device_extensions: vec![
                    String::from("VK_EXT_scalar_block_layout"),
                    String::from("VK_KHR_shader_clock"),
                ],
                ..Default::default()
            });
night charm
#

is it not

#

cant you p_next() it to the VkPhysicalDeviceFeatures::builder()

iron shadow
#

Nah p_next() doesn't exist on VkPhysicalDeviceFeatures for some reason

night charm
#

oh

#

its on vkPhysicalDeviceFeatures2

#

ill swap it out

night charm
#

we just need to replace it with VkPhysicalDeviceFeatures2 everywhere

#

pretty easy

iron shadow
#

yeah it;s on 2

#

lmk when fixed

#

it isn't a catastrophic issue as somehow i'm still getting random results from my hemisphere generator somehow bleakekw

night charm
iron shadow
#

Hey penguin how did you handle deallocating your buffers with gpu-allocator

night charm
#

You can free() them

iron shadow
#

Yo penguin

#

on persistant mapping

#

do you do it?

#

Been finding it a pain to deal with rn

night charm
#

Everything that’s mappable is persistently mapped yes

hybrid pilot
#

@night charm so for pipeline layout compatibility, can you point me at where bindings are currently cleared when changing pipelines?

night charm
#

It happens somewhat implicitly when binding a descriptor set, you can look at command_buffer/incomplete.rs:163

#

.take().unwrap() just sets the old value to None

#

But this would probably need to be changed

hybrid pilot
#

Uh I see, so the actual bound sets are not changed they are cleared from that array

night charm
#

Yeah

hybrid pilot
#

relevant sets are overridden and sets after those are ignored right?

#

Ok so

night charm
#

yeah the ones after should be kept if layouts are compatible

hybrid pilot
#

Currently all are kept right?

#

Oh no

#

oh no wait yeah

night charm
#

well this happens on the vulkan side still

hybrid pilot
#

say you bind the first 10 sets

night charm
#

but we dont detect it so theres no way to make use of that in a convenient way really

hybrid pilot
#

yeah makes sense

#

so what I'd change here is adding logic to keep track of which sets are actually bound, then when going through the array only bind those that have changed + clear the ones that have become incompatible if a pipeline change has happened

night charm
#

Yes, that sounds good

hybrid pilot
#

I'll be back in 10 mins

#

I'm back

#

so

#

I was thinking that when pipelines are bound a bitset of dirty sets could be kept

#

I mean it would or the bits of the sets that have been invalidated

#

then when ensure descriptor set runs it would clear those from the bound sets it keeps track of

hybrid pilot
#

Oh one thing I need to ask

night charm
#

yeah that makes sense so far

hybrid pilot
#

current_descriptor_sets stores builders

night charm
#

right

hybrid pilot
#

but for the pool we need a set

#

and keeping it externally would be hard

night charm
#

hmm

#

what about making it an enum with either a builder or a set

hybrid pilot
#

yeah that's what I was thinking

night charm
#

sounds like the easiest solution

hybrid pilot
#

indeed, so if it is ok for you that's what I'd do

night charm
#

Yeah thats fine by me

hybrid pilot
#

👍 thx

night charm
#

one exam down

#

two to go

languid fern
#

Oh damn you have exams now?

#

Tough

night charm
#

Yep, 2nd chances for those I failed in June/January

hybrid pilot
#

Gl

#

I made some progress on my patches but I've been spending time in other stuff

night charm
#

Thank froge

night charm
#

I hate real analysis

hybrid pilot
#

Real numbers aren't real

night charm
#

True

quiet star
night charm
#

yeah, not the first time either :/

quiet star
#

😿

#

are you in compsi ba?

night charm
#

Yeah, but this is course from the maths ba

#

Im required to pick one of 3 options with classes outside my degree

#

With one option being math, the other economics/business, and one just misc stuff

quiet star
#

i started with a math ba and switched to compsci

#

It was insane

night charm
#

i picked math because I do like math but eh yeah, math ba is insane lol

quiet star
#

yep

night charm
#

I did do well on the geometry exam I think

#

I still have algebra to do but I think I can pass that too

#

Then analysis 1 is the only class standing between me and a degree KEKW

quiet star
#

when i did math i dropped all hobbies to pass

#

only thing i still did was work out

#

without that i would have become a pile of dust

night charm
#

Seems like thats what it takes for some of these classes

#

I did quite enjoy geometry, it was cool

limber rapids
#

6 exams, 6 ultra intense, 8 hours a day sessions of solving random problems bleakekw

night charm
#

both my algebra and geometry exams have this nice structure of 8/20 points closed book theory, and 12/20 open book exercises

#

So if you know the theory well you already almost pass

limber rapids
#

wut is open book

night charm
#

Bring your notes and book

#

To the exam

limber rapids
#

lol

#

literally free

night charm
#

Eh

quiet star
#

no

#

its not useful

night charm
#

Its nice to have but it doesnt make it that much easier

#

Yeah

quiet star
#

you have so much timepressure that you cant look at them basically

#

at least it was for me

limber rapids
#

huh

night charm
#

You can look something up quickly to get the details right but yeah, you need to know whats in it

quiet star
#

all "open book" things just tricket you int owriting these cheat sheets to learn more

#

genius

limber rapids
#

I had 8 problems 2 theory questions in 3 hours

#

no notes

#

for algebra and geometry

#

having my notes would've been so free

#

I think I had achieved something like, every permutation of possible problems

night charm
#

lmao

limber rapids
#

my OneNote file was 20MB big

#

all latex expressions

night charm
#

why are you writing latex in onenote

#

tf

limber rapids
#

because onenote is nice

#

lets me share things across devices

night charm
#

hmm fair enough that is useful

limber rapids
#

plus my uni gives me a free account

#

so it's free real estate KEKW

night charm
#

oh yeah same

#

uni gives so much for free

#

free github pro and intellij ultimate is also nice

hybrid pilot
#

They gave me that stuff in uni but never used it. The marketing idea there is to get you used to those tools. Now personally for the main stuff I use for my job and hobby I don't want to depend on non Foss stuff

hybrid pilot
#

@night charm I've been thinking that due to how Phobos works currently, since it doesn't clear descriptor sets on the vulkan side, descriptor set compatibility might "just work". I mean once a set is bound it never gets bound again if ensure_descriptor_set is called more times right?

#

The vulkan semantic is almost directly exposed isn't it?

#

My concern was that it would override valid sets by binding on top again, but it never does from what I understand now

hybrid pilot
#

I updated my MR

#

Old on garbage ended up in there lol

#

No nvm

#

It's just that I rebased and the compare button shows all of the commits diff

languid fern
#

How does phobos handle desc sets actually anyways?

#

I want to know it handles that under the hood tbh

hybrid pilot
#

You tell it to bind stuff, it has an array of stuff you've bound, then when it matters it actually bindes stuff and removes it from the array

#

So it works like a queue/stack

languid fern
#

Ahh I see I see

night charm
#

ill do some more work on tests

#

factorio addiction is on hiatus

#

possibly until the expansion comes out

languid fern
#

@night charm Don't mind the PR that I made and instantly deleted lol

#

(misinput)

languid fern
#

Idea: Make satisfactory/factorio based game

#

That way you can be addicted to coding your own game!

#

(never goes well)

iron shadow
iron shadow
hybrid pilot
#

Penguin I've uploaded stuff that I've done for bindless some days ago

#

There is some new code around binding the pool

night charm
#

I saw but it was mixed in with a rebase on master so I got confused on what's new

#

But I think overall it looks good

#

its the stuff we talked about with stuffing the bound set in an enum right

languid fern
#

Hey @night charm are there any Phobos context resources that don't handle being arc-safe internally?

night charm
#

the instance iirc

languid fern
#

Ah I see ok

night charm
#

if i forget any the compiler will yell at you anyway

#

oh the debug messenger too I think

languid fern
#

Right yea lol

#

Talking about debug messenger is there a specific order when you destroy said resources?

night charm
#

and VkPhysicalDevice

languid fern
#

Lol yea

night charm
#

instance last

languid fern
#

If I drop my wrapper around them it gives a bunch of errors, which happened to me before using ash

#

Instance last okok

#

Thanks

night charm
#

yeah declaration order in the struct matters

#

first declared first destroyed

languid fern
#

Right yea

languid fern
#

that makes sense then kek

night charm
#

yea that looks good

#

id do the debug messenger right before the device

languid fern
#

Alright

#

I'm thinking about turning each one of these into world resources but idk

night charm
#

you could but idk

languid fern
#

Oh also, is there any motive to support phobos on mac / apple devices?

#

I know there's a way to make stuff work with vulkan-compatibility in ash / wgpu but I'm not too knowledgeable on the subject (I never have touched an apple device in my life lol)

hybrid pilot
#

You need moltenvk which is a non compliant implementation atop metal

#

Non compliant + lacks many features

languid fern
#

Ahhh I see ok

night charm
#

if it works it works

#

if it doesnt im not going to fix it because i dont have an apple device froge

#

if other people want to fix it im open to it though 🤷

languid fern
#

I just wanted to know if emulating VK on top of metal would be a reliable way to support cross-platform

#

But if not I couldn't care less lol

night charm
#

its possible but doesnt always work out of the box afaik

torn kettle
#

err, 2nd best, you could also actively despise

night charm
#

true

iron shadow
#

uh so does phobos

#

automatically query through each physical device

#

to find one with the proper extensions

#

I'm testing it on my laptop and it seems to be selecting my iGPU...

night charm
#

hm it shouldnt be doing that unless the igpu is "good enough" to satisfy your given requirements

#

You could just pass dedicated = true

languid fern
#

Yea actually in my fork I implemented custom physical device selection

night charm
#

do you think you can separate it into a pr

languid fern
#

I might have deleted the branch (in my fork) for that... shouldn't be too hard to reimplement though

#

Yea I could do that right now actually in my fork

languid fern
#

I'm gonna need to do that anyways for my custom engine since I do some noice selection based on laptop battery level anyways

night charm
#

Ooh I see

iron shadow
#

it's weird

#

as i'm saying rt is a requirement

#

then it selects the igpu

night charm
#

that is really weird

#

wait

#

maybe it doesnt check extensions lol

#

let me check its been so long

iron shadow
#

ah

#

I don't include the rt extensions in

night charm
#

i mean

#

phobos should enable them

#

ah i see

#

theyre not added in the device extensions list when checking the physical device

iron shadow
#

yeah

#

hmmm phobos should require you to do that

night charm
#

nah it should take care of that behind the scenes, the idea behind the rt option is that it just enabled the extensions for you

iron shadow
#

ahh okay

night charm
#

ill fix it rn hold up

iron shadow
#

rtx 4050

#

suprisingly isn't that bad

#

phobos approved 👍

night charm
#

epic

#

try pulling latest @iron shadow

#

the small amount of tests I have still pass so hopefully nothing broke

iron shadow
#

i'll try

#

for now uh i have to upload gigabytes of random gltf files onto my usb stick

night charm
#

sounds fun

iron shadow
#

i am absolutely gonna buy a samsung ssd

night charm
#

evo ssds are goated

#

good price, great ssd

iron shadow
#

sata bleakekw

#

i meant like usb-c ssd

#

but i agree

night charm
#

get these

#

or theres a newer model nowadays maybe

#

but these are great

iron shadow
#

i need to upgrade my ssd badly

#

P1 SSD bleakekw

night charm
#

rip

iron shadow
#

no way

#

i forgot the rtx 4050 only has like

#

6gb vram

#

no more bistro

iron shadow
#

btw

#

pr does work

night charm
#

nice

languid fern
#

Now my question is, how should custom device selection work? @night charm

#

Cause there are some things that should be up to phobos (like skipping over devices that don't have RT supported when RT is enabled)

#

In my old fork I just got completely rid of everything phobos did and just let the user control that through the callback fn but it's not such a good solution imo

iron shadow
#

Make it stochastic

#

Randomly keep picking devices until it stops crashing

languid fern
#

Lol

#

Russian roulette physical device selector

#

Sounds like a fun idea

#

(your graphics drivers crash 80% of the time)

night charm
#

Maybe the user could pass in a function that scores devices?

#

Like it can check properties and give a score based on that

#

Then Phobos takes all devices that will work and picks the one with the highest score

languid fern
#

I see I see

#

What I used to do is let phobos do the filtering first (based on features and stuff) and let the user select the remaining devices (to fix ambiguity)

night charm
#

hm that might be reasonable too

languid fern
#

Alright I'll implement that real quick and do a PR

#

And then we can see from there I guess

night charm
#

yeah thats good

night charm
#

Huge

#

No more abstract algebra

#

Exam went well

hybrid pilot
#

Great to hear!

languid fern
night charm
#

gtnh addiction strikes again

iron shadow
#

Penguin has two wolves in him:

  • Addicted to GTNH
  • Addicted to Factorio
    😔
night charm
#

At least it looks cool

hybrid pilot
#

Is there nothing exposing vkCmdUpdateBuffer?

night charm
#

apparently not

#

Easy enough to add

night charm
#

Alright I passed algebra and geometry and failed real analysis (again)

#

That went as expected i guess

hybrid pilot
#

Though what about dependencies 🤔

#

Like sync

#

Well I guess I'll see how you handle transfers and do the same since it is that basically

night charm
#

yeah could be similar to transfers

night charm
hybrid pilot
night charm
iron shadow
#

I thought you were talking about transferring out of your uni programbleakekw

night charm
#

nono

#

im starting my masters now

#

just need to take one extra class

hybrid pilot
#

penguin it's not clear to me how transfers would be tracked

#
pub(crate) enum ResourceUsage {
    #[default]
    Nothing,
    Present,
    Attachment(AttachmentType),
    ShaderRead,
    ShaderWrite,
}

I mean this struct doesn't even have a TransferDst

night charm
#

Worth adding a MemoryWrite and MemoryRead

hybrid pilot
#

With Vulkan's convention I'd call them TransferSrc and TransferDst

night charm
#

Yeah that would probably be better

hybrid pilot
#

Great

languid fern
#

Does phobos force you to use bda?

#

Like can I use storage buffers and uniform buffers normally

night charm
#

BDA is enabled by default and all buffers query their address, but you don’t have to use it at all

languid fern
#

O okok cool

#

Since renderdoc doesn't support it I want to disable it when not needed

night charm
#

Oh yeah might have to conditionally disable it then

#

Renderdoc not supporting BDA kinda surprises me though

#

Are you sure?

languid fern
#

I mean I've heard stories where it just crashes and won't run

#

Maybe that was in an older version though

#

Cause if not then I wouldn't have to ask to check if I can disable it lol

quiet star
#

never had problems

languid fern
#

Ah I might be tripping then

languid fern
night charm
#

lol

iron shadow
#

Don’t trust them nodle

#

They’re gaslighting you

snow dust
#

henlo how it goin

#

its been a while since i checked up on andromeda and phobos

night charm
#

Its going uh

#

Vacation mode

snow dust
#

that's one way to describe it lol

languid fern
#

Lol

night charm
#

BUT

#

in other news

#

i am starting my masters tomorrow

#

which will include a few computer graphics courses

languid fern
#

I should probably get working on my uni applications lol

hybrid pilot
night charm
#

froge thanks

limber rapids
night charm
#

bachelors is 3 years yes

#

i finished my last year (minus one course that im doing again this year) in august

limber rapids
#

so you can do the masters when you didn't finish all the courses

#

wat

quiet star
#

thats normal

night charm
#

yes, you can just not start your thesis

quiet star
#

whej you transition you can dtart before the bachelor is done

night charm
#

its so you dont need to do a full year with 1-2 classes

#

that would be a bit silly

limber rapids
#

huh interesting

night charm
#

on the agenda tomorrow: VR/AR class

#

that'll be interesting I think

limber rapids
#

OpenXR my beloved

night charm
#

I think OpenXR will be for the project class in the second semester

#

this will cover the theory part

languid fern
#

I was actually looking into making a VR game engine lol (even though I don't have a VR headset)

night charm
#

should go into #1019740594861522984

limber rapids
#

hm yes yes, giving yourself and the profs motion sickness

#

very good bleakekw

languid fern
#

On a side note idek how to get started with vulkan multi-view stuff anyways

torn kettle
night charm
#

Over the course of 2025-2026

#

Assuming I pass that one class this year

torn kettle
#

hmm so you continue your bach, take classes from your master, then get those credits transferred?

#

wait 25/26? No bachelor thesis at all?

night charm
night charm
#

I'm just taking it on top of the masters programme, simultaneously

#

It's something like as long as you have less than 30 credits of your bach left you're allowed to take masters classes

limber rapids
#

me struggling to do one thing: kekkedsadge

night charm
#

its just one course KEKW

#

i heard of someone starting this year

#

whos doing cs, math and physics degrees

#

together

limber rapids
#

ask him how many hours he sleeps per month

#

actually, per year

night charm
#

math and physics combined is not unheard of but difficult but this is just insane

night charm
limber rapids
#

I dun understand how to do that honestly

#

I'm in class 9-18 and then have to work 4 more hours

#

this is every single day, excluding Sat and Sun

night charm
#

i dont really have a lot of classes throughout the day typically

limber rapids
#

I am in class right now in fact bleakekw

limber rapids
#

VR/AR for me

night charm
#

oh

#

i have that later today

#

im excited for that one

limber rapids
#

we use Unity KEKW

night charm
#

i think we will too but i havent looked at it in detail

#

it says unity/unreal

#

not sure whats used in the project

#

hmm doesnt say

#

this is just pain

night charm
#

exactly

torn kettle
quiet star
#

when i started my master i still waited on the review on my ba so they just said i could start but need to have the ba reviewed in like 3 months

night charm
#

Not really, but if I don't get it this year I'm going to have to shuffle some thing around and end up studying an additional year

languid fern
#

Man whoever worked on phobos bless you

#

The API is so good to work with

#

And fsr2 out of the box as well

#

My only teensy tiny problem is the use of strings for resource ids (which might seem a bit foot-gunny) but a small fork could alleviate that

night charm
#

the thing is i kinda like string ids because theyre easy to work with

#

but maybe its time for something more sophisticated

#

maybe compile-time hashing of strings with a macro

languid fern
#

But it's not really "safe" per-se imo

#

Honestly I personally don't mind using it as my material system already makes use of string IDs but it seems like it's discouraged to use them

night charm
#

hmm true, its easy to pass a wrong string and mess something up

languid fern
#

I'd say you can use string IDs to make "reference" type ID which then you pass around

#

Something like TypeID basically

night charm
#

yea so

#

compile time hash the string

#

put it into a token-like object

#

that you can copy around as a reference to the attachment

languid fern
#

Yep pretty much

night charm
#

that could work

#

that way you can also keep using the string id if you want by just hashing the string again

languid fern
#

Now nothing would stop you from making multiple references but that's you wanting to shoot yourself in the foot lol

night charm
#

it should give the same token

#

yeah

languid fern
#

Then it would have to

night charm
#

yeah

languid fern
#

how convient!

night charm
#

yep froge

languid fern
#

I'm pretty sure it could kinda speed up lookups internally

night charm
#

for sure

languid fern
#

NoHashHasher for the win in that case

night charm
#

its pretty easy to add this in without having to rework much

#

the biggest part of the work I already refactored earlier

#

which was separating the version number from the string id in the resource identifiers

languid fern
#

Ooo I see I see

#

Yea I haven't really messed with resources yet so that's going to be fun

night charm
#
pub struct VirtualResource {
    pub(crate) name: String,
    pub(crate) version: usize,
    ty: ResourceType,
}

the 'version' field used to be implicit with just a number of + characters appended to name

#

(it was bad KEKW)

#
/// Syntax sugar to easily construct image virtual resources
#[macro_export]
macro_rules! image {
    ($id:literal) => {
        ::phobos::prelude::VirtualResource::image($id)
    };
}

/// Syntax sugar to easily construct buffer virtual resources
#[macro_export]
macro_rules! buffer {
    ($id:literal) => {
        ::phobos::prelude::VirtualResource::buffer($id)
    };
}

To add compile time hashing for the string ids I think this is the only part of the public api that needs to change

#

though it would remain compatible so thats nice

languid fern
#

Oh yea

#

What about stuff for pipelines though? Would you be keeping those as strings?

night charm
#

hmm

#

for pipelines its only the name right

#

i think maybe using string names can get inconvenient with pipeline permutations

#

so its worth thinking about a change for sure

#

could also go almost fully dynamic with shader objects down the line

#

but im not too sure about that

languid fern
#

Oh yea I forgot those existed lol

#

I'll check support for the extension rq I wanna see how widespread it is

#

damn that is a lot worse than I thought lol

night charm
#

yea its kinda bad

#

i dont like it a whole lot anyway

languid fern
#

most (gtx / rtx) nvidia gpus seem to be supported, none for AMD though

#

I mean tbf what kinda permutations do you handle in phobos?

night charm
#

none

#

Its all on the user side

#

So you would have to write the code for it and then feed your permutations to phobos

#

And find some way to assign string ids to those permutations

languid fern
#

Okok sweet so it doesn't do permutation handling internally?

quiet star
#

internal permutation handling of pipelines would be bad imo

languid fern
#

Yea that's why I'm asking to make sure lol

night charm
#

yea its not really the responsibility of a lib like this

languid fern
#

Yep fair fair

languid fern
#

I'm currently working on improving interface / init context for phobos as I feel like it could be a lot simpler than it is rn

#

Also working on physical device selection

languid fern
#
let settings = AppBuilder::new()
  .name("cFlake engine")
  .scratch_chunk_size(2048u64)
  .raytracing(false)
  .gpu(GPURequirements {
      queues: vec![
          QueueRequest { dedicated: false, queue_type: QueueType::Graphics },
          QueueRequest { dedicated: true, queue_type: QueueType::Transfer },
          QueueRequest { dedicated: true, queue_type: QueueType::Compute }
        ],
      ..Default::default()
      })
  .validation(true)
  .surface(Some(SurfaceSettings {
      surface_format: None,
      present_mode: None,
      window: &window,
  }));
#

yea so what I did in my fork is completely get rid of the HeadlessWindowInterface and HeadlessContext, WindowedContext, and ContextInit

#

Idk if this would be a good thing for phobos but imo I feel like it makes a bit more sense because it doesn't need to take advantage of the type system to make it work, so I just simplified it to making it work without them

#

(and the window field in the SurfaceSettings stores a &dyn Window to remove the need for generics completely)

night charm
#

that looks fine yeah, I think thats a lot cleaner

languid fern
#

Yep. Unfortunately it would a breaking change if we were to implement it

#

I could make a PR for it if you want me to, since it already worked and I tested it on my fork

languid fern
#

I mean tbf it's super easy to fix

languid fern
#

Alright, I tried out examples, and tests, they both work

#

Unfortunately I can't try the fsr2 flag since I don't have it installed yet or raytracing since I don't have an rt card

#

Also I noticed that you use gh actions; would it be possible to run the gfx tests through gh actions or are you not guaranteed to get a GPU to test with?

iron shadow
#

iirc penguin was malding about it a while ago trying to get a mock vulkan api or something set up

languid fern
#

ooo I see

#

well I really like the fact that the tests just use the headless context without any necessary overhead GPU test runner shenanigans

#

but I'd understand if that needs to change for gh action testing

hybrid pilot
#

Looking at the pass builder code to add buffer trabsfers it seems like images are assumed? I don't see anything for buffers

hybrid pilot
#

Like for example PassResource assumes the resource has a Layout

night charm
night charm
#

i barely know that part of the codebase at this point lol

#

its not very well written

#

theres this ResourceType enum

#
pub enum ResourceType {
    /// Image resource
    #[default]
    Image,
    /// Buffer resource
    Buffer,
}

hybrid pilot
hybrid pilot
night charm
#

it might be missng some methods to actually attach them

#

but yeah, layout is ignored in that case

hybrid pilot
#

However you can call the one for storage image but passing a buffer

#

And it will work as far as I can see

hybrid pilot
#

Haven't tried but later code does check for the resource type

night charm
#

lol thats a bit scuffed

#

i should check that

#

im gonna add an issue for that

hybrid pilot
#

So maybe just a matter of changing the naming (and havifn deprecated functions for comapat)

night charm
#

I dont like that too much because you cant sample a buffer for example

#

Maybe strongly typing VirtualResource is a way to get around it, not sure

hybrid pilot
#

Yeah lol

#

I'll look into vuk and see if I can come up with a design maybe

#

Though for now I'd like to actually start working on my renderer lol

night charm
#

understandable lol

hybrid pilot
#

So in execute_fn you get a pool which is the localpool. But if I want to use a resource across passes I guess I have to first allocate it then use VirtualResource like any resource?

night charm
#

the local pool lives for the entire frame

#

so you could also just allocate it from there

hybrid pilot
#

Yeah that's what I want to do

#

Allocate my buffer at the start of the frame and use it as any other resource

#

Though I didn't get why it is passed and if I need to access those resources differently

night charm
#

Oh right I was gonna reply to this and I forgot

#

The local pool is for resources that live for one frame

#

You create it yourself because it has some other uses you can use it for outside of that, for example temporary upload buffers for textures