Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qssgrhiparticles.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5#include "qssgrhicontext_p.h"
6
7#include <qfloat16.h>
8
9#include <QtQuick3DUtils/private/qssgutils_p.h>
10
11#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
12#include <QtQuick3DRuntimeRender/private/qssgrendercamera_p.h>
13#include <QtQuick3DRuntimeRender/private/qssglayerrenderdata_p.h>
14
16
17static const QRhiShaderResourceBinding::StageFlags VISIBILITY_ALL =
19
21{
23 float pointLightConstantAtt[4] = {1.0f, 1.0f, 1.0f, 1.0f};
24 float pointLightLinearAtt[4] = {0.0f};
25 float pointLightQuadAtt[4] = {0.0f};
28 float spotLightConstantAtt[4] = {1.0f, 1.0f, 1.0f, 1.0f};
29 float spotLightLinearAtt[4] = {0.0f};
30 float spotLightQuadAtt[4] = {0.0f};
33 float spotLightConeAngle[4] = {0.0f};
34 float spotLightInnerConeAngle[4] = {0.0f};
35};
36
38 QSSGRhiContext *rhiCtx,
39 char *ubufData,
40 QSSGParticlesRenderable &renderable,
41 QSSGRenderCamera &inCamera)
42{
43 const QMatrix4x4 clipSpaceCorrMatrix = rhiCtx->rhi()->clipSpaceCorrMatrix();
44
45 QSSGRhiShaderPipeline::CommonUniformIndices &cui = shaders.commonUniformIndices;
46
47 const QMatrix4x4 projection = clipSpaceCorrMatrix * inCamera.projection;
48 shaders.setUniform(ubufData, "qt_projectionMatrix", projection.constData(), 16 * sizeof(float), &cui.projectionMatrixIdx);
49
50 const QMatrix4x4 viewMatrix = inCamera.globalTransform.inverted();
51 shaders.setUniform(ubufData, "qt_viewMatrix", viewMatrix.constData(), 16 * sizeof(float), &cui.viewMatrixIdx);
52
53 const QMatrix4x4 &modelMatrix = renderable.globalTransform;
54 shaders.setUniform(ubufData, "qt_modelMatrix", modelMatrix.constData(), 16 * sizeof(float), &cui.modelMatrixIdx);
55
56 QVector2D oneOverSize = QVector2D(1.0f, 1.0f);
57 auto &particleBuffer = renderable.particles.m_particleBuffer;
58 const quint32 particlesPerSlice = particleBuffer.particlesPerSlice();
59 oneOverSize = QVector2D(1.0f / particleBuffer.size().width(), 1.0f / particleBuffer.size().height());
60 shaders.setUniform(ubufData, "qt_oneOverParticleImageSize", &oneOverSize, 2 * sizeof(float));
61 shaders.setUniform(ubufData, "qt_countPerSlice", &particlesPerSlice, 1 * sizeof(quint32));
62
63 // Global opacity of the particles node
64 shaders.setUniform(ubufData, "qt_opacity", &renderable.opacity, 1 * sizeof(float));
65
66 float blendImages = renderable.particles.m_blendImages ? 1.0f : 0.0f;
67 float imageCount = float(renderable.particles.m_spriteImageCount);
68 float ooImageCount = 1.0f / imageCount;
69
70 QVector4D spriteConfig(imageCount, ooImageCount, 0.0f, blendImages);
71 shaders.setUniform(ubufData, "qt_spriteConfig", &spriteConfig, 4 * sizeof(float));
72
73 const float billboard = renderable.particles.m_billboard ? 1.0f : 0.0f;
74 shaders.setUniform(ubufData, "qt_billboard", &billboard, 1 * sizeof(float));
75
76 // Lights
77 QVector3D theLightAmbientTotal;
78 bool hasLights = !renderable.particles.m_lights.isEmpty();
79 int pointLight = 0;
80 int spotLight = 0;
81 if (hasLights) {
82 ParticleLightData lightData;
83 auto &lights = renderable.lights;
84 for (quint32 lightIdx = 0, lightEnd = lights.size();
85 lightIdx < lightEnd && lightIdx < QSSG_MAX_NUM_LIGHTS; ++lightIdx) {
86 QSSGRenderLight *theLight(lights[lightIdx].light);
87 // Ignore lights which are not specified for the particle
88 if (!renderable.particles.m_lights.contains(theLight))
89 continue;
90 if (theLight->type == QSSGRenderLight::Type::DirectionalLight) {
91 theLightAmbientTotal += theLight->m_diffuseColor * theLight->m_brightness;
92 } else if (theLight->type == QSSGRenderLight::Type::PointLight && pointLight < 4) {
93 lightData.pointLightColor[pointLight] = QVector4D(theLight->m_diffuseColor * theLight->m_brightness, 1.0f);
94 lightData.pointLightPos[pointLight] = QVector4D(theLight->getGlobalPos(), 1.0f);
96 lightData.pointLightLinearAtt[pointLight] = aux::translateLinearAttenuation(theLight->m_linearFade);
98 pointLight++;
99 } else if (theLight->type == QSSGRenderLight::Type::SpotLight && spotLight < 4) {
100 lightData.spotLightColor[spotLight] = QVector4D(theLight->m_diffuseColor * theLight->m_brightness, 1.0f);
101 lightData.spotLightPos[spotLight] = QVector4D(theLight->getGlobalPos(), 1.0f);
102 lightData.spotLightDir[spotLight] = QVector4D(lights[lightIdx].direction, 0.0f);
104 lightData.spotLightLinearAtt[spotLight] = aux::translateLinearAttenuation(theLight->m_linearFade);
106 float coneAngle = theLight->m_coneAngle;
107 // Inner cone angle must always be < cone angle, to not have possible undefined behavior for shader smoothstep
108 float innerConeAngle = std::min(theLight->m_innerConeAngle, coneAngle - 0.01f);
109 lightData.spotLightConeAngle[spotLight] = qDegreesToRadians(coneAngle);
110 lightData.spotLightInnerConeAngle[spotLight] = qDegreesToRadians(innerConeAngle);
111 spotLight++;
112 }
113 theLightAmbientTotal += theLight->m_ambientColor;
114 }
115 // Copy light data
116 int lightOffset = shaders.offsetOfUniform("qt_pointLightPosition");
117 if (lightOffset >= 0)
118 memcpy(ubufData + lightOffset, &lightData, sizeof(ParticleLightData));
119 }
120 shaders.setUniform(ubufData, "qt_light_ambient_total", &theLightAmbientTotal, 3 * sizeof(float), &cui.light_ambient_totalIdx);
121 int enablePointLights = pointLight > 0 ? 1 : 0;
122 int enableSpotLights = spotLight > 0 ? 1 : 0;
123 shaders.setUniform(ubufData, "qt_pointLights", &enablePointLights, sizeof(int));
124 shaders.setUniform(ubufData, "qt_spotLights", &enableSpotLights, sizeof(int));
125
126 // Line particle uniform
127 int segmentCount = particleBuffer.segments();
128 if (segmentCount) {
129 shaders.setUniform(ubufData, "qt_lineSegmentCount", &segmentCount, sizeof(int));
130 float alphaFade = renderable.particles.m_alphaFade;
131 float sizeModifier = renderable.particles.m_sizeModifier;
132 float texcoordScale = renderable.particles.m_texcoordScale;
133 auto image = renderable.firstImage;
134 if (image && image->m_texture.m_texture) {
135 const auto size = image->m_texture.m_texture->pixelSize();
136 texcoordScale *= float(size.height()) / float(size.width());
137 }
138 shaders.setUniform(ubufData, "qt_alphaFade", &alphaFade, sizeof(float));
139 shaders.setUniform(ubufData, "qt_sizeModifier", &sizeModifier, sizeof(float));
140 shaders.setUniform(ubufData, "qt_texcoordScale", &texcoordScale, sizeof(float));
141 }
142}
143
145 char *ubufData,
146 const QSSGRenderModel *model,
148{
149 auto &particleBuffer = *model->particleBuffer;
150 const quint32 particlesPerSlice = particleBuffer.particlesPerSlice();
151 const QVector2D oneOverSize = QVector2D(1.0f / particleBuffer.size().width(), 1.0f / particleBuffer.size().height());
152 shaderPipeline.setUniform(ubufData, "qt_oneOverParticleImageSize", &oneOverSize, 2 * sizeof(float));
153 shaderPipeline.setUniform(ubufData, "qt_countPerSlice", &particlesPerSlice, sizeof(quint32));
154 const QMatrix4x4 &particleMatrix = model->particleMatrix;
155 shaderPipeline.setUniform(ubufData, "qt_particleMatrix", &particleMatrix, 16 * sizeof(float));
156 shaderPipeline.setUniform(ubufData, "qt_particleIndexOffset", &offset, sizeof(quint32));
157}
158
160{
161 switch (mode) {
167 break;
173 break;
174 default:
175 // Source over as default
180 break;
181
182 }
183}
184
186 const QSSGParticleBuffer &buffer, const QSSGRenderParticles &particles,
187 const QVector3D &cameraDirection, bool animatedParticles)
188{
189 const QMatrix4x4 &invModelMatrix = particles.globalTransform.inverted();
190 QVector3D dir = invModelMatrix.map(cameraDirection);
192 const auto segments = buffer.segments();
193 auto particleCount = buffer.particleCount();
194 const bool lineParticles = segments > 0;
195 if (lineParticles)
196 particleCount /= segments;
197 sortData.resize(particleCount);
198 sortData.fill({});
199
200 const auto srcParticlePointer = [](int line, int segment, int sc, int ss, int pps, const char *source) -> const QSSGLineParticle * {
201 int pi = (line * sc + segment) / pps;
202 int i = (line * sc + segment) % pps;
203 const QSSGLineParticle *sp = reinterpret_cast<const QSSGLineParticle *>(source + pi * ss);
204 return sp + i;
205 };
206
207 // create sort data
208 {
209 const auto slices = buffer.sliceCount();
210 const auto ss = buffer.sliceStride();
211 const auto pps = buffer.particlesPerSlice();
212
213 QSSGRhiSortData *dst = sortData.data();
214 const char *source = buffer.pointer();
215 const char *begin = source;
216 int i = 0;
217 if (lineParticles) {
218 for (i = 0; i < particleCount; i++) {
219 QSSGRhiSortData lineData;
220 const QSSGLineParticle *lineBegin = srcParticlePointer(i, 0, segments, ss, pps, source);
221 lineData.indexOrOffset = i;
222 lineData.d = QVector3D::dotProduct(lineBegin->position, n);
223 for (int j = 1; j < buffer.segments(); j++) {
224 const QSSGLineParticle *p = srcParticlePointer(i, j, segments, ss, pps, source);
225 lineData.d = qMin(lineData.d, QVector3D::dotProduct(p->position, n));
226 }
227 *dst++ = lineData;
228 }
229 } else if (animatedParticles) {
230 for (int s = 0; s < slices; s++) {
231 const QSSGParticleAnimated *sp = reinterpret_cast<const QSSGParticleAnimated *>(source);
232 for (int p = 0; p < pps && i < particleCount; p++) {
233 *dst = { QVector3D::dotProduct(sp->position, n), int(reinterpret_cast<const char *>(sp) - begin)};
234 sp++;
235 dst++;
236 i++;
237 }
238 source += ss;
239 }
240 } else {
241 for (int s = 0; s < slices; s++) {
242 const QSSGParticleSimple *sp = reinterpret_cast<const QSSGParticleSimple *>(source);
243 for (int p = 0; p < pps && i < particleCount; p++) {
244 *dst = { QVector3D::dotProduct(sp->position, n), int(reinterpret_cast<const char *>(sp) - begin)};
245 sp++;
246 dst++;
247 i++;
248 }
249 source += ss;
250 }
251 }
252 }
253
254 // sort
255 result.resize(buffer.bufferSize());
256 std::sort(sortData.begin(), sortData.end(), [](const QSSGRhiSortData &a, const QSSGRhiSortData &b){
257 return a.d > b.d;
258 });
259
260 auto copyParticles = [&](QByteArray &dst, const QList<QSSGRhiSortData> &data, const QSSGParticleBuffer &buffer) {
261 const auto slices = buffer.sliceCount();
262 const auto ss = buffer.sliceStride();
263 const auto pps = buffer.particlesPerSlice();
264 const QSSGRhiSortData *sdata = data.data();
265 char *dest = dst.data();
266 const char *source = buffer.pointer();
267 int i = 0;
268 if (lineParticles) {
269 int seg = 0;
270 for (int s = 0; s < slices; s++) {
271 QSSGLineParticle *dp = reinterpret_cast<QSSGLineParticle *>(dest);
272 for (int p = 0; p < pps && i < particleCount; p++) {
273 *dp = *srcParticlePointer(sdata->indexOrOffset, seg, segments, ss, pps, source);
274 dp++;
275 seg++;
276 if (seg == segments) {
277 sdata++;
278 i++;
279 seg = 0;
280 }
281 }
282 dest += ss;
283 }
284 } else if (animatedParticles) {
285 for (int s = 0; s < slices; s++) {
286 QSSGParticleAnimated *dp = reinterpret_cast<QSSGParticleAnimated *>(dest);
287 for (int p = 0; p < pps && i < particleCount; p++) {
288 *dp = *reinterpret_cast<const QSSGParticleAnimated *>(source + sdata->indexOrOffset);
289 dp++;
290 sdata++;
291 i++;
292 }
293 dest += ss;
294 }
295 } else {
296 for (int s = 0; s < slices; s++) {
297 QSSGParticleSimple *dp = reinterpret_cast<QSSGParticleSimple *>(dest);
298 for (int p = 0; p < pps && i < particleCount; p++) {
299 *dp = *reinterpret_cast<const QSSGParticleSimple *>(source + sdata->indexOrOffset);
300 dp++;
301 sdata++;
302 i++;
303 }
304 dest += ss;
305 }
306 }
307 };
308
309 // write result
310 copyParticles(result, sortData, buffer);
311}
312
314{
315 if (!convert)
316 return data;
317 int count = data.size() / 4;
318 if (dest.size() != count * 2)
319 dest.resize(2 * count);
320 qFloatToFloat16(reinterpret_cast<qfloat16 *>(dest.data()), reinterpret_cast<const float *>(data.constData()), count);
321 return dest;
322}
323
325 QSSGPassKey passKey,
326 QSSGRhiContext *rhiCtx,
328 QSSGParticlesRenderable &renderable,
329 const QSSGLayerRenderData &inData,
330 QRhiRenderPassDescriptor *renderPassDescriptor,
331 int samples,
333 int cubeFace,
335{
336 const void *node = &renderable.particles;
337 const bool needsConversion = !rhiCtx->rhi()->isTextureFormatSupported(QRhiTexture::RGBA32F);
338
339 QSSGRhiDrawCallData &dcd(cubeFace < 0 ? rhiCtx->drawCallData({ passKey, node,
340 nullptr, 0, QSSGRhiDrawCallDataKey::Main })
341 : rhiCtx->drawCallData({ passKey, node,
343 shaderPipeline.ensureUniformBuffer(&dcd.ubuf);
344
346 if (!camera)
347 updateUniformsForParticles(shaderPipeline, rhiCtx, ubufData, renderable, *inData.camera);
348 else
349 updateUniformsForParticles(shaderPipeline, rhiCtx, ubufData, renderable, *camera);
351
352 QSSGRhiParticleData &particleData = rhiCtx->particleData(&renderable.particles);
353 const QSSGParticleBuffer &particleBuffer = renderable.particles.m_particleBuffer;
354 int particleCount = particleBuffer.particleCount();
355 if (particleData.texture == nullptr || particleData.particleCount != particleCount) {
356 QSize size(particleBuffer.size());
357 if (!particleData.texture) {
358 particleData.texture = rhiCtx->rhi()->newTexture(needsConversion ? QRhiTexture::RGBA16F : QRhiTexture::RGBA32F, size);
359 particleData.texture->create();
360 } else {
361 particleData.texture->setPixelSize(size);
362 particleData.texture->create();
363 }
364 particleData.particleCount = particleCount;
365 }
366
367 bool sortingChanged = particleData.sorting != renderable.particles.m_depthSorting;
368 if (sortingChanged && !renderable.particles.m_depthSorting) {
369 particleData.sortData.clear();
370 particleData.sortedData.clear();
371 }
372 particleData.sorting = renderable.particles.m_depthSorting;
373
374 QByteArray uploadData;
375
376 if (renderable.particles.m_depthSorting) {
377 bool animatedParticles = renderable.particles.m_featureLevel == QSSGRenderParticles::FeatureLevel::Animated;
378 if (!camera)
379 sortParticles(particleData.sortedData, particleData.sortData, particleBuffer, renderable.particles, inData.cameraData->direction, animatedParticles);
380 else
381 sortParticles(particleData.sortedData, particleData.sortData, particleBuffer, renderable.particles, camera->getScalingCorrectDirection(), animatedParticles);
382 uploadData = convertParticleData(particleData.convertData, particleData.sortedData, needsConversion);
383 } else {
384 uploadData = convertParticleData(particleData.convertData, particleBuffer.data(), needsConversion);
385 }
386
389 upload.setData(uploadData);
391 rub->uploadTexture(particleData.texture, uploadDesc);
392 rhiCtx->commandBuffer()->resourceUpdate(rub);
393
396 ps->ia.inputs.clear();
397
398 ps->samples = samples;
400 if (renderable.renderableFlags.hasTransparency())
402 else
404
406 bindings.addUniformBuffer(0, VISIBILITY_ALL, dcd.ubuf, 0, shaderPipeline.ub0Size());
407
408 // Texture maps
409 // we only have one image
410 QSSGRenderableImage *renderableImage = renderable.firstImage;
411
412 int samplerBinding = shaderPipeline.bindingForTexture("qt_sprite");
413 if (samplerBinding >= 0) {
414 QRhiTexture *texture = renderableImage ? renderableImage->m_texture.m_texture : nullptr;
415 if (samplerBinding >= 0 && texture) {
416 const bool mipmapped = texture->flags().testFlag(QRhiTexture::MipMapped);
417 QRhiSampler *sampler = rhiCtx->sampler({ toRhi(renderableImage->m_imageNode.m_minFilterType),
418 toRhi(renderableImage->m_imageNode.m_magFilterType),
419 mipmapped ? toRhi(renderableImage->m_imageNode.m_mipFilterType) : QRhiSampler::None,
420 toRhi(renderableImage->m_imageNode.m_horizontalTilingMode),
421 toRhi(renderableImage->m_imageNode.m_verticalTilingMode),
423 });
425 } else {
427 QRhiTexture *texture = rhiCtx->dummyTexture({}, rub, QSize(4, 4), Qt::white);
428 rhiCtx->commandBuffer()->resourceUpdate(rub);
435 });
437 }
438 }
439
440 samplerBinding = shaderPipeline.bindingForTexture("qt_particleTexture");
441 if (samplerBinding >= 0) {
442 QRhiTexture *texture = particleData.texture;
443 if (samplerBinding >= 0 && texture) {
450 });
452 }
453 }
454
455 samplerBinding = shaderPipeline.bindingForTexture("qt_colorTable");
456 if (samplerBinding >= 0) {
457 bool hasTexture = false;
458 if (renderable.colorTable) {
460 if (texture) {
461 hasTexture = true;
468 });
470 }
471 }
472
473 if (!hasTexture) {
475 QRhiTexture *texture = rhiCtx->dummyTexture({}, rub, QSize(4, 4), Qt::white);
476 rhiCtx->commandBuffer()->resourceUpdate(rub);
483 });
485 }
486 }
487
488 // TODO: This is identical to other renderables. Make into a function?
490 bool srbChanged = false;
491 if (!srb || bindings != dcd.bindings) {
492 srb = rhiCtx->srb(bindings);
493 dcd.bindings = bindings;
494 srbChanged = true;
495 }
496
497 if (cubeFace < 0)
498 renderable.rhiRenderData.mainPass.srb = srb;
499 else
500 renderable.rhiRenderData.reflectionPass.srb[cubeFace] = srb;
501
502 const QSSGGraphicsPipelineStateKey pipelineKey = QSSGGraphicsPipelineStateKey::create(*ps, renderPassDescriptor, srb);
503 if (dcd.pipeline
504 && !srbChanged
507 && dcd.ps == *ps)
508 {
509 if (cubeFace < 0)
510 renderable.rhiRenderData.mainPass.pipeline = dcd.pipeline;
511 else
513 } else {
514 if (cubeFace < 0) {
515 renderable.rhiRenderData.mainPass.pipeline = rhiCtx->pipeline(pipelineKey,
516 renderPassDescriptor,
517 srb);
518 dcd.pipeline = renderable.rhiRenderData.mainPass.pipeline;
519 } else {
520 renderable.rhiRenderData.reflectionPass.pipeline = rhiCtx->pipeline(pipelineKey,
521 renderPassDescriptor,
522 srb);
524 }
527 dcd.ps = *ps;
528 }
529}
530
532 QSSGRhiContext *rhiCtx,
534 const QSSGRenderModel *model)
535{
536 QSSGRhiParticleData &particleData = rhiCtx->particleData(model);
537 const QSSGParticleBuffer &particleBuffer = *model->particleBuffer;
538 int particleCount = particleBuffer.particleCount();
539 bool update = particleBuffer.serial() != particleData.serial;
540 const bool needsConversion = !rhiCtx->rhi()->isTextureFormatSupported(QRhiTexture::RGBA32F);
541 if (particleData.texture == nullptr || particleData.particleCount != particleCount) {
542 QSize size(particleBuffer.size());
543 if (!particleData.texture) {
544 particleData.texture = rhiCtx->rhi()->newTexture(needsConversion ? QRhiTexture::RGBA16F : QRhiTexture::RGBA32F, size);
545 particleData.texture->create();
546 } else {
547 particleData.texture->setPixelSize(size);
548 particleData.texture->create();
549 }
550 particleData.particleCount = particleCount;
551 update = true;
552 }
553
554 if (update) {
557 upload.setData(convertParticleData(particleData.convertData, particleBuffer.data(), needsConversion));
559 rub->uploadTexture(particleData.texture, uploadDesc);
560 rhiCtx->commandBuffer()->resourceUpdate(rub);
561 }
562 particleData.serial = particleBuffer.serial();
563 int samplerBinding = shaderPipeline.bindingForTexture("qt_particleTexture");
564 if (samplerBinding >= 0) {
565 QRhiTexture *texture = particleData.texture;
566 if (samplerBinding >= 0 && texture) {
573 });
575 }
576 }
577}
578
580 QSSGParticlesRenderable &renderable,
581 bool *needsSetViewport,
582 int cubeFace,
584{
587
588 if (cubeFace >= 0) {
589 ps = renderable.rhiRenderData.reflectionPass.pipeline;
590 srb = renderable.rhiRenderData.reflectionPass.srb[cubeFace];
591 }
592
593 if (!ps || !srb)
594 return;
595
596 Q_QUICK3D_PROFILE_START(QQuick3DProfiler::Quick3DRenderCall);
597
599 // QRhi optimizes out unnecessary binding of the same pipline
600 cb->setGraphicsPipeline(ps);
601 cb->setVertexInput(0, 0, nullptr);
602 cb->setShaderResources(srb);
603
604 if (needsSetViewport && *needsSetViewport) {
605 cb->setViewport(state.viewport);
606 *needsSetViewport = false;
607 }
609 // draw triangle strip with 2 * segmentCount vertices N times
610 int S = renderable.particles.m_particleBuffer.segments();
611 int N = renderable.particles.m_particleBuffer.particleCount() / S;
612 cb->draw(2 * S, N);
613 QSSGRHICTX_STAT(rhiCtx, draw(2 * S, N));
614 Q_QUICK3D_PROFILE_END_WITH_ID(QQuick3DProfiler::Quick3DRenderCall, (2 * S | quint64(N) << 32), renderable.particles.profilingId);
615 } else {
616 // draw triangle strip with 2 triangles N times
617 cb->draw(4, renderable.particles.m_particleBuffer.particleCount());
619 Q_QUICK3D_PROFILE_END_WITH_ID(QQuick3DProfiler::Quick3DRenderCall, (4 | quint64(renderable.particles.m_particleBuffer.particleCount()) << 32), renderable.particles.profilingId);
620 }
621}
622
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:534
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:474
void clear()
Clears the contents of the byte array and makes it null.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
Definition qlist.h:74
QList< T > & fill(parameter_type t, qsizetype size=-1)
Definition qlist.h:896
iterator end()
Definition qlist.h:609
iterator begin()
Definition qlist.h:608
pointer data()
Definition qlist.h:414
void resize(qsizetype size)
Definition qlist.h:392
void clear()
Definition qlist.h:417
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
QMatrix4x4 inverted(bool *invertible=nullptr) const
Returns the inverse of this matrix.
QPoint map(const QPoint &point) const
Maps point by multiplying this matrix by point.
Definition qmatrix4x4.h:908
const float * constData() const
Returns a constant pointer to the raw data of this matrix.
Definition qmatrix4x4.h:147
virtual char * beginFullDynamicBufferUpdateForCurrentFrame()
Definition qrhi.cpp:3844
virtual void endFullDynamicBufferUpdateForCurrentFrame()
To be called when the entire contents of the buffer data has been updated in the memory block returne...
Definition qrhi.cpp:3854
\inmodule QtGui
Definition qrhi.h:1614
void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates)
Sometimes committing resource updates is necessary or just more convenient without starting a render ...
Definition qrhi.cpp:8986
\inmodule QtGui
Definition qrhi.h:1241
\inmodule QtGui
Definition qrhi.h:1119
\inmodule QtGui
Definition qrhi.h:1694
void uploadTexture(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
Enqueues uploading the image data for one or more mip levels in one or more layers of the texture tex...
Definition qrhi.cpp:8681
\inmodule QtGui
Definition qrhi.h:1007
@ ClampToEdge
Definition qrhi.h:1017
\inmodule QtGui
Definition qrhi.h:1190
void setData(const QByteArray &data)
Sets data.
Definition qrhi.h:655
\inmodule QtGui
Definition qrhi.h:704
\inmodule QtGui
Definition qrhi.h:681
\inmodule QtGui
Definition qrhi.h:883
@ MipMapped
Definition qrhi.h:888
virtual bool create()=0
Creates the corresponding native graphics resources.
@ RGBA32F
Definition qrhi.h:914
@ RGBA16F
Definition qrhi.h:913
Flags flags() const
Definition qrhi.h:980
void setPixelSize(const QSize &sz)
Sets the texture size, specified in pixels, to sz.
Definition qrhi.h:964
\inmodule QtGui
Definition qrhi.h:313
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags={}) const
Definition qrhi.cpp:9673
QMatrix4x4 clipSpaceCorrMatrix() const
Definition qrhi.cpp:9662
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
Definition qrhi.cpp:10133
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
Definition qrhi.cpp:8854
QSSGRenderCamera * camera
std::optional< QSSGCameraRenderData > cameraData
static void updateUniformsForParticles(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, char *ubufData, QSSGParticlesRenderable &renderable, QSSGRenderCamera &inCamera)
static void rhiRenderRenderable(QSSGRhiContext *rhiCtx, QSSGParticlesRenderable &renderable, bool *needsSetViewport, int cubeFace, const QSSGRhiGraphicsPipelineState &state)
static void updateUniformsForParticleModel(QSSGRhiShaderPipeline &shaderPipeline, char *ubufData, const QSSGRenderModel *model, quint32 offset)
static void prepareParticlesForModel(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, QSSGRhiShaderResourceBindingList &bindings, const QSSGRenderModel *model)
static void rhiPrepareRenderable(QSSGRhiShaderPipeline &shaderPipeline, QSSGPassKey passKey, QSSGRhiContext *rhiCtx, QSSGRhiGraphicsPipelineState *ps, QSSGParticlesRenderable &renderable, const QSSGLayerRenderData &inData, QRhiRenderPassDescriptor *renderPassDescriptor, int samples, QSSGRenderCamera *camera=nullptr, int cubeFace=-1, QSSGReflectionMapEntry *entry=nullptr)
QRhiTexture * dummyTexture(QRhiTexture::Flags flags, QRhiResourceUpdateBatch *rub, const QSize &size=QSize(64, 64), const QColor &fillColor=Qt::black)
QRhiCommandBuffer * commandBuffer() const
QSSGRhiDrawCallData & drawCallData(const QSSGRhiDrawCallDataKey &key)
QRhiShaderResourceBindings * srb(const QSSGRhiShaderResourceBindingList &bindings)
QRhiGraphicsPipeline * pipeline(const QSSGGraphicsPipelineStateKey &key, QRhiRenderPassDescriptor *rpDesc, QRhiShaderResourceBindings *srb)
QRhi * rhi() const
QRhiSampler * sampler(const QSSGRhiSamplerDescription &samplerDescription)
QSSGRhiParticleData & particleData(const QSSGRenderGraphObject *particlesOrModel)
void ensureUniformBuffer(QRhiBuffer **ubuf)
int bindingForTexture(const char *name, int hint=-1)
void setUniform(char *ubufData, const char *name, const void *data, size_t size, int *storeIndex=nullptr, UniformFlags flags={})
\inmodule QtCore
Definition qsize.h:25
QString normalized(NormalizationForm mode, QChar::UnicodeVersion version=QChar::Unicode_Unassigned) const
Returns the string in the given Unicode normalization mode, according to the given version of the Uni...
Definition qstring.cpp:8212
bool isEmpty() const
bool contains(const AT &t) const
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
static constexpr float dotProduct(QVector3D v1, QVector3D v2) noexcept
Returns the dot product of v1 and v2.
Definition qvectornd.h:770
The QVector4D class represents a vector or vertex in 4D space.
Definition qvectornd.h:330
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
Definition qfloat16.h:46
QCamera * camera
Definition camera.cpp:19
double pi
[0]
direction
else opt state
[0]
Combined button and popup list for selecting options.
@ white
Definition qnamespace.h:30
Q_DECL_CONSTEXPR float translateConstantAttenuation(float attenuation)
Definition qssgutils_p.h:40
Q_DECL_CONSTEXPR float translateQuadraticAttenuation(float attenuation)
Definition qssgutils_p.h:44
Q_DECL_CONSTEXPR float translateLinearAttenuation(float attenuation)
Definition qssgutils_p.h:42
Definition image.cpp:4
Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) noexcept
constexpr float qDegreesToRadians(float degrees)
Definition qmath.h:260
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
GLboolean GLboolean GLboolean b
GLsizei samples
GLenum mode
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint sampler
GLenum GLenum GLsizei count
GLenum GLuint buffer
GLenum GLenum dst
GLenum GLuint texture
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLfloat n
GLsizei GLsizei GLchar * source
GLuint segment
GLuint entry
GLuint segments
GLsizei GLsizei GLuint * shaders
Definition qopenglext.h:677
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
static constexpr To convert(const std::array< Mapping, N > &mapping, From Mapping::*from, To Mapping::*to, From value, To defaultValue)
#define Q_QUICK3D_PROFILE_START(Type)
#define Q_QUICK3D_PROFILE_END_WITH_ID(Type, Payload, POID)
static int segmentCount(const QPainterPath &path, qreal pathLength)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define QSSGRHICTX_STAT(ctx, f)
QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
#define QSSG_MAX_NUM_LIGHTS
static QByteArray convertParticleData(QByteArray &dest, const QByteArray &data, bool convert)
static void fillTargetBlend(QRhiGraphicsPipeline::TargetBlend &targetBlend, QSSGRenderParticles::BlendMode mode)
static QT_BEGIN_NAMESPACE const QRhiShaderResourceBinding::StageFlags VISIBILITY_ALL
static void sortParticles(QByteArray &result, QList< QSSGRhiSortData > &sortData, const QSSGParticleBuffer &buffer, const QSSGRenderParticles &particles, const QVector3D &cameraDirection, bool animatedParticles)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define sp
const void * QSSGPassKey
unsigned int quint32
Definition qtypes.h:45
unsigned long long quint64
Definition qtypes.h:56
QSqlQueryModel * model
[16]
QString dir
[11]
myFilter draw(painter, QPoint(0, 0), originalPixmap)
QVector4D spotLightDir[4]
QVector4D pointLightColor[4]
QVector4D spotLightPos[4]
QVector4D spotLightColor[4]
QVector4D pointLightPos[4]
static QSSGGraphicsPipelineStateKey create(const QSSGRhiGraphicsPipelineState &state, const QRhiRenderPassDescriptor *rpDesc, const QRhiShaderResourceBindings *srb)
struct QSSGGraphicsPipelineStateKey::@759 extra
QVector< quint32 > renderTargetDescription
QByteArray data() const
struct QSSGParticlesRenderable::@767::@768 mainPass
QSSGRenderableImage * colorTable
QRhiShaderResourceBindings * srb
struct QSSGParticlesRenderable::@767 rhiRenderData
struct QSSGParticlesRenderable::@767::@771 reflectionPass
const QSSGShaderLightListView & lights
QSSGRenderableImage * firstImage
const QSSGRenderParticles & particles
QRhiGraphicsPipeline * pipeline
QSSGRenderTextureFilterOp m_mipFilterType
QSSGRenderTextureCoordOp m_horizontalTilingMode
QSSGRenderTextureFilterOp m_minFilterType
QSSGRenderTextureCoordOp m_verticalTilingMode
QSSGRenderTextureFilterOp m_magFilterType
QMatrix4x4 globalTransform
QVector3D getGlobalPos() const
QSSGRenderParticles::BlendMode m_blendMode
QVarLengthArray< QSSGRenderLight *, 4 > m_lights
QSSGRenderParticles::FeatureLevel m_featureLevel
QSSGParticleBuffer m_particleBuffer
QSSGRenderImageTexture m_texture
const QSSGRenderImage & m_imageNode
const QMatrix4x4 & globalTransform
QSSGRenderableObjectFlags renderableFlags
QSSGRhiShaderResourceBindingList bindings
QSSGRhiGraphicsPipelineState ps
QRhiShaderResourceBindings * srb
QVector< quint32 > renderTargetDescription
QRhiGraphicsPipeline * pipeline
QSSGRhiInputAssemblerState ia
QRhiGraphicsPipeline::CullMode cullMode
QRhiGraphicsPipeline::TargetBlend targetBlend
QVarLengthArray< InputSemantic, 8 > inputs
QRhiVertexInputLayout inputLayout
QRhiGraphicsPipeline::Topology topology
QList< QSSGRhiSortData > sortData
void addUniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size)
void addTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)