Commit d3f0f1ec by Jamie Madill

Expose and generalize Clear11's CompareStates function, and add methods for…

Expose and generalize Clear11's CompareStates function, and add methods for equality test and initialization. TRAC #23841 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods
parent 10b411df
......@@ -56,6 +56,28 @@ void SafeDeleteArray(T*& resource)
resource = NULL;
}
// Provide a less-than function for comparing structs
// Note: struct memory must be initialized to zero, because of packing gaps
template <typename T>
inline bool StructLessThan(const T &a, const T &b)
{
return (memcmp(&a, &b, sizeof(T)) < 0);
}
// Provide a less-than function for comparing structs
// Note: struct memory must be initialized to zero, because of packing gaps
template <typename T>
inline bool StructEquals(const T &a, const T &b)
{
return (memcmp(&a, &b, sizeof(T)) == 0);
}
template <typename T>
inline void StructZero(T *obj)
{
memset(obj, 0, sizeof(T));
}
#if defined(_MSC_VER)
#define snprintf _snprintf
#endif
......
......@@ -28,13 +28,6 @@
namespace rx
{
// Provide a less-than function for comparing states in the caches
template <typename T>
static bool CompareStates(const T &a, const T &b)
{
return memcmp(&a, &b, sizeof(T)) < 0;
}
template <typename T>
static void ApplyVertices(const gl::Extents &framebufferSize, const gl::Rectangle *scissor, const gl::Color<T> &color, float depth, void *buffer)
{
......@@ -87,7 +80,7 @@ Clear11::ClearShader Clear11::CreateClearShader(ID3D11Device *device, DXGI_FORMA
}
Clear11::Clear11(Renderer11 *renderer)
: mRenderer(renderer), mClearBlendStates(CompareStates<ClearBlendInfo>), mClearDepthStencilStates(CompareStates<ClearDepthStencilInfo>),
: mRenderer(renderer), mClearBlendStates(StructLessThan<ClearBlendInfo>), mClearDepthStencilStates(StructLessThan<ClearDepthStencilInfo>),
mVertexBuffer(NULL), mRasterizerState(NULL)
{
HRESULT result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment