<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 7, 2017 at 6:48 AM, Chad Versace <span dir="ltr"><<a href="mailto:chadversary@chromium.org" target="_blank">chadversary@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Incremental implementation of VK_EXT_image_drm_format_<wbr>modifier.<br>
---<br>
src/intel/vulkan/anv_formats.c | 45 ++++++++++++++++++++++++++++++<wbr>+++++++-----<br>
1 file changed, 40 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_<wbr>formats.c b/src/intel/vulkan/anv_<wbr>formats.c<br>
index dc46fdb5425..d6eeb9d1c45 100644<br>
--- a/src/intel/vulkan/anv_<wbr>formats.c<br>
+++ b/src/intel/vulkan/anv_<wbr>formats.c<br>
@@ -813,6 +813,7 @@ static VkResult<br>
anv_get_image_format_<wbr>properties(<br>
struct anv_physical_device *physical_device,<br>
const VkPhysicalDeviceImageFormatInf<wbr>o2KHR *info,<br>
+ const VkPhysicalDeviceImageDrmFormat<wbr>ModifierInfoEXT *drm_info,<br>
VkImageFormatProperties *pImageFormatProperties,<br>
VkSamplerYcbcrConversionImageF<wbr>ormatPropertiesKHR *pYcbcrImageFormatProperties)<br>
{<br>
@@ -826,14 +827,34 @@ anv_get_image_format_<wbr>properties(<br>
if (format == NULL)<br>
goto unsupported;<br>
<br>
+ uint64_t drm_format_mod = DRM_FORMAT_MOD_INVALID;<br>
+ if (drm_info) {<br>
+ assert(info->tiling == VK_IMAGE_TILING_DRM_FORMAT_<wbr>MODIFIER_EXT);<br>
+ drm_format_mod = drm_info->drmFormatModifier;<br>
+ }<br>
+<br>
VkFormatFeatureFlags format_feature_flags =<br>
get_image_format_features(<wbr>devinfo, info->format, format, info->tiling,<br>
- DRM_FORMAT_MOD_INVALID);<br>
+ drm_format_mod);<br>
+<br>
+ /* The core Vulkan spec places strict constraints on the image capabilities<br>
+ * advertised here. For example, the core spec requires that<br>
+ * maxMipLevels == log2(maxWidth) + 1<br>
+ * when tiling is VK_IMAGE_TILING_OPTIMAL; and requires that<br>
+ * maxExtent >= VkPhysicalDeviceLimits::<wbr>maxImageDimension${N}D.<br>
+ * However, the VK_EXT_image_drm_format_<wbr>modifier specification grants the<br>
+ * implementation the freedom to further restrict the image capabilities<br>
+ * when tiling is VK_IMAGE_TILING_DRM_FORMAT_<wbr>MODIFIER_EXT.<br></blockquote><div><br></div><div>How about adding one extra paragraph here saying that we choose to only support "simple" 2D images.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ */<br>
<br>
switch (info->type) {<br>
default:<br>
unreachable("bad VkImageType");<br>
case VK_IMAGE_TYPE_1D:<br>
+ /* We reject 1D images with modifiers due to FUD */<br></blockquote><div><br></div><div>We could support 1D but meh. Just use a texture buffer instead.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ if (drm_info)<br>
+ goto unsupported;<br>
+<br>
maxExtent.width = 16384;<br>
maxExtent.height = 1;<br>
maxExtent.depth = 1;<br>
@@ -848,10 +869,20 @@ anv_get_image_format_<wbr>properties(<br>
maxExtent.width = 16384;<br>
maxExtent.height = 16384;<br>
maxExtent.depth = 1;<br>
- maxMipLevels = 15; /* log2(maxWidth) + 1 */<br>
- maxArraySize = 2048;<br>
+<br>
+ if (drm_info) {<br>
+ maxMipLevels = 1;<br>
+ maxArraySize = 1;<br>
+ } else {<br>
+ maxMipLevels = 15; /* log2(maxWidth) + 1 */<br>
+ maxArraySize = 2048;<br>
+ }<br>
break;<br>
case VK_IMAGE_TYPE_3D:<br>
+ /* We reject 3D images with modifiers due to FUD */<br></blockquote><div><br></div><div>I have neither uncertainty nor doubt, but I do have a very healthy helping of fear. :-) Let's just go with a global comment above and drop the ones that make us look like cowards. :-P</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ if (drm_info)<br>
+ goto unsupported;<br>
+<br>
maxExtent.width = 2048;<br>
maxExtent.height = 2048;<br>
maxExtent.depth = 2048;<br>
@@ -976,7 +1007,7 @@ VkResult anv_<wbr>GetPhysicalDeviceImageFormatPr<wbr>operties(<br>
.flags = createFlags,<br>
};<br>
<br>
- return anv_get_image_format_<wbr>properties(physical_device, &info,<br>
+ return anv_get_image_format_<wbr>properties(physical_device, &info, NULL,<br>
pImageFormatProperties, NULL);<br>
}<br>
<br>
@@ -1009,6 +1040,7 @@ VkResult anv_<wbr>GetPhysicalDeviceImageFormatPr<wbr>operties2KHR(<br>
{<br>
ANV_FROM_HANDLE(anv_physical_<wbr>device, physical_device, physicalDevice);<br>
const VkPhysicalDeviceExternalImageF<wbr>ormatInfoKHR *external_info = NULL;<br>
+ const VkPhysicalDeviceImageDrmFormat<wbr>ModifierInfoEXT *drm_info = NULL;<br>
VkExternalImageFormatPropertie<wbr>sKHR *external_props = NULL;<br>
VkSamplerYcbcrConversionImageF<wbr>ormatPropertiesKHR *ycbcr_props = NULL;<br>
VkResult result;<br>
@@ -1019,6 +1051,9 @@ VkResult anv_<wbr>GetPhysicalDeviceImageFormatPr<wbr>operties2KHR(<br>
case VK_STRUCTURE_TYPE_PHYSICAL_<wbr>DEVICE_EXTERNAL_IMAGE_FORMAT_<wbr>INFO_KHR:<br>
external_info = (const void *) s;<br>
break;<br>
+ case VK_STRUCTURE_TYPE_PHYSICAL_<wbr>DEVICE_IMAGE_DRM_FORMAT_<wbr>MODIFIER_INFO_EXT:<br>
+ drm_info = (const void *) s;<br>
+ break;<br>
default:<br>
anv_debug_ignored_stype(s-><wbr>sType);<br>
break;<br>
@@ -1041,7 +1076,7 @@ VkResult anv_<wbr>GetPhysicalDeviceImageFormatPr<wbr>operties2KHR(<br>
}<br>
<br>
result = anv_get_image_format_<wbr>properties(physical_device, base_info,<br>
- &base_props-><wbr>imageFormatProperties, ycbcr_props);<br>
+ drm_info, &base_props-><wbr>imageFormatProperties, ycbcr_props);<br>
if (result != VK_SUCCESS)<br>
goto fail;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.13.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">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/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>