-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. #17413
Changes from all commits
6aec99d
34f693d
b3bd9c8
6ff7c04
75ee16e
fc068fb
c48adf2
63733db
f170d1e
ff77eee
c21715d
ef82e53
677c947
0c78571
59c1424
e498850
c4698df
2dbf614
02b8486
d08b195
77bfc6a
795ddc4
129f12d
c1e5053
64cb9b7
c5df9c8
a57d2a5
9d16350
76e4f8a
f025875
dd8e93b
6911ddf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT | ||
@group(0) @binding(0) var<storage, read> mip_0: array<u64>; // Per pixel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just as a note: I believe all the meshlet-specific stuff is going to disappear here once wgpu 24 is merged and I can switch back to an image-based visbuffer. |
||
#else | ||
#ifdef MESHLET | ||
@group(0) @binding(0) var<storage, read> mip_0: array<u32>; // Per pixel | ||
#endif | ||
#else // MESHLET | ||
#ifdef MULTISAMPLE | ||
@group(0) @binding(0) var mip_0: texture_depth_multisampled_2d; | ||
#else // MULTISAMPLE | ||
@group(0) @binding(0) var mip_0: texture_depth_2d; | ||
#endif // MULTISAMPLE | ||
#endif // MESHLET | ||
#endif // MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT | ||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am reminded of how spoiled I am getting to just write Rust. |
||
@group(0) @binding(1) var mip_1: texture_storage_2d<r32float, write>; | ||
@group(0) @binding(2) var mip_2: texture_storage_2d<r32float, write>; | ||
@group(0) @binding(3) var mip_3: texture_storage_2d<r32float, write>; | ||
|
@@ -304,9 +312,25 @@ fn load_mip_0(x: u32, y: u32) -> f32 { | |
let i = y * constants.view_width + x; | ||
#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT | ||
return bitcast<f32>(u32(mip_0[i] >> 32u)); | ||
#else | ||
#else // MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT | ||
#ifdef MESHLET | ||
return bitcast<f32>(mip_0[i]); | ||
#endif | ||
#else // MESHLET | ||
// Downsample the top level. | ||
#ifdef MULTISAMPLE | ||
// The top level is multisampled, so we need to loop over all the samples | ||
// and reduce them to 1. | ||
var result = textureLoad(mip_0, vec2(x, y), 0); | ||
let sample_count = i32(textureNumSamples(mip_0)); | ||
for (var sample = 1; sample < sample_count; sample += 1) { | ||
result = min(result, textureLoad(mip_0, vec2(x, y), sample)); | ||
} | ||
return result; | ||
#else // MULTISAMPLE | ||
return textureLoad(mip_0, vec2(x, y), 0); | ||
#endif // MULTISAMPLE | ||
#endif // MESHLET | ||
#endif // MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT | ||
} | ||
|
||
fn reduce_4(v: vec4f) -> f32 { | ||
|
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.
Is the early prepass running the full prepass? E.g. for deferred is it doing the gbuffer rendering too?
Not sure, but it might make more sense to do depth only in the early pass, and then depth + other attachments in the late pass.
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'm pretty sure that Griffin said that you usually split the full prepass into early and late phases rather than having a separate z-prepass, but I'd rather not make that change here as this patch is too big as it is. Instead I just documented that occlusion culling is currently incompatible with deferred. We can add support for deferred in a followup.