commit 84294fce8d090f4e4f06d43d11780aeb9d818f76
parent 8ecf1014665dd83abec7c6ff0395df98926221b3
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 29 Apr 2021 14:57:45 +0200
Add the ssf_get_info function
Diffstat:
4 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -100,6 +100,7 @@ set(SSF_FILES_INC
ssf_optics.h
ssf_phase_c.h)
set(SSF_FILES_SRC
+ ssf.c
ssf_beckmann_distribution.c
ssf_blinn_distribution.c
ssf_bsdf.c
diff --git a/src/ssf.c b/src/ssf.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2016-2018, 2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "ssf.h"
+
+/*******************************************************************************
+ * API function
+ ******************************************************************************/
+res_T
+ssf_get_info(struct ssf_info* info)
+{
+ if(!info) return RES_BAD_ARG;
+#ifdef SSF_USE_SIMD_128
+ info->simd_128 = 1;
+#else
+ info->simd_128 = 0;
+#endif
+#ifdef SSF_USE_SIMD_256
+ info->simd_256 = 1;
+#else
+ info->simd_256 = 0;
+#endif
+ return RES_OK;
+}
diff --git a/src/ssf.h b/src/ssf.h
@@ -192,6 +192,14 @@ struct ssf_phase_type {
#define SSF_PHASE_TYPE_NULL__ {NULL,NULL,NULL,NULL,NULL,0,1}
static const struct ssf_phase_type SSF_PHASE_TYPE_NULL = SSF_PHASE_TYPE_NULL__;
+struct ssf_info {
+ /* Define the supported SIMD instruction sets */
+ char simd_128;
+ char simd_256;
+};
+#define SSF_INFO_NULL__ {0,0}
+static const struct ssf_info SSF_INFO_NULL = SSF_INFO_NULL__;
+
/* RDGFA phase function input arguments */
struct ssf_phase_rdgfa_setup_args {
double wavelength; /* In nm */
@@ -361,6 +369,13 @@ SSF_API const struct ssf_phase_type ssf_phase_rayleigh;
SSF_API const struct ssf_phase_type ssf_phase_rdgfa;
/*******************************************************************************
+ * SSF API
+ ******************************************************************************/
+SSF_API res_T
+ssf_get_info
+ (struct ssf_info* info);
+
+/*******************************************************************************
* BSDF API - Bidirectional Scattering Distribution Function. Describes the way
* the light is scattered by a surface. Note that by convention the outgoing
* direction `wo' and the incoming direction `wi' point outward the surface.
diff --git a/src/test_ssf_phase_rdgfa.c b/src/test_ssf_phase_rdgfa.c
@@ -24,6 +24,7 @@ main(int argc, char** argv)
static const size_t NSAMPS = 10000;
struct mem_allocator allocator;
+ struct ssf_info info = SSF_INFO_NULL;
struct ssf_phase_rdgfa_setup_args args = SSF_PHASE_RDGFA_SETUP_ARGS_DEFAULT;
struct ssf_phase_rdgfa_desc desc = SSF_PHASE_RDGFA_DESC_NULL;
struct ssf_phase_rdgfa_interval interval = SSF_PHASE_RDGFA_INTERVAL_NULL;
@@ -52,6 +53,15 @@ main(int argc, char** argv)
goto error;
}
+ CHK(ssf_get_info(NULL) == RES_BAD_ARG);
+ CHK(ssf_get_info(&info) == RES_OK);
+ if(args.simd == SSF_SIMD_128) {
+ CHK(info.simd_128 != 0);
+ }
+ if(args.simd == SSF_SIMD_256) {
+ CHK(info.simd_256 != 0);
+ }
+
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
CHK(ssp_rng_create(&allocator, &ssp_rng_mt19937_64, &rng) == RES_OK);
@@ -106,7 +116,7 @@ main(int argc, char** argv)
CHK(eq_eps(pdf, ssf_phase_eval(phase, wo, wi), fabs(pdf*1.e-6)));
CHK(d3_is_normalized(wi));
-#if 1
+#if 0
fprintf(stderr, "v %g %g %g\n", wi[0]*pdf, wi[1]*pdf, wi[2]*pdf);
fprintf(stderr, "p %lu\n", (unsigned long)(i+1));
#endif