nativePipelineContext.d.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. import type { Nullable } from "../../types";
  2. import type { Effect } from "../../Materials/effect";
  3. import type { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like, IQuaternionLike } from "../../Maths/math.like";
  4. import type { IPipelineContext } from "../IPipelineContext";
  5. import type { NativeEngine } from "../nativeEngine";
  6. import type { NativeProgram } from "./nativeInterfaces";
  7. export declare class NativePipelineContext implements IPipelineContext {
  8. isCompiled: boolean;
  9. compilationError?: Error;
  10. readonly isAsync: boolean;
  11. program: NativeProgram;
  12. get isReady(): boolean;
  13. onCompiled?: () => void;
  14. _getVertexShaderCode(): string | null;
  15. _getFragmentShaderCode(): string | null;
  16. private _engine;
  17. private _valueCache;
  18. private _uniforms;
  19. constructor(engine: NativeEngine, isAsync: boolean);
  20. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  21. [key: string]: number;
  22. }, uniformsNames: string[], uniforms: {
  23. [key: string]: Nullable<WebGLUniformLocation>;
  24. }, samplerList: string[], samplers: {
  25. [key: string]: number;
  26. }, attributesNames: string[], attributes: number[]): void;
  27. /**
  28. * Release all associated resources.
  29. **/
  30. dispose(): void;
  31. /**
  32. * @internal
  33. */
  34. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35. /**
  36. * @internal
  37. */
  38. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39. /**
  40. * @internal
  41. */
  42. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  43. /**
  44. * @internal
  45. */
  46. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  47. /**
  48. * Sets an integer value on a uniform variable.
  49. * @param uniformName Name of the variable.
  50. * @param value Value to be set.
  51. */
  52. setInt(uniformName: string, value: number): void;
  53. /**
  54. * Sets a int2 on a uniform variable.
  55. * @param uniformName Name of the variable.
  56. * @param x First int in int2.
  57. * @param y Second int in int2.
  58. */
  59. setInt2(uniformName: string, x: number, y: number): void;
  60. /**
  61. * Sets a int3 on a uniform variable.
  62. * @param uniformName Name of the variable.
  63. * @param x First int in int3.
  64. * @param y Second int in int3.
  65. * @param z Third int in int3.
  66. */
  67. setInt3(uniformName: string, x: number, y: number, z: number): void;
  68. /**
  69. * Sets a int4 on a uniform variable.
  70. * @param uniformName Name of the variable.
  71. * @param x First int in int4.
  72. * @param y Second int in int4.
  73. * @param z Third int in int4.
  74. * @param w Fourth int in int4.
  75. */
  76. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  77. /**
  78. * Sets an int array on a uniform variable.
  79. * @param uniformName Name of the variable.
  80. * @param array array to be set.
  81. */
  82. setIntArray(uniformName: string, array: Int32Array): void;
  83. /**
  84. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  85. * @param uniformName Name of the variable.
  86. * @param array array to be set.
  87. */
  88. setIntArray2(uniformName: string, array: Int32Array): void;
  89. /**
  90. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  91. * @param uniformName Name of the variable.
  92. * @param array array to be set.
  93. */
  94. setIntArray3(uniformName: string, array: Int32Array): void;
  95. /**
  96. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  97. * @param uniformName Name of the variable.
  98. * @param array array to be set.
  99. */
  100. setIntArray4(uniformName: string, array: Int32Array): void;
  101. /**
  102. * Sets an unsigned integer value on a uniform variable.
  103. * @param uniformName Name of the variable.
  104. * @param value Value to be set.
  105. */
  106. setUInt(uniformName: string, value: number): void;
  107. /**
  108. * Sets a unsigned int2 on a uniform variable.
  109. * @param uniformName Name of the variable.
  110. * @param x First unsigned int in uint2.
  111. * @param y Second unsigned int in uint2.
  112. */
  113. setUInt2(uniformName: string, x: number, y: number): void;
  114. /**
  115. * Sets a unsigned int3 on a uniform variable.
  116. * @param uniformName Name of the variable.
  117. * @param x First unsigned int in uint3.
  118. * @param y Second unsigned int in uint3.
  119. * @param z Third unsigned int in uint3.
  120. */
  121. setUInt3(uniformName: string, x: number, y: number, z: number): void;
  122. /**
  123. * Sets a unsigned int4 on a uniform variable.
  124. * @param uniformName Name of the variable.
  125. * @param x First unsigned int in uint4.
  126. * @param y Second unsigned int in uint4.
  127. * @param z Third unsigned int in uint4.
  128. * @param w Fourth unsigned int in uint4.
  129. */
  130. setUInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  131. /**
  132. * Sets an unsigned int array on a uniform variable.
  133. * @param uniformName Name of the variable.
  134. * @param array array to be set.
  135. */
  136. setUIntArray(uniformName: string, array: Uint32Array): void;
  137. /**
  138. * Sets an unsigned int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  139. * @param uniformName Name of the variable.
  140. * @param array array to be set.
  141. */
  142. setUIntArray2(uniformName: string, array: Uint32Array): void;
  143. /**
  144. * Sets an unsigned int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  145. * @param uniformName Name of the variable.
  146. * @param array array to be set.
  147. */
  148. setUIntArray3(uniformName: string, array: Uint32Array): void;
  149. /**
  150. * Sets an unsigned int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  151. * @param uniformName Name of the variable.
  152. * @param array array to be set.
  153. */
  154. setUIntArray4(uniformName: string, array: Uint32Array): void;
  155. /**
  156. * Sets an float array on a uniform variable.
  157. * @param uniformName Name of the variable.
  158. * @param array array to be set.
  159. */
  160. setFloatArray(uniformName: string, array: Float32Array): void;
  161. /**
  162. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  163. * @param uniformName Name of the variable.
  164. * @param array array to be set.
  165. */
  166. setFloatArray2(uniformName: string, array: Float32Array): void;
  167. /**
  168. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  169. * @param uniformName Name of the variable.
  170. * @param array array to be set.
  171. */
  172. setFloatArray3(uniformName: string, array: Float32Array): void;
  173. /**
  174. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  175. * @param uniformName Name of the variable.
  176. * @param array array to be set.
  177. */
  178. setFloatArray4(uniformName: string, array: Float32Array): void;
  179. /**
  180. * Sets an array on a uniform variable.
  181. * @param uniformName Name of the variable.
  182. * @param array array to be set.
  183. */
  184. setArray(uniformName: string, array: number[]): void;
  185. /**
  186. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  187. * @param uniformName Name of the variable.
  188. * @param array array to be set.
  189. */
  190. setArray2(uniformName: string, array: number[]): void;
  191. /**
  192. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  193. * @param uniformName Name of the variable.
  194. * @param array array to be set.
  195. */
  196. setArray3(uniformName: string, array: number[]): void;
  197. /**
  198. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  199. * @param uniformName Name of the variable.
  200. * @param array array to be set.
  201. */
  202. setArray4(uniformName: string, array: number[]): void;
  203. /**
  204. * Sets matrices on a uniform variable.
  205. * @param uniformName Name of the variable.
  206. * @param matrices matrices to be set.
  207. */
  208. setMatrices(uniformName: string, matrices: Float32Array): void;
  209. /**
  210. * Sets matrix on a uniform variable.
  211. * @param uniformName Name of the variable.
  212. * @param matrix matrix to be set.
  213. */
  214. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  215. /**
  216. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  217. * @param uniformName Name of the variable.
  218. * @param matrix matrix to be set.
  219. */
  220. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  221. /**
  222. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  223. * @param uniformName Name of the variable.
  224. * @param matrix matrix to be set.
  225. */
  226. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  227. /**
  228. * Sets a float on a uniform variable.
  229. * @param uniformName Name of the variable.
  230. * @param value value to be set.
  231. */
  232. setFloat(uniformName: string, value: number): void;
  233. /**
  234. * Sets a boolean on a uniform variable.
  235. * @param uniformName Name of the variable.
  236. * @param bool value to be set.
  237. */
  238. setBool(uniformName: string, bool: boolean): void;
  239. /**
  240. * Sets a Vector2 on a uniform variable.
  241. * @param uniformName Name of the variable.
  242. * @param vector2 vector2 to be set.
  243. */
  244. setVector2(uniformName: string, vector2: IVector2Like): void;
  245. /**
  246. * Sets a float2 on a uniform variable.
  247. * @param uniformName Name of the variable.
  248. * @param x First float in float2.
  249. * @param y Second float in float2.
  250. */
  251. setFloat2(uniformName: string, x: number, y: number): void;
  252. /**
  253. * Sets a Vector3 on a uniform variable.
  254. * @param uniformName Name of the variable.
  255. * @param vector3 Value to be set.
  256. */
  257. setVector3(uniformName: string, vector3: IVector3Like): void;
  258. /**
  259. * Sets a float3 on a uniform variable.
  260. * @param uniformName Name of the variable.
  261. * @param x First float in float3.
  262. * @param y Second float in float3.
  263. * @param z Third float in float3.
  264. */
  265. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  266. /**
  267. * Sets a Vector4 on a uniform variable.
  268. * @param uniformName Name of the variable.
  269. * @param vector4 Value to be set.
  270. */
  271. setVector4(uniformName: string, vector4: IVector4Like): void;
  272. /**
  273. * Sets a Quaternion on a uniform variable.
  274. * @param uniformName Name of the variable.
  275. * @param quaternion Value to be set.
  276. */
  277. setQuaternion(uniformName: string, quaternion: IQuaternionLike): void;
  278. /**
  279. * Sets a float4 on a uniform variable.
  280. * @param uniformName Name of the variable.
  281. * @param x First float in float4.
  282. * @param y Second float in float4.
  283. * @param z Third float in float4.
  284. * @param w Fourth float in float4.
  285. */
  286. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  287. /**
  288. * Sets a Color3 on a uniform variable.
  289. * @param uniformName Name of the variable.
  290. * @param color3 Value to be set.
  291. */
  292. setColor3(uniformName: string, color3: IColor3Like): void;
  293. /**
  294. * Sets a Color4 on a uniform variable.
  295. * @param uniformName Name of the variable.
  296. * @param color3 Value to be set.
  297. * @param alpha Alpha value to be set.
  298. */
  299. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  300. /**
  301. * Sets a Color4 on a uniform variable
  302. * @param uniformName defines the name of the variable
  303. * @param color4 defines the value to be set
  304. */
  305. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  306. }