Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-04-29 17:25:35 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-04-29 17:25:35 +0300
commit738a890025eccc1b98fdc11386a9f203acda71c4 (patch)
tree24553cbb0a6990840a3fb15f2ec0903c01e86e0f
parent9bdb2f5e0b2cbdcdb06af5d672cd8c22742346b2 (diff)
parent5946352ae2cd3ef14d8af07f8d4bd047954b9fd1 (diff)
Merge branch 'blender-v2.93-release'
-rw-r--r--intern/cycles/util/util_system.cpp46
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c29
2 files changed, 39 insertions, 36 deletions
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 8971867b736..03bc5aea1dd 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -145,7 +145,8 @@ int system_cpu_num_active_group_processors()
return numaAPI_GetNumCurrentNodesProcessors();
}
-#if !defined(__APPLE__) && (!defined(_WIN32) || defined(FREE_WINDOWS))
+/* Equivalent of Windows __cpuid for x86 processors on other platforms. */
+#if (!defined(_WIN32) || defined(FREE_WINDOWS)) && (defined(__x86_64__) || defined(__i386__))
static void __cpuid(int data[4], int selector)
{
# if defined(__x86_64__)
@@ -167,12 +168,33 @@ static void __cpuid(int data[4], int selector)
string system_cpu_brand_string()
{
#if defined(__APPLE__)
+ /* Get from system on macOS. */
char modelname[512] = "";
size_t bufferlen = 512;
if (sysctlbyname("machdep.cpu.brand_string", &modelname, &bufferlen, NULL, 0) == 0) {
return modelname;
}
-#elif !defined(WIN32) && !defined(__x86_64__) && !defined(__i386__)
+#elif defined(WIN32) || defined(__x86_64__) || defined(__i386__)
+ /* Get from intrinsics on Windows and x86. */
+ char buf[49] = {0};
+ int result[4] = {0};
+
+ __cpuid(result, 0x80000000);
+
+ if (result[0] != 0 && result[0] >= (int)0x80000004) {
+ __cpuid((int *)(buf + 0), 0x80000002);
+ __cpuid((int *)(buf + 16), 0x80000003);
+ __cpuid((int *)(buf + 32), 0x80000004);
+
+ string brand = buf;
+
+ /* Make it a bit more presentable. */
+ brand = string_remove_trademark(brand);
+
+ return brand;
+ }
+#else
+ /* Get from /proc/cpuinfo on Unix systems. */
FILE *cpuinfo = fopen("/proc/cpuinfo", "r");
if (cpuinfo != nullptr) {
char cpuinfo_buf[513] = "";
@@ -192,24 +214,6 @@ string system_cpu_brand_string()
}
}
}
-#else
- char buf[49] = {0};
- int result[4] = {0};
-
- __cpuid(result, 0x80000000);
-
- if (result[0] != 0 && result[0] >= (int)0x80000004) {
- __cpuid((int *)(buf + 0), 0x80000002);
- __cpuid((int *)(buf + 16), 0x80000003);
- __cpuid((int *)(buf + 32), 0x80000004);
-
- string brand = buf;
-
- /* make it a bit more presentable */
- brand = string_remove_trademark(brand);
-
- return brand;
- }
#endif
return "Unknown CPU";
}
@@ -219,7 +223,7 @@ int system_cpu_bits()
return (sizeof(void *) * 8);
}
-#if defined(__x86_64__) || defined(_M_X64) || defined(i386) || defined(_M_IX86)
+#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
struct CPUCapabilities {
bool x64;
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index a0a31ab6154..f47c8dfb405 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -867,19 +867,19 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
BMIter iter;
const float axis[3] = {0, 0, 1};
float vec[3], mat[4][4], cmat[3][3];
- float phi, phid;
int a;
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
- phid = 2.0f * (float)M_PI / tot;
+ const float phid = (float)M_PI / tot;
/* phi = 0.25f * (float)M_PI; */ /* UNUSED */
/* one segment first */
- phi = 0;
- phid /= 2;
for (a = 0; a <= tot; a++) {
/* Going in this direction, then edge extruding, makes normals face outward */
+ /* Calculate with doubles for higher precision, see: T87779. */
+ const float phi = M_PI * ((double)a / (double)tot);
+
vec[0] = 0.0;
vec[1] = dia * sinf(phi);
vec[2] = dia * cosf(phi);
@@ -891,7 +891,6 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
BMO_edge_flag_enable(bm, e, EDGE_ORIG);
}
- phi += phid;
preveve = eve;
}
@@ -1272,7 +1271,7 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
BMVert *v1, *lastv1 = NULL, *cent1, *firstv1 = NULL;
- float vec[3], mat[4][4], phi, phid;
+ float vec[3], mat[4][4];
int a;
if (!segs) {
@@ -1281,9 +1280,6 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
- phid = 2.0f * (float)M_PI / segs;
- phi = 0;
-
if (cap_ends) {
zero_v3(vec);
mul_m4_v3(mat, vec);
@@ -1292,8 +1288,11 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
BMO_vert_flag_enable(bm, cent1, VERT_MARK);
}
- for (a = 0; a < segs; a++, phi += phid) {
+ for (a = 0; a < segs; a++) {
/* Going this way ends up with normal(s) upward */
+
+ /* Calculate with doubles for higher precision, see: T87779. */
+ const float phi = (2.0 * M_PI) * ((double)a / (double)segs);
vec[0] = -radius * sinf(phi);
vec[1] = radius * cosf(phi);
vec[2] = 0.0f;
@@ -1392,7 +1391,7 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
{
BMVert *v1, *v2, *lastv1 = NULL, *lastv2 = NULL, *cent1, *cent2, *firstv1, *firstv2;
BMFace *f;
- float vec[3], mat[4][4], phi, phid;
+ float vec[3], mat[4][4];
const float dia1 = BMO_slot_float_get(op->slots_in, "diameter1");
const float dia2 = BMO_slot_float_get(op->slots_in, "diameter2");
const float depth_half = 0.5f * BMO_slot_float_get(op->slots_in, "depth");
@@ -1409,9 +1408,6 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
- phid = 2.0f * (float)M_PI / segs;
- phi = 0;
-
if (cap_ends) {
vec[0] = vec[1] = 0.0f;
vec[2] = -depth_half;
@@ -1432,7 +1428,10 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
const int side_faces_len = segs - 1;
BMFace **side_faces = MEM_mallocN(sizeof(*side_faces) * side_faces_len, __func__);
- for (int i = 0; i < segs; i++, phi += phid) {
+ for (int i = 0; i < segs; i++) {
+ /* Calculate with doubles for higher precision, see: T87779. */
+ const float phi = (2.0 * M_PI) * ((double)i / (double)segs);
+
vec[0] = dia1 * sinf(phi);
vec[1] = dia1 * cosf(phi);
vec[2] = -depth_half;