From ed7bff58c47500ce230d922970f212dad0324394 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 4 Feb 2021 10:51:46 -0700 Subject: DRTVWR-525, improve dev's quality-of-life --- indra/llrender/llshadermgr.h | 428 ++++++++++++++++++++-------------------- indra/llrender/llvertexbuffer.h | 43 ++-- 2 files changed, 238 insertions(+), 233 deletions(-) diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 127b5ce5b6..3908efd4ec 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -36,221 +36,223 @@ public: LLShaderMgr(); virtual ~LLShaderMgr(); - typedef enum - { - MODELVIEW_MATRIX = 0, - PROJECTION_MATRIX, - INVERSE_PROJECTION_MATRIX, - MODELVIEW_PROJECTION_MATRIX, - INVERSE_MODELVIEW_MATRIX, - NORMAL_MATRIX, - TEXTURE_MATRIX0, - TEXTURE_MATRIX1, - TEXTURE_MATRIX2, - TEXTURE_MATRIX3, - OBJECT_PLANE_S, - OBJECT_PLANE_T, - VIEWPORT, - LIGHT_POSITION, - LIGHT_DIRECTION, - LIGHT_ATTENUATION, - LIGHT_DIFFUSE, - LIGHT_AMBIENT, - MULTI_LIGHT_COUNT, - MULTI_LIGHT, - MULTI_LIGHT_COL, - MULTI_LIGHT_FAR_Z, - PROJECTOR_MATRIX, - PROJECTOR_NEAR, - PROJECTOR_P, - PROJECTOR_N, - PROJECTOR_ORIGIN, - PROJECTOR_RANGE, - PROJECTOR_AMBIANCE, - PROJECTOR_SHADOW_INDEX, - PROJECTOR_SHADOW_FADE, - PROJECTOR_FOCUS, - PROJECTOR_LOD, - PROJECTOR_AMBIENT_LOD, - DIFFUSE_COLOR, - DIFFUSE_MAP, - ALTERNATE_DIFFUSE_MAP, - SPECULAR_MAP, - BUMP_MAP, - BUMP_MAP2, - ENVIRONMENT_MAP, - CLOUD_NOISE_MAP, - CLOUD_NOISE_MAP_NEXT, - FULLBRIGHT, - LIGHTNORM, - SUNLIGHT_COLOR, - AMBIENT, - BLUE_HORIZON, - BLUE_DENSITY, - HAZE_HORIZON, - HAZE_DENSITY, - CLOUD_SHADOW, - DENSITY_MULTIPLIER, - DISTANCE_MULTIPLIER, - MAX_Y, - GLOW, - CLOUD_COLOR, - CLOUD_POS_DENSITY1, - CLOUD_POS_DENSITY2, - CLOUD_SCALE, - GAMMA, - SCENE_LIGHT_STRENGTH, - LIGHT_CENTER, - LIGHT_SIZE, - LIGHT_FALLOFF, - BOX_CENTER, - BOX_SIZE, - - GLOW_MIN_LUMINANCE, - GLOW_MAX_EXTRACT_ALPHA, - GLOW_LUM_WEIGHTS, - GLOW_WARMTH_WEIGHTS, - GLOW_WARMTH_AMOUNT, - GLOW_STRENGTH, - GLOW_DELTA, - - MINIMUM_ALPHA, - EMISSIVE_BRIGHTNESS, - - DEFERRED_SHADOW_MATRIX, - DEFERRED_ENV_MAT, - DEFERRED_SHADOW_CLIP, - DEFERRED_SUN_WASH, - DEFERRED_SHADOW_NOISE, - DEFERRED_BLUR_SIZE, - DEFERRED_SSAO_RADIUS, - DEFERRED_SSAO_MAX_RADIUS, - DEFERRED_SSAO_FACTOR, - DEFERRED_SSAO_FACTOR_INV, - DEFERRED_SSAO_EFFECT_MAT, - DEFERRED_SCREEN_RES, - DEFERRED_NEAR_CLIP, - DEFERRED_SHADOW_OFFSET, - DEFERRED_SHADOW_BIAS, - DEFERRED_SPOT_SHADOW_BIAS, - DEFERRED_SPOT_SHADOW_OFFSET, - DEFERRED_SUN_DIR, - DEFERRED_MOON_DIR, - DEFERRED_SHADOW_RES, - DEFERRED_PROJ_SHADOW_RES, - DEFERRED_DEPTH_CUTOFF, - DEFERRED_NORM_CUTOFF, - DEFERRED_SHADOW_TARGET_WIDTH, - - FXAA_TC_SCALE, - FXAA_RCP_SCREEN_RES, - FXAA_RCP_FRAME_OPT, - FXAA_RCP_FRAME_OPT2, - - DOF_FOCAL_DISTANCE, - DOF_BLUR_CONSTANT, - DOF_TAN_PIXEL_ANGLE, - DOF_MAGNIFICATION, - DOF_MAX_COF, - DOF_RES_SCALE, - DOF_WIDTH, - DOF_HEIGHT, - - DEFERRED_DEPTH, - DEFERRED_SHADOW0, - DEFERRED_SHADOW1, - DEFERRED_SHADOW2, - DEFERRED_SHADOW3, - DEFERRED_SHADOW4, - DEFERRED_SHADOW5, - DEFERRED_NORMAL, - DEFERRED_POSITION, - DEFERRED_DIFFUSE, - DEFERRED_SPECULAR, - DEFERRED_NOISE, - DEFERRED_LIGHTFUNC, - DEFERRED_LIGHT, - DEFERRED_BLOOM, - DEFERRED_PROJECTION, - DEFERRED_NORM_MATRIX, - TEXTURE_GAMMA, - SPECULAR_COLOR, - ENVIRONMENT_INTENSITY, - - AVATAR_MATRIX, - AVATAR_TRANSLATION, - - WATER_SCREENTEX, - WATER_SCREENDEPTH, - WATER_REFTEX, - WATER_EYEVEC, - WATER_TIME, - WATER_WAVE_DIR1, - WATER_WAVE_DIR2, - WATER_LIGHT_DIR, - WATER_SPECULAR, - WATER_SPECULAR_EXP, - WATER_FOGCOLOR, - WATER_FOGDENSITY, - WATER_FOGKS, - WATER_REFSCALE, - WATER_WATERHEIGHT, - WATER_WATERPLANE, - WATER_NORM_SCALE, - WATER_FRESNEL_SCALE, - WATER_FRESNEL_OFFSET, - WATER_BLUR_MULTIPLIER, - WATER_SUN_ANGLE, - WATER_SCALED_ANGLE, - WATER_SUN_ANGLE2, - - WL_CAMPOSLOCAL, - - AVATAR_WIND, - AVATAR_SINWAVE, - AVATAR_GRAVITY, - - TERRAIN_DETAIL0, - TERRAIN_DETAIL1, - TERRAIN_DETAIL2, - TERRAIN_DETAIL3, - TERRAIN_ALPHARAMP, - - SHINY_ORIGIN, - DISPLAY_GAMMA, - - INSCATTER_RT, - SUN_SIZE, - FOG_COLOR, + // clang-format off + typedef enum + { // Shader uniform name, set in LLShaderMgr::initAttribsAndUniforms() + MODELVIEW_MATRIX = 0, // "modelview_matrix" + PROJECTION_MATRIX, // "projection_matrix" + INVERSE_PROJECTION_MATRIX, // "inv_proj" + MODELVIEW_PROJECTION_MATRIX, // "modelview_projection_matrix" + INVERSE_MODELVIEW_MATRIX, // "inv_modelview" + NORMAL_MATRIX, // "normal_matrix" + TEXTURE_MATRIX0, // "texture_matrix0" + TEXTURE_MATRIX1, // "texture_matrix1" + TEXTURE_MATRIX2, // "texture_matrix2" + TEXTURE_MATRIX3, // "texture_matrix3" + OBJECT_PLANE_S, // "object_plane_s" + OBJECT_PLANE_T, // "object_plane_t" + VIEWPORT, // "viewport" + LIGHT_POSITION, // "light_position" + LIGHT_DIRECTION, // "light_direction" + LIGHT_ATTENUATION, // "light_attenuation" + LIGHT_DIFFUSE, // "light_diffuse" + LIGHT_AMBIENT, // "light_ambient" + MULTI_LIGHT_COUNT, // "light_count" + MULTI_LIGHT, // "light" + MULTI_LIGHT_COL, // "light_col" + MULTI_LIGHT_FAR_Z, // "far_z" + PROJECTOR_MATRIX, // "proj_mat" + PROJECTOR_NEAR, // "proj_near" + PROJECTOR_P, // "proj_p" + PROJECTOR_N, // "proj_n" + PROJECTOR_ORIGIN, // "proj_origin" + PROJECTOR_RANGE, // "proj_range" + PROJECTOR_AMBIANCE, // "proj_ambiance" + PROJECTOR_SHADOW_INDEX, // "proj_shadow_idx" + PROJECTOR_SHADOW_FADE, // "shadow_fade" + PROJECTOR_FOCUS, // "proj_focus" + PROJECTOR_LOD, // "proj_lod" + PROJECTOR_AMBIENT_LOD, // "proj_ambient_lod" + DIFFUSE_COLOR, // "color" + DIFFUSE_MAP, // "diffuseMap" + ALTERNATE_DIFFUSE_MAP, // "altDiffuseMap" + SPECULAR_MAP, // "specularMap" + BUMP_MAP, // "bumpMap" + BUMP_MAP2, // "bumpMap2" + ENVIRONMENT_MAP, // "environmentMap" + CLOUD_NOISE_MAP, // "cloud_noise_texture" + CLOUD_NOISE_MAP_NEXT, // "cloud_noise_texture_next" + FULLBRIGHT, // "fullbright" + LIGHTNORM, // "lightnorm" + SUNLIGHT_COLOR, // "sunlight_color" + AMBIENT, // "ambient_color" + BLUE_HORIZON, // "blue_horizon" + BLUE_DENSITY, // "blue_density" + HAZE_HORIZON, // "haze_horizon" + HAZE_DENSITY, // "haze_density" + CLOUD_SHADOW, // "cloud_shadow" + DENSITY_MULTIPLIER, // "density_multiplier" + DISTANCE_MULTIPLIER, // "distance_multiplier" + MAX_Y, // "max_y" + GLOW, // "glow" + CLOUD_COLOR, // "cloud_color" + CLOUD_POS_DENSITY1, // "cloud_pos_density1" + CLOUD_POS_DENSITY2, // "cloud_pos_density2" + CLOUD_SCALE, // "cloud_scale" + GAMMA, // "gamma" + SCENE_LIGHT_STRENGTH, // "scene_light_strength" + LIGHT_CENTER, // "center" + LIGHT_SIZE, // "size" + LIGHT_FALLOFF, // "falloff" + BOX_CENTER, // "box_center" + BOX_SIZE, // "box_size" + + GLOW_MIN_LUMINANCE, // "minLuminance" + GLOW_MAX_EXTRACT_ALPHA, // "maxExtractAlpha" + GLOW_LUM_WEIGHTS, // "lumWeights" + GLOW_WARMTH_WEIGHTS, // "warmthWeights" + GLOW_WARMTH_AMOUNT, // "warmthAmount" + GLOW_STRENGTH, // "glowStrength" + GLOW_DELTA, // "glowDelta" + + MINIMUM_ALPHA, // "minimum_alpha" + EMISSIVE_BRIGHTNESS, // "emissive_brightness" + + DEFERRED_SHADOW_MATRIX, // "shadow_matrix" + DEFERRED_ENV_MAT, // "env_mat" + DEFERRED_SHADOW_CLIP, // "shadow_clip" + DEFERRED_SUN_WASH, // "sun_wash" + DEFERRED_SHADOW_NOISE, // "shadow_noise" + DEFERRED_BLUR_SIZE, // "blur_size" + DEFERRED_SSAO_RADIUS, // "ssao_radius" + DEFERRED_SSAO_MAX_RADIUS, // "ssao_max_radius" + DEFERRED_SSAO_FACTOR, // "ssao_factor" + DEFERRED_SSAO_FACTOR_INV, // "ssao_factor_inv" + DEFERRED_SSAO_EFFECT_MAT, // "ssao_effect_mat" + DEFERRED_SCREEN_RES, // "screen_res" + DEFERRED_NEAR_CLIP, // "near_clip" + DEFERRED_SHADOW_OFFSET, // "shadow_offset" + DEFERRED_SHADOW_BIAS, // "shadow_bias" + DEFERRED_SPOT_SHADOW_BIAS, // "spot_shadow_bias" + DEFERRED_SPOT_SHADOW_OFFSET, // "spot_shadow_offset" + DEFERRED_SUN_DIR, // "sun_dir" + DEFERRED_MOON_DIR, // "moon_dir" + DEFERRED_SHADOW_RES, // "shadow_res" + DEFERRED_PROJ_SHADOW_RES, // "proj_shadow_res" + DEFERRED_DEPTH_CUTOFF, // "depth_cutoff" + DEFERRED_NORM_CUTOFF, // "norm_cutoff" + DEFERRED_SHADOW_TARGET_WIDTH, // "shadow_target_width" + + FXAA_TC_SCALE, // "tc_scale" + FXAA_RCP_SCREEN_RES, // "rcp_screen_res" + FXAA_RCP_FRAME_OPT, // "rcp_frame_opt" + FXAA_RCP_FRAME_OPT2, // "rcp_frame_opt2" + + DOF_FOCAL_DISTANCE, // "focal_distance" + DOF_BLUR_CONSTANT, // "blur_constant" + DOF_TAN_PIXEL_ANGLE, // "tan_pixel_angle" + DOF_MAGNIFICATION, // "magnification" + DOF_MAX_COF, // "max_cof" + DOF_RES_SCALE, // "res_scale" + DOF_WIDTH, // "dof_width" + DOF_HEIGHT, // "dof_height" + + DEFERRED_DEPTH, // "depthMap" + DEFERRED_SHADOW0, // "shadowMap0" + DEFERRED_SHADOW1, // "shadowMap1" + DEFERRED_SHADOW2, // "shadowMap2" + DEFERRED_SHADOW3, // "shadowMap3" + DEFERRED_SHADOW4, // "shadowMap4" + DEFERRED_SHADOW5, // "shadowMap5" + DEFERRED_NORMAL, // "normalMap" + DEFERRED_POSITION, // "positionMap" + DEFERRED_DIFFUSE, // "diffuseRect" + DEFERRED_SPECULAR, // "specularRect" + DEFERRED_NOISE, // "noiseMap" + DEFERRED_LIGHTFUNC, // "lightFunc" + DEFERRED_LIGHT, // "lightMap" + DEFERRED_BLOOM, // "bloomMap" + DEFERRED_PROJECTION, // "projectionMap" + DEFERRED_NORM_MATRIX, // "norm_mat" + TEXTURE_GAMMA, // "texture_gamma" + SPECULAR_COLOR, // "specular_color" + ENVIRONMENT_INTENSITY, // "env_intensity" + + AVATAR_MATRIX, // "matrixPalette" + AVATAR_TRANSLATION, // "translationPalette" + + WATER_SCREENTEX, // "screenTex" + WATER_SCREENDEPTH, // "screenDepth" + WATER_REFTEX, // "refTex" + WATER_EYEVEC, // "eyeVec" + WATER_TIME, // "time" + WATER_WAVE_DIR1, // "waveDir1" + WATER_WAVE_DIR2, // "waveDir2" + WATER_LIGHT_DIR, // "lightDir" + WATER_SPECULAR, // "specular" + WATER_SPECULAR_EXP, // "lightExp" + WATER_FOGCOLOR, // "waterFogColor" + WATER_FOGDENSITY, // "waterFogDensity" + WATER_FOGKS, // "waterFogKS" + WATER_REFSCALE, // "refScale" + WATER_WATERHEIGHT, // "waterHeight" + WATER_WATERPLANE, // "waterPlane" + WATER_NORM_SCALE, // "normScale" + WATER_FRESNEL_SCALE, // "fresnelScale" + WATER_FRESNEL_OFFSET, // "fresnelOffset" + WATER_BLUR_MULTIPLIER, // "blurMultiplier" + WATER_SUN_ANGLE, // "sunAngle" + WATER_SCALED_ANGLE, // "scaledAngle" + WATER_SUN_ANGLE2, // "sunAngle2" + + WL_CAMPOSLOCAL, // "camPosLocal" + + AVATAR_WIND, // "gWindDir" + AVATAR_SINWAVE, // "gSinWaveParams" + AVATAR_GRAVITY, // "gGravity" + + TERRAIN_DETAIL0, // "detail_0" + TERRAIN_DETAIL1, // "detail_1" + TERRAIN_DETAIL2, // "detail_2" + TERRAIN_DETAIL3, // "detail_3" + TERRAIN_ALPHARAMP, // "alpha_ramp" + + SHINY_ORIGIN, // "origin" + DISPLAY_GAMMA, // "display_gamma" + + INSCATTER_RT, // "inscatter" + SUN_SIZE, // "sun_size" + FOG_COLOR, // "fog_color" // precomputed textures - TRANSMITTANCE_TEX, - SCATTER_TEX, - SINGLE_MIE_SCATTER_TEX, - ILLUMINANCE_TEX, - BLEND_FACTOR, - - NO_ATMO, - MOISTURE_LEVEL, - DROPLET_RADIUS, - ICE_LEVEL, - RAINBOW_MAP, - HALO_MAP, - - MOON_BRIGHTNESS, - - CLOUD_VARIANCE, - - SH_INPUT_L1R, - SH_INPUT_L1G, - SH_INPUT_L1B, - - SUN_MOON_GLOW_FACTOR, - WATER_EDGE_FACTOR, - SUN_UP_FACTOR, - MOONLIGHT_COLOR, - END_RESERVED_UNIFORMS - } eGLSLReservedUniforms; + TRANSMITTANCE_TEX, // "transmittance_texture" + SCATTER_TEX, // "scattering_texture" + SINGLE_MIE_SCATTER_TEX, // "single_mie_scattering_texture" + ILLUMINANCE_TEX, // "irradiance_texture" + BLEND_FACTOR, // "blend_factor" + + NO_ATMO, // "no_atmo" + MOISTURE_LEVEL, // "moisture_level" + DROPLET_RADIUS, // "droplet_radius" + ICE_LEVEL, // "ice_level" + RAINBOW_MAP, // "rainbow_map" + HALO_MAP, // "halo_map" + + MOON_BRIGHTNESS, // "moon_brightness" + + CLOUD_VARIANCE, // "cloud_variance" + + SH_INPUT_L1R, // "sh_input_r" + SH_INPUT_L1G, // "sh_input_g" + SH_INPUT_L1B, // "sh_input_b" + + SUN_MOON_GLOW_FACTOR, // "sun_moon_glow_factor" + WATER_EDGE_FACTOR, // "water_edge" + SUN_UP_FACTOR, // "sun_up_factor" + MOONLIGHT_COLOR, // "moonlight_color" + END_RESERVED_UNIFORMS + } eGLSLReservedUniforms; + // clang-format on // singleton pattern implementation static LLShaderMgr * instance(); diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 9867bd16d6..dbe1a3687f 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -155,9 +155,8 @@ public: //get the size of a buffer with the given typemask and vertex count //fill offsets with the offset of each vertex component array into the buffer // indexed by the following enum - static S32 calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices); + static S32 calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices); - //WARNING -- when updating these enums you MUST // 1 - update LLVertexBuffer::sTypeSize // 2 - add a strider accessor @@ -165,24 +164,28 @@ public: // 4 - modify LLVertexBuffer::setupClientArray // 5 - modify LLViewerShaderMgr::mReservedAttribs // 6 - update LLVertexBuffer::setupVertexArray - enum { - TYPE_VERTEX = 0, - TYPE_NORMAL, - TYPE_TEXCOORD0, - TYPE_TEXCOORD1, - TYPE_TEXCOORD2, - TYPE_TEXCOORD3, - TYPE_COLOR, - TYPE_EMISSIVE, - TYPE_TANGENT, - TYPE_WEIGHT, - TYPE_WEIGHT4, - TYPE_CLOTHWEIGHT, - TYPE_TEXTURE_INDEX, - TYPE_MAX, // TYPE_MAX is the size/boundary marker for attributes that go in the vertex buffer - TYPE_INDEX, // TYPE_INDEX is beyond _MAX because it lives in a separate (index) buffer - }; - enum { + + // clang-format off + enum { // Shader attribute name, set in LLShaderMgr::initAttribsAndUniforms() + TYPE_VERTEX = 0, // "position" + TYPE_NORMAL, // "normal" + TYPE_TEXCOORD0, // "texcoord0" + TYPE_TEXCOORD1, // "texcoord1" + TYPE_TEXCOORD2, // "texcoord2" + TYPE_TEXCOORD3, // "texcoord3" + TYPE_COLOR, // "diffuse_color" + TYPE_EMISSIVE, // "emissive" + TYPE_TANGENT, // "tangent" + TYPE_WEIGHT, // "weight" + TYPE_WEIGHT4, // "weight4" + TYPE_CLOTHWEIGHT, // "clothing" + TYPE_TEXTURE_INDEX, // "texture_index" + TYPE_MAX, // TYPE_MAX is the size/boundary marker for attributes that go in the vertex buffer + TYPE_INDEX, // TYPE_INDEX is beyond _MAX because it lives in a separate (index) buffer + }; + // clang-format on + + enum { MAP_VERTEX = (1< Date: Tue, 9 Feb 2021 16:36:50 -0700 Subject: DRTVWR-525 housekeeping: delete unused shader file --- .../shaders/class3/deferred/lightUtil.glsl | 117 --------------------- 1 file changed, 117 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl diff --git a/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl deleted file mode 100644 index 8bb3f07fc6..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @file lightInfo.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -struct DirectionalLightInfo -{ - vec4 pos; - float depth; - vec4 normal; - vec3 normalizedLightDirection; - vec3 normalizedToLight; - float lightIntensity; - vec3 lightDiffuseColor; - float specExponent; - float shadow; -}; - -struct SpotLightInfo -{ - vec4 pos; - float depth; - vec4 normal; - vec3 normalizedLightDirection; - vec3 normalizedToLight; - float lightIntensity; - float attenuation; - float distanceToLight; - vec3 lightDiffuseColor; - float innerHalfAngleCos; - float outerHalfAngleCos; - float spotExponent; - float specExponent; - float shadow; -}; - -struct PointLightInfo -{ - vec4 pos; - float depth; - vec4 normal; - vec3 normalizedToLight; - float lightIntensity; - float attenuation; - float distanceToLight; - vec3 lightDiffuseColor; - float lightRadius; - float specExponent; - vec3 worldspaceLightDirection; - float shadow; -}; - -float attenuate(float attenuationSelection, float distanceToLight) -{ -// LLRENDER_REVIEW -// sh/could eventually consume attenuation func defined in texture - return (attenuationSelection == 0.0f) ? 1.0f : // none - (attenuationSelection < 1.0f) ? (1.0f / distanceToLight) : // linear atten - (attenuationSelection < 2.0f) ? (1.0f / (distanceToLight*distanceToLight)) // quadratic atten - : (1.0f / (distanceToLight*distanceToLight*distanceToLight)); // cubic atten -} - - -vec3 lightDirectional(struct DirectionalLightInfo dli) -{ - float lightIntensity = dli.lightIntensity; - lightIntensity *= dot(dli.normal.xyz, dli.normalizedLightDirection); - //lightIntensity *= directionalShadowSample(vec4(dli.pos.xyz, 1.0f), dli.depth, dli.directionalShadowMap, dli.directionalShadowMatrix); - return lightIntensity * dli.lightDiffuseColor; -} - - -vec3 lightSpot(struct SpotLightInfo sli) -{ - float penumbraRange = (sli.outerHalfAngleCos - sli.innerHalfAngleCos); - float coneAngleCos = max(dot(sli.normalizedLightDirection, sli.normalizedToLight), 0.0); - float coneAttenFactor = (coneAngleCos <= sli.outerHalfAngleCos) ? 1.0f : pow(smoothstep(1,0, sli.outerHalfAngleCos / penumbraRange), sli.spotExponent); - float distanceAttenuation = attenuate(sli.attenuation, sli.distanceToLight); - float lightIntensity = sli.lightIntensity; - lightIntensity *= distanceAttenuation; - lightIntensity *= max(dot(sli.normal.xyz, sli.normalizedLightDirection), 0.0); - lightIntensity *= coneAttenFactor; - lightIntensity *= sli.shadow; - return lightIntensity * sli.lightDiffuseColor; -} - -vec3 lightPoint(struct PointLightInfo pli) -{ - float padRadius = pli.lightRadius * 0.1; // distance for which to perform smoothed dropoff past light radius - float distanceAttenuation = attenuate(pli.attenuation, pli.distanceToLight); - float lightIntensity = pli.lightIntensity; - lightIntensity*= distanceAttenuation; - lightIntensity *= clamp((padRadius - pli.distanceToLight + pli.lightRadius) / padRadius, 0.0, 1.0); - lightIntensity *= pli.shadow; - lightIntensity *= max(dot(pli.normal.xyz, pli.normalizedToLight), 0.0); - return lightIntensity * pli.lightDiffuseColor; -} -- cgit v1.2.3 From 6e2c805dd34880cd186213f4c5aa01d8fe3daefc Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 17 Mar 2021 14:12:04 -0600 Subject: SL-14895, point light atten should move inversely light radius --- indra/newview/pipeline.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index cd1b9c7c69..9924b02a95 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6387,21 +6387,19 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) continue; } - LLVector3 light_pos(light->getRenderPosition()); - LLVector4 light_pos_gl(light_pos, 1.0f); - - F32 light_radius = llmax(light->getLightRadius(), 0.001f); - F32 size = light_radius * (sRenderDeferred ? 1.5f : 1.0f); + LLVector3 light_pos(light->getRenderPosition()); + LLVector4 light_pos_gl(light_pos, 1.0f); - if (size <= 0.001f) + F32 adjusted_radius = light->getLightRadius() * (sRenderDeferred ? 1.5f : 1.0f); + if (adjusted_radius <= 0.001f) { continue; } - F32 x = (3.f * (1.f + (light->getLightFalloff() * 2.0f))); // why this magic? probably trying to match a historic behavior. - F32 linatten = x / (light_radius); // % of brightness at radius + F32 x = (3.f * (1.f + (light->getLightFalloff() * 2.0f))); // why this magic? probably trying to match a historic behavior. + F32 linatten = x / adjusted_radius; // % of brightness at radius - mHWLightColors[cur_light] = light_color; + mHWLightColors[cur_light] = light_color; LLLightState* light_state = gGL.getLight(cur_light); light_state->setPosition(light_pos_gl); @@ -6410,7 +6408,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) light_state->setConstantAttenuation(0.f); if (sRenderDeferred) { - light_state->setLinearAttenuation(size); + light_state->setLinearAttenuation(linatten); light_state->setQuadraticAttenuation(light->getLightFalloff(DEFERRED_LIGHT_FALLOFF) + 1.f); // get falloff to match for forward deferred rendering lights } else -- cgit v1.2.3 From e745da0c0b49e36cfeb516c79e06422d2de66433 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 18 Mar 2021 18:01:23 -0600 Subject: DRTVWR-528, delete all unreferenced shader files, improve dev QoL --- .../class1/deferred/avatarAlphaNoColorV.glsl | 112 ------------ .../shaders/class1/deferred/cloudShadowF.glsl | 127 ------------- .../shaders/class1/deferred/cloudShadowV.glsl | 63 ------- .../shaders/class1/deferred/luminanceF.glsl | 40 ---- .../shaders/class1/deferred/luminanceV.glsl | 45 ----- .../shaders/class1/deferred/postgiF.glsl | 99 ---------- .../shaders/class1/deferred/shadowAlphaBlendF.glsl | 55 ------ .../shaders/class1/deferred/shadowAlphaBlendV.glsl | 67 ------- .../shaders/class1/objects/indexedTextureF.glsl | 33 ---- .../shaders/class1/windlight/cloudShadowF.glsl | 127 ------------- .../shaders/class1/windlight/cloudShadowV.glsl | 61 ------- .../shaders/class3/deferred/cloudShadowF.glsl | 119 ------------ .../shaders/class3/deferred/cloudShadowV.glsl | 63 ------- .../class3/deferred/depthToShadowVolumeG.glsl | 202 --------------------- .../shaders/class3/deferred/gatherSkyShF.glsl | 70 ------- .../shaders/class3/deferred/gatherSkyShV.glsl | 40 ---- .../shaders/class3/deferred/genSkyShF.glsl | 111 ----------- .../shaders/class3/deferred/genSkyShV.glsl | 37 ---- .../shaders/class3/deferred/pointShadowBlurF.glsl | 37 ---- .../shaders/class3/deferred/shVisF.glsl | 73 -------- .../shaders/class3/deferred/shVisV.glsl | 33 ---- .../shaders/class3/deferred/shadowAlphaBlendF.glsl | 58 ------ .../shaders/class3/deferred/shadowAlphaBlendV.glsl | 66 ------- .../shaders/class3/windlight/advancedAtmoF.glsl | 73 -------- .../shaders/class3/windlight/advancedAtmoV.glsl | 43 ----- 25 files changed, 1854 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/objects/indexedTextureF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl delete mode 100644 indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/cloudShadowV.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/depthToShadowVolumeG.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/gatherSkyShF.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/gatherSkyShV.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/genSkyShF.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/genSkyShV.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/pointShadowBlurF.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/shVisF.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/shVisV.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendF.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendV.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl delete mode 100644 indra/newview/app_settings/shaders/class3/windlight/advancedAtmoV.glsl diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl deleted file mode 100644 index bbdc8fdd1c..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @file avatarAlphaNoColorV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec3 normal; -ATTRIBUTE vec2 texcoord0; - -mat4 getSkinnedTransform(); -void calcAtmospherics(vec3 inPositionEye); - -float calcDirectionalLight(vec3 n, vec3 l); - -vec3 atmosAmbient(); -vec3 atmosAffectDirectionalLight(float lightIntensity); - -VARYING vec3 vary_position; -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; -VARYING vec3 vary_fragcoord; -VARYING vec3 vary_pointlight_col; -VARYING vec2 vary_texcoord0; -VARYING vec3 vary_norm; - - -uniform float near_clip; - -uniform vec4 color; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight); - -void main() -{ - vary_texcoord0 = texcoord0; - - vec4 pos; - vec3 norm; - - mat4 trans = getSkinnedTransform(); - vec4 pos_in = vec4(position.xyz, 1.0); - pos.x = dot(trans[0], pos_in); - pos.y = dot(trans[1], pos_in); - pos.z = dot(trans[2], pos_in); - pos.w = 1.0; - - norm.x = dot(trans[0].xyz, normal); - norm.y = dot(trans[1].xyz, normal); - norm.z = dot(trans[2].xyz, normal); - norm = normalize(norm); - vary_norm = norm; - - vec4 frag_pos = projection_matrix * pos; - gl_Position = frag_pos; - - vary_position = pos.xyz; - - calcAtmospherics(pos.xyz); - - vec4 col = vec4(0.0, 0.0, 0.0, 1.0); - - // Collect normal lights - col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z); - col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z); - col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z); - col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z); - col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z); - col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z); - - vary_pointlight_col = col.rgb*color.rgb; - - col.rgb = vec3(0,0,0); - - // Add windlight lights - col.rgb = atmosAmbient(); - - vary_ambient = col.rgb*color.rgb; - vary_directional = color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0)); - - col.rgb = col.rgb * color.rgb; - - vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -} - - diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl deleted file mode 100644 index 0157d166e0..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file class3/deferred/cloudsF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING float vary_CloudDensity; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; -VARYING vec2 vary_texcoord3; - -uniform sampler2D cloud_noise_texture; -uniform sampler2D cloud_noise_texture_next; -uniform float blend_factor; -uniform vec4 cloud_pos_density1; -uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; -uniform vec4 cloud_color; -uniform float cloud_shadow; -uniform float cloud_scale; -uniform float cloud_variance; -uniform vec3 camPosLocal; -uniform vec3 sun_dir; -uniform float sun_size; -uniform float far_z; - -#if !defined(DEPTH_CLAMP) -VARYING vec4 post_pos; -#endif - -vec4 cloudNoise(vec2 uv) -{ - vec4 a = texture2D(cloud_noise_texture, uv); - vec4 b = texture2D(cloud_noise_texture_next, uv); - vec4 cloud_noise_sample = mix(a, b, blend_factor); - return normalize(cloud_noise_sample); -} - -void main() -{ - // Set variables - vec2 uv1 = vary_texcoord0.xy; - vec2 uv2 = vary_texcoord1.xy; - vec2 uv3 = vary_texcoord2.xy; - float cloudDensity = 2.0 * (cloud_shadow - 0.25); - - if (cloud_scale >= 0.0001) - { - vec2 uv4 = vary_texcoord3.xy; - - vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); - vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); - - // Offset texture coords - uv1 += cloud_pos_density1.xy + (disturbance * 0.2); //large texture, visible density - uv2 += cloud_pos_density1.xy; //large texture, self shadow - uv3 += cloud_pos_density2.xy; //small texture, visible density - uv4 += cloud_pos_density2.xy; //small texture, self shadow - - float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y) * 4.0); - - cloudDensity *= 1.0 - (density_variance * density_variance); - - // Compute alpha1, the main cloud opacity - float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; - alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); - - // And smooth - alpha1 = 1. - alpha1 * alpha1; - alpha1 = 1. - alpha1 * alpha1; - - if (alpha1 < 0.001f) - { - discard; - } - - // Compute alpha2, for self shadowing effect - // (1 - alpha2) will later be used as percentage of incoming sunlight - float alpha2 = (cloudNoise(uv2).x - 0.5); - alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); - - // And smooth - alpha2 = 1. - alpha2; - alpha2 = 1. - alpha2 * alpha2; - - frag_color = vec4(alpha1, alpha1, alpha1, 1); - } - else - { - frag_color = vec4(1); - } - -#if !defined(DEPTH_CLAMP) - gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); -#endif - -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl deleted file mode 100644 index effb070f93..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file cloudShadowV.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_projection_matrix; -uniform float shadow_target_width; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING vec2 vary_texcoord0; -VARYING vec4 vertex_color; - -void passTextureIndex(); - -void main() -{ - //transform vertex - vec4 pre_pos = vec4(position.xyz, 1.0); - pos = modelview_projection_matrix * pre_pos; - target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; - -#if !defined(DEPTH_CLAMP) - pos_zd2 = pos.z * 0.5; - gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -#else - gl_Position = pos; -#endif - - passTextureIndex(); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - vertex_color = diffuse_color; -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl deleted file mode 100644 index be1003a7e0..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file luminanceF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/*[EXTRA_CODE_HERE]*/ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2DRect diffuseMap; -VARYING vec2 vary_fragcoord; - -void main() -{ - frag_color = texture2DRect(diffuseMap, vary_fragcoord.xy); -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl deleted file mode 100644 index f2dc60aa5d..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @file giV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; - -VARYING vec2 vary_fragcoord; -VARYING vec4 vertex_color; - -uniform vec2 screen_res; - -void main() -{ - //transform vertex - vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0); - gl_Position = pos; - - vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; - - vertex_color = diffuse_color; -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl deleted file mode 100644 index cf994d3547..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file postgiF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/*[EXTRA_CODE_HERE]*/ - - #ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2DRect depthMap; -uniform sampler2DRect normalMap; -uniform sampler2DRect giLightMap; -uniform sampler2D noiseMap; - -uniform vec2 kern[32]; -uniform float dist_factor; -uniform float blur_size; -uniform vec2 delta; -uniform int kern_length; -uniform float kern_scale; -uniform vec3 blur_quad; - -VARYING vec2 vary_fragcoord; - -uniform mat4 inv_proj; -uniform vec2 screen_res; - -vec4 getPosition(vec2 pos_screen); - -void main() -{ - vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz; - norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm - vec3 pos = getPosition(vary_fragcoord.xy).xyz; - - vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; - vec2 dlt = kern_scale * delta/(1.0+norm.xy*norm.xy); - dlt /= max(-pos.z*dist_factor, 1.0); - float defined_weight = kern[0].x; - vec3 col = vec3(0.0); - - for (int i = 0; i < kern_length; i++) - { - vec2 tc = vary_fragcoord.xy + kern[i].y*dlt; - vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz; - sampNorm = vec3((sampNorm.xy-0.5)*2.0,sampNorm.z); // unpack norm - - float d = dot(norm.xyz, sampNorm); - - if (d > 0.8) - { - vec3 samppos = getPosition(tc.xy).xyz; - samppos -= pos; - if (dot(samppos,samppos) < -0.05*pos.z) - { - col += texture2DRect(giLightMap, tc).rgb*kern[i].x; - defined_weight += kern[i].x; - } - } - } - - col /= defined_weight; - - //col = ccol; - - col = col*col*blur_quad.x + col*blur_quad.y + blur_quad.z; - - frag_color.rgb = col; - -#ifdef IS_AMD_CARD - // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts. - vec2 dummy1 = kern[0]; - vec2 dummy2 = kern[31]; -#endif -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl deleted file mode 100644 index 44f2a73e1f..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @file shadowAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/*[EXTRA_CODE_HERE]*/ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING float pos_w; - -VARYING float target_pos_x; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void main() -{ - float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a; - - frag_color = vec4(alpha, alpha, alpha, 1); - -#if !defined(DEPTH_CLAMP) - gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0); -#endif -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl deleted file mode 100644 index f45c343066..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file shadowAlphaMaskV.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_projection_matrix; -uniform float shadow_target_width; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING float pos_w; - -VARYING float target_pos_x; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void passTextureIndex(); - -void main() -{ - //transform vertex - vec4 pre_pos = vec4(position.xyz, 1.0); - vec4 pos = modelview_projection_matrix * pre_pos; - target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; - - pos_w = pos.w; - -#if !defined(DEPTH_CLAMP) - pos_zd2 = pos.z * 0.5; - - gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -#else - gl_Position = pos; -#endif - - passTextureIndex(); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - vertex_color = diffuse_color; -} diff --git a/indra/newview/app_settings/shaders/class1/objects/indexedTextureF.glsl b/indra/newview/app_settings/shaders/class1/objects/indexedTextureF.glsl deleted file mode 100644 index 254c1d4fc2..0000000000 --- a/indra/newview/app_settings/shaders/class1/objects/indexedTextureF.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file fullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - - - - -void main() -{ - fullbright_lighting(); -} - diff --git a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl deleted file mode 100644 index 82fad4db5a..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file class1/windlight/cloudShadowF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING float vary_CloudDensity; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; -VARYING vec2 vary_texcoord3; - -uniform sampler2D cloud_noise_texture; -uniform sampler2D cloud_noise_texture_next; -uniform float blend_factor; -uniform vec4 cloud_pos_density1; -uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; -uniform vec4 cloud_color; -uniform float cloud_shadow; -uniform float cloud_scale; -uniform float cloud_variance; -uniform vec3 camPosLocal; -uniform vec3 sun_dir; -uniform float sun_size; -uniform float far_z; - -#if !defined(DEPTH_CLAMP) -VARYING vec4 post_pos; -#endif - -vec4 cloudNoise(vec2 uv) -{ - vec4 a = texture2D(cloud_noise_texture, uv); - vec4 b = texture2D(cloud_noise_texture_next, uv); - vec4 cloud_noise_sample = mix(a, b, blend_factor); - return normalize(cloud_noise_sample); -} - -void main() -{ - if (cloud_scale >= 0.0001) - { - // Set variables - vec2 uv1 = vary_texcoord0.xy; - vec2 uv2 = vary_texcoord1.xy; - vec2 uv3 = vary_texcoord2.xy; - float cloudDensity = 2.0 * (cloud_shadow - 0.25); - - vec2 uv4 = vary_texcoord3.xy; - - vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); - vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); - - // Offset texture coords - uv1 += cloud_pos_density1.xy + (disturbance * 0.2); //large texture, visible density - uv2 += cloud_pos_density1.xy; //large texture, self shadow - uv3 += cloud_pos_density2.xy; //small texture, visible density - uv4 += cloud_pos_density2.xy; //small texture, self shadow - - float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y) * 4.0); - - cloudDensity *= 1.0 - (density_variance * density_variance); - - // Compute alpha1, the main cloud opacity - float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; - alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); - - // And smooth - alpha1 = 1. - alpha1 * alpha1; - alpha1 = 1. - alpha1 * alpha1; - - if (alpha1 < 0.001f) - { - discard; - } - - // Compute alpha2, for self shadowing effect - // (1 - alpha2) will later be used as percentage of incoming sunlight - float alpha2 = (cloudNoise(uv2).x - 0.5); - alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); - - // And smooth - alpha2 = 1. - alpha2; - alpha2 = 1. - alpha2 * alpha2; - - frag_color = vec4(alpha1, alpha1, alpha1, 1); - } - else - { - frag_color = vec4(1); - } - -#if !defined(DEPTH_CLAMP) - gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); -#endif - -} diff --git a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl deleted file mode 100644 index 09b6004481..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file class1\windlight\cloudShadowV.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_projection_matrix; -uniform float shadow_target_width; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING vec2 vary_texcoord0; - -void passTextureIndex(); - -void main() -{ - //transform vertex - vec4 pre_pos = vec4(position.xyz, 1.0); - pos = modelview_projection_matrix * pre_pos; - target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; - -#if !defined(DEPTH_CLAMP) - pos_zd2 = pos.z * 0.5; - gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -#else - gl_Position = pos; -#endif - - passTextureIndex(); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl deleted file mode 100644 index 32210f60dc..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @file class3/deferred/cloudsF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING float vary_CloudDensity; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; -VARYING vec2 vary_texcoord3; - -uniform sampler2D cloud_noise_texture; -uniform sampler2D cloud_noise_texture_next; -uniform float blend_factor; -uniform vec4 cloud_pos_density1; -uniform vec4 cloud_pos_density2; -uniform vec4 cloud_color; -uniform float cloud_shadow; -uniform float cloud_scale; -uniform float cloud_variance; -uniform vec3 camPosLocal; -uniform vec3 sun_dir; -uniform float sun_size; -uniform float far_z; - -vec4 cloudNoise(vec2 uv) -{ - vec4 a = texture2D(cloud_noise_texture, uv); - vec4 b = texture2D(cloud_noise_texture_next, uv); - vec4 cloud_noise_sample = mix(a, b, blend_factor); - return normalize(cloud_noise_sample); -} - -vec4 computeMoments(float depth, float alpha); - -void main() -{ - if (cloud_scale >= 0.001) - { - // Set variables - vec2 uv1 = vary_texcoord0.xy; - vec2 uv2 = vary_texcoord1.xy; - vec2 uv3 = vary_texcoord2.xy; - float cloudDensity = 2.0 * (cloud_shadow - 0.25); - - vec2 uv4 = vary_texcoord3.xy; - - vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); - vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); - - // Offset texture coords - uv1 += cloud_pos_density1.xy + (disturbance * 0.2); //large texture, visible density - uv2 += cloud_pos_density1.xy; //large texture, self shadow - uv3 += cloud_pos_density2.xy; //small texture, visible density - uv4 += cloud_pos_density2.xy; //small texture, self shadow - - float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y) * 4.0); - - cloudDensity *= 1.0 - (density_variance * density_variance); - - // Compute alpha1, the main cloud opacity - float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; - alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); - - // And smooth - alpha1 = 1. - alpha1 * alpha1; - alpha1 = 1. - alpha1 * alpha1; - - if (alpha1 < 0.001f) - { - discard; - } - - // Compute alpha2, for self shadowing effect - // (1 - alpha2) will later be used as percentage of incoming sunlight - float alpha2 = (cloudNoise(uv2).x - 0.5); - alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); - - // And smooth - alpha2 = 1. - alpha2; - alpha2 = 1. - alpha2 * alpha2; - - frag_color = computeMoments(length(pos), alpha1); - } - else - { - frag_color = vec4(0); - } -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowV.glsl deleted file mode 100644 index effb070f93..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowV.glsl +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file cloudShadowV.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_projection_matrix; -uniform float shadow_target_width; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING vec2 vary_texcoord0; -VARYING vec4 vertex_color; - -void passTextureIndex(); - -void main() -{ - //transform vertex - vec4 pre_pos = vec4(position.xyz, 1.0); - pos = modelview_projection_matrix * pre_pos; - target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; - -#if !defined(DEPTH_CLAMP) - pos_zd2 = pos.z * 0.5; - gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -#else - gl_Position = pos; -#endif - - passTextureIndex(); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - vertex_color = diffuse_color; -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/depthToShadowVolumeG.glsl b/indra/newview/app_settings/shaders/class3/deferred/depthToShadowVolumeG.glsl deleted file mode 100644 index cdaff4b09f..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/depthToShadowVolumeG.glsl +++ /dev/null @@ -1,202 +0,0 @@ -/** - * @file depthToShadowVolumeG.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ -#extension GL_ARB_geometry_shader4 : enable -#extension GL_ARB_texture_rectangle : enable - -/*[EXTRA_CODE_HERE]*/ - -layout (triangles) in; -layout (triangle_strip, max_vertices = 128) out; - -uniform sampler2DRect depthMap; -uniform mat4 shadowMatrix[6]; -uniform vec4 lightpos; - -VARYING vec2 vary_texcoord0; - -out vec3 to_vec; - -void cross_products(out vec4 ns[3], int a, int b, int c) -{ - ns[0] = cross(gl_PositionIn[b].xyz - gl_PositionIn[a].xyz, gl_PositionIn[c].xyz - gl_PositionIn[a].xyz); - ns[1] = cross(gl_PositionIn[c].xyz - gl_PositionIn[b].xyz, gl_PositionIn[a].xyz - gl_PositionIn[b].xyz); - ns[2] = cross(gl_PositionIn[a].xyz - gl_PositionIn[c].xyz, gl_PositionIn[b].xyz - gl_PositionIn[c].xyz); -} - -vec3 getLightDirection(vec4 lightpos, vec3 pos) -{ - - vec3 lightdir = lightpos.xyz - lightpos.w * pos; - return lightdir; -} - -void emitTri(vec4 v[3]) -{ - gl_Position = proj_matrix * v[0]; - EmitVertex(); - - gl_Position = proj_matrix * v[1]; - EmitVertex(); - - gl_Position = proj_matrix * v[2]; - EmitVertex(); - - EndPrimitive(); -} - -void emitQuad(vec4 v[4] -{ - // Emit a quad as a triangle strip. - gl_Position = proj_matrix*v[0]; - EmitVertex(); - - gl_Position = proj_matrix*v[1]; - EmitVertex(); - - gl_Position = proj_matrix*v[2]; - EmitVertex(); - - gl_Position = proj_matrix*v[3]; - EmitVertex(); - - EndPrimitive(); -} - -void emitPrimitives(int layer) -{ - int i = layer; - gl_Layer = i; - - vec4 depth1 = vec4(texture2DRect(depthMap, tc0).rg, texture2DRect(depthMap, tc1).rg)); - vec3 depth2 = vec4(texture2DRect(depthMap, tc2).rg, texture2DRect(depthMap, tc3).rg)); - vec3 depth3 = vec4(texture2DRect(depthMap, tc4).rg, texture2DRect(depthMap, tc5).rg)); - vec3 depth4 = vec4(texture2DRect(depthMap, tc6).rg, texture2DRect(depthMap, tc7).rg)); - - depth1 = min(depth1, depth2); - depth1 = min(depth1, depth3); - depth1 = min(depth1, depth4); - - vec2 depth = min(depth1.xy, depth1.zw); - - int side = sqrt(gl_VerticesIn); - - for (int j = 0; j < side; j++) - { - for (int k = 0; k < side; ++k) - { - vec3 pos = gl_PositionIn[(j * side) + k].xyz; - vec4 v = shadowMatrix[i] * vec4(pos, 1.0); - gl_Position = v; - to_vec = pos - light_position.xyz * depth; - EmitVertex(); - } - - EndPrimitive(); - } - - vec3 norms[3]; // Normals - vec3 lightdir3]; // Directions toward light - - vec4 v[4]; // Temporary vertices - - vec4 or_pos[3] = - { // Triangle oriented toward light source - gl_PositionIn[0], - gl_PositionIn[2], - gl_PositionIn[4] - }; - - // Compute normal at each vertex. - cross_products(n, 0, 2, 4); - - // Compute direction from vertices to light. - lightdir[0] = getLightDirection(lightpos, gl_PositionIn[0].xyz); - lightdir[1] = getLightDirection(lightpos, gl_PositionIn[2].xyz); - lightdir[2] = getLightDirection(lightpos, gl_PositionIn[4].xyz); - - // Check if the main triangle faces the light. - bool faces_light = true; - if (!(dot(ns[0],d[0]) > 0 - |dot(ns[1],d[1]) > 0 - |dot(ns[2],d[2]) > 0)) - { - // Flip vertex winding order in or_pos. - or_pos[1] = gl_PositionIn[4]; - or_pos[2] = gl_PositionIn[2]; - faces_light = false; - } - - // Near cap: simply render triangle. - emitTri(or_pos); - - // Far cap: extrude positions to infinity. - v[0] =vec4(lightpos.w * or_pos[0].xyz - lightpos.xyz,0); - v[1] =vec4(lightpos.w * or_pos[2].xyz - lightpos.xyz,0); - v[2] =vec4(lightpos.w * or_pos[1].xyz - lightpos.xyz,0); - - emitTri(v); - - // Loop over all edges and extrude if needed. - for ( int i=0; i<3; i++ ) - { - // Compute indices of neighbor triangle. - int v0 = i*2; - int nb = (i*2+1); - int v1 = (i*2+2) % 6; - cross_products(n, v0, nb, v1); - - // Compute direction to light, again as above. - d[0] =lightpos.xyz-lightpos.w*gl_PositionIn[v0].xyz; - d[1] =lightpos.xyz-lightpos.w*gl_PositionIn[nb].xyz; - d[2] =lightpos.xyz-lightpos.w*gl_PositionIn[v1].xyz; - - bool is_parallel = gl_PositionIn[nb].w < 1e-5; - - // Extrude the edge if it does not have a - // neighbor, or if it's a possible silhouette. - if (is_parallel || - ( faces_light != (dot(ns[0],d[0])>0 || - dot(ns[1],d[1])>0 || - dot(ns[2],d[2])>0) )) - { - // Make sure sides are oriented correctly. - int i0 = faces_light ? v0 : v1; - int i1 = faces_light ? v1 : v0; - - v[0] = gl_PositionIn[i0]; - v[1] = vec4(lightpos.w*gl_PositionIn[i0].xyz - lightpos.xyz, 0); - v[2] = gl_PositionIn[i1]; - v[3] = vec4(lightpos.w*gl_PositionIn[i1].xyz - lightpos.xyz, 0); - - emitQuad(v); - } - } -} - -void main() -{ - // Output - emitPrimitives(0); -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShF.glsl b/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShF.glsl deleted file mode 100644 index 34d26cddea..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShF.glsl +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file class3/deferred/gatherSkyShF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif - -VARYING vec2 vary_frag; - -uniform vec2 screen_res; -uniform sampler2D sh_input_r; -uniform sampler2D sh_input_g; -uniform sampler2D sh_input_b; - -void main() -{ - vec2 offset = vec2(2.0) / screen_res; - - vec4 r = vec4(0); - vec4 g = vec4(0); - vec4 b = vec4(0); - - vec2 tc = vary_frag * 2.0; - - r += texture2D(sh_input_r, tc + vec2(0, 0)); - r += texture2D(sh_input_r, tc + vec2(offset.x, 0)); - r += texture2D(sh_input_r, tc + vec2(0, offset.y)); - r += texture2D(sh_input_r, tc + vec2(offset.x, offset.y)); - r /= 4.0f; - - g += texture2D(sh_input_g, tc + vec2(0, 0)); - g += texture2D(sh_input_g, tc + vec2(offset.x, 0)); - g += texture2D(sh_input_g, tc + vec2(0, offset.y)); - g += texture2D(sh_input_g, tc + vec2(offset.x, offset.y)); - g /= 4.0f; - - b += texture2D(sh_input_b, tc + vec2(0, 0)); - b += texture2D(sh_input_b, tc + vec2(offset.x, 0)); - b += texture2D(sh_input_b, tc + vec2(0, offset.y)); - b += texture2D(sh_input_b, tc + vec2(offset.x, offset.y)); - b /= 4.0f; - - frag_data[0] = r; - frag_data[1] = g; - frag_data[2] = b; -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShV.glsl b/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShV.glsl deleted file mode 100644 index 337c8a50fe..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/gatherSkyShV.glsl +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file gatherSkyShV.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; - -VARYING vec2 vary_frag; -uniform vec2 screen_res; - -void main() -{ - // pass through untransformed fullscreen pos - float oo_divisor = screen_res.x / 64.0; - vec3 pos = (position.xyz * oo_divisor) + vec3(oo_divisor - 1, oo_divisor - 1, 0); - gl_Position = vec4(pos.xyz, 1.0); - vary_frag = texcoord0 * oo_divisor; -} - diff --git a/indra/newview/app_settings/shaders/class3/deferred/genSkyShF.glsl b/indra/newview/app_settings/shaders/class3/deferred/genSkyShF.glsl deleted file mode 100644 index d5d91c88f0..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/genSkyShF.glsl +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @file class3/deferred/genSkyShF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif - -VARYING vec2 vary_frag; - -uniform vec3 sun_dir; - -uniform sampler2D transmittance_texture; -uniform sampler3D scattering_texture; -uniform sampler3D single_mie_scattering_texture; -uniform sampler2D irradiance_texture; - -vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance); - -vec3 calcDirection(vec2 tc) -{ - float phi = tc.y * 2.0 * 3.14159265; - float cosTheta = sqrt(1.0 - tc.x); - float sinTheta = sqrt(1.0 - cosTheta * cosTheta); - return vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta); -} - -// reverse mapping above to convert a hemisphere direction into phi/theta values -void getPhiAndThetaFromDirection(vec3 dir, out float phi, out float theta) -{ - float sin_theta; - float cos_theta; - cos_theta = dir.z; - theta = acos(cos_theta); - sin_theta = sin(theta); - phi = abs(sin_theta) > 0.0001 ? acos(dir.x / sin_theta) : 1.0; -} - -// reverse mapping above to convert a hemisphere direction into an SH texture sample pos -vec2 calcShUvFromDirection(vec3 dir) -{ - vec2 uv; - float phi; - float theta; - getPhiAndThetaFromDirection(dir, phi, theta); - uv.y = phi / 2.0 * 3.14159265; - uv.x = theta / 2.0 * 3.14159265; - return uv; -} - -void projectToL1(vec3 n, vec3 c, vec4 basis, out vec4 coeffs[3]) -{ - coeffs[0] = vec4(basis.x, n * basis.yzw * c.r); - coeffs[1] = vec4(basis.x, n * basis.yzw * c.g); - coeffs[2] = vec4(basis.x, n * basis.yzw * c.b); -} - -void main() -{ - float Y00 = sqrt(1.0 / 3.14159265) * 0.5; - float Y1x = sqrt(3.0 / 3.14159265) * 0.5; - float Y1y = Y1x; - float Y1z = Y1x; - - vec4 L1 = vec4(Y00, Y1x, Y1y, Y1z); - - vec3 view_direction = calcDirection(vary_frag); - vec3 sun_direction = normalize(sun_dir); - vec3 cam_pos = vec3(0, 0, 6360); - - vec3 transmittance; - vec3 radiance = GetSkyLuminance(cam_pos, view_direction, 0.0f, sun_direction, transmittance); - - vec3 color = vec3(1.0) - exp(-radiance * 0.0001); - - color = pow(color, vec3(1.0/2.2)); - - vec4 coeffs[3]; - coeffs[0] = vec4(0); - coeffs[1] = vec4(0); - coeffs[2] = vec4(0); - - projectToL1(view_direction, color.rgb, L1, coeffs); - - frag_data[0] = coeffs[0]; - frag_data[1] = coeffs[1]; - frag_data[2] = coeffs[2]; -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/genSkyShV.glsl b/indra/newview/app_settings/shaders/class3/deferred/genSkyShV.glsl deleted file mode 100644 index b466883dc7..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/genSkyShV.glsl +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file genSkyShV.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -ATTRIBUTE vec3 position; -ATTRIBUTE vec2 texcoord0; - -VARYING vec2 vary_frag; - -void main() -{ - // pass through untransformed fullscreen pos - gl_Position = vec4(position.xyz, 1.0); - vary_frag = texcoord0; -} - diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointShadowBlurF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointShadowBlurF.glsl deleted file mode 100644 index ca9ce3a2e1..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/pointShadowBlurF.glsl +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file pointShadowBlur.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform samplerCube cube_map; - -in vec3 to_vec; - -out vec4 fragColor; - -void main() -{ - vec4 vcol = texture(cube_map, to_vec); - fragColor = vec4(vcol.rgb, 1.0); -} - diff --git a/indra/newview/app_settings/shaders/class3/deferred/shVisF.glsl b/indra/newview/app_settings/shaders/class3/deferred/shVisF.glsl deleted file mode 100644 index c8991f7a18..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/shVisF.glsl +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file class3/deferred/shVisF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR - out vec4 frag_color; -#else - #define frag_color gl_FragColor -#endif - -///////////////////////////////////////////////////////////////////////// -// Fragment shader for L1 SH debug rendering -///////////////////////////////////////////////////////////////////////// - -uniform sampler2D sh_input_r; -uniform sampler2D sh_input_g; -uniform sampler2D sh_input_b; - -uniform mat3 inv_modelviewprojection; - -VARYING vec4 vary_pos; - -void main(void) -{ - vec2 coord = vary_pos.xy + vec2(0.5,0.5); - - coord.x *= (1.6/0.9); - - if (dot(coord, coord) > 0.25) - { - discard; - } - - vec4 n = vec4(coord*2.0, 0.0, 1); - //n.y = -n.y; - n.z = sqrt(max(1.0-n.x*n.x-n.y*n.y, 0.0)); - //n.xyz = inv_modelviewprojection * n.xyz; - - vec4 l1tap = vec4(1.0/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265), sqrt(3)/sqrt(4*3.14159265)); - vec4 l1r = texture2D(sh_input_r, vec2(0,0)); - vec4 l1g = texture2D(sh_input_g, vec2(0,0)); - vec4 l1b = texture2D(sh_input_b, vec2(0,0)); - vec3 indirect = vec3( - dot(l1r, l1tap * n), - dot(l1g, l1tap * n), - dot(l1b, l1tap * n)); - - //indirect = pow(indirect, vec3(0.45)); - indirect *= 3.0; - - frag_color = vec4(indirect, 1.0); -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shVisV.glsl b/indra/newview/app_settings/shaders/class3/deferred/shVisV.glsl deleted file mode 100644 index 8f32dfde79..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/shVisV.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file class3/deferred/shVisV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ -ATTRIBUTE vec3 position; -VARYING vec4 vary_pos; - -void main() -{ - // Output - vary_pos = vec4(position, 1); - gl_Position = vary_pos; -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendF.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendF.glsl deleted file mode 100644 index 345c07a354..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendF.glsl +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file shadowAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/*[EXTRA_CODE_HERE]*/ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING float pos_w; - -VARYING float target_pos_x; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; -VARYING vec3 pos; - -vec4 computeMoments(float depth, float a); - -void main() -{ - float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a; - - frag_color = computeMoments(length(pos), float a); - -#if !defined(DEPTH_CLAMP) - gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0); -#endif -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendV.glsl b/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendV.glsl deleted file mode 100644 index af1461c297..0000000000 --- a/indra/newview/app_settings/shaders/class3/deferred/shadowAlphaBlendV.glsl +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file shadowAlphaMaskV.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_projection_matrix; -uniform float shadow_target_width; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING float target_pos_x; -VARYING vec4 pos; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void passTextureIndex(); - -void main() -{ - //transform vertex - vec4 pre_pos = vec4(position.xyz, 1.0); - vec4 pos = modelview_projection_matrix * pre_pos; - target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; - - pos_w = pos.w; - -#if !defined(DEPTH_CLAMP) - pos_zd2 = pos.z * 0.5; - - gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -#else - gl_Position = pos; -#endif - - passTextureIndex(); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - vertex_color = diffuse_color; -} diff --git a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl deleted file mode 100644 index c6ea3ec9d4..0000000000 --- a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file class3\wl\advancedAtmoF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -in vec3 view_dir; - -uniform vec3 cameraPosLocal; -uniform vec3 sun_dir; -uniform float sun_size; - -uniform sampler2D transmittance_texture; -uniform sampler3D scattering_texture; -uniform sampler3D mie_scattering_texture; -uniform sampler2D irradiance_texture; - -vec3 GetSolarLuminance(); -vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 sun_dir, out vec3 transmittance); -vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 sun_dir, out vec3 transmittance); -vec3 GetSunAndSkyIlluminance(vec3 pos, vec3 norm, vec3 sun_dir, out vec3 sky_irradiance); - -void main() -{ - vec3 view_direction = normalize(view_dir); - - vec3 camPos = cameraPosLocal; - vec3 transmittance; - vec3 sky_illum; - vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_dir, transmittance); - vec3 radiance2 = GetSunAndSkyIlluminance(camPos, view_direction, sun_dir, sky_illum); - - //radiance *= transmittance; - - // If the view ray intersects the Sun, add the Sun radiance. - if (dot(view_direction, sun_dir) >= sun_size) - { - radiance = radiance + transmittance * GetSolarLuminance(); - } - - //vec3 color = vec3(1.0) - exp(-radiance); - //color = pow(color, vec3(1.0 / 2.2)); - - frag_color.rgb = radiance; - - frag_color.a = 1.0; -} - diff --git a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoV.glsl b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoV.glsl deleted file mode 100644 index 65bb00b1f6..0000000000 --- a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoV.glsl +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file class3\wl\advancedAtmoV.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; - -// Inputs -uniform vec3 camPosLocal; - -out vec3 view_dir; - -void main() -{ - // World / view / projection - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - - // this will be normalized in the frag shader... - view_dir = position.xyz - camPosLocal.xyz; -} - -- cgit v1.2.3 From ebadc409de90c75f96a005e8f45a3eee4ad243e0 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Mon, 29 Mar 2021 16:00:19 -0600 Subject: SL-14895, restore previous post-deferred alpha behavior --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 14 +++++++++++--- .../app_settings/shaders/class1/deferred/materialF.glsl | 12 ++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index dc484317e9..d3a05c34c0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -86,6 +86,14 @@ float getAmbientClamp(); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { + // SL-14895 inverted attenuation work-around + // This routine is tweaked to match deferred lighting, but previously used an inverted la value. To reconstruct + // that previous value now that the inversion is corrected, we reverse the calculations in LLPipeline::setupHWLights() + // to recover the `adjusted_radius` value previously being sent as la. + float falloff_factor = (12.0 * fa) - 9.0; + float inverted_la = falloff_factor / la; + // Yes, it makes me want to cry as well. DJH + vec3 col = vec3(0); //get light vector @@ -95,7 +103,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float dist = length(lv); float da = 1.0; - /*if (dist > la) + /*if (dist > inverted_la) { return col; } @@ -113,9 +121,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec return col; }*/ - if (dist > 0.0 && la > 0.0) + if (dist > 0.0 && inverted_la > 0.0) { - dist /= la; + dist /= inverted_la; //normalize light vector lv = normalize(lv); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index e1f7031af6..02d83925ea 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -91,6 +91,14 @@ float getAmbientClamp(); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance) { + // SL-14895 inverted attenuation work-around + // This routine is tweaked to match deferred lighting, but previously used an inverted la value. To reconstruct + // that previous value now that the inversion is corrected, we reverse the calculations in LLPipeline::setupHWLights() + // to recover the `adjusted_radius` value previously being sent as la. + float falloff_factor = (12.0 * fa) - 9.0; + float inverted_la = falloff_factor / la; + // Yes, it makes me want to cry as well. DJH + vec3 col = vec3(0); //get light vector @@ -100,9 +108,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe float dist = length(lv); float da = 1.0; - dist /= la; + dist /= inverted_la; - if (dist > 0.0 && la > 0.0) + if (dist > 0.0 && inverted_la > 0.0) { //normalize light vector lv = normalize(lv); -- cgit v1.2.3 From 907140d248c4a45e61cb499f0cd2a38bff6f42d4 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 12 Apr 2021 16:04:10 -0700 Subject: SL-15110 Fix stars appearing in a different location in the night sky when ALM is turned on --- indra/newview/lldrawpoolwlsky.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 0c3d8f3098..c66aa905f5 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -340,6 +340,7 @@ void LLDrawPoolWLSky::renderStarsDeferred(const LLVector3& camPosLocal) const gGL.pushMatrix(); gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); + gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); gDeferredStarProgram.uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); if (LLPipeline::sReflectionRender) -- cgit v1.2.3 From 01e5caade3d85eb618c1d7f16eb2e3972d1f65f9 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 12 Apr 2021 16:58:18 -0700 Subject: SL-14113 Fix moon haze --- .../shaders/class1/deferred/cloudsF.glsl | 2 +- .../shaders/class1/deferred/moonF.glsl | 6 +++ .../shaders/class1/deferred/starsF.glsl | 7 ++- .../shaders/class1/environment/moonF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/moonV.glsl | 38 ++++++++++++++++ .../shaders/class1/environment/starsF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/starsV.glsl | 41 +++++++++++++++++ .../shaders/class1/windlight/moonF.glsl | 7 +++ .../shaders/class2/windlight/cloudsF.glsl | 6 +++ indra/newview/lldrawpoolsky.cpp | 19 ++++++++ indra/newview/lldrawpoolwlsky.cpp | 13 +++--- indra/newview/llviewershadermgr.cpp | 33 +++++++++++++- indra/newview/llviewershadermgr.h | 2 + 13 files changed, 267 insertions(+), 9 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsV.glsl diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index ae1ac5de7f..187fed72e1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999985; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 35068899ee..5906194437 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -55,6 +55,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = srgb_to_linear(c.rgb); c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index bac79a9fdc..50f10ad0fa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -46,8 +46,13 @@ float twinkle(){ return abs(d); } +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl void main() { + // camera above water: class1\deferred\starsF.glsl + // camera below water: starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); @@ -62,6 +67,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl new file mode 100644 index 0000000000..e1592c19fb --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/moonF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D tex0; + +VARYING vec2 vary_texcoord0; + +// See: +// AS off: class1/environment/moonF.glsl +// ALM off: class1/windlight/moonF.glsl +// ALM on : class1/deferred/moonF.glsl +void main() +{ + vec4 color = texture2D(tex0, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (color.a <= 2./255.) // 0.00784 + discard; + + frag_color = color; + gl_FragDepth = 0.999985f; // SL-14113 Moon is infront of stars +} diff --git a/indra/newview/app_settings/shaders/class1/environment/moonV.glsl b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl new file mode 100644 index 0000000000..1fc421a295 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl @@ -0,0 +1,38 @@ +/** + * @file class1\environment\moonV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position, 1); + vary_texcoord0 = texcoord0; +} + diff --git a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl new file mode 100644 index 0000000000..95ab4cbf8b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/starsF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +uniform float custom_alpha; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl +void main() +{ + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); + color.rgb = pow(color.rgb, vec3(0.45)); + color.rgb *= vertex_color.rgb; + color.a *= max(custom_alpha, vertex_color.a); + + frag_color = color; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon +} diff --git a/indra/newview/app_settings/shaders/class1/environment/starsV.glsl b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl new file mode 100644 index 0000000000..6fcfec6b6a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl @@ -0,0 +1,41 @@ +/** + * @file class1/environment/starsV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vary_texcoord0 = texcoord0; + vertex_color = diffuse_color; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 2425a2ad04..327accbd3b 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -52,6 +52,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = pow(c.rgb, vec3(0.7f)); // can't use "srgb_to_linear(color.rgb)" as that is a deferred only function c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; @@ -62,5 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); + gl_FragDepth = 0.999985f; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index fa928d993e..d89cc69d71 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -127,5 +127,11 @@ void main() /// Gamma correct for WL (soft clip effect). frag_color = vec4(color.rgb, alpha1); + + // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon + // camera above water: class1\defered\cloudsF.glsl + // camera below water: class2\windlight\coudsV.glsl + // See: starsV.glsl, cloudsV.glsl, moonF.glsl + gl_FragDepth = 0.999985; } diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index b6f55e800a..96b4a91b0f 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -130,13 +130,32 @@ void LLDrawPoolSky::renderSkyFace(U8 index) face->renderIndexed(); } + else // Moon + if (index == LLVOSky::FACE_MOON) + { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, true); // SL-14113 Write depth for moon so stars can test if behind it + + LLGLEnable blend(GL_BLEND); + + // if (LLGLSLShader::sNoFixedFunction) // TODO: Necessary? is this always true? We already bailed on gPipeline.canUseWindLightShaders ... above + LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); + if (tex) + { + gMoonProgram.bind(); // SL-14113 was gOneTextureNoColorProgram + gGL.getTexUnit(0)->bind(tex, true); + face->renderIndexed(); + } + } else // heavenly body faces, no interp... { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); // reset to previous + LLGLEnable blend(GL_BLEND); LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); if (tex) { + gOneTextureNoColorProgram.bind(); gGL.getTexUnit(0)->bind(tex, true); face->renderIndexed(); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 0c3d8f3098..f788a20e3c 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -270,8 +270,8 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.bind(); - gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); + gStarsProgram.bind(); + gStarsProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); } else { @@ -288,7 +288,7 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.unbind(); + gStarsProgram.unbind(); // SL-14113 was gCustomAlphaProgram } else { @@ -476,7 +476,8 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh void LLDrawPoolWLSky::renderHeavenlyBodies() { - LLGLSPipelineBlendSkyBox gls_skybox(true, false); + //LLGLSPipelineBlendSkyBox gls_skybox(true, false); + LLGLSPipelineBlendSkyBox gls_skybox(true, true); // SL-14113 we need moon to write to depth to clip stars behind LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); gGL.pushMatrix(); @@ -606,8 +607,8 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { renderSkyHazeDeferred(origin, camHeightLocal); - renderStarsDeferred(origin); renderHeavenlyBodies(); + renderStarsDeferred(origin); renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); } gGL.setColorMask(true, true); @@ -625,8 +626,8 @@ void LLDrawPoolWLSky::render(S32 pass) LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); renderSkyHaze(origin, camHeightLocal); + renderHeavenlyBodies(); renderStars(origin); - renderHeavenlyBodies(); renderSkyClouds(origin, camHeightLocal, cloud_shader); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index be5c22e7c3..8eb57799c9 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -78,7 +78,7 @@ LLGLSLShader gTransformTangentProgram; //utility shaders LLGLSLShader gOcclusionProgram; LLGLSLShader gOcclusionCubeProgram; -LLGLSLShader gCustomAlphaProgram; +LLGLSLShader gCustomAlphaProgram; // SL-14113 This used to be used for the stars with Atmospheric Shaders: OFF LLGLSLShader gGlowCombineProgram; LLGLSLShader gSplatTextureRectProgram; LLGLSLShader gGlowCombineFXAAProgram; @@ -148,6 +148,8 @@ LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +LLGLSLShader gMoonProgram; +LLGLSLShader gStarsProgram; LLGLSLShader gTerrainProgram; LLGLSLShader gTerrainWaterProgram; LLGLSLShader gWaterProgram; @@ -819,6 +821,9 @@ void LLViewerShaderMgr::unloadShaders() gWaterProgram.unload(); gWaterEdgeProgram.unload(); gUnderWaterProgram.unload(); + + gMoonProgram.unload(); + gStarsProgram.unload(); gTerrainProgram.unload(); gTerrainWaterProgram.unload(); gGlowProgram.unload(); @@ -1051,6 +1056,32 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() llassert(success); } + if (success) + { + gStarsProgram.mName = "Environment Stars Shader"; + gStarsProgram.mShaderFiles.clear(); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB)); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gStarsProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gMoonProgram.mName = "Environment Moon Shader"; + gMoonProgram.mShaderFiles.clear(); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); + gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gMoonProgram.createShader(NULL, NULL); + if (success) + { + gMoonProgram.bind(); + gMoonProgram.uniform1i(sTex0, 0); + } + } + if (!success) { mShaderLevel[SHADER_ENVIRONMENT] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 081221f15b..5122558a01 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -234,6 +234,8 @@ extern LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; extern LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +extern LLGLSLShader gMoonProgram; +extern LLGLSLShader gStarsProgram; extern LLGLSLShader gTerrainProgram; extern LLGLSLShader gTerrainWaterProgram; extern LLGLSLShader gWaterProgram; -- cgit v1.2.3 From d3cf486ea9eb5b3e7b51141a364a088dbba5054a Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 10:54:02 -0700 Subject: SL-14113 Cleanup typo and cross reference --- indra/newview/app_settings/shaders/class1/deferred/starsF.glsl | 2 +- indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 50f10ad0fa..b028c40ed9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -52,7 +52,7 @@ float twinkle(){ void main() { // camera above water: class1\deferred\starsF.glsl - // camera below water: starsF.glsl + // camera below water: class1\environment\starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index d89cc69d71..1c592402d4 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -129,7 +129,7 @@ void main() frag_color = vec4(color.rgb, alpha1); // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon - // camera above water: class1\defered\cloudsF.glsl + // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl gl_FragDepth = 0.999985; -- cgit v1.2.3 From 41473f7c506d8b9bb719d11ecac13c2ac516ef60 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:35:36 -0700 Subject: SL-14113 Cleanup face magic number --- indra/newview/lldrawpoolsky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 96b4a91b0f..77b8a1fc32 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -123,7 +123,7 @@ void LLDrawPoolSky::renderSkyFace(U8 index) return; } - if (index < 6) // sky tex...interp + if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); mSkyTex[index].bindTexture(true); // bind the current tex -- cgit v1.2.3 From 9ff19f4d50ed163c4b0ad4255ca618f27f98a3a3 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:36:33 -0700 Subject: SL-14113 Cleanup indentation --- indra/newview/lldrawpoolsky.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 77b8a1fc32..178564b0d4 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -116,17 +116,17 @@ void LLDrawPoolSky::render(S32 pass) void LLDrawPoolSky::renderSkyFace(U8 index) { - LLFace* face = mDrawFace[index]; + LLFace* face = mDrawFace[index]; - if (!face || !face->getGeomCount()) - { - return; - } + if (!face || !face->getGeomCount()) + { + return; + } if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); - mSkyTex[index].bindTexture(true); // bind the current tex + mSkyTex[index].bindTexture(true); // bind the current tex face->renderIndexed(); } -- cgit v1.2.3 From 4dd6b6b2bea93cd37d908f597482a42e80d3e8bb Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 13:12:44 -0700 Subject: SL-14885 Allow mousewheel to zoom way out when user has disabled camera constraints --- indra/newview/llagentcamera.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index ed6c3c307f..86d2b0fc6c 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2038,6 +2038,12 @@ LLVector3d LLAgentCamera::getFocusOffsetInitial() F32 LLAgentCamera::getCameraMaxZoomDistance() { + // SL-14706 / SL-14885 TPV have relaxed camera constraints allowing you to mousewheeel zoom WAY out. + if (gSavedSettings.getBOOL("DisableCameraConstraints")) + { + return (F32)INT_MAX; + } + // Ignore "DisableCameraConstraints", we don't want to be out of draw range when we focus onto objects or avatars return llmin(MAX_CAMERA_DISTANCE_FROM_OBJECT, mDrawDistance - 1, // convenience, don't hit draw limit when focusing on something -- cgit v1.2.3 From 8da31e0580338d7c0b2194731a03e387674055f0 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 15 Apr 2021 09:46:31 -0600 Subject: DRTVWR-528 clean up cmake recursive CXX_FLAGS definition (/Zo) --- indra/cmake/00-Common.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 8aea50e02b..7c9e07b099 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -42,8 +42,8 @@ if(NON_RELEASE_CRASH_REPORTING) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLL_SEND_CRASH_REPORTS=1") endif() -# Don't bother with a MinSizeRel build. -set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release;Debug" CACHE STRING +# Don't bother with MinSizeRel or Debug builds. +set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release" CACHE STRING "Supported build types." FORCE) @@ -70,13 +70,18 @@ if (WINDOWS) if( ADDRESS_SIZE EQUAL 32 ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /p:PreferredToolArchitecture=x64") endif() + + # Preserve first-pass-through versions (ie no FORCE overwrite). Prevents recursive addition of /Zo (04/2021) + set(OG_CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} CACHE STRING "OG_CXX_FLAGS_RELEASE") + set(OG_CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} CACHE STRING "OG_CXX_FLAGS_RELWITHDEBINFO") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO - "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Zo" + "${OG_CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Zo" CACHE STRING "C++ compiler release-with-debug options" FORCE) set(CMAKE_CXX_FLAGS_RELEASE - "${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /Zo" + "${OG_CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /Zo" CACHE STRING "C++ compiler release options" FORCE) + # zlib has assembly-language object files incompatible with SAFESEH set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE /SAFESEH:NO /NODEFAULTLIB:LIBCMT /IGNORE:4099") -- cgit v1.2.3 From 029f179719907d674f89e39577c37e82e654b59d Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 20 Apr 2021 10:49:33 -0600 Subject: DRTVWR-528 remove wrapper code for RAD telemetry library --- indra/newview/CMakeLists.txt | 1 - indra/newview/llappviewer.cpp | 3 - indra/newview/llstartup.cpp | 3 - indra/newview/lltelemetry.cpp | 145 ------------------------------------------ indra/newview/lltelemetry.h | 81 ----------------------- 5 files changed, 233 deletions(-) delete mode 100644 indra/newview/lltelemetry.cpp delete mode 100644 indra/newview/lltelemetry.h diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9405471f4b..87ee77a117 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -585,7 +585,6 @@ set(viewer_SOURCE_FILES llsyntaxid.cpp llsyswellitem.cpp llsyswellwindow.cpp - lltelemetry.cpp llteleporthistory.cpp llteleporthistorystorage.cpp lltextureatlas.cpp diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 06d513ad70..5de4871c65 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -90,7 +90,6 @@ #include "llsdutil_math.h" #include "lllocationhistory.h" #include "llfasttimerview.h" -#include "lltelemetry.h" #include "llvector4a.h" #include "llviewermenufile.h" #include "llvoicechannel.h" @@ -1627,8 +1626,6 @@ bool LLAppViewer::doFrame() LL_INFOS() << "Exiting main_loop" << LL_ENDL; } - LLPROFILE_UPDATE(); - return ! LLApp::isRunning(); } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 929e8c3dae..e2a39bdf86 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -176,7 +176,6 @@ #include "pipeline.h" #include "llappviewer.h" #include "llfasttimerview.h" -#include "lltelemetry.h" #include "llfloatermap.h" #include "llweb.h" #include "llvoiceclient.h" @@ -528,8 +527,6 @@ bool idle_startup() } #if LL_WINDOWS - LLPROFILE_STARTUP(); - // On the windows dev builds, unpackaged, the message.xml file will // be located in indra/build-vc**/newview//app_settings. std::string message_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"message.xml"); diff --git a/indra/newview/lltelemetry.cpp b/indra/newview/lltelemetry.cpp deleted file mode 100644 index 0c63e2fede..0000000000 --- a/indra/newview/lltelemetry.cpp +++ /dev/null @@ -1,145 +0,0 @@ - /** - * @file lltelemetry.cpp - * @brief Wrapper for Rad Game Tools Telemetry - * - * $LicenseInfo:firstyear=2020&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2020, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "lltelemetry.h" - -#if LLPROFILE_USE_RAD_TELEMETRY_PROFILER - #if LL_WINDOWS - #include "llwin32headers.h" - - // build-vc120-64\packages\lib\release - // build-vc150-64\packages\lib\release - #ifdef _MSC_VER - #pragma comment(lib,"rad_tm_win64.lib") - #else - #pragma message "NOTE: Rad GameTools Telemetry requested but non-MSVC compiler not yet supported on Windows" - #endif - #endif // LL_WINDOWS - - #if LL_DARWIN - #pragma message "NOTE: Rad Game Tools Telemetry requested but not yet supported on Darwin" - #endif - - #if LL_LINUX - #pragma message "NOTE: Rad Game Tools Telemetry requested but not yet supported on Linux" - #endif - -// -// local consts -// -static const tm_int32 TELEMETRY_BUFFER_SIZE = 8 * 1024 * 1024; - -// -// local globals -// -static char *gTelemetryBufferPtr = NULL; // Telemetry - -static const char *tm_status[ TMERR_INIT_NETWORKING_FAILED + 1 ] = -{ - "Telemetry pass: connected" // TM_OK - , "Telemetry FAIL: disabled via #define NTELEMETRY" // TMERR_DISABLED - , "Telemetry FAIL: invalid paramater" // TMERR_INVALID_PARAM - , "Telemetry FAIL: DLL not found" // TMERR_NULL_API - , "Telemetry FAIL: out of resources" // TMERR_OUT_OF_RESOURCES - , "Telemetry FAIL: tmInitialize() not called" // TMERR_UNINITIALIZED - , "Telemetry FAIL: bad hostname" // TMERR_BAD_HOSTNAME - , "Telemetry FAIL: couldn't connect to server" // TMERR_COULD_NOT_CONNECT - , "Telemetry FAIL: unknown network error" // TMERR_UNKNOWN_NETWORK - , "Telemetry FAIL: tmShutdown() already called" // TMERR_ALREADY_SHUTDOWN - , "Telemetry FAIL: memory buffer too small" // TMERR_ARENA_TOO_SMALL - , "Telemetry FAIL: server handshake error" // TMERR_BAD_HANDSHAKE - , "Telemetry FAIL: unaligned parameters" // TMERR_UNALIGNED - , "Telemetry FAIL: network not initialized" // TMERR_NETWORK_NOT_INITIALIZED -- WSAStartup not called before tmOpen() - , "Telemetry FAIL: bad version" // TMERR_BAD_VERSION - , "Telemetry FAIL: timer too large" // TMERR_BAD_TIMER - , "Telemetry FAIL: tmOpen() already called" // TMERR_ALREADY_OPENED - , "Telemetry FAIL: tmInitialize() already called" // TMERR_ALREADY_INITIALIZED - , "Telemetry FAIL: could't open file" // TMERR_FILE_OPEN_FAILED - , "Telemetry FAIL: tmOpen() failed networking" // TMERR_INIT_NETWORKING_FAILED -}; - -// -// exported functionality -// - -void telemetry_shutdown() -{ - #if LL_WINDOWS - if (gTelemetryBufferPtr) - { - tmClose(0); - tmShutdown(); - - delete[] gTelemetryBufferPtr; - gTelemetryBufferPtr = NULL; - } - #endif -} - -void telemetry_startup() -{ - #if LL_WINDOWS - tmLoadLibrary(TM_RELEASE); // Loads .dll - - gTelemetryBufferPtr = new char[ TELEMETRY_BUFFER_SIZE ]; - tmInitialize(TELEMETRY_BUFFER_SIZE, gTelemetryBufferPtr); - - tm_error telemetry_status = tmOpen( - 0, // unused - "SecondLife", // app name - __DATE__ " " __TIME__, // build identifier - "localhost", // server name (or filename) - TMCT_TCP, // connection type (or TMCT_FILE) - 4719, // port - TMOF_INIT_NETWORKING, // open flags - 250 ); // timeout ms - - if (telemetry_status == TMERR_UNKNOWN) - { - LL_ERRS() << "Telemetry FAIL: unknown error" << LL_ENDL; - } - else if (telemetry_status && (telemetry_status <= TMERR_INIT_NETWORKING_FAILED)) - { - LL_INFOS() << tm_status[ telemetry_status ] << LL_ENDL; - free(gTelemetryBufferPtr); - gTelemetryBufferPtr = NULL; - } - #endif // LL_WINDOWS -} - -// Called after we render a frame -void telemetry_update() -{ - #if LL_WINDOWS - if (gTelemetryBufferPtr) - { - tmTick(0); - } - #endif -} -#endif // LLPROFILE_USE_RAD_TELEMETRY_PROFILER diff --git a/indra/newview/lltelemetry.h b/indra/newview/lltelemetry.h deleted file mode 100644 index a73e5fcfa2..0000000000 --- a/indra/newview/lltelemetry.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file lltelemetry.h - * @brief Wrapper for Rad Game Tools Telemetry - * - * $LicenseInfo:firstyear=2020&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2020, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/* -To use: - -1. Uncomment #define LLPROFILE_USE_RAD_TELEMETRY_PROFILER below - -2. Include this header file - #include "lltelemetry.h" - -3. Add zones to the functions you wish to profile - void onFoo() - { - LLPROFILE_ZONE("Foo"); - } -*/ -//#define LLPROFILE_USE_RAD_TELEMETRY_PROFILER 1 - -// Default NO local telemetry profiling -#ifndef LLPROFILE_USE_RAD_TELEMETRY_PROFILER - #define LLPROFILE_USE_RAD_TELEMETRY_PROFILER 0 - #define LLPROFILE_SHUTDOWN( ...) {} - #define LLPROFILE_STARTUP( ...) {} - #define LLPROFILE_UPDATE( ...) {} - - #define LLPROFILE_AUTO_CPU_MARKER_COLOR(r, g, b) - #define LLPROFILE_ENTER(name) - #define LLPROFILE_ENTER_FORMAT(format, ...) - #define LLPROFILE_FUNCTION - #define LLPROFILE_LEAVE() - #define LLPROFILE_THREAD_NAME(name) - #define LLPROFILE_ZONE(name) - #define LLPROFILE_ZONE_FORMAT(format, ...) -#else - #include - - #define LLPROFILE_SHUTDOWN telemetry_shutdown - #define LLPROFILE_STARTUP telemetry_startup - #define LLPROFILE_UPDATE telemetry_update - - #define LLPROFILE_AUTO_CPU_MARKER_COLOR(r, g, b) tmZoneColor(r, g, b) - #define LLPROFILE_ENTER(name) tmEnter(0, 0, name) - #define LLPROFILE_ENTER_FORMAT(format, ...) tmEnter(0, 0, format, __VA_ARGS__) - #define LLPROFILE_FUNCTION tmFunction(0, 0) - #define LLPROFILE_LEAVE() tmLeave(0) - #define LLPROFILE_THREAD_NAME(name) tmThreadName(0, 0, name) - #define LLPROFILE_ZONE(name) tmZone(0, 0, name) - #define LLPROFILE_ZONE_FORMAT(format, ...) tmZone(0, 0, format, __VA_ARGS__) -#endif // LLPROFILE_USE_RAD_TELEMETRY_PROFILER - -// -// exported functionality -// - -extern void telemetry_startup(); -extern void telemetry_shutdown(); -extern void telemetry_update(); // called after every frame update -- cgit v1.2.3 From 70527ee66ca869184aba14db73e3ab3f1bd5e1c3 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 12 Apr 2021 16:58:18 -0700 Subject: SL-14113 Fix moon haze --- .../shaders/class1/deferred/cloudsF.glsl | 2 +- .../shaders/class1/deferred/moonF.glsl | 6 +++ .../shaders/class1/deferred/starsF.glsl | 7 ++- .../shaders/class1/environment/moonF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/moonV.glsl | 38 ++++++++++++++++ .../shaders/class1/environment/starsF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/starsV.glsl | 41 +++++++++++++++++ .../shaders/class1/windlight/moonF.glsl | 7 +++ .../shaders/class2/windlight/cloudsF.glsl | 6 +++ indra/newview/lldrawpoolsky.cpp | 19 ++++++++ indra/newview/lldrawpoolwlsky.cpp | 13 +++--- indra/newview/llviewershadermgr.cpp | 33 +++++++++++++- indra/newview/llviewershadermgr.h | 2 + 13 files changed, 267 insertions(+), 9 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsV.glsl diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index ae1ac5de7f..187fed72e1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999985; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 35068899ee..5906194437 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -55,6 +55,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = srgb_to_linear(c.rgb); c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index bac79a9fdc..50f10ad0fa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -46,8 +46,13 @@ float twinkle(){ return abs(d); } +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl void main() { + // camera above water: class1\deferred\starsF.glsl + // camera below water: starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); @@ -62,6 +67,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl new file mode 100644 index 0000000000..e1592c19fb --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/moonF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D tex0; + +VARYING vec2 vary_texcoord0; + +// See: +// AS off: class1/environment/moonF.glsl +// ALM off: class1/windlight/moonF.glsl +// ALM on : class1/deferred/moonF.glsl +void main() +{ + vec4 color = texture2D(tex0, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (color.a <= 2./255.) // 0.00784 + discard; + + frag_color = color; + gl_FragDepth = 0.999985f; // SL-14113 Moon is infront of stars +} diff --git a/indra/newview/app_settings/shaders/class1/environment/moonV.glsl b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl new file mode 100644 index 0000000000..1fc421a295 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl @@ -0,0 +1,38 @@ +/** + * @file class1\environment\moonV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position, 1); + vary_texcoord0 = texcoord0; +} + diff --git a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl new file mode 100644 index 0000000000..95ab4cbf8b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/starsF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +uniform float custom_alpha; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl +void main() +{ + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); + color.rgb = pow(color.rgb, vec3(0.45)); + color.rgb *= vertex_color.rgb; + color.a *= max(custom_alpha, vertex_color.a); + + frag_color = color; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon +} diff --git a/indra/newview/app_settings/shaders/class1/environment/starsV.glsl b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl new file mode 100644 index 0000000000..6fcfec6b6a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl @@ -0,0 +1,41 @@ +/** + * @file class1/environment/starsV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vary_texcoord0 = texcoord0; + vertex_color = diffuse_color; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 2425a2ad04..327accbd3b 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -52,6 +52,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = pow(c.rgb, vec3(0.7f)); // can't use "srgb_to_linear(color.rgb)" as that is a deferred only function c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; @@ -62,5 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); + gl_FragDepth = 0.999985f; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index fa928d993e..d89cc69d71 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -127,5 +127,11 @@ void main() /// Gamma correct for WL (soft clip effect). frag_color = vec4(color.rgb, alpha1); + + // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon + // camera above water: class1\defered\cloudsF.glsl + // camera below water: class2\windlight\coudsV.glsl + // See: starsV.glsl, cloudsV.glsl, moonF.glsl + gl_FragDepth = 0.999985; } diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index b6f55e800a..96b4a91b0f 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -130,13 +130,32 @@ void LLDrawPoolSky::renderSkyFace(U8 index) face->renderIndexed(); } + else // Moon + if (index == LLVOSky::FACE_MOON) + { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, true); // SL-14113 Write depth for moon so stars can test if behind it + + LLGLEnable blend(GL_BLEND); + + // if (LLGLSLShader::sNoFixedFunction) // TODO: Necessary? is this always true? We already bailed on gPipeline.canUseWindLightShaders ... above + LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); + if (tex) + { + gMoonProgram.bind(); // SL-14113 was gOneTextureNoColorProgram + gGL.getTexUnit(0)->bind(tex, true); + face->renderIndexed(); + } + } else // heavenly body faces, no interp... { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); // reset to previous + LLGLEnable blend(GL_BLEND); LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); if (tex) { + gOneTextureNoColorProgram.bind(); gGL.getTexUnit(0)->bind(tex, true); face->renderIndexed(); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index c66aa905f5..436ecabd83 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -270,8 +270,8 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.bind(); - gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); + gStarsProgram.bind(); + gStarsProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); } else { @@ -288,7 +288,7 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.unbind(); + gStarsProgram.unbind(); // SL-14113 was gCustomAlphaProgram } else { @@ -477,7 +477,8 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh void LLDrawPoolWLSky::renderHeavenlyBodies() { - LLGLSPipelineBlendSkyBox gls_skybox(true, false); + //LLGLSPipelineBlendSkyBox gls_skybox(true, false); + LLGLSPipelineBlendSkyBox gls_skybox(true, true); // SL-14113 we need moon to write to depth to clip stars behind LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); gGL.pushMatrix(); @@ -607,8 +608,8 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { renderSkyHazeDeferred(origin, camHeightLocal); - renderStarsDeferred(origin); renderHeavenlyBodies(); + renderStarsDeferred(origin); renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); } gGL.setColorMask(true, true); @@ -626,8 +627,8 @@ void LLDrawPoolWLSky::render(S32 pass) LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); renderSkyHaze(origin, camHeightLocal); + renderHeavenlyBodies(); renderStars(origin); - renderHeavenlyBodies(); renderSkyClouds(origin, camHeightLocal, cloud_shader); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index be5c22e7c3..8eb57799c9 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -78,7 +78,7 @@ LLGLSLShader gTransformTangentProgram; //utility shaders LLGLSLShader gOcclusionProgram; LLGLSLShader gOcclusionCubeProgram; -LLGLSLShader gCustomAlphaProgram; +LLGLSLShader gCustomAlphaProgram; // SL-14113 This used to be used for the stars with Atmospheric Shaders: OFF LLGLSLShader gGlowCombineProgram; LLGLSLShader gSplatTextureRectProgram; LLGLSLShader gGlowCombineFXAAProgram; @@ -148,6 +148,8 @@ LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +LLGLSLShader gMoonProgram; +LLGLSLShader gStarsProgram; LLGLSLShader gTerrainProgram; LLGLSLShader gTerrainWaterProgram; LLGLSLShader gWaterProgram; @@ -819,6 +821,9 @@ void LLViewerShaderMgr::unloadShaders() gWaterProgram.unload(); gWaterEdgeProgram.unload(); gUnderWaterProgram.unload(); + + gMoonProgram.unload(); + gStarsProgram.unload(); gTerrainProgram.unload(); gTerrainWaterProgram.unload(); gGlowProgram.unload(); @@ -1051,6 +1056,32 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() llassert(success); } + if (success) + { + gStarsProgram.mName = "Environment Stars Shader"; + gStarsProgram.mShaderFiles.clear(); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB)); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gStarsProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gMoonProgram.mName = "Environment Moon Shader"; + gMoonProgram.mShaderFiles.clear(); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); + gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gMoonProgram.createShader(NULL, NULL); + if (success) + { + gMoonProgram.bind(); + gMoonProgram.uniform1i(sTex0, 0); + } + } + if (!success) { mShaderLevel[SHADER_ENVIRONMENT] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 081221f15b..5122558a01 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -234,6 +234,8 @@ extern LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; extern LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +extern LLGLSLShader gMoonProgram; +extern LLGLSLShader gStarsProgram; extern LLGLSLShader gTerrainProgram; extern LLGLSLShader gTerrainWaterProgram; extern LLGLSLShader gWaterProgram; -- cgit v1.2.3 From bd9a6edbb53711e4a8ec2a178b4375db266844d3 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 10:54:02 -0700 Subject: SL-14113 Cleanup typo and cross reference --- indra/newview/app_settings/shaders/class1/deferred/starsF.glsl | 2 +- indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 50f10ad0fa..b028c40ed9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -52,7 +52,7 @@ float twinkle(){ void main() { // camera above water: class1\deferred\starsF.glsl - // camera below water: starsF.glsl + // camera below water: class1\environment\starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index d89cc69d71..1c592402d4 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -129,7 +129,7 @@ void main() frag_color = vec4(color.rgb, alpha1); // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon - // camera above water: class1\defered\cloudsF.glsl + // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl gl_FragDepth = 0.999985; -- cgit v1.2.3 From 63027bacf9b96202532a2dd47126ff8430723059 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:35:36 -0700 Subject: SL-14113 Cleanup face magic number --- indra/newview/lldrawpoolsky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 96b4a91b0f..77b8a1fc32 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -123,7 +123,7 @@ void LLDrawPoolSky::renderSkyFace(U8 index) return; } - if (index < 6) // sky tex...interp + if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); mSkyTex[index].bindTexture(true); // bind the current tex -- cgit v1.2.3 From 26f3c078363e3a8bd0ee284c7cd54e9f2b979e7b Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:36:33 -0700 Subject: SL-14113 Cleanup indentation --- indra/newview/lldrawpoolsky.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 77b8a1fc32..178564b0d4 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -116,17 +116,17 @@ void LLDrawPoolSky::render(S32 pass) void LLDrawPoolSky::renderSkyFace(U8 index) { - LLFace* face = mDrawFace[index]; + LLFace* face = mDrawFace[index]; - if (!face || !face->getGeomCount()) - { - return; - } + if (!face || !face->getGeomCount()) + { + return; + } if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); - mSkyTex[index].bindTexture(true); // bind the current tex + mSkyTex[index].bindTexture(true); // bind the current tex face->renderIndexed(); } -- cgit v1.2.3 From 7c3a511935a16e0e99b8a5a57edd69a9290465a2 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 08:41:50 -0700 Subject: SL-14113: Remove magic numbers. Take advantage of existing shader #defines injection by extending shader loading to make use of addConstant() instead of hard-coding magic number constants in each GLSL file. --- indra/llrender/llglslshader.cpp | 22 ++++++++++++++++++++++ indra/llrender/llglslshader.h | 12 +++++++++++- .../shaders/class1/deferred/cloudsF.glsl | 2 +- .../shaders/class1/deferred/moonF.glsl | 2 +- .../shaders/class1/deferred/starsF.glsl | 2 +- .../shaders/class1/environment/moonF.glsl | 2 +- .../shaders/class1/environment/starsF.glsl | 2 +- .../shaders/class1/windlight/moonF.glsl | 2 +- .../shaders/class2/windlight/cloudsF.glsl | 2 +- indra/newview/llviewershadermgr.cpp | 8 ++++++++ 10 files changed, 48 insertions(+), 8 deletions(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 74cfa60b27..458f83aabe 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -62,6 +62,23 @@ U32 LLGLSLShader::sTotalDrawCalls = 0; LLGLSLShader gUIProgram; LLGLSLShader gSolidColorProgram; +// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] = +{ + "LL_SHADER_CONST_CLOUD_DEPTH" + , "LL_SHADER_CONST_MOON_DEPTH" + , "LL_SHADER_CONST_STAR_DEPTH" +}; + +// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] = +{ + "0.999985" // SHADER_CONST_CLOUD_DEPTH // SL-14113 + , "0.999985" // SHADER_CONST_MOON_DEPTH // SL-14113 + , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 +}; + + BOOL shouldChange(const LLVector4& v1, const LLVector4& v2) { return v1 != v2; @@ -755,6 +772,11 @@ void LLGLSLShader::addPermutation(std::string name, std::string value) mDefines[name] = value; } +void LLGLSLShader::addConstant( const LLGLSLShader::eShaderConsts shader_const ) +{ + addPermutation( gShaderConstsKey[ shader_const ], gShaderConstsVal[ shader_const ] ); +} + void LLGLSLShader::removePermutation(std::string name) { mDefines[name].erase(); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 7cf6d3c941..35e796e961 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -67,6 +67,14 @@ public: class LLGLSLShader { public: + // NOTE:Keep gShaderConsts and LLGLSLShader::ShaderConsts_e in sync! + enum eShaderConsts + { + SHADER_CONST_CLOUD_DEPTH + , SHADER_CONST_MOON_DEPTH + , SHADER_CONST_STAR_DEPTH + , NUM_SHADER_CONSTS + }; enum { @@ -149,7 +157,9 @@ public: void clearPermutations(); void addPermutation(std::string name, std::string value); void removePermutation(std::string name); - + + void addConstant( const LLGLSLShader::eShaderConsts shader_const ); + //enable/disable texture channel for specified uniform //if given texture uniform is active in the shader, //the corresponding channel will be active upon return diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index 187fed72e1..ad8ab771b8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = 0.999985; // SL-14113 Stars and Clouds need same depth + gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 5906194437..ffeaf2b600 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -74,6 +74,6 @@ void main() frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0f); - gl_FragDepth = 0.999985f; + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index b028c40ed9..8d9c7e3507 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -67,6 +67,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon + gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl index e1592c19fb..983cd17979 100644 --- a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -47,5 +47,5 @@ void main() discard; frag_color = color; - gl_FragDepth = 0.999985f; // SL-14113 Moon is infront of stars + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 Moon is infront of stars } diff --git a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl index 95ab4cbf8b..e1a9cc6387 100644 --- a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl @@ -47,5 +47,5 @@ void main() color.a *= max(custom_alpha, vertex_color.a); frag_color = color; - gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon + gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 327accbd3b..293e09620f 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -68,6 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); - gl_FragDepth = 0.999985f; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index 1c592402d4..ec53ae75f9 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -132,6 +132,6 @@ void main() // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl - gl_FragDepth = 0.999985; + gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 8eb57799c9..1dcd9289ef 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1063,6 +1063,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB)); gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + gStarsProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113 success = gStarsProgram.createShader(NULL, NULL); llassert(success); } @@ -1074,8 +1075,10 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gMoonProgram.createShader(NULL, NULL); if (success) + { gMoonProgram.bind(); gMoonProgram.uniform1i(sTex0, 0); @@ -2750,6 +2753,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 success = gDeferredWLCloudProgram.createShader(NULL, NULL); llassert(success); } @@ -2789,6 +2793,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gDeferredWLMoonProgram.createShader(NULL, NULL); llassert(success); } @@ -2801,6 +2806,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredStarProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredStarProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113 success = gDeferredStarProgram.createShader(NULL, NULL); llassert(success); } @@ -4157,6 +4163,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 success = gWLCloudProgram.createShader(NULL, NULL); } @@ -4193,6 +4200,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gWLMoonProgram.createShader(NULL, NULL); } -- cgit v1.2.3 From 2908f99510ae91c7099b544693ae7628905d8244 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 10:27:09 -0700 Subject: SL-14113: Merge duplicate shader constant for clarity. --- indra/llrender/llglslshader.cpp | 12 +++++------- indra/llrender/llglslshader.h | 5 ++--- .../app_settings/shaders/class1/deferred/cloudsF.glsl | 2 +- .../newview/app_settings/shaders/class1/deferred/moonF.glsl | 2 +- .../app_settings/shaders/class1/environment/moonF.glsl | 2 +- .../newview/app_settings/shaders/class1/windlight/moonF.glsl | 2 +- .../app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- indra/newview/llviewershadermgr.cpp | 10 +++++----- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 458f83aabe..74c8b2e448 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -62,20 +62,18 @@ U32 LLGLSLShader::sTotalDrawCalls = 0; LLGLSLShader gUIProgram; LLGLSLShader gSolidColorProgram; -// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +// NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] = { - "LL_SHADER_CONST_CLOUD_DEPTH" - , "LL_SHADER_CONST_MOON_DEPTH" + "LL_SHADER_CONST_CLOUD_MOON_DEPTH" , "LL_SHADER_CONST_STAR_DEPTH" }; -// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +// NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] = { - "0.999985" // SHADER_CONST_CLOUD_DEPTH // SL-14113 - , "0.999985" // SHADER_CONST_MOON_DEPTH // SL-14113 - , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 + "0.999985" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 + , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 }; diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 35e796e961..e2d0031740 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -67,11 +67,10 @@ public: class LLGLSLShader { public: - // NOTE:Keep gShaderConsts and LLGLSLShader::ShaderConsts_e in sync! + // NOTE: Keep gShaderConsts and LLGLSLShader::ShaderConsts_e in sync! enum eShaderConsts { - SHADER_CONST_CLOUD_DEPTH - , SHADER_CONST_MOON_DEPTH + SHADER_CONST_CLOUD_MOON_DEPTH , SHADER_CONST_STAR_DEPTH , NUM_SHADER_CONSTS }; diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index ad8ab771b8..f1187fef9a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; // SL-14113 Stars and Clouds need same depth + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index ffeaf2b600..e709d73bfa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -74,6 +74,6 @@ void main() frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0f); - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl index 983cd17979..a220971f06 100644 --- a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -47,5 +47,5 @@ void main() discard; frag_color = color; - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 Moon is infront of stars + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Moon is infront of stars } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 293e09620f..2e0932343b 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -68,6 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index ec53ae75f9..490fde7cf6 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -132,6 +132,6 @@ void main() // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl - gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 32329dfde8..43e9a2333e 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1075,7 +1075,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; - gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gMoonProgram.createShader(NULL, NULL); if (success) { @@ -2752,7 +2752,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 + gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gDeferredWLCloudProgram.createShader(NULL, NULL); llassert(success); } @@ -2792,7 +2792,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gDeferredWLMoonProgram.createShader(NULL, NULL); llassert(success); } @@ -4162,7 +4162,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 + gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gWLCloudProgram.createShader(NULL, NULL); } @@ -4199,7 +4199,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gWLMoonProgram.createShader(NULL, NULL); } -- cgit v1.2.3 From 22f67f9913bad7934a95679318a4bc48444cedaa Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 14:06:37 -0700 Subject: SL-14113: Remove useless last digit in constant to help readability based on Euclid's feedback --- indra/llrender/llglslshader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 74c8b2e448..d669e7134c 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -72,8 +72,8 @@ const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] = // NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] = { - "0.999985" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 - , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 + "0.99998" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 + , "0.99999" // SHADER_CONST_STAR_DEPTH // SL-14113 }; -- cgit v1.2.3 From ced2bd5ed4386d50231edfd1ebec01561f9b4465 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 12 Apr 2021 16:58:18 -0700 Subject: SL-14113 Fix moon haze --- .../shaders/class1/deferred/cloudsF.glsl | 2 +- .../shaders/class1/deferred/moonF.glsl | 6 +++ .../shaders/class1/deferred/starsF.glsl | 7 ++- .../shaders/class1/environment/moonF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/moonV.glsl | 38 ++++++++++++++++ .../shaders/class1/environment/starsF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/starsV.glsl | 41 +++++++++++++++++ .../shaders/class1/windlight/moonF.glsl | 7 +++ .../shaders/class2/windlight/cloudsF.glsl | 6 +++ indra/newview/lldrawpoolsky.cpp | 19 ++++++++ indra/newview/lldrawpoolwlsky.cpp | 13 +++--- indra/newview/llviewershadermgr.cpp | 33 +++++++++++++- indra/newview/llviewershadermgr.h | 2 + 13 files changed, 267 insertions(+), 9 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsV.glsl diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index ae1ac5de7f..187fed72e1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999985; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 35068899ee..5906194437 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -55,6 +55,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = srgb_to_linear(c.rgb); c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index bac79a9fdc..50f10ad0fa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -46,8 +46,13 @@ float twinkle(){ return abs(d); } +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl void main() { + // camera above water: class1\deferred\starsF.glsl + // camera below water: starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); @@ -62,6 +67,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl new file mode 100644 index 0000000000..e1592c19fb --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/moonF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D tex0; + +VARYING vec2 vary_texcoord0; + +// See: +// AS off: class1/environment/moonF.glsl +// ALM off: class1/windlight/moonF.glsl +// ALM on : class1/deferred/moonF.glsl +void main() +{ + vec4 color = texture2D(tex0, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (color.a <= 2./255.) // 0.00784 + discard; + + frag_color = color; + gl_FragDepth = 0.999985f; // SL-14113 Moon is infront of stars +} diff --git a/indra/newview/app_settings/shaders/class1/environment/moonV.glsl b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl new file mode 100644 index 0000000000..1fc421a295 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl @@ -0,0 +1,38 @@ +/** + * @file class1\environment\moonV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position, 1); + vary_texcoord0 = texcoord0; +} + diff --git a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl new file mode 100644 index 0000000000..95ab4cbf8b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/starsF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +uniform float custom_alpha; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl +void main() +{ + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); + color.rgb = pow(color.rgb, vec3(0.45)); + color.rgb *= vertex_color.rgb; + color.a *= max(custom_alpha, vertex_color.a); + + frag_color = color; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon +} diff --git a/indra/newview/app_settings/shaders/class1/environment/starsV.glsl b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl new file mode 100644 index 0000000000..6fcfec6b6a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl @@ -0,0 +1,41 @@ +/** + * @file class1/environment/starsV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vary_texcoord0 = texcoord0; + vertex_color = diffuse_color; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 2425a2ad04..327accbd3b 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -52,6 +52,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = pow(c.rgb, vec3(0.7f)); // can't use "srgb_to_linear(color.rgb)" as that is a deferred only function c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; @@ -62,5 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); + gl_FragDepth = 0.999985f; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index fa928d993e..d89cc69d71 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -127,5 +127,11 @@ void main() /// Gamma correct for WL (soft clip effect). frag_color = vec4(color.rgb, alpha1); + + // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon + // camera above water: class1\defered\cloudsF.glsl + // camera below water: class2\windlight\coudsV.glsl + // See: starsV.glsl, cloudsV.glsl, moonF.glsl + gl_FragDepth = 0.999985; } diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index b6f55e800a..96b4a91b0f 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -130,13 +130,32 @@ void LLDrawPoolSky::renderSkyFace(U8 index) face->renderIndexed(); } + else // Moon + if (index == LLVOSky::FACE_MOON) + { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, true); // SL-14113 Write depth for moon so stars can test if behind it + + LLGLEnable blend(GL_BLEND); + + // if (LLGLSLShader::sNoFixedFunction) // TODO: Necessary? is this always true? We already bailed on gPipeline.canUseWindLightShaders ... above + LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); + if (tex) + { + gMoonProgram.bind(); // SL-14113 was gOneTextureNoColorProgram + gGL.getTexUnit(0)->bind(tex, true); + face->renderIndexed(); + } + } else // heavenly body faces, no interp... { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); // reset to previous + LLGLEnable blend(GL_BLEND); LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); if (tex) { + gOneTextureNoColorProgram.bind(); gGL.getTexUnit(0)->bind(tex, true); face->renderIndexed(); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index c66aa905f5..436ecabd83 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -270,8 +270,8 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.bind(); - gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); + gStarsProgram.bind(); + gStarsProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); } else { @@ -288,7 +288,7 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.unbind(); + gStarsProgram.unbind(); // SL-14113 was gCustomAlphaProgram } else { @@ -477,7 +477,8 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh void LLDrawPoolWLSky::renderHeavenlyBodies() { - LLGLSPipelineBlendSkyBox gls_skybox(true, false); + //LLGLSPipelineBlendSkyBox gls_skybox(true, false); + LLGLSPipelineBlendSkyBox gls_skybox(true, true); // SL-14113 we need moon to write to depth to clip stars behind LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); gGL.pushMatrix(); @@ -607,8 +608,8 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { renderSkyHazeDeferred(origin, camHeightLocal); - renderStarsDeferred(origin); renderHeavenlyBodies(); + renderStarsDeferred(origin); renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); } gGL.setColorMask(true, true); @@ -626,8 +627,8 @@ void LLDrawPoolWLSky::render(S32 pass) LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); renderSkyHaze(origin, camHeightLocal); + renderHeavenlyBodies(); renderStars(origin); - renderHeavenlyBodies(); renderSkyClouds(origin, camHeightLocal, cloud_shader); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index be5c22e7c3..8eb57799c9 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -78,7 +78,7 @@ LLGLSLShader gTransformTangentProgram; //utility shaders LLGLSLShader gOcclusionProgram; LLGLSLShader gOcclusionCubeProgram; -LLGLSLShader gCustomAlphaProgram; +LLGLSLShader gCustomAlphaProgram; // SL-14113 This used to be used for the stars with Atmospheric Shaders: OFF LLGLSLShader gGlowCombineProgram; LLGLSLShader gSplatTextureRectProgram; LLGLSLShader gGlowCombineFXAAProgram; @@ -148,6 +148,8 @@ LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +LLGLSLShader gMoonProgram; +LLGLSLShader gStarsProgram; LLGLSLShader gTerrainProgram; LLGLSLShader gTerrainWaterProgram; LLGLSLShader gWaterProgram; @@ -819,6 +821,9 @@ void LLViewerShaderMgr::unloadShaders() gWaterProgram.unload(); gWaterEdgeProgram.unload(); gUnderWaterProgram.unload(); + + gMoonProgram.unload(); + gStarsProgram.unload(); gTerrainProgram.unload(); gTerrainWaterProgram.unload(); gGlowProgram.unload(); @@ -1051,6 +1056,32 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() llassert(success); } + if (success) + { + gStarsProgram.mName = "Environment Stars Shader"; + gStarsProgram.mShaderFiles.clear(); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB)); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gStarsProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gMoonProgram.mName = "Environment Moon Shader"; + gMoonProgram.mShaderFiles.clear(); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); + gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gMoonProgram.createShader(NULL, NULL); + if (success) + { + gMoonProgram.bind(); + gMoonProgram.uniform1i(sTex0, 0); + } + } + if (!success) { mShaderLevel[SHADER_ENVIRONMENT] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 081221f15b..5122558a01 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -234,6 +234,8 @@ extern LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; extern LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +extern LLGLSLShader gMoonProgram; +extern LLGLSLShader gStarsProgram; extern LLGLSLShader gTerrainProgram; extern LLGLSLShader gTerrainWaterProgram; extern LLGLSLShader gWaterProgram; -- cgit v1.2.3 From 290c66ebf476cb1e6e7141889d1e6faf26dba3ce Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 10:54:02 -0700 Subject: SL-14113 Cleanup typo and cross reference --- indra/newview/app_settings/shaders/class1/deferred/starsF.glsl | 2 +- indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 50f10ad0fa..b028c40ed9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -52,7 +52,7 @@ float twinkle(){ void main() { // camera above water: class1\deferred\starsF.glsl - // camera below water: starsF.glsl + // camera below water: class1\environment\starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index d89cc69d71..1c592402d4 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -129,7 +129,7 @@ void main() frag_color = vec4(color.rgb, alpha1); // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon - // camera above water: class1\defered\cloudsF.glsl + // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl gl_FragDepth = 0.999985; -- cgit v1.2.3 From 1ef70ff1d3379fd2362f453dedff78c8aeda24ea Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:35:36 -0700 Subject: SL-14113 Cleanup face magic number --- indra/newview/lldrawpoolsky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 96b4a91b0f..77b8a1fc32 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -123,7 +123,7 @@ void LLDrawPoolSky::renderSkyFace(U8 index) return; } - if (index < 6) // sky tex...interp + if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); mSkyTex[index].bindTexture(true); // bind the current tex -- cgit v1.2.3 From eb1e2a231410f8d2fefa4b4903b46b24f4259b04 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:36:33 -0700 Subject: SL-14113 Cleanup indentation --- indra/newview/lldrawpoolsky.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 77b8a1fc32..178564b0d4 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -116,17 +116,17 @@ void LLDrawPoolSky::render(S32 pass) void LLDrawPoolSky::renderSkyFace(U8 index) { - LLFace* face = mDrawFace[index]; + LLFace* face = mDrawFace[index]; - if (!face || !face->getGeomCount()) - { - return; - } + if (!face || !face->getGeomCount()) + { + return; + } if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); - mSkyTex[index].bindTexture(true); // bind the current tex + mSkyTex[index].bindTexture(true); // bind the current tex face->renderIndexed(); } -- cgit v1.2.3 From e371fdbf311e450ac0cc7f4d3fdacc938b489d92 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 08:41:50 -0700 Subject: SL-14113: Remove magic numbers. Take advantage of existing shader #defines injection by extending shader loading to make use of addConstant() instead of hard-coding magic number constants in each GLSL file. --- indra/llrender/llglslshader.cpp | 22 ++++++++++++++++++++++ indra/llrender/llglslshader.h | 12 +++++++++++- .../shaders/class1/deferred/cloudsF.glsl | 2 +- .../shaders/class1/deferred/moonF.glsl | 2 +- .../shaders/class1/deferred/starsF.glsl | 2 +- .../shaders/class1/environment/moonF.glsl | 2 +- .../shaders/class1/environment/starsF.glsl | 2 +- .../shaders/class1/windlight/moonF.glsl | 2 +- .../shaders/class2/windlight/cloudsF.glsl | 2 +- indra/newview/llviewershadermgr.cpp | 8 ++++++++ 10 files changed, 48 insertions(+), 8 deletions(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 74cfa60b27..458f83aabe 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -62,6 +62,23 @@ U32 LLGLSLShader::sTotalDrawCalls = 0; LLGLSLShader gUIProgram; LLGLSLShader gSolidColorProgram; +// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] = +{ + "LL_SHADER_CONST_CLOUD_DEPTH" + , "LL_SHADER_CONST_MOON_DEPTH" + , "LL_SHADER_CONST_STAR_DEPTH" +}; + +// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] = +{ + "0.999985" // SHADER_CONST_CLOUD_DEPTH // SL-14113 + , "0.999985" // SHADER_CONST_MOON_DEPTH // SL-14113 + , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 +}; + + BOOL shouldChange(const LLVector4& v1, const LLVector4& v2) { return v1 != v2; @@ -755,6 +772,11 @@ void LLGLSLShader::addPermutation(std::string name, std::string value) mDefines[name] = value; } +void LLGLSLShader::addConstant( const LLGLSLShader::eShaderConsts shader_const ) +{ + addPermutation( gShaderConstsKey[ shader_const ], gShaderConstsVal[ shader_const ] ); +} + void LLGLSLShader::removePermutation(std::string name) { mDefines[name].erase(); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 7cf6d3c941..35e796e961 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -67,6 +67,14 @@ public: class LLGLSLShader { public: + // NOTE:Keep gShaderConsts and LLGLSLShader::ShaderConsts_e in sync! + enum eShaderConsts + { + SHADER_CONST_CLOUD_DEPTH + , SHADER_CONST_MOON_DEPTH + , SHADER_CONST_STAR_DEPTH + , NUM_SHADER_CONSTS + }; enum { @@ -149,7 +157,9 @@ public: void clearPermutations(); void addPermutation(std::string name, std::string value); void removePermutation(std::string name); - + + void addConstant( const LLGLSLShader::eShaderConsts shader_const ); + //enable/disable texture channel for specified uniform //if given texture uniform is active in the shader, //the corresponding channel will be active upon return diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index 187fed72e1..ad8ab771b8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = 0.999985; // SL-14113 Stars and Clouds need same depth + gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 5906194437..ffeaf2b600 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -74,6 +74,6 @@ void main() frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0f); - gl_FragDepth = 0.999985f; + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index b028c40ed9..8d9c7e3507 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -67,6 +67,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon + gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl index e1592c19fb..983cd17979 100644 --- a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -47,5 +47,5 @@ void main() discard; frag_color = color; - gl_FragDepth = 0.999985f; // SL-14113 Moon is infront of stars + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 Moon is infront of stars } diff --git a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl index 95ab4cbf8b..e1a9cc6387 100644 --- a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl @@ -47,5 +47,5 @@ void main() color.a *= max(custom_alpha, vertex_color.a); frag_color = color; - gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon + gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 327accbd3b..293e09620f 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -68,6 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); - gl_FragDepth = 0.999985f; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index 1c592402d4..ec53ae75f9 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -132,6 +132,6 @@ void main() // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl - gl_FragDepth = 0.999985; + gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 8eb57799c9..1dcd9289ef 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1063,6 +1063,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB)); gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + gStarsProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113 success = gStarsProgram.createShader(NULL, NULL); llassert(success); } @@ -1074,8 +1075,10 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gMoonProgram.createShader(NULL, NULL); if (success) + { gMoonProgram.bind(); gMoonProgram.uniform1i(sTex0, 0); @@ -2750,6 +2753,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 success = gDeferredWLCloudProgram.createShader(NULL, NULL); llassert(success); } @@ -2789,6 +2793,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gDeferredWLMoonProgram.createShader(NULL, NULL); llassert(success); } @@ -2801,6 +2806,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredStarProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredStarProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113 success = gDeferredStarProgram.createShader(NULL, NULL); llassert(success); } @@ -4157,6 +4163,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 success = gWLCloudProgram.createShader(NULL, NULL); } @@ -4193,6 +4200,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gWLMoonProgram.createShader(NULL, NULL); } -- cgit v1.2.3 From 3f4b8423a46bae4736ebcc28082ee1a9d5b71d6b Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 10:27:09 -0700 Subject: SL-14113: Merge duplicate shader constant for clarity. --- indra/llrender/llglslshader.cpp | 12 +++++------- indra/llrender/llglslshader.h | 5 ++--- .../app_settings/shaders/class1/deferred/cloudsF.glsl | 2 +- .../newview/app_settings/shaders/class1/deferred/moonF.glsl | 2 +- .../app_settings/shaders/class1/environment/moonF.glsl | 2 +- .../newview/app_settings/shaders/class1/windlight/moonF.glsl | 2 +- .../app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- indra/newview/llviewershadermgr.cpp | 10 +++++----- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 458f83aabe..74c8b2e448 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -62,20 +62,18 @@ U32 LLGLSLShader::sTotalDrawCalls = 0; LLGLSLShader gUIProgram; LLGLSLShader gSolidColorProgram; -// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +// NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] = { - "LL_SHADER_CONST_CLOUD_DEPTH" - , "LL_SHADER_CONST_MOON_DEPTH" + "LL_SHADER_CONST_CLOUD_MOON_DEPTH" , "LL_SHADER_CONST_STAR_DEPTH" }; -// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +// NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] = { - "0.999985" // SHADER_CONST_CLOUD_DEPTH // SL-14113 - , "0.999985" // SHADER_CONST_MOON_DEPTH // SL-14113 - , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 + "0.999985" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 + , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 }; diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 35e796e961..e2d0031740 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -67,11 +67,10 @@ public: class LLGLSLShader { public: - // NOTE:Keep gShaderConsts and LLGLSLShader::ShaderConsts_e in sync! + // NOTE: Keep gShaderConsts and LLGLSLShader::ShaderConsts_e in sync! enum eShaderConsts { - SHADER_CONST_CLOUD_DEPTH - , SHADER_CONST_MOON_DEPTH + SHADER_CONST_CLOUD_MOON_DEPTH , SHADER_CONST_STAR_DEPTH , NUM_SHADER_CONSTS }; diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index ad8ab771b8..f1187fef9a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; // SL-14113 Stars and Clouds need same depth + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index ffeaf2b600..e709d73bfa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -74,6 +74,6 @@ void main() frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0f); - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl index 983cd17979..a220971f06 100644 --- a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -47,5 +47,5 @@ void main() discard; frag_color = color; - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 Moon is infront of stars + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Moon is infront of stars } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 293e09620f..2e0932343b 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -68,6 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index ec53ae75f9..490fde7cf6 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -132,6 +132,6 @@ void main() // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl - gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 1dcd9289ef..0c1ba13bb1 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1075,7 +1075,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; - gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gMoonProgram.createShader(NULL, NULL); if (success) @@ -2753,7 +2753,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 + gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gDeferredWLCloudProgram.createShader(NULL, NULL); llassert(success); } @@ -2793,7 +2793,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gDeferredWLMoonProgram.createShader(NULL, NULL); llassert(success); } @@ -4163,7 +4163,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 + gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gWLCloudProgram.createShader(NULL, NULL); } @@ -4200,7 +4200,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gWLMoonProgram.createShader(NULL, NULL); } -- cgit v1.2.3 From d3c439b3743490ee22d5356ec3b61cb13c86f487 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 14:06:37 -0700 Subject: SL-14113: Remove useless last digit in constant to help readability based on Euclid's feedback --- indra/llrender/llglslshader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 74c8b2e448..d669e7134c 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -72,8 +72,8 @@ const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] = // NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] = { - "0.999985" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 - , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 + "0.99998" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 + , "0.99999" // SHADER_CONST_STAR_DEPTH // SL-14113 }; -- cgit v1.2.3 From d1875c4932ea83decf871a7fccf871fcfe4d01ea Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 13:12:44 -0700 Subject: SL-14885 Allow mousewheel to zoom way out when user has disabled camera constraints --- indra/newview/llagentcamera.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index ed6c3c307f..86d2b0fc6c 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2038,6 +2038,12 @@ LLVector3d LLAgentCamera::getFocusOffsetInitial() F32 LLAgentCamera::getCameraMaxZoomDistance() { + // SL-14706 / SL-14885 TPV have relaxed camera constraints allowing you to mousewheeel zoom WAY out. + if (gSavedSettings.getBOOL("DisableCameraConstraints")) + { + return (F32)INT_MAX; + } + // Ignore "DisableCameraConstraints", we don't want to be out of draw range when we focus onto objects or avatars return llmin(MAX_CAMERA_DISTANCE_FROM_OBJECT, mDrawDistance - 1, // convenience, don't hit draw limit when focusing on something -- cgit v1.2.3 From 176e56d3e8ddc7f937b2b67c005d7a210e2526a1 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 30 Apr 2021 10:56:08 -0700 Subject: SL-14885: Use LLCachedControl --- indra/newview/llagentcamera.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 86d2b0fc6c..0cf91ba3de 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2039,7 +2039,8 @@ LLVector3d LLAgentCamera::getFocusOffsetInitial() F32 LLAgentCamera::getCameraMaxZoomDistance() { // SL-14706 / SL-14885 TPV have relaxed camera constraints allowing you to mousewheeel zoom WAY out. - if (gSavedSettings.getBOOL("DisableCameraConstraints")) + static LLCachedControl s_disable_camera_constraints(gSavedSettings, "DisableCameraConstraints", false); + if (s_disable_camera_constraints) { return (F32)INT_MAX; } -- cgit v1.2.3 From 5da88f5a809fd6f29d7704cfd947226e23714bd1 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 5 May 2021 13:09:16 -0600 Subject: SL-15221 add VBO dirty bit to avoid many per-frame checks --- indra/llrender/llvertexbuffer.cpp | 45 +++++++++++++++++++++------------------ indra/llrender/llvertexbuffer.h | 1 + 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 7d2b09ca4a..0d39d503d7 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -144,9 +144,10 @@ void LLVBOPool::deleteBuffer(U32 name) LLVBOPool::LLVBOPool(U32 vboUsage, U32 vboType) -: mUsage(vboUsage), mType(vboType) +: mUsage(vboUsage), mType(vboType), mMissCountDirty(true) { - mMissCount.resize(LL_VBO_POOL_SEED_COUNT); + mFreeList.resize(LL_VBO_POOL_SEED_COUNT); + mMissCount.resize(LL_VBO_POOL_SEED_COUNT); std::fill(mMissCount.begin(), mMissCount.end(), 0); } @@ -173,7 +174,8 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) if (!for_seed && i < LL_VBO_POOL_SEED_COUNT) { //record this miss mMissCount[i]++; - } + mMissCountDirty = true; // signal to ::seedPool() + } if (mType == GL_ARRAY_BUFFER_ARB) { @@ -226,6 +228,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) sIndexBytesPooled += size; } mFreeList[i].push_back(rec); + mMissCountDirty = true; // signal to ::seedPool() } } else @@ -243,6 +246,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) } mFreeList[i].pop_front(); + mMissCountDirty = true; // signal to ::seedPool() } return ret; @@ -267,26 +271,25 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) void LLVBOPool::seedPool() { - U32 dummy_name = 0; + if (mMissCountDirty) + { + U32 dummy_name = 0; - if (mFreeList.size() < LL_VBO_POOL_SEED_COUNT) - { - mFreeList.resize(LL_VBO_POOL_SEED_COUNT); - } + for (U32 i = 0; i < LL_VBO_POOL_SEED_COUNT; i++) + { + if (mMissCount[i] > mFreeList[i].size()) + { + U32 size = i * LL_VBO_BLOCK_SIZE; - for (U32 i = 0; i < LL_VBO_POOL_SEED_COUNT; i++) - { - if (mMissCount[i] > mFreeList[i].size()) - { - U32 size = i*LL_VBO_BLOCK_SIZE; - - S32 count = mMissCount[i] - mFreeList[i].size(); - for (U32 j = 0; j < count; ++j) - { - allocate(dummy_name, size, true); - } - } - } + S32 count = mMissCount[i] - mFreeList[i].size(); + for (U32 j = 0; j < count; ++j) + { + allocate(dummy_name, size, true); + } + } + } + mMissCountDirty = false; + } } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index dbe1a3687f..649fbb782c 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -88,6 +88,7 @@ public: typedef std::list record_list_t; std::vector mFreeList; std::vector mMissCount; + bool mMissCountDirty; // flag any changes to mFreeList or mMissCount }; -- cgit v1.2.3 From fd9fc8e4a5d49d0d24e22c6cb2391f75bf0ea763 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 5 May 2021 15:15:50 -0600 Subject: SL-15221 fixed off-by-one accounting error --- indra/llrender/llvertexbuffer.cpp | 107 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 0d39d503d7..ebf0b2fe78 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -74,10 +74,12 @@ U32 vbo_block_size(U32 size) U32 vbo_block_index(U32 size) { - return vbo_block_size(size)/LL_VBO_BLOCK_SIZE; + U32 blocks = vbo_block_size(size)/LL_VBO_BLOCK_SIZE; // block count reqd + llassert(blocks > 0); + return blocks - 1; // Adj index, i.e. single-block allocations are at index 0, etc } -const U32 LL_VBO_POOL_SEED_COUNT = vbo_block_index(LL_VBO_POOL_MAX_SEED_SIZE); +const U32 LL_VBO_POOL_SEED_COUNT = vbo_block_index(LL_VBO_POOL_MAX_SEED_SIZE) + 1; //============================================================================ @@ -118,6 +120,97 @@ bool LLVertexBuffer::sUseStreamDraw = true; bool LLVertexBuffer::sUseVAO = false; bool LLVertexBuffer::sPreferStreamDraw = false; +// DEBUG, temporary +#include + +typedef struct +{ + U32 allocated_size; + void* memptr; +} glbufmem; + +static std::unordered_map buf_list; + +void add_buf(U32 name, U32 size, void* ptr) +{ + LL_WARNS("VBO_ACCOUNTING") << "ADD add_buf GLname " << name << ", size " << size << ", ptr " << ptr << LL_ENDL; + + if (0 < buf_list.count(name)) + { + if (buf_list[name].allocated_size > 0) + { + U32 a = buf_list[name].allocated_size; + LL_WARNS("VBO_ACC_ERROR") << "add_buf error, adding duplicate GLname " << name << ", size " << size << ", allocated " << a << LL_ENDL; + } + } + + buf_list[name].allocated_size = size; + buf_list[name].memptr = ptr; +} + +U32 find_buf_size(U32 name) +{ + if (buf_list.count(name) > 0) return buf_list[name].allocated_size; + return 0; +} + +bool clear_buf(U32 name, U32 size, void* ptr) +{ + LL_WARNS("VBO_ACCOUNTING") << "DEL clear_buf GLname " << name << ", size " << size << ", ptr " << ptr << LL_ENDL; + + if (0 == buf_list.count(name)) + { + LL_WARNS("VBO_ACC_ERROR") << "clear_buf error, attempt to remove unknown GLname " << name << ", size " << size << LL_ENDL; + return false; + } + + if (buf_list[name].allocated_size == 0) + { + LL_WARNS("VBO_ACC_ERROR") << "clear_buf error, attempt to remove empty GLname " << name << ", size " << size << LL_ENDL; + return false; + } + + if (buf_list[name].allocated_size != size) + { + U32 a = buf_list[name].allocated_size; + LL_WARNS("VBO_ACC_ERROR") << "clear_buf error, size mismatch " << name << ", size " << size << ", allocated " << a << LL_ENDL; + buf_list[name].allocated_size = 0; + buf_list[name].memptr = nullptr; + return false; + } + + if (buf_list[name].memptr != ptr) + { + void* p = buf_list[name].memptr; + LL_WARNS("VBO_ACC_ERROR") << "clear_buf error, ptr mismatch " << name << ", ptr " << ptr << ", saved ptr " << p << LL_ENDL; + buf_list[name].allocated_size = 0; + buf_list[name].memptr = nullptr; + return false; + } + + buf_list[name].allocated_size = 0; + buf_list[name].memptr = nullptr; + return true; +} + +#if 0 + // Find the GLname in the freelist +for (U32 i = 0; i < LL_VBO_POOL_SEED_COUNT; i++) +{ + for (auto &r : mFreeList[i]) + { + if (r.mGLName == name) + { + LL_WARNS() << "Release size " << size << ", found Name " << name << " in bucket " << i << LL_ENDL; + } + } +} + +// Remove the buffer record from the free record list, by GLname +U32 i = vbo_block_index(size); +mFreeList[i].remove_if([name](Record r) {return (name == r.mGLName); }); +i++; +#endif U32 LLVBOPool::genBuffer() { @@ -230,6 +323,8 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) mFreeList[i].push_back(rec); mMissCountDirty = true; // signal to ::seedPool() } + + add_buf(name, size, (void*)ret); } else { @@ -267,6 +362,8 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) { LLVertexBuffer::sAllocatedIndexBytes -= size; } + + clear_buf(name, size, (void*)buffer); } void LLVBOPool::seedPool() @@ -274,19 +371,19 @@ void LLVBOPool::seedPool() if (mMissCountDirty) { U32 dummy_name = 0; + U32 size = LL_VBO_BLOCK_SIZE; for (U32 i = 0; i < LL_VBO_POOL_SEED_COUNT; i++) { if (mMissCount[i] > mFreeList[i].size()) { - U32 size = i * LL_VBO_BLOCK_SIZE; - S32 count = mMissCount[i] - mFreeList[i].size(); for (U32 j = 0; j < count; ++j) { allocate(dummy_name, size, true); } } + size += LL_VBO_BLOCK_SIZE; } mMissCountDirty = false; } @@ -313,6 +410,8 @@ void LLVBOPool::cleanup() ll_aligned_free<64>((void*) r.mClientData); } + clear_buf(r.mGLName, size, (void*)r.mClientData); + l.pop_front(); if (mType == GL_ARRAY_BUFFER_ARB) -- cgit v1.2.3 From 7131f8c46499b8f856c35137cda5ad4cb1bce527 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 6 May 2021 14:50:26 -0600 Subject: SL-15221 strip debug code, add sanity asserts, format --- indra/llrender/llvertexbuffer.cpp | 275 +++++++++++++------------------------- 1 file changed, 90 insertions(+), 185 deletions(-) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index ebf0b2fe78..93967b128d 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -68,8 +68,8 @@ const U32 LL_VBO_POOL_MAX_SEED_SIZE = 256*1024; U32 vbo_block_size(U32 size) { //what block size will fit size? - U32 mod = size % LL_VBO_BLOCK_SIZE; - return mod == 0 ? size : size + (LL_VBO_BLOCK_SIZE-mod); + U32 mod = size % LL_VBO_BLOCK_SIZE; + return mod == 0 ? size : size + (LL_VBO_BLOCK_SIZE-mod); } U32 vbo_block_index(U32 size) @@ -120,98 +120,6 @@ bool LLVertexBuffer::sUseStreamDraw = true; bool LLVertexBuffer::sUseVAO = false; bool LLVertexBuffer::sPreferStreamDraw = false; -// DEBUG, temporary -#include - -typedef struct -{ - U32 allocated_size; - void* memptr; -} glbufmem; - -static std::unordered_map buf_list; - -void add_buf(U32 name, U32 size, void* ptr) -{ - LL_WARNS("VBO_ACCOUNTING") << "ADD add_buf GLname " << name << ", size " << size << ", ptr " << ptr << LL_ENDL; - - if (0 < buf_list.count(name)) - { - if (buf_list[name].allocated_size > 0) - { - U32 a = buf_list[name].allocated_size; - LL_WARNS("VBO_ACC_ERROR") << "add_buf error, adding duplicate GLname " << name << ", size " << size << ", allocated " << a << LL_ENDL; - } - } - - buf_list[name].allocated_size = size; - buf_list[name].memptr = ptr; -} - -U32 find_buf_size(U32 name) -{ - if (buf_list.count(name) > 0) return buf_list[name].allocated_size; - return 0; -} - -bool clear_buf(U32 name, U32 size, void* ptr) -{ - LL_WARNS("VBO_ACCOUNTING") << "DEL clear_buf GLname " << name << ", size " << size << ", ptr " << ptr << LL_ENDL; - - if (0 == buf_list.count(name)) - { - LL_WARNS("VBO_ACC_ERROR") << "clear_buf error, attempt to remove unknown GLname " << name << ", size " << size << LL_ENDL; - return false; - } - - if (buf_list[name].allocated_size == 0) - { - LL_WARNS("VBO_ACC_ERROR") << "clear_buf error, attempt to remove empty GLname " << name << ", size " << size << LL_ENDL; - return false; - } - - if (buf_list[name].allocated_size != size) - { - U32 a = buf_list[name].allocated_size; - LL_WARNS("VBO_ACC_ERROR") << "clear_buf error, size mismatch " << name << ", size " << size << ", allocated " << a << LL_ENDL; - buf_list[name].allocated_size = 0; - buf_list[name].memptr = nullptr; - return false; - } - - if (buf_list[name].memptr != ptr) - { - void* p = buf_list[name].memptr; - LL_WARNS("VBO_ACC_ERROR") << "clear_buf error, ptr mismatch " << name << ", ptr " << ptr << ", saved ptr " << p << LL_ENDL; - buf_list[name].allocated_size = 0; - buf_list[name].memptr = nullptr; - return false; - } - - buf_list[name].allocated_size = 0; - buf_list[name].memptr = nullptr; - return true; -} - -#if 0 - // Find the GLname in the freelist -for (U32 i = 0; i < LL_VBO_POOL_SEED_COUNT; i++) -{ - for (auto &r : mFreeList[i]) - { - if (r.mGLName == name) - { - LL_WARNS() << "Release size " << size << ", found Name " << name << " in bucket " << i << LL_ENDL; - } - } -} - -// Remove the buffer record from the free record list, by GLname -U32 i = vbo_block_index(size); -mFreeList[i].remove_if([name](Record r) {return (name == r.mGLName); }); -i++; -#endif - U32 LLVBOPool::genBuffer() { U32 ret = 0; @@ -244,107 +152,105 @@ LLVBOPool::LLVBOPool(U32 vboUsage, U32 vboType) std::fill(mMissCount.begin(), mMissCount.end(), 0); } -volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) +volatile U8 *LLVBOPool::allocate(U32 &name, U32 size, bool for_seed) { - llassert(vbo_block_size(size) == size); - - volatile U8* ret = NULL; + llassert(vbo_block_size(size) == size); - U32 i = vbo_block_index(size); + volatile U8 *ret = NULL; - if (mFreeList.size() <= i) - { - mFreeList.resize(i+1); - } + U32 i = vbo_block_index(size); - if (mFreeList[i].empty() || for_seed) - { - //make a new buffer - name = genBuffer(); - - glBindBufferARB(mType, name); + if (mFreeList.size() <= i) + { + mFreeList.resize(i + 1); + } - if (!for_seed && i < LL_VBO_POOL_SEED_COUNT) - { //record this miss - mMissCount[i]++; + if (mFreeList[i].empty() || for_seed) + { + // make a new buffer + name = genBuffer(); + + glBindBufferARB(mType, name); + + if (!for_seed && i < LL_VBO_POOL_SEED_COUNT) + { // record this miss + mMissCount[i]++; mMissCountDirty = true; // signal to ::seedPool() } - if (mType == GL_ARRAY_BUFFER_ARB) - { - LLVertexBuffer::sAllocatedBytes += size; - } - else - { - LLVertexBuffer::sAllocatedIndexBytes += size; - } + if (mType == GL_ARRAY_BUFFER_ARB) + { + LLVertexBuffer::sAllocatedBytes += size; + } + else + { + LLVertexBuffer::sAllocatedIndexBytes += size; + } - if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB) - { - glBufferDataARB(mType, size, 0, mUsage); - if (mUsage != GL_DYNAMIC_COPY_ARB) - { //data will be provided by application - ret = (U8*) ll_aligned_malloc<64>(size); - if (!ret) - { - LL_ERRS() << "Failed to allocate "<< size << " bytes for LLVBOPool buffer " << name <<"." << LL_NEWLINE - << "Free list size: " << mFreeList.size() // this happens if we are out of memory so a solution might be to clear some from freelist - << " Allocated Bytes: " << LLVertexBuffer::sAllocatedBytes - << " Allocated Index Bytes: " << LLVertexBuffer::sAllocatedIndexBytes - << " Pooled Bytes: " << sBytesPooled - << " Pooled Index Bytes: " << sIndexBytesPooled - << LL_ENDL; - } - } - } - else - { //always use a true hint of static draw when allocating non-client-backed buffers - glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB); - } + if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB) + { + glBufferDataARB(mType, size, 0, mUsage); + if (mUsage != GL_DYNAMIC_COPY_ARB) + { // data will be provided by application + ret = (U8 *) ll_aligned_malloc<64>(size); + if (!ret) + { + LL_ERRS() + << "Failed to allocate " << size << " bytes for LLVBOPool buffer " << name << "." << LL_NEWLINE + << "Free list size: " + << mFreeList.size() // this happens if we are out of memory so a solution might be to clear some from freelist + << " Allocated Bytes: " << LLVertexBuffer::sAllocatedBytes + << " Allocated Index Bytes: " << LLVertexBuffer::sAllocatedIndexBytes << " Pooled Bytes: " << sBytesPooled + << " Pooled Index Bytes: " << sIndexBytesPooled << LL_ENDL; + } + } + } + else + { // always use a true hint of static draw when allocating non-client-backed buffers + glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB); + } - glBindBufferARB(mType, 0); + glBindBufferARB(mType, 0); - if (for_seed) - { //put into pool for future use - llassert(mFreeList.size() > i); + if (for_seed) + { // put into pool for future use + llassert(mFreeList.size() > i); - Record rec; - rec.mGLName = name; - rec.mClientData = ret; - - if (mType == GL_ARRAY_BUFFER_ARB) - { - sBytesPooled += size; - } - else - { - sIndexBytesPooled += size; - } - mFreeList[i].push_back(rec); - mMissCountDirty = true; // signal to ::seedPool() - } + Record rec; + rec.mGLName = name; + rec.mClientData = ret; - add_buf(name, size, (void*)ret); - } - else - { - name = mFreeList[i].front().mGLName; - ret = mFreeList[i].front().mClientData; + if (mType == GL_ARRAY_BUFFER_ARB) + { + sBytesPooled += size; + } + else + { + sIndexBytesPooled += size; + } + mFreeList[i].push_back(rec); + mMissCountDirty = true; // signal to ::seedPool() + } + } + else + { + name = mFreeList[i].front().mGLName; + ret = mFreeList[i].front().mClientData; - if (mType == GL_ARRAY_BUFFER_ARB) - { - sBytesPooled -= size; - } - else - { - sIndexBytesPooled -= size; - } + if (mType == GL_ARRAY_BUFFER_ARB) + { + sBytesPooled -= size; + } + else + { + sIndexBytesPooled -= size; + } - mFreeList[i].pop_front(); + mFreeList[i].pop_front(); mMissCountDirty = true; // signal to ::seedPool() - } + } - return ret; + return ret; } void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) @@ -362,8 +268,6 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) { LLVertexBuffer::sAllocatedIndexBytes -= size; } - - clear_buf(name, size, (void*)buffer); } void LLVBOPool::seedPool() @@ -371,7 +275,7 @@ void LLVBOPool::seedPool() if (mMissCountDirty) { U32 dummy_name = 0; - U32 size = LL_VBO_BLOCK_SIZE; + U32 size = LL_VBO_BLOCK_SIZE; for (U32 i = 0; i < LL_VBO_POOL_SEED_COUNT; i++) { @@ -389,8 +293,6 @@ void LLVBOPool::seedPool() } } - - void LLVBOPool::cleanup() { U32 size = LL_VBO_BLOCK_SIZE; @@ -410,8 +312,6 @@ void LLVBOPool::cleanup() ll_aligned_free<64>((void*) r.mClientData); } - clear_buf(r.mGLName, size, (void*)r.mClientData); - l.pop_front(); if (mType == GL_ARRAY_BUFFER_ARB) @@ -1019,6 +919,11 @@ void LLVertexBuffer::cleanupClass() sStreamVBOPool.cleanup(); sDynamicVBOPool.cleanup(); sDynamicCopyVBOPool.cleanup(); + + llassert(0 == LLVBOPool::sBytesPooled); + llassert(0 == LLVBOPool::sIndexBytesPooled); + llassert(0 == sAllocatedBytes); + llassert(0 == sAllocatedIndexBytes); } //---------------------------------------------------------------------------- -- cgit v1.2.3 From 2ce141c5dc234201c05da4c7e28bf1255089a972 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 13 May 2021 02:35:45 +0300 Subject: SL-15225 llSetAgentEnvironment cloud density transition doesn't work --- indra/newview/llenvironment.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 74c1b99e4d..809289fd63 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -612,6 +612,7 @@ namespace specialSet.insert(SETTING_CLOUD_TEXTUREID); specialSet.insert(SETTING_MOON_TEXTUREID); specialSet.insert(SETTING_SUN_TEXTUREID); + specialSet.insert(SETTING_CLOUD_SHADOW); // due to being part of skips } return specialSet; } @@ -652,6 +653,7 @@ namespace template<> void LLSettingsInjected::updateSpecial(const typename LLSettingsInjected::Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix) { + bool is_texture = true; if (injection->mKeyName == SETTING_SUN_TEXTUREID) { mNextSunTextureId = injection->mValue.asUUID(); @@ -676,9 +678,29 @@ namespace { mNextHaloTextureId = injection->mValue.asUUID(); } + else if (injection->mKeyName == LLSettingsSky::SETTING_CLOUD_SHADOW) + { + // Special case due to being texture dependent and part of skips + is_texture = false; + if (!injection->mBlendIn) + mix = 1.0 - mix; + stringset_t dummy; + LLUUID cloud_noise_id = getCloudNoiseTextureId(); + F64 value = this->mSettings[injection->mKeyName].asReal(); + if (this->getCloudNoiseTextureId().isNull()) + { + value = 0; // there was no texture so start from zero coverage + } + // Ideally we need to check for texture in injection, but + // in this case user is setting value explicitly, potentially + // with different transitions, don't ignore it + F64 result = lerp(value, injection->mValue.asReal(), mix); + injection->mLastValue = LLSD::Real(result); + this->mSettings[injection->mKeyName] = injection->mLastValue; + } // Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along. - if (getBlendFactor() < mix) + if (is_texture && getBlendFactor() < mix) { setBlendFactor(mix); } -- cgit v1.2.3 From 639acb6ff7495a6840d437dd8473172ec03e200a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 1 Jun 2021 20:13:13 +0300 Subject: SL-15333 Crash in glh_init_extensions --- autobuild.xml | 4 +- indra/llrender/llgl.cpp | 2 +- indra/llwindow/GL/glh_extensions.h | 211 ----- indra/llwindow/GL/glh_genext.h | 1674 ------------------------------------ 4 files changed, 3 insertions(+), 1888 deletions(-) delete mode 100644 indra/llwindow/GL/glh_extensions.h delete mode 100644 indra/llwindow/GL/glh_genext.h diff --git a/autobuild.xml b/autobuild.xml index 2470b2e5aa..e92718f481 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -1036,9 +1036,9 @@ archive hash - 650e836255b6c2ecb93d3f1f7220051c + dce3f3c01fddb400cb143c3283fe9259 url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/55011/511905/glh_linear-0.0.0-common-538981.tar.bz2 + https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/82754/775367/glh_linear-0.0.0-common-560278.tar.bz2 name common diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 43fedeca64..33cd840e50 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -559,7 +559,7 @@ bool LLGLManager::initGL() glGetIntegerv(GL_NUM_EXTENSIONS, &count); for (GLint i = 0; i < count; ++i) { - std::string ext((const char*) glGetStringi(GL_EXTENSIONS, i)); + std::string ext = ll_safe_string((const char*) glGetStringi(GL_EXTENSIONS, i)); str << ext << " "; LL_DEBUGS("GLExtensions") << ext << LL_ENDL; } diff --git a/indra/llwindow/GL/glh_extensions.h b/indra/llwindow/GL/glh_extensions.h deleted file mode 100644 index 554cb1731f..0000000000 --- a/indra/llwindow/GL/glh_extensions.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * glh_extensions.h - * $LicenseInfo:firstyear=2006&license=mit$ (mit used here to satisfy validity checker) - * Copyright (C) 2006, NVIDIA - * From nVidia Corporation, downloaded 2006-12-18 from: - * http://developer.nvidia.com/attach/8196 - * ("NVParse Library with Source (.zip) (2390 KB)") - * - * License (quoted from license_info.txt in aforementioned file): - * "The files bison.exe, bison.simple, and flex.exe are covered by - * the GPL. All other files in this distribution can be used however - * you want." - * $/LicenseInfo$ - - */ - -#ifndef GLH_EXTENSIONS -#define GLH_EXTENSIONS - -#include -#include - -#ifdef _WIN32 -# include -#endif - -#ifndef __APPLE__ -#include -#endif - -#ifdef _WIN32 -# include "GL/wglext.h" -#endif - -#define CHECK_MEMORY(ptr) \ - if (NULL == ptr) { \ - printf("Error allocating memory in file %s, line %d\n", __FILE__, __LINE__); \ - exit(-1); \ - } - -#ifdef GLH_EXT_SINGLE_FILE -# define GLH_EXTENSIONS_SINGLE_FILE // have to do this because glh_genext.h unsets GLH_EXT_SINGLE_FILE -#endif - -#include "glh_genext.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef GLH_EXTENSIONS_SINGLE_FILE - -class GLHExts -{ -public: - GLHExts() - { - mSysExts = NULL; -// mUnsupportedExts = NULL; - } - ~GLHExts() - { - if (mSysExts) - { - free(mSysExts); - } -// if (mUnsupportedExts) -// { -// free(mUnsupportedExts); -// } - } - char *mSysExts; -// char *mUnsupportedExts; -}; - -GLHExts gGLHExts; - -static int ExtensionExists(const char* extName, const char* sysExts) -{ - char *padExtName = (char*)malloc(strlen(extName) + 2); - strcat(strcpy(padExtName, extName), " "); - - if (0 == strcmp(extName, "GL_VERSION_1_2")) { - const char *version = (const char*)glGetString(GL_VERSION); - if (strstr(version, "1.0") == version || strstr(version, "1.1") == version) { - return FALSE; - } else { - return TRUE; - } - } - if (strstr(sysExts, padExtName)) { - free(padExtName); - return TRUE; - } else { - free(padExtName); - return FALSE; - } -} - -static const char* EatWhiteSpace(const char *str) -{ - for (; *str && (' ' == *str || '\t' == *str || '\n' == *str); str++); - return str; -} - -static const char* EatNonWhiteSpace(const char *str) -{ - for (; *str && (' ' != *str && '\t' != *str && '\n' != *str); str++); - return str; -} - - -int glh_init_extensions(const char *origReqExts) -{ - // Length of requested extensions string - //unsigned reqExtsLen; - char *reqExts; - // Ptr for individual extensions within reqExts - char *reqExt; - int success = TRUE; - - // build space-padded extension string - if (NULL == gGLHExts.mSysExts) { - const char *extensions = (const char*)glGetString(GL_EXTENSIONS); - int sysExtsLen = (int)strlen(extensions); - const char *winsys_extensions = 0; - int winsysExtsLen = 0; -#ifdef _WIN32 - { - PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = 0; - wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); - if(wglGetExtensionsStringARB) - { - winsys_extensions = wglGetExtensionsStringARB(wglGetCurrentDC()); - winsysExtsLen = (S32)strlen(winsys_extensions); - } - } -#endif - // Add 2 bytes, one for padding space, one for terminating NULL - gGLHExts.mSysExts = (char*)malloc(sysExtsLen + winsysExtsLen + 3); - CHECK_MEMORY(gGLHExts.mSysExts); - strcpy(gGLHExts.mSysExts, extensions); - gGLHExts.mSysExts[sysExtsLen] = ' '; - gGLHExts.mSysExts[sysExtsLen + 1] = 0; - if (winsysExtsLen) - { - strcat(gGLHExts.mSysExts, winsys_extensions); - } - gGLHExts.mSysExts[sysExtsLen + 1 + winsysExtsLen] = ' '; - gGLHExts.mSysExts[sysExtsLen + 1 + winsysExtsLen + 1] = 0; - } - - if (NULL == origReqExts) - { - return TRUE; - } - reqExts = strdup(origReqExts); - /* - reqExtsLen = (S32)strlen(reqExts); - if (NULL == gGLHExts.mUnsupportedExts) - { - gGLHExts.mUnsupportedExts = (char*)malloc(reqExtsLen + 1); - } - else if (reqExtsLen > strlen(gGLHExts.mUnsupportedExts)) - { - gGLHExts.mUnsupportedExts = (char*)realloc(gGLHExts.mUnsupportedExts, reqExtsLen + 1); - } - CHECK_MEMORY(gGLHExts.mUnsupportedExts); - *gGLHExts.mUnsupportedExts = 0; - */ - - // Parse requested extension list - for (reqExt = reqExts; - (reqExt = (char*)EatWhiteSpace(reqExt)) && *reqExt; - reqExt = (char*)EatNonWhiteSpace(reqExt)) - { - char *extEnd = (char*)EatNonWhiteSpace(reqExt); - char saveChar = *extEnd; - *extEnd = (char)0; - - if (!ExtensionExists(reqExt, gGLHExts.mSysExts) || - !glh_init_extension(reqExt)) { - /* - // add reqExt to end of unsupportedExts - strcat(gGLHExts.mUnsupportedExts, reqExt); - strcat(gGLHExts.mUnsupportedExts, " "); - */ - success = FALSE; - } - *extEnd = saveChar; - } - free(reqExts); - return success; -} - -const char* glh_get_unsupported_extensions() -{ - return ""; -// return (const char*)gGLHExts.mUnsupportedExts; -} - -#else -int glh_init_extensions(const char *origReqExts); -const char* glh_get_unsupported_extensions(); -#endif /* GLH_EXT_SINGLE_FILE */ - -#ifdef __cplusplus -} -#endif - -#endif /* GLH_EXTENSIONS */ diff --git a/indra/llwindow/GL/glh_genext.h b/indra/llwindow/GL/glh_genext.h deleted file mode 100644 index cd5d1604a8..0000000000 --- a/indra/llwindow/GL/glh_genext.h +++ /dev/null @@ -1,1674 +0,0 @@ -/* - * glh_genext.h - * $LicenseInfo:firstyear=2008&license=mit$ (mit used here to satisfy validity checker) - * Copyright (C) 2008, NVIDIA - * From nVidia Corporation, downloaded 2006-12-18 from: - * http://developer.nvidia.com/attach/8196 - * ("NVParse Library with Source (.zip) (2390 KB)") - * - * License (quoted from license_info.txt in aforementioned file): - * "The files bison.exe, bison.simple, and flex.exe are covered by - * the GPL. All other files in this distribution can be used however - * you want." - * $/LicenseInfo$ - */ - -/* File generated by extgen.cpp -- do not modify */ -#ifndef GLH_GENEXT_H -#define GLH_GENEXT_H - -// MBW -- None of this is necessary on Mac OS. -#ifndef __APPLE__ - -#include -#include - -#ifdef _WIN32 /* supports windows, x -- need to generalize */ -# include -# define GLH_EXT_GET_PROC_ADDRESS(p) wglGetProcAddress(p) -#else if GLX_VERSION_1_3 -# include -# define GLH_EXT_GET_PROC_ADDRESS(p) glXGetProcAddressARB(p) -#endif - -#ifdef GLH_EXT_SINGLE_FILE - #define GLH_EXTERN - #define GLH_INITIALIZER = 0 -#else - #define GLH_EXTERN extern - #define GLH_INITIALIZER -#endif - -#define GLH__PREPROCESSOR_GYMNASTICS2(a,b) a##b -#define GLH__PREPROCESSOR_GYMNASTICS(a,b) GLH__PREPROCESSOR_GYMNASTICS2(a,b) - -#ifndef GLH_EXT_PREFIX -# define GLH_EXT_NAME(a) a -#else -# define GLH_EXT_NAME(a) GLH__PREPROCESSOR_GYMNASTICS(GLH_EXT_PREFIX,a) -#endif - -#ifndef _WIN32 -# ifndef GLH_CORE_1_2_PREFIX -# define GLH_CORE_1_2_PREFIX _ -# endif -#endif - -#ifndef GLH_CORE_1_2_PREFIX -# define GLH_CORE_1_2_NAME(a) a -#else -# define GLH_CORE_1_2_NAME(a) GLH__PREPROCESSOR_GYMNASTICS(GLH_CORE_1_2_PREFIX,a) -#endif - -#ifdef GL_ARB_multitexture - GLH_EXTERN PFNGLMULTITEXCOORD1DARBPROC GLH_EXT_NAME(glMultiTexCoord1dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD1DVARBPROC GLH_EXT_NAME(glMultiTexCoord1dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD1FARBPROC GLH_EXT_NAME(glMultiTexCoord1fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD1FVARBPROC GLH_EXT_NAME(glMultiTexCoord1fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD1IARBPROC GLH_EXT_NAME(glMultiTexCoord1iARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD1IVARBPROC GLH_EXT_NAME(glMultiTexCoord1ivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD1SARBPROC GLH_EXT_NAME(glMultiTexCoord1sARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD1SVARBPROC GLH_EXT_NAME(glMultiTexCoord1svARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD2DARBPROC GLH_EXT_NAME(glMultiTexCoord2dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD2DVARBPROC GLH_EXT_NAME(glMultiTexCoord2dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD2FARBPROC GLH_EXT_NAME(glMultiTexCoord2fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD2FVARBPROC GLH_EXT_NAME(glMultiTexCoord2fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD2IARBPROC GLH_EXT_NAME(glMultiTexCoord2iARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD2IVARBPROC GLH_EXT_NAME(glMultiTexCoord2ivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD2SARBPROC GLH_EXT_NAME(glMultiTexCoord2sARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD2SVARBPROC GLH_EXT_NAME(glMultiTexCoord2svARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD3DARBPROC GLH_EXT_NAME(glMultiTexCoord3dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD3DVARBPROC GLH_EXT_NAME(glMultiTexCoord3dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD3FARBPROC GLH_EXT_NAME(glMultiTexCoord3fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD3FVARBPROC GLH_EXT_NAME(glMultiTexCoord3fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD3IARBPROC GLH_EXT_NAME(glMultiTexCoord3iARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD3IVARBPROC GLH_EXT_NAME(glMultiTexCoord3ivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD3SARBPROC GLH_EXT_NAME(glMultiTexCoord3sARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD3SVARBPROC GLH_EXT_NAME(glMultiTexCoord3svARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD4DARBPROC GLH_EXT_NAME(glMultiTexCoord4dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD4DVARBPROC GLH_EXT_NAME(glMultiTexCoord4dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD4FARBPROC GLH_EXT_NAME(glMultiTexCoord4fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD4FVARBPROC GLH_EXT_NAME(glMultiTexCoord4fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD4IARBPROC GLH_EXT_NAME(glMultiTexCoord4iARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD4IVARBPROC GLH_EXT_NAME(glMultiTexCoord4ivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD4SARBPROC GLH_EXT_NAME(glMultiTexCoord4sARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTITEXCOORD4SVARBPROC GLH_EXT_NAME(glMultiTexCoord4svARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLACTIVETEXTUREARBPROC GLH_EXT_NAME(glActiveTextureARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLCLIENTACTIVETEXTUREARBPROC GLH_EXT_NAME(glClientActiveTextureARB) GLH_INITIALIZER; -#endif - -#ifdef GL_ARB_texture_border_clamp -#endif - -#ifdef GL_ARB_texture_compression - GLH_EXTERN PFNGLCOMPRESSEDTEXIMAGE3DARBPROC GLH_EXT_NAME(glCompressedTexImage3DARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMPRESSEDTEXIMAGE2DARBPROC GLH_EXT_NAME(glCompressedTexImage2DARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMPRESSEDTEXIMAGE1DARBPROC GLH_EXT_NAME(glCompressedTexImage1DARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC GLH_EXT_NAME(glCompressedTexSubImage3DARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC GLH_EXT_NAME(glCompressedTexSubImage2DARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC GLH_EXT_NAME(glCompressedTexSubImage1DARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOMPRESSEDTEXIMAGEARBPROC GLH_EXT_NAME(glGetCompressedTexImageARB) GLH_INITIALIZER; -#endif - -#ifdef GL_ARB_texture_cube_map -#endif - -#ifdef GL_ARB_transpose_matrix - GLH_EXTERN PFNGLLOADTRANSPOSEMATRIXFARBPROC GLH_EXT_NAME(glLoadTransposeMatrixfARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLLOADTRANSPOSEMATRIXDARBPROC GLH_EXT_NAME(glLoadTransposeMatrixdARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTTRANSPOSEMATRIXFARBPROC GLH_EXT_NAME(glMultTransposeMatrixfARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLMULTTRANSPOSEMATRIXDARBPROC GLH_EXT_NAME(glMultTransposeMatrixdARB) GLH_INITIALIZER; -#endif - -#ifdef GL_ARB_vertex_program - GLH_EXTERN PFNGLVERTEXATTRIB1SARBPROC GLH_EXT_NAME(glVertexAttrib1sARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1FARBPROC GLH_EXT_NAME(glVertexAttrib1fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1DARBPROC GLH_EXT_NAME(glVertexAttrib1dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2SARBPROC GLH_EXT_NAME(glVertexAttrib2sARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2FARBPROC GLH_EXT_NAME(glVertexAttrib2fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2DARBPROC GLH_EXT_NAME(glVertexAttrib2dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3SARBPROC GLH_EXT_NAME(glVertexAttrib3sARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3FARBPROC GLH_EXT_NAME(glVertexAttrib3fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3DARBPROC GLH_EXT_NAME(glVertexAttrib3dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4SARBPROC GLH_EXT_NAME(glVertexAttrib4sARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4FARBPROC GLH_EXT_NAME(glVertexAttrib4fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4DARBPROC GLH_EXT_NAME(glVertexAttrib4dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4NUBARBPROC GLH_EXT_NAME(glVertexAttrib4NubARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1SVARBPROC GLH_EXT_NAME(glVertexAttrib1svARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1FVARBPROC GLH_EXT_NAME(glVertexAttrib1fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1DVARBPROC GLH_EXT_NAME(glVertexAttrib1dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2SVARBPROC GLH_EXT_NAME(glVertexAttrib2svARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2FVARBPROC GLH_EXT_NAME(glVertexAttrib2fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2DVARBPROC GLH_EXT_NAME(glVertexAttrib2dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3SVARBPROC GLH_EXT_NAME(glVertexAttrib3svARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3FVARBPROC GLH_EXT_NAME(glVertexAttrib3fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3DVARBPROC GLH_EXT_NAME(glVertexAttrib3dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4BVARBPROC GLH_EXT_NAME(glVertexAttrib4bvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4SVARBPROC GLH_EXT_NAME(glVertexAttrib4svARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4IVARBPROC GLH_EXT_NAME(glVertexAttrib4ivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4UBVARBPROC GLH_EXT_NAME(glVertexAttrib4ubvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4USVARBPROC GLH_EXT_NAME(glVertexAttrib4usvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4UIVARBPROC GLH_EXT_NAME(glVertexAttrib4uivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4FVARBPROC GLH_EXT_NAME(glVertexAttrib4fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4DVARBPROC GLH_EXT_NAME(glVertexAttrib4dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4NBVARBPROC GLH_EXT_NAME(glVertexAttrib4NbvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4NSVARBPROC GLH_EXT_NAME(glVertexAttrib4NsvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4NIVARBPROC GLH_EXT_NAME(glVertexAttrib4NivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4NUBVARBPROC GLH_EXT_NAME(glVertexAttrib4NubvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4NUSVARBPROC GLH_EXT_NAME(glVertexAttrib4NusvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4NUIVARBPROC GLH_EXT_NAME(glVertexAttrib4NuivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBPOINTERARBPROC GLH_EXT_NAME(glVertexAttribPointerARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLENABLEVERTEXATTRIBARRAYARBPROC GLH_EXT_NAME(glEnableVertexAttribArrayARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLDISABLEVERTEXATTRIBARRAYARBPROC GLH_EXT_NAME(glDisableVertexAttribArrayARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMSTRINGARBPROC GLH_EXT_NAME(glProgramStringARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLBINDPROGRAMARBPROC GLH_EXT_NAME(glBindProgramARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLDELETEPROGRAMSARBPROC GLH_EXT_NAME(glDeleteProgramsARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGENPROGRAMSARBPROC GLH_EXT_NAME(glGenProgramsARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMENVPARAMETER4DARBPROC GLH_EXT_NAME(glProgramEnvParameter4dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMENVPARAMETER4DVARBPROC GLH_EXT_NAME(glProgramEnvParameter4dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMENVPARAMETER4FARBPROC GLH_EXT_NAME(glProgramEnvParameter4fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMENVPARAMETER4FVARBPROC GLH_EXT_NAME(glProgramEnvParameter4fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMLOCALPARAMETER4DARBPROC GLH_EXT_NAME(glProgramLocalParameter4dARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMLOCALPARAMETER4DVARBPROC GLH_EXT_NAME(glProgramLocalParameter4dvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMLOCALPARAMETER4FARBPROC GLH_EXT_NAME(glProgramLocalParameter4fARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMLOCALPARAMETER4FVARBPROC GLH_EXT_NAME(glProgramLocalParameter4fvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMENVPARAMETERDVARBPROC GLH_EXT_NAME(glGetProgramEnvParameterdvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMENVPARAMETERFVARBPROC GLH_EXT_NAME(glGetProgramEnvParameterfvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC GLH_EXT_NAME(glGetProgramLocalParameterdvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC GLH_EXT_NAME(glGetProgramLocalParameterfvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMIVARBPROC GLH_EXT_NAME(glGetProgramivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMSTRINGARBPROC GLH_EXT_NAME(glGetProgramStringARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETVERTEXATTRIBDVARBPROC GLH_EXT_NAME(glGetVertexAttribdvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETVERTEXATTRIBFVARBPROC GLH_EXT_NAME(glGetVertexAttribfvARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETVERTEXATTRIBIVARBPROC GLH_EXT_NAME(glGetVertexAttribivARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETVERTEXATTRIBPOINTERVARBPROC GLH_EXT_NAME(glGetVertexAttribPointervARB) GLH_INITIALIZER; - GLH_EXTERN PFNGLISPROGRAMARBPROC GLH_EXT_NAME(glIsProgramARB) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_abgr -#endif - -#ifdef GL_EXT_bgra -#endif - -#ifdef GL_EXT_blend_color - GLH_EXTERN PFNGLBLENDCOLOREXTPROC GLH_EXT_NAME(glBlendColorEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_blend_minmax - GLH_EXTERN PFNGLBLENDEQUATIONEXTPROC GLH_EXT_NAME(glBlendEquationEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_blend_subtract -#endif - -#ifdef GL_EXT_compiled_vertex_array - GLH_EXTERN PFNGLLOCKARRAYSEXTPROC GLH_EXT_NAME(glLockArraysEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLUNLOCKARRAYSEXTPROC GLH_EXT_NAME(glUnlockArraysEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_fog_coord - GLH_EXTERN PFNGLFOGCOORDDEXTPROC GLH_EXT_NAME(glFogCoorddEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLFOGCOORDDVEXTPROC GLH_EXT_NAME(glFogCoorddvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLFOGCOORDFEXTPROC GLH_EXT_NAME(glFogCoordfEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLFOGCOORDFVEXTPROC GLH_EXT_NAME(glFogCoordfvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLFOGCOORDPOINTEREXTPROC GLH_EXT_NAME(glFogCoordPointerEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_light_max_exponent -#endif - -#ifdef GL_EXT_packed_pixels -#endif - -#ifdef GL_EXT_paletted_texture - GLH_EXTERN PFNGLCOLORSUBTABLEEXTPROC GLH_EXT_NAME(glColorSubTableEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOLORTABLEEXTPROC GLH_EXT_NAME(glColorTableEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOLORTABLEEXTPROC GLH_EXT_NAME(glGetColorTableEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOLORTABLEPARAMETERFVEXTPROC GLH_EXT_NAME(glGetColorTableParameterfvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOLORTABLEPARAMETERIVEXTPROC GLH_EXT_NAME(glGetColorTableParameterivEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_point_parameters - GLH_EXTERN PFNGLPOINTPARAMETERFEXTPROC GLH_EXT_NAME(glPointParameterfEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLPOINTPARAMETERFVEXTPROC GLH_EXT_NAME(glPointParameterfvEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_rescale_normal -#endif - -#ifdef GL_EXT_secondary_color - GLH_EXTERN PFNGLSECONDARYCOLOR3BEXTPROC GLH_EXT_NAME(glSecondaryColor3bEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3BVEXTPROC GLH_EXT_NAME(glSecondaryColor3bvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3DEXTPROC GLH_EXT_NAME(glSecondaryColor3dEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3DVEXTPROC GLH_EXT_NAME(glSecondaryColor3dvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3FEXTPROC GLH_EXT_NAME(glSecondaryColor3fEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3FVEXTPROC GLH_EXT_NAME(glSecondaryColor3fvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3IEXTPROC GLH_EXT_NAME(glSecondaryColor3iEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3IVEXTPROC GLH_EXT_NAME(glSecondaryColor3ivEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3SEXTPROC GLH_EXT_NAME(glSecondaryColor3sEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3SVEXTPROC GLH_EXT_NAME(glSecondaryColor3svEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3UBEXTPROC GLH_EXT_NAME(glSecondaryColor3ubEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3UBVEXTPROC GLH_EXT_NAME(glSecondaryColor3ubvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3UIEXTPROC GLH_EXT_NAME(glSecondaryColor3uiEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3UIVEXTPROC GLH_EXT_NAME(glSecondaryColor3uivEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3USEXTPROC GLH_EXT_NAME(glSecondaryColor3usEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLOR3USVEXTPROC GLH_EXT_NAME(glSecondaryColor3usvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLSECONDARYCOLORPOINTEREXTPROC GLH_EXT_NAME(glSecondaryColorPointerEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_separate_specular_color -#endif - -#ifdef GL_EXT_shared_texture_palette -#endif - -#ifdef GL_EXT_stencil_wrap -#endif - -#ifdef GL_EXT_texture_compression_s3tc -#endif - -#ifdef GL_EXT_texture_cube_map -#endif - -#ifdef GL_EXT_texture_edge_clamp -#endif - -#ifdef GL_EXT_texture_env_add -#endif - -#ifdef GL_EXT_texture_env_combine -#endif - -#ifdef GL_EXT_texture_filter_anisotropic -#endif - -#ifdef GL_EXT_texture_lod_bias -#endif - -#ifdef GL_EXT_texture_object - GLH_EXTERN PFNGLARETEXTURESRESIDENTEXTPROC GLH_EXT_NAME(glAreTexturesResidentEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLBINDTEXTUREEXTPROC GLH_EXT_NAME(glBindTextureEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLDELETETEXTURESEXTPROC GLH_EXT_NAME(glDeleteTexturesEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLGENTEXTURESEXTPROC GLH_EXT_NAME(glGenTexturesEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLISTEXTUREEXTPROC GLH_EXT_NAME(glIsTextureEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLPRIORITIZETEXTURESEXTPROC GLH_EXT_NAME(glPrioritizeTexturesEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_texture3D - GLH_EXTERN PFNGLTEXIMAGE3DEXTPROC GLH_EXT_NAME(glTexImage3DEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_vertex_array - GLH_EXTERN PFNGLARRAYELEMENTEXTPROC GLH_EXT_NAME(glArrayElementEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOLORPOINTEREXTPROC GLH_EXT_NAME(glColorPointerEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLEDGEFLAGPOINTEREXTPROC GLH_EXT_NAME(glEdgeFlagPointerEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPOINTERVEXTPROC GLH_EXT_NAME(glGetPointervEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLINDEXPOINTEREXTPROC GLH_EXT_NAME(glIndexPointerEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLNORMALPOINTEREXTPROC GLH_EXT_NAME(glNormalPointerEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLTEXCOORDPOINTEREXTPROC GLH_EXT_NAME(glTexCoordPointerEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXPOINTEREXTPROC GLH_EXT_NAME(glVertexPointerEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLDRAWARRAYSEXTPROC GLH_EXT_NAME(glDrawArraysEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_EXT_vertex_weighting - GLH_EXTERN PFNGLVERTEXWEIGHTFEXTPROC GLH_EXT_NAME(glVertexWeightfEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXWEIGHTFVEXTPROC GLH_EXT_NAME(glVertexWeightfvEXT) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXWEIGHTPOINTEREXTPROC GLH_EXT_NAME(glVertexWeightPointerEXT) GLH_INITIALIZER; -#endif - -#ifdef GL_NV_blend_square -#endif - -#ifdef GL_NV_evaluators - GLH_EXTERN PFNGLMAPCONTROLPOINTSNVPROC GLH_EXT_NAME(glMapControlPointsNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLMAPPARAMETERIVNVPROC GLH_EXT_NAME(glMapParameterivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLMAPPARAMETERFVNVPROC GLH_EXT_NAME(glMapParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETMAPCONTROLPOINTSNVPROC GLH_EXT_NAME(glGetMapControlPointsNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETMAPPARAMETERIVNVPROC GLH_EXT_NAME(glGetMapParameterivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETMAPPARAMETERFVNVPROC GLH_EXT_NAME(glGetMapParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETMAPATTRIBPARAMETERIVNVPROC GLH_EXT_NAME(glGetMapAttribParameterivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETMAPATTRIBPARAMETERFVNVPROC GLH_EXT_NAME(glGetMapAttribParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLEVALMAPSNVPROC GLH_EXT_NAME(glEvalMapsNV) GLH_INITIALIZER; -#endif - -#ifdef GL_NV_fence - GLH_EXTERN PFNGLGENFENCESNVPROC GLH_EXT_NAME(glGenFencesNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLDELETEFENCESNVPROC GLH_EXT_NAME(glDeleteFencesNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLSETFENCENVPROC GLH_EXT_NAME(glSetFenceNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLTESTFENCENVPROC GLH_EXT_NAME(glTestFenceNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLFINISHFENCENVPROC GLH_EXT_NAME(glFinishFenceNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLISFENCENVPROC GLH_EXT_NAME(glIsFenceNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETFENCEIVNVPROC GLH_EXT_NAME(glGetFenceivNV) GLH_INITIALIZER; -#endif - -#ifdef GL_NV_fog_distance -#endif - -#ifdef GL_NV_packed_depth_stencil -#endif - -#ifdef GL_NV_register_combiners - GLH_EXTERN PFNGLCOMBINERPARAMETERFVNVPROC GLH_EXT_NAME(glCombinerParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMBINERPARAMETERFNVPROC GLH_EXT_NAME(glCombinerParameterfNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMBINERPARAMETERIVNVPROC GLH_EXT_NAME(glCombinerParameterivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMBINERPARAMETERINVPROC GLH_EXT_NAME(glCombinerParameteriNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMBINERINPUTNVPROC GLH_EXT_NAME(glCombinerInputNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOMBINEROUTPUTNVPROC GLH_EXT_NAME(glCombinerOutputNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLFINALCOMBINERINPUTNVPROC GLH_EXT_NAME(glFinalCombinerInputNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC GLH_EXT_NAME(glGetCombinerInputParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC GLH_EXT_NAME(glGetCombinerInputParameterivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC GLH_EXT_NAME(glGetCombinerOutputParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC GLH_EXT_NAME(glGetCombinerOutputParameterivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC GLH_EXT_NAME(glGetFinalCombinerInputParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC GLH_EXT_NAME(glGetFinalCombinerInputParameterivNV) GLH_INITIALIZER; -#endif - -#ifdef GL_NV_register_combiners2 - GLH_EXTERN PFNGLCOMBINERSTAGEPARAMETERFVNVPROC GLH_EXT_NAME(glCombinerStageParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC GLH_EXT_NAME(glGetCombinerStageParameterfvNV) GLH_INITIALIZER; -#endif - -#ifdef GL_NV_texgen_reflection -#endif - -#ifdef GL_NV_texture_env_combine4 -#endif - -#ifdef GL_NV_texture_rectangle -#endif - -#ifdef GL_NV_texture_shader -#endif - -#ifdef GL_NV_vertex_array_range - GLH_EXTERN PFNGLFLUSHVERTEXARRAYRANGENVPROC GLH_EXT_NAME(glFlushVertexArrayRangeNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXARRAYRANGENVPROC GLH_EXT_NAME(glVertexArrayRangeNV) GLH_INITIALIZER; -# ifdef _WIN32 - GLH_EXTERN PFNWGLALLOCATEMEMORYNVPROC GLH_EXT_NAME(wglAllocateMemoryNV) GLH_INITIALIZER; -# endif -# ifdef GLX_VERSION_1_3 - GLH_EXTERN PFNGLXALLOCATEMEMORYNVPROC GLH_EXT_NAME(glXAllocateMemoryNV) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLFREEMEMORYNVPROC GLH_EXT_NAME(wglFreeMemoryNV) GLH_INITIALIZER; -# endif -# ifdef GLX_VERSION_1_3 - GLH_EXTERN PFNGLXFREEMEMORYNVPROC GLH_EXT_NAME(glXFreeMemoryNV) GLH_INITIALIZER; -# endif -#endif - -#ifdef GL_NV_vertex_program - GLH_EXTERN PFNGLAREPROGRAMSRESIDENTNVPROC GLH_EXT_NAME(glAreProgramsResidentNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLBINDPROGRAMNVPROC GLH_EXT_NAME(glBindProgramNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLDELETEPROGRAMSNVPROC GLH_EXT_NAME(glDeleteProgramsNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLEXECUTEPROGRAMNVPROC GLH_EXT_NAME(glExecuteProgramNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGENPROGRAMSNVPROC GLH_EXT_NAME(glGenProgramsNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMPARAMETERDVNVPROC GLH_EXT_NAME(glGetProgramParameterdvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMPARAMETERFVNVPROC GLH_EXT_NAME(glGetProgramParameterfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMIVNVPROC GLH_EXT_NAME(glGetProgramivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETPROGRAMSTRINGNVPROC GLH_EXT_NAME(glGetProgramStringNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETTRACKMATRIXIVNVPROC GLH_EXT_NAME(glGetTrackMatrixivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETVERTEXATTRIBDVNVPROC GLH_EXT_NAME(glGetVertexAttribdvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETVERTEXATTRIBFVNVPROC GLH_EXT_NAME(glGetVertexAttribfvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETVERTEXATTRIBIVNVPROC GLH_EXT_NAME(glGetVertexAttribivNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETVERTEXATTRIBPOINTERVNVPROC GLH_EXT_NAME(glGetVertexAttribPointervNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLISPROGRAMNVPROC GLH_EXT_NAME(glIsProgramNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLLOADPROGRAMNVPROC GLH_EXT_NAME(glLoadProgramNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMPARAMETER4DNVPROC GLH_EXT_NAME(glProgramParameter4dNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMPARAMETER4DVNVPROC GLH_EXT_NAME(glProgramParameter4dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMPARAMETER4FNVPROC GLH_EXT_NAME(glProgramParameter4fNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMPARAMETER4FVNVPROC GLH_EXT_NAME(glProgramParameter4fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMPARAMETERS4DVNVPROC GLH_EXT_NAME(glProgramParameters4dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLPROGRAMPARAMETERS4FVNVPROC GLH_EXT_NAME(glProgramParameters4fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLREQUESTRESIDENTPROGRAMSNVPROC GLH_EXT_NAME(glRequestResidentProgramsNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLTRACKMATRIXNVPROC GLH_EXT_NAME(glTrackMatrixNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBPOINTERNVPROC GLH_EXT_NAME(glVertexAttribPointerNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1DNVPROC GLH_EXT_NAME(glVertexAttrib1dNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1DVNVPROC GLH_EXT_NAME(glVertexAttrib1dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1FNVPROC GLH_EXT_NAME(glVertexAttrib1fNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1FVNVPROC GLH_EXT_NAME(glVertexAttrib1fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1SNVPROC GLH_EXT_NAME(glVertexAttrib1sNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB1SVNVPROC GLH_EXT_NAME(glVertexAttrib1svNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2DNVPROC GLH_EXT_NAME(glVertexAttrib2dNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2DVNVPROC GLH_EXT_NAME(glVertexAttrib2dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2FNVPROC GLH_EXT_NAME(glVertexAttrib2fNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2FVNVPROC GLH_EXT_NAME(glVertexAttrib2fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2SNVPROC GLH_EXT_NAME(glVertexAttrib2sNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB2SVNVPROC GLH_EXT_NAME(glVertexAttrib2svNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3DNVPROC GLH_EXT_NAME(glVertexAttrib3dNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3DVNVPROC GLH_EXT_NAME(glVertexAttrib3dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3FNVPROC GLH_EXT_NAME(glVertexAttrib3fNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3FVNVPROC GLH_EXT_NAME(glVertexAttrib3fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3SNVPROC GLH_EXT_NAME(glVertexAttrib3sNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB3SVNVPROC GLH_EXT_NAME(glVertexAttrib3svNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4DNVPROC GLH_EXT_NAME(glVertexAttrib4dNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4DVNVPROC GLH_EXT_NAME(glVertexAttrib4dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4FNVPROC GLH_EXT_NAME(glVertexAttrib4fNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4FVNVPROC GLH_EXT_NAME(glVertexAttrib4fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4SNVPROC GLH_EXT_NAME(glVertexAttrib4sNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4SVNVPROC GLH_EXT_NAME(glVertexAttrib4svNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIB4UBVNVPROC GLH_EXT_NAME(glVertexAttrib4ubvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS1DVNVPROC GLH_EXT_NAME(glVertexAttribs1dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS1FVNVPROC GLH_EXT_NAME(glVertexAttribs1fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS1SVNVPROC GLH_EXT_NAME(glVertexAttribs1svNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS2DVNVPROC GLH_EXT_NAME(glVertexAttribs2dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS2FVNVPROC GLH_EXT_NAME(glVertexAttribs2fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS2SVNVPROC GLH_EXT_NAME(glVertexAttribs2svNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS3DVNVPROC GLH_EXT_NAME(glVertexAttribs3dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS3FVNVPROC GLH_EXT_NAME(glVertexAttribs3fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS3SVNVPROC GLH_EXT_NAME(glVertexAttribs3svNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS4DVNVPROC GLH_EXT_NAME(glVertexAttribs4dvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS4FVNVPROC GLH_EXT_NAME(glVertexAttribs4fvNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS4SVNVPROC GLH_EXT_NAME(glVertexAttribs4svNV) GLH_INITIALIZER; - GLH_EXTERN PFNGLVERTEXATTRIBS4UBVNVPROC GLH_EXT_NAME(glVertexAttribs4ubvNV) GLH_INITIALIZER; -#endif - -#ifdef GL_SGIS_generate_mipmap -#endif - -#ifdef GL_SGIS_texture_lod -#endif - -#ifdef GL_SGIX_depth_texture -#endif - -#ifdef GL_SGIX_shadow -#endif - -#ifdef GL_VERSION_1_2 - /* These routines are prefixed by the preprocessor constant - GLH_CORE_1_2_PREFIX to avoid colliding with the OpenGL 1.2 namespace. */ - GLH_EXTERN PFNGLBLENDCOLORPROC GLH_CORE_1_2_NAME(glBlendColor) GLH_INITIALIZER; - GLH_EXTERN PFNGLBLENDEQUATIONPROC GLH_CORE_1_2_NAME(glBlendEquation) GLH_INITIALIZER; - GLH_EXTERN PFNGLDRAWRANGEELEMENTSPROC GLH_CORE_1_2_NAME(glDrawRangeElements) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOLORTABLEPROC GLH_CORE_1_2_NAME(glColorTable) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOLORTABLEPARAMETERFVPROC GLH_CORE_1_2_NAME(glColorTableParameterfv) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOLORTABLEPARAMETERIVPROC GLH_CORE_1_2_NAME(glColorTableParameteriv) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOPYCOLORTABLEPROC GLH_CORE_1_2_NAME(glCopyColorTable) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOLORTABLEPROC GLH_CORE_1_2_NAME(glGetColorTable) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOLORTABLEPARAMETERFVPROC GLH_CORE_1_2_NAME(glGetColorTableParameterfv) GLH_INITIALIZER; - GLH_EXTERN PFNGLGETCOLORTABLEPARAMETERIVPROC GLH_CORE_1_2_NAME(glGetColorTableParameteriv) GLH_INITIALIZER; - GLH_EXTERN PFNGLTEXIMAGE3DPROC GLH_CORE_1_2_NAME(glTexImage3D) GLH_INITIALIZER; - GLH_EXTERN PFNGLTEXSUBIMAGE3DPROC GLH_CORE_1_2_NAME(glTexSubImage3D) GLH_INITIALIZER; - GLH_EXTERN PFNGLCOPYTEXSUBIMAGE3DPROC GLH_CORE_1_2_NAME(glCopyTexSubImage3D) GLH_INITIALIZER; -#endif - -#ifdef GL_WIN_swap_hint - GLH_EXTERN PFNGLADDSWAPHINTRECTWINPROC GLH_EXT_NAME(glAddSwapHintRectWIN) GLH_INITIALIZER; -#endif - -#ifdef WGL_ARB_pbuffer -# ifdef _WIN32 - GLH_EXTERN PFNWGLCREATEPBUFFERARBPROC GLH_EXT_NAME(wglCreatePbufferARB) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLGETPBUFFERDCARBPROC GLH_EXT_NAME(wglGetPbufferDCARB) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLRELEASEPBUFFERDCARBPROC GLH_EXT_NAME(wglReleasePbufferDCARB) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLDESTROYPBUFFERARBPROC GLH_EXT_NAME(wglDestroyPbufferARB) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLQUERYPBUFFERARBPROC GLH_EXT_NAME(wglQueryPbufferARB) GLH_INITIALIZER; -# endif -#endif - -#ifdef WGL_ARB_render_texture -# ifdef _WIN32 - GLH_EXTERN PFNWGLBINDTEXIMAGEARBPROC GLH_EXT_NAME(wglBindTexImageARB) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLRELEASETEXIMAGEARBPROC GLH_EXT_NAME(wglReleaseTexImageARB) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLSETPBUFFERATTRIBARBPROC GLH_EXT_NAME(wglSetPbufferAttribARB) GLH_INITIALIZER; -# endif -#endif - -#ifdef WGL_ARB_pixel_format -# ifdef _WIN32 - GLH_EXTERN PFNWGLGETPIXELFORMATATTRIBIVARBPROC GLH_EXT_NAME(wglGetPixelFormatAttribivARB) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLGETPIXELFORMATATTRIBFVARBPROC GLH_EXT_NAME(wglGetPixelFormatAttribfvARB) GLH_INITIALIZER; -# endif -# ifdef _WIN32 - GLH_EXTERN PFNWGLCHOOSEPIXELFORMATARBPROC GLH_EXT_NAME(wglChoosePixelFormatARB) GLH_INITIALIZER; -# endif -#endif - - -#ifdef GLH_EXT_SINGLE_FILE - -int glh_init_extension(const char* extension) -{ - if (NULL == extension) { - return FALSE; -#ifdef GL_ARB_multitexture - } else if (0 == strcmp(extension, "GL_ARB_multitexture")) { - GLH_EXT_NAME(glMultiTexCoord1dARB) = (PFNGLMULTITEXCOORD1DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord1dARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord1dARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord1dvARB) = (PFNGLMULTITEXCOORD1DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord1dvARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord1dvARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord1fARB) = (PFNGLMULTITEXCOORD1FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord1fARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord1fARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord1fvARB) = (PFNGLMULTITEXCOORD1FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord1fvARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord1fvARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord1iARB) = (PFNGLMULTITEXCOORD1IARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord1iARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord1iARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord1ivARB) = (PFNGLMULTITEXCOORD1IVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord1ivARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord1ivARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord1sARB) = (PFNGLMULTITEXCOORD1SARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord1sARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord1sARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord1svARB) = (PFNGLMULTITEXCOORD1SVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord1svARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord1svARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord2dARB) = (PFNGLMULTITEXCOORD2DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord2dARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord2dARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord2dvARB) = (PFNGLMULTITEXCOORD2DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord2dvARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord2dvARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord2fARB) = (PFNGLMULTITEXCOORD2FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord2fARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord2fARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord2fvARB) = (PFNGLMULTITEXCOORD2FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord2fvARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord2fvARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord2iARB) = (PFNGLMULTITEXCOORD2IARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord2iARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord2iARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord2ivARB) = (PFNGLMULTITEXCOORD2IVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord2ivARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord2ivARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord2sARB) = (PFNGLMULTITEXCOORD2SARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord2sARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord2sARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord2svARB) = (PFNGLMULTITEXCOORD2SVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord2svARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord2svARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord3dARB) = (PFNGLMULTITEXCOORD3DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord3dARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord3dARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord3dvARB) = (PFNGLMULTITEXCOORD3DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord3dvARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord3dvARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord3fARB) = (PFNGLMULTITEXCOORD3FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord3fARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord3fARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord3fvARB) = (PFNGLMULTITEXCOORD3FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord3fvARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord3fvARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord3iARB) = (PFNGLMULTITEXCOORD3IARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord3iARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord3iARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord3ivARB) = (PFNGLMULTITEXCOORD3IVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord3ivARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord3ivARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord3sARB) = (PFNGLMULTITEXCOORD3SARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord3sARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord3sARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord3svARB) = (PFNGLMULTITEXCOORD3SVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord3svARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord3svARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord4dARB) = (PFNGLMULTITEXCOORD4DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord4dARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord4dARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord4dvARB) = (PFNGLMULTITEXCOORD4DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord4dvARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord4dvARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord4fARB) = (PFNGLMULTITEXCOORD4FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord4fARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord4fARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord4fvARB) = (PFNGLMULTITEXCOORD4FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord4fvARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord4fvARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord4iARB) = (PFNGLMULTITEXCOORD4IARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord4iARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord4iARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord4ivARB) = (PFNGLMULTITEXCOORD4IVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord4ivARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord4ivARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord4sARB) = (PFNGLMULTITEXCOORD4SARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord4sARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord4sARB)) - return FALSE; - GLH_EXT_NAME(glMultiTexCoord4svARB) = (PFNGLMULTITEXCOORD4SVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultiTexCoord4svARB"); - if (NULL == GLH_EXT_NAME(glMultiTexCoord4svARB)) - return FALSE; - GLH_EXT_NAME(glActiveTextureARB) = (PFNGLACTIVETEXTUREARBPROC)GLH_EXT_GET_PROC_ADDRESS("glActiveTextureARB"); - if (NULL == GLH_EXT_NAME(glActiveTextureARB)) - return FALSE; - GLH_EXT_NAME(glClientActiveTextureARB) = (PFNGLCLIENTACTIVETEXTUREARBPROC)GLH_EXT_GET_PROC_ADDRESS("glClientActiveTextureARB"); - if (NULL == GLH_EXT_NAME(glClientActiveTextureARB)) - return FALSE; -#endif - -#ifdef GL_ARB_texture_border_clamp - } else if (0 == strcmp(extension, "GL_ARB_texture_border_clamp")) { -#endif - -#ifdef GL_ARB_texture_compression - } else if (0 == strcmp(extension, "GL_ARB_texture_compression")) { - GLH_EXT_NAME(glCompressedTexImage3DARB) = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glCompressedTexImage3DARB"); - if (NULL == GLH_EXT_NAME(glCompressedTexImage3DARB)) - return FALSE; - GLH_EXT_NAME(glCompressedTexImage2DARB) = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glCompressedTexImage2DARB"); - if (NULL == GLH_EXT_NAME(glCompressedTexImage2DARB)) - return FALSE; - GLH_EXT_NAME(glCompressedTexImage1DARB) = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glCompressedTexImage1DARB"); - if (NULL == GLH_EXT_NAME(glCompressedTexImage1DARB)) - return FALSE; - GLH_EXT_NAME(glCompressedTexSubImage3DARB) = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glCompressedTexSubImage3DARB"); - if (NULL == GLH_EXT_NAME(glCompressedTexSubImage3DARB)) - return FALSE; - GLH_EXT_NAME(glCompressedTexSubImage2DARB) = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glCompressedTexSubImage2DARB"); - if (NULL == GLH_EXT_NAME(glCompressedTexSubImage2DARB)) - return FALSE; - GLH_EXT_NAME(glCompressedTexSubImage1DARB) = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glCompressedTexSubImage1DARB"); - if (NULL == GLH_EXT_NAME(glCompressedTexSubImage1DARB)) - return FALSE; - GLH_EXT_NAME(glGetCompressedTexImageARB) = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetCompressedTexImageARB"); - if (NULL == GLH_EXT_NAME(glGetCompressedTexImageARB)) - return FALSE; -#endif - -#ifdef GL_ARB_texture_cube_map - } else if (0 == strcmp(extension, "GL_ARB_texture_cube_map")) { -#endif - -#ifdef GL_ARB_transpose_matrix - } else if (0 == strcmp(extension, "GL_ARB_transpose_matrix")) { - GLH_EXT_NAME(glLoadTransposeMatrixfARB) = (PFNGLLOADTRANSPOSEMATRIXFARBPROC)GLH_EXT_GET_PROC_ADDRESS("glLoadTransposeMatrixfARB"); - if (NULL == GLH_EXT_NAME(glLoadTransposeMatrixfARB)) - return FALSE; - GLH_EXT_NAME(glLoadTransposeMatrixdARB) = (PFNGLLOADTRANSPOSEMATRIXDARBPROC)GLH_EXT_GET_PROC_ADDRESS("glLoadTransposeMatrixdARB"); - if (NULL == GLH_EXT_NAME(glLoadTransposeMatrixdARB)) - return FALSE; - GLH_EXT_NAME(glMultTransposeMatrixfARB) = (PFNGLMULTTRANSPOSEMATRIXFARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultTransposeMatrixfARB"); - if (NULL == GLH_EXT_NAME(glMultTransposeMatrixfARB)) - return FALSE; - GLH_EXT_NAME(glMultTransposeMatrixdARB) = (PFNGLMULTTRANSPOSEMATRIXDARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMultTransposeMatrixdARB"); - if (NULL == GLH_EXT_NAME(glMultTransposeMatrixdARB)) - return FALSE; -#endif - -#ifdef GL_ARB_vertex_program - } else if (0 == strcmp(extension, "GL_ARB_vertex_program")) { - GLH_EXT_NAME(glVertexAttrib1sARB) = (PFNGLVERTEXATTRIB1SARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1sARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1sARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib1fARB) = (PFNGLVERTEXATTRIB1FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1fARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1fARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib1dARB) = (PFNGLVERTEXATTRIB1DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1dARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1dARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib2sARB) = (PFNGLVERTEXATTRIB2SARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2sARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2sARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib2fARB) = (PFNGLVERTEXATTRIB2FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2fARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2fARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib2dARB) = (PFNGLVERTEXATTRIB2DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2dARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2dARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib3sARB) = (PFNGLVERTEXATTRIB3SARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3sARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3sARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib3fARB) = (PFNGLVERTEXATTRIB3FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3fARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3fARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib3dARB) = (PFNGLVERTEXATTRIB3DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3dARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3dARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4sARB) = (PFNGLVERTEXATTRIB4SARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4sARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4sARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4fARB) = (PFNGLVERTEXATTRIB4FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4fARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4fARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4dARB) = (PFNGLVERTEXATTRIB4DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4dARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4dARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4NubARB) = (PFNGLVERTEXATTRIB4NUBARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4NubARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4NubARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib1svARB) = (PFNGLVERTEXATTRIB1SVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1svARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1svARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib1fvARB) = (PFNGLVERTEXATTRIB1FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1fvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1fvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib1dvARB) = (PFNGLVERTEXATTRIB1DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1dvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1dvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib2svARB) = (PFNGLVERTEXATTRIB2SVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2svARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2svARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib2fvARB) = (PFNGLVERTEXATTRIB2FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2fvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2fvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib2dvARB) = (PFNGLVERTEXATTRIB2DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2dvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2dvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib3svARB) = (PFNGLVERTEXATTRIB3SVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3svARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3svARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib3fvARB) = (PFNGLVERTEXATTRIB3FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3fvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3fvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib3dvARB) = (PFNGLVERTEXATTRIB3DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3dvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3dvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4bvARB) = (PFNGLVERTEXATTRIB4BVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4bvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4bvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4svARB) = (PFNGLVERTEXATTRIB4SVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4svARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4svARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4ivARB) = (PFNGLVERTEXATTRIB4IVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4ivARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4ivARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4ubvARB) = (PFNGLVERTEXATTRIB4UBVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4ubvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4ubvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4usvARB) = (PFNGLVERTEXATTRIB4USVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4usvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4usvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4uivARB) = (PFNGLVERTEXATTRIB4UIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4uivARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4uivARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4fvARB) = (PFNGLVERTEXATTRIB4FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4fvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4fvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4dvARB) = (PFNGLVERTEXATTRIB4DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4dvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4dvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4NbvARB) = (PFNGLVERTEXATTRIB4NBVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4NbvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4NbvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4NsvARB) = (PFNGLVERTEXATTRIB4NSVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4NsvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4NsvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4NivARB) = (PFNGLVERTEXATTRIB4NIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4NivARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4NivARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4NubvARB) = (PFNGLVERTEXATTRIB4NUBVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4NubvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4NubvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4NusvARB) = (PFNGLVERTEXATTRIB4NUSVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4NusvARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4NusvARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttrib4NuivARB) = (PFNGLVERTEXATTRIB4NUIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4NuivARB"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4NuivARB)) - return GL_FALSE; - GLH_EXT_NAME(glVertexAttribPointerARB) = (PFNGLVERTEXATTRIBPOINTERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribPointerARB"); - if (NULL == GLH_EXT_NAME(glVertexAttribPointerARB)) - return GL_FALSE; - GLH_EXT_NAME(glEnableVertexAttribArrayARB) = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)GLH_EXT_GET_PROC_ADDRESS("glEnableVertexAttribArrayARB"); - if (NULL == GLH_EXT_NAME(glEnableVertexAttribArrayARB)) - return GL_FALSE; - GLH_EXT_NAME(glDisableVertexAttribArrayARB) = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)GLH_EXT_GET_PROC_ADDRESS("glDisableVertexAttribArrayARB"); - if (NULL == GLH_EXT_NAME(glDisableVertexAttribArrayARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramStringARB) = (PFNGLPROGRAMSTRINGARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramStringARB"); - if (NULL == GLH_EXT_NAME(glProgramStringARB)) - return GL_FALSE; - GLH_EXT_NAME(glBindProgramARB) = (PFNGLBINDPROGRAMARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBindProgramARB"); - if (NULL == GLH_EXT_NAME(glBindProgramARB)) - return GL_FALSE; - GLH_EXT_NAME(glDeleteProgramsARB) = (PFNGLDELETEPROGRAMSARBPROC)GLH_EXT_GET_PROC_ADDRESS("glDeleteProgramsARB"); - if (NULL == GLH_EXT_NAME(glDeleteProgramsARB)) - return GL_FALSE; - GLH_EXT_NAME(glGenProgramsARB) = (PFNGLGENPROGRAMSARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGenProgramsARB"); - if (NULL == GLH_EXT_NAME(glGenProgramsARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramEnvParameter4dARB) = (PFNGLPROGRAMENVPARAMETER4DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramEnvParameter4dARB"); - if (NULL == GLH_EXT_NAME(glProgramEnvParameter4dARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramEnvParameter4dvARB) = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramEnvParameter4dvARB"); - if (NULL == GLH_EXT_NAME(glProgramEnvParameter4dvARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramEnvParameter4fARB) = (PFNGLPROGRAMENVPARAMETER4FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramEnvParameter4fARB"); - if (NULL == GLH_EXT_NAME(glProgramEnvParameter4fARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramEnvParameter4fvARB) = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramEnvParameter4fvARB"); - if (NULL == GLH_EXT_NAME(glProgramEnvParameter4fvARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramLocalParameter4dARB) = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramLocalParameter4dARB"); - if (NULL == GLH_EXT_NAME(glProgramLocalParameter4dARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramLocalParameter4dvARB) = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramLocalParameter4dvARB"); - if (NULL == GLH_EXT_NAME(glProgramLocalParameter4dvARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramLocalParameter4fARB) = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramLocalParameter4fARB"); - if (NULL == GLH_EXT_NAME(glProgramLocalParameter4fARB)) - return GL_FALSE; - GLH_EXT_NAME(glProgramLocalParameter4fvARB) = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramLocalParameter4fvARB"); - if (NULL == GLH_EXT_NAME(glProgramLocalParameter4fvARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetProgramEnvParameterdvARB) = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramEnvParameterdvARB"); - if (NULL == GLH_EXT_NAME(glGetProgramEnvParameterdvARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetProgramEnvParameterfvARB) = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramEnvParameterfvARB"); - if (NULL == GLH_EXT_NAME(glGetProgramEnvParameterfvARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetProgramLocalParameterdvARB) = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramLocalParameterdvARB"); - if (NULL == GLH_EXT_NAME(glGetProgramLocalParameterdvARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetProgramLocalParameterfvARB) = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramLocalParameterfvARB"); - if (NULL == GLH_EXT_NAME(glGetProgramLocalParameterfvARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetProgramivARB) = (PFNGLGETPROGRAMIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramivARB"); - if (NULL == GLH_EXT_NAME(glGetProgramivARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetProgramStringARB) = (PFNGLGETPROGRAMSTRINGARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramStringARB"); - if (NULL == GLH_EXT_NAME(glGetProgramStringARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetVertexAttribdvARB) = (PFNGLGETVERTEXATTRIBDVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetVertexAttribdvARB"); - if (NULL == GLH_EXT_NAME(glGetVertexAttribdvARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetVertexAttribfvARB) = (PFNGLGETVERTEXATTRIBFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetVertexAttribfvARB"); - if (NULL == GLH_EXT_NAME(glGetVertexAttribfvARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetVertexAttribivARB) = (PFNGLGETVERTEXATTRIBIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetVertexAttribivARB"); - if (NULL == GLH_EXT_NAME(glGetVertexAttribivARB)) - return GL_FALSE; - GLH_EXT_NAME(glGetVertexAttribPointervARB) = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetVertexAttribPointervARB"); - if (NULL == GLH_EXT_NAME(glGetVertexAttribPointervARB)) - return GL_FALSE; - GLH_EXT_NAME(glIsProgramARB) = (PFNGLISPROGRAMARBPROC)GLH_EXT_GET_PROC_ADDRESS("glIsProgramARB"); - if (NULL == GLH_EXT_NAME(glIsProgramARB)) - return GL_FALSE; -#endif - -#ifdef GL_EXT_abgr - } else if (0 == strcmp(extension, "GL_EXT_abgr")) { -#endif - -#ifdef GL_EXT_bgra - } else if (0 == strcmp(extension, "GL_EXT_bgra")) { -#endif - -#ifdef GL_EXT_blend_color - } else if (0 == strcmp(extension, "GL_EXT_blend_color")) { - GLH_EXT_NAME(glBlendColorEXT) = (PFNGLBLENDCOLOREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glBlendColorEXT"); - if (NULL == GLH_EXT_NAME(glBlendColorEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_blend_minmax - } else if (0 == strcmp(extension, "GL_EXT_blend_minmax")) { - GLH_EXT_NAME(glBlendEquationEXT) = (PFNGLBLENDEQUATIONEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glBlendEquationEXT"); - if (NULL == GLH_EXT_NAME(glBlendEquationEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_blend_subtract - } else if (0 == strcmp(extension, "GL_EXT_blend_subtract")) { -#endif - -#ifdef GL_EXT_compiled_vertex_array - } else if (0 == strcmp(extension, "GL_EXT_compiled_vertex_array")) { - GLH_EXT_NAME(glLockArraysEXT) = (PFNGLLOCKARRAYSEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glLockArraysEXT"); - if (NULL == GLH_EXT_NAME(glLockArraysEXT)) - return FALSE; - GLH_EXT_NAME(glUnlockArraysEXT) = (PFNGLUNLOCKARRAYSEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glUnlockArraysEXT"); - if (NULL == GLH_EXT_NAME(glUnlockArraysEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_fog_coord - } else if (0 == strcmp(extension, "GL_EXT_fog_coord")) { - GLH_EXT_NAME(glFogCoorddEXT) = (PFNGLFOGCOORDDEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glFogCoorddEXT"); - if (NULL == GLH_EXT_NAME(glFogCoorddEXT)) - return FALSE; - GLH_EXT_NAME(glFogCoorddvEXT) = (PFNGLFOGCOORDDVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glFogCoorddvEXT"); - if (NULL == GLH_EXT_NAME(glFogCoorddvEXT)) - return FALSE; - GLH_EXT_NAME(glFogCoordfEXT) = (PFNGLFOGCOORDFEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glFogCoordfEXT"); - if (NULL == GLH_EXT_NAME(glFogCoordfEXT)) - return FALSE; - GLH_EXT_NAME(glFogCoordfvEXT) = (PFNGLFOGCOORDFVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glFogCoordfvEXT"); - if (NULL == GLH_EXT_NAME(glFogCoordfvEXT)) - return FALSE; - GLH_EXT_NAME(glFogCoordPointerEXT) = (PFNGLFOGCOORDPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glFogCoordPointerEXT"); - if (NULL == GLH_EXT_NAME(glFogCoordPointerEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_light_max_exponent - } else if (0 == strcmp(extension, "GL_EXT_light_max_exponent")) { -#endif - -#ifdef GL_EXT_packed_pixels - } else if (0 == strcmp(extension, "GL_EXT_packed_pixels")) { -#endif - -#ifdef GL_EXT_paletted_texture - } else if (0 == strcmp(extension, "GL_EXT_paletted_texture")) { - GLH_EXT_NAME(glColorSubTableEXT) = (PFNGLCOLORSUBTABLEEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glColorSubTableEXT"); - if (NULL == GLH_EXT_NAME(glColorSubTableEXT)) - return FALSE; - GLH_EXT_NAME(glColorTableEXT) = (PFNGLCOLORTABLEEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glColorTableEXT"); - if (NULL == GLH_EXT_NAME(glColorTableEXT)) - return FALSE; - GLH_EXT_NAME(glGetColorTableEXT) = (PFNGLGETCOLORTABLEEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glGetColorTableEXT"); - if (NULL == GLH_EXT_NAME(glGetColorTableEXT)) - return FALSE; - GLH_EXT_NAME(glGetColorTableParameterfvEXT) = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glGetColorTableParameterfvEXT"); - if (NULL == GLH_EXT_NAME(glGetColorTableParameterfvEXT)) - return FALSE; - GLH_EXT_NAME(glGetColorTableParameterivEXT) = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glGetColorTableParameterivEXT"); - if (NULL == GLH_EXT_NAME(glGetColorTableParameterivEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_point_parameters - } else if (0 == strcmp(extension, "GL_EXT_point_parameters")) { - GLH_EXT_NAME(glPointParameterfEXT) = (PFNGLPOINTPARAMETERFEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfEXT"); - if (NULL == GLH_EXT_NAME(glPointParameterfEXT)) - return FALSE; - GLH_EXT_NAME(glPointParameterfvEXT) = (PFNGLPOINTPARAMETERFVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfvEXT"); - if (NULL == GLH_EXT_NAME(glPointParameterfvEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_rescale_normal - } else if (0 == strcmp(extension, "GL_EXT_rescale_normal")) { -#endif - -#ifdef GL_EXT_secondary_color - } else if (0 == strcmp(extension, "GL_EXT_secondary_color")) { - GLH_EXT_NAME(glSecondaryColor3bEXT) = (PFNGLSECONDARYCOLOR3BEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3bEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3bEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3bvEXT) = (PFNGLSECONDARYCOLOR3BVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3bvEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3bvEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3dEXT) = (PFNGLSECONDARYCOLOR3DEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3dEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3dEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3dvEXT) = (PFNGLSECONDARYCOLOR3DVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3dvEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3dvEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3fEXT) = (PFNGLSECONDARYCOLOR3FEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3fEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3fEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3fvEXT) = (PFNGLSECONDARYCOLOR3FVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3fvEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3fvEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3iEXT) = (PFNGLSECONDARYCOLOR3IEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3iEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3iEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3ivEXT) = (PFNGLSECONDARYCOLOR3IVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3ivEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3ivEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3sEXT) = (PFNGLSECONDARYCOLOR3SEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3sEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3sEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3svEXT) = (PFNGLSECONDARYCOLOR3SVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3svEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3svEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3ubEXT) = (PFNGLSECONDARYCOLOR3UBEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3ubEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3ubEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3ubvEXT) = (PFNGLSECONDARYCOLOR3UBVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3ubvEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3ubvEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3uiEXT) = (PFNGLSECONDARYCOLOR3UIEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3uiEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3uiEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3uivEXT) = (PFNGLSECONDARYCOLOR3UIVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3uivEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3uivEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3usEXT) = (PFNGLSECONDARYCOLOR3USEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3usEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3usEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColor3usvEXT) = (PFNGLSECONDARYCOLOR3USVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColor3usvEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColor3usvEXT)) - return FALSE; - GLH_EXT_NAME(glSecondaryColorPointerEXT) = (PFNGLSECONDARYCOLORPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glSecondaryColorPointerEXT"); - if (NULL == GLH_EXT_NAME(glSecondaryColorPointerEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_separate_specular_color - } else if (0 == strcmp(extension, "GL_EXT_separate_specular_color")) { -#endif - -#ifdef GL_EXT_shared_texture_palette - } else if (0 == strcmp(extension, "GL_EXT_shared_texture_palette")) { -#endif - -#ifdef GL_EXT_stencil_wrap - } else if (0 == strcmp(extension, "GL_EXT_stencil_wrap")) { -#endif - -#ifdef GL_EXT_texture_compression_s3tc - } else if (0 == strcmp(extension, "GL_EXT_texture_compression_s3tc")) { -#endif - -#ifdef GL_EXT_texture_cube_map - } else if (0 == strcmp(extension, "GL_EXT_texture_cube_map")) { -#endif - -#ifdef GL_EXT_texture_edge_clamp - } else if (0 == strcmp(extension, "GL_EXT_texture_edge_clamp")) { -#endif - -#ifdef GL_EXT_texture_env_add - } else if (0 == strcmp(extension, "GL_EXT_texture_env_add")) { -#endif - -#ifdef GL_EXT_texture_env_combine - } else if (0 == strcmp(extension, "GL_EXT_texture_env_combine")) { -#endif - -#ifdef GL_EXT_texture_filter_anisotropic - } else if (0 == strcmp(extension, "GL_EXT_texture_filter_anisotropic")) { -#endif - -#ifdef GL_EXT_texture_lod_bias - } else if (0 == strcmp(extension, "GL_EXT_texture_lod_bias")) { -#endif - -#ifdef GL_EXT_texture_object - } else if (0 == strcmp(extension, "GL_EXT_texture_object")) { - GLH_EXT_NAME(glAreTexturesResidentEXT) = (PFNGLARETEXTURESRESIDENTEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glAreTexturesResidentEXT"); - if (NULL == GLH_EXT_NAME(glAreTexturesResidentEXT)) - return FALSE; - GLH_EXT_NAME(glBindTextureEXT) = (PFNGLBINDTEXTUREEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glBindTextureEXT"); - if (NULL == GLH_EXT_NAME(glBindTextureEXT)) - return FALSE; - GLH_EXT_NAME(glDeleteTexturesEXT) = (PFNGLDELETETEXTURESEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glDeleteTexturesEXT"); - if (NULL == GLH_EXT_NAME(glDeleteTexturesEXT)) - return FALSE; - GLH_EXT_NAME(glGenTexturesEXT) = (PFNGLGENTEXTURESEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glGenTexturesEXT"); - if (NULL == GLH_EXT_NAME(glGenTexturesEXT)) - return FALSE; - GLH_EXT_NAME(glIsTextureEXT) = (PFNGLISTEXTUREEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glIsTextureEXT"); - if (NULL == GLH_EXT_NAME(glIsTextureEXT)) - return FALSE; - GLH_EXT_NAME(glPrioritizeTexturesEXT) = (PFNGLPRIORITIZETEXTURESEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glPrioritizeTexturesEXT"); - if (NULL == GLH_EXT_NAME(glPrioritizeTexturesEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_texture3D - } else if (0 == strcmp(extension, "GL_EXT_texture3D")) { - GLH_EXT_NAME(glTexImage3DEXT) = (PFNGLTEXIMAGE3DEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glTexImage3DEXT"); - if (NULL == GLH_EXT_NAME(glTexImage3DEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_vertex_array - } else if (0 == strcmp(extension, "GL_EXT_vertex_array")) { - GLH_EXT_NAME(glArrayElementEXT) = (PFNGLARRAYELEMENTEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glArrayElementEXT"); - if (NULL == GLH_EXT_NAME(glArrayElementEXT)) - return FALSE; - GLH_EXT_NAME(glColorPointerEXT) = (PFNGLCOLORPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glColorPointerEXT"); - if (NULL == GLH_EXT_NAME(glColorPointerEXT)) - return FALSE; - GLH_EXT_NAME(glEdgeFlagPointerEXT) = (PFNGLEDGEFLAGPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glEdgeFlagPointerEXT"); - if (NULL == GLH_EXT_NAME(glEdgeFlagPointerEXT)) - return FALSE; - GLH_EXT_NAME(glGetPointervEXT) = (PFNGLGETPOINTERVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glGetPointervEXT"); - if (NULL == GLH_EXT_NAME(glGetPointervEXT)) - return FALSE; - GLH_EXT_NAME(glIndexPointerEXT) = (PFNGLINDEXPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glIndexPointerEXT"); - if (NULL == GLH_EXT_NAME(glIndexPointerEXT)) - return FALSE; - GLH_EXT_NAME(glNormalPointerEXT) = (PFNGLNORMALPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glNormalPointerEXT"); - if (NULL == GLH_EXT_NAME(glNormalPointerEXT)) - return FALSE; - GLH_EXT_NAME(glTexCoordPointerEXT) = (PFNGLTEXCOORDPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glTexCoordPointerEXT"); - if (NULL == GLH_EXT_NAME(glTexCoordPointerEXT)) - return FALSE; - GLH_EXT_NAME(glVertexPointerEXT) = (PFNGLVERTEXPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexPointerEXT"); - if (NULL == GLH_EXT_NAME(glVertexPointerEXT)) - return FALSE; - GLH_EXT_NAME(glDrawArraysEXT) = (PFNGLDRAWARRAYSEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glDrawArraysEXT"); - if (NULL == GLH_EXT_NAME(glDrawArraysEXT)) - return FALSE; -#endif - -#ifdef GL_EXT_vertex_weighting - } else if (0 == strcmp(extension, "GL_EXT_vertex_weighting")) { - GLH_EXT_NAME(glVertexWeightfEXT) = (PFNGLVERTEXWEIGHTFEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexWeightfEXT"); - if (NULL == GLH_EXT_NAME(glVertexWeightfEXT)) - return FALSE; - GLH_EXT_NAME(glVertexWeightfvEXT) = (PFNGLVERTEXWEIGHTFVEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexWeightfvEXT"); - if (NULL == GLH_EXT_NAME(glVertexWeightfvEXT)) - return FALSE; - GLH_EXT_NAME(glVertexWeightPointerEXT) = (PFNGLVERTEXWEIGHTPOINTEREXTPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexWeightPointerEXT"); - if (NULL == GLH_EXT_NAME(glVertexWeightPointerEXT)) - return FALSE; -#endif - -#ifdef GL_NV_blend_square - } else if (0 == strcmp(extension, "GL_NV_blend_square")) { -#endif - -#ifdef GL_NV_evaluators - } else if (0 == strcmp(extension, "GL_NV_evaluators")) { - GLH_EXT_NAME(glMapControlPointsNV) = (PFNGLMAPCONTROLPOINTSNVPROC)GLH_EXT_GET_PROC_ADDRESS("glMapControlPointsNV"); - if (NULL == GLH_EXT_NAME(glMapControlPointsNV)) - return FALSE; - GLH_EXT_NAME(glMapParameterivNV) = (PFNGLMAPPARAMETERIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glMapParameterivNV"); - if (NULL == GLH_EXT_NAME(glMapParameterivNV)) - return FALSE; - GLH_EXT_NAME(glMapParameterfvNV) = (PFNGLMAPPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glMapParameterfvNV"); - if (NULL == GLH_EXT_NAME(glMapParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glGetMapControlPointsNV) = (PFNGLGETMAPCONTROLPOINTSNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetMapControlPointsNV"); - if (NULL == GLH_EXT_NAME(glGetMapControlPointsNV)) - return FALSE; - GLH_EXT_NAME(glGetMapParameterivNV) = (PFNGLGETMAPPARAMETERIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetMapParameterivNV"); - if (NULL == GLH_EXT_NAME(glGetMapParameterivNV)) - return FALSE; - GLH_EXT_NAME(glGetMapParameterfvNV) = (PFNGLGETMAPPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetMapParameterfvNV"); - if (NULL == GLH_EXT_NAME(glGetMapParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glGetMapAttribParameterivNV) = (PFNGLGETMAPATTRIBPARAMETERIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetMapAttribParameterivNV"); - if (NULL == GLH_EXT_NAME(glGetMapAttribParameterivNV)) - return FALSE; - GLH_EXT_NAME(glGetMapAttribParameterfvNV) = (PFNGLGETMAPATTRIBPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetMapAttribParameterfvNV"); - if (NULL == GLH_EXT_NAME(glGetMapAttribParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glEvalMapsNV) = (PFNGLEVALMAPSNVPROC)GLH_EXT_GET_PROC_ADDRESS("glEvalMapsNV"); - if (NULL == GLH_EXT_NAME(glEvalMapsNV)) - return FALSE; -#endif - -#ifdef GL_NV_fence - } else if (0 == strcmp(extension, "GL_NV_fence")) { - GLH_EXT_NAME(glGenFencesNV) = (PFNGLGENFENCESNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGenFencesNV"); - if (NULL == GLH_EXT_NAME(glGenFencesNV)) - return FALSE; - GLH_EXT_NAME(glDeleteFencesNV) = (PFNGLDELETEFENCESNVPROC)GLH_EXT_GET_PROC_ADDRESS("glDeleteFencesNV"); - if (NULL == GLH_EXT_NAME(glDeleteFencesNV)) - return FALSE; - GLH_EXT_NAME(glSetFenceNV) = (PFNGLSETFENCENVPROC)GLH_EXT_GET_PROC_ADDRESS("glSetFenceNV"); - if (NULL == GLH_EXT_NAME(glSetFenceNV)) - return FALSE; - GLH_EXT_NAME(glTestFenceNV) = (PFNGLTESTFENCENVPROC)GLH_EXT_GET_PROC_ADDRESS("glTestFenceNV"); - if (NULL == GLH_EXT_NAME(glTestFenceNV)) - return FALSE; - GLH_EXT_NAME(glFinishFenceNV) = (PFNGLFINISHFENCENVPROC)GLH_EXT_GET_PROC_ADDRESS("glFinishFenceNV"); - if (NULL == GLH_EXT_NAME(glFinishFenceNV)) - return FALSE; - GLH_EXT_NAME(glIsFenceNV) = (PFNGLISFENCENVPROC)GLH_EXT_GET_PROC_ADDRESS("glIsFenceNV"); - if (NULL == GLH_EXT_NAME(glIsFenceNV)) - return FALSE; - GLH_EXT_NAME(glGetFenceivNV) = (PFNGLGETFENCEIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetFenceivNV"); - if (NULL == GLH_EXT_NAME(glGetFenceivNV)) - return FALSE; -#endif - -#ifdef GL_NV_fog_distance - } else if (0 == strcmp(extension, "GL_NV_fog_distance")) { -#endif - -#ifdef GL_NV_packed_depth_stencil - } else if (0 == strcmp(extension, "GL_NV_packed_depth_stencil")) { -#endif - -#ifdef GL_NV_register_combiners - } else if (0 == strcmp(extension, "GL_NV_register_combiners")) { - GLH_EXT_NAME(glCombinerParameterfvNV) = (PFNGLCOMBINERPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glCombinerParameterfvNV"); - if (NULL == GLH_EXT_NAME(glCombinerParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glCombinerParameterfNV) = (PFNGLCOMBINERPARAMETERFNVPROC)GLH_EXT_GET_PROC_ADDRESS("glCombinerParameterfNV"); - if (NULL == GLH_EXT_NAME(glCombinerParameterfNV)) - return FALSE; - GLH_EXT_NAME(glCombinerParameterivNV) = (PFNGLCOMBINERPARAMETERIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glCombinerParameterivNV"); - if (NULL == GLH_EXT_NAME(glCombinerParameterivNV)) - return FALSE; - GLH_EXT_NAME(glCombinerParameteriNV) = (PFNGLCOMBINERPARAMETERINVPROC)GLH_EXT_GET_PROC_ADDRESS("glCombinerParameteriNV"); - if (NULL == GLH_EXT_NAME(glCombinerParameteriNV)) - return FALSE; - GLH_EXT_NAME(glCombinerInputNV) = (PFNGLCOMBINERINPUTNVPROC)GLH_EXT_GET_PROC_ADDRESS("glCombinerInputNV"); - if (NULL == GLH_EXT_NAME(glCombinerInputNV)) - return FALSE; - GLH_EXT_NAME(glCombinerOutputNV) = (PFNGLCOMBINEROUTPUTNVPROC)GLH_EXT_GET_PROC_ADDRESS("glCombinerOutputNV"); - if (NULL == GLH_EXT_NAME(glCombinerOutputNV)) - return FALSE; - GLH_EXT_NAME(glFinalCombinerInputNV) = (PFNGLFINALCOMBINERINPUTNVPROC)GLH_EXT_GET_PROC_ADDRESS("glFinalCombinerInputNV"); - if (NULL == GLH_EXT_NAME(glFinalCombinerInputNV)) - return FALSE; - GLH_EXT_NAME(glGetCombinerInputParameterfvNV) = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetCombinerInputParameterfvNV"); - if (NULL == GLH_EXT_NAME(glGetCombinerInputParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glGetCombinerInputParameterivNV) = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetCombinerInputParameterivNV"); - if (NULL == GLH_EXT_NAME(glGetCombinerInputParameterivNV)) - return FALSE; - GLH_EXT_NAME(glGetCombinerOutputParameterfvNV) = (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetCombinerOutputParameterfvNV"); - if (NULL == GLH_EXT_NAME(glGetCombinerOutputParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glGetCombinerOutputParameterivNV) = (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetCombinerOutputParameterivNV"); - if (NULL == GLH_EXT_NAME(glGetCombinerOutputParameterivNV)) - return FALSE; - GLH_EXT_NAME(glGetFinalCombinerInputParameterfvNV) = (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetFinalCombinerInputParameterfvNV"); - if (NULL == GLH_EXT_NAME(glGetFinalCombinerInputParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glGetFinalCombinerInputParameterivNV) = (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetFinalCombinerInputParameterivNV"); - if (NULL == GLH_EXT_NAME(glGetFinalCombinerInputParameterivNV)) - return FALSE; -#endif - -#ifdef GL_NV_register_combiners2 - } else if (0 == strcmp(extension, "GL_NV_register_combiners2")) { - GLH_EXT_NAME(glCombinerStageParameterfvNV) = (PFNGLCOMBINERSTAGEPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glCombinerStageParameterfvNV"); - if (NULL == GLH_EXT_NAME(glCombinerStageParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glGetCombinerStageParameterfvNV) = (PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetCombinerStageParameterfvNV"); - if (NULL == GLH_EXT_NAME(glGetCombinerStageParameterfvNV)) - return FALSE; -#endif - -#ifdef GL_NV_texgen_reflection - } else if (0 == strcmp(extension, "GL_NV_texgen_reflection")) { -#endif - -#ifdef GL_NV_texture_env_combine4 - } else if (0 == strcmp(extension, "GL_NV_texture_env_combine4")) { -#endif - -#ifdef GL_NV_texture_rectangle - } else if (0 == strcmp(extension, "GL_NV_texture_rectangle")) { -#endif - -#ifdef GL_NV_texture_shader - } else if (0 == strcmp(extension, "GL_NV_texture_shader")) { -#endif - -#ifdef GL_NV_vertex_array_range - } else if (0 == strcmp(extension, "GL_NV_vertex_array_range")) { - GLH_EXT_NAME(glFlushVertexArrayRangeNV) = (PFNGLFLUSHVERTEXARRAYRANGENVPROC)GLH_EXT_GET_PROC_ADDRESS("glFlushVertexArrayRangeNV"); - if (NULL == GLH_EXT_NAME(glFlushVertexArrayRangeNV)) - return FALSE; - GLH_EXT_NAME(glVertexArrayRangeNV) = (PFNGLVERTEXARRAYRANGENVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexArrayRangeNV"); - if (NULL == GLH_EXT_NAME(glVertexArrayRangeNV)) - return FALSE; -# ifdef _WIN32 - GLH_EXT_NAME(wglAllocateMemoryNV) = (PFNWGLALLOCATEMEMORYNVPROC)GLH_EXT_GET_PROC_ADDRESS("wglAllocateMemoryNV"); - if (NULL == GLH_EXT_NAME(wglAllocateMemoryNV)) - return FALSE; -# endif -# ifdef GLX_VERSION_1_3 - GLH_EXT_NAME(glXAllocateMemoryNV) = (PFNGLXALLOCATEMEMORYNVPROC)GLH_EXT_GET_PROC_ADDRESS("glXAllocateMemoryNV"); - if (NULL == GLH_EXT_NAME(glXAllocateMemoryNV)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglFreeMemoryNV) = (PFNWGLFREEMEMORYNVPROC)GLH_EXT_GET_PROC_ADDRESS("wglFreeMemoryNV"); - if (NULL == GLH_EXT_NAME(wglFreeMemoryNV)) - return FALSE; -# endif -# ifdef GLX_VERSION_1_3 - GLH_EXT_NAME(glXFreeMemoryNV) = (PFNGLXFREEMEMORYNVPROC)GLH_EXT_GET_PROC_ADDRESS("glXFreeMemoryNV"); - if (NULL == GLH_EXT_NAME(glXFreeMemoryNV)) - return FALSE; -# endif -#endif - -#ifdef GL_NV_vertex_program - } else if (0 == strcmp(extension, "GL_NV_vertex_program")) { - GLH_EXT_NAME(glAreProgramsResidentNV) = (PFNGLAREPROGRAMSRESIDENTNVPROC)GLH_EXT_GET_PROC_ADDRESS("glAreProgramsResidentNV"); - if (NULL == GLH_EXT_NAME(glAreProgramsResidentNV)) - return FALSE; - GLH_EXT_NAME(glBindProgramNV) = (PFNGLBINDPROGRAMNVPROC)GLH_EXT_GET_PROC_ADDRESS("glBindProgramNV"); - if (NULL == GLH_EXT_NAME(glBindProgramNV)) - return FALSE; - GLH_EXT_NAME(glDeleteProgramsNV) = (PFNGLDELETEPROGRAMSNVPROC)GLH_EXT_GET_PROC_ADDRESS("glDeleteProgramsNV"); - if (NULL == GLH_EXT_NAME(glDeleteProgramsNV)) - return FALSE; - GLH_EXT_NAME(glExecuteProgramNV) = (PFNGLEXECUTEPROGRAMNVPROC)GLH_EXT_GET_PROC_ADDRESS("glExecuteProgramNV"); - if (NULL == GLH_EXT_NAME(glExecuteProgramNV)) - return FALSE; - GLH_EXT_NAME(glGenProgramsNV) = (PFNGLGENPROGRAMSNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGenProgramsNV"); - if (NULL == GLH_EXT_NAME(glGenProgramsNV)) - return FALSE; - GLH_EXT_NAME(glGetProgramParameterdvNV) = (PFNGLGETPROGRAMPARAMETERDVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramParameterdvNV"); - if (NULL == GLH_EXT_NAME(glGetProgramParameterdvNV)) - return FALSE; - GLH_EXT_NAME(glGetProgramParameterfvNV) = (PFNGLGETPROGRAMPARAMETERFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramParameterfvNV"); - if (NULL == GLH_EXT_NAME(glGetProgramParameterfvNV)) - return FALSE; - GLH_EXT_NAME(glGetProgramivNV) = (PFNGLGETPROGRAMIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramivNV"); - if (NULL == GLH_EXT_NAME(glGetProgramivNV)) - return FALSE; - GLH_EXT_NAME(glGetProgramStringNV) = (PFNGLGETPROGRAMSTRINGNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetProgramStringNV"); - if (NULL == GLH_EXT_NAME(glGetProgramStringNV)) - return FALSE; - GLH_EXT_NAME(glGetTrackMatrixivNV) = (PFNGLGETTRACKMATRIXIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetTrackMatrixivNV"); - if (NULL == GLH_EXT_NAME(glGetTrackMatrixivNV)) - return FALSE; - GLH_EXT_NAME(glGetVertexAttribdvNV) = (PFNGLGETVERTEXATTRIBDVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetVertexAttribdvNV"); - if (NULL == GLH_EXT_NAME(glGetVertexAttribdvNV)) - return FALSE; - GLH_EXT_NAME(glGetVertexAttribfvNV) = (PFNGLGETVERTEXATTRIBFVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetVertexAttribfvNV"); - if (NULL == GLH_EXT_NAME(glGetVertexAttribfvNV)) - return FALSE; - GLH_EXT_NAME(glGetVertexAttribivNV) = (PFNGLGETVERTEXATTRIBIVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetVertexAttribivNV"); - if (NULL == GLH_EXT_NAME(glGetVertexAttribivNV)) - return FALSE; - GLH_EXT_NAME(glGetVertexAttribPointervNV) = (PFNGLGETVERTEXATTRIBPOINTERVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetVertexAttribPointervNV"); - if (NULL == GLH_EXT_NAME(glGetVertexAttribPointervNV)) - return FALSE; - GLH_EXT_NAME(glIsProgramNV) = (PFNGLISPROGRAMNVPROC)GLH_EXT_GET_PROC_ADDRESS("glIsProgramNV"); - if (NULL == GLH_EXT_NAME(glIsProgramNV)) - return FALSE; - GLH_EXT_NAME(glLoadProgramNV) = (PFNGLLOADPROGRAMNVPROC)GLH_EXT_GET_PROC_ADDRESS("glLoadProgramNV"); - if (NULL == GLH_EXT_NAME(glLoadProgramNV)) - return FALSE; - GLH_EXT_NAME(glProgramParameter4dNV) = (PFNGLPROGRAMPARAMETER4DNVPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramParameter4dNV"); - if (NULL == GLH_EXT_NAME(glProgramParameter4dNV)) - return FALSE; - GLH_EXT_NAME(glProgramParameter4dvNV) = (PFNGLPROGRAMPARAMETER4DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramParameter4dvNV"); - if (NULL == GLH_EXT_NAME(glProgramParameter4dvNV)) - return FALSE; - GLH_EXT_NAME(glProgramParameter4fNV) = (PFNGLPROGRAMPARAMETER4FNVPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramParameter4fNV"); - if (NULL == GLH_EXT_NAME(glProgramParameter4fNV)) - return FALSE; - GLH_EXT_NAME(glProgramParameter4fvNV) = (PFNGLPROGRAMPARAMETER4FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramParameter4fvNV"); - if (NULL == GLH_EXT_NAME(glProgramParameter4fvNV)) - return FALSE; - GLH_EXT_NAME(glProgramParameters4dvNV) = (PFNGLPROGRAMPARAMETERS4DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramParameters4dvNV"); - if (NULL == GLH_EXT_NAME(glProgramParameters4dvNV)) - return FALSE; - GLH_EXT_NAME(glProgramParameters4fvNV) = (PFNGLPROGRAMPARAMETERS4FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glProgramParameters4fvNV"); - if (NULL == GLH_EXT_NAME(glProgramParameters4fvNV)) - return FALSE; - GLH_EXT_NAME(glRequestResidentProgramsNV) = (PFNGLREQUESTRESIDENTPROGRAMSNVPROC)GLH_EXT_GET_PROC_ADDRESS("glRequestResidentProgramsNV"); - if (NULL == GLH_EXT_NAME(glRequestResidentProgramsNV)) - return FALSE; - GLH_EXT_NAME(glTrackMatrixNV) = (PFNGLTRACKMATRIXNVPROC)GLH_EXT_GET_PROC_ADDRESS("glTrackMatrixNV"); - if (NULL == GLH_EXT_NAME(glTrackMatrixNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribPointerNV) = (PFNGLVERTEXATTRIBPOINTERNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribPointerNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribPointerNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib1dNV) = (PFNGLVERTEXATTRIB1DNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1dNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1dNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib1dvNV) = (PFNGLVERTEXATTRIB1DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1dvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1dvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib1fNV) = (PFNGLVERTEXATTRIB1FNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1fNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1fNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib1fvNV) = (PFNGLVERTEXATTRIB1FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1fvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1fvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib1sNV) = (PFNGLVERTEXATTRIB1SNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1sNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1sNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib1svNV) = (PFNGLVERTEXATTRIB1SVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib1svNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib1svNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib2dNV) = (PFNGLVERTEXATTRIB2DNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2dNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2dNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib2dvNV) = (PFNGLVERTEXATTRIB2DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2dvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2dvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib2fNV) = (PFNGLVERTEXATTRIB2FNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2fNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2fNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib2fvNV) = (PFNGLVERTEXATTRIB2FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2fvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2fvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib2sNV) = (PFNGLVERTEXATTRIB2SNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2sNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2sNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib2svNV) = (PFNGLVERTEXATTRIB2SVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib2svNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib2svNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib3dNV) = (PFNGLVERTEXATTRIB3DNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3dNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3dNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib3dvNV) = (PFNGLVERTEXATTRIB3DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3dvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3dvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib3fNV) = (PFNGLVERTEXATTRIB3FNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3fNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3fNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib3fvNV) = (PFNGLVERTEXATTRIB3FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3fvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3fvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib3sNV) = (PFNGLVERTEXATTRIB3SNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3sNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3sNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib3svNV) = (PFNGLVERTEXATTRIB3SVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib3svNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib3svNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib4dNV) = (PFNGLVERTEXATTRIB4DNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4dNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4dNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib4dvNV) = (PFNGLVERTEXATTRIB4DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4dvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4dvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib4fNV) = (PFNGLVERTEXATTRIB4FNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4fNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4fNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib4fvNV) = (PFNGLVERTEXATTRIB4FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4fvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4fvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib4sNV) = (PFNGLVERTEXATTRIB4SNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4sNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4sNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib4svNV) = (PFNGLVERTEXATTRIB4SVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4svNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4svNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttrib4ubvNV) = (PFNGLVERTEXATTRIB4UBVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4ubvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttrib4ubvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs1dvNV) = (PFNGLVERTEXATTRIBS1DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs1dvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs1dvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs1fvNV) = (PFNGLVERTEXATTRIBS1FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs1fvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs1fvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs1svNV) = (PFNGLVERTEXATTRIBS1SVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs1svNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs1svNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs2dvNV) = (PFNGLVERTEXATTRIBS2DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs2dvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs2dvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs2fvNV) = (PFNGLVERTEXATTRIBS2FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs2fvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs2fvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs2svNV) = (PFNGLVERTEXATTRIBS2SVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs2svNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs2svNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs3dvNV) = (PFNGLVERTEXATTRIBS3DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs3dvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs3dvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs3fvNV) = (PFNGLVERTEXATTRIBS3FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs3fvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs3fvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs3svNV) = (PFNGLVERTEXATTRIBS3SVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs3svNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs3svNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs4dvNV) = (PFNGLVERTEXATTRIBS4DVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs4dvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs4dvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs4fvNV) = (PFNGLVERTEXATTRIBS4FVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs4fvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs4fvNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs4svNV) = (PFNGLVERTEXATTRIBS4SVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs4svNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs4svNV)) - return FALSE; - GLH_EXT_NAME(glVertexAttribs4ubvNV) = (PFNGLVERTEXATTRIBS4UBVNVPROC)GLH_EXT_GET_PROC_ADDRESS("glVertexAttribs4ubvNV"); - if (NULL == GLH_EXT_NAME(glVertexAttribs4ubvNV)) - return FALSE; -#endif - -#ifdef GL_SGIS_generate_mipmap - } else if (0 == strcmp(extension, "GL_SGIS_generate_mipmap")) { -#endif - -#ifdef GL_SGIS_texture_lod - } else if (0 == strcmp(extension, "GL_SGIS_texture_lod")) { -#endif - -#ifdef GL_SGIX_depth_texture - } else if (0 == strcmp(extension, "GL_SGIX_depth_texture")) { -#endif - -#ifdef GL_SGIX_shadow - } else if (0 == strcmp(extension, "GL_SGIX_shadow")) { -#endif - -#ifdef GL_VERSION_1_2 - } else if (0 == strcmp(extension, "GL_VERSION_1_2")) { - GLH_CORE_1_2_NAME(glBlendColor) = (PFNGLBLENDCOLORPROC)GLH_EXT_GET_PROC_ADDRESS("glBlendColor"); - if (NULL == GLH_CORE_1_2_NAME(glBlendColor)) - return FALSE; - GLH_CORE_1_2_NAME(glBlendEquation) = (PFNGLBLENDEQUATIONPROC)GLH_EXT_GET_PROC_ADDRESS("glBlendEquation"); - if (NULL == GLH_CORE_1_2_NAME(glBlendEquation)) - return FALSE; - GLH_CORE_1_2_NAME(glDrawRangeElements) = (PFNGLDRAWRANGEELEMENTSPROC)GLH_EXT_GET_PROC_ADDRESS("glDrawRangeElements"); - if (NULL == GLH_CORE_1_2_NAME(glDrawRangeElements)) - return FALSE; - GLH_CORE_1_2_NAME(glColorTable) = (PFNGLCOLORTABLEPROC)GLH_EXT_GET_PROC_ADDRESS("glColorTable"); - if (NULL == GLH_CORE_1_2_NAME(glColorTable)) - return FALSE; - GLH_CORE_1_2_NAME(glColorTableParameterfv) = (PFNGLCOLORTABLEPARAMETERFVPROC)GLH_EXT_GET_PROC_ADDRESS("glColorTableParameterfv"); - if (NULL == GLH_CORE_1_2_NAME(glColorTableParameterfv)) - return FALSE; - GLH_CORE_1_2_NAME(glColorTableParameteriv) = (PFNGLCOLORTABLEPARAMETERIVPROC)GLH_EXT_GET_PROC_ADDRESS("glColorTableParameteriv"); - if (NULL == GLH_CORE_1_2_NAME(glColorTableParameteriv)) - return FALSE; - GLH_CORE_1_2_NAME(glCopyColorTable) = (PFNGLCOPYCOLORTABLEPROC)GLH_EXT_GET_PROC_ADDRESS("glCopyColorTable"); - if (NULL == GLH_CORE_1_2_NAME(glCopyColorTable)) - return FALSE; - GLH_CORE_1_2_NAME(glGetColorTable) = (PFNGLGETCOLORTABLEPROC)GLH_EXT_GET_PROC_ADDRESS("glGetColorTable"); - if (NULL == GLH_CORE_1_2_NAME(glGetColorTable)) - return FALSE; - GLH_CORE_1_2_NAME(glGetColorTableParameterfv) = (PFNGLGETCOLORTABLEPARAMETERFVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetColorTableParameterfv"); - if (NULL == GLH_CORE_1_2_NAME(glGetColorTableParameterfv)) - return FALSE; - GLH_CORE_1_2_NAME(glGetColorTableParameteriv) = (PFNGLGETCOLORTABLEPARAMETERIVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetColorTableParameteriv"); - if (NULL == GLH_CORE_1_2_NAME(glGetColorTableParameteriv)) - return FALSE; - GLH_CORE_1_2_NAME(glTexImage3D) = (PFNGLTEXIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glTexImage3D"); - if (NULL == GLH_CORE_1_2_NAME(glTexImage3D)) - return FALSE; - GLH_CORE_1_2_NAME(glTexSubImage3D) = (PFNGLTEXSUBIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glTexSubImage3D"); - if (NULL == GLH_CORE_1_2_NAME(glTexSubImage3D)) - return FALSE; - GLH_CORE_1_2_NAME(glCopyTexSubImage3D) = (PFNGLCOPYTEXSUBIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glCopyTexSubImage3D"); - if (NULL == GLH_CORE_1_2_NAME(glCopyTexSubImage3D)) - return FALSE; -#endif - -#ifdef GL_WIN_swap_hint - } else if (0 == strcmp(extension, "GL_WIN_swap_hint")) { - GLH_EXT_NAME(glAddSwapHintRectWIN) = (PFNGLADDSWAPHINTRECTWINPROC)GLH_EXT_GET_PROC_ADDRESS("glAddSwapHintRectWIN"); - if (NULL == GLH_EXT_NAME(glAddSwapHintRectWIN)) - return FALSE; -#endif - -#ifdef WGL_ARB_pbuffer - } else if (0 == strcmp(extension, "WGL_ARB_pbuffer")) { -# ifdef _WIN32 - GLH_EXT_NAME(wglCreatePbufferARB) = (PFNWGLCREATEPBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglCreatePbufferARB"); - if (NULL == GLH_EXT_NAME(wglCreatePbufferARB)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglGetPbufferDCARB) = (PFNWGLGETPBUFFERDCARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglGetPbufferDCARB"); - if (NULL == GLH_EXT_NAME(wglGetPbufferDCARB)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglReleasePbufferDCARB) = (PFNWGLRELEASEPBUFFERDCARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglReleasePbufferDCARB"); - if (NULL == GLH_EXT_NAME(wglReleasePbufferDCARB)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglDestroyPbufferARB) = (PFNWGLDESTROYPBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglDestroyPbufferARB"); - if (NULL == GLH_EXT_NAME(wglDestroyPbufferARB)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglQueryPbufferARB) = (PFNWGLQUERYPBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglQueryPbufferARB"); - if (NULL == GLH_EXT_NAME(wglQueryPbufferARB)) - return FALSE; -# endif -#endif - -#ifdef WGL_ARB_render_texture -# ifdef _WIN32 - GLH_EXT_NAME(wglBindTexImageARB) = (PFNWGLBINDTEXIMAGEARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglBindTexImageARB"); - if (NULL == GLH_EXT_NAME(wglBindTexImageARB)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglReleaseTexImageARB) = (PFNWGLRELEASETEXIMAGEARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglReleaseTexImageARB"); - if (NULL == GLH_EXT_NAME(wglReleaseTexImageARB)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglSetPbufferAttribARB) = (PFNWGLSETPBUFFERATTRIBARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglSetPbufferAttribARB"); - if (NULL == GLH_EXT_NAME(wglSetPbufferAttribARB)) - return FALSE; -# endif -#endif - -#ifdef WGL_ARB_pixel_format - } else if (0 == strcmp(extension, "WGL_ARB_pixel_format")) { -# ifdef _WIN32 - GLH_EXT_NAME(wglGetPixelFormatAttribivARB) = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglGetPixelFormatAttribivARB"); - if (NULL == GLH_EXT_NAME(wglGetPixelFormatAttribivARB)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglGetPixelFormatAttribfvARB) = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglGetPixelFormatAttribfvARB"); - if (NULL == GLH_EXT_NAME(wglGetPixelFormatAttribfvARB)) - return FALSE; -# endif -# ifdef _WIN32 - GLH_EXT_NAME(wglChoosePixelFormatARB) = (PFNWGLCHOOSEPIXELFORMATARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglChoosePixelFormatARB"); - if (NULL == GLH_EXT_NAME(wglChoosePixelFormatARB)) - return FALSE; -# endif -#endif - - } else { - return FALSE; - } - return TRUE; -} -#endif - -#else // defined(__APPLE__) - -#ifdef GLH_EXT_SINGLE_FILE - -int glh_init_extension(const char* extension) -{ - // MBW -- XXX -- Should this check for extension availability? - return TRUE; -} -#endif // GLH_EXT_SINGLE_FILE - -#endif // defined(__APPLE__) - -#undef GLH_EXT_SINGLE_FILE - -#endif /* GLH_GENEXT_H */ -- cgit v1.2.3 From b854eceee3a867d64b20de18d6b7ce91b33abed0 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 11 Jun 2021 21:16:08 +0300 Subject: SL-15391 Crash at getUniformLocation --- indra/llrender/llglslshader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 42b8c35442..d3942c7552 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -1427,7 +1427,11 @@ GLint LLGLSLShader::getUniformLocation(U32 index) GLint ret = -1; if (mProgramObject) { - llassert(index < mUniform.size()); + if (index >= mUniform.size()) + { + LL_WARNS_ONCE("Shader") << "Uniform index " << index << " out of bounds " << (S32)mUniform.size() << LL_ENDL; + return ret; + } return mUniform[index]; } -- cgit v1.2.3 From 06969e980ee3cc16a61a934b9c6bc252149c15c9 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 25 Jun 2021 10:23:05 -0700 Subject: SL-11589: Fix horizon being U shaped bent in Low+ quality --- indra/newview/app_settings/shaders/class1/deferred/waterV.glsl | 2 +- indra/newview/app_settings/shaders/class1/environment/waterV.glsl | 2 +- indra/newview/app_settings/shaders/class3/deferred/waterV.glsl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl index 8863869e44..38276859a0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl @@ -70,7 +70,7 @@ void main() d *= d; oPosition = vec4(position, 1.0); - oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); +// oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove "U" shaped horizon vary_position = modelview_matrix * oPosition; oPosition = modelViewProj * oPosition; diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl index cc41e3f740..35770d3341 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl @@ -68,7 +68,7 @@ void main() d *= d; oPosition = vec4(position, 1.0); - oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); +// oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove "U" shaped horizon oPosition = modelViewProj * oPosition; refCoord.xyz = oPosition.xyz + vec3(0,0,0.2); diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl index 02000d90ca..b9089d69b7 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl @@ -68,7 +68,7 @@ void main() d *= d; oPosition = vec4(position, 1.0); - oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); +// oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove "U" shaped horizon vary_position = modelview_matrix * oPosition; oPosition = modelViewProj * oPosition; -- cgit v1.2.3 From 9b5b2eac82b1f423daec463b3d55d0f3d3979bbc Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 14 Sep 2021 22:43:17 +0300 Subject: SL-15993 Disabling transparent water should not disable advanced lighting --- indra/newview/llappviewer.cpp | 2 +- indra/newview/lldrawpoolwater.cpp | 13 +++++++++++++ indra/newview/llfloaterpreference.cpp | 6 ------ indra/newview/llviewercontrol.cpp | 1 - indra/newview/llviewershadermgr.cpp | 2 +- indra/newview/pipeline.cpp | 1 - 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 79f1cc0e8f..f68717ef9f 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -610,7 +610,7 @@ static void settings_modify() LLRenderTarget::sUseFBO = gSavedSettings.getBOOL("RenderDeferred"); LLPipeline::sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater"); LLPipeline::sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); - LLPipeline::sRenderDeferred = LLPipeline::sRenderTransparentWater && LLPipeline::sRenderBump && gSavedSettings.getBOOL("RenderDeferred"); + LLPipeline::sRenderDeferred = LLPipeline::sRenderBump && gSavedSettings.getBOOL("RenderDeferred"); LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor"); LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4] gDebugGL = gSavedSettings.getBOOL("RenderDebugGL") || gDebugSession; diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index aa426cd785..0cf36e4e8a 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -137,6 +137,14 @@ void LLDrawPoolWater::endPostDeferredPass(S32 pass) void LLDrawPoolWater::renderDeferred(S32 pass) { LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); + + if (!LLPipeline::sRenderTransparentWater) + { + // Will render opaque water without use of ALM + render(pass); + return; + } + deferred_render = TRUE; shade(); deferred_render = FALSE; @@ -339,6 +347,11 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() { LLVOSky *voskyp = gSky.mVOSkyp; + if (voskyp == NULL) + { + return; + } + LLGLSLShader* shader = NULL; if (LLGLSLShader::sNoFixedFunction) { diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 6bf2136f60..92e64d0b95 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1198,11 +1198,9 @@ void LLFloaterPreference::refreshEnabledState() //Deferred/SSAO/Shadows BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump"); - BOOL transparent_water = LLFeatureManager::getInstance()->isFeatureAvailable("RenderTransparentWater") && gSavedSettings.getBOOL("RenderTransparentWater"); BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders"); BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && bumpshiny && - transparent_water && shaders && gGLManager.mHasFramebufferObject && gSavedSettings.getBOOL("RenderAvatarVP") && @@ -1226,9 +1224,6 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() ctrl_reflections->setEnabled(reflections); reflections_text->setEnabled(reflections); - // Transparent Water - LLCheckBoxCtrl* transparent_water_ctrl = getChild("TransparentWater"); - // Bump & Shiny LLCheckBoxCtrl* bumpshiny_ctrl = getChild("BumpShiny"); bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump"); @@ -1279,7 +1274,6 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) && - ((transparent_water_ctrl && transparent_water_ctrl->get()) ? TRUE : FALSE) && gGLManager.mHasFramebufferObject && gSavedSettings.getBOOL("RenderAvatarVP") && (ctrl_wind_light->get()) ? TRUE : FALSE; diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 76dc9a6790..73e0719128 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -187,7 +187,6 @@ static bool handleRenderPerfTestChanged(const LLSD& newvalue) bool handleRenderTransparentWaterChanged(const LLSD& newvalue) { - LLRenderTarget::sUseFBO = newvalue.asBoolean(); if (gPipeline.isInit()) { gPipeline.updateRenderTransparentWater(); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 43e9a2333e..854fcf1359 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -435,7 +435,7 @@ void LLViewerShaderMgr::setShaders() initAttribsAndUniforms(); gPipeline.releaseGLBuffers(); - LLPipeline::sWaterReflections = gGLManager.mHasCubeMap; + LLPipeline::sWaterReflections = gGLManager.mHasCubeMap && LLPipeline::sRenderTransparentWater; LLPipeline::sRenderGlow = gSavedSettings.getBOOL("RenderGlow"); LLPipeline::updateRenderDeferred(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9924b02a95..3670272411 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1054,7 +1054,6 @@ void LLPipeline::updateRenderDeferred() RenderDeferred && LLRenderTarget::sUseFBO && LLPipeline::sRenderBump && - LLPipeline::sRenderTransparentWater && RenderAvatarVP && WindLightUseAtmosShaders && (bool) LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"); -- cgit v1.2.3 From 921c3f5f69c90b5924d2f4bbbd32455f8c9c8173 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 17 Sep 2021 15:48:57 +0300 Subject: SL-13561 When ALM is enabled, disabling water rendering breaks the sky. --- indra/newview/pipeline.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3670272411..391d2472a6 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9259,7 +9259,12 @@ inline float sgn(float a) void LLPipeline::generateWaterReflection(LLCamera& camera_in) { - if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate) + if (!assertInitialized()) + { + return; + } + + if (LLPipeline::sWaterReflections && LLDrawPoolWater::sNeedsReflectionUpdate) { bool skip_avatar_update = false; if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) @@ -9552,6 +9557,29 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; } + else + { + // Initial sky pass is still needed even if water reflection is not rendering + bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); + if (!camera_is_underwater) + { + gPipeline.pushRenderTypeMask(); + { + gPipeline.andRenderTypeMask( + LLPipeline::RENDER_TYPE_SKY, + LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::END_RENDER_TYPES); + + LLCamera camera = camera_in; + camera.setFar(camera_in.getFar() * 0.75f); + + updateCull(camera, mSky); + stateSort(camera, mSky); + renderGeom(camera, TRUE); + } + gPipeline.popRenderTypeMask(); + } + } } glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) -- cgit v1.2.3 From 53c0144dd272470172591b967a84beaa4019b728 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 23 Sep 2021 22:38:30 +0300 Subject: SL-11678 Avatar is reflecting on the under side of water surface Avatar wasn't reflecting but distorting, since avatar was already under water it looked like a 'reflection' of avatar, but was not rotated right and with wrong angle. --- indra/newview/pipeline.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 391d2472a6..c417b55108 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9491,19 +9491,13 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) //clip out geometry on the same side of water as the camera w/ enough margin to not include the water geo itself, // but not so much as to clip out parts of avatars that should be seen under the water in the distortion map - LLPlane plane(-pnorm, water_dist); + LLPlane plane(-pnorm, camera_is_underwater ? -water_height : water_dist); LLGLUserClipPlane clip_plane(plane, saved_modelview, saved_projection); gGL.setColorMask(true, true); mWaterDis.clear(); gGL.setColorMask(true, false); - // ignore clip plane if we're underwater and viewing distortion map of objects above waterline - if (camera_is_underwater) - { - clip_plane.disable(); - } - if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT) { updateCull(camera, mRefractedObjects, water_clip, &plane); -- cgit v1.2.3 From 492ea7c3a03d5ef0d3679b873a44c08baaced0f1 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 24 Sep 2021 23:35:12 +0300 Subject: SL-16056 Improve 'avatar cloud' behavior Make avatar cloud delay longer proportionally to load time --- indra/newview/llvoavatar.cpp | 35 +++++++++++++++++++++++++++++------ indra/newview/llvoavatar.h | 3 +++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index e085a945a8..6e7d0744a5 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -126,6 +126,9 @@ const F32 MIN_HOVER_Z = -2.0; const F32 MIN_ATTACHMENT_COMPLEXITY = 0.f; const F32 DEFAULT_MAX_ATTACHMENT_COMPLEXITY = 1.0e6f; +const F32 FIRST_APPEARANCE_CLOUD_MIN_DELAY = 3.f; // seconds +const F32 FIRST_APPEARANCE_CLOUD_MAX_DELAY = 45.f; + using namespace LLAvatarAppearanceDefines; //----------------------------------------------------------------------------- @@ -664,6 +667,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mVisuallyMuteSetting(AV_RENDER_NORMALLY), mMutedAVColor(LLColor4::white /* used for "uninitialize" */), mFirstFullyVisible(TRUE), + mFirstUseDelaySeconds(FIRST_APPEARANCE_CLOUD_MIN_DELAY), mFullyLoaded(FALSE), mPreviousFullyLoaded(FALSE), mFullyLoadedInitialized(FALSE), @@ -738,7 +742,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mCurrentGesticulationLevel = 0; - + mFirstSeenTimer.reset(); mRuthTimer.reset(); mRuthDebugTimer.reset(); mDebugExistenceTimer.reset(); @@ -8126,16 +8130,35 @@ void LLVOAvatar::updateRuthTimer(bool loading) BOOL LLVOAvatar::processFullyLoadedChange(bool loading) { // We wait a little bit before giving the 'all clear', to let things to - // settle down (models to snap into place, textures to get first packets) + // settle down (models to snap into place, textures to get first packets). + // And if viewer isn't aware of some parts yet, this gives them a chance + // to arrive. const F32 LOADED_DELAY = 1.f; - const F32 FIRST_USE_DELAY = 3.f; - if (loading) - mFullyLoadedTimer.reset(); + if (loading) + { + mFullyLoadedTimer.reset(); + } if (mFirstFullyVisible) { - mFullyLoaded = (mFullyLoadedTimer.getElapsedTimeF32() > FIRST_USE_DELAY); + if (!isSelf() && loading) + { + // Note that textures can causes 60s delay on thier own + // so this delay might end up on top of textures' delay + mFirstUseDelaySeconds = llclamp( + mFirstSeenTimer.getElapsedTimeF32(), + FIRST_APPEARANCE_CLOUD_MIN_DELAY, + FIRST_APPEARANCE_CLOUD_MAX_DELAY); + + if (shouldImpostor()) + { + // Impostors are less of a priority, + // let them stay cloud longer + mFirstUseDelaySeconds *= 1.25; + } + } + mFullyLoaded = (mFullyLoadedTimer.getElapsedTimeF32() > mFirstUseDelaySeconds); } else { diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 74ef589ca4..f7daabae56 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -380,6 +380,9 @@ protected: private: BOOL mFirstFullyVisible; + F32 mFirstUseDelaySeconds; + LLFrameTimer mFirstSeenTimer; + BOOL mFullyLoaded; BOOL mPreviousFullyLoaded; BOOL mFullyLoadedInitialized; -- cgit v1.2.3 From 7ce17542d46ff7cb6b88d33d4cad5ba4808c6c58 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 12 Nov 2021 17:34:13 +0200 Subject: DRTVWR-528 Reverting multiple commits due to moving them into D546 branch This reverts commits 9b5b2eac82b1f423daec463b3d55d0f3d3979bbc SL-15933 53c0144dd272470172591b967a84beaa4019b728 SL-11687 492ea7c3a03d5ef0d3679b873a44c08baaced0f1 SL-16056 b854eceee3a867d64b20de18d6b7ce91b33abed0 SL-15391 921c3f5f69c90b5924d2f4bbbd32455f8c9c8173 SL-13561 639acb6ff7495a6840d437dd8473172ec03e200a SL-15333 --- autobuild.xml | 4 ++-- indra/llrender/llgl.cpp | 2 +- indra/llrender/llglslshader.cpp | 6 +----- indra/newview/llappviewer.cpp | 2 +- indra/newview/lldrawpoolwater.cpp | 13 ------------ indra/newview/llfloaterpreference.cpp | 6 ++++++ indra/newview/llviewercontrol.cpp | 1 + indra/newview/llviewershadermgr.cpp | 2 +- indra/newview/llvoavatar.cpp | 35 ++++++------------------------- indra/newview/llvoavatar.h | 3 --- indra/newview/pipeline.cpp | 39 ++++++++--------------------------- 11 files changed, 28 insertions(+), 85 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index e80e6c99b2..5424e0629a 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -1036,9 +1036,9 @@ archive hash - dce3f3c01fddb400cb143c3283fe9259 + 650e836255b6c2ecb93d3f1f7220051c url - https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/82754/775367/glh_linear-0.0.0-common-560278.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/55011/511905/glh_linear-0.0.0-common-538981.tar.bz2 name common diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 33cd840e50..43fedeca64 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -559,7 +559,7 @@ bool LLGLManager::initGL() glGetIntegerv(GL_NUM_EXTENSIONS, &count); for (GLint i = 0; i < count; ++i) { - std::string ext = ll_safe_string((const char*) glGetStringi(GL_EXTENSIONS, i)); + std::string ext((const char*) glGetStringi(GL_EXTENSIONS, i)); str << ext << " "; LL_DEBUGS("GLExtensions") << ext << LL_ENDL; } diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index d3942c7552..42b8c35442 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -1427,11 +1427,7 @@ GLint LLGLSLShader::getUniformLocation(U32 index) GLint ret = -1; if (mProgramObject) { - if (index >= mUniform.size()) - { - LL_WARNS_ONCE("Shader") << "Uniform index " << index << " out of bounds " << (S32)mUniform.size() << LL_ENDL; - return ret; - } + llassert(index < mUniform.size()); return mUniform[index]; } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 4a33563f3f..87f22a98c1 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -610,7 +610,7 @@ static void settings_modify() LLRenderTarget::sUseFBO = gSavedSettings.getBOOL("RenderDeferred"); LLPipeline::sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater"); LLPipeline::sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); - LLPipeline::sRenderDeferred = LLPipeline::sRenderBump && gSavedSettings.getBOOL("RenderDeferred"); + LLPipeline::sRenderDeferred = LLPipeline::sRenderTransparentWater && LLPipeline::sRenderBump && gSavedSettings.getBOOL("RenderDeferred"); LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor"); LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4] gDebugGL = gSavedSettings.getBOOL("RenderDebugGL") || gDebugSession; diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 0cf36e4e8a..aa426cd785 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -137,14 +137,6 @@ void LLDrawPoolWater::endPostDeferredPass(S32 pass) void LLDrawPoolWater::renderDeferred(S32 pass) { LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); - - if (!LLPipeline::sRenderTransparentWater) - { - // Will render opaque water without use of ALM - render(pass); - return; - } - deferred_render = TRUE; shade(); deferred_render = FALSE; @@ -347,11 +339,6 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() { LLVOSky *voskyp = gSky.mVOSkyp; - if (voskyp == NULL) - { - return; - } - LLGLSLShader* shader = NULL; if (LLGLSLShader::sNoFixedFunction) { diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 92e64d0b95..6bf2136f60 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1198,9 +1198,11 @@ void LLFloaterPreference::refreshEnabledState() //Deferred/SSAO/Shadows BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump"); + BOOL transparent_water = LLFeatureManager::getInstance()->isFeatureAvailable("RenderTransparentWater") && gSavedSettings.getBOOL("RenderTransparentWater"); BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders"); BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && bumpshiny && + transparent_water && shaders && gGLManager.mHasFramebufferObject && gSavedSettings.getBOOL("RenderAvatarVP") && @@ -1224,6 +1226,9 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() ctrl_reflections->setEnabled(reflections); reflections_text->setEnabled(reflections); + // Transparent Water + LLCheckBoxCtrl* transparent_water_ctrl = getChild("TransparentWater"); + // Bump & Shiny LLCheckBoxCtrl* bumpshiny_ctrl = getChild("BumpShiny"); bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump"); @@ -1274,6 +1279,7 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) && + ((transparent_water_ctrl && transparent_water_ctrl->get()) ? TRUE : FALSE) && gGLManager.mHasFramebufferObject && gSavedSettings.getBOOL("RenderAvatarVP") && (ctrl_wind_light->get()) ? TRUE : FALSE; diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 73e0719128..76dc9a6790 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -187,6 +187,7 @@ static bool handleRenderPerfTestChanged(const LLSD& newvalue) bool handleRenderTransparentWaterChanged(const LLSD& newvalue) { + LLRenderTarget::sUseFBO = newvalue.asBoolean(); if (gPipeline.isInit()) { gPipeline.updateRenderTransparentWater(); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 854fcf1359..43e9a2333e 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -435,7 +435,7 @@ void LLViewerShaderMgr::setShaders() initAttribsAndUniforms(); gPipeline.releaseGLBuffers(); - LLPipeline::sWaterReflections = gGLManager.mHasCubeMap && LLPipeline::sRenderTransparentWater; + LLPipeline::sWaterReflections = gGLManager.mHasCubeMap; LLPipeline::sRenderGlow = gSavedSettings.getBOOL("RenderGlow"); LLPipeline::updateRenderDeferred(); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 6e7d0744a5..e085a945a8 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -126,9 +126,6 @@ const F32 MIN_HOVER_Z = -2.0; const F32 MIN_ATTACHMENT_COMPLEXITY = 0.f; const F32 DEFAULT_MAX_ATTACHMENT_COMPLEXITY = 1.0e6f; -const F32 FIRST_APPEARANCE_CLOUD_MIN_DELAY = 3.f; // seconds -const F32 FIRST_APPEARANCE_CLOUD_MAX_DELAY = 45.f; - using namespace LLAvatarAppearanceDefines; //----------------------------------------------------------------------------- @@ -667,7 +664,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mVisuallyMuteSetting(AV_RENDER_NORMALLY), mMutedAVColor(LLColor4::white /* used for "uninitialize" */), mFirstFullyVisible(TRUE), - mFirstUseDelaySeconds(FIRST_APPEARANCE_CLOUD_MIN_DELAY), mFullyLoaded(FALSE), mPreviousFullyLoaded(FALSE), mFullyLoadedInitialized(FALSE), @@ -742,7 +738,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mCurrentGesticulationLevel = 0; - mFirstSeenTimer.reset(); + mRuthTimer.reset(); mRuthDebugTimer.reset(); mDebugExistenceTimer.reset(); @@ -8130,35 +8126,16 @@ void LLVOAvatar::updateRuthTimer(bool loading) BOOL LLVOAvatar::processFullyLoadedChange(bool loading) { // We wait a little bit before giving the 'all clear', to let things to - // settle down (models to snap into place, textures to get first packets). - // And if viewer isn't aware of some parts yet, this gives them a chance - // to arrive. + // settle down (models to snap into place, textures to get first packets) const F32 LOADED_DELAY = 1.f; + const F32 FIRST_USE_DELAY = 3.f; - if (loading) - { - mFullyLoadedTimer.reset(); - } + if (loading) + mFullyLoadedTimer.reset(); if (mFirstFullyVisible) { - if (!isSelf() && loading) - { - // Note that textures can causes 60s delay on thier own - // so this delay might end up on top of textures' delay - mFirstUseDelaySeconds = llclamp( - mFirstSeenTimer.getElapsedTimeF32(), - FIRST_APPEARANCE_CLOUD_MIN_DELAY, - FIRST_APPEARANCE_CLOUD_MAX_DELAY); - - if (shouldImpostor()) - { - // Impostors are less of a priority, - // let them stay cloud longer - mFirstUseDelaySeconds *= 1.25; - } - } - mFullyLoaded = (mFullyLoadedTimer.getElapsedTimeF32() > mFirstUseDelaySeconds); + mFullyLoaded = (mFullyLoadedTimer.getElapsedTimeF32() > FIRST_USE_DELAY); } else { diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index f7daabae56..74ef589ca4 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -380,9 +380,6 @@ protected: private: BOOL mFirstFullyVisible; - F32 mFirstUseDelaySeconds; - LLFrameTimer mFirstSeenTimer; - BOOL mFullyLoaded; BOOL mPreviousFullyLoaded; BOOL mFullyLoadedInitialized; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c417b55108..9924b02a95 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1054,6 +1054,7 @@ void LLPipeline::updateRenderDeferred() RenderDeferred && LLRenderTarget::sUseFBO && LLPipeline::sRenderBump && + LLPipeline::sRenderTransparentWater && RenderAvatarVP && WindLightUseAtmosShaders && (bool) LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"); @@ -9259,12 +9260,7 @@ inline float sgn(float a) void LLPipeline::generateWaterReflection(LLCamera& camera_in) { - if (!assertInitialized()) - { - return; - } - - if (LLPipeline::sWaterReflections && LLDrawPoolWater::sNeedsReflectionUpdate) + if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate) { bool skip_avatar_update = false; if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) @@ -9491,13 +9487,19 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) //clip out geometry on the same side of water as the camera w/ enough margin to not include the water geo itself, // but not so much as to clip out parts of avatars that should be seen under the water in the distortion map - LLPlane plane(-pnorm, camera_is_underwater ? -water_height : water_dist); + LLPlane plane(-pnorm, water_dist); LLGLUserClipPlane clip_plane(plane, saved_modelview, saved_projection); gGL.setColorMask(true, true); mWaterDis.clear(); gGL.setColorMask(true, false); + // ignore clip plane if we're underwater and viewing distortion map of objects above waterline + if (camera_is_underwater) + { + clip_plane.disable(); + } + if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT) { updateCull(camera, mRefractedObjects, water_clip, &plane); @@ -9551,29 +9553,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; } - else - { - // Initial sky pass is still needed even if water reflection is not rendering - bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); - if (!camera_is_underwater) - { - gPipeline.pushRenderTypeMask(); - { - gPipeline.andRenderTypeMask( - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - - LLCamera camera = camera_in; - camera.setFar(camera_in.getFar() * 0.75f); - - updateCull(camera, mSky); - stateSort(camera, mSky); - renderGeom(camera, TRUE); - } - gPipeline.popRenderTypeMask(); - } - } } glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) -- cgit v1.2.3 From b7a7bcdc22addf49867bd522f239f0bc87a31891 Mon Sep 17 00:00:00 2001 From: Euclid Linden Date: Fri, 12 Nov 2021 21:30:52 +0000 Subject: Revert "SL-14895, point light atten should move inversely light radius (pull request #496)" --- indra/newview/pipeline.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9924b02a95..cd1b9c7c69 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6387,19 +6387,21 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) continue; } - LLVector3 light_pos(light->getRenderPosition()); - LLVector4 light_pos_gl(light_pos, 1.0f); + LLVector3 light_pos(light->getRenderPosition()); + LLVector4 light_pos_gl(light_pos, 1.0f); + + F32 light_radius = llmax(light->getLightRadius(), 0.001f); + F32 size = light_radius * (sRenderDeferred ? 1.5f : 1.0f); - F32 adjusted_radius = light->getLightRadius() * (sRenderDeferred ? 1.5f : 1.0f); - if (adjusted_radius <= 0.001f) + if (size <= 0.001f) { continue; } - F32 x = (3.f * (1.f + (light->getLightFalloff() * 2.0f))); // why this magic? probably trying to match a historic behavior. - F32 linatten = x / adjusted_radius; // % of brightness at radius + F32 x = (3.f * (1.f + (light->getLightFalloff() * 2.0f))); // why this magic? probably trying to match a historic behavior. + F32 linatten = x / (light_radius); // % of brightness at radius - mHWLightColors[cur_light] = light_color; + mHWLightColors[cur_light] = light_color; LLLightState* light_state = gGL.getLight(cur_light); light_state->setPosition(light_pos_gl); @@ -6408,7 +6410,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) light_state->setConstantAttenuation(0.f); if (sRenderDeferred) { - light_state->setLinearAttenuation(linatten); + light_state->setLinearAttenuation(size); light_state->setQuadraticAttenuation(light->getLightFalloff(DEFERRED_LIGHT_FALLOFF) + 1.f); // get falloff to match for forward deferred rendering lights } else -- cgit v1.2.3 From e914f3e4a11ff86b3e05089c9b3a6677ec623c9c Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Fri, 12 Nov 2021 14:49:00 -0700 Subject: Revert "SL-14895, restore previous post-deferred alpha behavior" This reverts commit ebadc409de90c75f96a005e8f45a3eee4ad243e0. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 14 +++----------- .../app_settings/shaders/class1/deferred/materialF.glsl | 12 ++---------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d3a05c34c0..dc484317e9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -86,14 +86,6 @@ float getAmbientClamp(); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { - // SL-14895 inverted attenuation work-around - // This routine is tweaked to match deferred lighting, but previously used an inverted la value. To reconstruct - // that previous value now that the inversion is corrected, we reverse the calculations in LLPipeline::setupHWLights() - // to recover the `adjusted_radius` value previously being sent as la. - float falloff_factor = (12.0 * fa) - 9.0; - float inverted_la = falloff_factor / la; - // Yes, it makes me want to cry as well. DJH - vec3 col = vec3(0); //get light vector @@ -103,7 +95,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float dist = length(lv); float da = 1.0; - /*if (dist > inverted_la) + /*if (dist > la) { return col; } @@ -121,9 +113,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec return col; }*/ - if (dist > 0.0 && inverted_la > 0.0) + if (dist > 0.0 && la > 0.0) { - dist /= inverted_la; + dist /= la; //normalize light vector lv = normalize(lv); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 02d83925ea..e1f7031af6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -91,14 +91,6 @@ float getAmbientClamp(); vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance) { - // SL-14895 inverted attenuation work-around - // This routine is tweaked to match deferred lighting, but previously used an inverted la value. To reconstruct - // that previous value now that the inversion is corrected, we reverse the calculations in LLPipeline::setupHWLights() - // to recover the `adjusted_radius` value previously being sent as la. - float falloff_factor = (12.0 * fa) - 9.0; - float inverted_la = falloff_factor / la; - // Yes, it makes me want to cry as well. DJH - vec3 col = vec3(0); //get light vector @@ -108,9 +100,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe float dist = length(lv); float da = 1.0; - dist /= inverted_la; + dist /= la; - if (dist > 0.0 && inverted_la > 0.0) + if (dist > 0.0 && la > 0.0) { //normalize light vector lv = normalize(lv); -- cgit v1.2.3 From 101e282ca3d0e8ca0bf10b32a2a4b6362bc66b80 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 16 Nov 2021 12:12:20 -0700 Subject: DRTVWR-528 eradicate tab char found in 00-Common.cmake (fails Mac build) --- indra/cmake/00-Common.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 7c9e07b099..bf54b655c2 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -81,7 +81,7 @@ if (WINDOWS) set(CMAKE_CXX_FLAGS_RELEASE "${OG_CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /Zo" CACHE STRING "C++ compiler release options" FORCE) - + # zlib has assembly-language object files incompatible with SAFESEH set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE /SAFESEH:NO /NODEFAULTLIB:LIBCMT /IGNORE:4099") -- cgit v1.2.3 From b24c0a6ba2a97dc0f0cc19acca0fc095dec850fc Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 7 Jan 2022 17:57:39 -0800 Subject: SL-16605: Report VulkanMaxApiVersion with the appropiate Vulkan 0.0, 1.0, 1.x max API version depending on if we can load the .dll and/or vkEnumerateInstanceVersion. --- indra/newview/llviewerstats.cpp | 109 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 108 insertions(+), 1 deletion(-) diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 6471e89233..e8dcd95e44 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -64,6 +64,56 @@ #include "llvoicevivox.h" #include "lluiusage.h" +#define LL_MINIMAL_VULKAN 1 +#if LL_MINIMAL_VULKAN +// Calls + #if defined(_WIN32) + #define VKAPI_ATTR + #define VKAPI_CALL __stdcall + #define VKAPI_PTR VKAPI_CALL + #else + #define VKAPI_ATTR + #define VKAPI_CALL + #define VKAPI_PTR + #endif // _WIN32 + +// Macros + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + // <-------major-------><-----------minor-----------> <--------------patch--------------> + // 0x7 0x7F 0x3FF 0xFFF + #define VK_API_VERSION_MAJOR( version) (((uint32_t)(version) >> 22) & 0x07FU) // 7 bits + #define VK_API_VERSION_MINOR( version) (((uint32_t)(version) >> 12) & 0x3FFU) // 10 bits + #define VK_API_VERSION_PATCH( version) (((uint32_t)(version) ) & 0xFFFU) // 12 bits + #define VK_API_VERSION_VARIANT(version) (((uint32_t)(version) >> 29) & 0x007U) // 3 bits + + // NOTE: variant is first parameter! This is to match vulkan/vulkan_core.h + #define VK_MAKE_API_VERSION(variant, major, minor, patch) (0\ + | (((uint32_t)(major & 0x07FU)) << 22) \ + | (((uint32_t)(minor & 0x3FFU)) << 12) \ + | (((uint32_t)(patch & 0xFFFU)) ) \ + | (((uint32_t)(variant & 0x007U)) << 29) ) + + #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; + +// Types + VK_DEFINE_HANDLE(VkInstance); + + typedef enum VkResult + { + VK_SUCCESS = 0, + VK_RESULT_MAX_ENUM = 0x7FFFFFFF + } VkResult; + +// Prototypes + typedef void (VKAPI_PTR *PFN_vkVoidFunction )(void); + typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddr )(VkInstance instance, const char* pName); + typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t* pApiVersion); +#else + #include +#endif // LL_MINIMAL_VULKAN + namespace LLStatViewer { @@ -594,19 +644,76 @@ void send_viewer_stats(bool include_preferences) // detailed information on versions and extensions can come later. static bool vulkan_oneshot = false; static bool vulkan_detected = false; + static std::string vulkan_max_api_version( "0.0" ); // Unknown/None if (!vulkan_oneshot) { - HMODULE vulkan_loader = LoadLibraryExA("vulkan-1.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); + // The 32-bit and 64-bit versions normally exist in: + // C:\Windows\System32 + // C:\Windows\SysWOW64 + HMODULE vulkan_loader = LoadLibraryA("vulkan-1.dll"); if (NULL != vulkan_loader) { vulkan_detected = true; + vulkan_max_api_version = "1.0"; // We have at least 1.0. See the note about vkEnumerateInstanceVersion() below. + + // We use Run-Time Dynamic Linking (via GetProcAddress()) instead of Load-Time Dynamic Linking (via directly calling vkGetInstanceProcAddr()). + // This allows us to: + // a) not need the header: #include + // (and not need to set the corresponding "Additional Include Directories" as long as we provide the equivalent Vulkan types/prototypes/etc.) + // b) not need to link to: vulkan-1.lib + // (and not need to set the corresponding "Additional Library Directories") + // The former will allow Second Life to start and run even if the vulkan.dll is missing. + // The latter will require us to: + // a) link with vulkan-1.lib + // b) cause a System Error at startup if the .dll is not found: + // "The code execution cannot proceed because vulkan-1.dll was not found." + // + // See: + // https://docs.microsoft.com/en-us/windows/win32/dlls/using-run-time-dynamic-linking + // https://docs.microsoft.com/en-us/windows/win32/dlls/run-time-dynamic-linking + + // NOTE: Technically we can use GetProcAddress() as a replacement for vkGetInstanceProcAddr() + // but the canonical recommendation (mandate?) is to use vkGetInstanceProcAddr(). + PFN_vkGetInstanceProcAddr pGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) GetProcAddress(vulkan_loader, "vkGetInstanceProcAddr"); + if(pGetInstanceProcAddr) + { + // Check for vkEnumerateInstanceVersion. If it exists then we have at least 1.1 and can query the max API version. + // NOTE: Each VkPhysicalDevice that supports Vulkan has its own VkPhysicalDeviceProperties.apiVersion which is separate from the max API version! + // See: https://www.lunarg.com/wp-content/uploads/2019/02/Vulkan-1.1-Compatibility-Statement_01_19.pdf + PFN_vkEnumerateInstanceVersion pEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) pGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion"); + if(pEnumerateInstanceVersion) + { + uint32_t version = VK_MAKE_API_VERSION(0,1,1,0); // e.g. 4202631 = 1.2.135.0 + VkResult status = pEnumerateInstanceVersion( &version ); + if (status != VK_SUCCESS) + { + LL_INFOS("Vulkan") << "Failed to get Vulkan version. Assuming 1.0" << LL_ENDL; + } + else + { + // https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#extendingvulkan-coreversions-versionnumbers + int major = VK_API_VERSION_MAJOR ( version ); + int minor = VK_API_VERSION_MINOR ( version ); + int patch = VK_API_VERSION_PATCH ( version ); + int variant = VK_API_VERSION_VARIANT( version ); + + vulkan_max_api_version = llformat( "%d.%d.%d.%d", major, minor, patch, variant ); + LL_INFOS("Vulkan") << "Vulkan API version: " << vulkan_max_api_version << ", Raw version: " << version << LL_ENDL; + } + } + } + else + { + LL_WARNS("Vulkan") << "FAILED to get Vulkan vkGetInstanceProcAddr()!" << LL_ENDL; + } FreeLibrary(vulkan_loader); } vulkan_oneshot = true; } misc["string_1"] = vulkan_detected ? llformat("Vulkan driver is detected") : llformat("No Vulkan driver detected"); + misc["VulkanMaxApiVersion"] = vulkan_max_api_version; #else misc["string_1"] = llformat("Unused"); -- cgit v1.2.3 From fe4f09e033ae2795f77281fa23533af343f423d3 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 10 Jan 2022 13:36:02 -0800 Subject: SL-16605: Remove fallback to Vulkan SDK --- indra/newview/llviewerstats.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index e8dcd95e44..a1f53743d4 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -64,8 +64,8 @@ #include "llvoicevivox.h" #include "lluiusage.h" -#define LL_MINIMAL_VULKAN 1 -#if LL_MINIMAL_VULKAN +// "Minimal Vulkan" to get max API Version + // Calls #if defined(_WIN32) #define VKAPI_ATTR @@ -110,9 +110,6 @@ typedef void (VKAPI_PTR *PFN_vkVoidFunction )(void); typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddr )(VkInstance instance, const char* pName); typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t* pApiVersion); -#else - #include -#endif // LL_MINIMAL_VULKAN namespace LLStatViewer { -- cgit v1.2.3 From d7bb4cdc8d90271a929bdae25628ef88437c5bee Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 7 Mar 2022 09:32:17 -0800 Subject: SL-15861: Fix inconsistent additive light spanning 180 degrees for water angles in Mid quality. --- indra/newview/lldrawpoolwater.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index aa426cd785..53e8ff6759 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -602,7 +602,10 @@ void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& li shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle); shader->uniform1i(LLShaderMgr::WATER_EDGE_FACTOR, edge ? 1 : 0); - LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); + // SL-15861 This was changed from getRotatedLightNorm() as it was causing + // lightnorm in shaders\class1\windlight\atmosphericsFuncs.glsl in have inconsistent additive lighting for 180 degrees of the FOV. + LLVector4 rotated_light_direction = LLEnvironment::instance().getClampedLightNorm(); + shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); -- cgit v1.2.3 From 34e79c8f4e251200496651f9ae2b5126a6f7faa3 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 11 Mar 2022 10:21:08 -0600 Subject: SL-17005 WIP Simplify what feeds texture loading bias to only pay attention to available memory according to OS and GL driver, not (broken) internal accounting (breaks intel GPUs, compatibility pass incoming). --- indra/llimage/llimage.cpp | 5 ---- indra/llimage/llimage.h | 1 - indra/llrender/llimagegl.cpp | 22 +---------------- indra/llrender/llimagegl.h | 8 +----- indra/llrender/llrender.cpp | 6 ++--- indra/newview/llfloaterlagmeter.cpp | 2 +- indra/newview/lltextureview.cpp | 11 +-------- indra/newview/llviewerstats.cpp | 5 +--- indra/newview/llviewerstats.h | 6 ++--- indra/newview/llviewertexture.cpp | 46 ++--------------------------------- indra/newview/llviewertexture.h | 8 ++---- indra/newview/llviewertexturelist.cpp | 3 --- indra/newview/llviewerwindow.cpp | 2 -- indra/newview/llvoavatarself.cpp | 1 - indra/newview/pipeline.cpp | 2 +- 15 files changed, 15 insertions(+), 113 deletions(-) diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 0fa027c9c3..3a3011d99b 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -798,7 +798,6 @@ U8* LLImageBase::allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 si // LLImageRaw //--------------------------------------------------------------------------- -S32 LLImageRaw::sGlobalRawMemory = 0; S32 LLImageRaw::sRawImageCount = 0; LLImageRaw::LLImageRaw() @@ -847,16 +846,13 @@ LLImageRaw::~LLImageRaw() U8* LLImageRaw::allocateData(S32 size) { U8* res = LLImageBase::allocateData(size); - sGlobalRawMemory += getDataSize(); return res; } // virtual U8* LLImageRaw::reallocateData(S32 size) { - sGlobalRawMemory -= getDataSize(); U8* res = LLImageBase::reallocateData(size); - sGlobalRawMemory += getDataSize(); return res; } @@ -869,7 +865,6 @@ void LLImageRaw::releaseData() // virtual void LLImageRaw::deleteData() { - sGlobalRawMemory -= getDataSize(); LLImageBase::deleteData(); } diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 7a588cfb03..460d5e0f5b 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -275,7 +275,6 @@ protected: void setDataAndSize(U8 *data, S32 width, S32 height, S8 components) ; public: - static S32 sGlobalRawMemory; static S32 sRawImageCount; private: diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 9bd3a0a6b0..c171f7051f 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -57,9 +57,6 @@ U32 wpo2(U32 i); U32 LLImageGL::sUniqueCount = 0; U32 LLImageGL::sBindCount = 0; -S32Bytes LLImageGL::sGlobalTextureMemory(0); -S32Bytes LLImageGL::sBoundTextureMemory(0); -S32Bytes LLImageGL::sCurBoundTextureMemory(0); S32 LLImageGL::sCount = 0; BOOL LLImageGL::sGlobalUseAnisotropic = FALSE; @@ -282,15 +279,6 @@ void LLImageGL::updateStats(F32 current_time) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; sLastFrameTime = current_time; - sBoundTextureMemory = sCurBoundTextureMemory; - sCurBoundTextureMemory = S32Bytes(0); -} - -//static -S32 LLImageGL::updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) -{ - LLImageGL::sCurBoundTextureMemory += mem ; - return LLImageGL::sCurBoundTextureMemory.value(); } //---------------------------------------------------------------------------- @@ -623,7 +611,7 @@ void LLImageGL::forceUpdateBindStats(void) const mLastBindTime = sLastFrameTime; } -BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const +BOOL LLImageGL::updateBindStats() const { if (mTexName != 0) { @@ -635,7 +623,6 @@ BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const { // we haven't accounted for this texture yet this frame sUniqueCount++; - updateBoundTexMem(tex_mem, mComponents, mCategory); mLastBindTime = sLastFrameTime; return TRUE ; @@ -1599,11 +1586,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ // things will break if we don't unbind after creation gGL.getTexUnit(0)->unbind(mBindTarget); - if (old_texname != 0) - { - sGlobalTextureMemory -= mTextureMemory; - } - //if we're on the image loading thread, be sure to delete old_texname and update mTexName on the main thread if (!defer_copy) { @@ -1624,7 +1606,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ mTextureMemory = (S32Bytes)getMipBytes(mCurrentDiscardLevel); - sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight(); // mark this as bound at this point, so we don't throw it out immediately @@ -1857,7 +1838,6 @@ void LLImageGL::destroyGLTexture() { if(mTextureMemory != S32Bytes(0)) { - sGlobalTextureMemory -= mTextureMemory; mTextureMemory = (S32Bytes)0; } diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 4d5b60d6bc..ae4ab7c9c3 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -61,7 +61,7 @@ public: static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); static S32 dataFormatComponents(S32 dataformat); - BOOL updateBindStats(S32Bytes tex_mem) const ; + BOOL updateBindStats() const ; F32 getTimePassedSinceLastBound(); void forceUpdateBindStats(void) const; @@ -73,9 +73,6 @@ public: static void restoreGL(); static void dirtyTexOptions(); - // Sometimes called externally for textures not using LLImageGL (should go away...) - static S32 updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) ; - static bool checkSize(S32 width, S32 height); //for server side use only. @@ -265,9 +262,6 @@ public: static F32 sLastFrameTime; // Global memory statistics - static S32Bytes sGlobalTextureMemory; // Tracks main memory texmem - static S32Bytes sBoundTextureMemory; // Tracks bound texmem for last completed frame - static S32Bytes sCurBoundTextureMemory; // Tracks bound texmem for current frame static U32 sBindCount; // Tracks number of texture binds for current frame static U32 sUniqueCount; // Tracks number of unique texture binds for current frame static BOOL sGlobalUseAnisotropic; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index a03a27cf94..15c509dbfb 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -223,7 +223,7 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) enable(gl_tex->getTarget()); mCurrTexture = gl_tex->getTexName(); glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); - if(gl_tex->updateBindStats(gl_tex->mTextureMemory)) + if(gl_tex->updateBindStats()) { texture->setActive() ; texture->updateBindStatsForTester() ; @@ -302,7 +302,7 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind, S32 mCurrTexture = texname; glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture); stop_glerror(); - texture->updateBindStats(texture->mTextureMemory); + texture->updateBindStats(); mHasMipMaps = texture->mHasMipMaps; if (texture->mTexOptionsDirty) { @@ -341,7 +341,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) mCurrTexture = cubeMap->mImages[0]->getTexName(); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture); mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps; - cubeMap->mImages[0]->updateBindStats(cubeMap->mImages[0]->mTextureMemory); + cubeMap->mImages[0]->updateBindStats(); if (cubeMap->mImages[0]->mTexOptionsDirty) { cubeMap->mImages[0]->mTexOptionsDirty = false; diff --git a/indra/newview/llfloaterlagmeter.cpp b/indra/newview/llfloaterlagmeter.cpp index f72f2631a1..db00f69f03 100644 --- a/indra/newview/llfloaterlagmeter.cpp +++ b/indra/newview/llfloaterlagmeter.cpp @@ -179,7 +179,7 @@ void LLFloaterLagMeter::determineClient() { mClientCause->setText( getString("client_texture_loading_cause_msg", mStringArgs) ); } - else if(LLViewerTexture::sBoundTextureMemory > LLViewerTexture::sMaxBoundTextureMemory) + else if(LLViewerTexture::isMemoryForTextureLow()) { mClientCause->setText( getString("client_texture_memory_cause_msg", mStringArgs) ); } diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index b74577315e..b58070526c 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -500,10 +500,6 @@ private: void LLGLTexMemBar::draw() { - S32Megabytes bound_mem = LLViewerTexture::sBoundTextureMemory; - S32Megabytes max_bound_mem = LLViewerTexture::sMaxBoundTextureMemory; - S32Megabytes total_mem = LLViewerTexture::sTotalTextureMemory; - S32Megabytes max_total_mem = LLViewerTexture::sMaxTotalTextureMem; F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; F32 cache_usage = LLAppViewer::getTextureCache()->getUsage().valueInUnits(); F32 cache_max_usage = LLAppViewer::getTextureCache()->getMaxUsage().valueInUnits(); @@ -549,15 +545,10 @@ void LLGLTexMemBar::draw() U32 texFetchLatMed = U32(recording.getMean(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); U32 texFetchLatMax = U32(recording.getMax(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); - text = llformat("GL Tot: %d/%d MB GL Free: %d Sys Free: %d MB Bound: %4d/%4d MB FBO: %d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB", - total_mem.value(), - max_total_mem.value(), + text = llformat("GL Free: %d Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB", LLImageGLThread::getFreeVRAMMegabytes(), LLMemory::getAvailableMemKB()/1024, - bound_mem.value(), - max_bound_mem.value(), LLRenderTarget::sBytesAllocated/(1024*1024), - LLImageRaw::sGlobalRawMemory >> 20, discard_bias, cache_usage, cache_max_usage); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 57a3d011d5..d87afa9a41 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -155,10 +155,7 @@ LLTrace::SampleStatHandle > static LLTrace::SampleStatHandle CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"); -LLTrace::SampleStatHandle GL_TEX_MEM("gltexmemstat"), - GL_BOUND_MEM("glboundmemstat"), - RAW_MEM("rawmemstat"), - FORMATTED_MEM("formattedmemstat"); +LLTrace::SampleStatHandle FORMATTED_MEM("formattedmemstat"); LLTrace::SampleStatHandle DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"), MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"); diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 017c79b2e3..8d1182d054 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -191,10 +191,8 @@ extern LLTrace::SampleStatHandle<> FPS_SAMPLE, extern LLTrace::SampleStatHandle > PACKETS_LOST_PERCENT; -extern LLTrace::SampleStatHandle GL_TEX_MEM, - GL_BOUND_MEM, - RAW_MEM, - FORMATTED_MEM; +extern LLTrace::SampleStatHandle FORMATTED_MEM; + extern LLTrace::SampleStatHandle DELTA_BANDWIDTH, MAX_BANDWIDTH; extern SimMeasurement SIM_FRAME_TIME, diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index e3ac56d0d3..be7ee3660e 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -84,11 +84,6 @@ S32 LLViewerTexture::sAuxCount = 0; LLFrameTimer LLViewerTexture::sEvaluationTimer; F32 LLViewerTexture::sDesiredDiscardBias = 0.f; F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; -S32Bytes LLViewerTexture::sBoundTextureMemory; -S32Bytes LLViewerTexture::sTotalTextureMemory; -S32Megabytes LLViewerTexture::sMaxBoundTextureMemory; -S32Megabytes LLViewerTexture::sMaxTotalTextureMem; -S32Bytes LLViewerTexture::sMaxDesiredTextureMem; S8 LLViewerTexture::sCameraMovingDiscardBias = 0; F32 LLViewerTexture::sCameraMovingBias = 0.0f; S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size @@ -553,27 +548,7 @@ void LLViewerTexture::updateClass() LLViewerMediaTexture::updateClass(); - sBoundTextureMemory = LLImageGL::sBoundTextureMemory; - sTotalTextureMemory = LLImageGL::sGlobalTextureMemory; - sMaxBoundTextureMemory = gTextureList.getMaxResidentTexMem(); - sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem(); - sMaxDesiredTextureMem = sMaxTotalTextureMem; //in Bytes, by default and when total used texture memory is small. - - if (sBoundTextureMemory >= sMaxBoundTextureMemory || - sTotalTextureMemory >= sMaxTotalTextureMem) - { - //when texture memory overflows, lower down the threshold to release the textures more aggressively. - sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, F32Bytes(gMaxVideoRam)); - - // If we are using more texture memory than we should, - // scale up the desired discard level - if (sEvaluationTimer.getElapsedTimeF32() > discard_delta_time) - { - sDesiredDiscardBias += discard_bias_delta; - sEvaluationTimer.reset(); - } - } - else if(isMemoryForTextureLow()) + if(isMemoryForTextureLow()) { // Note: isMemoryForTextureLow() uses 1s delay, make sure we waited enough for it to recheck if (sEvaluationTimer.getElapsedTimeF32() > GPU_MEMORY_CHECK_WAIT_TIME) @@ -583,8 +558,6 @@ void LLViewerTexture::updateClass() } } else if (sDesiredDiscardBias > 0.0f - && sBoundTextureMemory < sMaxBoundTextureMemory * texmem_lower_bound_scale - && sTotalTextureMemory < sMaxTotalTextureMem * texmem_lower_bound_scale && isMemoryForTextureSuficientlyFree()) { // If we are using less texture memory than we should, @@ -1352,10 +1325,7 @@ void LLViewerFetchedTexture::dump() void LLViewerFetchedTexture::destroyTexture() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - if(LLImageGL::sGlobalTextureMemory < sMaxDesiredTextureMem * 0.95f)//not ready to release unused memory. - { - return ; - } + if (mNeedsCreateTexture)//return if in the process of generating a new texture. { return; @@ -3400,18 +3370,6 @@ void LLViewerLODTexture::processTextureStats() //needs to release texture memory urgently scaleDown(); } - // Limit the amount of GL memory bound each frame - else if ( sBoundTextureMemory > sMaxBoundTextureMemory * texmem_middle_bound_scale && - (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) - { - scaleDown(); - } - // Only allow GL to have 2x the video card memory - else if ( sTotalTextureMemory > sMaxTotalTextureMem * texmem_middle_bound_scale && - (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) - { - scaleDown(); - } } if (isUpdateFrozen() // we are out of memory and nearing max allowed bias diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index b953d7006b..0640efe6df 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -188,10 +188,11 @@ private: virtual void switchToCachedImage(); - static bool isMemoryForTextureLow() ; static bool isMemoryForTextureSuficientlyFree(); static void getGPUMemoryForTextures(S32Megabytes &gpu, S32Megabytes &physical); +public: + static bool isMemoryForTextureLow(); protected: LLUUID mID; S32 mTextureListType; // along with mID identifies where to search for this texture in TextureList @@ -226,11 +227,6 @@ public: static LLFrameTimer sEvaluationTimer; static F32 sDesiredDiscardBias; static F32 sDesiredDiscardScale; - static S32Bytes sBoundTextureMemory; - static S32Bytes sTotalTextureMemory; - static S32Megabytes sMaxBoundTextureMemory; - static S32Megabytes sMaxTotalTextureMem; - static S32Bytes sMaxDesiredTextureMem ; static S8 sCameraMovingDiscardBias; static F32 sCameraMovingBias; static S32 sMaxSculptRez ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 94a91d4a72..66e113b45c 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -784,9 +784,6 @@ void LLViewerTextureList::updateImages(F32 max_time) using namespace LLStatViewer; sample(NUM_IMAGES, sNumImages); sample(NUM_RAW_IMAGES, LLImageRaw::sRawImageCount); - sample(GL_TEX_MEM, LLImageGL::sGlobalTextureMemory); - sample(GL_BOUND_MEM, LLImageGL::sBoundTextureMemory); - sample(RAW_MEM, F64Bytes(LLImageRaw::sGlobalRawMemory)); sample(FORMATTED_MEM, F64Bytes(LLImageFormatted::sGlobalFormattedMemory)); } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index a54c29a404..47d612ab9a 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5532,8 +5532,6 @@ void LLViewerWindow::stopGL(BOOL save_state) LLGLSLShader* shader = *(LLGLSLShader::sInstances.begin()); shader->unload(); } - - LL_INFOS() << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemory.value() << " bytes" << LL_ENDL; } } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 60a69a4ac4..49f5f40f03 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2823,7 +2823,6 @@ void LLVOAvatarSelf::deleteScratchTextures() LL_DEBUGS() << "Clearing Scratch Textures " << (S32Kilobytes)sScratchTexBytes << LL_ENDL; delete_and_clear(sScratchTexNames); - LLImageGL::sGlobalTextureMemory -= sScratchTexBytes; sScratchTexBytes = S32Bytes(0); } } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 34c4e2ddb9..2aff3de29b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3712,7 +3712,7 @@ void LLPipeline::touchTexture(LLViewerTexture* tex, F32 vsize) if (tex) { LLImageGL* gl_tex = tex->getGLTexture(); - if (gl_tex && gl_tex->updateBindStats(gl_tex->mTextureMemory)) + if (gl_tex && gl_tex->updateBindStats()) { tex->setActive(); tex->addTextureStats(vsize); -- cgit v1.2.3 From e60024f0afecb6f92e383221084f1a7af02f8542 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 29 Mar 2022 15:41:00 -0500 Subject: SL-17005 WIP - Use D3D/DXGI to query for available VRAM on Windows --- indra/llrender/llimagegl.cpp | 52 --------------- indra/llrender/llimagegl.h | 8 --- indra/llwindow/CMakeLists.txt | 2 + indra/llwindow/llwindow.h | 3 + indra/llwindow/llwindowheadless.h | 2 + indra/llwindow/llwindowwin32.cpp | 136 ++++++++++++++++++++++++++++++++++++++ indra/llwindow/llwindowwin32.h | 4 +- indra/newview/lltextureview.cpp | 6 +- indra/newview/llviewerdisplay.cpp | 2 - indra/newview/llviewertexture.cpp | 4 +- 10 files changed, 153 insertions(+), 66 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index c171f7051f..0a5d258b3a 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1615,51 +1615,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ return TRUE; } -void LLImageGLThread::updateClass() -{ - LL_PROFILE_ZONE_SCOPED; - - // update available vram one per second - static LLFrameTimer sTimer; - - if (sTimer.getElapsedSeconds() < 1.f) - { - return; - } - - sTimer.reset(); - - auto func = []() - { - if (gGLManager.mHasATIMemInfo) - { - S32 meminfo[4]; - glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo); - LLImageGLThread::sFreeVRAMMegabytes = meminfo[0]; - - } - else if (gGLManager.mHasNVXMemInfo) - { - S32 free_memory; - glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &free_memory); - LLImageGLThread::sFreeVRAMMegabytes = free_memory / 1024; - } - }; - - - // post update to background thread if available, otherwise execute immediately - auto queue = LL::WorkQueue::getInstance("LLImageGL"); - if (sEnabled) - { - queue->post(func); - } - else - { - llassert(queue == nullptr); - func(); - } -} - void LLImageGL::syncToMainThread(LLGLuint new_tex_name) { LL_PROFILE_ZONE_SCOPED; @@ -2389,8 +2344,6 @@ void LLImageGL::checkActiveThread() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, nummips); */ -std::atomic LLImageGLThread::sFreeVRAMMegabytes(4096); //if free vram is unknown, default to 4GB - LLImageGLThread::LLImageGLThread(LLWindow* window) // We want exactly one thread, but a very large capacity: we never want // anyone, especially inner-loop render code, to have to block on post() @@ -2418,8 +2371,3 @@ void LLImageGLThread::run() mWindow->destroySharedContext(mContext); } -S32 LLImageGLThread::getFreeVRAMMegabytes() -{ - return sFreeVRAMMegabytes; -} - diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index ae4ab7c9c3..1716338c0b 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -321,12 +321,6 @@ public: // follows gSavedSettings "RenderGLMultiThreaded" static bool sEnabled; - // app should call this function periodically - static void updateClass(); - - // free video memory in megabytes - static std::atomic sFreeVRAMMegabytes; - LLImageGLThread(LLWindow* window); // post a function to be executed on the LLImageGL background thread @@ -338,8 +332,6 @@ public: void run() override; - static S32 getFreeVRAMMegabytes(); - private: LLWindow* mWindow; void* mContext = nullptr; diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 70eb99c86c..32f0fa14c4 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -145,6 +145,8 @@ if (WINDOWS) list(APPEND llwindow_LINK_LIBRARIES comdlg32 # Common Dialogs for ChooseColor ole32 + dxgi + d3d9 ) endif (WINDOWS) diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 0edf39f6ef..507e6076d6 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -163,6 +163,9 @@ public: virtual F32 getPixelAspectRatio() = 0; virtual void setNativeAspectRatio(F32 aspect) = 0; + // query VRAM usage + virtual U32 getAvailableVRAMMegabytes() = 0; + virtual void beforeDialog() {}; // prepare to put up an OS dialog (if special measures are required, such as in fullscreen mode) virtual void afterDialog() {}; // undo whatever was done in beforeDialog() diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h index 410da79623..0e1f603db7 100644 --- a/indra/llwindow/llwindowheadless.h +++ b/indra/llwindow/llwindowheadless.h @@ -96,6 +96,8 @@ public: /*virtual*/ F32 getPixelAspectRatio() { return 1.0f; }; /*virtual*/ void setNativeAspectRatio(F32 ratio) {} + U32 getAvailableVRAMMegabytes() override { return 4096; } + /*virtual*/ void *getPlatformWindow() { return 0; }; /*virtual*/ void bringToFront() {}; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 9feccd7874..3afb78d1d2 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -47,6 +47,7 @@ #include "llglslshader.h" #include "llthreadsafequeue.h" #include "stringize.h" +#include "llframetimer.h" // System includes #include @@ -61,6 +62,10 @@ #include #include // std::pair +#include +#include + + // Require DirectInput version 8 #define DIRECTINPUT_VERSION 0x0800 @@ -347,6 +352,20 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool void run() override; + // initialzie DXGI adapter (for querying available VRAM) + void initDX(); + + // initialize D3D (if DXGI cannot be used) + void initD3D(); + + // call periodically to update available VRAM + void updateVRAMUsage(); + + U32 getAvailableVRAMMegabytes() + { + return mAvailableVRAM; + } + /// called by main thread to post work to this window thread template void post(CALLABLE&& func) @@ -395,6 +414,12 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool void gatherInput(); HWND mWindowHandle = NULL; HDC mhDC = 0; + + std::atomic mAvailableVRAM; + + IDXGIAdapter3* mDXGIAdapter = nullptr; + LPDIRECT3D9 mD3D = nullptr; + LPDIRECT3DDEVICE9 mD3DDevice = nullptr; }; @@ -4507,6 +4532,10 @@ std::vector LLWindowWin32::getDynamicFallbackFontList() return std::vector(); } +U32 LLWindowWin32::getAvailableVRAMMegabytes() +{ + return mWindowThread ? mWindowThread->getAvailableVRAMMegabytes() : 0; +} #endif // LL_WINDOWS @@ -4562,17 +4591,97 @@ private: std::string mPrev; }; +void LLWindowWin32::LLWindowWin32Thread::initDX() +{ + if (mDXGIAdapter == NULL) + { + IDXGIFactory4* pFactory = nullptr; + + HRESULT res = CreateDXGIFactory1(__uuidof(IDXGIFactory4), (void**)&pFactory); + + if (FAILED(res)) + { + LL_WARNS() << "CreateDXGIFactory1 failed: 0x" << std::hex << res << LL_ENDL; + } + else + { + res = pFactory->EnumAdapters(0, reinterpret_cast(&mDXGIAdapter)); + if (FAILED(res)) + { + LL_WARNS() << "EnumAdapters failed: 0x" << std::hex << res << LL_ENDL; + } + } + + pFactory->Release(); + } +} + +void LLWindowWin32::LLWindowWin32Thread::initD3D() +{ + if (mDXGIAdapter == NULL && mD3DDevice == NULL && mWindowHandle != 0) + { + mD3D = Direct3DCreate9(D3D_SDK_VERSION); + + D3DPRESENT_PARAMETERS d3dpp; + + ZeroMemory(&d3dpp, sizeof(d3dpp)); + d3dpp.Windowed = TRUE; + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + + mD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mWindowHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &mD3DDevice); + } +} + +void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage() +{ + LL_PROFILE_ZONE_SCOPED; + if (mDXGIAdapter != nullptr) + { + DXGI_QUERY_VIDEO_MEMORY_INFO info; + mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info); + + // try to use no more than the available reserve minus 10% + U32 target = info.AvailableForReservation / 1024 / 1024; + target -= target / 10; + + U32 used_vram = info.CurrentUsage / 1024 / 1024; + + mAvailableVRAM = used_vram < target ? target - used_vram : 0; + + /*LL_INFOS() << "\nLocal\nAFR: " << info.AvailableForReservation / 1024 / 1024 + << "\nBudget: " << info.Budget / 1024 / 1024 + << "\nCR: " << info.CurrentReservation / 1024 / 1024 + << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL; + + mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &info); + LL_INFOS() << "\nNon-Local\nAFR: " << info.AvailableForReservation / 1024 / 1024 + << "\nBudget: " << info.Budget / 1024 / 1024 + << "\nCR: " << info.CurrentReservation / 1024 / 1024 + << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL;*/ + } + else if (mD3DDevice != NULL) + { // fallback to D3D9 + mAvailableVRAM = mD3DDevice->GetAvailableTextureMem() / 1024 / 1024; + } + +} + void LLWindowWin32::LLWindowWin32Thread::run() { sWindowThreadId = std::this_thread::get_id(); LogChange logger("Window"); + initDX(); + while (! getQueue().done()) { LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32; if (mWindowHandle != 0) { + // lazily call initD3D inside this loop to catch when mWindowHandle has been set + initD3D(); + MSG msg; BOOL status; if (mhDC == 0) @@ -4605,6 +4714,13 @@ void LLWindowWin32::LLWindowWin32Thread::run() getQueue().runPending(); } + // update available vram once every 3 seconds + static LLFrameTimer vramTimer; + if (vramTimer.getElapsedTimeF32() > 3.f) + { + updateVRAMUsage(); + vramTimer.reset(); + } #if 0 { LL_PROFILE_ZONE_NAMED_CATEGORY_WIN32("w32t - Sleep"); @@ -4613,6 +4729,26 @@ void LLWindowWin32::LLWindowWin32Thread::run() } #endif } + + //clean up DXGI/D3D resources + if (mDXGIAdapter) + { + mDXGIAdapter->Release(); + mDXGIAdapter = nullptr; + } + + if (mD3DDevice) + { + mD3DDevice->Release(); + mD3DDevice = nullptr; + } + + if (mD3D) + { + mD3D->Release(); + mD3D = nullptr; + } + } void LLWindowWin32::post(const std::function& func) diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index b391acc12d..bd53b3e92a 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -108,7 +108,9 @@ public: /*virtual*/ F32 getPixelAspectRatio(); /*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; } - /*virtual*/ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b ); + U32 getAvailableVRAMMegabytes() override; + + /*virtual*/ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b ); /*virtual*/ void *getPlatformWindow(); /*virtual*/ void bringToFront(); diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index b58070526c..99ab854293 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -49,6 +49,8 @@ #include "llviewerobjectlist.h" #include "llviewertexture.h" #include "llviewertexturelist.h" +#include "llviewerwindow.h" +#include "llwindow.h" #include "llvovolume.h" #include "llviewerstats.h" #include "llworld.h" @@ -545,8 +547,8 @@ void LLGLTexMemBar::draw() U32 texFetchLatMed = U32(recording.getMean(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); U32 texFetchLatMax = U32(recording.getMax(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); - text = llformat("GL Free: %d Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB", - LLImageGLThread::getFreeVRAMMegabytes(), + text = llformat("GL Free: %d Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB", + gViewerWindow->getWindow()->getAvailableVRAMMegabytes(), LLMemory::getAvailableMemKB()/1024, LLRenderTarget::sBytesAllocated/(1024*1024), discard_bias, diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 6a2b06d9b5..4fc1bdbec3 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -788,8 +788,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLViewerTexture::updateClass(); } - LLImageGLThread::updateClass(); - { LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_BUMP); gBumpImageList.updateImages(); // must be called before gTextureList version so that it's textures are thrown out first. diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index be7ee3660e..ac6c86d9c6 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -58,6 +58,8 @@ #include "llvovolume.h" #include "llviewermedia.h" #include "lltexturecache.h" +#include "llviewerwindow.h" +#include "llwindow.h" /////////////////////////////////////////////////////////////////////////////// // extern @@ -523,7 +525,7 @@ void LLViewerTexture::getGPUMemoryForTextures(S32Megabytes &gpu, S32Megabytes &p timer.reset(); { - gpu_res = (S32Megabytes) LLImageGLThread::getFreeVRAMMegabytes(); + gpu_res = (S32Megabytes)gViewerWindow->getWindow()->getAvailableVRAMMegabytes(); //check main memory, only works for windows. LLMemory::updateMemoryInfo(); -- cgit v1.2.3 From b6841d75c2f259c84d5ab6b012bd2ae37d985451 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 15 Apr 2022 19:02:07 -0500 Subject: SL-17219 WIP - Texture pipeline overhaul --- indra/llappearance/lltexlayerparams.cpp | 2 +- indra/llappearance/lltexlayerparams.h | 2 +- indra/llcommon/llapr.cpp | 2 + indra/llcommon/llqueuedthread.cpp | 289 +++++++------- indra/llcommon/llqueuedthread.h | 51 +-- indra/llcommon/lltimer.cpp | 3 +- indra/llcommon/llworkerthread.cpp | 27 +- indra/llcommon/llworkerthread.h | 11 +- indra/llcommon/workqueue.h | 8 +- indra/llcorehttp/_httplibcurl.cpp | 59 +-- indra/llcorehttp/_httpoperation.cpp | 1 - indra/llcorehttp/_httpoperation.h | 1 - indra/llcorehttp/_httpoprequest.cpp | 48 ++- indra/llcorehttp/_httpoprequest.h | 22 -- indra/llcorehttp/_httpopsetpriority.cpp | 3 + indra/llcorehttp/_httpopsetpriority.h | 6 +- indra/llcorehttp/_httppolicy.cpp | 31 -- indra/llcorehttp/_httppolicy.h | 6 - indra/llcorehttp/_httpservice.cpp | 32 +- indra/llcorehttp/_httpservice.h | 9 - indra/llcorehttp/httprequest.cpp | 45 +-- indra/llcorehttp/httprequest.h | 30 -- indra/llfilesystem/lllfsthread.cpp | 25 +- indra/llfilesystem/lllfsthread.h | 13 +- indra/llimage/llimagej2c.cpp | 2 + indra/llimage/llimageworker.cpp | 36 +- indra/llimage/llimageworker.h | 9 +- indra/llimagej2coj/llimagej2coj.cpp | 1 + indra/llkdu/llimagej2ckdu.cpp | 29 +- indra/llmessage/llavatarnamecache.cpp | 2 - indra/llmessage/llcorehttputil.cpp | 27 +- indra/llmessage/llcorehttputil.h | 25 +- indra/llrender/llimagegl.cpp | 50 ++- indra/newview/app_settings/settings.xml | 28 +- indra/newview/featuretable.txt | 1 - indra/newview/featuretable_mac.txt | 1 - indra/newview/llappviewer.cpp | 2 +- indra/newview/lldrawpoolterrain.cpp | 2 +- indra/newview/llface.cpp | 1 + indra/newview/llfloaterpreference.cpp | 7 +- indra/newview/llinventorymodel.cpp | 3 - indra/newview/llinventorymodel.h | 2 - indra/newview/llmaterialmgr.cpp | 7 +- indra/newview/llmaterialmgr.h | 1 - indra/newview/llmediadataclient.cpp | 2 +- indra/newview/llmeshrepository.cpp | 8 +- indra/newview/llmeshrepository.h | 2 - indra/newview/llspatialpartition.cpp | 6 +- indra/newview/lltexturecache.cpp | 110 ++---- indra/newview/lltexturecache.h | 6 +- indra/newview/lltexturefetch.cpp | 275 ++++++------- indra/newview/lltexturefetch.h | 11 +- indra/newview/lltextureview.cpp | 39 +- indra/newview/llviewercontrol.cpp | 7 - indra/newview/llviewertexture.cpp | 316 +++++---------- indra/newview/llviewertexture.h | 27 +- indra/newview/llviewertexturelist.cpp | 433 ++++++++------------- indra/newview/llviewertexturelist.h | 17 +- indra/newview/llvoavatar.cpp | 9 - indra/newview/llvoavatarself.cpp | 8 +- indra/newview/llvovolume.cpp | 34 +- indra/newview/llxmlrpctransaction.cpp | 2 +- indra/newview/pipeline.cpp | 48 ++- .../en/floater_preferences_graphics_advanced.xml | 17 - 64 files changed, 893 insertions(+), 1446 deletions(-) diff --git a/indra/llappearance/lltexlayerparams.cpp b/indra/llappearance/lltexlayerparams.cpp index ce5c7142d5..06b4f6c75a 100644 --- a/indra/llappearance/lltexlayerparams.cpp +++ b/indra/llappearance/lltexlayerparams.cpp @@ -151,7 +151,7 @@ LLTexLayerParamAlpha::LLTexLayerParamAlpha(const LLTexLayerParamAlpha& pOther) mCachedProcessedTexture(pOther.mCachedProcessedTexture), mStaticImageTGA(pOther.mStaticImageTGA), mStaticImageRaw(pOther.mStaticImageRaw), - mNeedsCreateTexture(pOther.mNeedsCreateTexture), + mNeedsCreateTexture(pOther.mNeedsCreateTexture.load()), mStaticImageInvalid(pOther.mStaticImageInvalid), mAvgDistortionVec(pOther.mAvgDistortionVec), mCachedEffectiveWeight(pOther.mCachedEffectiveWeight) diff --git a/indra/llappearance/lltexlayerparams.h b/indra/llappearance/lltexlayerparams.h index e2440998b3..000f55685e 100644 --- a/indra/llappearance/lltexlayerparams.h +++ b/indra/llappearance/lltexlayerparams.h @@ -100,7 +100,7 @@ private: LLPointer mCachedProcessedTexture; LLPointer mStaticImageTGA; LLPointer mStaticImageRaw; - BOOL mNeedsCreateTexture; + std::atomic mNeedsCreateTexture; BOOL mStaticImageInvalid; LL_ALIGN_16(LLVector4a mAvgDistortionVec); F32 mCachedEffectiveWeight; diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index db94765871..b537102510 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -526,6 +526,7 @@ S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset) //static S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool) { + LL_PROFILE_ZONE_SCOPED; //***************************************** LLAPRFilePoolScope scope(pool); apr_file_t* file_handle = open(filename, scope.getVolatileAPRPool(), APR_READ|APR_BINARY); @@ -570,6 +571,7 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb //static S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool) { + LL_PROFILE_ZONE_SCOPED; apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; if (offset < 0) { diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 8cef4293cd..871c42f7ee 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -26,20 +26,25 @@ #include "linden_common.h" #include "llqueuedthread.h" +#include + #include "llstl.h" #include "lltimer.h" // ms_sleep() -#include "lltracethreadrecorder.h" +#include "llmutex.h" //============================================================================ // MAIN THREAD LLQueuedThread::LLQueuedThread(const std::string& name, bool threaded, bool should_pause) : - LLThread(name), - mThreaded(threaded), - mIdleThread(TRUE), - mNextHandle(0), - mStarted(FALSE) + LLThread(name), + mThreaded(threaded), + mIdleThread(TRUE), + mNextHandle(0), + mStarted(FALSE), + mRequestQueue(name, 1024 * 1024) { + mMainQueue = LL::WorkQueue::getInstance("mainloop"); + if (mThreaded) { if(should_pause) @@ -104,6 +109,8 @@ void LLQueuedThread::shutdown() { LL_WARNS() << "~LLQueuedThread() called with active requests: " << active_count << LL_ENDL; } + + mRequestQueue.close(); } //---------------------------------------------------------------------------- @@ -112,6 +119,7 @@ void LLQueuedThread::shutdown() // virtual S32 LLQueuedThread::update(F32 max_time_ms) { + LL_PROFILE_ZONE_SCOPED; if (!mStarted) { if (!mThreaded) @@ -125,29 +133,30 @@ S32 LLQueuedThread::update(F32 max_time_ms) S32 LLQueuedThread::updateQueue(F32 max_time_ms) { - F64 max_time = (F64)max_time_ms * .001; - LLTimer timer; - S32 pending = 1; - + LL_PROFILE_ZONE_SCOPED; // Frame Update if (mThreaded) { - pending = getPending(); - if(pending > 0) + // schedule a call to threadedUpdate for every call to updateQueue + mRequestQueue.post([=]() + { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update"); + mIdleThread = FALSE; + threadedUpdate(); + mIdleThread = TRUE; + } + ); + if(getPending() > 0) { - unpause(); - } + unpause(); + } } else { - while (pending > 0) - { - pending = processNextRequest(); - if (max_time && timer.getElapsedTimeF64() > max_time) - break; - } + mRequestQueue.runFor(std::chrono::microseconds((int) (max_time_ms*1000.f))); + threadedUpdate(); } - return pending; + return getPending(); } void LLQueuedThread::incQueue() @@ -166,11 +175,7 @@ void LLQueuedThread::incQueue() // May be called from any thread S32 LLQueuedThread::getPending() { - S32 res; - lockData(); - res = mRequestQueue.size(); - unlockData(); - return res; + return mRequestQueue.size(); } // MAIN thread @@ -195,35 +200,28 @@ void LLQueuedThread::waitOnPending() // MAIN thread void LLQueuedThread::printQueueStats() { - lockData(); - if (!mRequestQueue.empty()) + U32 size = mRequestQueue.size(); + if (size > 0) { - QueuedRequest *req = *mRequestQueue.begin(); - LL_INFOS() << llformat("Pending Requests:%d Current status:%d", mRequestQueue.size(), req->getStatus()) << LL_ENDL; + LL_INFOS() << llformat("Pending Requests:%d ", mRequestQueue.size()) << LL_ENDL; } else { LL_INFOS() << "Queued Thread Idle" << LL_ENDL; } - unlockData(); } // MAIN thread LLQueuedThread::handle_t LLQueuedThread::generateHandle() { - lockData(); - while ((mNextHandle == nullHandle()) || (mRequestHash.find(mNextHandle))) - { - mNextHandle++; - } - const LLQueuedThread::handle_t res = mNextHandle++; - unlockData(); + U32 res = ++mNextHandle; return res; } // MAIN thread bool LLQueuedThread::addRequest(QueuedRequest* req) { + LL_PROFILE_ZONE_SCOPED; if (mStatus == QUITTING) { return false; @@ -231,14 +229,14 @@ bool LLQueuedThread::addRequest(QueuedRequest* req) lockData(); req->setStatus(STATUS_QUEUED); - mRequestQueue.insert(req); - mRequestHash.insert(req); + mRequestHash.insert(req); #if _DEBUG // LL_INFOS() << llformat("LLQueuedThread::Added req [%08d]",handle) << LL_ENDL; #endif unlockData(); - incQueue(); + llassert(!mDataLock->isSelfLocked()); + mRequestQueue.post([this, req]() { processRequest(req); }); return true; } @@ -246,6 +244,7 @@ bool LLQueuedThread::addRequest(QueuedRequest* req) // MAIN thread bool LLQueuedThread::waitForResult(LLQueuedThread::handle_t handle, bool auto_complete) { + LL_PROFILE_ZONE_SCOPED; llassert (handle != nullHandle()); bool res = false; bool waspaused = isPaused(); @@ -312,6 +311,7 @@ LLQueuedThread::status_t LLQueuedThread::getRequestStatus(handle_t handle) void LLQueuedThread::abortRequest(handle_t handle, bool autocomplete) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; lockData(); QueuedRequest* req = (QueuedRequest*)mRequestHash.find(handle); if (req) @@ -333,30 +333,9 @@ void LLQueuedThread::setFlags(handle_t handle, U32 flags) unlockData(); } -void LLQueuedThread::setPriority(handle_t handle, U32 priority) -{ - lockData(); - QueuedRequest* req = (QueuedRequest*)mRequestHash.find(handle); - if (req) - { - if(req->getStatus() == STATUS_INPROGRESS) - { - // not in list - req->setPriority(priority); - } - else if(req->getStatus() == STATUS_QUEUED) - { - // remove from list then re-insert - llverify(mRequestQueue.erase(req) == 1); - req->setPriority(priority); - mRequestQueue.insert(req); - } - } - unlockData(); -} - bool LLQueuedThread::completeRequest(handle_t handle) { + LL_PROFILE_ZONE_SCOPED; bool res = false; lockData(); QueuedRequest* req = (QueuedRequest*)mRequestHash.find(handle); @@ -399,89 +378,115 @@ bool LLQueuedThread::check() //============================================================================ // Runs on its OWN thread -S32 LLQueuedThread::processNextRequest() +void LLQueuedThread::processRequest(LLQueuedThread::QueuedRequest* req) { - QueuedRequest *req; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; + + mIdleThread = FALSE; + //threadedUpdate(); + // Get next request from pool lockData(); - while(1) - { - req = NULL; - if (mRequestQueue.empty()) - { - break; - } - req = *mRequestQueue.begin(); - mRequestQueue.erase(mRequestQueue.begin()); - if ((req->getFlags() & FLAG_ABORT) || (mStatus == QUITTING)) - { - req->setStatus(STATUS_ABORTED); - req->finishRequest(false); - if (req->getFlags() & FLAG_AUTO_COMPLETE) - { - mRequestHash.erase(req); - req->deleteRequest(); -// check(); - } - continue; - } - llassert_always(req->getStatus() == STATUS_QUEUED); - break; - } - U32 start_priority = 0 ; - if (req) - { - req->setStatus(STATUS_INPROGRESS); - start_priority = req->getPriority(); - } - unlockData(); - - // This is the only place we will call req->setStatus() after - // it has initially been seet to STATUS_QUEUED, so it is - // safe to access req. - if (req) + if ((req->getFlags() & FLAG_ABORT) || (mStatus == QUITTING)) { - // process request - bool complete = req->processRequest(); - - if (complete) + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qtpr - abort"); + req->setStatus(STATUS_ABORTED); + req->finishRequest(false); + if (req->getFlags() & FLAG_AUTO_COMPLETE) { - lockData(); - req->setStatus(STATUS_COMPLETE); - req->finishRequest(true); - if (req->getFlags() & FLAG_AUTO_COMPLETE) - { - mRequestHash.erase(req); - req->deleteRequest(); + mRequestHash.erase(req); + req->deleteRequest(); // check(); - } - unlockData(); } - else - { - lockData(); - req->setStatus(STATUS_QUEUED); - mRequestQueue.insert(req); - unlockData(); - if (mThreaded && start_priority < PRIORITY_NORMAL) - { - ms_sleep(1); // sleep the thread a little - } - } - - LLTrace::get_thread_recorder()->pushToParent(); + unlockData(); } + else + { + llassert_always(req->getStatus() == STATUS_QUEUED); + + if (req) + { + req->setStatus(STATUS_INPROGRESS); + } + unlockData(); + + // This is the only place we will call req->setStatus() after + // it has initially been seet to STATUS_QUEUED, so it is + // safe to access req. + if (req) + { + // process request + bool complete = req->processRequest(); + + if (complete) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qtpr - complete"); + lockData(); + req->setStatus(STATUS_COMPLETE); + req->finishRequest(true); + if (req->getFlags() & FLAG_AUTO_COMPLETE) + { + mRequestHash.erase(req); + req->deleteRequest(); + // check(); + } + unlockData(); + } + else + { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qtpr - retry"); + //put back on queue and try again in 0.1ms + lockData(); + req->setStatus(STATUS_QUEUED); + + unlockData(); + + llassert(!mDataLock->isSelfLocked()); + +#if 0 + // try again on next frame + // NOTE: tried using "post" with a time in the future, but this + // would invariably cause this thread to wait for a long time (10+ ms) + // while work is pending + bool ret = LL::WorkQueue::postMaybe( + mMainQueue, + [=]() + { + LL_PROFILE_ZONE_NAMED("processRequest - retry"); + mRequestQueue.post([=]() + { + LL_PROFILE_ZONE_NAMED("processRequest - retry"); // <-- not redundant, track retry on both queues + processRequest(req); + }); + }); + llassert(ret); +#else + using namespace std::chrono_literals; + auto retry_time = LL::WorkQueue::TimePoint::clock::now() + 16ms; + mRequestQueue.post([=] + { + LL_PROFILE_ZONE_NAMED("processRequest - retry"); + while (LL::WorkQueue::TimePoint::clock::now() < retry_time) + { + std::this_thread::yield(); //note: don't use LLThread::yield here to avoid + } + processRequest(req); + }); +#endif + + } + } + } - S32 pending = getPending(); - return pending; + mIdleThread = TRUE; } // virtual bool LLQueuedThread::runCondition() { // mRunCondition must be locked here - if (mRequestQueue.empty() && mIdleThread) + if (mRequestQueue.size() == 0 && mIdleThread) return false; else return true; @@ -495,18 +500,13 @@ void LLQueuedThread::run() startThread(); mStarted = TRUE; - while (1) + + /*while (1) { + LL_PROFILE_ZONE_SCOPED; // this will block on the condition until runCondition() returns true, the thread is unpaused, or the thread leaves the RUNNING state. checkPause(); - if (isQuitting()) - { - LLTrace::get_thread_recorder()->pushToParent(); - endThread(); - break; - } - mIdleThread = FALSE; threadedUpdate(); @@ -515,12 +515,18 @@ void LLQueuedThread::run() if (pending_work == 0) { + //LL_PROFILE_ZONE_NAMED("LLQueuedThread - sleep"); mIdleThread = TRUE; - ms_sleep(1); + //ms_sleep(1); } //LLThread::yield(); // thread should yield after each request - } + }*/ + mRequestQueue.runUntilClose(); + + endThread(); LL_INFOS() << "LLQueuedThread " << mName << " EXITING." << LL_ENDL; + + } // virtual @@ -540,10 +546,9 @@ void LLQueuedThread::threadedUpdate() //============================================================================ -LLQueuedThread::QueuedRequest::QueuedRequest(LLQueuedThread::handle_t handle, U32 priority, U32 flags) : +LLQueuedThread::QueuedRequest::QueuedRequest(LLQueuedThread::handle_t handle, U32 flags) : LLSimpleHashEntry(handle), mStatus(STATUS_UNKNOWN), - mPriority(priority), mFlags(flags) { } diff --git a/indra/llcommon/llqueuedthread.h b/indra/llcommon/llqueuedthread.h index 5d3f873646..6b82ccc434 100644 --- a/indra/llcommon/llqueuedthread.h +++ b/indra/llcommon/llqueuedthread.h @@ -36,6 +36,7 @@ #include "llthread.h" #include "llsimplehash.h" +#include "workqueue.h" //============================================================================ // Note: ~LLQueuedThread is O(N) N=# of queued threads, assumed to be small @@ -45,15 +46,6 @@ class LL_COMMON_API LLQueuedThread : public LLThread { //------------------------------------------------------------------------ public: - enum priority_t { - PRIORITY_IMMEDIATE = 0x7FFFFFFF, - PRIORITY_URGENT = 0x40000000, - PRIORITY_HIGH = 0x30000000, - PRIORITY_NORMAL = 0x20000000, - PRIORITY_LOW = 0x10000000, - PRIORITY_LOWBITS = 0x0FFFFFFF, - PRIORITY_HIGHBITS = 0x70000000 - }; enum status_t { STATUS_EXPIRED = -1, STATUS_UNKNOWN = 0, @@ -82,28 +74,17 @@ public: virtual ~QueuedRequest(); // use deleteRequest() public: - QueuedRequest(handle_t handle, U32 priority, U32 flags = 0); + QueuedRequest(handle_t handle, U32 flags = 0); status_t getStatus() { return mStatus; } - U32 getPriority() const - { - return mPriority; - } U32 getFlags() const { return mFlags; } - bool higherPriority(const QueuedRequest& second) const - { - if ( mPriority == second.mPriority) - return mHashKey < second.mHashKey; - else - return mPriority > second.mPriority; - } - + protected: status_t setStatus(status_t newstatus) { @@ -121,28 +102,11 @@ public: virtual void finishRequest(bool completed); // Always called from thread after request has completed or aborted virtual void deleteRequest(); // Only method to delete a request - void setPriority(U32 pri) - { - // Only do this on a request that is not in a queued list! - mPriority = pri; - }; - protected: LLAtomicBase mStatus; - U32 mPriority; U32 mFlags; }; -protected: - struct queued_request_less - { - bool operator()(const QueuedRequest* lhs, const QueuedRequest* rhs) const - { - return lhs->higherPriority(*rhs); // higher priority in front of queue (set) - } - }; - - //------------------------------------------------------------------------ public: @@ -167,7 +131,7 @@ private: protected: handle_t generateHandle(); bool addRequest(QueuedRequest* req); - S32 processNextRequest(void); + void processRequest(QueuedRequest* req); void incQueue(); public: @@ -186,7 +150,6 @@ public: status_t getRequestStatus(handle_t handle); void abortRequest(handle_t handle, bool autocomplete); void setFlags(handle_t handle, U32 flags); - void setPriority(handle_t handle, U32 priority); bool completeRequest(handle_t handle); // This is public for support classes like LLWorkerThread, // but generally the methods above should be used. @@ -200,8 +163,10 @@ protected: BOOL mStarted; // required when mThreaded is false to call startThread() from update() LLAtomicBool mIdleThread; // request queue is empty (or we are quitting) and the thread is idle - typedef std::set request_queue_t; - request_queue_t mRequestQueue; + //typedef std::set request_queue_t; + //request_queue_t mRequestQueue; + LL::WorkQueue mRequestQueue; + LL::WorkQueue::weak_t mMainQueue; enum { REQUEST_HASH_SIZE = 512 }; // must be power of 2 typedef LLSimpleHash request_hash_t; diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index aaa6df325c..b250bc3e1c 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -64,7 +64,8 @@ LLTimer* LLTimer::sTimer = NULL; #if LL_WINDOWS void ms_sleep(U32 ms) { - Sleep(ms); + LL_PROFILE_ZONE_SCOPED; + std::this_thread::sleep_for(std::chrono::microseconds(ms)); } U32 micro_sleep(U64 us, U32 max_yields) diff --git a/indra/llcommon/llworkerthread.cpp b/indra/llcommon/llworkerthread.cpp index 4b91b2caca..02ce4823b8 100644 --- a/indra/llcommon/llworkerthread.cpp +++ b/indra/llcommon/llworkerthread.cpp @@ -133,11 +133,11 @@ S32 LLWorkerThread::update(F32 max_time_ms) //---------------------------------------------------------------------------- -LLWorkerThread::handle_t LLWorkerThread::addWorkRequest(LLWorkerClass* workerclass, S32 param, U32 priority) +LLWorkerThread::handle_t LLWorkerThread::addWorkRequest(LLWorkerClass* workerclass, S32 param) { handle_t handle = generateHandle(); - WorkRequest* req = new WorkRequest(handle, priority, workerclass, param); + WorkRequest* req = new WorkRequest(handle, workerclass, param); bool res = addRequest(req); if (!res) @@ -160,8 +160,8 @@ void LLWorkerThread::deleteWorker(LLWorkerClass* workerclass) //============================================================================ // Runs on its OWN thread -LLWorkerThread::WorkRequest::WorkRequest(handle_t handle, U32 priority, LLWorkerClass* workerclass, S32 param) : - LLQueuedThread::QueuedRequest(handle, priority), +LLWorkerThread::WorkRequest::WorkRequest(handle_t handle, LLWorkerClass* workerclass, S32 param) : + LLQueuedThread::QueuedRequest(handle), mWorkerClass(workerclass), mParam(param) { @@ -180,6 +180,7 @@ void LLWorkerThread::WorkRequest::deleteRequest() // virtual bool LLWorkerThread::WorkRequest::processRequest() { + LL_PROFILE_ZONE_SCOPED; LLWorkerClass* workerclass = getWorkerClass(); workerclass->setWorking(true); bool complete = workerclass->doWork(getParam()); @@ -190,6 +191,7 @@ bool LLWorkerThread::WorkRequest::processRequest() // virtual void LLWorkerThread::WorkRequest::finishRequest(bool completed) { + LL_PROFILE_ZONE_SCOPED; LLWorkerClass* workerclass = getWorkerClass(); workerclass->finishWork(getParam(), completed); U32 flags = LLWorkerClass::WCF_WORK_FINISHED | (completed ? 0 : LLWorkerClass::WCF_WORK_ABORTED); @@ -203,7 +205,6 @@ LLWorkerClass::LLWorkerClass(LLWorkerThread* workerthread, const std::string& na : mWorkerThread(workerthread), mWorkerClassName(name), mRequestHandle(LLWorkerThread::nullHandle()), - mRequestPriority(LLWorkerThread::PRIORITY_NORMAL), mMutex(), mWorkFlags(0) { @@ -292,7 +293,7 @@ bool LLWorkerClass::yield() //---------------------------------------------------------------------------- // calls startWork, adds doWork() to queue -void LLWorkerClass::addWork(S32 param, U32 priority) +void LLWorkerClass::addWork(S32 param) { mMutex.lock(); llassert_always(!(mWorkFlags & (WCF_WORKING|WCF_HAVE_WORK))); @@ -306,7 +307,7 @@ void LLWorkerClass::addWork(S32 param, U32 priority) startWork(param); clearFlags(WCF_WORK_FINISHED|WCF_WORK_ABORTED); setFlags(WCF_HAVE_WORK); - mRequestHandle = mWorkerThread->addWorkRequest(this, param, priority); + mRequestHandle = mWorkerThread->addWorkRequest(this, param); mMutex.unlock(); } @@ -321,7 +322,6 @@ void LLWorkerClass::abortWork(bool autocomplete) if (mRequestHandle != LLWorkerThread::nullHandle()) { mWorkerThread->abortRequest(mRequestHandle, autocomplete); - mWorkerThread->setPriority(mRequestHandle, LLQueuedThread::PRIORITY_IMMEDIATE); setFlags(WCF_ABORT_REQUESTED); } mMutex.unlock(); @@ -395,16 +395,5 @@ void LLWorkerClass::scheduleDelete() } } -void LLWorkerClass::setPriority(U32 priority) -{ - mMutex.lock(); - if (mRequestHandle != LLWorkerThread::nullHandle() && mRequestPriority != priority) - { - mRequestPriority = priority; - mWorkerThread->setPriority(mRequestHandle, priority); - } - mMutex.unlock(); -} - //============================================================================ diff --git a/indra/llcommon/llworkerthread.h b/indra/llcommon/llworkerthread.h index 0387e75c65..06bbb7369e 100644 --- a/indra/llcommon/llworkerthread.h +++ b/indra/llcommon/llworkerthread.h @@ -56,7 +56,7 @@ public: virtual ~WorkRequest(); // use deleteRequest() public: - WorkRequest(handle_t handle, U32 priority, LLWorkerClass* workerclass, S32 param); + WorkRequest(handle_t handle, LLWorkerClass* workerclass, S32 param); S32 getParam() { @@ -90,7 +90,7 @@ public: /*virtual*/ S32 update(F32 max_time_ms); - handle_t addWorkRequest(LLWorkerClass* workerclass, S32 param, U32 priority = PRIORITY_NORMAL); + handle_t addWorkRequest(LLWorkerClass* workerclass, S32 param); S32 getNumDeletes() { return (S32)mDeleteList.size(); } // debug @@ -151,10 +151,6 @@ public: bool isWorking() { return getFlags(WCF_WORKING); } bool wasAborted() { return getFlags(WCF_ABORT_REQUESTED); } - // setPriority(): changes the priority of a request - void setPriority(U32 priority); - U32 getPriority() { return mRequestPriority; } - const std::string& getName() const { return mWorkerClassName; } protected: @@ -169,7 +165,7 @@ protected: void setWorkerThread(LLWorkerThread* workerthread); // addWork(): calls startWork, adds doWork() to queue - void addWork(S32 param, U32 priority = LLWorkerThread::PRIORITY_NORMAL); + void addWork(S32 param); // abortWork(): requests that work be aborted void abortWork(bool autocomplete); @@ -193,7 +189,6 @@ protected: LLWorkerThread* mWorkerThread; std::string mWorkerClassName; handle_t mRequestHandle; - U32 mRequestPriority; // last priority set private: LLMutex mMutex; diff --git a/indra/llcommon/workqueue.h b/indra/llcommon/workqueue.h index 96574a18b9..46f7363830 100644 --- a/indra/llcommon/workqueue.h +++ b/indra/llcommon/workqueue.h @@ -161,10 +161,16 @@ namespace LL void postEvery(const std::chrono::duration& interval, CALLABLE&& callable); + template + bool tryPost(const TimePoint& time, CALLABLE&& callable) + { + return mQueue.tryPush(TimedWork(time, std::move(callable))); + } + template bool tryPost(CALLABLE&& callable) { - return mQueue.tryPush(TimedWork(TimePoint::clock::now(), std::move(callable))); + return mQueue.tryPost(TimePoint::clock::now(), std::move(callable)); } /*------------------------- handshake API --------------------------*/ diff --git a/indra/llcorehttp/_httplibcurl.cpp b/indra/llcorehttp/_httplibcurl.cpp index 975ce8a4d5..bd0ac740db 100644 --- a/indra/llcorehttp/_httplibcurl.cpp +++ b/indra/llcorehttp/_httplibcurl.cpp @@ -113,6 +113,7 @@ void HttpLibcurl::shutdown() void HttpLibcurl::start(int policy_count) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; llassert_always(policy_count <= HTTP_POLICY_CLASS_LIMIT); llassert_always(! mMultiHandles); // One-time call only @@ -143,6 +144,7 @@ void HttpLibcurl::start(int policy_count) // sleep otherwise ask for a normal polling interval. HttpService::ELoopSpeed HttpLibcurl::processTransport() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpService::ELoopSpeed ret(HttpService::REQUEST_SLEEP); // Give libcurl some cycles to do I/O & callbacks @@ -168,6 +170,7 @@ HttpService::ELoopSpeed HttpLibcurl::processTransport() CURLMcode status(CURLM_CALL_MULTI_PERFORM); do { + LL_PROFILE_ZONE_NAMED_CATEGORY_NETWORK("httppt - curl_multi_perform"); running = 0; status = curl_multi_perform(mMultiHandles[policy_class], &running); } @@ -176,31 +179,34 @@ HttpService::ELoopSpeed HttpLibcurl::processTransport() // Run completion on anything done CURLMsg * msg(NULL); int msgs_in_queue(0); - while ((msg = curl_multi_info_read(mMultiHandles[policy_class], &msgs_in_queue))) - { - if (CURLMSG_DONE == msg->msg) - { - CURL * handle(msg->easy_handle); - CURLcode result(msg->data.result); + { + LL_PROFILE_ZONE_NAMED_CATEGORY_NETWORK("httppt - curl_multi_info_read"); + while ((msg = curl_multi_info_read(mMultiHandles[policy_class], &msgs_in_queue))) + { + if (CURLMSG_DONE == msg->msg) + { + CURL* handle(msg->easy_handle); + CURLcode result(msg->data.result); - completeRequest(mMultiHandles[policy_class], handle, result); - handle = NULL; // No longer valid on return - ret = HttpService::NORMAL; // If anything completes, we may have a free slot. - // Turning around quickly reduces connection gap by 7-10mS. - } - else if (CURLMSG_NONE == msg->msg) - { - // Ignore this... it shouldn't mean anything. - ; - } - else - { - LL_WARNS_ONCE(LOG_CORE) << "Unexpected message from libcurl. Msg code: " - << msg->msg - << LL_ENDL; - } - msgs_in_queue = 0; - } + completeRequest(mMultiHandles[policy_class], handle, result); + handle = NULL; // No longer valid on return + ret = HttpService::NORMAL; // If anything completes, we may have a free slot. + // Turning around quickly reduces connection gap by 7-10mS. + } + else if (CURLMSG_NONE == msg->msg) + { + // Ignore this... it shouldn't mean anything. + ; + } + else + { + LL_WARNS_ONCE(LOG_CORE) << "Unexpected message from libcurl. Msg code: " + << msg->msg + << LL_ENDL; + } + msgs_in_queue = 0; + } + } } if (! mActiveOps.empty()) @@ -214,6 +220,7 @@ HttpService::ELoopSpeed HttpLibcurl::processTransport() // Caller has provided us with a ref count on op. void HttpLibcurl::addOp(const HttpOpRequest::ptr_t &op) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; llassert_always(op->mReqPolicy < mPolicyCount); llassert_always(mMultiHandles[op->mReqPolicy] != NULL); @@ -257,6 +264,7 @@ void HttpLibcurl::addOp(const HttpOpRequest::ptr_t &op) // method to kill the request. bool HttpLibcurl::cancel(HttpHandle handle) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t op = HttpOpRequest::fromHandle(handle); active_set_t::iterator it(mActiveOps.find(op)); if (mActiveOps.end() == it) @@ -282,6 +290,7 @@ bool HttpLibcurl::cancel(HttpHandle handle) // op to the reply queue with refcount intact. void HttpLibcurl::cancelRequest(const HttpOpRequest::ptr_t &op) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; // Deactivate request op->mCurlActive = false; @@ -308,6 +317,7 @@ void HttpLibcurl::cancelRequest(const HttpOpRequest::ptr_t &op) // Keep them synchronized as necessary. bool HttpLibcurl::completeRequest(CURLM * multi_handle, CURL * handle, CURLcode status) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpHandle ophandle(NULL); CURLcode ccode(CURLE_OK); @@ -445,6 +455,7 @@ int HttpLibcurl::getActiveCountInClass(int policy_class) const void HttpLibcurl::policyUpdated(int policy_class) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; if (policy_class < 0 || policy_class >= mPolicyCount || ! mMultiHandles) { return; diff --git a/indra/llcorehttp/_httpoperation.cpp b/indra/llcorehttp/_httpoperation.cpp index 3fc4e28910..3b64018132 100644 --- a/indra/llcorehttp/_httpoperation.cpp +++ b/indra/llcorehttp/_httpoperation.cpp @@ -62,7 +62,6 @@ HttpOperation::HttpOperation(): mReplyQueue(), mUserHandler(), mReqPolicy(HttpRequest::DEFAULT_POLICY_ID), - mReqPriority(0U), mTracing(HTTP_TRACE_OFF), mMyHandle(LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/llcorehttp/_httpoperation.h b/indra/llcorehttp/_httpoperation.h index 1a75921c09..8c1364bab4 100644 --- a/indra/llcorehttp/_httpoperation.h +++ b/indra/llcorehttp/_httpoperation.h @@ -181,7 +181,6 @@ protected: public: // Request Data HttpRequest::policy_t mReqPolicy; - HttpRequest::priority_t mReqPriority; // Reply Data HttpStatus mStatus; diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index ba31290c24..d60eb6c95f 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -200,6 +200,7 @@ HttpOpRequest::~HttpOpRequest() void HttpOpRequest::stageFromRequest(HttpService * service) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t self(boost::dynamic_pointer_cast(shared_from_this())); service->getPolicy().addOp(self); // transfers refcount } @@ -207,6 +208,7 @@ void HttpOpRequest::stageFromRequest(HttpService * service) void HttpOpRequest::stageFromReady(HttpService * service) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t self(boost::dynamic_pointer_cast(shared_from_this())); service->getTransport().addOp(self); // transfers refcount } @@ -214,6 +216,7 @@ void HttpOpRequest::stageFromReady(HttpService * service) void HttpOpRequest::stageFromActive(HttpService * service) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; if (mReplyLength) { // If non-zero, we received and processed a Content-Range @@ -250,6 +253,7 @@ void HttpOpRequest::stageFromActive(HttpService * service) void HttpOpRequest::visitNotifier(HttpRequest * request) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; if (mUserHandler) { HttpResponse * response = new HttpResponse(); @@ -292,6 +296,7 @@ void HttpOpRequest::visitNotifier(HttpRequest * request) HttpStatus HttpOpRequest::cancel() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; mStatus = HttpStatus(HttpStatus::LLCORE, HE_OP_CANCELED); addAsReply(); @@ -301,12 +306,12 @@ HttpStatus HttpOpRequest::cancel() HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers) { - setupCommon(policy_id, priority, url, NULL, options, headers); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + setupCommon(policy_id, url, NULL, options, headers); mReqMethod = HOR_GET; return HttpStatus(); @@ -314,14 +319,14 @@ HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, size_t offset, size_t len, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers) { - setupCommon(policy_id, priority, url, NULL, options, headers); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + setupCommon(policy_id, url, NULL, options, headers); mReqMethod = HOR_GET; mReqOffset = offset; mReqLength = len; @@ -335,13 +340,13 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers) { - setupCommon(policy_id, priority, url, body, options, headers); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + setupCommon(policy_id, url, body, options, headers); mReqMethod = HOR_POST; return HttpStatus(); @@ -349,13 +354,13 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers) { - setupCommon(policy_id, priority, url, body, options, headers); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + setupCommon(policy_id, url, body, options, headers); mReqMethod = HOR_PUT; return HttpStatus(); @@ -363,12 +368,12 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers) { - setupCommon(policy_id, priority, url, NULL, options, headers); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + setupCommon(policy_id, url, NULL, options, headers); mReqMethod = HOR_DELETE; return HttpStatus(); @@ -376,13 +381,13 @@ HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers) { - setupCommon(policy_id, priority, url, body, options, headers); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + setupCommon(policy_id, url, body, options, headers); mReqMethod = HOR_PATCH; return HttpStatus(); @@ -390,12 +395,12 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t &headers) { - setupCommon(policy_id, priority, url, NULL, options, headers); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + setupCommon(policy_id, url, NULL, options, headers); mReqMethod = HOR_COPY; return HttpStatus(); @@ -403,12 +408,12 @@ HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupMove(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t &headers) { - setupCommon(policy_id, priority, url, NULL, options, headers); + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + setupCommon(policy_id, url, NULL, options, headers); mReqMethod = HOR_MOVE; return HttpStatus(); @@ -416,15 +421,14 @@ HttpStatus HttpOpRequest::setupMove(HttpRequest::policy_t policy_id, void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; mProcFlags = 0U; mReqPolicy = policy_id; - mReqPriority = priority; mReqURL = url; if (body) { @@ -465,6 +469,7 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, // *TODO: Move this to _httplibcurl where it belongs. HttpStatus HttpOpRequest::prepareRequest(HttpService * service) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; // Scrub transport and result data for retried op case mCurlActive = false; mCurlHandle = NULL; @@ -773,6 +778,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) size_t HttpOpRequest::writeCallback(void * data, size_t size, size_t nmemb, void * userdata) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); if (! op->mReplyBody) @@ -788,6 +794,7 @@ size_t HttpOpRequest::writeCallback(void * data, size_t size, size_t nmemb, void size_t HttpOpRequest::readCallback(void * data, size_t size, size_t nmemb, void * userdata) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); if (! op->mReqBody) @@ -819,6 +826,7 @@ size_t HttpOpRequest::readCallback(void * data, size_t size, size_t nmemb, void int HttpOpRequest::seekCallback(void *userdata, curl_off_t offset, int origin) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); if (!op->mReqBody) @@ -850,6 +858,7 @@ int HttpOpRequest::seekCallback(void *userdata, curl_off_t offset, int origin) size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, void * userdata) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; static const char status_line[] = "HTTP/"; static const size_t status_line_len = sizeof(status_line) - 1; static const char con_ran_line[] = "content-range"; @@ -999,6 +1008,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi CURLcode HttpOpRequest::curlSslCtxCallback(CURL *curl, void *sslctx, void *userdata) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); if (op->mCallbackSSLVerify) @@ -1025,6 +1035,7 @@ CURLcode HttpOpRequest::curlSslCtxCallback(CURL *curl, void *sslctx, void *userd int HttpOpRequest::sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(param)); if (op->mCallbackSSLVerify) @@ -1037,6 +1048,7 @@ int HttpOpRequest::sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param) int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffer, size_t len, void * userdata) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); std::string safe_line; diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index cdbe350785..ec84822cf4 100644 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -105,13 +105,11 @@ public: /// Threading: called by application thread /// HttpStatus setupGet(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers); HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, size_t offset, size_t len, @@ -119,40 +117,34 @@ public: const HttpHeaders::ptr_t & headers); HttpStatus setupPost(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers); HttpStatus setupPut(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers); HttpStatus setupDelete(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers); HttpStatus setupPatch(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers); HttpStatus setupCopy(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers); HttpStatus setupMove(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers); @@ -172,7 +164,6 @@ protected: // Threading: called by application thread // void setupCommon(HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, @@ -239,19 +230,6 @@ public: -/// HttpOpRequestCompare isn't an operation but a uniform comparison -/// functor for STL containers that order by priority. Mainly -/// used for the ready queue container but defined here. -class HttpOpRequestCompare -{ -public: - bool operator()(const HttpOpRequest * lhs, const HttpOpRequest * rhs) - { - return lhs->mReqPriority > rhs->mReqPriority; - } -}; // end class HttpOpRequestCompare - - // --------------------------------------- // Free functions // --------------------------------------- diff --git a/indra/llcorehttp/_httpopsetpriority.cpp b/indra/llcorehttp/_httpopsetpriority.cpp index d48c7a0b7d..b99b4e9e4a 100644 --- a/indra/llcorehttp/_httpopsetpriority.cpp +++ b/indra/llcorehttp/_httpopsetpriority.cpp @@ -24,6 +24,7 @@ * $/LicenseInfo$ */ +#if 0 // DEPRECATED #include "_httpopsetpriority.h" #include "httpresponse.h" @@ -61,3 +62,5 @@ void HttpOpSetPriority::stageFromRequest(HttpService * service) } // end namespace LLCore + +#endif diff --git a/indra/llcorehttp/_httpopsetpriority.h b/indra/llcorehttp/_httpopsetpriority.h index 43e2aa081b..fd543f37cc 100644 --- a/indra/llcorehttp/_httpopsetpriority.h +++ b/indra/llcorehttp/_httpopsetpriority.h @@ -27,7 +27,7 @@ #ifndef _LLCORE_HTTP_SETPRIORITY_H_ #define _LLCORE_HTTP_SETPRIORITY_H_ - +#if 0 // DEPRECATED #include "httpcommon.h" #include "httprequest.h" #include "_httpoperation.h" @@ -49,7 +49,7 @@ namespace LLCore class HttpOpSetPriority : public HttpOperation { public: - HttpOpSetPriority(HttpHandle handle, HttpRequest::priority_t priority); + HttpOpSetPriority(HttpHandle handle); virtual ~HttpOpSetPriority(); @@ -63,10 +63,10 @@ public: protected: // Request Data HttpHandle mHandle; - HttpRequest::priority_t mPriority; }; // end class HttpOpSetPriority } // end namespace LLCore +#endif #endif // _LLCORE_HTTP_SETPRIORITY_H_ diff --git a/indra/llcorehttp/_httppolicy.cpp b/indra/llcorehttp/_httppolicy.cpp index 885f0ed61d..29f50c1693 100644 --- a/indra/llcorehttp/_httppolicy.cpp +++ b/indra/llcorehttp/_httppolicy.cpp @@ -330,37 +330,6 @@ HttpService::ELoopSpeed HttpPolicy::processReadyQueue() return result; } - -bool HttpPolicy::changePriority(HttpHandle handle, HttpRequest::priority_t priority) -{ - for (int policy_class(0); policy_class < mClasses.size(); ++policy_class) - { - ClassState & state(*mClasses[policy_class]); - // We don't scan retry queue because a priority change there - // is meaningless. The request will be issued based on retry - // intervals not priority value, which is now moot. - - // Scan ready queue for requests that match policy - HttpReadyQueue::container_type & c(state.mReadyQueue.get_container()); - for (HttpReadyQueue::container_type::iterator iter(c.begin()); c.end() != iter;) - { - HttpReadyQueue::container_type::iterator cur(iter++); - - if ((*cur)->getHandle() == handle) - { - HttpOpRequest::ptr_t op(*cur); - c.erase(cur); // All iterators are now invalidated - op->mReqPriority = priority; - state.mReadyQueue.push(op); // Re-insert using adapter class - return true; - } - } - } - - return false; -} - - bool HttpPolicy::cancel(HttpHandle handle) { for (int policy_class(0); policy_class < mClasses.size(); ++policy_class) diff --git a/indra/llcorehttp/_httppolicy.h b/indra/llcorehttp/_httppolicy.h index 3c4126e14b..0b8806a3e2 100644 --- a/indra/llcorehttp/_httppolicy.h +++ b/indra/llcorehttp/_httppolicy.h @@ -110,12 +110,6 @@ public: /// Threading: called by worker thread void retryOp(const opReqPtr_t &); - /// Attempt to change the priority of an earlier request. - /// Request that Shadows HttpService's method - /// - /// Threading: called by worker thread - bool changePriority(HttpHandle handle, HttpRequest::priority_t priority); - /// Attempt to cancel a previous request. /// Shadows HttpService's method as well /// diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp index 56f52f1b09..294acd7f63 100644 --- a/indra/llcorehttp/_httpservice.cpp +++ b/indra/llcorehttp/_httpservice.cpp @@ -80,6 +80,7 @@ HttpService::HttpService() HttpService::~HttpService() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; mExitRequested = 1U; if (RUNNING == sState) { @@ -131,6 +132,7 @@ HttpService::~HttpService() void HttpService::init(HttpRequestQueue * queue) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; llassert_always(! sInstance); llassert_always(NOT_INITIALIZED == sState); sInstance = new HttpService(); @@ -145,6 +147,7 @@ void HttpService::init(HttpRequestQueue * queue) void HttpService::term() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; if (sInstance) { if (RUNNING == sState && sInstance->mThread) @@ -196,6 +199,7 @@ bool HttpService::isStopped() /// Threading: callable by consumer thread *once*. void HttpService::startThread() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; llassert_always(! mThread || STOPPED == sState); llassert_always(INITIALIZED == sState || STOPPED == sState); @@ -220,22 +224,6 @@ void HttpService::stopRequested() } -/// Threading: callable by worker thread. -bool HttpService::changePriority(HttpHandle handle, HttpRequest::priority_t priority) -{ - bool found(false); - - // Skip the request queue as we currently don't leave earlier - // requests sitting there. Start with the ready queue... - found = mPolicy->changePriority(handle, priority); - - // If not there, we could try the transport/active queue but priority - // doesn't really have much effect there so we don't waste cycles. - - return found; -} - - /// Try to find the given request handle on any of the request /// queues and cancel the operation. /// @@ -244,6 +232,7 @@ bool HttpService::changePriority(HttpHandle handle, HttpRequest::priority_t prio /// Threading: callable by worker thread. bool HttpService::cancel(HttpHandle handle) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; bool canceled(false); // Request can't be on request queue so skip that. @@ -264,6 +253,7 @@ bool HttpService::cancel(HttpHandle handle) /// Threading: callable by worker thread. void HttpService::shutdown() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; // Disallow future enqueue of requests mRequestQueue->stopQueue(); @@ -293,6 +283,8 @@ void HttpService::shutdown() // requested to stop. void HttpService::threadRun(LLCoreInt::HttpThread * thread) { + LL_PROFILER_SET_THREAD_NAME("HttpService"); + boost::this_thread::disable_interruption di; LLThread::registerThreadID(); @@ -300,6 +292,7 @@ void HttpService::threadRun(LLCoreInt::HttpThread * thread) ELoopSpeed loop(REQUEST_SLEEP); while (! mExitRequested) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; try { loop = processRequestQueue(loop); @@ -344,6 +337,7 @@ void HttpService::threadRun(LLCoreInt::HttpThread * thread) HttpService::ELoopSpeed HttpService::processRequestQueue(ELoopSpeed loop) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpRequestQueue::OpContainer ops; const bool wait_for_req(REQUEST_SLEEP == loop); @@ -384,6 +378,7 @@ HttpService::ELoopSpeed HttpService::processRequestQueue(ELoopSpeed loop) HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, long * ret_value) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range || opt >= HttpRequest::PO_LAST // ditto || (! sOptionDesc[opt].mIsLong) // datatype is long @@ -416,6 +411,7 @@ HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, std::string * ret_value) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range @@ -443,6 +439,7 @@ HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, HttpRequest::policyCallback_t * ret_value) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range @@ -472,6 +469,7 @@ HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, long value, long * ret_value) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range @@ -517,6 +515,7 @@ HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, const std::string & value, std::string * ret_value) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range @@ -548,6 +547,7 @@ HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, HttpRequest::policyCallback_t value, HttpRequest::policyCallback_t * ret_value) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); if (opt < HttpRequest::PO_CONNECTION_LIMIT // option must be in range diff --git a/indra/llcorehttp/_httpservice.h b/indra/llcorehttp/_httpservice.h index d0c37ac195..551a718f20 100644 --- a/indra/llcorehttp/_httpservice.h +++ b/indra/llcorehttp/_httpservice.h @@ -146,15 +146,6 @@ public: /// Threading: callable by worker thread. void shutdown(); - /// Try to find the given request handle on any of the request - /// queues and reset the priority (and queue position) of the - /// request if found. - /// - /// @return True if the request was found somewhere. - /// - /// Threading: callable by worker thread. - bool changePriority(HttpHandle handle, HttpRequest::priority_t priority); - /// Try to find the given request handle on any of the request /// queues and cancel the operation. /// diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 2687f77217..de3854a101 100644 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -32,7 +32,6 @@ #include "_httppolicy.h" #include "_httpoperation.h" #include "_httpoprequest.h" -#include "_httpopsetpriority.h" #include "_httpopcancel.h" #include "_httpopsetget.h" @@ -183,16 +182,16 @@ HttpStatus HttpRequest::getStatus() const HttpHandle HttpRequest::requestGet(policy_t policy_id, - priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, HttpHandler::ptr_t user_handler) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpStatus status; HttpOpRequest::ptr_t op(new HttpOpRequest()); - if (! (status = op->setupGet(policy_id, priority, url, options, headers))) + if (! (status = op->setupGet(policy_id, url, options, headers))) { mLastReqStatus = status; return LLCORE_HTTP_HANDLE_INVALID; @@ -210,7 +209,6 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, - priority_t priority, const std::string & url, size_t offset, size_t len, @@ -218,10 +216,11 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, const HttpHeaders::ptr_t & headers, HttpHandler::ptr_t user_handler) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; HttpStatus status; HttpOpRequest::ptr_t op(new HttpOpRequest()); - if (! (status = op->setupGetByteRange(policy_id, priority, url, offset, len, options, headers))) + if (! (status = op->setupGetByteRange(policy_id, url, offset, len, options, headers))) { mLastReqStatus = status; return LLCORE_HTTP_HANDLE_INVALID; @@ -239,7 +238,6 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, HttpHandle HttpRequest::requestPost(policy_t policy_id, - priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, @@ -249,7 +247,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, HttpStatus status; HttpOpRequest::ptr_t op(new HttpOpRequest()); - if (! (status = op->setupPost(policy_id, priority, url, body, options, headers))) + if (! (status = op->setupPost(policy_id, url, body, options, headers))) { mLastReqStatus = status; return LLCORE_HTTP_HANDLE_INVALID; @@ -267,7 +265,6 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, HttpHandle HttpRequest::requestPut(policy_t policy_id, - priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, @@ -277,7 +274,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpStatus status; HttpOpRequest::ptr_t op (new HttpOpRequest()); - if (! (status = op->setupPut(policy_id, priority, url, body, options, headers))) + if (! (status = op->setupPut(policy_id, url, body, options, headers))) { mLastReqStatus = status; return LLCORE_HTTP_HANDLE_INVALID; @@ -294,7 +291,6 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, } HttpHandle HttpRequest::requestDelete(policy_t policy_id, - priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, @@ -303,7 +299,7 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id, HttpStatus status; HttpOpRequest::ptr_t op(new HttpOpRequest()); - if (!(status = op->setupDelete(policy_id, priority, url, options, headers))) + if (!(status = op->setupDelete(policy_id, url, options, headers))) { mLastReqStatus = status; return LLCORE_HTTP_HANDLE_INVALID; @@ -320,7 +316,6 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id, } HttpHandle HttpRequest::requestPatch(policy_t policy_id, - priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, @@ -330,7 +325,7 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, HttpStatus status; HttpOpRequest::ptr_t op (new HttpOpRequest()); - if (!(status = op->setupPatch(policy_id, priority, url, body, options, headers))) + if (!(status = op->setupPatch(policy_id, url, body, options, headers))) { mLastReqStatus = status; return LLCORE_HTTP_HANDLE_INVALID; @@ -347,7 +342,6 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, } HttpHandle HttpRequest::requestCopy(policy_t policy_id, - priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, @@ -356,7 +350,7 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id, HttpStatus status; HttpOpRequest::ptr_t op(new HttpOpRequest()); - if (!(status = op->setupCopy(policy_id, priority, url, options, headers))) + if (!(status = op->setupCopy(policy_id, url, options, headers))) { mLastReqStatus = status; return LLCORE_HTTP_HANDLE_INVALID; @@ -374,7 +368,6 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id, } HttpHandle HttpRequest::requestMove(policy_t policy_id, - priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, @@ -383,7 +376,7 @@ HttpHandle HttpRequest::requestMove(policy_t policy_id, HttpStatus status; HttpOpRequest::ptr_t op (new HttpOpRequest()); - if (!(status = op->setupMove(policy_id, priority, url, options, headers))) + if (!(status = op->setupMove(policy_id, url, options, headers))) { mLastReqStatus = status; return LLCORE_HTTP_HANDLE_INVALID; @@ -483,24 +476,6 @@ HttpHandle HttpRequest::requestCancel(HttpHandle request, HttpHandler::ptr_t use } -HttpHandle HttpRequest::requestSetPriority(HttpHandle request, priority_t priority, - HttpHandler::ptr_t handler) -{ - HttpStatus status; - - HttpOperation::ptr_t op (new HttpOpSetPriority(request, priority)); - op->setReplyPath(mReplyQueue, handler); - if (! (status = mRequestQueue->addOp(op))) // transfers refcount - { - mLastReqStatus = status; - return LLCORE_HTTP_HANDLE_INVALID; - } - - mLastReqStatus = status; - return op->getHandle(); -} - - // ==================================== // Utility Methods // ==================================== diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index a418eb6a7a..ca4b9e92bc 100644 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -95,7 +95,6 @@ private: public: typedef unsigned int policy_t; - typedef unsigned int priority_t; typedef boost::shared_ptr ptr_t; typedef boost::weak_ptr wptr_t; @@ -316,8 +315,6 @@ public: /// /// @param policy_id Default or user-defined policy class under /// which this request is to be serviced. - /// @param priority Standard priority scheme inherited from - /// Indra code base (U32-type scheme). /// @param url URL with any encoded query parameters to /// be accessed. /// @param options Optional instance of an HttpOptions object @@ -346,7 +343,6 @@ public: /// case, @see getStatus() will return more info. /// HttpHandle requestGet(policy_t policy_id, - priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, @@ -377,7 +373,6 @@ public: /// - Referer: /// /// @param policy_id @see requestGet() - /// @param priority " /// @param url " /// @param offset Offset of first byte into resource to be returned. /// @param len Count of bytes to be returned @@ -387,7 +382,6 @@ public: /// @return " /// HttpHandle requestGetByteRange(policy_t policy_id, - priority_t priority, const std::string & url, size_t offset, size_t len, @@ -418,7 +412,6 @@ public: /// - Expect: /// /// @param policy_id @see requestGet() - /// @param priority " /// @param url " /// @param body Byte stream to be sent as the body. No /// further encoding or escaping will be done @@ -429,7 +422,6 @@ public: /// @return " /// HttpHandle requestPost(policy_t policy_id, - priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, @@ -459,7 +451,6 @@ public: /// - Content-Type: /// /// @param policy_id @see requestGet() - /// @param priority " /// @param url " /// @param body Byte stream to be sent as the body. No /// further encoding or escaping will be done @@ -470,7 +461,6 @@ public: /// @return " /// HttpHandle requestPut(policy_t policy_id, - priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, @@ -483,7 +473,6 @@ public: /// encoding and communicating the content types. /// /// @param policy_id @see requestGet() - /// @param priority " /// @param url " /// @param options @see requestGet()K(optional) /// @param headers " @@ -491,7 +480,6 @@ public: /// @return " /// HttpHandle requestDelete(policy_t policy_id, - priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, @@ -502,7 +490,6 @@ public: /// encoding and communicating the content types. /// /// @param policy_id @see requestGet() - /// @param priority " /// @param url " /// @param body Byte stream to be sent as the body. No /// further encoding or escaping will be done @@ -513,7 +500,6 @@ public: /// @return " /// HttpHandle requestPatch(policy_t policy_id, - priority_t priority, const std::string & url, BufferArray * body, const HttpOptions::ptr_t & options, @@ -525,7 +511,6 @@ public: /// encoding and communicating the content types. /// /// @param policy_id @see requestGet() - /// @param priority " /// @param url " /// @param options @see requestGet()K(optional) /// @param headers " @@ -533,7 +518,6 @@ public: /// @return " /// HttpHandle requestCopy(policy_t policy_id, - priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, @@ -544,7 +528,6 @@ public: /// encoding and communicating the content types. /// /// @param policy_id @see requestGet() - /// @param priority " /// @param url " /// @param options @see requestGet()K(optional) /// @param headers " @@ -552,7 +535,6 @@ public: /// @return " /// HttpHandle requestMove(policy_t policy_id, - priority_t priority, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, @@ -593,18 +575,6 @@ public: HttpHandle requestCancel(HttpHandle request, HttpHandler::ptr_t); - /// Request that a previously-issued request be reprioritized. - /// The status of whether the change itself succeeded arrives - /// via notification. - /// - /// @param request Handle of previously-issued request to - /// be changed. - /// @param priority New priority value. - /// @param handler @see requestGet() - /// @return " - /// - HttpHandle requestSetPriority(HttpHandle request, priority_t priority, HttpHandler::ptr_t handler); - /// @} /// @name UtilityMethods diff --git a/indra/llfilesystem/lllfsthread.cpp b/indra/llfilesystem/lllfsthread.cpp index be8e83a56f..944e981ecf 100644 --- a/indra/llfilesystem/lllfsthread.cpp +++ b/indra/llfilesystem/lllfsthread.cpp @@ -65,8 +65,7 @@ void LLLFSThread::cleanupClass() //---------------------------------------------------------------------------- LLLFSThread::LLLFSThread(bool threaded) : - LLQueuedThread("LFS", threaded), - mPriorityCounter(PRIORITY_LOWBITS) + LLQueuedThread("LFS", threaded) { if(!mLocalAPRFilePoolp) { @@ -84,14 +83,12 @@ LLLFSThread::~LLLFSThread() LLLFSThread::handle_t LLLFSThread::read(const std::string& filename, /* Flawfinder: ignore */ U8* buffer, S32 offset, S32 numbytes, - Responder* responder, U32 priority) + Responder* responder) { + LL_PROFILE_ZONE_SCOPED; handle_t handle = generateHandle(); - if (priority == 0) priority = PRIORITY_NORMAL | priorityCounter(); - else if (priority < PRIORITY_LOW) priority |= PRIORITY_LOW; // All reads are at least PRIORITY_LOW - - Request* req = new Request(this, handle, priority, + Request* req = new Request(this, handle, FILE_READ, filename, buffer, offset, numbytes, responder); @@ -107,13 +104,12 @@ LLLFSThread::handle_t LLLFSThread::read(const std::string& filename, /* Flawfind LLLFSThread::handle_t LLLFSThread::write(const std::string& filename, U8* buffer, S32 offset, S32 numbytes, - Responder* responder, U32 priority) + Responder* responder) { + LL_PROFILE_ZONE_SCOPED; handle_t handle = generateHandle(); - if (priority == 0) priority = PRIORITY_LOW | priorityCounter(); - - Request* req = new Request(this, handle, priority, + Request* req = new Request(this, handle, FILE_WRITE, filename, buffer, offset, numbytes, responder); @@ -130,11 +126,11 @@ LLLFSThread::handle_t LLLFSThread::write(const std::string& filename, //============================================================================ LLLFSThread::Request::Request(LLLFSThread* thread, - handle_t handle, U32 priority, + handle_t handle, operation_t op, const std::string& filename, U8* buffer, S32 offset, S32 numbytes, Responder* responder) : - QueuedRequest(handle, priority, FLAG_AUTO_COMPLETE), + QueuedRequest(handle, FLAG_AUTO_COMPLETE), mThread(thread), mOperation(op), mFileName(filename), @@ -157,6 +153,7 @@ LLLFSThread::Request::~Request() // virtual, called from own thread void LLLFSThread::Request::finishRequest(bool completed) { + LL_PROFILE_ZONE_SCOPED; if (mResponder.notNull()) { mResponder->completed(completed ? mBytesRead : 0); @@ -166,6 +163,7 @@ void LLLFSThread::Request::finishRequest(bool completed) void LLLFSThread::Request::deleteRequest() { + LL_PROFILE_ZONE_SCOPED; if (getStatus() == STATUS_QUEUED) { LL_ERRS() << "Attempt to delete a queued LLLFSThread::Request!" << LL_ENDL; @@ -180,6 +178,7 @@ void LLLFSThread::Request::deleteRequest() bool LLLFSThread::Request::processRequest() { + LL_PROFILE_ZONE_SCOPED; bool complete = false; if (mOperation == FILE_READ) { diff --git a/indra/llfilesystem/lllfsthread.h b/indra/llfilesystem/lllfsthread.h index 58f658f7ba..f2693a1172 100644 --- a/indra/llfilesystem/lllfsthread.h +++ b/indra/llfilesystem/lllfsthread.h @@ -68,7 +68,7 @@ public: public: Request(LLLFSThread* thread, - handle_t handle, U32 priority, + handle_t handle, operation_t op, const std::string& filename, U8* buffer, S32 offset, S32 numbytes, Responder* responder); @@ -120,22 +120,15 @@ public: // Return a Request handle handle_t read(const std::string& filename, /* Flawfinder: ignore */ U8* buffer, S32 offset, S32 numbytes, - Responder* responder, U32 pri=0); + Responder* responder); handle_t write(const std::string& filename, U8* buffer, S32 offset, S32 numbytes, - Responder* responder, U32 pri=0); - - // Misc - U32 priorityCounter() { return mPriorityCounter-- & PRIORITY_LOWBITS; } // Use to order IO operations + Responder* responder); // static initializers static void initClass(bool local_is_threaded = TRUE); // Setup sLocal static S32 updateClass(U32 ms_elapsed); static void cleanupClass(); // Delete sLocal - - -private: - U32 mPriorityCounter; public: static LLLFSThread* sLocal; // Default local file thread diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index e1809dbe59..8dba1641a6 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -146,6 +146,7 @@ bool LLImageJ2C::initEncode(LLImageRaw &raw_image, int blocks_size, int precinct bool LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; return decodeChannels(raw_imagep, decode_time, 0, 4); } @@ -153,6 +154,7 @@ bool LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time) // Returns true to mean done, whether successful or not. bool LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count ) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLTimer elapsed; bool res = true; diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp index 0dbb744bcf..1aace5f3e8 100644 --- a/indra/llimage/llimageworker.cpp +++ b/indra/llimage/llimageworker.cpp @@ -49,33 +49,22 @@ LLImageDecodeThread::~LLImageDecodeThread() S32 LLImageDecodeThread::update(F32 max_time_ms) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - LLMutexLock lock(mCreationMutex); - for (creation_list_t::iterator iter = mCreationList.begin(); - iter != mCreationList.end(); ++iter) - { - creation_info& info = *iter; - ImageRequest* req = new ImageRequest(info.handle, info.image, - info.priority, info.discard, info.needs_aux, - info.responder); - - bool res = addRequest(req); - if (!res) - { - LL_ERRS() << "request added after LLLFSThread::cleanupClass()" << LL_ENDL; - } - } - mCreationList.clear(); S32 res = LLQueuedThread::update(max_time_ms); return res; } LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLImageFormatted* image, - U32 priority, S32 discard, BOOL needs_aux, Responder* responder) + S32 discard, BOOL needs_aux, Responder* responder) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - LLMutexLock lock(mCreationMutex); handle_t handle = generateHandle(); - mCreationList.push_back(creation_info(handle, image, priority, discard, needs_aux, responder)); + + ImageRequest* req = new ImageRequest(handle, image, + discard, needs_aux, + responder); + + addRequest(req); + return handle; } @@ -84,8 +73,7 @@ LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLImageFormatted* S32 LLImageDecodeThread::tut_size() { LLMutexLock lock(mCreationMutex); - S32 res = mCreationList.size(); - return res; + return 0; } LLImageDecodeThread::Responder::~Responder() @@ -95,9 +83,9 @@ LLImageDecodeThread::Responder::~Responder() //---------------------------------------------------------------------------- LLImageDecodeThread::ImageRequest::ImageRequest(handle_t handle, LLImageFormatted* image, - U32 priority, S32 discard, BOOL needs_aux, + S32 discard, BOOL needs_aux, LLImageDecodeThread::Responder* responder) - : LLQueuedThread::QueuedRequest(handle, priority, FLAG_AUTO_COMPLETE), + : LLQueuedThread::QueuedRequest(handle, FLAG_AUTO_COMPLETE), mFormattedImage(image), mDiscardLevel(discard), mNeedsAux(needs_aux), @@ -121,7 +109,7 @@ LLImageDecodeThread::ImageRequest::~ImageRequest() bool LLImageDecodeThread::ImageRequest::processRequest() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - const F32 decode_time_slice = .1f; + const F32 decode_time_slice = 0.f; //disable time slicing bool done = true; if (!mDecodedRaw && mFormattedImage.notNull()) { diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h index 1bfb0ddfd3..4619ddd6a2 100644 --- a/indra/llimage/llimageworker.h +++ b/indra/llimage/llimageworker.h @@ -49,7 +49,7 @@ public: public: ImageRequest(handle_t handle, LLImageFormatted* image, - U32 priority, S32 discard, BOOL needs_aux, + S32 discard, BOOL needs_aux, LLImageDecodeThread::Responder* responder); /*virtual*/ bool processRequest(); @@ -76,7 +76,7 @@ public: virtual ~LLImageDecodeThread(); handle_t decodeImage(LLImageFormatted* image, - U32 priority, S32 discard, BOOL needs_aux, + S32 discard, BOOL needs_aux, Responder* responder); S32 update(F32 max_time_ms); @@ -88,16 +88,13 @@ private: { handle_t handle; LLPointer image; - U32 priority; S32 discard; BOOL needs_aux; LLPointer responder; creation_info(handle_t h, LLImageFormatted* i, U32 p, S32 d, BOOL aux, Responder* r) - : handle(h), image(i), priority(p), discard(d), needs_aux(aux), responder(r) + : handle(h), image(i), discard(d), needs_aux(aux), responder(r) {} }; - typedef std::list creation_list_t; - creation_list_t mCreationList; LLMutex* mCreationMutex; }; diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index 925da5674b..8a641617fa 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -118,6 +118,7 @@ bool LLImageJ2COJ::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int block bool LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; // // FIXME: Get the comment field out of the texture // diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index dac5349f57..2ad42d6b87 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -379,6 +379,7 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod void LLImageJ2CKDU::cleanupCodeStream() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; mInputp.reset(); mDecodeState.reset(); mCodeStreamp.reset(); @@ -426,6 +427,7 @@ bool LLImageJ2CKDU::initEncode(LLImageJ2C &base, LLImageRaw &raw_image, int bloc // decodeImpl() usage matters for production. bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, ECodeStreamMode mode, S32 first_channel, S32 max_channel_count, int discard_level, int* region) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; base.resetLastError(); // *FIX: kdu calls our callback function if there's an error, and then bombs. @@ -509,6 +511,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco // Returns true to mean done, whether successful or not. bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; ECodeStreamMode mode = MODE_FAST; LLTimer decode_timer; @@ -1332,6 +1335,7 @@ the `buf' pointer may actually point into a larger buffer representing multiple tiles. For this reason, `row_gap' is needed to identify the separation between consecutive rows in the real buffer. */ { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; S32 c; // Now walk through the lines of the buffer, recovering them from the // relevant tile-component processing engines. @@ -1339,18 +1343,27 @@ separation between consecutive rows in the real buffer. */ LLTimer decode_timer; while (mDims.size.y--) { - for (c = 0; c < mNumComponents; c++) - { - mEngines[c].pull(mLines[c]); - } + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("kduptc - pull"); + for (c = 0; c < mNumComponents; c++) + { + mEngines[c].pull(mLines[c]); + } + } + if ((mNumComponents >= 3) && mUseYCC) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("kduptc - convert"); kdu_convert_ycc_to_rgb(mLines[0],mLines[1],mLines[2]); } - for (c = 0; c < mNumComponents; c++) - { - transfer_bytes(mBuf+c,mLines[c],mNumComponents,mBitDepths[c]); - } + + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("kduptc - transfer"); + for (c = 0; c < mNumComponents; c++) + { + transfer_bytes(mBuf + c, mLines[c], mNumComponents, mBitDepths[c]); + } + } mBuf += mRowGap; if (mDims.size.y % 10) { diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index c67f59bc0c..ae066112c1 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -64,7 +64,6 @@ LLCore::HttpRequest::ptr_t sHttpRequest; LLCore::HttpHeaders::ptr_t sHttpHeaders; LLCore::HttpOptions::ptr_t sHttpOptions; LLCore::HttpRequest::policy_t sHttpPolicy; -LLCore::HttpRequest::priority_t sHttpPriority; /* Sample response: @@ -121,7 +120,6 @@ LLAvatarNameCache::LLAvatarNameCache() sHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()); sHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); sHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID; - sHttpPriority = 0; } LLAvatarNameCache::~LLAvatarNameCache() diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 7031f1aa8c..96af8bacee 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -131,7 +131,6 @@ bool responseToLLSD(HttpResponse * response, bool log, LLSD & out_llsd) HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const HttpOptions::ptr_t &options, @@ -145,7 +144,6 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, LLSDSerialize::toXML(body, bas); handle = request->requestPost(policy_id, - priority, url, ba, options, @@ -158,7 +156,6 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const HttpOptions::ptr_t &options, @@ -172,7 +169,6 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, LLSDSerialize::toXML(body, bas); handle = request->requestPut(policy_id, - priority, url, ba, options, @@ -184,7 +180,6 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const HttpOptions::ptr_t &options, @@ -198,7 +193,6 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, LLSDSerialize::toXML(body, bas); handle = request->requestPatch(policy_id, - priority, url, ba, options, @@ -672,10 +666,9 @@ const std::string HttpCoroutineAdapter::HTTP_RESULTS_CONTENT("content"); const std::string HttpCoroutineAdapter::HTTP_RESULTS_RAW("raw"); HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, - LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : + LLCore::HttpRequest::policy_t policyId) : mAdapterName(name), mPolicyId(policyId), - mPriority(priority), mYieldingHandle(LLCORE_HTTP_HANDLE_INVALID), mWeakRequest(), mWeakHandler() @@ -709,7 +702,7 @@ LLSD HttpCoroutineAdapter::postAndSuspend_(LLCore::HttpRequest::ptr_t &request, // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPostWithLLSD(request, - mPolicyId, mPriority, url, body, options, headers, + mPolicyId, url, body, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) @@ -832,7 +825,7 @@ LLSD HttpCoroutineAdapter::postAndSuspend_(LLCore::HttpRequest::ptr_t &request, // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. - LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), + LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, url, rawbody.get(), options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) @@ -890,7 +883,7 @@ LLSD HttpCoroutineAdapter::putAndSuspend_(LLCore::HttpRequest::ptr_t &request, // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPutWithLLSD(request, - mPolicyId, mPriority, url, body, options, headers, + mPolicyId, url, body, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) @@ -916,7 +909,7 @@ LLSD HttpCoroutineAdapter::putAndSuspend_(LLCore::HttpRequest::ptr_t &request, // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. - LLCore::HttpHandle hhandle = request->requestPut(mPolicyId, mPriority, + LLCore::HttpHandle hhandle = request->requestPut(mPolicyId, url, rawbody.get(), options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) @@ -972,7 +965,7 @@ LLSD HttpCoroutineAdapter::getAndSuspend_(LLCore::HttpRequest::ptr_t &request, // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. - LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, + LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, url, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) @@ -1018,7 +1011,7 @@ LLSD HttpCoroutineAdapter::deleteAndSuspend_(LLCore::HttpRequest::ptr_t &request checkDefaultHeaders(headers); // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. - LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority, + LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, url, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) @@ -1056,7 +1049,7 @@ LLSD HttpCoroutineAdapter::patchAndSuspend_(LLCore::HttpRequest::ptr_t &request, // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPatchWithLLSD(request, - mPolicyId, mPriority, url, body, options, headers, + mPolicyId, url, body, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) @@ -1098,7 +1091,7 @@ LLSD HttpCoroutineAdapter::copyAndSuspend_(LLCore::HttpRequest::ptr_t &request, // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. // - LLCore::HttpHandle hhandle = request->requestCopy(mPolicyId, mPriority, url, + LLCore::HttpHandle hhandle = request->requestCopy(mPolicyId, url, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) @@ -1140,7 +1133,7 @@ LLSD HttpCoroutineAdapter::moveAndSuspend_(LLCore::HttpRequest::ptr_t &request, // The HTTPCoroHandler does not self delete, so retrieval of a the contained // pointer from the smart pointer is safe in this case. // - LLCore::HttpHandle hhandle = request->requestMove(mPolicyId, mPriority, url, + LLCore::HttpHandle hhandle = request->requestMove(mPolicyId, url, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 6f0b865f83..430dc417ac 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -116,7 +116,6 @@ std::string responseToString(LLCore::HttpResponse * response); /// LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const LLCore::HttpOptions::ptr_t &options, @@ -125,20 +124,18 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const LLCore::HttpOptions::ptr_t & options, const LLCore::HttpHeaders::ptr_t & headers, const LLCore::HttpHandler::ptr_t & handler) { - return requestPostWithLLSD(request.get(), policy_id, priority, + return requestPostWithLLSD(request.get(), policy_id, url, body, options, headers, handler); } inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const LLCore::HttpHandler::ptr_t &handler) @@ -146,7 +143,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpOptions::ptr_t options; LLCore::HttpHeaders::ptr_t headers; - return requestPostWithLLSD(request.get(), policy_id, priority, + return requestPostWithLLSD(request.get(), policy_id, url, body, options, headers, handler); } @@ -169,7 +166,6 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque /// LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const LLCore::HttpOptions::ptr_t &options, @@ -178,20 +174,18 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const LLCore::HttpOptions::ptr_t & options, const LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler::ptr_t handler) { - return requestPutWithLLSD(request.get(), policy_id, priority, + return requestPutWithLLSD(request.get(), policy_id, url, body, options, headers, handler); } inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, LLCore::HttpHandler::ptr_t handler) @@ -199,7 +193,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpOptions::ptr_t options; LLCore::HttpHeaders::ptr_t headers; - return requestPutWithLLSD(request.get(), policy_id, priority, + return requestPutWithLLSD(request.get(), policy_id, url, body, options, headers, handler); } @@ -221,7 +215,6 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques /// LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const LLCore::HttpOptions::ptr_t &options, @@ -230,20 +223,18 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const LLCore::HttpOptions::ptr_t & options, const LLCore::HttpHeaders::ptr_t & headers, const LLCore::HttpHandler::ptr_t & handler) { - return requestPatchWithLLSD(request.get(), policy_id, priority, + return requestPatchWithLLSD(request.get(), policy_id, url, body, options, headers, handler); } inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, const LLCore::HttpHandler::ptr_t &handler) @@ -251,7 +242,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpOptions::ptr_t options; LLCore::HttpHeaders::ptr_t headers; - return requestPatchWithLLSD(request.get(), policy_id, priority, + return requestPatchWithLLSD(request.get(), policy_id, url, body, options, headers, handler); } @@ -329,8 +320,7 @@ public: typedef boost::shared_ptr ptr_t; typedef boost::weak_ptr wptr_t; - HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, - LLCore::HttpRequest::priority_t priority = 0L); + HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId); ~HttpCoroutineAdapter(); /// Execute a Post transaction on the supplied URL and yield execution of @@ -673,7 +663,6 @@ private: void checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers); std::string mAdapterName; - LLCore::HttpRequest::priority_t mPriority; LLCore::HttpRequest::policy_t mPolicyId; LLCore::HttpHandle mYieldingHandle; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 0a5d258b3a..04974d9122 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1624,26 +1624,38 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) LL_PROFILE_ZONE_NAMED("cglt - sync"); if (gGLManager.mHasSync) { - // post a sync to the main thread (will execute before tex name swap lambda below) - // glFlush calls here are partly superstitious and partly backed by observation - // on AMD hardware - glFlush(); - auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - glFlush(); - LL::WorkQueue::postMaybe( - mMainQueue, - [=]() - { - LL_PROFILE_ZONE_NAMED("cglt - wait sync"); - { - LL_PROFILE_ZONE_NAMED("glWaitSync"); - glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); - } + if (gGLManager.mIsNVIDIA) + { + // wait for texture upload to finish before notifying main thread + // upload is complete + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + glClientWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + glDeleteSync(sync); + } + else + { + // post a sync to the main thread (will execute before tex name swap lambda below) + // glFlush calls here are partly superstitious and partly backed by observation + // on AMD hardware + glFlush(); + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + LL::WorkQueue::postMaybe( + mMainQueue, + [=]() { - LL_PROFILE_ZONE_NAMED("glDeleteSync"); - glDeleteSync(sync); - } - }); + LL_PROFILE_ZONE_NAMED("cglt - wait sync"); + { + LL_PROFILE_ZONE_NAMED("glWaitSync"); + glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + } + { + LL_PROFILE_ZONE_NAMED("glDeleteSync"); + glDeleteSync(sync); + } + }); + } } else { diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 17071d4a65..ffb2fa326d 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -3913,7 +3913,7 @@ Type F32 Value - 0.1 + 1.0 QueueInventoryFetchTimeout @@ -10368,17 +10368,6 @@ Value 12.0 - RenderTextureMemoryMultiple - - Comment - Multiple of texture memory value to use (should fit: 0 < value <= 1.0) - Persist - 1 - Type - F32 - Value - 1.0 - RenderTrackerBeacon Comment @@ -12456,7 +12445,7 @@ Type F32 Value - 1.0 + 2.0 TextureCameraMotionThreshold @@ -12683,20 +12672,9 @@ Comment If TRUE, always load textures at full resolution (discard = 0) Persist - 0 - Type - Boolean - Value - 0 - - TextureMemory - - Comment - Amount of memory to use for textures in MB (0 = autodetect) - Persist 1 Type - S32 + Boolean Value 0 diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 1ccde98283..e04e38b9de 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -60,7 +60,6 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 Disregard128DefaultDrawDistance 1 1 Disregard96DefaultDrawDistance 1 1 -RenderTextureMemoryMultiple 1 1.0 RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index c9efd89cc8..d319d26e1f 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -60,7 +60,6 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 Disregard128DefaultDrawDistance 1 1 Disregard96DefaultDrawDistance 1 1 -RenderTextureMemoryMultiple 1 1.0 RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 61fc693b99..7625547dd9 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3227,7 +3227,7 @@ LLSD LLAppViewer::getViewerInfo() const info["LOD_FACTOR"] = gSavedSettings.getF32("RenderVolumeLODFactor"); info["RENDER_QUALITY"] = (F32)gSavedSettings.getU32("RenderQualityPerformance"); info["GPU_SHADERS"] = gSavedSettings.getBOOL("RenderDeferred") ? "Enabled" : "Disabled"; - info["TEXTURE_MEMORY"] = gSavedSettings.getS32("TextureMemory"); + info["TEXTURE_MEMORY"] = gGLManager.mVRAM; #if LL_DARWIN info["HIDPI"] = gHiDPISupport; diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index cc5cb667f0..be33e1b30a 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -148,7 +148,7 @@ void LLDrawPoolTerrain::boostTerrainDetailTextures() for (S32 i = 0; i < 4; i++) { compp->mDetailTextures[i]->setBoostLevel(LLGLTexture::BOOST_TERRAIN); - compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area + gPipeline.touchTexture(compp->mDetailTextures[i], 1024.f * 1024.f); } } diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index b328dd2962..9bf9e7503e 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -2311,6 +2311,7 @@ void LLFace::resetVirtualSize() F32 LLFace::getTextureVirtualSize() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; F32 radius; F32 cos_angle_to_view_dir; BOOL in_frustum = calcPixelArea(cos_angle_to_view_dir, radius); diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 90bb80a08b..f94c53a08b 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1275,12 +1275,7 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() shadow_text->setEnabled(enabled); // Hardware settings - F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); - S32Megabytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting(); - S32Megabytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier); - getChild("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value()); - getChild("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value()); - + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") || !gGLManager.mHasVertexBufferObject) { diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index b4fc832596..fa7deb78f8 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -215,8 +215,6 @@ LLInventoryModel::LLInventoryModel() mHttpOptions(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpPriorityFG(0), - mHttpPriorityBG(0), mCategoryLock(), mItemLock(), mValidationInfo(new LLInventoryValidationInfo) @@ -2778,7 +2776,6 @@ LLCore::HttpHandle LLInventoryModel::requestPost(bool foreground, handle = LLCoreHttpUtil::requestPostWithLLSD(request, mHttpPolicyClass, - (foreground ? mHttpPriorityFG : mHttpPriorityBG), url, body, mHttpOptions, diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index e81652820f..fdbc6426ad 100644 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -610,8 +610,6 @@ private: LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; - LLCore::HttpRequest::priority_t mHttpPriorityFG; - LLCore::HttpRequest::priority_t mHttpPriorityBG; /** HTTP Transport ** ** diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 11aa607393..27a9758ec3 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -133,8 +133,7 @@ LLMaterialMgr::LLMaterialMgr(): mHttpRequest(), mHttpHeaders(), mHttpOptions(), - mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpPriority(0) + mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID) { LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); @@ -699,7 +698,7 @@ void LLMaterialMgr::processGetQueue() << "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, - mHttpPolicy, mHttpPriority, capURL, + mHttpPolicy, capURL, postData, mHttpOptions, mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) @@ -985,7 +984,7 @@ void LLMaterialMgr::processPutQueue() )); LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD( - mHttpRequest, mHttpPolicy, mHttpPriority, capURL, + mHttpRequest, mHttpPolicy, capURL, putData, mHttpOptions, mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 843dc66fbc..f76cc27db1 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -141,7 +141,6 @@ private: LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpRequest::policy_t mHttpPolicy; - LLCore::HttpRequest::priority_t mHttpPriority; U32 getMaxEntries(const LLViewerRegion* regionp); }; diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index bc45eb6d3a..142977e939 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -355,7 +355,7 @@ void LLMediaDataClient::serviceQueue() // and make the post LLCore::HttpHandler::ptr_t handler = request->createHandler(); - LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, 0, + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, url, sd_payload, mHttpOpts, mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index d28e929b48..6fa71e130e 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -823,8 +823,7 @@ LLMeshRepoThread::LLMeshRepoThread() mHttpLargeOptions(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpLargePolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpPriority(0) + mHttpLargePolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID) { LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); @@ -1268,7 +1267,6 @@ LLCore::HttpHandle LLMeshRepoThread::getByteRange(const std::string & url, if (len < LARGE_MESH_FETCH_THRESHOLD) { handle = mHttpRequest->requestGetByteRange( mHttpPolicyClass, - mHttpPriority, url, (disable_range_req ? size_t(0) : offset), (disable_range_req ? size_t(0) : len), @@ -1283,7 +1281,6 @@ LLCore::HttpHandle LLMeshRepoThread::getByteRange(const std::string & url, else { handle = mHttpRequest->requestGetByteRange(mHttpLargePolicyClass, - mHttpPriority, url, (disable_range_req ? size_t(0) : offset), (disable_range_req ? size_t(0) : len), @@ -2130,7 +2127,6 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); mHttpPolicyClass = LLAppViewer::instance()->getAppCoreHttp().getPolicy(LLAppCoreHttp::AP_UPLOADS); - mHttpPriority = 0; } LLMeshUploadThread::~LLMeshUploadThread() @@ -2649,7 +2645,6 @@ void LLMeshUploadThread::doWholeModelUpload() LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicyClass, - mHttpPriority, mWholeModelUploadURL, body, mHttpOptions, @@ -2700,7 +2695,6 @@ void LLMeshUploadThread::requestWholeModelFee() dump_llsd_to_file(mModelData, make_dump_name("whole_model_fee_request_", dump_num)); LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicyClass, - mHttpPriority, mWholeModelFeeCapability, mModelData, mHttpOptions, diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 1989350303..5459bbb4af 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -321,7 +321,6 @@ public: LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::policy_t mHttpLargePolicyClass; - LLCore::HttpRequest::priority_t mHttpPriority; typedef std::set http_request_set; http_request_set mHttpRequestSet; // Outstanding HTTP requests @@ -489,7 +488,6 @@ private: LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; - LLCore::HttpRequest::priority_t mHttpPriority; }; // Params related to streaming cost, render cost, and scene complexity tracking. diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 5c648c11e1..99d7c81c8d 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3364,10 +3364,10 @@ public: } } - if (drawable->getVOVolume() && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) + /*if (drawable->getVOVolume() && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) { renderTexturePriority(drawable); - } + }*/ if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_POINTS)) { @@ -3694,7 +3694,7 @@ void LLSpatialPartition::renderDebug() LLPipeline::RENDER_DEBUG_BBOXES | LLPipeline::RENDER_DEBUG_NORMALS | LLPipeline::RENDER_DEBUG_POINTS | - LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY | + //LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY | LLPipeline::RENDER_DEBUG_TEXTURE_ANIM | LLPipeline::RENDER_DEBUG_RAYCAST | LLPipeline::RENDER_DEBUG_AVATAR_VOLUME | diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index d4fc6f3de2..8f4eb9438b 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -95,14 +95,13 @@ private: }; public: - LLTextureCacheWorker(LLTextureCache* cache, U32 priority, const LLUUID& id, + LLTextureCacheWorker(LLTextureCache* cache, const LLUUID& id, U8* data, S32 datasize, S32 offset, S32 imagesize, // for writes LLTextureCache::Responder* responder) : LLWorkerClass(cache, "LLTextureCacheWorker"), mID(id), mCache(cache), - mPriority(priority), mReadData(NULL), mWriteData(data), mDataSize(datasize), @@ -115,7 +114,6 @@ public: mBytesToRead(0), mBytesRead(0) { - mPriority &= LLWorkerThread::PRIORITY_LOWBITS; } ~LLTextureCacheWorker() { @@ -129,13 +127,12 @@ public: virtual bool doWork(S32 param); // Called from LLWorkerThread::processRequest() - handle_t read() { addWork(0, LLWorkerThread::PRIORITY_HIGH | mPriority); return mRequestHandle; } - handle_t write() { addWork(1, LLWorkerThread::PRIORITY_HIGH | mPriority); return mRequestHandle; } + handle_t read() { addWork(0); return mRequestHandle; } + handle_t write() { addWork(1); return mRequestHandle; } bool complete() { return checkWork(); } void ioComplete(S32 bytes) { mBytesRead = bytes; - setPriority(LLWorkerThread::PRIORITY_HIGH | mPriority); } private: @@ -145,7 +142,6 @@ private: protected: LLTextureCache* mCache; - U32 mPriority; LLUUID mID; U8* mReadData; @@ -164,11 +160,11 @@ protected: class LLTextureCacheLocalFileWorker : public LLTextureCacheWorker { public: - LLTextureCacheLocalFileWorker(LLTextureCache* cache, U32 priority, const std::string& filename, const LLUUID& id, + LLTextureCacheLocalFileWorker(LLTextureCache* cache, const std::string& filename, const LLUUID& id, U8* data, S32 datasize, S32 offset, S32 imagesize, // for writes LLTextureCache::Responder* responder) - : LLTextureCacheWorker(cache, priority, id, data, datasize, offset, imagesize, responder), + : LLTextureCacheWorker(cache, id, data, datasize, offset, imagesize, responder), mFileName(filename) { @@ -183,6 +179,7 @@ private: bool LLTextureCacheLocalFileWorker::doRead() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; S32 local_size = LLAPRFile::size(mFileName, mCache->getLocalAPRFilePool()); if (local_size > 0 && mFileName.size() > 4) @@ -207,50 +204,6 @@ bool LLTextureCacheLocalFileWorker::doRead() return true; } -#if USE_LFS_READ - if (mFileHandle == LLLFSThread::nullHandle()) - { - mImageLocal = TRUE; - mImageSize = local_size; - if (!mDataSize || mDataSize + mOffset > local_size) - { - mDataSize = local_size - mOffset; - } - if (mDataSize <= 0) - { - // no more data to read - mDataSize = 0; - return true; - } - mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize); - mBytesRead = -1; - mBytesToRead = mDataSize; - setPriority(LLWorkerThread::PRIORITY_LOW | mPriority); - mFileHandle = LLLFSThread::sLocal->read(local_filename, mReadData, mOffset, mDataSize, - new ReadResponder(mCache, mRequestHandle)); - return false; - } - else - { - if (mBytesRead >= 0) - { - if (mBytesRead != mBytesToRead) - { -// LL_WARNS() << "Error reading file from local cache: " << local_filename -// << " Bytes: " << mDataSize << " Offset: " << mOffset -// << " / " << mDataSize << LL_ENDL; - mDataSize = 0; // failed - ll_aligned_free_16(mReadData); - mReadData = NULL; - } - return true; - } - else - { - return false; - } - } -#else if (!mDataSize || mDataSize > local_size) { mDataSize = local_size; @@ -274,7 +227,6 @@ bool LLTextureCacheLocalFileWorker::doRead() mImageLocal = TRUE; } return true; -#endif } bool LLTextureCacheLocalFileWorker::doWrite() @@ -286,12 +238,12 @@ bool LLTextureCacheLocalFileWorker::doWrite() class LLTextureCacheRemoteWorker : public LLTextureCacheWorker { public: - LLTextureCacheRemoteWorker(LLTextureCache* cache, U32 priority, const LLUUID& id, + LLTextureCacheRemoteWorker(LLTextureCache* cache, const LLUUID& id, U8* data, S32 datasize, S32 offset, S32 imagesize, // for writes LLPointer raw, S32 discardlevel, LLTextureCache::Responder* responder) - : LLTextureCacheWorker(cache, priority, id, data, datasize, offset, imagesize, responder), + : LLTextureCacheWorker(cache, id, data, datasize, offset, imagesize, responder), mState(INIT), mRawImage(raw), mRawDiscardLevel(discardlevel) @@ -329,6 +281,7 @@ void LLTextureCacheWorker::startWork(S32 param) // - the code supports offset reading but this is actually never exercised in the viewer bool LLTextureCacheRemoteWorker::doRead() { + LL_PROFILE_ZONE_SCOPED; bool done = false; S32 idx = -1; @@ -580,6 +533,7 @@ bool LLTextureCacheRemoteWorker::doRead() // - the code *does not* support offset writing so there are no difference between buffer addresses and start of data bool LLTextureCacheRemoteWorker::doWrite() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; bool done = false; S32 idx = -1; @@ -756,6 +710,7 @@ bool LLTextureCacheRemoteWorker::doWrite() //virtual bool LLTextureCacheWorker::doWork(S32 param) { + LL_PROFILE_ZONE_SCOPED; bool res = false; if (param == 0) // read { @@ -775,11 +730,13 @@ bool LLTextureCacheWorker::doWork(S32 param) //virtual (WORKER THREAD) void LLTextureCacheWorker::finishWork(S32 param, bool completed) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if (mResponder.notNull()) { bool success = (completed && mDataSize > 0); if (param == 0) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("tcwfw - read"); // read if (success) { @@ -789,12 +746,14 @@ void LLTextureCacheWorker::finishWork(S32 param, bool completed) } else { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("tcwfw - read fail"); ll_aligned_free_16(mReadData); mReadData = NULL; } } else { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("tcwfw - write"); // write mWriteData = NULL; // we never owned data mDataSize = 0; @@ -806,6 +765,7 @@ void LLTextureCacheWorker::finishWork(S32 param, bool completed) //virtual (MAIN THREAD) void LLTextureCacheWorker::endWork(S32 param, bool aborted) { + LL_PROFILE_ZONE_SCOPED; if (aborted) { // Let the destructor handle any cleanup @@ -861,6 +821,7 @@ LLTextureCache::~LLTextureCache() //virtual S32 LLTextureCache::update(F32 max_time_ms) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; static LLFrameTimer timer ; static const F32 MAX_TIME_INTERVAL = 300.f ; //seconds. @@ -874,22 +835,6 @@ S32 LLTextureCache::update(F32 max_time_ms) mCompletedList.clear(); mListMutex.unlock(); - lockWorkers(); - - for (handle_list_t::iterator iter1 = priorty_list.begin(); - iter1 != priorty_list.end(); ++iter1) - { - handle_t handle = *iter1; - handle_map_t::iterator iter2 = mWriters.find(handle); - if(iter2 != mWriters.end()) - { - LLTextureCacheWorker* worker = iter2->second; - worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mPriority); - } - } - - unlockWorkers(); - // call 'completed' with workers list unlocked (may call readComplete() or writeComplete() for (responder_list_t::iterator iter1 = completed_list.begin(); iter1 != completed_list.end(); ++iter1) @@ -1323,6 +1268,7 @@ void LLTextureCache::updateEntryTimeStamp(S32 idx, Entry& entry) //update an existing entry, write to header file immediately. bool LLTextureCache::updateEntry(S32& idx, Entry& entry, S32 new_image_size, S32 new_data_size) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; S32 new_body_size = llmax(0, new_data_size - TEXTURE_CACHE_ENTRY_SIZE) ; if(new_image_size == entry.mImageSize && new_body_size == entry.mBodySize) @@ -1872,6 +1818,7 @@ void LLTextureCache::purgeTextures(bool validate) // call lockWorkers() first! LLTextureCacheWorker* LLTextureCache::getReader(handle_t handle) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLTextureCacheWorker* res = NULL; handle_map_t::iterator iter = mReaders.find(handle); if (iter != mReaders.end()) @@ -1883,6 +1830,7 @@ LLTextureCacheWorker* LLTextureCache::getReader(handle_t handle) LLTextureCacheWorker* LLTextureCache::getWriter(handle_t handle) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLTextureCacheWorker* res = NULL; handle_map_t::iterator iter = mWriters.find(handle); if (iter != mWriters.end()) @@ -1898,6 +1846,7 @@ LLTextureCacheWorker* LLTextureCache::getWriter(handle_t handle) // Reads imagesize from the header, updates timestamp S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, Entry& entry) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLMutexLock lock(&mHeaderMutex); S32 idx = openAndReadEntry(id, entry, false); if (idx >= 0) @@ -1910,6 +1859,7 @@ S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, Entry& entry) // Writes imagesize to the header, updates timestamp S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, Entry& entry, S32 imagesize, S32 datasize) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; mHeaderMutex.lock(); S32 idx = openAndReadEntry(id, entry, true); // read or create mHeaderMutex.unlock(); @@ -1942,13 +1892,14 @@ S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, Entry& entry, S32 imag // Calls from texture pipeline thread (i.e. LLTextureFetch) -LLTextureCache::handle_t LLTextureCache::readFromCache(const std::string& filename, const LLUUID& id, U32 priority, +LLTextureCache::handle_t LLTextureCache::readFromCache(const std::string& filename, const LLUUID& id, S32 offset, S32 size, ReadResponder* responder) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; // Note: checking to see if an entry exists can cause a stall, // so let the thread handle it LLMutexLock lock(&mWorkersMutex); - LLTextureCacheWorker* worker = new LLTextureCacheLocalFileWorker(this, priority, filename, id, + LLTextureCacheWorker* worker = new LLTextureCacheLocalFileWorker(this, filename, id, NULL, size, offset, 0, responder); handle_t handle = worker->read(); @@ -1956,13 +1907,14 @@ LLTextureCache::handle_t LLTextureCache::readFromCache(const std::string& filena return handle; } -LLTextureCache::handle_t LLTextureCache::readFromCache(const LLUUID& id, U32 priority, +LLTextureCache::handle_t LLTextureCache::readFromCache(const LLUUID& id, S32 offset, S32 size, ReadResponder* responder) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; // Note: checking to see if an entry exists can cause a stall, // so let the thread handle it LLMutexLock lock(&mWorkersMutex); - LLTextureCacheWorker* worker = new LLTextureCacheRemoteWorker(this, priority, id, + LLTextureCacheWorker* worker = new LLTextureCacheRemoteWorker(this, id, NULL, size, offset, 0, NULL, 0, responder); handle_t handle = worker->read(); @@ -1973,6 +1925,7 @@ LLTextureCache::handle_t LLTextureCache::readFromCache(const LLUUID& id, U32 pri bool LLTextureCache::readComplete(handle_t handle, bool abort) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; lockWorkers(); handle_map_t::iterator iter = mReaders.find(handle); LLTextureCacheWorker* worker = NULL; @@ -2000,7 +1953,7 @@ bool LLTextureCache::readComplete(handle_t handle, bool abort) return (complete || abort); } -LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id, U32 priority, +LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id, U8* data, S32 datasize, S32 imagesize, LLPointer rawimage, S32 discardlevel, WriteResponder* responder) @@ -2018,7 +1971,7 @@ LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id, U32 prio mDoPurge = !mPurgeEntryList.empty(); } LLMutexLock lock(&mWorkersMutex); - LLTextureCacheWorker* worker = new LLTextureCacheRemoteWorker(this, priority, id, + LLTextureCacheWorker* worker = new LLTextureCacheRemoteWorker(this, id, data, datasize, 0, imagesize, rawimage, discardlevel, responder); handle_t handle = worker->write(); @@ -2086,6 +2039,7 @@ LLPointer LLTextureCache::readFromFastCache(const LLUUID& id, S32& d //return the fast cache location bool LLTextureCache::writeToFastCache(LLUUID image_id, S32 id, LLPointer raw, S32 discardlevel) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; //rescale image if needed if (raw.isNull() || raw->isBufferInvalid() || !raw->getData()) { diff --git a/indra/newview/lltexturecache.h b/indra/newview/lltexturecache.h index e1c752b58e..f2a5978a7c 100644 --- a/indra/newview/lltexturecache.h +++ b/indra/newview/lltexturecache.h @@ -119,13 +119,13 @@ public: void setReadOnly(BOOL read_only) ; S64 initCache(ELLPath location, S64 maxsize, BOOL texture_cache_mismatch); - handle_t readFromCache(const std::string& local_filename, const LLUUID& id, U32 priority, S32 offset, S32 size, + handle_t readFromCache(const std::string& local_filename, const LLUUID& id, S32 offset, S32 size, ReadResponder* responder); - handle_t readFromCache(const LLUUID& id, U32 priority, S32 offset, S32 size, + handle_t readFromCache(const LLUUID& id, S32 offset, S32 size, ReadResponder* responder); bool readComplete(handle_t handle, bool abort); - handle_t writeToCache(const LLUUID& id, U32 priority, U8* data, S32 datasize, S32 imagesize, LLPointer rawimage, S32 discardlevel, + handle_t writeToCache(const LLUUID& id, U8* data, S32 datasize, S32 imagesize, LLPointer rawimage, S32 discardlevel, WriteResponder* responder); LLPointer readFromFastCache(const LLUUID& id, S32& discardlevel); bool writeComplete(handle_t handle, bool abort = false); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 0edaf40c66..8ad28074de 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -213,35 +213,17 @@ const std::string sTesterName("TextureFetchTester"); // // Worker State Machine // -// (ASCII art needed) -// -// -// Priority Scheme -// -// [PRIORITY_LOW, PRIORITY_NORMAL) - for WAIT_HTTP_RESOURCE state -// and other wait states -// [PRIORITY_HIGH, PRIORITY_URGENT) - External event delivered, -// rapidly transitioning through states, -// no waiting allowed -// -// By itself, the above work queue model would fail the concurrency -// and liveness requirements of the interface. A high priority -// request could find itself on the head and stalled for external -// reasons (see VWR-28996). So a few additional constraints are -// required to keep things running: -// * Anything that can make forward progress must be kept at a -// higher priority than anything that can't. -// * On completion of external events, the associated request -// needs to be elevated beyond the normal range to handle -// any data delivery and release any external resource. -// -// This effort is made to keep higher-priority entities moving -// forward in their state machines at every possible step of -// processing. It's not entirely proven that this produces the -// experiencial benefits promised. +// "doWork" will be executed for a given worker on its respective +// LLQueuedThread. If doWork returns true, the worker is treated +// as completed. If doWork returns false, the worker will be +// put on the back of the work queue at the start of the next iteration +// of the mainloop. If a worker is waiting on a resource, it should +// return false as soon as possible and not block to avoid starving +// other workers of cpu cycles. // + ////////////////////////////////////////////////////////////////////////////// // Tuning/Parameterization Constants @@ -386,14 +368,7 @@ private: bool operator()(const LLTextureFetchWorker* lhs, const LLTextureFetchWorker* rhs) const { // greater priority is "less" - const F32 lpriority = lhs->mImagePriority; - const F32 rpriority = rhs->mImagePriority; - if (lpriority > rpriority) // higher priority - return true; - else if (lpriority < rpriority) - return false; - else - return lhs < rhs; + return lhs->mImagePriority > rhs->mImagePriority; } }; @@ -484,6 +459,9 @@ private: // Locks: Mw void resetFormattedData(); + // get the relative priority of this worker (should map to max virtual size) + F32 getImagePriority() const; + // Locks: Mw void setImagePriority(F32 priority); @@ -500,9 +478,6 @@ private: // Locks: Mw void setupPacketData(); - // Locks: Mw (ctor invokes without lock) - U32 calcWorkPriority(); - // Locks: Mw void removeFromCache(); @@ -573,8 +548,7 @@ private: LLHost mHost; std::string mUrl; U8 mType; - F32 mImagePriority; - U32 mWorkPriority; + F32 mImagePriority; // should map to max virtual size F32 mRequestedPriority; S32 mDesiredDiscard; S32 mSimRequestedDiscard; @@ -923,7 +897,6 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher, mHost(host), mUrl(url), mImagePriority(priority), - mWorkPriority(0), mRequestedPriority(0.f), mDesiredDiscard(-1), mSimRequestedDiscard(-1), @@ -970,17 +943,15 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher, mCacheReadCount(0U), mCacheWriteCount(0U), mResourceWaitCount(0U), - mFetchRetryPolicy(10.0,3600.0,2.0,10) + mFetchRetryPolicy(10.f,3600.f,2.f,10) { mCanUseNET = mUrl.empty() ; - calcWorkPriority(); mType = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL; // LL_INFOS(LOG_TXT) << "Create: " << mID << " mHost:" << host << " Discard=" << discard << LL_ENDL; if (!mFetcher->mDebugPause) { - U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH; - addWork(0, work_priority ); + addWork(0); } setDesiredDiscard(discard, size); } @@ -1070,16 +1041,6 @@ void LLTextureFetchWorker::setupPacketData() } } -// Locks: Mw (ctor invokes without lock) -U32 LLTextureFetchWorker::calcWorkPriority() -{ - //llassert_always(mImagePriority >= 0 && mImagePriority <= LLViewerFetchedTexture::maxDecodePriority()); - static const F32 PRIORITY_SCALE = (F32)LLWorkerThread::PRIORITY_LOWBITS / LLViewerFetchedTexture::maxDecodePriority(); - - mWorkPriority = llmin((U32)LLWorkerThread::PRIORITY_LOWBITS, (U32)(mImagePriority * PRIORITY_SCALE)); - return mWorkPriority; -} - // Locks: Mw (ctor invokes without lock) void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) { @@ -1088,11 +1049,9 @@ void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) { if (!haveWork()) { - calcWorkPriority(); if (!mFetcher->mDebugPause) { - U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH; - addWork(0, work_priority); + addWork(0); } } else if (mDesiredDiscard < discard) @@ -1111,23 +1070,13 @@ void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) if ((prioritize && mState == INIT) || mState == DONE) { setState(INIT); - U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH; - setPriority(work_priority); } } // Locks: Mw void LLTextureFetchWorker::setImagePriority(F32 priority) { -// llassert_always(priority >= 0 && priority <= LLViewerTexture::maxDecodePriority()); - F32 delta = fabs(priority - mImagePriority); - if (delta > (mImagePriority * .05f) || mState == DONE) - { - mImagePriority = priority; - calcWorkPriority(); - U32 work_priority = mWorkPriority | (getPriority() & LLWorkerThread::PRIORITY_HIGHBITS); - setPriority(work_priority); - } + mImagePriority = priority; //should map to max virtual size } // Locks: Mw @@ -1147,6 +1096,11 @@ void LLTextureFetchWorker::resetFormattedData() mHaveAllData = FALSE; } +F32 LLTextureFetchWorker::getImagePriority() const +{ + return mImagePriority; +} + // Threads: Tmain void LLTextureFetchWorker::startWork(S32 param) { @@ -1156,7 +1110,7 @@ void LLTextureFetchWorker::startWork(S32 param) // Threads: Ttf bool LLTextureFetchWorker::doWork(S32 param) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if (gNonInteractive) { return true; @@ -1171,20 +1125,23 @@ bool LLTextureFetchWorker::doWork(S32 param) { if (mState < DECODE_IMAGE) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - state < decode"); return true; // abort } } - if(mImagePriority < F_ALMOST_ZERO) + if (mImagePriority < F_ALMOST_ZERO) { if (mState == INIT || mState == LOAD_FROM_NETWORK || mState == LOAD_FROM_SIMULATOR) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - priority < 0"); LL_DEBUGS(LOG_TXT) << mID << " abort: mImagePriority < F_ALMOST_ZERO" << LL_ENDL; return true; // abort } } if(mState > CACHE_POST && !mCanUseNET && !mCanUseHTTP) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - state > cache_post"); //nowhere to get data, abort. LL_WARNS(LOG_TXT) << mID << " abort, nowhere to get data" << LL_ENDL; return true ; @@ -1206,6 +1163,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == INIT) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - INIT"); mStateTimer.reset(); mFetchTimer.reset(); for(auto i : LOGGED_STATES) @@ -1247,15 +1205,16 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == LOAD_FROM_TEXTURE_CACHE) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - LOAD_FROM_TEXTURE_CACHE"); if (mCacheReadHandle == LLTextureCache::nullHandle()) { - U32 cache_priority = mWorkPriority; S32 offset = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0; S32 size = mDesiredSize - offset; if (size <= 0) { setState(CACHE_POST); - return false; + return doWork(param); + // return false; } mFileSize = 0; mLoaded = FALSE; @@ -1264,35 +1223,28 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mUrl.compare(0, 7, "file://") == 0) { - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it - // read file from local disk ++mCacheReadCount; std::string filename = mUrl.substr(7, std::string::npos); CacheReadResponder* responder = new CacheReadResponder(mFetcher, mID, mFormattedImage); mCacheReadTimer.reset(); - mCacheReadHandle = mFetcher->mTextureCache->readFromCache(filename, mID, cache_priority, - offset, size, responder); + mCacheReadHandle = mFetcher->mTextureCache->readFromCache(filename, mID, offset, size, responder); } else if ((mUrl.empty() || mFTType==FTT_SERVER_BAKE) && mFetcher->canLoadFromCache()) { - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it - ++mCacheReadCount; CacheReadResponder* responder = new CacheReadResponder(mFetcher, mID, mFormattedImage); mCacheReadTimer.reset(); - mCacheReadHandle = mFetcher->mTextureCache->readFromCache(mID, cache_priority, + mCacheReadHandle = mFetcher->mTextureCache->readFromCache(mID, offset, size, responder);; } else if(!mUrl.empty() && mCanUseHTTP) { - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); setState(WAIT_HTTP_RESOURCE); } else { - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); setState(LOAD_FROM_NETWORK); } } @@ -1325,6 +1277,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == CACHE_POST) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - CACHE_POST"); mCachedSize = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0; // Successfully loaded if ((mCachedSize >= mDesiredSize) || mHaveAllData) @@ -1366,6 +1319,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == LOAD_FROM_NETWORK) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - LOAD_FROM_NETWORK"); // Check for retries to previous server failures. F32 wait_seconds; if (mFetchRetryPolicy.shouldRetry(wait_seconds)) @@ -1427,7 +1381,6 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mCanUseHTTP && !mUrl.empty()) { setState(WAIT_HTTP_RESOURCE); - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); if(mWriteToCacheState != NOT_WRITE) { mWriteToCacheState = CAN_WRITE ; @@ -1444,25 +1397,19 @@ bool LLTextureFetchWorker::doWork(S32 param) mSentRequest = QUEUED; mFetcher->addToNetworkQueue(this); recordTextureStart(false); - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); - return false; } else { // Shouldn't need to do anything here - //llassert_always(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end()); - // Make certain this is in the network queue - //mFetcher->addToNetworkQueue(this); - //recordTextureStart(false); - //setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); - + llassert(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end()); return false; } } if (mState == LOAD_FROM_SIMULATOR) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - LOAD_FROM_SIMULATOR"); if (mFormattedImage.isNull()) { mFormattedImage = new LLImageJ2C; @@ -1492,7 +1439,7 @@ bool LLTextureFetchWorker::doWork(S32 param) LL_WARNS(LOG_TXT) << mID << " processSimulatorPackets() failed to load buffer" << LL_ENDL; return true; // failed } - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); + if (mLoadedDiscard < 0) { LL_WARNS(LOG_TXT) << mID << " mLoadedDiscard is " << mLoadedDiscard @@ -1506,7 +1453,6 @@ bool LLTextureFetchWorker::doWork(S32 param) else { mFetcher->addToNetworkQueue(this); // failsafe - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); recordTextureStart(false); } return false; @@ -1514,6 +1460,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == WAIT_HTTP_RESOURCE) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - WAIT_HTTP_RESOURCE"); // NOTE: // control the number of the http requests issued for: // 1, not openning too many file descriptors at the same time; @@ -1524,7 +1471,6 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mFetcher->getHttpWaitersCount() || ! acquireHttpSemaphore()) { setState(WAIT_HTTP_RESOURCE2); - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); mFetcher->addHttpWaiter(this->mID); ++mResourceWaitCount; return false; @@ -1538,12 +1484,14 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == WAIT_HTTP_RESOURCE2) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - WAIT_HTTP_RESOURCE2"); // Just idle it if we make it to the head... return false; } if (mState == SEND_HTTP_REQ) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - SEND_HTTP_REQ"); // Also used in llmeshrepository static LLCachedControl disable_range_req(gSavedSettings, "HttpRangeRequestsDisable", false); @@ -1566,7 +1514,6 @@ bool LLTextureFetchWorker::doWork(S32 param) { // We already have all the data, just decode it mLoadedDiscard = mFormattedImage->getDiscardLevel(); - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); if (mLoadedDiscard < 0) { LL_WARNS(LOG_TXT) << mID << " mLoadedDiscard is " << mLoadedDiscard @@ -1574,7 +1521,8 @@ bool LLTextureFetchWorker::doWork(S32 param) } setState(DECODE_IMAGE); releaseHttpSemaphore(); - return false; + //return false; + return doWork(param); } else { @@ -1635,7 +1583,6 @@ bool LLTextureFetchWorker::doWork(S32 param) // by people with questionable ISPs or networking gear that // doesn't handle these well. mHttpHandle = mFetcher->mHttpRequest->requestGet(mHttpPolicyClass, - mWorkPriority, mUrl, options, mFetcher->mHttpHeaders, @@ -1644,7 +1591,6 @@ bool LLTextureFetchWorker::doWork(S32 param) else { mHttpHandle = mFetcher->mHttpRequest->requestGetByteRange(mHttpPolicyClass, - mWorkPriority, mUrl, mRequestedOffset, (mRequestedOffset + mRequestedSize) > HTTP_REQUESTS_RANGE_END_MAX @@ -1669,7 +1615,6 @@ bool LLTextureFetchWorker::doWork(S32 param) mHttpActive = true; mFetcher->addToHTTPQueue(mID); recordTextureStart(true); - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); setState(WAIT_HTTP_REQ); // fall through @@ -1677,6 +1622,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == WAIT_HTTP_REQ) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - WAIT_HTTP_REQ"); // *NOTE: As stated above, all transitions out of this state should // call releaseHttpSemaphore(). if (mLoaded) @@ -1708,9 +1654,9 @@ bool LLTextureFetchWorker::doWork(S32 param) setState(INIT); mCanUseHTTP = false; mUrl.clear(); - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); releaseHttpSemaphore(); - return false; + //return false; + return doWork(param); } } else if (http_service_unavail == mGetStatus) @@ -1738,7 +1684,6 @@ bool LLTextureFetchWorker::doWork(S32 param) { // Use available data mLoadedDiscard = mFormattedImage->getDiscardLevel(); - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); if (mLoadedDiscard < 0) { LL_WARNS(LOG_TXT) << mID << " mLoadedDiscard is " << mLoadedDiscard @@ -1746,7 +1691,8 @@ bool LLTextureFetchWorker::doWork(S32 param) } setState(DECODE_IMAGE); releaseHttpSemaphore(); - return false; + //return false; + return doWork(param); } // Fail harder @@ -1863,9 +1809,9 @@ bool LLTextureFetchWorker::doWork(S32 param) { mWriteToCacheState = SHOULD_WRITE ; } - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); releaseHttpSemaphore(); - return false; + //return false; + return doWork(param); } else { @@ -1875,17 +1821,16 @@ bool LLTextureFetchWorker::doWork(S32 param) // an enormous amount of time to load textures. We'll revisit the // various possible timeout components (total request time, connection // time, I/O time, with and without retries, etc.) in the future. - - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); + return false; } } if (mState == DECODE_IMAGE) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - DECODE_IMAGE"); static LLCachedControl textures_decode_disabled(gSavedSettings, "TextureDecodeDisabled", false); - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it if (textures_decode_disabled) { // for debug use, don't decode @@ -1924,18 +1869,18 @@ bool LLTextureFetchWorker::doWork(S32 param) mAuxImage = NULL; llassert_always(mFormattedImage.notNull()); S32 discard = mHaveAllData ? 0 : mLoadedDiscard; - U32 image_priority = LLWorkerThread::PRIORITY_NORMAL | mWorkPriority; mDecoded = FALSE; setState(DECODE_IMAGE_UPDATE); LL_DEBUGS(LOG_TXT) << mID << ": Decoding. Bytes: " << mFormattedImage->getDataSize() << " Discard: " << discard << " All Data: " << mHaveAllData << LL_ENDL; - mDecodeHandle = mFetcher->mImageDecodeThread->decodeImage(mFormattedImage, image_priority, discard, mNeedsAux, + mDecodeHandle = mFetcher->mImageDecodeThread->decodeImage(mFormattedImage, discard, mNeedsAux, new DecodeResponder(mFetcher, mID, this)); // fall though } if (mState == DECODE_IMAGE_UPDATE) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - DECODE_IMAGE_UPDATE"); if (mDecoded) { if(mFetcher->getFetchDebugger() && !mInLocalCache) @@ -1954,9 +1899,9 @@ bool LLTextureFetchWorker::doWork(S32 param) llassert_always(mDecodeHandle == 0); mFormattedImage = NULL; ++mRetryAttempt; - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); setState(INIT); - return false; + //return false; + return doWork(param); } else { @@ -1969,7 +1914,6 @@ bool LLTextureFetchWorker::doWork(S32 param) llassert_always(mRawImage.notNull()); LL_DEBUGS(LOG_TXT) << mID << ": Decoded. Discard: " << mDecodedDiscard << " Raw Image: " << llformat("%dx%d",mRawImage->getWidth(),mRawImage->getHeight()) << LL_ENDL; - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); setState(WRITE_TO_CACHE); } // fall through @@ -1982,12 +1926,14 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == WRITE_TO_CACHE) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - WRITE_TO_CACHE"); if (mWriteToCacheState != SHOULD_WRITE || mFormattedImage.isNull()) { // If we're in a local cache or we didn't actually receive any new data, // or we failed to load anything, skip setState(DONE); - return false; + //return false; + return doWork(param); } S32 datasize = mFormattedImage->getDataSize(); if(mFileSize < datasize)//This could happen when http fetching and sim fetching mixed. @@ -2002,8 +1948,6 @@ bool LLTextureFetchWorker::doWork(S32 param) } } llassert_always(datasize); - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it - U32 cache_priority = mWorkPriority; mWritten = FALSE; setState(WAIT_ON_WRITE); ++mCacheWriteCount; @@ -2014,7 +1958,7 @@ bool LLTextureFetchWorker::doWork(S32 param) // So make sure users of getRequestFinished() does not attempt to modify image while // fetcher is working mCacheWriteTimer.reset(); - mCacheWriteHandle = mFetcher->mTextureCache->writeToCache(mID, cache_priority, + mCacheWriteHandle = mFetcher->mTextureCache->writeToCache(mID, mFormattedImage->getData(), datasize, mFileSize, mRawImage, mDecodedDiscard, responder); // fall through @@ -2022,6 +1966,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == WAIT_ON_WRITE) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - WAIT_ON_WRITE"); if (writeToCacheComplete()) { mCacheWriteTime = mCacheWriteTimer.getElapsedTimeF32(); @@ -2043,6 +1988,7 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mState == DONE) { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - DONE"); if (mDecodedDiscard >= 0 && mDesiredDiscard < mDecodedDiscard) { // More data was requested, return to INIT @@ -2050,12 +1996,11 @@ bool LLTextureFetchWorker::doWork(S32 param) LL_DEBUGS(LOG_TXT) << mID << " more data requested, returning to INIT: " << " mDecodedDiscard " << mDecodedDiscard << ">= 0 && mDesiredDiscard " << mDesiredDiscard << "<" << " mDecodedDiscard " << mDecodedDiscard << LL_ENDL; - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); - return false; + // return false; + return doWork(param); } else { - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); mFetchTime = mFetchTimer.getElapsedTimeF32(); return true; } @@ -2068,6 +2013,7 @@ bool LLTextureFetchWorker::doWork(S32 param) // virtual void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) { + LL_PROFILE_ZONE_SCOPED; static LLCachedControl log_to_viewer_log(gSavedSettings, "LogTextureDownloadsToViewerLog", false); static LLCachedControl log_to_sim(gSavedSettings, "LogTextureDownloadsToSimulator", false); static LLCachedControl log_texture_traffic(gSavedSettings, "LogTextureNetworkTraffic", false) ; @@ -2177,6 +2123,7 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe // Threads: Tmain void LLTextureFetchWorker::endWork(S32 param, bool aborted) { + LL_PROFILE_ZONE_SCOPED; if (mDecodeHandle != 0) { mFetcher->mImageDecodeThread->abortRequest(mDecodeHandle, false); @@ -2192,6 +2139,7 @@ void LLTextureFetchWorker::endWork(S32 param, bool aborted) // virtual void LLTextureFetchWorker::finishWork(S32 param, bool completed) { + LL_PROFILE_ZONE_SCOPED; // The following are required in case the work was aborted if (mCacheReadHandle != LLTextureCache::nullHandle()) { @@ -2445,7 +2393,6 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response, } mLoaded = TRUE; - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); if (LLViewerStatsRecorder::instanceExists()) { @@ -2461,6 +2408,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response, void LLTextureFetchWorker::callbackCacheRead(bool success, LLImageFormatted* image, S32 imagesize, BOOL islocal) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLMutexLock lock(&mWorkMutex); // +Mw if (mState != LOAD_FROM_TEXTURE_CACHE) { @@ -2480,7 +2428,6 @@ void LLTextureFetchWorker::callbackCacheRead(bool success, LLImageFormatted* ima } } mLoaded = TRUE; - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); } // -Mw // Threads: Ttc @@ -2493,7 +2440,6 @@ void LLTextureFetchWorker::callbackCacheWrite(bool success) return; } mWritten = TRUE; - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); } // -Mw ////////////////////////////////////////////////////////////////////////////// @@ -2532,7 +2478,6 @@ void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImag } mDecoded = TRUE; // LL_INFOS(LOG_TXT) << mID << " : DECODE COMPLETE " << LL_ENDL; - setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); } // -Mw ////////////////////////////////////////////////////////////////////////////// @@ -2595,6 +2540,16 @@ void LLTextureFetchWorker::recordTextureDone(bool is_http, F64 byte_count) ////////////////////////////////////////////////////////////////////////////// // public +const char* LLTextureFetch::getStateString(S32 state) +{ + if (state < 0 || state > sizeof(e_state_name) / sizeof(char*)) + { + return llformat("%d", state).c_str(); + } + + return e_state_name[state]; +} + LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* imagedecodethread, bool threaded, bool qa_mode) : LLWorkerThread("TextureFetch", threaded, true), mDebugCount(0), @@ -2695,6 +2650,7 @@ LLTextureFetch::~LLTextureFetch() bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const LLUUID& id, const LLHost& host, F32 priority, S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux, bool can_use_http) { + LL_PROFILE_ZONE_SCOPED; if(mFetcherLocked) { return false; @@ -2786,7 +2742,7 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const worker->setState(LLTextureFetchWorker::INIT); worker->unlockWorkMutex(); // -Mw - worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority); + worker->addWork(0); } else { @@ -2818,6 +2774,7 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const // protected void LLTextureFetch::addToNetworkQueue(LLTextureFetchWorker* worker) { + LL_PROFILE_ZONE_SCOPED; lockQueue(); // +Mfq bool in_request_map = (mRequestMap.find(worker->mID) != mRequestMap.end()) ; unlockQueue(); // -Mfq @@ -2839,6 +2796,7 @@ void LLTextureFetch::addToNetworkQueue(LLTextureFetchWorker* worker) // Threads: T* void LLTextureFetch::removeFromNetworkQueue(LLTextureFetchWorker* worker, bool cancel) { + LL_PROFILE_ZONE_SCOPED; LLMutexLock lock(&mNetworkQueueMutex); // +Mfnq size_t erased = mNetworkQueue.erase(worker->mID); if (cancel && erased > 0) @@ -2852,6 +2810,7 @@ void LLTextureFetch::removeFromNetworkQueue(LLTextureFetchWorker* worker, bool c // protected void LLTextureFetch::addToHTTPQueue(const LLUUID& id) { + LL_PROFILE_ZONE_SCOPED; LLMutexLock lock(&mNetworkQueueMutex); // +Mfnq mHTTPTextureQueue.insert(id); mTotalHTTPRequests++; @@ -2860,6 +2819,7 @@ void LLTextureFetch::addToHTTPQueue(const LLUUID& id) // Threads: T* void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32Bytes received_size) { + LL_PROFILE_ZONE_SCOPED; LLMutexLock lock(&mNetworkQueueMutex); // +Mfnq mHTTPTextureQueue.erase(id); mHTTPTextureBits += received_size; // Approximate - does not include header bits @@ -2872,6 +2832,7 @@ void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32Bytes received_siz // Threads: T* void LLTextureFetch::deleteRequest(const LLUUID& id, bool cancel) { + LL_PROFILE_ZONE_SCOPED; lockQueue(); // +Mfq LLTextureFetchWorker* worker = getWorkerAfterLock(id); if (worker) @@ -2898,6 +2859,7 @@ void LLTextureFetch::deleteRequest(const LLUUID& id, bool cancel) // Threads: T* void LLTextureFetch::removeRequest(LLTextureFetchWorker* worker, bool cancel) { + LL_PROFILE_ZONE_SCOPED; if(!worker) { return; @@ -2967,6 +2929,7 @@ U32 LLTextureFetch::getTotalNumHTTPRequests() // Locks: Mfq LLTextureFetchWorker* LLTextureFetch::getWorkerAfterLock(const LLUUID& id) { + LL_PROFILE_ZONE_SCOPED; LLTextureFetchWorker* res = NULL; map_t::iterator iter = mRequestMap.find(id); if (iter != mRequestMap.end()) @@ -2990,6 +2953,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, LLPointer& raw, LLPointer& aux, LLCore::HttpStatus& last_http_get_status) { + LL_PROFILE_ZONE_SCOPED; bool res = false; LLTextureFetchWorker* worker = getWorker(id); if (worker) @@ -3004,7 +2968,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, if (!mDebugPause) { // LL_WARNS(LOG_TXT) << "Adding work for inactive worker: " << id << LL_ENDL; - worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority); + worker->addWork(0); } } else if (worker->checkWork()) @@ -3080,6 +3044,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, // Threads: T* bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority) { + LL_PROFILE_ZONE_SCOPED; bool res = false; LLTextureFetchWorker* worker = getWorker(id); if (worker) @@ -3106,6 +3071,7 @@ bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority) //virtual S32 LLTextureFetch::getPending() { + LL_PROFILE_ZONE_SCOPED; S32 res; lockData(); // +Ct { @@ -3139,7 +3105,7 @@ bool LLTextureFetch::runCondition() } // -Mfq return ! (have_no_commands - && (mRequestQueue.empty() && mIdleThread)); // From base class + && (mRequestQueue.size() == 0 && mIdleThread)); // From base class } ////////////////////////////////////////////////////////////////////////////// @@ -3147,6 +3113,7 @@ bool LLTextureFetch::runCondition() // Threads: Ttf void LLTextureFetch::commonUpdate() { + LL_PROFILE_ZONE_SCOPED; // Update low/high water levels based on pipelining. We pick // up setting eventually, so the semaphore/request level can // fall outside the [0..HIGH_WATER] range. Expect that. @@ -3183,6 +3150,7 @@ void LLTextureFetch::commonUpdate() //virtual S32 LLTextureFetch::update(F32 max_time_ms) { + LL_PROFILE_ZONE_SCOPED; static LLCachedControl band_width(gSavedSettings,"ThrottleBandwidthKBPS", 3000.0); { @@ -3266,6 +3234,7 @@ void LLTextureFetch::endThread() // Threads: Ttf void LLTextureFetch::threadedUpdate() { + LL_PROFILE_ZONE_SCOPED; llassert_always(mHttpRequest); #if 0 @@ -3301,6 +3270,7 @@ void LLTextureFetch::threadedUpdate() // Threads: Tmain void LLTextureFetch::sendRequestListToSimulators() { + LL_PROFILE_ZONE_SCOPED; // All requests const F32 REQUEST_DELTA_TIME = 0.10f; // 10 fps @@ -3351,7 +3321,6 @@ void LLTextureFetch::sendRequestListToSimulators() req->mLastPacket >= req->mTotalPackets-1) { // We have all the packets... make sure this is high priority -// req->setPriority(LLWorkerThread::PRIORITY_HIGH | req->mWorkPriority); continue; } F32 elapsed = req->mRequestedDeltaTimer.getElapsedTimeF32(); @@ -3498,6 +3467,7 @@ void LLTextureFetch::sendRequestListToSimulators() // Locks: Mw bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size) { + LL_PROFILE_ZONE_SCOPED; mRequestedDeltaTimer.reset(); if (index >= mTotalPackets) { @@ -3530,6 +3500,7 @@ bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size) void LLTextureFetchWorker::setState(e_state new_state) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if (mFTType == FTT_SERVER_BAKE) { // NOTE: turning on these log statements is a reliable way to get @@ -3551,7 +3522,7 @@ void LLTextureFetchWorker::setState(e_state new_state) mSkippedStatesTime += d_time; } } - + mStateTimer.reset(); mState = new_state; } @@ -3560,6 +3531,7 @@ void LLTextureFetchWorker::setState(e_state new_state) bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8 codec, U16 packets, U32 totalbytes, U16 data_size, U8* data) { + LL_PROFILE_ZONE_SCOPED; LLTextureFetchWorker* worker = getWorker(id); bool res = true; @@ -3611,7 +3583,6 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8 llassert_always(totalbytes > 0); llassert_always(data_size == FIRST_PACKET_SIZE || data_size == worker->mFileSize); res = worker->insertPacket(0, data, data_size); - worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority); worker->setState(LLTextureFetchWorker::LOAD_FROM_SIMULATOR); worker->unlockWorkMutex(); // -Mw return res; @@ -3621,6 +3592,7 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8 // Threads: T* bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U16 packet_num, U16 data_size, U8* data) { + LL_PROFILE_ZONE_SCOPED; LLTextureFetchWorker* worker = getWorker(id); bool res = true; @@ -3661,7 +3633,6 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1 if ((worker->mState == LLTextureFetchWorker::LOAD_FROM_SIMULATOR) || (worker->mState == LLTextureFetchWorker::LOAD_FROM_NETWORK)) { - worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority); worker->setState(LLTextureFetchWorker::LOAD_FROM_SIMULATOR); } else @@ -3706,10 +3677,23 @@ BOOL LLTextureFetch::isFromLocalCache(const LLUUID& id) return from_cache ; } +S32 LLTextureFetch::getFetchState(const LLUUID& id) +{ + S32 state = LLTextureFetchWorker::INVALID; + LLTextureFetchWorker* worker = getWorker(id); + if (worker && worker->haveWork()) + { + state = worker->mState; + } + + return state; +} + // Threads: T* S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& requested_priority_p, U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http) { + LL_PROFILE_ZONE_SCOPED; S32 state = LLTextureFetchWorker::INVALID; F32 data_progress = 0.0f; F32 requested_priority = 0.0f; @@ -3745,7 +3729,7 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r { requested_priority = worker->mImagePriority; } - fetch_priority = worker->getPriority(); + fetch_priority = worker->getImagePriority(); can_use_http = worker->getCanUseHTTP() ; worker->unlockWorkMutex(); // -Mw } @@ -3759,19 +3743,6 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r void LLTextureFetch::dump() { - LL_INFOS(LOG_TXT) << "LLTextureFetch REQUESTS:" << LL_ENDL; - for (request_queue_t::iterator iter = mRequestQueue.begin(); - iter != mRequestQueue.end(); ++iter) - { - LLQueuedThread::QueuedRequest* qreq = *iter; - LLWorkerThread::WorkRequest* wreq = (LLWorkerThread::WorkRequest*)qreq; - LLTextureFetchWorker* worker = (LLTextureFetchWorker*)wreq->getWorkerClass(); - LL_INFOS(LOG_TXT) << " ID: " << worker->mID - << " PRI: " << llformat("0x%08x",wreq->getPriority()) - << " STATE: " << sStateDescs[worker->mState] - << LL_ENDL; - } - LL_INFOS(LOG_TXT) << "LLTextureFetch ACTIVE_HTTP:" << LL_ENDL; for (queue_t::const_iterator iter(mHTTPTextureQueue.begin()); mHTTPTextureQueue.end() != iter; @@ -3838,6 +3809,7 @@ bool LLTextureFetch::isHttpWaiter(const LLUUID & tid) // Locks: -Mw (must not hold any worker when called) void LLTextureFetch::releaseHttpWaiters() { + LL_PROFILE_ZONE_SCOPED; // Use mHttpSemaphore rather than mHTTPTextureQueue.size() // to avoid a lock. if (mHttpSemaphore >= mHttpLowWater) @@ -3934,7 +3906,6 @@ void LLTextureFetch::releaseHttpWaiters() } worker->setState(LLTextureFetchWorker::SEND_HTTP_REQ); - worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority); worker->unlockWorkMutex(); // -Mw removeHttpWaiter(worker->mID); @@ -4024,6 +3995,7 @@ void LLTextureFetch::commandDataBreak() // Threads: T* void LLTextureFetch::cmdEnqueue(TFRequest * req) { + LL_PROFILE_ZONE_SCOPED; lockQueue(); // +Mfq mCommands.push_back(req); unlockQueue(); // -Mfq @@ -4034,6 +4006,7 @@ void LLTextureFetch::cmdEnqueue(TFRequest * req) // Threads: T* LLTextureFetch::TFRequest * LLTextureFetch::cmdDequeue() { + LL_PROFILE_ZONE_SCOPED; TFRequest * ret = 0; lockQueue(); // +Mfq @@ -4050,6 +4023,7 @@ LLTextureFetch::TFRequest * LLTextureFetch::cmdDequeue() // Threads: Ttf void LLTextureFetch::cmdDoWork() { + LL_PROFILE_ZONE_SCOPED; if (mDebugPause) { return; // debug: don't do any work @@ -4140,6 +4114,7 @@ TFReqSendMetrics::~TFReqSendMetrics() bool TFReqSendMetrics::doWork(LLTextureFetch * fetcher) { + LL_PROFILE_ZONE_SCOPED; static const U32 report_priority(1); //if (! gViewerAssetStatsThread1) @@ -4183,7 +4158,6 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) // Don't care about handle, this is a fire-and-forget operation. LLCoreHttpUtil::requestPostWithLLSD(&fetcher->getHttpRequest(), fetcher->getMetricsPolicyClass(), - report_priority, mCapsURL, mStatsSD, LLCore::HttpOptions::ptr_t(), @@ -4630,7 +4604,7 @@ void LLTextureFetchDebugger::debugCacheRead() for(S32 i = 0 ; i < size ; i++) { mFetchingHistory[i].mFormattedImage = NULL; - mFetchingHistory[i].mCacheHandle = mTextureCache->readFromCache(mFetchingHistory[i].mID, LLWorkerThread::PRIORITY_NORMAL, 0, mFetchingHistory[i].mFetchedSize, + mFetchingHistory[i].mCacheHandle = mTextureCache->readFromCache(mFetchingHistory[i].mID, 0, mFetchingHistory[i].mFetchedSize, new LLDebuggerCacheReadResponder(this, i, mFetchingHistory[i].mFormattedImage)); } } @@ -4667,8 +4641,8 @@ void LLTextureFetchDebugger::debugCacheWrite() { if(mFetchingHistory[i].mFormattedImage.notNull()) { - mFetchingHistory[i].mCacheHandle = mTextureCache->writeToCache(mFetchingHistory[i].mID, LLWorkerThread::PRIORITY_NORMAL, - mFetchingHistory[i].mFormattedImage->getData(), mFetchingHistory[i].mFetchedSize, + mFetchingHistory[i].mCacheHandle = mTextureCache->writeToCache(mFetchingHistory[i].mID, + mFetchingHistory[i].mFormattedImage->getData(), mFetchingHistory[i].mFetchedSize, mFetchingHistory[i].mDecodedLevel == 0 ? mFetchingHistory[i].mFetchedSize : mFetchingHistory[i].mFetchedSize + 1, NULL, 0, new LLDebuggerCacheWriteResponder(this, i)); } @@ -4699,7 +4673,7 @@ void LLTextureFetchDebugger::debugDecoder() continue; } - mImageDecodeThread->decodeImage(mFetchingHistory[i].mFormattedImage, LLWorkerThread::PRIORITY_NORMAL, + mImageDecodeThread->decodeImage(mFetchingHistory[i].mFormattedImage, mFetchingHistory[i].mDecodedLevel, mFetchingHistory[i].mNeedsAux, new LLDebuggerDecodeResponder(this, i)); } @@ -4767,7 +4741,6 @@ S32 LLTextureFetchDebugger::fillCurlQueue() requestedSize = (requestedSize == 33554432 ? 0 : requestedSize); LLCore::HttpHandle handle = mFetcher->getHttpRequest().requestGetByteRange(mHttpPolicyClass, - LLWorkerThread::PRIORITY_LOWBITS, texture_url, 0, requestedSize, diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index bf6732963f..0cf9775af2 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -59,6 +59,8 @@ class LLTextureFetch : public LLWorkerThread friend class LLTextureFetchWorker; public: + static const char* getStateString(S32 state); + LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* imagedecodethread, bool threaded, bool qa_mode); ~LLTextureFetch(); @@ -116,10 +118,11 @@ public: // Threads: T* BOOL isFromLocalCache(const LLUUID& id); - // @return Magic number giving the internal state of the - // request. We should make these codes public if we're - // going to return them as a status value. - // + // get the current fetch state, if any, from the given UUID + S32 getFetchState(const LLUUID& id); + + // @return Fetch state of given image and associates statistics + // See also getStateString // Threads: T* S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p, U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http); diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 99ab854293..f0e9cee101 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -119,8 +119,8 @@ public: LLTextureBar* bar2p = (LLTextureBar*)i2; LLViewerFetchedTexture *i1p = bar1p->mImagep; LLViewerFetchedTexture *i2p = bar2p->mImagep; - F32 pri1 = i1p->getDecodePriority(); // i1p->mRequestedDownloadPriority - F32 pri2 = i2p->getDecodePriority(); // i2p->mRequestedDownloadPriority + F32 pri1 = i1p->getMaxVirtualSize(); + F32 pri2 = i2p->getMaxVirtualSize(); if (pri1 > pri2) return true; else if (pri2 > pri1) @@ -179,7 +179,7 @@ void LLTextureBar::draw() { color = LLColor4::magenta; // except none and alm } - else if (mImagep->getDecodePriority() <= 0.0f) + else if (mImagep->getMaxVirtualSize() <= 0.0f) { color = LLColor4::grey; color[VALPHA] = .7f; } @@ -204,26 +204,13 @@ void LLTextureBar::draw() std::string uuid_str; mImagep->mID.toString(uuid_str); uuid_str = uuid_str.substr(0,7); - if (mTextureView->mOrderFetch) - { - tex_str = llformat("%s %7.0f %d(%d) 0x%08x(%8.0f)", - uuid_str.c_str(), - mImagep->mMaxVirtualSize, - mImagep->mDesiredDiscardLevel, - mImagep->mRequestedDiscardLevel, - mImagep->mFetchPriority, - mImagep->getDecodePriority()); - } - else - { - tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x)", - uuid_str.c_str(), - mImagep->mMaxVirtualSize, - mImagep->mDesiredDiscardLevel, - mImagep->mRequestedDiscardLevel, - mImagep->getDecodePriority(), - mImagep->mFetchPriority); - } + + tex_str = llformat("%s %7.0f %d(%d)", + uuid_str.c_str(), + mImagep->mMaxVirtualSize, + mImagep->mDesiredDiscardLevel, + mImagep->mRequestedDiscardLevel); + LLFontGL::getFontMonospace()->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(), color, LLFontGL::LEFT, LLFontGL::TOP); @@ -547,7 +534,7 @@ void LLGLTexMemBar::draw() U32 texFetchLatMed = U32(recording.getMean(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); U32 texFetchLatMax = U32(recording.getMax(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); - text = llformat("GL Free: %d Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB", + text = llformat("GL Free: %d MB Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB", gViewerWindow->getWindow()->getAvailableVRAMMegabytes(), LLMemory::getAvailableMemKB()/1024, LLRenderTarget::sBytesAllocated/(1024*1024), @@ -830,7 +817,7 @@ void LLTextureView::draw() LL_INFOS() << imagep->getID() << "\t" << tex_mem << "\t" << imagep->getBoostLevel() - << "\t" << imagep->getDecodePriority() + << "\t" << imagep->getMaxVirtualSize() << "\t" << imagep->getWidth() << "\t" << imagep->getHeight() << "\t" << cur_discard @@ -850,7 +837,7 @@ void LLTextureView::draw() } else { - pri = imagep->getDecodePriority(); + pri = imagep->getMaxVirtualSize(); } pri = llclamp(pri, 0.0f, HIGH_PRIORITY-1.f); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 4618871630..602597a86b 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -341,12 +341,6 @@ static bool handleMaxPartCountChanged(const LLSD& newvalue) return true; } -static bool handleVideoMemoryChanged(const LLSD& newvalue) -{ - gTextureList.updateMaxResidentTexMem(S32Megabytes(newvalue.asInteger())); - return true; -} - static bool handleChatFontSizeChanged(const LLSD& newvalue) { if(gConsole) @@ -697,7 +691,6 @@ void settings_setup_listeners() gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("RenderDeferredSSAO")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("RenderPerformanceTest")->getSignal()->connect(boost::bind(&handleRenderPerfTestChanged, _2)); - gSavedSettings.getControl("TextureMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2)); gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&handleChatFontSizeChanged, _2)); gSavedSettings.getControl("ChatPersistTime")->getSignal()->connect(boost::bind(&handleChatPersistTimeChanged, _2)); gSavedSettings.getControl("ConsoleMaxLines")->getSignal()->connect(boost::bind(&handleConsoleMaxLinesChanged, _2)); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index ac6c86d9c6..06673b50fa 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -78,6 +78,8 @@ LLPointer LLViewerFetchedTexture::sSmokeImagep = NULL; LLPointer LLViewerFetchedTexture::sFlatNormalImagep = NULL; LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap; LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL; +F32 LLViewerFetchedTexture::sMaxVirtualSize = F32_MAX/2.f; + const std::string sTesterName("TextureTester"); S32 LLViewerTexture::sImageCount = 0; @@ -490,7 +492,7 @@ bool LLViewerTexture::isMemoryForTextureLow() S32Megabytes physical; getGPUMemoryForTextures(gpu, physical); - return (gpu < MIN_FREE_TEXTURE_MEMORY) || (physical < MIN_FREE_MAIN_MEMORY); + return (gpu < MIN_FREE_TEXTURE_MEMORY); // || (physical < MIN_FREE_MAIN_MEMORY); } //static @@ -504,7 +506,7 @@ bool LLViewerTexture::isMemoryForTextureSuficientlyFree() S32Megabytes physical; getGPUMemoryForTextures(gpu, physical); - return (gpu > DESIRED_FREE_TEXTURE_MEMORY) && (physical > DESIRED_FREE_MAIN_MEMORY); + return (gpu > DESIRED_FREE_TEXTURE_MEMORY); // && (physical > DESIRED_FREE_MAIN_MEMORY); } //static @@ -629,7 +631,6 @@ void LLViewerTexture::init(bool firstinit) mMaxVirtualSize = 0.f; mMaxVirtualSizeResetInterval = 1; mMaxVirtualSizeResetCounter = mMaxVirtualSizeResetInterval; - mAdditionalDecodePriority = 0.f; mParcelMedia = NULL; memset(&mNumVolumes, 0, sizeof(U32)* LLRender::NUM_VOLUME_TEXTURE_CHANNELS); @@ -796,15 +797,14 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co } virtual_size *= sTexelPixelRatio; - if(!mMaxVirtualSizeResetCounter) + /*if (!mMaxVirtualSizeResetCounter) { //flag to reset the values because the old values are used. resetMaxVirtualSizeResetCounter(); mMaxVirtualSize = virtual_size; - mAdditionalDecodePriority = 0.f; mNeedsGLTexture = needs_gltexture; } - else if (virtual_size > mMaxVirtualSize) + else*/ if (virtual_size > mMaxVirtualSize) { mMaxVirtualSize = virtual_size; } @@ -813,7 +813,6 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co void LLViewerTexture::resetTextureStats() { mMaxVirtualSize = 0.0f; - mAdditionalDecodePriority = 0.f; mMaxVirtualSizeResetCounter = 0; } @@ -1082,7 +1081,6 @@ void LLViewerFetchedTexture::init(bool firstinit) if (firstinit) { - mDecodePriority = 0.f; mInImageList = 0; } @@ -1131,6 +1129,7 @@ void LLViewerFetchedTexture::init(bool firstinit) LLViewerFetchedTexture::~LLViewerFetchedTexture() { + assert_main_thread(); //*NOTE getTextureFetch can return NULL when Viewer is shutting down. // This is due to LLWearableList is singleton and is destroyed after // LLAppViewer::cleanup() was called. (see ticket EXT-177) @@ -1563,6 +1562,7 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/) void LLViewerFetchedTexture::postCreateTexture() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if (!mNeedsCreateTexture) { return; @@ -1586,6 +1586,8 @@ void LLViewerFetchedTexture::postCreateTexture() void LLViewerFetchedTexture::scheduleCreateTexture() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + if (!mNeedsCreateTexture) { mNeedsCreateTexture = TRUE; @@ -1662,6 +1664,7 @@ void LLViewerFetchedTexture::scheduleCreateTexture() //virtual void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if(mKnownDrawWidth < width || mKnownDrawHeight < height) { mKnownDrawWidth = llmax(mKnownDrawWidth, width); @@ -1673,9 +1676,31 @@ void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height) addTextureStats((F32)(mKnownDrawWidth * mKnownDrawHeight)); } +void LLViewerFetchedTexture::setDebugText(const std::string& text) +{ + for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) + { + llassert(mNumFaces[ch] <= mFaceList[ch].size()); + + for (U32 i = 0; i < mNumFaces[ch]; i++) + { + LLFace* facep = mFaceList[ch][i]; + if (facep) + { + LLDrawable* drawable = facep->getDrawable(); + if (drawable) + { + drawable->getVObj()->setDebugText(text); + } + } + } + } +} + //virtual void LLViewerFetchedTexture::processTextureStats() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if(mFullyLoaded) { if(mDesiredDiscardLevel > mMinDesiredDiscardLevel)//need to load more @@ -1683,6 +1708,7 @@ void LLViewerFetchedTexture::processTextureStats() mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel); mFullyLoaded = FALSE; } + //setDebugText("fully loaded"); } else { @@ -1695,7 +1721,7 @@ void LLViewerFetchedTexture::processTextureStats() mDesiredDiscardLevel = 0; } else if (!LLPipeline::sRenderDeferred && mBoostLevel == LLGLTexture::BOOST_ALM) - { + { // ??? don't load spec and normal maps when alm is disabled ??? mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; } else if (mDontDiscard && mBoostLevel == LLGLTexture::BOOST_ICON) @@ -1760,191 +1786,9 @@ const S32 MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY = 4; const F32 PRIORITY_ADDITIONAL_FACTOR = 1000000.f; //additional const S32 MAX_ADDITIONAL_LEVEL_FOR_PRIORITY = 8; const F32 PRIORITY_BOOST_HIGH_FACTOR = 10000000.f;//boost high -F32 LLViewerFetchedTexture::calcDecodePriority() -{ -#ifndef LL_RELEASE_FOR_DOWNLOAD - if (mID == LLAppViewer::getTextureFetch()->mDebugID) - { - LLAppViewer::getTextureFetch()->mDebugCount++; // for setting breakpoints - } -#endif - - if (mNeedsCreateTexture) - { - return mDecodePriority; // no change while waiting to create - } - if(mFullyLoaded && !mForceToSaveRawImage)//already loaded for static texture - { - return -1.0f; //alreay fetched - } - - S32 cur_discard = getCurrentDiscardLevelForFetching(); - bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel)); - F32 pixel_priority = (F32) sqrt(mMaxVirtualSize); - - F32 priority = 0.f; - - if (mIsMissingAsset) - { - priority = 0.0f; - } - else if(mDesiredDiscardLevel >= cur_discard && cur_discard > -1) - { - priority = -2.0f; - } - else if(mCachedRawDiscardLevel > -1 && mDesiredDiscardLevel >= mCachedRawDiscardLevel) - { - priority = -3.0f; - } - else if (mDesiredDiscardLevel > getMaxDiscardLevel()) - { - // Don't decode anything we don't need - priority = -4.0f; - } - else if ((mBoostLevel == LLGLTexture::BOOST_UI || mBoostLevel == LLGLTexture::BOOST_ICON) && !have_all_data) - { - priority = 1.f; - } - else if (pixel_priority < 0.001f && !have_all_data) - { - // Not on screen but we might want some data - if (mBoostLevel > BOOST_SELECTED) - { - // Always want high boosted images - priority = 1.f; - } - else - { - priority = -5.f; //stop fetching - } - } - else if (cur_discard < 0) - { - //texture does not have any data, so we don't know the size of the image, treat it like 32 * 32. - // priority range = 100,000 - 500,000 - static const F64 log_2 = log(2.0); - F32 desired = (F32)(log(32.0/pixel_priority) / log_2); - S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired; - ddiscard = llclamp(ddiscard, 0, MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY); - priority = (ddiscard + 1) * PRIORITY_DELTA_DISCARD_LEVEL_FACTOR; - setAdditionalDecodePriority(0.1f);//boost the textures without any data so far. - } - else if ((mMinDiscardLevel > 0) && (cur_discard <= mMinDiscardLevel)) - { - // larger mips are corrupted - priority = -6.0f; - } - else - { - // priority range = 100,000 - 500,000 - S32 desired_discard = mDesiredDiscardLevel; - if (!isJustBound() && mCachedRawImageReady) - { - if(mBoostLevel < BOOST_HIGH) - { - // We haven't rendered this in a while, de-prioritize it - desired_discard += 2; - } - else - { - // We haven't rendered this in the last half second, and we have a cached raw image, leave the desired discard as-is - desired_discard = cur_discard; - } - } - - S32 ddiscard = cur_discard - desired_discard; - ddiscard = llclamp(ddiscard, -1, MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY); - priority = (ddiscard + 1) * PRIORITY_DELTA_DISCARD_LEVEL_FACTOR; - } - - // Priority Formula: - // BOOST_HIGH + ADDITIONAL PRI + DELTA DISCARD + BOOST LEVEL + PIXELS - // [10,000,000] + [1,000,000-9,000,000] + [100,000-500,000] + [1-20,000] + [0-999] - if (priority > 0.0f) - { - bool large_enough = mCachedRawImageReady && ((S32)mTexelsPerImage > sMinLargeImageSize); - if(large_enough) - { - //Note: - //to give small, low-priority textures some chance to be fetched, - //cut the priority in half if the texture size is larger than 256 * 256 and has a 64*64 ready. - priority *= 0.5f; - } - - pixel_priority = llclamp(pixel_priority, 0.0f, MAX_PRIORITY_PIXEL); - - priority += pixel_priority + PRIORITY_BOOST_LEVEL_FACTOR * mBoostLevel; - - if ( mBoostLevel > BOOST_HIGH) - { - if(mBoostLevel > BOOST_SUPER_HIGH) - { - //for very important textures, always grant the highest priority. - priority += PRIORITY_BOOST_HIGH_FACTOR; - } - else if(mCachedRawImageReady) - { - //Note: - //to give small, low-priority textures some chance to be fetched, - //if high priority texture has a 64*64 ready, lower its fetching priority. - setAdditionalDecodePriority(0.5f); - } - else - { - priority += PRIORITY_BOOST_HIGH_FACTOR; - } - } - - if(mAdditionalDecodePriority > 0.0f) - { - // priority range += 1,000,000.f-9,000,000.f - F32 additional = PRIORITY_ADDITIONAL_FACTOR * (1.0 + mAdditionalDecodePriority * MAX_ADDITIONAL_LEVEL_FOR_PRIORITY); - if(large_enough) - { - //Note: - //to give small, low-priority textures some chance to be fetched, - //cut the additional priority to a quarter if the texture size is larger than 256 * 256 and has a 64*64 ready. - additional *= 0.25f; - } - priority += additional; - } - } - return priority; -} - -//static -F32 LLViewerFetchedTexture::maxDecodePriority() -{ - static const F32 max_priority = PRIORITY_BOOST_HIGH_FACTOR + //boost_high - PRIORITY_ADDITIONAL_FACTOR * (MAX_ADDITIONAL_LEVEL_FOR_PRIORITY + 1) + //additional (view dependent factors) - PRIORITY_DELTA_DISCARD_LEVEL_FACTOR * (MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY + 1) + //delta discard - PRIORITY_BOOST_LEVEL_FACTOR * (BOOST_MAX_LEVEL - 1) + //boost level - MAX_PRIORITY_PIXEL + 1.0f; //pixel area. - - return max_priority; -} //============================================================================ -void LLViewerFetchedTexture::setDecodePriority(F32 priority) -{ - mDecodePriority = priority; - - if(mDecodePriority < F_ALMOST_ZERO) - { - mStopFetchingTimer.reset(); - } -} - -void LLViewerFetchedTexture::setAdditionalDecodePriority(F32 priority) -{ - priority = llclamp(priority, 0.f, 1.f); - if(mAdditionalDecodePriority < priority) - { - mAdditionalDecodePriority = priority; - } -} - void LLViewerFetchedTexture::updateVirtualSize() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -1953,6 +1797,12 @@ void LLViewerFetchedTexture::updateVirtualSize() addTextureStats(0.f, FALSE);//reset } + if (getBoostLevel() >= LLViewerTexture::BOOST_HIGH) + { //always load boosted textures at highest priority full res + addTextureStats(sMaxVirtualSize); + return; + } + for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) { llassert(mNumFaces[ch] <= mFaceList[ch].size()); @@ -1974,8 +1824,12 @@ void LLViewerFetchedTexture::updateVirtualSize() setBoostLevel(LLViewerTexture::BOOST_SELECTED); } addTextureStats(facep->getVirtualSize()); - setAdditionalDecodePriority(facep->getImportanceToCamera()); + //drawable->getVObj()->setDebugText(llformat("%d:%d", (S32)sqrtf(facep->getVirtualSize()), (S32)sqrtf(getMaxVirtualSize()))); } + else + { + //drawable->getVObj()->setDebugText(""); + } } } } @@ -2063,31 +1917,35 @@ bool LLViewerFetchedTexture::updateFetch() if (mNeedsCreateTexture) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - needs create"); // We may be fetching still (e.g. waiting on write) // but don't check until we've processed the raw data we have return false; } if (mIsMissingAsset) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - missing asset"); llassert_always(!mHasFetcher); return false; // skip } if (!mLoadedCallbackList.empty() && mRawImage.notNull()) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - callback pending"); return false; // process any raw image data in callbacks before replacing } if(mInFastCacheList) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - in fast cache"); return false; } S32 current_discard = getCurrentDiscardLevelForFetching(); S32 desired_discard = getDesiredDiscardLevel(); - F32 decode_priority = getDecodePriority(); - decode_priority = llclamp(decode_priority, 0.0f, maxDecodePriority()); + F32 decode_priority = mMaxVirtualSize; if (mIsFetching) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - is fetching"); // Sets mRawDiscardLevel, mRawImage, mAuxRawImage S32 fetch_discard = current_discard; @@ -2105,17 +1963,25 @@ bool LLViewerFetchedTexture::updateFetch() if (finished) { mIsFetching = FALSE; + mLastFetchState = -1; + setDebugText(""); mLastPacketTimer.reset(); } else { mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP); + if (mFetchState != mLastFetchState) + { + setDebugText(LLTextureFetch::getStateString(mFetchState)); + mLastFetchState = mFetchState; + } } // We may have data ready regardless of whether or not we are finished (e.g. waiting on write) if (mRawImage.notNull()) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - has raw image"); LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); if (tester) { @@ -2126,6 +1992,7 @@ bool LLViewerFetchedTexture::updateFetch() if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && (current_discard < 0 || mRawDiscardLevel < current_discard)) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data good"); mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; mFullHeight = mRawImage->getHeight() << mRawDiscardLevel; setTexelsPerImage(); @@ -2162,6 +2029,7 @@ bool LLViewerFetchedTexture::updateFetch() } else { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data not needed"); // Data is ready but we don't need it // (received it already while fetcher was writing to disk) destroyRawImage(); @@ -2194,13 +2062,13 @@ bool LLViewerFetchedTexture::updateFetch() if(current_discard >= 0) { mMinDiscardLevel = current_discard; - desired_discard = current_discard; + //desired_discard = current_discard; } else { S32 dis_level = getDiscardLevel(); mMinDiscardLevel = dis_level; - desired_discard = dis_level; + //desired_discard = dis_level; } } destroyRawImage(); @@ -2214,12 +2082,6 @@ bool LLViewerFetchedTexture::updateFetch() } else { -// // Useful debugging code for undesired deprioritization of textures. -// if (decode_priority <= 0.0f && desired_discard >= 0 && desired_discard < current_discard) -// { -// LL_INFOS() << "Calling updateRequestPriority() with decode_priority = 0.0f" << LL_ENDL; -// calcDecodePriority(); -// } static const F32 MAX_HOLD_TIME = 5.0f; //seconds to wait before canceling fecthing if decode_priority is 0.f. if(decode_priority > 0.0f || mStopFetchingTimer.getElapsedTimeF32() > MAX_HOLD_TIME) { @@ -2229,21 +2091,27 @@ bool LLViewerFetchedTexture::updateFetch() } } + desired_discard = llmin(desired_discard, getMaxDiscardLevel()); + bool make_request = true; - if (decode_priority <= 0) + /*if (decode_priority <= 0) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - priority <= 0"); make_request = false; } else if(mDesiredDiscardLevel > getMaxDiscardLevel()) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - desired > max"); make_request = false; } - else if (mNeedsCreateTexture || mIsMissingAsset) + else */ if (mNeedsCreateTexture || mIsMissingAsset) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - create or missing"); make_request = false; } else if (current_discard >= 0 && current_discard <= mMinDiscardLevel) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - current < min"); make_request = false; } else if(mCachedRawImage.notNull() // can be empty @@ -2260,6 +2128,7 @@ bool LLViewerFetchedTexture::updateFetch() if (make_request) { +#if 0 // Load the texture progressively: we try not to rush to the desired discard too fast. // If the camera is not moving, we do not tweak the discard level notch by notch but go to the desired discard with larger boosted steps // This mitigates the "textures stay blurry" problem when loading while not killing the texture memory while moving around @@ -2276,18 +2145,23 @@ bool LLViewerFetchedTexture::updateFetch() { desired_discard = llmax(desired_discard, current_discard - delta_level); } +#endif if (mIsFetching) { + // already requested a higher resolution mip if (mRequestedDiscardLevel <= desired_discard) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - requested < desired"); make_request = false; } } else { + // already at a higher resolution mip, don't discard if (current_discard >= 0 && current_discard <= desired_discard) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - current <= desired"); make_request = false; } } @@ -2295,6 +2169,7 @@ bool LLViewerFetchedTexture::updateFetch() if (make_request) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - make request"); S32 w=0, h=0, c=0; if (getDiscardLevel() >= 0) { @@ -2316,6 +2191,7 @@ bool LLViewerFetchedTexture::updateFetch() if (fetch_request_created) { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - request created"); mHasFetcher = TRUE; mIsFetching = TRUE; mRequestedDiscardLevel = desired_discard; @@ -2331,7 +2207,7 @@ bool LLViewerFetchedTexture::updateFetch() // Only delete requests that haven't received any network data // for a while. Note - this is the normal mechanism for // deleting requests, not just a place to handle timeouts. - const F32 FETCH_IDLE_TIME = 5.f; + const F32 FETCH_IDLE_TIME = 0.1f; if (mLastPacketTimer.getElapsedTimeF32() > FETCH_IDLE_TIME) { LL_DEBUGS("Texture") << "exceeded idle time " << FETCH_IDLE_TIME << ", deleting request: " << getID() << LL_ENDL; @@ -2641,7 +2517,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks() LL_INFOS() << "baked texture: " << mID << "clears all call backs due to inactivity." << LL_ENDL; LL_INFOS() << mUrl << LL_ENDL; LL_INFOS() << "current discard: " << getDiscardLevel() << " current discard for fetch: " << getCurrentDiscardLevelForFetching() << - " Desired discard: " << getDesiredDiscardLevel() << "decode Pri: " << getDecodePriority() << LL_ENDL; + " Desired discard: " << getDesiredDiscardLevel() << "decode Pri: " << mMaxVirtualSize << LL_ENDL; } clearCallbackEntryList() ; //remove all callbacks. @@ -2872,7 +2748,7 @@ void LLViewerFetchedTexture::forceImmediateUpdate() return; } //if already called forceImmediateUpdate() - if(mInImageList && mDecodePriority == LLViewerFetchedTexture::maxDecodePriority()) + if(mInImageList && mMaxVirtualSize == LLViewerFetchedTexture::sMaxVirtualSize) { return; } @@ -2941,6 +2817,7 @@ bool LLViewerFetchedTexture::needsToSaveRawImage() void LLViewerFetchedTexture::destroyRawImage() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if (mAuxRawImage.notNull() && !needsToSaveRawImage()) { sAuxCount--; @@ -3024,6 +2901,7 @@ void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* im void LLViewerFetchedTexture::setCachedRawImage() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if(mRawImage == mCachedRawImage) { return; @@ -3099,6 +2977,7 @@ void LLViewerFetchedTexture::checkCachedRawSculptImage() void LLViewerFetchedTexture::saveRawImage() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if(mRawImage.isNull() || mRawImage == mSavedRawImage || (mSavedRawDiscardLevel >= 0 && mSavedRawDiscardLevel <= mRawDiscardLevel)) { return; @@ -3314,25 +3193,10 @@ void LLViewerLODTexture::processTextureStats() } else { - if(isLargeImage() && !isJustBound() && mAdditionalDecodePriority < 0.3f) - { - //if is a big image and not being used recently, nor close to the view point, do not load hi-res data. - mMaxVirtualSize = llmin(mMaxVirtualSize, (F32)LLViewerTexture::sMinLargeImageSize); - } - - if ((mCalculatedDiscardLevel >= 0.f) && - (llabs(mMaxVirtualSize - mDiscardVirtualSize) < mMaxVirtualSize*.20f)) - { - // < 20% change in virtual size = no change in desired discard - discard_level = mCalculatedDiscardLevel; - } - else - { - // Calculate the required scale factor of the image using pixels per texel - discard_level = (F32)(log(mTexelsPerImage/mMaxVirtualSize) / log_4); - mDiscardVirtualSize = mMaxVirtualSize; - mCalculatedDiscardLevel = discard_level; - } + // Calculate the required scale factor of the image using pixels per texel + discard_level = (F32)(log(mTexelsPerImage/mMaxVirtualSize) / log_4); + mDiscardVirtualSize = mMaxVirtualSize; + mCalculatedDiscardLevel = discard_level; } if (mBoostLevel < LLGLTexture::BOOST_SCULPTED) { diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 0640efe6df..ece6794592 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -194,14 +194,14 @@ private: public: static bool isMemoryForTextureLow(); protected: + friend class LLViewerTextureList; LLUUID mID; S32 mTextureListType; // along with mID identifies where to search for this texture in TextureList F32 mSelectedTime; // time texture was last selected mutable F32 mMaxVirtualSize; // The largest virtual size of the image, in pixels - how much data to we need? - mutable S32 mMaxVirtualSizeResetCounter ; + mutable S32 mMaxVirtualSizeResetCounter; mutable S32 mMaxVirtualSizeResetInterval; - mutable F32 mAdditionalDecodePriority; // priority add to mDecodePriority. LLFrameTimer mLastReferencedTimer; ll_face_list_t mFaceList[LLRender::NUM_TEXTURE_CHANNELS]; //reverse pointer pointing to the faces using this image as texture @@ -281,7 +281,6 @@ public: LLViewerFetchedTexture(const std::string& url, FTType f_type, const LLUUID& id, BOOL usemipmaps = TRUE); public: - static F32 maxDecodePriority(); struct Compare { @@ -290,9 +289,10 @@ public: { const LLViewerFetchedTexture* lhsp = (const LLViewerFetchedTexture*)lhs; const LLViewerFetchedTexture* rhsp = (const LLViewerFetchedTexture*)rhs; + // greater priority is "less" - const F32 lpriority = lhsp->getDecodePriority(); - const F32 rpriority = rhsp->getDecodePriority(); + const F32 lpriority = lhsp->mMaxVirtualSize; + const F32 rpriority = rhsp->mMaxVirtualSize; if (lpriority > rpriority) // higher priority return true; if (lpriority < rpriority) @@ -331,7 +331,6 @@ public: void destroyTexture() ; virtual void processTextureStats() ; - F32 calcDecodePriority() ; BOOL needsAux() const { return mNeedsAux; } @@ -339,15 +338,6 @@ public: void setTargetHost(LLHost host) { mTargetHost = host; } LLHost getTargetHost() const { return mTargetHost; } - // Set the decode priority for this image... - // DON'T CALL THIS UNLESS YOU KNOW WHAT YOU'RE DOING, it can mess up - // the priority list, and cause horrible things to happen. - void setDecodePriority(F32 priority = -1.0f); - F32 getDecodePriority() const { return mDecodePriority; }; - F32 getAdditionalDecodePriority() const { return mAdditionalDecodePriority; }; - - void setAdditionalDecodePriority(F32 priority) ; - void updateVirtualSize() ; S32 getDesiredDiscardLevel() { return mDesiredDiscardLevel; } @@ -367,6 +357,10 @@ public: // more data. /*virtual*/ void setKnownDrawSize(S32 width, S32 height); + // Set the debug text of all Viewer Objects associated with this texture + // to the specified text + void setDebugText(const std::string& text); + void setIsMissingAsset(BOOL is_missing = true); /*virtual*/ BOOL isMissingAsset() const { return mIsMissingAsset; } @@ -468,11 +462,11 @@ protected: S32 mRequestedDiscardLevel; F32 mRequestedDownloadPriority; S32 mFetchState; + S32 mLastFetchState = -1; // DEBUG U32 mFetchPriority; F32 mDownloadProgress; F32 mFetchDeltaTime; F32 mRequestDeltaTime; - F32 mDecodePriority; // The priority for decoding this image. S32 mMinDiscardLevel; S8 mDesiredDiscardLevel; // The discard level we'd LIKE to have - if we have it and there's space S8 mMinDesiredDiscardLevel; // The minimum discard level we'd like to have @@ -530,6 +524,7 @@ protected: BOOL mIsFetched ; //is loaded from remote or from cache, not generated locally. public: + static F32 sMaxVirtualSize; //maximum possible value of mMaxVirtualSize static LLPointer sMissingAssetImagep; // Texture to show for an image asset that is not in the database static LLPointer sWhiteImagep; // Texture to show NOTHING (whiteness) static LLPointer sDefaultImagep; // "Default" texture for error cases, the only case of fetched texture which is generated in local. diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 2a88d9314b..80565b0238 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -89,8 +89,6 @@ LLTextureKey::LLTextureKey(LLUUID id, ETexListType tex_type) LLViewerTextureList::LLViewerTextureList() : mForceResetTextureStats(FALSE), - mMaxResidentTexMemInMegaBytes(0), - mMaxTotalTextureMemInMegaBytes(0), mInitialized(FALSE) { } @@ -99,12 +97,6 @@ void LLViewerTextureList::init() { mInitialized = TRUE ; sNumImages = 0; - mMaxResidentTexMemInMegaBytes = (U32Bytes)0; - mMaxTotalTextureMemInMegaBytes = (U32Bytes)0; - - // Update how much texture RAM we're allowed to use. - updateMaxResidentTexMem(S32Megabytes(0)); // 0 = use current - doPreloadImages(); } @@ -342,7 +334,7 @@ void LLViewerTextureList::dump() { LLViewerFetchedTexture* image = *it; - LL_INFOS() << "priority " << image->getDecodePriority() + LL_INFOS() << "priority " << image->getMaxVirtualSize() << " boost " << image->getBoostLevel() << " size " << image->getWidth() << "x" << image->getHeight() << " discard " << image->getDiscardLevel() @@ -667,13 +659,14 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image) assert_main_thread(); llassert_always(mInitialized) ; llassert(image); + image->validateRefCount(); S32 count = 0; if (image->isInImageList()) { count = mImageList.erase(image) ; if(count != 1) - { + { LL_INFOS() << "Image " << image->getID() << " had mInImageList set but mImageList.erase() returned " << count << LL_ENDL; @@ -699,6 +692,7 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image) LL_INFOS() << "Image " << image->getID() << " was in mUUIDMap with same pointer" << LL_ENDL ; } count = mImageList.erase(image) ; + llassert(count != 0); if(count != 0) { // it was in the list already? LL_WARNS() << "Image " << image->getID() @@ -822,7 +816,6 @@ void LLViewerTextureList::updateImages(F32 max_time) didone = image->doLoadedCallbacks(); } } - updateImagesUpdateStats(); } @@ -847,118 +840,102 @@ void LLViewerTextureList::clearFetchingRequests() void LLViewerTextureList::updateImagesDecodePriorities() { +#if 0 LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - // Update the decode priority for N images each frame - { - F32 lazy_flush_timeout = 30.f; // stop decoding - F32 max_inactive_time = 20.f; // actually delete - S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference - - //reset imagep->getLastReferencedTimer() when screen is showing the progress view to avoid removing pre-fetched textures too soon. - bool reset_timer = gViewerWindow->getProgressView()->getVisible(); - - static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities"); // default: 32 - const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds.value()) + 1, MAX_PRIO_UPDATES); - S32 update_counter = llmin(max_update_count, mUUIDMap.size()); - uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateKey); - while ((update_counter-- > 0) && !mUUIDMap.empty()) - { - if (iter == mUUIDMap.end()) - { - iter = mUUIDMap.begin(); - } - mLastUpdateKey = iter->first; - LLPointer imagep = iter->second; - ++iter; // safe to increment now + // Update the decode priority for N images each frame + + /*static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities"); // default: 32 + const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds.value()) + 1, MAX_PRIO_UPDATES); + S32 update_counter = llmin(max_update_count, mUUIDMap.size()); + uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateKey);*/ + //while ((update_counter-- > 0) && !mUUIDMap.empty()) + for (uuid_map_t::iterator iter = mUUIDMap.begin(); iter != mUUIDMap.end(); ++iter) + { + /*if (iter == mUUIDMap.end()) + { + iter = mUUIDMap.begin(); + }*/ + mLastUpdateKey = iter->first; + LLPointer imagep = iter->second; + //++iter; // safe to increment now - if(imagep->isInDebug() || imagep->isUnremovable()) - { - update_counter--; - continue; //is in debug, ignore. - } + updateImageDecodePriority(imagep); + } +#endif +} - // - // Flush formatted images using a lazy flush - // - S32 num_refs = imagep->getNumRefs(); - if (num_refs == min_refs) - { - if(reset_timer) - { - imagep->getLastReferencedTimer()->reset(); - } - else if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > lazy_flush_timeout) - { - // Remove the unused image from the image list - deleteImage(imagep); - imagep = NULL; // should destroy the image - } - continue; - } - else - { - if(imagep->hasSavedRawImage()) - { - if(imagep->getElapsedLastReferencedSavedRawImageTime() > max_inactive_time) - { - imagep->destroySavedRawImage() ; - } - } +void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep) +{ + if (imagep->isInDebug() || imagep->isUnremovable()) + { + //update_counter--; + return; //is in debug, ignore. + } - if(imagep->isDeleted()) - { - continue ; - } - else if(imagep->isDeletionCandidate()) - { - imagep->destroyTexture() ; - continue ; - } - else if(imagep->isInactive()) - { - if(reset_timer) - { - imagep->getLastReferencedTimer()->reset(); - } - else if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > max_inactive_time) - { - imagep->setDeletionCandidate() ; - } - continue ; - } - else - { - imagep->getLastReferencedTimer()->reset(); + F32 lazy_flush_timeout = 30.f; // stop decoding + F32 max_inactive_time = 20.f; // actually delete + S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference - //reset texture state. - imagep->setInactive() ; - } - } + // + // Flush formatted images using a lazy flush + // + S32 num_refs = imagep->getNumRefs(); + if (num_refs == min_refs) + { + if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > lazy_flush_timeout) + { + // Remove the unused image from the image list + deleteImage(imagep); + imagep = NULL; // should destroy the image + } + return; + } + else + { + if (imagep->hasSavedRawImage()) + { + if (imagep->getElapsedLastReferencedSavedRawImageTime() > max_inactive_time) + { + imagep->destroySavedRawImage(); + } + } - if (!imagep->isInImageList()) - { - continue; - } - if(imagep->isInFastCacheList()) - { - continue; //wait for loading from the fast cache. - } + if (imagep->isDeleted()) + { + return; + } + else if (imagep->isDeletionCandidate()) + { + imagep->destroyTexture(); + return; + } + else if (imagep->isInactive()) + { + if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > max_inactive_time) + { + imagep->setDeletionCandidate(); + } + return; + } + else + { + imagep->getLastReferencedTimer()->reset(); - imagep->processTextureStats(); - F32 old_priority = imagep->getDecodePriority(); - F32 old_priority_test = llmax(old_priority, 0.0f); - F32 decode_priority = imagep->calcDecodePriority(); - F32 decode_priority_test = llmax(decode_priority, 0.0f); - // Ignore < 20% difference - if ((decode_priority_test < old_priority_test * .8f) || - (decode_priority_test > old_priority_test * 1.25f)) - { - mImageList.erase(imagep) ; - imagep->setDecodePriority(decode_priority); - mImageList.insert(imagep); - } - } - } + //reset texture state. + imagep->setInactive(); + } + } + + if (!imagep->isInImageList()) + { + return; + } + if (imagep->isInFastCacheList()) + { + return; //wait for loading from the fast cache. + } + + imagep->processTextureStats(); } void LLViewerTextureList::setDebugFetching(LLViewerFetchedTexture* tex, S32 debug_level) @@ -970,17 +947,9 @@ void LLViewerTextureList::setDebugFetching(LLViewerFetchedTexture* tex, S32 debu } const F32 DEBUG_PRIORITY = 100000.f; - F32 old_priority_test = llmax(tex->getDecodePriority(), 0.0f); - F32 decode_priority_test = DEBUG_PRIORITY; - - // Ignore < 20% difference - if ((decode_priority_test < old_priority_test * .8f) || - (decode_priority_test > old_priority_test * 1.25f)) - { - removeImageFromList(tex); - tex->setDecodePriority(decode_priority_test); - addImageToList(tex); - } + removeImageFromList(tex); + tex->mMaxVirtualSize = DEBUG_PRIORITY; + addImageToList(tex); } /* @@ -1030,10 +999,6 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time) LLViewerFetchedTexture *imagep = *curiter; imagep->createTexture(); imagep->postCreateTexture(); - if (create_timer.getElapsedTimeF32() > max_time) - { - break; - } } mCreateTextureList.erase(mCreateTextureList.begin(), enditer); return create_timer.getElapsedTimeF32(); @@ -1061,10 +1026,6 @@ F32 LLViewerTextureList::updateImagesLoadingFastCache(F32 max_time) enditer = iter; LLViewerFetchedTexture *imagep = *curiter; imagep->loadFromFastCache(); - if (timer.getElapsedTimeF32() > max_time) - { - break; - } } mFastCacheList.erase(mFastCacheList.begin(), enditer); return timer.getElapsedTimeF32(); @@ -1083,8 +1044,7 @@ void LLViewerTextureList::forceImmediateUpdate(LLViewerFetchedTexture* imagep) } imagep->processTextureStats(); - F32 decode_priority = LLViewerFetchedTexture::maxDecodePriority() ; - imagep->setDecodePriority(decode_priority); + imagep->sMaxVirtualSize = LLViewerFetchedTexture::sMaxVirtualSize; addImageToList(imagep); return ; @@ -1093,12 +1053,17 @@ void LLViewerTextureList::forceImmediateUpdate(LLViewerFetchedTexture* imagep) F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - LLTimer image_op_timer; - + LLTimer image_op_timer; + + typedef std::vector entries_list_t; + entries_list_t entries; + // Update fetch for N images each frame static const S32 MAX_HIGH_PRIO_COUNT = gSavedSettings.getS32("TextureFetchUpdateHighPriority"); // default: 32 + static const S32 MIN_UPDATE_COUNT = gSavedSettings.getS32("TextureFetchUpdateMinMediumPriority"); // default: 32 +#if 0 static const S32 MAX_UPDATE_COUNT = gSavedSettings.getS32("TextureFetchUpdateMaxMediumPriority"); // default: 256 - static const S32 MIN_UPDATE_COUNT = gSavedSettings.getS32("TextureFetchUpdateMinMediumPriority"); // default: 32 + static const F32 MIN_PRIORITY_THRESHOLD = gSavedSettings.getF32("TextureFetchUpdatePriorityThreshold"); // default: 0.0 static const bool SKIP_LOW_PRIO = gSavedSettings.getBOOL("TextureFetchUpdateSkipLowPriority"); // default: false @@ -1110,9 +1075,9 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) max_update_count = llmin(max_update_count, total_update_count); // MAX_HIGH_PRIO_COUNT high priority entries - typedef std::vector entries_list_t; - entries_list_t entries; - size_t update_counter = max_priority_count; + + //size_t update_counter = max_priority_count; + size_t update_counter = mImageList.size(); image_priority_list_t::iterator iter1 = mImageList.begin(); while(update_counter > 0) { @@ -1123,7 +1088,7 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) } // MAX_UPDATE_COUNT cycled entries - update_counter = max_update_count; + update_counter = max_update_count; if(update_counter > 0) { uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchKey); @@ -1147,22 +1112,65 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) } S32 fetch_count = 0; - size_t min_update_count = llmin(MIN_UPDATE_COUNT,(S32)(entries.size()-max_priority_count)); - S32 min_count = max_priority_count + min_update_count; + //size_t min_update_count = llmin(MIN_UPDATE_COUNT,(S32)(entries.size()-max_priority_count)); + //S32 min_count = max_priority_count + min_update_count; for (entries_list_t::iterator iter3 = entries.begin(); iter3 != entries.end(); ) { LLViewerFetchedTexture* imagep = *iter3++; + updateImageDecodePriority(imagep); fetch_count += (imagep->updateFetch() ? 1 : 0); - if (min_count <= min_update_count) + //if (min_count <= min_update_count) { mLastFetchKey = LLTextureKey(imagep->getID(), (ETexListType)imagep->getTextureListType()); } - if ((min_count-- <= 0) && (image_op_timer.getElapsedTimeF32() > max_time)) + /*if ((min_count-- <= 0) && (image_op_timer.getElapsedTimeF32() > max_time)) { break; - } + }*/ } +#else + + // update N textures at beginning of mImageList + U32 update_count = 0; + + /*for (auto& imagep : mImageList) + { + if (update_count++ > MAX_HIGH_PRIO_COUNT) + { + break; + } + + entries.push_back(imagep); + }*/ + + // WIP -- dumb code here + //update MIN_UPDATE_COUNT or 10% of other textures, whichever is greater + //update_count = llmax((U32) MIN_UPDATE_COUNT, (U32) mUUIDMap.size()/10); + //update_count = llmin(update_count, (U32) mUUIDMap.size()); + update_count -= mUUIDMap.size(); + + entries.reserve(update_count); + //uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchKey); + //while (update_count-- > 0) + for (auto iter2 = mUUIDMap.begin(); iter2 != mUUIDMap.end(); ++iter2) + { + entries.push_back(iter2->second); + } + + for (auto* imagep : entries) + { + updateImageDecodePriority(imagep); + imagep->updateFetch(); + } + + if (entries.size() > 0) + { + LLViewerFetchedTexture* imagep = *entries.rbegin(); + mLastFetchKey = LLTextureKey(imagep->getID(), (ETexListType)imagep->getTextureListType()); + } + +#endif return image_op_timer.getElapsedTimeF32(); } @@ -1206,8 +1214,6 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) { LLViewerFetchedTexture* imagep = *iter; imagep->processTextureStats(); - F32 decode_priority = imagep->calcDecodePriority(); - imagep->setDecodePriority(decode_priority); addImageToList(imagep); } image_list.clear(); @@ -1346,69 +1352,6 @@ LLPointer LLViewerTextureList::convertToUploadFile(LLPointer U32Megabytes(1500)) ? S32Megabytes(64) : gMinVideoRam ; -} - -//static -// Returns max setting for TextureMemory (in MB) -S32Megabytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, float mem_multiplier) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - S32Megabytes max_texmem; - if (gGLManager.mVRAM != 0) - { - // Treat any card with < 32 MB (shudder) as having 32 MB - // - it's going to be swapping constantly regardless - S32Megabytes max_vram(gGLManager.mVRAM); - - if(gGLManager.mIsAMD) - { - //shrink the availabe vram for ATI cards because some of them do not handel texture swapping well. - max_vram = max_vram * 0.75f; - } - - max_vram = llmax(max_vram, getMinVideoRamSetting()); - max_texmem = max_vram; - if (!get_recommended) - max_texmem *= 2; - } - else - { - if (!get_recommended) - { - max_texmem = (S32Megabytes)512; - } - else if (gSavedSettings.getBOOL("NoHardwareProbe")) //did not do hardware detection at startup - { - max_texmem = (S32Megabytes)512; - } - else - { - max_texmem = (S32Megabytes)128; - } - } - - S32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB(); // In MB - //LL_INFOS() << "*** DETECTED " << system_ram << " MB of system memory." << LL_ENDL; - if (get_recommended) - max_texmem = llmin(max_texmem, system_ram/2); - else - max_texmem = llmin(max_texmem, system_ram); - - // limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise - max_texmem = llmin(max_texmem, (S32Megabytes) (mem_multiplier * max_texmem)); - - max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), gMaxVideoRam); - - return max_texmem; -} - bool LLViewerTextureList::isPrioRequestsFetched() { static LLCachedControl prio_threshold(gSavedSettings, "TextureFetchUpdatePriorityThreshold", 0.0f); @@ -1420,7 +1363,7 @@ bool LLViewerTextureList::isPrioRequestsFetched() iter != gTextureList.mImageList.end(); ) { LLPointer imagep = *iter++; - if (imagep->getDecodePriority() > prio_threshold) + if (imagep->getMaxVirtualSize() > prio_threshold) { if (imagep->hasFetcher() || imagep->isFetching()) { @@ -1436,66 +1379,6 @@ bool LLViewerTextureList::isPrioRequestsFetched() return true; } -const S32Megabytes VIDEO_CARD_FRAMEBUFFER_MEM(12); -const S32Megabytes MIN_MEM_FOR_NON_TEXTURE(512); -void LLViewerTextureList::updateMaxResidentTexMem(S32Megabytes mem) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - // Initialize the image pipeline VRAM settings - S32Megabytes cur_mem(gSavedSettings.getS32("TextureMemory")); - F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); - S32Megabytes default_mem = getMaxVideoRamSetting(true, mem_multiplier); // recommended default - if (mem == (S32Bytes)0) - { - mem = cur_mem > (S32Bytes)0 ? cur_mem : default_mem; - } - else if (mem < (S32Bytes)0) - { - mem = default_mem; - } - - mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting(false, mem_multiplier)); - if (mem != cur_mem) - { - gSavedSettings.setS32("TextureMemory", mem.value()); - return; //listener will re-enter this function - } - - if (gGLManager.mVRAM == 0) - { - LL_WARNS() << "VRAM amount not detected, defaulting to " << mem << " MB" << LL_ENDL; - } - - // TODO: set available resident texture mem based on use by other subsystems - // currently max(12MB, VRAM/4) assumed... - - S32Megabytes vb_mem = mem; - S32Megabytes fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4); - mMaxResidentTexMemInMegaBytes = (vb_mem - fb_mem) ; //in MB - - mMaxTotalTextureMemInMegaBytes = mMaxResidentTexMemInMegaBytes * 2; - if (mMaxResidentTexMemInMegaBytes > (S32Megabytes)640) - { - mMaxTotalTextureMemInMegaBytes -= (mMaxResidentTexMemInMegaBytes / 4); - } - - //system mem - S32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB(); - - //minimum memory reserved for non-texture use. - //if system_raw >= 1GB, reserve at least 512MB for non-texture use; - //otherwise reserve half of the system_ram for non-texture use. - S32Megabytes min_non_texture_mem = llmin(system_ram / 2, MIN_MEM_FOR_NON_TEXTURE) ; - - if (mMaxTotalTextureMemInMegaBytes > system_ram - min_non_texture_mem) - { - mMaxTotalTextureMemInMegaBytes = system_ram - min_non_texture_mem ; - } - - LL_INFOS() << "Total Video Memory set to: " << vb_mem << " MB" << LL_ENDL; - LL_INFOS() << "Available Texture Memory set to: " << (vb_mem - fb_mem) << " MB" << LL_ENDL; -} - /////////////////////////////////////////////////////////////////////////////// // static diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index fead2e52b2..8d70add792 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -124,25 +124,24 @@ public: void handleIRCallback(void **data, const S32 number); - S32Megabytes getMaxResidentTexMem() const { return mMaxResidentTexMemInMegaBytes; } - S32Megabytes getMaxTotalTextureMem() const { return mMaxTotalTextureMemInMegaBytes;} S32 getNumImages() { return mImageList.size(); } - void updateMaxResidentTexMem(S32Megabytes mem); - void doPreloadImages(); void doPrefetchImages(); void clearFetchingRequests(); void setDebugFetching(LLViewerFetchedTexture* tex, S32 debug_level); - static S32Megabytes getMinVideoRamSetting(); - static S32Megabytes getMaxVideoRamSetting(bool get_recommended, float mem_multiplier); - static bool isPrioRequestsFetched(); private: void updateImagesDecodePriorities(); + + // do some book keeping on the specified texture + // - updates decode priority + // - updates desired discard level + // - cleans up textures that haven't been referenced in awhile + void updateImageDecodePriority(LLViewerFetchedTexture* imagep); F32 updateImagesCreateTextures(F32 max_time); F32 updateImagesFetchTextures(F32 max_time); void updateImagesUpdateStats(); @@ -217,15 +216,13 @@ private: LLTextureKey mLastUpdateKey; LLTextureKey mLastFetchKey; - typedef std::set, LLViewerFetchedTexture::Compare> image_priority_list_t; + typedef std::set < LLPointer > image_priority_list_t; image_priority_list_t mImageList; // simply holds on to LLViewerFetchedTexture references to stop them from being purged too soon std::set > mImagePreloads; BOOL mInitialized ; - S32Megabytes mMaxResidentTexMemInMegaBytes; - S32Megabytes mMaxTotalTextureMemInMegaBytes; LLFrameTimer mForceDecodeTimer; private: diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5ee661f6c0..151e03ac3b 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -5687,15 +5687,6 @@ void LLVOAvatar::addBakedTextureStats( LLViewerFetchedTexture* imagep, F32 pixel mMinPixelArea = llmin(pixel_area, mMinPixelArea); imagep->addTextureStats(pixel_area / texel_area_ratio); imagep->setBoostLevel(boost_level); - - if(boost_level != LLGLTexture::BOOST_AVATAR_BAKED_SELF) - { - imagep->setAdditionalDecodePriority(ADDITIONAL_PRI) ; - } - else - { - imagep->setAdditionalDecodePriority(SELF_ADDITIONAL_PRI) ; - } } //virtual diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 49f5f40f03..4080a61fb0 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -1825,7 +1825,7 @@ void LLVOAvatarSelf::dumpLocalTextures() const } else { - const LLViewerFetchedTexture* image = dynamic_cast( local_tex_obj->getImage() ); + LLViewerFetchedTexture* image = dynamic_cast( local_tex_obj->getImage() ); LL_INFOS() << "LocTex " << name << ": " << "Discard " << image->getDiscardLevel() << ", " @@ -1835,7 +1835,7 @@ void LLVOAvatarSelf::dumpLocalTextures() const // makes textures easier to steal << image->getID() << " " #endif - << "Priority: " << image->getDecodePriority() + << "Priority: " << image->getMaxVirtualSize() << LL_ENDL; } } @@ -2074,8 +2074,7 @@ const std::string LLVOAvatarSelf::verboseDebugDumpLocalTextureDataInfo(const LLV << " glocdisc: " << getLocalDiscardLevel(tex_index, wearable_index) << " discard: " << image->getDiscardLevel() << " desired: " << image->getDesiredDiscardLevel() - << " decode: " << image->getDecodePriority() - << " addl: " << image->getAdditionalDecodePriority() + << " vsize: " << image->getMaxVirtualSize() << " ts: " << image->getTextureState() << " bl: " << image->getBoostLevel() << " fl: " << image->isFullyLoaded() // this is not an accessor for mFullyLoaded - see comment there. @@ -2453,7 +2452,6 @@ void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerFetchedTe desired_pixels = llmin(mPixelArea, (F32)getTexImageArea()); imagep->setBoostLevel(getAvatarBoostLevel()); - imagep->setAdditionalDecodePriority(SELF_ADDITIONAL_PRI) ; imagep->resetTextureStats(); imagep->setMaxVirtualSizeResetInterval(MAX_TEXTURE_VIRTUAL_SIZE_RESET_INTERVAL); imagep->addTextureStats( desired_pixels / texel_area_ratio ); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index f18f6b1116..a0d034850f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -668,12 +668,13 @@ void LLVOVolume::animateTextures() void LLVOVolume::updateTextures() { - const F32 TEXTURE_AREA_REFRESH_TIME = 5.f; // seconds - if (mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + //const F32 TEXTURE_AREA_REFRESH_TIME = 1.f; // seconds + //if (mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) { updateTextureVirtualSize(); - if (mDrawable.notNull() && !isVisible() && !mDrawable->isActive()) + /*if (mDrawable.notNull() && !isVisible() && !mDrawable->isActive()) { //delete vertex buffer to free up some VRAM LLSpatialGroup* group = mDrawable->getSpatialGroup(); if (group && (group->mVertexBuffer.notNull() || !group->mBufferMap.empty() || !group->mDrawMap.empty())) @@ -684,9 +685,7 @@ void LLVOVolume::updateTextures() //it becomes visible group->setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); } - } - - + }*/ } } @@ -760,6 +759,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) const S32 num_faces = mDrawable->getNumFaces(); F32 min_vsize=999999999.f, max_vsize=0.f; LLViewerCamera* camera = LLViewerCamera::getInstance(); + std::stringstream debug_text; for (S32 i = 0; i < num_faces; i++) { LLFace* face = mDrawable->getFace(i); @@ -786,10 +786,14 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) else { vsize = face->getTextureVirtualSize(); + imagep->addTextureStats(vsize); } - mPixelArea = llmax(mPixelArea, face->getPixelArea()); + mPixelArea = llmax(mPixelArea, face->getPixelArea()); + // if the face has gotten small enough to turn off texture animation and texture + // animation is running, rebuild the render batch for this face to turn off + // texture animation if (face->mTextureMatrix != NULL) { if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) || @@ -809,10 +813,11 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) LLViewerFetchedTexture* img = LLViewerTextureManager::staticCastToFetchedTexture(imagep) ; if(img) { - F32 pri = img->getDecodePriority(); + debug_text << img->getDiscardLevel() << ":" << img->getDesiredDiscardLevel() << ":" << img->getWidth() << ":" << (S32) sqrtf(vsize) << ":" << (S32) sqrtf(img->getMaxVirtualSize()) << "\n"; + /*F32 pri = img->getDecodePriority(); pri = llmax(pri, 0.0f); if (pri < min_vsize) min_vsize = pri; - if (pri > max_vsize) max_vsize = pri; + if (pri > max_vsize) max_vsize = pri;*/ } } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_FACE_AREA)) @@ -844,14 +849,6 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) F32 lodf = ((F32)(lod + 1.0f)/4.f); F32 tex_size = lodf * LLViewerTexture::sMaxSculptRez ; mSculptTexture->addTextureStats(2.f * tex_size * tex_size, FALSE); - - //if the sculpty very close to the view point, load first - { - LLVector3 lookAt = getPositionAgent() - camera->getOrigin(); - F32 dist = lookAt.normVec() ; - F32 cos_angle_to_view_dir = lookAt * camera->getXAxis() ; - mSculptTexture->setAdditionalDecodePriority(0.8f * LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist)) ; - } } S32 texture_discard = mSculptTexture->getCachedRawImageLevel(); //try to match the texture @@ -895,7 +892,8 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) { - setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize))); + //setDebugText(llformat("%.0f:%.0f", (F32) sqrt(min_vsize),(F32) sqrt(max_vsize))); + setDebugText(debug_text.str()); } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_FACE_AREA)) { diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 32c8ce66a0..2b400c5586 100644 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -395,7 +395,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip, const mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); - mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, + mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, mURI, body.get(), httpOpts, httpHeaders, mHandler); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a5ae52af93..bc0d89f4ad 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3776,25 +3776,47 @@ void LLPipeline::postSort(LLCamera& camera) group->rebuildGeom(); } - for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j) - { - LLSpatialGroup::drawmap_elem_t& src_vec = j->second; - if (!hasRenderType(j->first)) - { - continue; - } - - for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) - { + for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j) + { + LLSpatialGroup::drawmap_elem_t& src_vec = j->second; + if (!hasRenderType(j->first)) + { + continue; + } + + // DEBUG -- force a texture virtual size update every frame + /*if (group->getSpatialPartition()->mDrawableType == LLPipeline::RENDER_TYPE_VOLUME) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("plps - update vsize"); + auto& entries = group->getData(); + for (auto& entry : entries) + { + if (entry) + { + auto* data = entry->getDrawable(); + if (data) + { + LLVOVolume* volume = ((LLDrawable*)data)->getVOVolume(); + if (volume) + { + volume->updateTextureVirtualSize(true); + } + } + } + } + }*/ + + for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) + { LLDrawInfo* info = *k; - - sCull->pushDrawInfo(j->first, info); + + sCull->pushDrawInfo(j->first, info); if (!sShadowRender && !sReflectionRender) { touchTextures(info); addTrianglesDrawn(info->mCount, info->mDrawMode); } - } + } } if (hasRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA)) diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index d1e167df64..0a4acd979a 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -272,23 +272,6 @@ Hardware - - Date: Wed, 27 Apr 2022 11:42:02 -0600 Subject: Prototype a SaveMaterial button --- indra/newview/llpanelface.cpp | 16 +++++++++++++++- indra/newview/llpanelface.h | 1 + .../newview/skins/default/xui/en/panel_tools_texture.xml | 14 +++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 71657239a6..c34010ce43 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -157,6 +157,7 @@ BOOL LLPanelFace::postBuild() childSetAction("button align",&LLPanelFace::onClickAutoFix,this); childSetAction("button align textures", &LLPanelFace::onAlignTexture, this); + childSetAction("button save material", &LLPanelFace::onSaveMaterial, this); LLTextureCtrl* mTextureCtrl; LLTextureCtrl* mShinyTextureCtrl; @@ -1409,7 +1410,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLMaterialPtr material; LLSelectedTEMaterial::getCurrent(material, identical); - if (material && editable) + // QUICKHACK - enable this UI box, indiscriminatly. TODO discriminate DJH 2022-04 + childSetEnabled("button save material", true); + + if (material && editable) { LL_DEBUGS("Materials") << material->asLLSD() << LL_ENDL; @@ -2538,6 +2542,16 @@ void LLPanelFace::onAlignTexture(void* userdata) self->alignTestureLayer(); } +void LLPanelFace::onSaveMaterial(void* userdata) +{ + LLPanelFace* self = (LLPanelFace*)userdata; + + // DRTVWR-559, Q&D material picker - save to inventory goes here + auto bound = self->getBoundingRect(); + self->setUseBoundingRect(self->getUseBoundingRect()); + //self->saveMaterialToInventory(); +} + // TODO: I don't know who put these in or what these are for??? void LLPanelFace::setMediaURL(const std::string& url) diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 2d57d89a44..183e5736ca 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -204,6 +204,7 @@ protected: static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo); static void onClickAutoFix(void*); static void onAlignTexture(void*); + static void onSaveMaterial(void*); static F32 valueGlow(LLViewerObject* object, S32 face); diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index 90f32ae452..9aaac7ac85 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -793,4 +793,16 @@ height="4" start_url="about:blank" decouple_texture_size="true" /> - + - - - - - - - - - - - - - diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 8d7cfe1116..85c20268d0 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2438,20 +2438,6 @@ function="World.EnvPreset" function="Advanced.ToggleConsole" parameter="scene monitor" /> - - - - - - Date: Tue, 31 May 2022 16:54:05 -0500 Subject: SL-17484 Fix for unit tests. Deprecate non-threaded LLQueuedThread and make lllfsthread threaded. --- indra/llcommon/llqueuedthread.cpp | 23 +++++++++++-------- indra/llcommon/lltimer.cpp | 7 +++++- indra/llfilesystem/lllfsthread.cpp | 4 ++-- indra/llimage/llimageworker.cpp | 8 ------- indra/llimage/llimageworker.h | 3 --- indra/llimage/tests/llimageworker_test.cpp | 25 --------------------- .../llmessage/tests/llcoproceduremanager_test.cpp | 2 +- indra/newview/llappviewer.cpp | 26 +++++++++++++--------- 8 files changed, 38 insertions(+), 60 deletions(-) diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 871c42f7ee..60304fff75 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -37,12 +37,13 @@ // MAIN THREAD LLQueuedThread::LLQueuedThread(const std::string& name, bool threaded, bool should_pause) : LLThread(name), - mThreaded(threaded), mIdleThread(TRUE), mNextHandle(0), mStarted(FALSE), + mThreaded(threaded), mRequestQueue(name, 1024 * 1024) { + llassert(threaded); // not threaded implementation is deprecated mMainQueue = LL::WorkQueue::getInstance("mainloop"); if (mThreaded) @@ -138,14 +139,18 @@ S32 LLQueuedThread::updateQueue(F32 max_time_ms) if (mThreaded) { // schedule a call to threadedUpdate for every call to updateQueue - mRequestQueue.post([=]() - { - LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update"); - mIdleThread = FALSE; - threadedUpdate(); - mIdleThread = TRUE; - } - ); + if (!isQuitting()) + { + mRequestQueue.post([=]() + { + LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update"); + mIdleThread = FALSE; + threadedUpdate(); + mIdleThread = TRUE; + } + ); + } + if(getPending() > 0) { unpause(); diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 466f98f9b2..39dfee3755 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -68,7 +68,12 @@ LLTimer* LLTimer::sTimer = NULL; void ms_sleep(U32 ms) { LL_PROFILE_ZONE_SCOPED; - std::this_thread::sleep_for(std::chrono::microseconds(ms)); + using TimePoint = std::chrono::steady_clock::time_point; + auto resume_time = TimePoint::clock::now() + std::chrono::milliseconds(ms); + while (TimePoint::clock::now() < resume_time) + { + std::this_thread::yield(); //note: don't use LLThread::yield here to avoid yielding for too long + } } U32 micro_sleep(U64 us, U32 max_yields) diff --git a/indra/llfilesystem/lllfsthread.cpp b/indra/llfilesystem/lllfsthread.cpp index 944e981ecf..dbb69cd605 100644 --- a/indra/llfilesystem/lllfsthread.cpp +++ b/indra/llfilesystem/lllfsthread.cpp @@ -45,8 +45,7 @@ void LLLFSThread::initClass(bool local_is_threaded) //static S32 LLLFSThread::updateClass(U32 ms_elapsed) { - sLocal->update((F32)ms_elapsed); - return sLocal->getPending(); + return sLocal->update((F32)ms_elapsed); } //static @@ -58,6 +57,7 @@ void LLLFSThread::cleanupClass() { sLocal->update(0); } + sLocal->shutdown(); delete sLocal; sLocal = NULL; } diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp index 1aace5f3e8..d8503396d7 100644 --- a/indra/llimage/llimageworker.cpp +++ b/indra/llimage/llimageworker.cpp @@ -68,14 +68,6 @@ LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLImageFormatted* return handle; } -// Used by unit test only -// Returns the size of the mutex guarded list as an indication of sanity -S32 LLImageDecodeThread::tut_size() -{ - LLMutexLock lock(mCreationMutex); - return 0; -} - LLImageDecodeThread::Responder::~Responder() { } diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h index 4619ddd6a2..e0a94d2841 100644 --- a/indra/llimage/llimageworker.h +++ b/indra/llimage/llimageworker.h @@ -80,9 +80,6 @@ public: Responder* responder); S32 update(F32 max_time_ms); - // Used by unit tests to check the consistency of the thread instance - S32 tut_size(); - private: struct creation_info { diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index 462dde9fb8..57d922b1a1 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -190,35 +190,10 @@ namespace tut template<> template<> void imagedecodethread_object_t::test<1>() - { - // Test a *non threaded* instance of the class - mThread = new LLImageDecodeThread(false); - ensure("LLImageDecodeThread: non threaded constructor failed", mThread != NULL); - // Test that we start with an empty list right at creation - ensure("LLImageDecodeThread: non threaded init state incorrect", mThread->tut_size() == 0); - // Insert something in the queue - bool done = false; - LLImageDecodeThread::handle_t decodeHandle = mThread->decodeImage(NULL, 0, FALSE, new responder_test(&done)); - // Verifies we got a valid handle - ensure("LLImageDecodeThread: non threaded decodeImage(), returned handle is null", decodeHandle != 0); - // Verifies that we do now have something in the queued list - ensure("LLImageDecodeThread: non threaded decodeImage() insertion in threaded list failed", mThread->tut_size() == 1); - // Trigger queue handling "manually" (on a threaded instance, this is done on the thread loop) - S32 res = mThread->update(0); - // Verifies that we successfully handled the list - ensure("LLImageDecodeThread: non threaded update() list handling test failed", res == 0); - // Verifies that the list is now empty - ensure("LLImageDecodeThread: non threaded update() list emptying test failed", mThread->tut_size() == 0); - } - - template<> template<> - void imagedecodethread_object_t::test<2>() { // Test a *threaded* instance of the class mThread = new LLImageDecodeThread(true); ensure("LLImageDecodeThread: threaded constructor failed", mThread != NULL); - // Test that we start with an empty list right at creation - ensure("LLImageDecodeThread: threaded init state incorrect", mThread->tut_size() == 0); // Insert something in the queue bool done = false; LLImageDecodeThread::handle_t decodeHandle = mThread->decodeImage(NULL, 0, FALSE, new responder_test(&done)); diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index 6424117ef3..78424a28c8 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -48,7 +48,7 @@ #pragma warning(disable: 4702) #endif -LLCoreHttpUtil::HttpCoroutineAdapter::HttpCoroutineAdapter(std::string const&, unsigned int, unsigned int) +LLCoreHttpUtil::HttpCoroutineAdapter::HttpCoroutineAdapter(std::string const&, unsigned int) { } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index a172308d2a..d7ed2bb4df 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1680,16 +1680,20 @@ S32 LLAppViewer::updateTextureThreads(F32 max_time) void LLAppViewer::flushLFSIO() { - while (1) - { - S32 pending = LLLFSThread::updateClass(0); - if (!pending) - { - break; - } - LL_INFOS() << "Waiting for pending IO to finish: " << pending << LL_ENDL; - ms_sleep(100); - } + S32 pending = LLLFSThread::updateClass(0); + if (pending > 0) + { + LL_INFOS() << "Waiting for pending IO to finish: " << pending << LL_ENDL; + while (1) + { + pending = LLLFSThread::updateClass(0); + if (!pending) + { + break; + } + ms_sleep(100); + } + } } bool LLAppViewer::cleanup() @@ -2187,7 +2191,7 @@ bool LLAppViewer::initThreads() LLImage::initClass(gSavedSettings.getBOOL("TextureNewByteRange"),gSavedSettings.getS32("TextureReverseByteRange")); - LLLFSThread::initClass(enable_threads && false); + LLLFSThread::initClass(enable_threads && true); // TODO: fix crashes associated with this shutdo // Image decoding LLAppViewer::sImageDecodeThread = new LLImageDecodeThread(enable_threads && true); -- cgit v1.2.3 From 609476e607b18d303afa5f5b5eeabeca84f95d16 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 1 Jun 2022 09:25:16 -0500 Subject: SL-17484 More unit test pruning. Fix for crash when deleting textures. --- indra/llcommon/llqueuedthread.cpp | 5 +++++ indra/llimage/tests/llimageworker_test.cpp | 6 ------ indra/newview/llviewertexturelist.cpp | 6 +++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 60304fff75..155e32ebae 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -75,6 +75,11 @@ void LLQueuedThread::shutdown() unpause(); // MAIN THREAD if (mThreaded) { + if (mRequestQueue.size() == 0) + { + mRequestQueue.close(); + } + S32 timeout = 100; for ( ; timeout>0; timeout--) { diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index 57d922b1a1..d36d35aba4 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -199,12 +199,6 @@ namespace tut LLImageDecodeThread::handle_t decodeHandle = mThread->decodeImage(NULL, 0, FALSE, new responder_test(&done)); // Verifies we get back a valid handle ensure("LLImageDecodeThread: threaded decodeImage(), returned handle is null", decodeHandle != 0); - // Wait a little so to simulate the main thread doing something on its main loop... - ms_sleep(500); // 500 milliseconds - // Verifies that the responder has *not* been called yet in the meantime - ensure("LLImageDecodeThread: responder creation failed", done == false); - // Ask the thread to update: that means tells the queue to check itself and creates work requests - mThread->update(1); // Wait till the thread has time to handle the work order (though it doesn't do much per work order...) const U32 INCREMENT_TIME = 500; // 500 milliseconds const U32 MAX_TIME = 20 * INCREMENT_TIME; // Do the loop 20 times max, i.e. wait 10 seconds but no more diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 555355059a..ac036bce31 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1048,7 +1048,11 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) { iter = mUUIDMap.begin(); } - entries.push_back(iter->second); + + if (iter->second->getGLTexture()) + { + entries.push_back(iter->second); + } ++iter; } } -- cgit v1.2.3 From 4261cbba783359e71b691d6e0e9477ce53f60251 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 1 Jun 2022 10:34:33 -0500 Subject: SL-17485 Add texture memory accounting for OS X --- indra/llrender/llimagegl.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++ indra/llrender/llimagegl.h | 6 ++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 04974d9122..46f0e1d69e 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -53,6 +53,88 @@ const F32 MIN_TEXTURE_LIFETIME = 10.f; //assumes i is a power of 2 > 0 U32 wpo2(U32 i); + +#if LL_DARWIN +// texture memory accounting (for OS X) +static LLMutex sTexMemMutex; +static std::unordered_map sTextureAllocs; +static U64 sTextureBytes = 0; + +// track a texture alloc on the currently bound texture. +// asserts that no currently tracked alloc exists +static void alloc_tex_image(U32 width, U32 height, U32 pixformat) +{ + U32 texUnit = gGL.getCurrentTexUnitIndex(); + U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture(); + S32 size = LLImageGL::dataFormatBytes(pixformat, width, height); + + llassert(size >= 0); + + sTexMemMutex.lock(); + llassert(sTextureAllocs.find(texName) == sTextureAllocs.end()); + + sTextureAllocs[texName] = size; + sTextureBytes += size; + + sTexMemMutex.unlock(); +} + +// track texture free on given texName +static void free_tex_image(U32 texName) +{ + sTexMemMutex.lock(); + auto iter = sTextureAllocs.find(texName); + if (iter != sTextureAllocs.end()) + { + llassert(iter->second <= sTextureBytes); // sTextureBytes MUST NOT go below zero + + sTextureBytes -= iter->second; + + sTextureAllocs.erase(iter); + } + + sTexMemMutex.unlock(); +} + +// track texture free on given texNames +static void free_tex_images(U32 count, const U32* texNames) +{ + for (int i = 0; i < count; ++i) + { + free_tex_image(texNames[i]); + } +} + +// track texture free on currently bound texture +static void free_cur_tex_image() +{ + U32 texUnit = gGL.getCurrentTexUnitIndex(); + U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture(); + free_tex_image(texName); +} + +// static +U64 LLImageGL::getTextureBytesAllocated() +{ + return sTextureBytes; +} + +#else + +#define alloc_tex_image(width, height, pixformat) (void) width; (void) height; (void) pixformat; +#define free_tex_image(texName) (void) texName; +#define free_tex_images(count, texNames) (void) count; (void) texNames; +#define free_cur_tex_image() + +// static +U64 LLImageGL::getTextureBytesAllocated() +{ + // UNIMPLEMENTED OUTSIDE OF OS X, DO NOT CALL + llassert(false); + return 0; +} +#endif + //statics U32 LLImageGL::sUniqueCount = 0; @@ -217,6 +299,7 @@ S32 LLImageGL::dataFormatBits(S32 dataformat) case GL_RGBA: return 32; case GL_SRGB_ALPHA: return 32; case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac + case GL_DEPTH_COMPONENT: return 24; default: LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL; return 0; @@ -1218,6 +1301,7 @@ void LLImageGL::deleteTextures(S32 numTextures, const U32 *textures) { if (gGLManager.mInited) { + free_tex_images(numTextures, textures); glDeleteTextures(numTextures, textures); } } @@ -1340,7 +1424,10 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt stop_glerror(); { LL_PROFILE_ZONE_NAMED("glTexImage2D"); + + free_cur_tex_image(); glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, use_scratch ? scratch : pixels); + alloc_tex_image(width, height, pixformat); } stop_glerror(); diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 1716338c0b..619421e68a 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -52,6 +52,10 @@ class LLImageGL : public LLRefCount { friend class LLTexUnit; public: + + // For OS X use only -- get an estimate of how many bytes have been allocated in vram for textures + static U64 getTextureBytesAllocated(); + // These 2 functions replace glGenTextures() and glDeleteTextures() static void generateTextures(S32 numTextures, U32 *textures); static void deleteTextures(S32 numTextures, const U32 *textures); @@ -162,7 +166,7 @@ public: void updatePickMask(S32 width, S32 height, const U8* data_in); BOOL getMask(const LLVector2 &tc); - void checkTexSize(bool forced = false) const ; + void checkTexSize(bool forced = false) const ; // Sets the addressing mode used to sample the texture // (such as wrapping, mirrored wrapping, and clamp) -- cgit v1.2.3 From f4473528eb3f37b4bec3c4cda2a83d9ca94ab133 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 1 Jun 2022 11:31:45 -0500 Subject: SL-17485 Remove unused members to make mac build happy. --- indra/newview/lltexturefetch.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index d811b32f4f..64ccbf5e4a 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -552,8 +552,6 @@ private: S32 mRequestedDiscard; S32 mLoadedDiscard; S32 mDecodedDiscard; - S32 mFullWidth; - S32 mFullHeight; LLFrameTimer mRequestedDeltaTimer; LLFrameTimer mFetchDeltaTimer; LLTimer mCacheReadTimer; -- cgit v1.2.3 From 220afbcda0961df86ad08bbd51d96b8c868b2e62 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 2 Jun 2022 18:42:38 -0500 Subject: SL-17285 Add proper reflection probe support to LLVOVolume, LLPrimitive, and LLPanelVolume --- indra/llprimitive/llprimitive.cpp | 95 +++++++++++++ indra/llprimitive/llprimitive.h | 44 ++++++ .../shaders/class3/deferred/reflectionProbeF.glsl | 21 ++- indra/newview/llpanelvolume.cpp | 100 +++++++++++++ indra/newview/llpanelvolume.h | 3 + indra/newview/llreflectionmap.cpp | 51 ++++--- indra/newview/llreflectionmap.h | 10 +- indra/newview/llreflectionmapmanager.cpp | 25 ++-- indra/newview/lltexturefetch.cpp | 1 + indra/newview/llviewerdisplay.cpp | 1 - indra/newview/llviewerobject.cpp | 5 + indra/newview/llviewerwindow.cpp | 3 +- indra/newview/llviewerwindow.h | 4 +- indra/newview/llvovolume.cpp | 157 ++++++++++++++++++--- indra/newview/llvovolume.h | 14 ++ .../newview/skins/default/xui/en/floater_tools.xml | 58 +++++++- 16 files changed, 519 insertions(+), 73 deletions(-) diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index c46e5fb3c5..87a78eb447 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -81,6 +81,14 @@ const F32 LIGHT_MIN_CUTOFF = 0.0f; const F32 LIGHT_DEFAULT_CUTOFF = 0.0f; const F32 LIGHT_MAX_CUTOFF = 180.f; +// reflection probes +const F32 REFLECTION_PROBE_MIN_AMBIANCE = 0.f; +const F32 REFLECTION_PROBE_MAX_AMBIANCE = 1.f; +const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE = 0.f; +const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE = 0.f; +const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE = 1024.f; +const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE = 0.f; + // "Tension" => [0,10], increments of 0.1 const F32 FLEXIBLE_OBJECT_MIN_TENSION = 0.0f; const F32 FLEXIBLE_OBJECT_DEFAULT_TENSION = 1.0f; @@ -1811,6 +1819,93 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ +LLReflectionProbeParams::LLReflectionProbeParams() +{ + mType = PARAMS_REFLECTION_PROBE; +} + +BOOL LLReflectionProbeParams::pack(LLDataPacker& dp) const +{ + dp.packF32(mAmbiance, "ambiance"); + dp.packF32(mClipDistance, "clip_distance"); + dp.packU8(mVolumeType, "volume_type"); + return TRUE; +} + +BOOL LLReflectionProbeParams::unpack(LLDataPacker& dp) +{ + F32 ambiance; + F32 clip_distance; + U8 volume_type; + + dp.unpackF32(ambiance, "ambiance"); + setAmbiance(ambiance); + + dp.unpackF32(clip_distance, "clip_distance"); + setClipDistance(clip_distance); + + dp.unpackU8(volume_type, "volume_type"); + setVolumeType((EInfluenceVolumeType)volume_type); + + return TRUE; +} + +bool LLReflectionProbeParams::operator==(const LLNetworkData& data) const +{ + if (data.mType != PARAMS_REFLECTION_PROBE) + { + return false; + } + const LLReflectionProbeParams* param = (const LLReflectionProbeParams*)&data; + if (param->mAmbiance != mAmbiance) + { + return false; + } + if (param->mClipDistance != mClipDistance) + { + return false; + } + if (param->mVolumeType != mVolumeType) + { + return false; + } + return true; +} + +void LLReflectionProbeParams::copy(const LLNetworkData& data) +{ + const LLReflectionProbeParams* param = (LLReflectionProbeParams*)&data; + mType = param->mType; + mAmbiance = param->mAmbiance; + mClipDistance = param->mClipDistance; + mVolumeType = param->mVolumeType; +} + +LLSD LLReflectionProbeParams::asLLSD() const +{ + LLSD sd; + sd["ambiance"] = getAmbiance(); + sd["clip_distance"] = getClipDistance(); + sd["volume_type"] = getVolumeType(); + return sd; +} + +bool LLReflectionProbeParams::fromLLSD(LLSD& sd) +{ + if (!sd.has("ambiance") || + !sd.has("clip_distance") || + !sd.has("volume_type")) + { + return false; + } + + setAmbiance((F32)sd["ambiance"].asReal()); + setClipDistance((F32)sd["clip_distance"].asReal()); + setVolumeType((EInfluenceVolumeType)sd["volume_type"].asInteger()); + + return true; +} +//============================================================================ LLFlexibleObjectData::LLFlexibleObjectData() { mSimulateLOD = FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS; diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index e23ddd2916..2215133e16 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -108,6 +108,7 @@ public: PARAMS_MESH = 0x60, PARAMS_EXTENDED_MESH = 0x70, PARAMS_RENDER_MATERIAL = 0x80, + PARAMS_REFLECTION_PROBE = 0x90, }; public: @@ -171,6 +172,49 @@ public: F32 getCutoff() const { return mCutoff; } }; +extern const F32 REFLECTION_PROBE_MIN_AMBIANCE; +extern const F32 REFLECTION_PROBE_MAX_AMBIANCE; +extern const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE; +extern const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE; +extern const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE; +extern const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; + +class LLReflectionProbeParams : public LLNetworkData +{ +public: + enum EInfluenceVolumeType : U8 + { + VOLUME_TYPE_SPHERE = 0, // use a sphere influence volume + VOLUME_TYPE_BOX = 1, // use a box influence volume + DEFAULT_VOLUME_TYPE = VOLUME_TYPE_SPHERE + }; + +protected: + F32 mAmbiance = REFLECTION_PROBE_DEFAULT_AMBIANCE; + F32 mClipDistance = REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; + EInfluenceVolumeType mVolumeType = DEFAULT_VOLUME_TYPE; + +public: + LLReflectionProbeParams(); + /*virtual*/ BOOL pack(LLDataPacker& dp) const; + /*virtual*/ BOOL unpack(LLDataPacker& dp); + /*virtual*/ bool operator==(const LLNetworkData& data) const; + /*virtual*/ void copy(const LLNetworkData& data); + // LLSD implementations here are provided by Eddy Stryker. + // NOTE: there are currently unused in protocols + LLSD asLLSD() const; + operator LLSD() const { return asLLSD(); } + bool fromLLSD(LLSD& sd); + + void setAmbiance(F32 ambiance) { mAmbiance = llclamp(ambiance, REFLECTION_PROBE_MIN_AMBIANCE, REFLECTION_PROBE_MAX_AMBIANCE); } + void setClipDistance(F32 distance) { mClipDistance = llclamp(distance, REFLECTION_PROBE_MIN_CLIP_DISTANCE, REFLECTION_PROBE_MAX_CLIP_DISTANCE); } + void setVolumeType(EInfluenceVolumeType type) { mVolumeType = llclamp(type, VOLUME_TYPE_SPHERE, VOLUME_TYPE_BOX); } + + F32 getAmbiance() const { return mAmbiance; } + F32 getClipDistance() const { return mClipDistance; } + EInfluenceVolumeType getVolumeType() const { return mVolumeType; } +}; + //------------------------------------------------- // This structure is also used in the part of the // code that creates new flexible objects. diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 8c1323ba1a..eb9d3f485b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -1,5 +1,5 @@ /** - * @file class2/deferred/reflectionProbeF.glsl + * @file class3/deferred/reflectionProbeF.glsl * * $LicenseInfo:firstyear=2022&license=viewerlgpl$ * Second Life Viewer Source Code @@ -42,6 +42,8 @@ layout (std140, binding = 1) uniform ReflectionProbes mat4 refBox[REFMAP_COUNT]; // list of bounding spheres for reflection probes sorted by distance to camera (closest first) vec4 refSphere[REFMAP_COUNT]; + // extra parameters (currently only .x used for probe ambiance) + vec4 refParams[REFMAP_COUNT]; // index of cube map in reflectionProbes for a corresponding reflection probe // e.g. cube map channel of refSphere[2] is stored in refIndex[2] // refIndex.x - cubemap channel in reflectionProbes @@ -55,9 +57,6 @@ layout (std140, binding = 1) uniform ReflectionProbes // number of reflection probes present in refSphere int refmapCount; - - // intensity of ambient light from reflection probes - float reflectionAmbiance; }; // Inputs @@ -335,7 +334,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, float lod, vec3 c, float r2, int i) } } -vec3 sampleProbes(vec3 pos, vec3 dir, float lod) +vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) { float wsum = 0.0; vec3 col = vec3(0,0,0); @@ -360,7 +359,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); w *= atten; w *= p; // boost weight based on priority - col += refcol*w; + col += refcol*w*max(minweight, refParams[i].x); wsum += w; } @@ -383,7 +382,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) float w = 1.0/d2; w *= w; - col += refcol*w; + col += refcol*w*max(minweight, refParams[i].x); wsum += w; } } @@ -399,7 +398,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) vec3 sampleProbeAmbient(vec3 pos, vec3 dir, float lod) { - vec3 col = sampleProbes(pos, dir, lod); + vec3 col = sampleProbes(pos, dir, lod, 0.f); //desaturate vec3 hcol = col *0.5; @@ -413,7 +412,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, float lod) col *= 0.333333; - return col*reflectionAmbiance; + return col; } @@ -445,12 +444,12 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 l if (glossiness > 0.0) { float lod = (1.0-glossiness)*reflection_lods; - glossenv = sampleProbes(pos, normalize(refnormpersp), lod); + glossenv = sampleProbes(pos, normalize(refnormpersp), lod, 1.f); } if (envIntensity > 0.0) { - legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0); + legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0, 1.f); } } diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 89c558e4f8..e7bbe266e5 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -145,6 +145,16 @@ BOOL LLPanelVolume::postBuild() getChild("Light Ambiance")->setValidateBeforeCommit( precommitValidate); } + // REFLECTION PROBE Parameters + { + childSetCommitCallback("Reflection Probe Checkbox Ctrl", onCommitIsReflectionProbe, this); + childSetCommitCallback("Probe Shape Type Combo Ctrl", onCommitProbe, this); + childSetCommitCallback("Probe Ambiance", onCommitProbe, this); + childSetCommitCallback("Probe Near Clip", onCommitProbe, this); + + + } + // PHYSICS Parameters { // PhysicsShapeType combobox @@ -360,6 +370,40 @@ void LLPanelVolume::getState( ) getChildView("Light Ambiance")->setEnabled(false); } + // Reflection Probe + BOOL is_probe = volobjp && volobjp->getIsReflectionProbe(); + getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); + getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); + + bool probe_enabled = is_probe && editable && single_volume; + + getChildView("Probe Volume Type Ctrl")->setEnabled(probe_enabled); + getChildView("Probe Ambiance")->setEnabled(probe_enabled); + getChildView("Probe Near Clip")->setEnabled(probe_enabled); + + if (!probe_enabled) + { + getChild("Probe Volume Type Ctrl", true)->clear(); + getChild("Probe Ambiance", true)->clear(); + getChild("Probe Near Clip", true)->clear(); + } + else + { + std::string volume_type; + if (volobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + { + volume_type = "Box"; + } + else + { + volume_type = "Sphere"; + } + + getChild("Probe Volume Type Ctrl", true)->setValue(volume_type); + getChild("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); + getChild("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); + } + // Animated Mesh BOOL is_animated_mesh = single_root_volume && root_volobjp && root_volobjp->isAnimatedObject(); getChild("Animated Mesh Checkbox Ctrl")->setValue(is_animated_mesh); @@ -647,6 +691,10 @@ void LLPanelVolume::clearCtrls() getChildView("Light Radius")->setEnabled(false); getChildView("Light Falloff")->setEnabled(false); + getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(false);; + getChildView("Probe Volume Type Ctrl")->setEnabled(false); + getChildView("Probe Ambiance")->setEnabled(false); + getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); getChildView("Flexible1D Checkbox Ctrl")->setEnabled(false); getChildView("FlexNumSections")->setEnabled(false); @@ -684,6 +732,20 @@ void LLPanelVolume::sendIsLight() LL_INFOS() << "update light sent" << LL_ENDL; } +void LLPanelVolume::sendIsReflectionProbe() +{ + LLViewerObject* objectp = mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume* volobjp = (LLVOVolume*)objectp; + + BOOL value = getChild("Reflection Probe Checkbox Ctrl")->getValue(); + volobjp->setIsReflectionProbe(value); + LL_INFOS() << "update reflection probe sent" << LL_ENDL; +} + void LLPanelVolume::sendIsFlexible() { LLViewerObject* objectp = mObject; @@ -927,6 +989,35 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata ) } +//static +void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) +{ + LLPanelVolume* self = (LLPanelVolume*)userdata; + LLViewerObject* objectp = self->mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume* volobjp = (LLVOVolume*)objectp; + + + volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); + volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); + + std::string shape_type = self->getChild("Probe Volume Type Ctrl")->getValue().asString(); + LLReflectionProbeParams::EInfluenceVolumeType volume_type = LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + + if (shape_type == "Sphere") + { + volume_type = LLReflectionProbeParams::VOLUME_TYPE_SPHERE; + } + else if (shape_type == "Box") + { + volume_type = LLReflectionProbeParams::VOLUME_TYPE_BOX; + } + volobjp->setReflectionProbeVolumeType(volume_type); +} + // static void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata ) { @@ -949,6 +1040,15 @@ void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item } //---------------------------------------------------------------------------- +// static +void LLPanelVolume::onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata) +{ + LLPanelVolume* self = (LLPanelVolume*)userdata; + self->sendIsReflectionProbe(); +} + +//---------------------------------------------------------------------------- + // static void LLPanelVolume::onCommitFlexible( LLUICtrl* ctrl, void* userdata ) { diff --git a/indra/newview/llpanelvolume.h b/indra/newview/llpanelvolume.h index 6e49ccb742..16d9ac292d 100644 --- a/indra/newview/llpanelvolume.h +++ b/indra/newview/llpanelvolume.h @@ -56,12 +56,15 @@ public: void refresh(); void sendIsLight(); + void sendIsReflectionProbe(); void sendIsFlexible(); static bool precommitValidate(const LLSD& data); static void onCommitIsLight( LLUICtrl* ctrl, void* userdata); static void onCommitLight( LLUICtrl* ctrl, void* userdata); + static void onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata); + static void onCommitProbe(LLUICtrl* ctrl, void* userdata); void onCommitIsFlexible( LLUICtrl* ctrl, void* userdata); static void onCommitFlexible( LLUICtrl* ctrl, void* userdata); void onCommitAnimatedMeshCheckbox(LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 54a627efd4..f8a2020ccb 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -35,7 +35,6 @@ extern F32SecondsImplicit gFrameTimeSeconds; LLReflectionMap::LLReflectionMap() { - mLastUpdateTime = gFrameTimeSeconds; } void LLReflectionMap::update(U32 resolution, U32 face) @@ -52,7 +51,7 @@ void LLReflectionMap::update(U32 resolution, U32 face) { resolution /= 2; } - gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face); + gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip()); } bool LLReflectionMap::shouldUpdate() @@ -215,6 +214,35 @@ bool LLReflectionMap::intersects(LLReflectionMap* other) return dist < r2; } +extern LLControlGroup gSavedSettings; + +F32 LLReflectionMap::getAmbiance() +{ + static LLCachedControl minimum_ambiance(gSavedSettings, "RenderReflectionProbeAmbiance", 0.f); + + F32 ret = 0.f; + if (mViewerObject && mViewerObject->getVolume()) + { + ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeAmbiance(); + } + + return llmax(ret, minimum_ambiance()); +} + +F32 LLReflectionMap::getNearClip() +{ + const F32 MINIMUM_NEAR_CLIP = 0.1f; + + F32 ret = 0.f; + + if (mViewerObject && mViewerObject->getVolume()) + { + ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeNearClip(); + } + + return llmax(ret, MINIMUM_NEAR_CLIP); +} + bool LLReflectionMap::getBox(LLMatrix4& box) { if (mViewerObject) @@ -224,25 +252,8 @@ bool LLReflectionMap::getBox(LLMatrix4& box) { LLVOVolume* vobjp = (LLVOVolume*)mViewerObject; - U8 profile = volume->getProfileType(); - U8 path = volume->getPathType(); - - if (profile == LL_PCODE_PROFILE_SQUARE && - path == LL_PCODE_PATH_LINE) + if (vobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) { - // nope - /*box = vobjp->getRelativeXform(); - box *= vobjp->mDrawable->getRenderMatrix(); - LLMatrix4 modelview(gGLModelView); - box *= modelview; - box.invert();*/ - - // nope - /*box = LLMatrix4(gGLModelView); - box *= vobjp->mDrawable->getRenderMatrix(); - box *= vobjp->getRelativeXform(); - box.invert();*/ - glh::matrix4f mv(gGLModelView); glh::matrix4f scale; LLVector3 s = vobjp->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f)); diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 4f0f124118..a358bf5fdf 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -55,9 +55,15 @@ public: // return true if given Reflection Map's influence volume intersect's with this one's bool intersects(LLReflectionMap* other); + // Get the ambiance value to use for this probe + F32 getAmbiance(); + + // Get the near clip plane distance to use for this probe + F32 getNearClip(); + // get the encoded bounding box of this probe's influence volume - // will only return a box if this probe has a volume with a square - // profile and a linear path + // will only return a box if this probe is associated with a VOVolume + // with its reflection probe influence volume to to VOLUME_TYPE_BOX // return false if no bounding box (treat as sphere influence volume) bool getBox(LLMatrix4& box); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 34055653d4..60396b6c60 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -127,18 +127,12 @@ void LLReflectionMapManager::update() camera_pos.load3(LLViewerCamera::instance().getOrigin().mV); // process kill list - for (int i = 0; i < mProbes.size(); ) + for (auto& probe : mKillList) { - auto& iter = std::find(mKillList.begin(), mKillList.end(), mProbes[i]); - if (iter != mKillList.end()) + auto& iter = std::find(mProbes.begin(), mProbes.end(), probe); + if (iter != mProbes.end()) { - deleteProbe(i); - mProbes.erase(mProbes.begin() + i); - mKillList.erase(iter); - } - else - { - ++i; + deleteProbe(iter - mProbes.begin()); } } @@ -275,7 +269,7 @@ LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* gr { OctreeNode* node = group->getOctreeNode(); F32 size = node->getSize().getF32ptr()[0]; - if (size >= 7.f && size <= 17.f) + if (size >= 15.f && size <= 17.f) { return addProbe(group); } @@ -514,15 +508,15 @@ void LLReflectionMapManager::updateUniforms() LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; // structure for packing uniform buffer object - // see class2/deferred/softenLightF.glsl + // see class3/deferred/reflectionProbeF.glsl struct ReflectionProbeData { LLMatrix4 refBox[LL_REFLECTION_PROBE_COUNT]; // object bounding box as needed LLVector4 refSphere[LL_REFLECTION_PROBE_COUNT]; //origin and radius of refmaps in clip space + LLVector4 refParams[LL_REFLECTION_PROBE_COUNT]; //extra parameters (currently only ambiance) GLint refIndex[LL_REFLECTION_PROBE_COUNT][4]; GLint refNeighbor[4096]; GLint refmapCount; - GLfloat reflectionAmbiance; }; mReflectionMaps.resize(LL_REFLECTION_PROBE_COUNT); @@ -530,9 +524,6 @@ void LLReflectionMapManager::updateUniforms() ReflectionProbeData rpd; - static LLCachedControl ambiance(gSavedSettings, "RenderReflectionProbeAmbiance", 0.f); - rpd.reflectionAmbiance = ambiance; - // load modelview matrix into matrix 4a LLMatrix4a modelview; modelview.loadu(gGLModelView); @@ -573,6 +564,8 @@ void LLReflectionMapManager::updateUniforms() rpd.refIndex[count][3] = -rpd.refIndex[count][3]; } + rpd.refParams[count].set(refmap->getAmbiance(), 0.f, 0.f, 0.f); + S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors { //LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - refNeighbors"); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 0edaf40c66..35e4bb03ac 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -3400,6 +3400,7 @@ void LLTextureFetch::sendRequestListToSimulators() gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); } S32 packet = req->mLastPacket + 1; + LL_INFOS() << req->mID << ": " << req->mImagePriority << LL_ENDL; gMessageSystem->nextBlockFast(_PREHASH_RequestImage); gMessageSystem->addUUIDFast(_PREHASH_Image, req->mID); gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, (S8)req->mDesiredDiscard); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 1b8e53e667..6d98d9b10e 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1082,7 +1082,6 @@ void display_cube_face() gPipeline.mBackfaceCull = TRUE; - LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); gViewerWindow->setup3DViewport(); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 6ecf9dd0c4..732beab448 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -6028,6 +6028,11 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para { new_block = new LLRenderMaterialParams(); break; + } + case LLNetworkData::PARAMS_REFLECTION_PROBE: + { + new_block = new LLReflectionProbeParams(); + break; } default: { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index a6597e3233..6a60671040 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5270,7 +5270,7 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ void display_cube_face(); -BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face) +BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip) { // NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; @@ -5299,6 +5299,7 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea camera->setView(F_PI_BY_TWO); camera->yaw(0.0); camera->setOrigin(origin); + camera->setNear(near_clip); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index ac7f8b2e39..c9cf7da8c7 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -368,7 +368,9 @@ public: // origin - vantage point to take the snapshot from // cubearray - cubemap array for storing the results // index - cube index in the array to use (cube index, not face-layer) - BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face); + // face - which cube face to update + // near_clip - near clip setting to use + BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip); // special implementation of simpleSnapshot for reflection maps diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 784c0350fc..6aef9ee7c0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -985,7 +985,12 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) // Add it to the pipeline mLightSet gPipeline.setLight(mDrawable, TRUE); } - + + if (getIsReflectionProbe()) + { + updateReflectionProbePtr(); + } + updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away mDrawable->updateDistance(*LLViewerCamera::getInstance(), force_update); @@ -3496,6 +3501,121 @@ F32 LLVOVolume::getLightCutoff() const } } +void LLVOVolume::setIsReflectionProbe(BOOL is_probe) +{ + BOOL was_probe = getIsReflectionProbe(); + if (is_probe != was_probe) + { + if (is_probe) + { + setParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE, TRUE, true); + } + else + { + setParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE, FALSE, true); + } + } + + updateReflectionProbePtr(); +} + +void LLVOVolume::setReflectionProbeAmbiance(F32 ambiance) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getAmbiance() != ambiance) + { + param_block->setAmbiance(ambiance); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeNearClip(F32 near_clip) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getClipDistance() != near_clip) + { + param_block->setClipDistance(near_clip); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getVolumeType() != volume_type) + { + param_block->setVolumeType(volume_type); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + + +BOOL LLVOVolume::getIsReflectionProbe() const +{ + // HACK - make this object a Reflection Probe if a certain UUID is detected + static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); + LLUUID probe_id(reflection_probe_id); + + for (U8 i = 0; i < getNumTEs(); ++i) + { + if (getTE(i)->getID() == probe_id) + { + return true; + } + } + // END HACK + + return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); +} + +F32 LLVOVolume::getReflectionProbeAmbiance() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getAmbiance(); + } + else + { + return 0.f; + } +} + +F32 LLVOVolume::getReflectionProbeNearClip() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getClipDistance(); + } + else + { + return 0.f; + } +} + +LLReflectionProbeParams::EInfluenceVolumeType LLVOVolume::getReflectionProbeVolumeType() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getVolumeType(); + } + else + { + return LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + } +} + U32 LLVOVolume::getVolumeInterfaceID() const { if (mVolumeImpl) @@ -4381,6 +4501,23 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u gPipeline.setLight(mDrawable, is_light); } } + + updateReflectionProbePtr(); +} + +void LLVOVolume::updateReflectionProbePtr() +{ + if (getIsReflectionProbe()) + { + if (mReflectionProbe.isNull()) + { + mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(this); + } + } + else if (mReflectionProbe.notNull()) + { + mReflectionProbe = nullptr; + } } void LLVOVolume::setSelected(BOOL sel) @@ -5690,24 +5827,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool is_pbr = false; #endif - // HACK - make this object a Reflection Probe if a certain UUID is detected - static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); - if (facep->getTextureEntry()->getID() == LLUUID(reflection_probe_id)) - { - if (!vobj->mIsReflectionProbe) - { - vobj->mIsReflectionProbe = true; - vobj->mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(vobj); - } - } - else - { - // not a refleciton probe any more - vobj->mIsReflectionProbe = false; - vobj->mReflectionProbe = nullptr; - } - // END HACK - //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group facep->setVertexBuffer(NULL); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 4cb7a5481c..93a10781c2 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -178,6 +178,9 @@ public: /*virtual*/ void parameterChanged(U16 param_type, bool local_origin); /*virtual*/ void parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_use, bool local_origin); + // update mReflectionProbe based on isReflectionProbe() + void updateReflectionProbePtr(); + /*virtual*/ U32 processUpdateMessage(LLMessageSystem *mesgsys, void **user_data, U32 block_num, const EObjectUpdateType update_type, @@ -281,6 +284,17 @@ public: F32 getLightFalloff(const F32 fudge_factor = 1.f) const; F32 getLightCutoff() const; + // Reflection Probes + void setIsReflectionProbe(BOOL is_probe); + void setReflectionProbeAmbiance(F32 ambiance); + void setReflectionProbeNearClip(F32 near_clip); + void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); + + BOOL getIsReflectionProbe() const; + F32 getReflectionProbeAmbiance() const; + F32 getReflectionProbeNearClip() const; + LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; + // Flexible Objects U32 getVolumeInterfaceID() const; virtual BOOL isFlexible() const; diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 44bdcd86f9..ae4eb64264 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2353,7 +2353,7 @@ even though the user gets a free copy. layout="topleft" left="10" name="Light Intensity" - top_pad="3" + top_delta="32" width="128" /> - + + + + + + + Date: Fri, 3 Jun 2022 10:14:45 -0500 Subject: SL-17285 Build fix (coding policy needs last line to be blank). --- .../newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index eb9d3f485b..edb78f114b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -472,4 +472,4 @@ void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 no fresnel = min(fresnel+envIntensity, 1.0); reflected_color *= (envIntensity*fresnel)*brighten(spec.rgb); color = mix(color.rgb, reflected_color, envIntensity); - } \ No newline at end of file + } -- cgit v1.2.3 From a185fae28d7e035226d4b5f7c350f94830001b06 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 3 Jun 2022 11:36:37 -0500 Subject: SL-17285 Build fix take two. --- indra/llprimitive/llprimitive.cpp | 2 +- .../newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 87a78eb447..6044048d09 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1886,7 +1886,7 @@ LLSD LLReflectionProbeParams::asLLSD() const LLSD sd; sd["ambiance"] = getAmbiance(); sd["clip_distance"] = getClipDistance(); - sd["volume_type"] = getVolumeType(); + sd["volume_type"] = (U8) getVolumeType(); return sd; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index edb78f114b..3fd001e7f5 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -473,3 +473,4 @@ void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 no reflected_color *= (envIntensity*fresnel)*brighten(spec.rgb); color = mix(color.rgb, reflected_color, envIntensity); } + -- cgit v1.2.3 From a562f6fe51a527a66884a0919d217ebb42270cc0 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 6 Jun 2022 14:59:03 -0700 Subject: SL-17489: Improve warning message for fetching texture with improper URL --- indra/newview/lltexturefetch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 64ccbf5e4a..873c9f3519 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1348,7 +1348,7 @@ bool LLTextureFetchWorker::doWork(S32 param) { if (mFTType != FTT_DEFAULT) { - LL_WARNS(LOG_TXT) << "trying to seek a non-default texture on the sim. Bad!" << LL_ENDL; + LL_WARNS(LOG_TXT) << "Trying to fetch a texture of non-default type by UUID. This probably won't work!" << LL_ENDL; } setUrl(http_url + "/?texture_id=" + mID.asString().c_str()); LL_DEBUGS(LOG_TXT) << "Texture URL: " << mUrl << LL_ENDL; -- cgit v1.2.3 From 5259fa811c11892ef150f853c9de5a8927fa68a6 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 6 Jun 2022 21:12:48 -0500 Subject: SL-17486 Force desired discard level to 0 for high boosted textures (fix for fuzzy terrain textures etc). --- indra/newview/llviewertexture.cpp | 10 ++++++++++ indra/newview/llviewertexture.h | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 0544bceb9f..2eb36a42be 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1884,6 +1884,16 @@ bool LLViewerFetchedTexture::isActiveFetching() return mFetchState > 7 && mFetchState < 10 && monitor_enabled; //in state of WAIT_HTTP_REQ or DECODE_IMAGE. } +void LLViewerFetchedTexture::setBoostLevel(S32 level) +{ + LLViewerTexture::setBoostLevel(level); + + if (level >= LLViewerTexture::BOOST_HIGH) + { + mDesiredDiscardLevel = 0; + } +} + bool LLViewerFetchedTexture::updateFetch() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index a5e5c37c22..f3bc9061a2 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -134,7 +134,7 @@ public: /*virtual*/ bool isActiveFetching(); /*virtual*/ const LLUUID& getID() const { return mID; } - void setBoostLevel(S32 level); + virtual void setBoostLevel(S32 level); S32 getBoostLevel() { return mBoostLevel; } void setTextureListType(S32 tex_type) { mTextureListType = tex_type; } S32 getTextureListType() { return mTextureListType; } @@ -343,6 +343,7 @@ public: S32 getDesiredDiscardLevel() { return mDesiredDiscardLevel; } void setMinDiscardLevel(S32 discard) { mMinDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel,(S8)discard); } + void setBoostLevel(S32 level) override; bool updateFetch(); bool setDebugFetching(S32 debug_level); bool isInDebug() const { return mInDebug; } -- cgit v1.2.3 From 7908ae701f245f6c15602b23b2073f6c0fe3fdb8 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 7 Jun 2022 11:42:51 -0700 Subject: SL-17489: Fix map tile log spam and resulting excessive invalid texture requests. This was affecting map tiles that the agent is not allowed to see (HTTP error: 403 forbidden). The URLs of these map tile requests were then getting cleared, so when these map tiles were re-requested (up to 10 times per second, from LLViewerFetchedTexture::updateFetch), the request would use the wrong URL and get a 404. Stay in DONE state if there is no new work to do, reducing unneeded requests for textures while leaving open the possibility to re-request a texture at different resolution. Alternatively, we could introduce a new FAILED state here. The current DONE state has nuance, and can either mean "texture loading failed" or "texture successfully loaded at a certain LOD." And a 4xx error is generally irrecoverable. Will strongly consider a FAILED state. Also, don't clear the map URL, so that any future network requests for the map textures request the correct resource. --- indra/newview/lltexturefetch.cpp | 7 ++++++- indra/newview/llviewertexture.cpp | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 873c9f3519..5eeecb33f2 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1671,7 +1671,7 @@ bool LLTextureFetchWorker::doWork(S32 param) << LL_ENDL; } - if (mFTType != FTT_SERVER_BAKE) + if (mFTType != FTT_SERVER_BAKE && mFTType != FTT_MAP_TILE) { mUrl.clear(); } @@ -2695,6 +2695,11 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const return false; // need to wait for previous aborted request to complete } worker->lockWorkMutex(); // +Mw + if (worker->mState == LLTextureFetchWorker::DONE && worker->mDesiredSize == llmax(desired_size, TEXTURE_CACHE_ENTRY_SIZE) && worker->mDesiredDiscard == desired_discard) { + worker->unlockWorkMutex(); // -Mw + + return false; // similar request has failed or is in a transitional state + } worker->mActiveCount++; worker->mNeedsAux = needs_aux; worker->setImagePriority(priority); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 0544bceb9f..1deb4b5ca1 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -2192,8 +2192,11 @@ bool LLViewerFetchedTexture::updateFetch() mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP); } - // if createRequest() failed, we're finishing up a request for this UUID, - // wait for it to complete + // If createRequest() failed, that means one of two things: + // 1. We're finishing up a request for this UUID, so we + // should wait for it to complete + // 2. We've failed a request for this UUID, so there is + // no need to create another request } else if (mHasFetcher && !mIsFetching) { -- cgit v1.2.3 From 197baebc62d1e4b922730266f77f4e6b555e2cac Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Jun 2022 15:12:58 -0500 Subject: SL-17547 Fix for crash in getCurrentDiscardLevelForFetching (and add runtime check and assertion to avoid crash in production and detect crash in development). --- indra/newview/lltexturefetch.cpp | 26 ++++++++++++++------------ indra/newview/llviewertexture.cpp | 7 +++++++ indra/newview/llviewertexturelist.cpp | 11 +++++++---- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 64ccbf5e4a..2bfdfe1789 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1071,7 +1071,7 @@ void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) // Locks: Mw void LLTextureFetchWorker::setImagePriority(F32 priority) { - mImagePriority = priority; //should map to max virtual size + mImagePriority = priority; //should map to max virtual size, abort if zero } // Locks: Mw @@ -1397,7 +1397,7 @@ bool LLTextureFetchWorker::doWork(S32 param) else { // Shouldn't need to do anything here - llassert(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end()); + //llassert(mFetcher->mNetworkQueue.find(mID) != mFetcher->mNetworkQueue.end()); return false; } } @@ -3011,16 +3011,18 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority) { LL_PROFILE_ZONE_SCOPED; - bool res = false; - LLTextureFetchWorker* worker = getWorker(id); - if (worker) - { - worker->lockWorkMutex(); // +Mw - worker->setImagePriority(priority); - worker->unlockWorkMutex(); // -Mw - res = true; - } - return res; + mRequestQueue.post([=]() + { + LLTextureFetchWorker* worker = getWorker(id); + if (worker) + { + worker->lockWorkMutex(); // +Mw + worker->setImagePriority(priority); + worker->unlockWorkMutex(); // -Mw + } + }); + + return true; } // Replicates and expands upon the base class's diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 2eb36a42be..ae480bcc35 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -653,6 +653,8 @@ void LLViewerTexture::cleanup() { notifyAboutMissingAsset(); + LLAppViewer::getTextureFetch()->updateRequestPriority(mID, 0.f); + mFaceList[LLRender::DIFFUSE_MAP].clear(); mFaceList[LLRender::NORMAL_MAP].clear(); mFaceList[LLRender::SPECULAR_MAP].clear(); @@ -1941,6 +1943,11 @@ bool LLViewerFetchedTexture::updateFetch() LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - in fast cache"); return false; } + if (mGLTexturep.isNull()) + { // fix for crash inside getCurrentDiscardLevelForFetching (shouldn't happen but appears to be happening) + llassert(false); + return false; + } S32 current_discard = getCurrentDiscardLevelForFetching(); S32 desired_discard = getDesiredDiscardLevel(); diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index ac036bce31..8faeb70553 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1025,7 +1025,7 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLTimer image_op_timer; - typedef std::vector entries_list_t; + typedef std::vector > entries_list_t; entries_list_t entries; // update N textures at beginning of mImageList @@ -1057,10 +1057,13 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) } } - for (auto* imagep : entries) + for (auto& imagep : entries) { - updateImageDecodePriority(imagep); - imagep->updateFetch(); + if (imagep->getNumRefs() > 1) // make sure this image hasn't been deleted before attempting to update (may happen as a side effect of some other image updating) + { + updateImageDecodePriority(imagep); + imagep->updateFetch(); + } } if (entries.size() > 0) -- cgit v1.2.3 From 99189ff2d5e96434cdc58115bbc03614f8e50773 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Jun 2022 15:24:40 -0500 Subject: SL-17547 Fix for crash on shutdown introduced in last commit. --- indra/newview/lltexturefetch.cpp | 2 +- indra/newview/llviewertexture.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 2bfdfe1789..0fa425cf22 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -3011,7 +3011,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority) { LL_PROFILE_ZONE_SCOPED; - mRequestQueue.post([=]() + mRequestQueue.tryPost([=]() { LLTextureFetchWorker* worker = getWorker(id); if (worker) diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index ae480bcc35..b7633545f9 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -653,7 +653,10 @@ void LLViewerTexture::cleanup() { notifyAboutMissingAsset(); - LLAppViewer::getTextureFetch()->updateRequestPriority(mID, 0.f); + if (LLAppViewer::getTextureFetch()) + { + LLAppViewer::getTextureFetch()->updateRequestPriority(mID, 0.f); + } mFaceList[LLRender::DIFFUSE_MAP].clear(); mFaceList[LLRender::NORMAL_MAP].clear(); -- cgit v1.2.3 From 039c6689c9f3e10970d2617a1127c6a48891e619 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Jun 2022 17:27:29 -0500 Subject: SL-17547 Fix for crash on shutdown cleaning up LLLFSThread --- indra/newview/llappviewer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index d7ed2bb4df..0b80d32ac3 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1850,8 +1850,6 @@ bool LLAppViewer::cleanup() LL_INFOS() << "Cache files removed" << LL_ENDL; - // Wait for any pending LFS IO - flushLFSIO(); LL_INFOS() << "Shutting down Views" << LL_ENDL; // Destroy the UI @@ -2058,6 +2056,7 @@ bool LLAppViewer::cleanup() sTextureFetch->shutDownTextureCacheThread() ; sTextureFetch->shutDownImageDecodeThread() ; + LLLFSThread::sLocal->shutdown(); LL_INFOS() << "Shutting down message system" << LL_ENDL; end_messaging_system(); -- cgit v1.2.3 From 0837b65fdd2ea7f50f47209bd8f1109968a677fb Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 7 Jun 2022 16:14:54 -0700 Subject: DRTVWR-559: Fix fullbrightShiny not compiling on AMD due to type mismatch --- .../app_settings/shaders/class1/deferred/fullbrightShinyF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl index 9fcee04c32..f693323d45 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl @@ -38,7 +38,7 @@ uniform sampler2D diffuseMap; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; VARYING vec3 vary_texcoord1; -VARYING vec4 vary_position; +VARYING vec3 vary_position; uniform samplerCube environmentMap; @@ -74,7 +74,7 @@ void main() vec3 amblit; vec3 additive; vec3 atten; - vec3 pos = vary_position.xyz/vary_position.w; + vec3 pos = vary_position.xyz; calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten, false); -- cgit v1.2.3 From 8c0163bcb48df56112a625550d411741c20c5846 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 13 Apr 2022 12:32:58 -0600 Subject: SL-17214 initial loader class skeleton --- indra/llmath/v4color.h | 12 +- indra/llprimitive/CMakeLists.txt | 2 + indra/llprimitive/lldaeloader.cpp | 26 +-- indra/llprimitive/lldaeloader.h | 2 +- indra/llprimitive/llgltfloader.cpp | 336 ++++++++++++++++++++++++++++++++ indra/llprimitive/llgltfloader.h | 207 ++++++++++++++++++++ indra/llprimitive/llmodelloader.cpp | 13 +- indra/newview/llfilepicker.cpp | 54 +++-- indra/newview/llfilepicker.h | 8 +- indra/newview/llfloatermodelpreview.cpp | 2 +- indra/newview/llmodelpreview.cpp | 50 +++-- indra/newview/llviewermenu.cpp | 5 - indra/newview/llviewermenufile.cpp | 7 - 13 files changed, 640 insertions(+), 84 deletions(-) create mode 100644 indra/llprimitive/llgltfloader.cpp create mode 100644 indra/llprimitive/llgltfloader.h diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index 175edf1471..f2863be531 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -88,7 +88,8 @@ class LLColor4 const LLColor4& set(const LLColor3 &vec); // Sets LLColor4 to LLColor3 vec (no change in alpha) const LLColor4& set(const LLColor3 &vec, F32 a); // Sets LLColor4 to LLColor3 vec, with alpha specified const LLColor4& set(const F32 *vec); // Sets LLColor4 to vec - const LLColor4& set(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled. + const LLColor4& set(const F64 *vec); // Sets LLColor4 to (double)vec + const LLColor4& set(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled. const LLColor4& setAlpha(F32 a); @@ -334,6 +335,15 @@ inline const LLColor4& LLColor4::set(const F32 *vec) return (*this); } +inline const LLColor4& LLColor4::set(const F64 *vec) +{ + mV[VX] = static_cast(vec[VX]); + mV[VY] = static_cast(vec[VY]); + mV[VZ] = static_cast(vec[VZ]); + mV[VW] = static_cast(vec[VW]); + return (*this); +} + // deprecated inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z) { diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index fff4d8ef0a..9d75dab31e 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -28,6 +28,7 @@ include_directories(SYSTEM set(llprimitive_SOURCE_FILES lldaeloader.cpp + llgltfloader.cpp llmaterialid.cpp llmaterial.cpp llmaterialtable.cpp @@ -46,6 +47,7 @@ set(llprimitive_SOURCE_FILES set(llprimitive_HEADER_FILES CMakeLists.txt lldaeloader.h + llgltfloader.h legacy_object_types.h llmaterial.h llmaterialid.h diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index e89690438e..94f8500dab 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -2504,19 +2504,19 @@ bool LLDAELoader::addVolumeFacesFromDomMesh(LLModel* pModel,domMesh* mesh, LLSD& return (status == LLModel::NO_ERRORS); } -//static -LLModel* LLDAELoader::loadModelFromDomMesh(domMesh *mesh) -{ - LLVolumeParams volume_params; - volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE); - LLModel* ret = new LLModel(volume_params, 0.f); - createVolumeFacesFromDomMesh(ret, mesh); - if (ret->mLabel.empty()) - { - ret->mLabel = getElementLabel(mesh); - } - return ret; -} +////static +//LLModel* LLDAELoader::loadModelFromDomMesh(domMesh *mesh) +//{ +// LLVolumeParams volume_params; +// volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE); +// LLModel* ret = new LLModel(volume_params, 0.f); +// createVolumeFacesFromDomMesh(ret, mesh); +// if (ret->mLabel.empty()) +// { +// ret->mLabel = getElementLabel(mesh); +// } +// return ret; +//} //static diff version supports creating multiple models when material counts spill // over the 8 face server-side limit diff --git a/indra/llprimitive/lldaeloader.h b/indra/llprimitive/lldaeloader.h index 2b211343e1..9e80980ddf 100644 --- a/indra/llprimitive/lldaeloader.h +++ b/indra/llprimitive/lldaeloader.h @@ -92,7 +92,7 @@ protected: static bool addVolumeFacesFromDomMesh(LLModel* model, domMesh* mesh, LLSD& log_msg); static bool createVolumeFacesFromDomMesh(LLModel* model, domMesh *mesh); - static LLModel* loadModelFromDomMesh(domMesh* mesh); + //static LLModel* loadModelFromDomMesh(domMesh* mesh); // Loads a mesh breaking it into one or more models as necessary // to get around volume face limitations while retaining >8 materials diff --git a/indra/llprimitive/llgltfloader.cpp b/indra/llprimitive/llgltfloader.cpp new file mode 100644 index 0000000000..001623ac9e --- /dev/null +++ b/indra/llprimitive/llgltfloader.cpp @@ -0,0 +1,336 @@ +/** + * @file LLGLTFLoader.cpp + * @brief LLGLTFLoader class implementation + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "LLGLTFLoader.h" + +// Import & define single-header gltf import/export lib +#define TINYGLTF_IMPLEMENTATION +#define TINYGLTF_USE_CPP14 // default is C++ 11 + +// tinygltf by default loads image files using STB +#define STB_IMAGE_IMPLEMENTATION +// to use our own image loading: +// 1. replace this definition with TINYGLTF_NO_STB_IMAGE +// 2. provide image loader callback with TinyGLTF::SetImageLoader(LoadimageDataFunction LoadImageData, void *user_data) + +// tinygltf saves image files using STB +#define STB_IMAGE_WRITE_IMPLEMENTATION +// similarly, can override with TINYGLTF_NO_STB_IMAGE_WRITE and TinyGLTF::SetImageWriter(fxn, data) + +// Additionally, disable inclusion of STB header files entirely with +// TINYGLTF_NO_INCLUDE_STB_IMAGE +// TINYGLTF_NO_INCLUDE_STB_IMAGE_WRITE +#include "tinygltf\tiny_gltf.h" + +#include + +#include "llsdserialize.h" +#include "lljoint.h" + +#include "glh/glh_linear.h" +#include "llmatrix4a.h" + +#include +#include + +static const std::string lod_suffix[LLModel::NUM_LODS] = +{ + "_LOD0", + "_LOD1", + "_LOD2", + "", + "_PHYS", +}; + +const U32 LIMIT_MATERIALS_OUTPUT = 12; + +LLGLTFLoader::LLGLTFLoader(std::string filename, + S32 lod, + LLModelLoader::load_callback_t load_cb, + LLModelLoader::joint_lookup_func_t joint_lookup_func, + LLModelLoader::texture_load_func_t texture_load_func, + LLModelLoader::state_callback_t state_cb, + void * opaque_userdata, + JointTransformMap & jointTransformMap, + JointNameSet & jointsFromNodes, + std::map &jointAliasMap, + U32 maxJointsPerMesh, + U32 modelLimit) //, + //bool preprocess) + : LLModelLoader( filename, + lod, + load_cb, + joint_lookup_func, + texture_load_func, + state_cb, + opaque_userdata, + jointTransformMap, + jointsFromNodes, + jointAliasMap, + maxJointsPerMesh ), + mGeneratedModelLimit(modelLimit), + //mPreprocessGLTF(preprocess), + mMeshesLoaded(false), + mMaterialsLoaded(false) +{ +} + +LLGLTFLoader::~LLGLTFLoader() {} + +bool LLGLTFLoader::OpenFile(const std::string &filename) +{ + tinygltf::TinyGLTF loader; + std::string error_msg; + std::string warn_msg; + + // Load a tinygltf model fom a file. Assumes that the input filename has already been + // been sanitized to one of (.gltf , .glb) extensions, so does a simple find to distinguish. + if (std::string::npos == filename.rfind(".gltf")) + { // file is binary + mGltfLoaded = loader.LoadBinaryFromFile(&mGltfModel, &error_msg, &warn_msg, filename); + } + else + { // file is ascii + mGltfLoaded = loader.LoadASCIIFromFile(&mGltfModel, &error_msg, &warn_msg, filename); + } + + if (!mGltfLoaded) + { + if (!warn_msg.empty()) + LL_WARNS() << "gltf load warning: " << warn_msg.c_str() << LL_ENDL; + if (!error_msg.empty()) + LL_WARNS() << "gltf load error: " << error_msg.c_str() << LL_ENDL; + return false; + } + + mMeshesLoaded = parseMeshes(); + if (mMeshesLoaded) uploadMeshes(); + + mMaterialsLoaded = parseMaterials(); + if (mMaterialsLoaded) uploadMaterials(); + + return (mMeshesLoaded || mMaterialsLoaded); +} + +bool LLGLTFLoader::parseMeshes() +{ + if (!mGltfLoaded) return false; + + // 2022-04 DJH Volume params from dae example. TODO understand PCODE + LLVolumeParams volume_params; + volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE); + + for (tinygltf::Mesh mesh : mGltfModel.meshes) + { + LLModel *pModel = new LLModel(volume_params, 0.f); + + if (populateModelFromMesh(pModel, mesh) && + (LLModel::NO_ERRORS == pModel->getStatus()) && + validate_model(pModel)) + { + mModelList.push_back(pModel); + } + else + { + setLoadState(ERROR_MODEL + pModel->getStatus()); + delete(pModel); + return false; + } + } + return true; +} + +bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const tinygltf::Mesh &mesh) +{ + pModel->mLabel = mesh.name; + int pos_idx, norm_idx, tan_idx, uv0_idx, uv1_idx, color0_idx, color1_idx; + tinygltf::Accessor indices_a, positions_a, normals_a, uv0_a, color0_a; + + auto prims = mesh.primitives; + for (auto prim : prims) + { + if (prim.indices >= 0) indices_a = mGltfModel.accessors[prim.indices]; + + pos_idx = (prim.attributes.count("POSITION") > 0) ? prim.attributes.at("POSITION") : -1; + if (pos_idx >= 0) + { + positions_a = mGltfModel.accessors[pos_idx]; + if (TINYGLTF_COMPONENT_TYPE_FLOAT != positions_a.componentType) + continue; + auto positions_bv = mGltfModel.bufferViews[positions_a.bufferView]; + auto positions_buf = mGltfModel.buffers[positions_bv.buffer]; + //auto type = positions_vb. + //if (positions_buf.name + } + + norm_idx = (prim.attributes.count("NORMAL") > 0) ? prim.attributes.at("NORMAL") : -1; + tan_idx = (prim.attributes.count("TANGENT") > 0) ? prim.attributes.at("TANGENT") : -1; + uv0_idx = (prim.attributes.count("TEXCOORDS_0") > 0) ? prim.attributes.at("TEXCOORDS_0") : -1; + uv1_idx = (prim.attributes.count("TEXCOORDS_1") > 0) ? prim.attributes.at("TEXCOORDS_1") : -1; + color0_idx = (prim.attributes.count("COLOR_0") > 0) ? prim.attributes.at("COLOR_0") : -1; + color1_idx = (prim.attributes.count("COLOR_1") > 0) ? prim.attributes.at("COLOR_1") : -1; + + if (prim.mode == TINYGLTF_MODE_TRIANGLES) + { + //auto pos = mesh. TODO resume here DJH 2022-04 + } + } + + //pModel->addFace() + return false; +} + +bool LLGLTFLoader::parseMaterials() +{ + if (!mGltfLoaded) return false; + + // fill local texture data structures + mSamplers.clear(); + for (auto in_sampler : mGltfModel.samplers) + { + gltf_sampler sampler{ 0 }; + sampler.magFilter = in_sampler.magFilter; + sampler.minFilter = in_sampler.minFilter; + sampler.wrapS = in_sampler.wrapS; + sampler.wrapT = in_sampler.wrapT; + sampler.name = in_sampler.name; // unused + mSamplers.push_back(sampler); + } + + mImages.clear(); + for (auto in_image : mGltfModel.images) + { + gltf_image image{ 0 }; + image.numChannels = in_image.component; + image.bytesPerChannel = in_image.bits >> 3; + image.pixelType = in_image.pixel_type; + image.size = in_image.image.size(); + image.height = in_image.height; + image.width = in_image.width; + image.data = in_image.image.data(); + + if (in_image.as_is) + { + LL_WARNS("GLTF_IMPORT") << "Unsupported image encoding" << LL_ENDL; + return false; + } + + if (image.size != image.height * image.width * image.numChannels * image.bytesPerChannel) + { + LL_WARNS("GLTF_IMPORT") << "Image size error" << LL_ENDL; + return false; + } + + mImages.push_back(image); + } + + mTextures.clear(); + for (auto in_tex : mGltfModel.textures) + { + gltf_texture tex{ 0 }; + tex.image_idx = in_tex.source; + tex.sampler_idx = in_tex.sampler; + + if (tex.image_idx >= mImages.size() || tex.sampler_idx >= mSamplers.size()) + { + LL_WARNS("GLTF_IMPORT") << "Texture sampler/image index error" << LL_ENDL; + return false; + } + + mTextures.push_back(tex); + } + + // parse each material + for (tinygltf::Material gltf_material : mGltfModel.materials) + { + gltf_render_material mat{ 0 }; + mat.name = gltf_material.name; + + mat.normalScale = gltf_material.normalTexture.scale; + mat.normalTexIdx = gltf_material.normalTexture.index; + mat.normalTexCoordIdx = gltf_material.normalTexture.texCoord; + + mat.occlusionScale = gltf_material.occlusionTexture.strength; + mat.occlusionTexIdx = gltf_material.occlusionTexture.index; + mat.occlusionTexCoordIdx = gltf_material.occlusionTexture.texCoord; + + mat.emissiveColor.set(gltf_material.emissiveFactor.data()); + mat.emissiveColorTexIdx = gltf_material.emissiveTexture.index; + mat.emissiveColorTexCoordIdx = gltf_material.emissiveTexture.texCoord; + + mat.alphaMode = gltf_material.alphaMode; + mat.alphaMask = gltf_material.alphaCutoff; + + tinygltf::PbrMetallicRoughness& pbr = gltf_material.pbrMetallicRoughness; + mat.hasPBR = true; + + mat.pbr.baseColor.set(pbr.baseColorFactor.data()); + mat.pbr.baseColorTexIdx = pbr.baseColorTexture.index; + mat.pbr.baseColorTexCoordIdx = pbr.baseColorTexture.texCoord; + + mat.pbr.metalness = pbr.metallicFactor; + mat.pbr.roughness = pbr.roughnessFactor; + mat.pbr.metalRoughTexIdx = pbr.metallicRoughnessTexture.index; + mat.pbr.metalRoughTexCoordIdx = pbr.metallicRoughnessTexture.texCoord; + + if (mat.normalTexIdx >= mTextures.size() || + mat.occlusionTexIdx >= mTextures.size() || + mat.emissiveColorTexIdx >= mTextures.size() || + mat.pbr.baseColorTexIdx >= mTextures.size() || + mat.pbr.metalRoughTexIdx >= mTextures.size()) + { + LL_WARNS("GLTF_IMPORT") << "Texture resource index error" << LL_ENDL; + return false; + } + + if (mat.normalTexCoordIdx > 0 || // May have to loosen this condition + mat.occlusionTexCoordIdx > 0 || + mat.emissiveColorTexCoordIdx > 0 || + mat.pbr.baseColorTexCoordIdx > 0 || + mat.pbr.metalRoughTexCoordIdx > 0) + { + LL_WARNS("GLTF_IMPORT") << "Image texcoord index error" << LL_ENDL; + return false; + } + + mMaterials.push_back(mat); + } + + return true; +} + +// TODO: convert raw vertex buffers to UUIDs +void LLGLTFLoader::uploadMeshes() +{ + llassert(0); +} + +// TODO: convert raw index buffers to UUIDs +void LLGLTFLoader::uploadMaterials() +{ + llassert(0); +} + diff --git a/indra/llprimitive/llgltfloader.h b/indra/llprimitive/llgltfloader.h new file mode 100644 index 0000000000..9bffeef4ab --- /dev/null +++ b/indra/llprimitive/llgltfloader.h @@ -0,0 +1,207 @@ +/** + * @file LLGLTFLoader.h + * @brief LLGLTFLoader class definition + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLGLTFLoader_H +#define LL_LLGLTFLoader_H + +#include "tinygltf\tiny_gltf.h" + +#include "llmodelloader.h" + +typedef struct // gltf sampler +{ // Uses GL enums + S32 minFilter; // GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR or GL_LINEAR_MIPMAP_LINEAR + S32 magFilter; // GL_NEAREST or GL_LINEAR + S32 wrapS; // GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT or GL_REPEAT + S32 wrapT; // GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT or GL_REPEAT + //S32 wrapR; // seen in some sample files, but not part of glTF 2.0 spec. Ignored. + std::string name; // optional, currently unused + // extensions and extras are sampler optional fields that we don't support - at least initially +} gltf_sampler; + +typedef struct // gltf image +{ // Note that glTF images are defined with row 0 at the top + U8* data; // ptr to decoded image data + U32 size; // in bytes, regardless of channel width + U32 width; + U32 height; + U32 numChannels; // range 1..4 + U32 bytesPerChannel; // converted from gltf "bits", expects only 8, 16 or 32 as input + U32 pixelType; // one of (TINYGLTF_COMPONENT_TYPE)_UNSIGNED_BYTE, _UNSIGNED_SHORT, _UNSIGNED_INT, or _FLOAT +} gltf_image; + +typedef struct // texture +{ + U32 image_idx; + U32 sampler_idx; +} gltf_texture; + + +// TODO: 2022-05 DJH add UUIDs for each texture +typedef struct // gltf_pbrMR_material +{ + // scalar values + LLColor4 baseColor; // linear encoding. Multiplied with vertex color, if present. + double metalness; + double roughness; + + // textures + U32 baseColorTexIdx; // always sRGB encoded + U32 baseColorTexCoordIdx; + + U32 metalRoughTexIdx; // always linear, roughness in G channel, metalness in B channel + U32 metalRoughTexCoordIdx; +} gltf_pbr; + +typedef struct // render material +{ + std::string name; + + // scalar values + double normalScale; // scale applies only to X,Y components of normal + double occlusionScale; // strength multiplier for occlusion + LLColor4 emissiveColor; // emissive mulitiplier, assumed linear encoding (spec 2.0 is silent) + std::string alphaMode; // "OPAQUE", "MASK" or "BLEND" + double alphaMask; + + // textures + U32 normalTexIdx; // linear, valid range R[0-1], G[0-1], B[0.5-1]. Normal = texel * 2 - vec3(1.0) + U32 normalTexCoordIdx; + + U32 occlusionTexIdx; // linear, occlusion in R channel, 0 meaning fully occluded, 1 meaning not occluded + U32 occlusionTexCoordIdx; + + U32 emissiveColorTexIdx; // always stored as sRGB, in nits (candela / meter^2) + U32 emissiveColorTexCoordIdx; + + // TODO: Add traditional (diffuse, normal, specular) UUIDs here, or add this struct to LL_TextureEntry?? + + bool hasPBR; + gltf_pbr pbr; + +} gltf_render_material; + +typedef struct // gltf_mesh +{ + std::string name; + + // TODO DJH 2022-04 + +} gltf_mesh; + +class LLGLTFLoader : public LLModelLoader +{ + public: + typedef std::map material_map; + typedef void gltfElement; // TBD + typedef void GLTF; // TBD + + // typedef std::map > > gltf_model_map; + // gltf_model_map mModelsMap; + + LLGLTFLoader(std::string filename, + S32 lod, + LLModelLoader::load_callback_t load_cb, + LLModelLoader::joint_lookup_func_t joint_lookup_func, + LLModelLoader::texture_load_func_t texture_load_func, + LLModelLoader::state_callback_t state_cb, + void * opaque_userdata, + JointTransformMap & jointTransformMap, + JointNameSet & jointsFromNodes, + std::map &jointAliasMap, + U32 maxJointsPerMesh, + U32 modelLimit); //, + //bool preprocess ); + virtual ~LLGLTFLoader(); + + virtual bool OpenFile(const std::string &filename); + +protected: + tinygltf::Model mGltfModel; + bool mGltfLoaded; + bool mMeshesLoaded; + bool mMaterialsLoaded; + + std::vector mMeshes; + std::vector mMaterials; + + std::vector mTextures; + std::vector mImages; + std::vector mSamplers; + +private: + U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels +// bool mPreprocessGLTF; + + bool parseMeshes(); + void uploadMeshes(); + bool parseMaterials(); + void uploadMaterials(); + bool populateModelFromMesh(LLModel* pModel, const tinygltf::Mesh &mesh); + + /* + void processElement(gltfElement *element, bool &badElement, GLTF *gltf); + void processGltfModel(LLModel *model, GLTF *gltf, gltfElement *pRoot, gltfMesh *mesh, gltfSkin *skin); + + material_map getMaterials(LLModel *model, gltfInstance_geometry *instance_geo, GLTF *gltf); + LLImportMaterial profileToMaterial(gltfProfile_COMMON *material, GLTF *gltf); + LLColor4 getGltfColor(gltfElement *element); + + gltfElement *getChildFromElement(gltfElement *pElement, std::string const &name); + + bool isNodeAJoint(gltfNode *pNode); + void processJointNode(gltfNode *pNode, std::map &jointTransforms); + void extractTranslation(gltfTranslate *pTranslate, LLMatrix4 &transform); + void extractTranslationViaElement(gltfElement *pTranslateElement, LLMatrix4 &transform); + void extractTranslationViaSID(gltfElement *pElement, LLMatrix4 &transform); + void buildJointToNodeMappingFromScene(gltfElement *pRoot); + void processJointToNodeMapping(gltfNode *pNode); + void processChildJoints(gltfNode *pParentNode); + + bool verifyCount(int expected, int result); + + // Verify that a controller matches vertex counts + bool verifyController(gltfController *pController); + + static bool addVolumeFacesFromGltfMesh(LLModel *model, gltfMesh *mesh, LLSD &log_msg); + static bool createVolumeFacesFromGltfMesh(LLModel *model, gltfMesh *mesh); + + static LLModel *loadModelFromGltfMesh(gltfMesh *mesh); + + // Loads a mesh breaking it into one or more models as necessary + // to get around volume face limitations while retaining >8 materials + // + bool loadModelsFromGltfMesh(gltfMesh *mesh, std::vector &models_out, U32 submodel_limit); + + static std::string getElementLabel(gltfElement *element); + static size_t getSuffixPosition(std::string label); + static std::string getLodlessLabel(gltfElement *element); + + static std::string preprocessGLTF(std::string filename); + */ + +}; +#endif // LL_LLGLTFLLOADER_H diff --git a/indra/llprimitive/llmodelloader.cpp b/indra/llprimitive/llmodelloader.cpp index 5171621007..554ed54de1 100644 --- a/indra/llprimitive/llmodelloader.cpp +++ b/indra/llprimitive/llmodelloader.cpp @@ -160,7 +160,8 @@ bool LLModelLoader::getSLMFilename(const std::string& model_filename, std::strin std::string::size_type i = model_filename.rfind("."); if (i != std::string::npos) { - slm_filename.replace(i, model_filename.size()-1, ".slm"); + slm_filename.resize(i, '\0'); + slm_filename.append(".slm"); return true; } else @@ -172,7 +173,7 @@ bool LLModelLoader::getSLMFilename(const std::string& model_filename, std::strin bool LLModelLoader::doLoadModel() { //first, look for a .slm file of the same name that was modified later - //than the .dae + //than the specified model file if (mTrySLM) { @@ -182,13 +183,13 @@ bool LLModelLoader::doLoadModel() llstat slm_status; if (LLFile::stat(slm_filename, &slm_status) == 0) { //slm file exists - llstat dae_status; - if (LLFile::stat(mFilename, &dae_status) != 0 || - dae_status.st_mtime < slm_status.st_mtime) + llstat model_file_status; + if (LLFile::stat(mFilename, &model_file_status) != 0 || + model_file_status.st_mtime < slm_status.st_mtime) { if (loadFromSLM(slm_filename)) { //slm successfully loaded, if this fails, fall through and - //try loading from dae + //try loading from model file mLod = -1; //successfully loading from an slm implicitly sets all //LoDs diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index 3669fb1eeb..4e2cc34207 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -55,13 +55,11 @@ LLFilePicker LLFilePicker::sInstance; #define IMAGE_FILTER L"Images (*.tga; *.bmp; *.jpg; *.jpeg; *.png)\0*.tga;*.bmp;*.jpg;*.jpeg;*.png\0" #define ANIM_FILTER L"Animations (*.bvh; *.anim)\0*.bvh;*.anim\0" #define COLLADA_FILTER L"Scene (*.dae)\0*.dae\0" -#ifdef _CORY_TESTING -#define GEOMETRY_FILTER L"SL Geometry (*.slg)\0*.slg\0" -#endif +#define GLTF_FILTER L"glTF (*.gltf; *.glb)\0*.gltf;*.glb\0" #define XML_FILTER L"XML files (*.xml)\0*.xml\0" #define SLOBJECT_FILTER L"Objects (*.slobject)\0*.slobject\0" #define RAW_FILTER L"RAW files (*.raw)\0*.raw\0" -#define MODEL_FILTER L"Model files (*.dae)\0*.dae\0" +#define MODEL_FILTER L"Model files (*.dae; *.gltf; *.glb)\0*.dae;*.gltf;*.glb\0" #define SCRIPT_FILTER L"Script files (*.lsl)\0*.lsl\0" #define DICTIONARY_FILTER L"Dictionary files (*.dic; *.xcu)\0*.dic;*.xcu\0" #endif @@ -193,16 +191,14 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter) mOFN.lpstrFilter = ANIM_FILTER \ L"\0"; break; - case FFLOAD_COLLADA: + case FFLOAD_GLTF: + mOFN.lpstrFilter = GLTF_FILTER \ + L"\0"; + break; + case FFLOAD_COLLADA: mOFN.lpstrFilter = COLLADA_FILTER \ L"\0"; break; -#ifdef _CORY_TESTING - case FFLOAD_GEOMETRY: - mOFN.lpstrFilter = GEOMETRY_FILTER \ - L"\0"; - break; -#endif case FFLOAD_XML: mOFN.lpstrFilter = XML_FILTER \ L"\0"; @@ -480,18 +476,16 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename, L"XAF Anim File (*.xaf)\0*.xaf\0" \ L"\0"; break; -#ifdef _CORY_TESTING - case FFSAVE_GEOMETRY: + case FFSAVE_GLTF: if (filename.empty()) { - wcsncpy( mFilesW,L"untitled.slg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ + wcsncpy( mFilesW,L"untitled.glb", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } - mOFN.lpstrDefExt = L"slg"; + mOFN.lpstrDefExt = L"glb"; mOFN.lpstrFilter = - L"SLG SL Geometry File (*.slg)\0*.slg\0" \ + L"glTF Asset File (*.gltf *.glb)\0*.gltf;*.glb\0" \ L"\0"; break; -#endif case FFSAVE_XML: if (filename.empty()) { @@ -621,14 +615,13 @@ std::vector* LLFilePicker::navOpenFilterProc(ELoadFilter filter) // allowedv->push_back("bvh"); allowedv->push_back("anim"); break; + case FFLOAD_GLTF: + allowedv->push_back("gltf"); + allowedv->push_back("glb"); + break; case FFLOAD_COLLADA: allowedv->push_back("dae"); break; -#ifdef _CORY_TESTING - case FFLOAD_GEOMETRY: - allowedv->push_back("slg"); - break; -#endif case FFLOAD_XML: allowedv->push_back("xml"); break; @@ -728,13 +721,11 @@ bool LLFilePicker::doNavSaveDialog(ESaveFilter filter, const std::string& filena extension = "xaf"; break; -#ifdef _CORY_TESTING - case FFSAVE_GEOMETRY: + case FFSAVE_GLTF: type = "\?\?\?\?"; creator = "\?\?\?\?"; - extension = "slg"; + extension = "glb"; break; -#endif case FFSAVE_XML: type = "\?\?\?\?"; @@ -1354,10 +1345,13 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking ) case FFLOAD_XML: filtername = add_xml_filter_to_gtkchooser(picker); break; - case FFLOAD_COLLADA: - filtername = add_collada_filter_to_gtkchooser(picker); - break; - case FFLOAD_IMAGE: + case FFLOAD_GLTF: + filtername = dead_code_should_blow_up_here(picker); + break; + case FFLOAD_COLLADA: + filtername = add_collada_filter_to_gtkchooser(picker); + break; + case FFLOAD_IMAGE: filtername = add_imageload_filter_to_gtkchooser(picker); break; case FFLOAD_SCRIPT: diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h index 04ba4416d7..a314207da6 100644 --- a/indra/newview/llfilepicker.h +++ b/indra/newview/llfilepicker.h @@ -77,9 +77,7 @@ public: FFLOAD_WAV = 2, FFLOAD_IMAGE = 3, FFLOAD_ANIM = 4, -#ifdef _CORY_TESTING - FFLOAD_GEOMETRY = 5, -#endif + FFLOAD_GLTF = 5, FFLOAD_XML = 6, FFLOAD_SLOBJECT = 7, FFLOAD_RAW = 8, @@ -99,9 +97,7 @@ public: FFSAVE_BMP = 5, FFSAVE_AVI = 6, FFSAVE_ANIM = 7, -#ifdef _CORY_TESTING - FFSAVE_GEOMETRY = 8, -#endif + FFSAVE_GLTF = 8, FFSAVE_XML = 9, FFSAVE_COLLADA = 10, FFSAVE_RAW = 11, diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 7279e1ad6d..b77341f806 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -97,7 +97,7 @@ private: }; LLMeshFilePicker::LLMeshFilePicker(LLModelPreview* mp, S32 lod) -: LLFilePickerThread(LLFilePicker::FFLOAD_COLLADA) +: LLFilePickerThread(LLFilePicker::FFLOAD_MODEL) { mMP = mp; mLOD = lod; diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 859d987fc3..e67bd6468e 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -30,6 +30,7 @@ #include "llmodelloader.h" #include "lldaeloader.h" +#include "llgltfloader.h" #include "llfloatermodelpreview.h" #include "llagent.h" @@ -732,20 +733,41 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable std::map joint_alias_map; getJointAliases(joint_alias_map); - mModelLoader = new LLDAELoader( - filename, - lod, - &LLModelPreview::loadedCallback, - &LLModelPreview::lookupJointByName, - &LLModelPreview::loadTextures, - &LLModelPreview::stateChangedCallback, - this, - mJointTransformMap, - mJointsFromNode, - joint_alias_map, - LLSkinningUtil::getMaxJointCount(), - gSavedSettings.getU32("ImporterModelLimit"), - gSavedSettings.getBOOL("ImporterPreprocessDAE")); + // three possible file extensions, .dae .gltf .glb + // check for .dae and if not then assume one of the .gl?? + if (std::string::npos != filename.rfind(".dae")) + { + mModelLoader = new LLDAELoader( + filename, + lod, + &LLModelPreview::loadedCallback, + &LLModelPreview::lookupJointByName, + &LLModelPreview::loadTextures, + &LLModelPreview::stateChangedCallback, + this, + mJointTransformMap, + mJointsFromNode, + joint_alias_map, + LLSkinningUtil::getMaxJointCount(), + gSavedSettings.getU32("ImporterModelLimit"), + gSavedSettings.getBOOL("ImporterPreprocessDAE")); + } + else + { + mModelLoader = new LLGLTFLoader( + filename, + lod, + &LLModelPreview::loadedCallback, + &LLModelPreview::lookupJointByName, + &LLModelPreview::loadTextures, + &LLModelPreview::stateChangedCallback, + this, + mJointTransformMap, + mJointsFromNode, + joint_alias_map, + LLSkinningUtil::getMaxJointCount(), + gSavedSettings.getU32("ImporterModelLimit")); + } if (force_disable_slm) { diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 8732bde35c..9c8a666185 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -267,16 +267,11 @@ void handle_reset_view(); void handle_duplicate_in_place(void*); - void handle_object_owner_self(void*); void handle_object_owner_permissive(void*); void handle_object_lock(void*); void handle_object_asset_ids(void*); void force_take_copy(void*); -#ifdef _CORY_TESTING -void force_export_copy(void*); -void force_import_geometry(void*); -#endif void handle_force_parcel_owner_to_me(void*); void handle_force_parcel_to_content(void*); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 28ff69eaf5..32fdfe282d 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -277,9 +277,6 @@ void LLMediaFilePicker::notify(const std::vector& filenames) static std::string SOUND_EXTENSIONS = "wav"; static std::string IMAGE_EXTENSIONS = "tga bmp jpg jpeg png"; static std::string ANIM_EXTENSIONS = "bvh anim"; -#ifdef _CORY_TESTING -static std::string GEOMETRY_EXTENSIONS = "slg"; -#endif static std::string XML_EXTENSIONS = "xml"; static std::string SLOBJECT_EXTENSIONS = "slobject"; #endif @@ -301,10 +298,6 @@ std::string build_extensions_string(LLFilePicker::ELoadFilter filter) return SLOBJECT_EXTENSIONS; case LLFilePicker::FFLOAD_MODEL: return MODEL_EXTENSIONS; -#ifdef _CORY_TESTING - case LLFilePicker::FFLOAD_GEOMETRY: - return GEOMETRY_EXTENSIONS; -#endif case LLFilePicker::FFLOAD_XML: return XML_EXTENSIONS; case LLFilePicker::FFLOAD_ALL: -- cgit v1.2.3 From adaaccd3d74dd05b596693ef7de90aeef20b5f9d Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 17 May 2022 15:54:00 -0600 Subject: SL-17214 additional glTF validation, remove dead code from DAE loader --- indra/llprimitive/CMakeLists.txt | 2 ++ indra/llprimitive/lldaeloader.cpp | 42 ------------------------------------ indra/llprimitive/lldaeloader.h | 3 --- indra/llprimitive/llgltfloader.cpp | 44 ++++++++++++++++++++++---------------- indra/llprimitive/llgltfloader.h | 6 +++++- 5 files changed, 32 insertions(+), 65 deletions(-) diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 9d75dab31e..2395841eae 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -10,12 +10,14 @@ include(LLCoreHttp) include(LLXML) include(LLPhysicsExtensions) include(LLCharacter) +include(LLRender) include_directories( ${LLCOMMON_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} + ${LLRENDER_INCLUDE_DIRS} ${LIBS_PREBUILT_DIR}/include/collada ${LIBS_PREBUILT_DIR}/include/collada/1.4 ${LLCHARACTER_INCLUDE_DIRS} diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 94f8500dab..68b29f01da 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -2504,20 +2504,6 @@ bool LLDAELoader::addVolumeFacesFromDomMesh(LLModel* pModel,domMesh* mesh, LLSD& return (status == LLModel::NO_ERRORS); } -////static -//LLModel* LLDAELoader::loadModelFromDomMesh(domMesh *mesh) -//{ -// LLVolumeParams volume_params; -// volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE); -// LLModel* ret = new LLModel(volume_params, 0.f); -// createVolumeFacesFromDomMesh(ret, mesh); -// if (ret->mLabel.empty()) -// { -// ret->mLabel = getElementLabel(mesh); -// } -// return ret; -//} - //static diff version supports creating multiple models when material counts spill // over the 8 face server-side limit // @@ -2608,31 +2594,3 @@ bool LLDAELoader::loadModelsFromDomMesh(domMesh* mesh, std::vector& mo return true; } - -bool LLDAELoader::createVolumeFacesFromDomMesh(LLModel* pModel, domMesh* mesh) -{ - if (mesh) - { - pModel->ClearFacesAndMaterials(); - - LLSD placeholder; - addVolumeFacesFromDomMesh(pModel, mesh, placeholder); - - if (pModel->getNumVolumeFaces() > 0) - { - pModel->normalizeVolumeFaces(); - pModel->optimizeVolumeFaces(); - - if (pModel->getNumVolumeFaces() > 0) - { - return true; - } - } - } - else - { - LL_WARNS() << "no mesh found" << LL_ENDL; - } - - return false; -} diff --git a/indra/llprimitive/lldaeloader.h b/indra/llprimitive/lldaeloader.h index 9e80980ddf..52ad908870 100644 --- a/indra/llprimitive/lldaeloader.h +++ b/indra/llprimitive/lldaeloader.h @@ -90,9 +90,6 @@ protected: bool verifyController( domController* pController ); static bool addVolumeFacesFromDomMesh(LLModel* model, domMesh* mesh, LLSD& log_msg); - static bool createVolumeFacesFromDomMesh(LLModel* model, domMesh *mesh); - - //static LLModel* loadModelFromDomMesh(domMesh* mesh); // Loads a mesh breaking it into one or more models as necessary // to get around volume face limitations while retaining >8 materials diff --git a/indra/llprimitive/llgltfloader.cpp b/indra/llprimitive/llgltfloader.cpp index 001623ac9e..bc9c4760f7 100644 --- a/indra/llprimitive/llgltfloader.cpp +++ b/indra/llprimitive/llgltfloader.cpp @@ -211,9 +211,9 @@ bool LLGLTFLoader::parseMaterials() mSamplers.clear(); for (auto in_sampler : mGltfModel.samplers) { - gltf_sampler sampler{ 0 }; - sampler.magFilter = in_sampler.magFilter; - sampler.minFilter = in_sampler.minFilter; + gltf_sampler sampler; + sampler.magFilter = in_sampler.magFilter > 0 ? in_sampler.magFilter : GL_LINEAR; + sampler.minFilter = in_sampler.minFilter > 0 ? in_sampler.minFilter : GL_LINEAR;; sampler.wrapS = in_sampler.wrapS; sampler.wrapT = in_sampler.wrapT; sampler.name = in_sampler.name; // unused @@ -223,10 +223,10 @@ bool LLGLTFLoader::parseMaterials() mImages.clear(); for (auto in_image : mGltfModel.images) { - gltf_image image{ 0 }; + gltf_image image; image.numChannels = in_image.component; - image.bytesPerChannel = in_image.bits >> 3; - image.pixelType = in_image.pixel_type; + image.bytesPerChannel = in_image.bits >> 3; // Convert bits to bytes + image.pixelType = in_image.pixel_type; // Maps exactly, i.e. TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE == GL_UNSIGNED_BYTE, etc image.size = in_image.image.size(); image.height = in_image.height; image.width = in_image.width; @@ -250,7 +250,7 @@ bool LLGLTFLoader::parseMaterials() mTextures.clear(); for (auto in_tex : mGltfModel.textures) { - gltf_texture tex{ 0 }; + gltf_texture tex; tex.image_idx = in_tex.source; tex.sampler_idx = in_tex.sampler; @@ -266,18 +266,21 @@ bool LLGLTFLoader::parseMaterials() // parse each material for (tinygltf::Material gltf_material : mGltfModel.materials) { - gltf_render_material mat{ 0 }; + gltf_render_material mat; mat.name = gltf_material.name; mat.normalScale = gltf_material.normalTexture.scale; + mat.hasNormalTex = gltf_material.normalTexture.index > 0; mat.normalTexIdx = gltf_material.normalTexture.index; mat.normalTexCoordIdx = gltf_material.normalTexture.texCoord; mat.occlusionScale = gltf_material.occlusionTexture.strength; + mat.hasOcclusionTex = gltf_material.occlusionTexture.index > 0; mat.occlusionTexIdx = gltf_material.occlusionTexture.index; mat.occlusionTexCoordIdx = gltf_material.occlusionTexture.texCoord; mat.emissiveColor.set(gltf_material.emissiveFactor.data()); + mat.hasEmissiveTex = gltf_material.emissiveTexture.index > 0; mat.emissiveColorTexIdx = gltf_material.emissiveTexture.index; mat.emissiveColorTexCoordIdx = gltf_material.emissiveTexture.texCoord; @@ -288,29 +291,31 @@ bool LLGLTFLoader::parseMaterials() mat.hasPBR = true; mat.pbr.baseColor.set(pbr.baseColorFactor.data()); + mat.pbr.hasBaseTex = pbr.baseColorTexture.index > 0; mat.pbr.baseColorTexIdx = pbr.baseColorTexture.index; mat.pbr.baseColorTexCoordIdx = pbr.baseColorTexture.texCoord; mat.pbr.metalness = pbr.metallicFactor; mat.pbr.roughness = pbr.roughnessFactor; + mat.pbr.hasMRTex = pbr.metallicRoughnessTexture.index > 0; mat.pbr.metalRoughTexIdx = pbr.metallicRoughnessTexture.index; mat.pbr.metalRoughTexCoordIdx = pbr.metallicRoughnessTexture.texCoord; - if (mat.normalTexIdx >= mTextures.size() || - mat.occlusionTexIdx >= mTextures.size() || - mat.emissiveColorTexIdx >= mTextures.size() || - mat.pbr.baseColorTexIdx >= mTextures.size() || - mat.pbr.metalRoughTexIdx >= mTextures.size()) + if ((mat.hasNormalTex && (mat.normalTexIdx >= mTextures.size())) || + (mat.hasOcclusionTex && (mat.occlusionTexIdx >= mTextures.size())) || + (mat.hasEmissiveTex && (mat.emissiveColorTexIdx >= mTextures.size())) || + (mat.pbr.hasBaseTex && (mat.pbr.baseColorTexIdx >= mTextures.size())) || + (mat.pbr.hasMRTex && (mat.pbr.metalRoughTexIdx >= mTextures.size()))) { LL_WARNS("GLTF_IMPORT") << "Texture resource index error" << LL_ENDL; return false; } - if (mat.normalTexCoordIdx > 0 || // May have to loosen this condition - mat.occlusionTexCoordIdx > 0 || - mat.emissiveColorTexCoordIdx > 0 || - mat.pbr.baseColorTexCoordIdx > 0 || - mat.pbr.metalRoughTexCoordIdx > 0) + if ((mat.hasNormalTex && (mat.normalTexCoordIdx > 2)) || // mesh can have up to 3 sets of UV + (mat.hasOcclusionTex && (mat.occlusionTexCoordIdx > 2)) || + (mat.hasEmissiveTex && (mat.emissiveColorTexCoordIdx > 2)) || + (mat.pbr.hasBaseTex && (mat.pbr.baseColorTexCoordIdx > 2)) || + (mat.pbr.hasMRTex && (mat.pbr.metalRoughTexCoordIdx > 2))) { LL_WARNS("GLTF_IMPORT") << "Image texcoord index error" << LL_ENDL; return false; @@ -331,6 +336,7 @@ void LLGLTFLoader::uploadMeshes() // TODO: convert raw index buffers to UUIDs void LLGLTFLoader::uploadMaterials() { - llassert(0); + //llassert(0); + } diff --git a/indra/llprimitive/llgltfloader.h b/indra/llprimitive/llgltfloader.h index 9bffeef4ab..08e9836d07 100644 --- a/indra/llprimitive/llgltfloader.h +++ b/indra/llprimitive/llgltfloader.h @@ -27,8 +27,9 @@ #ifndef LL_LLGLTFLoader_H #define LL_LLGLTFLoader_H -#include "tinygltf\tiny_gltf.h" +#include "tinygltf/tiny_gltf.h" +#include "llglheaders.h" #include "llmodelloader.h" typedef struct // gltf sampler @@ -74,6 +75,8 @@ typedef struct // gltf_pbrMR_material U32 metalRoughTexIdx; // always linear, roughness in G channel, metalness in B channel U32 metalRoughTexCoordIdx; + + bool hasBaseTex, hasMRTex; } gltf_pbr; typedef struct // render material @@ -100,6 +103,7 @@ typedef struct // render material // TODO: Add traditional (diffuse, normal, specular) UUIDs here, or add this struct to LL_TextureEntry?? bool hasPBR; + bool hasNormalTex, hasOcclusionTex, hasEmissiveTex; gltf_pbr pbr; } gltf_render_material; -- cgit v1.2.3 From c9ebb970ee916ace16e88508dc1a178336a91d52 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 1 Jun 2022 14:37:20 -0600 Subject: SL-17214 re-work gltf data organization --- indra/llprimitive/llgltfloader.cpp | 138 +++++++++++++++++++++++++++---------- indra/llprimitive/llgltfloader.h | 70 +++++++++---------- 2 files changed, 132 insertions(+), 76 deletions(-) diff --git a/indra/llprimitive/llgltfloader.cpp b/indra/llprimitive/llgltfloader.cpp index bc9c4760f7..3ec11f70c6 100644 --- a/indra/llprimitive/llgltfloader.cpp +++ b/indra/llprimitive/llgltfloader.cpp @@ -45,6 +45,9 @@ // TINYGLTF_NO_INCLUDE_STB_IMAGE_WRITE #include "tinygltf\tiny_gltf.h" + +// TODO: includes inherited from dae loader. Validate / prune + #include #include "llsdserialize.h" @@ -120,9 +123,9 @@ bool LLGLTFLoader::OpenFile(const std::string &filename) if (!mGltfLoaded) { if (!warn_msg.empty()) - LL_WARNS() << "gltf load warning: " << warn_msg.c_str() << LL_ENDL; + LL_WARNS("GLTF_IMPORT") << "gltf load warning: " << warn_msg.c_str() << LL_ENDL; if (!error_msg.empty()) - LL_WARNS() << "gltf load error: " << error_msg.c_str() << LL_ENDL; + LL_WARNS("GLTF_IMPORT") << "gltf load error: " << error_msg.c_str() << LL_ENDL; return false; } @@ -251,10 +254,11 @@ bool LLGLTFLoader::parseMaterials() for (auto in_tex : mGltfModel.textures) { gltf_texture tex; - tex.image_idx = in_tex.source; - tex.sampler_idx = in_tex.sampler; + tex.imageIdx = in_tex.source; + tex.samplerIdx = in_tex.sampler; + tex.imageUuid.setNull(); - if (tex.image_idx >= mImages.size() || tex.sampler_idx >= mSamplers.size()) + if (tex.imageIdx >= mImages.size() || tex.samplerIdx >= mSamplers.size()) { LL_WARNS("GLTF_IMPORT") << "Texture sampler/image index error" << LL_ENDL; return false; @@ -269,53 +273,53 @@ bool LLGLTFLoader::parseMaterials() gltf_render_material mat; mat.name = gltf_material.name; + tinygltf::PbrMetallicRoughness& pbr = gltf_material.pbrMetallicRoughness; + mat.hasPBR = true; // Always true, for now + + mat.baseColor.set(pbr.baseColorFactor.data()); + mat.hasBaseTex = pbr.baseColorTexture.index >= 0; + mat.baseColorTexIdx = pbr.baseColorTexture.index; + mat.baseColorTexCoords = pbr.baseColorTexture.texCoord; + + mat.metalness = pbr.metallicFactor; + mat.roughness = pbr.roughnessFactor; + mat.hasMRTex = pbr.metallicRoughnessTexture.index >= 0; + mat.metalRoughTexIdx = pbr.metallicRoughnessTexture.index; + mat.metalRoughTexCoords = pbr.metallicRoughnessTexture.texCoord; + mat.normalScale = gltf_material.normalTexture.scale; - mat.hasNormalTex = gltf_material.normalTexture.index > 0; + mat.hasNormalTex = gltf_material.normalTexture.index >= 0; mat.normalTexIdx = gltf_material.normalTexture.index; - mat.normalTexCoordIdx = gltf_material.normalTexture.texCoord; + mat.normalTexCoords = gltf_material.normalTexture.texCoord; mat.occlusionScale = gltf_material.occlusionTexture.strength; - mat.hasOcclusionTex = gltf_material.occlusionTexture.index > 0; + mat.hasOcclusionTex = gltf_material.occlusionTexture.index >= 0; mat.occlusionTexIdx = gltf_material.occlusionTexture.index; - mat.occlusionTexCoordIdx = gltf_material.occlusionTexture.texCoord; + mat.occlusionTexCoords = gltf_material.occlusionTexture.texCoord; mat.emissiveColor.set(gltf_material.emissiveFactor.data()); - mat.hasEmissiveTex = gltf_material.emissiveTexture.index > 0; - mat.emissiveColorTexIdx = gltf_material.emissiveTexture.index; - mat.emissiveColorTexCoordIdx = gltf_material.emissiveTexture.texCoord; + mat.hasEmissiveTex = gltf_material.emissiveTexture.index >= 0; + mat.emissiveTexIdx = gltf_material.emissiveTexture.index; + mat.emissiveTexCoords = gltf_material.emissiveTexture.texCoord; mat.alphaMode = gltf_material.alphaMode; mat.alphaMask = gltf_material.alphaCutoff; - tinygltf::PbrMetallicRoughness& pbr = gltf_material.pbrMetallicRoughness; - mat.hasPBR = true; - - mat.pbr.baseColor.set(pbr.baseColorFactor.data()); - mat.pbr.hasBaseTex = pbr.baseColorTexture.index > 0; - mat.pbr.baseColorTexIdx = pbr.baseColorTexture.index; - mat.pbr.baseColorTexCoordIdx = pbr.baseColorTexture.texCoord; - - mat.pbr.metalness = pbr.metallicFactor; - mat.pbr.roughness = pbr.roughnessFactor; - mat.pbr.hasMRTex = pbr.metallicRoughnessTexture.index > 0; - mat.pbr.metalRoughTexIdx = pbr.metallicRoughnessTexture.index; - mat.pbr.metalRoughTexCoordIdx = pbr.metallicRoughnessTexture.texCoord; - - if ((mat.hasNormalTex && (mat.normalTexIdx >= mTextures.size())) || - (mat.hasOcclusionTex && (mat.occlusionTexIdx >= mTextures.size())) || - (mat.hasEmissiveTex && (mat.emissiveColorTexIdx >= mTextures.size())) || - (mat.pbr.hasBaseTex && (mat.pbr.baseColorTexIdx >= mTextures.size())) || - (mat.pbr.hasMRTex && (mat.pbr.metalRoughTexIdx >= mTextures.size()))) + if ((mat.hasNormalTex && (mat.normalTexIdx >= mTextures.size())) || + (mat.hasOcclusionTex && (mat.occlusionTexIdx >= mTextures.size())) || + (mat.hasEmissiveTex && (mat.emissiveTexIdx >= mTextures.size())) || + (mat.hasBaseTex && (mat.baseColorTexIdx >= mTextures.size())) || + (mat.hasMRTex && (mat.metalRoughTexIdx >= mTextures.size()))) { LL_WARNS("GLTF_IMPORT") << "Texture resource index error" << LL_ENDL; return false; } - if ((mat.hasNormalTex && (mat.normalTexCoordIdx > 2)) || // mesh can have up to 3 sets of UV - (mat.hasOcclusionTex && (mat.occlusionTexCoordIdx > 2)) || - (mat.hasEmissiveTex && (mat.emissiveColorTexCoordIdx > 2)) || - (mat.pbr.hasBaseTex && (mat.pbr.baseColorTexCoordIdx > 2)) || - (mat.pbr.hasMRTex && (mat.pbr.metalRoughTexCoordIdx > 2))) + if ((mat.hasNormalTex && (mat.normalTexCoords > 2)) || // mesh can have up to 3 sets of UV + (mat.hasOcclusionTex && (mat.occlusionTexCoords > 2)) || + (mat.hasEmissiveTex && (mat.emissiveTexCoords > 2)) || + (mat.hasBaseTex && (mat.baseColorTexCoords > 2)) || + (mat.hasMRTex && (mat.metalRoughTexCoords > 2))) { LL_WARNS("GLTF_IMPORT") << "Image texcoord index error" << LL_ENDL; return false; @@ -333,10 +337,68 @@ void LLGLTFLoader::uploadMeshes() llassert(0); } -// TODO: convert raw index buffers to UUIDs +// convert raw image buffers to texture UUIDs & assemble into a render material void LLGLTFLoader::uploadMaterials() { - //llassert(0); + for (gltf_render_material mat : mMaterials) // Initially 1 material per gltf file, but design for multiple + { + if (mat.hasBaseTex) + { + gltf_texture& gtex = mTextures[mat.baseColorTexIdx]; + if (gtex.imageUuid.isNull()) + { + gtex.imageUuid = imageBufferToTextureUUID(gtex); + } + } + + if (mat.hasMRTex) + { + gltf_texture& gtex = mTextures[mat.metalRoughTexIdx]; + if (gtex.imageUuid.isNull()) + { + gtex.imageUuid = imageBufferToTextureUUID(gtex); + } + } + + if (mat.hasNormalTex) + { + gltf_texture& gtex = mTextures[mat.normalTexIdx]; + if (gtex.imageUuid.isNull()) + { + gtex.imageUuid = imageBufferToTextureUUID(gtex); + } + } + if (mat.hasOcclusionTex) + { + gltf_texture& gtex = mTextures[mat.occlusionTexIdx]; + if (gtex.imageUuid.isNull()) + { + gtex.imageUuid = imageBufferToTextureUUID(gtex); + } + } + + if (mat.hasEmissiveTex) + { + gltf_texture& gtex = mTextures[mat.emissiveTexIdx]; + if (gtex.imageUuid.isNull()) + { + gtex.imageUuid = imageBufferToTextureUUID(gtex); + } + } + } } +LLUUID LLGLTFLoader::imageBufferToTextureUUID(const gltf_texture& tex) +{ + //gltf_image& image = mImages[tex.imageIdx]; + //gltf_sampler& sampler = mSamplers[tex.samplerIdx]; + + // fill an LLSD container with image+sampler data + + // upload texture + + // retrieve UUID + + return LLUUID::null; +} diff --git a/indra/llprimitive/llgltfloader.h b/indra/llprimitive/llgltfloader.h index 08e9836d07..24496f6324 100644 --- a/indra/llprimitive/llgltfloader.h +++ b/indra/llprimitive/llgltfloader.h @@ -32,19 +32,21 @@ #include "llglheaders.h" #include "llmodelloader.h" +// gltf_* structs are temporary, used to organize the subset of data that eventually goes into the material LLSD + typedef struct // gltf sampler { // Uses GL enums S32 minFilter; // GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR or GL_LINEAR_MIPMAP_LINEAR S32 magFilter; // GL_NEAREST or GL_LINEAR S32 wrapS; // GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT or GL_REPEAT S32 wrapT; // GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT or GL_REPEAT - //S32 wrapR; // seen in some sample files, but not part of glTF 2.0 spec. Ignored. + //S32 wrapR; // Found in some sample files, but not part of glTF 2.0 spec. Ignored. std::string name; // optional, currently unused // extensions and extras are sampler optional fields that we don't support - at least initially } gltf_sampler; typedef struct // gltf image -{ // Note that glTF images are defined with row 0 at the top +{ // Note that glTF images are defined with row 0 at the top (opposite of OpenGL) U8* data; // ptr to decoded image data U32 size; // in bytes, regardless of channel width U32 width; @@ -56,34 +58,19 @@ typedef struct // gltf image typedef struct // texture { - U32 image_idx; - U32 sampler_idx; + U32 imageIdx; + U32 samplerIdx; + LLUUID imageUuid = LLUUID::null; } gltf_texture; - -// TODO: 2022-05 DJH add UUIDs for each texture -typedef struct // gltf_pbrMR_material -{ - // scalar values - LLColor4 baseColor; // linear encoding. Multiplied with vertex color, if present. - double metalness; - double roughness; - - // textures - U32 baseColorTexIdx; // always sRGB encoded - U32 baseColorTexCoordIdx; - - U32 metalRoughTexIdx; // always linear, roughness in G channel, metalness in B channel - U32 metalRoughTexCoordIdx; - - bool hasBaseTex, hasMRTex; -} gltf_pbr; - typedef struct // render material { std::string name; // scalar values + LLColor4 baseColor; // linear encoding. Multiplied with vertex color, if present. + double metalness; + double roughness; double normalScale; // scale applies only to X,Y components of normal double occlusionScale; // strength multiplier for occlusion LLColor4 emissiveColor; // emissive mulitiplier, assumed linear encoding (spec 2.0 is silent) @@ -91,20 +78,26 @@ typedef struct // render material double alphaMask; // textures - U32 normalTexIdx; // linear, valid range R[0-1], G[0-1], B[0.5-1]. Normal = texel * 2 - vec3(1.0) - U32 normalTexCoordIdx; - - U32 occlusionTexIdx; // linear, occlusion in R channel, 0 meaning fully occluded, 1 meaning not occluded - U32 occlusionTexCoordIdx; - - U32 emissiveColorTexIdx; // always stored as sRGB, in nits (candela / meter^2) - U32 emissiveColorTexCoordIdx; + U32 baseColorTexIdx; // always sRGB encoded + U32 metalRoughTexIdx; // always linear, roughness in G channel, metalness in B channel + U32 normalTexIdx; // linear, valid range R[0-1], G[0-1], B[0.5-1]. Normal = texel * 2 - vec3(1.0) + U32 occlusionTexIdx; // linear, occlusion in R channel, 0 meaning fully occluded, 1 meaning not occluded + U32 emissiveTexIdx; // always stored as sRGB, in nits (candela / meter^2) + + // texture coordinates + U32 baseColorTexCoords; + U32 metalRoughTexCoords; + U32 normalTexCoords; + U32 occlusionTexCoords; + U32 emissiveTexCoords; // TODO: Add traditional (diffuse, normal, specular) UUIDs here, or add this struct to LL_TextureEntry?? bool hasPBR; - bool hasNormalTex, hasOcclusionTex, hasEmissiveTex; - gltf_pbr pbr; + bool hasBaseTex, hasMRTex, hasNormalTex, hasOcclusionTex, hasEmissiveTex; + + // This field is populated after upload + LLUUID material_uuid = LLUUID::null; } gltf_render_material; @@ -112,7 +105,7 @@ typedef struct // gltf_mesh { std::string name; - // TODO DJH 2022-04 + // TODO add mesh import DJH 2022-04 } gltf_mesh; @@ -157,16 +150,17 @@ protected: std::vector mSamplers; private: - U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels -// bool mPreprocessGLTF; - bool parseMeshes(); void uploadMeshes(); bool parseMaterials(); void uploadMaterials(); bool populateModelFromMesh(LLModel* pModel, const tinygltf::Mesh &mesh); + LLUUID imageBufferToTextureUUID(const gltf_texture& tex); + + U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels + // bool mPreprocessGLTF; - /* + /* Inherited from dae loader - unknown how useful here void processElement(gltfElement *element, bool &badElement, GLTF *gltf); void processGltfModel(LLModel *model, GLTF *gltf, gltfElement *pRoot, gltfMesh *mesh, gltfSkin *skin); -- cgit v1.2.3 From 2dc376aa5324448de7d15717d5e24b812d885eea Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Fri, 3 Jun 2022 10:15:56 -0600 Subject: SL-17214 add 3p-tinygltf dependency to autobuild.xml --- autobuild.xml | 60 ++++++++++++++++++++++++++++++++++++++++ indra/cmake/TinyGLTF.cmake | 7 +++++ indra/llprimitive/CMakeLists.txt | 2 ++ 3 files changed, 69 insertions(+) create mode 100644 indra/cmake/TinyGLTF.cmake diff --git a/autobuild.xml b/autobuild.xml index 4c69ff71d4..f80ed200a0 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -3095,6 +3095,66 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors version 0.132.2 + tinygltf + + canonical_repo + https://bitbucket.org/lindenlab/3p-tinygltf + copyright + // Copyright (c) 2015 - Present Syoyo Fujita, Aurélien Chatelain and many contributors. + description + tinygltf import library + license + MIT + license_file + LICENSES/tinygltf_license.txt + name + tinygltf + platforms + + darwin64 + + archive + + hash + 13ebc64d8ba6276105a3fd516c7224f0 + url + https://s3-proxy.lindenlab.com/private-builds-secondlife-com/ct2/100740/887434/tinygltf-v2.5.0-windows64-572388.tar.bz2 + + name + darwin64 + + windows + + archive + + hash + 13ebc64d8ba6276105a3fd516c7224f0 + url + https://s3-proxy.lindenlab.com/private-builds-secondlife-com/ct2/100740/887434/tinygltf-v2.5.0-windows64-572388.tar.bz2 + + name + windows + + windows64 + + archive + + hash + 13ebc64d8ba6276105a3fd516c7224f0 + url + https://s3-proxy.lindenlab.com/private-builds-secondlife-com/ct2/100740/887434/tinygltf-v2.5.0-windows64-572388.tar.bz2 + + name + windows64 + + + source + https://bitbucket.org/lindenlab/3p-tinygltf + source_type + git + version + v2.5.0 + tracy canonical_repo diff --git a/indra/cmake/TinyGLTF.cmake b/indra/cmake/TinyGLTF.cmake new file mode 100644 index 0000000000..bb731637a0 --- /dev/null +++ b/indra/cmake/TinyGLTF.cmake @@ -0,0 +1,7 @@ +# -*- cmake -*- +include(Prebuilt) + +use_prebuilt_binary(tinygltf) + +set(TINYGLTF_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/tinygltf) + diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 2395841eae..e131b12371 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -11,6 +11,7 @@ include(LLXML) include(LLPhysicsExtensions) include(LLCharacter) include(LLRender) +include(TinyGLTF) include_directories( ${LLCOMMON_INCLUDE_DIRS} @@ -21,6 +22,7 @@ include_directories( ${LIBS_PREBUILT_DIR}/include/collada ${LIBS_PREBUILT_DIR}/include/collada/1.4 ${LLCHARACTER_INCLUDE_DIRS} + ${TINYGLTF_INCLUDE_DIR} ) include_directories(SYSTEM ${LLCOMMON_SYSTEM_INCLUDE_DIRS} -- cgit v1.2.3 From d3219f57c12ec29025e5c9c68b2cf90d49258672 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 7 Jun 2022 14:42:18 -0600 Subject: SL-17214 remove some dae clutter from gltf header --- indra/llprimitive/llgltfloader.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/indra/llprimitive/llgltfloader.h b/indra/llprimitive/llgltfloader.h index 24496f6324..9ee816e24e 100644 --- a/indra/llprimitive/llgltfloader.h +++ b/indra/llprimitive/llgltfloader.h @@ -75,7 +75,7 @@ typedef struct // render material double occlusionScale; // strength multiplier for occlusion LLColor4 emissiveColor; // emissive mulitiplier, assumed linear encoding (spec 2.0 is silent) std::string alphaMode; // "OPAQUE", "MASK" or "BLEND" - double alphaMask; + double alphaMask; // alpha cut-off // textures U32 baseColorTexIdx; // always sRGB encoded @@ -113,11 +113,6 @@ class LLGLTFLoader : public LLModelLoader { public: typedef std::map material_map; - typedef void gltfElement; // TBD - typedef void GLTF; // TBD - - // typedef std::map > > gltf_model_map; - // gltf_model_map mModelsMap; LLGLTFLoader(std::string filename, S32 lod, @@ -160,7 +155,8 @@ private: U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels // bool mPreprocessGLTF; - /* Inherited from dae loader - unknown how useful here + /* Below inherited from dae loader - unknown if/how useful here + void processElement(gltfElement *element, bool &badElement, GLTF *gltf); void processGltfModel(LLModel *model, GLTF *gltf, gltfElement *pRoot, gltfMesh *mesh, gltfSkin *skin); -- cgit v1.2.3 From da069765b1974e60df5ebf9e973c7fd00c52e329 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 8 Jun 2022 16:24:03 -0500 Subject: SL-17005 Tweak target VRAM usage and add some log spam to help zero in on good targets. --- indra/llwindow/llwindowwin32.cpp | 22 ++++++++++++++++------ indra/newview/llviewertexture.cpp | 16 ++++++++-------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index da79660239..20443988ab 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -65,7 +65,6 @@ #include #include - // Require DirectInput version 8 #define DIRECTINPUT_VERSION 0x0800 @@ -4649,23 +4648,34 @@ void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage() mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info); // try to use no more than the available reserve minus 10% - U32 target = info.AvailableForReservation / 1024 / 1024; - target -= target / 10; + U32 target = info.Budget / 1024 / 1024; + + // EXPERIMENTAL + // Trying to zero in on a good target usage, code here should be tuned against observed behavior + // of various hardware. + if (target > 4096) // if 4GB are installed, try to leave 2GB free + { + target -= 2048; + } + else // if less than 4GB are installed, try not to use more than half of it + { + target /= 2; + } U32 used_vram = info.CurrentUsage / 1024 / 1024; mAvailableVRAM = used_vram < target ? target - used_vram : 0; - /*LL_INFOS() << "\nLocal\nAFR: " << info.AvailableForReservation / 1024 / 1024 + LL_INFOS("Window") << "\nLocal\nAFR: " << info.AvailableForReservation / 1024 / 1024 << "\nBudget: " << info.Budget / 1024 / 1024 << "\nCR: " << info.CurrentReservation / 1024 / 1024 << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL; mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &info); - LL_INFOS() << "\nNon-Local\nAFR: " << info.AvailableForReservation / 1024 / 1024 + LL_INFOS("Window") << "\nNon-Local\nAFR: " << info.AvailableForReservation / 1024 / 1024 << "\nBudget: " << info.Budget / 1024 / 1024 << "\nCR: " << info.CurrentReservation / 1024 / 1024 - << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL;*/ + << "\nCU: " << info.CurrentUsage / 1024 / 1024 << LL_ENDL; } else if (mD3DDevice != NULL) { // fallback to D3D9 diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 16b07159ba..e31bc5ec6e 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -803,14 +803,8 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co } virtual_size *= sTexelPixelRatio; - /*if (!mMaxVirtualSizeResetCounter) - { - //flag to reset the values because the old values are used. - resetMaxVirtualSizeResetCounter(); - mMaxVirtualSize = virtual_size; - mNeedsGLTexture = needs_gltexture; - } - else*/ if (virtual_size > mMaxVirtualSize) + + if (virtual_size > mMaxVirtualSize) { mMaxVirtualSize = virtual_size; } @@ -1801,6 +1795,12 @@ void LLViewerFetchedTexture::updateVirtualSize() return; } + if (sDesiredDiscardBias > 0.f) + { + // running out of video memory, don't hold onto high res textures in the background + mMaxVirtualSize = 0.f; + } + for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) { llassert(mNumFaces[ch] <= mFaceList[ch].size()); -- cgit v1.2.3 From 5f606069e29db5d9554ce6f4200d0d4c35ecc3a1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 8 Jun 2022 17:48:58 -0500 Subject: SL-17285 Fix for probe influence volume combo box not applying. --- indra/newview/llpanelvolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index e7bbe266e5..f456ee4d4b 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -148,7 +148,7 @@ BOOL LLPanelVolume::postBuild() // REFLECTION PROBE Parameters { childSetCommitCallback("Reflection Probe Checkbox Ctrl", onCommitIsReflectionProbe, this); - childSetCommitCallback("Probe Shape Type Combo Ctrl", onCommitProbe, this); + childSetCommitCallback("Probe Volume Type Ctrl", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); -- cgit v1.2.3 From ef87eb7fa80a72b94d67d5ab680f60a837dd1ddd Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 31 May 2022 12:49:53 -0700 Subject: SL-17483: Make ThreadPool inherit LLInstanceTracker (cherry picked from commit 41d6a0e222241606c317281e2f0b211e16813dd5) --- indra/llcommon/threadpool.cpp | 1 + indra/llcommon/threadpool.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index ba914035e2..d5adf11264 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -22,6 +22,7 @@ #include "stringize.h" LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity): + super(name), mQueue(name, capacity), mName("ThreadPool:" + name), mThreadCount(threads) diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h index b79c9b9090..f8eec3b457 100644 --- a/indra/llcommon/threadpool.h +++ b/indra/llcommon/threadpool.h @@ -22,8 +22,10 @@ namespace LL { - class ThreadPool + class ThreadPool: public LLInstanceTracker { + private: + using super = LLInstanceTracker; public: /** * Pass ThreadPool a string name. This can be used to look up the -- cgit v1.2.3 From ac99e979f43d49402a24b2f58a154c4ef1583efd Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 9 Jun 2022 10:18:29 -0400 Subject: SL-17483: Make it possible to override width of any ThreadPool. Introduce CommonControl, which in a running viewer (or any program containing an LLViewerControlListener instance) gives access to LLViewerControl functionality, e.g. getting, setting or enumerating control variables -- without introducing a link dependency on newview. Make ThreadPool's constructor consult CommonControl to check for an override for the width of the new ThreadPool in the Global (i.e. gSavedSettings) setting ThreadPoolSizes, and honor that if found. Introduce static ThreadPool methods getConfiguredWidth(), to query for such an override on any particular ThreadPool name; and getWidth(), to ask for the width of an instance if that instance already exists, else the width with which it *would* be instantiated. --- indra/llcommon/CMakeLists.txt | 2 + indra/llcommon/commoncontrol.cpp | 104 +++++++++++++++++++++++++++++++++++++++ indra/llcommon/commoncontrol.h | 75 ++++++++++++++++++++++++++++ indra/llcommon/threadpool.cpp | 51 ++++++++++++++++++- indra/llcommon/threadpool.h | 30 ++++++++++- 5 files changed, 260 insertions(+), 2 deletions(-) create mode 100644 indra/llcommon/commoncontrol.cpp create mode 100644 indra/llcommon/commoncontrol.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index ca8b5e946f..4dbf1282c4 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -29,6 +29,7 @@ include_directories( # ${LLCOMMON_LIBRARIES}) set(llcommon_SOURCE_FILES + commoncontrol.cpp indra_constants.cpp llallocator.cpp llallocator_heap_profile.cpp @@ -129,6 +130,7 @@ set(llcommon_HEADER_FILES CMakeLists.txt chrono.h + commoncontrol.h ctype_workaround.h fix_macros.h indra_constants.h diff --git a/indra/llcommon/commoncontrol.cpp b/indra/llcommon/commoncontrol.cpp new file mode 100644 index 0000000000..2c2a2abeb0 --- /dev/null +++ b/indra/llcommon/commoncontrol.cpp @@ -0,0 +1,104 @@ +/** + * @file commoncontrol.cpp + * @author Nat Goodspeed + * @date 2022-06-08 + * @brief Implementation for commoncontrol. + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Copyright (c) 2022, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "linden_common.h" +// associated header +#include "commoncontrol.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "llevents.h" +#include "llsdutil.h" + +LLSD LL::CommonControl::access(const LLSD& params) +{ + // We can't actually introduce a link-time dependency on llxml, or on any + // global LLControlGroup (*koff* gSavedSettings *koff*) but we can issue a + // runtime query. If we're running as part of a viewer with + // LLViewerControlListener, we can use that to interact with any + // instantiated LLControGroup. + LLSD response; + { + LLEventStream reply("reply"); + LLTempBoundListener connection = reply.listen("listener", + [&response] (const LLSD& event) + { + response = event; + return false; + }); + LLSD rparams{ params }; + rparams["reply"] = reply.getName(); + LLEventPumps::instance().obtain("LLViewerControl").post(rparams); + } + // LLViewerControlListener responds immediately. If it's listening at all, + // it will already have set response. + if (! response.isDefined()) + { + LLTHROW(NoListener("No LLViewerControl listener instantiated")); + } + LLSD error{ response["error"] }; + if (error.isDefined()) + { + LLTHROW(ParamError(error)); + } + return response; +} + +/// set control group.key to defined default value +LLSD LL::CommonControl::set_default(const std::string& group, const std::string& key) +{ + return access(llsd::map("op", "set", + "group", group, "key", key))["value"]; +} + +/// set control group.key to specified value +LLSD LL::CommonControl::set(const std::string& group, const std::string& key, const LLSD& value) +{ + return access(llsd::map("op", "set", + "group", group, "key", key, "value", value))["value"]; +} + +/// toggle boolean control group.key +LLSD LL::CommonControl::toggle(const std::string& group, const std::string& key) +{ + return access(llsd::map("op", "toggle", + "group", group, "key", key))["value"]; +} + +/// get the definition for control group.key, (! isDefined()) if bad +/// ["name"], ["type"], ["value"], ["comment"] +LLSD LL::CommonControl::get_def(const std::string& group, const std::string& key) +{ + return access(llsd::map("op", "get", + "group", group, "key", key)); +} + +/// get the value of control group.key +LLSD LL::CommonControl::get(const std::string& group, const std::string& key) +{ + return access(llsd::map("op", "get", + "group", group, "key", key))["value"]; +} + +/// get defined groups +std::vector LL::CommonControl::get_groups() +{ + auto groups{ access(llsd::map("op", "groups"))["groups"] }; + return { groups.beginArray(), groups.endArray() }; +} + +/// get definitions for all variables in group +LLSD LL::CommonControl::get_vars(const std::string& group) +{ + return access(llsd::map("op", "vars", "group", group))["vars"]; +} diff --git a/indra/llcommon/commoncontrol.h b/indra/llcommon/commoncontrol.h new file mode 100644 index 0000000000..07d4a45ac5 --- /dev/null +++ b/indra/llcommon/commoncontrol.h @@ -0,0 +1,75 @@ +/** + * @file commoncontrol.h + * @author Nat Goodspeed + * @date 2022-06-08 + * @brief Access LLViewerControl LLEventAPI, if process has one. + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Copyright (c) 2022, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_COMMONCONTROL_H) +#define LL_COMMONCONTROL_H + +#include +#include "llexception.h" +#include "llsd.h" + +namespace LL +{ + class CommonControl + { + public: + struct Error: public LLException + { + Error(const std::string& what): LLException(what) {} + }; + + /// Exception thrown if there's no LLViewerControl LLEventAPI + struct NoListener: public Error + { + NoListener(const std::string& what): Error(what) {} + }; + + struct ParamError: public Error + { + ParamError(const std::string& what): Error(what) {} + }; + + /// set control group.key to defined default value + static + LLSD set_default(const std::string& group, const std::string& key); + + /// set control group.key to specified value + static + LLSD set(const std::string& group, const std::string& key, const LLSD& value); + + /// toggle boolean control group.key + static + LLSD toggle(const std::string& group, const std::string& key); + + /// get the definition for control group.key, (! isDefined()) if bad + /// ["name"], ["type"], ["value"], ["comment"] + static + LLSD get_def(const std::string& group, const std::string& key); + + /// get the value of control group.key + static + LLSD get(const std::string& group, const std::string& key); + + /// get defined groups + static + std::vector get_groups(); + + /// get definitions for all variables in group + static + LLSD get_vars(const std::string& group); + + private: + static + LLSD access(const LLSD& params); + }; +} // namespace LL + +#endif /* ! defined(LL_COMMONCONTROL_H) */ diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index d5adf11264..10d67abf37 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -17,15 +17,17 @@ // std headers // external library headers // other Linden headers +#include "commoncontrol.h" #include "llerror.h" #include "llevents.h" +#include "llsd.h" #include "stringize.h" LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity): super(name), mQueue(name, capacity), mName("ThreadPool:" + name), - mThreadCount(threads) + mThreadCount(getConfiguredWidth(name, threads)) {} void LL::ThreadPool::start() @@ -87,3 +89,50 @@ void LL::ThreadPool::run() { mQueue.runUntilClose(); } + +//static +size_t LL::ThreadPool::getConfiguredWidth(const std::string& name, size_t dft=0) +{ + LLSD poolSizes{ LL::CommonControl::get("Global", "ThreadPoolSizes") }; + // "ThreadPoolSizes" is actually a map containing the sizes of interest -- + // or should be, if this process has an "LLViewerControl" LLEventAPI + // instance and its settings include "ThreadPoolSizes". If we failed to + // retrieve it, perhaps we're in a program that doesn't define that, or + // perhaps there's no such setting, or perhaps we're asking too early, + // before the LLEventAPI itself has been instantiated. In any of those + // cases, it seems worth warning. + if (! poolSizes.isDefined()) + { + // Note: we don't warn about absence of an override key for a + // particular ThreadPool name, that's fine. This warning is about + // complete absence of a ThreadPoolSizes setting, which we expect in a + // normal viewer session. + LL_WARNS("ThreadPool") << "No 'ThreadPoolSizes' setting for ThreadPool '" + << name << "'" << LL_ENDL; + } + else + { + //LL_DEBUGS + LL_INFOS("ThreadPool") << "ThreadPoolSizes = " << poolSizes << LL_ENDL; + } + // LLSD treats an undefined value as an empty map when asked to retrieve a + // key, so we don't need this to be conditional. + LLSD sizeSpec{ poolSizes[name] }; + // We retrieve sizeSpec as LLSD, rather than immediately as LLSD::Integer, + // so we can distinguish the case when it's undefined. + return sizeSpec.isInteger() ? sizeSpec.asInteger() : dft; +} + +//static +size_t LL::ThreadPool::getWidth(const std::string& name, size_t dft) +{ + auto instance{ getInstance(name) }; + if (instance) + { + return instance->getWidth(); + } + else + { + return getConfiguredWidth(name, dft); + } +} diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h index f8eec3b457..b49d511257 100644 --- a/indra/llcommon/threadpool.h +++ b/indra/llcommon/threadpool.h @@ -30,8 +30,17 @@ namespace LL /** * Pass ThreadPool a string name. This can be used to look up the * relevant WorkQueue. + * + * The number of threads you pass sets the compile-time default. But + * if the user has overridden the LLSD map in the "ThreadPoolSizes" + * setting with a key matching this ThreadPool name, that setting + * overrides this parameter. + * + * Pass an explicit capacity to limit the size of the queue. + * Constraining the queue can cause a submitter to block. Do not + * constrain any ThreadPool accepting work from the main thread. */ - ThreadPool(const std::string& name, size_t threads=1, size_t capacity=1024); + ThreadPool(const std::string& name, size_t threads=1, size_t capacity=1024*1024); virtual ~ThreadPool(); /** @@ -59,6 +68,25 @@ namespace LL */ virtual void run(); + /** + * getConfiguredWidth() returns the setting, if any, for the specified + * ThreadPool name. Returns dft if the "ThreadPoolSizes" map does not + * contain the specified name. + */ + static + size_t getConfiguredWidth(const std::string& name, size_t dft=0); + + /** + * This getWidth() returns the width of the instantiated ThreadPool + * with the specified name, if any. If no instance exists, returns its + * getConfiguredWidth() if any. If there's no instance and no relevant + * override, return dft. Presumably dft should match the threads + * parameter passed to the ThreadPool constructor call that will + * eventually instantiate the ThreadPool with that name. + */ + static + size_t getWidth(const std::string& name, size_t dft); + private: void run(const std::string& name); -- cgit v1.2.3 From 276647789a7080c0d44ec8e4375daf0f42b73f17 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 9 Jun 2022 10:36:13 -0400 Subject: SL-17483: Simplify ThreadPool instantiations. Now that LL::ThreadPool's constructor has subsumed the work of discovering a runtime override width, LLAppViewer::initGeneralThread() can simply pass the compile-time default width instead of redundantly checking ThreadPoolSizes. Also the default ThreadPool capacity has been bumped up to what "General" and "LLImageGL" were requesting, so they need not pass that explicitly or explain in comments why they're doing it. But until we start throwing work at the "General" ThreadPool, configure it down to 1 thread in settings.xml. --- indra/llrender/llimagegl.cpp | 6 ++---- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llappviewer.cpp | 9 +-------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 9bd3a0a6b0..42460d23b8 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -2412,10 +2412,8 @@ void LLImageGL::checkActiveThread() std::atomic LLImageGLThread::sFreeVRAMMegabytes(4096); //if free vram is unknown, default to 4GB LLImageGLThread::LLImageGLThread(LLWindow* window) - // We want exactly one thread, but a very large capacity: we never want - // anyone, especially inner-loop render code, to have to block on post() - // because we're full. - : ThreadPool("LLImageGL", 1, 1024*1024) + // We want exactly one thread. + : ThreadPool("LLImageGL", 1) , mWindow(window) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 0000ae18bd..9c27e2a42e 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12766,7 +12766,7 @@ Value General - 4 + 1 ThrottleBandwidthKBPS diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 3bcd4f9a49..334df4ee20 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2183,14 +2183,7 @@ void LLAppViewer::initGeneralThread() return; } - LLSD poolSizes{ gSavedSettings.getLLSD("ThreadPoolSizes") }; - LLSD sizeSpec{ poolSizes["General"] }; - LLSD::Integer poolSize{ sizeSpec.isInteger() ? sizeSpec.asInteger() : 3 }; - LL_DEBUGS("ThreadPool") << "Instantiating General pool with " - << poolSize << " threads" << LL_ENDL; - // We don't want anyone, especially the main thread, to have to block - // due to this ThreadPool being full. - mGeneralThreadPool = new LL::ThreadPool("General", poolSize, 1024 * 1024); + mGeneralThreadPool = new LL::ThreadPool("General", 3); mGeneralThreadPool->start(); } -- cgit v1.2.3 From 1ff79a430d9d55cbb4b4ba55018c791a8a933916 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 9 Jun 2022 11:19:21 -0400 Subject: SL-17483: Fix ThreadPool::getConfiguredWidth() compile error. Log ThreadPoolSizes at DEBUG level, not INFO. --- indra/llcommon/threadpool.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index 10d67abf37..e8daf549ef 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -91,7 +91,7 @@ void LL::ThreadPool::run() } //static -size_t LL::ThreadPool::getConfiguredWidth(const std::string& name, size_t dft=0) +size_t LL::ThreadPool::getConfiguredWidth(const std::string& name, size_t dft) { LLSD poolSizes{ LL::CommonControl::get("Global", "ThreadPoolSizes") }; // "ThreadPoolSizes" is actually a map containing the sizes of interest -- @@ -112,8 +112,7 @@ size_t LL::ThreadPool::getConfiguredWidth(const std::string& name, size_t dft=0) } else { - //LL_DEBUGS - LL_INFOS("ThreadPool") << "ThreadPoolSizes = " << poolSizes << LL_ENDL; + LL_DEBUGS("ThreadPool") << "ThreadPoolSizes = " << poolSizes << LL_ENDL; } // LLSD treats an undefined value as an empty map when asked to retrieve a // key, so we don't need this to be conditional. -- cgit v1.2.3 From 125b099298652347991c521703109e12bccdd47e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Jun 2022 11:02:21 -0500 Subject: VS2019 build fix --- indra/llprimitive/llgltfloader.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/indra/llprimitive/llgltfloader.h b/indra/llprimitive/llgltfloader.h index 9ee816e24e..91389b5845 100644 --- a/indra/llprimitive/llgltfloader.h +++ b/indra/llprimitive/llgltfloader.h @@ -34,8 +34,10 @@ // gltf_* structs are temporary, used to organize the subset of data that eventually goes into the material LLSD -typedef struct // gltf sampler -{ // Uses GL enums +class gltf_sampler +{ +public: + // Uses GL enums S32 minFilter; // GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR or GL_LINEAR_MIPMAP_LINEAR S32 magFilter; // GL_NEAREST or GL_LINEAR S32 wrapS; // GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT or GL_REPEAT @@ -43,10 +45,11 @@ typedef struct // gltf sampler //S32 wrapR; // Found in some sample files, but not part of glTF 2.0 spec. Ignored. std::string name; // optional, currently unused // extensions and extras are sampler optional fields that we don't support - at least initially -} gltf_sampler; +}; -typedef struct // gltf image -{ // Note that glTF images are defined with row 0 at the top (opposite of OpenGL) +class gltf_image +{ +public:// Note that glTF images are defined with row 0 at the top (opposite of OpenGL) U8* data; // ptr to decoded image data U32 size; // in bytes, regardless of channel width U32 width; @@ -54,17 +57,19 @@ typedef struct // gltf image U32 numChannels; // range 1..4 U32 bytesPerChannel; // converted from gltf "bits", expects only 8, 16 or 32 as input U32 pixelType; // one of (TINYGLTF_COMPONENT_TYPE)_UNSIGNED_BYTE, _UNSIGNED_SHORT, _UNSIGNED_INT, or _FLOAT -} gltf_image; +}; -typedef struct // texture +class gltf_texture { +public: U32 imageIdx; U32 samplerIdx; LLUUID imageUuid = LLUUID::null; -} gltf_texture; +}; -typedef struct // render material +class gltf_render_material { +public: std::string name; // scalar values @@ -99,15 +104,16 @@ typedef struct // render material // This field is populated after upload LLUUID material_uuid = LLUUID::null; -} gltf_render_material; +}; -typedef struct // gltf_mesh +class gltf_mesh { +public: std::string name; // TODO add mesh import DJH 2022-04 -} gltf_mesh; +}; class LLGLTFLoader : public LLModelLoader { -- cgit v1.2.3 From 50dca86f64a167fe0db901310d04784b2f0dfa1f Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 9 Jun 2022 12:06:23 -0400 Subject: SL-17483: Recast LLImageDecodeThread as a facade for ThreadPool. Remove all references to LLQueuedThread (but emulate a couple bits of its API such as handle_t and getPending()). Migrate ImageRequest into llimageworker.cpp. It has never been part of LLImageDecodeThread's public API. Remove ImageRequest tests. Remove all references to LLImageDecodeThread::pause(). The idea of pausing another thread is bizarre to me, and LLThreadPool has no such operation. Nor does it have an abortRequest(). --- indra/llimage/llimageworker.cpp | 99 ++++++++++++++++++++---------- indra/llimage/llimageworker.h | 61 +++++------------- indra/llimage/tests/llimageworker_test.cpp | 66 -------------------- indra/newview/app_settings/settings.xml | 2 + indra/newview/llappviewer.cpp | 11 ++-- indra/newview/lltexturefetch.cpp | 6 +- indra/newview/llviewerwindow.cpp | 1 - indra/test/test.cpp | 2 +- 8 files changed, 91 insertions(+), 157 deletions(-) diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp index d8503396d7..3c21499673 100644 --- a/indra/llimage/llimageworker.cpp +++ b/indra/llimage/llimageworker.cpp @@ -28,44 +28,83 @@ #include "llimageworker.h" #include "llimagedxt.h" +#include "threadpool.h" + +/*--------------------------------------------------------------------------*/ +class ImageRequest +{ +public: + ImageRequest(LLPointer image, + S32 discard, BOOL needs_aux, + LLPointer responder); + virtual ~ImageRequest(); + + /*virtual*/ bool processRequest(); + /*virtual*/ void finishRequest(bool completed); + +private: + // input + LLPointer mFormattedImage; + S32 mDiscardLevel; + BOOL mNeedsAux; + // output + LLPointer mDecodedImageRaw; + LLPointer mDecodedImageAux; + BOOL mDecodedRaw; + BOOL mDecodedAux; + LLPointer mResponder; +}; + //---------------------------------------------------------------------------- // MAIN THREAD -LLImageDecodeThread::LLImageDecodeThread(bool threaded) - : LLQueuedThread("imagedecode", threaded) +LLImageDecodeThread::LLImageDecodeThread(bool /*threaded*/) { - mCreationMutex = new LLMutex(); + mThreadPool.reset(new LL::ThreadPool("ImageDecode", 8)); + mThreadPool->start(); } //virtual LLImageDecodeThread::~LLImageDecodeThread() -{ - delete mCreationMutex ; -} +{} // MAIN THREAD // virtual S32 LLImageDecodeThread::update(F32 max_time_ms) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - S32 res = LLQueuedThread::update(max_time_ms); - return res; + return getPending(); } -LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLImageFormatted* image, - S32 discard, BOOL needs_aux, Responder* responder) +S32 LLImageDecodeThread::getPending() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - handle_t handle = generateHandle(); + return mThreadPool->getQueue().size(); +} - ImageRequest* req = new ImageRequest(handle, image, - discard, needs_aux, - responder); +LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLPointer image, + S32 discard, BOOL needs_aux, LLPointer responder) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - addRequest(req); + // Instantiate the ImageRequest right in the lambda, why not? + mThreadPool->getQueue().post( + [req = ImageRequest(image, discard, needs_aux, responder)] + () mutable + { + auto done = req.processRequest(); + req.finishRequest(done); + }); + + // It's important to our consumer (LLTextureFetchWorker) that we return a + // nonzero handle. It is NOT important that the nonzero handle be unique: + // nothing is ever done with it except to compare it to zero, or zero it. + return 17; +} - return handle; +void LLImageDecodeThread::shutdown() +{ + mThreadPool->close(); } LLImageDecodeThread::Responder::~Responder() @@ -74,11 +113,10 @@ LLImageDecodeThread::Responder::~Responder() //---------------------------------------------------------------------------- -LLImageDecodeThread::ImageRequest::ImageRequest(handle_t handle, LLImageFormatted* image, - S32 discard, BOOL needs_aux, - LLImageDecodeThread::Responder* responder) - : LLQueuedThread::QueuedRequest(handle, FLAG_AUTO_COMPLETE), - mFormattedImage(image), +ImageRequest::ImageRequest(LLPointer image, + S32 discard, BOOL needs_aux, + LLPointer responder) + : mFormattedImage(image), mDiscardLevel(discard), mNeedsAux(needs_aux), mDecodedRaw(FALSE), @@ -87,7 +125,7 @@ LLImageDecodeThread::ImageRequest::ImageRequest(handle_t handle, LLImageFormatte { } -LLImageDecodeThread::ImageRequest::~ImageRequest() +ImageRequest::~ImageRequest() { mDecodedImageRaw = NULL; mDecodedImageAux = NULL; @@ -98,7 +136,7 @@ LLImageDecodeThread::ImageRequest::~ImageRequest() // Returns true when done, whether or not decode was successful. -bool LLImageDecodeThread::ImageRequest::processRequest() +bool ImageRequest::processRequest() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; const F32 decode_time_slice = 0.f; //disable time slicing @@ -125,7 +163,7 @@ bool LLImageDecodeThread::ImageRequest::processRequest() mFormattedImage->getHeight(), mFormattedImage->getComponents()); } - done = mFormattedImage->decode(mDecodedImageRaw, decode_time_slice); // 1ms + done = mFormattedImage->decode(mDecodedImageRaw, decode_time_slice); // some decoders are removing data when task is complete and there were errors mDecodedRaw = done && mDecodedImageRaw->getData(); } @@ -138,14 +176,14 @@ bool LLImageDecodeThread::ImageRequest::processRequest() mFormattedImage->getHeight(), 1); } - done = mFormattedImage->decodeChannels(mDecodedImageAux, decode_time_slice, 4, 4); // 1ms + done = mFormattedImage->decodeChannels(mDecodedImageAux, decode_time_slice, 4, 4); mDecodedAux = done && mDecodedImageAux->getData(); } return done; } -void LLImageDecodeThread::ImageRequest::finishRequest(bool completed) +void ImageRequest::finishRequest(bool completed) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if (mResponder.notNull()) @@ -155,10 +193,3 @@ void LLImageDecodeThread::ImageRequest::finishRequest(bool completed) } // Will automatically be deleted } - -// Used by unit test only -// Checks that a responder exists for this instance so that something can happen when completion is reached -bool LLImageDecodeThread::ImageRequest::tut_isOK() -{ - return mResponder.notNull(); -} diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h index e0a94d2841..6a0b2b4681 100644 --- a/indra/llimage/llimageworker.h +++ b/indra/llimage/llimageworker.h @@ -29,9 +29,13 @@ #include "llimage.h" #include "llpointer.h" -#include "llworkerthread.h" -class LLImageDecodeThread : public LLQueuedThread +namespace LL +{ + class ThreadPool; +} // namespace LL + +class LLImageDecodeThread { public: class Responder : public LLThreadSafeRefCount @@ -42,57 +46,24 @@ public: virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux) = 0; }; - class ImageRequest : public LLQueuedThread::QueuedRequest - { - protected: - virtual ~ImageRequest(); // use deleteRequest() - - public: - ImageRequest(handle_t handle, LLImageFormatted* image, - S32 discard, BOOL needs_aux, - LLImageDecodeThread::Responder* responder); - - /*virtual*/ bool processRequest(); - /*virtual*/ void finishRequest(bool completed); - - // Used by unit tests to check the consitency of the request instance - bool tut_isOK(); - - private: - // input - LLPointer mFormattedImage; - S32 mDiscardLevel; - BOOL mNeedsAux; - // output - LLPointer mDecodedImageRaw; - LLPointer mDecodedImageAux; - BOOL mDecodedRaw; - BOOL mDecodedAux; - LLPointer mResponder; - }; - public: LLImageDecodeThread(bool threaded = true); virtual ~LLImageDecodeThread(); - handle_t decodeImage(LLImageFormatted* image, + // meant to resemble LLQueuedThread::handle_t + typedef U32 handle_t; + handle_t decodeImage(LLPointer image, S32 discard, BOOL needs_aux, - Responder* responder); + LLPointer responder); + S32 getPending(); S32 update(F32 max_time_ms); + void shutdown(); private: - struct creation_info - { - handle_t handle; - LLPointer image; - S32 discard; - BOOL needs_aux; - LLPointer responder; - creation_info(handle_t h, LLImageFormatted* i, U32 p, S32 d, BOOL aux, Responder* r) - : handle(h), image(i), discard(d), needs_aux(aux), responder(r) - {} - }; - LLMutex* mCreationMutex; + // As of SL-17483, LLImageDecodeThread is no longer itself an + // LLQueuedThread - instead this is the API by which we submit work to the + // "ImageDecode" ThreadPool. + std::unique_ptr mThreadPool; }; #endif diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index d36d35aba4..0a97b739b0 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -125,42 +125,11 @@ namespace tut } }; - // Test wrapper declaration : image worker - // Note: this class is not meant to be instantiated outside an LLImageDecodeThread instance - // but it's not a bad idea to get its public API a good shake as part of a thorough unit test set. - // Some gotcha with the destructor though (see below). - struct imagerequest_test - { - // Instance to be tested - LLImageDecodeThread::ImageRequest* mRequest; - bool done; - - // Constructor and destructor of the test wrapper - imagerequest_test() - { - done = false; - - mRequest = new LLImageDecodeThread::ImageRequest(0, 0, - 0, FALSE, - new responder_test(&done)); - } - ~imagerequest_test() - { - // We should delete the object *but*, because its destructor is protected, that cannot be - // done from outside an LLImageDecodeThread instance... So we leak memory here... It's fine... - //delete mRequest; - } - }; - // Tut templating thingamagic: test group, object and test instance typedef test_group imagedecodethread_t; typedef imagedecodethread_t::object imagedecodethread_object_t; tut::imagedecodethread_t tut_imagedecodethread("LLImageDecodeThread"); - typedef test_group imagerequest_t; - typedef imagerequest_t::object imagerequest_object_t; - tut::imagerequest_t tut_imagerequest("LLImageRequest"); - // --------------------------------------------------------------------------------------- // Test functions // Notes: @@ -172,21 +141,6 @@ namespace tut // --------------------------------------------------------------------------------------- // Test the LLImageDecodeThread interface // --------------------------------------------------------------------------------------- - // - // Note on Unit Testing Queued Thread Classes - // - // Since methods on such a class are called on a separate loop and that we can't insert tut - // ensure() calls in there, we exercise the class with 2 sets of tests: - // - 1: Test as a single threaded instance: We declare the class but ask for no thread - // to be spawned (easy with LLThreads since there's a boolean argument on the constructor - // just for that). We can then unit test each public method like we do on a normal class. - // - 2: Test as a threaded instance: We let the thread launch and check that its external - // behavior is as expected (i.e. it runs, can accept a work order and processes - // it). Typically though there's no guarantee that this exercises all the methods of the - // class which is why we also need the previous "non threaded" set of unit tests for - // complete coverage. - // - // --------------------------------------------------------------------------------------- template<> template<> void imagedecodethread_object_t::test<1>() @@ -211,24 +165,4 @@ namespace tut // Verifies that the responder has now been called ensure("LLImageDecodeThread: threaded work unit not processed", done == true); } - - // --------------------------------------------------------------------------------------- - // Test the LLImageDecodeThread::ImageRequest interface - // --------------------------------------------------------------------------------------- - - template<> template<> - void imagerequest_object_t::test<1>() - { - // Test that we start with a correct request at creation - ensure("LLImageDecodeThread::ImageRequest::ImageRequest() constructor test failed", mRequest->tut_isOK()); - bool res = mRequest->processRequest(); - // Verifies that we processed the request successfully - ensure("LLImageDecodeThread::ImageRequest::processRequest() processing request test failed", res == true); - // Check that we can call the finishing call safely - try { - mRequest->finishRequest(false); - } catch (...) { - fail("LLImageDecodeThread::ImageRequest::finishRequest() test failed"); - } - } } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 3201848f38..bc4945eca5 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12646,6 +12646,8 @@ General 1 + ImageDecode + 9 ThrottleBandwidthKBPS diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index bc38a96ef2..ae0c9d4dd6 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1548,7 +1548,6 @@ bool LLAppViewer::doFrame() { S32 non_interactive_ms_sleep_time = 100; LLAppViewer::getTextureCache()->pause(); - LLAppViewer::getImageDecodeThread()->pause(); ms_sleep(non_interactive_ms_sleep_time); } @@ -1568,7 +1567,6 @@ bool LLAppViewer::doFrame() ms_sleep(milliseconds_to_sleep); // also pause worker threads during this wait period LLAppViewer::getTextureCache()->pause(); - LLAppViewer::getImageDecodeThread()->pause(); } } @@ -1617,7 +1615,6 @@ bool LLAppViewer::doFrame() { LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df getTextureCache" ) LLAppViewer::getTextureCache()->pause(); - LLAppViewer::getImageDecodeThread()->pause(); LLAppViewer::getTextureFetch()->pause(); } if(!total_io_pending) //pause file threads if nothing to process. @@ -2051,10 +2048,10 @@ bool LLAppViewer::cleanup() sTextureCache->shutdown(); sImageDecodeThread->shutdown(); sPurgeDiskCacheThread->shutdown(); - if (mGeneralThreadPool) - { - mGeneralThreadPool->close(); - } + if (mGeneralThreadPool) + { + mGeneralThreadPool->close(); + } sTextureFetch->shutDownTextureCacheThread() ; sTextureFetch->shutDownImageDecodeThread() ; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 64ccbf5e4a..539e2454ea 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2113,10 +2113,10 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe // Threads: Tmain void LLTextureFetchWorker::endWork(S32 param, bool aborted) { - LL_PROFILE_ZONE_SCOPED; + LL_PROFILE_ZONE_SCOPED; if (mDecodeHandle != 0) { - mFetcher->mImageDecodeThread->abortRequest(mDecodeHandle, false); + // LL::ThreadPool has no operation to cancel a particular work item mDecodeHandle = 0; } mFormattedImage = NULL; @@ -3169,7 +3169,7 @@ void LLTextureFetch::shutDownImageDecodeThread() { if(mImageDecodeThread) { - llassert_always(mImageDecodeThread->isQuitting() || mImageDecodeThread->isStopped()) ; + delete mImageDecodeThread; mImageDecodeThread = NULL ; } } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index e27b5caab7..15f20d1d34 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5476,7 +5476,6 @@ void LLViewerWindow::stopGL(BOOL save_state) // Pause texture decode threads (will get unpaused during main loop) LLAppViewer::getTextureCache()->pause(); - LLAppViewer::getImageDecodeThread()->pause(); LLAppViewer::getTextureFetch()->pause(); gSky.destroyGL(); diff --git a/indra/test/test.cpp b/indra/test/test.cpp index bb48216b2b..28f25087ac 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -401,7 +401,7 @@ public: { // Per http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ServiceMessages std::string result; - BOOST_FOREACH(char c, str) + for (char c : str) { switch (c) { -- cgit v1.2.3 From 5b76111b2796372e7558dcda7493b6536c7962f9 Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Thu, 9 Jun 2022 10:02:49 -0700 Subject: tinygltf updated with new public build for SL-17214 --- autobuild.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index f80ed200a0..1a9605b11d 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -3140,9 +3140,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors archive hash - 13ebc64d8ba6276105a3fd516c7224f0 + 7fd9a99cea31809c89759905fbba30c9 url - https://s3-proxy.lindenlab.com/private-builds-secondlife-com/ct2/100740/887434/tinygltf-v2.5.0-windows64-572388.tar.bz2 + https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/100928/888701/tinygltf-v2.5.0-windows64-572493.tar.bz2 name windows64 -- cgit v1.2.3 From d1dc9c35a94233f250a729becf9ccd4d88197198 Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Thu, 9 Jun 2022 10:06:21 -0700 Subject: tinygltf also updated mac and 32bit windows packages with new public build for SL-17214 --- autobuild.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index 1a9605b11d..aaff2d1360 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -3116,9 +3116,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors archive hash - 13ebc64d8ba6276105a3fd516c7224f0 + 7fd9a99cea31809c89759905fbba30c9 url - https://s3-proxy.lindenlab.com/private-builds-secondlife-com/ct2/100740/887434/tinygltf-v2.5.0-windows64-572388.tar.bz2 + https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/100928/888701/tinygltf-v2.5.0-windows64-572493.tar.bz2 name darwin64 @@ -3128,9 +3128,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors archive hash - 13ebc64d8ba6276105a3fd516c7224f0 + 7fd9a99cea31809c89759905fbba30c9 url - https://s3-proxy.lindenlab.com/private-builds-secondlife-com/ct2/100740/887434/tinygltf-v2.5.0-windows64-572388.tar.bz2 + https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/100928/888701/tinygltf-v2.5.0-windows64-572493.tar.bz2 name windows -- cgit v1.2.3 From 0d9c23372bf8b34387b7d9de89234d3e9a5fd879 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Jun 2022 14:09:33 -0500 Subject: SL-17551 Add "Select Reflection Probes" menu option and make invisible objects less annoying when alt-zooming in edit mode. --- indra/newview/app_settings/settings.xml | 11 ++++++++ indra/newview/llcontrolavatar.cpp | 5 ++-- indra/newview/llcontrolavatar.h | 1 + indra/newview/llpanelvolume.cpp | 2 +- indra/newview/llreflectionmap.cpp | 2 +- indra/newview/llselectmgr.cpp | 8 +++--- indra/newview/llspatialpartition.cpp | 16 +++++++----- indra/newview/llspatialpartition.h | 2 ++ indra/newview/lltoolselect.cpp | 5 +++- indra/newview/llviewermenu.cpp | 13 ++++++++++ indra/newview/llviewerobject.cpp | 13 +--------- indra/newview/llviewerobject.h | 6 ++--- indra/newview/llviewerobjectlist.cpp | 6 +++++ indra/newview/llviewerwindow.cpp | 29 ++++++++++------------ indra/newview/llviewerwindow.h | 3 ++- indra/newview/llvoavatar.cpp | 4 ++- indra/newview/llvoavatar.h | 2 ++ indra/newview/llvograss.cpp | 2 +- indra/newview/llvograss.h | 1 + indra/newview/llvopartgroup.cpp | 1 + indra/newview/llvopartgroup.h | 1 + indra/newview/llvosurfacepatch.cpp | 2 +- indra/newview/llvosurfacepatch.h | 1 + indra/newview/llvotree.cpp | 2 +- indra/newview/llvotree.h | 1 + indra/newview/llvovolume.cpp | 18 ++++++++++---- indra/newview/llvovolume.h | 3 ++- indra/newview/pipeline.cpp | 11 ++++---- indra/newview/pipeline.h | 1 + indra/newview/skins/default/xui/en/menu_viewer.xml | 9 +++++++ 30 files changed, 120 insertions(+), 61 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f6c5d46c33..6df71e1019 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11191,6 +11191,17 @@ Value 0 + SelectReflectionProbes + + Comment + Select reflection probes + Persist + 1 + Type + Boolean + Value + 1 + SelectOwnedOnly Comment diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index 4a87273372..d4d4f641cf 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -610,6 +610,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -627,7 +628,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV { LLVector4a local_end = end; LLVector4a local_intersection; - if (mRootVolp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (mRootVolp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) @@ -644,7 +645,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV for (std::vector::iterator vol_it = volumes.begin(); vol_it != volumes.end(); ++vol_it) { LLVOVolume *volp = *vol_it; - if (mRootVolp != volp && volp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (mRootVolp != volp && volp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) diff --git a/indra/newview/llcontrolavatar.h b/indra/newview/llcontrolavatar.h index 8e87299f3e..ea91d70e69 100644 --- a/indra/newview/llcontrolavatar.h +++ b/indra/newview/llcontrolavatar.h @@ -68,6 +68,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index f456ee4d4b..fb2cf484f5 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -371,7 +371,7 @@ void LLPanelVolume::getState( ) } // Reflection Probe - BOOL is_probe = volobjp && volobjp->getIsReflectionProbe(); + BOOL is_probe = volobjp && volobjp->isReflectionProbe(); getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index f8a2020ccb..5991d7a170 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -139,7 +139,7 @@ void LLReflectionMap::autoAdjustOrigin() { int face = -1; LLVector4a intersection; - LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, &face, &intersection); + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); if (drawable != nullptr) { hit = true; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 82a165cb35..7b4ba51859 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1066,8 +1066,9 @@ void LLSelectMgr::highlightObjectOnly(LLViewerObject* objectp) return; } - if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) - || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced()))) + if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) + || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced())) + || (!gSavedSettings.getBOOL("SelectReflectionProbes") && !objectp->isReflectionProbe())) { // only select my own objects return; @@ -7127,7 +7128,8 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object, BOOL ignore_select_own if(!ignore_select_owned) { if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) || - (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced()))) + (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced())) || + (!gSavedSettings.getBOOL("SelectReflectionProbes") && object->isReflectionProbe())) { // only select my own objects return FALSE; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 39bb46e6fa..a9e807e0f6 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3819,8 +3819,9 @@ public: LLDrawable* mHit; BOOL mPickTransparent; BOOL mPickRigged; + BOOL mPickUnselectable; - LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) : mStart(start), mEnd(end), @@ -3831,7 +3832,8 @@ public: mTangent(tangent), mHit(NULL), mPickTransparent(pick_transparent), - mPickRigged(pick_rigged) + mPickRigged(pick_rigged), + mPickUnselectable(pick_unselectable) { } @@ -3916,7 +3918,7 @@ public: LLVOAvatar* avatar = (LLVOAvatar*) vobj; if ((mPickRigged) || ((avatar->isSelf()) && (LLFloater::isVisible(gFloaterTools)))) { - LLViewerObject* hit = avatar->lineSegmentIntersectRiggedAttachments(mStart, mEnd, -1, mPickTransparent, mPickRigged, mFaceHit, &intersection, mTexCoord, mNormal, mTangent); + LLViewerObject* hit = avatar->lineSegmentIntersectRiggedAttachments(mStart, mEnd, -1, mPickTransparent, mPickRigged, mPickUnselectable, mFaceHit, &intersection, mTexCoord, mNormal, mTangent); if (hit) { mEnd = intersection; @@ -3932,7 +3934,7 @@ public: } } - if (!skip_check && vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mPickRigged, mFaceHit, &intersection, mTexCoord, mNormal, mTangent)) + if (!skip_check && vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mPickRigged, mPickUnselectable, mFaceHit, &intersection, mTexCoord, mNormal, mTangent)) { mEnd = intersection; // shorten ray so we only find CLOSER hits if (mIntersection) @@ -3952,6 +3954,7 @@ public: LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3960,7 +3963,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co ) { - LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, face_hit, intersection, tex_coord, normal, tangent); + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, tex_coord, normal, tangent); LLDrawable* drawable = intersect.check(mOctree); return drawable; @@ -3969,6 +3972,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3977,7 +3981,7 @@ LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const ) { - LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, face_hit, intersection, tex_coord, normal, tangent); + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, tex_coord, normal, tangent); LLDrawable* drawable = intersect.check(getOctreeNode()); return drawable; diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index e9d84ecf06..bebd8aec85 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -317,6 +317,7 @@ public: LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -400,6 +401,7 @@ public: LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index e52bc0b015..790d9a8ec5 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -84,12 +84,14 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi } BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly"); BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly"); - + BOOL select_probe = gSavedSettings.getBOOL("SelectReflectionProbes"); + // *NOTE: These settings must be cleaned up at bottom of function. if (temp_select || LLSelectMgr::getInstance()->mAllowSelectAvatar) { gSavedSettings.setBOOL("SelectOwnedOnly", FALSE); gSavedSettings.setBOOL("SelectMovableOnly", FALSE); + gSavedSettings.setBOOL("SelectReflectionProbes", FALSE); LLSelectMgr::getInstance()->setForceSelection(TRUE); } @@ -241,6 +243,7 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi { gSavedSettings.setBOOL("SelectOwnedOnly", select_owned); gSavedSettings.setBOOL("SelectMovableOnly", select_movable); + gSavedSettings.setBOOL("SelectReflectionProbes", select_probe); LLSelectMgr::getInstance()->setForceSelection(FALSE); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9c8a666185..b99299528c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7971,6 +7971,18 @@ class LLToolsSelectOnlyMovableObjects : public view_listener_t } }; +class LLToolsSelectReflectionProbes : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + BOOL cur_val = gSavedSettings.getBOOL("SelectReflectionProbes"); + + gSavedSettings.setBOOL("SelectReflectionProbes", !cur_val); + + return true; + } +}; + class LLToolsSelectBySurrounding : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -9200,6 +9212,7 @@ void initialize_menus() view_listener_t::addMenu(new LLToolsSelectTool(), "Tools.SelectTool"); view_listener_t::addMenu(new LLToolsSelectOnlyMyObjects(), "Tools.SelectOnlyMyObjects"); view_listener_t::addMenu(new LLToolsSelectOnlyMovableObjects(), "Tools.SelectOnlyMovableObjects"); + view_listener_t::addMenu(new LLToolsSelectReflectionProbes(), "Tools.SelectReflectionProbes"); view_listener_t::addMenu(new LLToolsSelectBySurrounding(), "Tools.SelectBySurrounding"); view_listener_t::addMenu(new LLToolsShowHiddenSelection(), "Tools.ShowHiddenSelection"); view_listener_t::addMenu(new LLToolsShowSelectionLightRadius(), "Tools.ShowSelectionLightRadius"); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 732beab448..d60fccdee3 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4573,6 +4573,7 @@ BOOL LLViewerObject::lineSegmentIntersect(const LLVector4a& start, const LLVecto S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -5509,18 +5510,6 @@ S32 LLViewerObject::countInventoryContents(LLAssetType::EType type) return count; } - -void LLViewerObject::setCanSelect(BOOL canSelect) -{ - mbCanSelect = canSelect; - for (child_list_t::iterator iter = mChildList.begin(); - iter != mChildList.end(); iter++) - { - LLViewerObject* child = *iter; - child->mbCanSelect = canSelect; - } -} - void LLViewerObject::setDebugText(const std::string &utf8text) { if (utf8text.empty() && !mText) diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 5b6d24887c..ddb0adaa23 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -239,6 +239,7 @@ public: virtual BOOL isMesh() const { return FALSE; } virtual BOOL isRiggedMesh() const { return FALSE; } virtual BOOL hasLightTexture() const { return FALSE; } + virtual BOOL isReflectionProbe() const { return FALSE; } // This method returns true if the object is over land owned by // the agent, one of its groups, or it encroaches and @@ -280,6 +281,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -421,8 +423,6 @@ public: void sendMaterialUpdate() const; - void setCanSelect(BOOL canSelect); - void setDebugText(const std::string &utf8text); void initHudText(); void restoreHudText(); @@ -678,7 +678,7 @@ public: // Selection, picking and rendering variables U32 mGLName; // GL "name" used by selection code - BOOL mbCanSelect; // true if user can select this object by clicking + BOOL mbCanSelect; // true if user can select this object by clicking under any circumstances (even if pick_unselectable is true) private: // Grabbed from UPDATE_FLAGS diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 0e585f13fc..593f593a0f 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1838,6 +1838,8 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 ¢er) void LLViewerObjectList::generatePickList(LLCamera &camera) { + llassert(false); +#if 0 //deprecated LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; LLViewerObject *objectp; @@ -1961,10 +1963,13 @@ void LLViewerObjectList::generatePickList(LLCamera &camera) LLHUDIcon::generatePickIDs(i * step, step); } +#endif } LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) { + llassert(false); +#if 0 std::set::iterator pick_it; for (pick_it = mSelectPickList.begin(); pick_it != mSelectPickList.end(); ++pick_it) { @@ -1973,6 +1978,7 @@ LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) return (*pick_it); } } +#endif return NULL; } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 6a60671040..6613c8ac01 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3371,7 +3371,7 @@ void LLViewerWindow::updateUI() if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) { gDebugRaycastFaceHit = -1; - gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, + gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, &gDebugRaycastFaceHit, &gDebugRaycastIntersection, &gDebugRaycastTexCoord, @@ -4195,13 +4195,11 @@ void LLViewerWindow::pickAsync( S32 x, BOOL pick_rigged, BOOL pick_unselectable) { - BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); - if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) - { - // build mode allows interaction with all transparent objects - // "Show Debug Alpha" means no object actually transparent - pick_transparent = TRUE; - } + // "Show Debug Alpha" means no object actually transparent + if (LLDrawPoolAlpha::sShowDebugAlpha) + { + pick_transparent = TRUE; + } LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, FALSE, TRUE, pick_unselectable, callback); schedulePick(pick_info); @@ -4259,7 +4257,7 @@ void LLViewerWindow::returnEmptyPicks() } // Performs the GL object/land pick. -LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle) +LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, BOOL pick_unselectable) { BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) @@ -4308,6 +4306,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de S32 this_face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a *intersection, LLVector2 *uv, @@ -4378,7 +4377,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de { if (this_object->isHUDAttachment()) // is a HUD object? { - if (this_object->lineSegmentIntersect(mh_start, mh_end, this_face, pick_transparent, pick_rigged, + if (this_object->lineSegmentIntersect(mh_start, mh_end, this_face, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent)) { found = this_object; @@ -4386,7 +4385,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de } else // is a world object { - if (this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent, pick_rigged, + if (this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent)) { found = this_object; @@ -4400,7 +4399,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de if (!found) // if not found in HUD, look in world: { - found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, pick_rigged, + found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent); if (found && !pick_transparent) { @@ -5007,8 +5006,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei F32 depth_conversion_factor_1 = (LLViewerCamera::getInstance()->getFar() + LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear()); F32 depth_conversion_factor_2 = (LLViewerCamera::getInstance()->getFar() - LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear()); - gObjectList.generatePickList(*LLViewerCamera::getInstance()); - // Subimages are in fact partial rendering of the final view. This happens when the final view is bigger than the screen. // In most common cases, scale_factor is 1 and there's no more than 1 iteration on x and y for (int subimage_y = 0; subimage_y < scale_factor; ++subimage_y) @@ -6060,7 +6057,7 @@ void LLPickInfo::fetchResults() } LLViewerObject* hit_object = gViewerWindow->cursorIntersect(mMousePt.mX, mMousePt.mY, 512.f, - NULL, -1, mPickTransparent, mPickRigged, &face_hit, + NULL, -1, mPickTransparent, mPickRigged, mPickUnselectable, &face_hit, &intersection, &uv, &normal, &tangent, &start, &end); mPickPt = mMousePt; @@ -6205,7 +6202,7 @@ void LLPickInfo::getSurfaceInfo() if (objectp) { if (gViewerWindow->cursorIntersect(ll_round((F32)mMousePt.mX), ll_round((F32)mMousePt.mY), 1024.f, - objectp, -1, mPickTransparent, mPickRigged, + objectp, -1, mPickTransparent, mPickRigged, mPickUnselectable, &mObjectFace, &intersection, &mSTCoords, diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index c9cf7da8c7..38ec0e1ac8 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -405,7 +405,7 @@ public: BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, BOOL pick_unselectable = FALSE); - LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent, BOOL pick_rigged = FALSE, BOOL pick_particle = FALSE); + LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent, BOOL pick_rigged = FALSE, BOOL pick_particle = FALSE, BOOL pick_unselectable = TRUE); LLHUDIcon* cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 depth, LLVector4a* intersection); @@ -414,6 +414,7 @@ public: S32 this_face = -1, BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, LLVector4a *intersection = NULL, LLVector2 *uv = NULL, diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 314c22eb6c..4ec5c999ac 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1777,6 +1777,7 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -1883,6 +1884,7 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -1913,7 +1915,7 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector { LLViewerObject* attached_object = attachment_iter->get(); - if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 3c3decaad6..a085d773dc 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -164,6 +164,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -174,6 +175,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 9a41eedb54..d109b7b34f 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -758,7 +758,7 @@ void LLVOGrass::updateDrawable(BOOL force_damped) } // virtual -BOOL LLVOGrass::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOGrass::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvograss.h b/indra/newview/llvograss.h index 5634e048eb..63876dc099 100644 --- a/indra/newview/llvograss.h +++ b/indra/newview/llvograss.h @@ -79,6 +79,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 04e9a4f179..cb4315a774 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -485,6 +485,7 @@ BOOL LLVOPartGroup::lineSegmentIntersect(const LLVector4a& start, const LLVector S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h index 4e4d6e609d..a45d381dfa 100644 --- a/indra/newview/llvopartgroup.h +++ b/indra/newview/llvopartgroup.h @@ -74,6 +74,7 @@ public: S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index b0af565867..6b56eaeb4a 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -880,7 +880,7 @@ void LLVOSurfacePatch::getGeomSizesEast(const S32 stride, const S32 east_stride, } } -BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvosurfacepatch.h b/indra/newview/llvosurfacepatch.h index 884dbb3be3..aed67162d1 100644 --- a/indra/newview/llvosurfacepatch.h +++ b/indra/newview/llvosurfacepatch.h @@ -85,6 +85,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 493162b47b..e26791aa29 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -1170,7 +1170,7 @@ void LLVOTree::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) mDrawable->setPositionGroup(pos); } -BOOL LLVOTree::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOTree::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h index 93c22d2da3..996e970cf8 100644 --- a/indra/newview/llvotree.h +++ b/indra/newview/llvotree.h @@ -111,6 +111,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 6aef9ee7c0..8f5d2d1c29 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -986,7 +986,7 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) gPipeline.setLight(mDrawable, TRUE); } - if (getIsReflectionProbe()) + if (isReflectionProbe()) { updateReflectionProbePtr(); } @@ -3503,7 +3503,7 @@ F32 LLVOVolume::getLightCutoff() const void LLVOVolume::setIsReflectionProbe(BOOL is_probe) { - BOOL was_probe = getIsReflectionProbe(); + BOOL was_probe = isReflectionProbe(); if (is_probe != was_probe) { if (is_probe) @@ -3559,7 +3559,7 @@ void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenc } -BOOL LLVOVolume::getIsReflectionProbe() const +BOOL LLVOVolume::isReflectionProbe() const { // HACK - make this object a Reflection Probe if a certain UUID is detected static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); @@ -4507,7 +4507,7 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u void LLVOVolume::updateReflectionProbePtr() { - if (getIsReflectionProbe()) + if (isReflectionProbe()) { if (mReflectionProbe.isNull()) { @@ -4717,7 +4717,7 @@ LLVector3 LLVOVolume::volumeDirectionToAgent(const LLVector3& dir) const } -BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { @@ -4728,6 +4728,14 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& return FALSE; } + if (!pick_unselectable) + { + if (!LLSelectMgr::instance().canSelectObject(this)) + { + return FALSE; + } + } + BOOL ret = FALSE; LLVolume* volume = getVolume(); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 93a10781c2..ad7a2c5606 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -151,6 +151,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -290,7 +291,7 @@ public: void setReflectionProbeNearClip(F32 near_clip); void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); - BOOL getIsReflectionProbe() const; + BOOL isReflectionProbe() const override; F32 getReflectionProbeAmbiance() const; F32 getReflectionProbeNearClip() const; LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3332185bfd..20a21a685c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6988,7 +6988,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_PARTICLE); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, face_hit, &position, NULL, NULL, NULL); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, TRUE, face_hit, &position, NULL, NULL, NULL); if (hit) { drawable = hit; @@ -7016,6 +7016,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, bool pick_rigged, + bool pick_unselectable, S32* face_hit, LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -7049,7 +7050,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(j); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7106,7 +7107,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_AVATAR); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); if (hit) { LLVector4a delta; @@ -7194,7 +7195,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector4a& start, c LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); if (part) { - LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, face_hit, intersection, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, TRUE, face_hit, intersection, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7695,7 +7696,7 @@ void LLPipeline::renderFinalize() LLVector4a result; result.clear(); - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, NULL, &result); + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); focus_point.set(result.getF32ptr()); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index bb2e1d65ae..f4c55bde7d 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -188,6 +188,7 @@ public: LLViewerObject* lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, bool pick_rigged, + bool pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 0b0f8e17bc..159b9aebd0 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1417,6 +1417,15 @@ function="World.EnvPreset" function="Tools.SelectOnlyMovableObjects" parameter="movable" /> + + + + -- cgit v1.2.3 From bc85cc300d32c543ab80204a9b2fcf54b4b11935 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Jun 2022 14:26:23 -0500 Subject: SL-17551 Followup -- remove some dead pick-render related code. --- indra/newview/lldrawable.cpp | 3 - indra/newview/llhudicon.cpp | 52 +---------- indra/newview/llhudicon.h | 5 - indra/newview/llviewerobject.cpp | 1 - indra/newview/llviewerobject.h | 6 +- indra/newview/llviewerobjectlist.cpp | 173 +---------------------------------- indra/newview/llviewerobjectlist.h | 8 -- 7 files changed, 6 insertions(+), 242 deletions(-) diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 4a0c9d399f..bfb79f3a4c 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -249,12 +249,9 @@ void LLDrawable::cleanupReferences() { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; - std::for_each(mFaces.begin(), mFaces.end(), DeletePointer()); mFaces.clear(); - gObjectList.removeDrawable(this); - gPipeline.unlinkDrawable(this); removeFromOctree(); diff --git a/indra/newview/llhudicon.cpp b/indra/newview/llhudicon.cpp index 85a878c4a2..60294f6a51 100644 --- a/indra/newview/llhudicon.cpp +++ b/indra/newview/llhudicon.cpp @@ -64,7 +64,6 @@ LLHUDIcon::icon_instance_t LLHUDIcon::sIconInstances; LLHUDIcon::LLHUDIcon(const U8 type) : LLHUDObject(type), mImagep(NULL), - mPickID(0), mScale(0.1f), mHidden(FALSE) { @@ -76,15 +75,11 @@ LLHUDIcon::~LLHUDIcon() mImagep = NULL; } -void LLHUDIcon::renderIcon(BOOL for_select) +void LLHUDIcon::render() { LLGLSUIDefault texture_state; LLGLDepthTest gls_depth(GL_TRUE); LLGLDisable gls_stencil(GL_STENCIL_TEST); - if (for_select) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } if (mHidden) return; @@ -116,7 +111,7 @@ void LLHUDIcon::renderIcon(BOOL for_select) mDistance = dist_vec(icon_position, camera->getOrigin()); - F32 alpha_factor = for_select ? 1.f : clamp_rescale(mDistance, DIST_START_FADE, DIST_END_FADE, 1.f, 0.f); + F32 alpha_factor = clamp_rescale(mDistance, DIST_START_FADE, DIST_END_FADE, 1.f, 0.f); LLVector3 x_pixel_vec; LLVector3 y_pixel_vec; @@ -150,13 +145,6 @@ void LLHUDIcon::renderIcon(BOOL for_select) LLVector3 upper_left = icon_position - (x_scale * 0.5f) + y_scale; LLVector3 upper_right = icon_position + (x_scale * 0.5f) + y_scale; - if (for_select) - { - // set color to unique color id for picking - LLColor4U coloru((U8)(mPickID >> 16), (U8)(mPickID >> 8), (U8)mPickID); - gGL.color4ubv(coloru.mV); - } - else { LLColor4 icon_color = LLColor4::white; icon_color.mV[VALPHA] = alpha_factor; @@ -198,11 +186,6 @@ void LLHUDIcon::markDead() LLHUDObject::markDead(); } -void LLHUDIcon::render() -{ - renderIcon(FALSE); -} - BOOL LLHUDIcon::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection) { if (mHidden) @@ -295,37 +278,6 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& return FALSE; } -//static -S32 LLHUDIcon::generatePickIDs(S32 start_id, S32 step_size) -{ - S32 cur_id = start_id; - icon_instance_t::iterator icon_it; - - for(icon_it = sIconInstances.begin(); icon_it != sIconInstances.end(); ++icon_it) - { - (*icon_it)->mPickID = cur_id; - cur_id += step_size; - } - - return cur_id; -} - -//static -LLHUDIcon* LLHUDIcon::handlePick(S32 pick_id) -{ - icon_instance_t::iterator icon_it; - - for(icon_it = sIconInstances.begin(); icon_it != sIconInstances.end(); ++icon_it) - { - if (pick_id == (*icon_it)->mPickID) - { - return *icon_it; - } - } - - return NULL; -} - //static LLHUDIcon* LLHUDIcon::lineSegmentIntersectAll(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection) { diff --git a/indra/newview/llhudicon.h b/indra/newview/llhudicon.h index e00a985ddc..7f452b5c36 100644 --- a/indra/newview/llhudicon.h +++ b/indra/newview/llhudicon.h @@ -56,8 +56,6 @@ public: void restartLifeTimer() { mLifeTimer.reset(); } - static S32 generatePickIDs(S32 start_id, S32 step_size); - static LLHUDIcon* handlePick(S32 pick_id); static LLHUDIcon* lineSegmentIntersectAll(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection); static void updateAll(); @@ -75,14 +73,11 @@ protected: LLHUDIcon(const U8 type); ~LLHUDIcon(); - void renderIcon(BOOL for_select); // common render code - private: LLPointer mImagep; LLFrameTimer mAnimTimer; LLFrameTimer mLifeTimer; F32 mDistance; - S32 mPickID; F32 mScale; BOOL mHidden; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index d60fccdee3..857a94d7be 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -259,7 +259,6 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mTEImages(NULL), mTENormalMaps(NULL), mTESpecularMaps(NULL), - mGLName(0), mbCanSelect(TRUE), mFlags(0), mPhysicsShapeType(0), diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index ddb0adaa23..1c4cfc6466 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -676,9 +676,9 @@ public: LLPointer *mTENormalMaps; LLPointer *mTESpecularMaps; - // Selection, picking and rendering variables - U32 mGLName; // GL "name" used by selection code - BOOL mbCanSelect; // true if user can select this object by clicking under any circumstances (even if pick_unselectable is true) + // true if user can select this object by clicking under any circumstances (even if pick_unselectable is true) + // can likely be factored out + BOOL mbCanSelect; private: // Grabbed from UPDATE_FLAGS diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 593f593a0f..47a996d894 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1339,38 +1339,13 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp) } // Don't clean up mObject references, these will be cleaned up more efficiently later! - // Also, not cleaned up - removeDrawable(objectp->mDrawable); - + if(new_dead_object) { mNumDeadObjects++; } } -void LLViewerObjectList::removeDrawable(LLDrawable* drawablep) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; - - if (!drawablep) - { - return; - } - - for (S32 i = 0; i < drawablep->getNumFaces(); i++) - { - LLFace* facep = drawablep->getFace(i) ; - if(facep) - { - LLViewerObject* objectp = facep->getViewerObject(); - if(objectp) - { - mSelectPickList.erase(objectp); - } - } - } -} - BOOL LLViewerObjectList::killObject(LLViewerObject *objectp) { // Don't ever kill gAgentAvatarp, just force it to the agent's region @@ -1836,152 +1811,6 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 ¢er) { } -void LLViewerObjectList::generatePickList(LLCamera &camera) -{ - llassert(false); -#if 0 //deprecated - LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; - - LLViewerObject *objectp; - S32 i; - // Reset all of the GL names to zero. - for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) - { - (*iter)->mGLName = 0; - } - - mSelectPickList.clear(); - - std::vector pick_drawables; - - for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); - iter != LLWorld::getInstance()->getRegionList().end(); ++iter) - { - LLViewerRegion* region = *iter; - for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) - { - LLSpatialPartition* part = region->getSpatialPartition(i); - if (part) - { - part->cull(camera, &pick_drawables, TRUE); - } - } - } - - for (std::vector::iterator iter = pick_drawables.begin(); - iter != pick_drawables.end(); iter++) - { - LLDrawable* drawablep = *iter; - if( !drawablep ) - continue; - - LLViewerObject* last_objectp = NULL; - for (S32 face_num = 0; face_num < drawablep->getNumFaces(); face_num++) - { - LLFace * facep = drawablep->getFace(face_num); - if (!facep) continue; - - LLViewerObject* objectp = facep->getViewerObject(); - - if (objectp && objectp != last_objectp) - { - mSelectPickList.insert(objectp); - last_objectp = objectp; - } - } - } - - LLHUDNameTag::addPickable(mSelectPickList); - - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) - { - objectp = (LLVOAvatar*) *iter; - if (!objectp->isDead()) - { - if (objectp->mDrawable.notNull() && objectp->mDrawable->isVisible()) - { - mSelectPickList.insert(objectp); - } - } - } - - // add all hud objects to pick list - if (isAgentAvatarValid()) - { - for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); - iter != gAgentAvatarp->mAttachmentPoints.end(); ) - { - LLVOAvatar::attachment_map_t::iterator curiter = iter++; - LLViewerJointAttachment* attachment = curiter->second; - if (attachment->getIsHUDAttachment()) - { - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) - { - if (LLViewerObject* attached_object = attachment_iter->get()) - { - mSelectPickList.insert(attached_object); - LLViewerObject::const_child_list_t& child_list = attached_object->getChildren(); - for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); - iter != child_list.end(); iter++) - { - LLViewerObject* childp = *iter; - if (childp) - { - mSelectPickList.insert(childp); - } - } - } - } - } - } - } - - S32 num_pickables = (S32)mSelectPickList.size() + LLHUDIcon::getNumInstances(); - - if (num_pickables != 0) - { - S32 step = (0x000fffff - GL_NAME_INDEX_OFFSET) / num_pickables; - - std::set::iterator pick_it; - i = 0; - for (pick_it = mSelectPickList.begin(); pick_it != mSelectPickList.end();) - { - LLViewerObject* objp = (*pick_it); - if (!objp || objp->isDead() || !objp->mbCanSelect) - { - mSelectPickList.erase(pick_it++); - continue; - } - - objp->mGLName = (i * step) + GL_NAME_INDEX_OFFSET; - i++; - ++pick_it; - } - - LLHUDIcon::generatePickIDs(i * step, step); - } -#endif -} - -LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) -{ - llassert(false); -#if 0 - std::set::iterator pick_it; - for (pick_it = mSelectPickList.begin(); pick_it != mSelectPickList.end(); ++pick_it) - { - if ((*pick_it)->mGLName == object_id) - { - return (*pick_it); - } - } -#endif - return NULL; -} - void LLViewerObjectList::addDebugBeacon(const LLVector3 &pos_agent, const std::string &string, const LLColor4 &color, diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 72b2b99004..f2cba8c259 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -77,7 +77,6 @@ public: BOOL killObject(LLViewerObject *objectp); void killObjects(LLViewerRegion *regionp); // Kill all objects owned by a particular region. void killAllObjects(); - void removeDrawable(LLDrawable* drawablep); void cleanDeadObjects(const BOOL use_timer = TRUE); // Clean up the dead object list. @@ -129,11 +128,6 @@ public: void updateAvatarVisibility(); - // Selection related stuff - void generatePickList(LLCamera &camera); - - LLViewerObject *getSelectedObject(const U32 object_id); - inline S32 getNumObjects() { return (S32) mObjects.size(); } inline S32 getNumActiveObjects() { return (S32) mActiveObjects.size(); } @@ -226,8 +220,6 @@ protected: static std::map sIndexAndLocalIDToUUID; - std::set mSelectPickList; - friend class LLViewerObject; private: -- cgit v1.2.3 From 1e28b8d992e6f24f85fde5c86bf9824bf7c7d277 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 9 Jun 2022 17:03:28 -0400 Subject: SL-17483: Let one override keyword into your class... and all the rest require it, too. --- indra/newview/llviewertexture.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index f3bc9061a2..088d11538a 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -302,10 +302,10 @@ public: }; public: - /*virtual*/ S8 getType() const ; + /*virtual*/ S8 getType() const override ; FTType getFTType() const; - /*virtual*/ void forceImmediateUpdate() ; - /*virtual*/ void dump() ; + /*virtual*/ void forceImmediateUpdate() override; + /*virtual*/ void dump() override; // Set callbacks to get called when the image gets updated with higher // resolution versions. @@ -356,14 +356,14 @@ public: // Override the computation of discard levels if we know the exact output // size of the image. Used for UI textures to not decode, even if we have // more data. - /*virtual*/ void setKnownDrawSize(S32 width, S32 height); + /*virtual*/ void setKnownDrawSize(S32 width, S32 height) override; // Set the debug text of all Viewer Objects associated with this texture // to the specified text void setDebugText(const std::string& text); void setIsMissingAsset(BOOL is_missing = true); - /*virtual*/ BOOL isMissingAsset() const { return mIsMissingAsset; } + /*virtual*/ BOOL isMissingAsset() const override { return mIsMissingAsset; } // returns dimensions of original image for local files (before power of two scaling) // and returns 0 for all asset system images @@ -406,7 +406,7 @@ public: BOOL isRawImageValid()const { return mIsRawImageValid ; } void forceToSaveRawImage(S32 desired_discard = 0, F32 kept_time = 0.f) ; void forceToRefetchTexture(S32 desired_discard = 0, F32 kept_time = 60.f); - /*virtual*/ void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) ; + /*virtual*/ void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) override; void destroySavedRawImage() ; LLImageRaw* getSavedRawImage() ; BOOL hasSavedRawImage() const ; @@ -422,10 +422,10 @@ public: void setInFastCacheList(bool in_list) { mInFastCacheList = in_list; } bool isInFastCacheList() { return mInFastCacheList; } - /*virtual*/bool isActiveFetching(); //is actively in fetching by the fetching pipeline. + /*virtual*/bool isActiveFetching() override; //is actively in fetching by the fetching pipeline. protected: - /*virtual*/ void switchToCachedImage(); + /*virtual*/ void switchToCachedImage() override; S32 getCurrentDiscardLevelForFetching() ; private: -- cgit v1.2.3 From 64209ddeeafd944f82da6f13a6e790f9b542b3ff Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 9 Jun 2022 17:04:26 -0400 Subject: SL-17483: Add integration test for CommonControl and for LLViewerControlListener, to which it talks. Fix glitches detected by the tests. --- indra/llcommon/commoncontrol.cpp | 2 + indra/llcommon/threadpool.cpp | 43 +++-- indra/newview/CMakeLists.txt | 13 ++ .../newview/tests/llviewercontrollistener_test.cpp | 174 +++++++++++++++++++++ 4 files changed, 215 insertions(+), 17 deletions(-) create mode 100644 indra/newview/tests/llviewercontrollistener_test.cpp diff --git a/indra/llcommon/commoncontrol.cpp b/indra/llcommon/commoncontrol.cpp index 2c2a2abeb0..81e66baf8c 100644 --- a/indra/llcommon/commoncontrol.cpp +++ b/indra/llcommon/commoncontrol.cpp @@ -51,6 +51,8 @@ LLSD LL::CommonControl::access(const LLSD& params) { LLTHROW(ParamError(error)); } + response.erase("error"); + response.erase("reqid"); return response; } diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index e8daf549ef..f49dd40a8b 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -93,27 +93,36 @@ void LL::ThreadPool::run() //static size_t LL::ThreadPool::getConfiguredWidth(const std::string& name, size_t dft) { - LLSD poolSizes{ LL::CommonControl::get("Global", "ThreadPoolSizes") }; - // "ThreadPoolSizes" is actually a map containing the sizes of interest -- - // or should be, if this process has an "LLViewerControl" LLEventAPI - // instance and its settings include "ThreadPoolSizes". If we failed to - // retrieve it, perhaps we're in a program that doesn't define that, or - // perhaps there's no such setting, or perhaps we're asking too early, - // before the LLEventAPI itself has been instantiated. In any of those - // cases, it seems worth warning. - if (! poolSizes.isDefined()) + LLSD poolSizes; + try { - // Note: we don't warn about absence of an override key for a - // particular ThreadPool name, that's fine. This warning is about - // complete absence of a ThreadPoolSizes setting, which we expect in a - // normal viewer session. - LL_WARNS("ThreadPool") << "No 'ThreadPoolSizes' setting for ThreadPool '" - << name << "'" << LL_ENDL; + poolSizes = LL::CommonControl::get("Global", "ThreadPoolSizes"); + // "ThreadPoolSizes" is actually a map containing the sizes of + // interest -- or should be, if this process has an + // LLViewerControlListener instance and its settings include + // "ThreadPoolSizes". If we failed to retrieve it, perhaps we're in a + // program that doesn't define that, or perhaps there's no such + // setting, or perhaps we're asking too early, before the LLEventAPI + // itself has been instantiated. In any of those cases, it seems worth + // warning. + if (! poolSizes.isDefined()) + { + // Note: we don't warn about absence of an override key for a + // particular ThreadPool name, that's fine. This warning is about + // complete absence of a ThreadPoolSizes setting, which we expect + // in a normal viewer session. + LL_WARNS("ThreadPool") << "No 'ThreadPoolSizes' setting for ThreadPool '" + << name << "'" << LL_ENDL; + } } - else + catch (const LL::CommonControl::Error& exc) { - LL_DEBUGS("ThreadPool") << "ThreadPoolSizes = " << poolSizes << LL_ENDL; + // We don't want ThreadPool to *require* LLViewerControlListener. + // Just log it and carry on. + LL_WARNS("ThreadPool") << "Can't check 'ThreadPoolSizes': " << exc.what() << LL_ENDL; } + + LL_DEBUGS("ThreadPool") << "ThreadPoolSizes = " << poolSizes << LL_ENDL; // LLSD treats an undefined value as an empty map when asked to retrieve a // key, so we don't need this to be conditional. LLSD sizeSpec{ poolSizes[name] }; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index c253eca94e..f13ce85495 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2506,6 +2506,19 @@ if (LL_TESTS) "${test_libs}" ) + set(llviewercontrollistener_test_sources + llviewercontrollistener.cpp + ../llxml/llcontrol.cpp + ../llxml/llxmltree.cpp + ../llxml/llxmlparser.cpp + ../llcommon/commoncontrol.cpp + ) + + LL_ADD_INTEGRATION_TEST(llviewercontrollistener + "${llviewercontrollistener_test_sources}" + "${test_libs}" + ) + LL_ADD_INTEGRATION_TEST(llviewernetwork llviewernetwork.cpp "${test_libs}" diff --git a/indra/newview/tests/llviewercontrollistener_test.cpp b/indra/newview/tests/llviewercontrollistener_test.cpp new file mode 100644 index 0000000000..6d100ef984 --- /dev/null +++ b/indra/newview/tests/llviewercontrollistener_test.cpp @@ -0,0 +1,174 @@ +/** + * @file llviewercontrollistener_test.cpp + * @author Nat Goodspeed + * @date 2022-06-09 + * @brief Test for llviewercontrollistener. + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Copyright (c) 2022, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "llviewerprecompiledheaders.h" +// associated header +#include "llviewercontrollistener.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "../test/lltut.h" +#include "../test/catch_and_store_what_in.h" // catch_what() +#include "commoncontrol.h" +#include "llcontrol.h" // LLControlGroup +#include "llviewercontrollistener.h" + +/***************************************************************************** +* TUT +*****************************************************************************/ +namespace tut +{ + void ensure_contains(const std::string& msg, const std::string& substr) + { + ensure_contains("Exception does not contain " + substr, msg, substr); + } + + struct llviewercontrollistener_data + { + LLControlGroup Global{"FakeGlobal"}; + + llviewercontrollistener_data() + { + Global.declareString("strvar", "woof", "string variable"); + // together we will stroll the boolvar, ma cherie + Global.declareBOOL("boolvar", TRUE, "bool variable"); + } + }; + typedef test_group llviewercontrollistener_group; + typedef llviewercontrollistener_group::object object; + llviewercontrollistener_group llviewercontrollistenergrp("llviewercontrollistener"); + + template<> template<> + void object::test<1>() + { + set_test_name("CommonControl no listener"); + // Not implemented: the linker drags in LLViewerControlListener when + // we bring in LLViewerControl. + } + + template<> template<> + void object::test<2>() + { + set_test_name("CommonControl bad group"); + std::string threw{ catch_what( + [](){ LL::CommonControl::get("Nonexistent", "Variable"); }) }; + ensure_contains(threw, "group"); + ensure_contains(threw, "Nonexistent"); + } + + template<> template<> + void object::test<3>() + { + set_test_name("CommonControl bad variable"); + std::string threw{ catch_what( + [](){ LL::CommonControl::get("FakeGlobal", "Nonexistent"); }) }; + ensure_contains(threw, "key"); + ensure_contains(threw, "Nonexistent"); + } + + template<> template<> + void object::test<4>() + { + set_test_name("CommonControl toggle string"); + std::string threw{ catch_what( + [](){ LL::CommonControl::toggle("FakeGlobal", "strvar"); }) }; + ensure_contains(threw, "non-boolean"); + ensure_contains(threw, "strvar"); + } + + template<> template<> + void object::test<5>() + { + set_test_name("CommonControl list bad group"); + std::string threw{ catch_what( + [](){ LL::CommonControl::get_vars("Nonexistent"); }) }; + ensure_contains(threw, "group"); + ensure_contains(threw, "Nonexistent"); + } + + template<> template<> + void object::test<6>() + { + set_test_name("CommonControl get"); + auto strvar{ LL::CommonControl::get("FakeGlobal", "strvar") }; + ensure_equals(strvar, "woof"); + auto boolvar{ LL::CommonControl::get("FakeGlobal", "boolvar") }; + ensure(boolvar); + } + + template<> template<> + void object::test<7>() + { + set_test_name("CommonControl set, set_default, toggle"); + + std::string newstr{ LL::CommonControl::set("FakeGlobal", "strvar", "mouse").asString() }; + ensure_equals(newstr, "mouse"); + ensure_equals(LL::CommonControl::get("FakeGlobal", "strvar").asString(), "mouse"); + ensure_equals(LL::CommonControl::set_default("FakeGlobal", "strvar").asString(), "woof"); + + bool newbool{ LL::CommonControl::set("FakeGlobal", "boolvar", false) }; + ensure(! newbool); + ensure(! LL::CommonControl::get("FakeGlobal", "boolvar").asBoolean()); + ensure(LL::CommonControl::set_default("FakeGlobal", "boolvar").asBoolean()); + ensure(! LL::CommonControl::toggle("FakeGlobal", "boolvar").asBoolean()); + } + + template<> template<> + void object::test<8>() + { + set_test_name("CommonControl get_def"); + LLSD def{ LL::CommonControl::get_def("FakeGlobal", "strvar") }; + ensure_equals( + def, + llsd::map("name", "strvar", + "type", "String", + "value", "woof", + "comment", "string variable")); + } + + template<> template<> + void object::test<9>() + { + set_test_name("CommonControl get_groups"); + std::vector groups{ LL::CommonControl::get_groups() }; + ensure_equals(groups.size(), 1); + ensure_equals(groups[0], "FakeGlobal"); + } + + template<> template<> + void object::test<10>() + { + set_test_name("CommonControl get_vars"); + LLSD vars{ LL::CommonControl::get_vars("FakeGlobal") }; + // convert from array (unpredictable order) to map + LLSD varsmap{ LLSD::emptyMap() }; + for (auto& var : llsd::inArray(vars)) + { + varsmap[var["name"].asString()] = var; + } + // comparing maps is order-insensitive + ensure_equals( + varsmap, + llsd::map( + "strvar", + llsd::map("name", "strvar", + "type", "String", + "value", "woof", + "comment", "string variable"), + "boolvar", + llsd::map("name", "boolvar", + "type", "Boolean", + "value", TRUE, + "comment", "bool variable"))); + } +} // namespace tut -- cgit v1.2.3 From 03d85bfb33f53e658256d8bedcf0b4262226cf90 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Jun 2022 19:43:21 -0500 Subject: SL-17573 Add "dynamic" checkbox, also followup on SL-17551 and do "Select Invisible Objects" checkbox instead of "Select Reflection Probes" --- indra/llprimitive/llprimitive.cpp | 103 +++++++++++++-------- indra/llprimitive/llprimitive.h | 15 +-- indra/newview/app_settings/settings.xml | 4 +- indra/newview/llpanelvolume.cpp | 37 ++++---- indra/newview/llreflectionmap.cpp | 14 ++- indra/newview/llreflectionmap.h | 3 + indra/newview/llselectmgr.cpp | 6 +- indra/newview/lltoolselect.cpp | 10 +- indra/newview/llviewermenu.cpp | 8 +- indra/newview/llviewerwindow.cpp | 46 +++++++-- indra/newview/llviewerwindow.h | 2 +- indra/newview/llvovolume.cpp | 36 +++++-- indra/newview/llvovolume.h | 6 +- indra/newview/pipeline.cpp | 9 -- .../newview/skins/default/xui/en/floater_tools.xml | 17 +++- indra/newview/skins/default/xui/en/menu_viewer.xml | 10 +- 16 files changed, 205 insertions(+), 121 deletions(-) diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 6044048d09..9e0a079fd9 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1819,92 +1819,117 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ +//============================================================================ + LLReflectionProbeParams::LLReflectionProbeParams() { mType = PARAMS_REFLECTION_PROBE; } -BOOL LLReflectionProbeParams::pack(LLDataPacker& dp) const +BOOL LLReflectionProbeParams::pack(LLDataPacker &dp) const { - dp.packF32(mAmbiance, "ambiance"); + dp.packF32(mAmbiance, "ambiance"); dp.packF32(mClipDistance, "clip_distance"); - dp.packU8(mVolumeType, "volume_type"); - return TRUE; + dp.packU8(mFlags, "flags"); + return TRUE; } -BOOL LLReflectionProbeParams::unpack(LLDataPacker& dp) +BOOL LLReflectionProbeParams::unpack(LLDataPacker &dp) { - F32 ambiance; + F32 ambiance; F32 clip_distance; - U8 volume_type; - - dp.unpackF32(ambiance, "ambiance"); - setAmbiance(ambiance); + dp.unpackF32(ambiance, "ambiance"); + setAmbiance(ambiance); + dp.unpackF32(clip_distance, "clip_distance"); - setClipDistance(clip_distance); - - dp.unpackU8(volume_type, "volume_type"); - setVolumeType((EInfluenceVolumeType)volume_type); - - return TRUE; + setClipDistance(clip_distance); + + dp.unpackU8(mFlags, "flags"); + + return TRUE; } bool LLReflectionProbeParams::operator==(const LLNetworkData& data) const { - if (data.mType != PARAMS_REFLECTION_PROBE) - { - return false; - } - const LLReflectionProbeParams* param = (const LLReflectionProbeParams*)&data; - if (param->mAmbiance != mAmbiance) - { - return false; - } + if (data.mType != PARAMS_REFLECTION_PROBE) + { + return false; + } + const LLReflectionProbeParams *param = (const LLReflectionProbeParams*)&data; + if (param->mAmbiance != mAmbiance) + { + return false; + } if (param->mClipDistance != mClipDistance) { return false; } - if (param->mVolumeType != mVolumeType) + if (param->mFlags != mFlags) { return false; } - return true; + return true; } void LLReflectionProbeParams::copy(const LLNetworkData& data) { - const LLReflectionProbeParams* param = (LLReflectionProbeParams*)&data; - mType = param->mType; - mAmbiance = param->mAmbiance; + const LLReflectionProbeParams *param = (LLReflectionProbeParams*)&data; + mType = param->mType; + mAmbiance = param->mAmbiance; mClipDistance = param->mClipDistance; - mVolumeType = param->mVolumeType; + mFlags = param->mFlags; } LLSD LLReflectionProbeParams::asLLSD() const { - LLSD sd; - sd["ambiance"] = getAmbiance(); + LLSD sd; + sd["ambiance"] = getAmbiance(); sd["clip_distance"] = getClipDistance(); - sd["volume_type"] = (U8) getVolumeType(); - return sd; + sd["flags"] = mFlags; + return sd; } bool LLReflectionProbeParams::fromLLSD(LLSD& sd) { if (!sd.has("ambiance") || !sd.has("clip_distance") || - !sd.has("volume_type")) + !sd.has("flags")) { return false; } - setAmbiance((F32)sd["ambiance"].asReal()); + setAmbiance((F32)sd["ambiance"].asReal()); setClipDistance((F32)sd["clip_distance"].asReal()); - setVolumeType((EInfluenceVolumeType)sd["volume_type"].asInteger()); - + mFlags = (U8) sd["flags"].asInteger(); + return true; } + +void LLReflectionProbeParams::setIsBox(bool is_box) +{ + if (is_box) + { + mFlags |= FLAG_BOX_VOLUME; + } + else + { + mFlags &= ~FLAG_BOX_VOLUME; + } +} + +void LLReflectionProbeParams::setIsDynamic(bool is_dynamic) +{ + if (is_dynamic) + { + mFlags |= FLAG_DYNAMIC; + } + else + { + mFlags &= ~FLAG_DYNAMIC; + } +} + //============================================================================ LLFlexibleObjectData::LLFlexibleObjectData() { diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 2215133e16..25196fb894 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -182,17 +182,16 @@ extern const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; class LLReflectionProbeParams : public LLNetworkData { public: - enum EInfluenceVolumeType : U8 + enum EFlags : U8 { - VOLUME_TYPE_SPHERE = 0, // use a sphere influence volume - VOLUME_TYPE_BOX = 1, // use a box influence volume - DEFAULT_VOLUME_TYPE = VOLUME_TYPE_SPHERE + FLAG_BOX_VOLUME = 0x01, // use a box influence volume + FLAG_DYNAMIC = 0x02, // render dynamic objects (avatars) into this Reflection Probe }; protected: F32 mAmbiance = REFLECTION_PROBE_DEFAULT_AMBIANCE; F32 mClipDistance = REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; - EInfluenceVolumeType mVolumeType = DEFAULT_VOLUME_TYPE; + U8 mFlags = 0; public: LLReflectionProbeParams(); @@ -208,11 +207,13 @@ public: void setAmbiance(F32 ambiance) { mAmbiance = llclamp(ambiance, REFLECTION_PROBE_MIN_AMBIANCE, REFLECTION_PROBE_MAX_AMBIANCE); } void setClipDistance(F32 distance) { mClipDistance = llclamp(distance, REFLECTION_PROBE_MIN_CLIP_DISTANCE, REFLECTION_PROBE_MAX_CLIP_DISTANCE); } - void setVolumeType(EInfluenceVolumeType type) { mVolumeType = llclamp(type, VOLUME_TYPE_SPHERE, VOLUME_TYPE_BOX); } + void setIsBox(bool is_box); + void setIsDynamic(bool is_dynamic); F32 getAmbiance() const { return mAmbiance; } F32 getClipDistance() const { return mClipDistance; } - EInfluenceVolumeType getVolumeType() const { return mVolumeType; } + bool getIsBox() const { return (mFlags & FLAG_BOX_VOLUME) != 0; } + bool getIsDynamic() const { return (mFlags & FLAG_DYNAMIC) != 0; } }; //------------------------------------------------- diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 6df71e1019..327dfe6955 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11191,10 +11191,10 @@ Value 0 - SelectReflectionProbes + SelectInvisibleObjects Comment - Select reflection probes + Select invisible objects Persist 1 Type diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index fb2cf484f5..ddce22fa20 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -147,8 +147,9 @@ BOOL LLPanelVolume::postBuild() // REFLECTION PROBE Parameters { - childSetCommitCallback("Reflection Probe Checkbox Ctrl", onCommitIsReflectionProbe, this); - childSetCommitCallback("Probe Volume Type Ctrl", onCommitProbe, this); + childSetCommitCallback("Reflection Probe", onCommitIsReflectionProbe, this); + childSetCommitCallback("Probe Dynamic", onCommitProbe, this); + childSetCommitCallback("Probe Volume Type", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); @@ -372,25 +373,27 @@ void LLPanelVolume::getState( ) // Reflection Probe BOOL is_probe = volobjp && volobjp->isReflectionProbe(); - getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); - getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); + getChild("Reflection Probe")->setValue(is_probe); + getChildView("Reflection Probe")->setEnabled(editable && single_volume && volobjp); bool probe_enabled = is_probe && editable && single_volume; - getChildView("Probe Volume Type Ctrl")->setEnabled(probe_enabled); + getChildView("Probe Dynamic")->setEnabled(probe_enabled); + getChildView("Probe Volume Type")->setEnabled(probe_enabled); getChildView("Probe Ambiance")->setEnabled(probe_enabled); getChildView("Probe Near Clip")->setEnabled(probe_enabled); if (!probe_enabled) { - getChild("Probe Volume Type Ctrl", true)->clear(); + getChild("Probe Volume Type", true)->clear(); getChild("Probe Ambiance", true)->clear(); getChild("Probe Near Clip", true)->clear(); + getChild("Probe Dynamic", true)->clear(); } else { std::string volume_type; - if (volobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + if (volobjp->getReflectionProbeIsBox()) { volume_type = "Box"; } @@ -399,9 +402,10 @@ void LLPanelVolume::getState( ) volume_type = "Sphere"; } - getChild("Probe Volume Type Ctrl", true)->setValue(volume_type); + getChild("Probe Volume Type", true)->setValue(volume_type); getChild("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); getChild("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); + getChild("Probe Dynamic", true)->setValue(volobjp->getReflectionProbeIsDynamic()); } // Animated Mesh @@ -692,7 +696,8 @@ void LLPanelVolume::clearCtrls() getChildView("Light Falloff")->setEnabled(false); getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(false);; - getChildView("Probe Volume Type Ctrl")->setEnabled(false); + getChildView("Probe Volume Type")->setEnabled(false); + getChildView("Probe Dynamic")->setEnabled(false); getChildView("Probe Ambiance")->setEnabled(false); getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); @@ -1003,19 +1008,11 @@ void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); + volobjp->setReflectionProbeIsDynamic(self->getChild("Probe Dynamic")->getValue().asBoolean()); - std::string shape_type = self->getChild("Probe Volume Type Ctrl")->getValue().asString(); - LLReflectionProbeParams::EInfluenceVolumeType volume_type = LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + std::string shape_type = self->getChild("Probe Volume Type")->getValue().asString(); - if (shape_type == "Sphere") - { - volume_type = LLReflectionProbeParams::VOLUME_TYPE_SPHERE; - } - else if (shape_type == "Box") - { - volume_type = LLReflectionProbeParams::VOLUME_TYPE_BOX; - } - volobjp->setReflectionProbeVolumeType(volume_type); + volobjp->setReflectionProbeIsBox(shape_type == "Box"); } // static diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 5991d7a170..39e0841fc5 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -51,7 +51,7 @@ void LLReflectionMap::update(U32 resolution, U32 face) { resolution /= 2; } - gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip()); + gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip(), getIsDynamic()); } bool LLReflectionMap::shouldUpdate() @@ -243,6 +243,16 @@ F32 LLReflectionMap::getNearClip() return llmax(ret, MINIMUM_NEAR_CLIP); } +bool LLReflectionMap::getIsDynamic() +{ + if (mViewerObject && mViewerObject->getVolume()) + { + return ((LLVOVolume*)mViewerObject)->getReflectionProbeIsDynamic(); + } + + return false; +} + bool LLReflectionMap::getBox(LLMatrix4& box) { if (mViewerObject) @@ -252,7 +262,7 @@ bool LLReflectionMap::getBox(LLMatrix4& box) { LLVOVolume* vobjp = (LLVOVolume*)mViewerObject; - if (vobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + if (vobjp->getReflectionProbeIsBox()) { glh::matrix4f mv(gGLModelView); glh::matrix4f scale; diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index a358bf5fdf..071568e53c 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -61,6 +61,9 @@ public: // Get the near clip plane distance to use for this probe F32 getNearClip(); + // Return true if this probe should include avatars in its reflection map + bool getIsDynamic(); + // get the encoded bounding box of this probe's influence volume // will only return a box if this probe is associated with a VOVolume // with its reflection probe influence volume to to VOLUME_TYPE_BOX diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 7b4ba51859..853703b4d5 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1067,8 +1067,7 @@ void LLSelectMgr::highlightObjectOnly(LLViewerObject* objectp) } if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) - || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced())) - || (!gSavedSettings.getBOOL("SelectReflectionProbes") && !objectp->isReflectionProbe())) + || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced()))) { // only select my own objects return; @@ -7128,8 +7127,7 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object, BOOL ignore_select_own if(!ignore_select_owned) { if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) || - (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced())) || - (!gSavedSettings.getBOOL("SelectReflectionProbes") && object->isReflectionProbe())) + (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced()))) { // only select my own objects return FALSE; diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 790d9a8ec5..c6f3905ddc 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -65,7 +65,8 @@ BOOL LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask) { // do immediate pick query BOOL pick_rigged = false; //gSavedSettings.getBOOL("AnimatedObjectsAllowLeftClick"); - mPick = gViewerWindow->pickImmediate(x, y, TRUE, pick_rigged); + BOOL pick_transparent = gSavedSettings.getBOOL("SelectInvisibleObjects"); + mPick = gViewerWindow->pickImmediate(x, y, pick_transparent, pick_rigged); // Pass mousedown to agent LLTool::handleMouseDown(x, y, mask); @@ -84,15 +85,13 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi } BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly"); BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly"); - BOOL select_probe = gSavedSettings.getBOOL("SelectReflectionProbes"); - // *NOTE: These settings must be cleaned up at bottom of function. + // *NOTE: These settings must be cleaned up at bottom of function. if (temp_select || LLSelectMgr::getInstance()->mAllowSelectAvatar) { gSavedSettings.setBOOL("SelectOwnedOnly", FALSE); gSavedSettings.setBOOL("SelectMovableOnly", FALSE); - gSavedSettings.setBOOL("SelectReflectionProbes", FALSE); - LLSelectMgr::getInstance()->setForceSelection(TRUE); + LLSelectMgr::getInstance()->setForceSelection(TRUE); } BOOL extend_select = (pick.mKeyMask == MASK_SHIFT) || (pick.mKeyMask == MASK_CONTROL); @@ -243,7 +242,6 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi { gSavedSettings.setBOOL("SelectOwnedOnly", select_owned); gSavedSettings.setBOOL("SelectMovableOnly", select_movable); - gSavedSettings.setBOOL("SelectReflectionProbes", select_probe); LLSelectMgr::getInstance()->setForceSelection(FALSE); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index b99299528c..b7f94a7e0c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7971,13 +7971,13 @@ class LLToolsSelectOnlyMovableObjects : public view_listener_t } }; -class LLToolsSelectReflectionProbes : public view_listener_t +class LLToolsSelectInvisibleObjects : public view_listener_t { bool handleEvent(const LLSD& userdata) { - BOOL cur_val = gSavedSettings.getBOOL("SelectReflectionProbes"); + BOOL cur_val = gSavedSettings.getBOOL("SelectInvisibleObjects"); - gSavedSettings.setBOOL("SelectReflectionProbes", !cur_val); + gSavedSettings.setBOOL("SelectInvisibleObjects", !cur_val); return true; } @@ -9212,7 +9212,7 @@ void initialize_menus() view_listener_t::addMenu(new LLToolsSelectTool(), "Tools.SelectTool"); view_listener_t::addMenu(new LLToolsSelectOnlyMyObjects(), "Tools.SelectOnlyMyObjects"); view_listener_t::addMenu(new LLToolsSelectOnlyMovableObjects(), "Tools.SelectOnlyMovableObjects"); - view_listener_t::addMenu(new LLToolsSelectReflectionProbes(), "Tools.SelectReflectionProbes"); + view_listener_t::addMenu(new LLToolsSelectInvisibleObjects(), "Tools.SelectInvisibleObjects"); view_listener_t::addMenu(new LLToolsSelectBySurrounding(), "Tools.SelectBySurrounding"); view_listener_t::addMenu(new LLToolsShowHiddenSelection(), "Tools.ShowHiddenSelection"); view_listener_t::addMenu(new LLToolsShowSelectionLightRadius(), "Tools.ShowSelectionLightRadius"); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 6613c8ac01..1230a6d327 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4196,10 +4196,15 @@ void LLViewerWindow::pickAsync( S32 x, BOOL pick_unselectable) { // "Show Debug Alpha" means no object actually transparent + BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (LLDrawPoolAlpha::sShowDebugAlpha) { pick_transparent = TRUE; } + else if (in_build_mode && !gSavedSettings.getBOOL("SelectInvisibleObjects")) + { + pick_transparent = FALSE; + } LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, FALSE, TRUE, pick_unselectable, callback); schedulePick(pick_info); @@ -4260,7 +4265,7 @@ void LLViewerWindow::returnEmptyPicks() LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, BOOL pick_unselectable) { BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); - if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) + if ((in_build_mode && gSavedSettings.getBOOL("SelectInvisibleObjects")) || LLDrawPoolAlpha::sShowDebugAlpha) { // build mode allows interaction with all transparent objects // "Show Debug Alpha" means no object actually transparent @@ -5267,7 +5272,7 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ void display_cube_face(); -BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip) +BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip, bool dynamic_render) { // NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; @@ -5300,16 +5305,33 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + U32 dynamic_render_types[] = { + LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_CONTROL_AV, + LLPipeline::RENDER_TYPE_PARTICLES + }; + constexpr U32 dynamic_render_type_count = sizeof(dynamic_render_types) / sizeof(U32); + bool prev_dynamic_render_type[dynamic_render_type_count]; + + + if (!dynamic_render) + { + for (int i = 0; i < dynamic_render_type_count; ++i) + { + prev_dynamic_render_type[i] = gPipeline.hasRenderType(dynamic_render_types[i]); + if (prev_dynamic_render_type[i]) + { + gPipeline.toggleRenderType(dynamic_render_types[i]); + } + } + } + BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI) ? TRUE : FALSE; if (prev_draw_ui != false) { LLPipeline::toggleRenderDebugFeature(LLPipeline::RENDER_DEBUG_FEATURE_UI); } - BOOL prev_draw_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES); - if (prev_draw_particles) - { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); - } + LLPipeline::sShowHUDAttachments = FALSE; LLRect window_rect = getWorldViewRectRaw(); @@ -5365,9 +5387,15 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea } } - if (prev_draw_particles) + if (!dynamic_render) { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); + for (int i = 0; i < dynamic_render_type_count; ++i) + { + if (prev_dynamic_render_type[i]) + { + gPipeline.toggleRenderType(dynamic_render_types[i]); + } + } } LLPipeline::sShowHUDAttachments = TRUE; diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 38ec0e1ac8..387a2cb06f 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -370,7 +370,7 @@ public: // index - cube index in the array to use (cube index, not face-layer) // face - which cube face to update // near_clip - near clip setting to use - BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip); + BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip, bool render_avatars); // special implementation of simpleSnapshot for reflection maps diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8f5d2d1c29..3a619b4fcc 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3545,14 +3545,27 @@ void LLVOVolume::setReflectionProbeNearClip(F32 near_clip) } } -void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type) +void LLVOVolume::setReflectionProbeIsBox(bool is_box) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) { - if (param_block->getVolumeType() != volume_type) + if (param_block->getIsBox() != is_box) { - param_block->setVolumeType(volume_type); + param_block->setIsBox(is_box); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getIsDynamic() != is_dynamic) + { + param_block->setIsDynamic(is_dynamic); parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); } } @@ -3603,17 +3616,26 @@ F32 LLVOVolume::getReflectionProbeNearClip() const } } -LLReflectionProbeParams::EInfluenceVolumeType LLVOVolume::getReflectionProbeVolumeType() const +bool LLVOVolume::getReflectionProbeIsBox() const { const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) { - return param_block->getVolumeType(); + return param_block->getIsBox(); } - else + + return false; +} + +bool LLVOVolume::getReflectionProbeIsDynamic() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) { - return LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + return param_block->getIsDynamic(); } + + return false; } U32 LLVOVolume::getVolumeInterfaceID() const diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index ad7a2c5606..1ca6b49c7d 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -289,12 +289,14 @@ public: void setIsReflectionProbe(BOOL is_probe); void setReflectionProbeAmbiance(F32 ambiance); void setReflectionProbeNearClip(F32 near_clip); - void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); + void setReflectionProbeIsBox(bool is_box); + void setReflectionProbeIsDynamic(bool is_dynamic); BOOL isReflectionProbe() const override; F32 getReflectionProbeAmbiance() const; F32 getReflectionProbeNearClip() const; - LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; + bool getReflectionProbeIsBox() const; + bool getReflectionProbeIsDynamic() const; // Flexible Objects U32 getVolumeInterfaceID() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 20a21a685c..28dc3781ba 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6734,15 +6734,6 @@ void LLPipeline::toggleRenderType(U32 type) //static void LLPipeline::toggleRenderTypeControl(U32 type) { - U32 bit = (1< + + label="Select Invisible Objects" + name="Select Invisible Objects"> + control="SelectInvisibleObjects" /> + function="Tools.SelectInvisibleObjects" + parameter="invisible" /> Date: Fri, 10 Jun 2022 01:13:41 -0500 Subject: SL-17574 Add probe detail combo box to advanced graphics preferences. Fix spot light shadows not working in probes. --- indra/llrender/llrendertarget.cpp | 4 + indra/newview/app_settings/settings.xml | 11 + .../shaders/class3/deferred/reflectionProbeF.glsl | 13 +- indra/newview/llpanelvolume.cpp | 6 +- indra/newview/llreflectionmap.cpp | 26 +- indra/newview/llreflectionmap.h | 8 - indra/newview/llreflectionmapmanager.cpp | 63 +++- indra/newview/llreflectionmapmanager.h | 11 +- indra/newview/llspatialpartition.cpp | 17 - indra/newview/llspatialpartition.h | 3 - indra/newview/llviewercamera.h | 13 +- indra/newview/pipeline.cpp | 387 +++++++++++---------- indra/newview/pipeline.h | 16 +- .../en/floater_preferences_graphics_advanced.xml | 38 +- 14 files changed, 350 insertions(+), 266 deletions(-) diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 85d6209964..fa46e0f7d0 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -473,6 +473,8 @@ void LLRenderTarget::release() void LLRenderTarget::bindTarget() { + llassert(mFBO); + if (mFBO) { stop_glerror(); @@ -514,6 +516,7 @@ void LLRenderTarget::bindTarget() void LLRenderTarget::clear(U32 mask_in) { LL_PROFILE_GPU_ZONE("clear"); + llassert(mFBO); U32 mask = GL_COLOR_BUFFER_BIT; if (mUseDepth) { @@ -579,6 +582,7 @@ void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilt void LLRenderTarget::flush(bool fetch_depth) { gGL.flush(); + llassert(mFBO); if (!mFBO) { gGL.getTexUnit(0)->bind(this); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 327dfe6955..35a79f12de 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10280,6 +10280,17 @@ Value 2 + RenderReflectionProbeDetail + + Comment + Detail of reflections. + Persist + 1 + Type + S32 + Value + 1 + RenderReflectionProbeDrawDistance diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 3fd001e7f5..b3396baeba 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -74,6 +74,8 @@ bool isAbove(vec3 pos, vec4 plane) return (dot(plane.xyz, pos) + plane.w) > 0; } +int max_priority = 0; + // return true if probe at index i influences position pos bool shouldSampleProbe(int i, vec3 pos) { @@ -86,6 +88,8 @@ bool shouldSampleProbe(int i, vec3 pos) { return false; } + + max_priority = max(max_priority, -refIndex[i].w); } else { @@ -98,6 +102,8 @@ bool shouldSampleProbe(int i, vec3 pos) { //outside bounding sphere return false; } + + max_priority = max(max_priority, refIndex[i].w); } return true; @@ -343,8 +349,13 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) for (int idx = 0; idx < probeInfluences; ++idx) { int i = probeIndex[idx]; + if (refIndex[i].w < max_priority) + { + continue; + } float r = refSphere[i].w; // radius of sphere volume float p = float(abs(refIndex[i].w)); // priority + float rr = r*r; // radius squred float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) vec3 delta = pos.xyz-refSphere[i].xyz; @@ -358,7 +369,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); w *= atten; - w *= p; // boost weight based on priority + //w *= p; // boost weight based on priority col += refcol*w*max(minweight, refParams[i].x); wsum += w; diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index ddce22fa20..956539cd98 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -152,8 +152,6 @@ BOOL LLPanelVolume::postBuild() childSetCommitCallback("Probe Volume Type", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); - - } // PHYSICS Parameters @@ -695,7 +693,7 @@ void LLPanelVolume::clearCtrls() getChildView("Light Radius")->setEnabled(false); getChildView("Light Falloff")->setEnabled(false); - getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(false);; + getChildView("Reflection Probe")->setEnabled(false);; getChildView("Probe Volume Type")->setEnabled(false); getChildView("Probe Dynamic")->setEnabled(false); getChildView("Probe Ambiance")->setEnabled(false); @@ -746,7 +744,7 @@ void LLPanelVolume::sendIsReflectionProbe() } LLVOVolume* volobjp = (LLVOVolume*)objectp; - BOOL value = getChild("Reflection Probe Checkbox Ctrl")->getValue(); + BOOL value = getChild("Reflection Probe")->getValue(); volobjp->setIsReflectionProbe(value); LL_INFOS() << "update reflection probe sent" << LL_ENDL; } diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 39e0841fc5..500485fc70 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -54,28 +54,6 @@ void LLReflectionMap::update(U32 resolution, U32 face) gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip(), getIsDynamic()); } -bool LLReflectionMap::shouldUpdate() -{ - const F32 TIMEOUT_INTERVAL = 30.f; // update no less than this often - const F32 RENDER_TIMEOUT = 1.f; // don't update if hasn't been used for rendering for this long - - if (mLastBindTime > gFrameTimeSeconds - RENDER_TIMEOUT) - { - if (mLastUpdateTime < gFrameTimeSeconds - TIMEOUT_INTERVAL) - { - return true; - } - } - - return false; -} - -void LLReflectionMap::dirty() -{ - mDirty = true; - mLastUpdateTime = gFrameTimeSeconds; -} - void LLReflectionMap::autoAdjustOrigin() { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; @@ -245,7 +223,9 @@ F32 LLReflectionMap::getNearClip() bool LLReflectionMap::getIsDynamic() { - if (mViewerObject && mViewerObject->getVolume()) + if (gSavedSettings.getS32("RenderReflectionProbeDetail") > (S32) LLReflectionMapManager::DetailLevel::STATIC_ONLY && + mViewerObject && + mViewerObject->getVolume()) { return ((LLVOVolume*)mViewerObject)->getReflectionProbeIsDynamic(); } diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 071568e53c..cf0bc2ff27 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -43,12 +43,6 @@ public: // resolution - size of cube map to generate void update(U32 resolution, U32 face); - // return true if this probe should update *now* - bool shouldUpdate(); - - // Mark this reflection map as needing an update (resets last update time, so spamming this call will cause a cube map to never update) - void dirty(); - // for volume partition probes, try to place this probe in the best spot void autoAdjustOrigin(); @@ -104,7 +98,5 @@ public: // what priority should this probe have (higher is higher priority) U32 mPriority = 1; - - bool mDirty = true; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 60396b6c60..dc733687c3 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -96,11 +96,13 @@ void LLReflectionMapManager::update() mRenderTarget.allocate(targetRes, targetRes, color_fmt, use_depth_buffer, use_stencil_buffer, LLTexUnit::TT_RECT_TEXTURE); // hack to allocate render targets using gPipeline code + gCubeSnapshot = TRUE; auto* old_rt = gPipeline.mRT; gPipeline.mRT = &gProbeRT; gPipeline.allocateScreenBuffer(targetRes, targetRes); gPipeline.allocateShadowBuffer(targetRes, targetRes); gPipeline.mRT = old_rt; + gCubeSnapshot = FALSE; } if (mMipChain.empty()) @@ -154,6 +156,10 @@ void LLReflectionMapManager::update() bool did_update = false; + bool realtime = gSavedSettings.getS32("RenderReflectionProbeDetail") >= (S32)LLReflectionMapManager::DetailLevel::REALTIME; + + LLReflectionMap* closestDynamic = nullptr; + LLReflectionMap* oldestProbe = nullptr; if (mUpdatingProbe != nullptr) @@ -183,11 +189,30 @@ void LLReflectionMapManager::update() oldestProbe = probe; } + if (realtime && + closestDynamic == nullptr && + probe->mCubeArray.notNull() && + probe->getIsDynamic()) + { + closestDynamic = probe; + } + d.setSub(camera_pos, probe->mOrigin); probe->mDistance = d.getLength3().getF32()-probe->mRadius; } -#if 1 + if (realtime && closestDynamic != nullptr) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmu - realtime"); + // update the closest dynamic probe realtime + closestDynamic->autoAdjustOrigin(); + for (U32 i = 0; i < 6; ++i) + { + updateProbeFace(closestDynamic, i); + } + } + + // switch to updating the next oldest probe if (!did_update && oldestProbe != nullptr) { LLReflectionMap* probe = oldestProbe; @@ -201,9 +226,7 @@ void LLReflectionMapManager::update() mUpdatingProbe = probe; doProbeUpdate(); - probe->mDirty = false; } -#endif // update distance to camera for all probes std::sort(mProbes.begin(), mProbes.end(), CompareProbeDistance()); @@ -214,7 +237,6 @@ LLReflectionMap* LLReflectionMapManager::addProbe(LLSpatialGroup* group) LLReflectionMap* probe = new LLReflectionMap(); probe->mGroup = group; probe->mOrigin = group->getOctreeNode()->getCenter(); - probe->mDirty = true; if (gCubeSnapshot) { //snapshot is in progress, mProbes is being iterated over, defer insertion until next update @@ -295,7 +317,6 @@ LLReflectionMap* LLReflectionMapManager::registerViewerObject(LLViewerObject* vo LLReflectionMap* probe = new LLReflectionMap(); probe->mViewerObject = vobj; probe->mOrigin.load3(vobj->getPositionAgent().mV); - probe->mDirty = true; if (gCubeSnapshot) { //snapshot is in progress, mProbes is being iterated over, defer insertion until next update @@ -368,10 +389,23 @@ void LLReflectionMapManager::doProbeUpdate() LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; llassert(mUpdatingProbe != nullptr); + updateProbeFace(mUpdatingProbe, mUpdatingFace); + + if (++mUpdatingFace == 6) + { + updateNeighbors(mUpdatingProbe); + mUpdatingProbe = nullptr; + mUpdatingFace = 0; + } +} + +void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) +{ mRenderTarget.bindTarget(); + // hacky hot-swap of camera specific render targets auto* old_rt = gPipeline.mRT; gPipeline.mRT = &gProbeRT; - mUpdatingProbe->update(mRenderTarget.getWidth(), mUpdatingFace); + probe->update(mRenderTarget.getWidth(), face); gPipeline.mRT = old_rt; mRenderTarget.flush(); @@ -390,9 +424,9 @@ void LLReflectionMapManager::doProbeUpdate() gGL.loadIdentity(); gGL.flush(); - U32 res = LL_REFLECTION_PROBE_RESOLUTION*2; + U32 res = LL_REFLECTION_PROBE_RESOLUTION * 2; - S32 mips = log2((F32) LL_REFLECTION_PROBE_RESOLUTION)+0.5f; + S32 mips = log2((F32)LL_REFLECTION_PROBE_RESOLUTION) + 0.5f; for (int i = 0; i < mMipChain.size(); ++i) { @@ -409,10 +443,10 @@ void LLReflectionMapManager::doProbeUpdate() } gGL.begin(gGL.QUADS); - + gGL.texCoord2f(0, 0); gGL.vertex2f(-1, -1); - + gGL.texCoord2f(res, 0); gGL.vertex2f(1, -1); @@ -431,7 +465,7 @@ void LLReflectionMapManager::doProbeUpdate() if (mip >= 0) { mTexture->bind(0); - glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, mUpdatingProbe->mCubeIndex * 6 + mUpdatingFace, 0, 0, res, res); + glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, probe->mCubeIndex * 6 + face, 0, 0, res, res); mTexture->unbind(); } mMipChain[i].flush(); @@ -443,13 +477,6 @@ void LLReflectionMapManager::doProbeUpdate() gReflectionMipProgram.unbind(); } - - if (++mUpdatingFace == 6) - { - updateNeighbors(mUpdatingProbe); - mUpdatingProbe = nullptr; - mUpdatingFace = 0; - } } void LLReflectionMapManager::rebuild() diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index bf963f3486..3b5cdc5520 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -46,6 +46,13 @@ class alignas(16) LLReflectionMapManager { LL_ALIGN_NEW public: + enum class DetailLevel + { + STATIC_ONLY = 0, + STATIC_AND_DYNAMIC, + REALTIME = 2 + }; + // allocate an environment map of the given resolution LLReflectionMapManager(); @@ -115,6 +122,9 @@ private: // perform an update on the currently updating Probe void doProbeUpdate(); + + // update the specified face of the specified probe + void updateProbeFace(LLReflectionMap* probe, U32 face); // list of active reflection maps std::vector > mProbes; @@ -133,6 +143,5 @@ private: LLReflectionMap* mUpdatingProbe = nullptr; U32 mUpdatingFace = 0; - }; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index a9e807e0f6..f445bc98eb 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -738,17 +738,8 @@ BOOL LLSpatialGroup::changeLOD() return FALSE; } -void LLSpatialGroup::dirtyReflectionProbe() -{ - if (mReflectionProbe != nullptr) - { - mReflectionProbe->dirty(); - } -} - void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* entry) { - dirtyReflectionProbe(); addObject((LLDrawable*)entry->getDrawable()); unbound(); setState(OBJECT_DIRTY); @@ -756,7 +747,6 @@ void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* entry) { - dirtyReflectionProbe(); removeObject((LLDrawable*)entry->getDrawable(), TRUE); LLViewerOctreeGroup::handleRemoval(node, entry); } @@ -793,8 +783,6 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c { LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL - dirtyReflectionProbe(); - if (child->getListenerCount() == 0) { new LLSpatialGroup(child, getSpatialPartition()); @@ -809,11 +797,6 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c assert_states_valid(this); } -void LLSpatialGroup::handleChildRemoval(const oct_node* parent, const oct_node* child) -{ - dirtyReflectionProbe(); -} - void LLSpatialGroup::destroyGL(bool keep_occlusion) { setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY); diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index bebd8aec85..07d62be7af 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -333,7 +333,6 @@ public: virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face); virtual void handleDestruction(const TreeNode* node); virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child); - virtual void handleChildRemoval(const oct_node* parent, const oct_node* child); public: LL_ALIGN_16(LLVector4a mViewAngle); @@ -341,8 +340,6 @@ public: F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3() - void dirtyReflectionProbe(); - protected: virtual ~LLSpatialGroup(); diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index 549778a841..b5841772ed 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -47,15 +47,14 @@ public: typedef enum { CAMERA_WORLD = 0, - CAMERA_SHADOW0, - CAMERA_SHADOW1, - CAMERA_SHADOW2, - CAMERA_SHADOW3, - CAMERA_SHADOW4, - CAMERA_SHADOW5, + CAMERA_SUN_SHADOW0, + CAMERA_SUN_SHADOW1, + CAMERA_SUN_SHADOW2, + CAMERA_SUN_SHADOW3, + CAMERA_SPOT_SHADOW0, + CAMERA_SPOT_SHADOW1, CAMERA_WATER0, CAMERA_WATER1, - CAMERA_GI_SOURCE, NUM_CAMERAS } eCameraID; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 28dc3781ba..8bac5131cf 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -739,7 +739,8 @@ void LLPipeline::requestResizeShadowTexture() void LLPipeline::resizeShadowTexture() { - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); allocateShadowBuffer(mRT->width, mRT->height); gResizeShadowTexture = FALSE; } @@ -754,7 +755,8 @@ void LLPipeline::resizeScreenTexture() if (gResizeScreenTexture || (resX != mRT->screen.getWidth()) || (resY != mRT->screen.getHeight())) { releaseScreenBuffers(); - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); allocateScreenBuffer(resX,resY); gResizeScreenTexture = FALSE; } @@ -913,7 +915,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { mRT->deferredLight.release(); - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); mRT->fxaaBuffer.release(); mRT->screen.release(); @@ -942,66 +945,66 @@ inline U32 BlurHappySize(U32 x, F32 scale) { return U32( x * scale + 16.0f) & ~0 bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - if (LLPipeline::sRenderDeferred) - { - S32 shadow_detail = RenderShadowDetail; + if (LLPipeline::sRenderDeferred) + { + S32 shadow_detail = RenderShadowDetail; - const U32 occlusion_divisor = 3; + const U32 occlusion_divisor = 3; - F32 scale = llmax(0.f,RenderShadowResolutionScale); - U32 sun_shadow_map_width = BlurHappySize(resX, scale); - U32 sun_shadow_map_height = BlurHappySize(resY, scale); + F32 scale = llmax(0.f, RenderShadowResolutionScale); + U32 sun_shadow_map_width = BlurHappySize(resX, scale); + U32 sun_shadow_map_height = BlurHappySize(resY, scale); - if (shadow_detail > 0) - { //allocate 4 sun shadow maps - for (U32 i = 0; i < 4; i++) - { - if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (shadow_detail > 0) + { //allocate 4 sun shadow maps + for (U32 i = 0; i < 4; i++) + { + if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } - if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width / occlusion_divisor, sun_shadow_map_height / occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } - } - } - else - { - for (U32 i = 0; i < 4; i++) - { - releaseShadowTarget(i); - } - } + } + } + else + { + for (U32 i = 0; i < 4; i++) + { + releaseSunShadowTarget(i); + } + } - U32 width = (U32) (resX*scale); - U32 height = width; + if (!gCubeSnapshot) // hack to not allocate spot shadow maps during ReflectionMapManager init + { + U32 width = (U32)(resX * scale); + U32 height = width; - if (shadow_detail > 1) - { //allocate two spot shadow maps - U32 spot_shadow_map_width = width; - U32 spot_shadow_map_height = height; - for (U32 i = 4; i < 6; i++) - { - if (!mRT->shadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) - { - return false; - } - if (!mRT->shadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE)) - { - return false; - } - } + if (shadow_detail > 1) + { //allocate two spot shadow maps + U32 spot_shadow_map_width = width; + U32 spot_shadow_map_height = height; + for (U32 i = 0; i < 2; i++) + { + if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) + { + return false; + } + if (!mSpotShadowOcclusion[i].allocate(spot_shadow_map_width / occlusion_divisor, height / occlusion_divisor, 0, TRUE, FALSE)) + { + return false; + } + } + } + else + { + releaseSpotShadowTargets(); + } } - else - { - for (U32 i = 4; i < 6; i++) - { - releaseShadowTarget(i); - } - } - } + } return true; } @@ -1175,7 +1178,8 @@ void LLPipeline::releaseLUTBuffers() void LLPipeline::releaseShadowBuffers() { - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); } void LLPipeline::releaseScreenBuffers() @@ -1191,20 +1195,33 @@ void LLPipeline::releaseScreenBuffers() } -void LLPipeline::releaseShadowTarget(U32 index) +void LLPipeline::releaseSunShadowTarget(U32 index) { + llassert(index < 4); mRT->shadow[index].release(); mRT->shadowOcclusion[index].release(); } -void LLPipeline::releaseShadowTargets() +void LLPipeline::releaseSunShadowTargets() { - for (U32 i = 0; i < 6; i++) + for (U32 i = 0; i < 4; i++) { - releaseShadowTarget(i); + releaseSunShadowTarget(i); } } +void LLPipeline::releaseSpotShadowTargets() +{ + if (!gCubeSnapshot) // hack to avoid freeing spot shadows during ReflectionMapManager init + { + for (U32 i = 0; i < 2; i++) + { + mSpotShadow[i].release(); + mSpotShadowOcclusion[i].release(); + } + } +} + void LLPipeline::createGLBuffers() { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -8162,7 +8179,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ for (U32 i = 0; i < 4; i++) { - LLRenderTarget* shadow_target = getShadowTarget(i); + LLRenderTarget* shadow_target = getSunShadowTarget(i); if (shadow_target) { channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE); @@ -8170,7 +8187,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ if (channel > -1) { stop_glerror(); - gGL.getTexUnit(channel)->bind(getShadowTarget(i), TRUE); + gGL.getTexUnit(channel)->bind(getSunShadowTarget(i), TRUE); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); stop_glerror(); @@ -8182,27 +8199,27 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - for (U32 i = 4; i < 6; i++) - { - channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i); - stop_glerror(); - if (channel > -1) - { - stop_glerror(); - LLRenderTarget* shadow_target = getShadowTarget(i); - if (shadow_target) - { - gGL.getTexUnit(channel)->bind(shadow_target, TRUE); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - stop_glerror(); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); - stop_glerror(); - } - } - } + for (U32 i = 4; i < 6; i++) + { + channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i); + stop_glerror(); + if (channel > -1) + { + stop_glerror(); + LLRenderTarget* shadow_target = getSpotShadowTarget(i-4); + if (shadow_target) + { + gGL.getTexUnit(channel)->bind(shadow_target, TRUE); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + stop_glerror(); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + stop_glerror(); + } + } + } stop_glerror(); @@ -8313,7 +8330,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mRT->shadow[0].getWidth(), mRT->shadow[0].getHeight()); - shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mRT->shadow[4].getWidth(), mRT->shadow[4].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mSpotShadow[0].getWidth(), mSpotShadow[0].getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); @@ -9077,7 +9094,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f); } - if (!gCubeSnapshot) + //if (!gCubeSnapshot) { LLDrawable* potential = drawablep; //determine if this is a good light for casting shadows @@ -9668,7 +9685,9 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowCubeProgram.bind(); } - LLRenderTarget& occlusion_target = mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_target = LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_SPOT_SHADOW0 ? + mSpotShadowOcclusion[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SPOT_SHADOW0] : + mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SUN_SHADOW0]; occlusion_target.bindTarget(); updateCull(shadow_cam, result); @@ -9812,7 +9831,9 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - LLRenderTarget& occlusion_source = mRT->shadow[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_source = LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_SPOT_SHADOW0 ? + mSpotShadow[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SPOT_SHADOW0] : + mRT->shadow[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SUN_SHADOW0]; if (occlude > 1) { @@ -10087,11 +10108,18 @@ void LLPipeline::generateHighlight(LLCamera& camera) } } -LLRenderTarget* LLPipeline::getShadowTarget(U32 i) +LLRenderTarget* LLPipeline::getSunShadowTarget(U32 i) { + llassert(i < 4); return &mRT->shadow[i]; } +LLRenderTarget* LLPipeline::getSpotShadowTarget(U32 i) +{ + llassert(i < 2); + return &mSpotShadow[i]; +} + static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow"); static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_SPOT_RENDER("Spot Shadow Render"); @@ -10371,7 +10399,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mShadowFrustPoints[j].clear(); } - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0+j); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SUN_SHADOW0+j); //restore render matrices set_current_modelview(saved_view); @@ -10745,116 +10773,119 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates { - LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); - F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); - - //update shadow targets - for (U32 i = 0; i < 2; i++) - { //for each current shadow - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); - - if (mShadowSpotLight[i].notNull() && - (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || - mShadowSpotLight[i] == mTargetShadowSpotLight[1])) - { //keep this spotlight - mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); - } - else - { //fade out this light - mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); - - if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) - { //faded out, grab one of the pending spots (whichever one isn't already taken) - if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) - { - mShadowSpotLight[i] = mTargetShadowSpotLight[0]; - } - else - { - mShadowSpotLight[i] = mTargetShadowSpotLight[1]; - } - } - } - } - - for (S32 i = 0; i < 2; i++) - { - set_current_modelview(saved_view); - set_current_projection(saved_proj); + LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); + F32 fade_amt = gFrameIntervalSeconds.value() + * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + + //update shadow targets + for (U32 i = 0; i < 2; i++) + { //for each current shadow + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SPOT_SHADOW0 + i); + + if (mShadowSpotLight[i].notNull() && + (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || + mShadowSpotLight[i] == mTargetShadowSpotLight[1])) + { //keep this spotlight + mSpotLightFade[i] = llmin(mSpotLightFade[i] + fade_amt, 1.f); + } + else + { //fade out this light + mSpotLightFade[i] = llmax(mSpotLightFade[i] - fade_amt, 0.f); - if (mShadowSpotLight[i].isNull()) - { - continue; + if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) + { //faded out, grab one of the pending spots (whichever one isn't already taken) + if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i + 1) % 2]) + { + mShadowSpotLight[i] = mTargetShadowSpotLight[0]; + } + else + { + mShadowSpotLight[i] = mTargetShadowSpotLight[1]; + } + } } + } + } - LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); + for (S32 i = 0; i < 2; i++) + { + set_current_modelview(saved_view); + set_current_projection(saved_proj); - if (!volume) - { - mShadowSpotLight[i] = NULL; - continue; - } + if (mShadowSpotLight[i].isNull()) + { + continue; + } - LLDrawable* drawable = mShadowSpotLight[i]; + LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); - LLVector3 params = volume->getSpotLightParams(); - F32 fov = params.mV[0]; + if (!volume) + { + mShadowSpotLight[i] = NULL; + continue; + } - //get agent->light space matrix (modelview) - LLVector3 center = drawable->getPositionAgent(); - LLQuaternion quat = volume->getRenderRotation(); + LLDrawable* drawable = mShadowSpotLight[i]; - //get near clip plane - LLVector3 scale = volume->getScale(); - LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); - at_axis *= quat; + LLVector3 params = volume->getSpotLightParams(); + F32 fov = params.mV[0]; - LLVector3 np = center + at_axis; - at_axis.normVec(); + //get agent->light space matrix (modelview) + LLVector3 center = drawable->getPositionAgent(); + LLQuaternion quat = volume->getRenderRotation(); - //get origin that has given fov for plane np, at_axis, and given scale - F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); + //get near clip plane + LLVector3 scale = volume->getScale(); + LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); + at_axis *= quat; - LLVector3 origin = np - at_axis * dist; + LLVector3 np = center + at_axis; + at_axis.normVec(); - LLMatrix4 mat(quat, LLVector4(origin, 1.f)); + //get origin that has given fov for plane np, at_axis, and given scale + F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); - view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); + LLVector3 origin = np - at_axis * dist; - view[i + 4] = view[i + 4].inverse(); + LLMatrix4 mat(quat, LLVector4(origin, 1.f)); - //get perspective matrix - F32 near_clip = dist + 0.01f; - F32 width = scale.mV[VX]; - F32 height = scale.mV[VY]; - F32 far_clip = dist + volume->getLightRadius() * 1.5f; + view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); - F32 fovy = fov * RAD_TO_DEG; - F32 aspect = width / height; + view[i + 4] = view[i + 4].inverse(); - proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); + //get perspective matrix + F32 near_clip = dist + 0.01f; + F32 width = scale.mV[VX]; + F32 height = scale.mV[VY]; + F32 far_clip = dist + volume->getLightRadius() * 1.5f; - //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + F32 fovy = fov * RAD_TO_DEG; + F32 aspect = width / height; - set_current_modelview(view[i + 4]); - set_current_projection(proj[i + 4]); + proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); - mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; + //translate and scale to from [-1, 1] to [0, 1] + glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, + 0.f, 0.5f, 0.f, 0.5f, + 0.f, 0.f, 0.5f, 0.5f, + 0.f, 0.f, 0.f, 1.f); - for (U32 j = 0; j < 16; j++) - { - gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; - gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; - } + set_current_modelview(view[i + 4]); + set_current_projection(proj[i + 4]); - mShadowModelview[i + 4] = view[i + 4]; - mShadowProjection[i + 4] = proj[i + 4]; + mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; + for (U32 j = 0; j < 16; j++) + { + gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; + gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; + } + + mShadowModelview[i + 4] = view[i + 4]; + mShadowProjection[i + 4] = proj[i + 4]; + + if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates + { LLCamera shadow_cam = camera; shadow_cam.setFar(far_clip); shadow_cam.setOrigin(origin); @@ -10863,15 +10894,17 @@ void LLPipeline::generateSunShadow(LLCamera& camera) stop_glerror(); - mRT->shadow[i + 4].bindTarget(); - mRT->shadow[i + 4].getViewport(gGLViewport); - mRT->shadow[i + 4].clear(); + // + + mSpotShadow[i].bindTarget(); + mSpotShadow[i].getViewport(gGLViewport); + mSpotShadow[i].clear(); - U32 target_width = mRT->shadow[i + 4].getWidth(); + U32 target_width = mSpotShadow[i].getWidth(); static LLCullResult result[2]; - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SPOT_SHADOW0 + i); RenderSpotLight = drawable; @@ -10879,7 +10912,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) RenderSpotLight = nullptr; - mRT->shadow[i + 4].flush(); + mSpotShadow[i].flush(); } } } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index f4c55bde7d..f05b7aec8e 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -218,8 +218,9 @@ public: U32 addObject(LLViewerObject *obj); void enableShadows(const bool enable_shadows); - void releaseShadowTargets(); - void releaseShadowTarget(U32 index); + void releaseSpotShadowTargets(); + void releaseSunShadowTargets(); + void releaseSunShadowTarget(U32 index); // void setLocalLighting(const bool local_lighting); // bool isLocalLightingEnabled() const; @@ -304,7 +305,8 @@ public: void generateWaterReflection(LLCamera& camera); void generateSunShadow(LLCamera& camera); - LLRenderTarget* getShadowTarget(U32 i); + LLRenderTarget* getSunShadowTarget(U32 i); + LLRenderTarget* getSpotShadowTarget(U32 i); void generateHighlight(LLCamera& camera); void renderHighlight(const LLViewerObject* obj, F32 fade); @@ -660,12 +662,15 @@ public: LLRenderTarget deferredLight; //sun shadow map - LLRenderTarget shadow[6]; - LLRenderTarget shadowOcclusion[6]; + LLRenderTarget shadow[4]; + LLRenderTarget shadowOcclusion[4]; }; RenderTargetPack* mRT; + LLRenderTarget mSpotShadow[2]; + LLRenderTarget mSpotShadowOcclusion[2]; + LLRenderTarget mHighlight; LLRenderTarget mPhysicsDisplay; @@ -688,6 +693,7 @@ public: LLVector3 mShadowFrustOrigin[4]; LLCamera mShadowCamera[8]; LLVector3 mShadowExtents[4][2]; + // TODO : separate Sun Shadow and Spot Shadow matrices glh::matrix4f mSunShadowMatrix[6]; glh::matrix4f mShadowModelview[6]; glh::matrix4f mShadowProjection[6]; diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index d1e167df64..8e12a01c6f 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -863,8 +863,42 @@ name="2" value="2"/> - - + + Reflections: + + + + + + + + Date: Fri, 10 Jun 2022 11:52:32 -0500 Subject: SL-17574 Fix for box probes not applying. --- .../newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index b3396baeba..4a40f691be 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -349,7 +349,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) for (int idx = 0; idx < probeInfluences; ++idx) { int i = probeIndex[idx]; - if (refIndex[i].w < max_priority) + if (abs(refIndex[i].w) < max_priority) { continue; } -- cgit v1.2.3 From 929abcd296199ab4ed7a0b08166e284502f7b8df Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 10 Jun 2022 16:36:38 -0500 Subject: SL-17523 Add reflection probe ambiance to windlight settings and integrate with UI and ReflectionMapManager --- indra/llinventory/llsettingssky.cpp | 17 ++++++++++++++++ indra/llinventory/llsettingssky.h | 6 ++++++ indra/llrender/llshadermgr.cpp | 1 + indra/llrender/llshadermgr.h | 1 + indra/newview/llpaneleditsky.cpp | 15 ++++++++++++++ indra/newview/llpaneleditsky.h | 1 + indra/newview/llreflectionmap.cpp | 4 +--- indra/newview/llreflectionmapmanager.cpp | 8 +++++++- indra/newview/llsettingsvo.cpp | 1 + .../default/xui/en/panel_settings_sky_atmos.xml | 23 ++++++++++++++++++++++ 10 files changed, 73 insertions(+), 4 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 83a92f08d0..d4e616abc2 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -131,6 +131,8 @@ const std::string LLSettingsSky::SETTING_SKY_MOISTURE_LEVEL("moisture_level"); const std::string LLSettingsSky::SETTING_SKY_DROPLET_RADIUS("droplet_radius"); const std::string LLSettingsSky::SETTING_SKY_ICE_LEVEL("ice_level"); +const std::string LLSettingsSky::SETTING_REFLECTION_PROBE_AMBIANCE("reflection_probe_ambiance"); + const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("3ae23978-ac82-bcf3-a9cb-ba6e52dcb9ad"); static const LLUUID DEFAULT_SUN_ID("32bfbcea-24b1-fb9d-1ef9-48a28a63730f"); // dataserver @@ -630,6 +632,9 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList() validation.push_back(Validator(SETTING_SKY_ICE_LEVEL, false, LLSD::TypeReal, boost::bind(&Validator::verifyFloatRange, _1, _2, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_REFLECTION_PROBE_AMBIANCE, false, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, _2, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_RAYLEIGH_CONFIG, true, LLSD::TypeArray, &validateRayleighLayers)); validation.push_back(Validator(SETTING_ABSORPTION_CONFIG, true, LLSD::TypeArray, &validateAbsorptionLayers)); validation.push_back(Validator(SETTING_MIE_CONFIG, true, LLSD::TypeArray, &validateMieLayers)); @@ -755,6 +760,8 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position) dfltsetting[SETTING_SKY_DROPLET_RADIUS] = 800.0f; dfltsetting[SETTING_SKY_ICE_LEVEL] = 0.0f; + dfltsetting[SETTING_REFLECTION_PROBE_AMBIANCE] = 0.0f; + dfltsetting[SETTING_RAYLEIGH_CONFIG] = rayleighConfigDefault(); dfltsetting[SETTING_MIE_CONFIG] = mieConfigDefault(); dfltsetting[SETTING_ABSORPTION_CONFIG] = absorptionConfigDefault(); @@ -1132,6 +1139,11 @@ void LLSettingsSky::setSkyIceLevel(F32 ice_level) setValue(SETTING_SKY_ICE_LEVEL, ice_level); } +void LLSettingsSky::setReflectionProbeAmbiance(F32 ambiance) +{ + setValue(SETTING_REFLECTION_PROBE_AMBIANCE, ambiance); +} + void LLSettingsSky::setAmbientColor(const LLColor3 &val) { mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = val.getValue(); @@ -1420,6 +1432,11 @@ F32 LLSettingsSky::getSkyIceLevel() const return mSettings[SETTING_SKY_ICE_LEVEL].asReal(); } +F32 LLSettingsSky::getReflectionProbeAmbiance() const +{ + return mSettings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); +} + F32 LLSettingsSky::getSkyBottomRadius() const { return mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index fa9326f006..715d31518b 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -97,6 +97,8 @@ public: static const std::string SETTING_SKY_DROPLET_RADIUS; static const std::string SETTING_SKY_ICE_LEVEL; + static const std::string SETTING_REFLECTION_PROBE_AMBIANCE; + static const std::string SETTING_LEGACY_HAZE; static const LLUUID DEFAULT_ASSET_ID; @@ -131,6 +133,8 @@ public: F32 getSkyDropletRadius() const; F32 getSkyIceLevel() const; + F32 getReflectionProbeAmbiance() const; + // Return first (only) profile layer represented in LLSD LLSD getRayleighConfig() const; LLSD getMieConfig() const; @@ -159,6 +163,8 @@ public: void setSkyDropletRadius(F32 radius); void setSkyIceLevel(F32 ice_level); + void setReflectionProbeAmbiance(F32 ambiance); + //--------------------------------------------------------------------- LLColor3 getAmbientColor() const; void setAmbientColor(const LLColor3 &val); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index bdc1f78201..e2e1ff9714 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1342,6 +1342,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("halo_map"); mReservedUniforms.push_back("moon_brightness"); mReservedUniforms.push_back("cloud_variance"); + mReservedUniforms.push_back("reflection_probe_ambiance"); mReservedUniforms.push_back("sh_input_r"); mReservedUniforms.push_back("sh_input_g"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 663ba28b6d..d3bb2b9db4 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -243,6 +243,7 @@ public: CLOUD_VARIANCE, // "cloud_variance" + REFLECTION_PROBE_AMBIANCE, // "reflection_probe_ambiance" SH_INPUT_L1R, // "sh_input_r" SH_INPUT_L1G, // "sh_input_g" SH_INPUT_L1B, // "sh_input_b" diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index a169712bd8..d17845ebc5 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -108,6 +108,8 @@ namespace const std::string FIELD_SKY_DENSITY_DROPLET_RADIUS("droplet_radius"); const std::string FIELD_SKY_DENSITY_ICE_LEVEL("ice_level"); + const std::string FIELD_REFLECTION_PROBE_AMBIANCE("probe_ambiance"); + const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f); const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f); const F32 SLIDER_SCALE_GLOW_R(20.0f); @@ -150,6 +152,7 @@ BOOL LLPanelSettingsSkyAtmosTab::postBuild() getChild(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoistureLevelChanged(); }); getChild(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDropletRadiusChanged(); }); getChild(FIELD_SKY_DENSITY_ICE_LEVEL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onIceLevelChanged(); }); + getChild(FIELD_REFLECTION_PROBE_AMBIANCE)->setCommitCallback([this](LLUICtrl*, const LLSD&) { onReflectionProbeAmbianceChanged(); }); refresh(); return TRUE; @@ -172,6 +175,7 @@ void LLPanelSettingsSkyAtmosTab::setEnabled(BOOL enabled) getChild(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ICE_LEVEL)->setEnabled(enabled); + getChild(FIELD_REFLECTION_PROBE_AMBIANCE)->setEnabled(enabled); } } @@ -203,10 +207,12 @@ void LLPanelSettingsSkyAtmosTab::refresh() F32 moisture_level = mSkySettings->getSkyMoistureLevel(); F32 droplet_radius = mSkySettings->getSkyDropletRadius(); F32 ice_level = mSkySettings->getSkyIceLevel(); + F32 rp_ambiance = mSkySettings->getReflectionProbeAmbiance(); getChild(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setValue(moisture_level); getChild(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setValue(droplet_radius); getChild(FIELD_SKY_DENSITY_ICE_LEVEL)->setValue(ice_level); + getChild(FIELD_REFLECTION_PROBE_AMBIANCE)->setValue(rp_ambiance); } //------------------------------------------------------------------------- @@ -311,6 +317,15 @@ void LLPanelSettingsSkyAtmosTab::onIceLevelChanged() setIsDirty(); } +void LLPanelSettingsSkyAtmosTab::onReflectionProbeAmbianceChanged() +{ + if (!mSkySettings) return; + F32 ambiance = getChild(FIELD_REFLECTION_PROBE_AMBIANCE)->getValue().asReal(); + mSkySettings->setReflectionProbeAmbiance(ambiance); + mSkySettings->update(); + setIsDirty(); +} + //========================================================================== LLPanelSettingsSkyCloudTab::LLPanelSettingsSkyCloudTab() : LLPanelSettingsSky() diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index cb63d40b0c..cd89e02eea 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -79,6 +79,7 @@ private: void onMoistureLevelChanged(); void onDropletRadiusChanged(); void onIceLevelChanged(); + void onReflectionProbeAmbianceChanged(); }; diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 500485fc70..4d4eb802f1 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -196,15 +196,13 @@ extern LLControlGroup gSavedSettings; F32 LLReflectionMap::getAmbiance() { - static LLCachedControl minimum_ambiance(gSavedSettings, "RenderReflectionProbeAmbiance", 0.f); - F32 ret = 0.f; if (mViewerObject && mViewerObject->getVolume()) { ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeAmbiance(); } - return llmax(ret, minimum_ambiance()); + return ret; } F32 LLReflectionMap::getNearClip() diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index dc733687c3..48ed22d79f 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -33,6 +33,7 @@ #include "pipeline.h" #include "llviewershadermgr.h" #include "llviewercontrol.h" +#include "llenvironment.h" extern BOOL gCubeSnapshot; extern BOOL gTeleportDisplay; @@ -559,6 +560,11 @@ void LLReflectionMapManager::updateUniforms() S32 count = 0; U32 nc = 0; // neighbor "cursor" - index into refNeighbor to start writing the next probe's list of neighbors + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); + + F32 minimum_ambiance = psky->getReflectionProbeAmbiance(); + for (auto* refmap : mReflectionMaps) { if (refmap == nullptr) @@ -591,7 +597,7 @@ void LLReflectionMapManager::updateUniforms() rpd.refIndex[count][3] = -rpd.refIndex[count][3]; } - rpd.refParams[count].set(refmap->getAmbiance(), 0.f, 0.f, 0.f); + rpd.refParams[count].set(llmax(minimum_ambiance, refmap->getAmbiance()), 0.f, 0.f, 0.f); S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors { diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 14a9f4aa30..ed823fbba4 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -758,6 +758,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); param_map[SETTING_SKY_ICE_LEVEL] = DefaultParam(LLShaderMgr::ICE_LEVEL, sky_defaults[SETTING_SKY_ICE_LEVEL]); + param_map[SETTING_REFLECTION_PROBE_AMBIANCE] = DefaultParam(LLShaderMgr::REFLECTION_PROBE_AMBIANCE, sky_defaults[SETTING_REFLECTION_PROBE_AMBIANCE]); // AdvancedAtmospherics TODO // Provide mappings for new shader params here } diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml index 6f82a0efa1..094be36b01 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml @@ -315,6 +315,29 @@ top_delta="20" width="219" can_edit_text="true"/> + + Reflection Probe Ambiance: + + -- cgit v1.2.3 From 3b043d90b60eca17dfcc014b21c4c8fc5b432384 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 13 Jun 2022 15:18:14 -0400 Subject: SL-17483: Per review feedback, avoid LLPointer refcount twiddling when passing LLPointers into functions. Only increment the refcount when storing in new ImageRequest. --- indra/llimage/llimageworker.cpp | 17 +++++++++++------ indra/llimage/llimageworker.h | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp index 3c21499673..0093958e6d 100644 --- a/indra/llimage/llimageworker.cpp +++ b/indra/llimage/llimageworker.cpp @@ -34,15 +34,17 @@ class ImageRequest { public: - ImageRequest(LLPointer image, + ImageRequest(const LLPointer& image, S32 discard, BOOL needs_aux, - LLPointer responder); + const LLPointer& responder); virtual ~ImageRequest(); /*virtual*/ bool processRequest(); /*virtual*/ void finishRequest(bool completed); private: + // LLPointers stored in ImageRequest MUST be LLPointer instances rather + // than references: we need to increment the refcount when storing these. // input LLPointer mFormattedImage; S32 mDiscardLevel; @@ -82,8 +84,11 @@ S32 LLImageDecodeThread::getPending() return mThreadPool->getQueue().size(); } -LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLPointer image, - S32 discard, BOOL needs_aux, LLPointer responder) +LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage( + const LLPointer& image, + S32 discard, + BOOL needs_aux, + const LLPointer& responder) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -113,9 +118,9 @@ LLImageDecodeThread::Responder::~Responder() //---------------------------------------------------------------------------- -ImageRequest::ImageRequest(LLPointer image, +ImageRequest::ImageRequest(const LLPointer& image, S32 discard, BOOL needs_aux, - LLPointer responder) + const LLPointer& responder) : mFormattedImage(image), mDiscardLevel(discard), mNeedsAux(needs_aux), diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h index 6a0b2b4681..18398d9ae2 100644 --- a/indra/llimage/llimageworker.h +++ b/indra/llimage/llimageworker.h @@ -52,9 +52,9 @@ public: // meant to resemble LLQueuedThread::handle_t typedef U32 handle_t; - handle_t decodeImage(LLPointer image, + handle_t decodeImage(const LLPointer& image, S32 discard, BOOL needs_aux, - LLPointer responder); + const LLPointer& responder); S32 getPending(); S32 update(F32 max_time_ms); void shutdown(); -- cgit v1.2.3 From 758a602f20340c5efde626fcace5a11133cfb859 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 13 Jun 2022 13:47:34 -0700 Subject: SL-17485 - mac getVramSize should return all vram, not just texture-specific, and use to compute getAvailableVRAMMegabytes. --- indra/llwindow/llopenglview-objc.mm | 7 ++++++- indra/llwindow/llwindowmacosx.cpp | 10 ++++++++++ indra/llwindow/llwindowmacosx.h | 3 +-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index fd20f2ad15..8d064ec86c 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -141,7 +141,12 @@ attributedStringInfo getSegments(NSAttributedString *str) CGLError the_err = CGLQueryRendererInfo (CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), &info, &num_renderers); if(0 == the_err) { - CGLDescribeRenderer (info, 0, kCGLRPTextureMemoryMegabytes, &vram_megabytes); + // The name, uses, and other platform definitions of gGLManager.mVRAM suggest that this is supposed to be total vram in MB, + // rather than, say, just the texture memory. The two exceptions are: + // 1. LLAppViewer::getViewerInfo() puts the value in a field labeled "TEXTURE_MEMORY" + // 2. For years, this present function used kCGLRPTextureMemoryMegabytes + // Now we use kCGLRPVideoMemoryMegabytes to bring it in line with everything else (except thatone label). + CGLDescribeRenderer (info, 0, kCGLRPVideoMemoryMegabytes, &vram_megabytes); CGLDestroyRendererInfo (info); } else diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index bc4f07941b..4bcb9b3aef 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -1222,6 +1222,16 @@ F32 LLWindowMacOSX::getPixelAspectRatio() return 1.f; } +U32 LLWindowMacOSX::getAvailableVRAMMegabytes() { + // MTL (and MoltenVK) has some additional gpu data, such as recommendedMaxWorkingSetSize and currentAllocatedSize. + // But these are not available for OpenGL and/or our current mimimum OS version. + // So we will estimate. + static const U32 mb = 1024*1024; + // We're asked for total available gpu memory, but we only have allocation info on texture usage. So estimate by doubling that. + static const U32 total_factor = 2; // estimated total/textures + return gGLManager.mVRAM - (LLImageGL::getTextureBytesAllocated() * total_factor/mb); +} + //static SInt32 oldWindowLevel; // MBW -- XXX -- There's got to be a better way than this. Find it, please... diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 309d1377ea..0f316f1ddf 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -101,8 +101,7 @@ public: void setNativeAspectRatio(F32 ratio) override { mOverrideAspectRatio = ratio; } // query VRAM usage - // FIXME FIXME - virtual U32 getAvailableVRAMMegabytes() override { return 0; } + /*virtual*/ U32 getAvailableVRAMMegabytes() override; void beforeDialog() override; void afterDialog() override; -- cgit v1.2.3 From bdd76a6a1d0ee0fa5a8da76f1e8c8583822eeabe Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 13 Jun 2022 13:59:07 -0700 Subject: SL-17485 - Provide corrected missing memory data on mac: sAllocatedPageSizeInKB, sAllocatedMemInKB, sAvailPhysicalMemInKB, sMaxPhysicalMemInKB --- indra/llcommon/llmemory.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 849867586a..267159e7cc 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -35,6 +35,7 @@ # include # include # include +#include #elif LL_LINUX # include #endif @@ -46,6 +47,9 @@ #include "lltrace.h" #include "llerror.h" //---------------------------------------------------------------------------- +#if defined(LL_DARWIN) +extern LLMemoryInfo gSysMemory; +#endif //static U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); @@ -109,6 +113,51 @@ void LLMemory::updateMemoryInfo() { sAvailPhysicalMemInKB = U32Kilobytes(0); } + +#elif defined(LL_DARWIN) + task_vm_info info; + mach_msg_type_number_t infoCount = TASK_VM_INFO_COUNT; + // MACH_TASK_BASIC_INFO reports the same resident_size, but does not tell us the reusable bytes or phys_footprint. + if (task_info(mach_task_self(), TASK_VM_INFO, reinterpret_cast(&info), &infoCount) == KERN_SUCCESS) + { + // Our Windows definition of PagefileUsage is documented by Microsoft as "the total amount of + // memory that the memory manager has committed for a running process", which is rss. + sAllocatedPageSizeInKB = U32Bytes(info.resident_size); + + // Activity Monitor => Inspect Process => Real Memory Size appears to report resident_size + // Activity monitor => main window memory column appears to report phys_footprint, which spot checks as at least 30% less. + // I think that is because of compression, which isn't going to give us a consistent measurement. We want uncompressed totals. + // + // In between is resident_size - reusable. This is what Chrome source code uses, with source comments saying it is 'the "Real Memory" value + // reported for the app by the Memory Monitor in Instruments.' It is still about 8% bigger than phys_footprint. + // + // (On Windows, we use WorkingSetSize.) + sAllocatedMemInKB = U32Bytes(info.resident_size - info.reusable); + } + else + { + LL_WARNS() << "task_info failed" << LL_ENDL; + } + + // Total installed and available physical memory are properties of the host, not just our process. + vm_statistics64_data_t vmstat; + mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; + mach_port_t host = mach_host_self(); + vm_size_t page_size; + host_page_size(host, &page_size); + kern_return_t result = host_statistics64(host, HOST_VM_INFO64, reinterpret_cast(&vmstat), &count); + if (result == KERN_SUCCESS) { + // This is what Chrome reports as 'the "Physical Memory Free" value reported by the Memory Monitor in Instruments.' + // Note though that inactive pages are not included here and not yet free, but could become so under memory pressure. + sAvailPhysicalMemInKB = U32Bytes(vmstat.free_count * page_size); + + sMaxPhysicalMemInKB = gSysMemory.getPhysicalMemoryKB(); + } + else + { + LL_WARNS() << "task_info failed" << LL_ENDL; + } + #else //not valid for other systems for now. sAllocatedMemInKB = U64Bytes(LLMemory::getCurrentRSS()); -- cgit v1.2.3 From 91a9665e35a3bfeb5a2bc81586a23e70bb2c7596 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 13 Jun 2022 14:00:13 -0700 Subject: SL-17485 - Make mac compiler happier. --- indra/cmake/00-Common.cmake | 2 +- indra/newview/llviewertexture.cpp | 2 +- indra/newview/llviewertexture.h | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index bb5dd8f847..3e672cb128 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -201,7 +201,7 @@ if (LINUX OR DARWIN) endif() if (NOT GCC_DISABLE_FATAL_WARNINGS) - set(GCC_WARNINGS "${GCC_WARNINGS} -Werror") + set(GCC_WARNINGS "${GCC_WARNINGS} -Werror -Wno-error=unused-but-set-variable") endif (NOT GCC_DISABLE_FATAL_WARNINGS) set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor") diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 16b07159ba..a6e7b01df7 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -524,7 +524,7 @@ void LLViewerTexture::getGPUMemoryForTextures(S32Megabytes &gpu, S32Megabytes &p { gpu_res = (S32Megabytes)gViewerWindow->getWindow()->getAvailableVRAMMegabytes(); - //check main memory, only works for windows. + //check main memory, only works for windows and macos. LLMemory::updateMemoryInfo(); physical_res = LLMemory::getAvailableMemKB(); diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index f3bc9061a2..8c41c4a6bc 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -302,10 +302,10 @@ public: }; public: - /*virtual*/ S8 getType() const ; + /*virtual*/ S8 getType() const override; FTType getFTType() const; - /*virtual*/ void forceImmediateUpdate() ; - /*virtual*/ void dump() ; + /*virtual*/ void forceImmediateUpdate() override; + /*virtual*/ void dump() override; // Set callbacks to get called when the image gets updated with higher // resolution versions. @@ -356,14 +356,14 @@ public: // Override the computation of discard levels if we know the exact output // size of the image. Used for UI textures to not decode, even if we have // more data. - /*virtual*/ void setKnownDrawSize(S32 width, S32 height); + /*virtual*/ void setKnownDrawSize(S32 width, S32 height) override; // Set the debug text of all Viewer Objects associated with this texture // to the specified text void setDebugText(const std::string& text); void setIsMissingAsset(BOOL is_missing = true); - /*virtual*/ BOOL isMissingAsset() const { return mIsMissingAsset; } + /*virtual*/ BOOL isMissingAsset() const override { return mIsMissingAsset; } // returns dimensions of original image for local files (before power of two scaling) // and returns 0 for all asset system images @@ -406,7 +406,7 @@ public: BOOL isRawImageValid()const { return mIsRawImageValid ; } void forceToSaveRawImage(S32 desired_discard = 0, F32 kept_time = 0.f) ; void forceToRefetchTexture(S32 desired_discard = 0, F32 kept_time = 60.f); - /*virtual*/ void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) ; + /*virtual*/ void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) override; void destroySavedRawImage() ; LLImageRaw* getSavedRawImage() ; BOOL hasSavedRawImage() const ; @@ -422,10 +422,10 @@ public: void setInFastCacheList(bool in_list) { mInFastCacheList = in_list; } bool isInFastCacheList() { return mInFastCacheList; } - /*virtual*/bool isActiveFetching(); //is actively in fetching by the fetching pipeline. + /*virtual*/bool isActiveFetching() override; //is actively in fetching by the fetching pipeline. protected: - /*virtual*/ void switchToCachedImage(); + /*virtual*/ void switchToCachedImage() override; S32 getCurrentDiscardLevelForFetching() ; private: -- cgit v1.2.3 From ad533fcd6b1a3433273fa6d75e19a7ce56c75867 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 14 Jun 2022 23:39:11 -0500 Subject: SL-17586 WIP -- LLMaterialEditor prototype and "New Material" inventory buttons. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llinventorybridge.cpp | 3 + indra/newview/llmaterialeditor.cpp | 207 ++++++++++++ indra/newview/llmaterialeditor.h | 58 ++++ indra/newview/llviewerfloaterreg.cpp | 3 + indra/newview/llviewerinventory.cpp | 11 + .../default/xui/en/floater_material_editor.xml | 374 +++++++++++++++++++++ .../skins/default/xui/en/menu_inventory.xml | 8 + .../skins/default/xui/en/menu_inventory_add.xml | 8 + indra/newview/skins/default/xui/en/menu_viewer.xml | 10 +- indra/newview/skins/default/xui/en/strings.xml | 1 + 11 files changed, 684 insertions(+), 1 deletion(-) create mode 100644 indra/newview/llmaterialeditor.cpp create mode 100644 indra/newview/llmaterialeditor.h create mode 100644 indra/newview/skins/default/xui/en/floater_material_editor.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e7aa884f6b..0d2b99a8cd 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -404,6 +404,7 @@ set(viewer_SOURCE_FILES llmaniptranslate.cpp llmarketplacefunctions.cpp llmarketplacenotifications.cpp + llmaterialeditor.cpp llmaterialmgr.cpp llmediactrl.cpp llmediadataclient.cpp @@ -1044,6 +1045,7 @@ set(viewer_HEADER_FILES llmaniptranslate.h llmarketplacefunctions.h llmarketplacenotifications.h + llmaterialeditor.h llmaterialmgr.h llmediactrl.h llmediadataclient.h diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index a0de3a2af1..a296d2dfef 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4011,6 +4011,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items disabled_items.push_back(std::string("New Note")); disabled_items.push_back(std::string("New Settings")); disabled_items.push_back(std::string("New Gesture")); + disabled_items.push_back(std::string("New Material")); disabled_items.push_back(std::string("New Clothes")); disabled_items.push_back(std::string("New Body Parts")); disabled_items.push_back(std::string("upload_def")); @@ -4038,6 +4039,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items disabled_items.push_back(std::string("New Script")); disabled_items.push_back(std::string("New Note")); disabled_items.push_back(std::string("New Gesture")); + disabled_items.push_back(std::string("New Material")); disabled_items.push_back(std::string("New Clothes")); disabled_items.push_back(std::string("New Body Parts")); disabled_items.push_back(std::string("upload_def")); @@ -4102,6 +4104,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items items.push_back(std::string("New Script")); items.push_back(std::string("New Note")); items.push_back(std::string("New Gesture")); + items.push_back(std::string("New Material")); items.push_back(std::string("New Clothes")); items.push_back(std::string("New Body Parts")); items.push_back(std::string("New Settings")); diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp new file mode 100644 index 0000000000..6e7f7adfed --- /dev/null +++ b/indra/newview/llmaterialeditor.cpp @@ -0,0 +1,207 @@ +/** + * @file llmaterialeditor.cpp + * @brief Implementation of the notecard editor + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llmaterialeditor.h" +#include "llcombobox.h" + +#include "tinygltf/tiny_gltf.h" + +///---------------------------------------------------------------------------- +/// Class LLPreviewNotecard +///---------------------------------------------------------------------------- + +// Default constructor +LLMaterialEditor::LLMaterialEditor(const LLSD& key) + : LLFloater(key) +{ +} + +BOOL LLMaterialEditor::postBuild() +{ + childSetAction("save", boost::bind(&LLMaterialEditor::onClickSave, this)); + return LLFloater::postBuild(); +} + +LLUUID LLMaterialEditor::getAlbedoId() +{ + return childGetValue("albedo texture").asUUID(); +} + +LLColor4 LLMaterialEditor::getAlbedoColor() +{ + LLColor4 ret = LLColor4(childGetValue("albedo color")); + ret.mV[3] = getTransparency(); + return ret; +} + + +F32 LLMaterialEditor::getTransparency() +{ + return childGetValue("transparency").asReal(); +} + +std::string LLMaterialEditor::getAlphaMode() +{ + return childGetValue("alpha mode").asString(); +} + +F32 LLMaterialEditor::getAlphaCutoff() +{ + return childGetValue("alpha cutoff").asReal(); +} + +LLUUID LLMaterialEditor::getMetallicRoughnessId() +{ + return childGetValue("metallic-roughness texture").asUUID(); +} + +F32 LLMaterialEditor::getMetalnessFactor() +{ + return childGetValue("metalness factor").asReal(); +} + +F32 LLMaterialEditor::getRoughnessFactor() +{ + return childGetValue("roughness factor").asReal(); +} + +LLUUID LLMaterialEditor::getEmissiveId() +{ + return childGetValue("emissive texture").asUUID(); +} + +LLColor4 LLMaterialEditor::getEmissiveColor() +{ + return LLColor4(childGetValue("emissive color")); +} + +LLUUID LLMaterialEditor::getNormalId() +{ + return childGetValue("normal texture").asUUID(); +} + +bool LLMaterialEditor::getDoubleSided() +{ + return childGetValue("double sided").asBoolean(); +} + + +static void write_color(const LLColor4& color, std::vector& c) +{ + for (int i = 0; i < c.size(); ++i) // NOTE -- use c.size because some gltf colors are 3-component + { + c[i] = color.mV[i]; + } +} + +static U32 write_texture(const LLUUID& id, tinygltf::Model& model) +{ + tinygltf::Image image; + image.uri = id.asString(); + model.images.push_back(image); + U32 image_idx = model.images.size() - 1; + + tinygltf::Texture texture; + texture.source = image_idx; + model.textures.push_back(texture); + U32 texture_idx = model.textures.size() - 1; + + return texture_idx; +} + +void LLMaterialEditor::onClickSave() +{ + tinygltf::Model model; + model.materials.resize(1); + tinygltf::PbrMetallicRoughness& pbrMaterial = model.materials[0].pbrMetallicRoughness; + + // write albedo + LLColor4 albedo_color = getAlbedoColor(); + albedo_color.mV[3] = getTransparency(); + write_color(albedo_color, pbrMaterial.baseColorFactor); + + model.materials[0].alphaCutoff = getAlphaCutoff(); + model.materials[0].alphaMode = getAlphaMode(); + + LLUUID albedo_id = getAlbedoId(); + + if (albedo_id.notNull()) + { + U32 texture_idx = write_texture(albedo_id, model); + + pbrMaterial.baseColorTexture.index = texture_idx; + } + + // write metallic/roughness + F32 metalness = getMetalnessFactor(); + F32 roughness = getRoughnessFactor(); + + pbrMaterial.metallicFactor = metalness; + pbrMaterial.roughnessFactor = roughness; + + LLUUID mr_id = getMetallicRoughnessId(); + if (mr_id.notNull()) + { + U32 texture_idx = write_texture(mr_id, model); + pbrMaterial.metallicRoughnessTexture.index = texture_idx; + } + + //write emissive + LLColor4 emissive_color = getEmissiveColor(); + model.materials[0].emissiveFactor.resize(3); + write_color(emissive_color, model.materials[0].emissiveFactor); + + LLUUID emissive_id = getEmissiveId(); + if (emissive_id.notNull()) + { + U32 idx = write_texture(emissive_id, model); + model.materials[0].emissiveTexture.index = idx; + } + + //write normal + LLUUID normal_id = getNormalId(); + if (normal_id.notNull()) + { + U32 idx = write_texture(normal_id, model); + model.materials[0].normalTexture.index = idx; + } + + //write doublesided + model.materials[0].doubleSided = getDoubleSided(); + + std::ostringstream str; + + tinygltf::TinyGLTF gltf; + model.asset.version = "2.0"; + gltf.WriteGltfSceneToStream(&model, str, true, false); + + std::string dump = str.str(); + + LL_INFOS() << dump << LL_ENDL; +} + diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h new file mode 100644 index 0000000000..febdb3bbc1 --- /dev/null +++ b/indra/newview/llmaterialeditor.h @@ -0,0 +1,58 @@ +/** + * @file llmaterialeditor.h + * @brief LLMaterialEditor class header file + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#pragma once + +#include "llfloater.h" + +class LLMaterialEditor : public LLFloater +{ +public: + LLMaterialEditor(const LLSD& key); + + void onClickSave(); + + // llpanel + BOOL postBuild() override; + + LLUUID getAlbedoId(); + LLColor4 getAlbedoColor(); + F32 getTransparency(); + std::string getAlphaMode(); + F32 getAlphaCutoff(); + + LLUUID getMetallicRoughnessId(); + F32 getMetalnessFactor(); + F32 getRoughnessFactor(); + + LLUUID getEmissiveId(); + LLColor4 getEmissiveColor(); + + LLUUID getNormalId(); + + bool getDoubleSided(); +}; + diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index dd03d6cfdd..97cb8e2000 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -152,6 +152,7 @@ #include "llinspectobject.h" #include "llinspectremoteobject.h" #include "llinspecttoast.h" +#include "llmaterialeditor.h" #include "llmoveview.h" #include "llfloaterimnearbychat.h" #include "llpanelblockedlist.h" @@ -337,6 +338,8 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("save_camera_preset", "floater_save_camera_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("material_editor", "floater_material_editor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build); LLFloaterReg::add("test_inspectors", "floater_test_inspectors.xml", &LLFloaterReg::build); //LLFloaterReg::add("test_list_view", "floater_test_list_view.xml",&LLFloaterReg::build); diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 55ac817479..d777cde554 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -147,6 +147,7 @@ LLLocalizedInventoryItemsDictionary::LLLocalizedInventoryItemsDictionary() mInventoryItemsDict["Invalid Wearable"] = LLTrans::getString("Invalid Wearable"); mInventoryItemsDict["New Gesture"] = LLTrans::getString("New Gesture"); + mInventoryItemsDict["New Material"] = LLTrans::getString("New Material"); mInventoryItemsDict["New Script"] = LLTrans::getString("New Script"); mInventoryItemsDict["New Folder"] = LLTrans::getString("New Folder"); mInventoryItemsDict["New Note"] = LLTrans::getString("New Note"); @@ -1672,6 +1673,7 @@ void remove_folder_contents(const LLUUID& category, bool keep_outfit_links, const std::string NEW_LSL_NAME = "New Script"; // *TODO:Translate? (probably not) const std::string NEW_NOTECARD_NAME = "New Note"; // *TODO:Translate? (probably not) const std::string NEW_GESTURE_NAME = "New Gesture"; // *TODO:Translate? (probably not) +const std::string NEW_MATERIAL_NAME = "New Material"; // *TODO:Translate? (probably not) // ! REFACTOR ! Really need to refactor this so that it's not a bunch of if-then statements... void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, const LLSD& userdata, const LLUUID& default_parent_uuid) @@ -1727,6 +1729,15 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge, LLInventoryType::IT_GESTURE, PERM_ALL); // overridden in create_new_item } + else if ("material" == type_name) + { + const LLUUID parent_id = bridge ? bridge->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE); + create_new_item(NEW_GESTURE_NAME, + parent_id, + LLAssetType::AT_MATERIAL, + LLInventoryType::IT_MATERIAL, + PERM_ALL); // overridden in create_new_item + } else if (("sky" == type_name) || ("water" == type_name) || ("daycycle" == type_name)) { LLSettingsType::type_e stype(LLSettingsType::ST_NONE); diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml new file mode 100644 index 0000000000..5d72e6f79d --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -0,0 +1,374 @@ + + + + + Albedo: + + + + Tint + + + + Transparency + + + + Alpha mode + + + + + + + + Alpha Cutoff + + + + + + Metallic-Roughness: + + + + Metallic Factor + + + + Roughness Factor + + + + + + Emissive: + + + + Tint + + + + + + + Normal: + + + + + + + + +