Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laszlo Agocs
qtrhi
Commits
89c843d9
Commit
89c843d9
authored
Jan 03, 2019
by
Laszlo Agocs
Browse files
vk: minimal sendVMemStatsToProfiler implementation
parent
4a2d50c2
Changes
7
Hide whitespace changes
Inline
Side-by-side
examples/rhi/plainqwindow_vulkan/main.cpp
View file @
89c843d9
...
...
@@ -53,6 +53,14 @@
#include <QRhiVulkanInitParams>
#include "examplewindow.h"
#define PROFILE
#ifdef PROFILE
#include <QRhiProfiler>
#include <QFile>
QFile
profOut
;
#endif
class
VWindow
:
public
ExampleWindow
{
public:
...
...
@@ -69,7 +77,16 @@ void VWindow::init()
params
.
inst
=
vulkanInstance
();
params
.
importExistingDevice
=
false
;
params
.
window
=
this
;
m_r
=
QRhi
::
create
(
QRhi
::
Vulkan
,
&
params
);
QRhi
::
Flags
flags
=
QRhi
::
EnableDebugMarkers
;
#ifdef PROFILE
flags
|=
QRhi
::
EnableProfiling
;
#endif
m_r
=
QRhi
::
create
(
QRhi
::
Vulkan
,
&
params
,
flags
);
#ifdef PROFILE
m_r
->
profiler
()
->
setDevice
(
&
profOut
);
#endif
//setSampleCount(4); // enable 4x MSAA (except for the render-to-texture pass)
...
...
@@ -100,6 +117,10 @@ int main(int argc, char **argv)
VWindow
w
;
if
(
inst
.
create
())
{
#ifdef PROFILE
profOut
.
setFileName
(
"rhiprof.cbor"
);
profOut
.
open
(
QIODevice
::
WriteOnly
);
#endif
w
.
setVulkanInstance
(
&
inst
);
w
.
resize
(
1280
,
720
);
w
.
setTitle
(
QLatin1String
(
"Vulkan"
));
...
...
examples/rhi/shared/examplewindow.cpp
View file @
89c843d9
...
...
@@ -50,6 +50,7 @@
#include "examplewindow.h"
#include <QFileInfo>
#include <QRhiProfiler>
//#define USE_SRGB_SWAPCHAIN
//#define READBACK_SWAPCHAIN
...
...
@@ -151,6 +152,10 @@ void ExampleWindow::init()
m_liveTexCubeRenderer
.
initResources
(
m_scrp
);
m_liveTexCubeRenderer
.
setTranslation
(
QVector3D
(
-
2.0
f
,
0
,
0
));
}
// Put the gpu mem allocator statistics to the profiling stream after doing
// all the init. (where applicable)
m_r
->
profiler
()
->
addVMemAllocatorStats
();
}
void
ExampleWindow
::
releaseResources
()
...
...
src/rhi/qrhiprofiler.cpp
View file @
89c843d9
...
...
@@ -304,4 +304,19 @@ void QRhiProfilerPrivate::releaseSwapChain(QRhiSwapChain *sc)
writer
->
endMap
();
}
void
QRhiProfilerPrivate
::
vmemStat
(
int
realAllocCount
,
int
subAllocCount
,
quint32
totalSize
,
quint32
unusedSize
)
{
if
(
!
ensureStream
())
return
;
writer
->
startMap
();
WRITE_OP
(
VMemAllocStats
);
WRITE_TIMESTAMP
;
WRITE_PAIR
(
QLatin1String
(
"realAllocCount"
),
realAllocCount
);
WRITE_PAIR
(
QLatin1String
(
"subAllocCount"
),
subAllocCount
);
WRITE_PAIR
(
QLatin1String
(
"totalSize"
),
totalSize
);
WRITE_PAIR
(
QLatin1String
(
"unusedSize"
),
unusedSize
);
writer
->
endMap
();
}
QT_END_NAMESPACE
src/rhi/qrhiprofiler.h
View file @
89c843d9
...
...
@@ -59,7 +59,8 @@ public:
NewTextureStagingArea
,
ReleaseTextureStagingArea
,
ResizeSwapChain
,
ReleaseSwapChain
ReleaseSwapChain
,
VMemAllocStats
};
QRhiProfiler
();
...
...
src/rhi/qrhiprofiler_p.h
View file @
89c843d9
...
...
@@ -72,6 +72,8 @@ public:
void
resizeSwapChain
(
QRhiSwapChain
*
sc
,
int
bufferCount
,
int
msaaBufferCount
,
int
sampleCount
);
void
releaseSwapChain
(
QRhiSwapChain
*
sc
);
void
vmemStat
(
int
realAllocCount
,
int
subAllocCount
,
quint32
totalSize
,
quint32
unusedSize
);
bool
ensureStream
();
void
flushStream
();
...
...
src/rhi/qrhivulkan.cpp
View file @
89c843d9
...
...
@@ -2648,9 +2648,14 @@ const QRhiNativeHandles *QRhiVulkan::nativeHandles()
void
QRhiVulkan
::
sendVMemStatsToProfiler
()
{
QRhiProfilerPrivate
*
rhiP
=
profilerPrivateOrNull
();
if
(
!
rhiP
)
return
;
VmaStats
stats
;
vmaCalculateStats
(
toVmaAllocator
(
allocator
),
&
stats
);
// ###
QRHI_PROF_F
(
vmemStat
(
stats
.
total
.
blockCount
,
stats
.
total
.
allocationCount
,
stats
.
total
.
usedBytes
,
stats
.
total
.
unusedBytes
));
}
QRhiRenderBuffer
*
QRhiVulkan
::
createRenderBuffer
(
QRhiRenderBuffer
::
Type
type
,
const
QSize
&
pixelSize
,
...
...
todo.txt
View file @
89c843d9
d3d: texture import/export
prof api
vk, d3d, gl: tex and other prof
vk: memalloc stats to prof
vk, d3d, gl: debug: object names
vk, d3d, gl: debug: markers (begin, end, msg)
max texture size?
...
...
@@ -54,6 +53,7 @@ dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done
vk: memalloc stats to prof
mtl: debug: markers (begin, end, msg)
mtl: debug: object names
mtl: buf/tex/rb/sc prof
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment