Merge pull request #557 from w23/E292

Things done in stream E292
This commit is contained in:
Ivan Avdeev 2023-09-08 12:45:14 -07:00 committed by GitHub
commit d9207963f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 3 deletions

View File

@ -16,6 +16,7 @@
#include "r_speeds.h" #include "r_speeds.h"
#include "vk_staging.h" #include "vk_staging.h"
#include "vk_logs.h" #include "vk_logs.h"
#include "profiler.h"
#include "ref_params.h" #include "ref_params.h"
#include "eiface.h" #include "eiface.h"
@ -416,7 +417,16 @@ static qboolean isSurfaceAnimated( const msurface_t *s, const struct texture_s *
if( base->name[0] == '-' ) if( base->name[0] == '-' )
return false; 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 { typedef enum {
@ -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) { 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); ASSERT(bmodel->water.surfaces_count > 0);
fillWaterSurfaces(NULL, bmodel, bmodel->water.render_model.geometries); fillWaterSurfaces(NULL, bmodel, bmodel->water.render_model.geometries);
@ -535,6 +546,8 @@ static void brushDrawWater(vk_brush_model_t *bmodel, const cl_entity_t *ent, int
.transform = (const matrix4x4*)transform, .transform = (const matrix4x4*)transform,
.prev_transform = &bmodel->prev_transform, .prev_transform = &bmodel->prev_transform,
}); });
APROF_SCOPE_END(brush_draw_water);
} }
// FIXME use this // FIXME use this
@ -694,6 +707,7 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, float blend, co
geom->texture = tglob.whiteTexture; geom->texture = tglob.whiteTexture;
} }
} else { } else {
APROF_SCOPE_DECLARE_BEGIN(brush_update_textures, "brush: update animated textures");
// Update animated textures // Update animated textures
int updated_textures_count = 0; int updated_textures_count = 0;
for (int i = 0; i < bmodel->animated_indexes_count; ++i) { for (int i = 0; i < bmodel->animated_indexes_count; ++i) {
@ -729,6 +743,7 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, float blend, co
if (updated_textures_count > 0) { if (updated_textures_count > 0) {
R_RenderModelUpdateMaterials(&bmodel->render_model, g_brush.updated_textures, updated_textures_count); 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){ R_RenderModelDraw(&bmodel->render_model, (r_model_draw_t){

View File

@ -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)); 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; 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 *vertices = g_lights_.polygon_vertices + g_lights_.num_polygon_vertices;
vec3_t normal; vec3_t normal;
@ -1143,6 +1144,7 @@ int RT_LightAddPolygon(const rt_light_add_polygon_t *addpoly) {
} }
g_lights_.num_polygon_vertices += addpoly->num_vertices; g_lights_.num_polygon_vertices += addpoly->num_vertices;
APROF_SCOPE_END(add_polygon);
return g_lights_.num_polygons++; return g_lights_.num_polygons++;
} }
} }

View File

@ -10,6 +10,7 @@
#include "vk_math.h" #include "vk_math.h"
#include "vk_combuf.h" #include "vk_combuf.h"
#include "vk_logs.h" #include "vk_logs.h"
#include "profiler.h"
#include "eiface.h" #include "eiface.h"
#include "xash3d_mathlib.h" #include "xash3d_mathlib.h"
@ -262,6 +263,8 @@ qboolean RT_ModelUpdateMaterials(struct rt_model_s *model, const struct vk_rende
if (!geom_indices_count) if (!geom_indices_count)
return true; return true;
APROF_SCOPE_DECLARE_BEGIN(update_materials, __FUNCTION__);
int begin = 0; int begin = 0;
for (int i = 1; i < geom_indices_count; ++i) { for (int i = 1; i < geom_indices_count; ++i) {
const int geom_index = geom_indices[i]; const int geom_index = geom_indices[i];
@ -272,8 +275,10 @@ qboolean RT_ModelUpdateMaterials(struct rt_model_s *model, const struct vk_rende
const int offset = geom_indices[begin]; const int offset = geom_indices[begin];
const int count = i - begin; const int count = i - begin;
ASSERT(offset + count <= geometries_count); 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; return false;
}
begin = i; begin = i;
} }
@ -283,10 +288,14 @@ qboolean RT_ModelUpdateMaterials(struct rt_model_s *model, const struct vk_rende
const int offset = geom_indices[begin]; const int offset = geom_indices[begin];
const int count = geom_indices_count - begin; const int count = geom_indices_count - begin;
ASSERT(offset + count <= geometries_count); 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; return false;
}
} }
APROF_SCOPE_END(update_materials);
return true; return true;
} }