11package net .caffeinemc .mods .sodium .client .render .chunk ;
22
33import net .caffeinemc .mods .sodium .client .SodiumClientMod ;
4+ import net .caffeinemc .mods .sodium .client .gl .attribute .GlVertexAttributeBinding ;
45import net .caffeinemc .mods .sodium .client .gl .device .CommandList ;
56import net .caffeinemc .mods .sodium .client .gl .device .DrawCommandList ;
67import net .caffeinemc .mods .sodium .client .gl .device .MultiDrawBatch ;
1516import net .caffeinemc .mods .sodium .client .render .chunk .lists .ChunkRenderList ;
1617import net .caffeinemc .mods .sodium .client .render .chunk .lists .ChunkRenderListIterable ;
1718import net .caffeinemc .mods .sodium .client .render .chunk .region .RenderRegion ;
19+ import net .caffeinemc .mods .sodium .client .render .chunk .shader .ChunkShaderBindingPoints ;
1820import net .caffeinemc .mods .sodium .client .render .chunk .shader .ChunkShaderInterface ;
1921import net .caffeinemc .mods .sodium .client .render .chunk .terrain .TerrainRenderPass ;
2022import net .caffeinemc .mods .sodium .client .render .chunk .translucent_sorting .SortBehavior ;
@@ -71,7 +73,7 @@ public void render(ChunkRenderMatrices matrices,
7173 continue ;
7274 }
7375
74- fillCommandBuffer (this .batch , region , storage , renderList , camera , renderPass , useBlockFaceCulling , useIndexedTessellation );
76+ fillCommandBuffer (this .batch , region , storage , renderList , camera , renderPass , useBlockFaceCulling );
7577
7678 if (this .batch .isEmpty ()) {
7779 continue ;
@@ -108,8 +110,7 @@ private static void fillCommandBuffer(MultiDrawBatch batch,
108110 ChunkRenderList renderList ,
109111 CameraTransform camera ,
110112 TerrainRenderPass pass ,
111- boolean useBlockFaceCulling ,
112- boolean useIndexedTessellation ) {
113+ boolean useBlockFaceCulling ) {
113114 batch .clear ();
114115
115116 var iterator = renderList .sectionsWithGeometryIterator (pass .isTranslucent ());
@@ -149,27 +150,19 @@ private static void fillCommandBuffer(MultiDrawBatch batch,
149150 continue ;
150151 }
151152
152- // it's necessary to sometimes not the locally-indexed command generator even for indexed tessellations since
153- // sometimes the index buffer is shared, but not globally shared. This means that translucent sections that
154- // are sharing an index buffer amongst them need to use the shared index command generator since it sets the
155- // same element offset for each draw command and doesn't increment it. Recall that in each draw command the indexing
156- // of the elements needs to start at 0 and thus starting somewhere further into the shared index buffer is invalid.
157- // there's also the optimization that draw commands can be combined when using a shared index buffer, be it
158- // globally shared or just shared within the region, which isn't possible with the locally-indexed command generator.
159- if (useIndexedTessellation && SectionRenderDataUnsafe .isLocalIndex (pMeshData )) {
160- addLocalIndexedDrawCommands (batch , pMeshData , slices );
153+ if (pass .isTranslucent ()) {
154+ addIndexedDrawCommands (batch , pMeshData , slices );
161155 } else {
162- addSharedIndexedDrawCommands (batch , pMeshData , slices );
156+ addNonIndexedDrawCommands (batch , pMeshData , slices );
163157 }
164158 }
165159 }
166160
167161 /**
168- * Generates the draw commands for a chunk's meshes, where each mesh has a separate index buffer. This is used
169- * when rendering translucent geometry, as each geometry set needs a sorted index buffer.
162+ * Generates the draw commands for a chunk's meshes using the shared index buffer.
170163 */
171164 @ SuppressWarnings ("IntegerMultiplicationImplicitCastToLong" )
172- private static void addLocalIndexedDrawCommands (MultiDrawBatch batch , long pMeshData , int mask ) {
165+ private static void addNonIndexedDrawCommands (MultiDrawBatch batch , long pMeshData , int mask ) {
173166 final var pElementPointer = batch .pElementPointer ;
174167 final var pBaseVertex = batch .pBaseVertex ;
175168 final var pElementCount = batch .pElementCount ;
@@ -189,10 +182,11 @@ private static void addLocalIndexedDrawCommands(MultiDrawBatch batch, long pMesh
189182 }
190183
191184 /**
192- * Generates the draw commands for a chunk's meshes using the shared index buffer.
185+ * Generates the draw commands for a chunk's meshes, where each mesh has a separate index buffer. This is used
186+ * when rendering translucent geometry, as each geometry set needs a sorted index buffer.
193187 */
194188 @ SuppressWarnings ("IntegerMultiplicationImplicitCastToLong" )
195- private static void addSharedIndexedDrawCommands (MultiDrawBatch batch , long pMeshData , int mask ) {
189+ private static void addIndexedDrawCommands (MultiDrawBatch batch , long pMeshData , int mask ) {
196190 final var pElementPointer = batch .pElementPointer ;
197191 final var pBaseVertex = batch .pBaseVertex ;
198192 final var pElementCount = batch .pElementCount ;
@@ -230,7 +224,7 @@ private static void addSharedIndexedDrawCommands(MultiDrawBatch batch, long pMes
230224 private static final int MODEL_NEG_Y = ModelQuadFacing .NEG_Y .ordinal ();
231225 private static final int MODEL_NEG_Z = ModelQuadFacing .NEG_Z .ordinal ();
232226
233- public static int getVisibleFaces (int originX , int originY , int originZ , int chunkX , int chunkY , int chunkZ ) {
227+ private static int getVisibleFaces (int originX , int originY , int originZ , int chunkX , int chunkY , int chunkZ ) {
234228 // This is carefully written so that we can keep everything branch-less.
235229 //
236230 // Normally, this would be a ridiculous way to handle the problem. But the Hotspot VM's
0 commit comments