diff --git a/qrenderdoc/Code/CaptureContext.cpp b/qrenderdoc/Code/CaptureContext.cpp index 7ab514b79..f54efc33e 100644 --- a/qrenderdoc/Code/CaptureContext.cpp +++ b/qrenderdoc/Code/CaptureContext.cpp @@ -25,6 +25,7 @@ #include "CaptureContext.h" #include #include +#include #include #include #include @@ -136,10 +137,20 @@ void CaptureContext::LoadCapture(const QString &captureFile, const QString &orig thread->selfDelete(true); thread->start(); + QElapsedTimer loadTimer; + loadTimer.start(); + ShowProgressDialog(m_MainWindow, tr("Loading Capture: %1").arg(origFilename), [this]() { return !m_LoadInProgress; }, [this]() { return UpdateLoadProgress(); }); + ANALYTIC_ADDAVG(LoadTime, double(loadTimer.nsecsElapsed() * 1.0e-9)); + + ANALYTIC_SET(CaptureFeatures.ShaderLinkage, m_APIProps.ShaderLinkage); + ANALYTIC_SET(CaptureFeatures.YUVTextures, m_APIProps.YUVTextures); + ANALYTIC_SET(CaptureFeatures.SparseResources, m_APIProps.SparseResources); + ANALYTIC_SET(CaptureFeatures.MultiGPU, m_APIProps.MultiGPU); + m_MainWindow->setProgress(-1.0f); if(m_CaptureLoaded) @@ -892,6 +903,8 @@ void CaptureContext::SetNotes(const QString &key, const QString &contents) void CaptureContext::SetBookmark(const EventBookmark &mark) { + ANALYTIC_SET(UIFeatures.Bookmarks, true); + int index = m_Bookmarks.indexOf(mark); if(index >= 0) { @@ -1042,6 +1055,8 @@ void CaptureContext::SaveNotes() props.type = SectionType::Notes; props.version = 1; + ANALYTIC_SET(UIFeatures.CaptureComments, true); + Replay().GetCaptureAccess()->WriteSection(props, json.toUtf8()); } diff --git a/qrenderdoc/Code/Interface/Analytics.cpp b/qrenderdoc/Code/Interface/Analytics.cpp new file mode 100644 index 000000000..29c7e815a --- /dev/null +++ b/qrenderdoc/Code/Interface/Analytics.cpp @@ -0,0 +1,396 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 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. + ******************************************************************************/ + +#include +#include +#include +#include +#include "Windows/Dialogs/AnalyticsConfirmDialog.h" +#include "Windows/Dialogs/AnalyticsPromptDialog.h" +#include "QRDInterface.h" + +#if RENDERDOC_ANALYTICS_ENABLE + +namespace +{ +enum class AnalyticsState +{ + Nothing, + PromptFirstTime, + SubmitReport, +}; + +enum class AnalyticsSerialiseType +{ + Loading, + Saving, + Reporting, +}; + +static AnalyticsState analyticsState = AnalyticsState::Nothing; +static Analytics actualDB; +static QString analyticsSaveLocation; + +static const char *analyticsJSONMagic = "Analytics"; +static const int analyticsJSONVersion = 1; + +template +QVariant analyticsToVar(const T &el, bool reporting) +{ + return QVariant(el); +} + +// annoying specialisation, but necessary +template +QVariant analyticsToVar(const bool (&el)[32], bool reporting) +{ + QVariantList l; + for(int i = 0; i < 32; i++) + l.push_back(QVariant(el[i])); + return l; +} + +template <> +QVariant analyticsToVar(const AnalyticsAverage &el, bool reporting) +{ + return el.toVariant(reporting); +} + +template +void analyticsFromVar(T &el, QVariant v) +{ + el = v.value(); +} + +template <> +void analyticsFromVar(bool (&el)[32], QVariant v) +{ + QVariantList l = v.toList(); + for(int i = 0; i < 32 && i < l.count(); i++) + el[i] = l[i].toBool(); +} + +template <> +void analyticsFromVar(AnalyticsAverage &el, QVariant v) +{ + el = AnalyticsAverage(v); +} + +// these functions will process a name like Foo.Bar into Foo being a QVariantMap and Bar being a +// member of it. +template +void loadFrom(const QVariantMap &parent, const QString &name, T &el) +{ + int idx = name.indexOf(QLatin1Char('.')); + if(idx > 0) + { + QString parentName = name.left(idx); + QString subname = name.mid(idx + 1); + + if(parent.contains(parentName)) + loadFrom(parent[parentName].toMap(), subname, el); + + return; + } + + if(parent.contains(name)) + analyticsFromVar(el, parent[name]); +} + +template +void saveTo(QVariantMap &parent, const QString &name, const T &el, bool reporting) +{ + int idx = name.indexOf(QLatin1Char('.')); + if(idx > 0) + { + QString parentName = name.left(idx); + QString subname = name.mid(idx + 1); + + // need to load-hit-store to change the contents :(. + { + QVariantMap map = parent[parentName].toMap(); + saveTo(map, subname, el, reporting); + parent[parentName] = map; + } + return; + } + + parent[name] = analyticsToVar(el, reporting); +} + +// add a macro to either load or save, depending on our state. +#define ANALYTIC_SERIALISE(varname) \ + if(type == AnalyticsSerialiseType::Loading) \ + { \ + loadFrom(values, lit(#varname), Analytics::db->varname); \ + } \ + else \ + { \ + saveTo(values, lit(#varname), Analytics::db->varname, reporting); \ + } + +void AnalyticsSerialise(QVariantMap &values, AnalyticsSerialiseType type) +{ + bool reporting = type == AnalyticsSerialiseType::Reporting; + + if(!Analytics::db) + return; + + static_assert(sizeof(Analytics) == 140, "Sizeof Analytics has changed - update serialisation."); + + // Date + { + ANALYTIC_SERIALISE(Date.Year); + ANALYTIC_SERIALISE(Date.Month); + } + ANALYTIC_SERIALISE(Version); + + // Environment + { + ANALYTIC_SERIALISE(Environment.RenderDocVersion); + ANALYTIC_SERIALISE(Environment.DistributionVersion); + ANALYTIC_SERIALISE(Environment.OSVersion); + ANALYTIC_SERIALISE(Environment.GPUVendors); + ANALYTIC_SERIALISE(Environment.Bitness); + ANALYTIC_SERIALISE(Environment.DevelBuildRun); + ANALYTIC_SERIALISE(Environment.OfficialBuildRun); + } + + // A flag for each dat counting which unique days in the last month the program was run. + ANALYTIC_SERIALISE(Version); + + // special handling for reporting DaysUsed, to flatten into a number + if(reporting) + { + int sum = 0; + for(bool day : Analytics::db->DaysUsed) + sum += day ? 1 : 0; + + saveTo(values, lit("DaysUsed"), sum, reporting); + } + else + { + ANALYTIC_SERIALISE(DaysUsed); + } + + ANALYTIC_SERIALISE(LoadTime); + ANALYTIC_SERIALISE(APIsUsed); + + // UIFeatures + { + ANALYTIC_SERIALISE(UIFeatures.Bookmarks); + ANALYTIC_SERIALISE(UIFeatures.ResourceInspect); + ANALYTIC_SERIALISE(UIFeatures.ShaderEditing); + ANALYTIC_SERIALISE(UIFeatures.CallstackResolve); + ANALYTIC_SERIALISE(UIFeatures.PixelHistory); + + ANALYTIC_SERIALISE(UIFeatures.DrawcallTimes); + ANALYTIC_SERIALISE(UIFeatures.PerformanceCounters); + ANALYTIC_SERIALISE(UIFeatures.PythonInterop); + ANALYTIC_SERIALISE(UIFeatures.CustomTextureVisualise); + ANALYTIC_SERIALISE(UIFeatures.ImageViewer); + ANALYTIC_SERIALISE(UIFeatures.CaptureComments); + + // Export + { + ANALYTIC_SERIALISE(UIFeatures.Export.EventBrowser); + ANALYTIC_SERIALISE(UIFeatures.Export.PipelineState); + ANALYTIC_SERIALISE(UIFeatures.Export.MeshOutput); + ANALYTIC_SERIALISE(UIFeatures.Export.TextureSave); + ANALYTIC_SERIALISE(UIFeatures.Export.ShaderSave); + } + + // ShaderDebug + { + ANALYTIC_SERIALISE(UIFeatures.ShaderDebug.Vertex); + ANALYTIC_SERIALISE(UIFeatures.ShaderDebug.Pixel); + ANALYTIC_SERIALISE(UIFeatures.ShaderDebug.Compute); + } + + // TextureDebugOverlays + { + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.Drawcall); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.Wireframe); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.Depth); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.Stencil); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.BackfaceCull); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.ViewportScissor); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.NaN); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.Clipping); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.ClearBeforePass); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.ClearBeforeDraw); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.QuadOverdrawPass); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.QuadOverdrawDraw); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.TriangleSizePass); + ANALYTIC_SERIALISE(UIFeatures.TextureDebugOverlays.TriangleSizeDraw); + } + + // RemoteReplay + { + ANALYTIC_SERIALISE(UIFeatures.RemoteReplay.Android); + ANALYTIC_SERIALISE(UIFeatures.RemoteReplay.NonAndroid); + } + } + + // CaptureFeatures + { + ANALYTIC_SERIALISE(CaptureFeatures.ShaderLinkage); + ANALYTIC_SERIALISE(CaptureFeatures.YUVTextures); + ANALYTIC_SERIALISE(CaptureFeatures.SparseResources); + ANALYTIC_SERIALISE(CaptureFeatures.MultiGPU); + } +} + +}; // anonymous namespace + +Analytics *Analytics::db = NULL; + +void Analytics::Save() +{ + if(analyticsSaveLocation.isEmpty()) + return; + + QVariantMap values; + + // call to the serialise function to save into the 'values' map + AnalyticsSerialise(values, AnalyticsSerialiseType::Saving); + + QFile f(analyticsSaveLocation); + if(f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) + SaveToJSON(values, f, analyticsJSONMagic, analyticsJSONVersion); +} + +void Analytics::Load() +{ + // allocate space for the Analytics singleton + Analytics::db = &actualDB; + + // find the filename where the analytics will be saved + analyticsSaveLocation = configFilePath(lit("analytics.json")); + + QFile f(analyticsSaveLocation); + + // silently allow missing database + if(f.exists()) + { + if(f.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QVariantMap values; + + bool success = LoadFromJSON(values, f, analyticsJSONMagic, analyticsJSONVersion); + + if(success) + AnalyticsSerialise(values, AnalyticsSerialiseType::Loading); + } + } + + // if year is 0, this was uninitialised meaning there was no previous analytics database. We set + // the current month, and mark a flag that we need to prompt the user about opting out of + // analytics. + int currentYear = QDateTime::currentDateTime().date().year(); + int currentMonth = QDateTime::currentDateTime().date().month(); + if(Analytics::db->Date.Year == 0) + { + Analytics::db->Date.Year = currentYear; + Analytics::db->Date.Month = currentMonth; + analyticsState = AnalyticsState::PromptFirstTime; + } + else if(Analytics::db->Date.Year != currentYear || Analytics::db->Date.Month != currentMonth) + { + // if the analytics is not from this month, submit the report. + analyticsState = AnalyticsState::SubmitReport; + } +} + +void Analytics::Prompt(ICaptureContext &ctx, PersistantConfig &config) +{ + if(analyticsState == AnalyticsState::PromptFirstTime) + { + QWidget *mainWindow = ctx.GetMainWindow()->Widget(); + + AnalyticsPromptDialog prompt(config, mainWindow); + RDDialog::show(&prompt); + } + else if(analyticsState == AnalyticsState::SubmitReport) + { + QWidget *mainWindow = ctx.GetMainWindow()->Widget(); + + QVariantMap values; + + AnalyticsSerialise(values, AnalyticsSerialiseType::Reporting); + + QBuffer buf; + buf.open(QBuffer::WriteOnly); + + SaveToJSON(values, buf, NULL, 0); + + QString jsonReport = QString::fromUtf8(buf.buffer()); + + if(config.Analytics_ManualCheck) + { + AnalyticsConfirmDialog confirm(jsonReport, mainWindow); + int res = RDDialog::show(&confirm); + + if(res == 0) + analyticsState = AnalyticsState::Nothing; + } + + if(analyticsState == AnalyticsState::SubmitReport) + { + QNetworkAccessManager *mgr = new QNetworkAccessManager(mainWindow); + + QUrlQuery postData; + + postData.addQueryItem(lit("report"), jsonReport); + + QNetworkRequest request(QUrl(lit("https://renderdoc.org/analytics"))); + + request.setHeader(QNetworkRequest::ContentTypeHeader, + lit("application/x-www-form-urlencoded")); + + QByteArray dataText = postData.toString(QUrl::FullyEncoded).toUtf8(); + mgr->post(request, dataText); + } + + // reset the database now + *Analytics::db = Analytics(); + Analytics::db->Date.Year = QDateTime::currentDateTime().date().year(); + Analytics::db->Date.Month = QDateTime::currentDateTime().date().month(); + } +} + +#else // RENDERDOC_ANALYTICS_ENABLE + +namespace Analytics +{ +void Load() +{ +} + +void Prompt(ICaptureContext &ctx, PersistantConfig &config) +{ +} +}; + +#endif diff --git a/qrenderdoc/Code/Interface/Analytics.h b/qrenderdoc/Code/Interface/Analytics.h new file mode 100644 index 000000000..6ac6ebe41 --- /dev/null +++ b/qrenderdoc/Code/Interface/Analytics.h @@ -0,0 +1,308 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 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 0 + +// we don't want any of this to be accessible to script, only code. +#if !defined(SWIG) + +// 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) + 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. +struct Analytics +{ + // utility function - loads the analytics from disk and initialise the Analytics::db member. + static void Load(); + // 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; + + // 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; + + // A list of which GPU vendors have been used for replay + QStringList GPUVendors; + + // 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; + } Environment; + + // Counts which unique days in the last month the program was run + bool DaysUsed[32] = {0}; + + // how long do captures take to load, on average + AnalyticsAverage LoadTime; + + // which APIs have been used + QStringList APIsUsed; + + // 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; + + struct + { + bool EventBrowser = false; + bool PipelineState = false; + bool MeshOutput = false; + bool RawBuffer = false; + bool TextureSave = false; + bool ShaderSave = 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; + } TextureDebugOverlays; + + struct + { + bool Android = false; + bool NonAndroid = false; + } RemoteReplay; + } UIFeatures; + + // 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; + } 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 Load(); +void Prompt(ICaptureContext &ctx, PersistantConfig &config); +}; + +#endif + +#endif \ No newline at end of file diff --git a/qrenderdoc/Code/Interface/PersistantConfig.h b/qrenderdoc/Code/Interface/PersistantConfig.h index b390df132..c5b07a9e3 100644 --- a/qrenderdoc/Code/Interface/PersistantConfig.h +++ b/qrenderdoc/Code/Interface/PersistantConfig.h @@ -133,6 +133,10 @@ DECLARE_REFLECTION_STRUCT(SPIRVDisassembler); \ CONFIG_SETTING(public, QVariantList, QList, SPIRVDisassemblers) \ \ + CONFIG_SETTING_VAL(public, bool, bool, Analytics_TotalOptOut, false) \ + \ + CONFIG_SETTING_VAL(public, bool, bool, Analytics_ManualCheck, false) \ + \ CONFIG_SETTING(private, QVariantMap, QStringMap, ConfigSettings) \ \ CONFIG_SETTING(private, QVariantList, QList, RemoteHostList) @@ -422,6 +426,21 @@ For more information about some of these settings that are user-facing see .. data:: RemoteHosts A ``list`` of :class:`RemoteHost` handles to the currently configured remote hosts. + +.. data:: Analytics_TotalOptOut + + ``True`` if the user has selected to completely opt-out from and disable all analytics collection + and reporting. + + Defaults to ``False``. + +.. data:: Analytics_ManualCheck + + ``True`` if the user has remained with analytics turned on, but has chosen to manually check each + report that is sent out. + + Defaults to ``False``. + )"); class PersistantConfig { diff --git a/qrenderdoc/Code/Interface/QRDInterface.cpp b/qrenderdoc/Code/Interface/QRDInterface.cpp index 7102ea5f6..e8563863e 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.cpp +++ b/qrenderdoc/Code/Interface/QRDInterface.cpp @@ -1,3 +1,26 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 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. + ******************************************************************************/ #include "QRDInterface.h" #include diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index e14d1a1a0..ab085d6e8 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -60,6 +60,7 @@ class QWidget; #define RENDERDOC_QT_COMPAT #include "renderdoc_replay.h" +#include "Analytics.h" #include "CommonPipelineState.h" #include "PersistantConfig.h" #include "RemoteHost.h" diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index 7c1059e45..102c270ca 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -729,7 +729,8 @@ void addStructuredObjects(RDTreeWidgetItem *parent, const StructuredObjectList & bool SaveToJSON(QVariantMap &data, QIODevice &f, const char *magicIdentifier, uint32_t magicVersion) { // marker that this data is valid - data[QString::fromLatin1(magicIdentifier)] = magicVersion; + if(magicIdentifier) + data[QString::fromLatin1(magicIdentifier)] = magicVersion; QJsonDocument doc = QJsonDocument::fromVariant(data); diff --git a/qrenderdoc/Code/ReplayManager.cpp b/qrenderdoc/Code/ReplayManager.cpp index a105e3848..09610a17b 100644 --- a/qrenderdoc/Code/ReplayManager.cpp +++ b/qrenderdoc/Code/ReplayManager.cpp @@ -302,6 +302,15 @@ ReplayStatus ReplayManager::ConnectToRemoteServer(RemoteHost *host) ReplayStatus status = RENDERDOC_CreateRemoteServerConnection(host->Hostname.toUtf8().data(), 0, &m_Remote); + if(host->IsHostADB()) + { + ANALYTIC_SET(UIFeatures.RemoteReplay.Android, true); + } + else + { + ANALYTIC_SET(UIFeatures.RemoteReplay.NonAndroid, true); + } + m_RemoteHost = host; if(status == ReplayStatus::Succeeded) diff --git a/qrenderdoc/Code/qrenderdoc.cpp b/qrenderdoc/Code/qrenderdoc.cpp index f18dc5381..6ce2bb8c6 100644 --- a/qrenderdoc/Code/qrenderdoc.cpp +++ b/qrenderdoc/Code/qrenderdoc.cpp @@ -28,11 +28,13 @@ #include #include #include +#include #include "Code/CaptureContext.h" #include "Code/QRDUtils.h" #include "Code/Resources.h" #include "Code/pyrenderdoc/PythonContext.h" #include "Windows/MainWindow.h" +#include "version.h" #if defined(Q_OS_WIN32) extern "C" { @@ -203,6 +205,9 @@ int main(int argc, char *argv[]) .arg(configFilename)); } + if(!config.Analytics_TotalOptOut) + Analytics::Load(); + bool isDarkTheme = IsDarkTheme(); bool styleSet = config.SetStyle(); @@ -234,10 +239,29 @@ int main(int argc, char *argv[]) { CaptureContext ctx(filename, remoteHost, remoteIdent, temp, config); + Analytics::Prompt(ctx, config); + + ANALYTIC_SET(Environment.RenderDocVersion, lit(FULL_VERSION_STRING)); +#if defined(DISTRIBUTION_VERSION) + ANALYTIC_SET(Environment.DistributionVersion, lit(DISTRIBUTION_NAME)); +#endif + ANALYTIC_SET(Environment.Bitness, ((sizeof(void *) == sizeof(uint64_t)) ? 64 : 32)); + ANALYTIC_SET(Environment.OSVersion, QSysInfo::prettyProductName()); + +#if RENDERDOC_STABLE_BUILD + ANALYTIC_SET(Environment.OfficialBuildRun, true); +#else + ANALYTIC_SET(Environment.DevelBuildRun, true); +#endif + + ANALYTIC_SET(DaysUsed[QDateTime::currentDateTime().date().day()], true); + if(!pyscripts.isEmpty()) { PythonContextHandle py; + ANALYTIC_SET(UIFeatures.PythonInterop, true); + py.ctx().setGlobal("pyrenderdoc", (ICaptureContext *)&ctx); QObject::connect(&py.ctx(), &PythonContext::exception, diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index 09413e883..a2e239d52 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -3063,6 +3063,15 @@ void BufferViewer::exportData(const BufferExport ¶ms) return; } + if(m_MeshView) + { + ANALYTIC_SET(UIFeatures.Export.MeshOutput, true); + } + else + { + ANALYTIC_SET(UIFeatures.Export.RawBuffer, true); + } + BufferItemModel *model = (BufferItemModel *)m_CurView->model(); LambdaThread *exportThread = new LambdaThread([this, params, model, f]() { diff --git a/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.cpp b/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.cpp new file mode 100644 index 000000000..d76de577f --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.cpp @@ -0,0 +1,41 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 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. + ******************************************************************************/ + +#include "AnalyticsConfirmDialog.h" +#include +#include "ui_AnalyticsConfirmDialog.h" + +AnalyticsConfirmDialog::AnalyticsConfirmDialog(QString report, QWidget *parent) + : QDialog(parent), ui(new Ui::AnalyticsConfirmDialog) +{ + ui->setupUi(this); + + ui->analyticsReport->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); + ui->analyticsReport->setText(report); +} + +AnalyticsConfirmDialog::~AnalyticsConfirmDialog() +{ + delete ui; +} diff --git a/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.h b/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.h new file mode 100644 index 000000000..cce1fdcd2 --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 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 + +#include + +namespace Ui +{ +class AnalyticsConfirmDialog; +} + +class AnalyticsConfirmDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AnalyticsConfirmDialog(QString report, QWidget *parent = 0); + ~AnalyticsConfirmDialog(); + +private: + Ui::AnalyticsConfirmDialog *ui; +}; diff --git a/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.ui b/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.ui new file mode 100644 index 000000000..c5ec2eaf3 --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AnalyticsConfirmDialog.ui @@ -0,0 +1,93 @@ + + + AnalyticsConfirmDialog + + + + 0 + 0 + 500 + 500 + + + + + 0 + 0 + + + + Analytics Report + + + true + + + + + + <html><head/><body><p align="center"><span style=" font-size:18pt; font-weight:600;">Analytics Report Ready</span></p><p><br/>RenderDoc has gathered analytics from your usage over the past month. This is now ready to send to the server for processing.</p><p>As requested, the full report is listed below where you can check the data and ensure you are happy with what's being sent.</p><p>When ready, click OK to send the report. Clicking Discard will throw away this report and begin again for next month.</p><p>If you want, you can manually copy-paste this report and send it through here: <a href="https://renderdoc.org/analytics"><span style=" text-decoration: underline; color:#0000ff;">https://renderdoc.org/analytics</span></a>.</p></body></html> + + + true + + + true + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Discard|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AnalyticsConfirmDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AnalyticsConfirmDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.cpp b/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.cpp new file mode 100644 index 000000000..5be0c158f --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.cpp @@ -0,0 +1,65 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 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. + ******************************************************************************/ + +#include "AnalyticsPromptDialog.h" +#include "Code/Interface/QRDInterface.h" +#include "ui_AnalyticsPromptDialog.h" + +AnalyticsPromptDialog::AnalyticsPromptDialog(PersistantConfig &cfg, QWidget *parent) + : QDialog(parent), ui(new Ui::AnalyticsPromptDialog), m_Config(cfg) +{ + ui->setupUi(this); +} + +AnalyticsPromptDialog::~AnalyticsPromptDialog() +{ + delete ui; +} + +void AnalyticsPromptDialog::on_autoSubmit_toggled(bool checked) +{ + if(checked) + { + m_Config.Analytics_ManualCheck = false; + m_Config.Analytics_TotalOptOut = false; + } +} + +void AnalyticsPromptDialog::on_manualCheck_toggled(bool checked) +{ + if(checked) + { + m_Config.Analytics_ManualCheck = true; + m_Config.Analytics_TotalOptOut = false; + } +} + +void AnalyticsPromptDialog::on_optOut_toggled(bool checked) +{ + if(checked) + { + m_Config.Analytics_ManualCheck = false; + m_Config.Analytics_TotalOptOut = true; + } +} diff --git a/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.h b/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.h new file mode 100644 index 000000000..e7278c435 --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.h @@ -0,0 +1,53 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 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 + +#include + +namespace Ui +{ +class AnalyticsPromptDialog; +} + +class PersistantConfig; + +class AnalyticsPromptDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AnalyticsPromptDialog(PersistantConfig &cfg, QWidget *parent = 0); + ~AnalyticsPromptDialog(); + +private slots: + // automatic slots + void on_autoSubmit_toggled(bool checked); + void on_manualCheck_toggled(bool checked); + void on_optOut_toggled(bool checked); + +private: + Ui::AnalyticsPromptDialog *ui; + PersistantConfig &m_Config; +}; diff --git a/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.ui b/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.ui new file mode 100644 index 000000000..33ef85b3b --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AnalyticsPromptDialog.ui @@ -0,0 +1,113 @@ + + + AnalyticsPromptDialog + + + + 0 + 0 + 498 + 554 + + + + Analytics + + + true + + + + + + <html><head/><body><p align="center"><span style=" font-size:18pt; font-weight:600;">Anonymous Analytics</span></p><p><br/>RenderDoc now has some very minimal analytics gathering in the UI, to help learn how RenderDoc is used and inform its future development. Here you can choose how to use it - if you have no problems with this, click OK to continue and you won't be prompted again.</p><p>The data gathered is <span style=" font-weight:600; text-decoration: underline;">not personally identifiable</span> and contains <span style=" font-weight:600; text-decoration: underline;">absolutely no data from captures</span>. It will store for example which API is captured, and what features in the UI are used. The source is freely available and auditable.</p><p>Analytics gathering only happens in the UI itself, no analytics code runs at capture time so there is no risk of leaking information from the target program.</p><p>Each month an anonymous report is generated and sent to securely the RenderDoc server. The aggregated statistics are visible publicly.</p><p>By default this happens behind the scenes and no user interaction is required. If you want, you can choose to manually approve each report before it's sent. That way you can see what information is stored.</p><p>If you wish, you can opt-out entirely and no statistics will be gathered or reported. However please consider this carefully as it will reduce the accuracy of the statistics and make it harder for me to reason about what features and work on RenderDoc to prioritise.</p><p>For more information (and to see what statistics are gathered) go to <a href="https://renderdoc.org/analytics"><span style=" text-decoration: underline; color:#0000ff;">https://renderdoc.org/analytics</span></a>.</p><p>Thanks!<br/>Baldur Karlsson</p></body></html> + + + true + + + true + + + + + + + Select your preference + + + + + + Gather anonymous low-detail statistics and submit automatically. + + + true + + + + + + + Gather anonymous low-detail statistics, but manually verify before submitting. + + + + + + + Do not gather or submit any statistics. + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AnalyticsPromptDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AnalyticsPromptDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/qrenderdoc/Windows/EventBrowser.cpp b/qrenderdoc/Windows/EventBrowser.cpp index f295fb5ec..f3251eebd 100644 --- a/qrenderdoc/Windows/EventBrowser.cpp +++ b/qrenderdoc/Windows/EventBrowser.cpp @@ -390,6 +390,8 @@ void EventBrowser::on_bookmark_clicked() void EventBrowser::on_timeDraws_clicked() { + ANALYTIC_SET(UIFeatures.DrawcallTimes, true); + ui->events->header()->showSection(COL_DURATION); m_Ctx.Replay().AsyncInvoke([this](IReplayController *r) { @@ -563,6 +565,8 @@ void EventBrowser::on_exportDraws_clicked() if(!filename.isEmpty()) { + ANALYTIC_SET(UIFeatures.Export.EventBrowser, true); + QDir dirinfo = QFileInfo(filename).dir(); if(dirinfo.exists()) { diff --git a/qrenderdoc/Windows/MainWindow.cpp b/qrenderdoc/Windows/MainWindow.cpp index 8ba80e9f6..d825cd237 100644 --- a/qrenderdoc/Windows/MainWindow.cpp +++ b/qrenderdoc/Windows/MainWindow.cpp @@ -569,6 +569,15 @@ void MainWindow::LoadCapture(const QString &filename, bool temporary, bool local statusText->setText(tr("Loading %1...").arg(origFilename)); + if(driver == lit("Image")) + { + ANALYTIC_SET(UIFeatures.ImageViewer, true); + } + else + { + ANALYTIC_ADDUNIQ(APIsUsed, driver); + } + m_Ctx.LoadCapture(fileToLoad, origFilename, temporary, local); } @@ -1641,6 +1650,8 @@ void MainWindow::on_action_Python_Shell_triggered() void MainWindow::on_action_Resolve_Symbols_triggered() { + ANALYTIC_SET(UIFeatures.CallstackResolve, true); + if(!m_Ctx.Replay().GetCaptureAccess()) { RDDialog::critical( diff --git a/qrenderdoc/Windows/PerformanceCounterViewer.cpp b/qrenderdoc/Windows/PerformanceCounterViewer.cpp index 8ac99fb38..8f8f299be 100644 --- a/qrenderdoc/Windows/PerformanceCounterViewer.cpp +++ b/qrenderdoc/Windows/PerformanceCounterViewer.cpp @@ -191,6 +191,8 @@ void PerformanceCounterViewer::CaptureCounters() return; m_SelectedCounters = pcs.GetSelectedCounters(); + ANALYTIC_SET(UIFeatures.PerformanceCounters, true); + bool done = false; m_Ctx.Replay().AsyncInvoke([this, &done](IReplayController *controller) -> void { rdcarray counters; diff --git a/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp index 4a71ef6da..6b40be3ce 100644 --- a/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp @@ -205,6 +205,8 @@ QXmlStreamWriter *PipelineStateViewer::beginHTMLExport() if(!filename.isEmpty()) { + ANALYTIC_SET(UIFeatures.Export.PipelineState, true); + QDir dirinfo = QFileInfo(filename).dir(); if(dirinfo.exists()) { @@ -718,6 +720,8 @@ void PipelineStateViewer::EditShader(ShaderStage shaderType, ResourceId id, const ShaderReflection *shaderDetails, const QString &entryFunc, const QStringMap &files, const QString &mainfile) { + ANALYTIC_SET(UIFeatures.ShaderEditing, true); + IShaderViewer *sv = m_Ctx.EditShader( false, entryFunc, files, // save callback @@ -882,6 +886,8 @@ bool PipelineStateViewer::SaveShaderFile(const ShaderReflection *shader) if(!filename.isEmpty()) { + ANALYTIC_SET(UIFeatures.Export.ShaderSave, true); + QDir dirinfo = QFileInfo(filename).dir(); if(dirinfo.exists()) { diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp index 76f02f61b..4972ecfae 100644 --- a/qrenderdoc/Windows/PythonShell.cpp +++ b/qrenderdoc/Windows/PythonShell.cpp @@ -505,6 +505,8 @@ void PythonShell::on_execute_clicked() { QString command = ui->lineInput->text(); + ANALYTIC_SET(UIFeatures.PythonInterop, true); + appendText(ui->interactiveOutput, command + lit("\n")); history.push_front(command); @@ -612,6 +614,8 @@ void PythonShell::on_runScript_clicked() { PythonContext *context = newContext(); + ANALYTIC_SET(UIFeatures.PythonInterop, true); + ui->scriptOutput->clear(); QString script = QString::fromUtf8(scriptEditor->getText(scriptEditor->textLength() + 1)); diff --git a/qrenderdoc/Windows/ResourceInspector.cpp b/qrenderdoc/Windows/ResourceInspector.cpp index ecc7aa2a4..54666a3fa 100644 --- a/qrenderdoc/Windows/ResourceInspector.cpp +++ b/qrenderdoc/Windows/ResourceInspector.cpp @@ -213,6 +213,8 @@ void ResourceInspector::Inspect(ResourceId id) if(desc) { + ANALYTIC_SET(UIFeatures.ResourceInspect, true); + ui->resourceName->setText(m_Ctx.GetResourceName(id)); ui->relatedResources->beginUpdate(); diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index e65d8a333..12885634a 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -335,6 +335,19 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR // suppress the built-in context menu and hook up our own if(trace) { + if(m_Stage == ShaderStage::Vertex) + { + ANALYTIC_SET(UIFeatures.ShaderDebug.Vertex, true); + } + else if(m_Stage == ShaderStage::Pixel) + { + ANALYTIC_SET(UIFeatures.ShaderDebug.Pixel, true); + } + else if(m_Stage == ShaderStage::Compute) + { + ANALYTIC_SET(UIFeatures.ShaderDebug.Compute, true); + } + m_DisassemblyView->usePopUp(SC_POPUP_NEVER); m_DisassemblyFrame->layout()->removeWidget(m_DisassemblyToolbar); diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 844d3da5d..2a85819d1 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -2843,6 +2843,30 @@ void TextureViewer::on_overlay_currentIndexChanged(int index) if(ui->overlay->currentIndex() > 0) m_TexDisplay.overlay = (DebugOverlay)ui->overlay->currentIndex(); +#define ANALYTICS_OVERLAY(name) \ + case DebugOverlay::name: ANALYTIC_SET(UIFeatures.TextureDebugOverlays.name, true); break; + + switch(m_TexDisplay.overlay) + { + ANALYTICS_OVERLAY(Drawcall); + ANALYTICS_OVERLAY(Wireframe); + ANALYTICS_OVERLAY(Depth); + ANALYTICS_OVERLAY(Stencil); + ANALYTICS_OVERLAY(BackfaceCull); + ANALYTICS_OVERLAY(ViewportScissor); + ANALYTICS_OVERLAY(NaN); + ANALYTICS_OVERLAY(Clipping); + ANALYTICS_OVERLAY(ClearBeforePass); + ANALYTICS_OVERLAY(ClearBeforeDraw); + ANALYTICS_OVERLAY(QuadOverdrawPass); + ANALYTICS_OVERLAY(QuadOverdrawDraw); + ANALYTICS_OVERLAY(TriangleSizePass); + ANALYTICS_OVERLAY(TriangleSizeDraw); + default: break; + } + +#undef ANALYTICS_OVERLAY + INVOKE_MEMFN(RT_UpdateAndDisplay); if(m_Output != NULL && m_PickedPoint.x() >= 0 && m_PickedPoint.y() >= 0) { @@ -3359,6 +3383,8 @@ void TextureViewer::on_saveTex_clicked() if(res) { + ANALYTIC_SET(UIFeatures.Export.TextureSave, true); + bool ret = false; QString fn = saveDialog.filename(); @@ -3420,6 +3446,8 @@ void TextureViewer::on_pixelHistory_clicked() if(!texptr || !m_Output) return; + ANALYTIC_SET(UIFeatures.PixelHistory, true); + int x = m_PickedPoint.x() >> (int)m_TexDisplay.mip; int y = m_PickedPoint.y() >> (int)m_TexDisplay.mip; @@ -3583,6 +3611,8 @@ void TextureViewer::reloadCustomShaders(const QString &filter) QTextStream stream(&fileHandle); QString source = stream.readAll(); + ANALYTIC_SET(UIFeatures.CustomTextureVisualise, true); + fileHandle.close(); m_CustomShaders[key] = ResourceId(); diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro index 407798ec6..a9c68c003 100644 --- a/qrenderdoc/qrenderdoc.pro +++ b/qrenderdoc/qrenderdoc.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui widgets svg +QT += core gui widgets svg network CONFIG += silent @@ -163,6 +163,7 @@ SOURCES += Code/qrenderdoc.cpp \ Code/Resources.cpp \ Code/pyrenderdoc/PythonContext.cpp \ Code/Interface/QRDInterface.cpp \ + Code/Interface/Analytics.cpp \ Code/Interface/CommonPipelineState.cpp \ Code/Interface/PersistantConfig.cpp \ Code/Interface/RemoteHost.cpp \ @@ -220,7 +221,9 @@ SOURCES += Code/qrenderdoc.cpp \ Windows/PythonShell.cpp \ Windows/Dialogs/PerformanceCounterSelection.cpp \ Windows/PerformanceCounterViewer.cpp \ - Windows/ResourceInspector.cpp + Windows/ResourceInspector.cpp \ + Windows/Dialogs/AnalyticsConfirmDialog.cpp \ + Windows/Dialogs/AnalyticsPromptDialog.cpp HEADERS += Code/CaptureContext.h \ Code/qprocessinfo.h \ Code/ReplayManager.h \ @@ -231,6 +234,7 @@ HEADERS += Code/CaptureContext.h \ Code/pyrenderdoc/pyconversion.h \ Code/pyrenderdoc/document_check.h \ Code/Interface/QRDInterface.h \ + Code/Interface/Analytics.h \ Code/Interface/CommonPipelineState.h \ Code/Interface/PersistantConfig.h \ Code/Interface/RemoteHost.h \ @@ -288,7 +292,9 @@ HEADERS += Code/CaptureContext.h \ Windows/PythonShell.h \ Windows/Dialogs/PerformanceCounterSelection.h \ Windows/PerformanceCounterViewer.h \ - Windows/ResourceInspector.h + Windows/ResourceInspector.h \ + Windows/Dialogs/AnalyticsConfirmDialog.h \ + Windows/Dialogs/AnalyticsPromptDialog.h FORMS += Windows/Dialogs/AboutDialog.ui \ Windows/MainWindow.ui \ Windows/EventBrowser.ui \ @@ -323,7 +329,9 @@ FORMS += Windows/Dialogs/AboutDialog.ui \ Windows/PythonShell.ui \ Windows/Dialogs/PerformanceCounterSelection.ui \ Windows/PerformanceCounterViewer.ui \ - Windows/ResourceInspector.ui + Windows/ResourceInspector.ui \ + Windows/Dialogs/AnalyticsConfirmDialog.ui \ + Windows/Dialogs/AnalyticsPromptDialog.ui RESOURCES += Resources/resources.qrc diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index 811961479..a0bdccb0b 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -88,7 +88,7 @@ ProgramDatabase true true - $(ProjectDir);$(IntDir)generated\;$(SolutionDir)\renderdoc\api\replay;3rdparty\python\include;3rdparty\pyside\include\PySide2;3rdparty\pyside\include\PySide2\QtCore;3rdparty\pyside\include\PySide2\QtGui;3rdparty\pyside\include\PySide2\QtWidgets;3rdparty\pyside\include\shiboken2;3rdparty\qt\$(Platform)\include;3rdparty\qt\$(Platform)\include\QtWidgets;3rdparty\qt\$(Platform)\include\QtGui;3rdparty\qt\$(Platform)\include\QtCore;3rdparty\qt\$(Platform)\include\QtSvg;%(AdditionalIncludeDirectories) + $(ProjectDir);$(IntDir)generated\;$(SolutionDir)\renderdoc\api\replay;3rdparty\python\include;3rdparty\pyside\include\PySide2;3rdparty\pyside\include\PySide2\QtCore;3rdparty\pyside\include\PySide2\QtGui;3rdparty\pyside\include\PySide2\QtWidgets;3rdparty\pyside\include\shiboken2;3rdparty\qt\$(Platform)\include;3rdparty\qt\$(Platform)\include\QtWidgets;3rdparty\qt\$(Platform)\include\QtGui;3rdparty\qt\$(Platform)\include\QtCore;3rdparty\qt\$(Platform)\include\QtSvg;3rdparty\qt\$(Platform)\include\QtNetwork;%(AdditionalIncludeDirectories) /Zc:strictStrings /Zc:throwingNew %(AdditionalOptions) _WINDOWS;UNICODE;WIN32;WIN64;RENDERDOC_PLATFORM_WIN32;PYSIDE2_ENABLED=1;SCINTILLA_QT=1;MAKING_LIBRARY=1;SCI_LEXER=1;QT_NO_CAST_FROM_ASCII;QT_NO_CAST_TO_ASCII;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_SVG_LIB;%(PreprocessorDefinitions) Level4 @@ -100,7 +100,7 @@ Windows - shiboken2.lib;python36.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Svg.lib;shell32.lib + shiboken2.lib;python36.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Svg.lib;Qt5Network.lib;shell32.lib 3rdparty\pyside\$(Platform);3rdparty\python\$(Platform);3rdparty\qt\$(Platform)\lib;%(AdditionalLibraryDirectories) true true @@ -561,6 +561,7 @@ + @@ -576,6 +577,8 @@ + + @@ -685,6 +688,8 @@ + + @@ -866,6 +871,7 @@ $(IntDir)generated\moc_%(Filename).cpp + @@ -879,6 +885,8 @@ + + @@ -1111,6 +1119,18 @@ MOC %(Filename).h $(IntDir)generated\moc_%(Filename).cpp + + %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe;%(AdditionalInputs) + "$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe" -DUNICODE -DWIN32 -DWIN64 -D_WIN32 -D_WIN64 -DRENDERDOC_PLATFORM_WIN32 -DSCINTILLA_QT=1 -DSCI_LEXER=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1900 -I"$(ProjectDir)." -I"$(SolutionDir)\renderdoc\api\replay" -I"$(ProjectDir)3rdparty\qt\$(Platform)\mkspecs/win32-msvc2015" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtWidgets" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtGui" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtCore" "%(Fullpath)" -o "$(IntDir)generated\moc_%(Filename).cpp" + MOC %(Filename).h + $(IntDir)generated\moc_%(Filename).cpp + + + %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe;%(AdditionalInputs) + "$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe" -DUNICODE -DWIN32 -DWIN64 -D_WIN32 -D_WIN64 -DRENDERDOC_PLATFORM_WIN32 -DSCINTILLA_QT=1 -DSCI_LEXER=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1900 -I"$(ProjectDir)." -I"$(SolutionDir)\renderdoc\api\replay" -I"$(ProjectDir)3rdparty\qt\$(Platform)\mkspecs/win32-msvc2015" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtWidgets" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtGui" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtCore" "%(Fullpath)" -o "$(IntDir)generated\moc_%(Filename).cpp" + MOC %(Filename).h + $(IntDir)generated\moc_%(Filename).cpp + %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe;%(AdditionalInputs) "$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe" -DUNICODE -DWIN32 -DWIN64 -D_WIN32 -D_WIN64 -DRENDERDOC_PLATFORM_WIN32 -DSCINTILLA_QT=1 -DSCI_LEXER=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1900 -I"$(ProjectDir)." -I"$(SolutionDir)\renderdoc\api\replay" -I"$(ProjectDir)3rdparty\qt\$(Platform)\mkspecs/win32-msvc2015" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtWidgets" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtGui" -I"$(ProjectDir)3rdparty\qt\$(Platform)\include\QtCore" "%(Fullpath)" -o "$(IntDir)generated\moc_%(Filename).cpp" @@ -1339,6 +1359,18 @@ UIC %(Filename).ui $(IntDir)generated\ui_%(Filename).h + + %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\uic.exe;%(AdditionalInputs) + "$(ProjectDir)3rdparty\qt\$(Platform)\bin\uic.exe" "%(Fullpath)" -o "$(IntDir)generated\ui_%(Filename).h" + UIC %(Filename).ui + $(IntDir)generated\ui_%(Filename).h + + + %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\uic.exe;%(AdditionalInputs) + "$(ProjectDir)3rdparty\qt\$(Platform)\bin\uic.exe" "%(Fullpath)" -o "$(IntDir)generated\ui_%(Filename).h" + UIC %(Filename).ui + $(IntDir)generated\ui_%(Filename).h + %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\uic.exe;%(AdditionalInputs) "$(ProjectDir)3rdparty\qt\$(Platform)\bin\uic.exe" "%(Fullpath)" -o "$(IntDir)generated\ui_%(Filename).h" diff --git a/qrenderdoc/qrenderdoc_local.vcxproj.filters b/qrenderdoc/qrenderdoc_local.vcxproj.filters index 2c4fe722e..9b780c817 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj.filters +++ b/qrenderdoc/qrenderdoc_local.vcxproj.filters @@ -675,6 +675,21 @@ Windows + + Generated Files + + + Windows\Dialogs + + + Generated Files + + + Windows\Dialogs + + + Code\Interface + @@ -1016,6 +1031,15 @@ Generated Files + + Code\Interface + + + Generated Files + + + Generated Files + @@ -1538,5 +1562,17 @@ Windows + + Windows\Dialogs + + + Windows\Dialogs + + + Windows\Dialogs + + + Windows\Dialogs + \ No newline at end of file diff --git a/renderdoc/api/replay/data_types.h b/renderdoc/api/replay/data_types.h index c3663ebea..dc650b953 100644 --- a/renderdoc/api/replay/data_types.h +++ b/renderdoc/api/replay/data_types.h @@ -947,6 +947,14 @@ Currently this is only true for OpenGL where the superfluous indirect in the bin worked around by re-sorting bindings. )"); bool shadersMutable = false; + +#if !defined(SWIG) + // flags about edge-case parts of the APIs that might be used in the capture. + bool ShaderLinkage = false; + bool YUVTextures = false; + bool SparseResources = false; + bool MultiGPU = false; +#endif }; DECLARE_REFLECTION_STRUCT(APIProperties); diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index d80849663..b26dc7cdd 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -426,6 +426,8 @@ public: //////////////////////////////////////////////////////////////// // non wrapping interface + APIProperties APIProps; + ID3D11Device *GetReal() { return m_pDevice; } static std::string GetChunkName(uint32_t idx); D3D11DebugManager *GetDebugManager() { return m_DebugManager; } diff --git a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp index 84a7a6f32..36ad15fd5 100644 --- a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp @@ -380,6 +380,8 @@ bool WrappedID3D11Device::Serialise_CreateTexture1D(SerialiserType &ser, else hr = m_pDevice->CreateTexture1D(&Descriptor, NULL, &ret); + APIProps.YUVTextures |= IsYUVFormat(Descriptor.Format); + if(FAILED(hr)) { RDCERR("Failed on resource serialise-creation, HRESULT: %s", ToStr(hr).c_str()); @@ -499,6 +501,8 @@ bool WrappedID3D11Device::Serialise_CreateTexture2D(SerialiserType &ser, TextureDisplayType dispType = DispTypeForTexture(Descriptor); + APIProps.YUVTextures |= IsYUVFormat(Descriptor.Format); + // unset flags that are unimportant/problematic in replay Descriptor.MiscFlags &= ~(D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | @@ -628,6 +632,8 @@ bool WrappedID3D11Device::Serialise_CreateTexture3D(SerialiserType &ser, TextureDisplayType dispType = DispTypeForTexture(Descriptor); + APIProps.YUVTextures |= IsYUVFormat(Descriptor.Format); + // unset flags that are unimportant/problematic in replay Descriptor.MiscFlags &= ~(D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | @@ -767,6 +773,9 @@ bool WrappedID3D11Device::Serialise_CreateShaderResourceView( pSRVDesc->Format = tex2d->m_RealDescriptor->Format; } + if(pSRVDesc) + APIProps.YUVTextures |= IsYUVFormat(pSRVDesc->Format); + HRESULT hr = m_pDevice->CreateShaderResourceView( GetResourceManager()->UnwrapResource(pResource), pSRVDesc, &ret); @@ -1962,6 +1971,8 @@ bool WrappedID3D11Device::Serialise_CreateClassInstance(SerialiserType &ser, LPC ->CreateClassInstance(pClassTypeName, ConstantBufferOffset, ConstantVectorOffset, TextureOffset, SamplerOffset, &real); + APIProps.ShaderLinkage = true; + if(FAILED(hr)) { RDCERR("Failed on resource serialise-creation, HRESULT: %s", ToStr(hr).c_str()); @@ -2030,6 +2041,8 @@ bool WrappedID3D11Device::Serialise_GetClassInstance(SerialiserType &ser, LPCSTR HRESULT hr = UNWRAP(WrappedID3D11ClassLinkage, pClassLinkage) ->GetClassInstance(pClassInstanceName, InstanceIndex, &real); + APIProps.ShaderLinkage = true; + if(FAILED(hr)) { RDCERR("Failed on resource serialise-creation, HRESULT: %s", ToStr(hr).c_str()); diff --git a/renderdoc/driver/d3d11/d3d11_replay.cpp b/renderdoc/driver/d3d11/d3d11_replay.cpp index c1b45153f..3dcec1f63 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.cpp +++ b/renderdoc/driver/d3d11/d3d11_replay.cpp @@ -317,7 +317,7 @@ vector D3D11Replay::GetDebugMessages() APIProperties D3D11Replay::GetAPIProperties() { - APIProperties ret; + APIProperties ret = m_pDevice->APIProps; ret.pipelineType = GraphicsAPI::D3D11; ret.localRenderer = GraphicsAPI::D3D11; diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index 4aa16920a..4cfd25410 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -365,6 +365,8 @@ public: //////////////////////////////////////////////////////////////// // non wrapping interface + APIProperties APIProps; + WriteSerialiser &GetThreadSerialiser(); ID3D12Device *GetReal() { return m_pDevice; } diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp index c585e6b2c..637ead0bc 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp @@ -1176,6 +1176,8 @@ bool WrappedID3D12Device::Serialise_CreateCommittedResource( } } + APIProps.YUVTextures |= IsYUVFormat(desc.Format); + // always allow SRVs on replay so we can inspect resources desc.Flags &= ~D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; @@ -1423,6 +1425,8 @@ bool WrappedID3D12Device::Serialise_CreatePlacedResource( m_GPUAddresses.AddTo(range); } + APIProps.YUVTextures |= IsYUVFormat(Descriptor.Format); + // always allow SRVs on replay so we can inspect resources Descriptor.Flags &= ~D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; @@ -1564,6 +1568,7 @@ bool WrappedID3D12Device::Serialise_CreateReservedResource( const D3D12_CLEAR_VALUE *pOptimizedClearValue, REFIID riid, void **ppvResource) { D3D12NOTIMP("Tiled Resources"); + APIProps.SparseResources = true; return true; } diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index baab720dd..e0854b31d 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -66,7 +66,7 @@ ReplayStatus D3D12Replay::ReadLogInitialisation(RDCFile *rdc, bool storeStructur APIProperties D3D12Replay::GetAPIProperties() { - APIProperties ret; + APIProperties ret = m_pDevice->APIProps; ret.pipelineType = GraphicsAPI::D3D12; ret.localRenderer = GraphicsAPI::D3D12; diff --git a/renderdoc/driver/dxgi/dxgi_common.cpp b/renderdoc/driver/dxgi/dxgi_common.cpp index d069ce492..b0bcb674f 100644 --- a/renderdoc/driver/dxgi/dxgi_common.cpp +++ b/renderdoc/driver/dxgi/dxgi_common.cpp @@ -479,6 +479,34 @@ bool IsSRGBFormat(DXGI_FORMAT f) return false; } +bool IsYUVFormat(DXGI_FORMAT f) +{ + switch(f) + { + case DXGI_FORMAT_AYUV: + case DXGI_FORMAT_Y410: + case DXGI_FORMAT_Y416: + case DXGI_FORMAT_NV12: + case DXGI_FORMAT_P010: + case DXGI_FORMAT_P016: + case DXGI_FORMAT_420_OPAQUE: + case DXGI_FORMAT_YUY2: + case DXGI_FORMAT_Y210: + case DXGI_FORMAT_Y216: + case DXGI_FORMAT_NV11: + case DXGI_FORMAT_AI44: + case DXGI_FORMAT_IA44: + case DXGI_FORMAT_P8: + case DXGI_FORMAT_A8P8: + case DXGI_FORMAT_P208: + case DXGI_FORMAT_V208: + case DXGI_FORMAT_V408: return true; + default: break; + } + + return false; +} + DXGI_FORMAT GetDepthTypedFormat(DXGI_FORMAT f) { switch(f) diff --git a/renderdoc/driver/dxgi/dxgi_common.h b/renderdoc/driver/dxgi/dxgi_common.h index d14f49594..cae03f857 100644 --- a/renderdoc/driver/dxgi/dxgi_common.h +++ b/renderdoc/driver/dxgi/dxgi_common.h @@ -55,6 +55,7 @@ bool IsUIntFormat(DXGI_FORMAT f); bool IsTypelessFormat(DXGI_FORMAT f); bool IsIntFormat(DXGI_FORMAT f); bool IsSRGBFormat(DXGI_FORMAT f); +bool IsYUVFormat(DXGI_FORMAT f); // not technically DXGI, but makes more sense to have it here common between D3D versions Topology MakePrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY Topo); diff --git a/renderdoc/driver/gl/gl_driver.h b/renderdoc/driver/gl/gl_driver.h index bf054647d..da7449af1 100644 --- a/renderdoc/driver/gl/gl_driver.h +++ b/renderdoc/driver/gl/gl_driver.h @@ -529,6 +529,8 @@ public: WrappedOpenGL(const GLHookSet &funcs, GLPlatform &platform); virtual ~WrappedOpenGL(); + APIProperties APIProps; + uint64_t GetLogVersion() { return m_SectionVersion; } static std::string GetChunkName(uint32_t idx); GLResourceManager *GetResourceManager() { return m_ResourceManager; } diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 7327a3dff..26e0e6e1f 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -137,7 +137,7 @@ ResourceId GLReplay::GetLiveID(ResourceId id) APIProperties GLReplay::GetAPIProperties() { - APIProperties ret; + APIProperties ret = m_pDriver->APIProps; ret.pipelineType = GraphicsAPI::OpenGL; ret.localRenderer = GraphicsAPI::OpenGL; diff --git a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp index b58cdd726..41eebcc84 100644 --- a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp @@ -892,8 +892,12 @@ bool WrappedOpenGL::Serialise_glUniformSubroutinesuiv(SerialiserType &ser, GLenu SERIALISE_CHECK_READ_ERRORS(); if(IsReplayingAndReading()) + { m_Real.glUniformSubroutinesuiv(shadertype, count, indices); + APIProps.ShaderLinkage = true; + } + return true; } diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index d805538f0..903e6e6f9 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -748,6 +748,8 @@ public: WrappedVulkan(); virtual ~WrappedVulkan(); + APIProperties APIProps; + ResourceId GetContextResourceID() { return m_FrameCaptureRecord->GetResourceID(); } static std::string GetChunkName(uint32_t idx); VulkanResourceManager *GetResourceManager() { return m_ResourceManager; } diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index efcf1b901..ed33fbd17 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -649,7 +649,7 @@ void VulkanReplay::Shutdown() APIProperties VulkanReplay::GetAPIProperties() { - APIProperties ret; + APIProperties ret = m_pDriver->APIProps; ret.pipelineType = GraphicsAPI::Vulkan; ret.localRenderer = GraphicsAPI::Vulkan; diff --git a/renderdoc/driver/vulkan/vk_resources.cpp b/renderdoc/driver/vulkan/vk_resources.cpp index 1060e786d..934950b6c 100644 --- a/renderdoc/driver/vulkan/vk_resources.cpp +++ b/renderdoc/driver/vulkan/vk_resources.cpp @@ -372,6 +372,50 @@ bool IsSIntFormat(VkFormat f) return false; } +bool IsYUVFormat(VkFormat f) +{ + switch(f) + { + case VK_FORMAT_G8B8G8R8_422_UNORM_KHR: + case VK_FORMAT_B8G8R8G8_422_UNORM_KHR: + case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR: + case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR: + case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM_KHR: + case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM_KHR: + case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM_KHR: + case VK_FORMAT_R10X6_UNORM_PACK16_KHR: + case VK_FORMAT_R10X6G10X6_UNORM_2PACK16_KHR: + case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR: + case VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR: + case VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR: + case VK_FORMAT_R12X4_UNORM_PACK16_KHR: + case VK_FORMAT_R12X4G12X4_UNORM_2PACK16_KHR: + case VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR: + case VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR: + case VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR: + case VK_FORMAT_G16B16G16R16_422_UNORM_KHR: + case VK_FORMAT_B16G16R16G16_422_UNORM_KHR: + case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM_KHR: + case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM_KHR: + case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM_KHR: + case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM_KHR: + case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR: return true; + default: break; + } + + return false; +} + VkFormat GetDepthOnlyFormat(VkFormat f) { switch(f) diff --git a/renderdoc/driver/vulkan/vk_resources.h b/renderdoc/driver/vulkan/vk_resources.h index e5ac6cb73..c6cbe1c4f 100644 --- a/renderdoc/driver/vulkan/vk_resources.h +++ b/renderdoc/driver/vulkan/vk_resources.h @@ -1172,6 +1172,7 @@ bool IsStencilOnlyFormat(VkFormat f); bool IsSRGBFormat(VkFormat f); bool IsUIntFormat(VkFormat f); bool IsSIntFormat(VkFormat f); +bool IsYUVFormat(VkFormat f); VkFormat GetDepthOnlyFormat(VkFormat f); VkFormat GetUIntTypedFormat(VkFormat f); diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index ff0bd744b..d199de187 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -1108,6 +1108,12 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(SerialiserType &ser, VkDevice devic VkResult ret = ObjDisp(device)->CreateBuffer(Unwrap(device), &CreateInfo, NULL, &buf); + if(CreateInfo.flags & + (VK_BUFFER_CREATE_SPARSE_BINDING_BIT | VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT)) + { + APIProps.SparseResources = true; + } + CreateInfo.usage = origusage; if(ret != VK_SUCCESS) @@ -1355,6 +1361,13 @@ bool WrappedVulkan::Serialise_vkCreateImage(SerialiserType &ser, VkDevice device } } + APIProps.YUVTextures |= IsYUVFormat(CreateInfo.format); + + if(CreateInfo.flags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) + { + APIProps.SparseResources = true; + } + VkResult ret = ObjDisp(device)->CreateImage(Unwrap(device), &CreateInfo, NULL, &img); CreateInfo.usage = origusage; @@ -1645,6 +1658,8 @@ bool WrappedVulkan::Serialise_vkCreateImageView(SerialiserType &ser, VkDevice de unwrappedInfo.image = Unwrap(unwrappedInfo.image); VkResult ret = ObjDisp(device)->CreateImageView(Unwrap(device), &unwrappedInfo, NULL, &view); + APIProps.YUVTextures |= IsYUVFormat(CreateInfo.format); + if(ret != VK_SUCCESS) { RDCERR("Failed on resource serialise-creation, VkResult: %s", ToStr(ret).c_str()); diff --git a/renderdoc/replay/renderdoc_serialise.inl b/renderdoc/replay/renderdoc_serialise.inl index 6574ca149..311defb14 100644 --- a/renderdoc/replay/renderdoc_serialise.inl +++ b/renderdoc/replay/renderdoc_serialise.inl @@ -399,7 +399,12 @@ void DoSerialise(SerialiserType &ser, APIProperties &el) SERIALISE_MEMBER(localRenderer); SERIALISE_MEMBER(degraded); - SIZE_CHECK(12); + SERIALISE_MEMBER(ShaderLinkage); + SERIALISE_MEMBER(YUVTextures); + SERIALISE_MEMBER(SparseResources); + SERIALISE_MEMBER(MultiGPU); + + SIZE_CHECK(16); } template