5#include <QtQuick3DRuntimeRender/private/qssgrenderlayer_p.h>
6#include <QtQuick3DRuntimeRender/private/qssgrendershadowmap_p.h>
7#include <QtQuick3DRuntimeRender/private/qssglayerrenderdata_p.h>
8#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
13 : m_context(inContext)
25 entry.destroyRhiResources();
27 m_shadowMapList.
clear();
33 QRhiTexture::Flags
flags = {})
37 qWarning(
"Failed to create shadow map texture of size %dx%d",
size.width(),
size.height());
46 if (!renderBuffer->create())
47 qWarning(
"Failed to build depth-stencil buffer of size %dx%d",
size.width(),
size.height());
75 const QString &renderNodeObjName)
126 pEntry = &m_shadowMapList.
back();
134 pEntry = &m_shadowMapList.
back();
159 qWarning(
"Failed to build shadow map render target");
182 for (
int i = 0;
i < 6; ++
i)
201 qWarning(
"Failed to build shadow map render target");
239 static bool warned =
false;
242 qWarning(
"Cubemap-based shadow maps will not be blurred because MaxColorAttachments is less than 6");
255 for (
int i = 0;
i < m_shadowMapList.
size();
i++) {
265 : m_lightIndex(
std::numeric_limits<
quint32>::max())
277 e.m_lightIndex = lightIdx;
278 e.m_shadowMapMode =
mode;
279 e.m_rhiDepthMap = depthMap;
280 e.m_rhiDepthCopy = depthCopy;
281 e.m_rhiDepthStencil = depthStencil;
292 e.m_lightIndex = lightIdx;
293 e.m_shadowMapMode =
mode;
294 e.m_rhiDepthCube = depthCube;
295 e.m_rhiCubeCopy = cubeCopy;
296 e.m_rhiDepthStencil = depthStencil;
qsizetype size() const noexcept
void push_back(parameter_type t)
void setTexture(QRhiTexture *tex)
Sets the texture tex.
void setLayer(int layer)
Sets the layer index.
Type
Specifies the type of the renderbuffer.
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
Sets the QRhiRenderPassDescriptor desc for use with this render target.
void setName(const QByteArray &name)
Sets a name for the object.
void setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer)
Sets the renderBuffer for depth-stencil.
void setColorAttachments(std::initializer_list< QRhiColorAttachment > list)
Sets the list of color attachments.
void setDescription(const QRhiTextureRenderTargetDescription &desc)
Sets the render target description desc.
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor()=0
virtual bool create()=0
Creates the corresponding native graphics resources.
Format
Specifies the texture format.
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags={}) const
int resourceLimit(ResourceLimit limit) const
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
static const char * displayName(QSSGRenderTextureCubeFace face)
const std::unique_ptr< QSSGRhiContext > & rhiContext() const
const QSSGRenderContextInterface & m_context
QSSGRenderShadowMap(const QSSGRenderContextInterface &inContext)
void releaseCachedResources()
QSSGShadowMapEntry * shadowMapEntry(int lightIdx)
void addShadowMapEntry(qint32 lightIdx, qint32 width, qint32 height, ShadowMapModes mode, const QString &renderNodeObjName)
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
constexpr size_type size() const noexcept
void resize(qsizetype sz)
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum format
static constexpr QSSGRenderTextureCubeFace QSSGRenderTextureCubeFaces[]
static QRhiTexture * allocateRhiShadowTexture(QRhi *rhi, QRhiTexture::Format format, const QSize &size, QRhiTexture::Flags flags={})
static QRhiRenderBuffer * allocateRhiShadowRenderBuffer(QRhi *rhi, QRhiRenderBuffer::Type type, const QSize &size)
static void setupForRhiDepth(QRhi *rhi, QSSGShadowMapEntry *entry, const QSize &size, QRhiTexture::Format format)
static void setupForRhiDepthCube(QRhi *rhi, QSSGShadowMapEntry *entry, const QSize &size, QRhiTexture::Format format)
@ VSM
variance shadow mapping
@ CUBE
cubemap omnidirectional shadows
QRhiTexture * m_rhiDepthCopy
QRhiTextureRenderTarget * m_rhiBlurRenderTarget0
QRhiTexture * m_rhiCubeCopy
QRhiTexture * m_rhiDepthMap
QRhiRenderPassDescriptor * m_rhiRenderPassDesc
QVarLengthArray< QRhiTextureRenderTarget *, 6 > m_rhiRenderTargets
static QSSGShadowMapEntry withRhiDepthCubeMap(quint32 lightIdx, ShadowMapModes mode, QRhiTexture *depthCube, QRhiTexture *cubeCopy, QRhiRenderBuffer *depthStencil)
QRhiRenderBuffer * m_rhiDepthStencil
void destroyRhiResources()
QRhiRenderPassDescriptor * m_rhiBlurRenderPassDesc
ShadowMapModes m_shadowMapMode
shadow map method
QRhiTextureRenderTarget * m_rhiBlurRenderTarget1
static QSSGShadowMapEntry withRhiDepthMap(quint32 lightIdx, ShadowMapModes mode, QRhiTexture *depthMap, QRhiTexture *depthCopy, QRhiRenderBuffer *depthStencil)
QRhiTexture * m_rhiDepthCube
quint32 m_lightIndex
the light index it belongs to