Commit a6da1449 authored by Laszlo Agocs's avatar Laszlo Agocs

mtl: Add support for buffer/texture object names

Exercise in trianglerenderer
parent 30a28699
......@@ -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);
......
......@@ -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();
......
......@@ -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_)
......
......@@ -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)
......
......@@ -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;
......
......@@ -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, ...)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment