mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-10 22:20:40 +01:00
clover/image: add templated basic_image class to simplify image subclassing
Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13401>
This commit is contained in:
parent
f6ecd284e5
commit
029f22e430
2 changed files with 19 additions and 31 deletions
|
|
@ -255,13 +255,8 @@ image1d::image1d(clover::context &ctx,
|
|||
const cl_image_format *format,
|
||||
size_t width, size_t row_pitch,
|
||||
void *host_ptr) :
|
||||
image(ctx, properties, flags, format, width, 1, 1,
|
||||
row_pitch, 0, row_pitch, host_ptr) {
|
||||
}
|
||||
|
||||
cl_mem_object_type
|
||||
image1d::type() const {
|
||||
return CL_MEM_OBJECT_IMAGE1D;
|
||||
basic_image(ctx, properties, flags, format, width, 1, 1,
|
||||
row_pitch, 0, row_pitch, host_ptr) {
|
||||
}
|
||||
|
||||
image2d::image2d(clover::context &ctx,
|
||||
|
|
@ -270,13 +265,8 @@ image2d::image2d(clover::context &ctx,
|
|||
const cl_image_format *format, size_t width,
|
||||
size_t height, size_t row_pitch,
|
||||
void *host_ptr) :
|
||||
image(ctx, properties, flags, format, width, height, 1,
|
||||
row_pitch, 0, height * row_pitch, host_ptr) {
|
||||
}
|
||||
|
||||
cl_mem_object_type
|
||||
image2d::type() const {
|
||||
return CL_MEM_OBJECT_IMAGE2D;
|
||||
basic_image(ctx, properties, flags, format, width, height, 1,
|
||||
row_pitch, 0, height * row_pitch, host_ptr) {
|
||||
}
|
||||
|
||||
image3d::image3d(clover::context &ctx,
|
||||
|
|
@ -286,12 +276,7 @@ image3d::image3d(clover::context &ctx,
|
|||
size_t width, size_t height, size_t depth,
|
||||
size_t row_pitch, size_t slice_pitch,
|
||||
void *host_ptr) :
|
||||
image(ctx, properties, flags, format, width, height, depth,
|
||||
row_pitch, slice_pitch, depth * slice_pitch,
|
||||
host_ptr) {
|
||||
}
|
||||
|
||||
cl_mem_object_type
|
||||
image3d::type() const {
|
||||
return CL_MEM_OBJECT_IMAGE3D;
|
||||
basic_image(ctx, properties, flags, format, width, height, depth,
|
||||
row_pitch, slice_pitch, depth * slice_pitch,
|
||||
host_ptr) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,16 @@ namespace clover {
|
|||
std::mutex resources_mtx;
|
||||
};
|
||||
|
||||
class image1d : public image {
|
||||
template<cl_mem_object_type Type>
|
||||
class basic_image : public image {
|
||||
public:
|
||||
using image::image;
|
||||
virtual cl_mem_object_type type() const {
|
||||
return Type;
|
||||
}
|
||||
};
|
||||
|
||||
class image1d : public basic_image<CL_MEM_OBJECT_IMAGE1D> {
|
||||
public:
|
||||
image1d(clover::context &ctx,
|
||||
std::vector<cl_mem_properties> properties,
|
||||
|
|
@ -180,11 +189,9 @@ namespace clover {
|
|||
const cl_image_format *format,
|
||||
size_t width, size_t row_pitch,
|
||||
void *host_ptr);
|
||||
|
||||
virtual cl_mem_object_type type() const;
|
||||
};
|
||||
|
||||
class image2d : public image {
|
||||
class image2d : public basic_image<CL_MEM_OBJECT_IMAGE2D> {
|
||||
public:
|
||||
image2d(clover::context &ctx,
|
||||
std::vector<cl_mem_properties> properties,
|
||||
|
|
@ -192,11 +199,9 @@ namespace clover {
|
|||
const cl_image_format *format, size_t width,
|
||||
size_t height, size_t row_pitch,
|
||||
void *host_ptr);
|
||||
|
||||
virtual cl_mem_object_type type() const;
|
||||
};
|
||||
|
||||
class image3d : public image {
|
||||
class image3d : public basic_image<CL_MEM_OBJECT_IMAGE3D>{
|
||||
public:
|
||||
image3d(clover::context &ctx,
|
||||
std::vector<cl_mem_properties> properties,
|
||||
|
|
@ -205,8 +210,6 @@ namespace clover {
|
|||
size_t width, size_t height, size_t depth,
|
||||
size_t row_pitch, size_t slice_pitch,
|
||||
void *host_ptr);
|
||||
|
||||
virtual cl_mem_object_type type() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue