<p>In accord with <a href="https://github.com/KhronosGroup/GLSL/blob/master/extensions/nv/GLSL_NV_mesh_shader.txt" rel="nofollow noreferrer">the GLSL extension</a>, <code>gl_Layer</code> in a mesh shader is part of the predefined <code>gl_MeshPerPrimitiveNV</code> output interface block. It seems to have the expected definition. This is a per-primitive parameter, so you can set it to a different value for each primitive you output.</p>
<p>Basically, yes: layered rendering is available in task/mesh shaders. And since this extension specifies the SPIR-V decorator equivalent (ie: <code>Layer</code>), it seems clear it can be used in the Vulkan equivalent just as well.</p>

CC BY-SA 4.0
2021-09-10T16:16:14.840Z
2021-09-10T16:16:14.840Z
Nicol Bolas
<p>In the usual pipeline (vertex, tessellation, geometry and fragment shaders) the geometry can be deformed and in the geometry shader it is possible to copy the generated and deformed geometry in order to transfer it from several positions into several layers of a texture to render. Also known as &quot;layered rendering&quot;.
Does the new mesh shading pipeline (task shader, mesh shader and fragment shader) also have the option of generating / deforming the mesh and then copying it into different layers? So that you can render the same scenario multiple times within one drawcall?</p>
<p>I am asking for Vulkan, OpenGL and DirectX 12</p>

CC BY-SA 4.0
2021-09-10T10:30:20.583Z
can someone link me a good dokumentation about task and mesh shaders? thanks!
Thomas
CC BY-SA 4.0
2021-09-10T16:01:00.727Z
You can always look at [the OpenGL extension, which spells out the behavior reasonably well](https://www.khronos.org/registry/OpenGL/extensions/NV/NV_mesh_shader.txt).
Nicol Bolas
CC BY-SA 4.0
2021-09-10T16:10:41.600Z
Also, it relies on a "GLSL extension", [whose documentation is here](https://github.com/KhronosGroup/GLSL/blob/master/extensions/nv/GLSL_NV_mesh_shader.txt).
Nicol Bolas
<opengl><shader><vulkan><directx12>
Mesh-Shader and layered rendering
Thomas
# Mesh-Shader and layered rendering

(Asked by: username_0 on 2021-09-10)

In the usual pipeline (vertex, tessellation, geometry and fragment shaders) the geometry can be deformed and in the geometry shader it is possible to copy the generated and deformed geometry in order to transfer it from several positions into several layers of a texture to render. Also known as "layered rendering".
Does the new mesh shading pipeline (task shader, mesh shader and fragment shader) also have the option of generating / deforming the mesh and then copying it into different layers? So that you can render the same scenario multiple times within one drawcall?

I am asking for Vulkan, OpenGL and DirectX 12

**Tags:** opengl, shader, vulkan, directx12

> **Comments:**
> **username_0**: can someone link me a good dokumentation about task and mesh shaders? thanks!  
> **username_1**: You can always look at [the OpenGL extension, which spells out the behavior reasonably well](https://www.khronos.org/registry/OpenGL/extensions/NV/NV_mesh_shader.txt).  
> **username_1**: Also, it relies on a "GLSL extension", [whose documentation is here](https://github.com/KhronosGroup/GLSL/blob/master/extensions/nv/GLSL_NV_mesh_shader.txt).  

---

## 1 answers

### Answer by username_1 on 2021-09-10. Score: 1 | Accepted answer

In accord with [the GLSL extension](https://github.com/KhronosGroup/GLSL/blob/master/extensions/nv/GLSL_NV_mesh_shader.txt), `gl_Layer` in a mesh shader is part of the predefined `gl_MeshPerPrimitiveNV` output interface block. It seems to have the expected definition. This is a per-primitive parameter, so you can set it to a different value for each primitive you output.

Basically, yes: layered rendering is available in task/mesh shaders. And since this extension specifies the SPIR-V decorator equivalent (ie: `Layer`), it seems clear it can be used in the Vulkan equivalent just as well.


---

