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

Update vulkan example #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update vulkan example #75

wants to merge 1 commit into from

Conversation

exrook
Copy link
Contributor

@exrook exrook commented Feb 22, 2021

Example now renders in 3D using the tracked HMD position and shows cubes at the location of each hand controller.

openxr/examples/vulkan.rs Outdated Show resolved Hide resolved
openxr/examples/vulkan.rs Outdated Show resolved Hide resolved
data_ptr,
mem::align_of::<f32>() as u64,
vertex_buffer_mem_requirements.size,
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align isn't doing anything useful here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you recommend instead? I did it this way because this is what I saw in the ash examples. (and I changed it again to use vertex_buffer_mem_requirements.alignment for the second argument in the force push I just did but I suspect that may have been incorrect after doing some more research)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to do anything special at all. Memory allocated according to the requirements of a vertex buffer will necessarily satisfy the buffer's GPU-side alignment requirements. I believe the CPU-side alignment should also be implicitly satisfied. Writing data starting at any location other than the start of the buffer, or with a non-dense stride, would constitute a mismatch with the vertex attribute layout declared in the pipeline.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(unfortunately the ash examples, and indeed most introductory vulkan examples, aren't great; there's a PR in need of review to improve them)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be sound to construct an &mut [T] from gpu memory or should I always go through ptr:;write?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see Align does create a slice but my concern is that the data in the buffer may not be valid for reads. I think I'll use std::ptr::copy for now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a slice to uninitialized memory would be unsound, yeah. copy_nonoverlapping should be preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

openxr/examples/vulkan.rs Outdated Show resolved Hide resolved
openxr/examples/vulkan.rs Show resolved Hide resolved
openxr/examples/vulkan.rs Show resolved Hide resolved
openxr/examples/fullscreen.vert Outdated Show resolved Hide resolved
openxr/examples/fullscreen.vert Outdated Show resolved Hide resolved
@exrook exrook force-pushed the master branch 2 times, most recently from 7770d9f to 61c7938 Compare February 22, 2021 22:55
Example now renders in 3D using the tracked HMD position and
shows cubes at the location of each hand controller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants