-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
texture.ts
250 lines (217 loc) · 4.12 KB
/
texture.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/**
* @category gfx
*/
import {
GFXFormat,
GFXObject,
GFXObjectType,
GFXSampleCount,
GFXTextureFlagBit,
GFXTextureFlags,
GFXTextureType,
GFXTextureUsage,
GFXTextureUsageBit,
} from './define';
import { GFXDevice } from './device';
/**
* @zh
* GFX纹理描述信息。
*/
export interface IGFXTextureInfo {
type: GFXTextureType;
usage: GFXTextureUsage;
format: GFXFormat;
width: number;
height: number;
depth?: number;
arrayLayer?: number;
mipLevel?: number;
samples?: GFXSampleCount;
flags?: GFXTextureFlags;
}
/**
* @zh
* GFX纹理。
*/
export abstract class GFXTexture extends GFXObject {
/**
* @zh
* 纹理类型。
*/
public get type (): GFXTextureType {
return this._type;
}
/**
* @zh
* 纹理使用方式。
*/
public get usage (): GFXTextureUsage {
return this._usage;
}
/**
* @zh
* 纹理格式。
*/
public get format (): GFXFormat {
return this._format;
}
/**
* @zh
* 纹理宽度。
*/
public get width (): number {
return this._width;
}
/**
* @zh
* 纹理高度。
*/
public get height (): number {
return this._height;
}
/**
* @zh
* 纹理深度。
*/
public get depth (): number {
return this._depth;
}
/**
* @zh
* 纹理数组层数。
*/
public get arrayLayer (): number {
return this._arrayLayer;
}
/**
* @zh
* 纹理mip层级数。
*/
public get mipLevel (): number {
return this._mipLevel;
}
/**
* @zh
* 纹理采样数。
*/
public get samples (): GFXSampleCount {
return this._samples;
}
/**
* @zh
* 纹理标识位。
*/
public get flags (): GFXTextureFlags {
return this._flags;
}
/**
* @zh
* 纹理大小。
*/
public get size (): number {
return this._size;
}
/**
* @zh
* 纹理缓冲。
*/
public get buffer (): ArrayBuffer | null {
return this._buffer;
}
/**
* @zh
* GFX设备。
*/
protected _device: GFXDevice;
/**
* @zh
* 纹理类型。
*/
protected _type: GFXTextureType = GFXTextureType.TEX2D;
/**
* @zh
* 纹理使用方式。
*/
protected _usage: GFXTextureUsage = GFXTextureUsageBit.NONE;
/**
* @zh
* 纹理格式。
*/
protected _format: GFXFormat = GFXFormat.UNKNOWN;
/**
* @zh
* 纹理宽度。
*/
protected _width: number = 0;
/**
* @zh
* 纹理高度。
*/
protected _height: number = 0;
/**
* @zh
* 纹理深度。
*/
protected _depth: number = 1;
/**
* @zh
* 纹理数组层数。
*/
protected _arrayLayer: number = 1;
/**
* @zh
* 纹理mip层级数。
*/
protected _mipLevel: number = 1;
/**
* @zh
* 纹理采样数。
*/
protected _samples: GFXSampleCount = GFXSampleCount.X1;
/**
* @zh
* 纹理标识位。
*/
protected _flags: GFXTextureFlags = GFXTextureFlagBit.NONE;
/**
* @zh
* 是否是2次幂大小。
*/
protected _isPowerOf2: boolean = false;
/**
* @zh
* 纹理大小。
*/
protected _size: number = 0;
/**
* @zh
* 纹理缓冲。
*/
protected _buffer: ArrayBuffer | null = null;
/**
* 构造函数。
* @param device GFX设备。
*/
constructor (device: GFXDevice) {
super(GFXObjectType.TEXTURE);
this._device = device;
}
/**
* @zh
* 初始化函数。
* @param info GFX纹理描述信息。
*/
public abstract initialize (info: IGFXTextureInfo): boolean;
/**
* @zh
* 销毁函数。
*/
public abstract destroy ();
/**
* @zh
* 重置纹理大小。
* @param width 纹理宽度。
* @param height 纹理高度。
*/
public abstract resize (width: number, height: number);
}