Search in sources :

Example 1 with BufferUploadData

use of me.jellysquid.mods.sodium.client.render.vertex.BufferUploadData in project sodium-fabric by CaffeineMC.

the class ChunkRenderDataVBO method uploadMeshes.

@Override
public void uploadMeshes(Object2ObjectMap<RenderLayer, BufferUploadData> layers) {
    for (Map.Entry<RenderLayer, BufferUploadData> entry : layers.entrySet()) {
        GlVertexBuffer array = this.vbos.get(entry.getKey());
        if (array == null) {
            throw new NullPointerException("No graphics state container for layer " + entry.getKey());
        }
        array.upload(entry.getValue());
    }
}
Also used : GlVertexBuffer(me.jellysquid.mods.sodium.client.render.gl.GlVertexBuffer) RenderLayer(net.minecraft.client.render.RenderLayer) BufferUploadData(me.jellysquid.mods.sodium.client.render.vertex.BufferUploadData) Object2ObjectMap(it.unimi.dsi.fastutil.objects.Object2ObjectMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with BufferUploadData

use of me.jellysquid.mods.sodium.client.render.vertex.BufferUploadData in project sodium-fabric by CaffeineMC.

the class MixinBufferBuilder method copyData.

@Override
public BufferUploadData copyData() {
    BufferBuilder.DrawArrayParameters params = this.parameters.get(this.lastParameterIndex++);
    this.buffer.position(this.nextDrawStart);
    this.nextDrawStart += params.getCount() * params.getVertexFormat().getVertexSize();
    this.buffer.limit(this.nextDrawStart);
    if (this.lastParameterIndex == this.parameters.size() && this.vertexCount == 0) {
        this.clear();
    }
    ByteBuffer copy = ByteBuffer.allocateDirect(this.buffer.limit());
    copy.put(this.buffer);
    copy.flip();
    this.buffer.clear();
    return new BufferUploadData(copy, this.format);
}
Also used : BufferBuilder(net.minecraft.client.render.BufferBuilder) CloneableBufferBuilder(me.jellysquid.mods.sodium.client.render.chunk.CloneableBufferBuilder) BufferUploadData(me.jellysquid.mods.sodium.client.render.vertex.BufferUploadData) ByteBuffer(java.nio.ByteBuffer)

Example 3 with BufferUploadData

use of me.jellysquid.mods.sodium.client.render.vertex.BufferUploadData in project sodium-fabric by CaffeineMC.

the class ChunkRenderRebuildTask method performBuild.

@Override
public ChunkRenderUploadTask performBuild(VertexBufferCache buffers) {
    ChunkMeshInfo meshInfo;
    Object2ObjectMap<RenderLayer, BufferUploadData> uploads;
    if (this.region == null) {
        meshInfo = new ChunkMeshInfo();
        meshInfo.occlusionGraph = new ChunkOcclusionData();
        meshInfo.occlusionGraph.addOpenEdgeFaces(EnumSet.allOf(Direction.class));
        uploads = Object2ObjectMaps.emptyMap();
    } else {
        meshInfo = this.generateMesh(buffers);
        uploads = new Object2ObjectArrayMap<>();
        for (RenderLayer layer : meshInfo.presentLayers) {
            BufferBuilder builder = buffers.get(layer);
            builder.end();
            uploads.put(layer, ((CloneableBufferBuilder) builder).copyData());
        }
    }
    return new Result(this.render, meshInfo, uploads);
}
Also used : ChunkOcclusionData(net.minecraft.client.render.chunk.ChunkOcclusionData) BufferBuilder(net.minecraft.client.render.BufferBuilder) CloneableBufferBuilder(me.jellysquid.mods.sodium.client.render.chunk.CloneableBufferBuilder) RenderLayer(net.minecraft.client.render.RenderLayer) BufferUploadData(me.jellysquid.mods.sodium.client.render.vertex.BufferUploadData) Direction(net.minecraft.util.math.Direction)

Aggregations

BufferUploadData (me.jellysquid.mods.sodium.client.render.vertex.BufferUploadData)3 CloneableBufferBuilder (me.jellysquid.mods.sodium.client.render.chunk.CloneableBufferBuilder)2 BufferBuilder (net.minecraft.client.render.BufferBuilder)2 RenderLayer (net.minecraft.client.render.RenderLayer)2 Object2ObjectMap (it.unimi.dsi.fastutil.objects.Object2ObjectMap)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GlVertexBuffer (me.jellysquid.mods.sodium.client.render.gl.GlVertexBuffer)1 ChunkOcclusionData (net.minecraft.client.render.chunk.ChunkOcclusionData)1 Direction (net.minecraft.util.math.Direction)1