51 #include "../shared/examplefw.h"
52 #include <QElapsedTimer>
57 static const int ARRAY_SIZE = 4;
58 static const int UBUF_SIZE = 72;
60 static float vertexData[] =
62 -0.5f, 0.5f, 0.0f, 0.0f,
63 -0.5f, -0.5f, 0.0f, 1.0f,
64 0.5f, -0.5f, 1.0f, 1.0f,
65 0.5f, 0.5f, 1.0f, 0.0f
91 qFatal(
"Texture array objects are not supported by this backend");
94 d.releasePool <<
d.texArr;
111 d.releasePool <<
d.sampler;
115 d.releasePool <<
d.ubuf;
119 d.releasePool <<
d.srb;
127 d.releasePool <<
d.vbuf;
131 d.releasePool <<
d.ibuf;
134 d.initialUpdates->uploadStaticBuffer(
d.vbuf, 0,
sizeof(vertexData), vertexData);
135 d.initialUpdates->uploadStaticBuffer(
d.ibuf, indexData);
138 d.releasePool <<
d.ps;
139 d.ps->setShaderStages({
144 inputLayout.
setBindings({ { 4 *
sizeof(float) } });
149 d.ps->setVertexInputLayout(inputLayout);
150 d.ps->setShaderResourceBindings(
d.srb);
151 d.ps->setRenderPassDescriptor(
m_rp);
160 d.releasePool.clear();
167 if (
d.initialUpdates) {
168 u->merge(
d.initialUpdates);
169 d.initialUpdates->release();
170 d.initialUpdates =
nullptr;
177 u->updateDynamicBuffer(
d.ubuf, 0, 64, mvp.
constData());
179 u->updateDynamicBuffer(
d.ubuf, 64, 4, &flip);
180 u->updateDynamicBuffer(
d.ubuf, 68, 4, &
d.arrayIndex);
183 if (
d.t.elapsed() > 2000) {
185 d.arrayIndex = (
d.arrayIndex + 1) % ARRAY_SIZE;
186 u->updateDynamicBuffer(
d.ubuf, 68, 4, &
d.arrayIndex);
189 const QSize outputSizeInPixels =
m_sc->currentPixelSize();
191 cb->setGraphicsPipeline(
d.ps);
192 cb->setViewport({ 0, 0, float(outputSizeInPixels.
width()), float(outputSizeInPixels.
height()) });
193 cb->setShaderResources();
small capitals from c petite p scientific f u
The QElapsedTimer class provides a fast way to calculate elapsed times.
The QImage class provides a hardware-independent image representation that allows direct access to th...
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void scale(const QVector3D &vector)
const float * constData() const
QPair< QRhiBuffer *, quint32 > VertexInput
QRhiTexture * newTextureArray(QRhiTexture::Format format, int arraySize, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
bool isFeatureSupported(QRhi::Feature feature) const
QRhiShaderResourceBindings * newShaderResourceBindings()
QRhiBuffer * newBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, int size)
QRhiSampler * newSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode addressU, QRhiSampler::AddressMode addressV, QRhiSampler::AddressMode addressW=QRhiSampler::Repeat)
QRhiGraphicsPipeline * newGraphicsPipeline()
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf)
The QSize class defines the size of a two-dimensional object using integer point precision.
constexpr int height() const noexcept
constexpr int width() const noexcept
std::unique_ptr< QRhiSwapChain > m_sc
std::unique_ptr< QRhiRenderPassDescriptor > m_rp
virtual void customRender()
virtual void customInit()
qDeleteAll(list.begin(), list.end())
QShader getShader(const QString &name)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
QList< QRhiResource * > releasePool
QRhiShaderResourceBindings * srb
QRhiGraphicsPipeline * ps
QRhiResourceUpdateBatch * initialUpdates