@babylonjs/core 8.18.0 → 8.19.1

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.
Files changed (100) hide show
  1. package/Collisions/intersectionInfo.d.ts +1 -0
  2. package/Collisions/intersectionInfo.js +1 -0
  3. package/Collisions/intersectionInfo.js.map +1 -1
  4. package/Compute/computeShader.d.ts +7 -0
  5. package/Compute/computeShader.js +15 -0
  6. package/Compute/computeShader.js.map +1 -1
  7. package/Engines/Extensions/engine.computeShader.d.ts +2 -1
  8. package/Engines/Extensions/engine.computeShader.js +1 -0
  9. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  10. package/Engines/IDrawContext.d.ts +31 -1
  11. package/Engines/IDrawContext.js.map +1 -1
  12. package/Engines/IMaterialContext.d.ts +1 -0
  13. package/Engines/IMaterialContext.js.map +1 -1
  14. package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -1
  15. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -2
  16. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  17. package/Engines/WebGPU/webgpuComputeContext.js +15 -0
  18. package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
  19. package/Engines/WebGPU/webgpuDrawContext.d.ts +48 -3
  20. package/Engines/WebGPU/webgpuDrawContext.js +81 -13
  21. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  22. package/Engines/WebGPU/webgpuMaterialContext.d.ts +1 -0
  23. package/Engines/WebGPU/webgpuMaterialContext.js +1 -0
  24. package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
  25. package/Engines/WebGPU/webgpuStencilStateComposer.js +7 -3
  26. package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
  27. package/Engines/abstractEngine.d.ts +4 -1
  28. package/Engines/abstractEngine.js +2 -2
  29. package/Engines/abstractEngine.js.map +1 -1
  30. package/Engines/engine.d.ts +2 -2
  31. package/Engines/nativeEngine.d.ts +1 -1
  32. package/Engines/nativeEngine.js +2 -2
  33. package/Engines/nativeEngine.js.map +1 -1
  34. package/Engines/renderTargetWrapper.d.ts +8 -0
  35. package/Engines/renderTargetWrapper.js +8 -0
  36. package/Engines/renderTargetWrapper.js.map +1 -1
  37. package/Engines/thinEngine.d.ts +2 -3
  38. package/Engines/thinEngine.js +3 -2
  39. package/Engines/thinEngine.js.map +1 -1
  40. package/Engines/webgpuEngine.d.ts +7 -4
  41. package/Engines/webgpuEngine.js +28 -15
  42. package/Engines/webgpuEngine.js.map +1 -1
  43. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +1 -1
  44. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  45. package/FrameGraph/Passes/renderPass.d.ts +8 -0
  46. package/FrameGraph/Passes/renderPass.js +10 -1
  47. package/FrameGraph/Passes/renderPass.js.map +1 -1
  48. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +46 -2
  49. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +62 -15
  50. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  51. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +4 -0
  52. package/FrameGraph/Tasks/Texture/clearTextureTask.js +5 -1
  53. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  54. package/FrameGraph/frameGraphRenderContext.d.ts +14 -5
  55. package/FrameGraph/frameGraphRenderContext.js +34 -14
  56. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  57. package/FrameGraph/frameGraphTextureManager.d.ts +3 -1
  58. package/FrameGraph/frameGraphTextureManager.js +16 -10
  59. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  60. package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +1 -0
  61. package/Materials/Node/Blocks/PBR/reflectionBlock.js +4 -1
  62. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  63. package/Materials/Node/nodeMaterial.js +7 -0
  64. package/Materials/Node/nodeMaterial.js.map +1 -1
  65. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
  66. package/Materials/PBR/pbrBaseMaterial.js +8 -6
  67. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  68. package/Materials/drawWrapper.d.ts +34 -2
  69. package/Materials/drawWrapper.js +22 -2
  70. package/Materials/drawWrapper.js.map +1 -1
  71. package/Materials/effectRenderer.d.ts +4 -0
  72. package/Materials/effectRenderer.js +2 -1
  73. package/Materials/effectRenderer.js.map +1 -1
  74. package/Materials/index.d.ts +1 -0
  75. package/Materials/index.js +1 -0
  76. package/Materials/index.js.map +1 -1
  77. package/Materials/material.d.ts +8 -1
  78. package/Materials/material.js +21 -1
  79. package/Materials/material.js.map +1 -1
  80. package/Materials/materialHelper.functions.d.ts +3 -1
  81. package/Materials/materialHelper.functions.js +7 -1
  82. package/Materials/materialHelper.functions.js.map +1 -1
  83. package/Materials/shaderMaterial.js +11 -0
  84. package/Materials/shaderMaterial.js.map +1 -1
  85. package/Materials/standardMaterial.d.ts +1 -0
  86. package/Materials/standardMaterial.js +2 -1
  87. package/Materials/standardMaterial.js.map +1 -1
  88. package/Materials/uniformBuffer.d.ts +6 -0
  89. package/Materials/uniformBuffer.js +8 -0
  90. package/Materials/uniformBuffer.js.map +1 -1
  91. package/Meshes/abstractMesh.js +3 -2
  92. package/Meshes/abstractMesh.js.map +1 -1
  93. package/Meshes/mesh.js +6 -0
  94. package/Meshes/mesh.js.map +1 -1
  95. package/Misc/fileTools.js +1 -1
  96. package/Misc/fileTools.js.map +1 -1
  97. package/States/index.d.ts +1 -0
  98. package/States/index.js +1 -0
  99. package/States/index.js.map +1 -1
  100. package/package.json +1 -1
@@ -1,13 +1,29 @@
1
+ import type { VertexBuffer } from "../../Buffers/buffer.js";
2
+ import type { DataBuffer } from "../../Buffers/dataBuffer.js";
1
3
  import type { WebGPUDataBuffer } from "../../Meshes/WebGPU/webgpuDataBuffer.js";
2
4
  import type { Nullable } from "../../types.js";
3
5
  import type { IDrawContext } from "../IDrawContext.js";
4
6
  import type { WebGPUBufferManager } from "./webgpuBufferManager.js";
5
- /** @internal */
7
+ import type { WebGPUPipelineContext } from "./webgpuPipelineContext.js";
8
+ /**
9
+ * WebGPU implementation of the IDrawContext interface.
10
+ * This class manages the draw context for WebGPU, including buffers and indirect draw data.
11
+ */
6
12
  export declare class WebGPUDrawContext implements IDrawContext {
13
+ private _dummyIndexBuffer;
7
14
  private static _Counter;
15
+ /**
16
+ * Bundle used in fast mode (when compatibilityMode==false)
17
+ */
8
18
  fastBundle?: GPURenderBundle;
19
+ /**
20
+ * Cache of the bind groups. Will be reused for the next draw if isDirty==false (and materialContext.isDirty==false)
21
+ */
9
22
  bindGroups?: GPUBindGroup[];
10
23
  uniqueId: number;
24
+ /**
25
+ * Buffers (uniform / storage) used for the draw call
26
+ */
11
27
  buffers: {
12
28
  [name: string]: Nullable<WebGPUDataBuffer>;
13
29
  };
@@ -18,13 +34,42 @@ export declare class WebGPUDrawContext implements IDrawContext {
18
34
  private _indirectDrawData?;
19
35
  private _currentInstanceCount;
20
36
  private _isDirty;
37
+ private _enableIndirectDraw;
38
+ private _vertexPullingEnabled;
39
+ /**
40
+ * Checks if the draw context is dirty.
41
+ * @param materialContextUpdateId The update ID of the material context associated with the draw context.
42
+ * @returns True if the draw or material context is dirty, false otherwise.
43
+ */
21
44
  isDirty(materialContextUpdateId: number): boolean;
45
+ /**
46
+ * Resets the dirty state of the draw context.
47
+ * @param materialContextUpdateId The update ID of the material context associated with the draw context.
48
+ */
22
49
  resetIsDirty(materialContextUpdateId: number): void;
50
+ get enableIndirectDraw(): boolean;
51
+ set enableIndirectDraw(enable: boolean);
23
52
  get useInstancing(): boolean;
24
53
  set useInstancing(use: boolean);
25
- constructor(bufferManager: WebGPUBufferManager);
54
+ /**
55
+ * Creates a new WebGPUDrawContext.
56
+ * @param bufferManager The buffer manager used to manage WebGPU buffers.
57
+ * @param _dummyIndexBuffer A dummy index buffer to be bound as the "indices"
58
+ * storage buffer when no index buffer is provided.
59
+ */
60
+ constructor(bufferManager: WebGPUBufferManager, _dummyIndexBuffer: WebGPUDataBuffer);
26
61
  reset(): void;
62
+ /**
63
+ * Associates a buffer to the draw context.
64
+ * @param name The name of the buffer.
65
+ * @param buffer The buffer to set.
66
+ */
27
67
  setBuffer(name: string, buffer: Nullable<WebGPUDataBuffer>): void;
28
- setIndirectData(indexOrVertexCount: number, instanceCount: number, firstIndexOrVertex: number): void;
68
+ setIndirectData(indexOrVertexCount: number, instanceCount: number, firstIndexOrVertex: number, forceUpdate?: boolean): void;
69
+ setVertexPulling(useVertexPulling: boolean, webgpuPipelineContext: WebGPUPipelineContext, vertexBuffers: {
70
+ [key: string]: Nullable<VertexBuffer>;
71
+ }, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
72
+ [kind: string]: Nullable<VertexBuffer>;
73
+ }>): void;
29
74
  dispose(): void;
30
75
  }
@@ -1,41 +1,70 @@
1
1
  import * as WebGPUConstants from "./webgpuConstants.js";
2
- /** @internal */
2
+ /**
3
+ * WebGPU implementation of the IDrawContext interface.
4
+ * This class manages the draw context for WebGPU, including buffers and indirect draw data.
5
+ */
3
6
  export class WebGPUDrawContext {
7
+ /**
8
+ * Checks if the draw context is dirty.
9
+ * @param materialContextUpdateId The update ID of the material context associated with the draw context.
10
+ * @returns True if the draw or material context is dirty, false otherwise.
11
+ */
4
12
  isDirty(materialContextUpdateId) {
5
13
  return this._isDirty || this._materialContextUpdateId !== materialContextUpdateId;
6
14
  }
15
+ /**
16
+ * Resets the dirty state of the draw context.
17
+ * @param materialContextUpdateId The update ID of the material context associated with the draw context.
18
+ */
7
19
  resetIsDirty(materialContextUpdateId) {
8
20
  this._isDirty = false;
9
21
  this._materialContextUpdateId = materialContextUpdateId;
10
22
  }
11
- get useInstancing() {
12
- return this._useInstancing;
23
+ get enableIndirectDraw() {
24
+ return this._enableIndirectDraw;
13
25
  }
14
- set useInstancing(use) {
15
- if (this._useInstancing === use) {
26
+ set enableIndirectDraw(enable) {
27
+ if (this._enableIndirectDraw === enable) {
16
28
  return;
17
29
  }
18
- if (!use) {
19
- if (this.indirectDrawBuffer) {
20
- this._bufferManager.releaseBuffer(this.indirectDrawBuffer);
21
- }
30
+ this._enableIndirectDraw = enable;
31
+ if (!enable && !this._useInstancing && this.indirectDrawBuffer) {
32
+ this._bufferManager.releaseBuffer(this.indirectDrawBuffer);
22
33
  this.indirectDrawBuffer = undefined;
23
34
  this._indirectDrawData = undefined;
24
35
  }
25
- else {
36
+ else if (enable && !this.indirectDrawBuffer) {
26
37
  this.indirectDrawBuffer = this._bufferManager.createRawBuffer(20, WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.Indirect | WebGPUConstants.BufferUsage.Storage, undefined, "IndirectDrawBuffer");
27
38
  this._indirectDrawData = new Uint32Array(5);
28
39
  this._indirectDrawData[3] = 0;
29
40
  this._indirectDrawData[4] = 0;
30
41
  }
42
+ }
43
+ get useInstancing() {
44
+ return this._useInstancing;
45
+ }
46
+ set useInstancing(use) {
47
+ if (this._useInstancing === use) {
48
+ return;
49
+ }
31
50
  this._useInstancing = use;
32
51
  this._currentInstanceCount = -1;
52
+ this.enableIndirectDraw = use;
33
53
  }
34
- constructor(bufferManager) {
54
+ /**
55
+ * Creates a new WebGPUDrawContext.
56
+ * @param bufferManager The buffer manager used to manage WebGPU buffers.
57
+ * @param _dummyIndexBuffer A dummy index buffer to be bound as the "indices"
58
+ * storage buffer when no index buffer is provided.
59
+ */
60
+ constructor(bufferManager, _dummyIndexBuffer) {
61
+ this._dummyIndexBuffer = _dummyIndexBuffer;
35
62
  this._bufferManager = bufferManager;
36
63
  this.uniqueId = WebGPUDrawContext._Counter++;
37
64
  this._useInstancing = false;
38
65
  this._currentInstanceCount = 0;
66
+ this._enableIndirectDraw = false;
67
+ this._vertexPullingEnabled = false;
39
68
  this.reset();
40
69
  }
41
70
  reset() {
@@ -44,13 +73,19 @@ export class WebGPUDrawContext {
44
73
  this._materialContextUpdateId = 0;
45
74
  this.fastBundle = undefined;
46
75
  this.bindGroups = undefined;
76
+ this._vertexPullingEnabled = false;
47
77
  }
78
+ /**
79
+ * Associates a buffer to the draw context.
80
+ * @param name The name of the buffer.
81
+ * @param buffer The buffer to set.
82
+ */
48
83
  setBuffer(name, buffer) {
49
84
  this._isDirty || (this._isDirty = buffer?.uniqueId !== this.buffers[name]?.uniqueId);
50
85
  this.buffers[name] = buffer;
51
86
  }
52
- setIndirectData(indexOrVertexCount, instanceCount, firstIndexOrVertex) {
53
- if (instanceCount === this._currentInstanceCount || !this.indirectDrawBuffer || !this._indirectDrawData) {
87
+ setIndirectData(indexOrVertexCount, instanceCount, firstIndexOrVertex, forceUpdate = false) {
88
+ if ((!forceUpdate && instanceCount === this._currentInstanceCount) || !this.indirectDrawBuffer || !this._indirectDrawData) {
54
89
  // The current buffer is already up to date so do nothing
55
90
  // Note that we only check for instanceCount and not indexOrVertexCount nor firstIndexOrVertex because those values
56
91
  // are supposed to not change during the lifetime of a draw context
@@ -62,6 +97,38 @@ export class WebGPUDrawContext {
62
97
  this._indirectDrawData[2] = firstIndexOrVertex;
63
98
  this._bufferManager.setRawData(this.indirectDrawBuffer, 0, this._indirectDrawData, 0, 20);
64
99
  }
100
+ setVertexPulling(useVertexPulling, webgpuPipelineContext, vertexBuffers, indexBuffer, overrideVertexBuffers) {
101
+ if (this._vertexPullingEnabled === useVertexPulling) {
102
+ return;
103
+ }
104
+ this._vertexPullingEnabled = useVertexPulling;
105
+ this._isDirty = true;
106
+ const bufferNames = webgpuPipelineContext.shaderProcessingContext.bufferNames;
107
+ if (overrideVertexBuffers) {
108
+ for (const attributeName in overrideVertexBuffers) {
109
+ const vertexBuffer = overrideVertexBuffers[attributeName];
110
+ if (!vertexBuffer || bufferNames.indexOf(attributeName) === -1) {
111
+ continue;
112
+ }
113
+ const buffer = vertexBuffer.effectiveBuffer;
114
+ this.setBuffer(attributeName, useVertexPulling ? buffer : null);
115
+ }
116
+ }
117
+ for (const attributeName in vertexBuffers) {
118
+ if (overrideVertexBuffers && attributeName in overrideVertexBuffers) {
119
+ continue;
120
+ }
121
+ const vertexBuffer = vertexBuffers[attributeName];
122
+ if (!vertexBuffer || bufferNames.indexOf(attributeName) === -1) {
123
+ continue;
124
+ }
125
+ const buffer = vertexBuffer.effectiveBuffer;
126
+ this.setBuffer(attributeName, useVertexPulling ? buffer : null);
127
+ }
128
+ if (bufferNames.indexOf("indices") !== -1) {
129
+ this.setBuffer("indices", !useVertexPulling ? null : (indexBuffer ?? this._dummyIndexBuffer));
130
+ }
131
+ }
65
132
  dispose() {
66
133
  if (this.indirectDrawBuffer) {
67
134
  this._bufferManager.releaseBuffer(this.indirectDrawBuffer);
@@ -71,6 +138,7 @@ export class WebGPUDrawContext {
71
138
  this.fastBundle = undefined;
72
139
  this.bindGroups = undefined;
73
140
  this.buffers = undefined;
141
+ this._enableIndirectDraw = false;
74
142
  }
75
143
  }
76
144
  WebGPUDrawContext._Counter = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpuDrawContext.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuDrawContext.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD,gBAAgB;AAChB,MAAM,OAAO,iBAAiB;IAmBnB,OAAO,CAAC,uBAA+B;QAC1C,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,wBAAwB,KAAK,uBAAuB,CAAC;IACtF,CAAC;IAEM,YAAY,CAAC,uBAA+B;QAC/C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,wBAAwB,GAAG,uBAAuB,CAAC;IAC5D,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,IAAW,aAAa,CAAC,GAAY;QACjC,IAAI,IAAI,CAAC,cAAc,KAAK,GAAG,EAAE,CAAC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I,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,SAAgB,CAAC;IACpC,CAAC;;AAzGc,0BAAQ,GAAG,CAAC,CAAC","sourcesContent":["import type { WebGPUDataBuffer } from \"../../Meshes/WebGPU/webgpuDataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IDrawContext } from \"../IDrawContext\";\r\nimport type { WebGPUBufferManager } from \"./webgpuBufferManager\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\n\r\n/** @internal */\r\nexport class WebGPUDrawContext implements IDrawContext {\r\n private static _Counter = 0;\r\n\r\n public fastBundle?: GPURenderBundle; // used only when compatibilityMode==false (fast mode)\r\n public bindGroups?: GPUBindGroup[]; // cache of the bind groups. Will be reused for the next draw if isDirty==false (and materialContext.isDirty==false)\r\n\r\n public uniqueId: number;\r\n\r\n public buffers: { [name: string]: Nullable<WebGPUDataBuffer> };\r\n\r\n public indirectDrawBuffer?: GPUBuffer;\r\n\r\n private _materialContextUpdateId: number;\r\n private _bufferManager: WebGPUBufferManager;\r\n private _useInstancing: boolean;\r\n private _indirectDrawData?: Uint32Array;\r\n private _currentInstanceCount: number;\r\n private _isDirty: boolean;\r\n\r\n public isDirty(materialContextUpdateId: number): boolean {\r\n return this._isDirty || this._materialContextUpdateId !== materialContextUpdateId;\r\n }\r\n\r\n public resetIsDirty(materialContextUpdateId: number): void {\r\n this._isDirty = false;\r\n this._materialContextUpdateId = materialContextUpdateId;\r\n }\r\n\r\n public get useInstancing() {\r\n return this._useInstancing;\r\n }\r\n\r\n public set useInstancing(use: boolean) {\r\n if (this._useInstancing === use) {\r\n return;\r\n }\r\n\r\n if (!use) {\r\n if (this.indirectDrawBuffer) {\r\n this._bufferManager.releaseBuffer(this.indirectDrawBuffer);\r\n }\r\n this.indirectDrawBuffer = undefined;\r\n this._indirectDrawData = undefined;\r\n } else {\r\n this.indirectDrawBuffer = this._bufferManager.createRawBuffer(\r\n 20,\r\n WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.Indirect | WebGPUConstants.BufferUsage.Storage,\r\n undefined,\r\n \"IndirectDrawBuffer\"\r\n );\r\n this._indirectDrawData = new Uint32Array(5);\r\n this._indirectDrawData[3] = 0;\r\n this._indirectDrawData[4] = 0;\r\n }\r\n\r\n this._useInstancing = use;\r\n this._currentInstanceCount = -1;\r\n }\r\n\r\n constructor(bufferManager: WebGPUBufferManager) {\r\n this._bufferManager = bufferManager;\r\n this.uniqueId = WebGPUDrawContext._Counter++;\r\n this._useInstancing = false;\r\n this._currentInstanceCount = 0;\r\n this.reset();\r\n }\r\n\r\n public reset(): void {\r\n this.buffers = {};\r\n this._isDirty = true;\r\n this._materialContextUpdateId = 0;\r\n this.fastBundle = undefined;\r\n this.bindGroups = undefined;\r\n }\r\n\r\n public setBuffer(name: string, buffer: Nullable<WebGPUDataBuffer>): void {\r\n this._isDirty ||= buffer?.uniqueId !== this.buffers[name]?.uniqueId;\r\n\r\n this.buffers[name] = buffer;\r\n }\r\n\r\n public setIndirectData(indexOrVertexCount: number, instanceCount: number, firstIndexOrVertex: number): void {\r\n if (instanceCount === this._currentInstanceCount || !this.indirectDrawBuffer || !this._indirectDrawData) {\r\n // The current buffer is already up to date so do nothing\r\n // Note that we only check for instanceCount and not indexOrVertexCount nor firstIndexOrVertex because those values\r\n // are supposed to not change during the lifetime of a draw context\r\n return;\r\n }\r\n this._currentInstanceCount = instanceCount;\r\n\r\n this._indirectDrawData[0] = indexOrVertexCount;\r\n this._indirectDrawData[1] = instanceCount;\r\n this._indirectDrawData[2] = firstIndexOrVertex;\r\n\r\n this._bufferManager.setRawData(this.indirectDrawBuffer, 0, this._indirectDrawData, 0, 20);\r\n }\r\n\r\n public dispose(): void {\r\n if (this.indirectDrawBuffer) {\r\n this._bufferManager.releaseBuffer(this.indirectDrawBuffer);\r\n this.indirectDrawBuffer = undefined;\r\n this._indirectDrawData = undefined;\r\n }\r\n this.fastBundle = undefined;\r\n this.bindGroups = undefined;\r\n this.buffers = undefined as any;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webgpuDrawContext.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuDrawContext.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IA8B1B;;;;OAIG;IACI,OAAO,CAAC,uBAA+B;QAC1C,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,wBAAwB,KAAK,uBAAuB,CAAC;IACtF,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,uBAA+B;QAC/C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,wBAAwB,GAAG,uBAAuB,CAAC;IAC5D,CAAC;IAED,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAED,IAAW,kBAAkB,CAAC,MAAe;QACzC,IAAI,IAAI,CAAC,mBAAmB,KAAK,MAAM,EAAE,CAAC;YACtC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;QAElC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC7D,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC3D,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;YACpC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACvC,CAAC;aAAM,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,CACzD,EAAE,EACF,eAAe,CAAC,WAAW,CAAC,OAAO,GAAG,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AC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,WAAgC,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACxH,CAAC;IACL,CAAC;IAEM,OAAO;QACV,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC3D,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;YACpC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACvC,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,SAAgB,CAAC;QAChC,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;IACrC,CAAC;;AA5Mc,0BAAQ,GAAG,CAAC,CAAC","sourcesContent":["import type { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport type { DataBuffer } from \"../../Buffers/dataBuffer\";\r\nimport type { WebGPUDataBuffer } from \"../../Meshes/WebGPU/webgpuDataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IDrawContext } from \"../IDrawContext\";\r\nimport type { WebGPUBufferManager } from \"./webgpuBufferManager\";\r\nimport type { WebGPUPipelineContext } from \"./webgpuPipelineContext\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\n\r\n/**\r\n * WebGPU implementation of the IDrawContext interface.\r\n * This class manages the draw context for WebGPU, including buffers and indirect draw data.\r\n */\r\nexport class WebGPUDrawContext implements IDrawContext {\r\n private static _Counter = 0;\r\n\r\n /**\r\n * Bundle used in fast mode (when compatibilityMode==false)\r\n */\r\n public fastBundle?: GPURenderBundle;\r\n /**\r\n * Cache of the bind groups. Will be reused for the next draw if isDirty==false (and materialContext.isDirty==false)\r\n */\r\n public bindGroups?: GPUBindGroup[];\r\n\r\n public uniqueId: number;\r\n\r\n /**\r\n * Buffers (uniform / storage) used for the draw call\r\n */\r\n public buffers: { [name: string]: Nullable<WebGPUDataBuffer> };\r\n\r\n public indirectDrawBuffer?: GPUBuffer;\r\n\r\n private _materialContextUpdateId: number;\r\n private _bufferManager: WebGPUBufferManager;\r\n private _useInstancing: boolean;\r\n private _indirectDrawData?: Uint32Array;\r\n private _currentInstanceCount: number;\r\n private _isDirty: boolean;\r\n private _enableIndirectDraw: boolean;\r\n private _vertexPullingEnabled: boolean;\r\n\r\n /**\r\n * Checks if the draw context is dirty.\r\n * @param materialContextUpdateId The update ID of the material context associated with the draw context.\r\n * @returns True if the draw or material context is dirty, false otherwise.\r\n */\r\n public isDirty(materialContextUpdateId: number): boolean {\r\n return this._isDirty || this._materialContextUpdateId !== materialContextUpdateId;\r\n }\r\n\r\n /**\r\n * Resets the dirty state of the draw context.\r\n * @param materialContextUpdateId The update ID of the material context associated with the draw context.\r\n */\r\n public resetIsDirty(materialContextUpdateId: number): void {\r\n this._isDirty = false;\r\n this._materialContextUpdateId = materialContextUpdateId;\r\n }\r\n\r\n public get enableIndirectDraw() {\r\n return this._enableIndirectDraw;\r\n }\r\n\r\n public set enableIndirectDraw(enable: boolean) {\r\n if (this._enableIndirectDraw === enable) {\r\n return;\r\n }\r\n\r\n this._enableIndirectDraw = enable;\r\n\r\n if (!enable && !this._useInstancing && this.indirectDrawBuffer) {\r\n this._bufferManager.releaseBuffer(this.indirectDrawBuffer);\r\n this.indirectDrawBuffer = undefined;\r\n this._indirectDrawData = undefined;\r\n } else if (enable && !this.indirectDrawBuffer) {\r\n this.indirectDrawBuffer = this._bufferManager.createRawBuffer(\r\n 20,\r\n WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.Indirect | WebGPUConstants.BufferUsage.Storage,\r\n undefined,\r\n \"IndirectDrawBuffer\"\r\n );\r\n this._indirectDrawData = new Uint32Array(5);\r\n this._indirectDrawData[3] = 0;\r\n this._indirectDrawData[4] = 0;\r\n }\r\n }\r\n\r\n public get useInstancing() {\r\n return this._useInstancing;\r\n }\r\n\r\n public set useInstancing(use: boolean) {\r\n if (this._useInstancing === use) {\r\n return;\r\n }\r\n\r\n this._useInstancing = use;\r\n this._currentInstanceCount = -1;\r\n\r\n this.enableIndirectDraw = use;\r\n }\r\n\r\n /**\r\n * Creates a new WebGPUDrawContext.\r\n * @param bufferManager The buffer manager used to manage WebGPU buffers.\r\n * @param _dummyIndexBuffer A dummy index buffer to be bound as the \"indices\"\r\n * storage buffer when no index buffer is provided.\r\n */\r\n constructor(\r\n bufferManager: WebGPUBufferManager,\r\n private _dummyIndexBuffer: WebGPUDataBuffer\r\n ) {\r\n this._bufferManager = bufferManager;\r\n this.uniqueId = WebGPUDrawContext._Counter++;\r\n this._useInstancing = false;\r\n this._currentInstanceCount = 0;\r\n this._enableIndirectDraw = false;\r\n this._vertexPullingEnabled = false;\r\n this.reset();\r\n }\r\n\r\n public reset(): void {\r\n this.buffers = {};\r\n this._isDirty = true;\r\n this._materialContextUpdateId = 0;\r\n this.fastBundle = undefined;\r\n this.bindGroups = undefined;\r\n this._vertexPullingEnabled = false;\r\n }\r\n\r\n /**\r\n * Associates a buffer to the draw context.\r\n * @param name The name of the buffer.\r\n * @param buffer The buffer to set.\r\n */\r\n public setBuffer(name: string, buffer: Nullable<WebGPUDataBuffer>): void {\r\n this._isDirty ||= buffer?.uniqueId !== this.buffers[name]?.uniqueId;\r\n\r\n this.buffers[name] = buffer;\r\n }\r\n\r\n public setIndirectData(indexOrVertexCount: number, instanceCount: number, firstIndexOrVertex: number, forceUpdate = false): void {\r\n if ((!forceUpdate && instanceCount === this._currentInstanceCount) || !this.indirectDrawBuffer || !this._indirectDrawData) {\r\n // The current buffer is already up to date so do nothing\r\n // Note that we only check for instanceCount and not indexOrVertexCount nor firstIndexOrVertex because those values\r\n // are supposed to not change during the lifetime of a draw context\r\n return;\r\n }\r\n this._currentInstanceCount = instanceCount;\r\n\r\n this._indirectDrawData[0] = indexOrVertexCount;\r\n this._indirectDrawData[1] = instanceCount;\r\n this._indirectDrawData[2] = firstIndexOrVertex;\r\n\r\n this._bufferManager.setRawData(this.indirectDrawBuffer, 0, this._indirectDrawData, 0, 20);\r\n }\r\n\r\n public setVertexPulling(\r\n useVertexPulling: boolean,\r\n webgpuPipelineContext: WebGPUPipelineContext,\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> },\r\n indexBuffer: Nullable<DataBuffer>,\r\n overrideVertexBuffers: Nullable<{ [kind: string]: Nullable<VertexBuffer> }>\r\n ): void {\r\n if (this._vertexPullingEnabled === useVertexPulling) {\r\n return;\r\n }\r\n\r\n this._vertexPullingEnabled = useVertexPulling;\r\n this._isDirty = true;\r\n\r\n const bufferNames = webgpuPipelineContext.shaderProcessingContext.bufferNames;\r\n\r\n if (overrideVertexBuffers) {\r\n for (const attributeName in overrideVertexBuffers) {\r\n const vertexBuffer = overrideVertexBuffers[attributeName];\r\n if (!vertexBuffer || bufferNames.indexOf(attributeName) === -1) {\r\n continue;\r\n }\r\n\r\n const buffer = vertexBuffer.effectiveBuffer as Nullable<WebGPUDataBuffer>;\r\n\r\n this.setBuffer(attributeName, useVertexPulling ? buffer : null);\r\n }\r\n }\r\n\r\n for (const attributeName in vertexBuffers) {\r\n if (overrideVertexBuffers && attributeName in overrideVertexBuffers) {\r\n continue;\r\n }\r\n\r\n const vertexBuffer = vertexBuffers[attributeName];\r\n if (!vertexBuffer || bufferNames.indexOf(attributeName) === -1) {\r\n continue;\r\n }\r\n\r\n const buffer = vertexBuffer.effectiveBuffer as Nullable<WebGPUDataBuffer>;\r\n\r\n this.setBuffer(attributeName, useVertexPulling ? buffer : null);\r\n }\r\n\r\n if (bufferNames.indexOf(\"indices\") !== -1) {\r\n this.setBuffer(\"indices\", !useVertexPulling ? null : ((indexBuffer as WebGPUDataBuffer) ?? this._dummyIndexBuffer));\r\n }\r\n }\r\n\r\n public dispose(): void {\r\n if (this.indirectDrawBuffer) {\r\n this._bufferManager.releaseBuffer(this.indirectDrawBuffer);\r\n this.indirectDrawBuffer = undefined;\r\n this._indirectDrawData = undefined;\r\n }\r\n this.fastBundle = undefined;\r\n this.bindGroups = undefined;\r\n this.buffers = undefined as any;\r\n this._enableIndirectDraw = false;\r\n }\r\n}\r\n"]}
@@ -27,6 +27,7 @@ export declare class WebGPUMaterialContext implements IMaterialContext {
27
27
  [name: string]: Nullable<IWebGPUMaterialContextTextureCache>;
28
28
  };
29
29
  textureState: number;
30
+ useVertexPulling: boolean;
30
31
  get forceBindGroupCreation(): boolean;
31
32
  get hasFloatOrDepthTextures(): boolean;
32
33
  protected _numFloatOrDepthTextures: number;
@@ -14,6 +14,7 @@ export class WebGPUMaterialContext {
14
14
  return this._numFloatOrDepthTextures > 0;
15
15
  }
16
16
  constructor() {
17
+ this.useVertexPulling = false;
17
18
  this.uniqueId = WebGPUMaterialContext._Counter++;
18
19
  this.updateId = 0;
19
20
  this.textureState = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpuMaterialContext.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuMaterialContext.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,wCAAwC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAI3E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAe1D,gBAAgB;AAChB,MAAM,OAAO,qBAAqB;IAiB9B,IAAW,sBAAsB;QAC7B,gGAAgG;QAChG,iGAAiG;QACjG,OAAO,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,IAAW,uBAAuB;QAC9B,OAAO,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;IAC7C,CAAC;IAKD;QACI,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,YAA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/D,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,OAAO,KAAZ,IAAI,CAAC,OAAO,GAAK,OAAO,EAAC;IAC7B,CAAC;;AAxGc,8BAAQ,GAAG,CAAC,CAAC","sourcesContent":["/* eslint-disable babylonjs/available */\r\n/* eslint-disable jsdoc/require-jsdoc */\r\nimport { ExternalTexture } from \"../../Materials/Textures/externalTexture\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { TextureSampler } from \"../../Materials/Textures/textureSampler\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { IMaterialContext } from \"../IMaterialContext\";\r\nimport { WebGPUCacheSampler } from \"./webgpuCacheSampler\";\r\n\r\n/** @internal */\r\ninterface IWebGPUMaterialContextSamplerCache {\r\n sampler: Nullable<TextureSampler>;\r\n hashCode: number;\r\n}\r\n\r\n/** @internal */\r\ninterface IWebGPUMaterialContextTextureCache {\r\n texture: Nullable<InternalTexture | ExternalTexture>;\r\n isFloatOrDepthTexture: boolean;\r\n isExternalTexture: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport class WebGPUMaterialContext implements IMaterialContext {\r\n private static _Counter = 0;\r\n\r\n public uniqueId: number;\r\n public updateId: number;\r\n public isDirty: boolean;\r\n public samplers: { [name: string]: Nullable<IWebGPUMaterialContextSamplerCache> };\r\n public textures: { [name: string]: Nullable<IWebGPUMaterialContextTextureCache> };\r\n\r\n // The texture state is a bitfield where each bit is set if the texture is a float32 texture (calculated in @WebGPUEngine._draw).\r\n // Float32 textures must be handled differently because float filtering may not be supported by the underlying browser implementation.\r\n // In this case, we must configure the sampler as \"non filtering\", as well as set the texture sample type to \"unfilterable-float\" when creating the bind group layout.\r\n // When that happens, we end up with different bind group layouts (depending on which type of textures have been set in the material), that we must all store\r\n // in the WebGPUPipelineContext (see @WebGPUPipelineContext.bindGroupLayouts) for later retrieval in the bind group cache implementation (see @WebGPUCacheBindGroups.getBindGroups), thanks to this property.\r\n // There's the same problem with depth textures, where \"float\" filtering is not supported either.\r\n public textureState: number;\r\n\r\n public get forceBindGroupCreation() {\r\n // If there is at least one external texture to bind, we must recreate the bind groups each time\r\n // because we need to retrieve a new texture each frame (by calling device.importExternalTexture)\r\n return this._numExternalTextures > 0;\r\n }\r\n\r\n public get hasFloatOrDepthTextures() {\r\n return this._numFloatOrDepthTextures > 0;\r\n }\r\n\r\n protected _numFloatOrDepthTextures: number;\r\n protected _numExternalTextures: number;\r\n\r\n constructor() {\r\n this.uniqueId = WebGPUMaterialContext._Counter++;\r\n this.updateId = 0;\r\n this.textureState = 0;\r\n this.reset();\r\n }\r\n\r\n public reset(): void {\r\n this.samplers = {};\r\n this.textures = {};\r\n this.isDirty = true;\r\n this._numFloatOrDepthTextures = 0;\r\n this._numExternalTextures = 0;\r\n }\r\n\r\n public setSampler(name: string, sampler: Nullable<TextureSampler>): void {\r\n let samplerCache = this.samplers[name];\r\n let currentHashCode = -1;\r\n if (!samplerCache) {\r\n this.samplers[name] = samplerCache = { sampler, hashCode: 0 };\r\n } else {\r\n currentHashCode = samplerCache.hashCode;\r\n }\r\n\r\n samplerCache.sampler = sampler;\r\n samplerCache.hashCode = sampler ? WebGPUCacheSampler.GetSamplerHashCode(sampler) : 0;\r\n\r\n const isDirty = currentHashCode !== samplerCache.hashCode;\r\n if (isDirty) {\r\n this.updateId++;\r\n }\r\n\r\n this.isDirty ||= isDirty;\r\n }\r\n\r\n public setTexture(name: string, texture: Nullable<InternalTexture | ExternalTexture>): void {\r\n let textureCache = this.textures[name];\r\n let currentTextureId = -1;\r\n if (!textureCache) {\r\n this.textures[name] = textureCache = { texture, isFloatOrDepthTexture: false, isExternalTexture: false };\r\n } else {\r\n currentTextureId = textureCache.texture?.uniqueId ?? -1;\r\n }\r\n\r\n if (textureCache.isExternalTexture) {\r\n this._numExternalTextures--;\r\n }\r\n if (textureCache.isFloatOrDepthTexture) {\r\n this._numFloatOrDepthTextures--;\r\n }\r\n\r\n if (texture) {\r\n textureCache.isFloatOrDepthTexture =\r\n texture.type === Constants.TEXTURETYPE_FLOAT ||\r\n (texture.format >= Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 && texture.format <= Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8);\r\n textureCache.isExternalTexture = ExternalTexture.IsExternalTexture(texture);\r\n if (textureCache.isFloatOrDepthTexture) {\r\n this._numFloatOrDepthTextures++;\r\n }\r\n if (textureCache.isExternalTexture) {\r\n this._numExternalTextures++;\r\n }\r\n } else {\r\n textureCache.isFloatOrDepthTexture = false;\r\n textureCache.isExternalTexture = false;\r\n }\r\n\r\n textureCache.texture = texture;\r\n\r\n const isDirty = currentTextureId !== (texture?.uniqueId ?? -1);\r\n if (isDirty) {\r\n this.updateId++;\r\n }\r\n\r\n this.isDirty ||= isDirty;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webgpuMaterialContext.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuMaterialContext.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,wCAAwC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAI3E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAe1D,gBAAgB;AAChB,MAAM,OAAO,qBAAqB;IAmB9B,IAAW,sBAAsB;QAC7B,gGAAgG;QAChG,iGAAiG;QACjG,OAAO,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,IAAW,uBAAuB;QAC9B,OAAO,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;IAC7C,CAAC;IAKD;QAfO,qBAAgB,GAAG,KAAK,CAAC;QAgB5B,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC;QACjD,IAAI,CAAC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,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,OAAO,KAAZ,IAAI,CAAC,OAAO,GAAK,OAAO,EAAC;IAC7B,CAAC;;AA1Gc,8BAAQ,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["/* eslint-disable babylonjs/available */\r\n/* eslint-disable jsdoc/require-jsdoc */\r\nimport { ExternalTexture } from \"../../Materials/Textures/externalTexture\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { TextureSampler } from \"../../Materials/Textures/textureSampler\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { IMaterialContext } from \"../IMaterialContext\";\r\nimport { WebGPUCacheSampler } from \"./webgpuCacheSampler\";\r\n\r\n/** @internal */\r\ninterface IWebGPUMaterialContextSamplerCache {\r\n sampler: Nullable<TextureSampler>;\r\n hashCode: number;\r\n}\r\n\r\n/** @internal */\r\ninterface IWebGPUMaterialContextTextureCache {\r\n texture: Nullable<InternalTexture | ExternalTexture>;\r\n isFloatOrDepthTexture: boolean;\r\n isExternalTexture: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport class WebGPUMaterialContext implements IMaterialContext {\r\n private static _Counter = 0;\r\n\r\n public uniqueId: number;\r\n public updateId: number;\r\n public isDirty: boolean;\r\n public samplers: { [name: string]: Nullable<IWebGPUMaterialContextSamplerCache> };\r\n public textures: { [name: string]: Nullable<IWebGPUMaterialContextTextureCache> };\r\n\r\n // The texture state is a bitfield where each bit is set if the texture is a float32 texture (calculated in @WebGPUEngine._draw).\r\n // Float32 textures must be handled differently because float filtering may not be supported by the underlying browser implementation.\r\n // In this case, we must configure the sampler as \"non filtering\", as well as set the texture sample type to \"unfilterable-float\" when creating the bind group layout.\r\n // When that happens, we end up with different bind group layouts (depending on which type of textures have been set in the material), that we must all store\r\n // in the WebGPUPipelineContext (see @WebGPUPipelineContext.bindGroupLayouts) for later retrieval in the bind group cache implementation (see @WebGPUCacheBindGroups.getBindGroups), thanks to this property.\r\n // There's the same problem with depth textures, where \"float\" filtering is not supported either.\r\n public textureState: number;\r\n\r\n public useVertexPulling = false;\r\n\r\n public get forceBindGroupCreation() {\r\n // If there is at least one external texture to bind, we must recreate the bind groups each time\r\n // because we need to retrieve a new texture each frame (by calling device.importExternalTexture)\r\n return this._numExternalTextures > 0;\r\n }\r\n\r\n public get hasFloatOrDepthTextures() {\r\n return this._numFloatOrDepthTextures > 0;\r\n }\r\n\r\n protected _numFloatOrDepthTextures: number;\r\n protected _numExternalTextures: number;\r\n\r\n constructor() {\r\n this.uniqueId = WebGPUMaterialContext._Counter++;\r\n this.updateId = 0;\r\n this.textureState = 0;\r\n this.reset();\r\n }\r\n\r\n public reset(): void {\r\n this.samplers = {};\r\n this.textures = {};\r\n this.isDirty = true;\r\n this._numFloatOrDepthTextures = 0;\r\n this._numExternalTextures = 0;\r\n }\r\n\r\n public setSampler(name: string, sampler: Nullable<TextureSampler>): void {\r\n let samplerCache = this.samplers[name];\r\n let currentHashCode = -1;\r\n if (!samplerCache) {\r\n this.samplers[name] = samplerCache = { sampler, hashCode: 0 };\r\n } else {\r\n currentHashCode = samplerCache.hashCode;\r\n }\r\n\r\n samplerCache.sampler = sampler;\r\n samplerCache.hashCode = sampler ? WebGPUCacheSampler.GetSamplerHashCode(sampler) : 0;\r\n\r\n const isDirty = currentHashCode !== samplerCache.hashCode;\r\n if (isDirty) {\r\n this.updateId++;\r\n }\r\n\r\n this.isDirty ||= isDirty;\r\n }\r\n\r\n public setTexture(name: string, texture: Nullable<InternalTexture | ExternalTexture>): void {\r\n let textureCache = this.textures[name];\r\n let currentTextureId = -1;\r\n if (!textureCache) {\r\n this.textures[name] = textureCache = { texture, isFloatOrDepthTexture: false, isExternalTexture: false };\r\n } else {\r\n currentTextureId = textureCache.texture?.uniqueId ?? -1;\r\n }\r\n\r\n if (textureCache.isExternalTexture) {\r\n this._numExternalTextures--;\r\n }\r\n if (textureCache.isFloatOrDepthTexture) {\r\n this._numFloatOrDepthTextures--;\r\n }\r\n\r\n if (texture) {\r\n textureCache.isFloatOrDepthTexture =\r\n texture.type === Constants.TEXTURETYPE_FLOAT ||\r\n (texture.format >= Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 && texture.format <= Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8);\r\n textureCache.isExternalTexture = ExternalTexture.IsExternalTexture(texture);\r\n if (textureCache.isFloatOrDepthTexture) {\r\n this._numFloatOrDepthTextures++;\r\n }\r\n if (textureCache.isExternalTexture) {\r\n this._numExternalTextures++;\r\n }\r\n } else {\r\n textureCache.isFloatOrDepthTexture = false;\r\n textureCache.isExternalTexture = false;\r\n }\r\n\r\n textureCache.texture = texture;\r\n\r\n const isDirty = currentTextureId !== (texture?.uniqueId ?? -1);\r\n if (isDirty) {\r\n this.updateId++;\r\n }\r\n\r\n this.isDirty ||= isDirty;\r\n }\r\n}\r\n"]}
@@ -123,18 +123,22 @@ export class WebGPUStencilStateComposer extends StencilStateComposer {
123
123
  this._cache.resetStencilState();
124
124
  }
125
125
  apply() {
126
- const stencilMaterialEnabled = this.stencilMaterial?.enabled;
126
+ const stencilMaterialEnabled = !this.useStencilGlobalOnly && !!this.stencilMaterial?.enabled;
127
127
  this.enabled = stencilMaterialEnabled ? this.stencilMaterial.enabled : this.stencilGlobal.enabled;
128
128
  if (!this.enabled) {
129
129
  return;
130
130
  }
131
- this.func = stencilMaterialEnabled ? this.stencilMaterial.func : this.stencilGlobal.func;
131
+ this.mask = stencilMaterialEnabled ? this.stencilMaterial.mask : this.stencilGlobal.mask;
132
132
  this.funcRef = stencilMaterialEnabled ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef;
133
133
  this.funcMask = stencilMaterialEnabled ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask;
134
+ this.func = stencilMaterialEnabled ? this.stencilMaterial.func : this.stencilGlobal.func;
134
135
  this.opStencilFail = stencilMaterialEnabled ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail;
135
136
  this.opDepthFail = stencilMaterialEnabled ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail;
136
137
  this.opStencilDepthPass = stencilMaterialEnabled ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass;
137
- this.mask = stencilMaterialEnabled ? this.stencilMaterial.mask : this.stencilGlobal.mask;
138
+ this.backFunc = stencilMaterialEnabled ? this.stencilMaterial.backFunc : this.stencilGlobal.backFunc;
139
+ this.backOpStencilFail = stencilMaterialEnabled ? this.stencilMaterial.backOpStencilFail : this.stencilGlobal.backOpStencilFail;
140
+ this.backOpDepthFail = stencilMaterialEnabled ? this.stencilMaterial.backOpDepthFail : this.stencilGlobal.backOpDepthFail;
141
+ this.backOpStencilDepthPass = stencilMaterialEnabled ? this.stencilMaterial.backOpStencilDepthPass : this.stencilGlobal.backOpStencilDepthPass;
138
142
  }
139
143
  }
140
144
  //# sourceMappingURL=webgpuStencilStateComposer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgpuStencilStateComposer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuStencilStateComposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE;;IAEI;AACJ,MAAM,OAAO,0BAA2B,SAAQ,oBAAoB;IAGhE,YAAmB,KAAgC;QAC/C,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAED,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAoB,IAAI,CAAC,KAAa;QAClC,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;YACvB,OAAO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,CAAC,eAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QACnG,IAAI,CAAC,QAAQ,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;QACtG,IAAI,CAAC,aAAa,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;QACrH,IAAI,CAAC,WAAW,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;QAC/G,IAAI,CAAC,kBAAkB,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC;QACpI,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;IAC9F,CAAC;CACJ","sourcesContent":["import type { WebGPUCacheRenderPipeline } from \"./webgpuCacheRenderPipeline\";\r\nimport { StencilStateComposer } from \"../../States/stencilStateComposer\";\r\n\r\n/**\r\n * @internal\r\n **/\r\nexport class WebGPUStencilStateComposer extends StencilStateComposer {\r\n private _cache: WebGPUCacheRenderPipeline;\r\n\r\n public constructor(cache: WebGPUCacheRenderPipeline) {\r\n super(false);\r\n this._cache = cache;\r\n this.reset();\r\n }\r\n\r\n public override get func(): number {\r\n return this._func;\r\n }\r\n\r\n public override set func(value: number) {\r\n if (this._func === value) {\r\n return;\r\n }\r\n\r\n this._func = value;\r\n this._cache.setStencilCompare(value);\r\n }\r\n\r\n public override get backFunc(): number {\r\n return this._backFunc;\r\n }\r\n\r\n public override set backFunc(value: number) {\r\n if (this._backFunc === value) {\r\n return;\r\n }\r\n\r\n this._backFunc = value;\r\n this._cache.setStencilBackCompare(value);\r\n }\r\n\r\n public override get funcMask(): number {\r\n return this._funcMask;\r\n }\r\n\r\n public override set funcMask(value: number) {\r\n if (this._funcMask === value) {\r\n return;\r\n }\r\n\r\n this._funcMask = value;\r\n this._cache.setStencilReadMask(value);\r\n }\r\n\r\n public override get opStencilFail(): number {\r\n return this._opStencilFail;\r\n }\r\n\r\n public override set opStencilFail(value: number) {\r\n if (this._opStencilFail === value) {\r\n return;\r\n }\r\n\r\n this._opStencilFail = value;\r\n this._cache.setStencilFailOp(value);\r\n }\r\n\r\n public override get opDepthFail(): number {\r\n return this._opDepthFail;\r\n }\r\n\r\n public override set opDepthFail(value: number) {\r\n if (this._opDepthFail === value) {\r\n return;\r\n }\r\n\r\n this._opDepthFail = value;\r\n this._cache.setStencilDepthFailOp(value);\r\n }\r\n\r\n public override get opStencilDepthPass(): number {\r\n return this._opStencilDepthPass;\r\n }\r\n\r\n public override set opStencilDepthPass(value: number) {\r\n if (this._opStencilDepthPass === value) {\r\n return;\r\n }\r\n\r\n this._opStencilDepthPass = value;\r\n this._cache.setStencilPassOp(value);\r\n }\r\n\r\n public override get backOpStencilFail(): number {\r\n return this._backOpStencilFail;\r\n }\r\n\r\n public override set backOpStencilFail(value: number) {\r\n if (this._backOpStencilFail === value) {\r\n return;\r\n }\r\n\r\n this._backOpStencilFail = value;\r\n this._cache.setStencilBackFailOp(value);\r\n }\r\n\r\n public override get backOpDepthFail(): number {\r\n return this._backOpDepthFail;\r\n }\r\n\r\n public override set backOpDepthFail(value: number) {\r\n if (this._backOpDepthFail === value) {\r\n return;\r\n }\r\n\r\n this._backOpDepthFail = value;\r\n this._cache.setStencilBackDepthFailOp(value);\r\n }\r\n\r\n public override get backOpStencilDepthPass(): number {\r\n return this._backOpStencilDepthPass;\r\n }\r\n\r\n public override set backOpStencilDepthPass(value: number) {\r\n if (this._backOpStencilDepthPass === value) {\r\n return;\r\n }\r\n\r\n this._backOpStencilDepthPass = value;\r\n this._cache.setStencilBackPassOp(value);\r\n }\r\n\r\n public override get mask(): number {\r\n return this._mask;\r\n }\r\n\r\n public override set mask(value: number) {\r\n if (this._mask === value) {\r\n return;\r\n }\r\n\r\n this._mask = value;\r\n this._cache.setStencilWriteMask(value);\r\n }\r\n\r\n public override get enabled(): boolean {\r\n return this._enabled;\r\n }\r\n\r\n public override set enabled(value: boolean) {\r\n if (this._enabled === value) {\r\n return;\r\n }\r\n\r\n this._enabled = value;\r\n this._cache.setStencilEnabled(value);\r\n }\r\n\r\n public override reset() {\r\n super.reset();\r\n this._cache.resetStencilState();\r\n }\r\n\r\n public override apply() {\r\n const stencilMaterialEnabled = this.stencilMaterial?.enabled;\r\n\r\n this.enabled = stencilMaterialEnabled ? this.stencilMaterial!.enabled : this.stencilGlobal.enabled;\r\n if (!this.enabled) {\r\n return;\r\n }\r\n\r\n this.func = stencilMaterialEnabled ? this.stencilMaterial!.func : this.stencilGlobal.func;\r\n this.funcRef = stencilMaterialEnabled ? this.stencilMaterial!.funcRef : this.stencilGlobal.funcRef;\r\n this.funcMask = stencilMaterialEnabled ? this.stencilMaterial!.funcMask : this.stencilGlobal.funcMask;\r\n this.opStencilFail = stencilMaterialEnabled ? this.stencilMaterial!.opStencilFail : this.stencilGlobal.opStencilFail;\r\n this.opDepthFail = stencilMaterialEnabled ? this.stencilMaterial!.opDepthFail : this.stencilGlobal.opDepthFail;\r\n this.opStencilDepthPass = stencilMaterialEnabled ? this.stencilMaterial!.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass;\r\n this.mask = stencilMaterialEnabled ? this.stencilMaterial!.mask : this.stencilGlobal.mask;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webgpuStencilStateComposer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuStencilStateComposer.ts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AAC,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC;QACpI,IAAI,CAAC,QAAQ,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;QACtG,IAAI,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC;QACjI,IAAI,CAAC,eAAe,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC;QAC3H,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAgB,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAAC;IACpJ,CAAC;CACJ","sourcesContent":["import type { WebGPUCacheRenderPipeline } from \"./webgpuCacheRenderPipeline\";\r\nimport { StencilStateComposer } from \"../../States/stencilStateComposer\";\r\n\r\n/**\r\n * @internal\r\n **/\r\nexport class WebGPUStencilStateComposer extends StencilStateComposer {\r\n private _cache: WebGPUCacheRenderPipeline;\r\n\r\n public constructor(cache: WebGPUCacheRenderPipeline) {\r\n super(false);\r\n this._cache = cache;\r\n this.reset();\r\n }\r\n\r\n public override get func(): number {\r\n return this._func;\r\n }\r\n\r\n public override set func(value: number) {\r\n if (this._func === value) {\r\n return;\r\n }\r\n\r\n this._func = value;\r\n this._cache.setStencilCompare(value);\r\n }\r\n\r\n public override get backFunc(): number {\r\n return this._backFunc;\r\n }\r\n\r\n public override set backFunc(value: number) {\r\n if (this._backFunc === value) {\r\n return;\r\n }\r\n\r\n this._backFunc = value;\r\n this._cache.setStencilBackCompare(value);\r\n }\r\n\r\n public override get funcMask(): number {\r\n return this._funcMask;\r\n }\r\n\r\n public override set funcMask(value: number) {\r\n if (this._funcMask === value) {\r\n return;\r\n }\r\n\r\n this._funcMask = value;\r\n this._cache.setStencilReadMask(value);\r\n }\r\n\r\n public override get opStencilFail(): number {\r\n return this._opStencilFail;\r\n }\r\n\r\n public override set opStencilFail(value: number) {\r\n if (this._opStencilFail === value) {\r\n return;\r\n }\r\n\r\n this._opStencilFail = value;\r\n this._cache.setStencilFailOp(value);\r\n }\r\n\r\n public override get opDepthFail(): number {\r\n return this._opDepthFail;\r\n }\r\n\r\n public override set opDepthFail(value: number) {\r\n if (this._opDepthFail === value) {\r\n return;\r\n }\r\n\r\n this._opDepthFail = value;\r\n this._cache.setStencilDepthFailOp(value);\r\n }\r\n\r\n public override get opStencilDepthPass(): number {\r\n return this._opStencilDepthPass;\r\n }\r\n\r\n public override set opStencilDepthPass(value: number) {\r\n if (this._opStencilDepthPass === value) {\r\n return;\r\n }\r\n\r\n this._opStencilDepthPass = value;\r\n this._cache.setStencilPassOp(value);\r\n }\r\n\r\n public override get backOpStencilFail(): number {\r\n return this._backOpStencilFail;\r\n }\r\n\r\n public override set backOpStencilFail(value: number) {\r\n if (this._backOpStencilFail === value) {\r\n return;\r\n }\r\n\r\n this._backOpStencilFail = value;\r\n this._cache.setStencilBackFailOp(value);\r\n }\r\n\r\n public override get backOpDepthFail(): number {\r\n return this._backOpDepthFail;\r\n }\r\n\r\n public override set backOpDepthFail(value: number) {\r\n if (this._backOpDepthFail === value) {\r\n return;\r\n }\r\n\r\n this._backOpDepthFail = value;\r\n this._cache.setStencilBackDepthFailOp(value);\r\n }\r\n\r\n public override get backOpStencilDepthPass(): number {\r\n return this._backOpStencilDepthPass;\r\n }\r\n\r\n public override set backOpStencilDepthPass(value: number) {\r\n if (this._backOpStencilDepthPass === value) {\r\n return;\r\n }\r\n\r\n this._backOpStencilDepthPass = value;\r\n this._cache.setStencilBackPassOp(value);\r\n }\r\n\r\n public override get mask(): number {\r\n return this._mask;\r\n }\r\n\r\n public override set mask(value: number) {\r\n if (this._mask === value) {\r\n return;\r\n }\r\n\r\n this._mask = value;\r\n this._cache.setStencilWriteMask(value);\r\n }\r\n\r\n public override get enabled(): boolean {\r\n return this._enabled;\r\n }\r\n\r\n public override set enabled(value: boolean) {\r\n if (this._enabled === value) {\r\n return;\r\n }\r\n\r\n this._enabled = value;\r\n this._cache.setStencilEnabled(value);\r\n }\r\n\r\n public override reset() {\r\n super.reset();\r\n this._cache.resetStencilState();\r\n }\r\n\r\n public override apply() {\r\n const stencilMaterialEnabled = !this.useStencilGlobalOnly && !!this.stencilMaterial?.enabled;\r\n\r\n this.enabled = stencilMaterialEnabled ? this.stencilMaterial!.enabled : this.stencilGlobal.enabled;\r\n if (!this.enabled) {\r\n return;\r\n }\r\n\r\n this.mask = stencilMaterialEnabled ? this.stencilMaterial!.mask : this.stencilGlobal.mask;\r\n this.funcRef = stencilMaterialEnabled ? this.stencilMaterial!.funcRef : this.stencilGlobal.funcRef;\r\n this.funcMask = stencilMaterialEnabled ? this.stencilMaterial!.funcMask : this.stencilGlobal.funcMask;\r\n this.func = stencilMaterialEnabled ? this.stencilMaterial!.func : this.stencilGlobal.func;\r\n this.opStencilFail = stencilMaterialEnabled ? this.stencilMaterial!.opStencilFail : this.stencilGlobal.opStencilFail;\r\n this.opDepthFail = stencilMaterialEnabled ? this.stencilMaterial!.opDepthFail : this.stencilGlobal.opDepthFail;\r\n this.opStencilDepthPass = stencilMaterialEnabled ? this.stencilMaterial!.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass;\r\n this.backFunc = stencilMaterialEnabled ? this.stencilMaterial!.backFunc : this.stencilGlobal.backFunc;\r\n this.backOpStencilFail = stencilMaterialEnabled ? this.stencilMaterial!.backOpStencilFail : this.stencilGlobal.backOpStencilFail;\r\n this.backOpDepthFail = stencilMaterialEnabled ? this.stencilMaterial!.backOpDepthFail : this.stencilGlobal.backOpDepthFail;\r\n this.backOpStencilDepthPass = stencilMaterialEnabled ? this.stencilMaterial!.backOpStencilDepthPass : this.stencilGlobal.backOpStencilDepthPass;\r\n }\r\n}\r\n"]}
@@ -191,6 +191,8 @@ export declare abstract class AbstractEngine {
191
191
  /** @internal */
192
192
  _currentDrawContext: IDrawContext;
193
193
  /** @internal */
194
+ _currentMaterialContext: IMaterialContext;
195
+ /** @internal */
194
196
  protected _boundTexturesCache: {
195
197
  [key: string]: Nullable<InternalTexture>;
196
198
  };
@@ -782,8 +784,9 @@ export declare abstract class AbstractEngine {
782
784
  * @param backBuffer defines if the back buffer must be cleared
783
785
  * @param depth defines if the depth buffer must be cleared
784
786
  * @param stencil defines if the stencil buffer must be cleared
787
+ * @param stencilClearValue defines the value to use to clear the stencil buffer
785
788
  */
786
- abstract clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
789
+ abstract clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue?: number): void;
787
790
  /**
788
791
  * Gets a boolean indicating that only power of 2 textures are supported
789
792
  * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
@@ -794,13 +794,13 @@ export class AbstractEngine {
794
794
  */
795
795
  // Not mixed with Version for tooling purpose.
796
796
  static get NpmPackage() {
797
- return "babylonjs@8.18.0";
797
+ return "babylonjs@8.19.1";
798
798
  }
799
799
  /**
800
800
  * Returns the current version of the framework
801
801
  */
802
802
  static get Version() {
803
- return "8.18.0";
803
+ return "8.19.1";
804
804
  }
805
805
  /**
806
806
  * Gets the HTML canvas attached with the current webGL context