mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-11 06:15:05 +00:00
gs-vertex: Always align to 16-byte
This commit is contained in:
parent
f721ad0f19
commit
3e97906b32
2 changed files with 62 additions and 1 deletions
|
@ -18,3 +18,48 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gs-vertexbuffer.h"
|
#include "gs-vertexbuffer.h"
|
||||||
|
#include "util-memory.h"
|
||||||
|
|
||||||
|
GS::Vertex& GS::Vertex::operator=(const Vertex& r) {
|
||||||
|
vec3_copy(&this->position, &r.position);
|
||||||
|
vec3_copy(&this->normal, &r.normal);
|
||||||
|
vec3_copy(&this->tangent, &r.tangent);
|
||||||
|
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
|
||||||
|
vec4_copy(&this->uv[n], &r.uv[n]);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
GS::Vertex* GS::Vertex::operator=(const Vertex* r) {
|
||||||
|
vec3_copy(&this->position, &r->position);
|
||||||
|
vec3_copy(&this->normal, &r->normal);
|
||||||
|
vec3_copy(&this->tangent, &r->tangent);
|
||||||
|
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
|
||||||
|
vec4_copy(&this->uv[n], &r->uv[n]);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* GS::Vertex::operator new(size_t count) {
|
||||||
|
return util::malloc_aligned(16, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* GS::Vertex::operator new(size_t count, void* d){
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* GS::Vertex::operator new[](size_t count) {
|
||||||
|
return util::malloc_aligned(16, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* GS::Vertex::operator new[](size_t count, void* d) {
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GS::Vertex::operator delete(void* p) {
|
||||||
|
return util::free_aligned(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GS::Vertex::operator delete[](void* p) {
|
||||||
|
return util::free_aligned(p);
|
||||||
|
}
|
||||||
|
|
|
@ -29,11 +29,27 @@ extern "C" {
|
||||||
namespace GS {
|
namespace GS {
|
||||||
const uint32_t MAXIMUM_UVW_LAYERS = 8u;
|
const uint32_t MAXIMUM_UVW_LAYERS = 8u;
|
||||||
// ToDo: Optimize for use with GS::VertexBuffer so that it doesn't require in-memory copy.
|
// ToDo: Optimize for use with GS::VertexBuffer so that it doesn't require in-memory copy.
|
||||||
struct Vertex {
|
__declspec(align(16)) struct Vertex {
|
||||||
vec3 position;
|
vec3 position;
|
||||||
vec3 normal;
|
vec3 normal;
|
||||||
vec3 tangent;
|
vec3 tangent;
|
||||||
vec4 uv[MAXIMUM_UVW_LAYERS];
|
vec4 uv[MAXIMUM_UVW_LAYERS];
|
||||||
uint32_t color;
|
uint32_t color;
|
||||||
|
|
||||||
|
// Operators
|
||||||
|
static void* Vertex::operator new(size_t count);
|
||||||
|
static void* Vertex::operator new[](size_t count);
|
||||||
|
static void* Vertex::operator new(size_t count, void* d);
|
||||||
|
static void* Vertex::operator new[](size_t count, void* d);
|
||||||
|
static void Vertex::operator delete(void* p);
|
||||||
|
static void Vertex::operator delete[](void* p);
|
||||||
|
|
||||||
|
//Vertex& Vertex::operator =(Vertex r);
|
||||||
|
Vertex& Vertex::operator =(const Vertex& r);
|
||||||
|
Vertex* Vertex::operator =(const Vertex* r);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t padding[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue