mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
meshes/float lists: make size a power of 2
This way it is way more likely to be page aligned and memory access should be faster
This commit is contained in:
parent
7229f9c06e
commit
c11d64f2d7
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -32,9 +32,9 @@ class ChunkMeshes(
|
|||||||
smallMesh: Boolean = false,
|
smallMesh: Boolean = false,
|
||||||
) : BlockVertexConsumer {
|
) : BlockVertexConsumer {
|
||||||
val center: Vec3 = Vec3(Vec3i.of(chunkPosition, sectionHeight, Vec3i(8, 8, 8)))
|
val center: Vec3 = Vec3(Vec3i.of(chunkPosition, sectionHeight, Vec3i(8, 8, 8)))
|
||||||
var opaqueMesh: ChunkMesh? = ChunkMesh(context, if (smallMesh) 3000 else 100000)
|
var opaqueMesh: ChunkMesh? = ChunkMesh(context, if (smallMesh) 8192 else 65536)
|
||||||
var translucentMesh: ChunkMesh? = ChunkMesh(context, if (smallMesh) 3000 else 10000)
|
var translucentMesh: ChunkMesh? = ChunkMesh(context, if (smallMesh) 4096 else 16384)
|
||||||
var textMesh: ChunkMesh? = ChunkMesh(context, if (smallMesh) 5000 else 50000)
|
var textMesh: ChunkMesh? = ChunkMesh(context, if (smallMesh) 1024 else 4096)
|
||||||
var blockEntities: ArrayList<BlockEntityRenderer<*>>? = null
|
var blockEntities: ArrayList<BlockEntityRenderer<*>>? = null
|
||||||
|
|
||||||
// used for frustum culling
|
// used for frustum culling
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -42,7 +42,7 @@ open class GUIMeshElement<T : Element>(
|
|||||||
override val context: RenderContext = guiRenderer.context
|
override val context: RenderContext = guiRenderer.context
|
||||||
private val clickCounter = MouseClickCounter()
|
private val clickCounter = MouseClickCounter()
|
||||||
private var _mesh: GUIMesh? = null
|
private var _mesh: GUIMesh? = null
|
||||||
var mesh: GUIMesh = GUIMesh(context, guiRenderer.halfSize, FloatListUtil.direct(1000))
|
var mesh: GUIMesh = GUIMesh(context, guiRenderer.halfSize, FloatListUtil.direct(1024))
|
||||||
override val skipDraw: Boolean
|
override val skipDraw: Boolean
|
||||||
get() = if (element is BaseDrawable) element.skipDraw else false
|
get() = if (element is BaseDrawable) element.skipDraw else false
|
||||||
protected var lastRevision = 0L
|
protected var lastRevision = 0L
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -27,7 +27,7 @@ class GUIMesh(
|
|||||||
context: RenderContext,
|
context: RenderContext,
|
||||||
val halfSize: Vec2,
|
val halfSize: Vec2,
|
||||||
data: AbstractFloatList,
|
data: AbstractFloatList,
|
||||||
) : Mesh(context, GUIMeshStruct, initialCacheSize = 40000, data = data), GUIVertexConsumer {
|
) : Mesh(context, GUIMeshStruct, initialCacheSize = 32768, data = data), GUIVertexConsumer {
|
||||||
private val whiteTexture = context.textures.whiteTexture
|
private val whiteTexture = context.textures.whiteTexture
|
||||||
override val order = context.system.quadOrder
|
override val order = context.system.quadOrder
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -29,7 +29,7 @@ abstract class Mesh(
|
|||||||
val context: RenderContext,
|
val context: RenderContext,
|
||||||
private val struct: MeshStruct,
|
private val struct: MeshStruct,
|
||||||
val primitive: PrimitiveTypes = context.system.quadType,
|
val primitive: PrimitiveTypes = context.system.quadType,
|
||||||
var initialCacheSize: Int = 10000,
|
var initialCacheSize: Int = 8192,
|
||||||
data: AbstractFloatList? = null,
|
data: AbstractFloatList? = null,
|
||||||
) : AbstractVertexConsumer {
|
) : AbstractVertexConsumer {
|
||||||
override val order = context.system.legacyQuadOrder
|
override val order = context.system.legacyQuadOrder
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -23,7 +23,7 @@ object FloatListUtil {
|
|||||||
const val PREFER_FRAGMENTED = true
|
const val PREFER_FRAGMENTED = true
|
||||||
|
|
||||||
val FLOAT_PUT_METHOD = catchAll { FloatBuffer::class.java.getMethod("put", Int::class.java, FloatBuffer::class.java, Int::class.java, Int::class.java) }
|
val FLOAT_PUT_METHOD = catchAll { FloatBuffer::class.java.getMethod("put", Int::class.java, FloatBuffer::class.java, Int::class.java, Int::class.java) }
|
||||||
const val DEFAULT_INITIAL_SIZE = 1000
|
const val DEFAULT_INITIAL_SIZE = 1024
|
||||||
|
|
||||||
fun direct(initialSize: Int = DEFAULT_INITIAL_SIZE): AbstractFloatList {
|
fun direct(initialSize: Int = DEFAULT_INITIAL_SIZE): AbstractFloatList {
|
||||||
return if (PREFER_FRAGMENTED) FragmentedArrayFloatList(initialSize) else BufferedArrayFloatList(initialSize)
|
return if (PREFER_FRAGMENTED) FragmentedArrayFloatList(initialSize) else BufferedArrayFloatList(initialSize)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user