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

[Vulkan Interop] Refining DPCT interface for handling mipmap images #2594

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/lib/DPCT/RulesLang/APINamesGraphicsInterop.inc
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ ASSIGNABLE_FACTORY(CONDITIONAL_FACTORY_ENTRY(
// External Resource APIs
CONDITIONAL_FACTORY_ENTRY(
UseExtBindlessImages,
CALL_FACTORY_ENTRY("cudaImportExternalMemory",
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaImportExternalMemory",
CALL(MapNames::getDpctNamespace() +
"experimental::import_external_memory",
ARG(0), ARG(1))),
ARG(0), ARG(1)))),
UNSUPPORT_FACTORY_ENTRY("cudaImportExternalMemory", Diagnostics::TRY_EXPERIMENTAL_FEATURE,
ARG("cudaImportExternalMemory"),
ARG("--use-experimental-features=bindless_images")))
Expand Down
23 changes: 21 additions & 2 deletions clang/runtime/dpct-rt/include/dpct/bindless_images.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,29 @@ class external_mem_img_desc {

/// size setter
/// \param [in] img_dims The dimensions of the imported image resource
void set_size(sycl::range<3> img_dims) { size = img_dims; }
void set_size(sycl::range<3> img_dims) {
size = img_dims;

for (int i = 0; i < 3; i++) {
if (size[i] == 1) {
size[i] = 0;
}
}
}

/// image_channel setter
/// \param [in] img_ch The channel info of the imported image resource
void set_image_channel(image_channel img_ch) { channel = img_ch; }

/// num_levels setter
/// \param [in] numLevels The no. of levels in the imported image resource
void set_num_levels(unsigned int numLevels) { num_levels = numLevels; }
void set_num_levels(unsigned int num_levels) {
this->num_levels = num_levels;

if (num_levels > 1) {
set_image_type(sycl::ext::oneapi::experimental::image_type::mipmap);
}
}

/// type setter
/// \param [in] img_type The type of the imported image resource
Expand Down Expand Up @@ -303,6 +317,11 @@ class image_mem_wrapper {
/// Get the image mip level of the bindless image memory.
/// \returns The image mip level of the bindless image memory.
image_mem_wrapper *get_mip_level(unsigned int level) {
if (_desc.type == sycl::ext::oneapi::experimental::image_type::standard) {
assert(level == 0);
return this;
}

assert(_desc.type == sycl::ext::oneapi::experimental::image_type::mipmap);
return _sub_wrappers + level;
}
Expand Down