maierfelix / maierfelix/webgpu

Support ray query

Open
#28 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
248
Forks
17
PR merge metrics
No merged PRs in 30d

Description

refer to [NVIDIA Vulkan Ray Tracing Tutorial -> ray query](https://nvpro-samples.github.io/vk_raytracing_tutorial_KHR/vkrt_tuto_rayquery.md.htm), I add ray query in .frag shader:

screen.frag
```glsl
#version 460
#pragma shader_stage(fragment)

#extension GL_EXT_ray_tracing : enable
#extension GL_EXT_ray_query : enable

...

layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;

...

void main() {
...

// Ray Query
vec3 origin = vec3(0.1);
vec3 direction = vec3(1.0); // vector to light
float tMin = 0.01f;
float tMax = 100000000.0f;

// Initializes a ray query object but does not start traversal
rayQueryEXT rayQuery;
rayQueryInitializeEXT(rayQuery, topLevelAS, gl_RayFlagsTerminateOnFirstHitEXT,
0xFF, origin, tMin, direction, tMax);

// Start traversal: return false if traversal is complete
while (rayQueryProceedEXT(rayQuery)) {
}

...
}

```

I pass the instance accelerationContainer to render bind group:
index.mjs
```js
...

let renderBindGroupLayout = device.createBindGroupLayout({
entries: [
{
binding: 0,
visibility: GPUShaderStage.FRAGMENT,
type: "acceleration-container"
},
...
]
});

...

let renderBindGroup = device.createBindGroup({
layout: renderBindGroupLayout,
entries: [
{
binding: 0,
accelerationContainer: instanceContainer,
offset: 0,
size: 0
},
...
]
});
```

then I run the index.mjs in nodejs, it error:
```js
Error: Validation Error: acceleration container binding is not supported in this shader
at ValidateBindingTypeWithShaderStageVisibility (../../src/dawn_native/BindGroupLayout.cpp:67)
at ValidateBindGroupLayoutDescriptor (../../src/dawn_native/BindGroupLayout.cpp:133)
at CreateBindGroupLayoutInternal (../../src/dawn_native/Device.cpp:837)
at Immediate. (D:\Github\WebGPU-Sample\node_modules\webgpu\index.js:41:30)
at processImmediate (internal/timers.js:458:21)
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the validation error with index.mjs and inspect the ray-query declarations in screen.frag, using the linked NVIDIA Vulkan Ray Tracing Tutorial for context. Trace how the render bind group layout and acceleration container binding are validated. Done means the fragment shader’s ray-query acceleration-container binding is accepted and the example runs without this validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.