Skip to content

Commit 3948bf4

Browse files
committed
Merge branch 'master' into for-0.56.0/sync
2 parents c5e4fcb + 4038c9e commit 3948bf4

23 files changed

+276
-562
lines changed

CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,20 @@ endif()
514514
if (WIN32)
515515
set(LIBS_BASE ${LIBS_BASE} winmm ws2_32)
516516
elseif (NACL)
517-
if (NOT USE_NACL_SAIGO)
518-
find_library(NACL_EXCEPTION nacl_exception)
519-
find_library(NACL_MINIDUMP minidump_generator)
520-
set(LIBS_BASE ${LIBS_BASE} ${NACL_MINIDUMP} ${NACL_EXCEPTION})
517+
find_library(NACL_EXCEPTION nacl_exception)
518+
find_library(NACL_MINIDUMP minidump_generator)
519+
520+
# HACK: To be removed when Saigo is repackaged properly.
521+
if (NOT NACL_MINIDUMP
522+
# NACL_TARGET is specific to Saigo, PNaCl target is le32 and doesn't set NACL_TARGET.
523+
AND "${NACL_TARGET}" STREQUAL "i686"
524+
# x86_64-nacl/lib32 is specific to Google build, other builds may provide i686-nacl/lib instead.
525+
AND EXISTS "${DEPS_DIR}/saigo_newlib/x86_64-nacl/lib32")
526+
set(NACL_EXCEPTION "${DEPS_DIR}/saigo_newlib/x86_64-nacl/lib32/libnacl_exception.a")
527+
set(NACL_MINIDUMP "${DEPS_DIR}/saigo_newlib/x86_64-nacl/lib32/libminidump_generator.a")
521528
endif()
529+
530+
set(LIBS_BASE ${LIBS_BASE} ${NACL_MINIDUMP} ${NACL_EXCEPTION})
522531
else()
523532
find_library(LIBM m)
524533
if (LIBM)

src/common/System.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3939
#include <sys/random.h>
4040
#endif
4141
#ifdef __native_client__
42-
#if !defined(__saigo__)
43-
#include <nacl/nacl_exception.h>
44-
#include <nacl/nacl_minidump.h>
45-
#endif
42+
#include <nacl/native_client/src/include/nacl/nacl_minidump.h>
4643
#include <nacl/nacl_random.h>
4744
#else
4845
#include <dlfcn.h>
@@ -60,12 +57,12 @@ namespace Sys {
6057
// TODO: also use in VMs when cvars can be observed from multiple modules
6158
// This option can be turned on when debugging memory management
6259
#ifdef BUILD_ENGINE
63-
static Cvar::Cvar<bool> pedanticShutdown("common.pedanticShutdown", "run useless shutdown procedures before exit", Cvar::NONE,
6460
#ifdef USING_SANITIZER
65-
true);
61+
constexpr bool defaultPedanticShutdown = true;
6662
#else
67-
false);
63+
constexpr bool defaultPedanticShutdown = false;
6864
#endif
65+
static Cvar::Cvar<bool> pedanticShutdown("common.pedanticShutdown", "run useless shutdown procedures before exit", Cvar::NONE, defaultPedanticShutdown);
6966
#endif // BUILD_ENGINE
7067

7168
#if defined(BUILD_ENGINE) && defined(_WIN32)
@@ -337,10 +334,8 @@ static void CrashHandler(const void* data, size_t n)
337334

338335
void SetupCrashHandler()
339336
{
340-
#if !defined(__saigo__)
341337
nacl_minidump_register_crash_handler();
342338
nacl_minidump_set_callback(CrashHandler);
343-
#endif
344339
}
345340
#else
346341
NORETURN static void CrashHandler(int sig)

src/engine/framework/CvarSystem.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -688,41 +688,48 @@ namespace Cvar {
688688
CvarMap& cvars = GetCvarMap();
689689

690690
bool raw = false;
691-
std::string match = "";
691+
std::string pattern = "";
692692

693693
//Read parameters
694694
if (args.Argc() > 1) {
695-
match = args.Argv(1);
696-
if (Cmd::IsSwitch(match, "-raw")) {
695+
pattern = args.Argv(1);
696+
if (Cmd::IsSwitch(pattern, "-raw")) {
697697
raw = true;
698-
match = (args.Argc() > 2) ? args.Argv(2) : "";
698+
pattern = (args.Argc() > 2) ? args.Argv(2) : "";
699699
}
700700
}
701701

702-
std::vector<cvarRecord_t*> matches;
702+
struct CvarMatch_t {
703+
std::string name;
704+
cvarRecord_t* record;
705+
};
703706

704-
std::vector<std::string> matchesNames;
705-
size_t maxNameLength = 0;
707+
std::vector<CvarMatch_t> matches;
706708

707-
std::vector<std::string> matchesValues;
709+
size_t maxNameLength = 0;
708710

709711
//Find all the matching cvars
710712
for (auto& entry : cvars) {
711-
if (Com_Filter(match.c_str(), entry.first.c_str(), false)) {
712-
matchesNames.push_back(entry.first);
713+
if (Com_Filter(pattern.c_str(), entry.first.c_str(), false)) {
714+
CvarMatch_t match;
713715

714-
matches.push_back(entry.second);
715-
matchesValues.push_back(entry.second->value);
716+
match.name = entry.first;
717+
match.record = entry.second;
718+
matches.push_back(match);
716719

717720
//TODO: the raw parameter is not handled, need a function to escape carets
718-
maxNameLength = std::max(maxNameLength, entry.first.length());
721+
maxNameLength = std::max(maxNameLength, match.name.length());
719722
}
720723
}
721724

725+
// TODO: case insensitive compare function?
726+
std::sort(matches.begin(), matches.end(),
727+
[](CvarMatch_t &a, CvarMatch_t &b) { return a.name < b.name; });
728+
722729
//Print the matches, keeping the flags and descriptions aligned
723730
for (size_t i = 0; i < matches.size(); i++) {
724-
const std::string& name = matchesNames[i];
725-
cvarRecord_t* var = matches[i];
731+
const std::string& name = matches[i].name;
732+
cvarRecord_t* var = matches[i].record;
726733

727734
std::string cvarFlags = "";
728735
cvarFlags += (var->flags & SERVERINFO) ? "S" : "_";

src/engine/renderer/Material.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,8 @@ void BindShaderLightMapping( Material* material ) {
908908

909909
const float interpolation = 1.0 - trilerp[0];
910910

911-
if ( r_logFile->integer ) {
912-
GLimp_LogComment( va( "Probe 0 distance = %f, probe 1 distance = %f, interpolation = %f\n",
913-
Distance( position, probes[0]->origin ), Distance( position, probes[1]->origin ), interpolation ) );
914-
}
911+
GLIMP_LOGCOMMENT( "Probe 0 distance = %f, probe 1 distance = %f, interpolation = %f",
912+
Distance( position, probes[0]->origin ), Distance( position, probes[1]->origin ), interpolation );
915913

916914
// bind u_EnvironmentMap0
917915
gl_lightMappingShaderMaterial->SetUniform_EnvironmentMap0Bindless(
@@ -2036,7 +2034,7 @@ void MaterialSystem::AddAutospriteSurfaces() {
20362034
for ( const drawSurf_t &drawSurf : autospriteSurfaces )
20372035
{
20382036
R_AddDrawSurf( drawSurf.surface, drawSurf.shader,
2039-
drawSurf.lightmapNum(), drawSurf.fogNum(), drawSurf.bspSurface );
2037+
drawSurf.lightmapNum(), drawSurf.fog, drawSurf.bspSurface );
20402038
}
20412039
}
20422040

src/engine/renderer/ShadeCommon.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ template<typename Obj> static bool hasExplicitelyDisabledLightMap( Obj* obj )
8787
return GetSurfaceShader( obj )->surfaceFlags & SURF_NOLIGHTMAP;
8888
}
8989

90-
inline size_t GetFogNum( shaderCommands_t* tess )
91-
{
92-
return tess->fogNum;
93-
}
94-
95-
inline size_t GetFogNum( drawSurf_t* drawSurf )
96-
{
97-
return drawSurf->fogNum();
98-
}
99-
10090
inline shaderStage_t* GetSurfaceLastStage( shaderCommands_t* tess )
10191
{
10292
return tess->surfaceLastStage;

src/engine/renderer/gl_shader.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,19 @@ static std::string GenCompatHeader() {
529529
str += "float smoothstep(float edge0, float edge1, float x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); return t * t * (3.0 - 2.0 * t); }\n";
530530
}
531531

532-
if ( !glConfig2.gpuShader5Available ) {
533-
str += "#define unpackUnorm4x8( value ) ( ( vec4( value, value >> 8, value >> 16, value >> 24 ) & 0xFF ) / 255.0f )\n";
532+
if ( !glConfig2.gpuShader5Available && glConfig2.gpuShader4Available )
533+
{
534+
str +=
535+
R"(vec4 unpackUnorm4x8( uint value )
536+
{
537+
uint x = value & 0xFFu;
538+
uint y = ( value >> 8u ) & 0xFFu;
539+
uint z = ( value >> 16u ) & 0xFFu;
540+
uint w = ( value >> 24u ) & 0xFFu;
541+
542+
return vec4( x, y, z, w ) / 255.0f;
543+
}
544+
)";
534545
}
535546

536547
/* Driver bug: Adrenaline/OGLP drivers fail to recognise the ARB function versions when they return a 4.6 context
@@ -2351,13 +2362,14 @@ void GLShader::BindProgram( int deformIndex ) {
23512362

23522363
currentProgram = &shaderPrograms[index];
23532364

2354-
if ( r_logFile->integer ) {
2365+
if ( GLimp_isLogging() )
2366+
{
23552367
std::string macros;
23562368

23572369
GetCompileMacrosString( index, macros, GLCompileMacro::VERTEX | GLCompileMacro::FRAGMENT );
23582370

2359-
auto msg = Str::Format( "--- GL_BindProgram( name = '%s', macros = '%s' ) ---\n", this->GetName(), macros );
2360-
GLimp_LogComment( msg.c_str() );
2371+
GLIMP_LOGCOMMENT( "--- GL_BindProgram( name = '%s', macros = '%s' ) ---",
2372+
this->GetName(), macros );
23612373
}
23622374

23632375
GL_BindProgram( &shaderPrograms[index] );

0 commit comments

Comments
 (0)