@next2d/webgpu 3.0.1 → 3.0.2

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.0.1",
3
+ "version": "3.0.2",
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.0.1",
28
- "@next2d/render-queue": "3.0.1"
27
+ "@next2d/texture-packer": "3.0.2",
28
+ "@next2d/render-queue": "3.0.2"
29
29
  }
30
30
  }
package/src/Context.d.ts CHANGED
@@ -59,6 +59,7 @@ export declare class Context {
59
59
  private fillDynamicBindGroupBuffer;
60
60
  private nodeClearQuadBuffer;
61
61
  private useOptimizedInstancing;
62
+ private $needsReconfigure;
62
63
  private readonly $uniformData8;
63
64
  private readonly $scissorRect;
64
65
  private readonly $filterConfig;
package/src/Context.js CHANGED
@@ -452,6 +452,14 @@ export class Context {
452
452
  writable: true,
453
453
  value: true
454
454
  });
455
+ // リサイズ後にcanvasContextの再設定が必要かどうか
456
+ // ($resizeComplete()でcanvas.width/heightが設定された後、ensureMainTexture()でconfigure()を呼ぶ)
457
+ Object.defineProperty(this, "$needsReconfigure", {
458
+ enumerable: true,
459
+ configurable: true,
460
+ writable: true,
461
+ value: false
462
+ });
455
463
  // Hot Path 用の事前割り当てバッファ
456
464
  Object.defineProperty(this, "$uniformData8", {
457
465
  enumerable: true,
@@ -636,13 +644,9 @@ export class Context {
636
644
  this.currentRenderTarget = null;
637
645
  // マスク状態をリセット
638
646
  $resetMaskState();
639
- // キャンバスのサイズを更新
640
- const canvas = this.canvasContext.canvas;
641
- // 型チェックを安全に実行(Worker環境対応)
642
- if (canvas && "width" in canvas && "height" in canvas) {
643
- canvas.width = width;
644
- canvas.height = height;
645
- }
647
+ // キャンバスのサイズ更新は$resizeComplete()に任せる
648
+ // WebGPUではcanvas.width/height設定でコンテキストが暗黙的にunconfigureされるため、
649
+ // 描画フレーム開始前に$resizeComplete()→configure()→getCurrentTexture()の順で実行する
646
650
  // WebGL版と同じ: スタックにあるアタッチメントも解放
647
651
  if (this.$stackAttachmentObject.length) {
648
652
  for (let idx = 0; idx < this.$stackAttachmentObject.length; ++idx) {
@@ -686,12 +690,9 @@ export class Context {
686
690
  }
687
691
  // アンバインド(WebGL版と同じ)
688
692
  this.frameBufferManager.setCurrentAttachment(null);
689
- // canvasContextを再設定
690
- this.canvasContext.configure({
691
- "device": this.device,
692
- "format": this.preferredFormat,
693
- "alphaMode": "premultiplied"
694
- });
693
+ // canvasContextの再設定はensureMainTexture()で行う
694
+ // $resizeComplete()でcanvas.width/heightが設定された後にconfigure()→getCurrentTexture()を実行するため
695
+ this.$needsReconfigure = true;
695
696
  // リサイズ時にスワップチェーンテクスチャをリセット
696
697
  // 古いテクスチャ参照を解放して、次のフレームで新しいサイズのテクスチャを取得
697
698
  this.mainTexture = null;
@@ -2014,6 +2015,16 @@ export class Context {
2014
2015
  */
2015
2016
  ensureMainTexture() {
2016
2017
  if (!this.mainTexture) {
2018
+ // リサイズ後はcanvas.width/heightが$resizeComplete()で更新されているので
2019
+ // ここでconfigure()を呼んでからgetCurrentTexture()を取得する
2020
+ if (this.$needsReconfigure) {
2021
+ this.canvasContext.configure({
2022
+ "device": this.device,
2023
+ "format": this.preferredFormat,
2024
+ "alphaMode": "premultiplied"
2025
+ });
2026
+ this.$needsReconfigure = false;
2027
+ }
2017
2028
  this.mainTexture = this.canvasContext.getCurrentTexture();
2018
2029
  this.mainTextureView = this.mainTexture.createView();
2019
2030
  }