Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for image1d_buffer #609

Merged
merged 6 commits into from
Oct 29, 2023
Merged

add support for image1d_buffer #609

merged 6 commits into from
Oct 29, 2023

Conversation

rjodinchr
Copy link
Contributor

This implementation has been tested using the OpenCL-CTS patch with KhronosGroup/OpenCL-CTS#1806

kpet and others added 2 commits October 13, 2023 08:21
Change-Id: I4eef91af393b5487bbc208bdc96d43daa4c5c462
remove 1DBUFFER mention in init_vulkan_image
limit CL_DEVICE_IMAGE_MAX_BUFFER_SIZE WITH CL_DEVICE_MAX_MEM_ALLOC_SIZE
@rjodinchr
Copy link
Contributor Author

This PR depends on an update of clspv

Copy link
Owner

@kpet kpet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not introduce CTS regressions at my end. As discussed I'm not a big fan of handling the buffer view special case in the API layer as this breaks encapsulation. In the interest of getting forward progress, I'm with this approach as a first step (and I think it likely makes the code a bit shorter).

src/memory.cpp Outdated Show resolved Hide resolved
src/api.cpp Outdated Show resolved Hide resolved
Comment on lines +4860 to +4863
if ((components_sampled != components_storage) &&
(image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER)) {
continue;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by this condition. Those swizzles are unused for 1D buffer images. Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, this is coming from your initial commit I believe. Thinking about it, I don't see a reason to have it, maybe we should get rid of it?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, if we pass the CTS without it, then we should remove it. If we somehow need this to pass the CTS, we should find a clearer expression of the conditions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this test is needed. Otherwise the CTS thinks that we support CL_INTENSITY and CL_LUMINANCE with 1d buffer, which does not work with the actual implementation. As they are not mandatory, it feels ok to remove them with this test. What do you think?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they're not supported we should remove them but the condition used to do that is a hack (you said it was part of my draft patch, I'm assuming I'd done that as a quick way of excluding those formats). I've added an entry to #625 so we don't forget to revisit this.

src/api.cpp Outdated Show resolved Hide resolved
src/api.cpp Outdated Show resolved Hide resolved
src/api.cpp Outdated Show resolved Hide resolved
src/api.cpp Show resolved Hide resolved
src/api.cpp Outdated Show resolved Hide resolved
src/api.cpp Outdated Show resolved Hide resolved
src/api.cpp Show resolved Hide resolved
@rjodinchr rjodinchr requested a review from kpet October 16, 2023 14:45
@kpet
Copy link
Owner

kpet commented Oct 19, 2023

@rjodinchr In case you hadn't noticed: it looks like the 1DBufferImageFromSubBuffer test is hitting an assert.

@rjodinchr
Copy link
Contributor Author

The tests are expected to fail one way or another as this PR is not updating clspv.

@kpet
Copy link
Owner

kpet commented Oct 19, 2023

Ok, makes sense. Can you include the clspv update here (just the one commit we need please) so the CI passes? Thanks!

Copy link
Owner

@kpet kpet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. I think we just need to resolve the one open thread about component mapping and update clspv (just the one commit this PR needs) so the CI can pass. Everything else looks nice!

Comment on lines +4860 to +4863
if ((components_sampled != components_storage) &&
(image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER)) {
continue;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, if we pass the CTS without it, then we should remove it. If we somehow need this to pass the CTS, we should find a clearer expression of the conditions.

@@ -957,6 +967,7 @@ struct cvk_command_buffer_image_copy final : public cvk_command_batchable {
size_t m_offset;
std::array<size_t, 3> m_origin;
std::array<size_t, 3> m_region;
cl_command_type m_copy_type;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reusing cl_command_type is a bit confusing but it'll do for a first implementation.

@kpet
Copy link
Owner

kpet commented Oct 23, 2023

@rjodinchr I've had a look at the CI failures. The newly added test creates a sub-buffer at an offset that does not satisfy Vulkan constraints. clvk should have rejected the creation of the sub-buffer and texel buffer alignment constraints should be taken into account when calculating CL_DEVICE_MEM_BASE_ADDR_ALIGN. I suggest we don't fix sub-buffer error handling in this PR. In the interest of getting forward progress, you could just modify the offsets used in the test so that it works in the CI or query CL_DEVICE_MEM_BASE_ADDR_ALIGN, use it to pick the sub-buffer offset and change its implementation to take storageTexelBufferOffsetAlignmentBytes, storageTexelBufferOffsetSingleTexelAlignment, uniformTexelBufferOffsetAlignmentBytes, and uniformTexelBufferOffsetSingleTexelAlignment into account.

Copy link
Owner

@kpet kpet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems swiftshader does not support VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT_KHR on any format for texel buffers so you're going to have to disable the test for swiftshader.

VkFormatFeatureFlags format_feature_flags_WO;
format_feature_flags_WO = VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
if (type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
format_feature_flags_WO = VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the latest CI failures, it seems we also need VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT_KHR which apparently is only available as a "2" format feature so we're dragging #497 as a dependency.

@kpet
Copy link
Owner

kpet commented Oct 29, 2023

Merging this as is to unblock clspv updates. I will fix the CI with a separate commit on top.

@kpet kpet merged commit a25eb53 into kpet:main Oct 29, 2023
3 of 9 checks passed
@rjodinchr rjodinchr deleted the dev/1dbuffer branch October 29, 2023 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants