Skip to content

Commit 34f3ae9

Browse files
committed
Removed stack and lock support
1 parent a00e169 commit 34f3ae9

1 file changed

Lines changed: 57 additions & 95 deletions

File tree

src/renderer/webgl/PipelineManager.js

Lines changed: 57 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,26 @@ var PipelineManager = new Class({
100100
*/
101101
this.previous = null;
102102

103+
/**
104+
* Current post pipeline in use by the WebGLRenderer.
105+
*
106+
* @name Phaser.Renderer.WebGL.PipelineManager#currentPost
107+
* @type {Phaser.Renderer.WebGL.WebGLPipeline}
108+
* @default null
109+
* @since 3.50.0
110+
*/
111+
this.currentPost = null;
112+
113+
/**
114+
* The previous post pipeline that was in use.
115+
*
116+
* @name Phaser.Renderer.WebGL.PipelineManager#previousPost
117+
* @type {Phaser.Renderer.WebGL.WebGLPipeline}
118+
* @default null
119+
* @since 3.50.0
120+
*/
121+
this.previousPost = null;
122+
103123
/**
104124
* A constant-style reference to the Multi Pipeline Instance.
105125
*
@@ -138,29 +158,6 @@ var PipelineManager = new Class({
138158
* @since 3.50.0
139159
*/
140160
this.CAMERA_PIPELINE = null;
141-
142-
/**
143-
* A stack of pipeline instances that is used to manage when the pipelines
144-
* are locked and unlocked.
145-
*
146-
* Treat this array as read-only.
147-
*
148-
* @name Phaser.Renderer.WebGL.PipelineManager#stack
149-
* @type {array}
150-
* @since 3.50.0
151-
*/
152-
this.stack = [];
153-
154-
/**
155-
* Is the Pipeline Manager currently locked from setting a new pipeline?
156-
*
157-
* Treat this property as read-only.
158-
*
159-
* @name Phaser.Renderer.WebGL.PipelineManager#locked
160-
* @type {boolean}
161-
* @since 3.50.0
162-
*/
163-
this.locked = false;
164161
},
165162

166163
/**
@@ -223,6 +220,7 @@ var PipelineManager = new Class({
223220
if (!pipelines.has(name))
224221
{
225222
pipeline.name = name;
223+
pipeline.manager = this;
226224

227225
pipelines.set(name, pipeline);
228226
}
@@ -231,14 +229,14 @@ var PipelineManager = new Class({
231229
console.warn('Pipeline exists: ' + name);
232230
}
233231

234-
if (renderer.width !== 0 && renderer.height !== 0)
232+
if (!pipeline.hasBooted)
235233
{
236-
pipeline.resize(renderer.width, renderer.height);
234+
pipeline.boot();
237235
}
238236

239-
if (!pipeline.hasBooted)
237+
if (renderer.width !== 0 && renderer.height !== 0)
240238
{
241-
pipeline.boot();
239+
pipeline.resize(renderer.width, renderer.height);
242240
}
243241

244242
return pipeline;
@@ -425,15 +423,7 @@ var PipelineManager = new Class({
425423
*/
426424
set: function (pipeline, gameObject)
427425
{
428-
var renderer = this.renderer;
429-
var current = this.current;
430-
431-
if (
432-
!this.locked &&
433-
(current !== pipeline ||
434-
current.vertexBuffer !== renderer.currentVertexBuffer ||
435-
current.currentShader.program !== renderer.currentProgram)
436-
)
426+
if (!this.isCurrent(pipeline))
437427
{
438428
this.flush();
439429

@@ -447,83 +437,56 @@ var PipelineManager = new Class({
447437
pipeline.bind();
448438
}
449439

450-
if (!this.locked)
451-
{
452-
pipeline.onBind(gameObject);
453-
}
440+
pipeline.onBind(gameObject);
454441

455442
return pipeline;
456443
},
457444

458-
/**
459-
* Sets the current pipeline to be used by the `WebGLRenderer` and then locks it.
460-
*
461-
* Once a pipeline is locked, further calls to `PipelineManager.set` are ignored.
462-
*
463-
* However, another pipeline may also be locked. If this happens, the previous pipeline
464-
* is flushed and the new one is locked in place.
465-
*
466-
* Make sure to call `PipelineManager.unlock` when you're done.
467-
*
468-
* This method accepts a pipeline instance as its parameter, not the name.
469-
*
470-
* If the pipeline isn't already the current one it will call `WebGLPipeline.bind` and then `onBind`.
471-
*
472-
* @method Phaser.Renderer.WebGL.PipelineManager#lock
473-
* @since 3.50.0
474-
*
475-
* @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The pipeline instance to be set as current.
476-
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
477-
*
478-
* @return {this} This Pipeline Manager.
479-
*/
480-
lock: function (pipeline, gameObject)
445+
preBatch: function (gameObject)
481446
{
482-
this.flush();
447+
if (!gameObject || !gameObject.postPipeline)
448+
{
449+
return;
450+
}
483451

484-
this.stack.push({ pipeline: pipeline, gameObject: gameObject });
452+
this.flush();
485453

486-
this.locked = false;
454+
gameObject.postPipeline.postBind(gameObject);
455+
},
487456

488-
this.set(pipeline, gameObject);
457+
postBatch: function (gameObject)
458+
{
459+
if (!gameObject || !gameObject.postPipeline)
460+
{
461+
return;
462+
}
489463

490-
this.locked = true;
464+
this.flush();
491465

492-
return this;
466+
gameObject.postPipeline.postFlush(gameObject);
493467
},
494468

495469
/**
496-
* Flushes the current pipeline, pops the previous one from the locked stack (if any)
497-
* and then sets that, locking it in turn. If there aren't any other pipelines on
498-
* the stack, the Pipeline Manager is fully unlocked.
470+
* Checks to see if the given pipeline is already the active pipeline, both within this
471+
* Pipeline Manager, and also has the same vertex buffer and shader set within the Renderer.
499472
*
500-
* @method Phaser.Renderer.WebGL.PipelineManager#unlock
473+
* @method Phaser.Renderer.WebGL.PipelineManager#isCurrent
501474
* @since 3.50.0
502475
*
503-
* @return {this} This Pipeline Manager.
476+
* @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The pipeline instance to be checked.
477+
*
478+
* @return {boolean} `true` if the given pipeline is already the current pipeline, otherwise `false`.
504479
*/
505-
unlock: function ()
480+
isCurrent: function (pipeline)
506481
{
507-
this.flush();
508-
509-
this.stack.pop();
510-
511-
if (this.stack.length > 0)
512-
{
513-
var previous = this.stack[this.stack.length - 1];
514-
515-
this.locked = false;
516-
517-
this.set(previous.pipeline, previous.gameObject);
518-
519-
this.locked = true;
520-
}
521-
else
522-
{
523-
this.locked = false;
524-
}
482+
var renderer = this.renderer;
483+
var current = this.current;
525484

526-
return this;
485+
return !(
486+
current !== pipeline ||
487+
current.vertexBuffer !== renderer.currentVertexBuffer ||
488+
current.currentShader.program !== renderer.currentProgram
489+
);
527490
},
528491

529492
/**
@@ -664,7 +627,6 @@ var PipelineManager = new Class({
664627
this.renderer = null;
665628
this.game = null;
666629
this.pipelines = null;
667-
this.stack = null;
668630
this.current = null;
669631
this.previous = null;
670632
}

0 commit comments

Comments
 (0)