More profiling ranges and updated performance testing scripts

This commit is contained in:
Brad Davis 2015-07-09 15:40:43 -07:00
parent cac239ad88
commit 446f800aee
6 changed files with 112 additions and 47 deletions

View file

@ -9,9 +9,7 @@
var NUM_MOONS = 20;
// 1 = 60Hz, 2 = 30Hz, 3 = 20Hz, etc
var UPDATE_FREQUENCY_DIVISOR = 2;
var MAX_RANGE = 75.0;
var LIFETIME = 600;
var SCALE = 0.1;
var center = Vec3.sum(MyAvatar.position,
@ -22,44 +20,47 @@ var PARTICLE_MIN_SIZE = 2.50;
var PARTICLE_MAX_SIZE = 2.50;
var planet = Entities.addEntity({
type: "Sphere",
position: center,
dimensions: { x: 10 * SCALE, y: 10 * SCALE, z: 10 * SCALE },
color: { red: 0, green: 0, blue: 255 },
ignoreCollisions: true,
collisionsWillMove: false,
lifetime: LIFETIME
});
function deleteAnimationTestEntitites() {
var ids = Entities.findEntities(MyAvatar.position, 50);
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
var properties = Entities.getEntityProperties(id);
if (properties.name == "AnimationTest") {
Entities.deleteEntity(id);
}
}
}
deleteAnimationTestEntitites();
var moons = [];
// Create initial test particles that will move according to gravity from the planets
for (var i = 0; i < NUM_MOONS; i++) {
var radius = PARTICLE_MIN_SIZE + Math.random() * PARTICLE_MAX_SIZE;
radius *= SCALE;
var gray = Math.random() * 155;
var position = { x: 10 , y: i * 3, z: 0 };
var color = { red: 100 + gray, green: 100 + gray, blue: 100 + gray };
if (i == 0) {
color = { red: 255, green: 0, blue: 0 };
radius = 6 * SCALE
}
moons.push(Entities.addEntity({
type: "Sphere",
position: Vec3.sum(center, position),
dimensions: { x: radius, y: radius, z: radius },
color: color,
ignoreCollisions: true,
lifetime: LIFETIME,
collisionsWillMove: false
}));
var radius = PARTICLE_MIN_SIZE + Math.random() * PARTICLE_MAX_SIZE;
radius *= SCALE;
var gray = Math.random() * 155;
var position = { x: 10 , y: i * 3, z: 0 };
var color = { red: 100 + gray, green: 100 + gray, blue: 100 + gray };
if (i == 0) {
color = { red: 255, green: 0, blue: 0 };
radius = 6 * SCALE
}
moons.push(Entities.addEntity({
type: "Sphere",
name: "AnimationTest",
position: Vec3.sum(center, position),
dimensions: { x: radius, y: radius, z: radius },
color: color,
ignoreCollisions: true,
collisionsWillMove: false
}));
}
Script.update.connect(update);
function scriptEnding() {
Entities.deleteEntity(planet);
for (var i = 0; i < moons.length; i++) {
Entities.deleteEntity(moons[i]);
}
@ -70,22 +71,20 @@ var updateCount = 0;
function update(deltaTime) {
// Apply gravitational force from planets
totalTime += deltaTime;
updateCount++;
if (0 != updateCount % UPDATE_FREQUENCY_DIVISOR) {
return;
}
var planetProperties = Entities.getEntityProperties(planet);
var center = planetProperties.position;
updateCount++;
if (0 != updateCount % UPDATE_FREQUENCY_DIVISOR) {
return;
}
var particlePos = Entities.getEntityProperties(moons[0]).position;
var relativePos = Vec3.subtract(particlePos.position, center);
for (var t = 0; t < moons.length; t++) {
var thetaDelta = (Math.PI * 2.0 / NUM_MOONS) * t;
var y = Math.sin(totalTime + thetaDelta) * 10.0 * SCALE;
var x = Math.cos(totalTime + thetaDelta) * 10.0 * SCALE;
var thetaDelta = (Math.PI * 2.0 / NUM_MOONS) * t;
var y = Math.sin(totalTime + thetaDelta) * 10.0 * SCALE;
var x = Math.cos(totalTime + thetaDelta) * 10.0 * SCALE;
var newBasePos = Vec3.sum({ x: 0, y: y, z: x }, center);
Entities.editEntity(moons[t], { position: newBasePos});
}
}
Script.scriptEnding.connect(scriptEnding);
Script.scriptEnding.connect(deleteAnimationTestEntitites);

58
examples/cubePerfTest.js Normal file
View file

@ -0,0 +1,58 @@
//
// Created by Bradley Austin Davis on 2015/07/01
// Copyright 2015 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
//
var SIDE_SIZE = 10;
var center = { x: 0, y: 0, z: 0 };
var DEGREES_TO_RADIANS = Math.PI / 180.0;
var PARTICLE_MIN_SIZE = 2.50;
var PARTICLE_MAX_SIZE = 2.50;
var LIFETIME = 600;
var boxes = [];
var ids = Entities.findEntities({ x: 512, y: 512, z: 512 }, 50);
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
var properties = Entities.getEntityProperties(id);
if (properties.name == "PerfTest") {
Entities.deleteEntity(id);
}
}
// Create initial test particles that will move according to gravity from the planets
for (var x = 0; x < SIDE_SIZE; x++) {
for (var y = 0; y < SIDE_SIZE; y++) {
for (var z = 0; z < SIDE_SIZE; z++) {
var gray = Math.random() * 155;
var cube = Math.random() > 0.5;
var color = { red: 100 + gray, green: 100 + gray, blue: 100 + gray };
var position = { x: 512 + x * 0.2, y: 512 + y * 0.2, z: 512 + z * 0.2};
var radius = Math.random() * 0.1;
boxes.push(Entities.addEntity({
type: cube ? "Box" : "Sphere",
name: "PerfTest",
position: position,
dimensions: { x: radius, y: radius, z: radius },
color: color,
ignoreCollisions: true,
collisionsWillMove: false,
lifetime: LIFETIME
}));
}
}
}
function scriptEnding() {
for (var i = 0; i < boxes.length; i++) {
//Entities.deleteEntity(boxes[i]);
}
}
Script.scriptEnding.connect(scriptEnding);

View file

@ -887,12 +887,6 @@ void Application::paintGL() {
{
PerformanceTimer perfTimer("renderOverlay");
/*
gpu::Context context(new gpu::GLBackend());
RenderArgs renderArgs(&context, nullptr, getViewFrustum(), lodManager->getOctreeSizeScale(),
lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
*/
_applicationOverlay.renderOverlay(&renderArgs);
}
@ -968,6 +962,8 @@ void Application::paintGL() {
} else if (TV3DManager::isConnected()) {
TV3DManager::display(&renderArgs, _myCamera);
} else {
PROFILE_RANGE(__function__ "/mainRender");
DependencyManager::get<GlowEffect>()->prepare(&renderArgs);
// Viewport is assigned to the size of the framebuffer
@ -1002,6 +998,7 @@ void Application::paintGL() {
if (!OculusManager::isConnected() || OculusManager::allowSwap()) {
PROFILE_RANGE(__FUNCTION__ "/bufferSwap");
_glWidget->swapBuffers();
}
@ -1051,6 +1048,7 @@ void Application::resetCameras(Camera& camera, const glm::uvec2& size) {
}
void Application::resizeGL() {
PROFILE_RANGE(__FUNCTION__);
// Set the desired FBO texture size. If it hasn't changed, this does nothing.
// Otherwise, it must rebuild the FBOs
QSize renderSize;
@ -1526,6 +1524,7 @@ void Application::focusOutEvent(QFocusEvent* event) {
}
void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
PROFILE_RANGE(__FUNCTION__);
// Used by application overlay to determine how to draw cursor(s)
_lastMouseMoveWasSimulated = deviceID > 0;
if (!_lastMouseMoveWasSimulated) {
@ -1829,6 +1828,7 @@ void Application::idle() {
PerformanceTimer perfTimer("update");
PerformanceWarning warn(showWarnings, "Application::idle()... update()");
const float BIGGEST_DELTA_TIME_SECS = 0.25f;
PROFILE_RANGE(__FUNCTION__ "/idleUpdate");
update(glm::clamp((float)timeSinceLastUpdate / 1000.0f, 0.0f, BIGGEST_DELTA_TIME_SECS));
}
{
@ -2954,6 +2954,7 @@ QRect Application::getDesirableApplicationGeometry() {
// or the "myCamera".
//
void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
PROFILE_RANGE(__FUNCTION__);
// We will use these below, from either the camera or head vectors calculated above
viewFrustum.setProjection(camera.getProjection());

View file

@ -184,6 +184,7 @@ void ApplicationCompositor::bindCursorTexture(gpu::Batch& batch, uint8_t cursorI
// Draws the FBO texture for the screen
void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) {
PROFILE_RANGE(__FUNCTION__);
if (_alpha == 0.0f) {
return;
}
@ -252,6 +253,7 @@ vec2 getPolarCoordinates(const PalmData& palm) {
// Draws the FBO texture for Oculus rift.
void ApplicationCompositor::displayOverlayTextureHmd(RenderArgs* renderArgs, int eye) {
PROFILE_RANGE(__FUNCTION__);
if (_alpha == 0.0f) {
return;
}

View file

@ -74,6 +74,7 @@ ApplicationOverlay::~ApplicationOverlay() {
// Renders the overlays either to a texture or to the screen
void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
PROFILE_RANGE(__FUNCTION__);
CHECK_GL_ERROR();
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
@ -98,6 +99,7 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
}
void ApplicationOverlay::renderQmlUi(RenderArgs* renderArgs) {
PROFILE_RANGE(__FUNCTION__);
if (_uiTexture) {
gpu::Batch batch;
auto geometryCache = DependencyManager::get<GeometryCache>();
@ -112,6 +114,7 @@ void ApplicationOverlay::renderQmlUi(RenderArgs* renderArgs) {
}
void ApplicationOverlay::renderOverlays(RenderArgs* renderArgs) {
PROFILE_RANGE(__FUNCTION__);
glm::vec2 size = qApp->getCanvasSize();
mat4 legacyProjection = glm::ortho<float>(0, size.x, size.y, 0, ORTHO_NEAR_CLIP, ORTHO_FAR_CLIP);
@ -219,6 +222,7 @@ GLuint ApplicationOverlay::getOverlayTexture() {
}
void ApplicationOverlay::buildFramebufferObject() {
PROFILE_RANGE(__FUNCTION__);
QSize fboSize = qApp->getDeviceSize();
if (_overlayFramebuffer && fboSize == _overlayFramebuffer->size()) {
// Already built

View file

@ -96,6 +96,7 @@ void Overlays::cleanupOverlaysToDelete() {
}
void Overlays::renderHUD(RenderArgs* renderArgs) {
PROFILE_RANGE(__FUNCTION__);
QReadLocker lock(&_lock);
gpu::Batch batch;
renderArgs->_batch = &batch;