{-# OPTIONS_GHC -fplugin Foreign.Storable.Generic.Plugin #-} {-# LANGUAGE DeriveAnyClass #-} module Render.Font.Msdf.Model ( InstanceAttrs(..) ) where import RIO import Geomancy (IVec2, Vec2, Vec4) import Graphics.Gl.Block (Block) import Graphics.Gl.Block qualified as Block import Vulkan.Core10 qualified as Vk import Engine.Vulkan.Format (HasVkFormat(..)) import Engine.Vulkan.Pipeline.Graphics (HasVertexInputBindings(..), instanceFormat) data InstanceAttrs = InstanceAttrs { -- static, can be shoved into font buffer vertRect :: Vec4 , fragRect :: Vec4 , textureIds :: IVec2 -- | sampler + textureId , sdfDist :: Vec2 -- dynamic , color :: Vec4 , outlineColor :: Vec4 , smoothing :: Float -- size-related , outlineWidth :: Float } deriving (Eq, Show, Generic, Block) deriving Storable via (Block.Packed InstanceAttrs) instance HasVkFormat InstanceAttrs where getVkFormat = [ Vk.FORMAT_R32G32B32A32_SFLOAT -- Quad scale+offset , Vk.FORMAT_R32G32B32A32_SFLOAT -- UV scale+offset , Vk.FORMAT_R32G32_SINT -- Sampler + texture IDs , Vk.FORMAT_R32G32_SFLOAT -- SDF lower + range ----- , Vk.FORMAT_R32G32B32A32_SFLOAT -- Color , Vk.FORMAT_R32G32B32A32_SFLOAT -- Outline color , Vk.FORMAT_R32G32_SFLOAT -- Smoothing + outline ] instance HasVertexInputBindings InstanceAttrs where vertexInputBindings = [instanceFormat @InstanceAttrs]