-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rare crash on SSE capable computers (everyone)
This crash happens every 1 in 100000 times in obs-stream-effects 64-bit, which has the same GS::VertexBuffer wrapper as node-obs::Display and Face Masks. The crash happens due to unlucky placement of the buffers, which need to be 16-byte aligned, otherwise we write into memory that we shouldn't have written to. This results in funky crashes down the road which make absolutely no sense at all with a mdmp or a simple stack trace, since the cause of the crash happened earlier. Affects pretty much all areas, as the Display was actively writing into memory of other areas. This might explain some exotic behavior we have seen, such as crashes inside the Chromium runtime or electron crashes.
- Loading branch information
Showing
10 changed files
with
945 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Modern effects for a modern Streamer | ||
* Copyright (C) 2017 Michael Fabian Dirks | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
*/ | ||
|
||
#pragma once | ||
#include <inttypes.h> | ||
|
||
namespace GS { | ||
static const uint32_t MAXIMUM_VERTICES = 0xFFFFFFu; | ||
static const uint32_t MAXIMUM_UVW_LAYERS = 8u; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Modern effects for a modern Streamer | ||
* Copyright (C) 2017 Michael Fabian Dirks | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
*/ | ||
|
||
#include "gs-vertex.h" | ||
#include "util-memory.h" | ||
|
||
GS::Vertex::Vertex() { | ||
this->hasStore = true; | ||
this->store = util::malloc_aligned(16, sizeof(vec3) * 3 + sizeof(uint32_t) + sizeof(vec4)*MAXIMUM_UVW_LAYERS); | ||
this->position = reinterpret_cast<vec3*>(store); | ||
this->normal = reinterpret_cast<vec3*>(reinterpret_cast<char*>(store) + (16 * 1)); | ||
this->tangent = reinterpret_cast<vec3*>(reinterpret_cast<char*>(store) + (16 * 2)); | ||
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { | ||
this->uv[n] = reinterpret_cast<vec4*>(reinterpret_cast<char*>(store) + (16 * (2 + n))); | ||
} | ||
this->color = reinterpret_cast<uint32_t*>(reinterpret_cast<char*>(store) + (16 * (3 + MAXIMUM_UVW_LAYERS))); | ||
} | ||
|
||
GS::Vertex::~Vertex() { | ||
if (hasStore) | ||
util::free_aligned(store); | ||
} | ||
|
||
GS::Vertex::Vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_UVW_LAYERS]) | ||
: position(p), normal(n), tangent(t), color(col) { | ||
if (uvs != nullptr) { | ||
for (size_t idx = 0; idx < MAXIMUM_UVW_LAYERS; idx++) { | ||
this->uv[idx] = uvs[idx]; | ||
} | ||
} | ||
this->hasStore = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Modern effects for a modern Streamer | ||
* Copyright (C) 2017 Michael Fabian Dirks | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
*/ | ||
|
||
#pragma once | ||
#include "gs-limits.h" | ||
#include <inttypes.h> | ||
#include <xmmintrin.h> | ||
extern "C" { | ||
#pragma warning( push ) | ||
#pragma warning( disable: 4201 ) | ||
#include <graphics/vec3.h> | ||
#pragma warning( pop ) | ||
} | ||
|
||
namespace GS { | ||
struct Vertex { | ||
vec3* position; | ||
vec3* normal; | ||
vec3* tangent; | ||
uint32_t* color; | ||
vec4* uv[MAXIMUM_UVW_LAYERS]; | ||
|
||
Vertex(); | ||
Vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uv[MAXIMUM_UVW_LAYERS]); | ||
~Vertex(); | ||
|
||
private: | ||
bool hasStore; | ||
void* store; | ||
}; | ||
} |
Oops, something went wrong.