@next2d/webgpu 3.2.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/webgpu",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Next2D WebGPU Package",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@next2d/texture-packer": "3.
|
|
28
|
-
"@next2d/render-queue": "3.
|
|
27
|
+
"@next2d/texture-packer": "3.4.0",
|
|
28
|
+
"@next2d/render-queue": "3.4.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -519,8 +519,12 @@ _layer_scale_x = 1, _layer_scale_y = 1) => {
|
|
|
519
519
|
// フィルターチェーンを適用
|
|
520
520
|
const devicePixelRatio = WebGPUUtil.getDevicePixelRatio();
|
|
521
521
|
filterAttachment = $applyFilterChain(filterAttachment, matrix, params, devicePixelRatio, config);
|
|
522
|
-
//
|
|
522
|
+
// キャッシュに保存(古いfTextureを先に解放してGPUリーク防止)
|
|
523
523
|
if (unique_key) {
|
|
524
|
+
const oldAttachment = $cacheStore.get(unique_key, "fTexture");
|
|
525
|
+
if (oldAttachment) {
|
|
526
|
+
config.frameBufferManager.releaseTemporaryAttachment(oldAttachment);
|
|
527
|
+
}
|
|
524
528
|
$cacheStore.set(unique_key, "fKey", filter_key);
|
|
525
529
|
$cacheStore.set(unique_key, "fTexture", filterAttachment);
|
|
526
530
|
}
|
package/src/Context.d.ts
CHANGED
|
@@ -761,6 +761,18 @@ export declare class Context {
|
|
|
761
761
|
* @return {void}
|
|
762
762
|
*/
|
|
763
763
|
removeNode(node: Node): void;
|
|
764
|
+
/**
|
|
765
|
+
* @description CacheStore に格納された任意の値を解放する。
|
|
766
|
+
* Release any value stored in CacheStore.
|
|
767
|
+
*
|
|
768
|
+
* CommandRemoveCacheService から instanceId / uniqueKey 単位で呼ばれ、
|
|
769
|
+
* Node / IAttachmentObject / プリミティブの全てを安全に解放できるよう
|
|
770
|
+
* 型判定で振り分ける。
|
|
771
|
+
*
|
|
772
|
+
* @param {*} value
|
|
773
|
+
* @return {void}
|
|
774
|
+
*/
|
|
775
|
+
releaseTextureCache(value: any): void;
|
|
764
776
|
/**
|
|
765
777
|
* @description フレームバッファの描画情報をキャンバスに転送
|
|
766
778
|
* Transfer frame buffer contents to the canvas
|
package/src/Context.js
CHANGED
|
@@ -2575,6 +2575,32 @@ export class Context {
|
|
|
2575
2575
|
rootNode.dispose(node.x, node.y, node.w, node.h);
|
|
2576
2576
|
}
|
|
2577
2577
|
}
|
|
2578
|
+
/**
|
|
2579
|
+
* @description CacheStore に格納された任意の値を解放する。
|
|
2580
|
+
* Release any value stored in CacheStore.
|
|
2581
|
+
*
|
|
2582
|
+
* CommandRemoveCacheService から instanceId / uniqueKey 単位で呼ばれ、
|
|
2583
|
+
* Node / IAttachmentObject / プリミティブの全てを安全に解放できるよう
|
|
2584
|
+
* 型判定で振り分ける。
|
|
2585
|
+
*
|
|
2586
|
+
* @param {*} value
|
|
2587
|
+
* @return {void}
|
|
2588
|
+
*/
|
|
2589
|
+
releaseTextureCache(value) {
|
|
2590
|
+
if (!value || typeof value !== "object") {
|
|
2591
|
+
return;
|
|
2592
|
+
}
|
|
2593
|
+
if ("w" in value) {
|
|
2594
|
+
const node = value;
|
|
2595
|
+
const rootNode = $rootNodes[node.index];
|
|
2596
|
+
if (rootNode) {
|
|
2597
|
+
rootNode.dispose(node.x, node.y, node.w, node.h);
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
else if ("color" in value || "texture" in value) {
|
|
2601
|
+
this.frameBufferManager.releaseTemporaryAttachment(value);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2578
2604
|
/**
|
|
2579
2605
|
* @description フレームバッファの描画情報をキャンバスに転送
|
|
2580
2606
|
* Transfer frame buffer contents to the canvas
|
package/src/FillTexturePool.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export declare const $getOrCreateView: (texture: GPUTexture) => GPUTextureView;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const $acquireFillTexture: (device: GPUDevice, width: number, height: number) => GPUTexture;
|
|
17
17
|
/**
|
|
18
|
-
* @description
|
|
19
|
-
* Release a fill texture back to the pool
|
|
18
|
+
* @description 塗りテクスチャをプールに返却。上限超過時は destroy する
|
|
19
|
+
* Release a fill texture back to the pool. Destroyed when limits are exceeded
|
|
20
20
|
* @param {GPUTexture} texture
|
|
21
21
|
* @return {void}
|
|
22
22
|
*/
|
|
@@ -31,8 +31,8 @@ export declare const $releaseFillTexture: (texture: GPUTexture) => void;
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const $acquireRenderTexture: (device: GPUDevice, width: number, height: number) => GPUTexture;
|
|
33
33
|
/**
|
|
34
|
-
* @description
|
|
35
|
-
* Release a render texture back to the pool
|
|
34
|
+
* @description レンダーテクスチャをプールに返却。上限超過時は destroy する
|
|
35
|
+
* Release a render texture back to the pool. Destroyed when limits are exceeded
|
|
36
36
|
* @param {GPUTexture} texture
|
|
37
37
|
* @return {void}
|
|
38
38
|
*/
|
package/src/FillTexturePool.js
CHANGED
|
@@ -32,18 +32,42 @@ const $FILL_TEXTURE_USAGE = 0x06;
|
|
|
32
32
|
* @type {number}
|
|
33
33
|
*/
|
|
34
34
|
const $RENDER_TEXTURE_USAGE = 0x16;
|
|
35
|
+
/**
|
|
36
|
+
* @description 同一サイズのバケットあたりの最大保持数
|
|
37
|
+
* Maximum number of textures held per same-size bucket
|
|
38
|
+
* @type {number}
|
|
39
|
+
*/
|
|
40
|
+
const $MAX_BUCKET_SIZE = 32;
|
|
41
|
+
/**
|
|
42
|
+
* @description プール全体での最大保持数(fill/render それぞれに適用)
|
|
43
|
+
* Maximum number of textures held in the entire pool (applied independently to fill/render)
|
|
44
|
+
* @type {number}
|
|
45
|
+
*/
|
|
46
|
+
const $MAX_TOTAL = 256;
|
|
35
47
|
/**
|
|
36
48
|
* @description 塗りテクスチャのオブジェクトプール
|
|
37
49
|
* Object pool for fill textures
|
|
38
50
|
* @type {Map<string, GPUTexture[]>}
|
|
39
51
|
*/
|
|
40
52
|
const $pool = new Map();
|
|
53
|
+
/**
|
|
54
|
+
* @description 塗りテクスチャプールの総数
|
|
55
|
+
* Total count of textures currently held in the fill pool
|
|
56
|
+
* @type {number}
|
|
57
|
+
*/
|
|
58
|
+
let $fillTotalCount = 0;
|
|
41
59
|
/**
|
|
42
60
|
* @description レンダーテクスチャのオブジェクトプール
|
|
43
61
|
* Object pool for render textures
|
|
44
62
|
* @type {Map<string, GPUTexture[]>}
|
|
45
63
|
*/
|
|
46
64
|
const $renderPool = new Map();
|
|
65
|
+
/**
|
|
66
|
+
* @description レンダーテクスチャプールの総数
|
|
67
|
+
* Total count of textures currently held in the render pool
|
|
68
|
+
* @type {number}
|
|
69
|
+
*/
|
|
70
|
+
let $renderTotalCount = 0;
|
|
47
71
|
/**
|
|
48
72
|
* @description プールから塗りテクスチャを取得、なければ新規作成
|
|
49
73
|
* Acquire a fill texture from the pool, or create a new one
|
|
@@ -56,6 +80,7 @@ export const $acquireFillTexture = (device, width, height) => {
|
|
|
56
80
|
const key = `${width}_${height}`;
|
|
57
81
|
const list = $pool.get(key);
|
|
58
82
|
if (list && list.length > 0) {
|
|
83
|
+
$fillTotalCount--;
|
|
59
84
|
return list.pop();
|
|
60
85
|
}
|
|
61
86
|
return device.createTexture({
|
|
@@ -65,8 +90,8 @@ export const $acquireFillTexture = (device, width, height) => {
|
|
|
65
90
|
});
|
|
66
91
|
};
|
|
67
92
|
/**
|
|
68
|
-
* @description
|
|
69
|
-
* Release a fill texture back to the pool
|
|
93
|
+
* @description 塗りテクスチャをプールに返却。上限超過時は destroy する
|
|
94
|
+
* Release a fill texture back to the pool. Destroyed when limits are exceeded
|
|
70
95
|
* @param {GPUTexture} texture
|
|
71
96
|
* @return {void}
|
|
72
97
|
*/
|
|
@@ -77,7 +102,12 @@ export const $releaseFillTexture = (texture) => {
|
|
|
77
102
|
list = [];
|
|
78
103
|
$pool.set(key, list);
|
|
79
104
|
}
|
|
105
|
+
if (list.length >= $MAX_BUCKET_SIZE || $fillTotalCount >= $MAX_TOTAL) {
|
|
106
|
+
texture.destroy();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
80
109
|
list.push(texture);
|
|
110
|
+
$fillTotalCount++;
|
|
81
111
|
};
|
|
82
112
|
/**
|
|
83
113
|
* @description プールからレンダーテクスチャを取得、なければ新規作成
|
|
@@ -91,6 +121,7 @@ export const $acquireRenderTexture = (device, width, height) => {
|
|
|
91
121
|
const key = `${width}_${height}`;
|
|
92
122
|
const list = $renderPool.get(key);
|
|
93
123
|
if (list && list.length > 0) {
|
|
124
|
+
$renderTotalCount--;
|
|
94
125
|
return list.pop();
|
|
95
126
|
}
|
|
96
127
|
return device.createTexture({
|
|
@@ -100,8 +131,8 @@ export const $acquireRenderTexture = (device, width, height) => {
|
|
|
100
131
|
});
|
|
101
132
|
};
|
|
102
133
|
/**
|
|
103
|
-
* @description
|
|
104
|
-
* Release a render texture back to the pool
|
|
134
|
+
* @description レンダーテクスチャをプールに返却。上限超過時は destroy する
|
|
135
|
+
* Release a render texture back to the pool. Destroyed when limits are exceeded
|
|
105
136
|
* @param {GPUTexture} texture
|
|
106
137
|
* @return {void}
|
|
107
138
|
*/
|
|
@@ -112,7 +143,12 @@ export const $releaseRenderTexture = (texture) => {
|
|
|
112
143
|
list = [];
|
|
113
144
|
$renderPool.set(key, list);
|
|
114
145
|
}
|
|
146
|
+
if (list.length >= $MAX_BUCKET_SIZE || $renderTotalCount >= $MAX_TOTAL) {
|
|
147
|
+
texture.destroy();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
115
150
|
list.push(texture);
|
|
151
|
+
$renderTotalCount++;
|
|
116
152
|
};
|
|
117
153
|
/**
|
|
118
154
|
* @description 全テクスチャプールを破棄してクリア
|
|
@@ -126,10 +162,12 @@ export const $clearFillTexturePool = () => {
|
|
|
126
162
|
}
|
|
127
163
|
}
|
|
128
164
|
$pool.clear();
|
|
165
|
+
$fillTotalCount = 0;
|
|
129
166
|
for (const [, list] of $renderPool) {
|
|
130
167
|
for (const texture of list) {
|
|
131
168
|
texture.destroy();
|
|
132
169
|
}
|
|
133
170
|
}
|
|
134
171
|
$renderPool.clear();
|
|
172
|
+
$renderTotalCount = 0;
|
|
135
173
|
};
|