<div dir="ltr">Are there any tests for this anywhere?<br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 9, 2018 at 5:56 AM Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Inherited commands buffers are not supported.<br>
<br>
v2: - disable predication for blit and copy commands<br>
<br>
Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com" target="_blank">samuel.pitoiset@gmail.com</a>><br>
---<br>
src/amd/vulkan/radv_cmd_buffer.c | 29 +++++++++++++++++++++++++++++<br>
src/amd/vulkan/radv_device.c | 7 +++++++<br>
src/amd/vulkan/radv_extensions.py | 1 +<br>
src/amd/vulkan/radv_meta_blit.c | 10 ++++++++++<br>
src/amd/vulkan/radv_meta_buffer.c | 10 ++++++++++<br>
src/amd/vulkan/radv_meta_copy.c | 30 ++++++++++++++++++++++++++++++<br>
6 files changed, 87 insertions(+)<br>
<br>
diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c<br>
index 29199f2b3d..3fd8ebe2d3 100644<br>
--- a/src/amd/vulkan/radv_cmd_buffer.c<br>
+++ b/src/amd/vulkan/radv_cmd_buffer.c<br>
@@ -4376,3 +4376,32 @@ void radv_CmdSetDeviceMask(VkCommandBuffer commandBuffer,<br>
{<br>
/* No-op */<br>
}<br>
+<br>
+/* VK_EXT_conditional_rendering */<br>
+void vkCmdBeginConditionalRenderingEXT(<br>
+ VkCommandBuffer commandBuffer,<br>
+ const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin)<br>
+{<br>
+ RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);<br>
+ RADV_FROM_HANDLE(radv_buffer, buffer, pConditionalRenderingBegin->buffer);<br>
+ bool inverted;<br>
+ uint64_t va;<br>
+<br>
+ va = radv_buffer_get_va(buffer->bo) + pConditionalRenderingBegin->offset;<br>
+<br>
+ inverted = pConditionalRenderingBegin->flags & VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT;<br>
+<br>
+ /* Enable predication for this command buffer. */<br>
+ si_emit_set_predication_state(cmd_buffer, inverted, va);<br>
+ cmd_buffer->state.predicating = true;<br>
+}<br>
+<br>
+void vkCmdEndConditionalRenderingEXT(<br>
+ VkCommandBuffer commandBuffer)<br>
+{<br>
+ RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);<br>
+<br>
+ /* Disable predication for this command buffer. */<br>
+ si_emit_set_predication_state(cmd_buffer, false, 0);<br>
+ cmd_buffer->state.predicating = false;<br>
+}<br>
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c<br>
index ad3465f594..06d70d305a 100644<br>
--- a/src/amd/vulkan/radv_device.c<br>
+++ b/src/amd/vulkan/radv_device.c<br>
@@ -806,6 +806,13 @@ void radv_GetPhysicalDeviceFeatures2(<br>
features->runtimeDescriptorArray = true;<br>
break;<br>
}<br>
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT: {<br>
+ VkPhysicalDeviceConditionalRenderingFeaturesEXT *features =<br>
+ (VkPhysicalDeviceConditionalRenderingFeaturesEXT*)ext;<br>
+ features->conditionalRendering = true;<br>
+ features->inheritedConditionalRendering = false;<br>
+ break;<br>
+ }<br>
default:<br>
break;<br>
}<br>
diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py<br>
index a0f1038110..6ddbabf26e 100644<br>
--- a/src/amd/vulkan/radv_extensions.py<br>
+++ b/src/amd/vulkan/radv_extensions.py<br>
@@ -89,6 +89,7 @@ EXTENSIONS = [<br>
Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'),<br>
Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),<br>
Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'),<br>
+ Extension('VK_EXT_conditional_rendering', 1, True),<br>
Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),<br>
Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),<br>
Extension('VK_EXT_debug_report', 9, True),<br>
diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c<br>
index a6ee0cb7e9..67c26aabdb 100644<br>
--- a/src/amd/vulkan/radv_meta_blit.c<br>
+++ b/src/amd/vulkan/radv_meta_blit.c<br>
@@ -520,6 +520,7 @@ void radv_CmdBlitImage(<br>
RADV_FROM_HANDLE(radv_image, src_image, srcImage);<br>
RADV_FROM_HANDLE(radv_image, dest_image, destImage);<br>
struct radv_meta_saved_state saved_state;<br>
+ bool old_predicating;<br>
<br>
/* From the Vulkan 1.0 spec:<br>
*<br>
@@ -534,6 +535,12 @@ void radv_CmdBlitImage(<br>
RADV_META_SAVE_CONSTANTS |<br>
RADV_META_SAVE_DESCRIPTORS);<br>
<br>
+ /* VK_EXT_conditional_rendering says that blit commands should not be<br>
+ * affected by conditional rendering.<br>
+ */<br>
+ old_predicating = cmd_buffer->state.predicating;<br>
+ cmd_buffer->state.predicating = false;<br>
+<br>
for (unsigned r = 0; r < regionCount; r++) {<br>
const VkImageSubresourceLayers *src_res = &pRegions[r].srcSubresource;<br>
const VkImageSubresourceLayers *dst_res = &pRegions[r].dstSubresource;<br>
@@ -648,6 +655,9 @@ void radv_CmdBlitImage(<br>
}<br>
}<br>
<br>
+ /* Restore conditional rendering. */<br>
+ cmd_buffer->state.predicating = old_predicating;<br>
+<br>
radv_meta_restore(&saved_state, cmd_buffer);<br>
}<br>
<br>
diff --git a/src/amd/vulkan/radv_meta_buffer.c b/src/amd/vulkan/radv_meta_buffer.c<br>
index 2e1ba2c7b2..a45a6d5aac 100644<br>
--- a/src/amd/vulkan/radv_meta_buffer.c<br>
+++ b/src/amd/vulkan/radv_meta_buffer.c<br>
@@ -472,6 +472,13 @@ void radv_CmdCopyBuffer(<br>
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);<br>
RADV_FROM_HANDLE(radv_buffer, src_buffer, srcBuffer);<br>
RADV_FROM_HANDLE(radv_buffer, dest_buffer, destBuffer);<br>
+ bool old_predicating;<br>
+<br>
+ /* VK_EXT_conditional_rendering says that copy commands should not be<br>
+ * affected by conditional rendering.<br>
+ */<br>
+ old_predicating = cmd_buffer->state.predicating;<br>
+ cmd_buffer->state.predicating = false;<br>
<br>
for (unsigned r = 0; r < regionCount; r++) {<br>
uint64_t src_offset = src_buffer->offset + pRegions[r].srcOffset;<br>
@@ -481,6 +488,9 @@ void radv_CmdCopyBuffer(<br>
radv_copy_buffer(cmd_buffer, src_buffer->bo, dest_buffer->bo,<br>
src_offset, dest_offset, copy_size);<br>
}<br>
+<br>
+ /* Restore conditional rendering. */<br>
+ cmd_buffer->state.predicating = old_predicating;<br>
}<br>
<br>
void radv_CmdUpdateBuffer(<br>
diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c<br>
index 3442b49fb9..f4de5528ed 100644<br>
--- a/src/amd/vulkan/radv_meta_copy.c<br>
+++ b/src/amd/vulkan/radv_meta_copy.c<br>
@@ -117,6 +117,7 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer,<br>
{<br>
bool cs = cmd_buffer->queue_family_index == RADV_QUEUE_COMPUTE;<br>
struct radv_meta_saved_state saved_state;<br>
+ bool old_predicating;<br>
<br>
/* The Vulkan 1.0 spec says "dstImage must have a sample count equal to<br>
* VK_SAMPLE_COUNT_1_BIT."<br>
@@ -129,6 +130,12 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer,<br>
RADV_META_SAVE_CONSTANTS |<br>
RADV_META_SAVE_DESCRIPTORS);<br>
<br>
+ /* VK_EXT_conditional_rendering says that copy commands should not be<br>
+ * affected by conditional rendering.<br>
+ */<br>
+ old_predicating = cmd_buffer->state.predicating;<br>
+ cmd_buffer->state.predicating = false;<br>
+<br>
for (unsigned r = 0; r < regionCount; r++) {<br>
<br>
/**<br>
@@ -208,6 +215,9 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer,<br>
}<br>
}<br>
<br>
+ /* Restore conditional rendering. */<br>
+ cmd_buffer->state.predicating = old_predicating;<br>
+<br>
radv_meta_restore(&saved_state, cmd_buffer);<br>
}<br>
<br>
@@ -236,12 +246,19 @@ meta_copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer,<br>
const VkBufferImageCopy* pRegions)<br>
{<br>
struct radv_meta_saved_state saved_state;<br>
+ bool old_predicating;<br>
<br>
radv_meta_save(&saved_state, cmd_buffer,<br>
RADV_META_SAVE_COMPUTE_PIPELINE |<br>
RADV_META_SAVE_CONSTANTS |<br>
RADV_META_SAVE_DESCRIPTORS);<br>
<br>
+ /* VK_EXT_conditional_rendering says that copy commands should not be<br>
+ * affected by conditional rendering.<br>
+ */<br>
+ old_predicating = cmd_buffer->state.predicating;<br>
+ cmd_buffer->state.predicating = false;<br>
+<br>
for (unsigned r = 0; r < regionCount; r++) {<br>
<br>
/**<br>
@@ -313,6 +330,9 @@ meta_copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer,<br>
}<br>
}<br>
<br>
+ /* Restore conditional rendering. */<br>
+ cmd_buffer->state.predicating = old_predicating;<br>
+<br>
radv_meta_restore(&saved_state, cmd_buffer);<br>
}<br>
<br>
@@ -344,6 +364,7 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,<br>
{<br>
bool cs = cmd_buffer->queue_family_index == RADV_QUEUE_COMPUTE;<br>
struct radv_meta_saved_state saved_state;<br>
+ bool old_predicating;<br>
<br>
/* From the Vulkan 1.0 spec:<br>
*<br>
@@ -358,6 +379,12 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,<br>
RADV_META_SAVE_CONSTANTS |<br>
RADV_META_SAVE_DESCRIPTORS);<br>
<br>
+ /* VK_EXT_conditional_rendering says that copy commands should not be<br>
+ * affected by conditional rendering.<br>
+ */<br>
+ old_predicating = cmd_buffer->state.predicating;<br>
+ cmd_buffer->state.predicating = false;<br>
+<br>
for (unsigned r = 0; r < regionCount; r++) {<br>
assert(pRegions[r].srcSubresource.aspectMask ==<br>
pRegions[r].dstSubresource.aspectMask);<br>
@@ -465,6 +492,9 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,<br>
}<br>
}<br>
<br>
+ /* Restore conditional rendering. */<br>
+ cmd_buffer->state.predicating = old_predicating;<br>
+<br>
radv_meta_restore(&saved_state, cmd_buffer);<br>
}<br>
<br>
-- <br>
2.18.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>