mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge branch 'master' of https://github.com/highfidelity/hifi into brown
This commit is contained in:
commit
044110e4f3
59 changed files with 1042 additions and 659 deletions
|
@ -16,7 +16,14 @@
|
|||
|
||||
#include "AvatarMixerClientData.h"
|
||||
|
||||
AvatarMixerClientData::AvatarMixerClientData(const QUuid& nodeID) :
|
||||
NodeData(nodeID)
|
||||
{
|
||||
_currentViewFrustum.invalidate();
|
||||
|
||||
// in case somebody calls getSessionUUID on the AvatarData instance, make sure it has the right ID
|
||||
_avatar->setID(nodeID);
|
||||
}
|
||||
|
||||
void AvatarMixerClientData::queuePacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer node) {
|
||||
if (!_packetQueue.node) {
|
||||
|
|
|
@ -36,7 +36,7 @@ const QString INBOUND_AVATAR_DATA_STATS_KEY = "inbound_av_data_kbps";
|
|||
class AvatarMixerClientData : public NodeData {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AvatarMixerClientData(const QUuid& nodeID = QUuid()) : NodeData(nodeID) { _currentViewFrustum.invalidate(); }
|
||||
AvatarMixerClientData(const QUuid& nodeID = QUuid());
|
||||
virtual ~AvatarMixerClientData() {}
|
||||
using HRCTime = p_high_resolution_clock::time_point;
|
||||
|
||||
|
|
|
@ -157,7 +157,8 @@
|
|||
"name": "http_password",
|
||||
"label": "HTTP Password",
|
||||
"type": "password",
|
||||
"help": "Password used for basic HTTP authentication. Leave this blank if you do not want to change it.",
|
||||
"help": "Password used for basic HTTP authentication. Leave this alone if you do not want to change it.",
|
||||
"password_placeholder" : "******",
|
||||
"value-hidden": true
|
||||
},
|
||||
{
|
||||
|
|
|
@ -123,7 +123,7 @@ var viewHelpers = {
|
|||
|
||||
form_group += "<input type='" + input_type + "'" + common_attrs() +
|
||||
"placeholder='" + (_.has(setting, 'placeholder') ? setting.placeholder : "") +
|
||||
"' value='" + setting_value + "'/>"
|
||||
"' value='" + (_.has(setting, 'password_placeholder') ? setting.password_placeholder : setting_value) + "'/>"
|
||||
}
|
||||
|
||||
form_group += "<span class='help-block'>" + setting.help + "</span>"
|
||||
|
@ -981,40 +981,38 @@ function saveSettings() {
|
|||
|
||||
if (validateInputs()) {
|
||||
// POST the form JSON to the domain-server settings.json endpoint so the settings are saved
|
||||
var canPost = true;
|
||||
|
||||
// disable any inputs not changed
|
||||
$("input:not([data-changed])").each(function(){
|
||||
$("input:not([data-changed])").each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
|
||||
// grab a JSON representation of the form via form2js
|
||||
var formJSON = form2js('settings-form', ".", false, cleanupFormValues, true);
|
||||
|
||||
// check if we've set the basic http password - if so convert it to base64
|
||||
// check if we've set the basic http password
|
||||
if (formJSON["security"]) {
|
||||
|
||||
var password = formJSON["security"]["http_password"];
|
||||
if (password && password.length > 0) {
|
||||
var verify_password = formJSON["security"]["verify_http_password"];
|
||||
|
||||
// if they've only emptied out the default password field, we should go ahead and acknowledge
|
||||
// the verify password field
|
||||
if (password != undefined && verify_password == undefined) {
|
||||
verify_password = "";
|
||||
}
|
||||
|
||||
// if we have a password and its verification, convert it to sha256 for comparison
|
||||
if (password != undefined && verify_password != undefined) {
|
||||
formJSON["security"]["http_password"] = sha256_digest(password);
|
||||
}
|
||||
var verify_password = formJSON["security"]["verify_http_password"];
|
||||
if (verify_password && verify_password.length > 0) {
|
||||
formJSON["security"]["verify_http_password"] = sha256_digest(verify_password);
|
||||
}
|
||||
}
|
||||
|
||||
// verify that the password and confirmation match before saving
|
||||
var canPost = true;
|
||||
|
||||
if (formJSON["security"]) {
|
||||
var password = formJSON["security"]["http_password"];
|
||||
var verify_password = formJSON["security"]["verify_http_password"];
|
||||
|
||||
if (password && password.length > 0) {
|
||||
if (password != verify_password) {
|
||||
bootbox.alert({"message": "Passwords must match!", "title":"Password Error"});
|
||||
canPost = false;
|
||||
} else {
|
||||
if (password == verify_password) {
|
||||
delete formJSON["security"]["verify_http_password"];
|
||||
} else {
|
||||
bootbox.alert({ "message": "Passwords must match!", "title": "Password Error" });
|
||||
canPost = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1023,7 +1021,7 @@ function saveSettings() {
|
|||
console.log(formJSON);
|
||||
|
||||
// re-enable all inputs
|
||||
$("input").each(function(){
|
||||
$("input").each(function () {
|
||||
$(this).prop('disabled', false);
|
||||
});
|
||||
|
||||
|
@ -1031,6 +1029,27 @@ function saveSettings() {
|
|||
$(this).blur();
|
||||
|
||||
if (canPost) {
|
||||
if (formJSON["security"]) {
|
||||
var username = formJSON["security"]["http_username"];
|
||||
var password = formJSON["security"]["http_password"];
|
||||
|
||||
if ((password == sha256_digest("")) && (username == undefined || (username && username.length != 0))) {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You have entered a blank password with a non-blank username. Are you sure you want to require a blank password?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#5cb85c",
|
||||
confirmButtonText: "Yes!",
|
||||
closeOnConfirm: true
|
||||
},
|
||||
function () {
|
||||
formJSON["security"]["http_password"] = "";
|
||||
postSettings(formJSON);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
// POST the form JSON to the domain-server settings.json endpoint so the settings are saved
|
||||
postSettings(formJSON);
|
||||
}
|
||||
|
|
|
@ -2114,10 +2114,10 @@ bool DomainServer::isAuthenticatedRequest(HTTPConnection* connection, const QUrl
|
|||
const QVariant* settingsPasswordVariant = valueForKeyPath(settingsMap, BASIC_AUTH_PASSWORD_KEY_PATH);
|
||||
|
||||
QString settingsPassword = settingsPasswordVariant ? settingsPasswordVariant->toString() : "";
|
||||
QString hexHeaderPassword = QCryptographicHash::hash(headerPassword.toUtf8(), QCryptographicHash::Sha256).toHex();
|
||||
|
||||
if (settingsUsername == headerUsername
|
||||
&& (settingsPassword.isEmpty() || hexHeaderPassword == settingsPassword)) {
|
||||
QString hexHeaderPassword = headerPassword.isEmpty() ?
|
||||
"" : QCryptographicHash::hash(headerPassword.toUtf8(), QCryptographicHash::Sha256).toHex();
|
||||
|
||||
if (settingsUsername == headerUsername && hexHeaderPassword == settingsPassword) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,33 @@
|
|||
{ "from": "Vive.RSCenter", "to": "Standard.RightPrimaryThumb" },
|
||||
{ "from": "Vive.RightApplicationMenu", "to": "Standard.RightSecondaryThumb" },
|
||||
|
||||
{ "from": "Vive.LeftHand", "to": "Standard.LeftHand", "when": [ "Application.InHMD" ] },
|
||||
{ "from": "Vive.LeftHand", "to": "Standard.LeftHand", "when": [ "Application.InHMD" ] },
|
||||
{ "from": "Vive.RightHand", "to": "Standard.RightHand", "when": [ "Application.InHMD" ] },
|
||||
{ "from": "Vive.LeftFoot", "to" : "Standard.LeftFoot", "when": [ "Application.InHMD"] },
|
||||
{ "from": "Vive.RightFoot", "to" : "Standard.RightFoot", "when": [ "Application.InHMD"] },
|
||||
{ "from": "Vive.Hips", "to" : "Standard.Hips", "when": [ "Application.InHMD"] },
|
||||
{ "from": "Vive.Spine2", "to" : "Standard.Spine2", "when": [ "Application.InHMD"] },
|
||||
|
||||
{
|
||||
"from": "Vive.LeftFoot", "to" : "Standard.LeftFoot",
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}],
|
||||
"when": [ "Application.InHMD"]
|
||||
},
|
||||
|
||||
{
|
||||
"from": "Vive.RightFoot", "to" : "Standard.RightFoot",
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}],
|
||||
"when": [ "Application.InHMD"]
|
||||
},
|
||||
|
||||
{
|
||||
"from": "Vive.Hips", "to" : "Standard.Hips",
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 0.01, "translation": 0.01}],
|
||||
"when": [ "Application.InHMD"]
|
||||
},
|
||||
|
||||
{
|
||||
"from": "Vive.Spine2", "to" : "Standard.Spine2",
|
||||
"filters" : [{"type" : "lowVelocity", "rotation" : 0.01, "translation": 0.01}],
|
||||
"when": [ "Application.InHMD"]
|
||||
},
|
||||
|
||||
{ "from": "Vive.Head", "to" : "Standard.Head", "when" : [ "Application.InHMD"] }
|
||||
]
|
||||
}
|
||||
|
|
BIN
interface/resources/icons/loader-snake-64-w.gif
Normal file
BIN
interface/resources/icons/loader-snake-64-w.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
|
@ -270,30 +270,26 @@ Item {
|
|||
StatText {
|
||||
text: "GPU Textures: ";
|
||||
}
|
||||
StatText {
|
||||
text: " Pressure State: " + root.gpuTextureMemoryPressureState;
|
||||
}
|
||||
StatText {
|
||||
text: " Count: " + root.gpuTextures;
|
||||
}
|
||||
StatText {
|
||||
text: " Rectified: " + root.rectifiedTextureCount;
|
||||
text: " Pressure State: " + root.gpuTextureMemoryPressureState;
|
||||
}
|
||||
StatText {
|
||||
text: " Decimated: " + root.decimatedTextureCount;
|
||||
text: " Resource Allocated / Populated / Pending: ";
|
||||
}
|
||||
StatText {
|
||||
text: " Pending Transfer: " + root.texturePendingTransfers + " MB";
|
||||
text: " " + root.gpuTextureResourceMemory + " / " + root.gpuTextureResourcePopulatedMemory + " / " + root.texturePendingTransfers + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Resource Memory: " + root.gpuTextureMemory + " MB";
|
||||
text: " Resident Memory: " + root.gpuTextureResidentMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Framebuffer Memory: " + root.gpuTextureFramebufferMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Sparse Memory: " + root.gpuTextureSparseMemory + " MB";
|
||||
visible: 0 != root.gpuSparseTextureEnabled;
|
||||
text: " External Memory: " + root.gpuTextureExternalMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: "GPU Buffers: "
|
||||
|
@ -302,7 +298,7 @@ Item {
|
|||
text: " Count: " + root.gpuBuffers;
|
||||
}
|
||||
StatText {
|
||||
text: " Memory: " + root.gpuBufferMemory;
|
||||
text: " Memory: " + root.gpuBufferMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: "GL Swapchain Memory: " + root.glContextSwapchainMemory + " MB";
|
||||
|
|
|
@ -4,6 +4,7 @@ import QtWebChannel 1.0
|
|||
import QtWebEngine 1.2
|
||||
|
||||
import "controls"
|
||||
import "controls-uit" as HifiControls
|
||||
import "styles" as HifiStyles
|
||||
import "styles-uit"
|
||||
import "windows"
|
||||
|
@ -117,6 +118,8 @@ Item {
|
|||
onNewViewRequested: {
|
||||
request.openIn(webView);
|
||||
}
|
||||
|
||||
HifiControls.WebSpinner { }
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
|
|
|
@ -36,4 +36,6 @@ WebEngineView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebSpinner { }
|
||||
}
|
||||
|
|
21
interface/resources/qml/controls-uit/WebSpinner.qml
Normal file
21
interface/resources/qml/controls-uit/WebSpinner.qml
Normal file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// WebSpinner.qml
|
||||
//
|
||||
// Created by David Rowe on 23 May 2017
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
|
||||
AnimatedImage {
|
||||
source: "../../icons/loader-snake-64-w.gif"
|
||||
visible: parent.loading && /^(http.*|)$/i.test(parent.url.toString())
|
||||
z: 10000
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
|
@ -116,6 +116,8 @@ Item {
|
|||
tabletRoot.openBrowserWindow(request, profile);
|
||||
}
|
||||
}
|
||||
|
||||
HiFiControls.WebSpinner { }
|
||||
}
|
||||
|
||||
HiFiControls.Keyboard {
|
||||
|
|
|
@ -238,6 +238,8 @@ Item {
|
|||
onNewViewRequested: {
|
||||
request.openIn(webview);
|
||||
}
|
||||
|
||||
HiFiControls.WebSpinner { }
|
||||
}
|
||||
|
||||
HiFiControls.Keyboard {
|
||||
|
|
|
@ -116,6 +116,8 @@ Item {
|
|||
tabletRoot.openBrowserWindow(request, profile);
|
||||
}
|
||||
}
|
||||
|
||||
HiFiControls.WebSpinner { }
|
||||
}
|
||||
|
||||
HiFiControls.Keyboard {
|
||||
|
|
|
@ -1340,8 +1340,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
|
||||
auto glInfo = getGLContextData();
|
||||
properties["gl_info"] = glInfo;
|
||||
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemory());
|
||||
properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory());
|
||||
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize());
|
||||
properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemSize());
|
||||
properties["gpu_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerGPUAverage());
|
||||
properties["batch_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerBatchAverage());
|
||||
properties["ideal_thread_count"] = QThread::idealThreadCount();
|
||||
|
@ -3601,10 +3601,6 @@ void Application::idle(float nsecsElapsed) {
|
|||
_overlayConductor.update(secondsSinceLastUpdate);
|
||||
}
|
||||
|
||||
void Application::setLowVelocityFilter(bool lowVelocityFilter) {
|
||||
controller::InputDevice::setLowVelocityFilter(lowVelocityFilter);
|
||||
}
|
||||
|
||||
ivec2 Application::getMouse() const {
|
||||
return getApplicationCompositor().getReticlePosition();
|
||||
}
|
||||
|
@ -4380,6 +4376,7 @@ void Application::update(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
userInputMapper->setInputCalibrationData(calibrationData);
|
||||
userInputMapper->update(deltaTime);
|
||||
|
||||
if (keyboardMousePlugin && keyboardMousePlugin->isActive()) {
|
||||
|
|
|
@ -314,7 +314,6 @@ public slots:
|
|||
void updateThreadPoolCount() const;
|
||||
void updateSystemTabletMode();
|
||||
|
||||
static void setLowVelocityFilter(bool lowVelocityFilter);
|
||||
Q_INVOKABLE void loadDialog();
|
||||
Q_INVOKABLE void loadScriptURLDialog() const;
|
||||
void toggleLogDialog();
|
||||
|
|
|
@ -540,8 +540,6 @@ Menu::Menu() {
|
|||
MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
|
||||
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false,
|
||||
avatar.get(), SLOT(setEnableDebugDrawHandControllers(bool)));
|
||||
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LowVelocityFilter, 0, true,
|
||||
qApp, SLOT(setLowVelocityFilter(bool)));
|
||||
|
||||
MenuWrapper* leapOptionsMenu = handOptionsMenu->addMenu("Leap Motion");
|
||||
addCheckableActionToQMenuAndActionHash(leapOptionsMenu, MenuOption::LeapMotionOnHMD, 0, false);
|
||||
|
|
|
@ -1323,28 +1323,10 @@ void MyAvatar::rebuildCollisionShape() {
|
|||
_characterController.setLocalBoundingBox(corner, diagonal);
|
||||
}
|
||||
|
||||
static controller::Pose applyLowVelocityFilter(const controller::Pose& oldPose, const controller::Pose& newPose) {
|
||||
controller::Pose finalPose = newPose;
|
||||
if (newPose.isValid()) {
|
||||
// Use a velocity sensitive filter to damp small motions and preserve large ones with
|
||||
// no latency.
|
||||
float velocityFilter = glm::clamp(1.0f - glm::length(oldPose.getVelocity()), 0.0f, 1.0f);
|
||||
finalPose.translation = oldPose.getTranslation() * velocityFilter + newPose.getTranslation() * (1.0f - velocityFilter);
|
||||
finalPose.rotation = safeMix(oldPose.getRotation(), newPose.getRotation(), 1.0f - velocityFilter);
|
||||
}
|
||||
return finalPose;
|
||||
}
|
||||
|
||||
void MyAvatar::setHandControllerPosesInSensorFrame(const controller::Pose& left, const controller::Pose& right) {
|
||||
if (controller::InputDevice::getLowVelocityFilter()) {
|
||||
auto oldLeftPose = getLeftHandControllerPoseInSensorFrame();
|
||||
auto oldRightPose = getRightHandControllerPoseInSensorFrame();
|
||||
_leftHandControllerPoseInSensorFrameCache.set(applyLowVelocityFilter(oldLeftPose, left));
|
||||
_rightHandControllerPoseInSensorFrameCache.set(applyLowVelocityFilter(oldRightPose, right));
|
||||
} else {
|
||||
_leftHandControllerPoseInSensorFrameCache.set(left);
|
||||
_rightHandControllerPoseInSensorFrameCache.set(right);
|
||||
}
|
||||
_leftHandControllerPoseInSensorFrameCache.set(left);
|
||||
_rightHandControllerPoseInSensorFrameCache.set(right);
|
||||
}
|
||||
|
||||
controller::Pose MyAvatar::getLeftHandControllerPoseInSensorFrame() const {
|
||||
|
@ -1374,15 +1356,8 @@ controller::Pose MyAvatar::getRightHandControllerPoseInAvatarFrame() const {
|
|||
}
|
||||
|
||||
void MyAvatar::setFootControllerPosesInSensorFrame(const controller::Pose& left, const controller::Pose& right) {
|
||||
if (controller::InputDevice::getLowVelocityFilter()) {
|
||||
auto oldLeftPose = getLeftFootControllerPoseInSensorFrame();
|
||||
auto oldRightPose = getRightFootControllerPoseInSensorFrame();
|
||||
_leftFootControllerPoseInSensorFrameCache.set(applyLowVelocityFilter(oldLeftPose, left));
|
||||
_rightFootControllerPoseInSensorFrameCache.set(applyLowVelocityFilter(oldRightPose, right));
|
||||
} else {
|
||||
_leftFootControllerPoseInSensorFrameCache.set(left);
|
||||
_rightFootControllerPoseInSensorFrameCache.set(right);
|
||||
}
|
||||
_leftFootControllerPoseInSensorFrameCache.set(left);
|
||||
_rightFootControllerPoseInSensorFrameCache.set(right);
|
||||
}
|
||||
|
||||
controller::Pose MyAvatar::getLeftFootControllerPoseInSensorFrame() const {
|
||||
|
@ -1412,15 +1387,8 @@ controller::Pose MyAvatar::getRightFootControllerPoseInAvatarFrame() const {
|
|||
}
|
||||
|
||||
void MyAvatar::setSpineControllerPosesInSensorFrame(const controller::Pose& hips, const controller::Pose& spine2) {
|
||||
if (controller::InputDevice::getLowVelocityFilter()) {
|
||||
auto oldHipsPose = getHipsControllerPoseInSensorFrame();
|
||||
auto oldSpine2Pose = getSpine2ControllerPoseInSensorFrame();
|
||||
_hipsControllerPoseInSensorFrameCache.set(applyLowVelocityFilter(oldHipsPose, hips));
|
||||
_spine2ControllerPoseInSensorFrameCache.set(applyLowVelocityFilter(oldSpine2Pose, spine2));
|
||||
} else {
|
||||
_hipsControllerPoseInSensorFrameCache.set(hips);
|
||||
_spine2ControllerPoseInSensorFrameCache.set(spine2);
|
||||
}
|
||||
_hipsControllerPoseInSensorFrameCache.set(hips);
|
||||
_spine2ControllerPoseInSensorFrameCache.set(spine2);
|
||||
}
|
||||
|
||||
controller::Pose MyAvatar::getHipsControllerPoseInSensorFrame() const {
|
||||
|
@ -1450,12 +1418,7 @@ controller::Pose MyAvatar::getSpine2ControllerPoseInAvatarFrame() const {
|
|||
}
|
||||
|
||||
void MyAvatar::setHeadControllerPoseInSensorFrame(const controller::Pose& head) {
|
||||
if (controller::InputDevice::getLowVelocityFilter()) {
|
||||
auto oldHeadPose = getHeadControllerPoseInSensorFrame();
|
||||
_headControllerPoseInSensorFrameCache.set(applyLowVelocityFilter(oldHeadPose, head));
|
||||
} else {
|
||||
_headControllerPoseInSensorFrameCache.set(head);
|
||||
}
|
||||
_headControllerPoseInSensorFrameCache.set(head);
|
||||
}
|
||||
|
||||
controller::Pose MyAvatar::getHeadControllerPoseInSensorFrame() const {
|
||||
|
|
|
@ -31,7 +31,7 @@ void TestScriptingInterface::quit() {
|
|||
|
||||
void TestScriptingInterface::waitForTextureIdle() {
|
||||
waitForCondition(0, []()->bool {
|
||||
return (0 == gpu::Context::getTextureGPUTransferCount());
|
||||
return (0 == gpu::Context::getTexturePendingGPUTransferCount());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -345,21 +345,21 @@ void Stats::updateStats(bool force) {
|
|||
|
||||
|
||||
STAT_UPDATE(gpuBuffers, (int)gpu::Context::getBufferGPUCount());
|
||||
STAT_UPDATE(gpuBufferMemory, (int)BYTES_TO_MB(gpu::Context::getBufferGPUMemoryUsage()));
|
||||
STAT_UPDATE(gpuBufferMemory, (int)BYTES_TO_MB(gpu::Context::getBufferGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextures, (int)gpu::Context::getTextureGPUCount());
|
||||
STAT_UPDATE(gpuTexturesSparse, (int)gpu::Context::getTextureGPUSparseCount());
|
||||
|
||||
STAT_UPDATE(glContextSwapchainMemory, (int)BYTES_TO_MB(gl::Context::getSwapchainMemoryUsage()));
|
||||
|
||||
STAT_UPDATE(qmlTextureMemory, (int)BYTES_TO_MB(OffscreenQmlSurface::getUsedTextureMemory()));
|
||||
STAT_UPDATE(texturePendingTransfers, (int)BYTES_TO_MB(gpu::Texture::getTextureTransferPendingSize()));
|
||||
STAT_UPDATE(gpuTextureMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureVirtualMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUVirtualMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureFramebufferMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUFramebufferMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureSparseMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUSparseMemoryUsage()));
|
||||
STAT_UPDATE(texturePendingTransfers, (int)BYTES_TO_MB(gpu::Context::getTexturePendingGPUTransferMemSize()));
|
||||
STAT_UPDATE(gpuTextureMemory, (int)BYTES_TO_MB(gpu::Context::getTextureGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureResidentMemory, (int)BYTES_TO_MB(gpu::Context::getTextureResidentGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureFramebufferMemory, (int)BYTES_TO_MB(gpu::Context::getTextureFramebufferGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureResourceMemory, (int)BYTES_TO_MB(gpu::Context::getTextureResourceGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureResourcePopulatedMemory, (int)BYTES_TO_MB(gpu::Context::getTextureResourcePopulatedGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureExternalMemory, (int)BYTES_TO_MB(gpu::Context::getTextureExternalGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureMemoryPressureState, getTextureMemoryPressureModeString());
|
||||
STAT_UPDATE(gpuSparseTextureEnabled, gpuContext->getBackend()->isTextureManagementSparseEnabled() ? 1 : 0);
|
||||
STAT_UPDATE(gpuFreeMemory, (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory()));
|
||||
STAT_UPDATE(gpuFreeMemory, (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemSize()));
|
||||
STAT_UPDATE(rectifiedTextureCount, (int)RECTIFIED_TEXTURE_COUNT.load());
|
||||
STAT_UPDATE(decimatedTextureCount, (int)DECIMATED_TEXTURE_COUNT.load());
|
||||
|
||||
|
|
|
@ -117,15 +117,15 @@ class Stats : public QQuickItem {
|
|||
STATS_PROPERTY(int, gpuBuffers, 0)
|
||||
STATS_PROPERTY(int, gpuBufferMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextures, 0)
|
||||
STATS_PROPERTY(int, gpuTexturesSparse, 0)
|
||||
STATS_PROPERTY(int, glContextSwapchainMemory, 0)
|
||||
STATS_PROPERTY(int, qmlTextureMemory, 0)
|
||||
STATS_PROPERTY(int, texturePendingTransfers, 0)
|
||||
STATS_PROPERTY(int, gpuTextureMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureVirtualMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureResidentMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureFramebufferMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureSparseMemory, 0)
|
||||
STATS_PROPERTY(int, gpuSparseTextureEnabled, 0)
|
||||
STATS_PROPERTY(int, gpuTextureResourceMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureResourcePopulatedMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureExternalMemory, 0)
|
||||
STATS_PROPERTY(QString, gpuTextureMemoryPressureState, QString())
|
||||
STATS_PROPERTY(int, gpuFreeMemory, 0)
|
||||
STATS_PROPERTY(float, gpuFrameTime, 0)
|
||||
|
@ -245,13 +245,13 @@ signals:
|
|||
void gpuBuffersChanged();
|
||||
void gpuBufferMemoryChanged();
|
||||
void gpuTexturesChanged();
|
||||
void gpuTexturesSparseChanged();
|
||||
void gpuTextureMemoryChanged();
|
||||
void gpuTextureVirtualMemoryChanged();
|
||||
void gpuTextureResidentMemoryChanged();
|
||||
void gpuTextureFramebufferMemoryChanged();
|
||||
void gpuTextureSparseMemoryChanged();
|
||||
void gpuTextureResourceMemoryChanged();
|
||||
void gpuTextureResourcePopulatedMemoryChanged();
|
||||
void gpuTextureExternalMemoryChanged();
|
||||
void gpuTextureMemoryPressureStateChanged();
|
||||
void gpuSparseTextureEnabledChanged();
|
||||
void gpuFreeMemoryChanged();
|
||||
void gpuFrameTimeChanged();
|
||||
void batchFrameTimeChanged();
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
namespace controller {
|
||||
|
||||
bool InputDevice::_lowVelocityFilter = false;
|
||||
|
||||
const float DEFAULT_HAND_RETICLE_MOVE_SPEED = 37.5f;
|
||||
float InputDevice::_reticleMoveSpeed = DEFAULT_HAND_RETICLE_MOVE_SPEED;
|
||||
|
||||
|
|
|
@ -77,17 +77,13 @@ public:
|
|||
static float getReticleMoveSpeed() { return _reticleMoveSpeed; }
|
||||
static void setReticleMoveSpeed(float reticleMoveSpeed) { _reticleMoveSpeed = reticleMoveSpeed; }
|
||||
|
||||
static bool getLowVelocityFilter() { return _lowVelocityFilter; };
|
||||
|
||||
Input makeInput(StandardButtonChannel button) const;
|
||||
Input makeInput(StandardAxisChannel axis) const;
|
||||
Input makeInput(StandardPoseChannel pose) const;
|
||||
Input::NamedPair makePair(StandardButtonChannel button, const QString& name) const;
|
||||
Input::NamedPair makePair(StandardAxisChannel button, const QString& name) const;
|
||||
Input::NamedPair makePair(StandardPoseChannel button, const QString& name) const;
|
||||
public slots:
|
||||
static void setLowVelocityFilter(bool newLowVelocityFilter) { _lowVelocityFilter = newLowVelocityFilter; };
|
||||
|
||||
|
||||
protected:
|
||||
friend class UserInputMapper;
|
||||
|
||||
|
@ -104,8 +100,6 @@ protected:
|
|||
AxisStateMap _axisStateMap;
|
||||
PoseStateMap _poseStateMap;
|
||||
|
||||
static bool _lowVelocityFilter;
|
||||
|
||||
private:
|
||||
static float _reticleMoveSpeed;
|
||||
};
|
||||
|
|
|
@ -114,6 +114,9 @@ namespace controller {
|
|||
void loadDefaultMapping(uint16 deviceID);
|
||||
void enableMapping(const QString& mappingName, bool enable = true);
|
||||
|
||||
void setInputCalibrationData(const InputCalibrationData& data) { inputCalibrationData = data; }
|
||||
const InputCalibrationData& getInputCalibrationData() { return inputCalibrationData; }
|
||||
|
||||
void unloadMappings(const QStringList& jsonFiles);
|
||||
void unloadMapping(const QString& jsonFile);
|
||||
|
||||
|
@ -187,6 +190,8 @@ namespace controller {
|
|||
|
||||
QSet<QString> _loadedRouteJsonFiles;
|
||||
|
||||
InputCalibrationData inputCalibrationData;
|
||||
|
||||
mutable std::recursive_mutex _lock;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "filters/TransformFilter.h"
|
||||
#include "filters/PostTransformFilter.h"
|
||||
#include "filters/RotateFilter.h"
|
||||
#include "filters/LowVelocityFilter.h"
|
||||
|
||||
using namespace controller;
|
||||
|
||||
|
@ -45,6 +46,7 @@ REGISTER_FILTER_CLASS_INSTANCE(TranslateFilter, "translate")
|
|||
REGISTER_FILTER_CLASS_INSTANCE(TransformFilter, "transform")
|
||||
REGISTER_FILTER_CLASS_INSTANCE(PostTransformFilter, "postTransform")
|
||||
REGISTER_FILTER_CLASS_INSTANCE(RotateFilter, "rotate")
|
||||
REGISTER_FILTER_CLASS_INSTANCE(LowVelocityFilter, "lowVelocity")
|
||||
|
||||
const QString JSON_FILTER_TYPE = QStringLiteral("type");
|
||||
const QString JSON_FILTER_PARAMS = QStringLiteral("params");
|
||||
|
@ -286,4 +288,4 @@ namespace controller {
|
|||
// const float _max;
|
||||
//};
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "filters/TransformFilter.h"
|
||||
#include "filters/PostTransformFilter.h"
|
||||
#include "filters/RotateFilter.h"
|
||||
#include "filters/LowVelocityFilter.h"
|
||||
#include "conditionals/AndConditional.h"
|
||||
|
||||
using namespace controller;
|
||||
|
@ -127,6 +128,11 @@ QObject* RouteBuilderProxy::rotate(glm::quat rotation) {
|
|||
return this;
|
||||
}
|
||||
|
||||
QObject* RouteBuilderProxy::lowVelocity(float rotationConstant, float translationConstant) {
|
||||
addFilter(std::make_shared<LowVelocityFilter>(rotationConstant, translationConstant));
|
||||
return this;
|
||||
}
|
||||
|
||||
QObject* RouteBuilderProxy::constrainToInteger() {
|
||||
addFilter(std::make_shared<ConstrainToIntegerFilter>());
|
||||
return this;
|
||||
|
|
|
@ -52,6 +52,7 @@ class RouteBuilderProxy : public QObject {
|
|||
Q_INVOKABLE QObject* transform(glm::mat4 transform);
|
||||
Q_INVOKABLE QObject* postTransform(glm::mat4 transform);
|
||||
Q_INVOKABLE QObject* rotate(glm::quat rotation);
|
||||
Q_INVOKABLE QObject* lowVelocity(float rotationConstant, float translationConstant);
|
||||
|
||||
private:
|
||||
void to(const Endpoint::Pointer& destination);
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
//
|
||||
// Created by Dante Ruiz 2017/05/15
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
|
||||
#include "LowVelocityFilter.h"
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
#include "../../UserInputMapper.h"
|
||||
#include "../../Input.h"
|
||||
#include <DependencyManager.h>
|
||||
|
||||
static const QString JSON_ROTATION = QStringLiteral("rotation");
|
||||
static const QString JSON_TRANSLATION = QStringLiteral("translation");
|
||||
namespace controller {
|
||||
|
||||
Pose LowVelocityFilter::apply(Pose newPose) const {
|
||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||
const InputCalibrationData calibrationData = userInputMapper->getInputCalibrationData();
|
||||
glm::mat4 sensorToAvatarMat = glm::inverse(calibrationData.avatarMat) * calibrationData.sensorToWorldMat;
|
||||
glm::mat4 avatarToSensorMat = glm::inverse(calibrationData.sensorToWorldMat) * calibrationData.avatarMat;
|
||||
Pose finalPose = newPose;
|
||||
if (finalPose.isValid() && _oldPose.isValid()) {
|
||||
Pose sensorPose = finalPose.transform(avatarToSensorMat);
|
||||
Pose lastPose = _oldPose;
|
||||
|
||||
float rotationFilter = glm::clamp(1.0f - (glm::length(lastPose.getVelocity() / _rotationConstant)), 0.0f, 1.0f);
|
||||
float translationFilter = glm::clamp(1.0f - (glm::length(lastPose.getVelocity() / _translationConstant)), 0.0f, 1.0f);
|
||||
sensorPose.translation = lastPose.getTranslation() * translationFilter + sensorPose.getTranslation() * (1.0f - translationFilter);
|
||||
sensorPose.rotation = safeMix(lastPose.getRotation(), sensorPose.getRotation(), 1.0f - rotationFilter);
|
||||
|
||||
finalPose = sensorPose.transform(sensorToAvatarMat);
|
||||
}
|
||||
_oldPose = finalPose.transform(avatarToSensorMat);
|
||||
return finalPose;
|
||||
}
|
||||
|
||||
bool LowVelocityFilter::parseParameters(const QJsonValue& parameters) {
|
||||
|
||||
if (parameters.isObject()) {
|
||||
auto obj = parameters.toObject();
|
||||
if (obj.contains(JSON_ROTATION) && obj.contains(JSON_TRANSLATION)) {
|
||||
_rotationConstant = obj[JSON_ROTATION].toDouble();
|
||||
_translationConstant = obj[JSON_TRANSLATION].toDouble();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Created by Dante Ruiz 2017/05/15
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
#ifndef hifi_Controllers_Filters_Low_Velocity_h
|
||||
#define hifi_Controllers_Filters_Low_Velocity_h
|
||||
|
||||
#include "../Filter.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
class LowVelocityFilter : public Filter {
|
||||
REGISTER_FILTER_CLASS(LowVelocityFilter);
|
||||
|
||||
public:
|
||||
LowVelocityFilter() {}
|
||||
LowVelocityFilter(float rotationConstant, float translationConstant) :
|
||||
_translationConstant(translationConstant), _rotationConstant(rotationConstant) {}
|
||||
|
||||
virtual float apply(float value) const override { return value; }
|
||||
virtual Pose apply(Pose newPose) const;
|
||||
virtual bool parseParameters(const QJsonValue& parameters) override;
|
||||
|
||||
private:
|
||||
float _translationConstant { 0.1f };
|
||||
float _rotationConstant { 0.1f };
|
||||
mutable Pose _oldPose { Pose() };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -645,7 +645,7 @@ void OpenGLDisplayPlugin::present() {
|
|||
internalPresent();
|
||||
}
|
||||
|
||||
gpu::Backend::setFreeGPUMemory(gpu::gl::getFreeDedicatedMemory());
|
||||
gpu::Backend::freeGPUMemSize.set(gpu::gl::getFreeDedicatedMemory());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -644,8 +644,6 @@ void GLBackend::recycle() const {
|
|||
ids.reserve(buffersTrash.size());
|
||||
for (auto pair : buffersTrash) {
|
||||
ids.push_back(pair.first);
|
||||
decrementBufferGPUCount();
|
||||
updateBufferGPUMemoryUsage(pair.second, 0);
|
||||
}
|
||||
if (!ids.empty()) {
|
||||
glDeleteBuffers((GLsizei)ids.size(), ids.data());
|
||||
|
@ -678,8 +676,6 @@ void GLBackend::recycle() const {
|
|||
ids.reserve(texturesTrash.size());
|
||||
for (auto pair : texturesTrash) {
|
||||
ids.push_back(pair.first);
|
||||
decrementTextureGPUCount();
|
||||
updateTextureGPUMemoryUsage(pair.second, 0);
|
||||
}
|
||||
if (!ids.empty()) {
|
||||
glDeleteTextures((GLsizei)ids.size(), ids.data());
|
||||
|
|
|
@ -13,6 +13,9 @@ using namespace gpu;
|
|||
using namespace gpu::gl;
|
||||
|
||||
GLBuffer::~GLBuffer() {
|
||||
Backend::bufferCount.decrement();
|
||||
Backend::bufferGPUMemSize.update(_size, 0);
|
||||
|
||||
if (_id) {
|
||||
auto backend = _backend.lock();
|
||||
if (backend) {
|
||||
|
@ -26,7 +29,7 @@ GLBuffer::GLBuffer(const std::weak_ptr<GLBackend>& backend, const Buffer& buffer
|
|||
_size((GLuint)buffer._renderSysmem.getSize()),
|
||||
_stamp(buffer._renderSysmem.getStamp())
|
||||
{
|
||||
Backend::incrementBufferGPUCount();
|
||||
Backend::updateBufferGPUMemoryUsage(0, _size);
|
||||
Backend::bufferCount.increment();
|
||||
Backend::bufferGPUMemSize.update(0, _size);
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,13 @@ GLenum GLTexelFormat::evalGLTexelFormatInternal(const gpu::Element& dstFormat) {
|
|||
case gpu::SRGBA:
|
||||
result = GL_SRGB8_ALPHA8; // standard 2.2 gamma correction color
|
||||
break;
|
||||
|
||||
default:
|
||||
qCWarning(gpugllogging) << "Unknown combination of texel format";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case gpu::TILE4x4: {
|
||||
switch (dstFormat.getSemantic()) {
|
||||
case gpu::COMPRESSED_BC4_RED:
|
||||
result = GL_COMPRESSED_RED_RGTC1;
|
||||
break;
|
||||
|
@ -349,8 +355,31 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E
|
|||
case gpu::SRGBA:
|
||||
texel.internalFormat = GL_SRGB8_ALPHA8;
|
||||
break;
|
||||
default:
|
||||
qCWarning(gpugllogging) << "Unknown combination of texel format";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case gpu::TILE4x4: {
|
||||
texel.format = GL_RGBA;
|
||||
texel.type = ELEMENT_TYPE_TO_GL[srcFormat.getType()];
|
||||
|
||||
switch (srcFormat.getSemantic()) {
|
||||
case gpu::BGRA:
|
||||
case gpu::SBGRA:
|
||||
texel.format = GL_BGRA;
|
||||
break;
|
||||
case gpu::RGB:
|
||||
case gpu::RGBA:
|
||||
case gpu::SRGB:
|
||||
case gpu::SRGBA:
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
switch (dstFormat.getSemantic()) {
|
||||
case gpu::COMPRESSED_BC4_RED:
|
||||
texel.internalFormat = GL_COMPRESSED_RED_RGTC1;
|
||||
break;
|
||||
|
@ -369,7 +398,6 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E
|
|||
case gpu::COMPRESSED_BC7_SRGBA:
|
||||
texel.internalFormat = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM;
|
||||
break;
|
||||
|
||||
default:
|
||||
qCWarning(gpugllogging) << "Unknown combination of texel format";
|
||||
}
|
||||
|
@ -623,7 +651,30 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E
|
|||
case gpu::SRGBA:
|
||||
texel.internalFormat = GL_SRGB8_ALPHA8; // standard 2.2 gamma correction color
|
||||
break;
|
||||
default:
|
||||
qCWarning(gpugllogging) << "Unknown combination of texel format";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case gpu::TILE4x4: {
|
||||
texel.format = GL_RGBA;
|
||||
texel.type = ELEMENT_TYPE_TO_GL[srcFormat.getType()];
|
||||
|
||||
switch (srcFormat.getSemantic()) {
|
||||
case gpu::BGRA:
|
||||
case gpu::SBGRA:
|
||||
texel.format = GL_BGRA;
|
||||
break;
|
||||
case gpu::RGB:
|
||||
case gpu::RGBA:
|
||||
case gpu::SRGB:
|
||||
case gpu::SRGBA:
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
switch (dstFormat.getSemantic()) {
|
||||
case gpu::COMPRESSED_BC4_RED:
|
||||
texel.internalFormat = GL_COMPRESSED_RED_RGTC1;
|
||||
break;
|
||||
|
|
|
@ -115,24 +115,27 @@ GLTexture::~GLTexture() {
|
|||
}
|
||||
}
|
||||
|
||||
void GLTexture::copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const {
|
||||
Size GLTexture::copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const {
|
||||
if (!_gpuObject.isStoredMipFaceAvailable(sourceMip)) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
auto size = _gpuObject.evalMipDimensions(sourceMip);
|
||||
auto dim = _gpuObject.evalMipDimensions(sourceMip);
|
||||
auto mipData = _gpuObject.accessStoredMipFace(sourceMip, face);
|
||||
auto mipSize = _gpuObject.getStoredMipFaceSize(sourceMip, face);
|
||||
if (mipData) {
|
||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
||||
copyMipFaceLinesFromTexture(targetMip, face, size, 0, texelFormat.internalFormat, texelFormat.format, texelFormat.type, mipSize, mipData->readData());
|
||||
return copyMipFaceLinesFromTexture(targetMip, face, dim, 0, texelFormat.internalFormat, texelFormat.format, texelFormat.type, mipSize, mipData->readData());
|
||||
} else {
|
||||
qCDebug(gpugllogging) << "Missing mipData level=" << sourceMip << " face=" << (int)face << " for texture " << _gpuObject.source().c_str();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
GLExternalTexture::GLExternalTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, GLuint id)
|
||||
: Parent(backend, texture, id) { }
|
||||
: Parent(backend, texture, id) {
|
||||
Backend::textureExternalCount.increment();
|
||||
}
|
||||
|
||||
GLExternalTexture::~GLExternalTexture() {
|
||||
auto backend = _backend.lock();
|
||||
|
@ -145,6 +148,7 @@ GLExternalTexture::~GLExternalTexture() {
|
|||
}
|
||||
const_cast<GLuint&>(_id) = 0;
|
||||
}
|
||||
Backend::textureExternalCount.decrement();
|
||||
}
|
||||
|
||||
|
||||
|
@ -211,7 +215,7 @@ TransferJob::TransferJob(const GLTexture& parent, uint16_t sourceMip, uint16_t t
|
|||
_transferSize = bytesPerLine * lines;
|
||||
}
|
||||
|
||||
Backend::updateTextureTransferPendingSize(0, _transferSize);
|
||||
Backend::texturePendingGPUTransferMemSize.update(0, _transferSize);
|
||||
|
||||
if (_transferSize > GLVariableAllocationSupport::MAX_TRANSFER_SIZE) {
|
||||
qCWarning(gpugllogging) << "Transfer size of " << _transferSize << " exceeds theoretical maximum transfer size";
|
||||
|
@ -233,7 +237,7 @@ TransferJob::TransferJob(const GLTexture& parent, std::function<void()> transfer
|
|||
}
|
||||
|
||||
TransferJob::~TransferJob() {
|
||||
Backend::updateTextureTransferPendingSize(_transferSize, 0);
|
||||
Backend::texturePendingGPUTransferMemSize.update(_transferSize, 0);
|
||||
}
|
||||
|
||||
bool TransferJob::tryTransfer() {
|
||||
|
@ -669,3 +673,24 @@ void GLVariableAllocationSupport::executeNextBuffer(const TexturePointer& curren
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GLVariableAllocationSupport::incrementPopulatedSize(Size delta) const {
|
||||
_populatedSize += delta;
|
||||
// Keep the 2 code paths to be able to debug
|
||||
if (_size < _populatedSize) {
|
||||
Backend::textureResourcePopulatedGPUMemSize.update(0, delta);
|
||||
} else {
|
||||
Backend::textureResourcePopulatedGPUMemSize.update(0, delta);
|
||||
}
|
||||
}
|
||||
void GLVariableAllocationSupport::decrementPopulatedSize(Size delta) const {
|
||||
_populatedSize -= delta;
|
||||
// Keep the 2 code paths to be able to debug
|
||||
if (_size < _populatedSize) {
|
||||
Backend::textureResourcePopulatedGPUMemSize.update(delta, 0);
|
||||
} else {
|
||||
Backend::textureResourcePopulatedGPUMemSize.update(delta, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -127,6 +127,14 @@ protected:
|
|||
virtual void promote() = 0;
|
||||
virtual void demote() = 0;
|
||||
|
||||
// THe amount of memory currently allocated
|
||||
Size _size { 0 };
|
||||
|
||||
// The amount of memory currnently populated
|
||||
void incrementPopulatedSize(Size delta) const;
|
||||
void decrementPopulatedSize(Size delta) const;
|
||||
mutable Size _populatedSize { 0 };
|
||||
|
||||
// The allocated mip level, relative to the number of mips in the gpu::Texture object
|
||||
// The relationship between a given glMip to the original gpu::Texture mip is always
|
||||
// glMip + _allocatedMip
|
||||
|
@ -174,8 +182,11 @@ public:
|
|||
protected:
|
||||
virtual Size size() const = 0;
|
||||
virtual void generateMips() const = 0;
|
||||
virtual void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const = 0;
|
||||
virtual void copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const final;
|
||||
virtual void syncSampler() const = 0;
|
||||
|
||||
virtual Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const = 0;
|
||||
virtual Size copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const final;
|
||||
virtual void copyTextureMipsInGPUMem(GLuint srcId, GLuint destId, uint16_t srcMipOffset, uint16_t destMipOffset, uint16_t populatedMips) {} // Only relevant for Variable Allocation textures
|
||||
|
||||
GLTexture(const std::weak_ptr<gl::GLBackend>& backend, const Texture& texture, GLuint id);
|
||||
};
|
||||
|
@ -188,7 +199,8 @@ public:
|
|||
protected:
|
||||
GLExternalTexture(const std::weak_ptr<gl::GLBackend>& backend, const Texture& texture, GLuint id);
|
||||
void generateMips() const override {}
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override {}
|
||||
void syncSampler() const override {}
|
||||
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override { return 0;}
|
||||
|
||||
Size size() const override { return 0; }
|
||||
};
|
||||
|
|
|
@ -54,8 +54,8 @@ public:
|
|||
protected:
|
||||
GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
void generateMips() const override;
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||
virtual void syncSampler() const;
|
||||
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||
void syncSampler() const override;
|
||||
|
||||
void withPreservedTexture(std::function<void()> f) const;
|
||||
};
|
||||
|
@ -92,6 +92,7 @@ public:
|
|||
friend class GL41Backend;
|
||||
protected:
|
||||
GL41StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
~GL41StrictResourceTexture();
|
||||
};
|
||||
|
||||
class GL41VariableAllocationTexture : public GL41Texture, public GLVariableAllocationSupport {
|
||||
|
@ -109,10 +110,13 @@ public:
|
|||
void promote() override;
|
||||
void demote() override;
|
||||
void populateTransferQueue() override;
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||
|
||||
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||
Size copyMipsFromTexture();
|
||||
|
||||
void copyTextureMipsInGPUMem(GLuint srcId, GLuint destId, uint16_t srcMipOffset, uint16_t destMipOffset, uint16_t populatedMips) override;
|
||||
|
||||
Size size() const override { return _size; }
|
||||
Size _size { 0 };
|
||||
};
|
||||
|
||||
class GL41ResourceTexture : public GL41VariableAllocationTexture {
|
||||
|
|
|
@ -76,16 +76,8 @@ using GL41Texture = GL41Backend::GL41Texture;
|
|||
|
||||
GL41Texture::GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture)
|
||||
: GLTexture(backend, texture, allocate(texture)) {
|
||||
incrementTextureGPUCount();
|
||||
}
|
||||
|
||||
GLuint GL41Texture::allocate(const Texture& texture) {
|
||||
GLuint result;
|
||||
glGenTextures(1, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void GL41Texture::withPreservedTexture(std::function<void()> f) const {
|
||||
glActiveTexture(GL_TEXTURE0 + GL41Backend::RESOURCE_TRANSFER_TEX_UNIT);
|
||||
glBindTexture(_target, _texture);
|
||||
|
@ -97,6 +89,14 @@ void GL41Texture::withPreservedTexture(std::function<void()> f) const {
|
|||
}
|
||||
|
||||
|
||||
GLuint GL41Texture::allocate(const Texture& texture) {
|
||||
GLuint result;
|
||||
glGenTextures(1, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GL41Texture::generateMips() const {
|
||||
withPreservedTexture([&] {
|
||||
glGenerateMipmap(_target);
|
||||
|
@ -104,7 +104,8 @@ void GL41Texture::generateMips() const {
|
|||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||
Size GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||
Size amountCopied = sourceSize;
|
||||
if (GL_TEXTURE_2D == _target) {
|
||||
switch (internalFormat) {
|
||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||
|
@ -139,8 +140,10 @@ void GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const
|
|||
}
|
||||
} else {
|
||||
assert(false);
|
||||
amountCopied = 0;
|
||||
}
|
||||
(void)CHECK_GL_ERROR();
|
||||
return amountCopied;
|
||||
}
|
||||
|
||||
void GL41Texture::syncSampler() const {
|
||||
|
@ -212,17 +215,22 @@ void GL41FixedAllocationTexture::syncSampler() const {
|
|||
using GL41AttachmentTexture = GL41Backend::GL41AttachmentTexture;
|
||||
|
||||
GL41AttachmentTexture::GL41AttachmentTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL41FixedAllocationTexture(backend, texture) {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(0, size());
|
||||
Backend::textureFramebufferCount.increment();
|
||||
Backend::textureFramebufferGPUMemSize.update(0, size());
|
||||
}
|
||||
|
||||
GL41AttachmentTexture::~GL41AttachmentTexture() {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(size(), 0);
|
||||
Backend::textureFramebufferCount.decrement();
|
||||
Backend::textureFramebufferGPUMemSize.update(size(), 0);
|
||||
}
|
||||
|
||||
// Strict resource textures
|
||||
using GL41StrictResourceTexture = GL41Backend::GL41StrictResourceTexture;
|
||||
|
||||
GL41StrictResourceTexture::GL41StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL41FixedAllocationTexture(backend, texture) {
|
||||
Backend::textureResidentCount.increment();
|
||||
Backend::textureResidentGPUMemSize.update(0, size());
|
||||
|
||||
withPreservedTexture([&] {
|
||||
|
||||
auto mipLevels = _gpuObject.getNumMips();
|
||||
|
@ -240,11 +248,19 @@ GL41StrictResourceTexture::GL41StrictResourceTexture(const std::weak_ptr<GLBacke
|
|||
}
|
||||
}
|
||||
|
||||
GL41StrictResourceTexture::~GL41StrictResourceTexture() {
|
||||
Backend::textureResidentCount.decrement();
|
||||
Backend::textureResidentGPUMemSize.update(size(), 0);
|
||||
}
|
||||
|
||||
|
||||
using GL41VariableAllocationTexture = GL41Backend::GL41VariableAllocationTexture;
|
||||
|
||||
GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) :
|
||||
GL41Texture(backend, texture)
|
||||
{
|
||||
Backend::textureResourceCount.increment();
|
||||
|
||||
auto mipLevels = texture.getNumMips();
|
||||
_allocatedMip = mipLevels;
|
||||
_maxAllocatedMip = _populatedMip = mipLevels;
|
||||
|
@ -263,18 +279,15 @@ GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr
|
|||
|
||||
allocateStorage(allocatedMip);
|
||||
_memoryPressureStateStale = true;
|
||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
||||
uint16_t targetMip = sourceMip - _allocatedMip;
|
||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||
copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
}
|
||||
}
|
||||
copyMipsFromTexture();
|
||||
|
||||
syncSampler();
|
||||
}
|
||||
|
||||
GL41VariableAllocationTexture::~GL41VariableAllocationTexture() {
|
||||
Backend::updateTextureGPUMemoryUsage(_size, 0);
|
||||
Backend::textureResourceCount.decrement();
|
||||
Backend::textureResourceGPUMemSize.update(_size, 0);
|
||||
Backend::textureResourcePopulatedGPUMemSize.update(_populatedSize, 0);
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) {
|
||||
|
@ -293,14 +306,32 @@ void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) {
|
|||
for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) {
|
||||
_size += _gpuObject.evalMipSize(mip);
|
||||
}
|
||||
Backend::updateTextureGPUMemoryUsage(0, _size);
|
||||
Backend::textureResourceGPUMemSize.update(0, _size);
|
||||
|
||||
}
|
||||
|
||||
Size GL41VariableAllocationTexture::copyMipsFromTexture() {
|
||||
auto mipLevels = _gpuObject.getNumMips();
|
||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||
Size amount = 0;
|
||||
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
||||
uint16_t targetMip = sourceMip - _allocatedMip;
|
||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||
amount += copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
}
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
Size GL41VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||
Size amountCopied = 0;
|
||||
withPreservedTexture([&] {
|
||||
Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
||||
amountCopied = Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
||||
});
|
||||
incrementPopulatedSize(amountCopied);
|
||||
return amountCopied;
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::syncSampler() const {
|
||||
|
@ -433,6 +464,17 @@ void copyCompressedTexGPUMem(const gpu::Texture& texture, GLenum texTarget, GLui
|
|||
glDeleteBuffers(1, &pbo);
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::copyTextureMipsInGPUMem(GLuint srcId, GLuint destId, uint16_t srcMipOffset, uint16_t destMipOffset, uint16_t populatedMips) {
|
||||
uint16_t numMips = _gpuObject.getNumMips();
|
||||
withPreservedTexture([&] {
|
||||
if (_texelFormat.isCompressed()) {
|
||||
copyCompressedTexGPUMem(_gpuObject, _target, srcId, destId, numMips, srcMipOffset, destMipOffset, populatedMips);
|
||||
} else {
|
||||
copyUncompressedTexGPUMem(_gpuObject, _target, srcId, destId, numMips, srcMipOffset, destMipOffset, populatedMips);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::promote() {
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
Q_ASSERT(_allocatedMip > 0);
|
||||
|
@ -451,20 +493,18 @@ void GL41VariableAllocationTexture::promote() {
|
|||
allocateStorage(targetAllocatedMip);
|
||||
|
||||
// copy pre-existing mips
|
||||
uint16_t numMips = _gpuObject.getNumMips();
|
||||
withPreservedTexture([&] {
|
||||
if (_texelFormat.isCompressed()) {
|
||||
copyCompressedTexGPUMem(_gpuObject, _target, oldId, _id, numMips, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
} else {
|
||||
copyUncompressedTexGPUMem(_gpuObject, _target, oldId, _id, numMips, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
}
|
||||
syncSampler();
|
||||
});
|
||||
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
|
||||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
|
||||
// Update sampler
|
||||
syncSampler();
|
||||
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
// no change to Backend::textureResourcePopulatedGPUMemSize
|
||||
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
|
@ -473,6 +513,7 @@ void GL41VariableAllocationTexture::demote() {
|
|||
Q_ASSERT(_allocatedMip < _maxAllocatedMip);
|
||||
auto oldId = _id;
|
||||
auto oldSize = _size;
|
||||
auto oldPopulatedMip = _populatedMip;
|
||||
|
||||
// allocate new texture
|
||||
const_cast<GLuint&>(_id) = allocate(_gpuObject);
|
||||
|
@ -480,22 +521,27 @@ void GL41VariableAllocationTexture::demote() {
|
|||
allocateStorage(_allocatedMip + 1);
|
||||
_populatedMip = std::max(_populatedMip, _allocatedMip);
|
||||
|
||||
// copy pre-existing mips
|
||||
uint16_t numMips = _gpuObject.getNumMips();
|
||||
withPreservedTexture([&] {
|
||||
if (_texelFormat.isCompressed()) {
|
||||
copyCompressedTexGPUMem(_gpuObject, _target, oldId, _id, numMips, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
} else {
|
||||
copyUncompressedTexGPUMem(_gpuObject, _target, oldId, _id, numMips, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
}
|
||||
syncSampler();
|
||||
});
|
||||
|
||||
// copy pre-existing mips
|
||||
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
|
||||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
|
||||
// Update sampler
|
||||
syncSampler();
|
||||
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
// Demoting unpopulate the memory delta
|
||||
if (oldPopulatedMip != _populatedMip) {
|
||||
auto numPopulatedDemoted = _populatedMip - oldPopulatedMip;
|
||||
Size amountUnpopulated = 0;
|
||||
for (int i = 0; i < numPopulatedDemoted; i++) {
|
||||
amountUnpopulated += _gpuObject.evalMipSize(oldPopulatedMip + i);
|
||||
}
|
||||
decrementPopulatedSize(amountUnpopulated);
|
||||
}
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ public:
|
|||
protected:
|
||||
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
void generateMips() const override;
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||
virtual void syncSampler() const;
|
||||
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||
void syncSampler() const override;
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -86,6 +86,7 @@ public:
|
|||
friend class GL45Backend;
|
||||
protected:
|
||||
GL45StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
~GL45StrictResourceTexture();
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -101,8 +102,12 @@ public:
|
|||
protected:
|
||||
GL45VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
~GL45VariableAllocationTexture();
|
||||
|
||||
Size size() const override { return _size; }
|
||||
Size _size { 0 };
|
||||
|
||||
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||
void copyTextureMipsInGPUMem(GLuint srcId, GLuint destId, uint16_t srcMipOffset, uint16_t destMipOffset, uint16_t populatedMips) override;
|
||||
|
||||
};
|
||||
|
||||
class GL45ResourceTexture : public GL45VariableAllocationTexture {
|
||||
|
@ -115,9 +120,10 @@ public:
|
|||
void promote() override;
|
||||
void demote() override;
|
||||
void populateTransferQueue() override;
|
||||
|
||||
|
||||
void allocateStorage(uint16 mip);
|
||||
void copyMipsFromTexture();
|
||||
Size copyMipsFromTexture();
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -116,7 +116,6 @@ using GL45Texture = GL45Backend::GL45Texture;
|
|||
|
||||
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture)
|
||||
: GLTexture(backend, texture, allocate(texture)) {
|
||||
incrementTextureGPUCount();
|
||||
}
|
||||
|
||||
GLuint GL45Texture::allocate(const Texture& texture) {
|
||||
|
@ -134,7 +133,8 @@ void GL45Texture::generateMips() const {
|
|||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||
Size GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||
Size amountCopied = sourceSize;
|
||||
if (GL_TEXTURE_2D == _target) {
|
||||
switch (internalFormat) {
|
||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||
|
@ -179,9 +179,12 @@ void GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
assert(false);
|
||||
amountCopied = 0;
|
||||
}
|
||||
(void)CHECK_GL_ERROR();
|
||||
|
||||
return amountCopied;
|
||||
}
|
||||
|
||||
void GL45Texture::syncSampler() const {
|
||||
|
@ -243,17 +246,22 @@ void GL45FixedAllocationTexture::syncSampler() const {
|
|||
using GL45AttachmentTexture = GL45Backend::GL45AttachmentTexture;
|
||||
|
||||
GL45AttachmentTexture::GL45AttachmentTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45FixedAllocationTexture(backend, texture) {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(0, size());
|
||||
Backend::textureFramebufferCount.increment();
|
||||
Backend::textureFramebufferGPUMemSize.update(0, size());
|
||||
}
|
||||
|
||||
GL45AttachmentTexture::~GL45AttachmentTexture() {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(size(), 0);
|
||||
Backend::textureFramebufferCount.decrement();
|
||||
Backend::textureFramebufferGPUMemSize.update(size(), 0);
|
||||
}
|
||||
|
||||
// Strict resource textures
|
||||
using GL45StrictResourceTexture = GL45Backend::GL45StrictResourceTexture;
|
||||
|
||||
GL45StrictResourceTexture::GL45StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45FixedAllocationTexture(backend, texture) {
|
||||
Backend::textureResidentCount.increment();
|
||||
Backend::textureResidentGPUMemSize.update(0, size());
|
||||
|
||||
auto mipLevels = _gpuObject.getNumMips();
|
||||
for (uint16_t sourceMip = 0; sourceMip < mipLevels; ++sourceMip) {
|
||||
uint16_t targetMip = sourceMip;
|
||||
|
@ -267,3 +275,8 @@ GL45StrictResourceTexture::GL45StrictResourceTexture(const std::weak_ptr<GLBacke
|
|||
}
|
||||
}
|
||||
|
||||
GL45StrictResourceTexture::~GL45StrictResourceTexture() {
|
||||
Backend::textureResidentCount.decrement();
|
||||
Backend::textureResidentGPUMemSize.update(size(), 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,12 +31,46 @@ using GL45VariableAllocationTexture = GL45Backend::GL45VariableAllocationTexture
|
|||
|
||||
GL45VariableAllocationTexture::GL45VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45Texture(backend, texture) {
|
||||
++_frameTexturesCreated;
|
||||
Backend::textureResourceCount.increment();
|
||||
}
|
||||
|
||||
GL45VariableAllocationTexture::~GL45VariableAllocationTexture() {
|
||||
Backend::updateTextureGPUMemoryUsage(_size, 0);
|
||||
Backend::textureResourceCount.decrement();
|
||||
Backend::textureResourceGPUMemSize.update(_size, 0);
|
||||
Backend::textureResourcePopulatedGPUMemSize.update(_populatedSize, 0);
|
||||
}
|
||||
|
||||
Size GL45VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||
Size amountCopied = 0;
|
||||
amountCopied = Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
||||
incrementPopulatedSize(amountCopied);
|
||||
return amountCopied;
|
||||
}
|
||||
|
||||
|
||||
void copyTexGPUMem(const gpu::Texture& texture, GLenum texTarget, GLuint srcId, GLuint destId, uint16_t numMips, uint16_t srcMipOffset, uint16_t destMipOffset, uint16_t populatedMips) {
|
||||
for (uint16_t mip = populatedMips; mip < numMips; ++mip) {
|
||||
auto mipDimensions = texture.evalMipDimensions(mip);
|
||||
uint16_t targetMip = mip - destMipOffset;
|
||||
uint16_t sourceMip = mip - srcMipOffset;
|
||||
auto faces = GLTexture::getFaceCount(texTarget);
|
||||
for (uint8_t face = 0; face < faces; ++face) {
|
||||
glCopyImageSubData(
|
||||
srcId, texTarget, sourceMip, 0, 0, face,
|
||||
destId, texTarget, targetMip, 0, 0, face,
|
||||
mipDimensions.x, mipDimensions.y, 1
|
||||
);
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GL45VariableAllocationTexture::copyTextureMipsInGPUMem(GLuint srcId, GLuint destId, uint16_t srcMipOffset, uint16_t destMipOffset, uint16_t populatedMips) {
|
||||
uint16_t numMips = _gpuObject.getNumMips();
|
||||
copyTexGPUMem(_gpuObject, _target, srcId, destId, numMips, srcMipOffset, destMipOffset, populatedMips);
|
||||
}
|
||||
|
||||
|
||||
// Managed size resource textures
|
||||
using GL45ResourceTexture = GL45Backend::GL45ResourceTexture;
|
||||
|
||||
|
@ -61,7 +95,6 @@ GL45ResourceTexture::GL45ResourceTexture(const std::weak_ptr<GLBackend>& backend
|
|||
_memoryPressureStateStale = true;
|
||||
copyMipsFromTexture();
|
||||
syncSampler();
|
||||
|
||||
}
|
||||
|
||||
void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) {
|
||||
|
@ -76,20 +109,20 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) {
|
|||
for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) {
|
||||
_size += _gpuObject.evalMipSize(mip);
|
||||
}
|
||||
|
||||
Backend::updateTextureGPUMemoryUsage(0, _size);
|
||||
|
||||
Backend::textureResourceGPUMemSize.update(0, _size);
|
||||
}
|
||||
|
||||
void GL45ResourceTexture::copyMipsFromTexture() {
|
||||
Size GL45ResourceTexture::copyMipsFromTexture() {
|
||||
auto mipLevels = _gpuObject.getNumMips();
|
||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||
Size amount = 0;
|
||||
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
||||
uint16_t targetMip = sourceMip - _allocatedMip;
|
||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||
copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
amount += copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
void GL45ResourceTexture::syncSampler() const {
|
||||
|
@ -97,24 +130,6 @@ void GL45ResourceTexture::syncSampler() const {
|
|||
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, _populatedMip - _allocatedMip);
|
||||
}
|
||||
|
||||
|
||||
void copyTexGPUMem(const gpu::Texture& texture, GLenum texTarget, GLuint srcId, GLuint destId, uint16_t numMips, uint16_t srcMipOffset, uint16_t destMipOffset, uint16_t populatedMips) {
|
||||
for (uint16_t mip = populatedMips; mip < numMips; ++mip) {
|
||||
auto mipDimensions = texture.evalMipDimensions(mip);
|
||||
uint16_t targetMip = mip - destMipOffset;
|
||||
uint16_t sourceMip = mip - srcMipOffset;
|
||||
auto faces = GLTexture::getFaceCount(texTarget);
|
||||
for (uint8_t face = 0; face < faces; ++face) {
|
||||
glCopyImageSubData(
|
||||
srcId, texTarget, sourceMip, 0, 0, face,
|
||||
destId, texTarget, targetMip, 0, 0, face,
|
||||
mipDimensions.x, mipDimensions.y, 1
|
||||
);
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GL45ResourceTexture::promote() {
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
Q_ASSERT(_allocatedMip > 0);
|
||||
|
@ -133,14 +148,18 @@ void GL45ResourceTexture::promote() {
|
|||
allocateStorage(targetAllocatedMip);
|
||||
|
||||
// copy pre-existing mips
|
||||
uint16_t numMips = _gpuObject.getNumMips();
|
||||
copyTexGPUMem(_gpuObject, _target, oldId, _id, numMips, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
|
||||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
|
||||
// Update sampler
|
||||
syncSampler();
|
||||
|
||||
// update the memory usage
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
// no change to Backend::textureResourcePopulatedGPUMemSize
|
||||
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
|
@ -149,6 +168,7 @@ void GL45ResourceTexture::demote() {
|
|||
Q_ASSERT(_allocatedMip < _maxAllocatedMip);
|
||||
auto oldId = _id;
|
||||
auto oldSize = _size;
|
||||
auto oldPopulatedMip = _populatedMip;
|
||||
|
||||
// allocate new texture
|
||||
const_cast<GLuint&>(_id) = allocate(_gpuObject);
|
||||
|
@ -157,18 +177,29 @@ void GL45ResourceTexture::demote() {
|
|||
_populatedMip = std::max(_populatedMip, _allocatedMip);
|
||||
|
||||
// copy pre-existing mips
|
||||
uint16_t numMips = _gpuObject.getNumMips();
|
||||
copyTexGPUMem(_gpuObject, _target, oldId, _id, numMips, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
copyTextureMipsInGPUMem(oldId, _id, oldAllocatedMip, _allocatedMip, _populatedMip);
|
||||
|
||||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
|
||||
// Update sampler
|
||||
syncSampler();
|
||||
|
||||
// update the memory usage
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
// Demoting unpopulate the memory delta
|
||||
if (oldPopulatedMip != _populatedMip) {
|
||||
auto numPopulatedDemoted = _populatedMip - oldPopulatedMip;
|
||||
Size amountUnpopulated = 0;
|
||||
for (int i = 0; i < numPopulatedDemoted; i++) {
|
||||
amountUnpopulated += _gpuObject.evalMipSize(oldPopulatedMip + i);
|
||||
}
|
||||
decrementPopulatedSize(amountUnpopulated);
|
||||
}
|
||||
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
|
||||
void GL45ResourceTexture::populateTransferQueue() {
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
if (_populatedMip <= _allocatedMip) {
|
||||
|
|
|
@ -11,47 +11,20 @@
|
|||
|
||||
using namespace gpu;
|
||||
|
||||
std::atomic<uint32_t> Buffer::_bufferCPUCount{ 0 };
|
||||
std::atomic<Buffer::Size> Buffer::_bufferCPUMemoryUsage{ 0 };
|
||||
|
||||
void Buffer::updateBufferCPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (prevObjectSize > newObjectSize) {
|
||||
_bufferCPUMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
} else {
|
||||
_bufferCPUMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::incrementBufferCPUCount() {
|
||||
_bufferCPUCount++;
|
||||
}
|
||||
|
||||
void Buffer::decrementBufferCPUCount() {
|
||||
_bufferCPUCount--;
|
||||
}
|
||||
ContextMetricCount Buffer::_bufferCPUCount;
|
||||
ContextMetricSize Buffer::_bufferCPUMemSize;
|
||||
|
||||
uint32_t Buffer::getBufferCPUCount() {
|
||||
return _bufferCPUCount.load();
|
||||
return _bufferCPUCount.getValue();
|
||||
}
|
||||
|
||||
Buffer::Size Buffer::getBufferCPUMemoryUsage() {
|
||||
return _bufferCPUMemoryUsage.load();
|
||||
}
|
||||
|
||||
uint32_t Buffer::getBufferGPUCount() {
|
||||
return Context::getBufferGPUCount();
|
||||
}
|
||||
|
||||
Buffer::Size Buffer::getBufferGPUMemoryUsage() {
|
||||
return Context::getBufferGPUMemoryUsage();
|
||||
Buffer::Size Buffer::getBufferCPUMemSize() {
|
||||
return _bufferCPUMemSize.getValue();
|
||||
}
|
||||
|
||||
Buffer::Buffer(Size pageSize) :
|
||||
_renderPages(pageSize), _pages(pageSize) {
|
||||
Buffer::incrementBufferCPUCount();
|
||||
_bufferCPUCount.increment();
|
||||
}
|
||||
|
||||
Buffer::Buffer(Size size, const Byte* bytes, Size pageSize) : Buffer(pageSize) {
|
||||
|
@ -69,8 +42,8 @@ Buffer& Buffer::operator=(const Buffer& buf) {
|
|||
}
|
||||
|
||||
Buffer::~Buffer() {
|
||||
Buffer::decrementBufferCPUCount();
|
||||
Buffer::updateBufferCPUMemoryUsage(_sysmem.getSize(), 0);
|
||||
_bufferCPUCount.decrement();
|
||||
_bufferCPUMemSize.update(_sysmem.getSize(), 0);
|
||||
}
|
||||
|
||||
Buffer::Size Buffer::resize(Size size) {
|
||||
|
@ -78,7 +51,7 @@ Buffer::Size Buffer::resize(Size size) {
|
|||
auto prevSize = _sysmem.getSize();
|
||||
if (prevSize < size) {
|
||||
_sysmem.resize(_pages.accommodate(_end));
|
||||
Buffer::updateBufferCPUMemoryUsage(prevSize, _sysmem.getSize());
|
||||
_bufferCPUMemSize.update(prevSize, _sysmem.getSize());
|
||||
}
|
||||
return _end;
|
||||
}
|
||||
|
|
|
@ -21,16 +21,12 @@
|
|||
#include "Resource.h"
|
||||
#include "Sysmem.h"
|
||||
#include "PageManager.h"
|
||||
#include "Metric.h"
|
||||
|
||||
namespace gpu {
|
||||
|
||||
class Buffer : public Resource {
|
||||
static std::atomic<uint32_t> _bufferCPUCount;
|
||||
static std::atomic<Size> _bufferCPUMemoryUsage;
|
||||
static void updateBufferCPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void incrementBufferCPUCount();
|
||||
static void decrementBufferCPUCount();
|
||||
|
||||
static ContextMetricCount _bufferCPUCount;
|
||||
static ContextMetricSize _bufferCPUMemSize;
|
||||
public:
|
||||
using Flag = PageManager::Flag;
|
||||
|
||||
|
@ -50,9 +46,7 @@ public:
|
|||
};
|
||||
|
||||
static uint32_t getBufferCPUCount();
|
||||
static Size getBufferCPUMemoryUsage();
|
||||
static uint32_t getBufferGPUCount();
|
||||
static Size getBufferGPUMemoryUsage();
|
||||
static Size getBufferCPUMemSize();
|
||||
|
||||
Buffer(Size pageSize = PageManager::DEFAULT_PAGE_SIZE);
|
||||
Buffer(Size size, const Byte* bytes, Size pageSize = PageManager::DEFAULT_PAGE_SIZE);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
using namespace gpu;
|
||||
|
||||
|
||||
void ContextStats::evalDelta(const ContextStats& begin, const ContextStats& end) {
|
||||
_ISNumFormatChanges = end._ISNumFormatChanges - begin._ISNumFormatChanges;
|
||||
_ISNumInputBufferChanges = end._ISNumInputBufferChanges - begin._ISNumInputBufferChanges;
|
||||
|
@ -238,213 +237,82 @@ Backend::TransformCamera Backend::TransformCamera::getEyeCamera(int eye, const S
|
|||
}
|
||||
|
||||
// Counters for Buffer and Texture usage in GPU/Context
|
||||
std::atomic<Size> Context::_freeGPUMemory { 0 };
|
||||
std::atomic<uint32_t> Context::_fenceCount { 0 };
|
||||
std::atomic<uint32_t> Context::_bufferGPUCount { 0 };
|
||||
std::atomic<Buffer::Size> Context::_bufferGPUMemoryUsage { 0 };
|
||||
|
||||
std::atomic<uint32_t> Context::_textureGPUCount{ 0 };
|
||||
std::atomic<uint32_t> Context::_textureGPUSparseCount { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureTransferPendingSize { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUVirtualMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUFramebufferMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUSparseMemoryUsage { 0 };
|
||||
std::atomic<uint32_t> Context::_textureGPUTransferCount { 0 };
|
||||
ContextMetricSize Backend::freeGPUMemSize;
|
||||
|
||||
void Context::setFreeGPUMemory(Size size) {
|
||||
_freeGPUMemory.store(size);
|
||||
ContextMetricCount Backend::bufferCount;
|
||||
ContextMetricSize Backend::bufferGPUMemSize;
|
||||
|
||||
ContextMetricCount Backend::textureResidentCount;
|
||||
ContextMetricCount Backend::textureFramebufferCount;
|
||||
ContextMetricCount Backend::textureResourceCount;
|
||||
ContextMetricCount Backend::textureExternalCount;
|
||||
|
||||
ContextMetricSize Backend::textureResidentGPUMemSize;
|
||||
ContextMetricSize Backend::textureFramebufferGPUMemSize;
|
||||
ContextMetricSize Backend::textureResourceGPUMemSize;
|
||||
ContextMetricSize Backend::textureExternalGPUMemSize;
|
||||
|
||||
ContextMetricCount Backend::texturePendingGPUTransferCount;
|
||||
ContextMetricSize Backend::texturePendingGPUTransferMemSize;
|
||||
|
||||
ContextMetricSize Backend::textureResourcePopulatedGPUMemSize;
|
||||
|
||||
Size Context::getFreeGPUMemSize() {
|
||||
return Backend::freeGPUMemSize.getValue();
|
||||
}
|
||||
|
||||
Size Context::getFreeGPUMemory() {
|
||||
return _freeGPUMemory.load();
|
||||
}
|
||||
|
||||
Size Context::getUsedGPUMemory() {
|
||||
return getTextureGPUMemoryUsage() + getBufferGPUMemoryUsage();
|
||||
Size Context::getUsedGPUMemSize() {
|
||||
return getTextureGPUMemSize() + getBufferGPUMemSize();
|
||||
};
|
||||
|
||||
void Context::incrementBufferGPUCount() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_bufferGPUCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
// qCDebug(gpulogging) << "New max GPU buffers " << total;
|
||||
}
|
||||
}
|
||||
void Context::decrementBufferGPUCount() {
|
||||
--_bufferGPUCount;
|
||||
}
|
||||
void Context::updateBufferGPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_bufferGPUMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_bufferGPUMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::incrementFenceCount() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_fenceCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
qCDebug(gpulogging) << "New max Fences " << total;
|
||||
}
|
||||
}
|
||||
void Context::decrementFenceCount() {
|
||||
--_fenceCount;
|
||||
}
|
||||
|
||||
void Context::incrementTextureGPUCount() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_textureGPUCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
// qCDebug(gpulogging) << "New max GPU textures " << total;
|
||||
}
|
||||
}
|
||||
void Context::decrementTextureGPUCount() {
|
||||
--_textureGPUCount;
|
||||
}
|
||||
|
||||
void Context::incrementTextureGPUSparseCount() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_textureGPUSparseCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
// qCDebug(gpulogging) << "New max GPU textures " << total;
|
||||
}
|
||||
}
|
||||
void Context::decrementTextureGPUSparseCount() {
|
||||
--_textureGPUSparseCount;
|
||||
}
|
||||
|
||||
void Context::updateTextureTransferPendingSize(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureTransferPendingSize.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureTransferPendingSize.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureGPUMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureGPUMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUVirtualMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureGPUVirtualMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureGPUVirtualMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUFramebufferMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureGPUFramebufferMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureGPUFramebufferMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUSparseMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureGPUSparseMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureGPUSparseMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::incrementTextureGPUTransferCount() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_textureGPUTransferCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
// qCDebug(gpulogging) << "New max GPU textures transfers" << total;
|
||||
}
|
||||
}
|
||||
|
||||
void Context::decrementTextureGPUTransferCount() {
|
||||
--_textureGPUTransferCount;
|
||||
}
|
||||
|
||||
uint32_t Context::getBufferGPUCount() {
|
||||
return _bufferGPUCount.load();
|
||||
return Backend::bufferCount.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getBufferGPUMemoryUsage() {
|
||||
return _bufferGPUMemoryUsage.load();
|
||||
Context::Size Context::getBufferGPUMemSize() {
|
||||
return Backend::bufferGPUMemSize.getValue();
|
||||
}
|
||||
|
||||
uint32_t Context::getTextureGPUCount() {
|
||||
return _textureGPUCount.load();
|
||||
return getTextureResidentGPUCount() + getTextureResourceGPUCount() + getTextureFramebufferGPUCount();
|
||||
}
|
||||
uint32_t Context::getTextureResidentGPUCount() {
|
||||
return Backend::textureResidentCount.getValue();
|
||||
}
|
||||
uint32_t Context::getTextureFramebufferGPUCount() {
|
||||
return Backend::textureFramebufferCount.getValue();
|
||||
}
|
||||
uint32_t Context::getTextureResourceGPUCount() {
|
||||
return Backend::textureResourceCount.getValue();
|
||||
}
|
||||
uint32_t Context::getTextureExternalGPUCount() {
|
||||
return Backend::textureExternalCount.getValue();
|
||||
}
|
||||
|
||||
uint32_t Context::getTextureGPUSparseCount() {
|
||||
return _textureGPUSparseCount.load();
|
||||
Size Context::getTextureGPUMemSize() {
|
||||
return getTextureResidentGPUMemSize() + getTextureResourceGPUMemSize() + getTextureFramebufferGPUMemSize();
|
||||
}
|
||||
Size Context::getTextureResidentGPUMemSize() {
|
||||
return Backend::textureResidentGPUMemSize.getValue();
|
||||
}
|
||||
Size Context::getTextureFramebufferGPUMemSize() {
|
||||
return Backend::textureFramebufferGPUMemSize.getValue();
|
||||
}
|
||||
Size Context::getTextureResourceGPUMemSize() {
|
||||
return Backend::textureResourceGPUMemSize.getValue();
|
||||
}
|
||||
Size Context::getTextureExternalGPUMemSize() {
|
||||
return Backend::textureExternalGPUMemSize.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureTransferPendingSize() {
|
||||
return _textureTransferPendingSize.load();
|
||||
uint32_t Context::getTexturePendingGPUTransferCount() {
|
||||
return Backend::texturePendingGPUTransferCount.getValue();
|
||||
}
|
||||
Size Context::getTexturePendingGPUTransferMemSize() {
|
||||
return Backend::texturePendingGPUTransferMemSize.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUMemoryUsage() {
|
||||
return _textureGPUMemoryUsage.load();
|
||||
Size Context::getTextureResourcePopulatedGPUMemSize() {
|
||||
return Backend::textureResourcePopulatedGPUMemSize.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUVirtualMemoryUsage() {
|
||||
return _textureGPUVirtualMemoryUsage.load();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUFramebufferMemoryUsage() {
|
||||
return _textureGPUFramebufferMemoryUsage.load();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUSparseMemoryUsage() {
|
||||
return _textureGPUSparseMemoryUsage.load();
|
||||
}
|
||||
|
||||
uint32_t Context::getTextureGPUTransferCount() {
|
||||
return _textureGPUTransferCount.load();
|
||||
}
|
||||
|
||||
void Backend::setFreeGPUMemory(Size size) { Context::setFreeGPUMemory(size); }
|
||||
Resource::Size Backend::getFreeGPUMemory() { return Context::getFreeGPUMemory(); }
|
||||
void Backend::incrementBufferGPUCount() { Context::incrementBufferGPUCount(); }
|
||||
void Backend::decrementBufferGPUCount() { Context::decrementBufferGPUCount(); }
|
||||
void Backend::updateBufferGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateBufferGPUMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::incrementTextureGPUCount() { Context::incrementTextureGPUCount(); }
|
||||
void Backend::decrementTextureGPUCount() { Context::decrementTextureGPUCount(); }
|
||||
void Backend::incrementTextureGPUSparseCount() { Context::incrementTextureGPUSparseCount(); }
|
||||
void Backend::decrementTextureGPUSparseCount() { Context::decrementTextureGPUSparseCount(); }
|
||||
void Backend::updateTextureTransferPendingSize(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureTransferPendingSize(prevObjectSize, newObjectSize); }
|
||||
void Backend::updateTextureGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::updateTextureGPUVirtualMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUVirtualMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::updateTextureGPUFramebufferMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUFramebufferMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::updateTextureGPUSparseMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUSparseMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::incrementTextureGPUTransferCount() { Context::incrementTextureGPUTransferCount(); }
|
||||
void Backend::decrementTextureGPUTransferCount() { Context::decrementTextureGPUTransferCount(); }
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "Forward.h"
|
||||
#include "Batch.h"
|
||||
#include "Resource.h"
|
||||
#include "Buffer.h"
|
||||
#include "Texture.h"
|
||||
#include "Pipeline.h"
|
||||
#include "Framebuffer.h"
|
||||
|
@ -94,24 +94,27 @@ public:
|
|||
|
||||
virtual bool isTextureManagementSparseEnabled() const = 0;
|
||||
|
||||
// These should only be accessed by Backend implementation to repport the buffer and texture allocations,
|
||||
// they are NOT public calls
|
||||
static Resource::Size getFreeGPUMemory();
|
||||
static void setFreeGPUMemory(Resource::Size prevObjectSize);
|
||||
static void incrementBufferGPUCount();
|
||||
static void decrementBufferGPUCount();
|
||||
static void updateBufferGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void incrementTextureGPUCount();
|
||||
static void decrementTextureGPUCount();
|
||||
static void incrementTextureGPUSparseCount();
|
||||
static void decrementTextureGPUSparseCount();
|
||||
static void updateTextureTransferPendingSize(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void updateTextureGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void updateTextureGPUSparseMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void updateTextureGPUVirtualMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void updateTextureGPUFramebufferMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void incrementTextureGPUTransferCount();
|
||||
static void decrementTextureGPUTransferCount();
|
||||
// These should only be accessed by Backend implementation to report the buffer and texture allocations,
|
||||
// they are NOT public objects
|
||||
static ContextMetricSize freeGPUMemSize;
|
||||
|
||||
static ContextMetricCount bufferCount;
|
||||
static ContextMetricSize bufferGPUMemSize;
|
||||
|
||||
static ContextMetricCount textureResidentCount;
|
||||
static ContextMetricCount textureFramebufferCount;
|
||||
static ContextMetricCount textureResourceCount;
|
||||
static ContextMetricCount textureExternalCount;
|
||||
|
||||
static ContextMetricSize textureResidentGPUMemSize;
|
||||
static ContextMetricSize textureFramebufferGPUMemSize;
|
||||
static ContextMetricSize textureResourceGPUMemSize;
|
||||
static ContextMetricSize textureExternalGPUMemSize;
|
||||
|
||||
static ContextMetricCount texturePendingGPUTransferCount;
|
||||
static ContextMetricSize texturePendingGPUTransferMemSize;
|
||||
static ContextMetricSize textureResourcePopulatedGPUMemSize;
|
||||
|
||||
|
||||
protected:
|
||||
virtual bool isStereo() {
|
||||
|
@ -220,19 +223,28 @@ public:
|
|||
double getFrameTimerGPUAverage() const;
|
||||
double getFrameTimerBatchAverage() const;
|
||||
|
||||
static Size getFreeGPUMemSize();
|
||||
static Size getUsedGPUMemSize();
|
||||
|
||||
static uint32_t getBufferGPUCount();
|
||||
static Size getBufferGPUMemoryUsage();
|
||||
static Size getBufferGPUMemSize();
|
||||
|
||||
static uint32_t getTextureGPUCount();
|
||||
static uint32_t getTextureGPUSparseCount();
|
||||
static Size getFreeGPUMemory();
|
||||
static Size getUsedGPUMemory();
|
||||
static Size getTextureTransferPendingSize();
|
||||
static Size getTextureGPUMemoryUsage();
|
||||
static Size getTextureGPUVirtualMemoryUsage();
|
||||
static Size getTextureGPUFramebufferMemoryUsage();
|
||||
static Size getTextureGPUSparseMemoryUsage();
|
||||
static uint32_t getTextureGPUTransferCount();
|
||||
static uint32_t getTextureResidentGPUCount();
|
||||
static uint32_t getTextureFramebufferGPUCount();
|
||||
static uint32_t getTextureResourceGPUCount();
|
||||
static uint32_t getTextureExternalGPUCount();
|
||||
|
||||
static Size getTextureGPUMemSize();
|
||||
static Size getTextureResidentGPUMemSize();
|
||||
static Size getTextureFramebufferGPUMemSize();
|
||||
static Size getTextureResourceGPUMemSize();
|
||||
static Size getTextureExternalGPUMemSize();
|
||||
|
||||
static uint32_t getTexturePendingGPUTransferCount();
|
||||
static Size getTexturePendingGPUTransferMemSize();
|
||||
|
||||
static Size getTextureResourcePopulatedGPUMemSize();
|
||||
|
||||
protected:
|
||||
Context(const Context& context);
|
||||
|
@ -257,44 +269,6 @@ protected:
|
|||
static std::once_flag _initialized;
|
||||
|
||||
friend class Shader;
|
||||
|
||||
// These should only be accessed by the Backend, they are NOT public calls
|
||||
static void incrementBufferGPUCount();
|
||||
static void decrementBufferGPUCount();
|
||||
static void updateBufferGPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
|
||||
static void incrementFenceCount();
|
||||
static void decrementFenceCount();
|
||||
|
||||
static void setFreeGPUMemory(Size size);
|
||||
static void incrementTextureGPUCount();
|
||||
static void decrementTextureGPUCount();
|
||||
static void incrementTextureGPUSparseCount();
|
||||
static void decrementTextureGPUSparseCount();
|
||||
static void updateTextureTransferPendingSize(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUSparseMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUVirtualMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUFramebufferMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void incrementTextureGPUTransferCount();
|
||||
static void decrementTextureGPUTransferCount();
|
||||
|
||||
// Buffer, Texture and Fence Counters
|
||||
static std::atomic<Size> _freeGPUMemory;
|
||||
static std::atomic<uint32_t> _fenceCount;
|
||||
|
||||
static std::atomic<uint32_t> _bufferGPUCount;
|
||||
static std::atomic<Size> _bufferGPUMemoryUsage;
|
||||
|
||||
static std::atomic<uint32_t> _textureGPUCount;
|
||||
static std::atomic<uint32_t> _textureGPUSparseCount;
|
||||
static std::atomic<Size> _textureTransferPendingSize;
|
||||
static std::atomic<Size> _textureGPUMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUSparseMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUVirtualMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUFramebufferMemoryUsage;
|
||||
static std::atomic<uint32_t> _textureGPUTransferCount;
|
||||
|
||||
friend class Backend;
|
||||
};
|
||||
typedef std::shared_ptr<Context> ContextPointer;
|
||||
|
|
|
@ -19,12 +19,12 @@ const Element Element::COLOR_SRGBA_32{ VEC4, NUINT8, SRGBA };
|
|||
const Element Element::COLOR_BGRA_32{ VEC4, NUINT8, BGRA };
|
||||
const Element Element::COLOR_SBGRA_32{ VEC4, NUINT8, SBGRA };
|
||||
|
||||
const Element Element::COLOR_COMPRESSED_RED{ VEC4, NUINT8, COMPRESSED_BC4_RED };
|
||||
const Element Element::COLOR_COMPRESSED_SRGB{ VEC4, NUINT8, COMPRESSED_BC1_SRGB };
|
||||
const Element Element::COLOR_COMPRESSED_SRGBA_MASK{ VEC4, NUINT8, COMPRESSED_BC1_SRGBA };
|
||||
const Element Element::COLOR_COMPRESSED_SRGBA{ VEC4, NUINT8, COMPRESSED_BC3_SRGBA };
|
||||
const Element Element::COLOR_COMPRESSED_XY{ VEC4, NUINT8, COMPRESSED_BC5_XY };
|
||||
const Element Element::COLOR_COMPRESSED_SRGBA_HIGH{ VEC4, NUINT8, COMPRESSED_BC7_SRGBA };
|
||||
const Element Element::COLOR_COMPRESSED_RED{ TILE4x4, COMPRESSED, COMPRESSED_BC4_RED };
|
||||
const Element Element::COLOR_COMPRESSED_SRGB { TILE4x4, COMPRESSED, COMPRESSED_BC1_SRGB };
|
||||
const Element Element::COLOR_COMPRESSED_SRGBA_MASK { TILE4x4, COMPRESSED, COMPRESSED_BC1_SRGBA };
|
||||
const Element Element::COLOR_COMPRESSED_SRGBA { TILE4x4, COMPRESSED, COMPRESSED_BC3_SRGBA };
|
||||
const Element Element::COLOR_COMPRESSED_XY { TILE4x4, COMPRESSED, COMPRESSED_BC5_XY };
|
||||
const Element Element::COLOR_COMPRESSED_SRGBA_HIGH { TILE4x4, COMPRESSED, COMPRESSED_BC7_SRGBA };
|
||||
|
||||
const Element Element::VEC2NU8_XY{ VEC2, NUINT8, XY };
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace gpu {
|
|||
class Backend;
|
||||
|
||||
// Description of a scalar type
|
||||
enum Type {
|
||||
enum Type : uint8_t {
|
||||
|
||||
FLOAT = 0,
|
||||
INT32,
|
||||
|
@ -39,6 +39,8 @@ enum Type {
|
|||
NINT8,
|
||||
NUINT8,
|
||||
|
||||
COMPRESSED,
|
||||
|
||||
NUM_TYPES,
|
||||
|
||||
BOOL = UINT8,
|
||||
|
@ -61,6 +63,8 @@ static const int TYPE_SIZE[NUM_TYPES] = {
|
|||
2,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
|
||||
1
|
||||
};
|
||||
// Array answering the question Does this type is integer or not
|
||||
|
@ -80,11 +84,13 @@ static const bool TYPE_IS_INTEGER[NUM_TYPES] = {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
false,
|
||||
|
||||
false,
|
||||
};
|
||||
|
||||
// Dimension of an Element
|
||||
enum Dimension {
|
||||
enum Dimension : uint8_t {
|
||||
SCALAR = 0,
|
||||
VEC2,
|
||||
VEC3,
|
||||
|
@ -92,11 +98,12 @@ enum Dimension {
|
|||
MAT2,
|
||||
MAT3,
|
||||
MAT4,
|
||||
TILE4x4, // Blob element's size is defined from the type and semantic, it s counted as 1 component
|
||||
NUM_DIMENSIONS,
|
||||
};
|
||||
|
||||
// Count (of scalars) in an Element for a given Dimension
|
||||
static const int LOCATION_COUNT[NUM_DIMENSIONS] = {
|
||||
static const int DIMENSION_LOCATION_COUNT[NUM_DIMENSIONS] = {
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
|
@ -104,10 +111,11 @@ static const int LOCATION_COUNT[NUM_DIMENSIONS] = {
|
|||
1,
|
||||
3,
|
||||
4,
|
||||
1,
|
||||
};
|
||||
|
||||
// Count (of scalars) in an Element for a given Dimension's location
|
||||
static const int SCALAR_COUNT_PER_LOCATION[NUM_DIMENSIONS] = {
|
||||
static const int DIMENSION_SCALAR_COUNT_PER_LOCATION[NUM_DIMENSIONS] = {
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
|
@ -115,10 +123,11 @@ static const int SCALAR_COUNT_PER_LOCATION[NUM_DIMENSIONS] = {
|
|||
4,
|
||||
3,
|
||||
4,
|
||||
1,
|
||||
};
|
||||
|
||||
// Count (of scalars) in an Element for a given Dimension
|
||||
static const int SCALAR_COUNT[NUM_DIMENSIONS] = {
|
||||
static const int DIMENSION_SCALAR_COUNT[NUM_DIMENSIONS] = {
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
|
@ -126,11 +135,24 @@ static const int SCALAR_COUNT[NUM_DIMENSIONS] = {
|
|||
4,
|
||||
9,
|
||||
16,
|
||||
1,
|
||||
};
|
||||
|
||||
// Tile dimension described by the ELement for "Tilexxx" DIMENSIONs
|
||||
static const glm::ivec2 DIMENSION_TILE_DIM[NUM_DIMENSIONS] = {
|
||||
{ 1, 1 },
|
||||
{ 1, 1 },
|
||||
{ 1, 1 },
|
||||
{ 1, 1 },
|
||||
{ 1, 1 },
|
||||
{ 1, 1 },
|
||||
{ 1, 1 },
|
||||
{ 4, 4 },
|
||||
};
|
||||
|
||||
// Semantic of an Element
|
||||
// Provide information on how to use the element
|
||||
enum Semantic {
|
||||
enum Semantic : uint8_t {
|
||||
RAW = 0, // used as RAW memory
|
||||
|
||||
RED,
|
||||
|
@ -156,6 +178,8 @@ enum Semantic {
|
|||
SBGRA,
|
||||
|
||||
// These are generic compression format smeantic for images
|
||||
// THey must be used with Dim = BLOB and Type = Compressed
|
||||
// THe size of a compressed element is defined from the semantic
|
||||
_FIRST_COMPRESSED,
|
||||
|
||||
COMPRESSED_BC1_SRGB,
|
||||
|
@ -175,11 +199,62 @@ enum Semantic {
|
|||
SAMPLER,
|
||||
SAMPLER_MULTISAMPLE,
|
||||
SAMPLER_SHADOW,
|
||||
|
||||
|
||||
NUM_SEMANTICS,
|
||||
|
||||
|
||||
NUM_SEMANTICS, // total Number of semantics (not a valid Semantic)!
|
||||
};
|
||||
|
||||
// Array providing the scaling factor to size in bytes depending on a given semantic
|
||||
static const int SEMANTIC_SIZE_FACTOR[NUM_SEMANTICS] = {
|
||||
1, //RAW = 0, // used as RAW memory
|
||||
|
||||
1, //RED,
|
||||
1, //RGB,
|
||||
1, //RGBA,
|
||||
1, //BGRA,
|
||||
|
||||
1, //XY,
|
||||
1, //XYZ,
|
||||
1, //XYZW,
|
||||
1, //QUAT,
|
||||
1, //UV,
|
||||
1, //INDEX, //used by index buffer of a mesh
|
||||
1, //PART, // used by part buffer of a mesh
|
||||
|
||||
1, //DEPTH, // Depth only buffer
|
||||
1, //STENCIL, // Stencil only buffer
|
||||
1, //DEPTH_STENCIL, // Depth Stencil buffer
|
||||
|
||||
1, //SRED,
|
||||
1, //SRGB,
|
||||
1, //SRGBA,
|
||||
1, //SBGRA,
|
||||
|
||||
// These are generic compression format smeantic for images
|
||||
// THey must be used with Dim = BLOB and Type = Compressed
|
||||
// THe size of a compressed element is defined from the semantic
|
||||
1, //_FIRST_COMPRESSED,
|
||||
|
||||
8, //COMPRESSED_BC1_SRGB, 1/2 byte/pixel * 4x4 pixels = 8 bytes
|
||||
8, //COMPRESSED_BC1_SRGBA, 1/2 byte/pixel * 4x4 pixels = 8 bytes
|
||||
16, //COMPRESSED_BC3_SRGBA, 1 byte/pixel * 4x4 pixels = 16 bytes
|
||||
8, //COMPRESSED_BC4_RED, 1/2 byte/pixel * 4x4 pixels = 8 bytes
|
||||
16, //COMPRESSED_BC5_XY, 1 byte/pixel * 4x4 pixels = 16 bytes
|
||||
16, //COMPRESSED_BC7_SRGBA, 1 byte/pixel * 4x4 pixels = 16 bytes
|
||||
|
||||
1, //_LAST_COMPRESSED,
|
||||
|
||||
1, //R11G11B10,
|
||||
|
||||
1, //UNIFORM,
|
||||
1, //UNIFORM_BUFFER,
|
||||
1, //RESOURCE_BUFFER,
|
||||
1, //SAMPLER,
|
||||
1, //SAMPLER_MULTISAMPLE,
|
||||
1, //SAMPLER_SHADOW,
|
||||
};
|
||||
|
||||
|
||||
// Element is a simple 16bit value that contains everything we need to know about an element
|
||||
// of a buffer, a pixel of a texture, a varying input/output or uniform from a shader pipeline.
|
||||
// Type and dimension of the element, and semantic
|
||||
|
@ -206,12 +281,13 @@ public:
|
|||
bool isNormalized() const { return (getType() >= NORMALIZED_START); }
|
||||
bool isInteger() const { return TYPE_IS_INTEGER[getType()]; }
|
||||
|
||||
uint8 getScalarCount() const { return SCALAR_COUNT[(Dimension)_dimension]; }
|
||||
uint32 getSize() const { return SCALAR_COUNT[_dimension] * TYPE_SIZE[_type]; }
|
||||
uint8 getScalarCount() const { return DIMENSION_SCALAR_COUNT[(Dimension)_dimension]; }
|
||||
uint32 getSize() const { return (DIMENSION_SCALAR_COUNT[_dimension] * TYPE_SIZE[_type] * SEMANTIC_SIZE_FACTOR[_semantic]); }
|
||||
const glm::ivec2& getTile() const { return (DIMENSION_TILE_DIM[_dimension]); }
|
||||
|
||||
uint8 getLocationCount() const { return LOCATION_COUNT[(Dimension)_dimension]; }
|
||||
uint8 getLocationScalarCount() const { return SCALAR_COUNT_PER_LOCATION[(Dimension)_dimension]; }
|
||||
uint32 getLocationSize() const { return SCALAR_COUNT_PER_LOCATION[_dimension] * TYPE_SIZE[_type]; }
|
||||
uint8 getLocationCount() const { return DIMENSION_LOCATION_COUNT[(Dimension)_dimension]; }
|
||||
uint8 getLocationScalarCount() const { return DIMENSION_SCALAR_COUNT_PER_LOCATION[(Dimension)_dimension]; }
|
||||
uint32 getLocationSize() const { return DIMENSION_SCALAR_COUNT_PER_LOCATION[_dimension] * TYPE_SIZE[_type]; }
|
||||
|
||||
uint16 getRaw() const { return *((uint16*) (this)); }
|
||||
|
||||
|
|
64
libraries/gpu/src/gpu/Metric.h
Normal file
64
libraries/gpu/src/gpu/Metric.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// Metric.h
|
||||
// libraries/gpu/src/gpu
|
||||
//
|
||||
// Created by Sam Gateau on 5/17/2017.
|
||||
// Copyright 2017 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
|
||||
//
|
||||
#ifndef hifi_gpu_Metric_h
|
||||
#define hifi_gpu_Metric_h
|
||||
|
||||
#include "Forward.h"
|
||||
|
||||
namespace gpu {
|
||||
|
||||
template <typename T>
|
||||
class Metric {
|
||||
std::atomic<T> _value { 0 };
|
||||
std::atomic<T> _maximum { 0 };
|
||||
|
||||
public:
|
||||
T getValue() { return _value; }
|
||||
T getMaximum() { return _maximum; }
|
||||
|
||||
void set(T newValue) {
|
||||
_value = newValue;
|
||||
}
|
||||
void increment() {
|
||||
auto total = ++_value;
|
||||
if (total > _maximum.load()) {
|
||||
_maximum = total;
|
||||
}
|
||||
}
|
||||
void decrement() {
|
||||
--_value;
|
||||
}
|
||||
|
||||
void update(T prevValue, T newValue) {
|
||||
if (prevValue == newValue) {
|
||||
return;
|
||||
}
|
||||
if (newValue > prevValue) {
|
||||
auto total = _value.fetch_add(newValue - prevValue);
|
||||
if (total > _maximum.load()) {
|
||||
_maximum = total;
|
||||
}
|
||||
} else {
|
||||
_value.fetch_sub(prevValue - newValue);
|
||||
}
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_value = 0;
|
||||
_maximum = 0;
|
||||
}
|
||||
};
|
||||
|
||||
using ContextMetricCount = Metric<uint32_t>;
|
||||
using ContextMetricSize = Metric<Size>;
|
||||
|
||||
}
|
||||
#endif
|
|
@ -42,6 +42,7 @@ protected:
|
|||
|
||||
}
|
||||
|
||||
|
||||
// FIXME Compatibility with headers that rely on Resource.h for the buffer and buffer view definitions
|
||||
#include "Buffer.h"
|
||||
|
||||
|
|
|
@ -31,8 +31,9 @@ using namespace gpu;
|
|||
|
||||
int TexturePointerMetaTypeId = qRegisterMetaType<TexturePointer>();
|
||||
|
||||
std::atomic<uint32_t> Texture::_textureCPUCount{ 0 };
|
||||
std::atomic<Texture::Size> Texture::_textureCPUMemoryUsage{ 0 };
|
||||
|
||||
ContextMetricCount Texture::_textureCPUCount;
|
||||
ContextMetricSize Texture::_textureCPUMemSize;
|
||||
std::atomic<Texture::Size> Texture::_allowedCPUMemoryUsage { 0 };
|
||||
|
||||
|
||||
|
@ -58,61 +59,18 @@ void Texture::setEnableSparseTextures(bool enabled) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void Texture::updateTextureCPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (prevObjectSize > newObjectSize) {
|
||||
_textureCPUMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
} else {
|
||||
_textureCPUMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
bool Texture::getEnableSparseTextures() {
|
||||
return _enableSparseTextures.load();
|
||||
}
|
||||
|
||||
uint32_t Texture::getTextureCPUCount() {
|
||||
return _textureCPUCount.load();
|
||||
return _textureCPUCount.getValue();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureCPUMemoryUsage() {
|
||||
return _textureCPUMemoryUsage.load();
|
||||
Texture::Size Texture::getTextureCPUMemSize() {
|
||||
return _textureCPUMemSize.getValue();
|
||||
}
|
||||
|
||||
uint32_t Texture::getTextureGPUCount() {
|
||||
return Context::getTextureGPUCount();
|
||||
}
|
||||
|
||||
uint32_t Texture::getTextureGPUSparseCount() {
|
||||
return Context::getTextureGPUSparseCount();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureTransferPendingSize() {
|
||||
return Context::getTextureTransferPendingSize();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureGPUMemoryUsage() {
|
||||
return Context::getTextureGPUMemoryUsage();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureGPUVirtualMemoryUsage() {
|
||||
return Context::getTextureGPUVirtualMemoryUsage();
|
||||
}
|
||||
|
||||
|
||||
Texture::Size Texture::getTextureGPUFramebufferMemoryUsage() {
|
||||
return Context::getTextureGPUFramebufferMemoryUsage();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureGPUSparseMemoryUsage() {
|
||||
return Context::getTextureGPUSparseMemoryUsage();
|
||||
}
|
||||
|
||||
uint32_t Texture::getTextureGPUTransferCount() {
|
||||
return Context::getTextureGPUTransferCount();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getAllowedGPUMemoryUsage() {
|
||||
return _allowedCPUMemoryUsage;
|
||||
|
@ -262,11 +220,11 @@ TexturePointer Texture::create(TextureUsageType usageType, Type type, const Elem
|
|||
|
||||
Texture::Texture(TextureUsageType usageType) :
|
||||
Resource(), _usageType(usageType) {
|
||||
_textureCPUCount++;
|
||||
_textureCPUCount.increment();
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
_textureCPUCount--;
|
||||
_textureCPUCount.decrement();
|
||||
if (_usageType == TextureUsageType::EXTERNAL) {
|
||||
Texture::ExternalUpdates externalUpdates;
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "Forward.h"
|
||||
#include "Resource.h"
|
||||
#include "Metric.h"
|
||||
|
||||
const int ABSOLUTE_MAX_TEXTURE_NUM_PIXELS = 8192 * 8192;
|
||||
|
||||
|
@ -167,8 +168,9 @@ enum class TextureUsageType : uint8 {
|
|||
};
|
||||
|
||||
class Texture : public Resource {
|
||||
static std::atomic<uint32_t> _textureCPUCount;
|
||||
static std::atomic<Size> _textureCPUMemoryUsage;
|
||||
static ContextMetricCount _textureCPUCount;
|
||||
static ContextMetricSize _textureCPUMemSize;
|
||||
|
||||
static std::atomic<Size> _allowedCPUMemoryUsage;
|
||||
static std::atomic<bool> _enableSparseTextures;
|
||||
static void updateTextureCPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
|
@ -176,15 +178,8 @@ class Texture : public Resource {
|
|||
public:
|
||||
static const uint32_t CUBE_FACE_COUNT { 6 };
|
||||
static uint32_t getTextureCPUCount();
|
||||
static Size getTextureCPUMemoryUsage();
|
||||
static uint32_t getTextureGPUCount();
|
||||
static uint32_t getTextureGPUSparseCount();
|
||||
static Size getTextureTransferPendingSize();
|
||||
static Size getTextureGPUMemoryUsage();
|
||||
static Size getTextureGPUVirtualMemoryUsage();
|
||||
static Size getTextureGPUFramebufferMemoryUsage();
|
||||
static Size getTextureGPUSparseMemoryUsage();
|
||||
static uint32_t getTextureGPUTransferCount();
|
||||
static Size getTextureCPUMemSize();
|
||||
|
||||
static Size getAllowedGPUMemoryUsage();
|
||||
static void setAllowedGPUMemoryUsage(Size size);
|
||||
|
||||
|
@ -421,32 +416,44 @@ public:
|
|||
// Same but applied to this texture's num max mips from evalNumMips()
|
||||
uint16 safeNumMips(uint16 askedNumMips) const;
|
||||
|
||||
// Eval the size that the mips level SHOULD have
|
||||
// Eval the dimensions & sizes that the mips level SHOULD have
|
||||
// not the one stored in the Texture
|
||||
|
||||
// Dimensions
|
||||
Vec3u evalMipDimensions(uint16 level) const;
|
||||
uint16 evalMipWidth(uint16 level) const { return std::max(_width >> level, 1); }
|
||||
uint16 evalMipHeight(uint16 level) const { return std::max(_height >> level, 1); }
|
||||
uint16 evalMipDepth(uint16 level) const { return std::max(_depth >> level, 1); }
|
||||
|
||||
// The size of a face is a multiple of the padded line = (width * texelFormat_size + alignment padding)
|
||||
Size evalMipLineSize(uint16 level) const { return evalPaddedSize(evalMipWidth(level) * getTexelFormat().getSize()); }
|
||||
// The true size of an image line or surface depends on the format, tiling and padding rules
|
||||
//
|
||||
// Here are the static function to compute the different sizes from parametered dimensions and format
|
||||
// Tile size must be a power of 2
|
||||
static uint16 evalTiledPadding(uint16 length, int tile) { int tileMinusOne = (tile - 1); return (tileMinusOne - (length + tileMinusOne) % tile); }
|
||||
static uint16 evalTiledLength(uint16 length, int tile) { return length / tile + (evalTiledPadding(length, tile) != 0); }
|
||||
static uint16 evalTiledWidth(uint16 width, int tileX) { return evalTiledLength(width, tileX); }
|
||||
static uint16 evalTiledHeight(uint16 height, int tileY) { return evalTiledLength(height, tileY); }
|
||||
static Size evalLineSize(uint16 width, const Element& format) { return evalPaddedSize(evalTiledWidth(width, format.getTile().x) * format.getSize()); }
|
||||
static Size evalSurfaceSize(uint16 width, uint16 height, const Element& format) { return evalLineSize(width, format) * evalTiledHeight(height, format.getTile().x); }
|
||||
|
||||
// Size for each face of a mip at a particular level
|
||||
uint32 evalMipFaceNumTexels(uint16 level) const { return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level); }
|
||||
Size evalMipFaceSize(uint16 level) const { return evalMipLineSize(level) * evalMipHeight(level) * evalMipDepth(level); }
|
||||
|
||||
// Total size for the mip
|
||||
uint32 evalMipNumTexels(uint16 level) const { return evalMipFaceNumTexels(level) * getNumFaces(); }
|
||||
Size evalMipSize(uint16 level) const { return evalMipFaceSize(level) * getNumFaces(); }
|
||||
// Compute the theorical size of the texture elements storage depending on the specified format
|
||||
Size evalStoredMipLineSize(uint16 level, const Element& format) const { return evalLineSize(evalMipWidth(level), format); }
|
||||
Size evalStoredMipSurfaceSize(uint16 level, const Element& format) const { return evalSurfaceSize(evalMipWidth(level), evalMipHeight(level), format); }
|
||||
Size evalStoredMipFaceSize(uint16 level, const Element& format) const { return evalStoredMipSurfaceSize(level, format) * evalMipDepth(level); }
|
||||
Size evalStoredMipSize(uint16 level, const Element& format) const { return evalStoredMipFaceSize(level, format) * getNumFaces(); }
|
||||
|
||||
// For this texture's texel format and dimensions, compute the various mem sizes
|
||||
Size evalMipLineSize(uint16 level) const { return evalStoredMipLineSize(level, getTexelFormat()); }
|
||||
Size evalMipSurfaceSize(uint16 level) const { return evalStoredMipSurfaceSize(level, getTexelFormat()); }
|
||||
Size evalMipFaceSize(uint16 level) const { return evalStoredMipFaceSize(level, getTexelFormat()); }
|
||||
Size evalMipSize(uint16 level) const { return evalStoredMipSize(level, getTexelFormat()); }
|
||||
|
||||
// Total size for all the mips of the texture
|
||||
Size evalTotalSize(uint16 startingMip = 0) const;
|
||||
|
||||
// Compute the theorical size of the texture elements storage depending on the specified format
|
||||
Size evalStoredMipLineSize(uint16 level, const Element& format) const { return evalPaddedSize(evalMipWidth(level) * format.getSize()); }
|
||||
Size evalStoredMipFaceSize(uint16 level, const Element& format) const { return evalMipFaceNumTexels(level) * format.getSize(); }
|
||||
Size evalStoredMipSize(uint16 level, const Element& format) const { return evalMipNumTexels(level) * format.getSize(); }
|
||||
// Number of texels (not it s not directly proprtional to the size!
|
||||
uint32 evalMipFaceNumTexels(uint16 level) const { return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level); }
|
||||
uint32 evalMipNumTexels(uint16 level) const { return evalMipFaceNumTexels(level) * getNumFaces(); }
|
||||
|
||||
// For convenience assign a source name
|
||||
const std::string& source() const { return _source; }
|
||||
|
|
|
@ -239,7 +239,7 @@ void ObjectMotionState::handleEasyChanges(uint32_t& flags) {
|
|||
}
|
||||
}
|
||||
|
||||
if (_body->getCollisionShape()->getShapeType() != TRIANGLE_MESH_SHAPE_PROXYTYPE) {
|
||||
if (_body && _body->getCollisionShape()->getShapeType() != TRIANGLE_MESH_SHAPE_PROXYTYPE) {
|
||||
if (flags & Simulation::DIRTY_LINEAR_VELOCITY) {
|
||||
btVector3 newLinearVelocity = glmToBullet(getObjectLinearVelocity());
|
||||
if (!(flags & Simulation::DIRTY_PHYSICS_ACTIVATION)) {
|
||||
|
|
|
@ -24,16 +24,29 @@ void EngineStats::run(const RenderContextPointer& renderContext) {
|
|||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||
|
||||
config->bufferCPUCount = gpu::Buffer::getBufferCPUCount();
|
||||
config->bufferGPUCount = gpu::Buffer::getBufferGPUCount();
|
||||
config->bufferCPUMemoryUsage = gpu::Buffer::getBufferCPUMemoryUsage();
|
||||
config->bufferGPUMemoryUsage = gpu::Buffer::getBufferGPUMemoryUsage();
|
||||
config->bufferGPUCount = gpu::Context::getBufferGPUCount();
|
||||
config->bufferCPUMemSize = gpu::Buffer::getBufferCPUMemSize();
|
||||
config->bufferGPUMemSize = gpu::Context::getBufferGPUMemSize();
|
||||
|
||||
config->textureCPUCount = gpu::Texture::getTextureCPUCount();
|
||||
config->textureGPUCount = gpu::Texture::getTextureGPUCount();
|
||||
config->textureCPUMemoryUsage = gpu::Texture::getTextureCPUMemoryUsage();
|
||||
config->textureGPUMemoryUsage = gpu::Texture::getTextureGPUMemoryUsage();
|
||||
config->textureGPUVirtualMemoryUsage = gpu::Texture::getTextureGPUVirtualMemoryUsage();
|
||||
config->textureGPUTransferCount = gpu::Texture::getTextureGPUTransferCount();
|
||||
config->textureGPUCount = gpu::Context::getTextureGPUCount();
|
||||
config->textureCPUMemSize = gpu::Texture::getTextureCPUMemSize();
|
||||
config->textureGPUMemSize = gpu::Context::getTextureGPUMemSize();
|
||||
|
||||
config->textureResidentGPUCount = gpu::Context::getTextureResidentGPUCount();
|
||||
config->textureFramebufferGPUCount = gpu::Context::getTextureFramebufferGPUCount();
|
||||
config->textureResourceGPUCount = gpu::Context::getTextureResourceGPUCount();
|
||||
config->textureExternalGPUCount = gpu::Context::getTextureExternalGPUCount();
|
||||
|
||||
config->textureResidentGPUMemSize = gpu::Context::getTextureResidentGPUMemSize();
|
||||
config->textureFramebufferGPUMemSize = gpu::Context::getTextureFramebufferGPUMemSize();
|
||||
config->textureResourceGPUMemSize = gpu::Context::getTextureResourceGPUMemSize();
|
||||
config->textureExternalGPUMemSize = gpu::Context::getTextureExternalGPUMemSize();
|
||||
|
||||
config->texturePendingGPUTransferCount = gpu::Context::getTexturePendingGPUTransferCount();
|
||||
config->texturePendingGPUTransferSize = gpu::Context::getTexturePendingGPUTransferMemSize();
|
||||
|
||||
config->textureResourcePopulatedGPUMemSize = gpu::Context::getTextureResourcePopulatedGPUMemSize();
|
||||
|
||||
renderContext->args->_context->getFrameStats(_gpuStats);
|
||||
|
||||
|
|
|
@ -26,15 +26,26 @@ namespace render {
|
|||
|
||||
Q_PROPERTY(quint32 bufferCPUCount MEMBER bufferCPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 bufferGPUCount MEMBER bufferGPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 bufferCPUMemoryUsage MEMBER bufferCPUMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 bufferGPUMemoryUsage MEMBER bufferGPUMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 bufferCPUMemSize MEMBER bufferCPUMemSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 bufferGPUMemSize MEMBER bufferGPUMemSize NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(quint32 textureCPUCount MEMBER textureCPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 textureGPUCount MEMBER textureGPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureCPUMemoryUsage MEMBER textureCPUMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureGPUMemoryUsage MEMBER textureGPUMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureGPUVirtualMemoryUsage MEMBER textureGPUVirtualMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 textureGPUTransferCount MEMBER textureGPUTransferCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 textureResidentGPUCount MEMBER textureResidentGPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 textureFramebufferGPUCount MEMBER textureFramebufferGPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 textureResourceGPUCount MEMBER textureResourceGPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 textureExternalGPUCount MEMBER textureExternalGPUCount NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(qint64 textureCPUMemSize MEMBER textureCPUMemSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureGPUMemSize MEMBER textureGPUMemSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureResidentGPUMemSize MEMBER textureResidentGPUMemSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureFramebufferGPUMemSize MEMBER textureFramebufferGPUMemSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureResourceGPUMemSize MEMBER textureResourceGPUMemSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureExternalGPUMemSize MEMBER textureExternalGPUMemSize NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(quint32 texturePendingGPUTransferCount MEMBER texturePendingGPUTransferCount NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 texturePendingGPUTransferSize MEMBER texturePendingGPUTransferSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureResourcePopulatedGPUMemSize MEMBER textureResourcePopulatedGPUMemSize NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(quint32 frameAPIDrawcallCount MEMBER frameAPIDrawcallCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 frameDrawcallCount MEMBER frameDrawcallCount NOTIFY dirty)
|
||||
|
@ -56,15 +67,25 @@ namespace render {
|
|||
|
||||
quint32 bufferCPUCount{ 0 };
|
||||
quint32 bufferGPUCount{ 0 };
|
||||
qint64 bufferCPUMemoryUsage{ 0 };
|
||||
qint64 bufferGPUMemoryUsage{ 0 };
|
||||
qint64 bufferCPUMemSize { 0 };
|
||||
qint64 bufferGPUMemSize { 0 };
|
||||
|
||||
quint32 textureCPUCount{ 0 };
|
||||
quint32 textureGPUCount{ 0 };
|
||||
qint64 textureCPUMemoryUsage{ 0 };
|
||||
qint64 textureGPUMemoryUsage{ 0 };
|
||||
qint64 textureGPUVirtualMemoryUsage{ 0 };
|
||||
quint32 textureGPUTransferCount{ 0 };
|
||||
quint32 textureGPUCount { 0 };
|
||||
quint32 textureResidentGPUCount { 0 };
|
||||
quint32 textureFramebufferGPUCount { 0 };
|
||||
quint32 textureResourceGPUCount { 0 };
|
||||
quint32 textureExternalGPUCount { 0 };
|
||||
quint32 texturePendingGPUTransferCount { 0 };
|
||||
|
||||
qint64 textureCPUMemSize { 0 };
|
||||
qint64 textureGPUMemSize { 0 };
|
||||
qint64 textureResidentGPUMemSize { 0 };
|
||||
qint64 textureFramebufferGPUMemSize { 0 };
|
||||
qint64 textureResourceGPUMemSize { 0 };
|
||||
qint64 textureExternalGPUMemSize { 0 };
|
||||
qint64 texturePendingGPUTransferSize { 0 };
|
||||
qint64 textureResourcePopulatedGPUMemSize { 0 };
|
||||
|
||||
quint32 frameAPIDrawcallCount{ 0 };
|
||||
quint32 frameDrawcallCount{ 0 };
|
||||
|
|
|
@ -421,6 +421,12 @@ QString ScriptEngine::getFilename() const {
|
|||
return lastPart;
|
||||
}
|
||||
|
||||
bool ScriptEngine::hasValidScriptSuffix(const QString& scriptFileName) {
|
||||
QFileInfo fileInfo(scriptFileName);
|
||||
QString scriptSuffixToLower = fileInfo.completeSuffix().toLower();
|
||||
return scriptSuffixToLower.contains(QString("js"), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
|
||||
if (_isRunning) {
|
||||
return;
|
||||
|
@ -430,6 +436,13 @@ void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
|
|||
_fileNameString = url.toString();
|
||||
_isReloading = reload;
|
||||
|
||||
// Check that script has a supported file extension
|
||||
if (!hasValidScriptSuffix(_fileNameString)) {
|
||||
scriptErrorMessage("File extension of file: " + _fileNameString + " is not a currently supported script type");
|
||||
emit errorLoadingScript(_fileNameString);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto maxRetries = 0; // for consistency with previous scriptCache->getScript() behavior
|
||||
auto scriptCache = DependencyManager::get<ScriptCache>();
|
||||
scriptCache->getScriptContents(url.toString(), [this](const QString& url, const QString& scriptContents, bool isURL, bool success, const QString&status) {
|
||||
|
|
|
@ -146,6 +146,7 @@ public:
|
|||
/// to run... NOTE - this is used by Application currently to load the url. We don't really want it to be exposed
|
||||
/// to scripts. we may not need this to be invokable
|
||||
void loadURL(const QUrl& scriptURL, bool reload);
|
||||
bool hasValidScriptSuffix(const QString& scriptFileName);
|
||||
|
||||
Q_INVOKABLE QString getContext() const;
|
||||
Q_INVOKABLE bool isClientScript() const { return _context == CLIENT_SCRIPT; }
|
||||
|
|
|
@ -163,12 +163,15 @@ void ViveControllerManager::pluginUpdate(float deltaTime, const controller::Inpu
|
|||
}
|
||||
|
||||
ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) : controller::InputDevice("Vive"), _system(system) {
|
||||
createPreferences();
|
||||
|
||||
_configStringMap[Config::Auto] = QString("Auto");
|
||||
_configStringMap[Config::Feet] = QString("Feet");
|
||||
_configStringMap[Config::FeetAndHips] = QString("FeetAndHips");
|
||||
_configStringMap[Config::FeetHipsAndChest] = QString("FeetHipsAndChest");
|
||||
|
||||
if (openVrSupported()) {
|
||||
createPreferences();
|
||||
}
|
||||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||
|
|
21
scripts/developer/utilities/render/textureMonitor.js
Normal file
21
scripts/developer/utilities/render/textureMonitor.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// textureMonitor.js
|
||||
// examples/utilities/tools/render
|
||||
//
|
||||
// Sam Gateau, created on 3/22/2016.
|
||||
// Copyright 2016 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
|
||||
//
|
||||
|
||||
// Set up the qml ui
|
||||
var qml = Script.resolvePath('textureMonitor.qml');
|
||||
var window = new OverlayWindow({
|
||||
title: 'Textures',
|
||||
source: qml,
|
||||
width: 320,
|
||||
height: 300,
|
||||
});
|
||||
window.setPosition(500, 50);
|
||||
window.closed.connect(function() { Script.stop(); });
|
78
scripts/developer/utilities/render/textureMonitor.qml
Normal file
78
scripts/developer/utilities/render/textureMonitor.qml
Normal file
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// texture monitor.qml
|
||||
// examples/utilities/render
|
||||
//
|
||||
// Created by Sam Gateau on 5/17/2017
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import "../lib/plotperf"
|
||||
|
||||
|
||||
Item {
|
||||
id: texMex
|
||||
anchors.fill:parent
|
||||
|
||||
Column {
|
||||
id: stats
|
||||
spacing: 8
|
||||
anchors.fill:parent
|
||||
|
||||
property var config: Render.getConfig("Stats")
|
||||
|
||||
function evalEvenHeight() {
|
||||
// Why do we have to do that manually ? cannot seem to find a qml / anchor / layout mode that does that ?
|
||||
return (height - spacing * (children.length - 1)) / children.length
|
||||
}
|
||||
PlotPerf {
|
||||
title: "gpu::Texture Memory"
|
||||
height: parent.evalEvenHeight()
|
||||
object: stats.config
|
||||
valueScale: 1048576
|
||||
valueUnit: "Mb"
|
||||
valueNumDigits: "1"
|
||||
plots: [
|
||||
{
|
||||
prop: "textureCPUMemSize",
|
||||
label: "CPU",
|
||||
color: "#00B4EF"
|
||||
},
|
||||
{
|
||||
prop: "textureGPUMemSize",
|
||||
label: "GPU",
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
{
|
||||
prop: "textureResidentGPUMemSize",
|
||||
label: "Resident",
|
||||
color: "#A2277C"
|
||||
},
|
||||
{
|
||||
prop: "textureFramebufferGPUMemSize",
|
||||
label: "Framebuffer",
|
||||
color: "#EF93D1"
|
||||
},
|
||||
{
|
||||
prop: "textureResourceGPUMemSize",
|
||||
label: "Resource",
|
||||
color: "#1FC6A6"
|
||||
},
|
||||
{
|
||||
prop: "textureResourcePopulatedGPUMemSize",
|
||||
label: "Populated",
|
||||
color: "#C6A61F"
|
||||
},
|
||||
{
|
||||
prop: "texturePendingGPUTransferSize",
|
||||
label: "Transfer",
|
||||
color: "#FF6309"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -753,8 +753,8 @@ private:
|
|||
void updateText() {
|
||||
QString title = QString("FPS %1 Culling %2 TextureMemory GPU %3 CPU %4 Max GPU %5")
|
||||
.arg(_fps).arg(_cullingEnabled)
|
||||
.arg(toHumanSize(gpu::Context::getTextureGPUMemoryUsage(), 2))
|
||||
.arg(toHumanSize(gpu::Texture::getTextureCPUMemoryUsage(), 2))
|
||||
.arg(toHumanSize(gpu::Context::getTextureGPUMemSize(), 2))
|
||||
.arg(toHumanSize(gpu::Texture::getTextureCPUMemSize(), 2))
|
||||
.arg(toHumanSize(gpu::Texture::getAllowedGPUMemoryUsage(), 2));
|
||||
setTitle(title);
|
||||
#if 0
|
||||
|
|
Loading…
Reference in a new issue