Since we always call swap buffer between a call to draw and
the next call to process(), we don't need it. In the future,
make this an option in case there is some usecase that require
it.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This app is CL 1.1 compatible and so we're forced to use some API
that were deprecated in 2.0, no need to be constantly reminded of
it
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
I originally used 1.5 compatibility because it still allows immediate
mode / fixed pipeline without warning. But Intel Cards on linux and
OSX in general don't implement it.
Using 1.3 works fine since I don't need anything more recent, but
if you display the compilation results, it will for a deprecation
warning.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
GL_MODULATE is required and since it might be used in other mode for
other function, we need to set it explicitely.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Much faster than glTexImage2D since it only updates the data
and doesn't delete/create a new storage space for the data.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
If no data was processed, finished would return 0 and then the gl_refresh
would not be called which would lead to the GL deferred init to not be
executed which can crash the OpenGL driver.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Although in theory there is nothing wrong with this and fosphor itself
should support it. However it seems some OpenCL implementation don't
really like having multiple context created in parallell, so we prevent
this manually here.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
The basic idea is that we just create normal CL buffers, then whenever
we need to draw, we wait for CL completion, read the buffers into the
main memory and upload them as textures using plain GL.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
When calling the process method several time without drawing, we don't
need to release the GL objects or even calling clFinish. So here we
internally keep track and only do the 'finishing up' of the CL process
when doing a drawing call.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
The OpenCL 1.2 is nicer but we can't always use it and on linux,
even if the CL_VERSION_1_2 exists, we can't trust it because distrib
sometimes have CL 1.2 headers with a CL 1.1 dispatcher.
So instead, we only assume we have 1.1 header and lib at compile time.
Then at run-time we do a dynamic lookup of the 1.2 symbols from the lib.
We also check if the actual selected platform does support 1.2 (you
could have a 1.2 dispatcher with a 1.1 platform implementation).
If both conditions are satisfied, then we dispatch the call to the 1.2
implementation and if not, then we dispatch them to a local fallback
implementation of the functions (but limited to the functions we need)
It's not pretty but it should work and it isolates all the hack magic
inside cl_compat.{c,h} and you just use the CL1.2 API normally outside
of it.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
cl_platform.h will convert any sign of windows to this symbol and this
is also the one use for the include at the top, so use it everywhere.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Since the width/height will be set as part of the initial reshape
callback and this is done in glfw_init, we need to make sure we
do the first init of the render option _before_ that, or we'll
undo what glfw_init did.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
'over' variable needs to be an integer or we'll end up shifting stuff
by half a pixel which causes weird render, especially for fonts.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Note that the d_zoom_* vars are kept as double to avoid error build-up
when changing them a lot from the UI.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Note that the zoom_* vars are kept as double to avoid error build-up
when changing them a lot from the UI.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
These are purely display things that allow to highligh chunks of spectrum
of interest. (like currently selected channel)
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
There is a lot of parameters that have no influence on the internal
computations but solely affect the rendering call. The height / width
are the only two that were supported previously.
This commit re-structures the drawing code and introduces a lot more
of those parameters. Instead of just passing them all as arguments, a
'struct fosphor_render' is introduced to hold them.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
The texture coordinates didn't match what the normal OpenGL bilinear
mapper does. It was off by half a texel.
This is needed because the color in the texture is considered to be a
sample at the center of the texel. (hence 0.5f, 0.5f offset removed)
For more details on bilinear from OpenGL :
http://hacksoflife.blogspot.be/2009/12/texture-coordinate-system-for-opengl.html
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This is required for OSX where you need to tell the GL context when resize
has occured and stuff like that.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
On system with an integrated gpu + external gpu, the integrated one looks
great "on paper". Plenty of local ram, plenty of compute units, ...
But in practice, it sucks against the external one. So here, we prefer
NVidia / AMD.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
- It's not longer hardcoded / computed in the kernel, but computed
once and read from constant memory
- By default it uses a periodic Hamming window
- But you can load any window as a simple array of float
- Different types of window is deemed out-of-scope here. The default
is provided just for convenience to have something valid.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
The setters can be called from any thrad and will just set the
member variables and a flag asking the main processing thread to apply
the new settings on the next iteration.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Although this is not actually used anywhere yet, but will be used in the
drawing routines to draw a proper scale.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
The CL code keeps its own copy since those values are tweaked to be
applied in the kernel. We may also need the callback in the future if
instead of storing them we reconfigure the kernel at that point.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Originally I wanted the CL/GL part to be as separate as possible and
have no shared data. But it's too inconvenient since a beside the
CL / GL objects there is also configuration data that should be shared
and distributed between the two.
So instead we still have separate gl/cl state that are restricted but
the function act on a shared 'struct fosphor' object that contains
everything that's shared and exposed to both cl.c and gl.c
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
It seems that some linux distro ship OpenCL 1.2 headers but a OpenCL 1.1
ICD ...
So we just use OpenCL 1.1 API everywhere and disable 1.1 deprecated
warnings.
OSX OTOH doesn't allow to disable the deprecated but at least ships
consistent headers/ICD so we use 1.2 is available.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
You'd don't have to have glfw, qt and wx all at once, you can select
which variant you want built.
Python support is also make fully optional
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
It's split into:
- A generic "base" sink that handles pretty much everything except
managing a GL context and getting the UI interaction for it
- The GLFW specific part
This is preparation for for WX and QT widget implementations of a
fosphor sink.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
I originally thought that even with multiple fosphor instance, the shaders
could just be shared. But if those instances are binded to different
GL Contexts, shaders aren't shared and so need to be recreated.
So all the gl_cmap shader stuff is now stored inside a fosphor_gl_cmap_ctx
struct and the latter is stored in fosphor_gl_state
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Since all the cmap stuff is fosphor-specific and can't be really
reused, use the fosphor_ prefix for stuff exposed outside gl_cmap.c
itself.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Basically need to :
- Set the kernel parameter at each kernel invocation
- Modify the kernel to deal with wrap-around when writing the
waterfall texture
The batch size still must meet some constraint :
- Be a multiple of FOSPHOR_FFT_MULT_BATCH
- Be less than FOSPHOR_FFT_MAX_BATCH
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Apparently there are some cards that are neither Nvidia SM1.1, nor
OpenCL 1.1 but that do have cl_khr_local_int32_base_atomics extension.
This is enough for fosphor to implement the histogram so add the
required code to test for it and enable its use in the kernel if
required.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
OSX doesn't allow query of NV attributes even on NVidia cards so we just
assume any non-opencl 1.1 nvidia card that does OpenCL is a SM1.1 one.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>