Skip to content

Commit

Permalink
Mat3/4 & SIMD fixes & cleanups
Browse files Browse the repository at this point in the history
- gen-manifest.sh ~> nacl.sh
- ozCore
  * fixed Plane serialisation
  * Mat3/4
    + deduplicated almost all split SIMD/non-SIMD code by replacing low-level
      per-component code with equivalent higer-level code
    + removed Cramer's inverse implementations
  • Loading branch information
ducakar committed Jun 17, 2015
1 parent 02f0bde commit 4ca8807
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 311 deletions.
7 changes: 2 additions & 5 deletions README.md
Expand Up @@ -216,11 +216,6 @@ Runs cppcheck tool for static code analysis. Output is written into `cppcheck.lo

Cleans up temporary, intermediate and backup files from a game source data directory.

### `gen-manifest.sh` ###

Writes `share/openzone/manifest.json` file that contains list of game packeges together with their
timestamps. Needed by NaCl to update cached game packages.

### `gettext-internal.sh <data_dir>` ###

Extracts internal strings for localisation from OpenZone source code and appends them to
Expand Down Expand Up @@ -255,6 +250,8 @@ The following alternative launches are available:
- `debug`: starts gdb and connets it to a running Chromium instance with a NaCl module pending for
debugging.
- `finalise`: runs `pnacl-finalize` to finalise openzone PNaCl pexe executable.
- `manifest`: writes `share/openzone/manifest.json` file that contains list of game packeges
together with their timestamps. Needed by NaCl to update cached game packages.

### `package.sh {src | data | datasrc | bundle}` ###

Expand Down
2 changes: 1 addition & 1 deletion cmake/PNaCl.Toolchain.cmake
Expand Up @@ -11,7 +11,7 @@ set(PLATFORM_PORTS_PREFIX "${CMAKE_SOURCE_DIR}/ports/PNaCl")
set(PLATFORM_EXE_SUFFIX ".pexe")

set(CMAKE_SYSTEM_NAME "Linux" CACHE STRING "Target system.")
set(CMAKE_SYSTEM_PROCESSOR "LLVM-IR" CACHE STRING "Target processor.")
set(CMAKE_SYSTEM_PROCESSOR "LLVM" CACHE STRING "Target processor.")
set(CMAKE_FIND_ROOT_PATH "${PLATFORM_PORTS_PREFIX}" "${PLATFORM_PREFIX}/le32-nacl")
set(CMAKE_AR "${PLATFORM_PREFIX}/bin/${PLATFORM_TRIPLET}-ar" CACHE STRING "")
set(CMAKE_RANLIB "${PLATFORM_PREFIX}/bin/${PLATFORM_TRIPLET}-ranlib" CACHE STRING "")
Expand Down
22 changes: 11 additions & 11 deletions etc/nacl/openzone.en.html
@@ -1,21 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OpenZone</title>
<link href="http://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet" type="text/css"/>
<link href="doc/style.css" rel="stylesheet" type="text/css"/>
<link href="http://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet" type="text/css">
<link href="doc/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="nacl.js"></script>
<script type="text/javascript">
var MSG_FINISHED = "Finished<br/>You can now safely close this page.";
var MSG_INITIALISING = "Initialising ...<br/>" +
var MSG_FINISHED = "Finished<br>You can now safely close this page.";
var MSG_INITIALISING = "Initialising ...<br>" +
"<span class='detail'>If it takes long enough that you can read this, " +
"you don't have good enough graphics card or you have to navigate to " +
"<code>chrome://flags</code> and turn on " +
"<code>Override software rendering list</code>.</span>";
var MSG_DOWNLOADING = "Downloading updates<br/>";
var MSG_DOWNLOADING = "Downloading updates<br>";
var MSG_LOADING = "Starting NaCl";
var MSG_LAUNCHING = "Starting NaCl<br/>" +
var MSG_LAUNCHING = "Starting NaCl<br>" +
"<span class='detail'>If it takes long enough that you can read this " +
"some unexpected error occurred.</span>";
var MSG_CLOSE = "When this messages has been displayed for a few seconds the game is " +
Expand All @@ -27,7 +27,7 @@
<table id="hudArea">
<tr>
<td id="hudText">
Loading<br/>
Loading<br>
<span class="detail">Google Chrome/Chromium 31 or newer is required.</span>
</td>
</tr>
Expand All @@ -37,7 +37,7 @@
<tr>
<td style="width: 10%"></td>
<td>
<embed id="module" type="application/x-pnacl" src="openzone.nmf"/>
<embed id="module" type="application/x-pnacl" src="openzone.nmf">
</td>
<td style="width: 10%"></td>
</tr>
Expand All @@ -46,7 +46,7 @@
<td>
<code>Click</code> game for focus
<code>F10</code> main menu
<code>F11</code> full screen<br/>
<code>F11</code> full screen<br>
<a href="http://ducakar.github.io/openzone/">http://ducakar.github.io/openzone/</a>
</td>
<td></td>
Expand Down Expand Up @@ -333,7 +333,7 @@

<p><a href="doc/README.html">More</a></p>

<p><small>OpenZone (engine) © 2002-2013 Davorin Učakar.<br/>
<p><small>OpenZone (engine) © 2002-2013 Davorin Učakar.<br>
<a href="http://ducakar.github.com/openzone/">http://ducakar.github.com/openzone/</a></small></p>

<p><small>Engine is licensed under <a href="doc/licences/COPYING.GPL3.txt">GNU GPL 3.0</a>.
Expand Down
22 changes: 11 additions & 11 deletions etc/nacl/openzone.sl.html
@@ -1,21 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OpenZone</title>
<link href="http://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet" type="text/css"/>
<link href="doc/style.css" rel="stylesheet" type="text/css"/>
<link href="http://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet" type="text/css">
<link href="doc/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="nacl.js"></script>
<script type="text/javascript">
var MSG_FINISHED = "Končano<br/>Sedaj lahko varno zapreš to stran.";
var MSG_INITIALISING = "Inicializiram ...<br/>" +
var MSG_FINISHED = "Končano<br>Sedaj lahko varno zapreš to stran.";
var MSG_INITIALISING = "Inicializiram ...<br>" +
"<span class='detail'>" +
"Če traja dovolj dolgo, da lahko to bereš, imaš preslabo grafično " +
"kartico ali pa moraš iti na <code>chrome://flags</code> in vklopiti " +
"možnost <code>Preglasi seznam programskega upodabljanja</code>.</span>";
var MSG_DOWNLOADING = "Prenašam posodobitve<br/>";
var MSG_DOWNLOADING = "Prenašam posodobitve<br>";
var MSG_LOADING = "Zaganjam NaCl";
var MSG_LAUNCHING = "Zaganjam NaCl<br/>" +
var MSG_LAUNCHING = "Zaganjam NaCl<br>" +
"<span class='detail'>Če traja dovolj dolgo, da lahko to bereš, je " +
"šlo narobe nekaj nepredvidenega.</span>";
var MSG_CLOSE = "Če je to sporočilo prikazano nekaj sekund, je igra verjetno že " +
Expand All @@ -27,7 +27,7 @@
<table id="hudArea">
<tr>
<td id="hudText">
Nalagam<br/>
Nalagam<br>
<span class="detail">Deluje samo v brskalniku Google Chrome/Chromium 31 ali novejšem.</span>
</td>
</tr>
Expand All @@ -37,7 +37,7 @@
<tr>
<td style="width: 10%"></td>
<td>
<embed id="module" type="application/x-pnacl" src="openzone.nmf"/>
<embed id="module" type="application/x-pnacl" src="openzone.nmf">
</td>
<td style="width: 10%"></td>
</tr>
Expand All @@ -46,7 +46,7 @@
<td>
<code>Klikni</code> igro za fokus
<code>F10</code> glavni meni
<code>F11</code> celotni zaslon<br/>
<code>F11</code> celotni zaslon<br>
<a href="http://ducakar.github.io/openzone/">http://ducakar.github.io/openzone/</a>
</td>
<td></td>
Expand Down Expand Up @@ -334,7 +334,7 @@

<p><a href="doc/PREBERI.html">Beri dalje</a></p>

<p><small>OpenZone (pogon) © 2002-2013 Davorin Učakar.<br/>
<p><small>OpenZone (pogon) © 2002-2013 Davorin Učakar.<br>
<a href="http://ducakar.github.com/openzone/">http://ducakar.github.com/openzone/</a></small></p>

<p><small>Pogon OpenZone je pod licenco <a href="doc/licences/COPYING.GPL3.txt">GNU GPL 3.0</a>.
Expand Down
2 changes: 2 additions & 0 deletions gen-manifest.sh
Expand Up @@ -22,3 +22,5 @@ for pkg in `echo *.zip`; do
done

printf '\n}\n' >> manifest.json

cat manifest.json
31 changes: 27 additions & 4 deletions nacl.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
# nacl.sh [run | debug | finalise]
# nacl.sh [run | debug | manifest]
#
# Linux-x86_64-Clang client is launched by default. <options> are passed to the client command line.
# `NACL_SDK_ROOT` environment variable must be set to use this script.
Expand All @@ -12,7 +12,8 @@
# opens `localhost:8000` in chromium browser to test the web-based NaCl port.
# - `debug`: starts gdb and connets it to a running Chromium instance with a NaCl module pending for
# debugging.
# - `finalise`: runs `pnacl-finalize` to finalise openzone PNaCl pexe executable.
# - `manifest`: writes `share/openzone/manifest.json` file that contains list of game packeges
# together with their timestamps. Needed by NaCl to update cached game packages.
#

if [[ `uname -m` == x86_64 ]]; then
Expand Down Expand Up @@ -55,14 +56,36 @@ debug()
build/PNaCl/src/tools/openzone.${arch}.nexe
}

function manifest()
{
cd share/openzone

printf '{\n' > manifest.json

first=1

for pkg in `echo *.zip`; do
if [[ -f $pkg ]]; then
timestamp=`stat -c %Y $pkg`

(( $first )) && first=0 || ( printf ',\n' >> manifest.json )
printf " \"$pkg\": $timestamp" >> manifest.json
fi
done

printf '\n}\n' >> manifest.json

cat manifest.json
}

case $1 in
run)
run
;;
debug)
debug
;;
finalise)
finalise
manifest)
manifest
;;
esac
32 changes: 16 additions & 16 deletions src/client/BuildInfo.cc.in
Expand Up @@ -22,24 +22,24 @@
namespace oz
{

const char* const BuildInfo::TIME = __DATE__ " " __TIME__;
const char* const BuildInfo::HOST = "@OZ_HOSTNAME@ @CMAKE_HOST_SYSTEM@";
const char* const BuildInfo::HOST_ARCH = "@CMAKE_HOST_SYSTEM_NAME@-@CMAKE_HOST_SYSTEM_PROCESSOR@";
const char* const BuildInfo::TARGET_ARCH = "@CMAKE_SYSTEM_NAME@-@CMAKE_SYSTEM_PROCESSOR@";
const char* const BuildInfo::BUILD_TYPE = "@CMAKE_BUILD_TYPE@";
const char* const BuildInfo::TIME = __DATE__ " " __TIME__;
const char* const BuildInfo::HOST = "@OZ_HOSTNAME@ @CMAKE_HOST_SYSTEM@";
const char* const BuildInfo::HOST_ARCH = "@CMAKE_HOST_SYSTEM_NAME@-@CMAKE_HOST_SYSTEM_PROCESSOR@";
const char* const BuildInfo::TARGET_ARCH = "@OZ_PLATFORM_NAME@";
const char* const BuildInfo::BUILD_TYPE = "@CMAKE_BUILD_TYPE@";
#ifdef OZ_CLANG
const char* const BuildInfo::COMPILER = "LLVM/Clang " __clang_version__;
const char* const BuildInfo::COMPILER = "LLVM/Clang " __clang_version__;
#else
const char* const BuildInfo::COMPILER = "GCC " __VERSION__;
const char* const BuildInfo::COMPILER = "GCC " __VERSION__;
#endif
const char* const BuildInfo::CXX_FLAGS = "@OZ_CXX_FLAGS@";
const char* const BuildInfo::CONFIG = "OZ_ALLOCATOR: @OZ_ALLOCATOR@, "
"OZ_SIMD: @OZ_SIMD@, "
"OZ_GL_ES: @OZ_GL_ES@, "
"OZ_LUAJIT: @OZ_LUAJIT@, "
"OZ_NONFREE: @OZ_NONFREE@, "
"OZ_TOOLS: @OZ_TOOLS@, "
"OZ_TESTS: @OZ_TESTS@, "
"OZ_BUNDLE: @OZ_BUNDLE@";
const char* const BuildInfo::CXX_FLAGS = "@OZ_CXX_FLAGS@";
const char* const BuildInfo::CONFIG = "OZ_ALLOCATOR: @OZ_ALLOCATOR@, "
"OZ_SIMD: @OZ_SIMD@, "
"OZ_GL_ES: @OZ_GL_ES@, "
"OZ_LUAJIT: @OZ_LUAJIT@, "
"OZ_NONFREE: @OZ_NONFREE@, "
"OZ_TOOLS: @OZ_TOOLS@, "
"OZ_TESTS: @OZ_TESTS@, "
"OZ_BUNDLE: @OZ_BUNDLE@";

}
4 changes: 2 additions & 2 deletions src/matrix/Struct.cc
Expand Up @@ -77,8 +77,9 @@ bool Entity::trigger()
}

if (clazz->type == EntityClass::STATIC) {
state = OPENING;
hard_assert(time == 0.0f);

state = OPENING;
}

int strIndex = clazz->target >> Struct::MAX_ENT_SHIFT;
Expand Down Expand Up @@ -124,7 +125,6 @@ bool Entity::lock(Bot* user)
return true;
}
}

return false;
}

Expand Down
10 changes: 5 additions & 5 deletions src/ozCore/Alloc.cc
Expand Up @@ -51,17 +51,17 @@ static void* allocate(AllocMode mode, size_t size)
{
static_cast<void>(mode);

size_t chunkSize = Alloc::alignUp(size);
size_t chunkSize = size;
#ifdef OZ_ALLOCATOR
chunkSize += Alloc::alignUp(sizeof(Alloc::ChunkInfo));
#endif

#if defined(OZ_SIMD) && _ISOC11_SOURCE
void* ptr = aligned_alloc(OZ_ALIGNMENT, size);
void* ptr = aligned_alloc(OZ_ALIGNMENT, chunkSize);
#elif defined(OZ_SIMD) && defined(_WIN32)
void* ptr = _aligned_malloc(size, OZ_ALIGNMENT);
void* ptr = _aligned_malloc(chunkSize, OZ_ALIGNMENT);
#elif defined(OZ_SIMD)
void* ptr = memalign(OZ_ALIGNMENT, size);
void* ptr = memalign(OZ_ALIGNMENT, chunkSize);
#else
void* ptr = malloc(chunkSize);
#endif
Expand Down Expand Up @@ -128,7 +128,7 @@ static void deallocate(AllocMode mode, void* ptr)

allocInfoLock.unlock();

size_t chunkSize = Alloc::alignUp(ci->size) + Alloc::alignUp(sizeof(Alloc::ChunkInfo));
size_t chunkSize = ci->size + Alloc::alignUp(sizeof(Alloc::ChunkInfo));
memset(ptr, 0xee, chunkSize);

#endif
Expand Down
26 changes: 13 additions & 13 deletions src/ozCore/Json.cc
Expand Up @@ -692,16 +692,16 @@ Json::Json(const Vec3& v) :
Json(v, 3)
{}

Json::Json(const Vec4& v) :
Json(v, 4)
{}

Json::Json(const Point& p) :
Json(p, 3)
{}

Json::Json(const Plane& p) :
Json(p, 4)
Json(Vec4(p.n.x, p.n.y, p.n.y, p.d))
{}

Json::Json(const Vec4& v) :
Json(v, 4)
{}

Json::Json(const Quat& q) :
Expand Down Expand Up @@ -1060,12 +1060,6 @@ Vec3 Json::get(const Vec3& defaultValue) const
return getVector(v, 3) ? v : defaultValue;
}

Vec4 Json::get(const Vec4& defaultValue) const
{
Vec4 v;
return getVector(v, 4) ? v : defaultValue;
}

Point Json::get(const Point& defaultValue) const
{
Point p;
Expand All @@ -1074,8 +1068,14 @@ Point Json::get(const Point& defaultValue) const

Plane Json::get(const Plane& defaultValue) const
{
Plane p;
return getVector(p.n, 4) ? p : defaultValue;
Vec4 v;
return getVector(v, 4) ? Plane(v.x, v.y, v.z, v.w) : defaultValue;
}

Vec4 Json::get(const Vec4& defaultValue) const
{
Vec4 v;
return getVector(v, 4) ? v : defaultValue;
}

Quat Json::get(const Quat& defaultValue) const
Expand Down

0 comments on commit 4ca8807

Please sign in to comment.