Moves uniform and texture binding to CDeviceCommandContext.

Tested By: Langbart
Differential Revision: https://code.wildfiregames.com/D4631
This was SVN commit r26848.
This commit is contained in:
vladislavbelov
2022-05-02 20:57:22 +00:00
parent a8caed8348
commit 04bd96cee0
65 changed files with 1590 additions and 969 deletions
+3 -2
View File
@@ -25,6 +25,7 @@
#include "maths/Vector3D.h"
#include "maths/Vector4D.h"
#include "ps/containers/Span.h"
class CQuaternion;
@@ -323,7 +324,7 @@ public:
CVector3D RotateTransposed(const CVector3D& vector) const;
// Returns 16 element array of floats, e.g. for mat4 uniforms.
const float* AsFloatArray() const
PS::span<const float> AsFloatArray() const
{
// Additional check to prevent a weird compiler has a different
// alignement for an array and a class members.
@@ -333,7 +334,7 @@ public:
offsetof(CMatrix3D, _11) == 0 &&
offsetof(CMatrix3D, _44) == sizeof(float) * 15u,
"CMatrix3D should be properly layouted to use AsFloatArray");
return _data;
return PS::span<const float>(_data, 16);
}
};
+5 -3
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -23,6 +23,8 @@
#ifndef INCLUDED_VECTOR3D
#define INCLUDED_VECTOR3D
#include "ps/containers/Span.h"
class CFixedVector3D;
class CVector3D
@@ -121,7 +123,7 @@ class CVector3D
CVector3D Normalized() const;
// Returns 3 element array of floats, e.g. for vec3 uniforms.
const float* AsFloatArray() const
PS::span<const float> AsFloatArray() const
{
// Additional check to prevent a weird compiler has a different
// alignement for an array and a class members.
@@ -131,7 +133,7 @@ class CVector3D
offsetof(CVector3D, Y) == sizeof(float) &&
offsetof(CVector3D, Z) == sizeof(float) * 2u,
"Vector3D should be properly layouted to use AsFloatArray");
return &X;
return PS::span<const float>(&X, 3);
}
};
+16 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -23,6 +23,8 @@
#ifndef INCLUDED_VECTOR4D
#define INCLUDED_VECTOR4D
#include "ps/containers/Span.h"
#include <math.h>
class CVector4D
@@ -124,8 +126,20 @@ public:
return X*a.X + Y*a.Y + Z*a.Z + W*a.W;
}
// Returns 4 element array of floats, e.g. for vec4 uniforms.
PS::span<const float> AsFloatArray() const
{
// Additional check to prevent a weird compiler has a different
// alignement for an array and a class members.
static_assert(
sizeof(CVector4D) == sizeof(float) * 4u &&
offsetof(CVector4D, X) == 0 &&
offsetof(CVector4D, W) == sizeof(float) * 3u,
"CVector4D should be properly layouted to use AsFloatArray");
return PS::span<const float>(&X, 4);
}
float X, Y, Z, W;
};
#endif
#endif // INCLUDED_VECTOR4D