KhronosGroup / KhronosGroup/GLSL

Support for Vertex/Fragment layout blocks

Open
#205 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
458
Forks
114
Avg merge
4m
Merged PRs (30d)
1

Description

I think it would be really nice and useful to have the ability to define in vertex blocks and out fragment blocks, so GLSL could function somewhat like HLSL. The following syntax would be very handy:

#version 450
layout(location=0) in Vertex {
 	vec2 pos, uv;
 	vec4 col;
} v; 

layout(location=0) out Fragment {
 	vec2 uv;
 	vec4 col; 
} f; 

layout(binding=0, std140) uniform GUIInfo {
 	vec2 res;
 };

 void vert() {
 	f.uv = v.uv;
 	f.col = v.col;
 	gl_Position = vec4(v.pos / res - 1, 0, 1); 
} 

layout(binding=0) uniform sampler2D tex; 
layout(location=0) out Buffer {
 	vec4 col; 
} b; 

void frag() {
 	b.col = f.col * texture(tex, f.uv); 
}

Which could be compiled in two stages or in one. It just reduces code duplication and in big projects that's one of the reasons HLSL is used; because it is easy to write shaders with multiple entrypoints in them. It doesn't matter if you have to compile this in two stages, because with HLSL that's the case as well. Even the renaming 'vert' to 'main' and 'frag' to 'main' would be fine using glslangValidator if this would be supported. I think this would be great; especially if you have multiple compute shaders that are similar but do different things, you could make two separate files and use includes for the majority, but that might make it less clear (especially since these files are finally linked together). Or for something like raytracing shaders it would definitely be a huge relief.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by reviewing the GLSL specification's existing layout and interface-block rules, then determine the required language and compilation changes and define tests for the proposed vertex and fragment block syntax.

Written by the indexing model from the issue text.

Assessment

Domain
computer-graphics
Issue type
Feature
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.