Skip to content

Commit

Permalink
fix loading multiple maps; also fix #68
Browse files Browse the repository at this point in the history
  • Loading branch information
w23 committed Nov 23, 2020
1 parent 56b6f10 commit b677711
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
25 changes: 16 additions & 9 deletions src/OpenSource.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,27 +312,34 @@ static void opensrcResizeVk() {
static void opensrcPaint(ATimeUs timestamp, float dt) {
(void)(timestamp); (void)(dt);

for (struct Map *map = g.maps_begin; map; map = map->next) {
if (map->flags & MapFlags_Broken)
continue;

if (map->flags & MapFlags_Loaded)
continue;

if (BSPLoadResult_Success != loadMap(map, g.collection_chain)) {
map->flags |= MapFlags_Broken;
continue;
}

break;
}

float move = dt * (g.run?3000.f:300.f);
cameraMove(&g.camera, aVec3f(g.right * move, 0.f, -g.forward * move));
cameraRecompute(&g.camera);

renderBegin();

int triangles = 0;
int can_load_map = 1;
for (struct Map *map = g.maps_begin; map; map = map->next) {
if (map->flags & MapFlags_Broken)
continue;

if (!(map->flags & MapFlags_Loaded)) {
if (can_load_map) {
if (BSPLoadResult_Success != loadMap(map, g.collection_chain))
map->flags |= MapFlags_Broken;
}

can_load_map = 0;
if (!(map->flags & MapFlags_Loaded))
continue;
}

const RDrawParams params = {
.camera = &g.camera,
Expand Down
11 changes: 8 additions & 3 deletions src/render_vk.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/* return ret; */
/* } */

#define MAX_DESC_SETS 1024
#define MAX_DESC_SETS 65536

static struct {
VkFence fence;
Expand Down Expand Up @@ -686,10 +686,15 @@ void renderModelDraw(const RDrawParams *params, const struct BSPModel *model) {
for (int i = 0; i < model->detailed.draws_count; ++i) {
const struct BSPDraw* draw = model->detailed.draws + i;

// FIXME HOW: allocate next descriptor pool
if (g.next_free_set >= MAX_DESC_SETS)
//if (draw->material->shader != MShader_LightmappedGeneric)
if (!draw->material->base_texture.texture)
break;

if (g.next_free_set >= MAX_DESC_SETS) {
aAppDebugPrintf("FIXME ran out of descriptor sets");
break;
}

{
VkDescriptorSet set = g.desc_sets[g.next_free_set];
g.next_free_set++;
Expand Down

0 comments on commit b677711

Please sign in to comment.