|
@@ -28,6 +28,10 @@ import { EngineStore } from "./engineStore";
|
|
import { RenderTargetCreationOptions } from "../Materials/Textures/renderTargetCreationOptions";
|
|
import { RenderTargetCreationOptions } from "../Materials/Textures/renderTargetCreationOptions";
|
|
import { _DevTools } from '../Misc/devTools';
|
|
import { _DevTools } from '../Misc/devTools';
|
|
import { WebRequest } from '../Misc/webRequest';
|
|
import { WebRequest } from '../Misc/webRequest';
|
|
|
|
+import { WebGLPipelineContext } from './WebGL/webGLPipelineContext';
|
|
|
|
+import { IPipelineContext } from './IPipelineContext';
|
|
|
|
+import { DataBuffer } from '../Meshes/dataBuffer';
|
|
|
|
+import { WebGLDataBuffer } from '../Meshes/WebGL/webGLDataBuffer';
|
|
|
|
|
|
declare type PostProcess = import("../PostProcesses/postProcess").PostProcess;
|
|
declare type PostProcess = import("../PostProcesses/postProcess").PostProcess;
|
|
declare type Texture = import("../Materials/Textures/texture").Texture;
|
|
declare type Texture = import("../Materials/Textures/texture").Texture;
|
|
@@ -884,7 +888,7 @@ export class Engine {
|
|
/** @hidden */
|
|
/** @hidden */
|
|
protected _cachedVertexBuffers: any;
|
|
protected _cachedVertexBuffers: any;
|
|
/** @hidden */
|
|
/** @hidden */
|
|
- protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
|
|
|
|
|
|
+ protected _cachedIndexBuffer: Nullable<DataBuffer>;
|
|
/** @hidden */
|
|
/** @hidden */
|
|
protected _cachedEffectForVertexBuffers: Nullable<Effect>;
|
|
protected _cachedEffectForVertexBuffers: Nullable<Effect>;
|
|
/** @hidden */
|
|
/** @hidden */
|
|
@@ -895,7 +899,7 @@ export class Engine {
|
|
protected _currentFramebuffer: Nullable<WebGLFramebuffer> = null;
|
|
protected _currentFramebuffer: Nullable<WebGLFramebuffer> = null;
|
|
private _currentBufferPointers = new Array<BufferPointer>();
|
|
private _currentBufferPointers = new Array<BufferPointer>();
|
|
private _currentInstanceLocations = new Array<number>();
|
|
private _currentInstanceLocations = new Array<number>();
|
|
- private _currentInstanceBuffers = new Array<WebGLBuffer>();
|
|
|
|
|
|
+ private _currentInstanceBuffers = new Array<DataBuffer>();
|
|
private _textureUnits: Int32Array;
|
|
private _textureUnits: Int32Array;
|
|
|
|
|
|
/** @hidden */
|
|
/** @hidden */
|
|
@@ -2536,14 +2540,15 @@ export class Engine {
|
|
* @param elements defines the content of the uniform buffer
|
|
* @param elements defines the content of the uniform buffer
|
|
* @returns the webGL uniform buffer
|
|
* @returns the webGL uniform buffer
|
|
*/
|
|
*/
|
|
- public createUniformBuffer(elements: FloatArray): WebGLBuffer {
|
|
|
|
|
|
+ public createUniformBuffer(elements: FloatArray): DataBuffer {
|
|
var ubo = this._gl.createBuffer();
|
|
var ubo = this._gl.createBuffer();
|
|
|
|
|
|
if (!ubo) {
|
|
if (!ubo) {
|
|
throw new Error("Unable to create uniform buffer");
|
|
throw new Error("Unable to create uniform buffer");
|
|
}
|
|
}
|
|
|
|
+ let result = new WebGLDataBuffer(ubo);
|
|
|
|
|
|
- this.bindUniformBuffer(ubo);
|
|
|
|
|
|
+ this.bindUniformBuffer(result);
|
|
|
|
|
|
if (elements instanceof Float32Array) {
|
|
if (elements instanceof Float32Array) {
|
|
this._gl.bufferData(this._gl.UNIFORM_BUFFER, <Float32Array>elements, this._gl.STATIC_DRAW);
|
|
this._gl.bufferData(this._gl.UNIFORM_BUFFER, <Float32Array>elements, this._gl.STATIC_DRAW);
|
|
@@ -2553,8 +2558,8 @@ export class Engine {
|
|
|
|
|
|
this.bindUniformBuffer(null);
|
|
this.bindUniformBuffer(null);
|
|
|
|
|
|
- ubo.references = 1;
|
|
|
|
- return ubo;
|
|
|
|
|
|
+ result.references = 1;
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2563,14 +2568,15 @@ export class Engine {
|
|
* @param elements defines the content of the uniform buffer
|
|
* @param elements defines the content of the uniform buffer
|
|
* @returns the webGL uniform buffer
|
|
* @returns the webGL uniform buffer
|
|
*/
|
|
*/
|
|
- public createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer {
|
|
|
|
|
|
+ public createDynamicUniformBuffer(elements: FloatArray): DataBuffer {
|
|
var ubo = this._gl.createBuffer();
|
|
var ubo = this._gl.createBuffer();
|
|
|
|
|
|
if (!ubo) {
|
|
if (!ubo) {
|
|
throw new Error("Unable to create dynamic uniform buffer");
|
|
throw new Error("Unable to create dynamic uniform buffer");
|
|
}
|
|
}
|
|
|
|
|
|
- this.bindUniformBuffer(ubo);
|
|
|
|
|
|
+ let result = new WebGLDataBuffer(ubo);
|
|
|
|
+ this.bindUniformBuffer(result);
|
|
|
|
|
|
if (elements instanceof Float32Array) {
|
|
if (elements instanceof Float32Array) {
|
|
this._gl.bufferData(this._gl.UNIFORM_BUFFER, <Float32Array>elements, this._gl.DYNAMIC_DRAW);
|
|
this._gl.bufferData(this._gl.UNIFORM_BUFFER, <Float32Array>elements, this._gl.DYNAMIC_DRAW);
|
|
@@ -2580,8 +2586,8 @@ export class Engine {
|
|
|
|
|
|
this.bindUniformBuffer(null);
|
|
this.bindUniformBuffer(null);
|
|
|
|
|
|
- ubo.references = 1;
|
|
|
|
- return ubo;
|
|
|
|
|
|
+ result.references = 1;
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2592,7 +2598,7 @@ export class Engine {
|
|
* @param offset defines the offset in the uniform buffer where update should start
|
|
* @param offset defines the offset in the uniform buffer where update should start
|
|
* @param count defines the size of the data to update
|
|
* @param count defines the size of the data to update
|
|
*/
|
|
*/
|
|
- public updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void {
|
|
|
|
|
|
+ public updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void {
|
|
this.bindUniformBuffer(uniformBuffer);
|
|
this.bindUniformBuffer(uniformBuffer);
|
|
|
|
|
|
if (offset === undefined) {
|
|
if (offset === undefined) {
|
|
@@ -2627,14 +2633,15 @@ export class Engine {
|
|
* @param data the data for the vertex buffer
|
|
* @param data the data for the vertex buffer
|
|
* @returns the new WebGL static buffer
|
|
* @returns the new WebGL static buffer
|
|
*/
|
|
*/
|
|
- public createVertexBuffer(data: DataArray): WebGLBuffer {
|
|
|
|
|
|
+ public createVertexBuffer(data: DataArray): DataBuffer {
|
|
var vbo = this._gl.createBuffer();
|
|
var vbo = this._gl.createBuffer();
|
|
|
|
|
|
if (!vbo) {
|
|
if (!vbo) {
|
|
throw new Error("Unable to create vertex buffer");
|
|
throw new Error("Unable to create vertex buffer");
|
|
}
|
|
}
|
|
|
|
|
|
- this.bindArrayBuffer(vbo);
|
|
|
|
|
|
+ let dataBuffer = new WebGLDataBuffer(vbo);
|
|
|
|
+ this.bindArrayBuffer(dataBuffer);
|
|
|
|
|
|
if (data instanceof Array) {
|
|
if (data instanceof Array) {
|
|
this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
|
|
this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
|
|
@@ -2643,8 +2650,9 @@ export class Engine {
|
|
}
|
|
}
|
|
|
|
|
|
this._resetVertexBufferBinding();
|
|
this._resetVertexBufferBinding();
|
|
- vbo.references = 1;
|
|
|
|
- return vbo;
|
|
|
|
|
|
+
|
|
|
|
+ dataBuffer.references = 1;
|
|
|
|
+ return dataBuffer;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2652,14 +2660,15 @@ export class Engine {
|
|
* @param data the data for the dynamic vertex buffer
|
|
* @param data the data for the dynamic vertex buffer
|
|
* @returns the new WebGL dynamic buffer
|
|
* @returns the new WebGL dynamic buffer
|
|
*/
|
|
*/
|
|
- public createDynamicVertexBuffer(data: DataArray): WebGLBuffer {
|
|
|
|
|
|
+ public createDynamicVertexBuffer(data: DataArray): DataBuffer {
|
|
var vbo = this._gl.createBuffer();
|
|
var vbo = this._gl.createBuffer();
|
|
|
|
|
|
if (!vbo) {
|
|
if (!vbo) {
|
|
throw new Error("Unable to create dynamic vertex buffer");
|
|
throw new Error("Unable to create dynamic vertex buffer");
|
|
}
|
|
}
|
|
|
|
|
|
- this.bindArrayBuffer(vbo);
|
|
|
|
|
|
+ let result = new WebGLDataBuffer(vbo);
|
|
|
|
+ this.bindArrayBuffer(result);
|
|
|
|
|
|
if (data instanceof Array) {
|
|
if (data instanceof Array) {
|
|
this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
|
|
this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
|
|
@@ -2668,8 +2677,8 @@ export class Engine {
|
|
}
|
|
}
|
|
|
|
|
|
this._resetVertexBufferBinding();
|
|
this._resetVertexBufferBinding();
|
|
- vbo.references = 1;
|
|
|
|
- return vbo;
|
|
|
|
|
|
+ result.references = 1;
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2678,7 +2687,7 @@ export class Engine {
|
|
* @param indices defines the data to update
|
|
* @param indices defines the data to update
|
|
* @param offset defines the offset in the target index buffer where update should start
|
|
* @param offset defines the offset in the target index buffer where update should start
|
|
*/
|
|
*/
|
|
- public updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset: number = 0): void {
|
|
|
|
|
|
+ public updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset: number = 0): void {
|
|
// Force cache update
|
|
// Force cache update
|
|
this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
|
|
this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
|
|
this.bindIndexBuffer(indexBuffer);
|
|
this.bindIndexBuffer(indexBuffer);
|
|
@@ -2702,7 +2711,7 @@ export class Engine {
|
|
* @param byteOffset the byte offset of the data
|
|
* @param byteOffset the byte offset of the data
|
|
* @param byteLength the byte length of the data
|
|
* @param byteLength the byte length of the data
|
|
*/
|
|
*/
|
|
- public updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void {
|
|
|
|
|
|
+ public updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void {
|
|
this.bindArrayBuffer(vertexBuffer);
|
|
this.bindArrayBuffer(vertexBuffer);
|
|
|
|
|
|
if (byteOffset === undefined) {
|
|
if (byteOffset === undefined) {
|
|
@@ -2747,14 +2756,15 @@ export class Engine {
|
|
* @param updatable defines if the index buffer must be updatable
|
|
* @param updatable defines if the index buffer must be updatable
|
|
* @returns a new webGL buffer
|
|
* @returns a new webGL buffer
|
|
*/
|
|
*/
|
|
- public createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer {
|
|
|
|
|
|
+ public createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer {
|
|
var vbo = this._gl.createBuffer();
|
|
var vbo = this._gl.createBuffer();
|
|
|
|
+ let dataBuffer = new WebGLDataBuffer(vbo!);
|
|
|
|
|
|
if (!vbo) {
|
|
if (!vbo) {
|
|
throw new Error("Unable to create index buffer");
|
|
throw new Error("Unable to create index buffer");
|
|
}
|
|
}
|
|
|
|
|
|
- this.bindIndexBuffer(vbo);
|
|
|
|
|
|
+ this.bindIndexBuffer(dataBuffer);
|
|
|
|
|
|
// Check for 32 bits indices
|
|
// Check for 32 bits indices
|
|
var arrayBuffer;
|
|
var arrayBuffer;
|
|
@@ -2787,16 +2797,16 @@ export class Engine {
|
|
|
|
|
|
this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
|
|
this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
|
|
this._resetIndexBufferBinding();
|
|
this._resetIndexBufferBinding();
|
|
- vbo.references = 1;
|
|
|
|
- vbo.is32Bits = need32Bits;
|
|
|
|
- return vbo;
|
|
|
|
|
|
+ dataBuffer.references = 1;
|
|
|
|
+ dataBuffer.is32Bits = need32Bits;
|
|
|
|
+ return dataBuffer;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Bind a webGL buffer to the webGL context
|
|
* Bind a webGL buffer to the webGL context
|
|
* @param buffer defines the buffer to bind
|
|
* @param buffer defines the buffer to bind
|
|
*/
|
|
*/
|
|
- public bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void {
|
|
|
|
|
|
+ public bindArrayBuffer(buffer: Nullable<DataBuffer>): void {
|
|
if (!this._vaoRecordInProgress) {
|
|
if (!this._vaoRecordInProgress) {
|
|
this._unbindVertexArrayObject();
|
|
this._unbindVertexArrayObject();
|
|
}
|
|
}
|
|
@@ -2807,8 +2817,8 @@ export class Engine {
|
|
* Bind an uniform buffer to the current webGL context
|
|
* Bind an uniform buffer to the current webGL context
|
|
* @param buffer defines the buffer to bind
|
|
* @param buffer defines the buffer to bind
|
|
*/
|
|
*/
|
|
- public bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void {
|
|
|
|
- this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
|
|
|
|
|
|
+ public bindUniformBuffer(buffer: Nullable<DataBuffer>): void {
|
|
|
|
+ this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer ? buffer.underlyingResource : null);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2816,32 +2826,34 @@ export class Engine {
|
|
* @param buffer defines the buffer to bind
|
|
* @param buffer defines the buffer to bind
|
|
* @param location defines the index where to bind the buffer
|
|
* @param location defines the index where to bind the buffer
|
|
*/
|
|
*/
|
|
- public bindUniformBufferBase(buffer: WebGLBuffer, location: number): void {
|
|
|
|
- this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
|
|
|
|
|
|
+ public bindUniformBufferBase(buffer: DataBuffer, location: number): void {
|
|
|
|
+ this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer ? buffer.underlyingResource : null);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Bind a specific block at a given index in a specific shader program
|
|
* Bind a specific block at a given index in a specific shader program
|
|
- * @param shaderProgram defines the shader program
|
|
|
|
|
|
+ * @param pipelineContext defines the pipeline context to use
|
|
* @param blockName defines the block name
|
|
* @param blockName defines the block name
|
|
* @param index defines the index where to bind the block
|
|
* @param index defines the index where to bind the block
|
|
*/
|
|
*/
|
|
- public bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void {
|
|
|
|
- var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
|
|
|
|
|
|
+ public bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void {
|
|
|
|
+ let program = (pipelineContext as WebGLPipelineContext).program!;
|
|
|
|
+
|
|
|
|
+ var uniformLocation = this._gl.getUniformBlockIndex(program, blockName);
|
|
|
|
|
|
- this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
|
|
|
|
|
|
+ this._gl.uniformBlockBinding(program, uniformLocation, index);
|
|
}
|
|
}
|
|
|
|
|
|
- private bindIndexBuffer(buffer: Nullable<WebGLBuffer>): void {
|
|
|
|
|
|
+ private bindIndexBuffer(buffer: Nullable<DataBuffer>): void {
|
|
if (!this._vaoRecordInProgress) {
|
|
if (!this._vaoRecordInProgress) {
|
|
this._unbindVertexArrayObject();
|
|
this._unbindVertexArrayObject();
|
|
}
|
|
}
|
|
this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
|
|
this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
|
|
}
|
|
}
|
|
|
|
|
|
- private bindBuffer(buffer: Nullable<WebGLBuffer>, target: number): void {
|
|
|
|
|
|
+ private bindBuffer(buffer: Nullable<DataBuffer>, target: number): void {
|
|
if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
|
|
if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
|
|
- this._gl.bindBuffer(target, buffer);
|
|
|
|
|
|
+ this._gl.bindBuffer(target, buffer ? buffer.underlyingResource : null);
|
|
this._currentBoundBuffer[target] = buffer;
|
|
this._currentBoundBuffer[target] = buffer;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2854,7 +2866,7 @@ export class Engine {
|
|
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
|
|
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
|
|
}
|
|
}
|
|
|
|
|
|
- private _vertexAttribPointer(buffer: WebGLBuffer, indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void {
|
|
|
|
|
|
+ private _vertexAttribPointer(buffer: DataBuffer, indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void {
|
|
var pointer = this._currentBufferPointers[indx];
|
|
var pointer = this._currentBufferPointers[indx];
|
|
|
|
|
|
var changed = false;
|
|
var changed = false;
|
|
@@ -2883,7 +2895,7 @@ export class Engine {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private _bindIndexBufferWithCache(indexBuffer: Nullable<WebGLBuffer>): void {
|
|
|
|
|
|
+ private _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void {
|
|
if (indexBuffer == null) {
|
|
if (indexBuffer == null) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -2942,7 +2954,7 @@ export class Engine {
|
|
* @param effect defines the effect to store
|
|
* @param effect defines the effect to store
|
|
* @returns the new vertex array object
|
|
* @returns the new vertex array object
|
|
*/
|
|
*/
|
|
- public recordVertexArrayObject(vertexBuffers: { [key: string]: VertexBuffer; }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject {
|
|
|
|
|
|
+ public recordVertexArrayObject(vertexBuffers: { [key: string]: VertexBuffer; }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject {
|
|
var vao = this._gl.createVertexArray();
|
|
var vao = this._gl.createVertexArray();
|
|
|
|
|
|
this._vaoRecordInProgress = true;
|
|
this._vaoRecordInProgress = true;
|
|
@@ -2966,7 +2978,7 @@ export class Engine {
|
|
* @param vertexArrayObject defines the vertex array object to bind
|
|
* @param vertexArrayObject defines the vertex array object to bind
|
|
* @param indexBuffer defines the index buffer to bind
|
|
* @param indexBuffer defines the index buffer to bind
|
|
*/
|
|
*/
|
|
- public bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void {
|
|
|
|
|
|
+ public bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void {
|
|
if (this._cachedVertexArrayObject !== vertexArrayObject) {
|
|
if (this._cachedVertexArrayObject !== vertexArrayObject) {
|
|
this._cachedVertexArrayObject = vertexArrayObject;
|
|
this._cachedVertexArrayObject = vertexArrayObject;
|
|
|
|
|
|
@@ -2987,7 +2999,7 @@ export class Engine {
|
|
* @param vertexStrideSize defines the vertex stride of the vertex buffer
|
|
* @param vertexStrideSize defines the vertex stride of the vertex buffer
|
|
* @param effect defines the effect associated with the vertex buffer
|
|
* @param effect defines the effect associated with the vertex buffer
|
|
*/
|
|
*/
|
|
- public bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void {
|
|
|
|
|
|
+ public bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void {
|
|
if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
|
|
if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
|
|
this._cachedVertexBuffers = vertexBuffer;
|
|
this._cachedVertexBuffers = vertexBuffer;
|
|
this._cachedEffectForVertexBuffers = effect;
|
|
this._cachedEffectForVertexBuffers = effect;
|
|
@@ -3033,7 +3045,7 @@ export class Engine {
|
|
* @param indexBuffer defines the index buffer to bind
|
|
* @param indexBuffer defines the index buffer to bind
|
|
* @param effect defines the effect associated with the vertex buffers
|
|
* @param effect defines the effect associated with the vertex buffers
|
|
*/
|
|
*/
|
|
- public bindBuffers(vertexBuffers: { [key: string]: Nullable<VertexBuffer> }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void {
|
|
|
|
|
|
+ public bindBuffers(vertexBuffers: { [key: string]: Nullable<VertexBuffer> }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void {
|
|
if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
|
|
if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
|
|
this._cachedVertexBuffers = vertexBuffers;
|
|
this._cachedVertexBuffers = vertexBuffers;
|
|
this._cachedEffectForVertexBuffers = effect;
|
|
this._cachedEffectForVertexBuffers = effect;
|
|
@@ -3071,11 +3083,11 @@ export class Engine {
|
|
}
|
|
}
|
|
|
|
|
|
/** @hidden */
|
|
/** @hidden */
|
|
- public _releaseBuffer(buffer: WebGLBuffer): boolean {
|
|
|
|
|
|
+ public _releaseBuffer(buffer: DataBuffer): boolean {
|
|
buffer.references--;
|
|
buffer.references--;
|
|
|
|
|
|
if (buffer.references === 0) {
|
|
if (buffer.references === 0) {
|
|
- this._gl.deleteBuffer(buffer);
|
|
|
|
|
|
+ this._gl.deleteBuffer(buffer.underlyingResource);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3087,18 +3099,19 @@ export class Engine {
|
|
* @param capacity defines the size of the buffer
|
|
* @param capacity defines the size of the buffer
|
|
* @returns the webGL buffer
|
|
* @returns the webGL buffer
|
|
*/
|
|
*/
|
|
- public createInstancesBuffer(capacity: number): WebGLBuffer {
|
|
|
|
|
|
+ public createInstancesBuffer(capacity: number): DataBuffer {
|
|
var buffer = this._gl.createBuffer();
|
|
var buffer = this._gl.createBuffer();
|
|
|
|
|
|
if (!buffer) {
|
|
if (!buffer) {
|
|
throw new Error("Unable to create instance buffer");
|
|
throw new Error("Unable to create instance buffer");
|
|
}
|
|
}
|
|
|
|
|
|
- buffer.capacity = capacity;
|
|
|
|
|
|
+ var result = new WebGLDataBuffer(buffer);
|
|
|
|
+ result.capacity = capacity;
|
|
|
|
|
|
- this.bindArrayBuffer(buffer);
|
|
|
|
|
|
+ this.bindArrayBuffer(result);
|
|
this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
|
|
this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
|
|
- return buffer;
|
|
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3115,7 +3128,7 @@ export class Engine {
|
|
* @param data defines the data to store in the buffer
|
|
* @param data defines the data to store in the buffer
|
|
* @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
|
|
* @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
|
|
*/
|
|
*/
|
|
- public updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void {
|
|
|
|
|
|
+ public updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void {
|
|
this.bindArrayBuffer(instancesBuffer);
|
|
this.bindArrayBuffer(instancesBuffer);
|
|
if (data) {
|
|
if (data) {
|
|
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
|
|
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
|
|
@@ -3276,21 +3289,22 @@ export class Engine {
|
|
if (this._compiledEffects[effect._key]) {
|
|
if (this._compiledEffects[effect._key]) {
|
|
delete this._compiledEffects[effect._key];
|
|
delete this._compiledEffects[effect._key];
|
|
|
|
|
|
- this._deleteProgram(effect.getProgram());
|
|
|
|
|
|
+ this._deletePipelineContext(effect.getPipelineContext() as WebGLPipelineContext);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/** @hidden */
|
|
/** @hidden */
|
|
- public _deleteProgram(program: WebGLProgram): void {
|
|
|
|
- if (program) {
|
|
|
|
- program.__SPECTOR_rebuildProgram = null;
|
|
|
|
-
|
|
|
|
- if (program.transformFeedback) {
|
|
|
|
- this.deleteTransformFeedback(program.transformFeedback);
|
|
|
|
- program.transformFeedback = null;
|
|
|
|
|
|
+ public _deletePipelineContext(pipelineContext: IPipelineContext): void {
|
|
|
|
+ let webGLPipelineContext = pipelineContext as WebGLPipelineContext;
|
|
|
|
+ if (webGLPipelineContext && webGLPipelineContext.program) {
|
|
|
|
+ webGLPipelineContext.program.__SPECTOR_rebuildProgram = null;
|
|
|
|
+
|
|
|
|
+ if (webGLPipelineContext.transformFeedback) {
|
|
|
|
+ this.deleteTransformFeedback(webGLPipelineContext.transformFeedback);
|
|
|
|
+ webGLPipelineContext.transformFeedback = null;
|
|
}
|
|
}
|
|
|
|
|
|
- this._gl.deleteProgram(program);
|
|
|
|
|
|
+ this._gl.deleteProgram(webGLPipelineContext.program);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3348,23 +3362,25 @@ export class Engine {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Directly creates a webGL program
|
|
* Directly creates a webGL program
|
|
|
|
+ * @param pipelineContext defines the pipeline context to attach to
|
|
* @param vertexCode defines the vertex shader code to use
|
|
* @param vertexCode defines the vertex shader code to use
|
|
* @param fragmentCode defines the fragment shader code to use
|
|
* @param fragmentCode defines the fragment shader code to use
|
|
* @param context defines the webGL context to use (if not set, the current one will be used)
|
|
* @param context defines the webGL context to use (if not set, the current one will be used)
|
|
* @param transformFeedbackVaryings defines the list of transform feedback varyings to use
|
|
* @param transformFeedbackVaryings defines the list of transform feedback varyings to use
|
|
* @returns the new webGL program
|
|
* @returns the new webGL program
|
|
*/
|
|
*/
|
|
- public createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings: Nullable<string[]> = null): WebGLProgram {
|
|
|
|
|
|
+ public createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings: Nullable<string[]> = null): WebGLProgram {
|
|
context = context || this._gl;
|
|
context = context || this._gl;
|
|
|
|
|
|
var vertexShader = this._compileRawShader(vertexCode, "vertex");
|
|
var vertexShader = this._compileRawShader(vertexCode, "vertex");
|
|
var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
|
|
var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
|
|
|
|
|
|
- return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
|
|
|
|
|
|
+ return this._createShaderProgram(pipelineContext as WebGLPipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates a webGL program
|
|
* Creates a webGL program
|
|
|
|
+ * @param pipelineContext defines the pipeline context to attach to
|
|
* @param vertexCode defines the vertex shader code to use
|
|
* @param vertexCode defines the vertex shader code to use
|
|
* @param fragmentCode defines the fragment shader code to use
|
|
* @param fragmentCode defines the fragment shader code to use
|
|
* @param defines defines the string containing the defines to use to compile the shaders
|
|
* @param defines defines the string containing the defines to use to compile the shaders
|
|
@@ -3372,7 +3388,7 @@ export class Engine {
|
|
* @param transformFeedbackVaryings defines the list of transform feedback varyings to use
|
|
* @param transformFeedbackVaryings defines the list of transform feedback varyings to use
|
|
* @returns the new webGL program
|
|
* @returns the new webGL program
|
|
*/
|
|
*/
|
|
- public createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings: Nullable<string[]> = null): WebGLProgram {
|
|
|
|
|
|
+ public createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings: Nullable<string[]> = null): WebGLProgram {
|
|
context = context || this._gl;
|
|
context = context || this._gl;
|
|
|
|
|
|
this.onBeforeShaderCompilationObservable.notifyObservers(this);
|
|
this.onBeforeShaderCompilationObservable.notifyObservers(this);
|
|
@@ -3381,24 +3397,36 @@ export class Engine {
|
|
var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
|
|
var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
|
|
var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
|
|
var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
|
|
|
|
|
|
- let program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
|
|
|
|
|
|
+ let program = this._createShaderProgram(pipelineContext as WebGLPipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
|
|
|
|
|
|
this.onAfterShaderCompilationObservable.notifyObservers(this);
|
|
this.onAfterShaderCompilationObservable.notifyObservers(this);
|
|
|
|
|
|
return program;
|
|
return program;
|
|
}
|
|
}
|
|
|
|
|
|
- private _createShaderProgram(vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings: Nullable<string[]> = null): WebGLProgram {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new pipeline context
|
|
|
|
+ * @returns the new pipeline
|
|
|
|
+ */
|
|
|
|
+ public createPipelineContext() {
|
|
|
|
+ var pipelineContext = new WebGLPipelineContext();
|
|
|
|
+ pipelineContext.engine = this;
|
|
|
|
+
|
|
|
|
+ if (this._caps.parallelShaderCompile) {
|
|
|
|
+ pipelineContext.isParallelCompiled = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return pipelineContext;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings: Nullable<string[]> = null): WebGLProgram {
|
|
var shaderProgram = context.createProgram();
|
|
var shaderProgram = context.createProgram();
|
|
|
|
+ pipelineContext.program = shaderProgram;
|
|
|
|
|
|
if (!shaderProgram) {
|
|
if (!shaderProgram) {
|
|
throw new Error("Unable to create program");
|
|
throw new Error("Unable to create program");
|
|
}
|
|
}
|
|
|
|
|
|
- if (this._caps.parallelShaderCompile) {
|
|
|
|
- shaderProgram.isParallelCompiled = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
context.attachShader(shaderProgram, vertexShader);
|
|
context.attachShader(shaderProgram, vertexShader);
|
|
context.attachShader(shaderProgram, fragmentShader);
|
|
context.attachShader(shaderProgram, fragmentShader);
|
|
|
|
|
|
@@ -3407,7 +3435,7 @@ export class Engine {
|
|
|
|
|
|
this.bindTransformFeedback(transformFeedback);
|
|
this.bindTransformFeedback(transformFeedback);
|
|
this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
|
|
this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
|
|
- shaderProgram.transformFeedback = transformFeedback;
|
|
|
|
|
|
+ pipelineContext.transformFeedback = transformFeedback;
|
|
}
|
|
}
|
|
|
|
|
|
context.linkProgram(shaderProgram);
|
|
context.linkProgram(shaderProgram);
|
|
@@ -3416,23 +3444,24 @@ export class Engine {
|
|
this.bindTransformFeedback(null);
|
|
this.bindTransformFeedback(null);
|
|
}
|
|
}
|
|
|
|
|
|
- shaderProgram.context = context;
|
|
|
|
- shaderProgram.vertexShader = vertexShader;
|
|
|
|
- shaderProgram.fragmentShader = fragmentShader;
|
|
|
|
|
|
+ pipelineContext.context = context;
|
|
|
|
+ pipelineContext.vertexShader = vertexShader;
|
|
|
|
+ pipelineContext.fragmentShader = fragmentShader;
|
|
|
|
|
|
- if (!shaderProgram.isParallelCompiled) {
|
|
|
|
- this._finalizeProgram(shaderProgram);
|
|
|
|
|
|
+ if (!pipelineContext.isParallelCompiled) {
|
|
|
|
+ this._finalizePipelineContext(pipelineContext);
|
|
}
|
|
}
|
|
|
|
|
|
return shaderProgram;
|
|
return shaderProgram;
|
|
}
|
|
}
|
|
|
|
|
|
- private _finalizeProgram(shaderProgram: WebGLProgram) {
|
|
|
|
- const context = shaderProgram.context!;
|
|
|
|
- const vertexShader = shaderProgram.vertexShader!;
|
|
|
|
- const fragmentShader = shaderProgram.fragmentShader!;
|
|
|
|
|
|
+ private _finalizePipelineContext(pipelineContext: WebGLPipelineContext) {
|
|
|
|
+ const context = pipelineContext.context!;
|
|
|
|
+ const vertexShader = pipelineContext.vertexShader!;
|
|
|
|
+ const fragmentShader = pipelineContext.fragmentShader!;
|
|
|
|
+ const program = pipelineContext.program!;
|
|
|
|
|
|
- var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
|
|
|
|
|
|
+ var linked = context.getProgramParameter(program, context.LINK_STATUS);
|
|
|
|
|
|
if (!linked) { // Get more info
|
|
if (!linked) { // Get more info
|
|
|
|
|
|
@@ -3452,18 +3481,18 @@ export class Engine {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- var error = context.getProgramInfoLog(shaderProgram);
|
|
|
|
|
|
+ var error = context.getProgramInfoLog(program);
|
|
if (error) {
|
|
if (error) {
|
|
throw new Error(error);
|
|
throw new Error(error);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (this.validateShaderPrograms) {
|
|
if (this.validateShaderPrograms) {
|
|
- context.validateProgram(shaderProgram);
|
|
|
|
- var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
|
|
|
|
|
|
+ context.validateProgram(program);
|
|
|
|
+ var validated = context.getProgramParameter(program, context.VALIDATE_STATUS);
|
|
|
|
|
|
if (!validated) {
|
|
if (!validated) {
|
|
- var error = context.getProgramInfoLog(shaderProgram);
|
|
|
|
|
|
+ var error = context.getProgramInfoLog(program);
|
|
if (error) {
|
|
if (error) {
|
|
throw new Error(error);
|
|
throw new Error(error);
|
|
}
|
|
}
|
|
@@ -3473,24 +3502,37 @@ export class Engine {
|
|
context.deleteShader(vertexShader);
|
|
context.deleteShader(vertexShader);
|
|
context.deleteShader(fragmentShader);
|
|
context.deleteShader(fragmentShader);
|
|
|
|
|
|
- shaderProgram.context = undefined;
|
|
|
|
- shaderProgram.vertexShader = undefined;
|
|
|
|
- shaderProgram.fragmentShader = undefined;
|
|
|
|
|
|
+ pipelineContext.context = undefined;
|
|
|
|
+ pipelineContext.vertexShader = undefined;
|
|
|
|
+ pipelineContext.fragmentShader = undefined;
|
|
|
|
|
|
- if (shaderProgram.onCompiled) {
|
|
|
|
- shaderProgram.onCompiled();
|
|
|
|
- shaderProgram.onCompiled = undefined;
|
|
|
|
|
|
+ if (pipelineContext.onCompiled) {
|
|
|
|
+ pipelineContext.onCompiled();
|
|
|
|
+ pipelineContext.onCompiled = undefined;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/** @hidden */
|
|
/** @hidden */
|
|
- public _isProgramCompiled(shaderProgram: WebGLProgram): boolean {
|
|
|
|
- if (!shaderProgram.isParallelCompiled) {
|
|
|
|
- return true;
|
|
|
|
|
|
+ public _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean,
|
|
|
|
+ rebuildRebind: any,
|
|
|
|
+ defines: Nullable<string>,
|
|
|
|
+ transformFeedbackVaryings: Nullable<string[]>) {
|
|
|
|
+ let webGLRenderingState = pipelineContext as WebGLPipelineContext;
|
|
|
|
+
|
|
|
|
+ if (createAsRaw) {
|
|
|
|
+ webGLRenderingState.program = this.createRawShaderProgram(webGLRenderingState, vertexSourceCode, fragmentSourceCode, undefined, transformFeedbackVaryings);
|
|
}
|
|
}
|
|
|
|
+ else {
|
|
|
|
+ webGLRenderingState.program = this.createShaderProgram(webGLRenderingState, vertexSourceCode, fragmentSourceCode, defines, undefined, transformFeedbackVaryings);
|
|
|
|
+ }
|
|
|
|
+ webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;
|
|
|
|
+ }
|
|
|
|
|
|
- if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
|
|
|
|
- this._finalizeProgram(shaderProgram);
|
|
|
|
|
|
+ /** @hidden */
|
|
|
|
+ public _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean {
|
|
|
|
+ let webGLPipelineContext = pipelineContext as WebGLPipelineContext;
|
|
|
|
+ if (this._gl.getProgramParameter(webGLPipelineContext.program!, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
|
|
|
|
+ this._finalizePipelineContext(webGLPipelineContext);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3498,26 +3540,29 @@ export class Engine {
|
|
}
|
|
}
|
|
|
|
|
|
/** @hidden */
|
|
/** @hidden */
|
|
- public _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void) {
|
|
|
|
- if (!shaderProgram.isParallelCompiled) {
|
|
|
|
|
|
+ public _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void) {
|
|
|
|
+ let webGLPipelineContext = pipelineContext as WebGLPipelineContext;
|
|
|
|
+
|
|
|
|
+ if (!webGLPipelineContext.isParallelCompiled) {
|
|
action();
|
|
action();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- shaderProgram.onCompiled = action;
|
|
|
|
|
|
+ webGLPipelineContext.onCompiled = action;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
|
|
* Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
|
|
- * @param shaderProgram defines the webGL program to use
|
|
|
|
|
|
+ * @param pipelineContext defines the pipeline context to use
|
|
* @param uniformsNames defines the list of uniform names
|
|
* @param uniformsNames defines the list of uniform names
|
|
* @returns an array of webGL uniform locations
|
|
* @returns an array of webGL uniform locations
|
|
*/
|
|
*/
|
|
- public getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[] {
|
|
|
|
|
|
+ public getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[] {
|
|
var results = new Array<Nullable<WebGLUniformLocation>>();
|
|
var results = new Array<Nullable<WebGLUniformLocation>>();
|
|
|
|
+ let webGLPipelineContext = pipelineContext as WebGLPipelineContext;
|
|
|
|
|
|
for (var index = 0; index < uniformsNames.length; index++) {
|
|
for (var index = 0; index < uniformsNames.length; index++) {
|
|
- results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
|
|
|
|
|
|
+ results.push(this._gl.getUniformLocation(webGLPipelineContext.program!, uniformsNames[index]));
|
|
}
|
|
}
|
|
|
|
|
|
return results;
|
|
return results;
|
|
@@ -3525,16 +3570,17 @@ export class Engine {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets the lsit of active attributes for a given webGL program
|
|
* Gets the lsit of active attributes for a given webGL program
|
|
- * @param shaderProgram defines the webGL program to use
|
|
|
|
|
|
+ * @param pipelineContext defines the pipeline context to use
|
|
* @param attributesNames defines the list of attribute names to get
|
|
* @param attributesNames defines the list of attribute names to get
|
|
* @returns an array of indices indicating the offset of each attribute
|
|
* @returns an array of indices indicating the offset of each attribute
|
|
*/
|
|
*/
|
|
- public getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[] {
|
|
|
|
|
|
+ public getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[] {
|
|
var results = [];
|
|
var results = [];
|
|
|
|
+ let webGLPipelineContext = pipelineContext as WebGLPipelineContext;
|
|
|
|
|
|
for (var index = 0; index < attributesNames.length; index++) {
|
|
for (var index = 0; index < attributesNames.length; index++) {
|
|
try {
|
|
try {
|
|
- results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
|
|
|
|
|
|
+ results.push(this._gl.getAttribLocation(webGLPipelineContext.program!, attributesNames[index]));
|
|
} catch (e) {
|
|
} catch (e) {
|
|
results.push(-1);
|
|
results.push(-1);
|
|
}
|
|
}
|
|
@@ -5361,7 +5407,8 @@ export class Engine {
|
|
* @param effect defines the effect to bind
|
|
* @param effect defines the effect to bind
|
|
*/
|
|
*/
|
|
public bindSamplers(effect: Effect): void {
|
|
public bindSamplers(effect: Effect): void {
|
|
- this.setProgram(effect.getProgram());
|
|
|
|
|
|
+ let webGLPipelineContext = effect.getPipelineContext() as WebGLPipelineContext;
|
|
|
|
+ this.setProgram(webGLPipelineContext.program!);
|
|
var samplers = effect.getSamplers();
|
|
var samplers = effect.getSamplers();
|
|
for (var index = 0; index < samplers.length; index++) {
|
|
for (var index = 0; index < samplers.length; index++) {
|
|
var uniform = effect.getUniform(samplers[index]);
|
|
var uniform = effect.getUniform(samplers[index]);
|
|
@@ -5803,7 +5850,8 @@ export class Engine {
|
|
*/
|
|
*/
|
|
public releaseEffects() {
|
|
public releaseEffects() {
|
|
for (var name in this._compiledEffects) {
|
|
for (var name in this._compiledEffects) {
|
|
- this._deleteProgram(this._compiledEffects[name]._program);
|
|
|
|
|
|
+ let webGLPipelineContext = this._compiledEffects[name].getPipelineContext() as WebGLPipelineContext;
|
|
|
|
+ this._deletePipelineContext(webGLPipelineContext);
|
|
}
|
|
}
|
|
|
|
|
|
this._compiledEffects = {};
|
|
this._compiledEffects = {};
|
|
@@ -6502,4 +6550,4 @@ export class Engine {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|