This repository was archived by the owner on Nov 26, 2024. It is now read-only.
forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComputeCommand.js
119 lines (106 loc) · 2.87 KB
/
ComputeCommand.js
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
import defaultValue from "../Core/defaultValue.js";
import Pass from "./Pass.js";
/**
* Represents a command to the renderer for GPU Compute (using old-school GPGPU).
*
* @private
* @constructor
*/
function ComputeCommand(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
/**
* The vertex array. If none is provided, a viewport quad will be used.
*
* @type {VertexArray}
* @default undefined
*/
this.vertexArray = options.vertexArray;
/**
* The fragment shader source. The default vertex shader is ViewportQuadVS.
*
* @type {ShaderSource}
* @default undefined
*/
this.fragmentShaderSource = options.fragmentShaderSource;
/**
* The shader program to apply.
*
* @type {ShaderProgram}
* @default undefined
*/
this.shaderProgram = options.shaderProgram;
/**
* An object with functions whose names match the uniforms in the shader program
* and return values to set those uniforms.
*
* @type {Object}
* @default undefined
*/
this.uniformMap = options.uniformMap;
/**
* Texture to use for offscreen rendering.
*
* @type {Texture}
* @default undefined
*/
this.outputTexture = options.outputTexture;
/**
* Function that is called immediately before the ComputeCommand is executed. Used to
* update any renderer resources. Takes the ComputeCommand as its single argument.
*
* @type {Function}
* @default undefined
*/
this.preExecute = options.preExecute;
/**
* Function that is called after the ComputeCommand is executed. Takes the output
* texture as its single argument.
*
* @type {Function}
* @default undefined
*/
this.postExecute = options.postExecute;
/**
* Function that is called when the command is canceled
*
* @type {Function}
* @default undefined
*/
this.canceled = options.canceled;
/**
* Whether the renderer resources will persist beyond this call. If not, they
* will be destroyed after completion.
*
* @type {Boolean}
* @default false
*/
this.persists = defaultValue(options.persists, false);
/**
* The pass when to render. Always compute pass.
*
* @type {Pass}
* @default Pass.COMPUTE;
*/
this.pass = Pass.COMPUTE;
/**
* The object who created this command. This is useful for debugging command
* execution; it allows us to see who created a command when we only have a
* reference to the command, and can be used to selectively execute commands
* with {@link Scene#debugCommandFilter}.
*
* @type {Object}
* @default undefined
*
* @see Scene#debugCommandFilter
*/
this.owner = options.owner;
}
/**
* Executes the compute command.
*
* @param {ComputeEngine} computeEngine The context that processes the compute command.
*/
ComputeCommand.prototype.execute = function (computeEngine) {
computeEngine.execute(this);
};
export default ComputeCommand;