1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017-2018 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#pragma once
// This file controls the telemetry/analytics functionality in RenderDoc.
//
// If you don't care about any details and just want to make sure this is turned off for your builds
// then go below to #define RENDERDOC_ANALYTICS_ENABLE and change it to 0. That will cease all
// recording and reporting of analytics data. It won't delete any previously recorded analytics and
// won't stop any other builds from working, since the code that knows about what the analytics is
// will be compiled out.
//
// -------------------------------------------------------------------------------------------------
//
// RenderDoc's analytics works in two phases: Data is recorded first to an internal database that
// can contain more information than will be sent, to allow for accurate tracking before
// aggregation. This isn't as scary as it sounds - e.g. consider the 'UsageLevel' stat that's
// reported, which is a number in the range 1 to 31 indicating how many days in the month the
// program was launched. In order to track that, we need to have a sticky flag for each day to count
// it, since given a number "20" it's impossible to know if we've counted today or not.
//
// Similar cases are found for averages that need to store the number of cases and a total, which is
// then flattened down into just an average for reporting.
//
// This database is stored internally and then converted to the report in the 'AnalyticsSerialise'
// function.
//
// Once the report is sent, the database is reset and begins the next period.
// this is the root switch that can turn off *all* analytics code globally
#define RENDERDOC_ANALYTICS_ENABLE 1
// we don't want any of this to be accessible to script, only code.
#if !defined(SWIG) && !defined(SWIG_GENERATED)
// We also compile out all of the code if analytics are disabled so there's not even a code
// reference to where the data is collected.
#if RENDERDOC_ANALYTICS_ENABLE
struct AnalyticsAverage
{
double Total = 0.0;
int Count = 0;
void Add(double Val)
{
Total += Val;
Count++;
}
AnalyticsAverage() = default;
AnalyticsAverage(QVariant v)
{
QVariantMap vmap = v.toMap();
Total = vmap[lit("Total")].toDouble();
Count = vmap[lit("Count")].toInt();
}
QVariant toVariant(bool reporting) const
{
if(reporting)
{
if(Count == 0)
return 0.0;
return Total / double(Count);
}
QVariantMap ret;
ret[lit("Total")] = Total;
ret[lit("Count")] = Count;
return ret;
}
};
class PersistantConfig;
struct ICaptureContext;
// we set this struct to byte-packing, so that any change will affect sizeof() and fail a
// static_assert in AnalyticsSerialise. This only has to be on one platform since it will block
// building when a commit is pushed. This struct isn't memcpy'd around and isn't performance
// sensitive, so there's no need to have perfectly aligned data.
#if defined(_MSC_VER)
#pragma pack(push, 1)
#endif
// we declare the analystics data struct here, this contains the information we're storing
// If you add anything to this struct, make sure to update AnalyticsSerialise, and
// AnalyticsDocumentation.
struct Analytics
{
// utility function - loads the analytics from disk and initialise the Analytics::db member.
static void Load();
// utility function - explicitly disables the analytics and sets it into a black-hole mode that
// does nothing.
static void Disable();
// utility function - performs any UI-level prompting, such as asking the user if they want to
// opt-out, or manually vetting a report for uploading.
static void Prompt(ICaptureContext &ctx, PersistantConfig &config);
// the singleton instance of analytics. May be NULL if analytics aren't initialised or have been
// opted-out from.
static Analytics *db;
// utility function - displays an annotated report documenting what each member means
static void DocumentReport();
// Function to save the analytics to disk, if it's been initialised. Every set macro below will
// call this after the data is set to flush it to disk.
void Save();
// book-keeping: contains the year/month where this database was started. Thus if current date !=
// saved date, then we should try to submit the analytics report.
struct
{
int Year = 0;
int Month = 0;
} Date;
// version number. Most data is opportunistically gathered, so if some data is missing then it
// just doesn't get included in the report so we can add new data, but we bump the version
// here if something more significant changes.
int Version = 1;
struct
{
// The version string (MAJOR_MINOR_VERSION_STRING) of this build.
QString RenderDocVersion;
// The distribution information (DISTRIBUTION_NAME) for this build.
QString DistributionVersion;
// A human readable name of the operating system.
QString OSVersion;
// Either 32 or 64 indicating which bit-depth the UI is running as
int Bitness = 0;
// whether a development build has been run - either a nightly build or a local build.
bool DevelBuildRun = false;
// whether an official build has been run - whether distributed from the RenderDoc website or
// through a linux distribution
bool OfficialBuildRun = false;
// Counts which unique days in the last month the program was run
bool DaysUsed[32] = {0};
} Metadata;
struct
{
// how long do captures take to load, on average
AnalyticsAverage LoadTime;
} Performance;
// which APIs have been used
QStringList APIs;
// A list of which GPU vendors have been used for replay
QStringList GPUVendors;
// which UI features have been used, as a simple yes/no
struct
{
bool Bookmarks = false;
bool ResourceInspect = false;
bool ShaderEditing = false;
bool CallstackResolve = false;
bool PixelHistory = false;
bool DrawcallTimes = false;
bool PerformanceCounters = false;
bool PythonInterop = false;
bool CustomTextureVisualise = false;
bool ImageViewer = false;
bool CaptureComments = false;
bool AndroidRemoteReplay = false;
bool NonAndroidRemoteReplay = false;
} UIFeatures;
struct
{
bool EventBrowser = false;
bool PipelineState = false;
bool MeshOutput = false;
bool RawBuffer = false;
bool Texture = false;
bool Shader = false;
} Export;
struct
{
bool Vertex = false;
bool Pixel = false;
bool Compute = false;
} ShaderDebug;
struct
{
bool Drawcall = false;
bool Wireframe = false;
bool Depth = false;
bool Stencil = false;
bool BackfaceCull = false;
bool ViewportScissor = false;
bool NaN = false;
bool Clipping = false;
bool ClearBeforePass = false;
bool ClearBeforeDraw = false;
bool QuadOverdrawPass = false;
bool QuadOverdrawDraw = false;
bool TriangleSizePass = false;
bool TriangleSizeDraw = false;
} TextureOverlays;
// If some particular API specific features are seen in a capture, as a simple yes/no. See
// APIProperties
struct
{
bool ShaderLinkage = false;
bool YUVTextures = false;
bool SparseResources = false;
bool MultiGPU = false;
bool D3D12Bundle = false;
} CaptureFeatures;
};
#if defined(_MSC_VER)
#pragma pack(pop)
#endif
// straightforward set of a value
#define ANALYTIC_SET(name, val) \
do \
{ \
if(Analytics::db) \
{ \
auto value = val; \
if(Analytics::db->name != value) \
{ \
Analytics::db->name = value; \
Analytics::db->Save(); \
} \
} \
} while(0);
// add a data point to an average
#define ANALYTIC_ADDAVG(name, val) \
do \
{ \
if(Analytics::db) \
{ \
Analytics::db->name.Add(val); \
Analytics::db->Save(); \
} \
} while(0);
// add an element to an array, if it's not already present
#define ANALYTIC_ADDUNIQ(name, val) \
do \
{ \
if(Analytics::db) \
{ \
bool found = false; \
for(auto &v : Analytics::db->name) \
{ \
if(v == val) \
{ \
found = true; \
break; \
} \
} \
\
if(!found) \
{ \
Analytics::db->name.push_back(val); \
Analytics::db->Save(); \
} \
} \
} while(0);
#else
// here we declare macro stubs that satisfy the use in the codebase.
#define ANALYTIC_SET(name, val) (void)val
#define ANALYTIC_ADDAVG(name, val) (void)val
#define ANALYTIC_ADDUNIQ(name, val) (void)val
class PersistantConfig;
struct ICaptureContext;
namespace Analytics
{
void Disable();
void Load();
void Prompt(ICaptureContext &ctx, PersistantConfig &config);
void DocumentReport();
};
#endif
#endif
|