@next2d/webgpu 3.1.0 → 3.2.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 +3 -3
- package/src/AtlasManager.js +12 -14
- package/src/Context/usecase/ContextContainerEndLayerUseCase.d.ts +1 -1
- package/src/Context/usecase/ContextContainerEndLayerUseCase.js +4 -1
- package/src/Context/usecase/ContextDrawArraysInstancedUseCase.js +23 -11
- package/src/Context.d.ts +1 -1
- package/src/Context.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/webgpu",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.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.2.0",
|
|
28
|
+
"@next2d/render-queue": "3.2.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/AtlasManager.js
CHANGED
|
@@ -77,16 +77,15 @@ export const $setAtlasCreator = (creator) => {
|
|
|
77
77
|
* @return {IAttachmentObject | null}
|
|
78
78
|
*/
|
|
79
79
|
export const $getAtlasAttachmentObject = () => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
$setAtlasAttachmentObject(attachment);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
80
|
+
let attachment = $atlasAttachmentObjects[$activeAtlasIndex];
|
|
81
|
+
if (!attachment) {
|
|
82
|
+
if (!$atlasCreator) {
|
|
86
83
|
return null;
|
|
87
84
|
}
|
|
85
|
+
attachment = $atlasCreator($activeAtlasIndex);
|
|
86
|
+
$setAtlasAttachmentObject(attachment);
|
|
88
87
|
}
|
|
89
|
-
return
|
|
88
|
+
return attachment;
|
|
90
89
|
};
|
|
91
90
|
/**
|
|
92
91
|
* @description 指定インデックスのアタッチメントオブジェクトを取得する
|
|
@@ -95,10 +94,7 @@ export const $getAtlasAttachmentObject = () => {
|
|
|
95
94
|
* @return {IAttachmentObject | null}
|
|
96
95
|
*/
|
|
97
96
|
export const $getAtlasAttachmentObjectByIndex = (index) => {
|
|
98
|
-
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
return $atlasAttachmentObjects[index];
|
|
97
|
+
return $atlasAttachmentObjects[index] ?? null;
|
|
102
98
|
};
|
|
103
99
|
/**
|
|
104
100
|
* @description テクスチャパッカーのルートノード配列
|
|
@@ -119,15 +115,17 @@ const $transferBounds = [];
|
|
|
119
115
|
* @return {Float32Array}
|
|
120
116
|
*/
|
|
121
117
|
export const $getActiveTransferBounds = (index) => {
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
let bounds = $transferBounds[index];
|
|
119
|
+
if (!bounds) {
|
|
120
|
+
bounds = new Float32Array([
|
|
124
121
|
$MAX_VALUE,
|
|
125
122
|
$MAX_VALUE,
|
|
126
123
|
$MIN_VALUE,
|
|
127
124
|
$MIN_VALUE
|
|
128
125
|
]);
|
|
126
|
+
$transferBounds[index] = bounds;
|
|
129
127
|
}
|
|
130
|
-
return
|
|
128
|
+
return bounds;
|
|
131
129
|
};
|
|
132
130
|
/**
|
|
133
131
|
* @description 全ての転送領域を初期値にリセットする
|
|
@@ -22,4 +22,4 @@ import type { BufferManager } from "../../BufferManager";
|
|
|
22
22
|
* @param {BufferManager} buffer_manager バッファマネージャ / Buffer manager
|
|
23
23
|
* @return {void}
|
|
24
24
|
*/
|
|
25
|
-
export declare const execute: (temp_attachment: IAttachmentObject, main_attachment: IAttachmentObject, _temp_name: string, blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array | null, use_filter: boolean, filter_bounds: Float32Array | null, params: Float32Array | null, unique_key: string, filter_key: string, _content_width: number, _content_height: number, config: ILocalFilterConfig, buffer_manager: BufferManager) => void;
|
|
25
|
+
export declare const execute: (temp_attachment: IAttachmentObject, main_attachment: IAttachmentObject, _temp_name: string, blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array | null, use_filter: boolean, filter_bounds: Float32Array | null, params: Float32Array | null, unique_key: string, filter_key: string, _content_width: number, _content_height: number, config: ILocalFilterConfig, buffer_manager: BufferManager, _layer_scale_x?: number, _layer_scale_y?: number) => void;
|
|
@@ -500,7 +500,10 @@ const $applyFilterChain = (filter_attachment, matrix, params, device_pixel_ratio
|
|
|
500
500
|
* @param {BufferManager} buffer_manager バッファマネージャ / Buffer manager
|
|
501
501
|
* @return {void}
|
|
502
502
|
*/
|
|
503
|
-
export const execute = (temp_attachment, main_attachment, _temp_name, blend_mode, matrix, color_transform, use_filter, filter_bounds, params, unique_key, filter_key, _content_width, _content_height, config, buffer_manager
|
|
503
|
+
export const execute = (temp_attachment, main_attachment, _temp_name, blend_mode, matrix, color_transform, use_filter, filter_bounds, params, unique_key, filter_key, _content_width, _content_height, config, buffer_manager,
|
|
504
|
+
// TODO: WebGPU版でも layer_scale による 1/layerScale 縮小合成に対応する。
|
|
505
|
+
// 現状はWebGL版のみで動作、WebGPU版は従来通り layer_scale=1 として合成される。
|
|
506
|
+
_layer_scale_x = 1, _layer_scale_y = 1) => {
|
|
504
507
|
if (use_filter && matrix && filter_bounds && params) {
|
|
505
508
|
// containerEndLayerが呼ばれる=ディスプレイレイヤーがコンテンツ変更を検出して再レンダリングを要求
|
|
506
509
|
// 常に新鮮なテクスチャを抽出してフィルターを適用する
|
|
@@ -4,15 +4,20 @@ import { renderQueue } from "@next2d/render-queue";
|
|
|
4
4
|
import { $isMaskTestEnabled, $getMaskStencilReference } from "../../Mask";
|
|
5
5
|
import { $getAtlasAttachmentObject } from "../../AtlasManager";
|
|
6
6
|
/**
|
|
7
|
-
* @description
|
|
8
|
-
*
|
|
7
|
+
* @description atlasViewをキーにしたBindGroupキャッシュ。複数アトラスを
|
|
8
|
+
* 交互に描画してもヒットする。textureが破棄されたら自動GC。
|
|
9
|
+
* BindGroup cache keyed by atlas view. Survives multi-atlas
|
|
10
|
+
* switching; entries are GC'd when the texture view is released.
|
|
9
11
|
*/
|
|
10
|
-
let $
|
|
12
|
+
let $bindGroupCache = new WeakMap();
|
|
11
13
|
/**
|
|
12
|
-
* @description
|
|
13
|
-
*
|
|
14
|
+
* @description キャッシュの整合性ガード。samplerまたはbindGroupLayoutが
|
|
15
|
+
* 切り替わった場合は全エントリを無効化する。
|
|
16
|
+
* Invalidates the entire cache when the sampler or bind
|
|
17
|
+
* group layout changes.
|
|
14
18
|
*/
|
|
15
|
-
let $
|
|
19
|
+
let $cachedSampler = null;
|
|
20
|
+
let $cachedLayout = null;
|
|
16
21
|
/**
|
|
17
22
|
* @description ブレンドモードに応じたインスタンスパイプライン名を返す
|
|
18
23
|
*/
|
|
@@ -125,10 +130,17 @@ export const execute = (device, command_encoder, render_pass_encoder, main_attac
|
|
|
125
130
|
passEncoder.end();
|
|
126
131
|
return null;
|
|
127
132
|
}
|
|
128
|
-
// BindGroupキャッシュ:
|
|
133
|
+
// BindGroupキャッシュ: atlasView毎にBindGroupを保持。sampler/layoutが
|
|
134
|
+
// 切り替わった場合はキャッシュをクリアして整合性を保つ。
|
|
129
135
|
const atlasView = atlasAttachment.texture.view;
|
|
130
|
-
if (
|
|
131
|
-
$
|
|
136
|
+
if ($cachedSampler !== sampler || $cachedLayout !== bindGroupLayout) {
|
|
137
|
+
$bindGroupCache = new WeakMap();
|
|
138
|
+
$cachedSampler = sampler;
|
|
139
|
+
$cachedLayout = bindGroupLayout;
|
|
140
|
+
}
|
|
141
|
+
let bindGroup = $bindGroupCache.get(atlasView);
|
|
142
|
+
if (!bindGroup) {
|
|
143
|
+
bindGroup = device.createBindGroup({
|
|
132
144
|
"layout": bindGroupLayout,
|
|
133
145
|
"entries": [
|
|
134
146
|
{
|
|
@@ -141,12 +153,12 @@ export const execute = (device, command_encoder, render_pass_encoder, main_attac
|
|
|
141
153
|
}
|
|
142
154
|
]
|
|
143
155
|
});
|
|
144
|
-
$
|
|
156
|
+
$bindGroupCache.set(atlasView, bindGroup);
|
|
145
157
|
}
|
|
146
158
|
// 描画
|
|
147
159
|
passEncoder.setVertexBuffer(0, vertexBuffer);
|
|
148
160
|
passEncoder.setVertexBuffer(1, instanceBuffer);
|
|
149
|
-
passEncoder.setBindGroup(0,
|
|
161
|
+
passEncoder.setBindGroup(0, bindGroup);
|
|
150
162
|
passEncoder.draw(6, shaderManager.count, 0, 0);
|
|
151
163
|
// レンダーパスを終了
|
|
152
164
|
passEncoder.end();
|
package/src/Context.d.ts
CHANGED
|
@@ -652,7 +652,7 @@ export declare class Context {
|
|
|
652
652
|
* @param {string} filter_key - フィルターキー / Filter key
|
|
653
653
|
* @return {void}
|
|
654
654
|
*/
|
|
655
|
-
containerEndLayer(blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array | null, use_filter: boolean, filter_bounds: Float32Array | null, filter_params: Float32Array | null, unique_key: string, filter_key: string): void;
|
|
655
|
+
containerEndLayer(blend_mode: IBlendMode, matrix: Float32Array, color_transform: Float32Array | null, use_filter: boolean, filter_bounds: Float32Array | null, filter_params: Float32Array | null, unique_key: string, filter_key: string, layer_scale_x?: number, layer_scale_y?: number): void;
|
|
656
656
|
/**
|
|
657
657
|
* @description cacheAsBitmap: temp FBO作成→子要素描画開始
|
|
658
658
|
* Begin container cacheAsBitmap: create temp bgra8unorm FBO for children,
|
package/src/Context.js
CHANGED
|
@@ -2119,7 +2119,7 @@ export class Context {
|
|
|
2119
2119
|
* @param {string} filter_key - フィルターキー / Filter key
|
|
2120
2120
|
* @return {void}
|
|
2121
2121
|
*/
|
|
2122
|
-
containerEndLayer(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key) {
|
|
2122
|
+
containerEndLayer(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, layer_scale_x = 1, layer_scale_y = 1) {
|
|
2123
2123
|
this.drawArraysInstanced();
|
|
2124
2124
|
// 既存のレンダーパスを終了
|
|
2125
2125
|
if (this.renderPassEncoder) {
|
|
@@ -2133,7 +2133,7 @@ export class Context {
|
|
|
2133
2133
|
this.$mainAttachmentObject = this.$containerLayerStack.pop();
|
|
2134
2134
|
this.$filterConfig.commandEncoder = this.commandEncoder;
|
|
2135
2135
|
this.$filterConfig.mainAttachment = undefined;
|
|
2136
|
-
contextContainerEndLayerUseCase(tempAttachment, this.$mainAttachmentObject, "container_layer", blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, contentSize.width, contentSize.height, this.$filterConfig, this.bufferManager);
|
|
2136
|
+
contextContainerEndLayerUseCase(tempAttachment, this.$mainAttachmentObject, "container_layer", blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, contentSize.width, contentSize.height, this.$filterConfig, this.bufferManager, layer_scale_x, layer_scale_y);
|
|
2137
2137
|
// メインのアタッチメントをバインド
|
|
2138
2138
|
this.bind(this.$mainAttachmentObject);
|
|
2139
2139
|
}
|