KhronosGroup / KhronosGroup/Vulkan-ValidationLayers

Missing OOB check when using gl_VertexIndex to index into an array defined in the vertex shader

Open
#9,801 0 comments 0 reactions 1 assignee Claimed by @spencer-lunarg View on GitHub
Incomplete SpecChange
Dominant language
C++
Stars
1k
Forks
504
Avg merge
11h 35m
Merged PRs (30d)
224

Description

**Describe the situation in which you encountered the missing validation**
Run `vkCmdDraw(cmd_buf, 4000, 1, 0, 0);` when the following vertex shader is bound:
```glsl
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout (location = 0) out vec3 fragColor;
vec2 positions[3] = vec2[](vec2 (0.0, -0.5), vec2 (0.5, 0.5), vec2 (-0.5, 0.5));
vec3 colors[3] = vec3[](vec3 (1.0, 0.0, 0.0), vec3 (0.0, 1.0, 0.0), vec3 (0.0, 0.0, 1.0));
void main ()
{
gl_Position = vec4 (positions[gl_VertexIndex], 0.0, 1.0);
fragColor = colors[gl_VertexIndex];
}
```
This is invalid due to indexing Out of Bounds in the position & color arrays but isn't getting caught.

**Additional Context**
This issue comes from: https://github.com/charles-lunarg/vk-bootstrap/issues/364

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.