mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 20:06:02 +02:00
Merge and many more counters
This commit is contained in:
parent
3f844d7a82
commit
9fb1a9a2a8
14 changed files with 219 additions and 55 deletions
|
@ -13,8 +13,8 @@ import QtQuick.Controls 1.4
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
width: 400
|
|
||||||
height: 100
|
height: 100
|
||||||
|
property string title
|
||||||
property var config
|
property var config
|
||||||
property string parameters
|
property string parameters
|
||||||
|
|
||||||
|
@ -24,14 +24,15 @@ Item {
|
||||||
property var valueScale: +inputs[0]
|
property var valueScale: +inputs[0]
|
||||||
property var valueUnit: inputs[1]
|
property var valueUnit: inputs[1]
|
||||||
property var valueNumDigits: inputs[2]
|
property var valueNumDigits: inputs[2]
|
||||||
|
property var input_VALUE_OFFSET: 3
|
||||||
property var valueMax : 1
|
property var valueMax : 1
|
||||||
|
|
||||||
property var _values : new Array()
|
property var _values : new Array()
|
||||||
property var tick : 0
|
property var tick : 0
|
||||||
|
|
||||||
function createValues() {
|
function createValues() {
|
||||||
if (inputs.length > 3) {
|
if (inputs.length > input_VALUE_OFFSET) {
|
||||||
for (var i = 3; i < inputs.length; i++) {
|
for (var i = input_VALUE_OFFSET; i < inputs.length; i++) {
|
||||||
var varProps = inputs[i].split("-")
|
var varProps = inputs[i].split("-")
|
||||||
_values.push( {
|
_values.push( {
|
||||||
value: varProps[1],
|
value: varProps[1],
|
||||||
|
@ -83,25 +84,26 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onTriggerChanged: pullFreshValues()
|
onTriggerChanged: pullFreshValues()
|
||||||
|
|
||||||
Canvas {
|
Canvas {
|
||||||
id: mycanvas
|
id: mycanvas
|
||||||
width: 300
|
anchors.fill:parent
|
||||||
height: 100
|
|
||||||
onPaint: {
|
onPaint: {
|
||||||
|
var lineHeight = 12;
|
||||||
|
|
||||||
function displayValue(val) {
|
function displayValue(val) {
|
||||||
return (val / root.valueScale).toFixed(root.valueNumDigits) + " " + root.valueUnit
|
return (val / root.valueScale).toFixed(root.valueNumDigits) + " " + root.valueUnit
|
||||||
}
|
}
|
||||||
|
|
||||||
function pixelFromVal(val) {
|
function pixelFromVal(val) {
|
||||||
return height * (1 - (0.9) * val / valueMax);
|
return lineHeight + (height - lineHeight) * (1 - (0.9) * val / valueMax);
|
||||||
}
|
}
|
||||||
function plotValueHistory(ctx, valHistory, color) {
|
function plotValueHistory(ctx, valHistory, color) {
|
||||||
var widthStep= width / (valHistory.length - 1);
|
var widthStep= width / (valHistory.length - 1);
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.strokeStyle= color; // Green path
|
ctx.strokeStyle= color; // Green path
|
||||||
ctx.lineWidth="4";
|
ctx.lineWidth="2";
|
||||||
ctx.moveTo(0, pixelFromVal(valHistory[i]));
|
ctx.moveTo(0, pixelFromVal(valHistory[i]));
|
||||||
|
|
||||||
for (var i = 1; i < valHistory.length; i++) {
|
for (var i = 1; i < valHistory.length; i++) {
|
||||||
|
@ -110,21 +112,38 @@ Item {
|
||||||
|
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
function plotValueLegend(ctx, val, num) {
|
function displayValueLegend(ctx, val, num) {
|
||||||
var lineHeight = 12;
|
ctx.fillStyle = val.color;
|
||||||
ctx.font="14px Verdana";
|
var bestValue = val.valueHistory[val.valueHistory.length -1];
|
||||||
ctx.fillStyle = val.color;
|
ctx.textAlign = "right";
|
||||||
ctx.fillText(displayValue(val.valueHistory[val.valueHistory.length -1]), 0, height - num * lineHeight);
|
ctx.fillText(displayValue(bestValue), width, height - num * lineHeight);
|
||||||
|
ctx.textAlign = "left";
|
||||||
|
ctx.fillText(val.label, 0, height - num * lineHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayTitle(ctx, text, maxVal) {
|
||||||
|
ctx.fillStyle = "grey";
|
||||||
|
ctx.textAlign = "right";
|
||||||
|
ctx.fillText(displayValue(maxVal), width, lineHeight);
|
||||||
|
|
||||||
|
ctx.fillStyle = "white";
|
||||||
|
ctx.textAlign = "left";
|
||||||
|
ctx.fillText(text, 0, lineHeight);
|
||||||
|
}
|
||||||
|
|
||||||
var ctx = getContext("2d");
|
var ctx = getContext("2d");
|
||||||
ctx.clearRect(0, 0, width, height);
|
ctx.clearRect(0, 0, width, height);
|
||||||
ctx.fillStyle = Qt.rgba(0, 0, 0, 0.4);
|
ctx.fillStyle = Qt.rgba(0, 0, 0, 0.4);
|
||||||
ctx.fillRect(0, 0, width, height);
|
ctx.fillRect(0, 0, width, height);
|
||||||
|
|
||||||
|
ctx.font="12px Verdana";
|
||||||
|
|
||||||
for (var i = 0; i < _values.length; i++) {
|
for (var i = 0; i < _values.length; i++) {
|
||||||
plotValueHistory(ctx, _values[i].valueHistory, _values[i].color)
|
plotValueHistory(ctx, _values[i].valueHistory, _values[i].color)
|
||||||
plotValueLegend(ctx, _values[i], i)
|
displayValueLegend(ctx, _values[i], i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayTitle(ctx, title, valueMax)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ var qml = Script.resolvePath('stats.qml');
|
||||||
var window = new OverlayWindow({
|
var window = new OverlayWindow({
|
||||||
title: 'Render Stats',
|
title: 'Render Stats',
|
||||||
source: qml,
|
source: qml,
|
||||||
width: 300
|
width: 300,
|
||||||
|
height: 200
|
||||||
});
|
});
|
||||||
window.setPosition(500, 50);
|
window.setPosition(500, 50);
|
||||||
window.closed.connect(function() { Script.stop(); });
|
window.closed.connect(function() { Script.stop(); });
|
|
@ -13,20 +13,39 @@ import QtQuick.Controls 1.4
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
id: statsUI
|
||||||
|
width: 300
|
||||||
spacing: 8
|
spacing: 8
|
||||||
Column {
|
Column {
|
||||||
spacing: 4
|
spacing: 8
|
||||||
|
|
||||||
id: stats
|
|
||||||
property var config: Render.getConfig("Stats")
|
property var config: Render.getConfig("Stats")
|
||||||
|
id: stats
|
||||||
|
|
||||||
PlotPerf {
|
PlotPerf {
|
||||||
|
title: "Num Buffers"
|
||||||
|
width:statsUI.width
|
||||||
config: stats.config
|
config: stats.config
|
||||||
parameters: "1::0:num Textures-numTextures-blue:num GPU Textures-numGPUTextures-green"
|
parameters: "1::0:CPU-numBuffers-#00B4EF:GPU-numGPUBuffers-#1AC567"
|
||||||
}
|
}
|
||||||
PlotPerf {
|
PlotPerf {
|
||||||
|
title: "Memory Usage"
|
||||||
|
width:statsUI.width
|
||||||
config: stats.config
|
config: stats.config
|
||||||
parameters: "1048576:Mb:1:Sysmem-textureSysmemUsage-blue:Vidmem-textureVidmemUsage-green"
|
parameters: "1048576:Mb:1:CPU-bufferSysmemUsage-#00B4EF:GPU-bufferVidmemUsage-#1AC567"
|
||||||
|
}
|
||||||
|
|
||||||
|
PlotPerf {
|
||||||
|
title: "Num Textures"
|
||||||
|
width:statsUI.width
|
||||||
|
config: stats.config
|
||||||
|
parameters: "1::0:CPU-numTextures-#00B4EF:GPU-numGPUTextures-#1AC567:Frame-numFrameTextures-#E2334D"
|
||||||
|
}
|
||||||
|
PlotPerf {
|
||||||
|
title: "Memory Usage"
|
||||||
|
width:statsUI.width
|
||||||
|
config: stats.config
|
||||||
|
parameters: "1048576:Mb:1:CPU-textureSysmemUsage-#00B4EF:GPU-textureVidmemUsage-#1AC567"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,11 @@ void Context::downloadFramebuffer(const FramebufferPointer& srcFramebuffer, cons
|
||||||
_backend->downloadFramebuffer(srcFramebuffer, region, destImage);
|
_backend->downloadFramebuffer(srcFramebuffer, region, destImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Context::getStats(ContextStats& stats) const {
|
||||||
|
_backend->getStats(stats);
|
||||||
|
}
|
||||||
|
|
||||||
const Backend::TransformCamera& Backend::TransformCamera::recomputeDerived(const Transform& xformView) const {
|
const Backend::TransformCamera& Backend::TransformCamera::recomputeDerived(const Transform& xformView) const {
|
||||||
_projectionInverse = glm::inverse(_projection);
|
_projectionInverse = glm::inverse(_projection);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,21 @@ class QImage;
|
||||||
|
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
|
|
||||||
|
struct ContextStats {
|
||||||
|
public:
|
||||||
|
int _ISNumFormatChanges = 0;
|
||||||
|
int _ISNumInputBufferChanges = 0;
|
||||||
|
int _ISNumIndexBufferChanges = 0;
|
||||||
|
|
||||||
|
int _RSNumTextureBounded = 0;
|
||||||
|
|
||||||
|
int _DSNumDrawcalls = 0;
|
||||||
|
int _DSNumTriangles = 0;
|
||||||
|
|
||||||
|
ContextStats() {}
|
||||||
|
ContextStats(const ContextStats& stats) = default;
|
||||||
|
};
|
||||||
|
|
||||||
struct StereoState {
|
struct StereoState {
|
||||||
bool _enable{ false };
|
bool _enable{ false };
|
||||||
bool _skybox{ false };
|
bool _skybox{ false };
|
||||||
|
@ -100,9 +115,11 @@ public:
|
||||||
return reinterpret_cast<T*>(object.gpuObject.getGPUObject());
|
return reinterpret_cast<T*>(object.gpuObject.getGPUObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getStats(ContextStats& stats) const { stats = _stats; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StereoState _stereo;
|
StereoState _stereo;
|
||||||
|
ContextStats _stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Context {
|
class Context {
|
||||||
|
@ -125,6 +142,7 @@ public:
|
||||||
~Context();
|
~Context();
|
||||||
|
|
||||||
void render(Batch& batch);
|
void render(Batch& batch);
|
||||||
|
|
||||||
void enableStereo(bool enable = true);
|
void enableStereo(bool enable = true);
|
||||||
bool isStereo();
|
bool isStereo();
|
||||||
void setStereoProjections(const mat4 eyeProjections[2]);
|
void setStereoProjections(const mat4 eyeProjections[2]);
|
||||||
|
@ -137,6 +155,9 @@ public:
|
||||||
// It s here for convenience to easily capture a snapshot
|
// It s here for convenience to easily capture a snapshot
|
||||||
void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage);
|
void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage);
|
||||||
|
|
||||||
|
// Repporting stats of the context
|
||||||
|
void getStats(ContextStats& stats) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Context(const Context& context);
|
Context(const Context& context);
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
|
|
||||||
GLBuffer();
|
GLBuffer();
|
||||||
~GLBuffer();
|
~GLBuffer();
|
||||||
|
|
||||||
|
void setSize(GLuint size);
|
||||||
};
|
};
|
||||||
static GLBuffer* syncGPUObject(const Buffer& buffer);
|
static GLBuffer* syncGPUObject(const Buffer& buffer);
|
||||||
static GLuint getBufferID(const Buffer& buffer);
|
static GLuint getBufferID(const Buffer& buffer);
|
||||||
|
@ -234,26 +236,11 @@ public:
|
||||||
void do_setStateBlend(State::BlendFunction blendFunction);
|
void do_setStateBlend(State::BlendFunction blendFunction);
|
||||||
|
|
||||||
void do_setStateColorWriteMask(uint32 mask);
|
void do_setStateColorWriteMask(uint32 mask);
|
||||||
|
|
||||||
// Repporting stats of the context
|
|
||||||
class Stats {
|
|
||||||
public:
|
|
||||||
int _ISNumFormatChanges = 0;
|
|
||||||
int _ISNumInputBufferChanges = 0;
|
|
||||||
int _ISNumIndexBufferChanges = 0;
|
|
||||||
|
|
||||||
Stats() {}
|
|
||||||
Stats(const Stats& stats) = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
void getStats(Stats& stats) const { stats = _stats; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void renderPassTransfer(Batch& batch);
|
void renderPassTransfer(Batch& batch);
|
||||||
void renderPassDraw(Batch& batch);
|
void renderPassDraw(Batch& batch);
|
||||||
|
|
||||||
Stats _stats;
|
|
||||||
|
|
||||||
// Draw Stage
|
// Draw Stage
|
||||||
void do_draw(Batch& batch, size_t paramOffset);
|
void do_draw(Batch& batch, size_t paramOffset);
|
||||||
void do_drawIndexed(Batch& batch, size_t paramOffset);
|
void do_drawIndexed(Batch& batch, size_t paramOffset);
|
||||||
|
|
|
@ -16,12 +16,29 @@ GLBackend::GLBuffer::GLBuffer() :
|
||||||
_stamp(0),
|
_stamp(0),
|
||||||
_buffer(0),
|
_buffer(0),
|
||||||
_size(0)
|
_size(0)
|
||||||
{}
|
{
|
||||||
|
Buffer::_numGPUBuffers++;
|
||||||
|
}
|
||||||
|
|
||||||
GLBackend::GLBuffer::~GLBuffer() {
|
GLBackend::GLBuffer::~GLBuffer() {
|
||||||
if (_buffer != 0) {
|
if (_buffer != 0) {
|
||||||
glDeleteBuffers(1, &_buffer);
|
glDeleteBuffers(1, &_buffer);
|
||||||
}
|
}
|
||||||
|
Buffer::_bufferVideoMemoryUsage.fetch_sub(_size);
|
||||||
|
Buffer::_numGPUBuffers--;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLBackend::GLBuffer::setSize(GLuint size) {
|
||||||
|
if (_size == size) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (size > _size) {
|
||||||
|
Buffer::_bufferVideoMemoryUsage.fetch_add(size - _size);
|
||||||
|
} else {
|
||||||
|
Buffer::_bufferVideoMemoryUsage.fetch_sub(_size - size);
|
||||||
|
}
|
||||||
|
|
||||||
|
_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLBackend::GLBuffer* GLBackend::syncGPUObject(const Buffer& buffer) {
|
GLBackend::GLBuffer* GLBackend::syncGPUObject(const Buffer& buffer) {
|
||||||
|
@ -46,7 +63,7 @@ GLBackend::GLBuffer* GLBackend::syncGPUObject(const Buffer& buffer) {
|
||||||
glBufferData(GL_ARRAY_BUFFER, buffer.getSysmem().getSize(), buffer.getSysmem().readData(), GL_DYNAMIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, buffer.getSysmem().getSize(), buffer.getSysmem().readData(), GL_DYNAMIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
object->_stamp = buffer.getSysmem().getStamp();
|
object->_stamp = buffer.getSysmem().getStamp();
|
||||||
object->_size = (GLuint)buffer.getSysmem().getSize();
|
object->setSize((GLuint)buffer.getSysmem().getSize());
|
||||||
//}
|
//}
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,9 @@ void GLBackend::do_setResourceTexture(Batch& batch, size_t paramOffset) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// One more True texture bound
|
||||||
|
_stats._RSNumTextureBounded++;
|
||||||
|
|
||||||
// Always make sure the GLObject is in sync
|
// Always make sure the GLObject is in sync
|
||||||
GLTexture* object = GLBackend::syncGPUObject(*resourceTexture);
|
GLTexture* object = GLBackend::syncGPUObject(*resourceTexture);
|
||||||
if (object) {
|
if (object) {
|
||||||
|
|
|
@ -232,19 +232,66 @@ Resource::Size Resource::Sysmem::append(Size size, const Byte* bytes) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::atomic<int> Buffer::_numBuffers{ 0 };
|
||||||
|
std::atomic<int> Buffer::_numGPUBuffers{ 0 };
|
||||||
|
std::atomic<unsigned long long> Buffer::_bufferSystemMemoryUsage{ 0 };
|
||||||
|
std::atomic<unsigned long long> Buffer::_bufferVideoMemoryUsage{ 0 };
|
||||||
|
|
||||||
|
|
||||||
|
int Buffer::getCurrentNumBuffers() {
|
||||||
|
return _numBuffers.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer::Size Buffer::getCurrentSystemMemoryUsage() {
|
||||||
|
return _bufferSystemMemoryUsage.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
int Buffer::getCurrentNumGPUBuffers() {
|
||||||
|
return _numGPUBuffers.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer::Size Buffer::getCurrentVideoMemoryUsage() {
|
||||||
|
return _bufferVideoMemoryUsage.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Buffer::addSystemMemoryUsage(Size memorySize) {
|
||||||
|
_bufferSystemMemoryUsage.fetch_add(memorySize);
|
||||||
|
}
|
||||||
|
void Buffer::subSystemMemoryUsage(Size memorySize) {
|
||||||
|
_bufferSystemMemoryUsage.fetch_sub(memorySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Buffer::updateSystemMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||||
|
if (prevObjectSize == newObjectSize) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (prevObjectSize > newObjectSize) {
|
||||||
|
subSystemMemoryUsage(prevObjectSize - newObjectSize);
|
||||||
|
} else {
|
||||||
|
addSystemMemoryUsage(newObjectSize - prevObjectSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Buffer::Buffer() :
|
Buffer::Buffer() :
|
||||||
Resource(),
|
Resource(),
|
||||||
_sysmem(new Sysmem()) {
|
_sysmem(new Sysmem()) {
|
||||||
|
_numBuffers++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::Buffer(Size size, const Byte* bytes) :
|
Buffer::Buffer(Size size, const Byte* bytes) :
|
||||||
Resource(),
|
Resource(),
|
||||||
_sysmem(new Sysmem(size, bytes)) {
|
_sysmem(new Sysmem(size, bytes)) {
|
||||||
|
_numBuffers++;
|
||||||
|
Buffer::updateSystemMemoryUsage(0, _sysmem->getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::Buffer(const Buffer& buf) :
|
Buffer::Buffer(const Buffer& buf) :
|
||||||
Resource(),
|
Resource(),
|
||||||
_sysmem(new Sysmem(buf.getSysmem())) {
|
_sysmem(new Sysmem(buf.getSysmem())) {
|
||||||
|
_numBuffers++;
|
||||||
|
Buffer::updateSystemMemoryUsage(0, _sysmem->getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer& Buffer::operator=(const Buffer& buf) {
|
Buffer& Buffer::operator=(const Buffer& buf) {
|
||||||
|
@ -253,18 +300,27 @@ Buffer& Buffer::operator=(const Buffer& buf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::~Buffer() {
|
Buffer::~Buffer() {
|
||||||
|
_numBuffers--;
|
||||||
|
|
||||||
if (_sysmem) {
|
if (_sysmem) {
|
||||||
|
Buffer::updateSystemMemoryUsage(_sysmem->getSize(), 0);
|
||||||
delete _sysmem;
|
delete _sysmem;
|
||||||
_sysmem = NULL;
|
_sysmem = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::Size Buffer::resize(Size size) {
|
Buffer::Size Buffer::resize(Size size) {
|
||||||
return editSysmem().resize(size);
|
auto prevSize = editSysmem().getSize();
|
||||||
|
auto newSize = editSysmem().resize(size);
|
||||||
|
Buffer::updateSystemMemoryUsage(prevSize, newSize);
|
||||||
|
return newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::Size Buffer::setData(Size size, const Byte* data) {
|
Buffer::Size Buffer::setData(Size size, const Byte* data) {
|
||||||
return editSysmem().setData(size, data);
|
auto prevSize = editSysmem().getSize();
|
||||||
|
auto newSize = editSysmem().setData(size, data);
|
||||||
|
Buffer::updateSystemMemoryUsage(prevSize, newSize);
|
||||||
|
return newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::Size Buffer::setSubData(Size offset, Size size, const Byte* data) {
|
Buffer::Size Buffer::setSubData(Size offset, Size size, const Byte* data) {
|
||||||
|
@ -272,6 +328,9 @@ Buffer::Size Buffer::setSubData(Size offset, Size size, const Byte* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::Size Buffer::append(Size size, const Byte* data) {
|
Buffer::Size Buffer::append(Size size, const Byte* data) {
|
||||||
return editSysmem().append( size, data);
|
auto prevSize = editSysmem().getSize();
|
||||||
|
auto newSize = editSysmem().append( size, data);
|
||||||
|
Buffer::updateSystemMemoryUsage(prevSize, newSize);
|
||||||
|
return newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -109,7 +110,21 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
class Buffer : public Resource {
|
class Buffer : public Resource {
|
||||||
|
static std::atomic<int> _numBuffers;
|
||||||
|
static std::atomic<Size> _bufferSystemMemoryUsage;
|
||||||
public:
|
public:
|
||||||
|
static std::atomic<int> _numGPUBuffers;
|
||||||
|
static std::atomic<Size> _bufferVideoMemoryUsage;
|
||||||
|
private:
|
||||||
|
static void addSystemMemoryUsage(Size memorySize);
|
||||||
|
static void subSystemMemoryUsage(Size memorySize);
|
||||||
|
static void updateSystemMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static int getCurrentNumBuffers();
|
||||||
|
static Size getCurrentSystemMemoryUsage();
|
||||||
|
static int getCurrentNumGPUBuffers();
|
||||||
|
static Size getCurrentVideoMemoryUsage();
|
||||||
|
|
||||||
Buffer();
|
Buffer();
|
||||||
Buffer(Size size, const Byte* bytes);
|
Buffer(Size size, const Byte* bytes);
|
||||||
|
|
|
@ -57,13 +57,6 @@ void Texture::updateSystemMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::addVideoMemoryUsage(Size memorySize) {
|
|
||||||
_textureVideoMemoryUsage.fetch_add(memorySize);
|
|
||||||
}
|
|
||||||
void Texture::subVideoMemoryUsage(Size memorySize) {
|
|
||||||
_textureVideoMemoryUsage.fetch_sub(memorySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8 Texture::NUM_FACES_PER_TYPE[NUM_TYPES] = {1, 1, 1, 6};
|
uint8 Texture::NUM_FACES_PER_TYPE[NUM_TYPES] = {1, 1, 1, 6};
|
||||||
|
|
||||||
Texture::Pixels::Pixels(const Element& format, Size size, const Byte* bytes) :
|
Texture::Pixels::Pixels(const Element& format, Size size, const Byte* bytes) :
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include <algorithm> //min max and more
|
#include <algorithm> //min max and more
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
@ -149,9 +148,6 @@ private:
|
||||||
static void subSystemMemoryUsage(Size memorySize);
|
static void subSystemMemoryUsage(Size memorySize);
|
||||||
static void updateSystemMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
static void updateSystemMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||||
|
|
||||||
static void addVideoMemoryUsage(Size memorySize);
|
|
||||||
static void subVideoMemoryUsage(Size memorySize);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static int getCurrentNumTextures();
|
static int getCurrentNumTextures();
|
||||||
|
|
|
@ -67,10 +67,22 @@ void EngineStats::run(const SceneContextPointer& sceneContext, const RenderConte
|
||||||
// Update the stats
|
// Update the stats
|
||||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||||
|
|
||||||
|
config->numBuffers = gpu::Buffer::getCurrentNumBuffers();
|
||||||
|
config->numGPUBuffers = gpu::Buffer::getCurrentNumGPUBuffers();
|
||||||
|
config->bufferSysmemUsage = gpu::Buffer::getCurrentSystemMemoryUsage();
|
||||||
|
config->bufferVidmemUsage = gpu::Buffer::getCurrentVideoMemoryUsage();
|
||||||
|
|
||||||
config->numTextures = gpu::Texture::getCurrentNumTextures();
|
config->numTextures = gpu::Texture::getCurrentNumTextures();
|
||||||
config->textureSysmemUsage = gpu::Texture::getCurrentSystemMemoryUsage();
|
|
||||||
config->numGPUTextures = gpu::Texture::getCurrentNumGPUTextures();
|
config->numGPUTextures = gpu::Texture::getCurrentNumGPUTextures();
|
||||||
|
config->textureSysmemUsage = gpu::Texture::getCurrentSystemMemoryUsage();
|
||||||
config->textureVidmemUsage = gpu::Texture::getCurrentVideoMemoryUsage();
|
config->textureVidmemUsage = gpu::Texture::getCurrentVideoMemoryUsage();
|
||||||
|
|
||||||
|
gpu::ContextStats gpuStats(_gpuStats);
|
||||||
|
renderContext->args->_context->getStats(_gpuStats);
|
||||||
|
|
||||||
|
config->numFrameTextures = _gpuStats._RSNumTextureBounded - gpuStats._RSNumTextureBounded;
|
||||||
|
|
||||||
|
config->numFrameTriangles = _gpuStats._DSNumTriangles - gpuStats._DSNumTriangles;
|
||||||
|
|
||||||
config->emitDirty();
|
config->emitDirty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
#define hifi_render_Engine_h
|
#define hifi_render_Engine_h
|
||||||
|
|
||||||
#include <SettingHandle.h>
|
#include <SettingHandle.h>
|
||||||
|
#include <gpu/Context.h>
|
||||||
|
|
||||||
#include "Context.h"
|
#include "Context.h"
|
||||||
#include "Task.h"
|
#include "Task.h"
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
// The render engine holds all render tasks, and is itself a render task.
|
// The render engine holds all render tasks, and is itself a render task.
|
||||||
|
@ -53,18 +53,33 @@ namespace render {
|
||||||
// A simple job collecting global stats on the Engine / Scene / GPU
|
// A simple job collecting global stats on the Engine / Scene / GPU
|
||||||
class EngineStatsConfig : public Job::Config{
|
class EngineStatsConfig : public Job::Config{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int numTextures MEMBER numTextures NOTIFY dirty)
|
|
||||||
Q_PROPERTY(int numGPUTextures MEMBER numGPUTextures NOTIFY dirty)
|
Q_PROPERTY(int numBuffers MEMBER numBuffers NOTIFY dirty)
|
||||||
|
Q_PROPERTY(int numGPUBuffers MEMBER numGPUBuffers NOTIFY dirty)
|
||||||
|
Q_PROPERTY(qint64 bufferSysmemUsage MEMBER bufferSysmemUsage NOTIFY dirty)
|
||||||
|
Q_PROPERTY(qint64 bufferVidmemUsage MEMBER bufferVidmemUsage NOTIFY dirty)
|
||||||
|
|
||||||
|
Q_PROPERTY(int numTextures MEMBER numTextures NOTIFY dirty)
|
||||||
|
Q_PROPERTY(int numGPUTextures MEMBER numGPUTextures NOTIFY dirty)
|
||||||
Q_PROPERTY(qint64 textureSysmemUsage MEMBER textureSysmemUsage NOTIFY dirty)
|
Q_PROPERTY(qint64 textureSysmemUsage MEMBER textureSysmemUsage NOTIFY dirty)
|
||||||
Q_PROPERTY(qint64 textureVidmemUsage MEMBER textureVidmemUsage NOTIFY dirty)
|
Q_PROPERTY(qint64 textureVidmemUsage MEMBER textureVidmemUsage NOTIFY dirty)
|
||||||
|
Q_PROPERTY(int numFrameTextures MEMBER numFrameTextures NOTIFY dirty)
|
||||||
public:
|
public:
|
||||||
EngineStatsConfig() : Job::Config(true) {}
|
EngineStatsConfig() : Job::Config(true) {}
|
||||||
|
|
||||||
|
int numBuffers{ 0 };
|
||||||
|
int numGPUBuffers{ 0 };
|
||||||
|
qint64 bufferSysmemUsage{ 0 };
|
||||||
|
qint64 bufferVidmemUsage{ 0 };
|
||||||
|
|
||||||
int numTextures{ 0 };
|
int numTextures{ 0 };
|
||||||
int numGPUTextures{ 0 };
|
int numGPUTextures{ 0 };
|
||||||
qint64 textureSysmemUsage{ 0 };
|
qint64 textureSysmemUsage{ 0 };
|
||||||
qint64 textureVidmemUsage{ 0 };
|
qint64 textureVidmemUsage{ 0 };
|
||||||
|
|
||||||
|
int numFrameTriangles{ 0 };
|
||||||
|
int numFrameTextures{ 0 };
|
||||||
|
|
||||||
void emitDirty() { emit dirty(); }
|
void emitDirty() { emit dirty(); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -78,6 +93,8 @@ namespace render {
|
||||||
|
|
||||||
EngineStats() {}
|
EngineStats() {}
|
||||||
|
|
||||||
|
gpu::ContextStats _gpuStats;
|
||||||
|
|
||||||
void configure(const Config& configuration) {}
|
void configure(const Config& configuration) {}
|
||||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext);
|
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue