-
Notifications
You must be signed in to change notification settings - Fork 199
Adding SYCL bindless image support #612
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
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| #include "common/DeviceRT.h" | ||
|
|
||
| #include <sycl/sycl.hpp> | ||
|
|
||
| namespace syclexp = sycl::ext::oneapi::experimental; | ||
| namespace ospray { | ||
| namespace devicert { | ||
|
|
||
|
|
@@ -43,6 +43,7 @@ struct OSPRAY_SDK_INTERFACE DeviceImpl : public Device | |
| DeviceImpl(bool debug); | ||
| DeviceImpl(uint32_t deviceId, bool debug); | ||
| DeviceImpl(void *devicePtr, void *contextPtr, bool debug); | ||
| ~DeviveImpl(); | ||
|
|
||
| // Allocate device memory | ||
| void *deviceMalloc(std::size_t size) override; | ||
|
|
@@ -89,7 +90,28 @@ struct OSPRAY_SDK_INTERFACE DeviceImpl : public Device | |
| void *getSyclContextPtr() override; | ||
| void *getSyclQueuePtr() override; | ||
|
|
||
| void *createImageMemHandle(void ** hostData, | ||
| const size_t width, | ||
| const size_t height, | ||
| const unsigned int numLevels, | ||
| const OSPTextureFormat format) override; | ||
|
|
||
| void freeImageMemHandle(void *handle) override; | ||
|
|
||
| void *createSampledImageHandle(void *imgMemHandle, | ||
| const OSPTextureFilter filter, | ||
| const vec2ui wrapMode) override; | ||
|
|
||
| void freeSampledImageHandle(void *handle) override; | ||
|
|
||
| private: | ||
|
|
||
| struct ImageMemEntry { | ||
| syclexp::image_mem_handle memHandle; | ||
| syclexp::image_descriptor desc; | ||
| }; | ||
| std::unordered_map<void *, ImageMemEntry> imageMemCache; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This extra cache just to remember the |
||
|
|
||
| sycl::device device; | ||
| sycl::context context; | ||
| sycl::queue queue; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,10 @@ | |
| #include "Texture2DFormats.ih" | ||
|
|
||
| OSPRAY_BEGIN_ISPC_NAMESPACE | ||
|
|
||
| #ifdef OSPRAY_TARGET_SYCL | ||
| using half = sycl::half; | ||
| namespace syclexp = sycl::ext::oneapi::experimental; | ||
| #endif | ||
| // TODO tiling | ||
|
|
||
| // Texture coordinate utilities | ||
|
|
@@ -136,6 +139,17 @@ inline vec4f Texture2D_bilinear_l( | |
| SYCL_EXTERNAL __noinline vec4f Texture2D_get( | ||
| const Texture2D *uniform self, const vec2f &st, const float pixelFootprint) | ||
| { | ||
| #ifdef OSPRAY_TARGET_SYCL | ||
| syclexp::sampled_image_handle handle; | ||
| handle.raw_handle = (syclexp::sampled_image_handle::raw_handle_type)self->data[0]; | ||
|
|
||
| sycl::float4 res = syclexp::sample_mipmap<sycl::float4>( | ||
| handle, | ||
| sycl::float2{st.x, st.y}, | ||
| 0.f); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
|
|
||
| return make_vec4f(res.x(), res.y(), res.z(), res.w()); | ||
| #else | ||
| int mipLevel = 0; | ||
| float frac = 0.f; | ||
| const uniform bool filter_nearest = self->filter & OSP_TEXTURE_FILTER_NEAREST; | ||
|
|
@@ -145,15 +159,14 @@ SYCL_EXTERNAL __noinline vec4f Texture2D_get( | |
| mipLevel = min((int)lambda, self->maxLevel - 1); | ||
| frac = min(lambda - mipLevel, 1.f); | ||
| } | ||
|
|
||
| vec4f t0 = filter_nearest ? Texture2D_nearest_l(self, st, mipLevel) | ||
| : Texture2D_bilinear_l(self, st, mipLevel); | ||
| if (frac == 0.f) | ||
| return t0; | ||
|
|
||
| vec4f t1 = filter_nearest ? Texture2D_nearest_l(self, st, mipLevel + 1) | ||
| : Texture2D_bilinear_l(self, st, mipLevel + 1); | ||
| return lerp(frac, t0, t1); | ||
| #endif | ||
| } | ||
|
|
||
| export void *uniform Texture2D_get_addr(const uniform uint32 type) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OSPRay supports
wrapModeper dimension (x and y).