Skip to content

Commit

Permalink
Use correct nonuniformEXT with sampler2D.
Browse files Browse the repository at this point in the history
Used to crash some drivers, but should be fine now ...
  • Loading branch information
Hans-Kristian Arntzen committed Dec 3, 2020
1 parent 902cad1 commit 8e1c9fe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions assets/shaders/lights/pcf.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ layout(set = 1, binding = 15) uniform sampler LinearShadowSampler;
#endif

#define SAMPLE_PCF_BINDLESS(tex, index, uv, x, y) \
textureLodOffset(sampler2DShadow(tex[nonuniformEXT(index)], LinearShadowSampler), uv, 0.0, ivec2(x, y))
textureLodOffset(nonuniformEXT(sampler2DShadow(tex[index], LinearShadowSampler)), uv, 0.0, ivec2(x, y))
#define SAMPLE_PCF(tex, uv, x, y) \
textureLodOffset(tex, uv, 0.0, ivec2(x, y))
#define SAMPLE_PCF_LAYER(tex, uvz, x, y) \
Expand Down Expand Up @@ -172,7 +172,7 @@ layout(set = 1, binding = 15) uniform sampler LinearShadowSampler;
var += 0.0625 * SAMPLE_PCF_LAYER(tex, clip_uv, +1, +1); \
}
#elif SHADOW_MAP_PCF_KERNEL_WIDTH == 1
#define SAMPLE_PCF_KERNEL_BINDLESS(var, tex, index, uv) var = textureProjLod(sampler2DShadow(tex[nonuniformEXT(index)], LinearShadowSampler), uv, 0.0)
#define SAMPLE_PCF_KERNEL_BINDLESS(var, tex, index, uv) var = textureProjLod(nonuniformEXT(sampler2DShadow(tex[index], LinearShadowSampler)), uv, 0.0)
#define SAMPLE_PCF_KERNEL(var, tex, uv) var = textureProjLod(tex, uv, 0.0)
#define SAMPLE_PCF_KERNEL_LAYER_NOPROJ(var, tex, uv, layer) var = SAMPLE_PCF_LAYER_NO_OFFSET(tex, vec4((uv).xy, layer, (uv).z))
#else
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/lights/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ mediump vec3 compute_point_color(int index, vec3 world_pos, out mediump vec3 lig
#endif
#else
#ifdef POSITIONAL_SHADOW_VSM
vec2 shadow_moments = textureLod(samplerCube(uPointShadowAtlas[nonuniformEXT(index)], LinearClampSampler), light_dir_full, 0.0).xy;
vec2 shadow_moments = textureLod(nonuniformEXT(samplerCube(uPointShadowAtlas[index], LinearClampSampler)), light_dir_full, 0.0).xy;
mediump float shadow_falloff = vsm(max_z, shadow_moments);
#else
vec2 shadow_ref2 = shadow_transform.zw - shadow_transform.xy * max_z;
float shadow_ref = shadow_ref2.x / shadow_ref2.y;
mediump float shadow_falloff = texture(samplerCubeShadow(uPointShadowAtlas[nonuniformEXT(index)], LinearShadowSampler), vec4(light_dir_full, shadow_ref));
mediump float shadow_falloff = texture(nonuniformEXT(samplerCubeShadow(uPointShadowAtlas[index], LinearShadowSampler)), vec4(light_dir_full, shadow_ref));
#endif
#endif
#else
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/lights/spot.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mediump vec3 compute_spot_color(int index, vec3 world_pos, out mediump vec3 ligh
vec4 spot_shadow_clip = SPOT_SHADOW_TRANSFORM(index) * vec4(world_pos, 1.0);
vec2 shadow_uv = spot_shadow_clip.xy / spot_shadow_clip.w;
#ifdef CLUSTERER_BINDLESS
vec2 shadow_moments = textureLod(sampler2D(uSpotShadowAtlas[nonuniformEXT(index)], LinearClampSampler), shadow_uv, 0.0).xy;
vec2 shadow_moments = textureLod(nonuniformEXT(sampler2D(uSpotShadowAtlas[index], LinearClampSampler)), shadow_uv, 0.0).xy;
#else
vec2 shadow_moments = textureLod(uSpotShadowAtlas, shadow_uv, 0.0).xy;
#endif
Expand Down
6 changes: 3 additions & 3 deletions tests/assets/shaders/bindless.frag
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ void main()
int index = x ^ y;

FragColor =
textureLod(sampler2D(uImages[nonuniformEXT(index)], uSampler), vec2(0.5), 0.0) *
textureLod(sampler2D(uImages2[nonuniformEXT(index)], uSampler), vec2(0.5), 0.0);
}
textureLod(nonuniformEXT(sampler2D(uImages[index], uSampler)), vec2(0.5), 0.0) *
textureLod(nonuniformEXT(sampler2D(uImages2[index], uSampler)), vec2(0.5), 0.0);
}

0 comments on commit 8e1c9fe

Please sign in to comment.