@babylonjs/core 5.57.0 → 6.0.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/Engines/WebGPU/Extensions/engine.multiRender.js +51 -8
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +4 -3
- package/Engines/WebGPU/webgpuHardwareTexture.js +23 -10
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +6 -14
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/engine.d.ts +5 -6
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +16 -8
- package/Engines/webgpuEngine.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +2 -0
- package/Lights/Shadows/shadowGenerator.js +11 -22
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Maths/math.vector.js +4 -2
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +13 -0
- package/Meshes/abstractMesh.js +20 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +4 -1
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +1 -1
- package/Particles/solidParticleSystem.js +1 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Physics/physicsEngineComponent.d.ts +1 -0
- package/Physics/physicsEngineComponent.js +1 -0
- package/Physics/physicsEngineComponent.js.map +1 -1
- package/Physics/physicsHelper.d.ts +12 -5
- package/Physics/physicsHelper.js +160 -90
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +9 -0
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +120 -77
- package/Physics/v2/IPhysicsEnginePlugin.js +119 -48
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +687 -0
- package/Physics/v2/Plugins/havokPlugin.js +1592 -0
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -0
- package/Physics/v2/Plugins/index.d.ts +1 -0
- package/Physics/v2/Plugins/index.js +1 -1
- package/Physics/v2/Plugins/index.js.map +1 -1
- package/Physics/v2/index.d.ts +1 -0
- package/Physics/v2/index.js +2 -0
- package/Physics/v2/index.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +9 -2
- package/Physics/v2/physicsAggregate.js +66 -31
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +51 -62
- package/Physics/v2/physicsBody.js +101 -128
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +57 -25
- package/Physics/v2/physicsConstraint.js +32 -15
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +0 -1
- package/Physics/v2/physicsEngine.js +0 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Physics/v2/physicsEngineComponent.d.ts +0 -10
- package/Physics/v2/physicsEngineComponent.js +0 -29
- package/Physics/v2/physicsEngineComponent.js.map +1 -1
- package/Physics/v2/physicsShape.d.ts +52 -11
- package/Physics/v2/physicsShape.js +80 -23
- package/Physics/v2/physicsShape.js.map +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,7 @@ WebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (rtWrapp
|
|
|
26
26
|
this._setColorFormat(this._mainRenderPassWrapper);
|
|
27
27
|
};
|
|
28
28
|
WebGPUEngine.prototype.createMultipleRenderTarget = function (size, options, initializeBuffers) {
|
|
29
|
-
var _a;
|
|
29
|
+
var _a, _b;
|
|
30
30
|
let generateMipMaps = false;
|
|
31
31
|
let generateDepthBuffer = true;
|
|
32
32
|
let generateStencilBuffer = false;
|
|
@@ -37,10 +37,15 @@ WebGPUEngine.prototype.createMultipleRenderTarget = function (size, options, ini
|
|
|
37
37
|
const defaultSamplingMode = 3;
|
|
38
38
|
const defaultUseSRGBBuffer = false;
|
|
39
39
|
const defaultFormat = 5;
|
|
40
|
+
const defaultTarget = 3553;
|
|
40
41
|
let types = new Array();
|
|
41
42
|
let samplingModes = new Array();
|
|
42
43
|
let useSRGBBuffers = new Array();
|
|
43
44
|
let formats = new Array();
|
|
45
|
+
let targets = new Array();
|
|
46
|
+
let faceIndex = new Array();
|
|
47
|
+
let layerIndex = new Array();
|
|
48
|
+
let layers = new Array();
|
|
44
49
|
const rtWrapper = this._createHardwareRenderTargetWrapper(true, false, size);
|
|
45
50
|
if (options !== undefined) {
|
|
46
51
|
generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
|
|
@@ -61,6 +66,18 @@ WebGPUEngine.prototype.createMultipleRenderTarget = function (size, options, ini
|
|
|
61
66
|
if (options.formats) {
|
|
62
67
|
formats = options.formats;
|
|
63
68
|
}
|
|
69
|
+
if (options.targetTypes) {
|
|
70
|
+
targets = options.targetTypes;
|
|
71
|
+
}
|
|
72
|
+
if (options.faceIndex) {
|
|
73
|
+
faceIndex = options.faceIndex;
|
|
74
|
+
}
|
|
75
|
+
if (options.layerIndex) {
|
|
76
|
+
layerIndex = options.layerIndex;
|
|
77
|
+
}
|
|
78
|
+
if (options.layerCounts) {
|
|
79
|
+
layers = options.layerCounts;
|
|
80
|
+
}
|
|
64
81
|
}
|
|
65
82
|
const width = size.width || size;
|
|
66
83
|
const height = size.height || size;
|
|
@@ -91,10 +108,12 @@ WebGPUEngine.prototype.createMultipleRenderTarget = function (size, options, ini
|
|
|
91
108
|
for (let i = 0; i < textureCount; i++) {
|
|
92
109
|
let samplingMode = samplingModes[i] || defaultSamplingMode;
|
|
93
110
|
let type = types[i] || defaultType;
|
|
94
|
-
const useSRGBBuffer = useSRGBBuffers[i] || defaultUseSRGBBuffer;
|
|
95
111
|
const format = formats[i] || defaultFormat;
|
|
112
|
+
const useSRGBBuffer = (useSRGBBuffers[i] || defaultUseSRGBBuffer) && this._caps.supportSRGBBuffers;
|
|
113
|
+
const target = targets[i] || defaultTarget;
|
|
114
|
+
const layerCount = (_b = layers[i]) !== null && _b !== void 0 ? _b : 1;
|
|
96
115
|
if (type === 1 && !this._caps.textureFloatLinearFiltering) {
|
|
97
|
-
// if floating point linear (
|
|
116
|
+
// if floating point linear (FLOAT) then force to NEAREST_SAMPLINGMODE
|
|
98
117
|
samplingMode = 1;
|
|
99
118
|
}
|
|
100
119
|
else if (type === 2 && !this._caps.textureHalfFloatLinearFiltering) {
|
|
@@ -105,10 +124,26 @@ WebGPUEngine.prototype.createMultipleRenderTarget = function (size, options, ini
|
|
|
105
124
|
type = 0;
|
|
106
125
|
Logger.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
|
|
107
126
|
}
|
|
108
|
-
const texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);
|
|
109
|
-
textures.push(texture);
|
|
110
127
|
attachments.push(i + 1);
|
|
111
128
|
defaultAttachments.push(initializeBuffers ? i + 1 : i === 0 ? 1 : 0);
|
|
129
|
+
if (target === -1) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);
|
|
133
|
+
textures[i] = texture;
|
|
134
|
+
switch (target) {
|
|
135
|
+
case 34067:
|
|
136
|
+
texture.isCube = true;
|
|
137
|
+
break;
|
|
138
|
+
case 32879:
|
|
139
|
+
texture.is3D = true;
|
|
140
|
+
texture.baseDepth = texture.depth = layerCount;
|
|
141
|
+
break;
|
|
142
|
+
case 35866:
|
|
143
|
+
texture.is2DArray = true;
|
|
144
|
+
texture.baseDepth = texture.depth = layerCount;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
112
147
|
texture.baseWidth = width;
|
|
113
148
|
texture.baseHeight = height;
|
|
114
149
|
texture.width = width;
|
|
@@ -127,10 +162,11 @@ WebGPUEngine.prototype.createMultipleRenderTarget = function (size, options, ini
|
|
|
127
162
|
}
|
|
128
163
|
if (depthStencilTexture) {
|
|
129
164
|
depthStencilTexture.incrementReferences();
|
|
130
|
-
textures
|
|
165
|
+
textures[textureCount] = depthStencilTexture;
|
|
131
166
|
this._internalTexturesCache.push(depthStencilTexture);
|
|
132
167
|
}
|
|
133
168
|
rtWrapper.setTextures(textures);
|
|
169
|
+
rtWrapper.setLayerAndFaceIndices(layerIndex, faceIndex);
|
|
134
170
|
return rtWrapper;
|
|
135
171
|
};
|
|
136
172
|
WebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function (rtWrapper, samples) {
|
|
@@ -144,13 +180,20 @@ WebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function (
|
|
|
144
180
|
samples = Math.min(samples, this.getCaps().maxMSAASamples);
|
|
145
181
|
for (let i = 0; i < count; ++i) {
|
|
146
182
|
const texture = rtWrapper.textures[i];
|
|
147
|
-
|
|
183
|
+
const gpuTextureWrapper = texture._hardwareTexture;
|
|
184
|
+
gpuTextureWrapper === null || gpuTextureWrapper === void 0 ? void 0 : gpuTextureWrapper.releaseMSAATexture();
|
|
185
|
+
}
|
|
186
|
+
// Note that rtWrapper.textures can't have null textures, lastTextureIsDepthTexture can't be true if rtWrapper._depthStencilTexture is null
|
|
187
|
+
const lastTextureIsDepthTexture = rtWrapper._depthStencilTexture === rtWrapper.textures[count - 1];
|
|
188
|
+
for (let i = 0; i < count; ++i) {
|
|
189
|
+
const texture = rtWrapper.textures[i];
|
|
190
|
+
this._textureHelper.createMSAATexture(texture, samples, false, i === count - 1 && lastTextureIsDepthTexture ? 0 : i);
|
|
148
191
|
texture.samples = samples;
|
|
149
192
|
}
|
|
150
193
|
// Note that the last texture of textures is the depth texture if the depth texture has been generated by the MRT class and so the MSAA texture
|
|
151
194
|
// will be recreated for this texture by the loop above: in that case, there's no need to create the MSAA texture for rtWrapper._depthStencilTexture
|
|
152
195
|
// because rtWrapper._depthStencilTexture is the same texture than the depth texture
|
|
153
|
-
if (rtWrapper._depthStencilTexture &&
|
|
196
|
+
if (rtWrapper._depthStencilTexture && !lastTextureIsDepthTexture) {
|
|
154
197
|
this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);
|
|
155
198
|
rtWrapper._depthStencilTexture.samples = samples;
|
|
156
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.multiRender.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/WebGPU/Extensions/engine.multiRender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,YAAY,CAAC,SAAS,CAAC,qCAAqC,GAAG,UAC3D,SAA8B,EAC9B,yBAAkC,KAAK,EACvC,cAA2B;IAE3B,IAAI,cAAc,EAAE;QAChB,cAAc,EAAE,CAAC;KACpB;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,YAAa,CAAC;IAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC;IAEjC,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI,CAAC,sBAAsB,CAAC,UAAU,EAAE;QAC/F,IAAI,CAAC,0BAA0B,EAAE,CAAC;KACrC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAG,SAAS,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,OAAO,CAAC,eAAe,IAAI,CAAC,sBAAsB,IAAI,CAAC,O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AClB,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,uBAAuB,GAAG;IAC7C,mKAAmK;AACvK,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,sCAAsC,GAAG;IAC5D,oJAAoJ;AACxJ,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IMultiRenderTargetOptions } from \"../../../Materials/Textures/multiRenderTarget\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\n\r\nWebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (\r\n rtWrapper: RenderTargetWrapper,\r\n disableGenerateMipMaps: boolean = false,\r\n onBeforeUnbind?: () => void\r\n): void {\r\n if (onBeforeUnbind) {\r\n onBeforeUnbind();\r\n }\r\n\r\n const attachments = rtWrapper._attachments!;\r\n const count = attachments.length;\r\n\r\n if (this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass) {\r\n this._endRenderTargetRenderPass();\r\n }\r\n\r\n for (let i = 0; i < count; i++) {\r\n const texture = rtWrapper.textures![i];\r\n if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {\r\n this._generateMipmaps(texture);\r\n }\r\n }\r\n\r\n this._currentRenderTarget = null;\r\n\r\n this._mrtAttachments = [];\r\n this._cacheRenderPipeline.setMRT([]);\r\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\r\n this._currentRenderPass = this._mainRenderPassWrapper.renderPass;\r\n this._setDepthTextureFormat(this._mainRenderPassWrapper);\r\n this._setColorFormat(this._mainRenderPassWrapper);\r\n};\r\n\r\nWebGPUEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): RenderTargetWrapper {\r\n let generateMipMaps = false;\r\n let generateDepthBuffer = true;\r\n let generateStencilBuffer = false;\r\n let generateDepthTexture = false;\r\n let depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH16;\r\n let textureCount = 1;\r\n\r\n const defaultType = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n const defaultSamplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n const defaultUseSRGBBuffer = false;\r\n const defaultFormat = Constants.TEXTUREFORMAT_RGBA;\r\n\r\n let types = new Array<number>();\r\n let samplingModes = new Array<number>();\r\n let useSRGBBuffers = new Array<boolean>();\r\n let formats = new Array<number>();\r\n\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(true, false, size) as WebGPURenderTargetWrapper;\r\n\r\n if (options !== undefined) {\r\n generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;\r\n generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;\r\n generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;\r\n textureCount = options.textureCount || 1;\r\n depthTextureFormat = options.depthTextureFormat ?? Constants.TEXTUREFORMAT_DEPTH16;\r\n\r\n if (options.types) {\r\n types = options.types;\r\n }\r\n if (options.samplingModes) {\r\n samplingModes = options.samplingModes;\r\n }\r\n if (options.useSRGBBuffers) {\r\n useSRGBBuffers = options.useSRGBBuffers;\r\n }\r\n if (options.formats) {\r\n formats = options.formats;\r\n }\r\n }\r\n\r\n const width = (<{ width: number; height: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number }>size).height || <number>size;\r\n\r\n let depthStencilTexture = null;\r\n if (generateDepthBuffer || generateStencilBuffer || generateDepthTexture) {\r\n if (!generateDepthTexture) {\r\n // The caller doesn't want a depth texture, so we are free to use the depth texture format we want.\r\n // So, we will align with what the WebGL engine does\r\n if (generateDepthBuffer && generateStencilBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\r\n } else if (generateDepthBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\r\n } else {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_STENCIL8;\r\n }\r\n }\r\n depthStencilTexture = rtWrapper.createDepthStencilTexture(0, false, generateStencilBuffer, 1, depthTextureFormat);\r\n }\r\n\r\n const textures: InternalTexture[] = [];\r\n const attachments: number[] = [];\r\n const defaultAttachments: number[] = [];\r\n\r\n rtWrapper._generateDepthBuffer = generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = generateStencilBuffer;\r\n rtWrapper._attachments = attachments;\r\n rtWrapper._defaultAttachments = defaultAttachments;\r\n\r\n for (let i = 0; i < textureCount; i++) {\r\n let samplingMode = samplingModes[i] || defaultSamplingMode;\r\n let type = types[i] || defaultType;\r\n const useSRGBBuffer = useSRGBBuffers[i] || defaultUseSRGBBuffer;\r\n const format = formats[i] || defaultFormat;\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {\r\n // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n Logger.Warn(\"Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type\");\r\n }\r\n\r\n const texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);\r\n\r\n textures.push(texture);\r\n attachments.push(i + 1);\r\n defaultAttachments.push(initializeBuffers ? i + 1 : i === 0 ? 1 : 0);\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n texture.samples = 1;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.type = type;\r\n texture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n texture.format = format;\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture);\r\n }\r\n\r\n if (depthStencilTexture) {\r\n depthStencilTexture.incrementReferences();\r\n textures.push(depthStencilTexture);\r\n this._internalTexturesCache.push(depthStencilTexture);\r\n }\r\n\r\n rtWrapper.setTextures(textures);\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.textures || rtWrapper.textures[0].samples === samples) {\r\n return samples;\r\n }\r\n\r\n const count = rtWrapper.textures.length;\r\n\r\n if (count === 0) {\r\n return 1;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n this._textureHelper.createMSAATexture(texture, samples);\r\n texture.samples = samples;\r\n }\r\n\r\n // Note that the last texture of textures is the depth texture if the depth texture has been generated by the MRT class and so the MSAA texture\r\n // will be recreated for this texture by the loop above: in that case, there's no need to create the MSAA texture for rtWrapper._depthStencilTexture\r\n // because rtWrapper._depthStencilTexture is the same texture than the depth texture\r\n if (rtWrapper._depthStencilTexture && rtWrapper._depthStencilTexture !== rtWrapper.textures[rtWrapper.textures.length - 1]) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n return samples;\r\n};\r\n\r\nWebGPUEngine.prototype.bindAttachments = function (attachments: number[]): void {\r\n if (attachments.length === 0 || !this._currentRenderTarget) {\r\n return;\r\n }\r\n\r\n this._mrtAttachments = attachments;\r\n if (this._currentRenderPass) {\r\n // the render pass has already been created, we need to call setMRTAttachments to update the state of the attachments\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n } else {\r\n // the render pass is not created yet so we don't need to call setMRTAttachments: it will be called as part of the render pass creation (see WebGPUEngine._startRenderTargetRenderPass)\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.buildTextureLayout = function (textureStatus: boolean[]): number[] {\r\n const result = [];\r\n\r\n for (let i = 0; i < textureStatus.length; i++) {\r\n if (textureStatus[i]) {\r\n result.push(i + 1);\r\n } else {\r\n result.push(0);\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachment = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachmentForRenderTarget are not called in Babylon.js so it's hard to know the use case\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachmentForRenderTarget = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachment are not called in Babylon.js so it's hard to know the use case\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"engine.multiRender.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/WebGPU/Extensions/engine.multiRender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;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EF,YAAY,CAAC,SAAS,CAAC,sCAAsC,GAAG;IAC5D,oJAAoJ;AACxJ,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IMultiRenderTargetOptions } from \"../../../Materials/Textures/multiRenderTarget\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\n\r\nWebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (\r\n rtWrapper: RenderTargetWrapper,\r\n disableGenerateMipMaps: boolean = false,\r\n onBeforeUnbind?: () => void\r\n): void {\r\n if (onBeforeUnbind) {\r\n onBeforeUnbind();\r\n }\r\n\r\n const attachments = rtWrapper._attachments!;\r\n const count = attachments.length;\r\n\r\n if (this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass) {\r\n this._endRenderTargetRenderPass();\r\n }\r\n\r\n for (let i = 0; i < count; i++) {\r\n const texture = rtWrapper.textures![i];\r\n if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {\r\n this._generateMipmaps(texture);\r\n }\r\n }\r\n\r\n this._currentRenderTarget = null;\r\n\r\n this._mrtAttachments = [];\r\n this._cacheRenderPipeline.setMRT([]);\r\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\r\n this._currentRenderPass = this._mainRenderPassWrapper.renderPass;\r\n this._setDepthTextureFormat(this._mainRenderPassWrapper);\r\n this._setColorFormat(this._mainRenderPassWrapper);\r\n};\r\n\r\nWebGPUEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): RenderTargetWrapper {\r\n let generateMipMaps = false;\r\n let generateDepthBuffer = true;\r\n let generateStencilBuffer = false;\r\n let generateDepthTexture = false;\r\n let depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH16;\r\n let textureCount = 1;\r\n\r\n const defaultType = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n const defaultSamplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n const defaultUseSRGBBuffer = false;\r\n const defaultFormat = Constants.TEXTUREFORMAT_RGBA;\r\n const defaultTarget = Constants.TEXTURE_2D;\r\n\r\n let types = new Array<number>();\r\n let samplingModes = new Array<number>();\r\n let useSRGBBuffers = new Array<boolean>();\r\n let formats = new Array<number>();\r\n let targets = new Array<number>();\r\n let faceIndex = new Array<number>();\r\n let layerIndex = new Array<number>();\r\n let layers = new Array<number>();\r\n\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(true, false, size) as WebGPURenderTargetWrapper;\r\n\r\n if (options !== undefined) {\r\n generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;\r\n generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;\r\n generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;\r\n textureCount = options.textureCount || 1;\r\n depthTextureFormat = options.depthTextureFormat ?? Constants.TEXTUREFORMAT_DEPTH16;\r\n\r\n if (options.types) {\r\n types = options.types;\r\n }\r\n if (options.samplingModes) {\r\n samplingModes = options.samplingModes;\r\n }\r\n if (options.useSRGBBuffers) {\r\n useSRGBBuffers = options.useSRGBBuffers;\r\n }\r\n if (options.formats) {\r\n formats = options.formats;\r\n }\r\n if (options.targetTypes) {\r\n targets = options.targetTypes;\r\n }\r\n if (options.faceIndex) {\r\n faceIndex = options.faceIndex;\r\n }\r\n if (options.layerIndex) {\r\n layerIndex = options.layerIndex;\r\n }\r\n if (options.layerCounts) {\r\n layers = options.layerCounts;\r\n }\r\n }\r\n\r\n const width = (<{ width: number; height: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number }>size).height || <number>size;\r\n\r\n let depthStencilTexture = null;\r\n if (generateDepthBuffer || generateStencilBuffer || generateDepthTexture) {\r\n if (!generateDepthTexture) {\r\n // The caller doesn't want a depth texture, so we are free to use the depth texture format we want.\r\n // So, we will align with what the WebGL engine does\r\n if (generateDepthBuffer && generateStencilBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\r\n } else if (generateDepthBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\r\n } else {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_STENCIL8;\r\n }\r\n }\r\n depthStencilTexture = rtWrapper.createDepthStencilTexture(0, false, generateStencilBuffer, 1, depthTextureFormat);\r\n }\r\n\r\n const textures: InternalTexture[] = [];\r\n const attachments: number[] = [];\r\n const defaultAttachments: number[] = [];\r\n\r\n rtWrapper._generateDepthBuffer = generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = generateStencilBuffer;\r\n rtWrapper._attachments = attachments;\r\n rtWrapper._defaultAttachments = defaultAttachments;\r\n\r\n for (let i = 0; i < textureCount; i++) {\r\n let samplingMode = samplingModes[i] || defaultSamplingMode;\r\n let type = types[i] || defaultType;\r\n\r\n const format = formats[i] || defaultFormat;\r\n const useSRGBBuffer = (useSRGBBuffers[i] || defaultUseSRGBBuffer) && this._caps.supportSRGBBuffers;\r\n\r\n const target = targets[i] || defaultTarget;\r\n const layerCount = layers[i] ?? 1;\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n // if floating point linear (FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {\r\n // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n Logger.Warn(\"Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type\");\r\n }\r\n\r\n attachments.push(i + 1);\r\n defaultAttachments.push(initializeBuffers ? i + 1 : i === 0 ? 1 : 0);\r\n\r\n if (target === -1) {\r\n continue;\r\n }\r\n\r\n const texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);\r\n textures[i] = texture;\r\n\r\n switch (target) {\r\n case Constants.TEXTURE_CUBE_MAP:\r\n texture.isCube = true;\r\n break;\r\n case Constants.TEXTURE_3D:\r\n texture.is3D = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n case Constants.TEXTURE_2D_ARRAY:\r\n texture.is2DArray = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n }\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n texture.samples = 1;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.type = type;\r\n texture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n texture.format = format;\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture);\r\n }\r\n\r\n if (depthStencilTexture) {\r\n depthStencilTexture.incrementReferences();\r\n textures[textureCount] = depthStencilTexture;\r\n this._internalTexturesCache.push(depthStencilTexture);\r\n }\r\n\r\n rtWrapper.setTextures(textures);\r\n rtWrapper.setLayerAndFaceIndices(layerIndex, faceIndex);\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.textures || rtWrapper.textures[0].samples === samples) {\r\n return samples;\r\n }\r\n\r\n const count = rtWrapper.textures.length;\r\n\r\n if (count === 0) {\r\n return 1;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n const gpuTextureWrapper = texture._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n gpuTextureWrapper?.releaseMSAATexture();\r\n }\r\n\r\n // Note that rtWrapper.textures can't have null textures, lastTextureIsDepthTexture can't be true if rtWrapper._depthStencilTexture is null\r\n const lastTextureIsDepthTexture = rtWrapper._depthStencilTexture === rtWrapper.textures[count - 1];\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n this._textureHelper.createMSAATexture(texture, samples, false, i === count - 1 && lastTextureIsDepthTexture ? 0 : i);\r\n texture.samples = samples;\r\n }\r\n\r\n // Note that the last texture of textures is the depth texture if the depth texture has been generated by the MRT class and so the MSAA texture\r\n // will be recreated for this texture by the loop above: in that case, there's no need to create the MSAA texture for rtWrapper._depthStencilTexture\r\n // because rtWrapper._depthStencilTexture is the same texture than the depth texture\r\n if (rtWrapper._depthStencilTexture && !lastTextureIsDepthTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n return samples;\r\n};\r\n\r\nWebGPUEngine.prototype.bindAttachments = function (attachments: number[]): void {\r\n if (attachments.length === 0 || !this._currentRenderTarget) {\r\n return;\r\n }\r\n\r\n this._mrtAttachments = attachments;\r\n if (this._currentRenderPass) {\r\n // the render pass has already been created, we need to call setMRTAttachments to update the state of the attachments\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n } else {\r\n // the render pass is not created yet so we don't need to call setMRTAttachments: it will be called as part of the render pass creation (see WebGPUEngine._startRenderTargetRenderPass)\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.buildTextureLayout = function (textureStatus: boolean[]): number[] {\r\n const result = [];\r\n\r\n for (let i = 0; i < textureStatus.length; i++) {\r\n if (textureStatus[i]) {\r\n result.push(i + 1);\r\n } else {\r\n result.push(0);\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachment = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachmentForRenderTarget are not called in Babylon.js so it's hard to know the use case\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachmentForRenderTarget = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachment are not called in Babylon.js so it's hard to know the use case\r\n};\r\n"]}
|
|
@@ -35,8 +35,9 @@ export declare class WebGPUHardwareTexture implements HardwareTextureWrapper {
|
|
|
35
35
|
private _webgpuTexture;
|
|
36
36
|
private _webgpuMSAATexture;
|
|
37
37
|
get underlyingResource(): Nullable<GPUTexture>;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
getMSAATexture(index?: number): Nullable<GPUTexture>;
|
|
39
|
+
setMSAATexture(texture: GPUTexture, index?: number): void;
|
|
40
|
+
releaseMSAATexture(): void;
|
|
40
41
|
view: Nullable<GPUTextureView>;
|
|
41
42
|
viewForWriting: Nullable<GPUTextureView>;
|
|
42
43
|
format: GPUTextureFormat;
|
|
@@ -44,7 +45,7 @@ export declare class WebGPUHardwareTexture implements HardwareTextureWrapper {
|
|
|
44
45
|
textureAdditionalUsages: number;
|
|
45
46
|
constructor(existingTexture?: Nullable<GPUTexture>);
|
|
46
47
|
set(hardwareTexture: GPUTexture): void;
|
|
47
|
-
setUsage(
|
|
48
|
+
setUsage(_textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
|
|
48
49
|
createView(descriptor?: GPUTextureViewDescriptor, createViewForWriting?: boolean): void;
|
|
49
50
|
reset(): void;
|
|
50
51
|
release(): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { InternalTextureSource } from "../../Materials/Textures/internalTexture.js";
|
|
2
1
|
import { Scalar } from "../../Maths/math.scalar.js";
|
|
3
2
|
import * as WebGPUConstants from "./webgpuConstants.js";
|
|
4
3
|
/** @internal */
|
|
@@ -6,11 +5,26 @@ export class WebGPUHardwareTexture {
|
|
|
6
5
|
get underlyingResource() {
|
|
7
6
|
return this._webgpuTexture;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
getMSAATexture(index = 0) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
return (_b = (_a = this._webgpuMSAATexture) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : null;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
this._webgpuMSAATexture
|
|
12
|
+
setMSAATexture(texture, index = -1) {
|
|
13
|
+
if (!this._webgpuMSAATexture) {
|
|
14
|
+
this._webgpuMSAATexture = [];
|
|
15
|
+
}
|
|
16
|
+
if (index === -1) {
|
|
17
|
+
index = this._webgpuMSAATexture.length;
|
|
18
|
+
}
|
|
19
|
+
this._webgpuMSAATexture[index] = texture;
|
|
20
|
+
}
|
|
21
|
+
releaseMSAATexture() {
|
|
22
|
+
if (this._webgpuMSAATexture) {
|
|
23
|
+
for (const texture of this._webgpuMSAATexture) {
|
|
24
|
+
texture.destroy();
|
|
25
|
+
}
|
|
26
|
+
this._webgpuMSAATexture = null;
|
|
27
|
+
}
|
|
14
28
|
}
|
|
15
29
|
constructor(existingTexture = null) {
|
|
16
30
|
this.format = WebGPUConstants.TextureFormat.RGBA8Unorm;
|
|
@@ -24,8 +38,7 @@ export class WebGPUHardwareTexture {
|
|
|
24
38
|
set(hardwareTexture) {
|
|
25
39
|
this._webgpuTexture = hardwareTexture;
|
|
26
40
|
}
|
|
27
|
-
setUsage(
|
|
28
|
-
generateMipMaps = textureSource === InternalTextureSource.RenderTarget ? false : generateMipMaps;
|
|
41
|
+
setUsage(_textureSource, generateMipMaps, isCube, width, height) {
|
|
29
42
|
this.createView({
|
|
30
43
|
format: this.format,
|
|
31
44
|
dimension: isCube ? WebGPUConstants.TextureViewDimension.Cube : WebGPUConstants.TextureViewDimension.E2d,
|
|
@@ -52,10 +65,10 @@ export class WebGPUHardwareTexture {
|
|
|
52
65
|
this.viewForWriting = null;
|
|
53
66
|
}
|
|
54
67
|
release() {
|
|
55
|
-
var _a, _b
|
|
68
|
+
var _a, _b;
|
|
56
69
|
(_a = this._webgpuTexture) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
57
|
-
|
|
58
|
-
(
|
|
70
|
+
this.releaseMSAATexture();
|
|
71
|
+
(_b = this._copyInvertYTempTexture) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
59
72
|
this.reset();
|
|
60
73
|
}
|
|
61
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpuHardwareTexture.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/WebGPU/webgpuHardwareTexture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"webgpuHardwareTexture.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/WebGPU/webgpuHardwareTexture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAIrD,gBAAgB;AAChB,MAAM,OAAO,qBAAqB;IAsC9B,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAEM,cAAc,CAAC,KAAK,GAAG,CAAC;;QAC3B,OAAO,MAAA,MAAA,IAAI,CAAC,kBAAkB,0CAAG,KAAK,CAAC,mCAAI,IAAI,CAAC;I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hardwareTextureWrapper\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Nullable } from \"../../types\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\n\r\ndeclare type WebGPUBundleList = import(\"./webgpuBundleList\").WebGPUBundleList;\r\n\r\n/** @internal */\r\nexport class WebGPUHardwareTexture implements HardwareTextureWrapper {\r\n /**\r\n * List of bundles collected in the snapshot rendering mode when the texture is a render target texture\r\n * The index in this array is the current layer we are rendering into\r\n * @internal\r\n */\r\n public _bundleLists: WebGPUBundleList[];\r\n /**\r\n * Current layer we are rendering into when in snapshot rendering mode (if the texture is a render target texture)\r\n * @internal\r\n */\r\n public _currentLayer: number;\r\n\r\n /**\r\n * Cache of RenderPassDescriptor and BindGroup used when generating mipmaps (see WebGPUTextureHelper.generateMipmaps)\r\n * @internal\r\n */\r\n public _mipmapGenRenderPassDescr: GPURenderPassDescriptor[][];\r\n /** @internal */\r\n public _mipmapGenBindGroup: GPUBindGroup[][];\r\n\r\n /**\r\n * Cache for the invertYPreMultiplyAlpha function (see WebGPUTextureHelper)\r\n * @internal\r\n */\r\n public _copyInvertYTempTexture?: GPUTexture;\r\n /** @internal */\r\n public _copyInvertYRenderPassDescr: GPURenderPassDescriptor;\r\n /** @internal */\r\n public _copyInvertYBindGroup: GPUBindGroup;\r\n /** @internal */\r\n public _copyInvertYBindGroupWithOfst: GPUBindGroup;\r\n\r\n private _webgpuTexture: Nullable<GPUTexture>;\r\n // There can be multiple MSAA textures for a single WebGPU texture because different layers of a 2DArrayTexture / 3DTexture\r\n // or different faces of a cube texture can be bound to different render targets at the same time (in a multi RenderTargetWrapper)\r\n private _webgpuMSAATexture: Nullable<GPUTexture[]>;\r\n\r\n public get underlyingResource(): Nullable<GPUTexture> {\r\n return this._webgpuTexture;\r\n }\r\n\r\n public getMSAATexture(index = 0): Nullable<GPUTexture> {\r\n return this._webgpuMSAATexture?.[index] ?? null;\r\n }\r\n\r\n public setMSAATexture(texture: GPUTexture, index = -1) {\r\n if (!this._webgpuMSAATexture) {\r\n this._webgpuMSAATexture = [];\r\n }\r\n\r\n if (index === -1) {\r\n index = this._webgpuMSAATexture.length;\r\n }\r\n\r\n this._webgpuMSAATexture![index] = texture;\r\n }\r\n\r\n public releaseMSAATexture() {\r\n if (this._webgpuMSAATexture) {\r\n for (const texture of this._webgpuMSAATexture) {\r\n texture.destroy();\r\n }\r\n this._webgpuMSAATexture = null;\r\n }\r\n }\r\n\r\n public view: Nullable<GPUTextureView>;\r\n public viewForWriting: Nullable<GPUTextureView>;\r\n public format: GPUTextureFormat = WebGPUConstants.TextureFormat.RGBA8Unorm;\r\n public textureUsages = 0;\r\n public textureAdditionalUsages = 0;\r\n\r\n constructor(existingTexture: Nullable<GPUTexture> = null) {\r\n this._webgpuTexture = existingTexture;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public set(hardwareTexture: GPUTexture): void {\r\n this._webgpuTexture = hardwareTexture;\r\n }\r\n\r\n public setUsage(_textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void {\r\n this.createView({\r\n format: this.format,\r\n dimension: isCube ? WebGPUConstants.TextureViewDimension.Cube : WebGPUConstants.TextureViewDimension.E2d,\r\n mipLevelCount: generateMipMaps ? Scalar.ILog2(Math.max(width, height)) + 1 : 1,\r\n baseArrayLayer: 0,\r\n baseMipLevel: 0,\r\n arrayLayerCount: isCube ? 6 : 1,\r\n aspect: WebGPUConstants.TextureAspect.All,\r\n });\r\n }\r\n\r\n public createView(descriptor?: GPUTextureViewDescriptor, createViewForWriting = false): void {\r\n this.view = this._webgpuTexture!.createView(descriptor);\r\n if (createViewForWriting && descriptor) {\r\n const saveNumMipMaps = descriptor.mipLevelCount;\r\n descriptor.mipLevelCount = 1;\r\n this.viewForWriting = this._webgpuTexture!.createView(descriptor);\r\n descriptor.mipLevelCount = saveNumMipMaps;\r\n }\r\n }\r\n\r\n public reset(): void {\r\n this._webgpuTexture = null;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public release(): void {\r\n this._webgpuTexture?.destroy();\r\n this.releaseMSAATexture();\r\n this._copyInvertYTempTexture?.destroy();\r\n this.reset();\r\n }\r\n}\r\n"]}
|
|
@@ -63,7 +63,7 @@ export declare class WebGPUTextureHelper {
|
|
|
63
63
|
generateCubeMipmaps(gpuTexture: GPUTexture | WebGPUHardwareTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
|
|
64
64
|
generateMipmaps(gpuOrHdwTexture: GPUTexture | WebGPUHardwareTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
|
|
65
65
|
createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number, creationFlags?: number): WebGPUHardwareTexture;
|
|
66
|
-
createMSAATexture(texture: InternalTexture, samples: number): void;
|
|
66
|
+
createMSAATexture(texture: InternalTexture, samples: number, releaseExisting?: boolean, index?: number): void;
|
|
67
67
|
updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number): void;
|
|
68
68
|
updateTexture(imageBitmap: ImageBitmap | Uint8Array | HTMLCanvasElement | OffscreenCanvas, texture: GPUTexture | InternalTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, allowGPUOptimization?: boolean): void;
|
|
69
69
|
readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>, noDataConversion?: boolean): Promise<ArrayBufferView>;
|
|
@@ -1260,7 +1260,7 @@ export class WebGPUTextureHelper {
|
|
|
1260
1260
|
additionalUsages |= WebGPUConstants.TextureUsage.RenderAttachment | WebGPUConstants.TextureUsage.CopyDst;
|
|
1261
1261
|
}
|
|
1262
1262
|
const gpuTexture = this._device.createTexture({
|
|
1263
|
-
label: `
|
|
1263
|
+
label: `Texture${is3D ? "3D" : "2D"}_${label ? label + "_" : ""}${textureSize.width}x${textureSize.height}x${textureSize.depthOrArrayLayers}_${hasMipmaps ? "wmips" : "womips"}_${format}_samples${sampleCount}`,
|
|
1264
1264
|
size: textureSize,
|
|
1265
1265
|
dimension: is3D ? WebGPUConstants.TextureDimension.E3d : WebGPUConstants.TextureDimension.E2d,
|
|
1266
1266
|
format,
|
|
@@ -1476,26 +1476,18 @@ export class WebGPUTextureHelper {
|
|
|
1476
1476
|
this.createMSAATexture(texture, texture.samples);
|
|
1477
1477
|
return gpuTextureWrapper;
|
|
1478
1478
|
}
|
|
1479
|
-
createMSAATexture(texture, samples) {
|
|
1479
|
+
createMSAATexture(texture, samples, releaseExisting = true, index = -1) {
|
|
1480
1480
|
const gpuTextureWrapper = texture._hardwareTexture;
|
|
1481
|
-
if (
|
|
1482
|
-
|
|
1483
|
-
gpuTextureWrapper.msaaTexture = null;
|
|
1481
|
+
if (releaseExisting) {
|
|
1482
|
+
gpuTextureWrapper === null || gpuTextureWrapper === void 0 ? void 0 : gpuTextureWrapper.releaseMSAATexture();
|
|
1484
1483
|
}
|
|
1485
1484
|
if (!gpuTextureWrapper || (samples !== null && samples !== void 0 ? samples : 1) <= 1) {
|
|
1486
1485
|
return;
|
|
1487
1486
|
}
|
|
1488
1487
|
const width = texture.width;
|
|
1489
1488
|
const height = texture.height;
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1492
|
-
const gpuMSAATexture = this.createCubeTexture({ width, height }, false, false, texture.invertY, false, gpuTextureWrapper.format, samples, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages, texture.label ? "MSAA" + texture.label : undefined);
|
|
1493
|
-
gpuTextureWrapper.msaaTexture = gpuMSAATexture;
|
|
1494
|
-
}
|
|
1495
|
-
else {
|
|
1496
|
-
const gpuMSAATexture = this.createTexture({ width, height, layers: layerCount }, false, false, texture.invertY, false, texture.is3D, gpuTextureWrapper.format, samples, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages, texture.label ? "MSAA" + texture.label : undefined);
|
|
1497
|
-
gpuTextureWrapper.msaaTexture = gpuMSAATexture;
|
|
1498
|
-
}
|
|
1489
|
+
const gpuMSAATexture = this.createTexture({ width, height, layers: 1 }, false, false, false, false, false, gpuTextureWrapper.format, samples, this._commandEncoderForCreation, WebGPUConstants.TextureUsage.RenderAttachment, 0, texture.label ? "MSAA" + texture.label : undefined);
|
|
1490
|
+
gpuTextureWrapper.setMSAATexture(gpuMSAATexture, index);
|
|
1499
1491
|
}
|
|
1500
1492
|
//------------------------------------------------------------------------------
|
|
1501
1493
|
// Update
|