From c8fce521d78088a51ab388ab2260b7d9a6eb02b0 Mon Sep 17 00:00:00 2001 From: payonel Date: Thu, 21 May 2020 02:41:22 -0700 Subject: [PATCH] gpu vram api return change - freeAllBuffers returns the number of buffers freed increase timeouts on bitblt after further server load and network load testing --- src/main/resources/application.conf | 6 +++--- .../oc/common/component/traits/VideoRamAware.scala | 14 ++++++++------ .../li/cil/oc/server/component/GraphicsCard.scala | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 768405939..1a2add46a 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -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 ] } } diff --git a/src/main/scala/li/cil/oc/common/component/traits/VideoRamAware.scala b/src/main/scala/li/cil/oc/common/component/traits/VideoRamAware.scala index 55b30b2fe..6a1fe0764 100644 --- a/src/main/scala/li/cil/oc/common/component/traits/VideoRamAware.scala +++ b/src/main/scala/li/cil/oc/common/component/traits/VideoRamAware.scala @@ -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) diff --git a/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala b/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala index b9b135617..67e819046 100644 --- a/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala +++ b/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala @@ -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.""")