Skip to content

Commit

Permalink
Updated C API, made it easier to port GPUDriver-related structs to ot…
Browse files Browse the repository at this point in the history
…her languages by limiting custom byte alignment to vertex declarations.
  • Loading branch information
adamjs committed Aug 7, 2020
1 parent 68a4198 commit 0a5d7f8
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Ultralight/CAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -1481,12 +1481,6 @@ typedef struct {
* GPUDriver
*****************************************************************************/

///
/// @note This pragma pack(push, 1) command is important! Vertex layouts
/// should not be padded with any bytes.
///
#pragma pack(push, 1)

///
/// Render buffer description.
///
Expand All @@ -1498,9 +1492,17 @@ typedef struct {
bool has_depth_buffer; // Currently unsued, always false.
} ULRenderBuffer;

///
/// @note This pragma pack(push, 1) command is important! Vertex layouts
/// should not be padded with any bytes.
///
#pragma pack(push, 1)

///
/// Vertex layout for path vertices.
///
/// (this struct's members aligned on single-byte boundaries)
///
typedef struct {
float pos[2];
unsigned char color[4];
Expand All @@ -1510,6 +1512,8 @@ typedef struct {
///
/// Vertex layout for quad vertices.
///
/// (this struct's members aligned on single-byte boundaries)
///
typedef struct {
float pos[2];
unsigned char color[4];
Expand All @@ -1524,6 +1528,11 @@ typedef struct {
float data6[4];
} ULVertex_2f_4ub_2f_2f_28f;

///
/// End single-byte alignment.
///
#pragma pack(pop)

///
/// Vertex formats.
///
Expand Down Expand Up @@ -1621,7 +1630,7 @@ typedef struct {
/// The following four members are passed to the pixel shader via uniforms.
float uniform_scalar[8];
ULvec4 uniform_vector[8];
unsigned int clip_size;
unsigned char clip_size;
ULMatrix4x4 clip[8];

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

#pragma pack(pop)

///
/// The callback invoked when the GPUDriver will begin dispatching commands
/// (such as CreateTexture and UpdateCommandList) during the current call to
Expand Down

0 comments on commit 0a5d7f8

Please sign in to comment.