ワーカーの画像加工を自動GPU委譲へ統一
このコミットが含まれているのは:
2ファイル変更
+87
-19
検索条件に一致するファイルはありません
@@ -1988,7 +1988,7 @@ namespace LuaScript.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelProcess_DefaultFill_SkipsHostProcessor()
|
||||
public void PixelProcess_DefaultFill_UsesHostProcessor()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
@@ -2000,14 +2000,17 @@ namespace LuaScript.Tests
|
||||
bool ok = RunWorker(
|
||||
"obj.fill(10, 20, 30, 40, 0, 0, 1024, 1024)",
|
||||
Fields(w, h, 0d), NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(0, processor.FillCalls);
|
||||
Assert.True(dirty);
|
||||
Assert.Equal(1, processor.FillCalls);
|
||||
Assert.Equal(0x41, pixels[0]);
|
||||
Assert.Equal(0x41, pixels[^1]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelProcess_DefaultConvolve_SkipsHostProcessor()
|
||||
public void PixelProcess_DefaultConvolve_UsesHostProcessor()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
@@ -2019,14 +2022,19 @@ namespace LuaScript.Tests
|
||||
bool ok = RunWorker(
|
||||
"obj.convolve({1, 2, 3, 4, 5, 6, 7, 8, 9}, 3, 45, 6)",
|
||||
Fields(w, h, 0d), NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
out bool dirty, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(0, processor.ConvolveCalls);
|
||||
Assert.True(dirty);
|
||||
Assert.Equal(1, processor.ConvolveCalls);
|
||||
Assert.Equal(3, processor.Size);
|
||||
Assert.Equal(45d, processor.Divisor);
|
||||
Assert.Equal(6d, processor.Offset);
|
||||
Assert.Equal(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, processor.Kernel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelProcess_DefaultResize_SkipsHostProcessor()
|
||||
public void PixelProcess_DefaultResize_UsesHostProcessor()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
@@ -2038,6 +2046,66 @@ namespace LuaScript.Tests
|
||||
bool ok = RunWorker(
|
||||
"obj.resize(512, 512, 'nearest')",
|
||||
Fields(w, h, 0d), NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out bool replaced, out _, out int rw, out int rh, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.True(replaced);
|
||||
Assert.Equal(1, processor.ResizeCalls);
|
||||
Assert.Equal(512, rw);
|
||||
Assert.Equal(512, rh);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelProcess_BelowThresholdFill_SkipsHostProcessor()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
const int w = 64, h = 64;
|
||||
var pixels = new byte[w * h * 4];
|
||||
var processor = new RecordingPixelProcessor { FillResult = true };
|
||||
_pixelProcessor = processor;
|
||||
|
||||
bool ok = RunWorker(
|
||||
"obj.fill(10, 20, 30, 40)",
|
||||
Fields(w, h, 0d), NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(0, processor.FillCalls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelProcess_BelowThresholdConvolve_SkipsHostProcessor()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
const int w = 8, h = 8;
|
||||
var pixels = new byte[w * h * 4];
|
||||
var processor = new RecordingPixelProcessor { ConvolveResult = true };
|
||||
_pixelProcessor = processor;
|
||||
|
||||
bool ok = RunWorker(
|
||||
"obj.convolve({1, 1, 1, 1, 1, 1, 1, 1, 1}, 3)",
|
||||
Fields(w, h, 0d), NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
Assert.Equal(0, processor.ConvolveCalls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PixelProcess_BelowThresholdResize_SkipsHostProcessor()
|
||||
{
|
||||
Assert.True(LuaJitWorker.IsAvailable(NativeDir), "native/luajit.exe must be present");
|
||||
|
||||
const int w = 2, h = 2;
|
||||
var pixels = new byte[w * h * 4];
|
||||
var processor = new RecordingPixelProcessor { ResizeResult = true };
|
||||
_pixelProcessor = processor;
|
||||
|
||||
bool ok = RunWorker(
|
||||
"obj.resize(4, 4, 'nearest')",
|
||||
Fields(w, h, 0d), NoStringParams, () => pixels, w, h, 5000, NoResolver, NoLoadFigure, NoLoadText, NoLoadImage, NoLoadMovie, NoAddEffect, NoAddDraw, NoSetAnchor,
|
||||
out _, out _, out _, out _, out _, out string? error);
|
||||
|
||||
Assert.True(ok, error);
|
||||
|
||||
+12
-12
@@ -864,7 +864,7 @@ function obj.copybuffer(dst, src)
|
||||
end
|
||||
end
|
||||
|
||||
local function fillImpl(accel, r, g, b, a, x, y, w, h)
|
||||
local function fillImpl(r, g, b, a, x, y, w, h)
|
||||
ensurePixels()
|
||||
flushPixelData()
|
||||
r = r or 0; g = g or 0; b = b or 0; a = a or 255
|
||||
@@ -892,7 +892,7 @@ local function fillImpl(accel, r, g, b, a, x, y, w, h)
|
||||
cbResult[6] = y0
|
||||
cbResult[7] = x1 - x0
|
||||
cbResult[8] = y1 - y0
|
||||
if accel and usePixelProcess and tryPixelProcess(PIXEL_PROCESS_FILL) then
|
||||
if usePixelProcess and tryPixelProcess(PIXEL_PROCESS_FILL) then
|
||||
dirty = true
|
||||
pdValid = false
|
||||
pdDirty = false
|
||||
@@ -913,8 +913,8 @@ local function fillImpl(accel, r, g, b, a, x, y, w, h)
|
||||
pdValid = false
|
||||
end
|
||||
|
||||
function obj.fill(r, g, b, a, x, y, w, h) fillImpl(false, r, g, b, a, x, y, w, h) end
|
||||
function __fast_fill(r, g, b, a, x, y, w, h) fillImpl(true, r, g, b, a, x, y, w, h) end
|
||||
obj.fill = fillImpl
|
||||
__fast_fill = fillImpl
|
||||
|
||||
function obj.getpixelregion(x, y, w, h)
|
||||
x = math.floor(x or 0); y = math.floor(y or 0)
|
||||
@@ -977,7 +977,7 @@ function obj.putpixelregion(x, y, w, h, data)
|
||||
pdValid = false
|
||||
end
|
||||
|
||||
local function convolveImpl(accel, kernel, size, divisor, offset)
|
||||
local function convolveImpl(kernel, size, divisor, offset)
|
||||
if type(kernel) ~= "table" then return end
|
||||
size = math.floor(size or 0)
|
||||
if size < 1 or size % 2 == 0 then return end
|
||||
@@ -994,7 +994,7 @@ local function convolveImpl(accel, kernel, size, divisor, offset)
|
||||
local inv = divisor or sum
|
||||
if inv == 0 then inv = 1 end
|
||||
offset = offset or 0
|
||||
if accel and taps * 8 <= CB_TAG_MAX and width * height * taps >= PIXEL_PROCESS_CONVOLVE_WORK_THRESHOLD then
|
||||
if taps * 8 <= CB_TAG_MAX and width * height * taps >= PIXEL_PROCESS_CONVOLVE_WORK_THRESHOLD then
|
||||
cbResult[1] = size
|
||||
cbResult[2] = inv
|
||||
cbResult[3] = offset
|
||||
@@ -1061,10 +1061,10 @@ local function convolveImpl(accel, kernel, size, divisor, offset)
|
||||
pdValid = false
|
||||
end
|
||||
|
||||
function obj.convolve(kernel, size, divisor, offset) convolveImpl(false, kernel, size, divisor, offset) end
|
||||
function __fast_convolve(kernel, size, divisor, offset) convolveImpl(true, kernel, size, divisor, offset) end
|
||||
obj.convolve = convolveImpl
|
||||
__fast_convolve = convolveImpl
|
||||
|
||||
local function resizeImpl(accel, newW, newH, mode)
|
||||
local function resizeImpl(newW, newH, mode)
|
||||
newW = math.floor(newW or 0); newH = math.floor(newH or 0)
|
||||
if newW < 1 then newW = 1 end
|
||||
if newH < 1 then newH = 1 end
|
||||
@@ -1077,7 +1077,7 @@ local function resizeImpl(accel, newW, newH, mode)
|
||||
cbResult[1] = newW
|
||||
cbResult[2] = newH
|
||||
cbResult[3] = linear and 1 or 0
|
||||
if accel and newW * newH >= PIXEL_PROCESS_RESIZE_THRESHOLD and tryPixelProcess(PIXEL_PROCESS_RESIZE) then
|
||||
if newW * newH >= PIXEL_PROCESS_RESIZE_THRESHOLD and tryPixelProcess(PIXEL_PROCESS_RESIZE) then
|
||||
width = newW; height = newH
|
||||
i32[OFF_WIDTH] = newW; i32[OFF_HEIGHT] = newH
|
||||
dirty = true
|
||||
@@ -1142,8 +1142,8 @@ local function resizeImpl(accel, newW, newH, mode)
|
||||
obj.diagonal = math.sqrt(newW * newW + newH * newH)
|
||||
end
|
||||
|
||||
function obj.resize(newW, newH, mode) resizeImpl(false, newW, newH, mode) end
|
||||
function __fast_resize(newW, newH, mode) resizeImpl(true, newW, newH, mode) end
|
||||
obj.resize = resizeImpl
|
||||
__fast_resize = resizeImpl
|
||||
|
||||
local SCENE_VALUE_MAX = 4095
|
||||
local SCENE_NIL = {}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする