Add NSIGHT Profiliing capability

This commit is contained in:
Sam Gateau 2014-10-27 11:40:52 -07:00
parent 2dff75dac1
commit ff44a460d6
3 changed files with 33 additions and 5 deletions

View file

@ -226,11 +226,17 @@ else (APPLE)
if (WIN32)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
# we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib)
find_package(NSIGHT)
if (NSIGHT_FOUND)
include_directories(${NSIGHT_INCLUDE_DIRS})
add_definitions(-DNSIGHT_FOUND)
endif ()
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${NSIGHT_LIBRARIES}" wsock32.lib opengl32.lib)
endif()
endif (APPLE)

View file

@ -16,6 +16,23 @@
#include <vector>
#if defined(NSIGHT_FOUND)
#include "nvToolsExt.h"
class ProfileRange {
public:
ProfileRange(const char *name) {
nvtxRangePush(name);
}
~ProfileRange() {
nvtxRangePop();
}
};
#define PROFILE_SCOPE(name) ProfileRange profileRangeThis(name);
#else
#define PROFILE_SCOPE(name)
#endif
namespace gpu {
class Batch;

View file

@ -395,6 +395,7 @@ void Model::setJointStates(QVector<JointState> states) {
}
bool Model::render(float alpha, RenderMode mode, RenderArgs* args) {
PROFILE_SCOPE(__FUNCTION__);
// render the attachments
foreach (Model* attachment, _attachments) {
attachment->render(alpha, mode);
@ -560,8 +561,11 @@ bool Model::render(float alpha, RenderMode mode, RenderArgs* args) {
GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0);
// Render!
::gpu::backend::renderBatch(batch);
batch.clear();
{
PROFILE_SCOPE("render Batch");
::gpu::backend::renderBatch(batch);
batch.clear();
}
// restore all the default material settings
Application::getInstance()->setupWorldLight();
@ -1551,6 +1555,7 @@ void Model::segregateMeshGroups() {
int Model::renderMeshes(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold,
bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args) {
PROFILE_SCOPE(__FUNCTION__);
bool dontCullOutOfViewMeshParts = Menu::getInstance()->isOptionChecked(MenuOption::DontCullOutOfViewMeshParts);
bool cullTooSmallMeshParts = !Menu::getInstance()->isOptionChecked(MenuOption::DontCullTooSmallMeshParts);
bool dontReduceMaterialSwitches = Menu::getInstance()->isOptionChecked(MenuOption::DontReduceMaterialSwitches);