KhronosGroup / KhronosGroup/WebGL

Clarify VS/FS fragment shader matching with anonymous struct varying

Open
#3,656 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
2.9k
Forks
703
Avg merge
2d 9h
Merged PRs (30d)
4

Description

Clarify how are the output or input variables variables matched when the variable declaration contains possibly anonymous struct.

> The type of vertex outputs and fragment inputs with the same name must match, otherwise the link
command will fail. The precision does not need to match. Only those fragment inputs statically used (i.e.
read) in the fragment shader must be declared as outputs in the vertex shader; declaring superfluous vertex
shader outputs is permissible.

https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf

**Two unnamed structs**
```
// VS
out struct { float field; } s0;

// FS
in struct { float field; } s0;
```

**Two named structs with the same name**

```
// VS
out struct T { float field; } s0;

// FS
in struct T { float field; } s0;
```

**One unnamed struct and one named struct**

```
// VS
out struct T { float field; } s0;

// FS
in struct { float field; } s0;
```

**Two named structs with different struct names**

```
// VS
out struct T { float field; } s0;

// FS
in struct Q { float field; } s0;
```

**Anonymous struct matched to two distinct anonymous structs at the other side**

```
// VS
out struct { float field; } s0, s1;

// FS
in struct { float field; } s0;
in struct { float field; } s1;
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked GLSL ES 3.00 specification and compare its rules against the five vertex-shader and fragment-shader examples in the issue. Done means the matching behavior for anonymous, same-named, differently named, mixed, and repeated anonymous structs is explicitly clarified.

Written by the indexing model from the issue text.

Assessment

Domain
computer-graphics, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.