Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/common/angleutils.cpp
1693 views
1
//
2
// Copyright 2014 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
7
#include "common/angleutils.h"
8
#include "common/debug.h"
9
10
#include <stdio.h>
11
12
#include <limits>
13
#include <vector>
14
15
namespace angle
16
{
17
// dirtyPointer is a special value that will make the comparison with any valid pointer fail and
18
// force the renderer to re-apply the state.
19
const uintptr_t DirtyPointer = std::numeric_limits<uintptr_t>::max();
20
} // namespace angle
21
22
std::string ArrayString(unsigned int i)
23
{
24
// We assume that UINT_MAX and GL_INVALID_INDEX are equal.
25
ASSERT(i != UINT_MAX);
26
27
std::stringstream strstr;
28
strstr << "[";
29
strstr << i;
30
strstr << "]";
31
return strstr.str();
32
}
33
34
std::string ArrayIndexString(const std::vector<unsigned int> &indices)
35
{
36
std::stringstream strstr;
37
38
for (auto indicesIt = indices.rbegin(); indicesIt != indices.rend(); ++indicesIt)
39
{
40
// We assume that UINT_MAX and GL_INVALID_INDEX are equal.
41
ASSERT(*indicesIt != UINT_MAX);
42
strstr << "[";
43
strstr << (*indicesIt);
44
strstr << "]";
45
}
46
47
return strstr.str();
48
}
49
50
size_t FormatStringIntoVector(const char *fmt, va_list vararg, std::vector<char> &outBuffer)
51
{
52
va_list varargCopy;
53
va_copy(varargCopy, vararg);
54
55
int len = vsnprintf(nullptr, 0, fmt, vararg);
56
ASSERT(len >= 0);
57
58
outBuffer.resize(len + 1, 0);
59
60
len = vsnprintf(outBuffer.data(), outBuffer.size(), fmt, varargCopy);
61
va_end(varargCopy);
62
ASSERT(len >= 0);
63
return static_cast<size_t>(len);
64
}
65
66