Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Laszlo Agocs
qtrhi
Commits
a6da1449
Commit
a6da1449
authored
Jan 03, 2019
by
Laszlo Agocs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtl: Add support for buffer/texture object names
Exercise in trianglerenderer
parent
30a28699
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
6 deletions
+36
-6
examples/rhi/plainqwindow_metal/main.cpp
examples/rhi/plainqwindow_metal/main.cpp
+3
-3
examples/rhi/shared/trianglerenderer.cpp
examples/rhi/shared/trianglerenderer.cpp
+2
-0
src/rhi/qrhi.cpp
src/rhi/qrhi.cpp
+10
-0
src/rhi/qrhi.h
src/rhi/qrhi.h
+9
-2
src/rhi/qrhimetal.mm
src/rhi/qrhimetal.mm
+8
-0
todo.txt
todo.txt
+4
-1
No files found.
examples/rhi/plainqwindow_metal/main.cpp
View file @
a6da1449
...
...
@@ -73,11 +73,11 @@ private:
void
MetalWindow
::
init
()
{
QRhiMetalInitParams
params
;
m_r
=
QRhi
::
create
(
QRhi
::
Metal
,
&
params
QRhi
::
Flags
flags
=
QRhi
::
EnableDebugMarkers
;
#ifdef PROFILE
,
QRhi
::
EnableProfiling
flags
|=
QRhi
::
EnableProfiling
;
#endif
);
m_r
=
QRhi
::
create
(
QRhi
::
Metal
,
&
params
,
flags
);
#ifdef PROFILE
m_r
->
profiler
()
->
setDevice
(
&
profOut
);
...
...
examples/rhi/shared/trianglerenderer.cpp
View file @
a6da1449
...
...
@@ -76,10 +76,12 @@ void TriangleRenderer::initResources(QRhiRenderPassDescriptor *rp)
#else
m_vbuf
=
m_r
->
newBuffer
(
QRhiBuffer
::
Immutable
,
QRhiBuffer
::
VertexBuffer
,
sizeof
(
vertexData
));
#endif
m_vbuf
->
setName
(
QByteArrayLiteral
(
"Triangle vbuf"
));
m_vbuf
->
build
();
m_vbufReady
=
false
;
m_ubuf
=
m_r
->
newBuffer
(
QRhiBuffer
::
Dynamic
,
QRhiBuffer
::
UniformBuffer
,
68
);
m_ubuf
->
setName
(
QByteArrayLiteral
(
"Triangle ubuf"
));
m_ubuf
->
build
();
m_srb
=
m_r
->
newShaderResourceBindings
();
...
...
src/rhi/qrhi.cpp
View file @
a6da1449
...
...
@@ -65,6 +65,16 @@ void QRhiResource::releaseAndDestroy()
delete
this
;
}
QByteArray
QRhiResource
::
name
()
const
{
return
objectName
;
}
void
QRhiResource
::
setName
(
const
QByteArray
&
name
)
{
objectName
=
name
;
}
QRhiBuffer
::
QRhiBuffer
(
QRhiImplementation
*
rhi
,
Type
type_
,
UsageFlags
usage_
,
int
size_
)
:
QRhiResource
(
rhi
),
m_type
(
type_
),
m_usage
(
usage_
),
m_size
(
size_
)
...
...
src/rhi/qrhi.h
View file @
a6da1449
...
...
@@ -365,10 +365,16 @@ public:
virtual
void
release
()
=
0
;
void
releaseAndDestroy
();
// May be ignored unless EnableDebugMarkers is set.
// May also be ignored for some objects, depending on the backend.
QByteArray
name
()
const
;
void
setName
(
const
QByteArray
&
name
);
protected:
QRhiImplementation
*
rhi
=
nullptr
;
QRhiResource
(
QRhiImplementation
*
rhi_
);
Q_DISABLE_COPY
(
QRhiResource
)
QRhiImplementation
*
rhi
=
nullptr
;
QByteArray
objectName
;
};
class
Q_RHI_EXPORT
QRhiBuffer
:
public
QRhiResource
...
...
@@ -1085,7 +1091,8 @@ public:
};
enum
Flag
{
EnableProfiling
=
1
<<
0
EnableProfiling
=
1
<<
0
,
EnableDebugMarkers
=
1
<<
1
};
Q_DECLARE_FLAGS
(
Flags
,
Flag
)
...
...
src/rhi/qrhimetal.mm
View file @
a6da1449
...
...
@@ -1237,6 +1237,8 @@ bool QMetalBuffer::build()
if
(
i
==
0
||
m_type
!=
Immutable
)
{
d
->
buf
[
i
]
=
[
rhiD
->
d
->
dev
newBufferWithLength
:
roundedSize
options
:
opts
];
d
->
pendingUpdates
[
i
].
reserve
(
16
);
if
(
!
objectName
.
isEmpty
())
d
->
buf
[
i
].
label
=
[
NSString
stringWithUTF8String
:
objectName
.
constData
()];
}
}
...
...
@@ -1322,6 +1324,9 @@ bool QMetalRenderBuffer::build()
d
->
tex
=
[
rhiD
->
d
->
dev
newTextureWithDescriptor
:
desc
];
[
desc
release
];
if
(
!
objectName
.
isEmpty
())
d
->
tex
.
label
=
[
NSString
stringWithUTF8String
:
objectName
.
constData
()];
QRHI_PROF
;
QRHI_PROF_F
(
newRenderBuffer
(
this
,
transientBacking
,
false
,
samples
));
...
...
@@ -1552,6 +1557,9 @@ bool QMetalTexture::build()
d
->
tex
=
[
rhiD
->
d
->
dev
newTextureWithDescriptor
:
desc
];
[
desc
release
];
if
(
!
objectName
.
isEmpty
())
d
->
tex
.
label
=
[
NSString
stringWithUTF8String
:
objectName
.
constData
()];
d
->
owns
=
true
;
nativeHandlesStruct
.
texture
=
d
->
tex
;
...
...
todo.txt
View file @
a6da1449
...
...
@@ -2,7 +2,9 @@ d3d: texture import/export
prof api
vk, d3d, gl: tex and other prof
vk: memalloc stats to prof
debug markers, object names, etc.
vk, d3d, gl: debug: object names
debug: markers (begin, end, msg)
max texture size?
multiwindow_threaded should demo pulling out the device and importing to another rhi
mtl: reduce set*
advanced blend modes
...
...
@@ -52,6 +54,7 @@ dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done
mtl: debug: object names
mtl: buf/tex/rb/sc prof
mtl, gl, vk: texture import/export
rhi native handle getter (device, ...)
...
...
Write
Preview
Markdown
is supported
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