Skip to content

Commit 0a5d7f8

Browse files
committed
Updated C API, made it easier to port GPUDriver-related structs to other languages by limiting custom byte alignment to vertex declarations.
1 parent 68a4198 commit 0a5d7f8

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

Ultralight/CAPI.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,12 +1481,6 @@ typedef struct {
14811481
* GPUDriver
14821482
*****************************************************************************/
14831483

1484-
///
1485-
/// @note This pragma pack(push, 1) command is important! Vertex layouts
1486-
/// should not be padded with any bytes.
1487-
///
1488-
#pragma pack(push, 1)
1489-
14901484
///
14911485
/// Render buffer description.
14921486
///
@@ -1498,9 +1492,17 @@ typedef struct {
14981492
bool has_depth_buffer; // Currently unsued, always false.
14991493
} ULRenderBuffer;
15001494

1495+
///
1496+
/// @note This pragma pack(push, 1) command is important! Vertex layouts
1497+
/// should not be padded with any bytes.
1498+
///
1499+
#pragma pack(push, 1)
1500+
15011501
///
15021502
/// Vertex layout for path vertices.
15031503
///
1504+
/// (this struct's members aligned on single-byte boundaries)
1505+
///
15041506
typedef struct {
15051507
float pos[2];
15061508
unsigned char color[4];
@@ -1510,6 +1512,8 @@ typedef struct {
15101512
///
15111513
/// Vertex layout for quad vertices.
15121514
///
1515+
/// (this struct's members aligned on single-byte boundaries)
1516+
///
15131517
typedef struct {
15141518
float pos[2];
15151519
unsigned char color[4];
@@ -1524,6 +1528,11 @@ typedef struct {
15241528
float data6[4];
15251529
} ULVertex_2f_4ub_2f_2f_28f;
15261530

1531+
///
1532+
/// End single-byte alignment.
1533+
///
1534+
#pragma pack(pop)
1535+
15271536
///
15281537
/// Vertex formats.
15291538
///
@@ -1621,7 +1630,7 @@ typedef struct {
16211630
/// The following four members are passed to the pixel shader via uniforms.
16221631
float uniform_scalar[8];
16231632
ULvec4 uniform_vector[8];
1624-
unsigned int clip_size;
1633+
unsigned char clip_size;
16251634
ULMatrix4x4 clip[8];
16261635

16271636
/// Whether or not scissor testing should be used for the current draw
@@ -1660,8 +1669,6 @@ typedef struct {
16601669
ULCommand* commands;
16611670
} ULCommandList;
16621671

1663-
#pragma pack(pop)
1664-
16651672
///
16661673
/// The callback invoked when the GPUDriver will begin dispatching commands
16671674
/// (such as CreateTexture and UpdateCommandList) during the current call to

0 commit comments

Comments
 (0)