Skip to content

Commit

Permalink
Merge pull request #557 from w23/E292
Browse files Browse the repository at this point in the history
Things done in stream E292
  • Loading branch information
w23 authored Sep 8, 2023
2 parents 49bfd28 + 26a4fff commit d920796
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
17 changes: 16 additions & 1 deletion ref/vk/vk_brush.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "r_speeds.h"
#include "vk_staging.h"
#include "vk_logs.h"
#include "profiler.h"

#include "ref_params.h"
#include "eiface.h"
Expand Down Expand Up @@ -416,7 +417,16 @@ static qboolean isSurfaceAnimated( const msurface_t *s, const struct texture_s *
if( base->name[0] == '-' )
return false;

return true;
// It is not an animation if all textures are the same
const texture_t *prev = base;
base = base->anim_next;
while (base && base != prev) {
if (prev->gl_texturenum != base->gl_texturenum)
return true;
base = base->anim_next;
}

return false;
}

typedef enum {
Expand Down Expand Up @@ -522,6 +532,7 @@ static qboolean brushCreateWaterModel(const model_t *mod, vk_brush_model_t *bmod
}

static void brushDrawWater(vk_brush_model_t *bmodel, const cl_entity_t *ent, int render_type, const vec4_t color, const matrix4x4 transform) {
APROF_SCOPE_DECLARE_BEGIN(brush_draw_water, __FUNCTION__);
ASSERT(bmodel->water.surfaces_count > 0);

fillWaterSurfaces(NULL, bmodel, bmodel->water.render_model.geometries);
Expand All @@ -535,6 +546,8 @@ static void brushDrawWater(vk_brush_model_t *bmodel, const cl_entity_t *ent, int
.transform = (const matrix4x4*)transform,
.prev_transform = &bmodel->prev_transform,
});

APROF_SCOPE_END(brush_draw_water);
}

// FIXME use this
Expand Down Expand Up @@ -694,6 +707,7 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, float blend, co
geom->texture = tglob.whiteTexture;
}
} else {
APROF_SCOPE_DECLARE_BEGIN(brush_update_textures, "brush: update animated textures");
// Update animated textures
int updated_textures_count = 0;
for (int i = 0; i < bmodel->animated_indexes_count; ++i) {
Expand Down Expand Up @@ -729,6 +743,7 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, float blend, co
if (updated_textures_count > 0) {
R_RenderModelUpdateMaterials(&bmodel->render_model, g_brush.updated_textures, updated_textures_count);
}
APROF_SCOPE_END(brush_update_textures);
}

R_RenderModelDraw(&bmodel->render_model, (r_model_draw_t){
Expand Down
2 changes: 2 additions & 0 deletions ref/vk/vk_light.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ int RT_LightAddPolygon(const rt_light_add_polygon_t *addpoly) {
ASSERT(g_lights_.num_polygon_vertices + addpoly->num_vertices <= COUNTOF(g_lights_.polygon_vertices));

{
APROF_SCOPE_DECLARE_BEGIN(add_polygon, __FUNCTION__);
rt_light_polygon_t *const poly = g_lights_.polygons + g_lights_.num_polygons;
vec3_t *vertices = g_lights_.polygon_vertices + g_lights_.num_polygon_vertices;
vec3_t normal;
Expand Down Expand Up @@ -1143,6 +1144,7 @@ int RT_LightAddPolygon(const rt_light_add_polygon_t *addpoly) {
}

g_lights_.num_polygon_vertices += addpoly->num_vertices;
APROF_SCOPE_END(add_polygon);
return g_lights_.num_polygons++;
}
}
Expand Down
13 changes: 11 additions & 2 deletions ref/vk/vk_ray_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "vk_math.h"
#include "vk_combuf.h"
#include "vk_logs.h"
#include "profiler.h"

#include "eiface.h"
#include "xash3d_mathlib.h"
Expand Down Expand Up @@ -262,6 +263,8 @@ qboolean RT_ModelUpdateMaterials(struct rt_model_s *model, const struct vk_rende
if (!geom_indices_count)
return true;

APROF_SCOPE_DECLARE_BEGIN(update_materials, __FUNCTION__);

int begin = 0;
for (int i = 1; i < geom_indices_count; ++i) {
const int geom_index = geom_indices[i];
Expand All @@ -272,8 +275,10 @@ qboolean RT_ModelUpdateMaterials(struct rt_model_s *model, const struct vk_rende
const int offset = geom_indices[begin];
const int count = i - begin;
ASSERT(offset + count <= geometries_count);
if (!RT_KusochkiUpload(model->kusochki.offset + offset, geometries + offset, count, -1, NULL))
if (!RT_KusochkiUpload(model->kusochki.offset + offset, geometries + offset, count, -1, NULL)) {
APROF_SCOPE_END(update_materials);
return false;
}

begin = i;
}
Expand All @@ -283,10 +288,14 @@ qboolean RT_ModelUpdateMaterials(struct rt_model_s *model, const struct vk_rende
const int offset = geom_indices[begin];
const int count = geom_indices_count - begin;
ASSERT(offset + count <= geometries_count);
if (!RT_KusochkiUpload(model->kusochki.offset + offset, geometries + offset, count, -1, NULL))
if (!RT_KusochkiUpload(model->kusochki.offset + offset, geometries + offset, count, -1, NULL)) {

APROF_SCOPE_END(update_materials);
return false;
}
}

APROF_SCOPE_END(update_materials);
return true;
}

Expand Down

0 comments on commit d920796

Please sign in to comment.