Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
askmeaboutlo0m committed Aug 15, 2023
1 parent 84507f9 commit 6bf4fe3
Show file tree
Hide file tree
Showing 11 changed files with 456 additions and 49 deletions.
2 changes: 2 additions & 0 deletions src/drawdance/libcommon/dpcommon/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ DP_INLINE size_t DP_flex_size(size_t type_size, size_t flex_offset,
* member. Takes potential trailing padding being used as part of the flexible
* array member into account.
*/
// NOLINTBEGIN(bugprone-sizeof-expression)
#define DP_FLEX_SIZEOF(TYPE, FIELD, COUNT) \
DP_flex_size(sizeof(TYPE), offsetof(TYPE, FIELD), \
sizeof(((TYPE *)NULL)->FIELD[0]), COUNT)
// NOLINTEND(bugprone-sizeof-expression)


void *DP_malloc(size_t size) DP_MALLOC_ATTR;
Expand Down
10 changes: 6 additions & 4 deletions src/drawdance/libengine/dpengine/paint_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ typedef struct DP_PaintEngineDabsPreview {

typedef struct DP_PaintEngineRenderBuffer {
DP_ALIGNAS_SIMD DP_Pixel8 pixels[DP_TILE_LENGTH];
DP_ViewModeBuffer *vmb;
DP_ViewModeBuffer vmb;
} DP_PaintEngineRenderBuffer;

typedef struct DP_PaintEngineCursorChange {
Expand Down Expand Up @@ -632,6 +632,7 @@ static void run_paint_engine(void *user)
DP_PaintEngine *pe = user;
DP_DrawContext *dc = pe->paint_dc;
DP_Semaphore *sem = pe->queue_sem;
// NOLINTNEXTLINE(bugprone-sizeof-expression)
DP_Message **msgs = DP_malloc(sizeof(*msgs) * MAX_MULTIDAB_MESSAGES);
while (true) {
DP_SEMAPHORE_MUST_WAIT(sem);
Expand Down Expand Up @@ -677,7 +678,7 @@ static void render_job(void *user, int thread_index)
DP_PaintEngine *pe = render_params->pe;
int tile_index = y * render_params->xtiles + x;
DP_TransientTile *tt =
flatten_tile(pe, pe->render.buffers[thread_index].vmb,
flatten_tile(pe, &pe->render.buffers[thread_index].vmb,
render_params->needs_checkers, tile_index);

DP_Pixel8 *pixel_buffer = pe->render.buffers[thread_index].pixels;
Expand Down Expand Up @@ -796,7 +797,7 @@ DP_PaintEngine *DP_paint_engine_new_inc(
pe->render.buffers = DP_malloc_simd(sizeof(DP_PaintEngineRenderBuffer)
* DP_int_to_size(render_thread_count));
for (int i = 0; i < render_thread_count; ++i) {
pe->render.buffers[i].vmb = DP_view_mode_buffer_new();
DP_view_mode_buffer_init(&pe->render.buffers[i].vmb);
}
return pe;
}
Expand All @@ -809,7 +810,7 @@ void DP_paint_engine_free_join(DP_PaintEngine *pe)
DP_semaphore_free(pe->render.tiles_done_sem);
int render_thread_count = DP_paint_engine_render_thread_count(pe);
for (int i = 0; i < render_thread_count; ++i) {
DP_view_mode_buffer_free(pe->render.buffers[i].vmb);
DP_view_mode_buffer_dispose(&pe->render.buffers[i].vmb);
}
DP_free_simd(pe->render.buffers);
DP_worker_free_join(pe->render.worker);
Expand Down Expand Up @@ -838,6 +839,7 @@ void DP_paint_engine_free_join(DP_PaintEngine *pe)
DP_Message **msgs =
DP_msg_internal_dump_command_messages(mi, &count);
decref_messages(count, msgs);
break;
}
default:
break;
Expand Down
Loading

0 comments on commit 6bf4fe3

Please sign in to comment.