4#ifndef QSSGRHICONTEXT_P_H
5#define QSSGRHICONTEXT_P_H
18#include <QtGui/rhi/qrhi.h>
20#include <QtQuick3DRuntimeRender/qtquick3druntimerenderexports.h>
21#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
22#include <ssg/qssgrhicontext.h>
45 ps.shaderPipeline = pipeline;
50 return ps.shaderPipeline;
89 switch (cullFaceMode) {
97 qWarning(
"FrontAndBack cull mode not supported");
119 &&
a.samples ==
b.samples
120 &&
a.flags ==
b.flags
121 &&
a.stencilRef ==
b.stencilRef
123 &&
a.stencilWriteMask ==
b.stencilWriteMask
124 &&
a.depthFunc ==
b.depthFunc
125 &&
a.cullMode ==
b.cullMode
126 &&
a.depthBias ==
b.depthBias
127 &&
a.slopeScaledDepthBias ==
b.slopeScaledDepthBias
128 &&
a.viewport ==
b.viewport
129 &&
a.scissor ==
b.scissor
130 && ia_a.topology == ia_b.topology
131 && ia_a.inputLayout == ia_b.inputLayout
132 &&
a.targetBlend.colorWrite ==
b.targetBlend.colorWrite
133 &&
a.targetBlend.srcColor ==
b.targetBlend.srcColor
134 &&
a.targetBlend.dstColor ==
b.targetBlend.dstColor
135 &&
a.targetBlend.opColor ==
b.targetBlend.opColor
136 &&
a.targetBlend.srcAlpha ==
b.targetBlend.srcAlpha
137 &&
a.targetBlend.dstAlpha ==
b.targetBlend.dstAlpha
138 &&
a.targetBlend.opAlpha ==
b.targetBlend.opAlpha
139 &&
a.colorAttachmentCount ==
b.colorAttachmentCount
140 &&
a.lineWidth ==
b.lineWidth
141 &&
a.polygonMode ==
b.polygonMode
142 &&
a.viewCount ==
b.viewCount;
156 ^
qHash(
s.targetBlend.dstColor)
159 ^
qHash(
s.colorAttachmentCount)
164 ^ (
s.stencilRef << 6)
165 ^ (
s.stencilWriteMask << 7);
178 const void *
cid =
nullptr;
190 QRhiBuffer::UsageFlags usageMask,
202 return sz / m_stride;
220 bool maybeExists =
true;
233 bool maybeExists =
true;
241 return a.hTiling ==
b.hTiling &&
a.vTiling ==
b.vTiling &&
a.zTiling ==
b.zTiling
242 &&
a.minFilter ==
b.minFilter &&
a.magFilter ==
b.magFilter
243 &&
a.mipmap ==
b.mipmap;
273#define QSSG_MAX_NUM_LIGHTS 15
274#define QSSG_REDUCED_MAX_NUM_LIGHTS 5
275#define QSSG_MAX_NUM_SHADOW_MAPS 8
315 bool isNull()
const {
return m_stages.isEmpty(); }
351 const QHash<QSSGRhiInputAssemblerState::InputSemantic, QShaderDescription::InOutVariable> &
vertexInputs()
const {
return m_vertexInputs; }
358 int cameraPositionIdx = -1;
359 int cameraDirectionIdx = -1;
360 int viewProjectionMatrixIdx = -1;
361 int projectionMatrixIdx = -1;
362 int inverseProjectionMatrixIdx = -1;
363 int viewMatrixIdx = -1;
364 int modelViewProjectionIdx = -1;
365 int normalMatrixIdx = -1;
366 int modelMatrixIdx = -1;
367 int lightProbeOrientationIdx = -1;
368 int lightProbePropertiesIdx = -1;
369 int material_emissiveColorIdx = -1;
370 int material_baseColorIdx = -1;
371 int material_specularIdx = -1;
372 int cameraPropertiesIdx = -1;
373 int light_ambient_totalIdx = -1;
374 int material_propertiesIdx = -1;
375 int material_properties2Idx = -1;
376 int material_properties3Idx = -1;
377 int material_properties4Idx = -1;
378 int material_properties5Idx = -1;
379 int material_attenuationIdx = -1;
380 int thicknessFactorIdx = -1;
381 int clearcoatNormalStrengthIdx = -1;
382 int clearcoatFresnelPowerIdx = -1;
383 int rhiPropertiesIdx = -1;
384 int displaceAmountIdx = -1;
385 int boneTransformsIdx = -1;
386 int boneNormalTransformsIdx = -1;
387 int shadowDepthAdjustIdx = -1;
388 int pointSizeIdx = -1;
389 int morphWeightsIdx = -1;
390 int reflectionProbeCubeMapCenter = -1;
391 int reflectionProbeBoxMax = -1;
392 int reflectionProbeBoxMin = -1;
393 int reflectionProbeCorrection = -1;
394 int specularAAIdx = -1;
395 int fogColorIdx = -1;
396 int fogSunColorIdx = -1;
397 int fogDepthPropertiesIdx = -1;
398 int fogHeightPropertiesIdx = -1;
399 int fogTransmitPropertiesIdx = -1;
403 int imageRotationsUniformIndex = -1;
404 int imageOffsetsUniformIndex = -1;
407 } commonUniformIndices;
423 void setUniform(
char *ubufData,
const char *
name,
const void *
data,
size_t size,
int *storeIndex =
nullptr, UniformFlags
flags = {});
425 int bindingForTexture(
const char *
name,
int hint = -1);
436 void ensureCombinedMainLightsUniformBuffer(
QRhiBuffer **ubuf);
443 m_lightProbeTexture =
texture; m_lightProbeHorzTile = hTile; m_lightProbeVertTile = vTile;
448 return {m_lightProbeHorzTile, m_lightProbeVertTile};
476 QVarLengthArray<QRhiShaderStage, 2> m_stages;
478 int m_ub0NextUBufOffset = 0;
479 QHash<QByteArray, QShaderDescription::BlockVariable> m_ub0;
480 QHash<QSSGRhiInputAssemblerState::InputSemantic, QShaderDescription::InOutVariable> m_vertexInputs;
481 QHash<QByteArray, QShaderDescription::InOutVariable> m_combinedImageSamplers;
484 QVarLengthArray<QSSGRhiShaderUniform, 32> m_uniforms;
485 QVarLengthArray<QSSGRhiShaderUniformArray, 8> m_uniformArrays;
486 QHash<QByteArray, size_t> m_uniformIndex;
489 bool m_lightsEnabled =
false;
491 QVarLengthArray<QSSGRhiShadowMapProperties, QSSG_MAX_NUM_SHADOW_MAPS> m_shadowMaps;
499 QVarLengthArray<QSSGRhiTexture, 8> m_extraTextures;
510 static const int MAX_SIZE = 32;
524 for (
int i = 0;
i <
p; ++
i)
530 if (
this != &
other) {
533 for (
int i = 0;
i <
p; ++
i)
539 void addUniformBuffer(
int binding, QRhiShaderResourceBinding::StageFlags stage,
QRhiBuffer *
buf,
int offset = 0 ,
int size = 0);
549 for (
int i = 0;
i <
a.p; ++
i) {
550 if (
a.v[
i] !=
b.v[
i])
656 return a.shader ==
b.shader &&
a.srbLayoutDescription ==
b.srbLayoutDescription;
680 ^
qHash(k.size.width() ^ k.size.height() ^ k.color.red() ^ k.color.green()
681 ^ k.color.blue() ^ k.color.alpha() ^ k.arraySize);
686 return a.flags ==
b.flags &&
a.size ==
b.size &&
a.color ==
b.color &&
a.arraySize ==
b.arraySize;
716 return a.state ==
b.state
717 &&
a.renderTargetDescription ==
b.renderTargetDescription
718 &&
a.srbLayoutDescription ==
b.srbLayoutDescription;
729 ^ k.extra.renderTargetDescriptionHash
730 ^ k.extra.srbLayoutDescriptionHash;
733#define QSSGRHICTX_STAT(ctx, f) \
734 for (bool qssgrhictxlog_enabled = QSSGRhiContextStats::get(*ctx).isEnabled(); qssgrhictxlog_enabled; qssgrhictxlog_enabled = false) \
735 QSSGRhiContextStats::get(*ctx).f
775 int currentRenderPassIndex = -1;
805 static bool profilingEnabled();
806 static bool rendererDebugEnabled();
808 bool isEnabled()
const;
851 void endRenderPass();
852 void printRenderPass(
const RenderPassInfo &rp);
877 [[nodiscard]]
static bool shaderDebuggingEnabled();
878 [[nodiscard]]
static bool editorMode();
883 void setMainPassSampleCount(
int samples);
884 void setMainPassViewCount(
int viewCount);
886 void releaseCachedResources();
928 int m_mainSamples = 1;
929 int m_mainViewCount = 1;
931 QVector<QPair<QSSGRhiSamplerDescription, QRhiSampler*>>
m_samplers;
934 QHash<QSSGRhiShaderResourceBindingList, QRhiShaderResourceBindings *>
m_srbCache;
935 QHash<QSSGGraphicsPipelineStateKey, QRhiGraphicsPipeline *>
m_pipelines;
946 return a.cid ==
b.cid &&
a.model ==
b.model &&
a.entry ==
b.entry &&
a.entryIdx ==
b.entryIdx;
The QColor class provides colors based on RGB, HSV or CMYK values.
Type
Specifies storage type of buffer resource.
IndexFormat
Specifies the index data type.
CullMode
Specifies the culling mode.
Topology
Specifies the primitive topology.
virtual QVector< quint32 > serializedFormat() const =0
Filter
Specifies the minification, magnification, or mipmap filtering.
AddressMode
Specifies the addressing mode.
QVector< quint32 > serializedLayoutDescription() const
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
static QSSGComputePipelineStateKey create(const QShader &shader, const QRhiShaderResourceBindings *srb)
size_t srbLayoutDescriptionHash
struct QSSGComputePipelineStateKey::@763 extra
QVector< quint32 > srbLayoutDescription
size_t srbLayoutDescriptionHash
static QSSGGraphicsPipelineStateKey create(const QSSGRhiGraphicsPipelineState &state, const QRhiRenderPassDescriptor *rpDesc, const QRhiShaderResourceBindings *srb)
QSSGRhiGraphicsPipelineState state
QVector< quint32 > srbLayoutDescription
QVector< quint32 > renderTargetDescription
size_t renderTargetDescriptionHash
struct QSSGGraphicsPipelineStateKey::@764 extra
QRhiBuffer * buffer() const
QRhiCommandBuffer::IndexFormat indexFormat() const
quint32 numVertices() const
static const QSSGRhiContextPrivate * get(const QSSGRhiContext *q)
QHash< QSSGRenderInstanceTable *, QSSGRhiInstanceBufferData > m_instanceBuffers
QVector< QPair< QSSGRhiSamplerDescription, QRhiSampler * > > m_samplers
QHash< const QSSGRenderGraphObject *, QSSGRhiParticleData > m_particleData
QSSGRhiContextStats m_stats
QHash< const QSSGRenderModel *, QSSGRhiInstanceBufferData > m_instanceBuffersLod
QHash< QSSGRhiDummyTextureKey, QRhiTexture * > m_dummyTextures
QHash< QSSGRhiShaderResourceBindingList, QRhiShaderResourceBindings * > m_srbCache
QHash< QSSGRhiDrawCallDataKey, QSSGRhiDrawCallData > m_drawCallData
static QSSGRhiContextPrivate * get(QSSGRhiContext *q)
QHash< QSSGComputePipelineStateKey, QRhiComputePipeline * > m_computePipelines
QHash< QSSGGraphicsPipelineStateKey, QRhiGraphicsPipeline * > m_pipelines
void imageDataSizeChanges(quint64 newSize)
static quint64 totalVertexCountForPass(const QSSGRhiContextStats::RenderPassInfo &pass)
void registerEffectShaderGenerationTime(qint64 ms)
void registerMaterialShaderGenerationTime(qint64 ms)
QSSGRhiContextStats(QSSGRhiContext &context)
void meshDataSizeChanges(quint64 newSize)
QHash< QSSGRenderLayer *, PerLayerInfo > perLayerInfo
static quint64 totalDrawCallCountForPass(const QSSGRhiContextStats::RenderPassInfo &pass)
QSet< QSSGRenderLayer * > dynamicDataSources
const QRhiShaderStage * cendStages() const
QRhiTexture * ssaoTexture() const
const QHash< QSSGRhiInputAssemblerState::InputSemantic, QShaderDescription::InOutVariable > & vertexInputs() const
QRhiTexture * lightProbeTexture() const
void resetExtraTextures()
QSSGRhiShaderPipeline(QSSGRhiContext &context)
QPair< QSSGRenderTextureCoordOp, QSSGRenderTextureCoordOp > lightProbeTiling() const
QSSGRhiTexture & extraTextureAt(int index)
void setLightProbeTexture(QRhiTexture *texture, QSSGRenderTextureCoordOp hTile=QSSGRenderTextureCoordOp::ClampToEdge, QSSGRenderTextureCoordOp vTile=QSSGRenderTextureCoordOp::ClampToEdge)
void setLightmapTexture(QRhiTexture *texture)
InstanceLocations instanceBufferLocations() const
void setDepthTexture(QRhiTexture *texture)
bool isLightingEnabled() const
QSSGRhiShadowMapProperties & shadowMapAt(int index)
QRhiTexture * screenTexture() const
const QRhiShaderStage * cbeginStages() const
const QRhiShaderStage * fragmentStage() const
QRhiTexture * depthTexture() const
int ub0LightDataSize() const
void addExtraTexture(const QSSGRhiTexture &t)
int ub0LightDataOffset() const
void setLightsEnabled(bool enable)
void setScreenTexture(QRhiTexture *texture)
const QSSGRhiShadowMapProperties & shadowMapAt(int index) const
int extraTextureCount() const
QSSGRhiContext & context() const
const QRhiShaderStage * vertexStage() const
QSSGShaderLightsUniformData & lightsUniformData()
QSSGRhiShadowMapProperties & addShadowMap()
QRhiTexture * lightmapTexture() const
int shadowMapCount() const
void setSsaoTexture(QRhiTexture *texture)
const QSSGRhiTexture & extraTextureAt(int index) const
QSSGRhiShaderResourceBindingList()
QSSGRhiShaderResourceBindingList(const QSSGRhiShaderResourceBindingList &other)
QSSGRhiShaderResourceBindingList & operator=(const QSSGRhiShaderResourceBindingList &other) Q_DECL_NOTHROW
The QVector3D class represents a vector or vertex in 3D space.
QRhiVertexInputAttribute::Format toVertexInputFormat(QSSGRenderComponentType compType, quint32 numComps)
QRhiGraphicsPipeline::CullMode toCullMode(QSSGCullFaceMode cullFaceMode)
QRhiGraphicsPipeline::Topology toTopology(QSSGRenderDrawMode drawMode)
void bakeVertexInputLocations(QSSGRhiInputAssemblerState *ia, const QSSGRhiShaderPipeline &shaders, int instanceBufferBinding)
QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
static QDBusError::ErrorType get(const char *name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
size_t qHashBits(const void *p, size_t size, size_t seed) noexcept
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
const void GLsizei GLsizei stride
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint GLintptr offset
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
GLsizei GLsizei GLuint * shaders
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
QSSGRenderTextureFilterOp
bool operator==(const QSSGRhiGraphicsPipelineState &a, const QSSGRhiGraphicsPipelineState &b) Q_DECL_NOTHROW
std::shared_ptr< QSSGRhiBuffer > QSSGRhiBufferPtr
QSSGRhiInputAssemblerStatePrivate::InputAssemblerState QSSGRhiInputAssemblerState
std::shared_ptr< QSSGRhiShaderPipeline > QSSGRhiShaderPipelinePtr
#define QSSG_MAX_NUM_LIGHTS
QSSGRhiSamplerBindingHints
size_t qHash(const QSSGRhiGraphicsPipelineState &s, size_t seed) Q_DECL_NOTHROW
bool operator!=(const QSSGRhiGraphicsPipelineState &a, const QSSGRhiGraphicsPipelineState &b) Q_DECL_NOTHROW
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
unsigned long long quint64
static size_t imageDataSize(const xcb_image_t *image)
QSqlQueryModel * model
[16]
myFilter draw(painter, QPoint(0, 0), originalPixmap)
\variable QRhiGraphicsPipeline::TargetBlend::colorWrite
quint64 vertexOrIndexCount
qint64 materialGenerationTime
qint64 effectGenerationTime
quint64 vertexOrIndexCount
RenderPassInfo externalRenderPass
QVector< RenderPassInfo > renderPasses
InstancedDrawInfo instancedDraws
InstancedDrawInfo instancedIndexedDraws
QSSGRhiShaderResourceBindingList bindings
QSSGRhiGraphicsPipelineState ps
QRhiShaderResourceBindings * srb
QVector< quint32 > renderTargetDescription
QRhiGraphicsPipeline * pipeline
size_t renderTargetDescriptionHash
static constexpr const QSSGRhiShaderPipeline * getShaderPipeline(const QSSGRhiGraphicsPipelineState &ps)
static void setShaderPipeline(QSSGRhiGraphicsPipelineState &ps, const QSSGRhiShaderPipeline *pipeline)
QList< QSSGRhiSortData > sortData
QVector3D sortedCameraDirection
QList< QSSGRhiSortData > sortData
QRhiTextureRenderTarget * rt
QRhiTexture * depthTexture
QRhiRenderPassDescriptor * rpDesc
QRhiRenderBuffer * depthStencil
\variable QSSGRhiGraphicsPipelineState::depthFunc
QRhiTexture * shadowMapTexture
QByteArray shadowMapTextureUniformName
QSSGRhiSamplerDescription samplerDesc
float constantAttenuation
float quadraticAttenuation