Closed claudeha closed 4 years ago
I suppose if the compiler doesn't choke on it and it doesn't create much of a binary footprint it sounds great, Complex.frag is almost entirely your doing anyways (great work btw) so you can take it in any direction you like, I'll always support improvements :-D
as long as we don't have to change every occurrence of vec with VEC in all frags :-p or all previous frags that used Complex.frag break now :-(
Proposal Rebuttal:
2 new files DoubleMath.frag DoubleComplex.frag keep the name of Complex.frag the same
define USE_DOUBLE at the top of DoubleMath.frag
so if no #include DoubleMath.frag
in loaded working frag then included Complex.frag is float only, if it is included then double types enabled as well, this should make earlier frags happy too. Complex.frag can detect USE_DOUBLE and include the DoubleComplex.frag
edit: not really a rebuttal more like agreement
User frags should work as before. If USE_DOUBLE is defined, the VEC etc will be double as before, otherwise float. User frags can choose whether to use vec (single) dvec (double) or VEC (highest available precision).
Re the rebuttal, I don't want to have to write all the complex functions twice, which is why I want to do something like:
#define VEC2 vec2
#include "ComplexBase.frag"
#ifdef USE_DOUBLE
#undef VEC2
#define VEC2 dvec2
#include "ComplexBase.frag"
#endif
Can the name remain Complex.frag and #define USE_DOUBLE in DoubleMath.frag so it is enabled when DoubleMath.frag is included? I think that would be ideal.
Sure, but for backwards compatibility with user frags, I think it'd be better for Complex.frag to do something like:
#ifdef USE_DOUBLE
#include "DoubleMath.frag"
#endif
But perhaps it would be better to drop needing USE_DOUBLE at all, and just check for #if __VERSION__ >= 400
? I don't know if there are any implementations out there that support double and don't support OpenGL 4, I guess we deal with that when a bug report arrives...
that's a good point, maybe FragM should not care what the user wants and it will simply make it available if it's supported, if it doesn't get used then there is no impact on binary size after optimization by the compiler, and the user doesn't have to wonder "how and where do I enable double types"
#if __VERSION__ >= 400
#include "DoubleMath.frag"
#endif
...in Complex.frag sounds good
bump... any progress with further testing?
I think this would be more applicable on the gl4dev branch and #included by default in new FragMv3 fragment code, a legacy branch \< GL4 and a modern branch > GL4
Not had a chance to look at it recently, sorry.
Issues remaining to be investigated:
cosh
etc) for old GLSL versions all present and correct? (or should we just require a minimum version? if so, which?)
At the moment, when
USE_DOUBLE
is defined, the complex functions (egcMul()
) are defined only fordouble
precision.Proposal: refactor
Complex.frag
so that it includes aDoubleMath.frag
for the trig etc and aComplexBase.frag
twice (once forfloat
and once fordouble
with differentVEC2
defines etc).It should be backward compatible, just exposing additional overloaded
float
versions of the complex functions even whenUSE_DOUBLE
is defined.