Mesa (master): clover/spirv: Add version conversion utilities
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jan 1 22:28:33 UTC 2021
Module: Mesa
Branch: master
Commit: 47feba98f3833801ec2e8fdd018081897af6c510
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=47feba98f3833801ec2e8fdd018081897af6c510
Author: Pierre Moreau <dev at pmoreau.org>
Date: Thu Nov 12 20:08:45 2020 +0100
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 at redhat.com>
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
Signed-off-by: Pierre Moreau <dev at pmoreau.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2078>
---
src/gallium/frontends/clover/spirv/invocation.cpp | 22 ++++++++++++++++++++++
src/gallium/frontends/clover/spirv/invocation.hpp | 6 ++++++
2 files changed, 28 insertions(+)
diff --git a/src/gallium/frontends/clover/spirv/invocation.cpp b/src/gallium/frontends/clover/spirv/invocation.cpp
index a755df18055..38b1c6398b0 100644
--- a/src/gallium/frontends/clover/spirv/invocation.cpp
+++ b/src/gallium/frontends/clover/spirv/invocation.cpp
@@ -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
diff --git a/src/gallium/frontends/clover/spirv/invocation.hpp b/src/gallium/frontends/clover/spirv/invocation.hpp
index f4ef93151d8..559260627c1 100644
--- a/src/gallium/frontends/clover/spirv/invocation.hpp
+++ b/src/gallium/frontends/clover/spirv/invocation.hpp
@@ -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);
}
}
More information about the mesa-commit
mailing list