renderspu.h revision f350d4fb2d12fd22c0905fe9c7a121499da7b52d
/* Copyright (c) 2001, Stanford University
* All rights reserved.
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#ifndef CR_RENDERSPU_H
#define CR_RENDERSPU_H
#ifdef WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define RENDER_APIENTRY __stdcall
# ifndef VBOX_WITH_COCOA_QT
# else
# include "renderspu_cocoa_helper.h"
# endif
#define RENDER_APIENTRY
#else
#define RENDER_APIENTRY
#endif
#include "cr_threads.h"
#include "cr_spu.h"
#include "cr_hash.h"
#include "cr_server.h"
#include "cr_blitter.h"
#include <iprt/critsect.h>
#if defined(GLX) /* @todo: unify windows and glx thread creation code */
#include <iprt/semaphore.h>
/* special window id used for representing the command window CRWindowInfo */
/* CRHashTable is using unsigned long keys, we use it to trore X Window -> CRWindowInfo association */
AssertCompile(sizeof (Window) == sizeof (unsigned long));
#endif
#define MAX_VISUALS 32
#ifdef RT_OS_DARWIN
# ifndef VBOX_WITH_COCOA_QT
enum
{
/* Event classes */
kEventClassVBox = 'vbox',
/* Event kinds */
kEventVBoxShowWindow = 'swin',
kEventVBoxHideWindow = 'hwin',
kEventVBoxMoveWindow = 'mwin',
kEventVBoxResizeWindow = 'rwin',
kEventVBoxDisposeWindow = 'dwin',
kEventVBoxUpdateDock = 'udck',
kEventVBoxUpdateContext = 'uctx',
kEventVBoxBoundsChanged = 'bchg'
};
# endif
#endif /* RT_OS_DARWIN */
/**
* Visual info
*/
typedef struct {
const char *displayName;
#if defined(WINDOWS)
// HDC device_context;
# ifndef VBOX_WITH_COCOA_QT
# endif
#ifdef GLX_VERSION_1_3
#endif /* GLX_VERSION_1_3 */
#endif
} VisualInfo;
/**
* Window info
*/
typedef struct WindowInfo {
int x, y;
// int width, height;
// int id; /**< integer window ID */
char *title;
/* the composotor lock is used to synchronize the current compositor access,
* i.e. the compositor can be accessed by a gui refraw thread,
* while chromium thread might try to set a new compositor
* note that the compositor internally has its own lock to be used for accessing its data
* see CrVrScrCompositorLock/Unlock; renderspu and crserverlib would use it for compositor data access */
#if defined(WINDOWS)
# ifndef VBOX_WITH_COCOA_QT
/* unsigned long context_ptr; */
# else
# endif
#endif
int nvSwapGroup;
#ifdef USE_OSMESA
int in_buffer_width;
int in_buffer_height;
#endif
} WindowInfo;
/**
* Context Info
*/
typedef struct _ContextInfo {
// int id; /**< integer context ID */
#if defined(WINDOWS)
# ifndef VBOX_WITH_COCOA_QT
# else
# endif
#endif
struct _ContextInfo *shared;
char *extensionString;
} ContextInfo;
/**
* Barrier info
*/
typedef struct {
} Barrier;
#ifdef GLX
typedef enum
{
/* create the window (not used for now) */
/* destroy the window (not used for now) */
/* notify the WinCmd thread about window creation */
/* notify the WinCmd thread about window destroy */
/* nop used to synchronize with the WinCmd thread */
/* exit Win Cmd thread */
typedef struct CR_RENDER_WINCMD
{
/* command type */
/* command result */
int rc;
/* valid for WIN_CREATE & WIN_DESTROY only */
#endif
#ifdef RT_OS_DARWIN
typedef void (*PFNGET_ATTACHED_OBJECTS)( GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, GLhandleARB * obj );
typedef void (*PFNGET_INFO_LOG)( GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog );
#endif
/**
* Renderspu state info
*/
typedef struct {
int id;
/** config options */
/*@{*/
char *window_title;
unsigned int defaultWidth, defaultHeight;
int default_visual;
int use_L2;
int fullscreen, ontop;
char display_string[100];
#if defined(GLX)
int try_direct;
int force_direct;
int sync;
#endif
int render_to_app_window;
int crut_drawable;
int resizable;
int borderless;
int nvSwapGroup;
int ignore_papi;
int ignore_window_moves;
int pbufferWidth, pbufferHeight;
int use_glxchoosevisual;
int draw_bbox;
/*@}*/
int gather_port;
int gather_userbuf_size;
int numVisuals;
#ifndef CHROMIUM_THREADSAFE
#endif
int swap_mtu;
char *swap_master_url;
#ifdef USE_OSMESA
/** Off screen rendering hooks. */
int use_osmesa;
#endif
#if defined(GLX)
/* display connection used to send data to the WinCmd thread */
/* X Window -> CRWindowInfo table */
#endif
#ifdef RT_OS_WINDOWS
#endif
#ifdef RT_OS_DARWIN
# ifdef VBOX_WITH_COCOA_QT
# else
bool fInit;
# endif
#endif /* RT_OS_DARWIN */
} RenderSPU;
#ifdef RT_OS_WINDOWS
/* Asks window thread to create new window.
msg.lParam - holds pointer to CREATESTRUCT structure
note that lpCreateParams is used to specify address to store handle of created window
msg.wParam - unused, should be NULL
*/
typedef struct _VBOX_RENDERSPU_DESTROY_WINDOW {
/* Asks window thread to destroy previously created window.
msg.lParam - holds pointer to RENDERSPU_VBOX_WINDOW_DESTROY structure
msg.wParam - unused, should be NULL
*/
#endif
extern RenderSPU render_spu;
/* @todo remove this hack */
extern uint64_t render_spu_parent_window_id;
#ifdef CHROMIUM_THREADSAFE
extern CRtsd _RenderTSD;
#define SET_CONTEXT_VAL(_v) do { \
} while (0)
#else
#define SET_CONTEXT_VAL(_v) do { \
} while (0)
#endif
extern GLboolean renderspu_SystemCreateContext( VisualInfo *visual, ContextInfo *context, ContextInfo *sharedContext );
extern GLboolean renderspu_SystemCreateWindow( VisualInfo *visual, GLboolean showIt, WindowInfo *window );
extern GLboolean renderspu_SystemVBoxCreateWindow( VisualInfo *visual, GLboolean showIt, WindowInfo *window );
extern void renderspu_SystemGetWindowGeometry( WindowInfo *window, GLint *x, GLint *y, GLint *w, GLint *h );
extern void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, const GLint* pRects);
extern int renderspu_SystemInit();
extern int renderspu_SystemTerm();
extern void renderspu_SystemDefaultSharedContextChanged(ContextInfo *fromContext, ContextInfo *toContext);
extern void renderspu_SystemMakeCurrent( WindowInfo *window, GLint windowInfor, ContextInfo *context );
extern void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry );
uint32_t renderspu_SystemPostprocessFunctions(SPUNamedFunctionTable *aFunctions, uint32_t cFunctions, uint32_t cTable);
extern void renderspu_GCWindow(void);
extern void renderspuVBoxCompositorSet( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor);
extern void renderspuVBoxCompositorClearAll();
extern int renderspuVBoxCompositorTryAcquire(WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR **ppCompositor);
extern void renderspuVBoxPresentCompositionGeneric( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry, int32_t i32MakeCurrentUserData );
extern int renderspuVBoxPresentBlitterEnter( PCR_BLITTER pBlitter, int32_t i32MakeCurrentUserData );
extern PCR_BLITTER renderspuVBoxPresentBlitterGetAndEnter( WindowInfo *window, int32_t i32MakeCurrentUserData );
extern PCR_BLITTER renderspuVBoxPresentBlitterEnsureCreated( WindowInfo *window, int32_t i32MakeCurrentUserData );
extern void renderspuPerformMakeCurrent(WindowInfo *window, GLint nativeWindow, ContextInfo *context);
extern GLboolean renderspuWindowInit(WindowInfo *pWindow, const char *dpyName, GLint visBits, GLint id);
extern GLboolean renderspuWindowInitWithVisual( WindowInfo *window, VisualInfo *visual, GLboolean showIt, GLint id );
extern GLboolean renderspuInitVisual(VisualInfo *pVisInfo, const char *displayName, GLbitfield visAttribs);
extern void renderspuVBoxCompositorBlit ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter);
extern void renderspuVBoxCompositorBlitStretched ( struct VBOXVR_SCR_COMPOSITOR * pCompositor, PCR_BLITTER pBlitter, GLfloat scaleX, GLfloat scaleY);
extern GLint renderspuCreateContextEx(const char *dpyName, GLint visBits, GLint id, GLint shareCtx);
extern GLint RENDER_APIENTRY renderspuCreateContext( const char *dpyname, GLint visBits, GLint shareCtx );
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* CR_RENDERSPU_H */