Skip to content

Commit 2f37c04

Browse files
WebGPURenderer: Move TexelCopyTextureInfo to WebGPUTextureUtils.
The wrapper class for `GPUTexelCopyTextureInfo` belongs with the other texture utilities. Export it from `WebGPUTextureUtils.js` and import it into `WebGPUBackend.js`. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5126da4 commit 2f37c04

2 files changed

Lines changed: 47 additions & 46 deletions

File tree

src/renderers/webgpu/WebGPUBackend.js

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import WebGPUAttributeUtils from './utils/WebGPUAttributeUtils.js';
1212
import WebGPUBindingUtils from './utils/WebGPUBindingUtils.js';
1313
import WebGPUCapabilities from './utils/WebGPUCapabilities.js';
1414
import WebGPUPipelineUtils from './utils/WebGPUPipelineUtils.js';
15-
import WebGPUTextureUtils from './utils/WebGPUTextureUtils.js';
15+
import WebGPUTextureUtils, { TexelCopyTextureInfo } from './utils/WebGPUTextureUtils.js';
1616

1717
import { WebGPUCoordinateSystem, TimestampQuery, REVISION, HalfFloatType, Compatibility } from '../../constants.js';
1818
import WebGPUTimestampQueryPool from './utils/WebGPUTimestampQueryPool.js';
@@ -25,51 +25,6 @@ const _clearValue = { r: 0, g: 0, b: 0, a: 1 };
2525

2626
const _submitArray = [ null ];
2727

28-
/**
29-
* Reusable wrapper around `GPUTexelCopyTextureInfo`. Mutates in place to avoid
30-
* per-frame GC pressure while keeping call sites readable via chainable setters.
31-
*/
32-
class TexelCopyTextureInfo {
33-
34-
constructor() {
35-
36-
this.texture = null;
37-
this.mipLevel = 0;
38-
this.origin = { x: 0, y: 0, z: 0 };
39-
40-
}
41-
42-
setTexture( texture ) {
43-
44-
this.texture = texture;
45-
return this;
46-
47-
}
48-
49-
setMipLevel( mipLevel ) {
50-
51-
this.mipLevel = mipLevel;
52-
return this;
53-
54-
}
55-
56-
setOrigin( x, y, z ) {
57-
58-
this.origin.x = x;
59-
this.origin.y = y;
60-
this.origin.z = z;
61-
return this;
62-
63-
}
64-
65-
reset() {
66-
67-
this.texture = null;
68-
69-
}
70-
71-
}
72-
7328
const _copySrc = new TexelCopyTextureInfo();
7429
const _copyDst = new TexelCopyTextureInfo();
7530
const _copySize = [ 0, 0 ];

src/renderers/webgpu/utils/WebGPUTextureUtils.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,51 @@ const _compareToWebGPU = {
3535

3636
const _flipMap = [ 0, 1, 3, 2, 4, 5 ];
3737

38+
/**
39+
* Reusable wrapper around `GPUTexelCopyTextureInfo`. Mutates in place to avoid
40+
* per-frame GC pressure while keeping call sites readable via chainable setters.
41+
*/
42+
class TexelCopyTextureInfo {
43+
44+
constructor() {
45+
46+
this.texture = null;
47+
this.mipLevel = 0;
48+
this.origin = { x: 0, y: 0, z: 0 };
49+
50+
}
51+
52+
setTexture( texture ) {
53+
54+
this.texture = texture;
55+
return this;
56+
57+
}
58+
59+
setMipLevel( mipLevel ) {
60+
61+
this.mipLevel = mipLevel;
62+
return this;
63+
64+
}
65+
66+
setOrigin( x, y, z ) {
67+
68+
this.origin.x = x;
69+
this.origin.y = y;
70+
this.origin.z = z;
71+
return this;
72+
73+
}
74+
75+
reset() {
76+
77+
this.texture = null;
78+
79+
}
80+
81+
}
82+
3883
/**
3984
* A WebGPU backend utility module for managing textures.
4085
*
@@ -1670,4 +1715,5 @@ export function getFormat( texture, device ) {
16701715

16711716
}
16721717

1718+
export { TexelCopyTextureInfo };
16731719
export default WebGPUTextureUtils;

0 commit comments

Comments
 (0)