Merge pull request #642 from w23/E325

Things done during stream E325

- [x] fix #638
- [x] fix #640 
- [x] fix #641
This commit is contained in:
Ivan Avdeev 2023-11-06 10:32:21 -08:00 committed by GitHub
commit a18ed8ddc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 77 additions and 29 deletions

View File

@ -1,3 +1,9 @@
# 2023-11-06 E325
- [x] fix material asserts and inherit
- [x] fixup -vkverboselogs
- [x] changing textures on buttons, etc
- [x] fix unpatched chrome surfaces brightness glitches
# 2023-11-03 E324
- [x] add cvar for displaying only specified channel
- [x] r_lightmap

View File

@ -149,6 +149,7 @@ void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specula
RayPayloadPrimary payload;
payload.base_color_a = vec4(0.);
payload.emissive = vec4(0.);
payload.material_rmxx = vec4(0.);
const vec3 pos = imageLoad(position_t, pix).xyz + geometry_normal * ray_normal_fudge;
if (!getHit(pos, bounce_direction, payload))
return;

View File

@ -213,6 +213,21 @@ void main() {
const Components c = blurSamples(res, pix);
if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_DISABLED) {
} else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_DIRECT) {
imageStore(out_dest, pix, vec4(LINEARtoSRGB(c.direct_diffuse + c.direct_specular), 0.)); return;
return;
} else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_INDIRECT) {
imageStore(out_dest, pix, vec4(LINEARtoSRGB(c.indirect_diffuse + c.indirect_specular), 0.)); return;
return;
} else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_INDIRECT_SPEC) {
imageStore(out_dest, pix, vec4(LINEARtoSRGB(c.indirect_specular), 0.)); return;
return;
} else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_INDIRECT_DIFF) {
imageStore(out_dest, pix, vec4(LINEARtoSRGB(c.indirect_diffuse), 0.)); return;
return;
}
vec3 colour = vec3(0.);
{
// TODO: need to extract reprojecting from this shader because reprojected stuff need svgf denoising pass after it

View File

@ -176,6 +176,10 @@ struct PushConstants {
#define DEBUG_DISPLAY_NGEOM 5
#define DEBUG_DISPLAY_LIGHTING 6
#define DEBUG_DISPLAY_SURFHASH 7
#define DEBUG_DISPLAY_DIRECT 8
#define DEBUG_DISPLAY_INDIRECT 9
#define DEBUG_DISPLAY_INDIRECT_SPEC 10
#define DEBUG_DISPLAY_INDIRECT_DIFF 11
// add more when needed
struct UniformBuffer {

View File

@ -404,32 +404,35 @@ static void fillWaterSurfaces( const cl_entity_t *ent, vk_brush_model_t *bmodel,
static rt_light_add_polygon_t loadPolyLight(const model_t *mod, const int surface_index, const msurface_t *surf, const vec3_t emissive);
static qboolean isSurfaceAnimated( const msurface_t *s ) {
const texture_t *base = s->texinfo->texture;
/* FIXME don't have ent here, need to check both explicitly
if( ent && ent->curstate.frame ) {
if( base->alternate_anims )
base = base->alternate_anims;
}
*/
if( !base->anim_total )
static qboolean doesTextureChainChange( const texture_t *const base ) {
const texture_t *cur = base;
if (!cur)
return false;
cur = cur->anim_next;
while (cur && cur != base) {
if (cur->gl_texturenum != base->gl_texturenum)
return true;
cur = cur->anim_next;
}
return false;
}
static qboolean isSurfaceAnimated( const msurface_t *s ) {
const texture_t *const base = s->texinfo->texture;
if( !base->anim_total && !base->alternate_anims )
return false;
/* TODO why did we do this? It doesn't seem to rule out animation really.
if( base->name[0] == '-' )
return false;
*/
// 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;
}
if (base->alternate_anims && base->gl_texturenum != base->alternate_anims->gl_texturenum)
return true;
return false;
return doesTextureChainChange(base) || doesTextureChainChange(base->alternate_anims);
}
typedef enum {
@ -742,7 +745,6 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, float blend, co
const int geom_index = bmodel->animated_indexes[i];
vk_render_geometry_t *geom = bmodel->render_model.geometries + geom_index;
const int surface_index = geom->surf_deprecate - mod->surfaces;
const xvk_patch_surface_t *const patch_surface = R_VkPatchGetSurface(surface_index);
// Optionally patch by texture_s pointer and run animations
const texture_t *t = R_TextureAnimation(ent, geom->surf_deprecate);

View File

@ -700,15 +700,15 @@ qboolean R_VkInit( void )
vk_core.debug = vk_core.validate || !!(gEngine.Sys_CheckParm("-vkdebug") || gEngine.Sys_CheckParm("-gldebug"));
vk_core.rtx = false;
VK_LoadCvars();
VK_LogsReadCvar();
// Force extremely verbose logs at startup.
// This is instrumental in some investigations, because the usual "vk_debug_log" cvar is not set
// at this point and cannot be used to selectively swith things on.
if (gEngine.Sys_CheckParm("-vkverboselogs"))
g_log_debug_bits = 0xffffffffu;
VK_LoadCvars();
VK_LogsReadCvar();
R_SpeedsInit();
if( !gEngine.R_Init_Video( REF_VULKAN )) // request Vulkan surface

View File

@ -126,7 +126,8 @@ static void printMaterial(int index) {
static void acquireTexturesForMaterial( int index ) {
const r_vk_material_t *mat = &g_materials.table[index].material;
DEBUG("%s(%d: %s)", __FUNCTION__, index, g_materials.table[index].name);
R_TextureAcquire(mat->tex_base_color);
if (mat->tex_base_color > 0)
R_TextureAcquire(mat->tex_base_color);
R_TextureAcquire(mat->tex_metalness);
R_TextureAcquire(mat->tex_roughness);
if (mat->tex_normalmap > 0)
@ -134,7 +135,8 @@ static void acquireTexturesForMaterial( int index ) {
}
static void releaseTexturesForMaterialPtr( const r_vk_material_t *mat ) {
R_TextureRelease(mat->tex_base_color);
if (mat->tex_base_color > 0)
R_TextureRelease(mat->tex_base_color);
R_TextureRelease(mat->tex_metalness);
R_TextureRelease(mat->tex_roughness);
if (mat->tex_normalmap > 0)
@ -245,8 +247,11 @@ static void loadMaterialsFromFile( const char *filename, int depth ) {
continue;
}
// If basecolor_map wasn't inherited
if (current_material.tex_base_color < 0) {
// Start with *default texture for base color, it will be acquired if no replacement is specified or could be loaded.
current_material.tex_base_color = for_tex_id >= 0 ? for_tex_id : 0;
current_material.tex_base_color = for_tex_id >= 0 ? for_tex_id : 0;
}
#define LOAD_TEXTURE_FOR(name, field, colorspace) \
do { \
@ -561,7 +566,7 @@ r_vk_material_t R_VkMaterialGetForTextureWithFlags( int tex_index, uint32_t flag
ret.tex_base_color = tex_index;
if ( flags & kVkMaterialFlagChrome )
ret.roughness = tglob.grayTexture;
ret.tex_roughness = tglob.grayTexture;
//DEBUG("Returning default material with tex_base_color=%d", tex_index);
return ret;

View File

@ -29,6 +29,11 @@ static void applyMaterialToKusok(vk_kusok_data_t* kusok, const vk_render_geometr
const r_vk_material_t *const mat = override_material ? override_material : &geom->material;
ASSERT(mat);
ASSERT(mat->tex_base_color >= 0);
ASSERT(mat->tex_roughness >= 0);
ASSERT(mat->tex_metalness >= 0);
ASSERT(mat->tex_normalmap >= 0);
// TODO split kusochki into static geometry data and potentially dynamic material data
// This data is static, should never change
kusok->vertex_offset = geom->vertex_offset;

View File

@ -164,6 +164,10 @@ static void parseDebugDisplayValue( void ) {
X(NSHADE) \
X(NGEOM) \
X(SURFHASH) \
X(DIRECT) \
X(INDIRECT) \
X(INDIRECT_SPEC) \
X(INDIRECT_DIFF) \
#define X(suffix) \
if (0 == Q_stricmp(cvalue, #suffix)) { \
@ -174,6 +178,13 @@ static void parseDebugDisplayValue( void ) {
LIST_DISPLAYS(X)
#undef X
if (Q_strlen(cvalue) > 0) {
gEngine.Con_Printf("Invalid rt_debug_display_only mode %s. Valid modes are:\n", cvalue);
#define X(suffix) gEngine.Con_Printf("\t%s\n", #suffix);
LIST_DISPLAYS(X)
#undef X
}
g_rtx.debug.rt_debug_display_only_value = DEBUG_DISPLAY_DISABLED;
}

View File

@ -144,7 +144,6 @@ static void preloadModels( void ) {
}
static void loadMap(const model_t* const map) {
VK_LogsReadCvar();
mapLoadBegin(map);
R_SpriteNewMapFIXME();