void ReallyCreateAtlas() { m_Atlas = new UIRAtlasManager( m_VertexTexturingEnabled ? RenderTextureFormat.ARGBFloat : RenderTextureFormat.ARGB32, // If no vertex texturing, only store opacity in ARGB32 FilterMode.Point, // Filtering is never needed for this texture Math.Max(pageWidth, pageHeight * 3), // Each transform row is stored vertically 64); // Because we want predictable placement of first pages, 64 will fit all three default allocs // The order of allocation from the atlas below is important. See the comment at the beginning of Construct(). RectInt rcTransform, rcClipRect, rcOpacity; m_Atlas.AllocateRect(pageWidth * m_TransformAllocator.entryWidth, pageHeight * m_TransformAllocator.entryHeight, out rcTransform); m_Atlas.AllocateRect(pageWidth * m_ClipRectAllocator.entryWidth, pageHeight * m_ClipRectAllocator.entryHeight, out rcClipRect); m_Atlas.AllocateRect(pageWidth * m_OpacityAllocator.entryWidth, pageHeight * m_OpacityAllocator.entryHeight, out rcOpacity); if (!AtlasRectMatchesPage(ref m_TransformAllocator, identityTransform, rcTransform)) { throw new Exception("Atlas identity transform allocation failed unexpectedly"); } if (!AtlasRectMatchesPage(ref m_ClipRectAllocator, infiniteClipRect, rcClipRect)) { throw new Exception("Atlas infinite clip rect allocation failed unexpectedly"); } if (!AtlasRectMatchesPage(ref m_OpacityAllocator, fullOpacity, rcOpacity)) { throw new Exception("Atlas full opacity allocation failed unexpectedly"); } var whiteTexel = UIRenderDevice.whiteTexel; if (m_VertexTexturingEnabled) { var allocXY = AllocToTexelCoord(ref m_TransformAllocator, identityTransform); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y + 0, false, identityTransformRow0Value); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y + 1, false, identityTransformRow1Value); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y + 2, false, identityTransformRow2Value); allocXY = AllocToTexelCoord(ref m_ClipRectAllocator, infiniteClipRect); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y, false, infiniteClipRectValue); } { var allocXY = AllocToTexelCoord(ref m_OpacityAllocator, fullOpacity); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y, false, fullOpacityValue); } m_AtlasReallyCreated = true; }
public void SetTransformValue(BMPAlloc alloc, Matrix4x4 xform) { Debug.Assert(alloc.IsValid()); if (m_VertexTexturingEnabled) { var allocXY = AllocToTexelCoord(ref m_TransformAllocator, alloc); m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, allocXY.x, allocXY.y + 0, false, xform.GetRow(0)); m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, allocXY.x, allocXY.y + 1, false, xform.GetRow(1)); m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, allocXY.x, allocXY.y + 2, false, xform.GetRow(2)); } else { m_Transforms[AllocToConstantBufferIndex(alloc)] = new Transform3x4() { v0 = xform.GetRow(0), v1 = xform.GetRow(1), v2 = xform.GetRow(2) } }; }