static GLXContext ctx = NULL;
static GC vidx11_gc = NULL;
static XImage *vidx11_ximage[2] = { NULL, NULL };
-static int vidx11_ximage_pos;
+static int vidx11_ximage_pos = 0;
static XShmSegmentInfo vidx11_shminfo[2];
static int vidx11_shmevent = -1;
static int vidx11_shmwait = 0; // number of frames outstanding
static qboolean BuildXImages(int w, int h)
{
int i;
+ if(DefaultDepth(vidx11_display, vidx11_screen) != 32 && DefaultDepth(vidx11_display, vidx11_screen) != 24)
+ {
+ Con_Printf("Sorry, we only support 24bpp and 32bpp modes\n");
+ VID_Shutdown();
+ return false;
+ }
+ // match to dpsoftrast's specs
+ if(vidx11_visual->red_mask != 0x00FF0000)
+ {
+ Con_Printf("Sorry, we only support BGR visuals\n");
+ VID_Shutdown();
+ return false;
+ }
+ if(vidx11_visual->green_mask != 0x0000FF00)
+ {
+ Con_Printf("Sorry, we only support BGR visuals\n");
+ VID_Shutdown();
+ return false;
+ }
+ if(vidx11_visual->blue_mask != 0x000000FF)
+ {
+ Con_Printf("Sorry, we only support BGR visuals\n");
+ VID_Shutdown();
+ return false;
+ }
if(vidx11_shmevent >= 0)
{
for(i = 0; i < 2; ++i)
VID_Shutdown();
return false;
}
+ if(vidx11_ximage[i]->bytes_per_line != w * 4)
+ {
+ Con_Printf("Sorry, we only support linear pixel layout\n");
+ VID_Shutdown();
+ return false;
+ }
vidx11_shminfo[i].shmid = shmget(IPC_PRIVATE, vidx11_ximage[i]->bytes_per_line * vidx11_ximage[i]->height, IPC_CREAT|0777);
if(vidx11_shminfo[i].shmid < 0)
{
}
else
{
- for(i = 0; i < 2; ++i)
+ for(i = 0; i < 1; ++i) // we only need one buffer if we don't use Xshm
{
char *p = calloc(4, w * h);
vidx11_shminfo[i].shmid = -1;
VID_Shutdown();
return false;
}
+ if(vidx11_ximage[i]->bytes_per_line != w * 4)
+ {
+ Con_Printf("Sorry, we only support linear pixel layout\n");
+ VID_Shutdown();
+ return false;
+ }
}
}
return true;
void VID_Shutdown(void)
{
- if (!ctx || !vidx11_display)
+ if (!vidx11_display)
return;
VID_SetMouse(false, false, false);
if (vid.softdepthpixels)
free(vid.softdepthpixels);
+ vid.softdepthpixels = NULL;
if (win)
XDestroyWindow(vidx11_display, win);
switch(vid.renderpath)
{
case RENDERPATH_SOFT:
- vidx11_ximage_pos = !vidx11_ximage_pos;
- vid.softpixels = (unsigned int *) vidx11_ximage[vidx11_ximage_pos]->data;
- DPSOFTRAST_SetRenderTargets(vid.width, vid.height, vid.softdepthpixels, vid.softpixels, NULL, NULL, NULL);
-
if(vidx11_shmevent >= 0) {
+ vidx11_ximage_pos = !vidx11_ximage_pos;
+ vid.softpixels = (unsigned int *) vidx11_ximage[vidx11_ximage_pos]->data;
+ DPSOFTRAST_SetRenderTargets(vid.width, vid.height, vid.softdepthpixels, vid.softpixels, NULL, NULL, NULL);
+
// save mouse motion so we can deal with it later
in_mouse_x = 0;
in_mouse_y = 0;
++vidx11_shmwait;
XShmPutImage(vidx11_display, win, vidx11_gc, vidx11_ximage[!vidx11_ximage_pos], 0, 0, 0, 0, vid.width, vid.height, True);
} else {
- XPutImage(vidx11_display, win, vidx11_gc, vidx11_ximage[!vidx11_ximage_pos], 0, 0, 0, 0, vid.width, vid.height);
+ // no buffer switching here, we just flush the renderer
+ DPSOFTRAST_Finish();
+ XPutImage(vidx11_display, win, vidx11_gc, vidx11_ximage[vidx11_ximage_pos], 0, 0, 0, 0, vid.width, vid.height);
}
break;