diff options
Diffstat (limited to 'examples/widgets/rhi/simplerhiwidget')
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.rst | 34 | ||||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.webp | bin | 0 -> 8556 bytes | |||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/examplewidget.py | 136 | ||||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/main.py | 36 | ||||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/rc_simplerhiwidget.py | 163 | ||||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb | bin | 0 -> 738 bytes | |||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb | bin | 0 -> 1091 bytes | |||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/shaders/color.frag | 10 | ||||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/shaders/color.vert | 16 | ||||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pyproject | 4 | ||||
-rw-r--r-- | examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc | 6 |
11 files changed, 405 insertions, 0 deletions
diff --git a/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.rst b/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.rst new file mode 100644 index 000000000..c33c6660a --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.rst @@ -0,0 +1,34 @@ +.. _rhi-widget-example: + +Simple RHI Widget Example +========================= + +Shows how to render a triangle using ``QRhi``, Qt's 3D API and shading +language abstraction layer. + +This example is, in many ways, the counterpart of the :ref:`rhi-window-example` +in the QWidget world. The ``QRhiWidget`` subclass in this applications renders +a single triangle, using a simple graphics pipeline with basic vertex and +fragment shaders. Unlike the plain ``QWindow``-based application, this example +does not need to worry about lower level details, such as setting up the window +and the ``QRhi``, or dealing with swapchain and window events, as that is taken +care of by the ``QWidget`` framework here. The instance of the ``QRhiWidget`` +subclass is added to a ``QVBoxLayout``. To keep the example minimal and +compact, there are no further widgets or 3D content introduced. + +Once an instance of ``ExampleRhiWidget``, a ``QRhiWidget`` subclass, is added +to a top-level widget's child hierarchy, the corresponding window automatically +becomes a Direct 3D, Vulkan, Metal, or OpenGL-rendered window. The +``QPainter``-rendered widget content, i.e. everything that is not a +``QRhiWidget``, ``QOpenGLWidget``, or ``QQuickWidget``, is then uploaded to a +texture, whereas the mentioned special widgets each render to a texture. The +resulting set textures is composited together by the top-level widget's +backingstore. + +As opposed to the C++ example, the cleanup is done by reimplementing +``QRhiWidget.releaseResources()``, which is called from QWidget.closeEvent() of +the top level widget to ensure a deterministic cleanup sequence. + +.. image:: simplerhiwidget.webp + :width: 400 + :alt: Screenshot of the Simple RHI Widget example diff --git a/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.webp b/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.webp Binary files differnew file mode 100644 index 000000000..fdb8d20ec --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/doc/simplerhiwidget.webp diff --git a/examples/widgets/rhi/simplerhiwidget/examplewidget.py b/examples/widgets/rhi/simplerhiwidget/examplewidget.py new file mode 100644 index 000000000..9f3ef70e9 --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/examplewidget.py @@ -0,0 +1,136 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +from __future__ import annotations + +import numpy + +from PySide6.QtCore import (QFile, QIODevice) +from PySide6.QtGui import (QColor, QMatrix4x4) +from PySide6.QtGui import (QRhiBuffer, + QRhiDepthStencilClearValue, + QRhiShaderResourceBinding, + QRhiShaderStage, + QRhiVertexInputAttribute, QRhiVertexInputBinding, + QRhiVertexInputLayout, QRhiViewport, + QShader) +from PySide6.QtWidgets import QRhiWidget +from PySide6.support import VoidPtr + +VERTEX_DATA = numpy.array([ 0.0, 0.5, 1.0, 0.0, 0.0, # noqa E:201 + -0.5, -0.5, 0.0, 1.0, 0.0, # noqa E:241 + 0.5, -0.5, 0.0, 0.0, 1.0], + dtype=numpy.float32) + + +def getShader(name): + f = QFile(name) + if f.open(QIODevice.ReadOnly): + return QShader.fromSerialized(f.readAll()) + return QShader() + + +class ExampleRhiWidget(QRhiWidget): + + def __init__(self, parent=None): + super().__init__(parent) + self.m_rhi = None + self.m_vbuf = None + self.m_ubuf = None + self.m_srb = None + self.m_pipeline = None + self.m_viewProjection = QMatrix4x4() + self.m_rotation = 0.0 + + def releaseResources(self): + self.m_pipeline.destroy() + del self.m_pipeline + self.m_pipeline = None + self.m_srb.destroy() + del self.m_srb + self.m_srb = None + self.m_ubuf.destroy() + del self.m_ubuf + self.m_ubuf = None + self.m_vbuf.destroy() + del self.m_vbuf + self.m_buf = None + + def initialize(self, cb): + if self.m_rhi != self.rhi(): + self.m_pipeline = None + self.m_rhi = self.rhi() + + if not self.m_pipeline: + vertex_size = 4 * VERTEX_DATA.size + self.m_vbuf = self.m_rhi.newBuffer(QRhiBuffer.Immutable, + QRhiBuffer.VertexBuffer, vertex_size) + self.m_vbuf.create() + + self.m_ubuf = self.m_rhi.newBuffer(QRhiBuffer.Dynamic, + QRhiBuffer.UniformBuffer, 64) + self.m_ubuf.create() + + self.m_srb = self.m_rhi.newShaderResourceBindings() + bindings = [ + QRhiShaderResourceBinding.uniformBuffer(0, QRhiShaderResourceBinding.VertexStage, + self.m_ubuf) + ] + self.m_srb.setBindings(bindings) + self.m_srb.create() + + self.m_pipeline = self.m_rhi.newGraphicsPipeline() + stages = [ + QRhiShaderStage(QRhiShaderStage.Vertex, + getShader(":/shader_assets/color.vert.qsb")), + QRhiShaderStage(QRhiShaderStage.Fragment, + getShader(":/shader_assets/color.frag.qsb")) + ] + self.m_pipeline.setShaderStages(stages) + inputLayout = QRhiVertexInputLayout() + input_bindings = [QRhiVertexInputBinding(5 * 4)] # sizeof(float) + inputLayout.setBindings(input_bindings) + attributes = [ # 4: sizeof(float) + QRhiVertexInputAttribute(0, 0, QRhiVertexInputAttribute.Float2, 0), + QRhiVertexInputAttribute(0, 1, QRhiVertexInputAttribute.Float3, 2 * 4) + ] + inputLayout.setAttributes(attributes) + self.m_pipeline.setVertexInputLayout(inputLayout) + self.m_pipeline.setShaderResourceBindings(self.m_srb) + self.m_pipeline.setRenderPassDescriptor(self.renderTarget().renderPassDescriptor()) + self.m_pipeline.create() + + resourceUpdates = self.m_rhi.nextResourceUpdateBatch() + resourceUpdates.uploadStaticBuffer(self.m_vbuf, VoidPtr(VERTEX_DATA.tobytes(), + vertex_size)) + cb.resourceUpdate(resourceUpdates) + + outputSize = self.renderTarget().pixelSize() + self.m_viewProjection = self.m_rhi.clipSpaceCorrMatrix() + r = float(outputSize.width()) / float(outputSize.height()) + self.m_viewProjection.perspective(45.0, r, 0.01, 1000.0) + self.m_viewProjection.translate(0, 0, -4) + + def render(self, cb): + resourceUpdates = self.m_rhi.nextResourceUpdateBatch() + self.m_rotation += 1.0 + modelViewProjection = self.m_viewProjection + modelViewProjection.rotate(self.m_rotation, 0, 1, 0) + projection = numpy.array(modelViewProjection.data(), + dtype=numpy.float32) + resourceUpdates.updateDynamicBuffer(self.m_ubuf, 0, 64, + projection.tobytes()) + clearColor = QColor.fromRgbF(0.4, 0.7, 0.0, 1.0) + cv = QRhiDepthStencilClearValue(1.0, 0) + cb.beginPass(self.renderTarget(), clearColor, cv, resourceUpdates) + + cb.setGraphicsPipeline(self.m_pipeline) + outputSize = self.renderTarget().pixelSize() + cb.setViewport(QRhiViewport(0, 0, outputSize.width(), + outputSize.height())) + cb.setShaderResources() + vbufBinding = (self.m_vbuf, 0) + cb.setVertexInput(0, [vbufBinding]) + cb.draw(3) + cb.endPass() + + self.update() diff --git a/examples/widgets/rhi/simplerhiwidget/main.py b/examples/widgets/rhi/simplerhiwidget/main.py new file mode 100644 index 000000000..5b23af0df --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/main.py @@ -0,0 +1,36 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +from __future__ import annotations + +"""PySide6 port of the Qt Simple RHI Widget Example example from Qt v6.x""" + +import sys + +from PySide6.QtWidgets import QApplication, QVBoxLayout, QWidget + +from examplewidget import ExampleRhiWidget +import rc_simplerhiwidget # noqa F:401 + + +class Widget(QWidget): + + def __init__(self, parent=None): + super().__init__(parent) + layout = QVBoxLayout(self) + self._rhi_widget = ExampleRhiWidget(self) + layout.addWidget(self._rhi_widget) + + def closeEvent(self, e): + self._rhi_widget.releaseResources() + e.accept() + + +if __name__ == "__main__": + app = QApplication(sys.argv) + + w = Widget() + w.resize(1280, 720) + w.show() + exit_code = app.exec() + del w + sys.exit(exit_code) diff --git a/examples/widgets/rhi/simplerhiwidget/rc_simplerhiwidget.py b/examples/widgets/rhi/simplerhiwidget/rc_simplerhiwidget.py new file mode 100644 index 000000000..ee8b41242 --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/rc_simplerhiwidget.py @@ -0,0 +1,163 @@ +# Resource object code (Python 3) +# Created by: object code +# Created by: The Resource Compiler for Qt version 6.7.0 +# WARNING! All changes made in this file will be lost! + +from PySide6 import QtCore + +qt_resource_data = b"\ +\x00\x00\x02\xe2\ +\x00\ +\x00\x07\xc4x\x9c\xb5T]k\xd4@\x14\x9d\xed\xa6]\ +\x9b\xd6\xda\x0f\xd07\x19\xe9\xcb\x16%\xa6\xb5\x15q\xdd\ +\xfa\xb0U)\x14Z\xdbR\x84e\x091\x9bM\x07\xb2\ +\xc9\x92\x8fE)\x05\xdf}\xf7w\xf8'\xfcO\xbe\x88\ +\xde;s\xd3\xcc\xa6[*\x88\x03\xb3\x999s\xef=\ +g\xceM\x9616\xcf\x183`\xd6`.\xb11s\ +\x98\xc7b\x16\xc2L\x00\xa9\xc3d\xbfi\xb0)\x03\xd3\ +V\xd9\x00\x82]\x16\xb0\x8e\x96j\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\x95\xfe\x82\xe8\xc7\x99\ +\xa8\x84\xcfs\xbf z\xa9l\xf09yn\x900\xd3\ +\xc7\x0b]%\xecw=\xe30\x0b\xda\xba\xb6{\xfa(\ +:\xf2\x9c\xe7sV\x1d4\xc7\x14\x07n\xcf<\xdb\xc7\ +\xb5\x86\xd6\xc0\x86\xa9k$1)20=\x8ac\x91\ +\xe9\x17\x05)\xc5\x82\x8c\xd4\xeeX\x0a\xca\xc9\xd4t\xcb\ +\xc5\x96\x9ag\xce\xb7`+\xef$\xd9\xb1\x9e\xc8\x92\xa8\ +\x0243oA\x93~{\xd0\xa8\xfd\xd9\xf2#7\xc8\ +F\x1e\xff2\xf4\x84\x13\xd8\xf0WR\xe0\x0f\x8f\xacB\ +\x9f\xfa\xe1\xe83\xfc\xd1}q\x04w<\xc5\xc7+r\ +B/\x85+\xe0q\xb9\xab\xbf\xe0i\xc8\xefL\xfe<\ +\x90\x0bf\xd2\xc3\xec\x16\xb7\xd5`\x90\xa5p\x0d\x83\xd8\ +\x8dz\x9d\xd3\xd3\x0b[k0\xd0'\x80Ns\xf1\xfd\ +\xe8\x82K1\x18\xe4\xafj\xbb\x02\xa0o\x86\xe9\xb2\xdb\ +\xd1\xe1\xf1\x88\xbd\xf3\x22}\xb5jk8\xeecl\xdd\ +!\xa7\xa7\xf7 X\x04b$I\xf9\x18\xfb\x15\xec\xea\ +\xcd\x91\xc0\x9d\xfc\x0d\xd5\x01q\x1e\xf2W3\x95R\x5c\ +:g?2{2\x9e\xeb\x97\xe2\x01\x04\xcfroR\ +W\xc4\xaa\x19\xb0\x1b\x96$&=\x8a\x95\x871\xff\xad\ +\xce\xe8\xbf\x83J\xcb\xcc\xd9\xb5\xae\xea'\xc7\xdf%\xe1\ +\xb4\xa2\ +" + +qt_resource_name = b"\ +\x00\x0d\ +\x06E\xc5\xd3\ +\x00s\ +\x00h\x00a\x00d\x00e\x00r\x00_\x00a\x00s\x00s\x00e\x00t\x00s\ +\x00\x0e\ +\x04\x16\xeb\xb2\ +\x00c\ +\x00o\x00l\x00o\x00r\x00.\x00f\x00r\x00a\x00g\x00.\x00q\x00s\x00b\ +\x00\x0e\ +\x00\xfb\xe9\x92\ +\x00c\ +\x00o\x00l\x00o\x00r\x00.\x00v\x00e\x00r\x00t\x00.\x00q\x00s\x00b\ +" + +qt_resource_struct = b"\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00B\x00\x00\x00\x00\x00\x01\x00\x00\x02\xe6\ +\x00\x00\x01\x8a!\x0c\xa5\xeb\ +\x00\x00\x00 \x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +\x00\x00\x01\x8a!\x0c\xa5\xeb\ +" + +def qInitResources(): + QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() diff --git a/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb Binary files differnew file mode 100644 index 000000000..32bd2d595 --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb diff --git a/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb Binary files differnew file mode 100644 index 000000000..bf97035d7 --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb diff --git a/examples/widgets/rhi/simplerhiwidget/shaders/color.frag b/examples/widgets/rhi/simplerhiwidget/shaders/color.frag new file mode 100644 index 000000000..375587662 --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/shaders/color.frag @@ -0,0 +1,10 @@ +#version 440 + +layout(location = 0) in vec3 v_color; + +layout(location = 0) out vec4 fragColor; + +void main() +{ + fragColor = vec4(v_color, 1.0); +} diff --git a/examples/widgets/rhi/simplerhiwidget/shaders/color.vert b/examples/widgets/rhi/simplerhiwidget/shaders/color.vert new file mode 100644 index 000000000..e876f290e --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/shaders/color.vert @@ -0,0 +1,16 @@ +#version 440 + +layout(location = 0) in vec4 position; +layout(location = 1) in vec3 color; + +layout(location = 0) out vec3 v_color; + +layout(std140, binding = 0) uniform buf { + mat4 mvp; +}; + +void main() +{ + v_color = color; + gl_Position = mvp * position; +} diff --git a/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pyproject b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pyproject new file mode 100644 index 000000000..ff0d62755 --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pyproject @@ -0,0 +1,4 @@ +{ + "files": ["main.py","examplewidget.py", "simplerhiwidget.qrc", + "shaders/color.frag", "shaders/color.vert"] +} diff --git a/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc new file mode 100644 index 000000000..ddc6dfbe5 --- /dev/null +++ b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>shader_assets/color.vert.qsb</file> + <file>shader_assets/color.frag.qsb</file> +</qresource> +</RCC> |