@swf2es/context3d 0.1.10 → 0.1.12

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.
@@ -5,12 +5,18 @@ import { Context3DError } from "../errors.js";
5
5
  export interface ProgramState {
6
6
  handle: WebGLProgram | null;
7
7
  targetY: WebGLUniformLocation | null;
8
+ targetYValue: number;
8
9
  attributes: number[];
10
+ attributeMask: number;
9
11
  vertex: (WebGLUniformLocation | null)[];
10
12
  vertexBank: WebGLUniformLocation | null;
11
13
  fragment: (WebGLUniformLocation | null)[];
12
14
  samplers: { source: SamplerSource; location: WebGLUniformLocation | null }[];
13
15
  samplerMask: number;
16
+ samplersSet: boolean;
17
+ vertexVersions: Float64Array;
18
+ fragmentVersions: Float64Array;
19
+ vertexVersion: number;
14
20
  }
15
21
 
16
22
  export interface CopyProgram {
@@ -53,12 +59,19 @@ export function uploadProgram(
53
59
  gl.deleteProgram(state.handle);
54
60
  state.handle = handle;
55
61
  state.targetY = gl.getUniformLocation(handle, "targetY");
62
+ state.targetYValue = Number.NaN;
56
63
  state.attributes = vs.attributes;
64
+ state.attributeMask = 0;
65
+ for (const slot of state.attributes) {
66
+ state.attributeMask |= 1 << slot;
67
+ }
68
+
57
69
  state.vertex = [];
58
70
  state.vertexBank = vs.indirect ? gl.getUniformLocation(handle, "vc[0]") : null;
59
71
  state.fragment = [];
60
72
  state.samplers = [];
61
73
  state.samplerMask = 0;
74
+ state.samplersSet = false;
62
75
  for (let i = 0; i < vs.constants.length; i++) {
63
76
  const index = vs.constants[i];
64
77
  state.vertex[index] = gl.getUniformLocation(handle, `vc${index}`);
@@ -77,6 +90,11 @@ export function uploadProgram(
77
90
  location: gl.getUniformLocation(handle, `fs${source.index}`),
78
91
  });
79
92
  }
93
+
94
+ // A fresh link has GL's defaults, even when the context's constants were never written.
95
+ state.vertexVersions = new Float64Array(state.vertex.length).fill(-1);
96
+ state.fragmentVersions = new Float64Array(state.fragment.length).fill(-1);
97
+ state.vertexVersion = -1;
80
98
  }
81
99
 
82
100
  /** A program linked as the device links one, its failures Context3D's errors as before. */