Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Laszlo Agocs
qtrhi
Commits
2764ee1c
Commit
2764ee1c
authored
Feb 11, 2019
by
Laszlo Agocs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add layout compatibility query for srbs
Plus some doc cleanups.
parent
1540f4f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
31 deletions
+85
-31
src/rhi/qrhi.cpp
src/rhi/qrhi.cpp
+81
-31
src/rhi/qrhi.h
src/rhi/qrhi.h
+4
-0
No files found.
src/rhi/qrhi.cpp
View file @
2764ee1c
...
...
@@ -417,7 +417,7 @@ QRhiColorClearValue::QRhiColorClearValue(float r, float g, float b, float a)
}
/*!
R
eturn
s
\c true if the colors in the two QRhiColorClearValue objects \a a
\r
eturn \c true if the colors in the two QRhiColorClearValue objects \a a
and \a b are equal.
\relates QRhiColorClearValue
...
...
@@ -428,7 +428,7 @@ bool operator==(const QRhiColorClearValue &a, const QRhiColorClearValue &b) Q_DE
}
/*!
R
eturn
s
\c false if the colors in the two QRhiColorClearValue objects \a a
\r
eturn \c false if the colors in the two QRhiColorClearValue objects \a a
and \a b are equal; otherwise returns \c true.
\relates QRhiColorClearValue
...
...
@@ -439,7 +439,7 @@ bool operator!=(const QRhiColorClearValue &a, const QRhiColorClearValue &b) Q_DE
}
/*!
R
eturn
s
the hash value for \a v, using \a seed to seed the calculation.
\r
eturn the hash value for \a v, using \a seed to seed the calculation.
\relates QRhiColorClearValue
*/
...
...
@@ -476,7 +476,7 @@ QRhiDepthStencilClearValue::QRhiDepthStencilClearValue(float d, quint32 s)
}
/*!
R
eturn
s
\c true if the values in the two QRhiDepthStencilClearValue objects
\r
eturn \c true if the values in the two QRhiDepthStencilClearValue objects
\a a and \a b are equal.
\relates QRhiDepthStencilClearValue
...
...
@@ -488,7 +488,7 @@ bool operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClear
}
/*!
R
eturn
s
\c false if the values in the two QRhiDepthStencilClearValue
\r
eturn \c false if the values in the two QRhiDepthStencilClearValue
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiDepthStencilClearValue
...
...
@@ -499,7 +499,7 @@ bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClear
}
/*!
R
eturn
s
the hash value for \a v, using \a seed to seed the calculation.
\r
eturn the hash value for \a v, using \a seed to seed the calculation.
\relates QRhiDepthStencilClearValue
*/
...
...
@@ -561,7 +561,7 @@ QRhiViewport::QRhiViewport(float x, float y, float w, float h, float minDepth, f
}
/*!
R
eturn
s
\c true if the values in the two QRhiViewport objects
\r
eturn \c true if the values in the two QRhiViewport objects
\a a and \a b are equal.
\relates QRhiViewport
...
...
@@ -574,7 +574,7 @@ bool operator==(const QRhiViewport &a, const QRhiViewport &b) Q_DECL_NOTHROW
}
/*!
R
eturn
s
\c false if the values in the two QRhiViewport
\r
eturn \c false if the values in the two QRhiViewport
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiViewport
...
...
@@ -585,7 +585,7 @@ bool operator!=(const QRhiViewport &a, const QRhiViewport &b) Q_DECL_NOTHROW
}
/*!
R
eturn
s
the hash value for \a v, using \a seed to seed the calculation.
\r
eturn the hash value for \a v, using \a seed to seed the calculation.
\relates QRhiViewport
*/
...
...
@@ -629,7 +629,7 @@ QRhiScissor::QRhiScissor(int x, int y, int w, int h)
}
/*!
R
eturn
s
\c true if the values in the two QRhiScissor objects
\r
eturn \c true if the values in the two QRhiScissor objects
\a a and \a b are equal.
\relates QRhiScissor
...
...
@@ -640,7 +640,7 @@ bool operator==(const QRhiScissor &a, const QRhiScissor &b) Q_DECL_NOTHROW
}
/*!
R
eturn
s
\c false if the values in the two QRhiScissor
\r
eturn \c false if the values in the two QRhiScissor
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiScissor
...
...
@@ -651,7 +651,7 @@ bool operator!=(const QRhiScissor &a, const QRhiScissor &b) Q_DECL_NOTHROW
}
/*!
R
eturn
s
the hash value for \a v, using \a seed to seed the calculation.
\r
eturn the hash value for \a v, using \a seed to seed the calculation.
\relates QRhiScissor
*/
...
...
@@ -743,7 +743,7 @@ QRhiVertexInputBinding::QRhiVertexInputBinding(quint32 stride, Classification cl
}
/*!
R
eturn
s
\c true if the values in the two QRhiVertexInputBinding objects
\r
eturn \c true if the values in the two QRhiVertexInputBinding objects
\a a and \a b are equal.
\relates QRhiVertexInputBinding
...
...
@@ -756,7 +756,7 @@ bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b
}
/*!
R
eturn
s
\c false if the values in the two QRhiVertexInputBinding
\r
eturn \c false if the values in the two QRhiVertexInputBinding
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiVertexInputBinding
...
...
@@ -767,7 +767,7 @@ bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b
}
/*!
R
eturn
s
the hash value for \a v, using \a seed to seed the calculation.
\r
eturn the hash value for \a v, using \a seed to seed the calculation.
\relates QRhiVertexInputBinding
*/
...
...
@@ -878,7 +878,7 @@ QRhiVertexInputAttribute::QRhiVertexInputAttribute(int binding, int location, Fo
}
/*!
R
eturn
s
\c true if the values in the two QRhiVertexInputAttribute objects
\r
eturn \c true if the values in the two QRhiVertexInputAttribute objects
\a a and \a b are equal.
\relates QRhiVertexInputAttribute
...
...
@@ -892,7 +892,7 @@ bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribut
}
/*!
R
eturn
s
\c false if the values in the two QRhiVertexInputAttribute
\r
eturn \c false if the values in the two QRhiVertexInputAttribute
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiVertexInputAttribute
...
...
@@ -903,7 +903,7 @@ bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribut
}
/*!
R
eturn
s
the hash value for \a v, using \a seed to seed the calculation.
\r
eturn the hash value for \a v, using \a seed to seed the calculation.
\relates QRhiVertexInputAttribute
*/
...
...
@@ -929,7 +929,7 @@ QRhiVertexInputLayout::QRhiVertexInputLayout()
}
/*!
R
eturn
s
\c true if the values in the two QRhiVertexInputLayout objects
\r
eturn \c true if the values in the two QRhiVertexInputLayout objects
\a a and \a b are equal.
\relates QRhiVertexInputLayout
...
...
@@ -941,7 +941,7 @@ bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b)
}
/*!
R
eturn
s
\c false if the values in the two QRhiVertexInputLayout
\r
eturn \c false if the values in the two QRhiVertexInputLayout
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiVertexInputLayout
...
...
@@ -952,7 +952,7 @@ bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b)
}
/*!
R
eturn
s
the hash value for \a v, using \a seed to seed the calculation.
\r
eturn the hash value for \a v, using \a seed to seed the calculation.
\relates QRhiVertexInputLayout
*/
...
...
@@ -998,7 +998,7 @@ QRhiGraphicsShaderStage::QRhiGraphicsShaderStage(Type type, const QBakedShader &
}
/*!
R
eturn
s
\c true if the values in the two QRhiGraphicsShaderStage objects
\r
eturn \c true if the values in the two QRhiGraphicsShaderStage objects
\a a and \a b are equal.
\relates QRhiGraphicsShaderStage
...
...
@@ -1010,7 +1010,7 @@ bool operator==(const QRhiGraphicsShaderStage &a, const QRhiGraphicsShaderStage
}
/*!
R
eturn
s
\c false if the values in the two QRhiGraphicsShaderStage
\r
eturn \c false if the values in the two QRhiGraphicsShaderStage
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiGraphicsShaderStage
...
...
@@ -1021,7 +1021,7 @@ bool operator!=(const QRhiGraphicsShaderStage &a, const QRhiGraphicsShaderStage
}
/*!
R
eturn
s
the hash value for \a v, using \a seed to seed the calculation.
\r
eturn the hash value for \a v, using \a seed to seed the calculation.
\relates QRhiGraphicsShaderStage
*/
...
...
@@ -1977,7 +1977,7 @@ QRhiTextureRenderTarget::QRhiTextureRenderTarget(QRhiImplementation *rhi,
\brief Encapsulates resources for making buffer, texture, sampler resources visible to shaders.
A QRhiShaderResourceBindings is a collection of QRhiShaderResourceBinding
instance
s, each of which describe a single binding.
object
s, each of which describe a single binding.
Take a fragment shader with the following interface:
...
...
@@ -2049,10 +2049,36 @@ QRhiShaderResourceBindings::QRhiShaderResourceBindings(QRhiImplementation *rhi)
{
}
/*!
\return \c true if the layout is compatible with \a other. The layout does
not include the actual resource (such as, buffer or texture) and related
parameters (such as, offset or size). It does include the binding point,
pipeline stage, and resource type, however. The number and order of the
bindings must also match in order to be compatible.
When there is a QRhiGraphicsPipeline created with this
QRhiShaderResourceBindings, and the function returns \c true, \a other can
then safely be passed to QRhiCommandBuffer::setGraphicsPipeline(), and so
be used with the pipeline in place of this QRhiShaderResourceBindings.
*/
bool
QRhiShaderResourceBindings
::
isLayoutCompatible
(
const
QRhiShaderResourceBindings
*
other
)
const
{
const
int
count
=
m_bindings
.
count
();
if
(
count
!=
other
->
m_bindings
.
count
())
return
false
;
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
if
(
!
m_bindings
[
i
].
isLayoutCompatible
(
other
->
m_bindings
.
at
(
i
)))
return
false
;
}
return
true
;
}
/*!
\class QRhiShaderResourceBinding
\inmodule QtRhi
\brief
Specifi
es the shader resource
s that are made visible to one or more shader stages
.
\brief
Describ
es the shader resource
for a single binding point
.
A QRhiShaderResourceBinding cannot be constructed directly. Instead, use
the static functions uniformBuffer(), sampledTexture() to get an instance.
...
...
@@ -2129,6 +2155,24 @@ QRhiShaderResourceBinding::~QRhiShaderResourceBinding()
delete
d
;
}
/*!
\return \c true if the layout is compatible with \a other. The layout does not
include the actual resource (such as, buffer or texture) and related
parameters (such as, offset or size).
For example, \c a and \c b below are not equal, but are compatible layout-wise:
\badcode
auto a = QRhiShaderResourceBinding::uniformBuffer(0, QRhiShaderResourceBinding::VertexStage, buffer);
auto b = QRhiShaderResourceBinding::uniformBuffer(0, QRhiShaderResourceBinding::VertexStage, someOtherBuffer, 256);
\endcode
*/
bool
QRhiShaderResourceBinding
::
isLayoutCompatible
(
const
QRhiShaderResourceBinding
&
other
)
const
{
return
(
d
==
other
.
d
)
||
(
d
->
binding
==
other
.
d
->
binding
&&
d
->
stage
==
other
.
d
->
stage
&&
d
->
type
==
other
.
d
->
type
);
}
/*!
\return a shader resource binding for the given binding number, pipeline
stage, and buffer specified by \a binding, \a stage, and \a buf.
...
...
@@ -2192,8 +2236,12 @@ QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTexture(
}
/*!
Returns \c true if all the bindings in the two QRhiShaderResourceBinding
objects \a a and \a b are equal.
\return \c true if the contents of the two QRhiShaderResourceBinding
objects \a a and \a b are equal. This includes the resources (buffer,
texture) and related parameters (offset, size) as well. To only compare
layouts (binding point, pipeline stage, resource type), use
\l{QRhiShaderResourceBinding::isLayoutCompatible()}{isLayoutCompatible()}
instead.
\relates QRhiShaderResourceBinding
*/
...
...
@@ -2234,7 +2282,7 @@ bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBind
}
/*!
R
eturn
s
\c false if all the bindings in the two QRhiShaderResourceBinding
\r
eturn \c false if all the bindings in the two QRhiShaderResourceBinding
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiShaderResourceBinding
...
...
@@ -2245,7 +2293,7 @@ bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBind
}
/*!
R
eturn
s
the hash value for \a b, using \a seed to seed the calculation.
\r
eturn the hash value for \a b, using \a seed to seed the calculation.
\relates QRhiShaderResourceBinding
*/
...
...
@@ -3254,7 +3302,7 @@ QRhiResourceUpdateBatch::~QRhiResourceUpdateBatch()
}
/*!
R
eturn
s
the batch to the pool. This should only be used when the batch is
\r
eturn the batch to the pool. This should only be used when the batch is
not passed to one of QRhiCommandBuffer::beginPass(),
QRhiCommandBuffer::endPass(), or QRhiCommandBuffer::resourceUpdate()
because these implicitly call release().
...
...
@@ -3601,6 +3649,8 @@ void QRhiCommandBuffer::endPass(QRhiResourceUpdateBatch *resourceUpdates)
\note This function can only be called inside a pass, meaning between a
beginPass() end endPass() call.
\sa QRhiShaderResourceBindings::isLayoutCompatible()
*/
void
QRhiCommandBuffer
::
setGraphicsPipeline
(
QRhiGraphicsPipeline
*
ps
,
QRhiShaderResourceBindings
*
srb
)
...
...
src/rhi/qrhi.h
View file @
2764ee1c
...
...
@@ -302,6 +302,8 @@ public:
~
QRhiShaderResourceBinding
();
void
detach
();
bool
isLayoutCompatible
(
const
QRhiShaderResourceBinding
&
other
)
const
;
static
QRhiShaderResourceBinding
uniformBuffer
(
int
binding
,
StageFlags
stage
,
QRhiBuffer
*
buf
);
static
QRhiShaderResourceBinding
uniformBuffer
(
int
binding
,
StageFlags
stage
,
QRhiBuffer
*
buf
,
int
offset
,
int
size
);
static
QRhiShaderResourceBinding
sampledTexture
(
int
binding
,
StageFlags
stage
,
QRhiTexture
*
tex
,
QRhiSampler
*
sampler
);
...
...
@@ -818,6 +820,8 @@ public:
QVector
<
QRhiShaderResourceBinding
>
bindings
()
const
{
return
m_bindings
;
}
void
setBindings
(
const
QVector
<
QRhiShaderResourceBinding
>
&
b
)
{
m_bindings
=
b
;
}
bool
isLayoutCompatible
(
const
QRhiShaderResourceBindings
*
other
)
const
;
virtual
bool
build
()
=
0
;
protected:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment