MCPcopy Create free account
hub / github.com/amandaghassaei/gpu-io / offsetProgramForType

Function offsetProgramForType

tests/common/ReadWrite.js:23–69  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

21 } = GPUIO;
22
23 function offsetProgramForType(type) {
24 switch (type) {
25 case HALF_FLOAT:
26 case FLOAT:
27 return `
28 in vec2 v_uv;
29
30 uniform sampler2D u_state;
31 uniform vec2 u_offset;
32
33 out vec4 out_FragColor;
34
35 void main() {
36 out_FragColor = texture(u_state, v_uv + u_offset);
37 }`;
38 case UNSIGNED_BYTE:
39 case UNSIGNED_SHORT:
40 case UNSIGNED_INT:
41 return `
42 in vec2 v_uv;
43
44 uniform usampler2D u_state;
45 uniform vec2 u_offset;
46
47 out uvec4 out_FragColor;
48
49 void main() {
50 out_FragColor = texture(u_state, v_uv + u_offset);
51 }`;
52 case BYTE:
53 case SHORT:
54 case INT:
55 return `
56 in vec2 v_uv;
57
58 uniform isampler2D u_state;
59 uniform vec2 u_offset;
60
61 out ivec4 out_FragColor;
62
63 void main() {
64 out_FragColor = texture(u_state, v_uv + u_offset);
65 }`;
66 default:
67 throw new Error(`Invalid type: ${type}.`);
68 }
69 }
70
71 function zeroProgramForType(type) {
72 switch (type) {

Callers 1

testLayerWritesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected