Mesa (main): clover: Implement CL_MEM_OBJECT_IMAGE1D_BUFFER
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Oct 18 02:55:12 UTC 2021
Module: Mesa
Branch: main
Commit: 3200669c2b6189cdfa1ae056e1a8234951742928
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3200669c2b6189cdfa1ae056e1a8234951742928
Author: Edward O'Callaghan <funfunctor at folklore1984.net>
Date: Fri Nov 18 16:51:14 2016 +1100
clover: Implement CL_MEM_OBJECT_IMAGE1D_BUFFER
v2: Consider surface height as valid when unused by using 1.
Fixup width boundary checking.
v3 (Karol): Pull in changes from later commits
v4:(airlied): use max_buffer_size as the limit (Fixes CTS test)
Signed-off-by: Edward O'Callaghan <funfunctor at folklore1984.net>
Signed-off-by: Karol Herbst <kherbst at redhat.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13401>
---
src/gallium/frontends/clover/api/memory.cpp | 15 ++++++++++++++-
src/gallium/frontends/clover/core/memory.cpp | 10 ++++++++++
src/gallium/frontends/clover/core/memory.hpp | 10 ++++++++++
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/gallium/frontends/clover/api/memory.cpp b/src/gallium/frontends/clover/api/memory.cpp
index 668d86bf6a4..014babac6db 100644
--- a/src/gallium/frontends/clover/api/memory.cpp
+++ b/src/gallium/frontends/clover/api/memory.cpp
@@ -228,6 +228,20 @@ clCreateImageWithProperties(cl_context d_ctx,
desc->image_width,
row_pitch, host_ptr);
+ case CL_MEM_OBJECT_IMAGE1D_BUFFER:
+ if (!desc->image_width)
+ throw error(CL_INVALID_IMAGE_SIZE);
+
+ if (all_of([=](const device &dev) {
+ const size_t max = dev.max_image_buffer_size();
+ return (desc->image_width > max);
+ }, ctx.devices()))
+ throw error(CL_INVALID_IMAGE_SIZE);
+
+ return new image1d_buffer(ctx, properties, flags, format,
+ desc->image_width,
+ row_pitch, host_ptr, desc->buffer);
+
case CL_MEM_OBJECT_IMAGE2D:
if (!desc->image_width || !desc->image_height)
throw error(CL_INVALID_IMAGE_SIZE);
@@ -287,7 +301,6 @@ clCreateImageWithProperties(cl_context d_ctx,
}
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
- case CL_MEM_OBJECT_IMAGE1D_BUFFER:
// XXX - Not implemented.
throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED);
diff --git a/src/gallium/frontends/clover/core/memory.cpp b/src/gallium/frontends/clover/core/memory.cpp
index a59972f7953..6180fcf5d41 100644
--- a/src/gallium/frontends/clover/core/memory.cpp
+++ b/src/gallium/frontends/clover/core/memory.cpp
@@ -270,6 +270,16 @@ image1d::image1d(clover::context &ctx,
row_pitch, 0, row_pitch, host_ptr, nullptr) {
}
+image1d_buffer::image1d_buffer(clover::context &ctx,
+ std::vector<cl_mem_properties> properties,
+ cl_mem_flags flags,
+ const cl_image_format *format,
+ size_t width, size_t row_pitch,
+ void *host_ptr, cl_mem buffer) :
+ basic_image(ctx, properties, flags, format, width, 1, 1, 0,
+ row_pitch, 0, row_pitch, host_ptr, buffer) {
+}
+
image2d::image2d(clover::context &ctx,
std::vector<cl_mem_properties> properties,
cl_mem_flags flags,
diff --git a/src/gallium/frontends/clover/core/memory.hpp b/src/gallium/frontends/clover/core/memory.hpp
index 72d9d32d969..fa1e53e767f 100644
--- a/src/gallium/frontends/clover/core/memory.hpp
+++ b/src/gallium/frontends/clover/core/memory.hpp
@@ -195,6 +195,16 @@ namespace clover {
void *host_ptr);
};
+ class image1d_buffer : public basic_image<CL_MEM_OBJECT_IMAGE1D_BUFFER> {
+ public:
+ image1d_buffer(clover::context &ctx,
+ std::vector<cl_mem_properties> properties,
+ cl_mem_flags flags,
+ const cl_image_format *format,
+ size_t width, size_t row_pitch,
+ void *host_ptr, cl_mem buffer);
+ };
+
class image2d : public basic_image<CL_MEM_OBJECT_IMAGE2D> {
public:
image2d(clover::context &ctx,
More information about the mesa-commit
mailing list