Skip to content

Commit

Permalink
project: added asan, ubsan support
Browse files Browse the repository at this point in the history
few ub fixes
  • Loading branch information
JaCzekanski committed Aug 11, 2019
1 parent b4e5702 commit 80494d6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
26 changes: 26 additions & 0 deletions premake5.lua
Expand Up @@ -25,6 +25,32 @@ newoption {
filter "options:enable-io-log"
defines "ENABLE_IO_LOG"

newoption {
trigger = "asan",
description = "Build with Address Sanitizer enabled"
}
filter "options:asan"
symbols "On"
buildoptions {"-fsanitize=address"}
linkoptions {"-fsanitize=address"}

newoption {
trigger = "msan",
description = "Build with Memory Sanitizer enabled"
}
filter "options:msan"
symbols "On"
buildoptions {"-fsanitize=memory"}
linkoptions {"-fsanitize=memory"}

newoption {
trigger = "ubsan",
description = "Build with Undefined Behaviour Sanitizer enabled"
}
filter "options:ubsan"
symbols "On"
buildoptions {"-fsanitize=undefined"}
linkoptions {"-fsanitize=undefined"}

filter {}
language "c++"
Expand Down
4 changes: 2 additions & 2 deletions src/cpu/cpu.h
Expand Up @@ -52,8 +52,8 @@ struct CPU {

// Saved state for exception handling
uint32_t exceptionPC;
uint32_t exceptionIsInBranchDelay;
uint32_t exceptionIsBranchTaken;
bool exceptionIsInBranchDelay;
bool exceptionIsBranchTaken;

uint32_t PC; // Address to be executed
uint32_t nextPC; // Next address to be executed
Expand Down
2 changes: 1 addition & 1 deletion src/device/gpu/gpu.cpp
Expand Up @@ -198,7 +198,7 @@ void GPU::cmdLine(LineArgs arg) {
if (arg.semiTransparency) flags |= Vertex::Flags::SemiTransparency;
if (arg.gouroudShading) flags |= Vertex::Flags::GouroudShading;
for (int i : {0, 1}) {
Vertex v = {Vertex::Type::Line, {x[i], y[i]}, {c[i].r, c[i].g, c[i].b}, {0, 0}, 0, {0, 0}, {0, 0}, flags, gp0_e2};
Vertex v = {Vertex::Type::Line, {x[i], y[i]}, {c[i].r, c[i].g, c[i].b}, {0, 0}, 0, {0, 0}, {0, 0}, flags, gp0_e2, gp0_e6};
vertices.push_back(v);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/device/gpu/render/render_polygon.cpp
Expand Up @@ -39,9 +39,9 @@ bool isCw(const ivec2 v[3]) {
}

INLINE uvec2 calculateTexel(const ivec3 s, const int area, const ivec2 tex[3], const gpu::GP0_E2 textureWindow) {
uvec2 texel( //
(s.x * tex[0].x + s.y * tex[1].x + s.z * tex[2].x) / area, //
(s.x * tex[0].y + s.y * tex[1].y + s.z * tex[2].y) / area //
uvec2 texel( //
((int64_t)s.x * tex[0].x + (int64_t)s.y * tex[1].x + (int64_t)s.z * tex[2].x) / area, //
((int64_t)s.x * tex[0].y + (int64_t)s.y * tex[1].y + (int64_t)s.z * tex[2].y) / area //
);

// Texture is repeated outside of 256x256 window
Expand Down

0 comments on commit 80494d6

Please sign in to comment.