Camera API

1. Add send/receive lists of file-descriptors through any stardust message 2. Create Camera Item type: pass projection, resolution, render-target (pass through file-descriptor e.g. dma-buf, supporting any pixel format)
264 Replies
Nova
Nova•3y ago
glImportMemoryFdEXT or dmabuf or maybe some third thing i didn't know of oh and we gotta make sure the client can't ever crash the server with an invalid texture or such very important
UnderSampled
UnderSampledOP•3y ago
Should have no response from the server
UnderSampled
UnderSampledOP•3y ago
Phind: AI Programming Assistant
Get instant answers, explanations, and examples for all of your technical questions.
Nova
Nova•3y ago
seems kinda reasonable to me also i was mistaken we need dmabuf for this indeed arcan didn't find an alternative good to know oh also the gl memory fd extension actually uses dmabuf under the hood so we might as well just use dmabuf directly
UnderSampled
UnderSampledOP•3y ago
why? the gl memory looks a lot easier to use if you're already doing gl
Nova
Nova•3y ago
but we can't guarantee that someone might be using vulkan on their client
UnderSampled
UnderSampledOP•3y ago
the FD is the same
Nova
Nova•3y ago
ok, but what about the formats? what about GLES that doesn't support the external mem fd
UnderSampled
UnderSampledOP•3y ago
GLES does It's an extension for both: https://registry.khronos.org/OpenGL/extensions/EXT/EXT_external_objects_fd.txt usable only with POSIX, of course
UnderSampled
UnderSampledOP•3y ago
Some reason I thought you'd shared that to me They use it specifically as a way to go between OpenGL and Vulkan
Nova
Nova•3y ago
ooooh hmm so... what about formats?
UnderSampled
UnderSampledOP•3y ago
it's not sharing a texture it's sharing a memory object which might be a texture
Nova
Nova•3y ago
? oh well uh
UnderSampled
UnderSampledOP•3y ago
so it's whatever formats your texture is
Nova
Nova•3y ago
we should share a texture
UnderSampled
UnderSampledOP•3y ago
yes
Nova
Nova•3y ago
right but how do we sync formats
UnderSampled
UnderSampledOP•3y ago
you don't have to
Nova
Nova•3y ago
like, we need to make sure that this will eventually work for HDR
UnderSampled
UnderSampledOP•3y ago
it's just a texture (if that's what you've shared)
Nova
Nova•3y ago
i'm confused so ok we have a texture now
UnderSampled
UnderSampledOP•3y ago
which has whatever formats that texture has, including HDR
Nova
Nova•3y ago
the client has sent over the texture
UnderSampled
UnderSampledOP•3y ago
HDR is just color gamut nothing really new
Nova
Nova•3y ago
ok, so on the server how do we make sure whatever format it is, it can be rnedered to
UnderSampled
UnderSampledOP•3y ago
afaik
Nova
Nova•3y ago
wait what, then why is it such a big deal requiring tons of protocols
UnderSampled
UnderSampledOP•3y ago
point me to them?
Nova
Nova•3y ago
oh huh i guess it is just color management ok, you know more about this than me for sure if we can make a system that will work into the future with HDR and other new texture formats in an easy way that doesn't require a ton of back and forth then i'll be happy
UnderSampled
UnderSampledOP•3y ago
I think we should be good On Naming: Perhaps Cameras should be physical sensors? we can go with 'Viewpoint', since that's what SK calls it Or Viewport, but that has another meaning in GL (Viewpoints can have Viewports, even)
Nova
Nova•3y ago
hmm i like camera besides, to stardust a physical vs virtual camera will be the same thing
UnderSampled
UnderSampledOP•3y ago
So you could ask for access to a physical camera's stream?
Nova
Nova•3y ago
no, more like you can attach a camera item that represents a physical camera to your object
UnderSampled
UnderSampledOP•3y ago
Isn't that what I just said?
Nova
Nova•3y ago
oh uh idk ask for access implies a permission dialog
UnderSampled
UnderSampledOP•3y ago
the client asking the server for access, whether it's presented to the user in a UI or not You can't have security popups for every capability conferred On Security: SK Viewpoints support a Render Layer filter, which could be used to control what is shown to a Virtual Camera. Unfortunately, they only support 9 layers 😦
Nova
Nova•3y ago
ehh, i don't want stardust to have that anyway what i do want is to have near/far depthbuffer clipping is that part of the projection matrix?
UnderSampled
UnderSampledOP•3y ago
I think so yes
Nova
Nova•3y ago
if anything it would be "only show these objects" but that's really difficult because in stardust you can't really see all the objects because that'd be privacy issues
UnderSampled
UnderSampledOP•3y ago
My thought was it wouldn't be so much render layers as containers the cameras have permission to see
Nova
Nova•3y ago
oh yea also can you think of a good way to make sure that when a camera item is released out of an item acceptor that the client who made the item acceptor can't just keep getting frames from it? oh wait you could just call a frame method every frame on the item duhhh
UnderSampled
UnderSampledOP•3y ago
that's backwards the server is rendering to the buffer
Nova
Nova•3y ago
right
UnderSampled
UnderSampledOP•3y ago
when it stops rendering, the client just won't get anything new But, I don't think any of this will work if you have to 'physically' put cameras into acceptors The 2d screen client needs to be able to boot up and configure its cameras without interaction
Nova
Nova•3y ago
ok but how can i trust the 2D screen client
UnderSampled
UnderSampledOP•3y ago
that's why I said to use render layers then it can only see the objects shared with it or that it creates
Nova
Nova•3y ago
how would you share objects it's just... really complicated
UnderSampled
UnderSampledOP•3y ago
well, then you have to just trust the client
Nova
Nova•3y ago
also, your 2D screen client could be a camera item UI handler in which case it would have access to the cameras
UnderSampled
UnderSampledOP•3y ago
because I'm not going to reconfigure everything everytime I boot up Stardust
Nova
Nova•3y ago
that's what the camera item UI handler is for
UnderSampled
UnderSampledOP•3y ago
I guess I don't understand yet. The 2D screen client creates a Camera that it wants to look through Positions it and gives it a rendertarget What's the User Interaction/Interface there?
Nova
Nova•3y ago
if the 2D screen client is an item UI handler, there is no UI it just does it
UnderSampled
UnderSampledOP•3y ago
as long as that's possible, I'm happy So, what is UI handler? something that has permission to interact with system UI stuff?
Nova
Nova•3y ago
it's an object that the first client to create it gets it and it lets the client both access all items of a type anytime and acceptors and create UIs for all the items of that type and manages when the items are accepted into item acceptors look at orbit for a panel UI handler as well as flatland
UnderSampled
UnderSampledOP•3y ago
so, there can only be one Camera Item UI Handler?
Nova
Nova•3y ago
yea
UnderSampled
UnderSampledOP•3y ago
the 2d screen manager would be the only thing that can create cameras?
Nova
Nova•3y ago
uh... yea well you could also just have a camera item UI that you can grab cameras out of and drop them on the screens too and your screens are camera item acceptors which wouldn't be very hard to do
UnderSampled
UnderSampledOP•3y ago
that's a no go
Nova
Nova•3y ago
when stardust has persistence, it won't be an issue the camera items will automatically be put back on after a restart
UnderSampled
UnderSampledOP•3y ago
you have to have a programatic way to set it up even for the first time "why is my screen black?" "Oh, you have to drag this camera thing onto it" "..." That's why I suggested render layers. You could have up to 9 camera system UI handlers, each with their own set of objects they can see
Nova
Nova•3y ago
if we have only 9 then what happens when you have more it'll just break
UnderSampled
UnderSampledOP•3y ago
we'd have to fix StereoKit to allow more
Nova
Nova•3y ago
also, now you have to explain to users "this camera can only see these things" which is very challenging it's a ton easier to say "this camera can view this far"
UnderSampled
UnderSampledOP•3y ago
How were you hoping to show the camera as something you could drag into a camera item acceptor?
Nova
Nova•3y ago
2 ways 1. have the camera item UI handler render a camera ghost on all acceptors 2. have that ghost automatically make a tracer to where you can summon more cameras but that's the thing for now we can just have your screen handler be a camera item UI handler and just get access to cameras directly there's no problem with that
UnderSampled
UnderSampledOP•3y ago
ok I don't think you ever want to see the cameras though
Nova
Nova•3y ago
the camera UI handler would hide them whenever they're accepted
UnderSampled
UnderSampledOP•3y ago
there might be a client that lets you have a camera you can drag around It feels like we'll just need to have a camera system ui handler that presents the pop-up "this app wants to use a camera; allow? remember?" someday and until then you can only use one client that uses cameras You need a way to revoke the privilege too basically, I think we've established that camera management is tricky enough it actually does need to be handled by a handler that handler may choose to show ghosts
Nova
Nova•3y ago
yep, you can grab the cameras right out of their sockets or such
UnderSampled
UnderSampledOP•3y ago
if they were visible usually they won't be
Nova
Nova•3y ago
really it just depends on the item UI handler you can have a virtual tool for that like a glove that lets you pick up intangible stuff
UnderSampled
UnderSampledOP•3y ago
nice 'camera vision goggles'
Nova
Nova•3y ago
that'd use pulse receivers and such to send a message to the UI handler to go "we want to pick this up" or such
UnderSampled
UnderSampledOP•3y ago
can also have a dumb ui-less handler that has a config file that says "this client is allowed to make and use a camera"
Nova
Nova•3y ago
haha that'd be neat not this though i really don't like hidden config files
UnderSampled
UnderSampledOP•3y ago
not hidden ~/.configs
Nova
Nova•3y ago
those are hidden
UnderSampled
UnderSampledOP•3y ago
remember, not everyone likes UIs
Nova
Nova•3y ago
if i have to hunt in some folder then it's hidden
UnderSampled
UnderSampledOP•3y ago
I think config files can be easier to use
Nova
Nova•3y ago
i def disagree config files are the WORSTT
UnderSampled
UnderSampledOP•3y ago
better than the Windows Registry and guess what, the Windows Registry was created to store configurations for system UIs
Nova
Nova•3y ago
aAAAAAAAAA
UnderSampled
UnderSampledOP•3y ago
seriously though, writing things down is a good way to remember things you can't have persistence without remembering things, and I'd much rather remember them in a way a human can deal with hence, config files
Nova
Nova•3y ago
this is a great example of object oriented code though i'd rather just have persistence with some good UI
UnderSampled
UnderSampledOP•3y ago
See, I think a text file is a good UI You can make GUIs that work on them too
Nova
Nova•3y ago
yes, GUIs that lack context spatially
UnderSampled
UnderSampledOP•3y ago
storing state for user-configurable things as binary, not good like I said, you have to store the configuration somehow. Put the good UI on top of it Anyways, the idea was that you could have a System UI Handler Bus of sorts that lets you run multiple System UI Handlers through it Maybe it would be a Stardust server itself šŸ¤”
Nova
Nova•3y ago
please no that sounds so convoluted
UnderSampled
UnderSampledOP•3y ago
That way the Camera Handler could manage, present UI for, and remember permissions, keeping the config files outside of the core server, giving permission to the 2D Screen Manager to make however many cameras it wants as if it were a SystemUI itself, but still allowing e.g. screenshare to ask for permission each time with a good UI
Nova
Nova•3y ago
that's... a LOT for 1 client
UnderSampled
UnderSampledOP•3y ago
permission management and permission UI? doesn't seem like too much
Nova
Nova•3y ago
permission management delegated to a client
UnderSampled
UnderSampledOP•3y ago
because you didn't want to do it in the server You'd have to do all of that in the server if you didn't delegate it to a client
Nova
Nova•3y ago
that's what the item system is for
UnderSampled
UnderSampledOP•3y ago
You would have to support multiple system UI handlers in the server if you don't have the single system UI handler to handle that sort of thing
Nova
Nova•3y ago
why?
UnderSampled
UnderSampledOP•3y ago
well, you just said that I could only have one System UI handler that could create it's own cameras (for the screens, e.g.). What if I want another client that is able to e.g. to video recordings? or display your ghost cameras
Nova
Nova•3y ago
camera item acceptors and when persistence is implemented in stardust, those will automatically be filled with cameras if they were before
UnderSampled
UnderSampledOP•3y ago
That requires physical interaction please don't make me have to drag a camera onto my virtual dslr everytime I want to use it
Nova
Nova•3y ago
only the first time
UnderSampled
UnderSampledOP•3y ago
configuration is much better than persistence
Nova
Nova•3y ago
also, there's no reason your camera UI handler couldn't make it so you can just press on the camera item acceptor to place a camera in there instead of dragging it over
UnderSampled
UnderSampledOP•3y ago
every time I create a fake dslr, it's the first time for that dslr ... any sort of interaction there is going to be very annoying
Nova
Nova•3y ago
look, for most people if you don't have something in their face it doesn't exist you gotta understand that configuration without spatial context instantly is in the ether it's in a nowhere place another universe etc.
UnderSampled
UnderSampledOP•3y ago
use your ether-goggles then but it's on a computer. It doesn't exist
Nova
Nova•3y ago
sure, but in order to make it actually obvious to the person using it you gotta pretend like it does map the abstract nonsense to 3D objects so people can see it
UnderSampled
UnderSampledOP•3y ago
the fake DSLR in my example is that object a ghost camera doesn't make any sense when I've got a (virtual) DSLR right here! Why do I have to drag a ghost camera to possess my DSLR?
Nova
Nova•3y ago
because you don't want some other client making a camera without your knowledge
UnderSampled
UnderSampledOP•3y ago
hence a system ui handler manager that can ask you one of which may show ghost cameras for those people who really want to see them
Nova
Nova•3y ago
that's what the camera item UI handler can do
UnderSampled
UnderSampledOP•3y ago
yes
Nova
Nova•3y ago
anyway, if you really want one with configuration then you can make that i definitely won't though :p
UnderSampled
UnderSampledOP•3y ago
the thing is, the 2D screen manager needs to be able to act as a system UI handler but I don't want it to do the permission management
Nova
Nova•3y ago
for now, you can make it so it just doesn't worry about camera UI handlers at all but then it's super easy to update later to be camera item acceptors and your camera item UI handler to give it to them properly
Nova
Nova•3y ago
withfd - Rust
withfd allows passing file descriptors through Unix sockets.
UnderSampled
UnderSampledOP•3y ago
Vectored I/O
In computing, vectored I/O, also known as scatter/gather I/O, is a method of input and output by which a single procedure call sequentially reads data from multiple buffers and writes it to a single data stream (gather), or reads data from a data stream and writes it to multiple buffers (scatter), as defined in a vector of buffers. Scatter/gathe...
UnderSampled
UnderSampledOP•3y ago
@Nova The message header we are adding the FDs into has a 'scatter/gather array' in it @Nova Sorry for the confusion I made. There is no message header actually sent with iovecs: iovecs tell the system-call where to read or write the data to/from the 'header' I thought I understood was actually just a structure to provide more parameters to the system call it does allow you to split up the bytes you read into multiple buffers, but they're all fixed so if you want to stream the data with a variable length, I think you'll have to continue doing it as you do The other option is to choose a max length, and use two iovecs to split it into the length and the content. The advantage of this is that you can reuse the same buffers each time, which could be faster
UnderSampled
UnderSampledOP•3y ago
I was not able to use sendFd because it didn't do async, but I was able to learn from it's source how it worked with Tokio and was able to do that myself as well Originally, I had planned to include the FDs when the header is sent, but moved it to the body so that the number of FDs could be sent in the header too the number to receive is limited by the OS; modern Linux is limited to 253 FDS withFd just always made the buffer for receiving the FDs big enough to receive all 253, so I could have done it that way instead and used the suggested cmsg_space macro (I had to reimplement it to accept a variable number of expected FDs, but it was only a few lines) I brought the FDs all the way up to the scenegraph and mostly stopped there, thinking you'll want to take over from there. I also recommend turning the method response return value into a tuple (Vec<u8>, Vec<RawFd>) Also: You have to send some data in the body if you're sending an FD. If that doesn't work for you, we can switch it back to the header message and fixed 253, since the header always has something. I did not test it at all, but it did compile.
Nova
Nova•3y ago
@UnderSampled what data do we have to send in the body?
UnderSampled
UnderSampledOP•3y ago
It just can't be null Sorry, I should have added a check
Nova
Nova•3y ago
@UnderSampled making a type safe api for this with OwnedFd so you actually send owned fds to the other side
UnderSampled
UnderSampledOP•3y ago
I wondered if you might šŸ™‚ @Nova how's it working out?
Nova
Nova•3y ago
haven't fully updated everything yet but you should take a look at the API see if i missed anything check core main branch @UnderSampled make sure my owned fd logic is sound?
UnderSampled
UnderSampledOP•3y ago
I think, even though they should be the same size (being as they are the same data), it isn't good to use size_of::<OwnedFd>() for the csmghdr buffer I could be convinced otherwise but the libc function is outputting raw fds into that buffer
Nova
Nova•3y ago
idk where that was set but... yea idk, anything you want to fix?
UnderSampled
UnderSampledOP•3y ago
199 still reading the rest but it's recieving rawfds, not owned ones
Nova
Nova•3y ago
well yea, doesn't it have to recieve raw fds? instead of owned ones?
UnderSampled
UnderSampledOP•3y ago
yes
Nova
Nova•3y ago
anyway, i figure you know more than me... i'll integrate this into the server test and hope it works if it does, we'll need to update... all the clients right? since the message header is double length breaking the spec?
UnderSampled
UnderSampledOP•3y ago
CMSG_SPACE((::std::mem::size_of::<OwnedFd>() * header.fd_count as usize) as c_uint)
CMSG_SPACE((::std::mem::size_of::<OwnedFd>() * header.fd_count as usize) as c_uint)
should be
CMSG_SPACE((::std::mem::size_of::<RawFd>() * header.fd_count as usize) as c_uint)
CMSG_SPACE((::std::mem::size_of::<RawFd>() * header.fd_count as usize) as c_uint)
Nova
Nova•3y ago
oh oopsies should i edit that?
UnderSampled
UnderSampledOP•3y ago
yes I'm still reading the rest and, yes. I wasn't really thinking about compatibility... if you don't want to change the header length, we can have a fixed buffer for the cmsgs
Nova
Nova•3y ago
orrr we could add it to the end of the message struct... right? hmm maybe not actually
UnderSampled
UnderSampledOP•3y ago
no
Nova
Nova•3y ago
wait why do we need a fixed buffer?
UnderSampled
UnderSampledOP•3y ago
well, you could, but you'd have to do a third message for any fds
Nova
Nova•3y ago
couldn't we just have like idk what even is a message header anyway???? like, what are cmsgs?? some side channel of communication?
UnderSampled
UnderSampledOP•3y ago
no well, sorta? I think the data probably comes through the same channel, but it's parsed out anyways, the cmsgs are just places for it to put the extra data like the iovecs are where you tell it to put the data it's reading off the socket
Nova
Nova•3y ago
can you shove... any data through the socket?
UnderSampled
UnderSampledOP•3y ago
you can shove any data through the socket, yess
Nova
Nova•3y ago
like i mean in cmsgs
UnderSampled
UnderSampledOP•3y ago
no remember, the fds aren't normal data, because when you tell the kernel to send it on the socket, it creates a new fd for the other process so it needs this special way to send it
Nova
Nova•3y ago
so we can't just stuff the count through the cmsgs on the length shoot :((
UnderSampled
UnderSampledOP•3y ago
so, the way withfd recieves them, is it creates a buffer that can accept up to the maximum 253 (which is the max supported by the linux kernel) if you don't receive that many, that's fine, it will just be a bigger buffer than necessary 253*4 bytes so, a 1k buffer. woo not necessarily great to keep allocating it each time though to be efficient, you'd just reuse the same buffer, probably though maybe that's too much optimization stuff like that matters more on e.g. microcontrollers Would you like me to just allocate 1k each time, and see what fds we get?
Nova
Nova•3y ago
mind making a benchmark? or is that too much?
UnderSampled
UnderSampledOP•3y ago
you don't have any tests
Nova
Nova•3y ago
i guess
UnderSampled
UnderSampledOP•3y ago
How important is compatibility at the moment?
Nova
Nova•3y ago
i guess not much
UnderSampled
UnderSampledOP•3y ago
If we do the fixed max 1k buffer, this
// Nix's suggested cmsg_space macro doesn't support fd_count as a variable, so we have to do this manually.
let space = unsafe {
CMSG_SPACE((::std::mem::size_of::<RawFd>() * header.fd_count as usize) as c_uint)
} as usize;
// Nix's suggested cmsg_space macro doesn't support fd_count as a variable, so we have to do this manually.
let space = unsafe {
CMSG_SPACE((::std::mem::size_of::<RawFd>() * header.fd_count as usize) as c_uint)
} as usize;
becomes
let space = cmsgspace!([RawFd; 253]);
let space = cmsgspace!([RawFd; 253]);
and it wouldn't have the if for whether to handle fds or not I'd also probably send them when sending the header. That was my original plan, which I switched around when I tried to make it dynamic in theory, instead of 253, it should be SCM_MAX_FD, but I can't figure where that is available
Nova
Nova•3y ago
idk, what do you think is best?
UnderSampled
UnderSampledOP•3y ago
probably keeping compatibility
Nova
Nova•3y ago
@UnderSampled cool! i can give you access to the repo if you like to help fix that i'm really tired right now
UnderSampled
UnderSampledOP•3y ago
okay
Nova
Nova•3y ago
ok @UnderSampled invited you
UnderSampled
UnderSampledOP•3y ago
sweet! The core send/recieve should be quite different, and the header will be smaller again (I'll keep the struct though), but everything else should be about the same you can start using FDs in things now šŸ™‚ or, maybe writing tests to see if you can šŸ˜„
Nova
Nova•3y ago
so, backwards compatibility or not?
UnderSampled
UnderSampledOP•3y ago
it should be backwards compatible, I'm just leaving the code for fancy headers in place if you want to break compatibility now and leave extra room for future stuff in the header, now's your chance šŸ˜„ (I can't think of what might be in the header besides length though, if we're not putting fd-count)
Nova
Nova•3y ago
yea i think that's good like, what we have now i mean, what other data can you even stuff in a header??
UnderSampled
UnderSampledOP•3y ago
often things like recipient/channel, if you're sharing a stream with something else error correction TCP has all sorts of stuff do you want me not to keep the Header struct?
Nova
Nova•3y ago
idk tbh this is a part of the code i really just want to get fixed and never touch again :p
UnderSampled
UnderSampledOP•3y ago
I noticed that you probably used an autoreformatter on some things So I figured I'd run it too I'm not sure it came up with the same results? oh, it's probably because I removed an indent
Nova
Nova•3y ago
cargo fmt aka rustfmt
UnderSampled
UnderSampledOP•3y ago
hmm I see it in GitHub, but when I go to push locally it doesn't like it @Nova I have it back in my branch
Nova
Nova•3y ago
oof lemme see i sent you an invite now @UnderSampled
UnderSampled
UnderSampledOP•3y ago
k Did you want to review? I left it sending the fds on the body message, since I didn't have to change the code around as much, and if you ever do need to add the header stuff back you don't have to change it back again (technically, its just writing/reading it with the same call as the body is added to the stream; there are no 'packets')
Nova
Nova•3y ago
oh weeeird
UnderSampled
UnderSampledOP•3y ago
what? ... I literally just pushed
Nova
Nova•3y ago
oh well uh ok thank you!
UnderSampled
UnderSampledOP•3y ago
is it all good? (besides never being tested)
Nova
Nova•3y ago
haha yea looks good so far
UnderSampled
UnderSampledOP•3y ago
šŸ™‚ :3 So, what's next?
Nova
Nova•3y ago
well, i JUST got the server syntax errors fixed so time to test!!!
Nova
Nova•3y ago
VERY GOOD SIGN @UnderSampled
No description
Nova
Nova•3y ago
i just loaded it up and BAM
UnderSampled
UnderSampledOP•3y ago
woah!
Nova
Nova•3y ago
works as normal backwards compatible indeed!
UnderSampled
UnderSampledOP•3y ago
I mean, we haven't successfully tried sending FDs but, I didn't break it! woot!
Nova
Nova•3y ago
i'll save that for the camera item
UnderSampled
UnderSampledOP•3y ago
yeah
Nova
Nova•3y ago
good news is that this feature can go on the server and client independently
UnderSampled
UnderSampledOP•3y ago
yeah, old clients will still work and most of them won't need the feature new ones will still be checking for FDs with every message e.g. with a buffer to catch them šŸ˜„
Nova
Nova•3y ago
fixing versions and uploading is that a problem? will it slow it down enough to matter?
UnderSampled
UnderSampledOP•3y ago
no the compiler might even notice that it's going to be used a lot and prepare for that being the same size each time will actually help with that
Nova
Nova•3y ago
oh yea rust's whole design is STUPID EFFICIENT
UnderSampled
UnderSampledOP•3y ago
- Add send/receive lists of file-descriptors through any stardust message - Create Camera Item type: pass projection, resolution, render-target (pass through file-descriptor e.g. dma-buf, supporting any pixel format)
Nova
Nova•3y ago
well, not quite done with send/recieve lists we have to actually upload it :p
UnderSampled
UnderSampledOP•3y ago
well, nothing uses them now, so how would you know? we won't know until we either write a unit-test or create a Camera Item
Nova
Nova•3y ago
i have faith in your code and the power of rust
UnderSampled
UnderSampledOP•3y ago
😬 we shall see still, what do we need to do to make a Camera Item?
Nova
Nova•3y ago
ok so! we wanted to do the variable length buffers right? we need to figure out how to: a. use dmabufs at all in rust b. render to a dmabuf texture that could be... basically any format with stereokit render_to
UnderSampled
UnderSampledOP•3y ago
Nova
Nova•3y ago
it does use dmabuf under the hood
UnderSampled
UnderSampledOP•3y ago
which would mean we don't have to figure out dmabuf, yeah?
Nova
Nova•3y ago
maybe... can you help figure out how you negotiate formats with this? and if you can use the same fd with dmabuf? i just don't want this to become an issue later
UnderSampled
UnderSampledOP•3y ago
why does it have to work with dmabuf?
Nova
Nova•3y ago
because dmabuf gives finer grained control that may be necessary for some applications
Nova
Nova•3y ago
i want to avoid this
No description
UnderSampled
UnderSampledOP•3y ago
even if we have to use dmabuf, I don't think that's the first thing to tackle first, we need the Camera Item to exist to start playing with it
Nova
Nova•3y ago
fair fair
UnderSampled
UnderSampledOP•3y ago
it does seem like DMA-buf might be better documented. The external_objects thing is more focused on vulkan->opengl stuff
UnderSampled
UnderSampledOP•3y ago
UnderSampled
UnderSampledOP•3y ago
so, we can use dma buf, sure šŸ™‚ still need a camera first
Nova
Nova•3y ago
right ok so i'm just publishing the 2 client crates needed to get the server updated
UnderSampled
UnderSampledOP•3y ago
lol now there's a type name šŸ˜„ PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC
Nova
Nova•3y ago
oh god
UnderSampled
UnderSampledOP•3y ago
PFN EGL export DMABUF image query Mesa Process?
Nova
Nova•3y ago
uhhh idk
UnderSampled
UnderSampledOP•3y ago
it's just a place to load the function from the extension I don't think we'll see that in Rust
Nova
Nova•3y ago
yea... where do we even deal with this in rust
UnderSampled
UnderSampledOP•3y ago
do you do anything with GL at the moment? (besides use SterepKit) presumably something for panels?
Nova
Nova•3y ago
i mean... barely smithay does most of it but yea smithay has GL bindings... and i guess needs to use dmabuf!
UnderSampled
UnderSampledOP•3y ago
I can look at their code šŸ™‚ we might actually be able to just reuse it
UnderSampled
UnderSampledOP•3y ago
Nova
Nova•3y ago
@UnderSampled made the camera item... should it be an immediate mode API or not?
UnderSampled
UnderSampledOP•3y ago
cool! What do you mean?
Nova
Nova•3y ago
like call frame() on it every frame and feed it a dmabuf
UnderSampled
UnderSampledOP•3y ago
hmm
Nova
Nova•3y ago
and it'll render into it then return a success or such value actually wait wait no multiple dmabufs is a bad idea... hmm
UnderSampled
UnderSampledOP•3y ago
so, judging from https://blaztinn.gitlab.io/post/dmabuf-texture-sharing/, I don't think we'll need multiple I'm hopeful
Nova
Nova•3y ago
right, but we might want multiple i might just ask the arcan people
UnderSampled
UnderSampledOP•3y ago
k the question is really just about if screen-tearing or access management are things we need to worry about if dmabuf handles that (and I think it does?) we don't need to worry about it, and one is enough but I think RenderTo has to be called each frame We'll have to upgrade StereoKit if we want a RenderTo equivalent that stays around
Nova
Nova•3y ago
screen tearing isn't handled by dmabuf at all access management is done by the client giving the server the dmabuf it should render into so... screen tearing is what happens when you swap a texture right in the middle of rendering to a newer one or you change content in a CPU buffer or such that can be avoided by having multiple buffers, drawing into 1, then swapping them and drawing into another, at the cost of a teeeny bit of latency
UnderSampled
UnderSampledOP•3y ago
I don't think so
Nova
Nova•3y ago
what do you mean?
UnderSampled
UnderSampledOP•3y ago
from https://www.kernel.org/doc/html/latest/driver-api/dma-buf.html
The three main components of this are: (1) dma-buf, representing a sg_table and exposed to userspace as a file descriptor to allow passing between devices, (2) fence, which provides a mechanism to signal when one device has finished access, and (3) reservation, which manages the shared or exclusive fence(s) associated with the buffer.
fence being the functionality in question both devices have to be able to use the same buffer. just because you sent it to the other over an FD doesn't mean they don't both still need it they just can't use it at the same time (without screen tearing or maybe worse things)
Nova
Nova•3y ago
it wouldn't be worse
UnderSampled
UnderSampledOP•3y ago
yes, it easily culd be
Nova
Nova•3y ago
how? it's not changing in terms of allocation
UnderSampled
UnderSampledOP•3y ago
knowing which texture to use when? remember, the client is running at a different framerate but, I go back to this: RenderTo has to be called each frame if that logic runs in the CameraItem, then it needs to receive the frame signal
Nova
Nova•3y ago
no ok here's how it would work when the client calls frame() on the camera item it just saves your settings into the camera item for the next xr frame on the server, renders to the dmabuf with those settings, then will send the method return back
UnderSampled
UnderSampledOP•3y ago
Could you say that again, defining 'you'? And 'next time it can render'? I don't know those parts well enough to understand who's talking to it when, and how it knows about when it can render
Nova
Nova•3y ago
ok yea did thata
UnderSampled
UnderSampledOP•3y ago
That sounds good šŸ‘ After some review, it seems that Smithay exposes it's dmabuf utilities as a toolbox specifically for this sort of use case šŸ™‚ Not only that, but it also provides the tools to make the GL contexts, swapchains, create windows, or even work with DRM and logind!
Nova
Nova•3y ago
yep
UnderSampled
UnderSampledOP•3y ago
basically, everything needed to make the client šŸ™‚
Nova
Nova•3y ago
No description
UnderSampled
UnderSampledOP•3y ago
okay well, hopefully we can work out a double buffer that makes sense then or maybe your last solution as a sort of semaphore will be enough šŸ¤ž
Nova
Nova•3y ago
idk what a semaphore is
UnderSampled
UnderSampledOP•3y ago
Semaphore (programming)
In computer science, a semaphore is a variable or abstract data type used to control access to a common resource by multiple threads and avoid critical section problems in a concurrent system such as a multitasking operating system. Semaphores are a type of synchronization primitive. A trivial semaphore is a plain variable that is changed (for e...
UnderSampled
UnderSampledOP•3y ago
a message that says "your turn" (or "my turn")
Nova
Nova•3y ago
ahh
UnderSampled
UnderSampledOP•3y ago
Next steps: 1. Make initial client screen manager with: https://docs.rs/smithay/latest/smithay/backend/winit/index.html 2. Add buffer format capability info request method 3. Create and export a pair of buffers from screen manager renderer into dmabufs 4. Add camera setup/update method to Import the dmabufs on the server into render targets compatible with glBindTexture and change transforms. 5. Add camera render method with preloaded-buffer index as target (e.g. render camera to buffer 1) 6. In client: on frame event, present frame n, then ask for render to n=(n+1)%bufferCount
smithay::backend::winit - Rust
Implementation of backend traits for types provided by winit
Nova
Nova•3y ago
that sounds a lot more complicated :S
UnderSampled
UnderSampledOP•3y ago
Than what?
Nova
Nova•3y ago
the idea i had of it i'm not saying i know a better way just... :((
UnderSampled
UnderSampledOP•3y ago
If you'd like, we can start with virtual screens: 1. Add a method to create a panel with a render target compatible with glBindTexture (or create one for an existing panel? Panel shell?) and export a secure ref for it to a client. 2. Add camera setup/update method to choose buffers (provide the single texture-ref) and change transforms. 3. Add camera render method with preloaded-buffer index as target (e.g. render camera to buffer 1) 4. In client: on frame event, ask for render to buffer 1
Nova
Nova•3y ago
huh... maybe security might be an issue with that though
UnderSampled
UnderSampledOP•3y ago
Agreed, however consider that the same thing can be done with dmabufs The trick that the texture ref sent over to the client should only be usable by that client You could make it a FD šŸ˜†
Nova
Nova•3y ago
that's the idea
UnderSampled
UnderSampledOP•3y ago
Not dmabufs, just using FDs to make sure only thay process has access to it To save the step of reimporting the dmabuf to a rendertarget when it comes back to the server (Since the rendertarget texture already exists there) @Nova I think I'm at a place where doing some pair programming to get your rust knowledge would help me immensely I'm free the rest of the evening
Nova
Nova•3y ago
i'm pretty fatigued right now, but idk how i can make that better so whatever, might as well just do what i normally would sleep won't fix this kind of fatigue how about in 30min?
UnderSampled
UnderSampledOP•3y ago
I just took a long nap šŸ˜‰ 30 mins should be fine though I'll have to get food sometime around then Another thing that can help with fatigue is exercise, though I'm not a good role-model there
Nova
Nova•3y ago
hi @UnderSampled
UnderSampled
UnderSampledOP•3y ago
hey šŸ™‚
Nova
Nova•3y ago
vc?

Did you find this page helpful?