|
|
@ -1400,6 +1400,16 @@ void flush_quad_batch()
|
|
|
|
cur_batch_data_index = 0;
|
|
|
|
cur_batch_data_index = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LAYER_TILEMAP,
|
|
|
|
|
|
|
|
LAYER_WORLD,
|
|
|
|
|
|
|
|
LAYER_UI,
|
|
|
|
|
|
|
|
LAYER_UI_FG,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LAYER_LAST
|
|
|
|
|
|
|
|
} Layer;
|
|
|
|
|
|
|
|
|
|
|
|
#define Y_COORD_IN_BACK (-1.0f)
|
|
|
|
#define Y_COORD_IN_BACK (-1.0f)
|
|
|
|
#define Y_COORD_IN_FRONT (3.0f)
|
|
|
|
#define Y_COORD_IN_FRONT (3.0f)
|
|
|
|
typedef struct DrawParams
|
|
|
|
typedef struct DrawParams
|
|
|
@ -1415,11 +1425,9 @@ typedef struct DrawParams
|
|
|
|
float alpha_clip_threshold;
|
|
|
|
float alpha_clip_threshold;
|
|
|
|
|
|
|
|
|
|
|
|
bool do_clipping;
|
|
|
|
bool do_clipping;
|
|
|
|
|
|
|
|
Layer layer;
|
|
|
|
} DrawParams;
|
|
|
|
} DrawParams;
|
|
|
|
|
|
|
|
|
|
|
|
BUFF(DrawParams, 1024*5) rendering_queue = {0};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vec2 into_clip_space(Vec2 screen_space_point)
|
|
|
|
Vec2 into_clip_space(Vec2 screen_space_point)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Vec2 zero_to_one = DivV2(screen_space_point, screen_size());
|
|
|
|
Vec2 zero_to_one = DivV2(screen_space_point, screen_size());
|
|
|
@ -1427,6 +1435,9 @@ Vec2 into_clip_space(Vec2 screen_space_point)
|
|
|
|
return in_clip_space;
|
|
|
|
return in_clip_space;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef BUFF(DrawParams, 1024*5) RenderingQueue;
|
|
|
|
|
|
|
|
RenderingQueue rendering_queues[LAYER_LAST] = {0};
|
|
|
|
|
|
|
|
|
|
|
|
// The image region is in pixel space of the image
|
|
|
|
// The image region is in pixel space of the image
|
|
|
|
void draw_quad(DrawParams d)
|
|
|
|
void draw_quad(DrawParams d)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1441,7 +1452,8 @@ void draw_quad(DrawParams d)
|
|
|
|
// we've aplied the world space transform
|
|
|
|
// we've aplied the world space transform
|
|
|
|
d.world_space = false;
|
|
|
|
d.world_space = false;
|
|
|
|
|
|
|
|
|
|
|
|
BUFF_APPEND(&rendering_queue, d);
|
|
|
|
assert(d.layer >= 0 && d.layer < ARRLEN(rendering_queues));
|
|
|
|
|
|
|
|
BUFF_APPEND(&rendering_queues[(int)d.layer], d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int rendering_compare(const void *a, const void *b)
|
|
|
|
int rendering_compare(const void *a, const void *b)
|
|
|
@ -3910,9 +3922,12 @@ F cost: G + H
|
|
|
|
|
|
|
|
|
|
|
|
PROFILE_SCOPE("flush rendering")
|
|
|
|
PROFILE_SCOPE("flush rendering")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qsort(&rendering_queue.data[0], rendering_queue.cur_index, sizeof(rendering_queue.data[0]), rendering_compare);
|
|
|
|
ARR_ITER(RenderingQueue, rendering_queues)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RenderingQueue *rendering_queue = it;
|
|
|
|
|
|
|
|
qsort(&rendering_queue->data[0], rendering_queue->cur_index, sizeof(rendering_queue->data[0]), rendering_compare);
|
|
|
|
|
|
|
|
|
|
|
|
BUFF_ITER(DrawParams, &rendering_queue)
|
|
|
|
BUFF_ITER(DrawParams, rendering_queue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DrawParams d = *it;
|
|
|
|
DrawParams d = *it;
|
|
|
|
PROFILE_SCOPE("Draw quad")
|
|
|
|
PROFILE_SCOPE("Draw quad")
|
|
|
@ -4026,12 +4041,13 @@ F cost: G + H
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BUFF_CLEAR(&rendering_queue);
|
|
|
|
BUFF_CLEAR(rendering_queue);
|
|
|
|
|
|
|
|
|
|
|
|
flush_quad_batch();
|
|
|
|
flush_quad_batch();
|
|
|
|
sg_end_pass();
|
|
|
|
sg_end_pass();
|
|
|
|
sg_commit();
|
|
|
|
sg_commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
last_frame_processing_time = stm_sec(stm_diff(stm_now(),time_start_frame));
|
|
|
|
last_frame_processing_time = stm_sec(stm_diff(stm_now(),time_start_frame));
|
|
|
|
|
|
|
|
|
|
|
|