aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEleni Maria Stea <elene.mst@gmail.com>2021-02-28 23:17:44 +0200
committerEleni Maria Stea <elene.mst@gmail.com>2021-03-02 13:20:28 +0200
commit1427b339399ff5f767c2c7de71da5adc022b76b6 (patch)
tree7bca4bcee4fb4f19850eee2d30f7db7df450db5f
parentd66dc8d34c7eb138fa7cf841a1231ce9402f704e (diff)
downloadpiglit-1427b339399ff5f767c2c7de71da5adc022b76b6.tar.gz
ext_external_objects: All supported image usage flags are set
According to issue 13 of EXT_external_objects extension all supported usage flags for an image should be set from Vulkan if the image is going to be used from OpenGL. Change the function of Vulkan framework that sets the usage flags to check which flags are supported for the format and the tiling and use them at image creation automatically. Modified the tests so that they don't expect the flag to be set by the user. Signed-off-by: Eleni Maria Stea <elene.mst@gmail.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
-rw-r--r--tests/spec/ext_external_objects/params.h7
-rw-r--r--tests/spec/ext_external_objects/vk.c55
-rw-r--r--tests/spec/ext_external_objects/vk.h2
-rw-r--r--tests/spec/ext_external_objects/vk_buf_exchange.c7
-rw-r--r--tests/spec/ext_external_objects/vk_depth_display.c2
-rw-r--r--tests/spec/ext_external_objects/vk_image_display.c7
-rw-r--r--tests/spec/ext_external_objects/vk_image_display_overwrite.c7
-rw-r--r--tests/spec/ext_external_objects/vk_image_overwrite.c11
-rw-r--r--tests/spec/ext_external_objects/vk_pix_buf_update_errors.c12
-rw-r--r--tests/spec/ext_external_objects/vk_vert_buf_reuse.c2
10 files changed, 48 insertions, 64 deletions
diff --git a/tests/spec/ext_external_objects/params.h b/tests/spec/ext_external_objects/params.h
index 0eeb46285..2613619b7 100644
--- a/tests/spec/ext_external_objects/params.h
+++ b/tests/spec/ext_external_objects/params.h
@@ -37,13 +37,6 @@ uint32_t num_levels = 1;
uint32_t num_layers = 1;
VkFormat color_format = VK_FORMAT_R32G32B32A32_SFLOAT;
VkFormat depth_format = VK_FORMAT_D32_SFLOAT;
-VkImageUsageFlagBits color_usage = VK_IMAGE_USAGE_SAMPLED_BIT |
- VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
- VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
-VkImageUsageFlagBits depth_usage = VK_IMAGE_USAGE_SAMPLED_BIT |
- VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
- VK_IMAGE_USAGE_TRANSFER_DST_BIT |
- VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
VkImageTiling color_tiling = VK_IMAGE_TILING_OPTIMAL;
VkImageTiling depth_tiling = VK_IMAGE_TILING_OPTIMAL;
VkImageLayout color_in_layout = VK_IMAGE_LAYOUT_UNDEFINED;
diff --git a/tests/spec/ext_external_objects/vk.c b/tests/spec/ext_external_objects/vk.c
index 03a6e0b82..ab2be9776 100644
--- a/tests/spec/ext_external_objects/vk.c
+++ b/tests/spec/ext_external_objects/vk.c
@@ -866,9 +866,31 @@ static bool
are_props_supported(struct vk_ctx *ctx, struct vk_image_props *props)
{
VkPhysicalDeviceExternalImageFormatInfo ext_img_fmt_info;
- VkPhysicalDeviceImageFormatInfo2 img_fmt_info;
VkExternalImageFormatProperties ext_img_fmt_props;
+
+ int i;
+ VkPhysicalDeviceImageFormatInfo2 img_fmt_info;
VkImageFormatProperties2 img_fmt_props;
+ VkImageUsageFlagBits all_flags[] = {
+ VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
+ VK_IMAGE_USAGE_TRANSFER_DST_BIT,
+ VK_IMAGE_USAGE_SAMPLED_BIT,
+ VK_IMAGE_USAGE_STORAGE_BIT,
+ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
+ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
+ VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
+ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT,
+ /* Provided by VK_EXT_fragment_density_map */
+ VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT,
+ /* Comment out when the headers become available in all
+ * distros:
+ * Provided by VK_NV_shading_rate_image
+ * VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV,
+ * Provided by VK_KHR_fragment_shading_rate
+ * VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
+ */
+ };
+ VkImageUsageFlagBits flags = 0;
VkExternalMemoryFeatureFlagBits export_feature_flags =
VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
@@ -880,6 +902,14 @@ are_props_supported(struct vk_ctx *ctx, struct vk_image_props *props)
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO;
ext_img_fmt_info.handleType = handle_type;
+ memset(&ext_img_fmt_props, 0, sizeof ext_img_fmt_props);
+ ext_img_fmt_props.sType =
+ VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES;
+
+ memset(&img_fmt_props, 0, sizeof img_fmt_props);
+ img_fmt_props.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
+ img_fmt_props.pNext = &ext_img_fmt_props;
+
memset(&img_fmt_info, 0, sizeof img_fmt_info);
img_fmt_info.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2;
@@ -887,25 +917,28 @@ are_props_supported(struct vk_ctx *ctx, struct vk_image_props *props)
img_fmt_info.format = props->format;
img_fmt_info.type = get_image_type(props->h, props->depth);
img_fmt_info.tiling = props->tiling;
- img_fmt_info.usage = props->usage ? props->usage : VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
-
- memset(&ext_img_fmt_props, 0, sizeof ext_img_fmt_props);
- ext_img_fmt_props.sType =
- VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES;
- memset(&img_fmt_props, 0, sizeof img_fmt_props);
- img_fmt_props.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
- img_fmt_props.pNext = &ext_img_fmt_props;
+ for (i = 0; i < ARRAY_SIZE(all_flags); i++) {
+ img_fmt_info.usage = all_flags[i];
+ if (vkGetPhysicalDeviceImageFormatProperties2(ctx->pdev,
+ &img_fmt_info,
+ &img_fmt_props) == VK_SUCCESS) {
+ flags |= all_flags[i];
+ }
+ }
+ img_fmt_info.usage = flags;
if (vkGetPhysicalDeviceImageFormatProperties2
(ctx->pdev, &img_fmt_info, &img_fmt_props) != VK_SUCCESS) {
fprintf(stderr,
"Unsupported Vulkan format properties.\n");
return false;
}
+ props->usage = flags;
if (props->need_export &&
- !(ext_img_fmt_props.externalMemoryProperties.externalMemoryFeatures & export_feature_flags)) {
+ !(ext_img_fmt_props.externalMemoryProperties.externalMemoryFeatures
+ & export_feature_flags)) {
fprintf(stderr, "Unsupported Vulkan external memory features.\n");
return false;
}
@@ -1140,7 +1173,6 @@ vk_fill_ext_image_props(struct vk_ctx *ctx,
uint32_t num_layers,
VkFormat format,
VkImageTiling tiling,
- VkImageUsageFlagBits usage,
VkImageLayout in_layout,
VkImageLayout end_layout,
bool need_export,
@@ -1155,7 +1187,6 @@ vk_fill_ext_image_props(struct vk_ctx *ctx,
props->num_layers = num_layers;
props->format = format;
- props->usage = usage;
props->tiling = tiling;
props->in_layout = in_layout;
diff --git a/tests/spec/ext_external_objects/vk.h b/tests/spec/ext_external_objects/vk.h
index 5229645ea..1cac0dfe7 100644
--- a/tests/spec/ext_external_objects/vk.h
+++ b/tests/spec/ext_external_objects/vk.h
@@ -161,7 +161,6 @@ vk_fill_ext_image_props(struct vk_ctx *ctx,
uint32_t num_layers,
VkFormat format,
VkImageTiling tiling,
- VkImageUsageFlagBits usage,
VkImageLayout in_layout,
VkImageLayout end_layout,
bool need_export,
@@ -236,4 +235,5 @@ vk_transition_image_layout(struct vk_image_att *img_att,
VkImageLayout new_layout,
uint32_t src_queue_family_index,
uint32_t dst_queue_family_index);
+
#endif /* VK_H */
diff --git a/tests/spec/ext_external_objects/vk_buf_exchange.c b/tests/spec/ext_external_objects/vk_buf_exchange.c
index 72724e246..f564c68d0 100644
--- a/tests/spec/ext_external_objects/vk_buf_exchange.c
+++ b/tests/spec/ext_external_objects/vk_buf_exchange.c
@@ -67,8 +67,6 @@ vk_init(uint32_t w,
uint32_t num_layers,
VkFormat color_format,
VkFormat depth_format,
- VkImageUsageFlagBits color_usage,
- VkImageUsageFlagBits depth_usage,
VkImageTiling color_tiling,
VkImageTiling depth_tiling,
VkImageLayout color_in_layout,
@@ -119,7 +117,6 @@ piglit_init(int argc, char **argv)
if (!vk_init(w, h, d, num_samples, num_levels, num_layers,
color_format, depth_format,
- color_usage, depth_usage,
color_tiling, depth_tiling,
color_in_layout, depth_in_layout,
color_end_layout, depth_end_layout)) {
@@ -190,8 +187,6 @@ vk_init(uint32_t w,
uint32_t num_layers,
VkFormat color_format,
VkFormat depth_format,
- VkImageUsageFlagBits color_usage,
- VkImageUsageFlagBits depth_usage,
VkImageTiling color_tiling,
VkImageTiling depth_tiling,
VkImageLayout color_in_layout,
@@ -221,7 +216,6 @@ vk_init(uint32_t w,
num_layers,
color_format,
color_tiling,
- color_usage,
color_in_layout,
color_end_layout,
false,
@@ -241,7 +235,6 @@ vk_init(uint32_t w,
num_layers,
depth_format,
depth_tiling,
- depth_usage,
depth_in_layout,
depth_end_layout,
false,
diff --git a/tests/spec/ext_external_objects/vk_depth_display.c b/tests/spec/ext_external_objects/vk_depth_display.c
index 0ccacfec0..e7a0a5820 100644
--- a/tests/spec/ext_external_objects/vk_depth_display.c
+++ b/tests/spec/ext_external_objects/vk_depth_display.c
@@ -286,7 +286,6 @@ vk_subtest_init(int case_num)
num_layers,
color_format,
color_tiling,
- color_usage,
color_in_layout,
color_end_layout,
true,
@@ -306,7 +305,6 @@ vk_subtest_init(int case_num)
num_layers,
depth_stencil_formats[case_num].vk_ds_fmt,
depth_tiling,
- depth_usage,
depth_in_layout,
depth_end_layout,
true,
diff --git a/tests/spec/ext_external_objects/vk_image_display.c b/tests/spec/ext_external_objects/vk_image_display.c
index 724f3b896..03543109b 100644
--- a/tests/spec/ext_external_objects/vk_image_display.c
+++ b/tests/spec/ext_external_objects/vk_image_display.c
@@ -67,8 +67,6 @@ vk_init(uint32_t w,
uint32_t num_layers,
VkFormat color_format,
VkFormat depth_format,
- VkImageUsageFlagBits color_usage,
- VkImageUsageFlagBits depth_usage,
VkImageTiling color_tiling,
VkImageTiling depth_tiling,
VkImageLayout color_in_layout,
@@ -119,7 +117,6 @@ void piglit_init(int argc, char **argv)
if (!vk_init(w, h, d, num_samples, num_levels, num_layers,
color_format, depth_format,
- color_usage, depth_usage,
color_tiling, depth_tiling,
color_in_layout, depth_in_layout,
color_end_layout, depth_end_layout)) {
@@ -216,8 +213,6 @@ vk_init(uint32_t w,
uint32_t num_layers,
VkFormat color_format,
VkFormat depth_format,
- VkImageUsageFlagBits color_usage,
- VkImageUsageFlagBits depth_usage,
VkImageTiling color_tiling,
VkImageTiling depth_tiling,
VkImageLayout color_in_layout,
@@ -249,7 +244,6 @@ vk_init(uint32_t w,
num_layers,
color_format,
color_tiling,
- color_usage,
color_in_layout,
color_end_layout,
true,
@@ -270,7 +264,6 @@ vk_init(uint32_t w,
num_layers,
depth_format,
depth_tiling,
- depth_usage,
depth_in_layout,
depth_end_layout,
false,
diff --git a/tests/spec/ext_external_objects/vk_image_display_overwrite.c b/tests/spec/ext_external_objects/vk_image_display_overwrite.c
index 37981a4a4..871202a93 100644
--- a/tests/spec/ext_external_objects/vk_image_display_overwrite.c
+++ b/tests/spec/ext_external_objects/vk_image_display_overwrite.c
@@ -96,8 +96,6 @@ vk_init(uint32_t w,
uint32_t num_layers,
VkFormat color_format,
VkFormat depth_format,
- VkImageUsageFlagBits color_usage,
- VkImageUsageFlagBits depth_usage,
VkImageTiling color_tiling,
VkImageTiling depth_tiling,
VkImageLayout color_in_layout,
@@ -155,7 +153,6 @@ void piglit_init(int argc, char **argv)
if (!vk_init(w, h, d, num_samples, num_levels, num_layers,
color_format, depth_format,
- color_usage, depth_usage,
color_tiling, depth_tiling,
color_in_layout, depth_in_layout,
color_end_layout, depth_end_layout)) {
@@ -280,8 +277,6 @@ vk_init(uint32_t w,
uint32_t num_layers,
VkFormat color_format,
VkFormat depth_format,
- VkImageUsageFlagBits color_usage,
- VkImageUsageFlagBits depth_usage,
VkImageTiling color_tiling,
VkImageTiling depth_tiling,
VkImageLayout color_in_layout,
@@ -313,7 +308,6 @@ vk_init(uint32_t w,
num_layers,
color_format,
color_tiling,
- color_usage,
color_in_layout,
color_end_layout,
true,
@@ -334,7 +328,6 @@ vk_init(uint32_t w,
num_layers,
depth_format,
depth_tiling,
- depth_usage,
depth_in_layout,
depth_end_layout,
false,
diff --git a/tests/spec/ext_external_objects/vk_image_overwrite.c b/tests/spec/ext_external_objects/vk_image_overwrite.c
index a6ebc6d54..6797216f6 100644
--- a/tests/spec/ext_external_objects/vk_image_overwrite.c
+++ b/tests/spec/ext_external_objects/vk_image_overwrite.c
@@ -111,7 +111,7 @@ vk_set_image_props(uint32_t w, uint32_t h,
uint32_t depth,
uint32_t num_samples,
uint32_t num_levels, VkFormat format,
- VkImageTiling tiling, VkImageUsageFlagBits usage);
+ VkImageTiling tiling);
static bool
gl_draw_texture(enum fragment_type fs_type, uint32_t w, uint32_t h);
@@ -168,12 +168,10 @@ run_subtest(int case_num)
const float color_prb[] = { 0.0, 1.0, 0.0, 1.0 };
GLint loc = -1;
- /* We don't set the usage flags as the purpose of this test is to test different formats
- * We will check different combinations of usage/tiling mode in another test */
if (!vk_set_image_props(piglit_width, piglit_height, d,
num_samples, num_levels,
vk_gl_format[case_num].vkformat,
- vk_gl_format[case_num].tiling, 0)) {
+ vk_gl_format[case_num].tiling)) {
piglit_report_subtest_result(PIGLIT_SKIP,
"%s: Unsupported image format.",
vk_gl_format[case_num].name);
@@ -317,8 +315,7 @@ vk_init(void)
static bool
vk_set_image_props(uint32_t w, uint32_t h, uint32_t d,
uint32_t num_samples, uint32_t num_levels,
- VkFormat format, VkImageTiling tiling,
- VkImageUsageFlagBits usage)
+ VkFormat format, VkImageTiling tiling)
{
VkImageLayout in_layout = VK_IMAGE_LAYOUT_UNDEFINED;
VkImageLayout end_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
@@ -327,7 +324,7 @@ vk_set_image_props(uint32_t w, uint32_t h, uint32_t d,
return vk_fill_ext_image_props(&vk_core, w, h, d,
num_samples, num_levels,
num_layers,
- format, tiling, usage,
+ format, tiling,
in_layout, end_layout,
true, &vk_img_props);
}
diff --git a/tests/spec/ext_external_objects/vk_pix_buf_update_errors.c b/tests/spec/ext_external_objects/vk_pix_buf_update_errors.c
index f8f1930fa..4a9d64207 100644
--- a/tests/spec/ext_external_objects/vk_pix_buf_update_errors.c
+++ b/tests/spec/ext_external_objects/vk_pix_buf_update_errors.c
@@ -66,8 +66,6 @@ vk_init(uint32_t w,
uint32_t num_layers,
VkFormat color_format,
VkFormat depth_format,
- VkImageUsageFlagBits color_usage,
- VkImageUsageFlagBits depth_usage,
VkImageTiling color_tiling,
VkImageTiling depth_tiling,
VkImageLayout color_in_layout,
@@ -110,11 +108,6 @@ static uint32_t num_levels = 1;
static uint32_t num_layers = 1;
static VkFormat color_format = VK_FORMAT_R32G32B32A32_SFLOAT;
static VkFormat depth_format = VK_FORMAT_D32_SFLOAT;
-static VkImageUsageFlagBits color_usage = VK_IMAGE_USAGE_SAMPLED_BIT |
- VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
- VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
-static VkImageUsageFlagBits depth_usage = VK_IMAGE_USAGE_SAMPLED_BIT |
- VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
static VkImageTiling color_tiling = VK_IMAGE_TILING_OPTIMAL;
static VkImageTiling depth_tiling = VK_IMAGE_TILING_OPTIMAL;
static VkImageLayout color_in_layout = VK_IMAGE_LAYOUT_UNDEFINED;
@@ -137,7 +130,6 @@ piglit_init(int argc, char **argv)
if (!vk_init(w, h, d, num_samples, num_levels, num_layers,
color_format, depth_format,
- color_usage, depth_usage,
color_tiling, depth_tiling,
color_in_layout, depth_in_layout,
color_end_layout, depth_end_layout)) {
@@ -222,8 +214,6 @@ vk_init(uint32_t w,
uint32_t num_layers,
VkFormat color_format,
VkFormat depth_format,
- VkImageUsageFlagBits color_usage,
- VkImageUsageFlagBits depth_usage,
VkImageTiling color_tiling,
VkImageTiling depth_tiling,
VkImageLayout color_in_layout,
@@ -253,7 +243,6 @@ vk_init(uint32_t w,
num_layers,
color_format,
color_tiling,
- color_usage,
color_in_layout,
color_end_layout,
false,
@@ -273,7 +262,6 @@ vk_init(uint32_t w,
num_layers,
depth_format,
depth_tiling,
- depth_usage,
depth_in_layout,
depth_end_layout,
false,
diff --git a/tests/spec/ext_external_objects/vk_vert_buf_reuse.c b/tests/spec/ext_external_objects/vk_vert_buf_reuse.c
index 322ffba6c..24d1eb889 100644
--- a/tests/spec/ext_external_objects/vk_vert_buf_reuse.c
+++ b/tests/spec/ext_external_objects/vk_vert_buf_reuse.c
@@ -352,7 +352,6 @@ vk_init_vulkan_drawing()
num_layers,
color_format,
color_tiling,
- color_usage,
color_in_layout,
color_end_layout,
false,
@@ -373,7 +372,6 @@ vk_init_vulkan_drawing()
num_layers,
depth_format,
depth_tiling,
- depth_usage,
depth_in_layout,
depth_end_layout,
false,