Ejemplo n.º 1
0
        private unsafe static void OnRenderNodeExecute(IntPtr obj)
        {
            RenderNodeData rnd = AccessRenderNodeData(obj);
            Exception      immediateException = null;

            rnd.device.EvaluateChain(rnd.firstCommand, rnd.initialMaterial, rnd.standardMaterial,
                                     rnd.atlas, rnd.vectorAtlas, rnd.shaderInfoAtlas,
                                     rnd.dpiScale, rnd.transformConstants, rnd.clipRectConstants,
                                     rnd.matPropBlock, false, ref immediateException);
        }
Ejemplo n.º 2
0
        private unsafe static void OnRenderNodeExecute(IntPtr obj)
        {
            RenderChain    rc;
            RenderNodeData rnd = AccessRenderNodeData(obj, out rc);

            Exception immediateException = null;

            rc.device.EvaluateChain(rc.m_FirstCommand, rnd.viewport, rnd.standardMat, rc.atlasManager?.atlas,
                                    rc.vectorImageManager?.atlas, rc.shaderInfoAllocator.atlas,
                                    (rc.panel as BaseVisualElementPanel).scaledPixelsPerPoint, rc.shaderInfoAllocator.transformConstants, rc.shaderInfoAllocator.clipRectConstants,
                                    rnd.matPropBlock, ref immediateException);
        }
Ejemplo n.º 3
0
        private static void OnRegisterIntermediateRenderers(Camera camera)
        {
            int commandOrder = 0;
            var panels       = UIElementsUtility.GetPanelsIterator();

            while (panels.MoveNext())
            {
                var         p           = panels.Current.Value;
                RenderChain renderChain = (p.GetUpdater(VisualTreeUpdatePhase.Repaint) as UIRRepaintUpdater)?.renderChain;
                if (renderChain == null || renderChain.m_StaticIndex < 0 || renderChain.m_FirstCommand == null)
                {
                    continue;
                }

                RuntimePanel   rtp = (RuntimePanel)p;
                Material       standardMaterial = renderChain.GetStandardWorldSpaceMaterial();
                RenderNodeData rndSource        = new RenderNodeData();
                rndSource.device             = renderChain.device;
                rndSource.standardMaterial   = standardMaterial;
                rndSource.atlas              = renderChain.atlasManager?.atlas;
                rndSource.vectorAtlas        = renderChain.vectorImageManager?.atlas;
                rndSource.shaderInfoAtlas    = renderChain.shaderInfoAllocator.atlas;
                rndSource.dpiScale           = rtp.scaledPixelsPerPoint;
                rndSource.transformConstants = renderChain.shaderInfoAllocator.transformConstants;
                rndSource.clipRectConstants  = renderChain.shaderInfoAllocator.clipRectConstants;

                if (renderChain.m_CustomMaterialCommands == 0)
                {
                    // Trivial case, custom materials not used, so we don't have to chop the chain
                    // to multiple intermediate renderers
                    rndSource.initialMaterial = standardMaterial;
                    rndSource.firstCommand    = renderChain.m_FirstCommand;
                    OnRegisterIntermediateRendererMat(rtp, renderChain, ref rndSource, camera, commandOrder++);
                    continue;
                }

                // Complex case, custom materials used
                // TODO: Early out once all custom materials have been counted
                Material           lastMaterial       = null;
                var                command            = renderChain.m_FirstCommand;
                RenderChainCommand commandToStartWith = command;
                while (command != null)
                {
                    if (command.type != CommandType.Draw)
                    {
                        command = command.next;
                        continue;
                    }
                    Material commandMat = command.state.material == null ? standardMaterial : command.state.material;
                    if (commandMat != lastMaterial)
                    {
                        if (lastMaterial != null)
                        {
                            rndSource.initialMaterial = lastMaterial;
                            rndSource.firstCommand    = commandToStartWith;
                            OnRegisterIntermediateRendererMat(rtp, renderChain, ref rndSource, camera, commandOrder++);
                            commandToStartWith = command;
                        }
                        lastMaterial = commandMat;
                    }
                    command = command.next;
                } // While render chain commands to execute

                if (commandToStartWith != null)
                {
                    rndSource.initialMaterial = lastMaterial;
                    rndSource.firstCommand    = commandToStartWith;
                    OnRegisterIntermediateRendererMat(rtp, renderChain, ref rndSource, camera, commandOrder++);
                }
            } // For each panel
        }
Ejemplo n.º 4
0
        private unsafe static void OnRegisterIntermediateRendererMat(RuntimePanel rtp, RenderChain renderChain, ref RenderNodeData rnd, Camera camera, int sameDistanceSortPriority)
        {
            int renderNodeIndex = renderChain.m_ActiveRenderNodes++;

            if (renderNodeIndex < renderChain.m_RenderNodesData.Count)
            {
                var reuseRND = renderChain.m_RenderNodesData[renderNodeIndex];
                rnd.matPropBlock = reuseRND.matPropBlock;
                renderChain.m_RenderNodesData[renderNodeIndex] = rnd;
            }
            else
            {
                rnd.matPropBlock = new MaterialPropertyBlock();
                renderNodeIndex  = renderChain.m_RenderNodesData.Count;
                renderChain.m_RenderNodesData.Add(rnd);
            }

            int *userData = stackalloc int[2];

            userData[0] = renderChain.m_StaticIndex;
            userData[1] = renderNodeIndex;
            UIR.Utility.RegisterIntermediateRenderer(camera, rnd.initialMaterial, rtp.panelToWorld,
                                                     new Bounds(Vector3.zero, new Vector3(float.MaxValue, float.MaxValue, float.MaxValue)),
                                                     3, 0, false, sameDistanceSortPriority, (ulong)camera.cullingMask, (int)UIR.Utility.RendererCallbacks.RendererCallback_Exec,
                                                     new IntPtr(userData), sizeof(int) * 2);
        }