aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-09-16 15:51:21 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-09-18 02:27:10 +0000
commit89d654fcd4f06311c69393d5a1e1fbc8932347a1 (patch)
tree15ed158c2bbbf6f60de325bd0b8d2fea1d2199d8
parentdbf40f74de81e2780e3b14e35704750a2e44d978 (diff)
Clean up GraphicsStateInfo after API review
Change-Id: I715ad71153151a0e6521bc182227d9fa2dc0a3ea Reviewed-by: Christian Strømme <christian.stromme@qt.io>
-rw-r--r--examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm8
-rw-r--r--examples/quick/scenegraph/metalunderqml/metalsquircle.mm8
-rw-r--r--examples/quick/scenegraph/rendernode/metalrenderer.mm8
-rw-r--r--examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp8
-rw-r--r--src/quick/items/qquickwindow.cpp6
-rw-r--r--src/quick/items/qquickwindow.h6
6 files changed, 22 insertions, 22 deletions
diff --git a/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm b/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm
index 6bb68dac44..66a39083f7 100644
--- a/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm
+++ b/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm
@@ -281,7 +281,7 @@ void CustomTextureNode::sync()
m_vs = compileShaderFromSource(m_vert, m_vertEntryPoint);
m_fs = compileShaderFromSource(m_frag, m_fragEntryPoint);
- const int framesInFlight = m_window->graphicsStateInfo()->framesInFlight;
+ const int framesInFlight = m_window->graphicsStateInfo().framesInFlight;
m_vbuf = [m_device newBufferWithLength: sizeof(vertices) options: MTLResourceStorageModeShared];
void *p = [m_vbuf contents];
@@ -348,8 +348,8 @@ void CustomTextureNode::render()
Q_ASSERT(cb);
id<MTLRenderCommandEncoder> encoder = [cb renderCommandEncoderWithDescriptor: renderpassdesc];
- const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo();
- void *p = [m_ubuf[stateInfo->currentFrameSlot] contents];
+ const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo());
+ void *p = [m_ubuf[stateInfo.currentFrameSlot] contents];
memcpy(p, &m_t, 4);
MTLViewport vp;
@@ -361,7 +361,7 @@ void CustomTextureNode::render()
vp.zfar = 1;
[encoder setViewport: vp];
- [encoder setFragmentBuffer: m_ubuf[stateInfo->currentFrameSlot] offset: 0 atIndex: 0];
+ [encoder setFragmentBuffer: m_ubuf[stateInfo.currentFrameSlot] offset: 0 atIndex: 0];
[encoder setVertexBuffer: m_vbuf offset: 0 atIndex: 1];
[encoder setRenderPipelineState: m_pipeline];
[encoder drawPrimitives: MTLPrimitiveTypeTriangleStrip vertexStart: 0 vertexCount: 4 instanceCount: 1 baseInstance: 0];
diff --git a/examples/quick/scenegraph/metalunderqml/metalsquircle.mm b/examples/quick/scenegraph/metalunderqml/metalsquircle.mm
index 8a1a03dc68..5ca6daa01a 100644
--- a/examples/quick/scenegraph/metalunderqml/metalsquircle.mm
+++ b/examples/quick/scenegraph/metalunderqml/metalsquircle.mm
@@ -215,7 +215,7 @@ void SquircleRenderer::frameStart()
prepareShader(FragmentStage);
if (!m_initialized)
- init(m_window->graphicsStateInfo()->framesInFlight);
+ init(m_window->graphicsStateInfo().framesInFlight);
}
static const float vertices[] = {
@@ -233,7 +233,7 @@ void SquircleRenderer::mainPassRecordingStart()
// the scenegraph's main renderpass. It does not create its own passes,
// rendertargets, etc. so no synchronization is needed.
- const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo();
+ const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo());
QSGRendererInterface *rif = m_window->rendererInterface();
id<MTLRenderCommandEncoder> encoder = (id<MTLRenderCommandEncoder>) rif->getResource(
@@ -242,7 +242,7 @@ void SquircleRenderer::mainPassRecordingStart()
m_window->beginExternalCommands();
- void *p = [m_ubuf[stateInfo->currentFrameSlot] contents];
+ void *p = [m_ubuf[stateInfo.currentFrameSlot] contents];
float t = m_t;
memcpy(p, &t, 4);
@@ -255,7 +255,7 @@ void SquircleRenderer::mainPassRecordingStart()
vp.zfar = 1;
[encoder setViewport: vp];
- [encoder setFragmentBuffer: m_ubuf[stateInfo->currentFrameSlot] offset: 0 atIndex: 0];
+ [encoder setFragmentBuffer: m_ubuf[stateInfo.currentFrameSlot] offset: 0 atIndex: 0];
[encoder setVertexBuffer: m_vbuf offset: 0 atIndex: 1];
[encoder setRenderPipelineState: m_pipeline];
[encoder drawPrimitives: MTLPrimitiveTypeTriangleStrip vertexStart: 0 vertexCount: 4 instanceCount: 1 baseInstance: 0];
diff --git a/examples/quick/scenegraph/rendernode/metalrenderer.mm b/examples/quick/scenegraph/rendernode/metalrenderer.mm
index 11db276f37..b83dc62c48 100644
--- a/examples/quick/scenegraph/rendernode/metalrenderer.mm
+++ b/examples/quick/scenegraph/rendernode/metalrenderer.mm
@@ -131,7 +131,7 @@ void MetalRenderNodeResourceBuilder::build()
g.fs = compileShaderFromSource(g.fsSource, QByteArrayLiteral("main0"));
}
- const int framesInFlight = m_window->graphicsStateInfo()->framesInFlight;
+ const int framesInFlight = m_window->graphicsStateInfo().framesInFlight;
// For simplicity's sake we use shared mode (something like host visible +
// host coherent) for everything.
@@ -258,9 +258,9 @@ void MetalRenderNode::releaseResources()
void MetalRenderNode::render(const RenderState *state)
{
Q_ASSERT(m_window);
- const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo();
- id<MTLBuffer> vbuf = g.vbuf[stateInfo->currentFrameSlot];
- id<MTLBuffer> ubuf = g.ubuf[stateInfo->currentFrameSlot];
+ const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo());
+ id<MTLBuffer> vbuf = g.vbuf[stateInfo.currentFrameSlot];
+ id<MTLBuffer> ubuf = g.ubuf[stateInfo.currentFrameSlot];
QPointF p0(m_width - 1, m_height - 1);
QPointF p1(0, 0);
diff --git a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp
index 6e24391257..21f46a25c1 100644
--- a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp
+++ b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp
@@ -212,7 +212,7 @@ void SquircleRenderer::frameStart()
prepareShader(FragmentStage);
if (!m_initialized)
- init(m_window->graphicsStateInfo()->framesInFlight);
+ init(m_window->graphicsStateInfo().framesInFlight);
}
static const float vertices[] = {
@@ -230,10 +230,10 @@ void SquircleRenderer::mainPassRecordingStart()
// the scenegraph's main renderpass. It does not create its own passes,
// rendertargets, etc. so no synchronization is needed.
- const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo();
+ const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo());
QSGRendererInterface *rif = m_window->rendererInterface();
- VkDeviceSize ubufOffset = stateInfo->currentFrameSlot * m_allocPerUbuf;
+ VkDeviceSize ubufOffset = stateInfo.currentFrameSlot * m_allocPerUbuf;
void *p = nullptr;
VkResult err = m_devFuncs->vkMapMemory(m_dev, m_ubufMem, ubufOffset, m_allocPerUbuf, 0, &p);
if (err != VK_SUCCESS || !p)
@@ -259,7 +259,7 @@ void SquircleRenderer::mainPassRecordingStart()
VkDeviceSize vbufOffset = 0;
m_devFuncs->vkCmdBindVertexBuffers(cb, 0, 1, &m_vbuf, &vbufOffset);
- uint32_t dynamicOffset = m_allocPerUbuf * stateInfo->currentFrameSlot;
+ uint32_t dynamicOffset = m_allocPerUbuf * stateInfo.currentFrameSlot;
m_devFuncs->vkCmdBindDescriptorSets(cb, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1,
&m_ubufDescriptor, 1, &dynamicOffset);
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 6fe2891242..cd620e3408 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -4737,7 +4737,7 @@ void QQuickWindow::resetOpenGLState()
*/
/*!
- \return a pointer to a GraphicsStateInfo struct describing some of the
+ \return a reference to a GraphicsStateInfo struct describing some of the
RHI's internal state, in particular, the double or tripple buffering status
of the backend (such as, the Vulkan or Metal integrations). This is
relevant when the underlying graphics APIs is Vulkan or Metal, and the
@@ -4745,14 +4745,14 @@ void QQuickWindow::resetOpenGLState()
its own often-changing resources, such as, uniform buffers, in order to
avoid stalling the pipeline.
*/
-const QQuickWindow::GraphicsStateInfo *QQuickWindow::graphicsStateInfo()
+const QQuickWindow::GraphicsStateInfo &QQuickWindow::graphicsStateInfo()
{
Q_D(QQuickWindow);
if (d->rhi) {
d->rhiStateInfo.currentFrameSlot = d->rhi->currentFrameSlot();
d->rhiStateInfo.framesInFlight = d->rhi->resourceLimit(QRhi::FramesInFlight);
}
- return &d->rhiStateInfo;
+ return d->rhiStateInfo;
}
/*!
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index 9dbff88f0d..56d50cec2a 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -142,10 +142,10 @@ public:
void resetOpenGLState();
#endif
struct GraphicsStateInfo {
- int currentFrameSlot = 0;
- int framesInFlight = 0;
+ int currentFrameSlot;
+ int framesInFlight;
};
- const GraphicsStateInfo *graphicsStateInfo();
+ const GraphicsStateInfo &graphicsStateInfo();
void beginExternalCommands();
void endExternalCommands();
QQmlIncubationController *incubationController() const;