+ * @brief Processes a discard queue for pipeline
+ *
+ * @param[in,out] queue Reference to the create queue
+ */
+ void ProcessDiscardQueue(std::queue<GLES::Pipeline*>& queue)
+ {
+ while(!queue.empty())
+ {
+ auto* object = const_cast<GLES::Pipeline*>(queue.front());
+
+ // Inform the contexts to invalidate the pipeline if cached
+ if(mContext)
+ {
+ mContext->InvalidateCachedPipeline(object);
+ }
+
+ for(auto&& context : mSurfaceContexts)
+ {
+ if(context.second)
+ {
+ context.second->InvalidateCachedPipeline(object);
+ }
+ }
+
+ // Destroy
+ object->DestroyResource();
+
+ // Free
+ auto* clbk = object->GetCreateInfo().allocationCallbacks;
+ if(clbk)
+ {
+ // Call destructor
+ using GLESPipeline = GLES::Pipeline;
+ object->~GLESPipeline();
+
+ // Free memory
+ clbk->freeCallback(object, clbk->userData);
+ }
+ else
+ {
+ delete object;
+ }
+ queue.pop();
+ }
+ }
+
+ /**