Skip to content
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

Remove any pointer usage in the code #34

Open
keryell opened this issue Feb 5, 2021 · 0 comments
Open

Remove any pointer usage in the code #34

keryell opened this issue Feb 5, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@keryell
Copy link
Member

keryell commented Feb 5, 2021

There are a few superfluous .data() and get_pointer() instead of just using the accessor.

For example instead of

render<width, height, samples>(myQueue, fb.data(), hittables.data(),
                                 hittables.size(), cam);
save_image<width, height>(fb.data());
render<width, height, samples>(myQueue, fb, hittables, cam);
save_image<width, height>(fb);

Also replace hittables_ptr, num_hittables by hittables_acc since the accessor has the size too.

Then probably hit_world and get_color can be just plain functions.
I have the feeling that you could replace

    auto render_kernel = pixel_renderer<width, height, samples, depth>(
        frame_ptr, hittables_ptr, num_hittables, cam);
    executor<width, height>(cgh, render_kernel);

by

    executor<width, height>(cgh, [=] (...) { ... here is the full renderer code });

and in the executor do not copy the lambda:

void executor(auto& cgh, T& render_kernel) {

(or perhaps even const T& render_kernel).

I think all these copies explain the slowdown from #33

Be sure you do not copy anything in a useless way. Pass by reference or at least std::forward.

@keryell keryell added the enhancement New feature or request label Feb 5, 2021
@lforg37 lforg37 mentioned this issue Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants