@@ -111,7 +111,7 @@ namespace wi::font
111111 bool start_new_word = false ;
112112 };
113113
114- static thread_local wi::vector<FontVertex > vertexList;
114+ static thread_local wi::vector<XMFLOAT4 > vertexList;
115115 ParseStatus ParseText (const wchar_t * text, size_t text_length, const Params& params)
116116 {
117117 ParseStatus status;
@@ -128,11 +128,11 @@ namespace wi::font
128128 if (status.last_word_begin > 0 && params.h_wrap >= 0 && status.cursor .position .x >= params.h_wrap - 1 )
129129 {
130130 // Word ended and wrap detected, push down last word by one line:
131- const float word_offset = vertexList[status.last_word_begin ].pos . x ;
131+ const float word_offset = vertexList[status.last_word_begin ].x ;
132132 for (size_t i = status.last_word_begin ; i < status.quadCount * 4 ; ++i)
133133 {
134- vertexList[i].pos . x -= word_offset;
135- vertexList[i].pos . y += linebreak_size;
134+ vertexList[i].x -= word_offset;
135+ vertexList[i].y += linebreak_size;
136136 }
137137 status.cursor .position .x -= word_offset;
138138 status.cursor .position .y += linebreak_size;
@@ -202,11 +202,6 @@ namespace wi::font
202202 const float top = status.cursor .position .y + glyphOffsetY;
203203 const float bottom = top + glyphHeight;
204204
205- vertexList[vertexID + 0 ].pos = float2 (left, top);
206- vertexList[vertexID + 1 ].pos = float2 (right, top);
207- vertexList[vertexID + 2 ].pos = float2 (left, bottom);
208- vertexList[vertexID + 3 ].pos = float2 (right, bottom);
209-
210205 float tc_left = glyph.tc_left ;
211206 float tc_right = glyph.tc_right ;
212207 float tc_top = glyph.tc_top ;
@@ -219,10 +214,11 @@ namespace wi::font
219214 {
220215 std::swap (tc_top, tc_bottom);
221216 }
222- vertexList[vertexID + 0 ].uv = float2 (tc_left, tc_top);
223- vertexList[vertexID + 1 ].uv = float2 (tc_right, tc_top);
224- vertexList[vertexID + 2 ].uv = float2 (tc_left, tc_bottom);
225- vertexList[vertexID + 3 ].uv = float2 (tc_right, tc_bottom);
217+
218+ vertexList[vertexID + 0 ] = float4 (left, top, tc_left, tc_top);
219+ vertexList[vertexID + 1 ] = float4 (right, top, tc_right, tc_top);
220+ vertexList[vertexID + 2 ] = float4 (left, bottom, tc_left, tc_bottom);
221+ vertexList[vertexID + 3 ] = float4 (right, bottom, tc_right, tc_bottom);
226222
227223 int advance, lsb;
228224 stbtt_GetCodepointHMetrics (&glyph.fontStyle ->fontInfo , code, &advance, &lsb);
@@ -259,7 +255,7 @@ namespace wi::font
259255
260256 void CommitText (void * vertexList_GPU)
261257 {
262- std::memcpy (vertexList_GPU, vertexList.data (), sizeof (FontVertex ) * vertexList.size ());
258+ std::memcpy (vertexList_GPU, vertexList.data (), sizeof (XMFLOAT4 ) * vertexList.size ());
263259 }
264260
265261 }
@@ -560,7 +556,7 @@ namespace wi::font
560556 M = M * Projection;
561557
562558 GraphicsDevice* device = wi::graphics::GetDevice ();
563- GraphicsDevice::GPUAllocation mem = device->AllocateGPU (sizeof (FontVertex ) * status.quadCount * 4 , cmd);
559+ GraphicsDevice::GPUAllocation mem = device->AllocateGPU (sizeof (float4 ) * status.quadCount * 4 , cmd);
564560 if (!mem.IsValid ())
565561 return status.cursor ;
566562 CommitText (mem.data );
@@ -612,8 +608,9 @@ namespace wi::font
612608 image.packed_color = pack_half4 (color);
613609 bolden = params.shadow_bolden ;
614610 softness = params.shadow_softness * 0 .5f ;
615- image.softness_bolden_hdrscaling = pack_half3 (softness, bolden, hdr_scaling);
616- device->BindDynamicConstantBuffer (image, CBSLOT_FONT , cmd);
611+ image.hdr_scaling_aspect = pack_half2 (hdr_scaling, 0 );
612+ image.angular_softness_direction = pack_half2 (softness, bolden);
613+ device->BindDynamicConstantBuffer (image, CBSLOT_IMAGE , cmd);
617614
618615 device->DrawInstanced (4 , status.quadCount , 0 , 0 , cmd);
619616 }
@@ -627,8 +624,9 @@ namespace wi::font
627624 image.packed_color = pack_half4 (color);
628625 bolden = params.bolden ;
629626 softness = params.softness * 0 .5f ;
630- image.softness_bolden_hdrscaling = pack_half3 (softness, bolden, hdr_scaling);
631- device->BindDynamicConstantBuffer (image, CBSLOT_FONT , cmd);
627+ image.hdr_scaling_aspect = pack_half2 (hdr_scaling, 0 );
628+ image.angular_softness_direction = pack_half2 (softness, bolden);
629+ device->BindDynamicConstantBuffer (image, CBSLOT_IMAGE , cmd);
632630
633631 device->DrawInstanced (4 , status.quadCount , 0 , 0 , cmd);
634632
0 commit comments