mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-13 10:11:02 +00:00
Notes ====== - Create a (hopefully) cross-backend performance statistics abstraction as part of FetchFrameInfo. This currently collects statistics about constant buffer binds, sampler binds, resource binds, client and server style resource updates (e.g. Map and UpdateSubresource), index & vertex buffer binds, and draws and dispatches. In my captures this covers approximately half of all API traffic. The rest is often shader sets, and then usual RS, OM, etc., that aren't currently tracked. During READING state parsing on the wrapped device context, record statistics about the calls and store them into the current frame info. We inspect objects occasionally to get things like their type for recording. It may be useful to expand this in the future to check bind types, etc. On the GL/Vulkan backends the stats data is never initialized and we display the same statistics data as before. - Add a new statistics pane in the UI. A variety of shim arbitration/marshalling is provided to get the statistics data across the managed/native boundary. Removed the old statistics menu item. Currently the statistics pane is just a text log of various gathered data, with ASCII art (woo!) histograms. However in the future we would like to have image based historgrams as well as support for gathering statistics on a mask of stages, etc. - Remove 'diagnostic' events (e.g. push/pop/marker) from the API call count as it distorts the API:draw call ratio. - Add _First and _Count to ShaderResourceType and ShaderStageType for weak enumeration (weak due to int cast requirement). - Provide utility functions Log2Floor for 32 and 64 bit types. These require OS specific clz, which are provided for Windows/VS and Linux/gcc/clang. TODO ====== - UI toolkit based historgram, ability to set stages enabled for statistics, etc. - Revisit necessity of gathering statistics across frames--apparently there is no multi-frame capture in a single log anymore? - Revisit min/max/etc. gathering on the data--is there some way to improve this to not be so mechanical? Perhaps with field enumeration? However if moving to C++/Qt in future, possibly not a good time investment.
77 lines
2.5 KiB
C++
77 lines
2.5 KiB
C++
/******************************************************************************
|
|
* The MIT License (MIT)
|
|
*
|
|
* Copyright (c) 2015-2016 Baldur Karlsson
|
|
* Copyright (c) 2014 Crytek
|
|
*
|
|
* 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 <windows.h>
|
|
#include <intrin.h>
|
|
#include "data/resource.h"
|
|
|
|
#define __PRETTY_FUNCTION_SIGNATURE__ __FUNCSIG__
|
|
|
|
#define OS_DEBUG_BREAK() __debugbreak()
|
|
|
|
#define GetEmbeddedResource(filename) GetEmbeddedResourceWin32( CONCAT(RESOURCE_, filename) )
|
|
string GetEmbeddedResourceWin32(int resource);
|
|
|
|
namespace StringFormat
|
|
{
|
|
// useful for converting to wide before passing to OS functions
|
|
std::wstring UTF82Wide(const string &s);
|
|
};
|
|
|
|
namespace OSUtility
|
|
{
|
|
inline void ForceCrash() { *((int *)NULL) = 0; }
|
|
inline void DebugBreak() { __debugbreak(); }
|
|
inline bool DebuggerPresent() { return ::IsDebuggerPresent() == TRUE; }
|
|
void WriteOutput(int channel, const char *str);
|
|
};
|
|
|
|
namespace Threading
|
|
{
|
|
typedef CriticalSectionTemplate<CRITICAL_SECTION> CriticalSection;
|
|
};
|
|
|
|
namespace Bits
|
|
{
|
|
inline uint32_t CountLeadingZeroes(uint32_t value)
|
|
{
|
|
DWORD index;
|
|
BOOLEAN result = _BitScanReverse(&index, value);
|
|
return (result == TRUE) ? (index ^ 31) : 32;
|
|
}
|
|
|
|
#if RDC64BIT
|
|
inline uint64_t CountLeadingZeroes(uint64_t value)
|
|
{
|
|
DWORD index;
|
|
BOOLEAN result = _BitScanReverse64(&index, value);
|
|
return (result == TRUE) ? (index ^ 63) : 64;
|
|
}
|
|
#endif
|
|
};
|