Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/libANGLE/CLImage.h
1693 views
1
//
2
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
// CLImage.h: Defines the cl::Image class, which stores a texture, frame-buffer or image.
7
8
#ifndef LIBANGLE_CLIMAGE_H_
9
#define LIBANGLE_CLIMAGE_H_
10
11
#include "libANGLE/CLMemory.h"
12
13
#include "libANGLE/cl_utils.h"
14
15
namespace cl
16
{
17
18
class Image final : public Memory
19
{
20
public:
21
// Front end entry functions, only called from OpenCL entry points
22
23
static bool IsTypeValid(MemObjectType imageType);
24
static bool IsValid(const _cl_mem *image);
25
26
cl_int getInfo(ImageInfo name, size_t valueSize, void *value, size_t *valueSizeRet) const;
27
28
public:
29
~Image() override;
30
31
MemObjectType getType() const final;
32
33
const cl_image_format &getFormat() const;
34
const ImageDescriptor &getDescriptor() const;
35
36
bool isRegionValid(const size_t origin[3], const size_t region[3]) const;
37
38
size_t getElementSize() const;
39
size_t getRowSize() const;
40
size_t getSliceSize() const;
41
42
private:
43
Image(Context &context,
44
PropArray &&properties,
45
MemFlags flags,
46
const cl_image_format &format,
47
const ImageDescriptor &desc,
48
Memory *parent,
49
void *hostPtr,
50
cl_int &errorCode);
51
52
const cl_image_format mFormat;
53
const ImageDescriptor mDesc;
54
55
friend class Object;
56
};
57
58
inline bool Image::IsValid(const _cl_mem *image)
59
{
60
return Memory::IsValid(image) && IsTypeValid(image->cast<Memory>().getType());
61
}
62
63
inline MemObjectType Image::getType() const
64
{
65
return mDesc.type;
66
}
67
68
inline const cl_image_format &Image::getFormat() const
69
{
70
return mFormat;
71
}
72
73
inline const ImageDescriptor &Image::getDescriptor() const
74
{
75
return mDesc;
76
}
77
78
inline size_t Image::getElementSize() const
79
{
80
return GetElementSize(mFormat);
81
}
82
83
inline size_t Image::getRowSize() const
84
{
85
return GetElementSize(mFormat) * mDesc.width;
86
}
87
88
inline size_t Image::getSliceSize() const
89
{
90
return GetElementSize(mFormat) * mDesc.width * mDesc.height;
91
}
92
93
} // namespace cl
94
95
#endif // LIBANGLE_CLIMAGE_H_
96
97