@@ -357,34 +357,55 @@ struct PSInput
357357 // Set functions used in vshader, get functions used in fshader
358358 // We have to do this because we don't have union in hlsl and this is the best way to alias
359359
360- // data1 (w component reserved for later)
360+ /* SHARED: ALL ObjectTypes */
361361 ObjectType getObjType () { return (ObjectType) data1.x; }
362362 uint getMainObjectIdx () { return data1.y; }
363- float getLineThickness () { return asfloat (data1.z); }
364- float getPatternStretch () { return asfloat (data1.w); }
365363
366364 void setObjType (ObjectType objType) { data1.x = (uint ) objType; }
367365 void setMainObjectIdx (uint mainObjIdx) { data1.y = mainObjIdx; }
366+
367+ /* SHARED: LINE + QUAD_BEZIER (Curve Outlines) */
368+ float getLineThickness () { return asfloat (data1.z); }
369+ float getPatternStretch () { return asfloat (data1.w); }
370+
368371 void setLineThickness (float lineThickness) { data1.z = asuint (lineThickness); }
369372 void setPatternStretch (float stretch) { data1.w = asuint (stretch); }
373+
374+ void setCurrentPhaseShift (float phaseShift) { interp_data5.x = phaseShift; }
375+ float getCurrentPhaseShift () { return interp_data5.x; }
376+
377+ void setCurrentWorldToScreenRatio (float worldToScreen) { interp_data5.y = worldToScreen; }
378+ float getCurrentWorldToScreenRatio () { return interp_data5.y; }
370379
371- // data2
380+ /* LINE */
372381 float2 getLineStart () { return data2.xy; }
373382 float2 getLineEnd () { return data2.zw; }
374-
375383 void setLineStart (float2 lineStart) { data2.xy = lineStart; }
376384 void setLineEnd (float2 lineEnd) { data2.zw = lineEnd; }
377-
378- // Texture glyph UVs
379- // data2
380- float2 getFontGlyphUv () { return interp_data5.xy; }
381- uint32_t getFontGlyphTextureId () { return asuint (data2.x); }
382- float getFontGlyphScreenPxRange () { return data2.y; }
383385
384- void setFontGlyphUv (float2 uv) { interp_data5.xy = uv; }
385- void setFontGlyphTextureId (uint32_t textureId) { data2.x = asfloat (textureId); }
386- void setFontGlyphScreenPxRange (float glyphScreenPxRange) { data2.y = glyphScreenPxRange; }
386+ /* QUAD_BEZIER */
387+ nbl::hlsl::shapes::Quadratic<float > getQuadratic ()
388+ {
389+ return nbl::hlsl::shapes::Quadratic<float >::construct (data2.xy, data2.zw, data3.xy);
390+ }
391+ void setQuadratic (nbl::hlsl::shapes::Quadratic<float > quadratic)
392+ {
393+ data2.xy = quadratic.A;
394+ data2.zw = quadratic.B;
395+ data3.xy = quadratic.C;
396+ }
387397
398+ void setQuadraticPrecomputedArcLenData (nbl::hlsl::shapes::Quadratic<float >::ArcLengthCalculator preCompData)
399+ {
400+ data3.zw = float2 (preCompData.lenA2, preCompData.AdotB);
401+ data4 = float4 (preCompData.a, preCompData.b, preCompData.c, preCompData.b_over_4a);
402+ }
403+ nbl::hlsl::shapes::Quadratic<float >::ArcLengthCalculator getQuadraticArcLengthCalculator ()
404+ {
405+ return nbl::hlsl::shapes::Quadratic<float >::ArcLengthCalculator::construct (data3.z, data3.w, data4.x, data4.y, data4.z, data4.w);
406+ }
407+
408+ /* CURVE_BOX */
388409 // Curves are split in the vertex shader based on their tmin and tmax
389410 // Min curve is smaller in the minor coordinate (e.g. in the default of y top to bottom sweep,
390411 // curveMin = smaller x / left, curveMax = bigger x / right)
@@ -429,64 +450,15 @@ struct PSInput
429450 }
430451
431452 // Curve box value along minor & major axis
432- float getMinorBBoxUv () { return interp_data5.x; };
433- void setMinorBBoxUv (float minorBBoxUv ) { interp_data5.x = minorBBoxUv ; }
434- float getMajorBBoxUv () { return interp_data5.y; };
435- void setMajorBBoxUv (float majorBBoxUv ) { interp_data5.y = majorBBoxUv ; }
453+ float getMinorBBoxUV () { return interp_data5.x; };
454+ void setMinorBBoxUV (float minorBBoxUV ) { interp_data5.x = minorBBoxUV ; }
455+ float getMajorBBoxUV () { return interp_data5.y; };
456+ void setMajorBBoxUV (float majorBBoxUV ) { interp_data5.y = majorBBoxUV ; }
436457
437458 float2 getCurveBoxScreenSpaceSize () { return asfloat (data1.zw); }
438459 void setCurveBoxScreenSpaceSize (float2 aabbSize) { data1.zw = asuint (aabbSize); }
439-
440- // data2 + data3.xy
441- nbl::hlsl::shapes::Quadratic<float > getQuadratic ()
442- {
443- return nbl::hlsl::shapes::Quadratic<float >::construct (data2.xy, data2.zw, data3.xy);
444- }
445460
446- void setQuadratic (nbl::hlsl::shapes::Quadratic<float > quadratic)
447- {
448- data2.xy = quadratic.A;
449- data2.zw = quadratic.B;
450- data3.xy = quadratic.C;
451- }
452-
453- // data3.zw + data4
454-
455- void setQuadraticPrecomputedArcLenData (nbl::hlsl::shapes::Quadratic<float >::ArcLengthCalculator preCompData)
456- {
457- data3.zw = float2 (preCompData.lenA2, preCompData.AdotB);
458- data4 = float4 (preCompData.a, preCompData.b, preCompData.c, preCompData.b_over_4a);
459- }
460-
461- nbl::hlsl::shapes::Quadratic<float >::ArcLengthCalculator getQuadraticArcLengthCalculator ()
462- {
463- return nbl::hlsl::shapes::Quadratic<float >::ArcLengthCalculator::construct (data3.z, data3.w, data4.x, data4.y, data4.z, data4.w);
464- }
465-
466- // data5.x
467-
468- void setCurrentPhaseShift (float phaseShift)
469- {
470- interp_data5.x = phaseShift;
471- }
472-
473- float getCurrentPhaseShift ()
474- {
475- return interp_data5.x;
476- }
477-
478- // Use only for Lines and QuadBeziers, other objects use this slot of interp_data5.y
479- void setCurrentWorldToScreenRatio (float worldToScreen)
480- {
481- interp_data5.y = worldToScreen;
482- }
483-
484- float getCurrentWorldToScreenRatio ()
485- {
486- return interp_data5.y;
487- }
488- // POLYLINE_CONNECTOR data
489-
461+ /* POLYLINE_CONNECTOR */
490462 void setPolylineConnectorTrapezoidStart (float2 trapezoidStart) { data2.xy = trapezoidStart; }
491463 void setPolylineConnectorTrapezoidEnd (float2 trapezoidEnd) { data2.zw = trapezoidEnd; }
492464 void setPolylineConnectorTrapezoidShortBase (float shortBase) { data3.x = shortBase; }
@@ -499,7 +471,17 @@ struct PSInput
499471 float getPolylineConnectorTrapezoidLongBase () { return data3.y; }
500472 float2 getPolylineConnectorCircleCenter () { return data3.zw; }
501473
502- // IMAGE object data
474+ /* FONT_GLYPH */
475+ float2 getFontGlyphUV () { return interp_data5.xy; }
476+ uint32_t getFontGlyphTextureId () { return asuint (data2.x); }
477+ float getFontGlyphScreenPxRange () { return data2.y; }
478+
479+ void setFontGlyphUV (float2 uv) { interp_data5.xy = uv; }
480+ void setFontGlyphTextureId (uint32_t textureId) { data2.x = asfloat (textureId); }
481+ void setFontGlyphScreenPxRange (float glyphScreenPxRange) { data2.y = glyphScreenPxRange; }
482+
483+
484+ /* IMAGE */
503485 float2 getImageUV () { return interp_data5.xy; }
504486 uint32_t getImageTextureId () { return asuint (data2.x); }
505487
0 commit comments