From 245d4a8d9a6d1f8a56be4799c4e0bc5485018380 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 17 Dec 2023 13:14:43 +0900 Subject: [PATCH] [vulkan] Clean up make_id() Passing the control struct and a flag for style/nostyle makes the calls much easier to read. --- libs/video/renderer/vulkan/vulkan_lighting.c | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index 8e08b1d1b..99b1bc79d 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -389,10 +389,19 @@ lighting_draw_shadow_maps (const exprval_t **params, exprval_t *result, } } +typedef enum : uint32_t { + style_enable, + style_disable = 0x80000000, +} style_e; + static uint32_t -make_id (uint32_t matrix_index, uint32_t map_index, uint32_t layer, - uint32_t type) +make_id (const light_control_t *cont, style_e style) { + uint32_t matrix_index = cont->matrix_id; + uint32_t map_index = cont->map_index; + uint32_t layer = cont->layer; + uint32_t type = cont->mode; + if (type == ST_CUBE) { // on the GPU, layer is the cube layer, and one cube layer is 6 // flat image layers @@ -400,7 +409,8 @@ make_id (uint32_t matrix_index, uint32_t map_index, uint32_t layer, } return ((matrix_index & 0x3fff) << 0) | ((map_index & 0x1f) << 14) - | ((layer & 0x7ff) << 19); + | ((layer & 0x7ff) << 19) + | style; } static void @@ -791,10 +801,8 @@ lighting_update_lights (const exprval_t **params, exprval_t *result, for (int i = 0; i < ndlight; i++) { auto r = &lctx->light_control.a[lctx->dynamic_base + i]; render[i] = (qfv_light_render_t) { - .id_data = make_id(r->matrix_id, r->map_index, r->layer, - r->mode), + .id_data = make_id(r, style_disable), }; - render[i].id_data |= 0x80000000; // no style } QFV_PacketScatterBuffer (packet, lframe->render_buffer, 1, &render_scatter, bb); @@ -2090,7 +2098,7 @@ upload_light_data (lightingctx_t *lctx, vulkan_ctx_t *ctx) } auto r = &lctx->light_control.a[id]; render[i] = (qfv_light_render_t) { - .id_data = make_id(r->matrix_id, r->map_index, r->layer, r->mode), + .id_data = make_id(r, style_enable), .style = get_lightstyle (ent), }; }