mojira.dev

haubner

Assigned

No issues.

Comments

Since this functionality was introduced exclusively for mod devs (not used in vanilla minecraft) there is no way to reproduce this crash without a mod.

Basically this function in GlCommandEncoder misses the index buffer binding

	public void executeDraws(
		final GlRenderPass renderPass,
		@Nullable final IndexType indexType,
		@Nullable final PointerBuffer firstIndexOffsets,
		final IntBuffer indexCounts,
		final IntBuffer vertexOffsets,
		final int drawCount
	) {
		if (this.trySetup(renderPass, Collections.emptyList())) {
			this.validateDraw(renderPass, indexType);
			this.lastVertexArray = this.device
				.vertexArrayCache()
				.bindVertexArray(renderPass.pipeline.info().getVertexFormatBindings(), renderPass.vertexBuffers, renderPass.vertexBufferDirty ? null : this.lastVertexArray);
			renderPass.vertexBufferDirty = false;
			if (indexType == null) {
				GL33C.nglMultiDrawArrays(
					GlConst.toGl(renderPass.pipeline.info().getPrimitiveTopology()), MemoryUtil.memAddress(vertexOffsets), MemoryUtil.memAddress(indexCounts), drawCount
				);
			} else {
				assert firstIndexOffsets != null;


				GL33C.nglMultiDrawElementsBaseVertex(
					GlConst.toGl(renderPass.pipeline.info().getPrimitiveTopology()),
					MemoryUtil.memAddress(indexCounts),
					GlConst.toGl(indexType),
					MemoryUtil.memAddress(firstIndexOffsets),
					drawCount,
					MemoryUtil.memAddress(vertexOffsets)
				);
			}
		}
	}

Here is the other function in GlCommandEncoder which actually properly binds the index buffer

	private void drawFromBuffers(
		final GlRenderPass renderPass,
		final int baseVertex,
		final int firstIndex,
		final int drawCount,
		@Nullable final IndexType indexType,
		final GlRenderPipeline pipeline,
		final int instanceCount,
		final int firstInstance
	) {
		if (indexType != null) {
--->		GlStateManager._glBindBuffer(34963, ((GlBuffer)renderPass.indexBuffer).handle());
			if (firstInstance > 0) {
				ARBBaseInstance.glDrawElementsInstancedBaseVertexBaseInstance(
					GlConst.toGl(pipeline.info().getPrimitiveTopology()),
					drawCount,
					GlConst.toGl(indexType),
					(long)firstIndex * indexType.bytes,
					instanceCount,
					baseVertex,
					firstInstance
				);
			} else {
				GL33C.glDrawElementsInstancedBaseVertex(
					GlConst.toGl(pipeline.info().getPrimitiveTopology()), drawCount, GlConst.toGl(indexType), (long)firstIndex * indexType.bytes, instanceCount, baseVertex
				);
			}
		} else if (firstInstance > 0) {
			ARBBaseInstance.glDrawArraysInstancedBaseInstance(GlConst.toGl(pipeline.info().getPrimitiveTopology()), baseVertex, drawCount, instanceCount, firstInstance);
		} else {
			GL33C.glDrawArraysInstanced(GlConst.toGl(pipeline.info().getPrimitiveTopology()), baseVertex, drawCount, instanceCount);
		}
	}