WebGPUBackend.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. /*// debugger tools
  2. import 'https://greggman.github.io/webgpu-avoid-redundant-state-setting/webgpu-check-redundant-state-setting.js';
  3. //*/
  4. import { GPUFeatureName, GPUTextureFormat, GPULoadOp, GPUStoreOp, GPUIndexFormat, GPUTextureViewDimension } from './utils/WebGPUConstants.js';
  5. import WGSLNodeBuilder from './nodes/WGSLNodeBuilder.js';
  6. import Backend from '../common/Backend.js';
  7. import { DepthTexture, DepthFormat, DepthStencilFormat, UnsignedInt248Type, UnsignedIntType, WebGPUCoordinateSystem } from 'three';
  8. import WebGPUUtils from './utils/WebGPUUtils.js';
  9. import WebGPUAttributeUtils from './utils/WebGPUAttributeUtils.js';
  10. import WebGPUBindingUtils from './utils/WebGPUBindingUtils.js';
  11. import WebGPUPipelineUtils from './utils/WebGPUPipelineUtils.js';
  12. import WebGPUTextureUtils from './utils/WebGPUTextureUtils.js';
  13. // statics
  14. let _staticAdapter = null;
  15. if ( navigator.gpu !== undefined ) {
  16. _staticAdapter = await navigator.gpu.requestAdapter();
  17. }
  18. //
  19. class WebGPUBackend extends Backend {
  20. constructor( parameters = {} ) {
  21. super( parameters );
  22. // some parameters require default values other than "undefined"
  23. this.parameters.antialias = ( parameters.antialias === true );
  24. if ( this.parameters.antialias === true ) {
  25. this.parameters.sampleCount = ( parameters.sampleCount === undefined ) ? 4 : parameters.sampleCount;
  26. } else {
  27. this.parameters.sampleCount = 1;
  28. }
  29. this.parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;
  30. this.adapter = null;
  31. this.device = null;
  32. this.context = null;
  33. this.colorBuffer = null;
  34. this.depthBuffers = new WeakMap();
  35. this.utils = new WebGPUUtils( this );
  36. this.attributeUtils = new WebGPUAttributeUtils( this );
  37. this.bindingUtils = new WebGPUBindingUtils( this );
  38. this.pipelineUtils = new WebGPUPipelineUtils( this );
  39. this.textureUtils = new WebGPUTextureUtils( this );
  40. }
  41. async init( renderer ) {
  42. await super.init( renderer );
  43. //
  44. const parameters = this.parameters;
  45. const adapterOptions = {
  46. powerPreference: parameters.powerPreference
  47. };
  48. const adapter = await navigator.gpu.requestAdapter( adapterOptions );
  49. if ( adapter === null ) {
  50. throw new Error( 'WebGPUBackend: Unable to create WebGPU adapter.' );
  51. }
  52. // feature support
  53. const features = Object.values( GPUFeatureName );
  54. const supportedFeatures = [];
  55. for ( const name of features ) {
  56. if ( adapter.features.has( name ) ) {
  57. supportedFeatures.push( name );
  58. }
  59. }
  60. const deviceDescriptor = {
  61. requiredFeatures: supportedFeatures,
  62. requiredLimits: parameters.requiredLimits
  63. };
  64. const device = await adapter.requestDevice( deviceDescriptor );
  65. const context = ( parameters.context !== undefined ) ? parameters.context : renderer.domElement.getContext( 'webgpu' );
  66. this.adapter = adapter;
  67. this.device = device;
  68. this.context = context;
  69. this.updateSize();
  70. }
  71. get coordinateSystem() {
  72. return WebGPUCoordinateSystem;
  73. }
  74. async getArrayBuffer( attribute ) {
  75. return await this.attributeUtils.getArrayBuffer( attribute );
  76. }
  77. beginRender( renderContext ) {
  78. const renderContextData = this.get( renderContext );
  79. const device = this.device;
  80. const descriptor = {
  81. colorAttachments: [ {
  82. view: null
  83. } ],
  84. depthStencilAttachment: {
  85. view: null
  86. }
  87. };
  88. const colorAttachment = descriptor.colorAttachments[ 0 ];
  89. const depthStencilAttachment = descriptor.depthStencilAttachment;
  90. const antialias = this.parameters.antialias;
  91. if ( renderContext.texture !== null ) {
  92. const textureData = this.get( renderContext.texture );
  93. const depthTextureData = this.get( renderContext.depthTexture );
  94. // @TODO: Support RenderTarget with antialiasing.
  95. colorAttachment.view = textureData.texture.createView( {
  96. baseMipLevel: 0,
  97. mipLevelCount: 1,
  98. baseArrayLayer: renderContext.activeCubeFace,
  99. dimension: GPUTextureViewDimension.TwoD
  100. } );
  101. depthStencilAttachment.view = depthTextureData.texture.createView();
  102. if ( renderContext.stencil && renderContext.depthTexture.format === DepthFormat ) {
  103. renderContext.stencil = false;
  104. }
  105. } else {
  106. if ( antialias === true ) {
  107. colorAttachment.view = this.colorBuffer.createView();
  108. colorAttachment.resolveTarget = this.context.getCurrentTexture().createView();
  109. } else {
  110. colorAttachment.view = this.context.getCurrentTexture().createView();
  111. colorAttachment.resolveTarget = undefined;
  112. }
  113. depthStencilAttachment.view = this._getDepthBufferGPU( renderContext ).createView();
  114. }
  115. if ( renderContext.clearColor ) {
  116. colorAttachment.clearValue = renderContext.clearColorValue;
  117. colorAttachment.loadOp = GPULoadOp.Clear;
  118. colorAttachment.storeOp = GPUStoreOp.Store;
  119. } else {
  120. colorAttachment.loadOp = GPULoadOp.Load;
  121. colorAttachment.storeOp = GPUStoreOp.Store;
  122. }
  123. //
  124. if ( renderContext.depth ) {
  125. if ( renderContext.clearDepth ) {
  126. depthStencilAttachment.depthClearValue = renderContext.clearDepthValue;
  127. depthStencilAttachment.depthLoadOp = GPULoadOp.Clear;
  128. depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
  129. } else {
  130. depthStencilAttachment.depthLoadOp = GPULoadOp.Load;
  131. depthStencilAttachment.depthStoreOp = GPUStoreOp.Store;
  132. }
  133. }
  134. if ( renderContext.stencil ) {
  135. if ( renderContext.clearStencil ) {
  136. depthStencilAttachment.stencilClearValue = renderContext.clearStencilValue;
  137. depthStencilAttachment.stencilLoadOp = GPULoadOp.Clear;
  138. depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
  139. } else {
  140. depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
  141. depthStencilAttachment.stencilStoreOp = GPUStoreOp.Store;
  142. }
  143. }
  144. //
  145. const encoder = device.createCommandEncoder( { label: 'renderContext_' + renderContext.id } );
  146. const currentPass = encoder.beginRenderPass( descriptor );
  147. //
  148. renderContextData.descriptor = descriptor;
  149. renderContextData.encoder = encoder;
  150. renderContextData.currentPass = currentPass;
  151. renderContextData.currentAttributesSet = {};
  152. //
  153. if ( renderContext.viewport ) {
  154. this.updateViewport( renderContext );
  155. }
  156. if ( renderContext.scissor ) {
  157. const { x, y, width, height } = renderContext.scissorValue;
  158. currentPass.setScissorRect( x, y, width, height );
  159. }
  160. }
  161. finishRender( renderContext ) {
  162. const renderContextData = this.get( renderContext );
  163. renderContextData.currentPass.end();
  164. this.device.queue.submit( [ renderContextData.encoder.finish() ] );
  165. //
  166. if ( renderContext.texture !== null && renderContext.texture.generateMipmaps === true ) {
  167. this.textureUtils.generateMipmaps( renderContext.texture );
  168. }
  169. }
  170. updateViewport( renderContext ) {
  171. const { currentPass } = this.get( renderContext );
  172. const { x, y, width, height, minDepth, maxDepth } = renderContext.viewportValue;
  173. currentPass.setViewport( x, y, width, height, minDepth, maxDepth );
  174. }
  175. clear( renderContext, color, depth, stencil ) {
  176. const device = this.device;
  177. const renderContextData = this.get( renderContext );
  178. const { descriptor } = renderContextData;
  179. depth = depth && renderContext.depth;
  180. stencil = stencil && renderContext.stencil;
  181. const colorAttachment = descriptor.colorAttachments[ 0 ];
  182. const antialias = this.parameters.antialias;
  183. // @TODO: Include render target in clear operation.
  184. if ( antialias === true ) {
  185. colorAttachment.view = this.colorBuffer.createView();
  186. colorAttachment.resolveTarget = this.context.getCurrentTexture().createView();
  187. } else {
  188. colorAttachment.view = this.context.getCurrentTexture().createView();
  189. colorAttachment.resolveTarget = undefined;
  190. }
  191. descriptor.depthStencilAttachment.view = this._getDepthBufferGPU( renderContext ).createView();
  192. if ( color ) {
  193. colorAttachment.loadOp = GPULoadOp.Clear;
  194. colorAttachment.clearValue = renderContext.clearColorValue;
  195. }
  196. if ( depth ) {
  197. descriptor.depthStencilAttachment.depthLoadOp = GPULoadOp.Clear;
  198. descriptor.depthStencilAttachment.depthClearValue = renderContext.clearDepthValue;
  199. }
  200. if ( stencil ) {
  201. descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Clear;
  202. descriptor.depthStencilAttachment.stencilClearValue = renderContext.clearStencilValue;
  203. }
  204. renderContextData.encoder = device.createCommandEncoder( {} );
  205. renderContextData.currentPass = renderContextData.encoder.beginRenderPass( descriptor );
  206. renderContextData.currentPass.end();
  207. device.queue.submit( [ renderContextData.encoder.finish() ] );
  208. }
  209. // compute
  210. beginCompute( computeGroup ) {
  211. const groupGPU = this.get( computeGroup );
  212. groupGPU.cmdEncoderGPU = this.device.createCommandEncoder( {} );
  213. groupGPU.passEncoderGPU = groupGPU.cmdEncoderGPU.beginComputePass();
  214. }
  215. compute( computeGroup, computeNode, bindings, pipeline ) {
  216. const { passEncoderGPU } = this.get( computeGroup );
  217. // pipeline
  218. const pipelineGPU = this.get( pipeline ).pipeline;
  219. passEncoderGPU.setPipeline( pipelineGPU );
  220. // bind group
  221. const bindGroupGPU = this.get( bindings ).group;
  222. passEncoderGPU.setBindGroup( 0, bindGroupGPU );
  223. passEncoderGPU.dispatchWorkgroups( computeNode.dispatchCount );
  224. }
  225. finishCompute( computeGroup ) {
  226. const groupData = this.get( computeGroup );
  227. groupData.passEncoderGPU.end();
  228. this.device.queue.submit( [ groupData.cmdEncoderGPU.finish() ] );
  229. }
  230. // render object
  231. draw( renderObject, info ) {
  232. const { object, geometry, context, pipeline } = renderObject;
  233. const bindingsData = this.get( renderObject.getBindings() );
  234. const contextData = this.get( context );
  235. const pipelineGPU = this.get( pipeline ).pipeline;
  236. const attributesSet = contextData.currentAttributesSet;
  237. // pipeline
  238. const passEncoderGPU = contextData.currentPass;
  239. passEncoderGPU.setPipeline( pipelineGPU );
  240. // bind group
  241. const bindGroupGPU = bindingsData.group;
  242. passEncoderGPU.setBindGroup( 0, bindGroupGPU );
  243. // attributes
  244. const index = renderObject.getIndex();
  245. const hasIndex = ( index !== null );
  246. // index
  247. if ( hasIndex === true ) {
  248. if ( attributesSet.index !== index ) {
  249. const buffer = this.get( index ).buffer;
  250. const indexFormat = ( index.array instanceof Uint16Array ) ? GPUIndexFormat.Uint16 : GPUIndexFormat.Uint32;
  251. passEncoderGPU.setIndexBuffer( buffer, indexFormat );
  252. attributesSet.index = index;
  253. }
  254. }
  255. // vertex buffers
  256. const vertexBuffers = renderObject.getVertexBuffers();
  257. for ( let i = 0, l = vertexBuffers.length; i < l; i ++ ) {
  258. const vertexBuffer = vertexBuffers[ i ];
  259. if ( attributesSet[ i ] !== vertexBuffer ) {
  260. const buffer = this.get( vertexBuffer ).buffer;
  261. passEncoderGPU.setVertexBuffer( i, buffer );
  262. attributesSet[ i ] = vertexBuffer;
  263. }
  264. }
  265. // draw
  266. const drawRange = geometry.drawRange;
  267. const firstVertex = drawRange.start;
  268. const instanceCount = this.getInstanceCount( renderObject );
  269. if ( hasIndex === true ) {
  270. const indexCount = ( drawRange.count !== Infinity ) ? drawRange.count : index.count;
  271. passEncoderGPU.drawIndexed( indexCount, instanceCount, firstVertex, 0, 0 );
  272. info.update( object, indexCount, instanceCount );
  273. } else {
  274. const positionAttribute = geometry.attributes.position;
  275. const vertexCount = ( drawRange.count !== Infinity ) ? drawRange.count : positionAttribute.count;
  276. passEncoderGPU.draw( vertexCount, instanceCount, firstVertex, 0 );
  277. info.update( object, vertexCount, instanceCount );
  278. }
  279. }
  280. // cache key
  281. needsUpdate( renderObject ) {
  282. const renderObjectGPU = this.get( renderObject );
  283. const { object, material } = renderObject;
  284. const utils = this.utils;
  285. const sampleCount = utils.getSampleCount( renderObject.context );
  286. const colorSpace = utils.getCurrentColorSpace( renderObject.context );
  287. const colorFormat = utils.getCurrentColorFormat( renderObject.context );
  288. const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
  289. const primitiveTopology = utils.getPrimitiveTopology( object, material );
  290. let needsUpdate = false;
  291. if ( renderObjectGPU.sampleCount !== sampleCount || renderObjectGPU.colorSpace !== colorSpace ||
  292. renderObjectGPU.colorFormat !== colorFormat || renderObjectGPU.depthStencilFormat !== depthStencilFormat ||
  293. renderObjectGPU.primitiveTopology !== primitiveTopology ) {
  294. renderObjectGPU.sampleCount = sampleCount;
  295. renderObjectGPU.colorSpace = colorSpace;
  296. renderObjectGPU.colorFormat = colorFormat;
  297. renderObjectGPU.depthStencilFormat = depthStencilFormat;
  298. renderObjectGPU.primitiveTopology = primitiveTopology;
  299. needsUpdate = true;
  300. }
  301. return needsUpdate;
  302. }
  303. getCacheKey( renderObject ) {
  304. const { object, material } = renderObject;
  305. const utils = this.utils;
  306. const renderContext = renderObject.context;
  307. return [
  308. utils.getSampleCount( renderContext ),
  309. utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
  310. utils.getPrimitiveTopology( object, material )
  311. ].join();
  312. }
  313. // textures
  314. createSampler( texture ) {
  315. this.textureUtils.createSampler( texture );
  316. }
  317. destroySampler( texture ) {
  318. this.textureUtils.destroySampler( texture );
  319. }
  320. createDefaultTexture( texture ) {
  321. this.textureUtils.createDefaultTexture( texture );
  322. }
  323. createTexture( texture ) {
  324. this.textureUtils.createTexture( texture );
  325. }
  326. updateTexture( texture ) {
  327. this.textureUtils.updateTexture( texture );
  328. }
  329. destroyTexture( texture ) {
  330. this.textureUtils.destroyTexture( texture );
  331. }
  332. copyTextureToBuffer( texture, x, y, width, height ) {
  333. return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height );
  334. }
  335. // node builder
  336. createNodeBuilder( object, renderer, scene = null ) {
  337. return new WGSLNodeBuilder( object, renderer, scene );
  338. }
  339. // program
  340. createProgram( program ) {
  341. const programGPU = this.get( program );
  342. programGPU.module = {
  343. module: this.device.createShaderModule( { code: program.code, label: program.stage } ),
  344. entryPoint: 'main'
  345. };
  346. }
  347. destroyProgram( program ) {
  348. this.delete( program );
  349. }
  350. // pipelines
  351. createRenderPipeline( renderObject ) {
  352. this.pipelineUtils.createRenderPipeline( renderObject );
  353. }
  354. createComputePipeline( computePipeline ) {
  355. this.pipelineUtils.createComputePipeline( computePipeline );
  356. }
  357. // bindings
  358. createBindings( bindings, pipeline ) {
  359. this.bindingUtils.createBindings( bindings, pipeline );
  360. }
  361. updateBindings( bindings, pipeline ) {
  362. this.bindingUtils.createBindings( bindings, pipeline );
  363. }
  364. updateBinding( binding ) {
  365. this.bindingUtils.updateBinding( binding );
  366. }
  367. // attributes
  368. createIndexAttribute( attribute ) {
  369. this.attributeUtils.createAttribute( attribute, GPUBufferUsage.INDEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST );
  370. }
  371. createAttribute( attribute ) {
  372. this.attributeUtils.createAttribute( attribute, GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST );
  373. }
  374. createStorageAttribute( attribute ) {
  375. this.attributeUtils.createAttribute( attribute, GPUBufferUsage.STORAGE | GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST );
  376. }
  377. updateAttribute( attribute ) {
  378. this.attributeUtils.updateAttribute( attribute );
  379. }
  380. destroyAttribute( attribute ) {
  381. this.attributeUtils.destroyAttribute( attribute );
  382. }
  383. // canvas
  384. updateSize() {
  385. this._configureContext();
  386. this._setupColorBuffer();
  387. }
  388. // utils public
  389. hasFeature( name ) {
  390. const adapter = this.adapter || _staticAdapter;
  391. //
  392. const features = Object.values( GPUFeatureName );
  393. if ( features.includes( name ) === false ) {
  394. throw new Error( 'THREE.WebGPURenderer: Unknown WebGPU GPU feature: ' + name );
  395. }
  396. //
  397. return adapter.features.has( name );
  398. }
  399. copyFramebufferToTexture( texture, renderContext ) {
  400. const renderContextData = this.get( renderContext );
  401. const { encoder, descriptor } = renderContextData;
  402. let sourceGPU = null;
  403. if ( texture.isFramebufferTexture ) {
  404. sourceGPU = this.context.getCurrentTexture();
  405. } else if ( texture.isDepthTexture ) {
  406. sourceGPU = this._getDepthBufferGPU( renderContext );
  407. }
  408. const destinationGPU = this.get( texture ).texture;
  409. renderContextData.currentPass.end();
  410. encoder.copyTextureToTexture(
  411. {
  412. texture: sourceGPU,
  413. origin: { x: 0, y: 0, z: 0 }
  414. },
  415. {
  416. texture: destinationGPU
  417. },
  418. [
  419. texture.image.width,
  420. texture.image.height
  421. ]
  422. );
  423. if ( texture.generateMipmaps ) this.textureUtils.generateMipmaps( texture );
  424. descriptor.colorAttachments[ 0 ].loadOp = GPULoadOp.Load;
  425. if ( renderContext.depth ) descriptor.depthStencilAttachment.depthLoadOp = GPULoadOp.Load;
  426. if ( renderContext.stencil ) descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
  427. renderContextData.currentPass = encoder.beginRenderPass( descriptor );
  428. renderContextData.currentAttributesSet = {};
  429. }
  430. // utils
  431. _getDepthBufferGPU( renderContext ) {
  432. const { depthBuffers } = this;
  433. const { width, height } = this.getDrawingBufferSize();
  434. let depthTexture = depthBuffers.get( renderContext );
  435. if ( depthTexture !== undefined && depthTexture.image.width === width && depthTexture.image.height === height ) {
  436. return this.get( depthTexture ).texture;
  437. }
  438. this._destroyDepthBufferGPU( renderContext );
  439. depthTexture = new DepthTexture();
  440. depthTexture.name = 'depthBuffer';
  441. if ( renderContext.stencil ) {
  442. depthTexture = new DepthTexture();
  443. depthTexture.format = DepthStencilFormat;
  444. depthTexture.type = UnsignedInt248Type;
  445. } else if ( renderContext.depth ) {
  446. depthTexture = new DepthTexture();
  447. depthTexture.format = DepthFormat;
  448. depthTexture.type = UnsignedIntType;
  449. }
  450. depthTexture.image.width = width;
  451. depthTexture.image.height = height;
  452. this.textureUtils.createTexture( depthTexture, { sampleCount: this.parameters.sampleCount } );
  453. depthBuffers.set( renderContext, depthTexture );
  454. return this.get( depthTexture ).texture;
  455. }
  456. _destroyDepthBufferGPU( renderContext ) {
  457. const { depthBuffers } = this;
  458. const depthTexture = depthBuffers.get( renderContext );
  459. if ( depthTexture !== undefined ) {
  460. this.textureUtils.destroyTexture( depthTexture );
  461. depthBuffers.delete( renderContext );
  462. }
  463. }
  464. _configureContext() {
  465. this.context.configure( {
  466. device: this.device,
  467. format: GPUTextureFormat.BGRA8Unorm,
  468. usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
  469. alphaMode: 'premultiplied'
  470. } );
  471. }
  472. _setupColorBuffer() {
  473. if ( this.colorBuffer ) this.colorBuffer.destroy();
  474. const { width, height } = this.getDrawingBufferSize();
  475. //const format = navigator.gpu.getPreferredCanvasFormat(); // @TODO: Move to WebGPUUtils
  476. this.colorBuffer = this.device.createTexture( {
  477. label: 'colorBuffer',
  478. size: {
  479. width: width,
  480. height: height,
  481. depthOrArrayLayers: 1
  482. },
  483. sampleCount: this.parameters.sampleCount,
  484. format: GPUTextureFormat.BGRA8Unorm,
  485. usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
  486. } );
  487. }
  488. }
  489. export default WebGPUBackend;