-
Notifications
You must be signed in to change notification settings - Fork 180
Implement SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING #369
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#version 450 | ||
|
||
#extension GL_EXT_nonuniform_qualifier : require | ||
|
||
layout(location = 0) in vec2 v_TexCoord; | ||
layout(location = 1) flat in int v_Index; // dynamically non-uniform | ||
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. This is actually uniform across the wave, since it's flat-interpolated. Is it supposed to be non-uniform in a difference sense? 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. 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)? 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. 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 - The link you provided is very familiar to me, although I'll make sure to rehash that part in my mind. 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. 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. |
||
layout(location = 0) out vec4 o_Color; | ||
|
||
layout(set = 0, binding = 0) uniform texture2D u_Textures[2]; | ||
layout(set = 0, binding = 1) uniform sampler u_Sampler; | ||
|
||
void main() { | ||
o_Color = vec4(texture(sampler2D(u_Textures[v_Index], u_Sampler), v_TexCoord).rgb, 1.0); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#version 450 | ||
|
||
layout(location = 0) in vec2 v_TexCoord; | ||
layout(location = 1) flat in int v_Index; // dynamically non-uniform | ||
layout(location = 0) out vec4 o_Color; | ||
|
||
layout(set = 0, binding = 0) uniform texture2D u_Textures[2]; | ||
layout(set = 0, binding = 1) uniform sampler u_Sampler; | ||
layout(set = 1, binding = 0) uniform Uniforms { | ||
int u_Index; // dynamically uniform | ||
kvark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
void main() { | ||
o_Color = vec4(texture(sampler2D(u_Textures[u_Index], u_Sampler), v_TexCoord).rgb, 1.0); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#version 450 | ||
|
||
#extension GL_EXT_nonuniform_qualifier : require | ||
|
||
layout(location = 0) in vec2 v_TexCoord; | ||
layout(location = 1) flat in int v_Index; // dynamically non-uniform | ||
layout(location = 0) out vec4 o_Color; | ||
|
||
layout(set = 0, binding = 0) uniform texture2D u_Textures[]; | ||
layout(set = 0, binding = 1) uniform sampler u_Sampler; | ||
|
||
void main() { | ||
o_Color = vec4(texture(sampler2D(u_Textures[v_Index], u_Sampler), v_TexCoord).rgb, 1.0); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.