11/**
2- * meshletdec.slang - an example GPU decoder for meshlet data encoded using meshopt_encodeMeshlet
3- * This is intended to be used as a starting point for applications that want to decode meshlet data on the GPU.
4- *
5- * The shader exposes an entrypoint, decodeMeshlets, that decodes a set of meshlets; each meshlet is decoded independently,
6- * and the output vertex/triangle data is written as uint32 per element (triangle data is written as 0xabc ).
7- * This matches the output format for meshopt_decodeMeshlet with vertex_size=4 triangle_size=4. If alternative formats are
8- * needed, the code should be changed to output them; note that for triangle data, it may make sense to output data to shared
9- * memory to be able to use larger aligned 32-bit writes to global memory after that.
10- *
11- * Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
12- * This code is distributed under the MIT License. See notice at the end of this file.
13- */
2+ * meshletdec.slang - an example GPU decoder for meshlet data encoded using meshopt_encodeMeshlet
3+ * This is intended to be used as a starting point for applications that want to decode meshlet data on the GPU.
4+ *
5+ * The shader exposes an entrypoint, decodeMeshlets, that decodes a set of meshlets; each meshlet is decoded independently,
6+ * and the output vertex/triangle data is written as uint32 per element (triangle data is written as 0xccbbaa ).
7+ * This matches the output format for meshopt_decodeMeshlet with vertex_size=4 triangle_size=4. If alternative formats are
8+ * needed, the code should be changed to output them; note that for triangle data, it may make sense to output data to shared
9+ * memory to be able to use larger aligned 32-bit writes to global memory after that.
10+ *
11+ * Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
12+ * This code is distributed under the MIT License. See notice at the end of this file.
13+ */
1414
1515struct MeshletDesc
1616{
@@ -95,6 +95,7 @@ uint decodeTriangle(uint code, uint extra0, uint extra1, uint extra2, inout uint
9595 fifo1 = fifo0;
9696 fifo0 = tri;
9797
98+ // output triangle is stored without extra edge vertex (0xcbac => 0xcba)
9899 return tri >> 8 ;
99100}
100101
@@ -161,7 +162,7 @@ int decodeMeshlet(uint out_vertices, uint vertex_count, uint out_triangles, uint
161162
162163[shader(" compute" )]
163164[numthreads(32 , 1 , 1 )]
164- void decodeMeshlets(uint3 dispatch_thread_id : SV_DispatchThreadID)
165+ void decodeMeshlets(uint3 dispatch_thread_id: SV_DispatchThreadID)
165166{
166167 uint meshlet_count = gMeshletCount;
167168
@@ -183,26 +184,26 @@ void decodeMeshlets(uint3 dispatch_thread_id : SV_DispatchThreadID)
183184}
184185
185186/**
186- * Copyright (c) 2016-2026 Arseny Kapoulkine
187- *
188- * Permission is hereby granted, free of charge, to any person
189- * obtaining a copy of this software and associated documentation
190- * files (the "Software"), to deal in the Software without
191- * restriction, including without limitation the rights to use,
192- * copy, modify, merge, publish, distribute, sublicense, and/or sell
193- * copies of the Software, and to permit persons to whom the
194- * Software is furnished to do so, subject to the following
195- * conditions:
196- *
197- * The above copyright notice and this permission notice shall be
198- * included in all copies or substantial portions of the Software.
199- *
200- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
201- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
202- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
203- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
204- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
205- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
206- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
207- * OTHER DEALINGS IN THE SOFTWARE.
208- */
187+ * Copyright (c) 2016-2026 Arseny Kapoulkine
188+ *
189+ * Permission is hereby granted, free of charge, to any person
190+ * obtaining a copy of this software and associated documentation
191+ * files (the "Software"), to deal in the Software without
192+ * restriction, including without limitation the rights to use,
193+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
194+ * copies of the Software, and to permit persons to whom the
195+ * Software is furnished to do so, subject to the following
196+ * conditions:
197+ *
198+ * The above copyright notice and this permission notice shall be
199+ * included in all copies or substantial portions of the Software.
200+ *
201+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
202+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
203+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
204+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
205+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
206+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
207+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208+ * OTHER DEALINGS IN THE SOFTWARE.
209+ */
0 commit comments