23 s->
c0 = glGetAttribLocation(s->
program,
"c0");
D;
24 glGenVertexArrays(1, &s->
vao);
38 glDeleteVertexArrays(1, &s->
vao);
52 void fpxx_approx_do(
struct fpxx_approx *s, GLuint *active_count, GLuint *vbo, GLuint query, mpfr_t zx, mpfr_t zy, mpfr_t dzx, mpfr_t dzy,
int pass,
const mpfr_t radius,
const mpfr_t refx,
const mpfr_t refy,
bool series_approx,
bool initial_slice,
void *abort_data,
abort_t abort_fn) {
55 mpfr_sqr(s->
delta4, radius, MPFR_RNDN);
57 mpfr_prec_t p = mpfr_get_prec(refx);
79 mpfr_set(s->
p.
x, refx, MPFR_RNDN); mpfr_set(s->
p.
y, refy, MPFR_RNDN);
80 mpfr_set(s->
z.
x, refx, MPFR_RNDN); mpfr_set(s->
z.
y, refy, MPFR_RNDN);
81 mpfr_set_ui(s->
a.
x, 1, MPFR_RNDN); mpfr_set_ui(s->
a.
y, 0, MPFR_RNDN);
82 mpfr_set_ui(s->
b.
x, 0, MPFR_RNDN); mpfr_set_ui(s->
b.
y, 0, MPFR_RNDN);
83 mpfr_set_ui(s->
c.
x, 0, MPFR_RNDN); mpfr_set_ui(s->
c.
y, 0, MPFR_RNDN);
85 mpfr_set_ui(s->
u.
x, 0, MPFR_RNDN); mpfr_set_ui(s->
u.
y, 0, MPFR_RNDN);
86 mpfr_set_ui(s->
v.
x, 0, MPFR_RNDN); mpfr_set_ui(s->
v.
y, 0, MPFR_RNDN);
87 mpfr_set_ui(s->
w.
x, 0, MPFR_RNDN); mpfr_set_ui(s->
w.
y, 0, MPFR_RNDN);
92 if (abort_fn(abort_data)) {
95 s->
values[0][0] = mpfr_get_d(s->
a.
x, MPFR_RNDN);
96 s->
values[0][1] = mpfr_get_d(s->
a.
y, MPFR_RNDN);
97 s->
values[1][0] = mpfr_get_d(s->
b.
x, MPFR_RNDN);
98 s->
values[1][1] = mpfr_get_d(s->
b.
y, MPFR_RNDN);
99 s->
values[2][0] = mpfr_get_d(s->
c.
x, MPFR_RNDN);
100 s->
values[2][1] = mpfr_get_d(s->
c.
y, MPFR_RNDN);
102 s->
values[3][0] = mpfr_get_d(s->
u.
x, MPFR_RNDN);
103 s->
values[3][1] = mpfr_get_d(s->
u.
y, MPFR_RNDN);
104 s->
values[4][0] = mpfr_get_d(s->
v.
x, MPFR_RNDN);
105 s->
values[4][1] = mpfr_get_d(s->
v.
y, MPFR_RNDN);
106 s->
values[5][0] = mpfr_get_d(s->
w.
x, MPFR_RNDN);
107 s->
values[5][1] = mpfr_get_d(s->
w.
y, MPFR_RNDN);
109 if (! series_approx) {
152 mpfr_add_ui(s->
a2.
x, s->
a2.
x, 1, MPFR_RNDN);
159 mpfr_div(s->
t1.
x, s->
t1.
x, s->
t1.
y, MPFR_RNDN);
164 mpfr_div(s->
t2.
x, s->
t2.
x, s->
t2.
y, MPFR_RNDN);
168 const double eps = 1e-40;
169 accurate = mpfr_get_d(s->
t1.
x, MPFR_RNDN) < eps && ! (mpfr_get_d(s->
t4.
y, MPFR_RNDN) > 5);
187 for (
int i = 0; i < (
DE ? 6 : 3); ++i) {
188 for (
int j = 0; j < 2; ++j) {
189 if (fabs(s->
values[i][j]) > 1.0e144 || isnan(s->
values[i][j])) {
194 mpfr_set_prec(dzx, mpfr_get_prec(s->
a.
x));
195 mpfr_set_prec(dzy, mpfr_get_prec(s->
a.
y));
196 mpfr_set_prec(zx, mpfr_get_prec(s->
z.
x));
197 mpfr_set_prec(zy, mpfr_get_prec(s->
z.
y));
198 mpfr_set(dzx, s->
a.
x, MPFR_RNDN);
199 mpfr_set(dzy, s->
a.
y, MPFR_RNDN);
200 mpfr_set(zx, s->
z.
x, MPFR_RNDN);
201 mpfr_set(zy, s->
z.
y, MPFR_RNDN);
202 if (! (*active_count > 0)) {
207 glEnable(GL_RASTERIZER_DISCARD);
D;
208 glBindVertexArray(s->
vao);
209 glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
D;
213 glVertexAttribLPointer(s->
c0, 2, GL_DOUBLE, (
DE ? 9 : 7) *
sizeof(GLdouble), 0);
D;
214 glEnableVertexAttribArray(s->
c0);
D;
215 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, vbo[0]);
D;
216 glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query);
D;
217 glBeginTransformFeedback(GL_POINTS);
D;
218 glDrawArrays(GL_POINTS, 0, *active_count);
D;
219 glEndTransformFeedback();
D;
220 glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
D;
221 int before = *active_count;
222 glGetQueryObjectuiv(query, GL_QUERY_RESULT, active_count);
D;
223 int after = *active_count;
224 debug_message(
"approx active_count: %d -> %d\n", before, after);
225 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
D;
226 glDisableVertexAttribArray(s->
c0);
D;
228 glBindBuffer(GL_ARRAY_BUFFER, 0);
D;
229 glBindVertexArray(0);
230 glDisable(GL_RASTERIZER_DISCARD);
D;
235 glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
D;
236 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, vbo[0]);
D;
237 const double *in = glMapBufferRange(GL_ARRAY_BUFFER, 0, *active_count * (
DE ? 9 : 7) *
sizeof(GLdouble), GL_MAP_READ_BIT);
D;
240 const double *q = in;
241 if (pass == 0 && ! (q[0] != 0) && ! (q[1] != 0)) {
245 double *out = glMapBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, *active_count * (
DE ? 9 : 7) *
sizeof(GLdouble), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
D;
249 C c, c2, c3, z, dz, t;
251 #define VARS c.x, c.y, c2.x, c2.y, c3.x, c3.y, z.x, z.y, dz.x, dz.y, t.x, t.y, t0, t1, t2, t3
252 mpfr_inits2(mpfr_get_prec(refx),
VARS, (mpfr_ptr) 0);
253 for (
unsigned int k = 0; k < *active_count; ++k) {
254 mpfr_set_d(c.
x, q[0], MPFR_RNDN);
255 mpfr_set_d(c.
y, q[1], MPFR_RNDN);
257 *p++ = mpfr_get_d(c.
x, MPFR_RNDN);
258 *p++ = mpfr_get_d(c.
y, MPFR_RNDN);
262 c_mul(z, s->
a, c, t0, t1, t2, t3);
263 c_sqr(c2, c, t0, t1, t3);
264 c_mul(t, s->
b, c2, t0, t1, t2, t3);
266 c_mul(c3, c, c2, t0, t1, t2, t3);
267 c_mul(t, s->
c, c3, t0, t1, t2, t3);
269 *p++ = mpfr_get_d(z.
x, MPFR_RNDN);
270 *p++ = mpfr_get_d(z.
y, MPFR_RNDN);
273 c_mul(dz, s->
u, c, t0, t1, t2, t3);
274 c_mul(t, s->
v, c2, t0, t1, t2, t3);
276 c_mul(t, s->
w, c3, t0, t1, t2, t3);
278 *p++ = mpfr_get_d(dz.
x, MPFR_RNDN);
279 *p++ = mpfr_get_d(dz.
y, MPFR_RNDN);
284 debug_message(
"approx out: c %e %e z %e %e dz %e %e\n", out[0], out[1], out[4], out[5], out[6], out[7]);
286 debug_message(
"approx out: c %e %e z %e %e\n", out[0], out[1], out[4], out[5]);
288 mpfr_clears(
VARS, (mpfr_ptr) 0);
292 ok = glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER);
D;
293 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
D;
299 ok &= glUnmapBuffer(GL_ARRAY_BUFFER);
D;
300 glBindBuffer(GL_ARRAY_BUFFER, 0);
D;