rhi: backends: Get color attachment count in a saner way
Also bring all list-like data to the same level when it comes to the interface exposed in QRhi*. Change-Id: I90296a49ff1f52c1ce4e787167c99006fab3c4c3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>bb10
parent
c6b7737436
commit
6cf3447f1d
|
|
@ -228,7 +228,8 @@ public:
|
|||
}
|
||||
const QRhiVertexInputBinding *cbeginBindings() const { return m_bindings.cbegin(); }
|
||||
const QRhiVertexInputBinding *cendBindings() const { return m_bindings.cend(); }
|
||||
const QRhiVertexInputBinding *bindingAt(int index) const { return &m_bindings.at(index); }
|
||||
const QRhiVertexInputBinding *bindingAt(qsizetype index) const { return &m_bindings.at(index); }
|
||||
qsizetype bindingCount() const { return m_bindings.count(); }
|
||||
|
||||
void setAttributes(std::initializer_list<QRhiVertexInputAttribute> list) { m_attributes = list; }
|
||||
template<typename InputIterator>
|
||||
|
|
@ -239,6 +240,8 @@ public:
|
|||
}
|
||||
const QRhiVertexInputAttribute *cbeginAttributes() const { return m_attributes.cbegin(); }
|
||||
const QRhiVertexInputAttribute *cendAttributes() const { return m_attributes.cend(); }
|
||||
const QRhiVertexInputAttribute *attributeAt(qsizetype index) const { return &m_attributes.at(index); }
|
||||
qsizetype attributeCount() const { return m_attributes.count(); }
|
||||
|
||||
private:
|
||||
QVarLengthArray<QRhiVertexInputBinding, 8> m_bindings;
|
||||
|
|
@ -494,7 +497,8 @@ public:
|
|||
}
|
||||
const QRhiColorAttachment *cbeginColorAttachments() const { return m_colorAttachments.cbegin(); }
|
||||
const QRhiColorAttachment *cendColorAttachments() const { return m_colorAttachments.cend(); }
|
||||
const QRhiColorAttachment *colorAttachmentAt(int index) const { return &m_colorAttachments.at(index); }
|
||||
const QRhiColorAttachment *colorAttachmentAt(qsizetype index) const { return &m_colorAttachments.at(index); }
|
||||
qsizetype colorAttachmentCount() const { return m_colorAttachments.count(); }
|
||||
|
||||
QRhiRenderBuffer *depthStencilBuffer() const { return m_depthStencilBuffer; }
|
||||
void setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer) { m_depthStencilBuffer = renderBuffer; }
|
||||
|
|
@ -584,6 +588,8 @@ public:
|
|||
}
|
||||
const QRhiTextureUploadEntry *cbeginEntries() const { return m_entries.cbegin(); }
|
||||
const QRhiTextureUploadEntry *cendEntries() const { return m_entries.cend(); }
|
||||
const QRhiTextureUploadEntry *entryAt(qsizetype index) const { return &m_entries.at(index); }
|
||||
qsizetype entryCount() const { return m_entries.count(); }
|
||||
|
||||
private:
|
||||
QVarLengthArray<QRhiTextureUploadEntry, 16> m_entries;
|
||||
|
|
@ -1058,16 +1064,16 @@ public:
|
|||
QRhiResource::Type resourceType() const override;
|
||||
|
||||
void setBindings(std::initializer_list<QRhiShaderResourceBinding> list) { m_bindings = list; }
|
||||
|
||||
template<typename InputIterator>
|
||||
void setBindings(InputIterator first, InputIterator last)
|
||||
{
|
||||
m_bindings.clear();
|
||||
std::copy(first, last, std::back_inserter(m_bindings));
|
||||
}
|
||||
|
||||
const QRhiShaderResourceBinding *cbeginBindings() const { return m_bindings.cbegin(); }
|
||||
const QRhiShaderResourceBinding *cendBindings() const { return m_bindings.cend(); }
|
||||
const QRhiShaderResourceBinding *bindingAt(qsizetype index) const { return &m_bindings.at(index); }
|
||||
qsizetype bindingCount() const { return m_bindings.count(); }
|
||||
|
||||
bool isLayoutCompatible(const QRhiShaderResourceBindings *other) const;
|
||||
|
||||
|
|
@ -1241,6 +1247,8 @@ public:
|
|||
}
|
||||
const TargetBlend *cbeginTargetBlends() const { return m_targetBlends.cbegin(); }
|
||||
const TargetBlend *cendTargetBlends() const { return m_targetBlends.cend(); }
|
||||
const TargetBlend *targetBlendAt(qsizetype index) const { return &m_targetBlends.at(index); }
|
||||
qsizetype targetBlendCount() const { return m_targetBlends.count(); }
|
||||
|
||||
bool hasDepthTest() const { return m_depthTest; }
|
||||
void setDepthTest(bool enable) { m_depthTest = enable; }
|
||||
|
|
@ -1287,6 +1295,8 @@ public:
|
|||
}
|
||||
const QRhiShaderStage *cbeginShaderStages() const { return m_shaderStages.cbegin(); }
|
||||
const QRhiShaderStage *cendShaderStages() const { return m_shaderStages.cend(); }
|
||||
const QRhiShaderStage *shaderStageAt(qsizetype index) const { return &m_shaderStages.at(index); }
|
||||
qsizetype shaderStageCount() const { return m_shaderStages.count(); }
|
||||
|
||||
QRhiVertexInputLayout vertexInputLayout() const { return m_vertexInputLayout; }
|
||||
void setVertexInputLayout(const QRhiVertexInputLayout &layout) { m_vertexInputLayout = layout; }
|
||||
|
|
|
|||
|
|
@ -739,9 +739,8 @@ inline bool operator!=(const QRhiRenderTargetAttachmentTracker::ResId &a, const
|
|||
template<typename TexType, typename RenderBufferType>
|
||||
void QRhiRenderTargetAttachmentTracker::updateResIdList(const QRhiTextureRenderTargetDescription &desc, ResIdList *dst)
|
||||
{
|
||||
const quintptr colorAttCount = desc.cendColorAttachments() - desc.cbeginColorAttachments();
|
||||
const bool hasDepthStencil = desc.depthStencilBuffer() || desc.depthTexture();
|
||||
dst->resize(colorAttCount * 2 + (hasDepthStencil ? 1 : 0));
|
||||
dst->resize(desc.colorAttachmentCount() * 2 + (hasDepthStencil ? 1 : 0));
|
||||
int n = 0;
|
||||
for (auto it = desc.cbeginColorAttachments(), itEnd = desc.cendColorAttachments(); it != itEnd; ++it, ++n) {
|
||||
const QRhiColorAttachment &colorAtt(*it);
|
||||
|
|
|
|||
|
|
@ -3671,8 +3671,7 @@ bool QD3D11TextureRenderTarget::create()
|
|||
if (rtv[0] || dsv)
|
||||
destroy();
|
||||
|
||||
const bool hasColorAttachments = m_desc.cbeginColorAttachments() != m_desc.cendColorAttachments();
|
||||
Q_ASSERT(hasColorAttachments || m_desc.depthTexture());
|
||||
Q_ASSERT(m_desc.colorAttachmentCount() > 0 || m_desc.depthTexture());
|
||||
Q_ASSERT(!m_desc.depthStencilBuffer() || !m_desc.depthTexture());
|
||||
const bool hasDepthStencil = m_desc.depthStencilBuffer() || m_desc.depthTexture();
|
||||
|
||||
|
|
|
|||
|
|
@ -4230,8 +4230,7 @@ bool QD3D12TextureRenderTarget::create()
|
|||
destroy();
|
||||
|
||||
QRHI_RES_RHI(QRhiD3D12);
|
||||
const bool hasColorAttachments = m_desc.cbeginColorAttachments() != m_desc.cendColorAttachments();
|
||||
Q_ASSERT(hasColorAttachments || m_desc.depthTexture());
|
||||
Q_ASSERT(m_desc.colorAttachmentCount() > 0 || m_desc.depthTexture());
|
||||
Q_ASSERT(!m_desc.depthStencilBuffer() || !m_desc.depthTexture());
|
||||
const bool hasDepthStencil = m_desc.depthStencilBuffer() || m_desc.depthTexture();
|
||||
d.colorAttCount = 0;
|
||||
|
|
|
|||
|
|
@ -5428,13 +5428,13 @@ bool QGles2TextureRenderTarget::create()
|
|||
if (framebuffer)
|
||||
destroy();
|
||||
|
||||
const bool hasColorAttachments = m_desc.cbeginColorAttachments() != m_desc.cendColorAttachments();
|
||||
const bool hasColorAttachments = m_desc.colorAttachmentCount() > 0;
|
||||
Q_ASSERT(hasColorAttachments || m_desc.depthTexture());
|
||||
Q_ASSERT(!m_desc.depthStencilBuffer() || !m_desc.depthTexture());
|
||||
const bool hasDepthStencil = m_desc.depthStencilBuffer() || m_desc.depthTexture();
|
||||
|
||||
if (hasColorAttachments) {
|
||||
const int count = m_desc.cendColorAttachments() - m_desc.cbeginColorAttachments();
|
||||
const int count = int(m_desc.colorAttachmentCount());
|
||||
if (count > rhiD->caps.maxDrawBuffers) {
|
||||
qWarning("QGles2TextureRenderTarget: Too many color attachments (%d, max is %d)",
|
||||
count, rhiD->caps.maxDrawBuffers);
|
||||
|
|
|
|||
|
|
@ -4036,7 +4036,7 @@ void QMetalTextureRenderTarget::destroy()
|
|||
|
||||
QRhiRenderPassDescriptor *QMetalTextureRenderTarget::newCompatibleRenderPassDescriptor()
|
||||
{
|
||||
const int colorAttachmentCount = m_desc.cendColorAttachments() - m_desc.cbeginColorAttachments();
|
||||
const int colorAttachmentCount = int(m_desc.colorAttachmentCount());
|
||||
QMetalRenderPassDescriptor *rpD = new QMetalRenderPassDescriptor(m_rhi);
|
||||
rpD->colorAttachmentCount = colorAttachmentCount;
|
||||
rpD->hasDepthStencil = m_desc.depthStencilBuffer() || m_desc.depthTexture();
|
||||
|
|
@ -4060,8 +4060,7 @@ QRhiRenderPassDescriptor *QMetalTextureRenderTarget::newCompatibleRenderPassDesc
|
|||
bool QMetalTextureRenderTarget::create()
|
||||
{
|
||||
QRHI_RES_RHI(QRhiMetal);
|
||||
const bool hasColorAttachments = m_desc.cbeginColorAttachments() != m_desc.cendColorAttachments();
|
||||
Q_ASSERT(hasColorAttachments || m_desc.depthTexture());
|
||||
Q_ASSERT(m_desc.colorAttachmentCount() > 0 || m_desc.depthTexture());
|
||||
Q_ASSERT(!m_desc.depthStencilBuffer() || !m_desc.depthTexture());
|
||||
const bool hasDepthStencil = m_desc.depthStencilBuffer() || m_desc.depthTexture();
|
||||
|
||||
|
|
|
|||
|
|
@ -6493,8 +6493,7 @@ bool QVkTextureRenderTarget::create()
|
|||
if (d.fb)
|
||||
destroy();
|
||||
|
||||
const bool hasColorAttachments = m_desc.cbeginColorAttachments() != m_desc.cendColorAttachments();
|
||||
Q_ASSERT(hasColorAttachments || m_desc.depthTexture());
|
||||
Q_ASSERT(m_desc.colorAttachmentCount() > 0 || m_desc.depthTexture());
|
||||
Q_ASSERT(!m_desc.depthStencilBuffer() || !m_desc.depthTexture());
|
||||
const bool hasDepthStencil = m_desc.depthStencilBuffer() || m_desc.depthTexture();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue