Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Implement SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING #369

Merged
merged 1 commit into from
Jun 15, 2020

Conversation

cwfitzgerald
Copy link
Member

This implements gfx-rs/wgpu#715 in wgpu-rs. I haven't changed the example, as I want to actually think up a better example to use and didn't want that to block this. It will change in the future however.

@cwfitzgerald cwfitzgerald force-pushed the descriptor-indexing branch from 0d62a31 to 1635e8d Compare June 13, 2020 02:13
#extension GL_EXT_nonuniform_qualifier : require

layout(location = 0) in vec2 v_TexCoord;
layout(location = 1) flat in int v_Index; // dynamically non-uniform
Copy link
Member

Choose a reason for hiding this comment

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

This is actually uniform across the wave, since it's flat-interpolated. Is it supposed to be non-uniform in a difference sense?

Copy link
Member Author

@cwfitzgerald cwfitzgerald Jun 13, 2020

Choose a reason for hiding this comment

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

If you consider how gpus run fragment shaders, it may not be even coherent in the wave. They take 2x2 blocks of pixels, put N of them together into a wave. These blocks may not be from the same primative, so this may be different across the wave. This 2x2 action is also why gpus are bad at rendering small polygons, they always get a 2x2 section, even if they are only 1x1. (edit: src also this comment which is really helpful)

Maybe confusion between uniform (same over the draw call) and coherent (same over the wave)?

Copy link
Member

Choose a reason for hiding this comment

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

My understanding is that 2x2 blocks are always from the same primitive. If some of these pixels lie outside, they become "ghost" threads, but regardless - flat is there precisely to inform the compiler that this is constant across the wave.

The link you provided is very familiar to me, although I'll make sure to rehash that part in my mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

The pixels from within the 2x2 blocks are always from the same primitive, being masked out and such as needed, but when 8 of those are combined into a wave, each of those 8 blocks could be from a different primitive. If that wasn't allowed, having a 1x1 triangle would waste an entire wave of processing power, not just a 2x2 block.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

I guess we are still missing the logic in the example to select the proper shader

@cwfitzgerald cwfitzgerald force-pushed the descriptor-indexing branch 3 times, most recently from 6086f94 to f046e26 Compare June 14, 2020 19:36
@cwfitzgerald cwfitzgerald force-pushed the descriptor-indexing branch from f046e26 to 021419b Compare June 15, 2020 19:09
@cwfitzgerald
Copy link
Member Author

Alright, I think this is finally ready for review on this one

@cwfitzgerald cwfitzgerald marked this pull request as ready for review June 15, 2020 19:10
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 15, 2020

@bors bors bot merged commit b915133 into gfx-rs:master Jun 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants