@zephyr3d/device 0.1.1 → 0.2.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.
@@ -68,52 +68,52 @@ function makeTextureFormat(compression, r, g, b, a, depth, stencil, float, integ
68
68
  return compressionBits | colorBits | depthStencilBits | floatBits | integerBits | signedBits | srgbBits | bgrBits | blockBits;
69
69
  }
70
70
  const textureFormatMap = {
71
- 'unknown': 0,
72
- 'r8unorm': makeTextureFormat(0, true, false, false, false, false, false, false, false, false, false, false, 1, 1, 1),
73
- 'r8snorm': makeTextureFormat(0, true, false, false, false, false, false, false, false, true, false, false, 1, 1, 1),
74
- 'r16f': makeTextureFormat(0, true, false, false, false, false, false, true, false, true, false, false, 1, 1, 2),
75
- 'r32f': makeTextureFormat(0, true, false, false, false, false, false, true, false, true, false, false, 1, 1, 4),
76
- 'r8ui': makeTextureFormat(0, true, false, false, false, false, false, false, true, false, false, false, 1, 1, 1),
77
- 'r8i': makeTextureFormat(0, true, false, false, false, false, false, false, true, true, false, false, 1, 1, 1),
78
- 'r16ui': makeTextureFormat(0, true, false, false, false, false, false, false, true, false, false, false, 1, 1, 2),
79
- 'r16i': makeTextureFormat(0, true, false, false, false, false, false, false, true, true, false, false, 1, 1, 2),
80
- 'r32ui': makeTextureFormat(0, true, false, false, false, false, false, false, true, false, false, false, 1, 1, 4),
81
- 'r32i': makeTextureFormat(0, true, false, false, false, false, false, false, true, true, false, false, 1, 1, 4),
82
- 'rg8unorm': makeTextureFormat(0, true, true, false, false, false, false, false, false, false, false, false, 1, 1, 2),
83
- 'rg8snorm': makeTextureFormat(0, true, true, false, false, false, false, false, false, true, false, false, 1, 1, 2),
84
- 'rg16f': makeTextureFormat(0, true, true, false, false, false, false, true, false, true, false, false, 1, 1, 4),
85
- 'rg32f': makeTextureFormat(0, true, true, false, false, false, false, true, false, true, false, false, 1, 1, 8),
86
- 'rg8ui': makeTextureFormat(0, true, true, false, false, false, false, false, true, false, false, false, 1, 1, 2),
87
- 'rg8i': makeTextureFormat(0, true, true, false, false, false, false, false, true, true, false, false, 1, 1, 2),
88
- 'rg16ui': makeTextureFormat(0, true, true, false, false, false, false, false, true, false, false, false, 1, 1, 4),
89
- 'rg16i': makeTextureFormat(0, true, true, false, false, false, false, false, true, true, false, false, 1, 1, 4),
90
- 'rg32ui': makeTextureFormat(0, true, true, false, false, false, false, false, true, false, false, false, 1, 1, 8),
91
- 'rg32i': makeTextureFormat(0, true, true, false, false, false, false, false, true, true, false, false, 1, 1, 8),
92
- 'rgba8unorm': makeTextureFormat(0, true, true, true, true, false, false, false, false, false, false, false, 1, 1, 4),
71
+ unknown: 0,
72
+ r8unorm: makeTextureFormat(0, true, false, false, false, false, false, false, false, false, false, false, 1, 1, 1),
73
+ r8snorm: makeTextureFormat(0, true, false, false, false, false, false, false, false, true, false, false, 1, 1, 1),
74
+ r16f: makeTextureFormat(0, true, false, false, false, false, false, true, false, true, false, false, 1, 1, 2),
75
+ r32f: makeTextureFormat(0, true, false, false, false, false, false, true, false, true, false, false, 1, 1, 4),
76
+ r8ui: makeTextureFormat(0, true, false, false, false, false, false, false, true, false, false, false, 1, 1, 1),
77
+ r8i: makeTextureFormat(0, true, false, false, false, false, false, false, true, true, false, false, 1, 1, 1),
78
+ r16ui: makeTextureFormat(0, true, false, false, false, false, false, false, true, false, false, false, 1, 1, 2),
79
+ r16i: makeTextureFormat(0, true, false, false, false, false, false, false, true, true, false, false, 1, 1, 2),
80
+ r32ui: makeTextureFormat(0, true, false, false, false, false, false, false, true, false, false, false, 1, 1, 4),
81
+ r32i: makeTextureFormat(0, true, false, false, false, false, false, false, true, true, false, false, 1, 1, 4),
82
+ rg8unorm: makeTextureFormat(0, true, true, false, false, false, false, false, false, false, false, false, 1, 1, 2),
83
+ rg8snorm: makeTextureFormat(0, true, true, false, false, false, false, false, false, true, false, false, 1, 1, 2),
84
+ rg16f: makeTextureFormat(0, true, true, false, false, false, false, true, false, true, false, false, 1, 1, 4),
85
+ rg32f: makeTextureFormat(0, true, true, false, false, false, false, true, false, true, false, false, 1, 1, 8),
86
+ rg8ui: makeTextureFormat(0, true, true, false, false, false, false, false, true, false, false, false, 1, 1, 2),
87
+ rg8i: makeTextureFormat(0, true, true, false, false, false, false, false, true, true, false, false, 1, 1, 2),
88
+ rg16ui: makeTextureFormat(0, true, true, false, false, false, false, false, true, false, false, false, 1, 1, 4),
89
+ rg16i: makeTextureFormat(0, true, true, false, false, false, false, false, true, true, false, false, 1, 1, 4),
90
+ rg32ui: makeTextureFormat(0, true, true, false, false, false, false, false, true, false, false, false, 1, 1, 8),
91
+ rg32i: makeTextureFormat(0, true, true, false, false, false, false, false, true, true, false, false, 1, 1, 8),
92
+ rgba8unorm: makeTextureFormat(0, true, true, true, true, false, false, false, false, false, false, false, 1, 1, 4),
93
93
  'rgba8unorm-srgb': makeTextureFormat(0, true, true, true, true, false, false, false, false, false, true, false, 1, 1, 4),
94
- 'rgba8snorm': makeTextureFormat(0, true, true, true, true, false, false, false, false, true, false, false, 1, 1, 4),
95
- 'bgra8unorm': makeTextureFormat(0, true, true, true, true, false, false, false, false, false, false, true, 1, 1, 4),
94
+ rgba8snorm: makeTextureFormat(0, true, true, true, true, false, false, false, false, true, false, false, 1, 1, 4),
95
+ bgra8unorm: makeTextureFormat(0, true, true, true, true, false, false, false, false, false, false, true, 1, 1, 4),
96
96
  'bgra8unorm-srgb': makeTextureFormat(0, true, true, true, true, false, false, false, false, false, true, true, 1, 1, 4),
97
- 'rgba16f': makeTextureFormat(0, true, true, true, true, false, false, true, false, true, false, false, 1, 1, 8),
98
- 'rgba32f': makeTextureFormat(0, true, true, true, true, false, false, true, false, true, false, false, 1, 1, 16),
99
- 'rgba8ui': makeTextureFormat(0, true, true, true, true, false, false, false, true, false, false, false, 1, 1, 4),
100
- 'rgba8i': makeTextureFormat(0, true, true, true, true, false, false, false, true, true, false, false, 1, 1, 4),
101
- 'rgba16ui': makeTextureFormat(0, true, true, true, true, false, false, false, true, false, false, false, 1, 1, 8),
102
- 'rgba16i': makeTextureFormat(0, true, true, true, true, false, false, false, true, true, false, false, 1, 1, 8),
103
- 'rgba32ui': makeTextureFormat(0, true, true, true, true, false, false, false, true, false, false, false, 1, 1, 16),
104
- 'rgba32i': makeTextureFormat(0, true, true, true, true, false, false, false, true, true, false, false, 1, 1, 16),
105
- 'rg11b10uf': makeTextureFormat(0, true, true, true, false, false, false, true, false, false, false, false, 1, 1, 4),
106
- 'd16': makeTextureFormat(0, false, false, false, false, true, false, false, false, false, false, false, 1, 1, 2),
107
- 'd24': makeTextureFormat(0, false, false, false, false, true, false, false, false, false, false, false, 0, 0, 0),
108
- 'd32f': makeTextureFormat(0, false, false, false, false, true, false, true, false, true, false, false, 1, 1, 4),
109
- 'd24s8': makeTextureFormat(0, false, false, false, false, true, true, false, false, false, false, false, 1, 1, 4),
110
- 'd32fs8': makeTextureFormat(0, false, false, false, false, true, true, true, false, true, false, false, 1, 1, 5),
97
+ rgba16f: makeTextureFormat(0, true, true, true, true, false, false, true, false, true, false, false, 1, 1, 8),
98
+ rgba32f: makeTextureFormat(0, true, true, true, true, false, false, true, false, true, false, false, 1, 1, 16),
99
+ rgba8ui: makeTextureFormat(0, true, true, true, true, false, false, false, true, false, false, false, 1, 1, 4),
100
+ rgba8i: makeTextureFormat(0, true, true, true, true, false, false, false, true, true, false, false, 1, 1, 4),
101
+ rgba16ui: makeTextureFormat(0, true, true, true, true, false, false, false, true, false, false, false, 1, 1, 8),
102
+ rgba16i: makeTextureFormat(0, true, true, true, true, false, false, false, true, true, false, false, 1, 1, 8),
103
+ rgba32ui: makeTextureFormat(0, true, true, true, true, false, false, false, true, false, false, false, 1, 1, 16),
104
+ rgba32i: makeTextureFormat(0, true, true, true, true, false, false, false, true, true, false, false, 1, 1, 16),
105
+ rg11b10uf: makeTextureFormat(0, true, true, true, false, false, false, true, false, false, false, false, 1, 1, 4),
106
+ d16: makeTextureFormat(0, false, false, false, false, true, false, false, false, false, false, false, 1, 1, 2),
107
+ d24: makeTextureFormat(0, false, false, false, false, true, false, false, false, false, false, false, 0, 0, 0),
108
+ d32f: makeTextureFormat(0, false, false, false, false, true, false, true, false, true, false, false, 1, 1, 4),
109
+ d24s8: makeTextureFormat(0, false, false, false, false, true, true, false, false, false, false, false, 1, 1, 4),
110
+ d32fs8: makeTextureFormat(0, false, false, false, false, true, true, true, false, true, false, false, 1, 1, 5),
111
111
  // compressed texture formats
112
- 'dxt1': makeTextureFormat(COMPRESSION_FORMAT_BC1, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 8),
112
+ dxt1: makeTextureFormat(COMPRESSION_FORMAT_BC1, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 8),
113
113
  'dxt1-srgb': makeTextureFormat(COMPRESSION_FORMAT_BC1, true, true, true, true, false, false, false, false, false, true, false, 4, 4, 8),
114
- 'dxt3': makeTextureFormat(COMPRESSION_FORMAT_BC2, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 16),
114
+ dxt3: makeTextureFormat(COMPRESSION_FORMAT_BC2, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 16),
115
115
  'dxt3-srgb': makeTextureFormat(COMPRESSION_FORMAT_BC2, true, true, true, true, false, false, false, false, false, true, false, 4, 4, 16),
116
- 'dxt5': makeTextureFormat(COMPRESSION_FORMAT_BC3, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 16),
116
+ dxt5: makeTextureFormat(COMPRESSION_FORMAT_BC3, true, true, true, true, false, false, false, false, false, false, false, 4, 4, 16),
117
117
  'dxt5-srgb': makeTextureFormat(COMPRESSION_FORMAT_BC3, true, true, true, true, false, false, false, false, false, true, false, 4, 4, 16)
118
118
  };
119
119
  /**
@@ -3,18 +3,21 @@ import { semanticToAttrib } from '../gpuobject.js';
3
3
  import { PBPrimitiveTypeInfo, PBPrimitiveType, PBTextureType, PBAddressSpace, PBPointerTypeInfo, typeBool, typeF32, typeI32, typeU32, typeVoid } from './types.js';
4
4
  import { PBASTError, PBTypeCastError, PBInternalError, PBParamTypeError } from './errors.js';
5
5
 
6
- const BuiltinInputStructNameVS = 'uu_VSInput';
7
- const BuiltinOutputStructNameVS = 'uu_VSOutput';
8
- const BuiltinInputStructNameFS = 'uu_FSInput';
9
- const BuiltinOutputStructNameFS = 'uu_FSOutput';
10
- const BuiltinInputStructNameCS = 'uu_CSInput';
11
- const BuiltinOutputStructNameCS = 'uu_CSOutput';
12
- const BuiltinInputStructInstanceNameVS = 'uu_VSInputCpy';
13
- const BuiltinOutputStructInstanceNameVS = 'uu_VSOutputCpy';
14
- const BuiltinInputStructInstanceNameFS = 'uu_FSInputCpy';
15
- const BuiltinOutputStructInstanceNameFS = 'uu_FSOutputCpy';
16
- const BuiltinInputStructInstanceNameCS = 'uu_CSInputCpy';
17
- const BuiltinOutputStructInstanceNameCS = 'uu_CSOutputCpy';
6
+ const BuiltinInputStructNameVS = 'zVSInput';
7
+ const BuiltinOutputStructNameVS = 'zVSOutput';
8
+ const BuiltinInputStructNameFS = 'zFSInput';
9
+ const BuiltinOutputStructNameFS = 'zFSOutput';
10
+ const BuiltinInputStructNameCS = 'zCSInput';
11
+ const BuiltinOutputStructNameCS = 'zCSOutput';
12
+ const BuiltinParamNameVS = 'zVertexInput';
13
+ const BuiltinParamNameFS = 'zVertexOutput';
14
+ const BuiltinParamNameCS = 'zComputeInput';
15
+ const BuiltinInputStructInstanceNameVS = 'zVSInputCpy';
16
+ const BuiltinOutputStructInstanceNameVS = 'zVSOutputCpy';
17
+ const BuiltinInputStructInstanceNameFS = 'zFSInputCpy';
18
+ const BuiltinOutputStructInstanceNameFS = 'zFSOutputCpy';
19
+ const BuiltinInputStructInstanceNameCS = 'zCSInputCpy';
20
+ const BuiltinOutputStructInstanceNameCS = 'zCSOutputCpy';
18
21
  var DeclareType;
19
22
  (function(DeclareType) {
20
23
  DeclareType[DeclareType["DECLARE_TYPE_NONE"] = 0] = "DECLARE_TYPE_NONE";
@@ -31,6 +34,18 @@ var ShaderPrecisionType;
31
34
  ShaderPrecisionType[ShaderPrecisionType["MEDIUM"] = 2] = "MEDIUM";
32
35
  ShaderPrecisionType[ShaderPrecisionType["LOW"] = 3] = "LOW";
33
36
  })(ShaderPrecisionType || (ShaderPrecisionType = {}));
37
+ /** @internal */ function getBuiltinParamName(shaderType) {
38
+ switch(shaderType){
39
+ case ShaderType.Vertex:
40
+ return BuiltinParamNameVS;
41
+ case ShaderType.Fragment:
42
+ return BuiltinParamNameFS;
43
+ case ShaderType.Compute:
44
+ return BuiltinParamNameCS;
45
+ default:
46
+ return null;
47
+ }
48
+ }
34
49
  /** @internal */ function getBuiltinInputStructInstanceName(shaderType) {
35
50
  switch(shaderType){
36
51
  case ShaderType.Vertex:
@@ -188,91 +203,91 @@ var ShaderPrecisionType;
188
203
  },
189
204
  webgpu: {
190
205
  vertexIndex: {
191
- name: 'ch_builtin_vertexIndex',
206
+ name: 'zVertexId',
192
207
  semantic: 'vertex_index',
193
208
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32),
194
209
  inOrOut: 'in',
195
210
  stage: 'vertex'
196
211
  },
197
212
  instanceIndex: {
198
- name: 'ch_builtin_instanceIndex',
213
+ name: 'zInstanceId',
199
214
  semantic: 'instance_index',
200
215
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32),
201
216
  inOrOut: 'in',
202
217
  stage: 'vertex'
203
218
  },
204
219
  position: {
205
- name: 'ch_builtin_position',
220
+ name: 'zPosition',
206
221
  semantic: 'position',
207
222
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.F32VEC4),
208
223
  inOrOut: 'out',
209
224
  stage: 'vertex'
210
225
  },
211
226
  fragCoord: {
212
- name: 'ch_builtin_fragCoord',
227
+ name: 'zFragCoord',
213
228
  semantic: 'position',
214
229
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.F32VEC4),
215
230
  inOrOut: 'in',
216
231
  stage: 'fragment'
217
232
  },
218
233
  frontFacing: {
219
- name: 'ch_builtin_frontFacing',
234
+ name: 'zFrontFacing',
220
235
  semantic: 'front_facing',
221
236
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.BOOL),
222
237
  inOrOut: 'in',
223
238
  stage: 'fragment'
224
239
  },
225
240
  fragDepth: {
226
- name: 'ch_builtin_fragDepth',
241
+ name: 'zFragDepth',
227
242
  semantic: 'frag_depth',
228
243
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.F32),
229
244
  inOrOut: 'out',
230
245
  stage: 'fragment'
231
246
  },
232
247
  localInvocationId: {
233
- name: 'ch_builtin_localInvocationId',
248
+ name: 'zLocalInvocationId',
234
249
  semantic: 'local_invocation_id',
235
250
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32VEC3),
236
251
  inOrOut: 'in',
237
252
  stage: 'compute'
238
253
  },
239
254
  globalInvocationId: {
240
- name: 'ch_builtin_globalInvocationId',
255
+ name: 'zGlobalInvocationId',
241
256
  semantic: 'global_invocation_id',
242
257
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32VEC3),
243
258
  inOrOut: 'in',
244
259
  stage: 'compute'
245
260
  },
246
261
  workGroupId: {
247
- name: 'ch_builtin_workGroupId',
262
+ name: 'zWorkGroupId',
248
263
  semantic: 'workgroup_id',
249
264
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32VEC3),
250
265
  inOrOut: 'in',
251
266
  stage: 'compute'
252
267
  },
253
268
  numWorkGroups: {
254
- name: 'ch_builtin_numWorkGroups',
269
+ name: 'zNumWorkGroups',
255
270
  semantic: 'num_workgroups',
256
271
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32VEC3),
257
272
  inOrOut: 'in',
258
273
  stage: 'compute'
259
274
  },
260
275
  sampleMaskIn: {
261
- name: 'ch_builtin_sampleMaskIn',
276
+ name: 'zSampleMaskIn',
262
277
  semantic: 'sample_mask_in',
263
278
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32),
264
279
  inOrOut: 'in',
265
280
  stage: 'fragment'
266
281
  },
267
282
  sampleMaskOut: {
268
- name: 'ch_builtin_sampleMaskOut',
283
+ name: 'zSampleMaskOut',
269
284
  semantic: 'sample_mask_out',
270
285
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32),
271
286
  inOrOut: 'out',
272
287
  stage: 'fragment'
273
288
  },
274
289
  sampleIndex: {
275
- name: 'ch_builtin_sampleIndex',
290
+ name: 'zSampleIndex',
276
291
  semantic: 'sample_index',
277
292
  type: new PBPrimitiveTypeInfo(PBPrimitiveType.U32),
278
293
  inOrOut: 'in',
@@ -1611,13 +1626,7 @@ function unbracket(e) {
1611
1626
  return `${this.isStatement ? indent : ''}${this.name}(${args.join(',')})${this.isStatement ? ';\n' : ''}`;
1612
1627
  }
1613
1628
  toWGSL(indent, ctx) {
1614
- let thisArgs = this.args.filter((val)=>{
1615
- const type = val.getType();
1616
- if (val instanceof ASTPrimitive && type.isStructType() && ctx.types.findIndex((t)=>t instanceof ASTStructDefine && t.type.structName === type.structName) < 0) {
1617
- return false;
1618
- }
1619
- return true;
1620
- });
1629
+ let thisArgs = this.args;
1621
1630
  if (this.func) {
1622
1631
  let argsNew;
1623
1632
  const convertedArgs = convertArgs(thisArgs, this.func.funcType);
@@ -1627,7 +1636,13 @@ function unbracket(e) {
1627
1636
  if (!argsNew) {
1628
1637
  throw new Error(`no matching overloading found for function '${this.name}'`);
1629
1638
  }
1630
- thisArgs = argsNew;
1639
+ thisArgs = argsNew.filter((val)=>{
1640
+ const type = val.getType();
1641
+ if (type.isStructType() && ctx.types.findIndex((t)=>t instanceof ASTStructDefine && t.type.structName === type.structName) < 0) {
1642
+ return false;
1643
+ }
1644
+ return true;
1645
+ });
1631
1646
  }
1632
1647
  const args = thisArgs.map((arg)=>unbracket(arg.toWGSL(indent, ctx)));
1633
1648
  return `${this.isStatement ? indent : ''}${this.name}(${args.join(',')})${this.isStatement ? ';\n' : ''}`;
@@ -1986,10 +2001,7 @@ function unbracket(e) {
1986
2001
  }
1987
2002
  }
1988
2003
  toWebGL(indent, ctx) {
1989
- let str = `${indent}do {\n`;
1990
- str += super.toWebGL(indent + ' ', ctx);
1991
- str += `${indent}} while(${unbracket(this.condition.toWebGL(indent, ctx))});\n`;
1992
- return str;
2004
+ throw new Error(`No do-while() loop support for WebGL1.0 device`);
1993
2005
  }
1994
2006
  toWebGL2(indent, ctx) {
1995
2007
  let str = `${indent}do {\n`;
@@ -2015,8 +2027,10 @@ function unbracket(e) {
2015
2027
  }
2016
2028
  }
2017
2029
  toWebGL(indent, ctx) {
2018
- let str = `${indent}while(${unbracket(this.condition.toWebGL(indent, ctx))}) {\n`;
2019
- str += super.toWebGL(indent + ' ', ctx);
2030
+ let str = `${indent}for(int z_tmp_counter = 0; z_tmp_counter == 0; z_tmp_counter += 0) {\n`;
2031
+ const indent2 = indent + ' ';
2032
+ str += `${indent2}if(!(${unbracket(this.condition.toWebGL(indent, ctx))})){ break; }\n`;
2033
+ str += super.toWebGL(indent2, ctx);
2020
2034
  str += `${indent}}\n`;
2021
2035
  return str;
2022
2036
  }
@@ -2131,5 +2145,5 @@ function convertArgs(args, overload) {
2131
2145
  };
2132
2146
  }
2133
2147
 
2134
- export { ASTAddressOf, ASTArrayIndex, ASTAssignment, ASTBinaryFunc, ASTBreak, ASTCallFunction, ASTCast, ASTContinue, ASTDeclareVar, ASTDiscard, ASTDoWhile, ASTExpression, ASTFunction, ASTFunctionParameter, ASTGlobalScope, ASTHash, ASTIf, ASTLValue, ASTLValueArray, ASTLValueDeclare, ASTLValueHash, ASTLValueScalar, ASTNakedScope, ASTPrimitive, ASTRange, ASTReferenceOf, ASTReturn, ASTScalar, ASTScope, ASTSelect, ASTShaderExpConstructor, ASTStructDefine, ASTTouch, ASTUnaryFunc, ASTWhile, DeclareType, ShaderAST, ShaderPrecisionType, builtinVariables, genSamplerName, getBuiltinInputStructInstanceName, getBuiltinInputStructName, getBuiltinOutputStructInstanceName, getBuiltinOutputStructName, getTextureSampleType };
2148
+ export { ASTAddressOf, ASTArrayIndex, ASTAssignment, ASTBinaryFunc, ASTBreak, ASTCallFunction, ASTCast, ASTContinue, ASTDeclareVar, ASTDiscard, ASTDoWhile, ASTExpression, ASTFunction, ASTFunctionParameter, ASTGlobalScope, ASTHash, ASTIf, ASTLValue, ASTLValueArray, ASTLValueDeclare, ASTLValueHash, ASTLValueScalar, ASTNakedScope, ASTPrimitive, ASTRange, ASTReferenceOf, ASTReturn, ASTScalar, ASTScope, ASTSelect, ASTShaderExpConstructor, ASTStructDefine, ASTTouch, ASTUnaryFunc, ASTWhile, DeclareType, ShaderAST, ShaderPrecisionType, builtinVariables, genSamplerName, getBuiltinInputStructInstanceName, getBuiltinInputStructName, getBuiltinOutputStructInstanceName, getBuiltinOutputStructName, getBuiltinParamName, getTextureSampleType };
2135
2149
  //# sourceMappingURL=ast.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { ShaderPrecisionType, ASTPrimitive, DeclareType, getTextureSampleType, ASTArrayIndex, ASTScalar, ASTCast, ASTAssignment, ASTLValueArray, ASTLValueScalar, ASTHash, ASTLValueHash, ASTShaderExpConstructor } from './ast.js';
1
+ import { ShaderPrecisionType, ASTPrimitive, DeclareType, getTextureSampleType, ASTArrayIndex, ASTScalar, ASTCast, ASTAssignment, ASTLValueArray, ASTLValueScalar, ASTShaderExpConstructor, ASTHash, ASTLValueHash } from './ast.js';
2
2
  import { PBPointerTypeInfo, PBAddressSpace, PBArrayTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, typeI32 } from './types.js';
3
3
  import { PBASTError } from './errors.js';
4
4
 
@@ -326,6 +326,12 @@ let uidExp = 0;
326
326
  return this;
327
327
  }
328
328
  /**
329
+ * Whether this is a constructor
330
+ * @returns true if this is a constructor
331
+ */ isConstructor() {
332
+ return this.$ast instanceof ASTShaderExpConstructor && this.$ast.args.length === 0;
333
+ }
334
+ /**
329
335
  * Determine if this variable is of vector type
330
336
  * @returns true if the variable is of vector type, otherwise false
331
337
  */ isVector() {
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -3632,6 +3632,10 @@ const builtinFunctionsAll = {
3632
3632
  if (!texType.isTextureType()) {
3633
3633
  throw new PBParamTypeError('textureSampleLevel', 'texture');
3634
3634
  }
3635
+ if (pb.getDevice().type === 'webgl' && pb.shaderKind === 'vertex') {
3636
+ // WebGL1 does not support vertex texture lod
3637
+ return pb.textureSample(tex, args[1]);
3638
+ }
3635
3639
  if (pb.getDevice().type === 'webgpu') {
3636
3640
  if (texType.isExternalTexture()) {
3637
3641
  return pb.textureLoad(tex, pb.ivec2(args[1]), 0);
@@ -1 +1 @@
1
- {"version":3,"file":"builtinfunc.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2,7 +2,7 @@ import { ShaderType } from '../base_types.js';
2
2
  import { MAX_BINDING_GROUPS, getVertexAttribByName } from '../gpuobject.js';
3
3
  import { PBReflection } from './reflection.js';
4
4
  import { setCurrentProgramBuilder, PBShaderExp, getCurrentProgramBuilder, makeConstructor, Proxiable } from './base.js';
5
- import { ASTAddressOf, ASTReferenceOf, ASTStructDefine, ASTShaderExpConstructor, getBuiltinInputStructName, getBuiltinOutputStructName, getBuiltinInputStructInstanceName, getBuiltinOutputStructInstanceName, builtinVariables, ASTDeclareVar, ASTScalar, ASTDiscard, DeclareType, ASTPrimitive, ASTAssignment, ASTLValueScalar, genSamplerName, ASTCallFunction, ASTTouch, ASTLValueDeclare, ASTGlobalScope, ASTFunctionParameter, ASTFunction, ASTScope, ASTReturn, ASTNakedScope, ASTIf, ASTSelect, ASTBreak, ASTContinue, ASTRange, ASTDoWhile, ASTWhile } from './ast.js';
5
+ import { ASTAddressOf, ASTReferenceOf, ASTStructDefine, ASTShaderExpConstructor, getBuiltinInputStructName, getBuiltinOutputStructName, getBuiltinInputStructInstanceName, getBuiltinOutputStructInstanceName, builtinVariables, ASTDeclareVar, getBuiltinParamName, ASTScalar, ASTDiscard, DeclareType, ASTPrimitive, ASTAssignment, ASTLValueScalar, genSamplerName, ASTCallFunction, ASTTouch, ASTLValueDeclare, ASTGlobalScope, ASTFunctionParameter, ASTFunction, ASTScope, ASTReturn, ASTNakedScope, ASTIf, ASTSelect, ASTBreak, ASTContinue, ASTRange, ASTDoWhile, ASTWhile } from './ast.js';
6
6
  import { PBDeviceNotSupport, PBReferenceValueRequired, PBPointerValueRequired, PBParamValueError, PBInternalError, PBParamLengthError, PBParamTypeError, PBTypeCastError, PBValueOutOfRange, PBError, PBNonScopedFunctionCall, PBASTError } from './errors.js';
7
7
  import { setBuiltinFuncs } from './builtinfunc.js';
8
8
  import { setConstructors } from './constructors.js';
@@ -16,9 +16,9 @@ const SHARED_UNIFORM_NAME = 'ch_shared_uniform_block';
16
16
  const VERTEX_STORAGE_NAME = 'ch_vertex_storage_block';
17
17
  const FRAGMENT_STORAGE_NAME = 'ch_fragment_storage_block';
18
18
  const SHARED_STORAGE_NAME = 'ch_shared_storage_block';
19
- const input_prefix = 'uu_in_';
20
- const output_prefix_vs = 'uu_vsout_';
21
- const output_prefix_fs = 'uu_fsout_';
19
+ const input_prefix = 'zVSInput_';
20
+ const output_prefix_vs = 'zVSOutput_';
21
+ const output_prefix_fs = 'zFSOutput_';
22
22
  /**
23
23
  * The program builder class
24
24
  * @public
@@ -134,6 +134,13 @@ const output_prefix_fs = 'uu_fsout_';
134
134
  /** Gets the current scope */ getCurrentScope() {
135
135
  return this._scopeStack[0];
136
136
  }
137
+ /** Gets the current function scope */ getCurrentFunctionScope() {
138
+ let funcScope = this.getCurrentScope();
139
+ while(funcScope && !(funcScope instanceof PBFunctionScope)){
140
+ funcScope = funcScope.$parent;
141
+ }
142
+ return funcScope;
143
+ }
137
144
  /**
138
145
  * Generates shader codes for a render program
139
146
  * @param options - The build options
@@ -289,7 +296,7 @@ const output_prefix_fs = 'uu_fsout_';
289
296
  return true;
290
297
  }
291
298
  /** @internal */ generateStructureName() {
292
- return `uu_GeneratedStruct${this._autoStructureTypeIndex++}`;
299
+ return `zStruct${this._autoStructureTypeIndex++}`;
293
300
  }
294
301
  /** @internal */ getVertexAttributes() {
295
302
  return this._vertexAttributes;
@@ -533,7 +540,7 @@ const output_prefix_fs = 'uu_fsout_';
533
540
  const structType = this.internalDefineStructByType(this._shaderType, false, new PBStructTypeInfo(structName, 'default', args));
534
541
  this.findStructType(structName, shaderType).prefix = prefix;
535
542
  const structInstance = this.struct(structName, instanceName);
536
- const structInstanceIN = inOrOut === 'in' ? this.struct(structName, 'uu_AppInput') : structInstance;
543
+ const structInstanceIN = inOrOut === 'in' ? this.struct(structName, getBuiltinParamName(shaderType)) : structInstance;
537
544
  return [
538
545
  structType,
539
546
  structInstance,
@@ -665,23 +672,35 @@ const output_prefix_fs = 'uu_fsout_';
665
672
  }
666
673
  /** @internal */ in(location, name, variable) {
667
674
  if (this._inputs[location]) {
668
- throw new Error(`input location ${location} already declared`);
669
- }
670
- variable.$location = location;
671
- variable.$declareType = DeclareType.DECLARE_TYPE_IN;
672
- this._inputs[location] = [
673
- name,
674
- new ASTDeclareVar(new ASTPrimitive(variable))
675
- ];
676
- Object.defineProperty(this._inputScope, name, {
677
- get: function() {
678
- return variable;
679
- },
680
- set: function() {
681
- throw new Error(`cannot assign to readonly variable: ${name}`);
675
+ // input already exists, create an alias
676
+ if (!this._inputScope[name]) {
677
+ Object.defineProperty(this._inputScope, name, {
678
+ get: function() {
679
+ return variable;
680
+ },
681
+ set: function() {
682
+ throw new Error(`cannot assign to readonly variable: ${name}`);
683
+ }
684
+ });
682
685
  }
683
- });
684
- variable.$tags.forEach((val)=>this.tagShaderExp(()=>variable, val));
686
+ //throw new Error(`input location ${location} already declared`);
687
+ } else {
688
+ variable.$location = location;
689
+ variable.$declareType = DeclareType.DECLARE_TYPE_IN;
690
+ this._inputs[location] = [
691
+ name,
692
+ new ASTDeclareVar(new ASTPrimitive(variable))
693
+ ];
694
+ Object.defineProperty(this._inputScope, name, {
695
+ get: function() {
696
+ return variable;
697
+ },
698
+ set: function() {
699
+ throw new Error(`cannot assign to readonly variable: ${name}`);
700
+ }
701
+ });
702
+ variable.$tags.forEach((val)=>this.tagShaderExp(()=>variable, val));
703
+ }
685
704
  }
686
705
  /** @internal */ out(location, name, variable) {
687
706
  if (this._outputs[location]) {
@@ -900,6 +919,11 @@ const output_prefix_fs = 'uu_fsout_';
900
919
  }
901
920
  body && body.call(this._globalScope, this);
902
921
  this.popScope();
922
+ // Global delcarations should be at the first
923
+ this._globalScope.$ast.statements = [
924
+ ...this._globalScope.$ast.statements.filter((val)=>val instanceof ASTDeclareVar || val instanceof ASTAssignment),
925
+ ...this._globalScope.$ast.statements.filter((val)=>!(val instanceof ASTDeclareVar) && !(val instanceof ASTAssignment))
926
+ ];
903
927
  }
904
928
  /** @internal */ generateRenderSource(shaderType, scope, builtinScope, inputs, outputs) {
905
929
  const context = {
@@ -1493,7 +1517,7 @@ const output_prefix_fs = 'uu_fsout_';
1493
1517
  * @param semantic - The vertex semantic
1494
1518
  * @returns The input vertex attribute or null if not exists
1495
1519
  */ $getVertexAttrib(semantic) {
1496
- return getCurrentProgramBuilder().getReflection().attribute(semantic);
1520
+ return this.$inputs.$getVertexAttrib(semantic); // getCurrentProgramBuilder().getReflection().attribute(semantic);
1497
1521
  }
1498
1522
  /** Get the current local scope */ get $l() {
1499
1523
  return this.$_getLocalScope();
@@ -1744,6 +1768,11 @@ const output_prefix_fs = 'uu_fsout_';
1744
1768
  this[prop] = value;
1745
1769
  return true;
1746
1770
  }
1771
+ if (!(this.$_scope instanceof PBGlobalScope) && value instanceof PBShaderExp && (value.isConstructor() || value.$typeinfo.isTextureType() && value.$ast instanceof ASTPrimitive && !value.$ast.name) && value.$declareType === DeclareType.DECLARE_TYPE_UNIFORM) {
1772
+ // We are setting uniform a uniform, should invoke in the global scope
1773
+ this.$g[prop] = value;
1774
+ return true;
1775
+ }
1747
1776
  const val = this.$_scope.$localGet(prop);
1748
1777
  if (val === undefined) {
1749
1778
  const type = getCurrentProgramBuilder().guessExpValueType(value);
@@ -1816,6 +1845,9 @@ const output_prefix_fs = 'uu_fsout_';
1816
1845
  const v = builtinVariables[pb.getDevice().type];
1817
1846
  const info = v[name];
1818
1847
  const inout = info.inOrOut;
1848
+ if (inout === 'in') {
1849
+ return pb.getCurrentFunctionScope()[getBuiltinParamName(pb.shaderType)][info.name];
1850
+ }
1819
1851
  const structName = inout === 'in' ? getBuiltinInputStructInstanceName(pb.shaderType) : getBuiltinOutputStructInstanceName(pb.shaderType);
1820
1852
  const scope = pb.getCurrentScope();
1821
1853
  if (!scope[structName] || !scope[structName][info.name]) {
@@ -1835,18 +1867,46 @@ const output_prefix_fs = 'uu_fsout_';
1835
1867
  * The input scope of a shader
1836
1868
  * @public
1837
1869
  */ class PBInputScope extends PBScope {
1870
+ /** @internal */ $_names;
1871
+ $_aliases;
1838
1872
  /** @internal */ constructor(){
1839
1873
  super(null);
1874
+ this.$_names = {};
1875
+ this.$_aliases = {};
1876
+ }
1877
+ /** @internal */ $getVertexAttrib(attrib) {
1878
+ const name = this.$_names[attrib];
1879
+ return name ? this[name] : null;
1840
1880
  }
1841
1881
  /** @internal */ $_getLocalScope() {
1842
1882
  return null;
1843
1883
  }
1884
+ /** @internal */ $get(prop) {
1885
+ if (prop[0] === '$') {
1886
+ return this[prop];
1887
+ }
1888
+ if (this.$_aliases[prop]) {
1889
+ prop = this.$_aliases[prop];
1890
+ }
1891
+ const pb = this.$builder;
1892
+ if (pb.getDevice().type === 'webgpu') {
1893
+ const param = pb.getCurrentFunctionScope()[getBuiltinParamName(pb.shaderType)];
1894
+ const prefix = pb.shaderKind === 'vertex' ? input_prefix : output_prefix_vs;
1895
+ const name = `${prefix}${prop}`;
1896
+ if (param.$typeinfo.structMembers.findIndex((val)=>val.name === name) < 0) {
1897
+ return undefined;
1898
+ }
1899
+ return param[`${prefix}${prop}`];
1900
+ }
1901
+ return super.$get(prop);
1902
+ }
1844
1903
  /** @internal */ $set(prop, value) {
1845
1904
  if (prop[0] === '$') {
1846
1905
  this[prop] = value;
1847
- } else if (prop in this) {
1848
- throw new Error(`Can not assign to shader input variable: "${prop}"`);
1849
1906
  } else {
1907
+ if (!(value instanceof PBShaderExp)) {
1908
+ throw new Error(`invalid vertex input value`);
1909
+ }
1850
1910
  const st = getCurrentProgramBuilder().shaderType;
1851
1911
  if (st !== ShaderType.Vertex) {
1852
1912
  throw new Error(`shader input variables can only be declared in vertex shader: "${prop}"`);
@@ -1856,7 +1916,15 @@ const output_prefix_fs = 'uu_fsout_';
1856
1916
  throw new Error(`can not declare shader input variable: invalid vertex attribute: "${prop}"`);
1857
1917
  }
1858
1918
  if (getCurrentProgramBuilder()._vertexAttributes.indexOf(attrib) >= 0) {
1859
- throw new Error(`can not declare shader input variable: attribute already declared: "${prop}"`);
1919
+ const lastName = this.$_names[value.$attrib];
1920
+ if (prop !== lastName) {
1921
+ const p = this[lastName];
1922
+ if (p.$typeinfo.typeId !== value.$typeinfo.typeId) {
1923
+ throw new Error(`can not declare shader input variable: attribute already declared with different type: "${prop}"`);
1924
+ }
1925
+ this.$_aliases[prop] = lastName;
1926
+ }
1927
+ return true;
1860
1928
  }
1861
1929
  if (!(value instanceof PBShaderExp) || !(value.$ast instanceof ASTShaderExpConstructor)) {
1862
1930
  throw new Error(`invalid shader input variable declaration: "${prop}"`);
@@ -1865,11 +1933,12 @@ const output_prefix_fs = 'uu_fsout_';
1865
1933
  if (!type.isPrimitiveType() || type.isMatrixType() || type.primitiveType === PBPrimitiveType.BOOL) {
1866
1934
  throw new Error(`type cannot be used as pipeline input/output: ${prop}`);
1867
1935
  }
1936
+ this.$_names[value.$attrib] = prop;
1868
1937
  const location = getCurrentProgramBuilder()._inputs.length;
1869
1938
  const exp = new PBShaderExp(`${input_prefix}${prop}`, type).tag(...value.$tags);
1870
1939
  getCurrentProgramBuilder().in(location, prop, exp);
1871
1940
  getCurrentProgramBuilder()._vertexAttributes.push(attrib);
1872
- getCurrentProgramBuilder().getReflection().setAttrib(value.$attrib, exp);
1941
+ //getCurrentProgramBuilder().getReflection().setAttrib(value.$attrib, exp);
1873
1942
  // modify input struct for webgpu
1874
1943
  if (getCurrentProgramBuilder().getDevice().type === 'webgpu') {
1875
1944
  if (getCurrentProgramBuilder().findStructType(getBuiltinInputStructName(st), st)) {
@@ -1927,30 +1996,43 @@ const output_prefix_fs = 'uu_fsout_';
1927
1996
  * The global scope of a shader
1928
1997
  * @public
1929
1998
  */ class PBGlobalScope extends PBScope {
1999
+ /** @internal */ $_inputStructInfo;
1930
2000
  /** @internal */ constructor(){
1931
2001
  super(new ASTGlobalScope());
2002
+ this.$_inputStructInfo = null;
2003
+ }
2004
+ /** @internal */ get $inputStructInfo() {
2005
+ if (!this.$_inputStructInfo) {
2006
+ this.$_inputStructInfo = this.$builder.defineBuiltinStruct(this.$builder.shaderType, 'in');
2007
+ }
2008
+ return this.$_inputStructInfo;
2009
+ }
2010
+ /** @internal */ get $inputStruct() {
2011
+ return this.$inputStructInfo[0];
1932
2012
  }
1933
2013
  /** @internal */ $mainFunc(body) {
1934
2014
  const pb = getCurrentProgramBuilder();
1935
2015
  if (pb.getDevice().type === 'webgpu') {
1936
- const inputStruct = pb.defineBuiltinStruct(pb.shaderType, 'in');
1937
- this.$local(inputStruct[1]);
2016
+ const inputStruct = this.$inputStructInfo;
2017
+ //this.$local(inputStruct[1]);
1938
2018
  const isCompute = pb.shaderType === ShaderType.Compute;
1939
2019
  const outputStruct = isCompute ? null : pb.defineBuiltinStruct(pb.shaderType, 'out');
1940
- if (!isCompute) {
2020
+ if (outputStruct) {
1941
2021
  this.$local(outputStruct[1]);
1942
2022
  }
1943
- this.$internalCreateFunction('chMainStub', [], false, body);
2023
+ // this.$internalCreateFunction('chMainStub', [], false, body);
1944
2024
  this.$internalCreateFunction('main', inputStruct ? [
1945
2025
  inputStruct[3]
1946
2026
  ] : [], true, function() {
1947
- if (inputStruct) {
1948
- this[inputStruct[1].$str] = this[inputStruct[3].$str];
1949
- }
1950
- if (pb.shaderType === ShaderType.Fragment && pb.emulateDepthClamp) {
2027
+ /*
2028
+ if (inputStruct) {
2029
+ this[inputStruct[1].$str] = this[inputStruct[3].$str];
2030
+ }
2031
+ */ if (pb.shaderType === ShaderType.Fragment && pb.emulateDepthClamp) {
1951
2032
  this.$builtins.fragDepth = pb.clamp(this.$inputs.clamppedDepth, 0, 1);
1952
2033
  }
1953
- this.chMainStub();
2034
+ body?.call(this);
2035
+ //this.chMainStub();
1954
2036
  if (pb.shaderType === ShaderType.Vertex) {
1955
2037
  if (pb.depthRangeCorrection) {
1956
2038
  this.$builtins.position.z = pb.mul(pb.add(this.$builtins.position.z, this.$builtins.position.w), 0.5);
@@ -1996,6 +2078,9 @@ const output_prefix_fs = 'uu_fsout_';
1996
2078
  }
1997
2079
  /** @internal */ $internalCreateFunction(name, params, isMain, body) {
1998
2080
  const pb = getCurrentProgramBuilder();
2081
+ if (pb.getDevice().type === 'webgpu' && !isMain) {
2082
+ params.push(this.$inputStruct(getBuiltinParamName(pb.shaderType)));
2083
+ }
1999
2084
  params.forEach((param)=>{
2000
2085
  if (!(param.$ast instanceof ASTPrimitive)) {
2001
2086
  throw new Error(`${name}(): invalid function definition`);
@@ -2055,7 +2140,21 @@ const output_prefix_fs = 'uu_fsout_';
2055
2140
  throw new Error(`function ${name} not found`);
2056
2141
  }
2057
2142
  return (...args)=>{
2058
- const argsNonArray = args.map((val)=>pb.normalizeExpValue(val));
2143
+ let inputArg = null;
2144
+ if (pb.getDevice().type === 'webgpu') {
2145
+ let funcScope = pb.getCurrentScope();
2146
+ while(funcScope && !(funcScope instanceof PBFunctionScope)){
2147
+ funcScope = funcScope.$parent;
2148
+ }
2149
+ const funcArgs = funcScope.$ast.args;
2150
+ const arg = funcArgs[funcArgs.length - 1].paramAST;
2151
+ const name = arg.name;
2152
+ inputArg = funcScope[name];
2153
+ }
2154
+ const argsNonArray = (inputArg ? [
2155
+ ...args,
2156
+ inputArg
2157
+ ] : args).map((val)=>pb.normalizeExpValue(val));
2059
2158
  const funcType = pb._getFunctionOverload(name, argsNonArray);
2060
2159
  if (!funcType) {
2061
2160
  throw new Error(`ERROR: no matching overloads for function ${name}`);
@@ -2193,6 +2292,9 @@ const output_prefix_fs = 'uu_fsout_';
2193
2292
  * @param body - Generator function for the scope that inside the do..while statment
2194
2293
  * @returns The scope that inside the do..while statement
2195
2294
  */ $do(body) {
2295
+ if (this.$builder.getDevice().type === 'webgl') {
2296
+ throw new Error(`No do-while() loop support for WebGL1.0 device`);
2297
+ }
2196
2298
  const astDoWhile = new ASTDoWhile(null);
2197
2299
  this.$ast.statements.push(astDoWhile);
2198
2300
  return new PBDoWhileScope(this, astDoWhile, body);
@@ -2233,6 +2335,9 @@ const output_prefix_fs = 'uu_fsout_';
2233
2335
  body && body.call(this);
2234
2336
  getCurrentProgramBuilder().popScope();
2235
2337
  }
2338
+ $isMain() {
2339
+ return this.$ast.isMainFunc;
2340
+ }
2236
2341
  }
2237
2342
  /**
2238
2343
  * Scope that insides a while statement
@@ -1 +1 @@
1
- {"version":3,"file":"programbuilder.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -334,23 +334,23 @@ const textureTypeMapWGSL = {
334
334
  [PBTextureType.TEX_EXTERNAL]: 'texture_external'
335
335
  };
336
336
  const storageTexelFormatMap = {
337
- 'rgba8unorm': 'rgba8unorm',
338
- 'rgba8snorm': 'rgba8snorm',
339
- 'bgra8unorm': 'bgra8unorm',
340
- 'rgba8ui': 'rgba8uint',
341
- 'rgba8i': 'rgba8sint',
342
- 'rgba16ui': 'rgba16uint',
343
- 'rgba16i': 'rgba16sint',
344
- 'rgba16f': 'rgba16float',
345
- 'r32f': 'r32float',
346
- 'r32ui': 'r32uint',
347
- 'r32i': 'r32sint',
348
- 'rg32f': 'rg32float',
349
- 'rg32ui': 'rg32uint',
350
- 'rg32i': 'rg32sint',
351
- 'rgba32f': 'rgba32float',
352
- 'rgba32ui': 'rgba32uint',
353
- 'rgba32i': 'rgba32sint'
337
+ rgba8unorm: 'rgba8unorm',
338
+ rgba8snorm: 'rgba8snorm',
339
+ bgra8unorm: 'bgra8unorm',
340
+ rgba8ui: 'rgba8uint',
341
+ rgba8i: 'rgba8sint',
342
+ rgba16ui: 'rgba16uint',
343
+ rgba16i: 'rgba16sint',
344
+ rgba16f: 'rgba16float',
345
+ r32f: 'r32float',
346
+ r32ui: 'r32uint',
347
+ r32i: 'r32sint',
348
+ rg32f: 'rg32float',
349
+ rg32ui: 'rg32uint',
350
+ rg32i: 'rg32sint',
351
+ rgba32f: 'rgba32float',
352
+ rgba32ui: 'rgba32uint',
353
+ rgba32i: 'rgba32sint'
354
354
  };
355
355
  var PBSamplerAccessMode;
356
356
  (function(PBSamplerAccessMode) {
@@ -36,9 +36,9 @@
36
36
  }
37
37
  }
38
38
  /**
39
- * The font class
40
- * @public
41
- */ class Font {
39
+ * The font class
40
+ * @public
41
+ */ class Font {
42
42
  /** @internal */ static fontCache = {};
43
43
  /** @internal */ _name;
44
44
  /** @internal */ _nameScaled;
@@ -51,10 +51,10 @@
51
51
  /** @internal */ _bottomScaled;
52
52
  /** @internal */ _div;
53
53
  /**
54
- * Creates a instance of font class from font name and the scale value
55
- * @param name - The font name
56
- * @param scale - The scale value
57
- */ constructor(name, scale){
54
+ * Creates a instance of font class from font name and the scale value
55
+ * @param name - The font name
56
+ * @param scale - The scale value
57
+ */ constructor(name, scale){
58
58
  this._top = 0;
59
59
  this._bottom = 0;
60
60
  this._size = 0;
@@ -70,11 +70,11 @@
70
70
  }
71
71
  }
72
72
  /**
73
- * Fetch a font from cache
74
- * @param name - The font name
75
- * @param scale - The scale value
76
- * @returns The font object
77
- */ static fetchFont(name, scale) {
73
+ * Fetch a font from cache
74
+ * @param name - The font name
75
+ * @param scale - The scale value
76
+ * @returns The font object
77
+ */ static fetchFont(name, scale) {
78
78
  let fontlist = this.fontCache[name];
79
79
  if (!fontlist) {
80
80
  fontlist = {};
@@ -56,7 +56,7 @@ import { TextureAtlasManager } from './textureatlas.js';
56
56
  * @param charMargin - Margin size between characters
57
57
  * @param start - Start index of the string to be clipped
58
58
  * @param font - Font of the string
59
- * @returns
59
+ * @returns
60
60
  */ clipStringToWidth(str, width, charMargin, start, font) {
61
61
  let sum = 0;
62
62
  let i = start;
package/dist/index.d.ts CHANGED
@@ -273,11 +273,11 @@ declare abstract class PBTypeInfo<DetailType extends TypeDetailInfo = TypeDetail
273
273
  */
274
274
  isCompatibleType(other: PBTypeInfo): boolean;
275
275
  /**
276
- * Creates a buffer layout from this type
277
- * @param offset - Byte offset of the layout
278
- * @param layout - Type of the layout
279
- * @returns The created buffer layout
280
- */
276
+ * Creates a buffer layout from this type
277
+ * @param offset - Byte offset of the layout
278
+ * @param layout - Type of the layout
279
+ * @returns The created buffer layout
280
+ */
281
281
  abstract toBufferLayout(offset: number, layout: PBStructLayout): UniformBufferLayout;
282
282
  }
283
283
  /**
@@ -1282,6 +1282,11 @@ declare class PBShaderExp extends Proxiable<PBShaderExp> {
1282
1282
  * @returns self
1283
1283
  */
1284
1284
  lowp(): PBShaderExp;
1285
+ /**
1286
+ * Whether this is a constructor
1287
+ * @returns true if this is a constructor
1288
+ */
1289
+ isConstructor(): boolean;
1285
1290
  /**
1286
1291
  * Determine if this variable is of vector type
1287
1292
  * @returns true if the variable is of vector type, otherwise false
@@ -2102,6 +2107,8 @@ declare class ProgramBuilder {
2102
2107
  set emulateDepthClamp(val: boolean);
2103
2108
  /** Get the shader code reflection interface */
2104
2109
  getReflection(): PBReflection;
2110
+ /** Gets the current function scope */
2111
+ getCurrentFunctionScope(): PBFunctionScope;
2105
2112
  }
2106
2113
  /**
2107
2114
  * Base class for scope of the shader program
@@ -2178,6 +2185,7 @@ declare class PBBuiltinScope extends PBScope {
2178
2185
  * @public
2179
2186
  */
2180
2187
  declare class PBInputScope extends PBScope {
2188
+ private $_aliases;
2181
2189
  }
2182
2190
  /**
2183
2191
  * The output scope of a shader
@@ -2253,6 +2261,7 @@ declare class PBInsideFunctionScope extends PBScope {
2253
2261
  * @public
2254
2262
  */
2255
2263
  declare class PBFunctionScope extends PBInsideFunctionScope {
2264
+ $isMain(): boolean;
2256
2265
  }
2257
2266
  /**
2258
2267
  * Scope that insides a while statement
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ export { VertexData } from './vertexdata.js';
3
3
  export { GPUResourceUsageFlags, MAX_BINDING_GROUPS, MAX_TEXCOORD_INDEX_COUNT, MAX_VERTEX_ATTRIBUTES, VERTEX_ATTRIB_BLEND_INDICES, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_DIFFUSE, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TANGENT, VERTEX_ATTRIB_TEXCOORD0, VERTEX_ATTRIB_TEXCOORD1, VERTEX_ATTRIB_TEXCOORD2, VERTEX_ATTRIB_TEXCOORD3, VERTEX_ATTRIB_TEXCOORD4, VERTEX_ATTRIB_TEXCOORD5, VERTEX_ATTRIB_TEXCOORD6, VERTEX_ATTRIB_TEXCOORD7, genDefaultName, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatSize, makeVertexBufferType, semanticList, semanticToAttrib } from './gpuobject.js';
4
4
  export { BaseDevice } from './device.js';
5
5
  export { PBShaderExp, Proxiable, getCurrentProgramBuilder, makeConstructor, setCurrentProgramBuilder } from './builder/base.js';
6
- export { ASTAddressOf, ASTArrayIndex, ASTAssignment, ASTBinaryFunc, ASTBreak, ASTCallFunction, ASTCast, ASTContinue, ASTDeclareVar, ASTDiscard, ASTDoWhile, ASTExpression, ASTFunction, ASTFunctionParameter, ASTGlobalScope, ASTHash, ASTIf, ASTLValue, ASTLValueArray, ASTLValueDeclare, ASTLValueHash, ASTLValueScalar, ASTNakedScope, ASTPrimitive, ASTRange, ASTReferenceOf, ASTReturn, ASTScalar, ASTScope, ASTSelect, ASTShaderExpConstructor, ASTStructDefine, ASTTouch, ASTUnaryFunc, ASTWhile, DeclareType, ShaderAST, ShaderPrecisionType, builtinVariables, genSamplerName, getBuiltinInputStructInstanceName, getBuiltinInputStructName, getBuiltinOutputStructInstanceName, getBuiltinOutputStructName, getTextureSampleType } from './builder/ast.js';
6
+ export { ASTAddressOf, ASTArrayIndex, ASTAssignment, ASTBinaryFunc, ASTBreak, ASTCallFunction, ASTCast, ASTContinue, ASTDeclareVar, ASTDiscard, ASTDoWhile, ASTExpression, ASTFunction, ASTFunctionParameter, ASTGlobalScope, ASTHash, ASTIf, ASTLValue, ASTLValueArray, ASTLValueDeclare, ASTLValueHash, ASTLValueScalar, ASTNakedScope, ASTPrimitive, ASTRange, ASTReferenceOf, ASTReturn, ASTScalar, ASTScope, ASTSelect, ASTShaderExpConstructor, ASTStructDefine, ASTTouch, ASTUnaryFunc, ASTWhile, DeclareType, ShaderAST, ShaderPrecisionType, builtinVariables, genSamplerName, getBuiltinInputStructInstanceName, getBuiltinInputStructName, getBuiltinOutputStructInstanceName, getBuiltinOutputStructName, getBuiltinParamName, getTextureSampleType } from './builder/ast.js';
7
7
  export { PBBuiltinScope, PBDoWhileScope, PBForScope, PBFunctionScope, PBGlobalScope, PBIfScope, PBInputScope, PBInsideFunctionScope, PBLocalScope, PBNakedScope, PBOutputScope, PBScope, PBWhileScope, ProgramBuilder } from './builder/programbuilder.js';
8
8
  export { PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBFunctionTypeInfo, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBSamplerAccessMode, PBSamplerTypeInfo, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, typeAny, typeAtomicI32, typeAtomicU32, typeBVec2, typeBVec3, typeBVec4, typeBool, typeF16, typeF16Vec2, typeF16Vec3, typeF16Vec4, typeF32, typeF32Vec2, typeF32Vec3, typeF32Vec4, typeFrexpResult, typeFrexpResultVec2, typeFrexpResultVec3, typeFrexpResultVec4, typeI16, typeI16Vec2, typeI16Vec2_Norm, typeI16Vec3, typeI16Vec3_Norm, typeI16Vec4, typeI16Vec4_Norm, typeI16_Norm, typeI32, typeI32Vec2, typeI32Vec2_Norm, typeI32Vec3, typeI32Vec3_Norm, typeI32Vec4, typeI32Vec4_Norm, typeI32_Norm, typeI8, typeI8Vec2, typeI8Vec2_Norm, typeI8Vec3, typeI8Vec3_Norm, typeI8Vec4, typeI8Vec4_Norm, typeI8_Norm, typeITex1D, typeITex2D, typeITex2DArray, typeITex3D, typeITexCube, typeITexCubeArray, typeITexMultisampled2D, typeMat2, typeMat2x3, typeMat2x4, typeMat3, typeMat3x2, typeMat3x4, typeMat4, typeMat4x2, typeMat4x3, typeSampler, typeSamplerComparison, typeTex1D, typeTex2D, typeTex2DArray, typeTex3D, typeTexCube, typeTexCubeArray, typeTexDepth2D, typeTexDepth2DArray, typeTexDepthCube, typeTexDepthCubeArray, typeTexDepthMultisampled2D, typeTexExternal, typeTexMultisampled2D, typeTexStorage1D_bgra8unorm, typeTexStorage1D_r32float, typeTexStorage1D_r32sint, typeTexStorage1D_r32uint, typeTexStorage1D_rg32float, typeTexStorage1D_rg32sint, typeTexStorage1D_rg32uint, typeTexStorage1D_rgba16float, typeTexStorage1D_rgba16sint, typeTexStorage1D_rgba16uint, typeTexStorage1D_rgba32float, typeTexStorage1D_rgba32sint, typeTexStorage1D_rgba32uint, typeTexStorage1D_rgba8sint, typeTexStorage1D_rgba8snorm, typeTexStorage1D_rgba8uint, typeTexStorage1D_rgba8unorm, typeTexStorage2DArray_bgra8unorm, typeTexStorage2DArray_r32float, typeTexStorage2DArray_r32sint, typeTexStorage2DArray_r32uint, typeTexStorage2DArray_rg32float, typeTexStorage2DArray_rg32sint, typeTexStorage2DArray_rg32uint, typeTexStorage2DArray_rgba16float, typeTexStorage2DArray_rgba16sint, typeTexStorage2DArray_rgba16uint, typeTexStorage2DArray_rgba32float, typeTexStorage2DArray_rgba32sint, typeTexStorage2DArray_rgba32uint, typeTexStorage2DArray_rgba8sint, typeTexStorage2DArray_rgba8snorm, typeTexStorage2DArray_rgba8uint, typeTexStorage2DArray_rgba8unorm, typeTexStorage2D_bgra8unorm, typeTexStorage2D_r32float, typeTexStorage2D_r32sint, typeTexStorage2D_r32uint, typeTexStorage2D_rg32float, typeTexStorage2D_rg32sint, typeTexStorage2D_rg32uint, typeTexStorage2D_rgba16float, typeTexStorage2D_rgba16sint, typeTexStorage2D_rgba16uint, typeTexStorage2D_rgba32float, typeTexStorage2D_rgba32sint, typeTexStorage2D_rgba32uint, typeTexStorage2D_rgba8sint, typeTexStorage2D_rgba8snorm, typeTexStorage2D_rgba8uint, typeTexStorage2D_rgba8unorm, typeTexStorage3D_bgra8unorm, typeTexStorage3D_r32float, typeTexStorage3D_r32sint, typeTexStorage3D_r32uint, typeTexStorage3D_rg32float, typeTexStorage3D_rg32sint, typeTexStorage3D_rg32uint, typeTexStorage3D_rgba16float, typeTexStorage3D_rgba16sint, typeTexStorage3D_rgba16uint, typeTexStorage3D_rgba32float, typeTexStorage3D_rgba32sint, typeTexStorage3D_rgba32uint, typeTexStorage3D_rgba8sint, typeTexStorage3D_rgba8snorm, typeTexStorage3D_rgba8uint, typeTexStorage3D_rgba8unorm, typeU16, typeU16Vec2, typeU16Vec2_Norm, typeU16Vec3, typeU16Vec3_Norm, typeU16Vec4, typeU16Vec4_Norm, typeU16_Norm, typeU32, typeU32Vec2, typeU32Vec2_Norm, typeU32Vec3, typeU32Vec3_Norm, typeU32Vec4, typeU32Vec4_Norm, typeU32_Norm, typeU8, typeU8Vec2, typeU8Vec2_Norm, typeU8Vec3, typeU8Vec3_Norm, typeU8Vec4, typeU8Vec4_Norm, typeU8_Norm, typeUTex1D, typeUTex2D, typeUTex2DArray, typeUTex3D, typeUTexCube, typeUTexCubeArray, typeUTexMultisampled2D, typeVoid } from './builder/types.js';
9
9
  export { PBReflection } from './builder/reflection.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zephyr3d/device",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "base system for zephyr3d library",
5
5
  "homepage": "https://github.com/gavinyork/zephyr3d#readme",
6
6
  "type": "module",
@@ -43,23 +43,23 @@
43
43
  "@rollup/plugin-strip": "^3.0.2",
44
44
  "@rollup/plugin-terser": "^0.4.0",
45
45
  "@rollup/pluginutils": "^5.0.2",
46
+ "@swc/core": "^1.3.62",
47
+ "@zephyr3d/base": "^0.1.2",
48
+ "cross-env": "^7.0.3",
46
49
  "rollup": "^3.15.0",
47
- "rollup-plugin-dts": "^5.2.0",
48
50
  "rollup-plugin-copy": "^3.4.0",
49
- "rollup-plugin-typescript2": "^0.34.1",
50
- "@swc/core": "^1.3.62",
51
+ "rollup-plugin-dts": "^5.2.0",
51
52
  "rollup-plugin-swc3": "^0.8.2",
53
+ "rollup-plugin-typescript2": "^0.34.1",
52
54
  "shx": "^0.3.4",
53
- "cross-env": "^7.0.3",
54
- "typescript": "^5.1.3",
55
- "@zephyr3d/base": "^0.1.1"
55
+ "typescript": "^5.1.3"
56
56
  },
57
57
  "peerDependencies": {
58
- "@zephyr3d/base": "^0.1.1"
58
+ "@zephyr3d/base": "^0.1.2"
59
59
  },
60
60
  "dependencies": {
61
- "@webgpu/types": "^0.1.31",
62
- "@types/node": "^18.13.0"
61
+ "@types/node": "^18.13.0",
62
+ "@webgpu/types": "^0.1.31"
63
63
  },
64
64
  "scripts": {
65
65
  "clean": "shx rm -rf ./dist .tsbuildinfo",