mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 12:28:07 +02:00
clover/spirv: Add version conversion utilities
SPIR-V and OpenCL encodes differently version numbers and since SPIR-V version numbers are reported in OpenCL, there is a need for utilities to convert back and forth. Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Francisco Jerez <currojerez@riseup.net> Signed-off-by: Pierre Moreau <dev@pmoreau.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2078>
This commit is contained in:
parent
7de1468932
commit
47feba98f3
2 changed files with 28 additions and 0 deletions
|
|
@ -837,6 +837,18 @@ clover::spirv::supported_versions() {
|
|||
return { make_spirv_version(1u, 0u) };
|
||||
}
|
||||
|
||||
cl_version
|
||||
clover::spirv::to_opencl_version_encoding(uint32_t version) {
|
||||
return CL_MAKE_VERSION((version >> 16u) & 0xff,
|
||||
(version >> 8u) & 0xff, 0u);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
clover::spirv::to_spirv_version_encoding(cl_version version) {
|
||||
return ((CL_VERSION_MAJOR(version) & 0xff) << 16u) |
|
||||
((CL_VERSION_MINOR(version) & 0xff) << 8u);
|
||||
}
|
||||
|
||||
#else
|
||||
bool
|
||||
clover::spirv::is_valid_spirv(const std::vector<char> &/*binary*/,
|
||||
|
|
@ -876,4 +888,14 @@ std::vector<uint32_t>
|
|||
clover::spirv::supported_versions() {
|
||||
return {};
|
||||
}
|
||||
|
||||
cl_version
|
||||
clover::spirv::to_opencl_version_encoding(uint32_t version) {
|
||||
return CL_MAKE_VERSION(0u, 0u, 0u);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
clover::spirv::to_spirv_version_encoding(cl_version version) {
|
||||
return 0u;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -60,6 +60,12 @@ namespace clover {
|
|||
// Returns a vector (sorted in increasing order) of supported SPIR-V
|
||||
// versions.
|
||||
std::vector<uint32_t> supported_versions();
|
||||
|
||||
// Converts a version number from SPIR-V's encoding to OpenCL's one.
|
||||
cl_version to_opencl_version_encoding(uint32_t version);
|
||||
|
||||
// Converts a version number from OpenCL's encoding to SPIR-V's one.
|
||||
uint32_t to_spirv_version_encoding(cl_version version);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue