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

Ray tracing position fetch support #1092

Open
atynagano opened this issue Sep 12, 2023 · 3 comments
Open

Ray tracing position fetch support #1092

atynagano opened this issue Sep 12, 2023 · 3 comments
Labels
t: enhancement A new feature or improvement to an existing one.

Comments

@atynagano
Copy link

https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/HitTriangleVertexPositionsKHR.html

Is it planned, or is there any way to use such a extension?

@atynagano atynagano added the t: enhancement A new feature or improvement to an existing one. label Sep 12, 2023
@atynagano
Copy link
Author

atynagano commented Sep 23, 2023

    use core::arch::asm;
    use spirv_std::glam::Vec3;

    #[spirv_std::macros::gpu_only]
    pub fn get_positions() -> [Vec3; 3] {
        unsafe {
            let mut result: [Vec3; 3] = Default::default();
            asm! {
                "%f32 = OpTypeFloat 32",
                "%f32x3 = OpTypeVector %f32 3",
                // OpTypeArray in asm! is not supported yet
                // "%f32x3x3 = OpTypeArray %f32x3 3",
                "%f32x3x3 = OpTypeMatrix %f32x3 3",
                "%ptr_f32x3x3 = OpTypePointer Generic %f32x3x3",
                "%positions = OpVariable %ptr_f32x3x3 Input",
                "OpDecorate %positions BuiltIn HitTriangleVertexPositionsKHR",
                "%result = OpLoad %f32x3x3 %positions",
                "OpStore {result} %result",
                result = in(reg) &mut result,
            }
            result
        }
    }

I tried the above code and got the error message error: unknown BuiltIn HitTriangleVertexPositionsKHR. So I think rspirv needs to support it first.
(I am not familiar with spirv so this code may be wrong to begin with.)

@atynagano
Copy link
Author

Seems supported in version 0.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: enhancement A new feature or improvement to an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants
@atynagano and others