Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laszlo Agocs
qtrhi
Commits
f3518b10
Commit
f3518b10
authored
Jan 08, 2019
by
Laszlo Agocs
Browse files
vk: implement instance step rate
parent
4d35b6d0
Changes
9
Hide whitespace changes
Inline
Side-by-side
examples/rhi/shared/examplefw.h
View file @
f3518b10
...
...
@@ -482,6 +482,8 @@ int main(int argc, char **argv)
<<
"VK_LAYER_LUNARG_swapchain"
<<
"VK_LAYER_GOOGLE_unique_objects"
);
#endif
inst
.
setExtensions
(
QByteArrayList
()
<<
"VK_KHR_get_physical_device_properties2"
);
if
(
!
inst
.
create
())
{
qWarning
(
"Failed to create Vulkan instance, switching to OpenGL"
);
graphicsApi
=
OpenGL
;
...
...
examples/rhi/triquadcube/triquadcube.cpp
View file @
f3518b10
...
...
@@ -154,6 +154,9 @@ void Window::customInit()
qDebug
(
"isFeatureSupported(MultisampleTexture): %d"
,
m_r
->
isFeatureSupported
(
QRhi
::
MultisampleTexture
));
qDebug
(
"isFeatureSupported(MultisampleRenderBuffer): %d"
,
m_r
->
isFeatureSupported
(
QRhi
::
MultisampleRenderBuffer
));
qDebug
(
"isFeatureSupported(DebugMarkers): %d"
,
m_r
->
isFeatureSupported
(
QRhi
::
DebugMarkers
));
qDebug
(
"isFeatureSupported(Timestamps): %d"
,
m_r
->
isFeatureSupported
(
QRhi
::
Timestamps
));
qDebug
(
"isFeatureSupported(Instancing): %d"
,
m_r
->
isFeatureSupported
(
QRhi
::
Instancing
));
qDebug
(
"isFeatureSupported(CustomInstanceStepRate): %d"
,
m_r
->
isFeatureSupported
(
QRhi
::
CustomInstanceStepRate
));
qDebug
(
"Min 2D texture width/height: %d"
,
m_r
->
resourceSizeLimit
(
QRhi
::
TextureSizeMin
));
qDebug
(
"Max 2D texture width/height: %d"
,
m_r
->
resourceSizeLimit
(
QRhi
::
TextureSizeMax
));
}
...
...
src/rhi/qrhi.h
View file @
f3518b10
...
...
@@ -1118,7 +1118,9 @@ public:
MultisampleTexture
=
1
,
MultisampleRenderBuffer
,
DebugMarkers
,
Timestamps
Timestamps
,
Instancing
,
CustomInstanceStepRate
};
enum
ResourceSizeLimit
{
...
...
src/rhi/qrhid3d11.cpp
View file @
f3518b10
...
...
@@ -256,13 +256,17 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
{
switch
(
feature
)
{
case
QRhi
::
MultisampleTexture
:
Q_FALLTHROUGH
()
;
return
true
;
case
QRhi
::
MultisampleRenderBuffer
:
return
true
;
case
QRhi
::
DebugMarkers
:
return
annotations
!=
nullptr
;
case
QRhi
::
Timestamps
:
return
true
;
case
QRhi
::
Instancing
:
return
true
;
case
QRhi
::
CustomInstanceStepRate
:
return
true
;
default:
Q_UNREACHABLE
();
return
false
;
...
...
src/rhi/qrhigles2.cpp
View file @
f3518b10
...
...
@@ -267,6 +267,10 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
return
false
;
case
QRhi
::
Timestamps
:
return
false
;
case
QRhi
::
Instancing
:
return
false
;
case
QRhi
::
CustomInstanceStepRate
:
return
false
;
default:
Q_UNREACHABLE
();
return
false
;
...
...
src/rhi/qrhimetal.mm
View file @
f3518b10
...
...
@@ -356,13 +356,17 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
{
switch
(
feature
)
{
case
QRhi
::
MultisampleTexture
:
Q_FALLTHROUGH
()
;
return
true
;
case
QRhi
::
MultisampleRenderBuffer
:
Q_FALLTHROUGH
()
;
return
true
;
case
QRhi
::
DebugMarkers
:
return
true
;
case
QRhi
::
Timestamps
:
return
false
;
case
QRhi
::
Instancing
:
return
true
;
case
QRhi
::
CustomInstanceStepRate
:
return
true
;
default:
Q_UNREACHABLE
();
return
false
;
...
...
src/rhi/qrhivulkan.cpp
View file @
f3518b10
...
...
@@ -260,12 +260,15 @@ bool QRhiVulkan::create(QRhi::Flags flags)
requestedDevExts
.
append
(
"VK_KHR_swapchain"
);
debugMarkersAvailable
=
false
;
if
(
debugMarkers
)
{
for
(
const
VkExtensionProperties
&
ext
:
devExts
)
{
if
(
!
strcmp
(
ext
.
extensionName
,
VK_EXT_DEBUG_MARKER_EXTENSION_NAME
))
{
requestedDevExts
.
append
(
VK_EXT_DEBUG_MARKER_EXTENSION_NAME
);
debugMarkersAvailable
=
true
;
break
;
vertexAttribDivisorAvailable
=
false
;
for
(
const
VkExtensionProperties
&
ext
:
devExts
)
{
if
(
!
strcmp
(
ext
.
extensionName
,
VK_EXT_DEBUG_MARKER_EXTENSION_NAME
))
{
requestedDevExts
.
append
(
VK_EXT_DEBUG_MARKER_EXTENSION_NAME
);
debugMarkersAvailable
=
true
;
}
else
if
(
!
strcmp
(
ext
.
extensionName
,
VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME
))
{
if
(
inst
->
extensions
().
contains
(
QByteArrayLiteral
(
"VK_KHR_get_physical_device_properties2"
)))
{
requestedDevExts
.
append
(
VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME
);
vertexAttribDivisorAvailable
=
true
;
}
}
}
...
...
@@ -2753,13 +2756,17 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
{
switch
(
feature
)
{
case
QRhi
::
MultisampleTexture
:
Q_FALLTHROUGH
()
;
return
true
;
case
QRhi
::
MultisampleRenderBuffer
:
return
true
;
case
QRhi
::
DebugMarkers
:
return
debugMarkersAvailable
;
case
QRhi
::
Timestamps
:
return
timestampValidBits
!=
0
;
case
QRhi
::
Instancing
:
return
true
;
case
QRhi
::
CustomInstanceStepRate
:
return
vertexAttribDivisorAvailable
;
default:
Q_UNREACHABLE
();
return
false
;
...
...
@@ -3027,7 +3034,7 @@ void QRhiVulkan::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
void
QRhiVulkan
::
debugMarkBegin
(
QRhiCommandBuffer
*
cb
,
const
QByteArray
&
name
)
{
if
(
!
debugMarkersAvailable
)
if
(
!
debugMarkers
||
!
debugMarkersAvailable
)
return
;
VkDebugMarkerMarkerInfoEXT
marker
;
...
...
@@ -3039,7 +3046,7 @@ void QRhiVulkan::debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name)
void
QRhiVulkan
::
debugMarkEnd
(
QRhiCommandBuffer
*
cb
)
{
if
(
!
debugMarkersAvailable
)
if
(
!
debugMarkers
||
!
debugMarkersAvailable
)
return
;
vkCmdDebugMarkerEnd
(
QRHI_RES
(
QVkCommandBuffer
,
cb
)
->
cb
);
...
...
@@ -3047,7 +3054,7 @@ void QRhiVulkan::debugMarkEnd(QRhiCommandBuffer *cb)
void
QRhiVulkan
::
debugMarkMsg
(
QRhiCommandBuffer
*
cb
,
const
QByteArray
&
msg
)
{
if
(
!
debugMarkersAvailable
)
if
(
!
debugMarkers
||
!
debugMarkersAvailable
)
return
;
VkDebugMarkerMarkerInfoEXT
marker
;
...
...
@@ -3059,7 +3066,7 @@ void QRhiVulkan::debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg)
void
QRhiVulkan
::
setObjectName
(
uint64_t
object
,
VkDebugReportObjectTypeEXT
type
,
const
QByteArray
&
name
)
{
if
(
!
debugMarkersAvailable
||
name
.
isEmpty
())
if
(
!
debugMarkers
||
!
debugMarkersAvailable
||
name
.
isEmpty
())
return
;
VkDebugMarkerObjectNameInfoEXT
nameInfo
;
...
...
@@ -4233,6 +4240,7 @@ bool QVkGraphicsPipeline::build()
pipelineInfo
.
pStages
=
shaderStageCreateInfos
.
constData
();
QVarLengthArray
<
VkVertexInputBindingDescription
,
4
>
vertexBindings
;
QVarLengthArray
<
VkVertexInputBindingDivisorDescriptionEXT
>
nonOneStepRates
;
for
(
int
i
=
0
,
ie
=
m_vertexInputLayout
.
bindings
.
count
();
i
!=
ie
;
++
i
)
{
const
QRhiVertexInputLayout
::
Binding
&
binding
(
m_vertexInputLayout
.
bindings
[
i
]);
VkVertexInputBindingDescription
bindingInfo
=
{
...
...
@@ -4244,8 +4252,13 @@ bool QVkGraphicsPipeline::build()
if
(
binding
.
classification
==
QRhiVertexInputLayout
::
Binding
::
PerInstance
&&
binding
.
instanceStepRate
!=
1
)
{
// ### could be supported with VK_EXT_vertex_attribute_divisor (Vulkan 1.1)
qWarning
(
"QRhiVulkan: Instance step rates other than 1 not currently supported"
);
if
(
rhiD
->
vertexAttribDivisorAvailable
)
{
nonOneStepRates
.
append
({
uint32_t
(
i
),
uint32_t
(
binding
.
instanceStepRate
)
});
}
else
{
qWarning
(
"QRhiVulkan: Instance step rates other than 1 not supported without "
"VK_EXT_vertex_attribute_divisor on the device and "
"VK_KHR_get_physical_device_properties2 on the instance"
);
}
}
vertexBindings
.
append
(
bindingInfo
);
}
...
...
@@ -4266,6 +4279,14 @@ bool QVkGraphicsPipeline::build()
vertexInputInfo
.
pVertexBindingDescriptions
=
vertexBindings
.
constData
();
vertexInputInfo
.
vertexAttributeDescriptionCount
=
vertexAttributes
.
count
();
vertexInputInfo
.
pVertexAttributeDescriptions
=
vertexAttributes
.
constData
();
VkPipelineVertexInputDivisorStateCreateInfoEXT
divisorInfo
;
if
(
!
nonOneStepRates
.
isEmpty
())
{
memset
(
&
divisorInfo
,
0
,
sizeof
(
divisorInfo
));
divisorInfo
.
sType
=
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT
;
divisorInfo
.
vertexBindingDivisorCount
=
nonOneStepRates
.
count
();
divisorInfo
.
pVertexBindingDivisors
=
nonOneStepRates
.
constData
();
vertexInputInfo
.
pNext
=
&
divisorInfo
;
}
pipelineInfo
.
pVertexInputState
=
&
vertexInputInfo
;
QVarLengthArray
<
VkDynamicState
,
8
>
dynEnable
;
...
...
src/rhi/qrhivulkan_p.h
View file @
f3518b10
...
...
@@ -486,6 +486,7 @@ public:
VkDeviceSize
texbufAlign
;
bool
debugMarkersAvailable
=
false
;
bool
vertexAttribDivisorAvailable
=
false
;
PFN_vkCmdDebugMarkerBeginEXT
vkCmdDebugMarkerBegin
=
nullptr
;
PFN_vkCmdDebugMarkerEndEXT
vkCmdDebugMarkerEnd
=
nullptr
;
PFN_vkCmdDebugMarkerInsertEXT
vkCmdDebugMarkerInsert
=
nullptr
;
...
...
todo.txt
View file @
f3518b10
...
...
@@ -19,7 +19,6 @@ more QImage->tex formats
if tex adjust its size (e.g. npot on gl), should QImage get scaled automatically?
d3d, gl, mtl: cache shader sources?
gl: ubuf structs, arrays
vk: support instanceStepRate via VK_EXT_vertex_attribute_divisor
test cubemap face as target
test cubemap face readback
object names for other than buf/rb/tex
...
...
@@ -48,6 +47,7 @@ dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done
vk: support instanceStepRate via VK_EXT_vertex_attribute_divisor
resize to 0 width or height fails (vk, d3d)
vk: rendering hangs sometimes when minimize and back on some systems?
allow requesting no-vsync present mode where applicable
...
...
Write
Preview
Supports
Markdown
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