7#include <QtQuick3DUtils/private/qssgutils_p.h> 
    9#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h> 
   10#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h> 
   11#include <QtQuick3DRuntimeRender/private/qssgrendermesh_p.h> 
   12#include <QtQuick3DRuntimeRender/private/qssgrendercamera_p.h> 
   13#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h> 
   14#include <QtQuick3DRuntimeRender/private/qssgrenderlayer_p.h> 
   15#include <QtQuick3DRuntimeRender/private/qssgrenderableimage_p.h> 
   16#include <QtQuick3DRuntimeRender/private/qssgvertexpipelineimpl_p.h> 
   17#include <QtQuick3DRuntimeRender/private/qssglayerrenderdata_p.h> 
   18#include <QtQuick3DRuntimeRender/private/qssgrendermodel_p.h> 
   19#include <QtQuick3DRuntimeRender/private/qssgruntimerenderlogging_p.h> 
   20#include <QtQuick3DRuntimeRender/private/qssgrhiparticles_p.h> 
   21#include <qtquick3d_tracepoints_p.h> 
   23#include <QtCore/qbitarray.h> 
   71    auto it = shaderMap.
find(skey);
 
   72    if (
it == shaderMap.
end()) {
 
   76        matKey.
toString(shaderString, context->
renderer()->defaultMaterialShaderKeyProperties());
 
   82        if (!shaderPipeline) {
 
   87                                                      context->
renderer()->defaultMaterialShaderKeyProperties(),
 
   93                                                                                    context->
renderer()->defaultMaterialShaderKeyProperties(),
 
  106        shaderMap.
insert(skey, shaderPipeline);
 
  108        shaderPipeline = 
it.value();
 
  111    if (shaderPipeline) {
 
  116    context->
rhiContext()->stats().registerMaterialShaderGenerationTime(
timer.elapsed());
 
  118    return shaderPipeline;
 
  132    const QMatrix4x4 &mvp(alteredModelViewProjection ? *alteredModelViewProjection
 
  139    const QMatrix4x4 &localInstanceTransform(modelNode.localInstanceTransform);
 
  140    const QMatrix4x4 &globalInstanceTransform(modelNode.globalInstanceTransform);
 
  151                                                          context->
renderer()->defaultMaterialShaderKeyProperties(),
 
  157                                                          localInstanceTransform,
 
  158                                                          globalInstanceTransform,
 
  204    if (shaderPipeline) {
 
  218        shaderPipeline->ensureCombinedMainLightsUniformBuffer(&dcd.
ubuf);
 
  230        bool instancing = 
false;
 
  245        int instanceBufferBinding = 0;
 
  252                      std::back_inserter(bindings));
 
  254            instanceBufferBinding = bindings.
size() - 1;
 
  267                                  shaderPipeline->ub0LightDataOffset(),
 
  268                                  shaderPipeline->ub0LightDataSize());
 
  271                shaderPipeline->fragmentStage()->shader().description().combinedImageSamplers();
 
  273            auto it = std::find_if(samplerVars.
cbegin(), samplerVars.
cend(),
 
  275            if (
it == samplerVars.
cend())
 
  279        int maxSamplerBinding = -1;
 
  281            maxSamplerBinding = 
qMax(maxSamplerBinding, 
var.binding);
 
  290        QBitArray samplerBindingsSpecified(maxSamplerBinding + 1);
 
  293            samplerBindingsSpecified.
setBit(shaderPipeline->bindingForTexture(
"qt_particleTexture"));
 
  297            int binding = shaderPipeline->bindingForTexture(
"qt_boneTexture");
 
  310                samplerBindingsSpecified.
setBit(binding);
 
  316        if (targetsTexture) {
 
  317            int binding = shaderPipeline->bindingForTexture(
"qt_morphTargetTexture");
 
  327                samplerBindingsSpecified.
setBit(binding);
 
  335            int reflectionSampler = shaderPipeline->bindingForTexture(
"qt_reflectionMap");
 
  339            if (reflectionSampler >= 0 && reflectionTexture) {
 
  341                samplerBindingsSpecified.
setBit(reflectionSampler);
 
  343        } 
else if (shaderPipeline->lightProbeTexture()) {
 
  346                samplerBindingsSpecified.
setBit(binding);
 
  352                                    shaderPipeline->lightProbeTexture(), 
sampler);
 
  356        if (shaderPipeline->screenTexture()) {
 
  359                samplerBindingsSpecified.
setBit(binding);
 
  370                                    shaderPipeline->screenTexture(), 
sampler);
 
  374        if (shaderPipeline->depthTexture()) {
 
  377                samplerBindingsSpecified.
setBit(binding);
 
  383                                    shaderPipeline->depthTexture(), 
sampler);
 
  387        if (shaderPipeline->ssaoTexture()) {
 
  390                samplerBindingsSpecified.
setBit(binding);
 
  396                                    shaderPipeline->ssaoTexture(), 
sampler);
 
  400        if (shaderPipeline->lightmapTexture()) {
 
  403                samplerBindingsSpecified.
setBit(binding);
 
  408                                    shaderPipeline->lightmapTexture(), 
sampler);
 
  412        const int shadowMapCount = shaderPipeline->shadowMapCount();
 
  413        for (
int i = 0; 
i < shadowMapCount; ++
i) {
 
  431        while (renderableImage) {
 
  433            const int samplerHint = int(renderableImage->
m_mapType);
 
  434            int samplerBinding = shaderPipeline->bindingForTexture(samplerName, samplerHint);
 
  435            if (samplerBinding >= 0) {
 
  437                if (samplerBinding >= 0 && 
texture) {
 
  449                    samplerBindingsSpecified.
setBit(samplerBinding);
 
  458        if (maxSamplerBinding >= 0) {
 
  460            int customTexCount = shaderPipeline->extraTextureCount();
 
  461            for (
int i = 0; 
i < customTexCount; ++
i) {
 
  463                const int samplerBinding = shaderPipeline->bindingForTexture(
t.name);
 
  464                if (samplerBinding >= 0) {
 
  465                    samplerBindingsSpecified.
setBit(samplerBinding);
 
  480                if (!samplerBindingsSpecified.
testBit(
var.binding)) {
 
  489        bool srbChanged = 
false;
 
  490        if (!srb || bindings != dcd.
bindings) {
 
  491            srb = rhiCtx->
srb(bindings);
 
  515                                                                              renderPassDescriptor,
 
  520                                                                                    renderPassDescriptor,
 
  532void QSSGCustomMaterialSystem::setShaderResources(
char *ubufData,
 
  555                      toRhi(textureProperty->horizontalClampType),
 
  556                      toRhi(textureProperty->verticalClampType),
 
  564        shaderPipeline.
setUniformValue(ubufData, inPropertyName, propertyValue, inPropertyType);
 
  574        setShaderResources(ubufData, material, prop.name, prop.value, prop.shaderDataType, shaderPipeline);
 
  577    for (
const auto &prop : textProps)
 
  578        setShaderResources(ubufData, material, prop.name, 
QVariant::fromValue((
void *)&prop), prop.shaderDataType, shaderPipeline);
 
  583                                                   bool *needsSetViewport,
 
  603    cb->setGraphicsPipeline(ps);
 
  604    cb->setShaderResources(srb);
 
  606    if (*needsSetViewport) {
 
  607        cb->setViewport(
state.viewport);
 
  608        *needsSetViewport = 
false;
 
bool testBit(qsizetype i) const
Returns true if the bit at index position i is 1; otherwise returns false.
 
void setBit(qsizetype i)
Sets the bit at index position i to 1.
 
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
 
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
 
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
 
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
 
const_iterator cend() const noexcept
 
void append(parameter_type t)
 
const_iterator cbegin() const noexcept
 
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
 
static FeatureSet toFeatureSet(const T &ssgFeatureSet)
 
virtual char * beginFullDynamicBufferUpdateForCurrentFrame()
 
virtual void endFullDynamicBufferUpdateForCurrentFrame()
To be called when the entire contents of the buffer data has been updated in the memory block returne...
 
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
 
void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates)
Sometimes committing resource updates is necessary or just more convenient without starting a render ...
 
Filter
Specifies the minification, magnification, or mipmap filtering.
 
QMatrix4x4 clipSpaceCorrMatrix() const
 
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
 
void rhiRenderRenderable(QSSGRhiContext *rhiCtx, QSSGSubsetRenderable &renderable, bool *needsSetViewport, int cubeFace, const QSSGRhiGraphicsPipelineState &state)
 
void applyRhiShaderPropertyValues(char *ubufData, const QSSGRenderCustomMaterial &inMaterial, QSSGRhiShaderPipeline &shaderPipeline)
 
void setRenderContextInterface(QSSGRenderContextInterface *inContext)
 
void updateUniformsForCustomMaterial(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, char *ubufData, QSSGRhiGraphicsPipelineState *ps, const QSSGRenderCustomMaterial &material, QSSGSubsetRenderable &renderable, const QSSGRenderCamera &camera, const QVector2D *depthAdjust, const QMatrix4x4 *alteredModelViewProjection)
 
bool prepareForRender(const QSSGRenderModel &inModel, const QSSGRenderSubset &inSubset, QSSGRenderCustomMaterial &inMaterial)
 
void releaseCachedResources()
 
void rhiPrepareRenderable(QSSGRhiGraphicsPipelineState *ps, QSSGPassKey passKey, QSSGSubsetRenderable &renderable, const QSSGShaderFeatures &featureSet, const QSSGRenderCustomMaterial &material, const QSSGLayerRenderData &layerData, QRhiRenderPassDescriptor *renderPassDescriptor, int samples, QSSGRenderCamera *camera=nullptr, int cubeFace=-1, QMatrix4x4 *modelViewProjection=nullptr, QSSGReflectionMapEntry *entry=nullptr)
 
QSSGRhiShaderPipelinePtr shadersForCustomMaterial(QSSGRhiGraphicsPipelineState *ps, const QSSGRenderCustomMaterial &material, QSSGSubsetRenderable &renderable, const QSSGShaderFeatures &featureSet)
 
~QSSGCustomMaterialSystem()
 
QSSGCustomMaterialSystem()
 
QRhiTexture * getLightmapTexture(const QSSGModelContext &modelContext) const
 
const QSSGRenderReflectionMapPtr & getReflectionMapManager() const
 
QSSGRenderCamera * camera
 
QRhiTexture * getBonemapTexture(const QSSGModelContext &modelContext) const
 
std::optional< QSSGCameraRenderData > cameraData
 
static void updateUniformsForParticleModel(QSSGRhiShaderPipeline &shaderPipeline, char *ubufData, const QSSGRenderModel *model, quint32 offset)
 
static void prepareParticlesForModel(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, QSSGRhiShaderResourceBindingList &bindings, const QSSGRenderModel *model)
 
const std::unique_ptr< QSSGRhiContext > & rhiContext() const
 
const std::unique_ptr< QSSGProgramGenerator > & shaderProgramGenerator() const
 
const std::shared_ptr< QSSGShaderLibraryManager > & shaderLibraryManager() const
 
const std::unique_ptr< QSSGBufferManager > & bufferManager() const
 
const std::unique_ptr< QSSGRenderer > & renderer() const
 
const std::unique_ptr< QSSGShaderCache > & shaderCache() const
 
QSSGShaderDefaultMaterialKeyProperties & defaultMaterialShaderKeyProperties()
 
QSSGLayerGlobalRenderProperties getLayerGlobalRenderProperties()
 
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)
 
void checkAndAdjustForNPoT(QRhiTexture *texture, QSSGRhiSamplerDescription *samplerDescription)
 
QRhiShaderResourceBindings * srb(const QSSGRhiShaderResourceBindingList &bindings)
 
QRhiGraphicsPipeline * pipeline(const QSSGGraphicsPipelineStateKey &key, QRhiRenderPassDescriptor *rpDesc, QRhiShaderResourceBindings *srb)
 
QRhiSampler * sampler(const QSSGRhiSamplerDescription &samplerDescription)
 
void setUniformValue(char *ubufData, const char *name, const QVariant &value, QSSGRenderShaderDataType type)
 
void resetExtraTextures()
 
void addExtraTexture(const QSSGRhiTexture &t)
 
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
 
constexpr size_type size() const noexcept
 
const_iterator cbegin() const noexcept
 
const_iterator cend() const noexcept
 
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
 
The QVector2D class represents a vector or vertex in 2D space.
 
QSet< QString >::iterator it
 
Combined button and popup list for selecting options.
 
std::pair< T1, T2 > QPair
 
static const QCssKnownValue properties[NumProperties - 1]
 
constexpr const T & qMax(const T &a, const T &b)
 
GLsizei const GLfloat * v
[13]
 
const void GLsizei GLsizei stride
 
const void GLsizei GLsizei GLint vertexBufferCount
 
#define Q_QUICK3D_PROFILE_START(Type)
 
#define Q_QUICK3D_PROFILE_END_WITH_ID(Type, Payload, POID)
 
#define Q_QUICK3D_PROFILE_END_WITH_IDS(Type, Payload, POIDs)
 
QSSGDataView< T > toDataView(const T &type)
 
#define QSSGRHICTX_STAT(ctx, f)
 
std::shared_ptr< QSSGRhiShaderPipeline > QSSGRhiShaderPipelinePtr
 
QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
 
static const QRhiShaderResourceBinding::StageFlags CUSTOM_MATERIAL_VISIBILITY_ALL
 
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
 
#define Q_TRACE_SCOPE(x,...)
 
#define Q_TRACE_POINT(provider, tracepoint,...)
 
unsigned long long quint64
 
myFilter draw(painter, QPoint(0, 0), originalPixmap)
 
QByteArray generateSha() const
 
static QSSGGraphicsPipelineStateKey create(const QSSGRhiGraphicsPipelineState &state, const QRhiRenderPassDescriptor *rpDesc, const QRhiShaderResourceBindings *srb)
 
struct QSSGGraphicsPipelineStateKey::@759 extra
 
QVector< quint32 > renderTargetDescription
 
size_t renderTargetDescriptionHash
 
static QSSGRhiShaderPipelinePtr generateMaterialRhiShader(const QByteArray &inShaderKeyPrefix, QSSGMaterialVertexPipeline &vertexGenerator, const QSSGShaderDefaultMaterialKey &key, QSSGShaderDefaultMaterialKeyProperties &inProperties, const QSSGShaderFeatures &inFeatureSet, const QSSGRenderGraphObject &inMaterial, const QSSGShaderLightListView &inLights, QSSGRenderableImage *inFirstImage, QSSGShaderLibraryManager &shaderLibraryManager, QSSGShaderCache &theCache)
 
static const char * getSamplerName(QSSGRenderableImage::Type type)
 
static void setRhiMaterialProperties(const QSSGRenderContextInterface &, QSSGRhiShaderPipeline &shaders, char *ubufData, QSSGRhiGraphicsPipelineState *inPipelineState, const QSSGRenderGraphObject &inMaterial, const QSSGShaderDefaultMaterialKey &inKey, QSSGShaderDefaultMaterialKeyProperties &inProperties, const QSSGRenderCamera &inCamera, const QMatrix4x4 &inModelViewProjection, const QMatrix3x3 &inNormalMatrix, const QMatrix4x4 &inGlobalTransform, const QMatrix4x4 &clipSpaceCorrMatrix, const QMatrix4x4 &localInstanceTransform, const QMatrix4x4 &globalInstanceTransform, const QSSGDataView< float > &inMorphWeights, QSSGRenderableImage *inFirstImage, float inOpacity, const QSSGLayerGlobalRenderProperties &inRenderProperties, const QSSGShaderLightListView &inLights, const QSSGShaderReflectionProbe &reflectionProbe, bool receivesShadows, bool receivesReflections, const QVector2D *shadowDepthAdjust, QRhiTexture *lightmapTexture)
 
QMatrix4x4 modelViewProjection
 
const QSSGRenderModel & model
 
QSSGRenderTextureFilterOp mipFilterType
 
QSSGRenderTextureFilterOp magFilterType
 
QSSGRenderTextureFilterOp minFilterType
 
QSSGRenderImage * texImage
 
QRhiGraphicsPipeline::BlendFactor m_srcBlend
 
RenderFlags m_renderFlags
 
QSSGShaderMaterialAdapter * adapter
 
QRhiGraphicsPipeline::BlendFactor m_dstBlend
 
PropertyList m_properties
 
TexturePropertyList m_textureProperties
 
QByteArray m_shaderPathKey
 
QSSGCullFaceMode m_cullMode
 
QSSGRenderTextureFilterOp m_mipFilterType
 
QSSGRenderTextureCoordOp m_horizontalTilingMode
 
QSSGRenderTextureFilterOp m_minFilterType
 
QSSGRenderTextureCoordOp m_verticalTilingMode
 
QSSGRenderTextureFilterOp m_magFilterType
 
int instanceCount() const
 
QSSGRenderInstanceTable * instanceTable
 
QSSGRhiBufferPtr indexBuffer
 
QSSGRhiInputAssemblerState ia
 
QRhiTexture * targetsTexture
 
QSSGRhiBufferPtr vertexBuffer
 
struct QSSGRenderSubset::@751 rhi
 
QSSGRenderImageTexture m_texture
 
QSSGRenderableImage * m_nextImage
 
const QSSGRenderImage & m_imageNode
 
bool receivesReflections() const
 
const QMatrix4x4 & globalTransform
 
QSSGRenderableObjectFlags renderableFlags
 
QSSGRhiShaderResourceBindingList bindings
 
QSSGRhiGraphicsPipelineState ps
 
QRhiShaderResourceBindings * srb
 
QVector< quint32 > renderTargetDescription
 
QRhiGraphicsPipeline * pipeline
 
size_t renderTargetDescriptionHash
 
QSSGRhiInputAssemblerState ia
 
QRhiGraphicsPipeline::CullMode cullMode
 
static QRhiGraphicsPipeline::CullMode toCullMode(QSSGCullFaceMode cullFaceMode)
 
QRhiGraphicsPipeline::TargetBlend targetBlend
 
const QSSGRhiShaderPipeline * shaderPipeline
 
void addUniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size)
 
void addTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
 
QRhiTexture * shadowMapTexture
 
QByteArray shadowMapTextureUniformName
 
QSSGShaderKeyBoolean m_blendParticles
 
void toString(QByteArray &ioString, const QSSGShaderDefaultMaterialKeyProperties &inProperties) const
 
constexpr bool isSet(Feature feature) const
 
bool getValue(QSSGDataView< quint32 > inDataStore) const
 
QRhiGraphicsPipeline * pipeline
 
bool prepareInstancing(QSSGRhiContext *rhiCtx, const QVector3D &cameraDirection, const QVector3D &cameraPosition, float minThreshold, float maxThreshold)
 
const QSSGShaderLightListView & lights
 
struct QSSGSubsetRenderable::@762 rhiRenderData
 
QSSGShaderReflectionProbe reflectionProbe
 
struct QSSGSubsetRenderable::@762::@763 mainPass
 
const QSSGRenderSubset & subset
 
struct QSSGSubsetRenderable::@762::@766 reflectionPass
 
QRhiShaderResourceBindings * srb
 
QRhiBuffer * instanceBuffer
 
QSSGShaderDefaultMaterialKey shaderDescription
 
QSSGRenderableImage * firstImage
 
const QSSGModelContext & modelContext
 
const QSSGRenderGraphObject & material