gpu vram api return change - freeAllBuffers returns the number of buffers freed

increase timeouts on bitblt after further server load and network load testing
This commit is contained in:
payonel 2020-05-21 02:41:22 -07:00
parent a4fbcd975b
commit c8fce521d7
3 changed files with 13 additions and 11 deletions

View File

@ -1604,9 +1604,9 @@ opencomputers {
# network laod the defaults settings put bitblit network impact close to gpu.set
# Increase these values to throttle bitblt more.
bitbltCosts: [
0.375, # (1/64) * 16 * 1.5
0.29296875, # (1/128) * 25 * 1.5
0.29296875, # (1/256) * 50 * 1.5
2, # (1/64) * 16 * 8
1.5625, # (1/128) * 25 * 8
1.5625, # (1/256) * 50 * 8
]
}
}

View File

@ -1,6 +1,7 @@
package li.cil.oc.common.component.traits
import li.cil.oc.common.component
import li.cil.oc.common.component.GpuTextBuffer
import net.minecraft.nbt.NBTTagCompound
trait VideoRamAware {
@ -25,19 +26,20 @@ trait VideoRamAware {
preexists
}
def removeBuffers(ids: Array[Int]): Boolean = {
var allRemoved: Boolean = true
def removeBuffers(ids: Array[Int]): Int = {
var count = 0
if (ids.nonEmpty) {
onBufferRamDestroy(ids)
for (id <- ids) {
if (internalBuffers.remove(id).isEmpty)
allRemoved = false
if (internalBuffers.remove(id).nonEmpty) {
count += 1
}
}
}
allRemoved
count
}
def removeAllBuffers(): Boolean = removeBuffers(bufferIndexes())
def removeAllBuffers(): Int = removeBuffers(bufferIndexes())
def loadBuffer(id: Int, nbt: NBTTagCompound): Unit = {
val src = new li.cil.oc.util.TextBuffer(width = 1, height = 1, li.cil.oc.util.PackedColor.SingleBitFormat)

View File

@ -169,11 +169,11 @@ class GraphicsCard(val tier: Int) extends prefab.ManagedEnvironment with DeviceI
@Callback(direct = true, doc = """function(index: number): boolean -- Closes buffer at `index`. Returns true if a buffer closed. If the current buffer is closed, index moves to 0""")
def freeBuffer(context: Context, args: Arguments): Array[AnyRef] = {
val index: Int = args.optInteger(0, bufferIndex)
if (removeBuffers(Array(index))) result(true)
if (removeBuffers(Array(index)) == 1) result(true)
else result(Unit, "no buffer at index")
}
@Callback(direct = true, doc = """function(): number -- Closes all buffers and returns true on success. If the active buffer is closed, index moves to 0""")
@Callback(direct = true, doc = """function(): number -- Closes all buffers and returns the count. If the active buffer is closed, index moves to 0""")
def freeAllBuffers(context: Context, args: Arguments): Array[AnyRef] = result(removeAllBuffers())
@Callback(direct = true, doc = """function(): number -- returns the total memory size of the gpu vram. This does not include the screen.""")