4#ifndef QSSGRHICONTEXT_P_H
5#define QSSGRHICONTEXT_P_H
19#include <QtCore/qstack.h>
20#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
21#include <QtGui/private/qrhi_p.h>
22#include "private/qquick3dprofiler_p.h"
28struct QSSGShaderLightProperties;
45 MaxTargetSemantic = ColorSemantic,
48 TexCoordLightmapSemantic
55 std::array<quint8, MaxTargetSemantic + 1> targetOffsets = { UINT8_MAX, UINT8_MAX, UINT8_MAX, UINT8_MAX,
56 UINT8_MAX, UINT8_MAX, UINT8_MAX };
73 QRhiBuffer::UsageFlags usageMask,
103 bool maybeExists =
true;
116 bool maybeExists =
true;
137 return a.hTiling ==
b.hTiling &&
a.vTiling ==
b.vTiling &&
a.zTiling ==
b.zTiling
138 &&
a.minFilter ==
b.minFilter &&
a.magFilter ==
b.magFilter
139 &&
a.mipmap ==
b.mipmap;
166#define QSSG_MAX_NUM_LIGHTS 15
167#define QSSG_REDUCED_MAX_NUM_LIGHTS 5
168#define QSSG_MAX_NUM_SHADOW_MAPS 8
208 bool isNull()
const {
return m_stages.isEmpty(); }
251 int cameraPositionIdx = -1;
252 int cameraDirectionIdx = -1;
253 int viewProjectionMatrixIdx = -1;
254 int projectionMatrixIdx = -1;
255 int inverseProjectionMatrixIdx = -1;
256 int viewMatrixIdx = -1;
257 int modelViewProjectionIdx = -1;
258 int normalMatrixIdx = -1;
259 int modelMatrixIdx = -1;
260 int lightProbeOrientationIdx = -1;
261 int lightProbePropertiesIdx = -1;
262 int material_emissiveColorIdx = -1;
263 int material_baseColorIdx = -1;
264 int material_specularIdx = -1;
265 int cameraPropertiesIdx = -1;
266 int light_ambient_totalIdx = -1;
267 int material_propertiesIdx = -1;
268 int material_properties2Idx = -1;
269 int material_properties3Idx = -1;
270 int material_properties4Idx = -1;
271 int material_properties5Idx = -1;
272 int material_attenuationIdx = -1;
273 int thicknessFactorIdx = -1;
274 int rhiPropertiesIdx = -1;
275 int displaceAmountIdx = -1;
276 int boneTransformsIdx = -1;
277 int boneNormalTransformsIdx = -1;
278 int shadowDepthAdjustIdx = -1;
279 int pointSizeIdx = -1;
280 int morphWeightsIdx = -1;
281 int reflectionProbeCubeMapCenter = -1;
282 int reflectionProbeBoxMax = -1;
283 int reflectionProbeBoxMin = -1;
284 int reflectionProbeCorrection = -1;
285 int specularAAIdx = -1;
286 int fogColorIdx = -1;
287 int fogSunColorIdx = -1;
288 int fogDepthPropertiesIdx = -1;
289 int fogHeightPropertiesIdx = -1;
290 int fogTransmitPropertiesIdx = -1;
294 int imageRotationsUniformIndex = -1;
295 int imageOffsetsUniformIndex = -1;
298 } commonUniformIndices;
314 void setUniform(
char *ubufData,
const char *
name,
const void *
data,
size_t size,
int *storeIndex =
nullptr, UniformFlags
flags = {});
316 int bindingForTexture(
const char *
name,
int hint = -1);
327 void ensureCombinedMainLightsUniformBuffer(
QRhiBuffer **ubuf);
334 m_lightProbeTexture =
texture; m_lightProbeHorzTile = hTile; m_lightProbeVertTile = vTile;
339 return {m_lightProbeHorzTile, m_lightProbeVertTile};
369 int m_ub0NextUBufOffset = 0;
380 bool m_lightsEnabled =
false;
403 bool depthTestEnable =
false;
404 bool depthWriteEnable =
false;
405 bool usesStencilRef =
false;
412 float slopeScaledDepthBias = 0.0f;
413 bool blendEnable =
false;
415 int colorAttachmentCount = 1;
418 bool scissorEnable =
false;
422 float lineWidth = 1.0f;
431 return a.shaderPipeline ==
b.shaderPipeline
432 &&
a.samples ==
b.samples
433 &&
a.depthTestEnable ==
b.depthTestEnable
434 &&
a.depthWriteEnable ==
b.depthWriteEnable
435 &&
a.usesStencilRef ==
b.usesStencilRef
436 &&
a.stencilRef ==
b.stencilRef
438 &&
a.stencilWriteMask ==
b.stencilWriteMask
439 &&
a.depthFunc ==
b.depthFunc
440 &&
a.cullMode ==
b.cullMode
441 &&
a.depthBias ==
b.depthBias
442 &&
a.slopeScaledDepthBias ==
b.slopeScaledDepthBias
443 &&
a.blendEnable ==
b.blendEnable
444 &&
a.scissorEnable ==
b.scissorEnable
445 &&
a.viewport ==
b.viewport
446 &&
a.scissor ==
b.scissor
447 &&
a.ia.topology ==
b.ia.topology
448 &&
a.ia.inputLayout ==
b.ia.inputLayout
449 &&
a.targetBlend.colorWrite ==
b.targetBlend.colorWrite
450 &&
a.targetBlend.srcColor ==
b.targetBlend.srcColor
451 &&
a.targetBlend.dstColor ==
b.targetBlend.dstColor
452 &&
a.targetBlend.opColor ==
b.targetBlend.opColor
453 &&
a.targetBlend.srcAlpha ==
b.targetBlend.srcAlpha
454 &&
a.targetBlend.dstAlpha ==
b.targetBlend.dstAlpha
455 &&
a.targetBlend.opAlpha ==
b.targetBlend.opAlpha
456 &&
a.colorAttachmentCount ==
b.colorAttachmentCount
457 &&
a.lineWidth ==
b.lineWidth
458 &&
a.polygonMode ==
b.polygonMode;
471 ^
qHash(
s.targetBlend.dstColor)
474 ^
qHash(
s.colorAttachmentCount)
478 ^ (
s.depthTestEnable << 1)
479 ^ (
s.depthWriteEnable << 2)
480 ^ (
s.blendEnable << 3)
481 ^ (
s.scissorEnable << 4)
482 ^ (
s.usesStencilRef << 5)
483 ^ (
s.stencilRef << 6)
484 ^ (
s.stencilWriteMask << 7);
508 return a.state ==
b.state
509 &&
a.renderTargetDescription ==
b.renderTargetDescription
510 &&
a.srbLayoutDescription ==
b.srbLayoutDescription;
521 ^ k.extra.renderTargetDescriptionHash
522 ^ k.extra.srbLayoutDescriptionHash;
542 return a.shader ==
b.shader &&
a.srbLayoutDescription ==
b.srbLayoutDescription;
571 for (
int i = 0;
i <
p; ++
i)
577 if (
this != &
other) {
580 for (
int i = 0;
i <
p; ++
i)
596 for (
int i = 0;
i <
a.p; ++
i) {
597 if (
a.v[
i] !=
b.v[
i])
624 d->binding = binding;
629 d->u.ubuf.maybeSize =
size;
630 d->u.ubuf.hasDynamicOffset =
false;
644 d->binding = binding;
648 d->u.stex.texSamplers[0].tex = tex;
649 d->u.stex.texSamplers[0].sampler =
sampler;
686 return a.selector ==
b.selector &&
a.layer ==
b.layer &&
a.model ==
b.model &&
a.entry ==
b.entry &&
a.index ==
b.index;
775 ^
qHash(k.size.width() ^ k.size.height() ^ k.color.red() ^ k.color.green()
776 ^ k.color.blue() ^ k.color.alpha());
781 return a.flags ==
b.flags &&
a.size ==
b.size &&
a.color ==
b.color;
789#define QSSGRHICTX_STAT(ctx, f) for (bool qssgrhictxlog_enabled = ctx->stats().isEnabled(); qssgrhictxlog_enabled; qssgrhictxlog_enabled = false) ctx->stats().f
826 int currentRenderPassIndex = -1;
868 bool isEnabled()
const;
911 void endRenderPass();
912 void printRenderPass(
const RenderPassInfo &rp);
931 bool isValid()
const {
return m_rhi !=
nullptr; }
955 return m_drawCallData[
key];
983 static bool shaderDebuggingEnabled();
984 static bool editorMode();
988 return m_instanceBuffers[instanceTable];
993 return m_instanceBuffersLod[
model];
998 return m_particleData[particlesOrModel];
1005 void releaseCachedResources();
1008 QRhi *m_rhi =
nullptr;
1012 int m_mainSamples = 1;
bool contains(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QColor class provides colors based on RGB, HSV or CMYK values.
Type
Specifies storage type of buffer resource.
@ DoNotTrackResourcesForCompute
IndexFormat
Specifies the index data type.
PolygonMode
Specifies the polygon rasterization mode.
CompareOp
Specifies the depth or stencil comparison function.
CullMode
Specifies the culling mode.
Topology
Specifies the primitive topology.
static const QRhiShaderResourceBinding::Data * shaderResourceBindingData(const QRhiShaderResourceBinding &binding)
virtual QVector< quint32 > serializedFormat() const =0
Filter
Specifies the minification, magnification, or mipmap filtering.
AddressMode
Specifies the addressing mode.
QVector< quint32 > serializedLayoutDescription() const
QRhiBuffer * buffer() const
QRhiCommandBuffer::IndexFormat indexFormat() const
quint32 numVertices() const
void imageDataSizeChanges(quint64 newSize)
static bool rendererDebugEnabled()
static quint64 totalVertexCountForPass(const QSSGRhiContextStats::RenderPassInfo &pass)
void registerEffectShaderGenerationTime(qint64 ms)
void registerMaterialShaderGenerationTime(qint64 ms)
static bool profilingEnabled()
QSSGRhiContextStats(QSSGRhiContext &context)
void meshDataSizeChanges(quint64 newSize)
QHash< QSSGRenderLayer *, PerLayerInfo > perLayerInfo
static quint64 totalDrawCallCountForPass(const QSSGRhiContextStats::RenderPassInfo &pass)
QSet< QSSGRenderLayer * > dynamicDataSources
void setMainPassSampleCount(int samples)
int mainPassSampleCount() const
QSSGRhiInstanceBufferData & instanceBufferData(QSSGRenderInstanceTable *instanceTable)
void setMainRenderPassDescriptor(QRhiRenderPassDescriptor *rpDesc)
QRhiCommandBuffer * commandBuffer() const
int maxUniformBufferRange() const
static QRhiCommandBuffer::BeginPassFlags commonPassFlags()
QSet< QSSGRenderMesh * > registeredMeshes() const
QSSGRhiDrawCallData & drawCallData(const QSSGRhiDrawCallDataKey &key)
QSSGRhiContextStats & stats()
QSet< QRhiTexture * > registeredTextures() const
QSSGRhiParticleData & particleData(const QSSGRenderGraphObject *particlesOrModel)
void setRenderTarget(QRhiRenderTarget *rt)
QRhiRenderTarget * renderTarget() const
QRhiRenderPassDescriptor * mainRenderPassDescriptor() const
QHash< QSSGGraphicsPipelineStateKey, QRhiGraphicsPipeline * > pipelines() const
void setCommandBuffer(QRhiCommandBuffer *cb)
QSSGRhiInstanceBufferData & instanceBufferData(const QSSGRenderModel *model)
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
The QVector3D class represents a vector or vertex in 3D space.
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
std::pair< T1, T2 > QPair
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
GLenum GLenum GLsizei const GLuint GLboolean enabled
const void GLsizei GLsizei stride
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLuint * shaders
#define Q_QUICK3D_PROFILING_ENABLED
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
QSSGRenderTextureFilterOp
bool operator!=(const QSSGRhiSamplerDescription &a, const QSSGRhiSamplerDescription &b) Q_DECL_NOTHROW
std::shared_ptr< QSSGRhiBuffer > QSSGRhiBufferPtr
std::shared_ptr< QSSGRhiShaderPipeline > QSSGRhiShaderPipelinePtr
QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
#define QSSG_MAX_NUM_LIGHTS
bool operator==(const QSSGRhiSamplerDescription &a, const QSSGRhiSamplerDescription &b) Q_DECL_NOTHROW
QSSGRhiSamplerBindingHints
size_t qHash(const QSSGRhiGraphicsPipelineState &s, size_t seed) 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)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
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
struct QSSGComputePipelineStateKey::@761 extra
static QSSGComputePipelineStateKey create(const QShader &shader, const QRhiShaderResourceBindings *srb)
size_t srbLayoutDescriptionHash
QVector< quint32 > srbLayoutDescription
size_t srbLayoutDescriptionHash
static QSSGGraphicsPipelineStateKey create(const QSSGRhiGraphicsPipelineState &state, const QRhiRenderPassDescriptor *rpDesc, const QRhiShaderResourceBindings *srb)
QSSGRhiGraphicsPipelineState state
QVector< quint32 > srbLayoutDescription
struct QSSGGraphicsPipelineStateKey::@759 extra
QVector< quint32 > renderTargetDescription
size_t renderTargetDescriptionHash
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
QSSGRhiInputAssemblerState ia
QRhiGraphicsPipeline::TargetBlend targetBlend
const QSSGRhiShaderPipeline * shaderPipeline
QList< QSSGRhiSortData > sortData
QVector3D sortedCameraDirection
QList< QSSGRhiSortData > sortData
QRhiTextureRenderTarget * rt
QRhiRenderPassDescriptor * rpDesc
QRhiRenderBuffer * depthStencil
QRhiSampler::AddressMode hTiling
QRhiSampler::Filter minFilter
QRhiSampler::Filter magFilter
QRhiSampler::AddressMode vTiling
QRhiSampler::Filter mipmap
QRhiSampler::AddressMode zTiling
void addUniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size)
QSSGRhiShaderResourceBindingList()
static const int MAX_SIZE
void addTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
QSSGRhiShaderResourceBindingList(const QSSGRhiShaderResourceBindingList &other)
QSSGRhiShaderResourceBindingList & operator=(const QSSGRhiShaderResourceBindingList &other) Q_DECL_NOTHROW
QRhiTexture * shadowMapTexture
QByteArray shadowMapTextureUniformName
QSSGRhiSamplerDescription samplerDesc
float constantAttenuation
float quadraticAttenuation