From 103b612082bda74471dc3e5abca30d1aadcddf4b Mon Sep 17 00:00:00 2001 From: routersys Date: Sat, 4 Jul 2026 12:08:09 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B7=E3=82=A7=E3=83=BC=E3=83=80=E3=83=BC?= =?UTF-8?q?=E9=A0=98=E5=9F=9F=E3=81=AE=E6=95=B4=E5=88=97=E3=81=A8=E5=AE=B9?= =?UTF-8?q?=E9=87=8F=E5=88=A4=E5=AE=9A=E3=82=92=E8=A3=9C=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript.Runtime/Engine/LuaJitWorker.cs | 2 +- LuaScript.Runtime/Engine/NativeProtocol.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/LuaScript.Runtime/Engine/LuaJitWorker.cs b/LuaScript.Runtime/Engine/LuaJitWorker.cs index 47cfa5c..7180d03 100644 --- a/LuaScript.Runtime/Engine/LuaJitWorker.cs +++ b/LuaScript.Runtime/Engine/LuaJitWorker.cs @@ -818,7 +818,7 @@ namespace LuaScript.Engine private void EnsureWorker(int width, int height, int stringCapacity) { - long required = NativeProtocol.PixelOffset(stringCapacity) + (long)width * height * 4; + long required = NativeProtocol.PixelOffset(stringCapacity) + (long)width * height * 4 + NativeProtocol.ShaderRegionBytes; if (_alive && _process is { HasExited: false } && _stringParamsCapacity == stringCapacity && required <= _allocatedSize) return; diff --git a/LuaScript.Runtime/Engine/NativeProtocol.cs b/LuaScript.Runtime/Engine/NativeProtocol.cs index 18f3a56..cf1b435 100644 --- a/LuaScript.Runtime/Engine/NativeProtocol.cs +++ b/LuaScript.Runtime/Engine/NativeProtocol.cs @@ -187,6 +187,9 @@ namespace LuaScript.Engine public static long ShaderImageOffset(long bufferSize) => ShaderConstantsOffset(bufferSize) + ShaderConstantsMax * 4; public static long BufferSize(int width, int height, int stringCapacity) => - PixelOffset(stringCapacity) + Math.Max((long)width * height * 4, MaxPixelBufferSize) + ShaderRegionBytes; + PixelOffset(stringCapacity) + PixelRegionSize(width, height) + ShaderRegionBytes; + + public static long PixelRegionSize(int width, int height) => + (Math.Max((long)width * height * 4, MaxPixelBufferSize) + 7) & ~7L; } }