-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Headless renderer example has been added #13006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Headless renderer example has been added #13006
Conversation
@alice-i-cecile May I ask you for a review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick review of the first couple of things I saw, this isn't a comprehensive review.
The code seems to do a lot of things and I'd prefer if it could be streamlined a bit to be easier to follow, but it's hard to know if there are parts of it that aren't as important because it lacks documentation of what all the pieces are.
782ada3
to
40bb6d8
Compare
e648765
to
4960008
Compare
4960008
to
d85d6a7
Compare
@IceSentry , may I ask you for a rereview? |
Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com>
could you add objects to the scene, so that it doesn't render just a black picture? the example panics for me:
Is it possible to not surface that panic? |
examples/app/headless_renderer.rs
Outdated
let number = rng.gen::<u128>(); | ||
let image_path = images_dir.join(format!("{number:032X}.png")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use an incrementing number instead of a random value?
replace println to info Co-authored-by: François Mockers <francois.mockers@vleue.com>
The reason of this panic is attempt to send image data to nonexistent receiver, because MainWorld destroyed while RenderWorld still renders. For such case I left comment |
11edefd
to
946ae14
Compare
@mockersf May I ask you for a rereview? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the comment about the nested modules being unnecessary for an example but otherwise lgtm.
examples/app/headless_renderer.rs
Outdated
let mut cpu_image = Image { | ||
texture_descriptor: TextureDescriptor { | ||
label: None, | ||
size, | ||
dimension: TextureDimension::D2, | ||
format: TextureFormat::Rgba8UnormSrgb, | ||
mip_level_count: 1, | ||
sample_count: 1, | ||
usage: TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING, | ||
view_formats: &[], | ||
}, | ||
..Default::default() | ||
}; | ||
cpu_image.resize(size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified a little with this:
let mut cpu_image = Image { | |
texture_descriptor: TextureDescriptor { | |
label: None, | |
size, | |
dimension: TextureDimension::D2, | |
format: TextureFormat::Rgba8UnormSrgb, | |
mip_level_count: 1, | |
sample_count: 1, | |
usage: TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING, | |
view_formats: &[], | |
}, | |
..Default::default() | |
}; | |
cpu_image.resize(size); | |
let cpu_image = Image::new_fill( | |
size, | |
TextureDimension::D2, | |
&[0; 4], | |
TextureFormat::bevy_default(), | |
RenderAssetUsages::default(), | |
); |
examples/app/headless_renderer.rs
Outdated
let mut render_target_image = Image { | ||
texture_descriptor: TextureDescriptor { | ||
label: None, | ||
size, | ||
dimension: TextureDimension::D2, | ||
format: TextureFormat::Rgba8UnormSrgb, | ||
mip_level_count: 1, | ||
sample_count: 1, | ||
usage: TextureUsages::COPY_SRC | ||
| TextureUsages::COPY_DST | ||
| TextureUsages::TEXTURE_BINDING | ||
| TextureUsages::RENDER_ATTACHMENT, | ||
view_formats: &[], | ||
}, | ||
..Default::default() | ||
}; | ||
render_target_image.resize(size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut render_target_image = Image { | |
texture_descriptor: TextureDescriptor { | |
label: None, | |
size, | |
dimension: TextureDimension::D2, | |
format: TextureFormat::Rgba8UnormSrgb, | |
mip_level_count: 1, | |
sample_count: 1, | |
usage: TextureUsages::COPY_SRC | |
| TextureUsages::COPY_DST | |
| TextureUsages::TEXTURE_BINDING | |
| TextureUsages::RENDER_ATTACHMENT, | |
view_formats: &[], | |
}, | |
..Default::default() | |
}; | |
render_target_image.resize(size); | |
let mut render_target_image = Image::new_fill( | |
size, | |
TextureDimension::D2, | |
&[0; 4], | |
TextureFormat::bevy_default(), | |
RenderAssetUsages::default(), | |
); | |
render_target_image .texture_descriptor.usage |= TextureUsages::RENDER_ATTACHMENT | TextureUsages::TEXTURE_BINDING; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a few things that can be improved to simplify this example a little, but it's probably better to merge it as-is and improve it later.
I haven't tested my suggestions, but I know they should roughly work. There might be some fmt issues.
@bugsweeper those suggestions look solid, but once CI is green I'll merge this in either way :) |
examples/app/headless_renderer.rs
Outdated
while image_path.exists() { | ||
number += 1; | ||
image_path = images_dir.join(format!("{number:03}.png")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could keep a Local<u32>
as a system parameter instead of iterating on every file. this has the potential to blow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example can be run multiple times with single_image option, Local helps only at first run with multiple files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overwriting files from a previous run seems better to me than iterating over every files. additional bonus is that we create less random files on their computer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Searching free filenames has been changed to Local usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interaction with the file system should be improved or commented
08c6aff
to
b74e238
Compare
@mockersf May I ask you for a rereview? |
@alice-i-cecile Ci is green now |
Objective
Fixes #11457.
Fixes #22.
Solution
Based on another headless application
Changelog