From 889a556837ddb0e0548af0d28a8b9494b51311cd Mon Sep 17 00:00:00 2001 From: routersys Date: Tue, 20 Oct 2026 18:31:57 +0900 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E3=82=8A=E4=B8=8A=E3=81=92=E3=81=AE?= =?UTF-8?q?=E9=99=A4=E7=AE=97=E3=82=92=E5=85=B1=E9=80=9A=E3=81=AE=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inflate/InflatePipelineHost.cs | 4 ++-- Inflate/InflateSettings.cs | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Inflate/InflatePipelineHost.cs b/Inflate/InflatePipelineHost.cs index a2c994f..3382504 100644 --- a/Inflate/InflatePipelineHost.cs +++ b/Inflate/InflatePipelineHost.cs @@ -264,7 +264,7 @@ internal sealed partial class InflatePipelineHost coarseHeight, gridWidth, gridHeight, - (gridWidth + InflateSettings.CorrectionGroupSize - 1) / InflateSettings.CorrectionGroupSize)); + InflateSettings.GetCorrectionGroupColumns(gridWidth))); context.Barrier(grid.Partial); context.Barrier(grid.Scale); context.For( @@ -316,7 +316,7 @@ internal sealed partial class InflatePipelineHost for (var color = 0; color < 2; color++) { context.For( - (width + 1) / 2, + InflateSettings.CeilDivide(width, 2), height, new GaussSeidelShader(grid.Mask, grid.Residual, grid.Potential, offset, width, height, color, constantRhs ? 1 : 0, rhsValue)); context.Barrier(grid.Potential); diff --git a/Inflate/InflateSettings.cs b/Inflate/InflateSettings.cs index 503cb01..477561b 100644 --- a/Inflate/InflateSettings.cs +++ b/Inflate/InflateSettings.cs @@ -60,7 +60,7 @@ internal static class InflateSettings } public static (int Width, int Height) GetCoarserLevelSize(int width, int height) - => ((width + 1) / 2, (height + 1) / 2); + => (CeilDivide(width, 2), CeilDivide(height, 2)); public static int GetLevelCount(int gridWidth, int gridHeight) { @@ -100,8 +100,14 @@ internal static class InflateSettings public static int GetPyramidLength(int gridWidth, int gridHeight) => GetLevelOffset(gridWidth, gridHeight, GetLevelCount(gridWidth, gridHeight)); + public static int GetCorrectionGroupColumns(int gridWidth) + => CeilDivide(gridWidth, CorrectionGroupSize); + public static int GetCorrectionGroupCount(int gridWidth, int gridHeight) - => (gridWidth + CorrectionGroupSize - 1) / CorrectionGroupSize * ((gridHeight + CorrectionGroupSize - 1) / CorrectionGroupSize); + => GetCorrectionGroupColumns(gridWidth) * CeilDivide(gridHeight, CorrectionGroupSize); + + public static int CeilDivide(int value, int divisor) + => (value + divisor - 1) / divisor; public static bool IsSupportedSize(double width, double height) => width >= 1d && height >= 1d &&