51 #include "../shared/examplefw.h"
59 static float quadVertexData[] =
61 -0.5f, 0.5f, 0.0f, 0.0f,
62 -0.5f, -0.5f, 0.0f, 1.0f,
63 0.5f, -0.5f, 1.0f, 1.0f,
64 0.5f, 0.5f, 1.0f, 0.0f
67 static quint16 quadIndexData[] =
72 static float triangleData[] =
74 0.0f, 0.5f, 1.0f, 0.0f, 0.0f,
75 -0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
76 0.5f, -0.5f, 0.0f, 0.0f, 1.0f,
90 struct PerColorBuffer {
111 d.releasePool <<
d.vbuf;
115 d.releasePool <<
d.ibuf;
120 d.releasePool <<
d.ubuf;
124 d.releasePool <<
d.sampler;
129 d.releasePool <<
tex;
133 d.releasePool <<
srb;
136 d.ubuf,
i * oneRoundedUniformBlockSize, 68),
141 d.colData[
i].tex =
tex;
142 d.colData[
i].srb =
srb;
151 d.releasePool <<
d.rt;
152 d.rtRp =
d.rt->newCompatibleRenderPassDescriptor();
153 d.releasePool <<
d.rtRp;
154 d.rt->setRenderPassDescriptor(
d.rtRp);
158 d.releasePool <<
d.ps;
159 d.ps->setShaderStages({
165 { 4 *
sizeof(float) }
171 d.ps->setVertexInputLayout(inputLayout);
172 d.ps->setShaderResourceBindings(
d.colData[0].srb);
173 d.ps->setRenderPassDescriptor(
m_rp);
177 d.initialUpdates->uploadStaticBuffer(
d.vbuf, 0,
sizeof(quadVertexData), quadVertexData);
178 d.initialUpdates->uploadStaticBuffer(
d.vbuf,
sizeof(quadVertexData),
sizeof(triangleData), triangleData);
179 d.initialUpdates->uploadStaticBuffer(
d.ibuf, quadIndexData);
183 d.initialUpdates->updateDynamicBuffer(
d.ubuf,
i * oneRoundedUniformBlockSize + 64, 4, &flip);
187 d.releasePool <<
d.triUbuf;
191 d.releasePool <<
d.triSrb;
192 d.triSrb->setBindings({
198 d.releasePool <<
d.triPs;
199 d.triPs->setShaderStages({
205 d.triPs->setTargetBlends(blends, blends +
ATTCOUNT);
208 { 5 *
sizeof(float) }
214 d.triPs->setVertexInputLayout(inputLayout);
215 d.triPs->setShaderResourceBindings(
d.triSrb);
216 d.triPs->setRenderPassDescriptor(
d.rtRp);
220 d.triBaseMvp.perspective(45.0f,
d.rt->pixelSize().width() / float(
d.rt->pixelSize().height()), 0.01f, 1000.0f);
221 d.triBaseMvp.translate(0, 0, -2);
223 d.initialUpdates->updateDynamicBuffer(
d.triUbuf, 64, 4, &
opacity);
229 d.releasePool.clear();
236 if (
d.initialUpdates) {
237 u->merge(
d.initialUpdates);
238 d.initialUpdates->release();
239 d.initialUpdates =
nullptr;
243 triMvp.
rotate(
d.triRot, 0, 1, 0);
245 u->updateDynamicBuffer(
d.triUbuf, 0, 64, triMvp.
constData());
248 cb->setGraphicsPipeline(
d.triPs);
249 cb->setViewport({ 0, 0, float(
d.rt->pixelSize().width()), float(
d.rt->pixelSize().height()) });
250 cb->setShaderResources();
252 cb->setVertexInput(0, 1, &vbufBinding);
279 u->updateDynamicBuffer(
d.ubuf,
i * oneRoundedUniformBlockSize, 64, mvp.
constData());
283 const QSize outputSizeInPixels =
m_sc->currentPixelSize();
285 cb->setGraphicsPipeline(
d.ps);
286 cb->setViewport({ 0, 0, float(outputSizeInPixels.
width()), float(outputSizeInPixels.
height()) });
287 vbufBinding.second = 0;
290 cb->setShaderResources(
d.colData[
i].srb);
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
static QColor fromRgbF(float r, float g, float b, float a=1.0)
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 rotate(float angle, const QVector3D &vector)
const float * constData() const
void translate(const QVector3D &vector)
QPair< QRhiBuffer *, quint32 > VertexInput
int ubufAligned(int v) const
int resourceLimit(ResourceLimit limit) const
QMatrix4x4 clipSpaceCorrMatrix() const
bool isYUpInFramebuffer() 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)
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
QRhiGraphicsPipeline * newGraphicsPipeline()
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf)
void setBindings(std::initializer_list< QRhiShaderResourceBinding > list)
void setColorAttachments(std::initializer_list< QRhiColorAttachment > list)
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
qreal opacity
The opacity of the window in the windowing system.
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)
QRhiShaderResourceBindings * triSrb
QList< QRhiResource * > releasePool
QRhiTextureRenderTarget * rt
QRhiRenderPassDescriptor * rtRp
QRhiGraphicsPipeline * triPs
QRhiShaderResourceBindings * srb
PerColorBuffer colData[ATTCOUNT]
QRhiGraphicsPipeline * ps
QRhiResourceUpdateBatch * initialUpdates
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)