clover/device: store version in device at constructor.

This reads the env vars once and stores the value, and converts
to strings when needed

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7520>
This commit is contained in:
Dave Airlie 2020-11-10 10:03:47 +10:00
parent 297ad1bbb3
commit 981f8d7252
2 changed files with 18 additions and 6 deletions

View File

@ -49,6 +49,14 @@ namespace {
device::device(clover::platform &platform, pipe_loader_device *ldev) :
platform(platform), clc_cache(NULL), ldev(ldev) {
unsigned major = 1, minor = 1;
debug_get_version_option("CLOVER_DEVICE_VERSION_OVERRIDE", &major, &minor);
version = CL_MAKE_VERSION(major, minor, 0);
major = 1, minor = 1;
debug_get_version_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", &major, &minor);
clc_version = CL_MAKE_VERSION(major, minor, 0);
pipe = pipe_loader_create_screen(ldev);
if (pipe && pipe->get_param(pipe, PIPE_CAP_COMPUTE)) {
if (supports_ir(PIPE_SHADER_IR_NATIVE))
@ -313,16 +321,18 @@ device::endianness() const {
std::string
device::device_version_as_string() const {
static const std::string device_version =
debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1");
return device_version;
static const std::string version_string =
std::to_string(CL_VERSION_MAJOR(version)) + "." +
std::to_string(CL_VERSION_MINOR(version));
return version_string;
}
std::string
device::device_clc_version_as_string() const {
static const std::string device_clc_version =
debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1");
return device_clc_version;
static const std::string version_string =
std::to_string(CL_VERSION_MAJOR(clc_version)) + "." +
std::to_string(CL_VERSION_MINOR(clc_version));
return version_string;
}
bool

View File

@ -108,6 +108,8 @@ namespace clover {
lazy<std::shared_ptr<nir_shader>> clc_nir;
disk_cache *clc_cache;
cl_version version;
cl_version clc_version;
private:
pipe_screen *pipe;
pipe_loader_device *ldev;