mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Fix a pile of leaks and uninit errors
Still "some" more to go: a pile to do with transforms and temporary entities, and a nasty one with host_cbuf. There's also all the static block-alloc lists :/
This commit is contained in:
parent
a3c1b2e992
commit
cc4167668c
16 changed files with 153 additions and 81 deletions
|
@ -70,7 +70,7 @@ typedef struct lightingframe_s {
|
|||
// illuminate the leafs visible to the player
|
||||
byte pvs[MAP_PVS_BYTES];
|
||||
struct mleaf_s *leaf; // the last leaf used to generate the pvs
|
||||
qfv_lightleafset_t lightvis;
|
||||
qfv_lightvisset_t lightvis;
|
||||
} lightingframe_t;
|
||||
|
||||
typedef struct lightingframeset_s
|
||||
|
|
|
@ -1782,6 +1782,7 @@ struct progs_s {
|
|||
///@{
|
||||
struct hashtab_s *builtin_hash;
|
||||
struct hashtab_s *builtin_num_hash;
|
||||
struct biblock_s *builtin_blocks;
|
||||
unsigned bi_next;
|
||||
unsigned (*bi_map) (progs_t *pr, unsigned binum);
|
||||
///@}
|
||||
|
|
|
@ -172,6 +172,7 @@ Load_Tracklist (void)
|
|||
buffile = calloc (size+10, sizeof (char));
|
||||
Qread (oggfile, buffile, size);
|
||||
|
||||
PL_Free (tracklist);
|
||||
tracklist = PL_GetPropertyList (buffile, 0);
|
||||
if (!tracklist || PL_Type (tracklist) != QFDictionary) {
|
||||
Sys_Printf ("Malformed or empty tracklist file. check mus_ogglist\n");
|
||||
|
|
|
@ -249,6 +249,7 @@ vorbis_stream_close (sfx_t *sfx)
|
|||
if (vf->data)
|
||||
free (vf->data);
|
||||
ov_clear (vf->vf);
|
||||
free (vf->vf);
|
||||
free (vf);
|
||||
SND_SFX_StreamClose (sfx);
|
||||
}
|
||||
|
|
|
@ -317,12 +317,13 @@ CL_ParseBeam (qmsg_t *net_message, model_t *m, double time, TEntContext_t *ctx)
|
|||
tent_obj_t *to;
|
||||
beam_t *b;
|
||||
int ent;
|
||||
vec3_t start, end;
|
||||
vec4f_t start, end;
|
||||
|
||||
ent = MSG_ReadShort (net_message);
|
||||
|
||||
MSG_ReadCoordV (net_message, start);
|
||||
MSG_ReadCoordV (net_message, end);
|
||||
MSG_ReadCoordV (net_message, &start[0]);//FIXME
|
||||
MSG_ReadCoordV (net_message, &end[0]);//FIXME
|
||||
start[3] = end[3] = 1;//FIXME
|
||||
|
||||
to = 0;
|
||||
if (ent) {
|
||||
|
@ -345,10 +346,10 @@ CL_ParseBeam (qmsg_t *net_message, model_t *m, double time, TEntContext_t *ctx)
|
|||
b->model = m;
|
||||
b->endtime = time + 0.2;
|
||||
b->seed = rand ();
|
||||
VectorCopy (end, b->end);
|
||||
b->end = end;
|
||||
if (b->entity != ctx->playerEntity) {
|
||||
// this will be done in CL_UpdateBeams
|
||||
VectorCopy (start, b->start);
|
||||
b->start = start;
|
||||
beam_setup (b, true, time, ctx);
|
||||
}
|
||||
}
|
||||
|
@ -626,7 +627,7 @@ CL_UpdateBeams (double time, TEntContext_t *ctx)
|
|||
// if coming from the player, update the start position
|
||||
if (b->entity == ctx->playerEntity) {
|
||||
beam_clear (b);
|
||||
VectorCopy (ctx->simorg, b->start);
|
||||
b->start = ctx->simorg;
|
||||
beam_setup (b, false, time, ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "QF/cmd.h"
|
||||
#include "QF/crc.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/darray.h"
|
||||
#include "QF/hash.h"
|
||||
#include "QF/progs.h"
|
||||
#include "QF/qdefs.h"
|
||||
|
@ -50,6 +51,8 @@
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
typedef struct biblock_s DARRAY_TYPE (builtin_t *) biblock_t;
|
||||
|
||||
static const char *
|
||||
builtin_get_key (const void *_bi, void *unused)
|
||||
{
|
||||
|
@ -92,6 +95,8 @@ PR_RegisterBuiltins (progs_t *pr, builtin_t *builtins)
|
|||
int count;
|
||||
|
||||
if (!pr->builtin_hash) {
|
||||
pr->builtin_blocks = malloc (sizeof (biblock_t));
|
||||
DARRAY_INIT (pr->builtin_blocks, 16);
|
||||
pr->builtin_hash = Hash_NewTable (1021, builtin_get_key, 0, pr,
|
||||
pr->hashlink_freelist);
|
||||
pr->builtin_num_hash = Hash_NewTable (1021, 0, 0, pr,
|
||||
|
@ -104,6 +109,7 @@ PR_RegisterBuiltins (progs_t *pr, builtin_t *builtins)
|
|||
for (bi = builtins, count = 1; bi->name; bi++)
|
||||
count++;
|
||||
bi = malloc (count * sizeof (builtin_t));
|
||||
DARRAY_APPEND (pr->builtin_blocks, bi);
|
||||
memcpy (bi, builtins, count * sizeof (builtin_t));
|
||||
builtins = bi;
|
||||
|
||||
|
|
|
@ -387,4 +387,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
|||
} else {
|
||||
mod->aliashdr = header;
|
||||
}
|
||||
DARRAY_CLEAR (&alias_ctx.poseverts);
|
||||
DARRAY_CLEAR (&alias_ctx.stverts);
|
||||
DARRAY_CLEAR (&alias_ctx.triangles);
|
||||
}
|
||||
|
|
|
@ -326,6 +326,7 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
|
|||
barriers->size, barriers->a);
|
||||
QFV_PacketSubmit (packet);
|
||||
QFV_DestroyStagingBuffer (stage);
|
||||
free (barriers);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -223,6 +223,7 @@ PL_Free (plitem_t *item)
|
|||
dict = item->data;
|
||||
Hash_DelTable (dict->tab);
|
||||
DARRAY_CLEAR (&dict->keys);
|
||||
free (item->data);
|
||||
break;
|
||||
|
||||
case QFArray:
|
||||
|
|
|
@ -252,12 +252,11 @@ static void
|
|||
delete_searchpath (searchpath_t *searchpath)
|
||||
{
|
||||
if (searchpath->pack) {
|
||||
Qclose (searchpath->pack->handle);
|
||||
free (searchpath->pack->files);
|
||||
free (searchpath->pack);
|
||||
pack_del (searchpath->pack);
|
||||
}
|
||||
if (searchpath->filename)
|
||||
if (searchpath->filename) {
|
||||
free (searchpath->filename);
|
||||
}
|
||||
FREE (searchpaths, searchpath);
|
||||
}
|
||||
|
||||
|
@ -274,8 +273,9 @@ delete_vpath (vpath_t *vpath)
|
|||
{
|
||||
searchpath_t *next;
|
||||
|
||||
if (vpath->name)
|
||||
if (vpath->name) {
|
||||
free (vpath->name);
|
||||
}
|
||||
while (vpath->user) {
|
||||
next = vpath->user->next;
|
||||
delete_searchpath (vpath->user);
|
||||
|
@ -859,6 +859,7 @@ qfs_findfile_search (const vpath_t *vpath, const searchpath_t *sp,
|
|||
found.ff.realname = strdup (*fn);
|
||||
found.path = strdup (path->str);
|
||||
found.fname_index = fn - fnames;
|
||||
dstring_delete (path);
|
||||
return &found;
|
||||
}
|
||||
}
|
||||
|
@ -1416,6 +1417,16 @@ qfs_path_cvar (cvar_t *var)
|
|||
free (cpath);
|
||||
}
|
||||
|
||||
static void
|
||||
qfs_shutdown (void *data)
|
||||
{
|
||||
while (qfs_vpaths) {
|
||||
vpath_t *next = qfs_vpaths->next;
|
||||
delete_vpath (qfs_vpaths);
|
||||
qfs_vpaths = next;
|
||||
}
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
QFS_Init (const char *game)
|
||||
{
|
||||
|
@ -1465,6 +1476,7 @@ QFS_Init (const char *game)
|
|||
} else {
|
||||
QFS_Gamedir ("");
|
||||
}
|
||||
Sys_RegisterShutdown (qfs_shutdown, 0);
|
||||
}
|
||||
|
||||
VISIBLE const char *
|
||||
|
|
|
@ -285,11 +285,14 @@ void
|
|||
QFV_DestroyInstance (qfv_instance_t *instance)
|
||||
{
|
||||
qfv_instfuncs_t *ifunc = instance->funcs;
|
||||
|
||||
if (instance->debug_handle) {
|
||||
ifunc->vkDestroyDebugUtilsMessengerEXT (instance->instance,
|
||||
instance->debug_handle, 0);
|
||||
}
|
||||
instance->funcs->vkDestroyInstance (instance->instance, 0);
|
||||
del_strset (instance->enabled_extensions);
|
||||
free (instance->devices);
|
||||
free (instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,6 +252,13 @@ parse_reference (const plitem_t *item, const char *type, plitem_t *messages,
|
|||
return refItem;
|
||||
}
|
||||
|
||||
static void *
|
||||
vkparse_alloc (void *context, size_t size)
|
||||
{
|
||||
parsectx_t *pctx = context;
|
||||
return cmemalloc (pctx->ectx->memsuper, size);
|
||||
}
|
||||
|
||||
static int
|
||||
parse_single (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages, void *context)
|
||||
|
@ -269,9 +276,9 @@ parse_single (const plfield_t *field, const plitem_t *item,
|
|||
}
|
||||
|
||||
plfield_t f = { 0, 0, single->type, single->parser, 0 };
|
||||
void *value = calloc (1, single->stride);
|
||||
void *value = vkparse_alloc (context, single->stride);
|
||||
memset (value, 0, single->stride);
|
||||
if (!single->parser (&f, item, value, messages, context)) {
|
||||
free (value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -279,12 +286,6 @@ parse_single (const plfield_t *field, const plitem_t *item,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void *
|
||||
array_alloc (void *context, size_t size)
|
||||
{
|
||||
return malloc (size);
|
||||
}
|
||||
|
||||
static int
|
||||
parse_array (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages, void *context)
|
||||
|
@ -296,7 +297,7 @@ parse_array (const plfield_t *field, const plitem_t *item,
|
|||
plelement_t element = {
|
||||
array->type,
|
||||
array->stride,
|
||||
array_alloc,
|
||||
vkparse_alloc,
|
||||
array->parser,
|
||||
0,
|
||||
};
|
||||
|
@ -313,12 +314,11 @@ parse_array (const plfield_t *field, const plitem_t *item,
|
|||
if (!PL_ParseArray (&f, item, &arr, messages, context)) {
|
||||
return 0;
|
||||
}
|
||||
*value = malloc (array->stride * arr->size);
|
||||
*value = vkparse_alloc (context, array->stride * arr->size);
|
||||
memcpy (*value, arr->a, array->stride * arr->size);
|
||||
if ((void *) size >= data) {
|
||||
*size = arr->size;
|
||||
}
|
||||
free (arr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ parse_data (const plfield_t *field, const plitem_t *item,
|
|||
Sys_Printf (" %zd %zd\n", datad->value_offset, datad->size_offset);
|
||||
Sys_Printf (" %zd %p\n", binsize, bindata);
|
||||
|
||||
*value = malloc (binsize);
|
||||
*value = vkparse_alloc (context, binsize);
|
||||
memcpy (*value, bindata, binsize);
|
||||
if ((void *) size > data) {
|
||||
*size = binsize;
|
||||
|
@ -362,7 +362,9 @@ parse_string (const plfield_t *field, const plitem_t *item,
|
|||
//Sys_Printf (" %zd\n", string->value_offset);
|
||||
//Sys_Printf (" %s\n", str);
|
||||
|
||||
*value = strdup (str);
|
||||
size_t len = strlen (str) + 1;
|
||||
*value = vkparse_alloc (context, len);
|
||||
memcpy (*value, str, len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -877,7 +879,7 @@ typedef struct qfv_renderpass_s {
|
|||
static plelement_t parse_qfv_renderpass_attachments_data = {
|
||||
QFDictionary,
|
||||
sizeof (VkAttachmentDescription),
|
||||
array_alloc,
|
||||
vkparse_alloc,
|
||||
parse_VkAttachmentDescription,
|
||||
0,
|
||||
};
|
||||
|
@ -885,7 +887,7 @@ static plelement_t parse_qfv_renderpass_attachments_data = {
|
|||
static plelement_t parse_qfv_renderpass_subpasses_data = {
|
||||
QFDictionary,
|
||||
sizeof (VkSubpassDescription),
|
||||
array_alloc,
|
||||
vkparse_alloc,
|
||||
parse_VkSubpassDescription,
|
||||
0,
|
||||
};
|
||||
|
@ -893,7 +895,7 @@ static plelement_t parse_qfv_renderpass_subpasses_data = {
|
|||
static plelement_t parse_qfv_renderpass_dependencies_data = {
|
||||
QFDictionary,
|
||||
sizeof (VkSubpassDependency),
|
||||
array_alloc,
|
||||
vkparse_alloc,
|
||||
parse_VkSubpassDependency,
|
||||
0,
|
||||
};
|
||||
|
@ -953,7 +955,7 @@ QFV_GetEnum (const char *name)
|
|||
}
|
||||
|
||||
static int
|
||||
parse_object (vulkan_ctx_t *ctx, plitem_t *plist,
|
||||
parse_object (vulkan_ctx_t *ctx, memsuper_t *memsuper, plitem_t *plist,
|
||||
plparser_t parser, void *object, plitem_t *properties)
|
||||
{
|
||||
plitem_t *messages = PL_NewArray ();
|
||||
|
@ -970,9 +972,9 @@ parse_object (vulkan_ctx_t *ctx, plitem_t *plist,
|
|||
exprtab_t vars_tab = { var_syms, 0 };
|
||||
|
||||
exprctx.external_variables = &vars_tab;
|
||||
exprctx.memsuper = new_memsuper ();
|
||||
exprctx.messages = messages;
|
||||
exprctx.hashlinks = &ctx->hashlinks;
|
||||
exprctx.memsuper = memsuper;
|
||||
|
||||
cexpr_init_symtab (&vars_tab, &exprctx);
|
||||
|
||||
|
@ -983,8 +985,8 @@ parse_object (vulkan_ctx_t *ctx, plitem_t *plist,
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
Hash_DelTable (vars_tab.tab);
|
||||
PL_Free (messages);
|
||||
delete_memsuper (exprctx.memsuper);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -999,12 +1001,14 @@ parse_qfv_renderpass (const plfield_t *field, const plitem_t *item, void *data,
|
|||
VkRenderPass
|
||||
QFV_ParseRenderPass (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
||||
{
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
qfv_device_t *device = ctx->device;
|
||||
|
||||
qfv_renderpass_t renderpass_data = {};
|
||||
|
||||
if (!parse_object (ctx, plist, parse_qfv_renderpass, &renderpass_data,
|
||||
properties)) {
|
||||
if (!parse_object (ctx, memsuper, plist, parse_qfv_renderpass,
|
||||
&renderpass_data, properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1014,29 +1018,22 @@ QFV_ParseRenderPass (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
|||
renderpass_data.subpasses,
|
||||
renderpass_data.dependencies);
|
||||
|
||||
free (renderpass_data.attachments);
|
||||
for (size_t i = 0; i < renderpass_data.subpasses->size; i++) {
|
||||
free ((void *) renderpass_data.subpasses->a[i].pInputAttachments);
|
||||
free ((void *) renderpass_data.subpasses->a[i].pColorAttachments);
|
||||
free ((void *) renderpass_data.subpasses->a[i].pResolveAttachments);
|
||||
free ((void *) renderpass_data.subpasses->a[i].pDepthStencilAttachment);
|
||||
free ((void *) renderpass_data.subpasses->a[i].pPreserveAttachments);
|
||||
}
|
||||
free (renderpass_data.subpasses);
|
||||
free (renderpass_data.dependencies);
|
||||
delete_memsuper (memsuper);
|
||||
return renderpass;
|
||||
}
|
||||
|
||||
VkPipeline
|
||||
QFV_ParsePipeline (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
||||
{
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
qfv_device_t *device = ctx->device;
|
||||
|
||||
__auto_type cInfo = QFV_AllocGraphicsPipelineCreateInfoSet (1, alloca);
|
||||
memset (&cInfo->a[0], 0, sizeof (cInfo->a[0]));
|
||||
|
||||
if (!parse_object (ctx, plist, parse_VkGraphicsPipelineCreateInfo,
|
||||
if (!parse_object (ctx, memsuper, plist, parse_VkGraphicsPipelineCreateInfo,
|
||||
&cInfo->a[0], properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1044,6 +1041,7 @@ QFV_ParsePipeline (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
|||
__auto_type plSet = QFV_CreateGraphicsPipelines (device, 0, cInfo);
|
||||
VkPipeline pipeline = plSet->a[0];
|
||||
free (plSet);
|
||||
delete_memsuper (memsuper);
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
|
@ -1053,17 +1051,20 @@ QFV_ParseDescriptorPool (vulkan_ctx_t *ctx, plitem_t *plist,
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
VkDescriptorPoolCreateInfo cInfo = {};
|
||||
|
||||
if (!parse_object (ctx, plist, parse_VkDescriptorPoolCreateInfo, &cInfo,
|
||||
properties)) {
|
||||
if (!parse_object (ctx, memsuper, plist, parse_VkDescriptorPoolCreateInfo,
|
||||
&cInfo, properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkDescriptorPool pool;
|
||||
dfunc->vkCreateDescriptorPool (device->dev, &cInfo, 0, &pool);
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
@ -1073,17 +1074,21 @@ QFV_ParseDescriptorSetLayout (vulkan_ctx_t *ctx, plitem_t *plist,
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo cInfo = {};
|
||||
|
||||
if (!parse_object (ctx, plist, parse_VkDescriptorSetLayoutCreateInfo,
|
||||
if (!parse_object (ctx, memsuper, plist,
|
||||
parse_VkDescriptorSetLayoutCreateInfo,
|
||||
&cInfo, properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkDescriptorSetLayout setLayout;
|
||||
dfunc->vkCreateDescriptorSetLayout (device->dev, &cInfo, 0, &setLayout);
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return setLayout;
|
||||
}
|
||||
|
||||
|
@ -1093,17 +1098,20 @@ QFV_ParsePipelineLayout (vulkan_ctx_t *ctx, plitem_t *plist,
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
VkPipelineLayoutCreateInfo cInfo = {};
|
||||
|
||||
if (!parse_object (ctx, plist, parse_VkPipelineLayoutCreateInfo,
|
||||
if (!parse_object (ctx, memsuper, plist, parse_VkPipelineLayoutCreateInfo,
|
||||
&cInfo, properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkPipelineLayout layout;
|
||||
dfunc->vkCreatePipelineLayout (device->dev, &cInfo, 0, &layout);
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return layout;
|
||||
}
|
||||
|
||||
|
@ -1112,17 +1120,20 @@ QFV_ParseSampler (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
VkSamplerCreateInfo cInfo = {};
|
||||
|
||||
if (!parse_object (ctx, plist, parse_VkSamplerCreateInfo, &cInfo,
|
||||
if (!parse_object (ctx, memsuper, plist, parse_VkSamplerCreateInfo, &cInfo,
|
||||
properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkSampler sampler;
|
||||
dfunc->vkCreateSampler (device->dev, &cInfo, 0, &sampler);
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return sampler;
|
||||
}
|
||||
|
||||
|
@ -1131,17 +1142,20 @@ QFV_ParseImage (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
VkImageCreateInfo cInfo = {};
|
||||
|
||||
if (!parse_object (ctx, plist, parse_VkImageCreateInfo, &cInfo,
|
||||
if (!parse_object (ctx, memsuper, plist, parse_VkImageCreateInfo, &cInfo,
|
||||
properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkImage image;
|
||||
dfunc->vkCreateImage (device->dev, &cInfo, 0, &image);
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
@ -1150,17 +1164,20 @@ QFV_ParseImageView (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
VkImageViewCreateInfo cInfo = {};
|
||||
|
||||
if (!parse_object (ctx, plist, parse_VkImageViewCreateInfo, &cInfo,
|
||||
properties)) {
|
||||
if (!parse_object (ctx, memsuper, plist, parse_VkImageViewCreateInfo,
|
||||
&cInfo, properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkImageView imageView;
|
||||
dfunc->vkCreateImageView (device->dev, &cInfo, 0, &imageView);
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return imageView;
|
||||
}
|
||||
|
||||
|
@ -1177,14 +1194,14 @@ typedef struct {
|
|||
static plelement_t qfv_imagecreate_dict = {
|
||||
QFDictionary,
|
||||
sizeof (VkImageCreateInfo),
|
||||
array_alloc,
|
||||
vkparse_alloc,
|
||||
parse_VkImageCreateInfo,
|
||||
};
|
||||
|
||||
static plelement_t qfv_imageviewcreate_dict = {
|
||||
QFDictionary,
|
||||
sizeof (VkImageViewCreateInfo),
|
||||
array_alloc,
|
||||
vkparse_alloc,
|
||||
parse_VkImageViewCreateInfo,
|
||||
};
|
||||
|
||||
|
@ -1202,11 +1219,6 @@ parse_imagecreate_dict (const plfield_t *field, const plitem_t *item,
|
|||
imagecreate_t *imagecreate = data;
|
||||
imagecreate->count = arr->size;
|
||||
imagecreate->info = (VkImageCreateInfo *) arr->a;
|
||||
} else {
|
||||
//FIXME leaky boat when succeeds
|
||||
if (arr) {
|
||||
free (arr);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1239,18 +1251,21 @@ QFV_ParseImageSet (vulkan_ctx_t *ctx, plitem_t *item, plitem_t *properties)
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
imagecreate_t create = {};
|
||||
|
||||
pltype_t type = PL_Type (item);
|
||||
|
||||
if (type == QFDictionary) {
|
||||
if (!parse_object (ctx, item, parse_imagecreate_dict, &create,
|
||||
properties)) {
|
||||
if (!parse_object (ctx, memsuper, item, parse_imagecreate_dict,
|
||||
&create, properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
Sys_Printf ("Neither array nor dictionary: %d\n", PL_Line (item));
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1265,6 +1280,7 @@ QFV_ParseImageSet (vulkan_ctx_t *ctx, plitem_t *item, plitem_t *properties)
|
|||
QFV_AddHandle (ctx->images, name, (uint64_t) set->a[i]);
|
||||
}
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return set;
|
||||
}
|
||||
|
||||
|
@ -1274,18 +1290,21 @@ QFV_ParseImageViewSet (vulkan_ctx_t *ctx, plitem_t *item,
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
imageviewcreate_t create = {};
|
||||
|
||||
pltype_t type = PL_Type (item);
|
||||
|
||||
if (type == QFDictionary) {
|
||||
if (!parse_object (ctx, item, parse_imageviewcreate_dict, &create,
|
||||
properties)) {
|
||||
if (!parse_object (ctx, memsuper, item, parse_imageviewcreate_dict,
|
||||
&create, properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
Sys_Printf ("Neither array nor dictionary: %d\n", PL_Line (item));
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1298,6 +1317,7 @@ QFV_ParseImageViewSet (vulkan_ctx_t *ctx, plitem_t *item,
|
|||
QFV_AddHandle (ctx->imageViews, name, (uint64_t) set->a[i]);
|
||||
}
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return set;
|
||||
}
|
||||
|
||||
|
@ -1306,11 +1326,13 @@ QFV_ParseFramebuffer (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
|||
{
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
|
||||
VkFramebufferCreateInfo cInfo = {};
|
||||
|
||||
if (!parse_object (ctx, plist, parse_VkFramebufferCreateInfo, &cInfo,
|
||||
properties)) {
|
||||
if (!parse_object (ctx, memsuper, plist, parse_VkFramebufferCreateInfo,
|
||||
&cInfo, properties)) {
|
||||
delete_memsuper (memsuper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1318,6 +1340,7 @@ QFV_ParseFramebuffer (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
|||
dfunc->vkCreateFramebuffer (device->dev, &cInfo, 0, &framebuffer);
|
||||
printf ("framebuffer, renderPass: %p, %p\n", framebuffer, cInfo.renderPass);
|
||||
|
||||
delete_memsuper (memsuper);
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
|
@ -1325,19 +1348,16 @@ static int
|
|||
parse_clearvalueset (const plfield_t *field, const plitem_t *item, void *data,
|
||||
plitem_t *messages, void *context)
|
||||
{
|
||||
parsectx_t *parsectx = context;
|
||||
vulkan_ctx_t *ctx = parsectx->vctx;
|
||||
|
||||
plelement_t element = {
|
||||
QFDictionary,
|
||||
sizeof (VkClearValue),
|
||||
array_alloc,
|
||||
vkparse_alloc,
|
||||
parse_VkClearValue,
|
||||
0,
|
||||
};
|
||||
plfield_t f = { 0, 0, 0, 0, &element };
|
||||
|
||||
if (!PL_ParseArray (&f, item, &ctx->clearValues, messages, context)) {
|
||||
if (!PL_ParseArray (&f, item, data, messages, context)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
@ -1346,9 +1366,19 @@ parse_clearvalueset (const plfield_t *field, const plitem_t *item, void *data,
|
|||
int
|
||||
QFV_ParseClearValues (vulkan_ctx_t *ctx, plitem_t *plist, plitem_t *properties)
|
||||
{
|
||||
if (!parse_object (ctx, plist, parse_clearvalueset, &ctx->clearValues,
|
||||
properties)) {
|
||||
return 0;
|
||||
int ret = 0;
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
clearvalueset_t *clearValues = 0;
|
||||
|
||||
ctx->clearValues = 0;
|
||||
if (parse_object (ctx, memsuper, plist, parse_clearvalueset, &clearValues,
|
||||
properties)) {
|
||||
ret = 1;
|
||||
ctx->clearValues = DARRAY_ALLOCFIXED (clearvalueset_t,
|
||||
clearValues->size, malloc);
|
||||
memcpy (ctx->clearValues->a, clearValues->a,
|
||||
clearValues->size * sizeof (clearValues->a[0]));
|
||||
}
|
||||
return 1;
|
||||
delete_memsuper (memsuper);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ find_visible_lights (vulkan_ctx_t *ctx)
|
|||
}
|
||||
|
||||
if (leaf != lframe->leaf) {
|
||||
double start = Sys_DoubleTime ();
|
||||
//double start = Sys_DoubleTime ();
|
||||
byte pvs[MAP_PVS_BYTES];
|
||||
|
||||
Mod_LeafPVS_set (leaf, model, 0, pvs);
|
||||
|
@ -89,8 +89,8 @@ find_visible_lights (vulkan_ctx_t *ctx)
|
|||
}
|
||||
lframe->leaf = leaf;
|
||||
|
||||
double end = Sys_DoubleTime ();
|
||||
Sys_Printf ("find_visible_lights: %.5gus\n", (end - start) * 1e6);
|
||||
//double end = Sys_DoubleTime ();
|
||||
//Sys_Printf ("find_visible_lights: %.5gus\n", (end - start) * 1e6);
|
||||
|
||||
int visible = 0;
|
||||
memset (lframe->lightvis.a, 0, lframe->lightvis.size * sizeof (byte));
|
||||
|
@ -101,8 +101,8 @@ find_visible_lights (vulkan_ctx_t *ctx)
|
|||
visible++;
|
||||
}
|
||||
}
|
||||
Sys_Printf ("find_visible_lights: %d / %zd visible\n", visible,
|
||||
lframe->lightvis.size);
|
||||
//Sys_Printf ("find_visible_lights: %d / %zd visible\n", visible,
|
||||
// lframe->lightvis.size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,6 +313,7 @@ Vulkan_Lighting_Init (vulkan_ctx_t *ctx)
|
|||
__auto_type lframe = &lctx->frames.a[i];
|
||||
|
||||
DARRAY_INIT (&lframe->lightvis, 16);
|
||||
lframe->leaf = 0;
|
||||
|
||||
QFV_AllocateCommandBuffers (device, ctx->cmdpool, 1, cmdSet);
|
||||
lframe->cmd = cmdSet->a[0];
|
||||
|
|
|
@ -186,6 +186,8 @@ clear_table (hashtab_t **table)
|
|||
void
|
||||
Vulkan_Shutdown_Common (vulkan_ctx_t *ctx)
|
||||
{
|
||||
PL_Free (ctx->pipelineDef);
|
||||
PL_Free (ctx->renderpassDef);
|
||||
if (ctx->pipeline) {
|
||||
QFV_DestroyPipeline (ctx->device, ctx->pipeline);
|
||||
}
|
||||
|
@ -546,6 +548,10 @@ Vulkan_DestroyFrames (vulkan_ctx_t *ctx)
|
|||
df->vkDestroySemaphore (dev, frame->imageAvailableSemaphore, 0);
|
||||
df->vkDestroySemaphore (dev, frame->renderDoneSemaphore, 0);
|
||||
df->vkDestroyFramebuffer (dev, frame->framebuffer, 0);
|
||||
for (int j = 0; j < frame->cmdSetCount; j++) {
|
||||
DARRAY_CLEAR (&frame->cmdSets[j]);
|
||||
}
|
||||
free (frame->cmdSets);
|
||||
}
|
||||
|
||||
DARRAY_CLEAR (&ctx->frames);
|
||||
|
|
|
@ -311,9 +311,9 @@ void
|
|||
X11_CreateNullCursor (void)
|
||||
{
|
||||
Pixmap cursormask;
|
||||
XGCValues xgc;
|
||||
XGCValues xgc = { };
|
||||
GC gc;
|
||||
XColor dummycolour;
|
||||
XColor dummycolour = { };
|
||||
|
||||
if (nullcursor != None)
|
||||
return;
|
||||
|
|
|
@ -842,6 +842,11 @@ Key_IMT_Drop_All_f (void)
|
|||
while (key_targets[kd].imts) {
|
||||
imt = key_targets[kd].imts;
|
||||
key_targets[kd].imts = imt->next;
|
||||
for (int i = 0; i < QFK_LAST; i++) {
|
||||
if (imt->bindings[i].str) {
|
||||
free (imt->bindings[i].str);
|
||||
}
|
||||
}
|
||||
free ((char *) imt->name);
|
||||
free (imt);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue