Module: Mesa Branch: main Commit: 400847a990033c6d7e0bfab716bce49ec600358d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=400847a990033c6d7e0bfab716bce49ec600358d
Author: Karol Herbst <[email protected]> Date: Mon Apr 24 12:54:59 2023 +0200 rusticl/device: improve advertisement of fp64 support Enabling fp64 support makes rarely sense, but in case we do claim it, we should also tell if it's a pure software implementation. Signed-off-by: Karol Herbst <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22649> --- src/gallium/frontends/rusticl/api/device.rs | 21 ++++++++++++++------- src/gallium/frontends/rusticl/core/device.rs | 13 ++++++++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/gallium/frontends/rusticl/api/device.rs b/src/gallium/frontends/rusticl/api/device.rs index 6b36054846f..2428d997af6 100644 --- a/src/gallium/frontends/rusticl/api/device.rs +++ b/src/gallium/frontends/rusticl/api/device.rs @@ -45,18 +45,23 @@ impl CLInfo<cl_device_info> for cl_device_id { CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES => { cl_prop::<cl_device_device_enqueue_capabilities>(0) } - CL_DEVICE_DOUBLE_FP_CONFIG => { - cl_prop::<cl_device_fp_config>(if dev.doubles_supported() { - (CL_FP_FMA + CL_DEVICE_DOUBLE_FP_CONFIG => cl_prop::<cl_device_fp_config>( + if dev.doubles_supported() { + let mut fp64_config = CL_FP_FMA | CL_FP_ROUND_TO_NEAREST | CL_FP_ROUND_TO_ZERO | CL_FP_ROUND_TO_INF | CL_FP_INF_NAN - | CL_FP_DENORM) as cl_device_fp_config + | CL_FP_DENORM; + if dev.doubles_is_softfp() { + fp64_config |= CL_FP_SOFT_FLOAT; + } + fp64_config } else { 0 - }) - } + } + .into(), + ), CL_DEVICE_ENDIAN_LITTLE => cl_prop::<bool>(dev.little_endian()), CL_DEVICE_ERROR_CORRECTION_SUPPORT => cl_prop::<bool>(false), CL_DEVICE_EXECUTION_CAPABILITIES => { @@ -125,7 +130,9 @@ impl CLInfo<cl_device_info> for cl_device_id { } CL_DEVICE_NAME => cl_prop(dev.screen().name()), CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR => cl_prop::<cl_uint>(1), - CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE => cl_prop::<cl_uint>(0), + CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE => { + cl_prop::<cl_uint>(if dev.doubles_supported() { 1 } else { 0 }) + } CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT => cl_prop::<cl_uint>(1), CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF => cl_prop::<cl_uint>(0), CL_DEVICE_NATIVE_VECTOR_WIDTH_INT => cl_prop::<cl_uint>(1), diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index b3f6aeefe06..35711d303aa 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -584,17 +584,20 @@ impl Device { pub fn doubles_supported(&self) -> bool { false /* - if self.screen.param(pipe_cap::PIPE_CAP_DOUBLES) == 0 { - return false; - } + + self.screen.param(pipe_cap::PIPE_CAP_DOUBLES) == 1 + */ + } + + pub fn doubles_is_softfp(&self) -> bool { let nir_options = self .screen .nir_shader_compiler_options(pipe_shader_type::PIPE_SHADER_COMPUTE); - !bit_check( + + bit_check( unsafe { *nir_options }.lower_doubles_options as u32, nir_lower_doubles_options::nir_lower_fp64_full_software as u32, ) - */ } pub fn long_supported(&self) -> bool {
