diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-09-16 15:51:21 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-09-18 02:27:10 +0000 |
commit | 89d654fcd4f06311c69393d5a1e1fbc8932347a1 (patch) | |
tree | 15ed158c2bbbf6f60de325bd0b8d2fea1d2199d8 /examples | |
parent | dbf40f74de81e2780e3b14e35704750a2e44d978 (diff) |
Clean up GraphicsStateInfo after API review
Change-Id: I715ad71153151a0e6521bc182227d9fa2dc0a3ea
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'examples')
4 files changed, 16 insertions, 16 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); |