Merge pull request #3670 from samcake/temp0

Add NSIGHT profiling information to the Build
This commit is contained in:
Andrzej Kapolka 2014-10-27 17:03:19 -07:00
commit fc3f27b70a
4 changed files with 85 additions and 5 deletions

View file

@ -0,0 +1,49 @@
#
# FindNSIGHT.cmake
#
# Try to find NSIGHT NvToolsExt library and include path.
# Once done this will define
#
# NSIGHT_FOUND
# NSIGHT_INCLUDE_DIRS
# NSIGHT_LIBRARIES
#
# Created on 10/27/2014 by Sam Gateau
# Copyright 2014 High Fidelity, Inc.
#
# Distributed under the Apache License, Version 2.0.
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (WIN32)
find_path(NSIGHT_INCLUDE_DIRS
NAMES
nvToolsExt.h
PATH_SUFFIXES
include
PATHS
"C:/Program Files/NVIDIA Corporation/NvToolsExt")
find_library(NSIGHT_LIBRARY_RELEASE nvToolsExt32_1
PATH_SUFFIXES
"lib/Win32" "lib"
PATHS
"C:/Program Files/NVIDIA Corporation/NvToolsExt")
find_library(NSIGHT_LIBRARY_DEBUG nvToolsExt32_1
PATH_SUFFIXES
"lib/Win32" "lib"
PATHS
"C:/Program Files/NVIDIA Corporation/NvToolsExt")
include(SelectLibraryConfigurations)
select_library_configurations(NSIGHT)
endif ()
set(NSIGHT_LIBRARIES "${NSIGHT_LIBRARY}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NSIGHT DEFAULT_MSG NSIGHT_INCLUDE_DIRS NSIGHT_LIBRARIES)
mark_as_advanced(NSIGHT_INCLUDE_DIRS NSIGHT_LIBRARIES NSIGHT_SEARCH_DIRS)

View file

@ -226,11 +226,20 @@ 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)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${NSIGHT_LIBRARIES}" wsock32.lib opengl32.lib)
# try to find the Nsight package and add it to the build if we find it
find_package(NSIGHT)
if (NSIGHT_FOUND)
include_directories(${NSIGHT_INCLUDE_DIRS})
add_definitions(-DNSIGHT_FOUND)
target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}")
endif ()
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_RANGE(name) ProfileRange profileRangeThis(name);
#else
#define PROFILE_RANGE(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_RANGE(__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_RANGE("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_RANGE(__FUNCTION__);
bool dontCullOutOfViewMeshParts = Menu::getInstance()->isOptionChecked(MenuOption::DontCullOutOfViewMeshParts);
bool cullTooSmallMeshParts = !Menu::getInstance()->isOptionChecked(MenuOption::DontCullTooSmallMeshParts);
bool dontReduceMaterialSwitches = Menu::getInstance()->isOptionChecked(MenuOption::DontReduceMaterialSwitches);