Browse Source

add USE_BEGIN_REDRAW_FXN build option (disabled by default, see setenv_linux.sh)

pull/1639/head
bsp2 6 years ago
parent
commit
29a0d43b56
4 changed files with 55 additions and 5 deletions
  1. +35
    -4
      include/plugin.hpp
  2. +2
    -1
      setenv_linux.sh
  3. +11
    -0
      src/plugin.cpp
  4. +7
    -0
      src/vst2_main.cpp

+ 35
- 4
include/plugin.hpp View File

@@ -6,9 +6,14 @@
#include "tags.hpp" #include "tags.hpp"
#include "util/common.hpp" #include "util/common.hpp"



#define RACK_PLUGIN_INIT_ID_INTERNAL p->slug = TOSTRING(SLUG); p->version = TOSTRING(VERSION) #define RACK_PLUGIN_INIT_ID_INTERNAL p->slug = TOSTRING(SLUG); p->version = TOSTRING(VERSION)


#ifdef USE_BEGIN_REDRAW_FXN
extern "C" {
#include <lglw.h>
}
#endif // USE_BEGIN_REDRAW_FXN

#ifdef USE_VST2 #ifdef USE_VST2


namespace rack { namespace rack {
@@ -20,6 +25,9 @@ namespace rack {
typedef void (*vst2_handle_ui_param_fxn_t) (int uniqueParamId, float normValue); typedef void (*vst2_handle_ui_param_fxn_t) (int uniqueParamId, float normValue);
typedef void (*vst2_queue_param_sync_fxn_t) (int uniqueParamId, float value, bool _bNormalized); typedef void (*vst2_queue_param_sync_fxn_t) (int uniqueParamId, float value, bool _bNormalized);
typedef void (*rack_set_tls_globals_fxn_t) (rack::Plugin *p); typedef void (*rack_set_tls_globals_fxn_t) (rack::Plugin *p);
#ifdef USE_BEGIN_REDRAW_FXN
typedef void (*rack_begin_redraw_fxn_t) (void);
#endif // USE_BEGIN_REDRAW_FXN


#ifdef RACK_HOST #ifdef RACK_HOST


@@ -64,7 +72,21 @@ extern vst2_queue_param_sync_fxn_t vst2_queue_param_sync;
#else #else
#define JSON_SEED_INIT_EXTERNAL extern "C" { extern volatile char seed_initialized; } #define JSON_SEED_INIT_EXTERNAL extern "C" { extern volatile char seed_initialized; }
#endif #endif
#define RACK_PLUGIN_INIT(pluginname) \

#ifdef USE_BEGIN_REDRAW_FXN
// a hack that rebinds the GL context in shared plugins (may fix shared module redraw issues on Linux)
#define BEGIN_REDRAW_FXN_SET \
rack::plugin->begin_redraw_fxn = &rack::loc_begin_redraw;
#define BEGIN_REDRAW_FXN_IMP \
static void loc_begin_redraw(void) { \
lglw_glcontext_rebind(global_ui->window.lglw); \
}
#else
#define BEGIN_REDRAW_FXN_SET
#define BEGIN_REDRAW_FXN_IMP
#endif // USE_BEGIN_REDRAW_FXN

#define RACK_PLUGIN_INIT(pluginname) \
vst2_handle_ui_param_fxn_t vst2_handle_ui_param; \ vst2_handle_ui_param_fxn_t vst2_handle_ui_param; \
vst2_queue_param_sync_fxn_t vst2_queue_param_sync; \ vst2_queue_param_sync_fxn_t vst2_queue_param_sync; \
JSON_SEED_INIT_EXTERNAL \ JSON_SEED_INIT_EXTERNAL \
@@ -74,18 +96,20 @@ namespace rack { \
RACK_TLS Global *global; \ RACK_TLS Global *global; \
RACK_TLS GlobalUI *global_ui; \ RACK_TLS GlobalUI *global_ui; \
static void loc_set_tls_globals(rack::Plugin *p) { \ static void loc_set_tls_globals(rack::Plugin *p) { \
plugin = p; \
plugin = p; \
global = plugin->global; \ global = plugin->global; \
global_ui = plugin->global_ui; \ global_ui = plugin->global_ui; \
/*printf("xxx plugin:loc_set_tls_globals: &global=%p global=%p\n", &global, plugin->global);*/ \ /*printf("xxx plugin:loc_set_tls_globals: &global=%p global=%p\n", &global, plugin->global);*/ \
hashtable_seed = p->json.hashtable_seed; \ hashtable_seed = p->json.hashtable_seed; \
seed_initialized = p->json.seed_initialized; \ seed_initialized = p->json.seed_initialized; \
} \ } \
BEGIN_REDRAW_FXN_IMP \
} \ } \
static void loc_init_plugin(rack::Plugin *p); extern "C" { RACK_PLUGIN_EXPORT void init_plugin(rack::Plugin *p) { loc_init_plugin(p); } } static void loc_init_plugin(rack::Plugin *p) static void loc_init_plugin(rack::Plugin *p); extern "C" { RACK_PLUGIN_EXPORT void init_plugin(rack::Plugin *p) { loc_init_plugin(p); } } static void loc_init_plugin(rack::Plugin *p)
#define RACK_PLUGIN_INIT_ID() \ #define RACK_PLUGIN_INIT_ID() \
rack::plugin = p; \ rack::plugin = p; \
rack::plugin->set_tls_globals_fxn = &rack::loc_set_tls_globals; \ rack::plugin->set_tls_globals_fxn = &rack::loc_set_tls_globals; \
BEGIN_REDRAW_FXN_SET \
vst2_handle_ui_param = p->vst2_handle_ui_param_fxn; \ vst2_handle_ui_param = p->vst2_handle_ui_param_fxn; \
vst2_queue_param_sync = p->vst2_queue_param_sync_fxn; \ vst2_queue_param_sync = p->vst2_queue_param_sync_fxn; \
rack::global = p->global; \ rack::global = p->global; \
@@ -186,10 +210,17 @@ struct Plugin {
// //
// Set by plugin: // Set by plugin:
// - in init_plugin() // - in init_plugin()
// - called by Rack host in audio thread
// - called by Rack host in audio+UI threads
// - NULL if this is a statically linked add-on // - NULL if this is a statically linked add-on
// //
rack_set_tls_globals_fxn_t set_tls_globals_fxn = NULL; rack_set_tls_globals_fxn_t set_tls_globals_fxn = NULL;

#ifdef USE_BEGIN_REDRAW_FXN
// Called when redrawing the UI.
// An attempt to fix the GL issue with shared modules on Cameron's machine.
rack_begin_redraw_fxn_t begin_redraw_fxn = NULL;
#endif // USE_BEGIN_REDRAW_FXN

#endif // USE_VST2 #endif // USE_VST2


virtual ~Plugin(); virtual ~Plugin();


+ 2
- 1
setenv_linux.sh View File

@@ -23,13 +23,14 @@ fi


# Extra compiler flags (C and C++) # Extra compiler flags (C and C++)
#EXTRA_FLAGS=-DUSE_LOG_PRINTF #EXTRA_FLAGS=-DUSE_LOG_PRINTF
#EXTRA_FLAGS="-DUSE_BEGIN_REDRAW_FXN -I${VSVR_BASE_DIR}/dep/lglw"
EXTRA_FLAGS="" EXTRA_FLAGS=""


# Extra C compiler flags # Extra C compiler flags
export EXTRA_CFLAGS="-march=${CPU_ARCH} ${EXTRA_FLAGS}" export EXTRA_CFLAGS="-march=${CPU_ARCH} ${EXTRA_FLAGS}"


# Extra C++ compiler flags # Extra C++ compiler flags
export EXTRA_CPPFLAGS="-march=${CPU_ARCH} ${EXTRA_FLAGS}"
export EXTRA_CPPFLAGS="-march=${CPU_ARCH} ${EXTRA_FLAGS}"


# Extra optimization flags (C/C++) # Extra optimization flags (C/C++)
export EXTRA_OPTFLAGS= export EXTRA_OPTFLAGS=


+ 11
- 0
src/plugin.cpp View File

@@ -629,6 +629,17 @@ void vst2_set_shared_plugin_tls_globals(void) {
} }
} }
} }
#ifdef USE_BEGIN_REDRAW_FXN
void vst2_begin_shared_plugin_redraw(void) {
// Called in UI thread
for(Plugin *p : global->plugin.gPlugins) {
if(NULL != p->begin_redraw_fxn) {
printf("xxx call begin_redraw_fxn()\n");
p->begin_redraw_fxn();
}
}
}
#endif // USE_BEGIN_REDRAW_FXN
#endif // USE_VST2 #endif // USE_VST2


RackScene *rack_plugin_ui_get_rackscene(void) { RackScene *rack_plugin_ui_get_rackscene(void) {


+ 7
- 0
src/vst2_main.cpp View File

@@ -85,6 +85,9 @@ extern void vst2_handle_queued_params (void);
extern float vst2_get_param (int uniqueParamId); extern float vst2_get_param (int uniqueParamId);
extern void vst2_get_param_name (int uniqueParamId, char *s, int sMaxLen); extern void vst2_get_param_name (int uniqueParamId, char *s, int sMaxLen);
extern void vst2_set_shared_plugin_tls_globals (void); // see plugin.cpp extern void vst2_set_shared_plugin_tls_globals (void); // see plugin.cpp
#ifdef USE_BEGIN_REDRAW_FXN
extern void vst2_begin_shared_plugin_redraw (void); // see plugin.cpp
#endif // USE_BEGIN_REDRAW_FXN
extern "C" { extern int vst2_handle_effeditkeydown (unsigned int _vkey); } extern "C" { extern int vst2_handle_effeditkeydown (unsigned int _vkey); }


namespace rack { namespace rack {
@@ -1175,6 +1178,10 @@ public:
// Save DAW GL context and bind our own // Save DAW GL context and bind our own
lglw_glcontext_push(rack::global_ui->window.lglw); lglw_glcontext_push(rack::global_ui->window.lglw);


#ifdef USE_BEGIN_REDRAW_FXN
vst2_begin_shared_plugin_redraw();
#endif // USE_BEGIN_REDRAW_FXN

rack::vst2_editor_redraw(); rack::vst2_editor_redraw();


// Restore the DAW's GL context // Restore the DAW's GL context


Loading…
Cancel
Save