[vulkan] Implement mouse-picking for light entities

Currently, only light entities get drawn to the entid buffer, and the
ids are simply displayed in a window for now (not very useful yet).
This commit is contained in:
Bill Currie 2023-08-07 17:47:49 +09:00
parent 95b660d7fd
commit 1745d3bccc
17 changed files with 697 additions and 46 deletions

View file

@ -0,0 +1,46 @@
#ifndef __QF_Vulkan_mouse_pick_h
#define __QF_Vulkan_mouse_pick_h
#ifndef VK_NO_PROTOTYPES
#define VK_NO_PROTOTYPES
#endif
#include <vulkan/vulkan.h>
#include "QF/darray.h"
#include "QF/qtypes.h"
#define mousepick_size 5
struct vulkan_ctx_s;
typedef void (*mousepickfunc_t) (const uint32_t *entid, void *data);
typedef struct qfv_mousepick_frame_s {
VkBuffer entid_buffer;
uint32_t *entid_data;
bool initiated;
mousepickfunc_t callback;
void *callback_data;
uint32_t x, y;
VkOffset3D offset;
VkExtent3D extent;
VkImage entid_image;
} qfv_mousepick_frame_t;
typedef struct qfv_mousepick_frame_set_s
DARRAY_TYPE (qfv_mousepick_frame_t) qfv_mousepick_frame_set_t;
typedef struct qfv_mousepickctx_s {
qfv_mousepick_frame_set_t frames;
struct qfv_resobj_s *entid_res;
struct qfv_resource_s *resources;
} qfv_mousepickctx_t;
struct vulkan_ctx_s;
void QFV_MousePick_Init (struct vulkan_ctx_s *ctx);
void QFV_MousePick_Shutdown (struct vulkan_ctx_s *ctx);
void QFV_MousePick_Read (struct vulkan_ctx_s *ctx, uint32_t x, uint32_t y,
mousepickfunc_t callback, void *data);
#endif//__QF_Vulkan_mouse_pick_h

View file

@ -85,6 +85,7 @@ typedef struct lightingframe_s {
VkBuffer render_buffer;
VkBuffer style_buffer;
VkBuffer id_buffer;
VkBuffer entid_buffer;
light_queue_t light_queue[4];
qfv_imageviewset_t views;

View file

@ -433,8 +433,7 @@ typedef struct qfv_renderctx_s {
qfv_job_t *job;
qfv_renderframeset_t frames;
int64_t size_time;
struct imui_window_s *job_timings_window;
struct imui_window_s *job_control_window;
struct qfv_renderdebug_s *debug;
} qfv_renderctx_t;
typedef struct qfv_taskctx_s {
@ -472,6 +471,7 @@ VkSampler QFV_Render_Sampler (struct vulkan_ctx_s *ctx, const char *name);
qfv_step_t *QFV_GetStep (const exprval_t *param, qfv_job_t *job);
qfv_step_t *QFV_FindStep (const char *step, qfv_job_t *job) __attribute__((pure));
struct qfv_resobj_s *QFV_FindResource (const char *name, qfv_renderpass_t *rp) __attribute__((pure));
struct imui_ctx_s;
void QFV_Render_UI (struct vulkan_ctx_s *ctx, struct imui_ctx_s *imui_ctx);