Merge branch 'mesa_7_7_branch'

This commit is contained in:
Jakob Bornecrantz
2009-12-02 14:56:56 +01:00
33 changed files with 1834 additions and 103 deletions

View File

@@ -4,7 +4,7 @@ TOP = ..
include $(TOP)/configs/current
SUBDIRS = "$(strip "$(PROGRAM_DIRS)")"
SUBDIRS = $(PROGRAM_DIRS)
default: message subdirs
@@ -15,22 +15,18 @@ message:
subdirs:
@if test -n "$(SUBDIRS)" ; then \
for dir in $(SUBDIRS) ; do \
@list='$(SUBDIRS)'; for dir in $$list ; do \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE)) || exit 1 ; \
fi \
done \
fi
done
# Dummy install target
install:
clean:
-@if test -n "$(SUBDIRS)" ; then \
for dir in $(SUBDIRS) tests ; do \
@list='$(SUBDIRS)'; for dir in $$list tests ; do \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE) clean) ; \
fi \
done \
fi
done

View File

@@ -15,8 +15,6 @@
#define DEPTH 5.0f
static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
static GLfloat camz;
static GLint fogMode;

View File

@@ -0,0 +1,89 @@
/**********************************************************
* Copyright 2007-2009 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************/
/*
* svga_escape.h --
*
* Definitions for our own (vendor-specific) SVGA Escape commands.
*/
#ifndef _SVGA_ESCAPE_H_
#define _SVGA_ESCAPE_H_
/*
* Namespace IDs for the escape command
*/
#define SVGA_ESCAPE_NSID_VMWARE 0x00000000
#define SVGA_ESCAPE_NSID_DEVEL 0xFFFFFFFF
/*
* Within SVGA_ESCAPE_NSID_VMWARE, we multiplex commands according to
* the first DWORD of escape data (after the nsID and size). As a
* guideline we're using the high word and low word as a major and
* minor command number, respectively.
*
* Major command number allocation:
*
* 0000: Reserved
* 0001: SVGA_ESCAPE_VMWARE_LOG (svga_binary_logger.h)
* 0002: SVGA_ESCAPE_VMWARE_VIDEO (svga_overlay.h)
* 0003: SVGA_ESCAPE_VMWARE_HINT (svga_escape.h)
*/
#define SVGA_ESCAPE_VMWARE_MAJOR_MASK 0xFFFF0000
/*
* SVGA Hint commands.
*
* These escapes let the SVGA driver provide optional information to
* he host about the state of the guest or guest applications. The
* host can use these hints to make user interface or performance
* decisions.
*
* Notes:
*
* - SVGA_ESCAPE_VMWARE_HINT_FULLSCREEN is deprecated for guests
* that use the SVGA Screen Object extension. Instead of sending
* this escape, use the SVGA_SCREEN_FULLSCREEN_HINT flag on your
* Screen Object.
*/
#define SVGA_ESCAPE_VMWARE_HINT 0x00030000
#define SVGA_ESCAPE_VMWARE_HINT_FULLSCREEN 0x00030001 // Deprecated
typedef
struct {
uint32 command;
uint32 fullscreen;
struct {
int32 x, y;
} monitorPosition;
} SVGAEscapeHintFullscreen;
#endif /* _SVGA_ESCAPE_H_ */

View File

@@ -0,0 +1,201 @@
/**********************************************************
* Copyright 2007-2009 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************/
/*
* svga_overlay.h --
*
* Definitions for video-overlay support.
*/
#ifndef _SVGA_OVERLAY_H_
#define _SVGA_OVERLAY_H_
#include "svga_reg.h"
/*
* Video formats we support
*/
#define VMWARE_FOURCC_YV12 0x32315659 // 'Y' 'V' '1' '2'
#define VMWARE_FOURCC_YUY2 0x32595559 // 'Y' 'U' 'Y' '2'
#define VMWARE_FOURCC_UYVY 0x59565955 // 'U' 'Y' 'V' 'Y'
typedef enum {
SVGA_OVERLAY_FORMAT_INVALID = 0,
SVGA_OVERLAY_FORMAT_YV12 = VMWARE_FOURCC_YV12,
SVGA_OVERLAY_FORMAT_YUY2 = VMWARE_FOURCC_YUY2,
SVGA_OVERLAY_FORMAT_UYVY = VMWARE_FOURCC_UYVY,
} SVGAOverlayFormat;
#define SVGA_VIDEO_COLORKEY_MASK 0x00ffffff
#define SVGA_ESCAPE_VMWARE_VIDEO 0x00020000
#define SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS 0x00020001
/* FIFO escape layout:
* Type, Stream Id, (Register Id, Value) pairs */
#define SVGA_ESCAPE_VMWARE_VIDEO_FLUSH 0x00020002
/* FIFO escape layout:
* Type, Stream Id */
typedef
struct SVGAEscapeVideoSetRegs {
struct {
uint32 cmdType;
uint32 streamId;
} header;
// May include zero or more items.
struct {
uint32 registerId;
uint32 value;
} items[1];
} SVGAEscapeVideoSetRegs;
typedef
struct SVGAEscapeVideoFlush {
uint32 cmdType;
uint32 streamId;
} SVGAEscapeVideoFlush;
/*
* Struct definitions for the video overlay commands built on
* SVGAFifoCmdEscape.
*/
typedef
struct {
uint32 command;
uint32 overlay;
} SVGAFifoEscapeCmdVideoBase;
typedef
struct {
SVGAFifoEscapeCmdVideoBase videoCmd;
} SVGAFifoEscapeCmdVideoFlush;
typedef
struct {
SVGAFifoEscapeCmdVideoBase videoCmd;
struct {
uint32 regId;
uint32 value;
} items[1];
} SVGAFifoEscapeCmdVideoSetRegs;
typedef
struct {
SVGAFifoEscapeCmdVideoBase videoCmd;
struct {
uint32 regId;
uint32 value;
} items[SVGA_VIDEO_NUM_REGS];
} SVGAFifoEscapeCmdVideoSetAllRegs;
/*
*----------------------------------------------------------------------
*
* VMwareVideoGetAttributes --
*
* Computes the size, pitches and offsets for YUV frames.
*
* Results:
* TRUE on success; otherwise FALSE on failure.
*
* Side effects:
* Pitches and offsets for the given YUV frame are put in 'pitches'
* and 'offsets' respectively. They are both optional though.
*
*----------------------------------------------------------------------
*/
static INLINE Bool
VMwareVideoGetAttributes(const SVGAOverlayFormat format, // IN
uint32 *width, // IN / OUT
uint32 *height, // IN / OUT
uint32 *size, // OUT
uint32 *pitches, // OUT (optional)
uint32 *offsets) // OUT (optional)
{
int tmp;
*width = (*width + 1) & ~1;
if (offsets) {
offsets[0] = 0;
}
switch (format) {
case VMWARE_FOURCC_YV12:
*height = (*height + 1) & ~1;
*size = (*width + 3) & ~3;
if (pitches) {
pitches[0] = *size;
}
*size *= *height;
if (offsets) {
offsets[1] = *size;
}
tmp = ((*width >> 1) + 3) & ~3;
if (pitches) {
pitches[1] = pitches[2] = tmp;
}
tmp *= (*height >> 1);
*size += tmp;
if (offsets) {
offsets[2] = *size;
}
*size += tmp;
break;
case VMWARE_FOURCC_YUY2:
case VMWARE_FOURCC_UYVY:
*size = *width * 2;
if (pitches) {
pitches[0] = *size;
}
*size *= *height;
break;
default:
return FALSE;
}
return TRUE;
}
#endif // _SVGA_OVERLAY_H_

View File

@@ -72,19 +72,7 @@ stw_flush_frontbuffer(struct pipe_screen *screen,
return;
}
#if DEBUG
{
/* ensure that a random surface was not passed to us */
struct pipe_surface *surface2;
if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
assert(0);
else
assert(surface2 == surface);
}
#endif
stw_framebuffer_present_locked(hdc, fb, ST_SURFACE_FRONT_LEFT);
stw_framebuffer_present_locked(hdc, fb, surface);
}

View File

@@ -475,8 +475,6 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
struct stw_framebuffer *fb;
struct pipe_screen *screen;
struct pipe_surface *surface;
unsigned surface_index;
BOOL ret = FALSE;
fb = stw_framebuffer_from_hdc( hdc );
if (fb == NULL)
@@ -484,9 +482,7 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
screen = stw_dev->screen;
surface_index = (unsigned)(uintptr_t)data->pPrivateData;
if(!st_get_framebuffer_surface( fb->stfb, surface_index, &surface ))
goto fail;
surface = (struct pipe_surface *)data->pPrivateData;
#ifdef DEBUG
if(stw_dev->trace_running) {
@@ -520,15 +516,11 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
stw_dev->stw_winsys->present( screen, surface, hdc );
}
ret = TRUE;
fail:
stw_framebuffer_update(fb);
stw_framebuffer_release(fb);
return ret;
return TRUE;
}
@@ -540,7 +532,7 @@ fail:
BOOL
stw_framebuffer_present_locked(HDC hdc,
struct stw_framebuffer *fb,
unsigned surface_index)
struct pipe_surface *surface)
{
if(stw_dev->callbacks.wglCbPresentBuffers &&
stw_dev->stw_winsys->compose) {
@@ -551,7 +543,7 @@ stw_framebuffer_present_locked(HDC hdc,
data.magic2 = 0;
data.AdapterLuid = stw_dev->AdapterLuid;
data.rect = fb->client_rect;
data.pPrivateData = (void *)(uintptr_t)surface_index;
data.pPrivateData = (void *)surface;
stw_framebuffer_release(fb);
@@ -559,13 +551,6 @@ stw_framebuffer_present_locked(HDC hdc,
}
else {
struct pipe_screen *screen = stw_dev->screen;
struct pipe_surface *surface;
if(!st_get_framebuffer_surface( fb->stfb, surface_index, &surface )) {
/* FIXME: this shouldn't happen, but does on glean */
stw_framebuffer_release(fb);
return FALSE;
}
#ifdef DEBUG
if(stw_dev->trace_running) {
@@ -590,6 +575,7 @@ DrvSwapBuffers(
HDC hdc )
{
struct stw_framebuffer *fb;
struct pipe_surface *surface = NULL;
fb = stw_framebuffer_from_hdc( hdc );
if (fb == NULL)
@@ -600,12 +586,9 @@ DrvSwapBuffers(
return TRUE;
}
/* If we're swapping the buffer associated with the current context
* we have to flush any pending rendering commands first.
*/
st_notify_swapbuffers( fb->stfb );
st_swapbuffers(fb->stfb, &surface, NULL);
return stw_framebuffer_present_locked(hdc, fb, ST_SURFACE_BACK_LEFT);
return stw_framebuffer_present_locked(hdc, fb, surface);
}

View File

@@ -34,6 +34,7 @@
#include "pipe/p_thread.h"
struct pipe_surface;
struct stw_pixelformat_info;
/**
@@ -140,7 +141,7 @@ stw_framebuffer_allocate(
BOOL
stw_framebuffer_present_locked(HDC hdc,
struct stw_framebuffer *fb,
unsigned surface_index);
struct pipe_surface *surface);
void
stw_framebuffer_update(

View File

@@ -652,6 +652,9 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (serverGeneration == 1)
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
if (ms->winsys_screen_init)
ms->winsys_screen_init(pScrn);
return drv_enter_vt(scrnIndex, 1);
}
@@ -768,6 +771,9 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
drv_leave_vt(scrnIndex, 0);
}
if (ms->winsys_screen_close)
ms->winsys_screen_close(pScrn);
#ifdef DRI2
if (ms->screen)
xorg_dri2_close(pScreen);

View File

@@ -114,6 +114,11 @@ typedef struct _modesettingRec
Bool noEvict;
Bool debug_fallback;
/* winsys hocks */
Bool (*winsys_screen_init)(ScrnInfoPtr pScr);
Bool (*winsys_screen_close)(ScrnInfoPtr pScr);
void *winsys_priv;
#ifdef DRM_MODE_FEATURE_DIRTYFB
DamagePtr damage;
#endif

View File

@@ -45,7 +45,7 @@
#define DRM_VMW_UNREF_DMABUF 10
#define DRM_VMW_FIFO_DEBUG 11
#define DRM_VMW_FENCE_WAIT 12
#define DRM_VMW_OVERLAY 13
/*************************************************************************/
/**
@@ -439,4 +439,68 @@ struct drm_vmw_fence_wait_arg {
int32_t pad64;
};
/*************************************************************************/
/**
* DRM_VMW_OVERLAY - Control overlays.
*
* This IOCTL controls the overlay units of the svga device.
* The SVGA overlay units does not work like regular hardware units in
* that they do not automaticaly read back the contents of the given dma
* buffer. But instead only read back for each call to this ioctl, and
* at any point between this call being made and a following call that
* either changes the buffer or disables the stream.
*/
/**
* struct drm_vmw_rect
*
* Defines a rectangle. Used in the overlay ioctl to define
* source and destination rectangle.
*/
struct drm_vmw_rect {
int32_t x;
int32_t y;
uint32_t w;
uint32_t h;
};
/**
* struct drm_vmw_overlay_arg
*
* @stream_id: Stearm to control
* @enabled: If false all following arguments are ignored.
* @handle: Handle to buffer for getting data from.
* @format: Format of the overlay as understood by the host.
* @width: Width of the overlay.
* @height: Height of the overlay.
* @size: Size of the overlay in bytes.
* @pitch: Array of pitches, the two last are only used for YUV12 formats.
* @offset: Offset from start of dma buffer to overlay.
* @src: Source rect, must be within the defined area above.
* @dst: Destination rect, x and y may be negative.
*
* Argument to the DRM_VMW_OVERLAY Ioctl.
*/
struct drm_vmw_overlay_arg {
uint32_t stream_id;
uint32_t enabled;
uint32_t flags;
uint32_t color_key;
uint32_t handle;
uint32_t offset;
int32_t format;
uint32_t size;
uint32_t width;
uint32_t height;
uint32_t pitch[3];
uint32_t pad64;
struct drm_vmw_rect src;
struct drm_vmw_rect dst;
};
#endif

View File

@@ -1,10 +1,17 @@
TARGET = vmwgfx_drv.so
CFILES = $(wildcard ./*.c)
OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES))
TOP = ../../../../../..
include $(TOP)/configs/current
TARGET = vmwgfx_drv.so
CFILES = \
vmw_xorg.c \
vmw_video.c \
vmw_ioctl.c \
vmw_screen.c
OBJECTS = $(patsubst %.c,%.o,$(CFILES))
INCLUDES = \
$(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
-I$(TOP)/src/gallium/include \
@@ -24,6 +31,7 @@ LINKS = \
$(shell pkg-config --libs libdrm)
DRIVER_DEFINES = \
-std=gnu99 \
-DHAVE_CONFIG_H
TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)

View File

@@ -0,0 +1,86 @@
/**********************************************************
* Copyright 2009 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************/
/**
* @file
* Contains the shared resources for VMware Xorg driver
* that sits ontop of the Xorg State Traker.
*
* It is initialized in vmw_screen.c.
*
* @author Jakob Bornecrantz <jakob@vmware.com>
*/
#ifndef VMW_DRIVER_H_
#define VMW_DRIVER_H_
#include "state_trackers/xorg/xorg_tracker.h"
struct vmw_dma_buffer;
struct vmw_driver
{
int fd;
/* vmw_video.c */
void *video_priv;
};
static INLINE struct vmw_driver *
vmw_driver(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
return ms ? (struct vmw_driver *)ms->winsys_priv : NULL;
}
/***********************************************************************
* vmw_video.c
*/
Bool vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
Bool vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
/***********************************************************************
* vmw_ioctl.c
*/
struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_driver *vmw,
uint32_t size,
unsigned *handle);
void * vmw_ioctl_buffer_map(struct vmw_driver *vmw,
struct vmw_dma_buffer *buf);
void vmw_ioctl_buffer_unmap(struct vmw_driver *vmw,
struct vmw_dma_buffer *buf);
void vmw_ioctl_buffer_destroy(struct vmw_driver *vmw,
struct vmw_dma_buffer *buf);
#endif

View File

@@ -0,0 +1,39 @@
/**********************************************************
* Copyright 2009 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************/
#ifndef VMW_HOOK_H_
#define VMW_HOOK_H_
#include "state_trackers/xorg/xorg_winsys.h"
/***********************************************************************
* vmw_screen.c
*/
void vmw_screen_set_functions(ScrnInfoPtr pScrn);
#endif

View File

@@ -0,0 +1,140 @@
/**********************************************************
* Copyright 2009 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************/
/**
* @file
* Contains the functions for creating dma buffers by calling
* the kernel via driver specific ioctls.
*
* @author Jakob Bornecrantz <jakob@vmware.com>
*/
#define HAVE_STDINT_H
#define _FILE_OFFSET_BITS 64
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include "xf86drm.h"
#include "../core/vmwgfx_drm.h"
#include "vmw_driver.h"
#include "util/u_debug.h"
struct vmw_dma_buffer
{
void *data;
unsigned handle;
uint64_t map_handle;
unsigned map_count;
uint32_t size;
};
struct vmw_dma_buffer *
vmw_ioctl_buffer_create(struct vmw_driver *vmw, uint32_t size, unsigned *handle)
{
struct vmw_dma_buffer *buf;
union drm_vmw_alloc_dmabuf_arg arg;
struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
struct drm_vmw_dmabuf_rep *rep = &arg.rep;
int ret;
buf = xcalloc(1, sizeof(*buf));
if (!buf)
goto err;
memset(&arg, 0, sizeof(arg));
req->size = size;
do {
ret = drmCommandWriteRead(vmw->fd, DRM_VMW_ALLOC_DMABUF, &arg, sizeof(arg));
} while (ret == -ERESTART);
if (ret) {
debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
goto err_free;
}
buf->data = NULL;
buf->handle = rep->handle;
buf->map_handle = rep->map_handle;
buf->map_count = 0;
buf->size = size;
*handle = rep->handle;
return buf;
err_free:
xfree(buf);
err:
return NULL;
}
void
vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
{
struct drm_vmw_unref_dmabuf_arg arg;
if (buf->data) {
munmap(buf->data, buf->size);
buf->data = NULL;
}
memset(&arg, 0, sizeof(arg));
arg.handle = buf->handle;
drmCommandWrite(vmw->fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
xfree(buf);
}
void *
vmw_ioctl_buffer_map(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
{
void *map;
if (buf->data == NULL) {
map = mmap(NULL, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED,
vmw->fd, buf->map_handle);
if (map == MAP_FAILED) {
debug_printf("%s: Map failed.\n", __FUNCTION__);
return NULL;
}
buf->data = map;
}
++buf->map_count;
return buf->data;
}
void
vmw_ioctl_buffer_unmap(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
{
--buf->map_count;
}

View File

@@ -0,0 +1,104 @@
/**********************************************************
* Copyright 2009 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************/
/**
* @file
* Contains the init code for the VMware Xorg driver.
*
* @author Jakob Bornecrantz <jakob@vmware.com>
*/
#include "vmw_hook.h"
#include "vmw_driver.h"
static Bool
vmw_screen_init(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
struct vmw_driver *vmw;
/* if gallium is used then we don't need to do anything. */
if (ms->screen)
return TRUE;
vmw = xnfcalloc(sizeof(*vmw), 1);
if (!vmw)
return FALSE;
vmw->fd = ms->fd;
ms->winsys_priv = vmw;
vmw_video_init(pScrn, vmw);
return TRUE;
}
static Bool
vmw_screen_close(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
struct vmw_driver *vmw = vmw_driver(pScrn);
if (!vmw)
return TRUE;
vmw_video_close(pScrn, vmw);
ms->winsys_priv = NULL;
xfree(vmw);
return TRUE;
}
/*
* Functions for setting up hooks into the xorg state tracker
*/
static Bool (*vmw_screen_pre_init_saved)(ScrnInfoPtr pScrn, int flags) = NULL;
static Bool
vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
{
modesettingPtr ms;
pScrn->PreInit = vmw_screen_pre_init_saved;
if (!pScrn->PreInit(pScrn, flags))
return FALSE;
ms = modesettingPTR(pScrn);
ms->winsys_screen_init = vmw_screen_init;
ms->winsys_screen_close = vmw_screen_close;
return TRUE;
}
void
vmw_screen_set_functions(ScrnInfoPtr pScrn)
{
assert(!vmw_screen_pre_init_saved);
vmw_screen_pre_init_saved = pScrn->PreInit;
pScrn->PreInit = vmw_screen_pre_init;
}

File diff suppressed because it is too large Load Diff

View File

@@ -31,7 +31,7 @@
* @author Jakob Bornecrantz <wallbraker@gmail.com>
*/
#include "state_trackers/xorg/xorg_winsys.h"
#include "vmw_hook.h"
static void vmw_xorg_identify(int flags);
static Bool vmw_xorg_pci_probe(DriverPtr driver,
@@ -145,6 +145,8 @@ vmw_xorg_pci_probe(DriverPtr driver,
/* Use all the functions from the xorg tracker */
xorg_tracker_set_functions(scrn);
vmw_screen_set_functions(scrn);
}
return scrn != NULL;
}

View File

@@ -291,6 +291,7 @@ xm_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
enum pipe_format format,
unsigned usage,
unsigned tex_usage,
unsigned *stride)
{
const unsigned alignment = 64;

View File

@@ -124,7 +124,6 @@ static const struct dri_extension card_extensions[] = {
{ "GL_MESA_pack_invert", NULL },
{ "GL_MESA_ycbcr_texture", NULL },
{ "GL_NV_blend_square", NULL },
{ "GL_NV_point_sprite", GL_NV_point_sprite_functions },
{ "GL_NV_vertex_program", GL_NV_vertex_program_functions },
{ "GL_NV_vertex_program1_1", NULL },
{ "GL_SGIS_generate_mipmap", NULL },

View File

@@ -126,7 +126,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_RGB16:
rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
irb->texformat = MESA_FORMAT_ARGB8888; /* XXX: Need xrgb8888 */
irb->texformat = MESA_FORMAT_XRGB8888;
cpp = 4;
break;
case GL_RGBA:
@@ -314,10 +314,6 @@ intel_create_renderbuffer(gl_format format)
irb->Base.DataType = GL_UNSIGNED_BYTE;
break;
case MESA_FORMAT_XRGB8888:
/* XXX this is a hack since XRGB surfaces don't seem to work
* properly yet. Reading the alpha channel returns 0 instead of 1.
*/
format = MESA_FORMAT_ARGB8888;
irb->Base._BaseFormat = GL_RGB;
irb->Base.DataType = GL_UNSIGNED_BYTE;
break;

View File

@@ -335,6 +335,8 @@ out:
unpack->BufferObj);
}
intel_check_front_buffer_rendering(intel);
return GL_TRUE;
}

View File

@@ -222,6 +222,8 @@ do_blit_copypixels(GLcontext * ctx,
out:
UNLOCK_HARDWARE(intel);
intel_check_front_buffer_rendering(intel);
DBG("%s: success\n", __FUNCTION__);
return GL_TRUE;
}

View File

@@ -325,7 +325,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
_mesa_init_driver_functions(&functions);
r200InitDriverFuncs(&functions);
r200InitIoctlFuncs(&functions);
r200InitStateFuncs(&functions, screen->kernel_mm);
r200InitStateFuncs(&functions);
r200InitTextureFuncs(&functions);
r200InitShaderFuncs(&functions);
radeonInitQueryObjFunctions(&functions);

View File

@@ -2476,7 +2476,7 @@ static void r200PolygonStipple( GLcontext *ctx, const GLubyte *mask )
}
/* Initialize the driver's state functions.
*/
void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 )
void r200InitStateFuncs( struct dd_function_table *functions )
{
functions->UpdateState = r200InvalidateState;
functions->LightingSpaceChange = r200LightingSpaceChange;
@@ -2510,10 +2510,7 @@ void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 )
functions->LogicOpcode = r200LogicOpCode;
functions->PolygonMode = r200PolygonMode;
functions->PolygonOffset = r200PolygonOffset;
if (dri2)
functions->PolygonStipple = r200PolygonStipple;
else
functions->PolygonStipple = radeonPolygonStipplePreKMS;
functions->PointParameterfv = r200PointParameter;
functions->PointSize = r200PointSize;
functions->RenderMode = r200RenderMode;

View File

@@ -38,7 +38,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r200_context.h"
extern void r200InitState( r200ContextPtr rmesa );
extern void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 );
extern void r200InitStateFuncs( struct dd_function_table *functions );
extern void r200InitTnlFuncs( GLcontext *ctx );
extern void r200UpdateMaterial( GLcontext *ctx );

View File

@@ -887,10 +887,8 @@ void r200InitState( r200ContextPtr rmesa )
}
}
}
/* polygon stipple is done with irq for non-kms */
if (rmesa->radeon.radeonScreen->kernel_mm) {
ALLOC_STATE( stp, always, STP_STATE_SIZE, "STP/stp", 0 );
}
for (i = 0; i < 6; i++)
if (rmesa->radeon.radeonScreen->kernel_mm)
@@ -1122,12 +1120,11 @@ void r200InitState( r200ContextPtr rmesa )
rmesa->hw.sci.cmd[SCI_CMD_1] = CP_PACKET0(R200_RE_TOP_LEFT, 0);
rmesa->hw.sci.cmd[SCI_CMD_2] = CP_PACKET0(R200_RE_WIDTH_HEIGHT, 0);
if (rmesa->radeon.radeonScreen->kernel_mm) {
rmesa->hw.stp.cmd[STP_CMD_0] = CP_PACKET0(RADEON_RE_STIPPLE_ADDR, 0);
rmesa->hw.stp.cmd[STP_DATA_0] = 0;
rmesa->hw.stp.cmd[STP_CMD_1] = CP_PACKET0_ONE(RADEON_RE_STIPPLE_DATA, 31);
if (rmesa->radeon.radeonScreen->kernel_mm) {
rmesa->hw.mtl[0].emit = mtl_emit;
rmesa->hw.mtl[1].emit = mtl_emit;

View File

@@ -1741,7 +1741,6 @@ static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
r300SetPolygonOffsetState(ctx, state);
break;
case GL_SCISSOR_TEST:
if (!rmesa->radeon.radeonScreen->kernel_mm)
radeon_firevertices(&rmesa->radeon);
rmesa->radeon.state.scissor.enabled = state;
radeonUpdateScissor( ctx );

View File

@@ -257,9 +257,7 @@ void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
radeonContextPtr radeon = RADEON_CONTEXT(ctx);
if (ctx->Scissor.Enabled) {
/* We don't pipeline cliprect changes */
if (!radeon->radeonScreen->kernel_mm) {
radeon_firevertices(radeon);
}
radeonUpdateScissor(ctx);
}
}

View File

@@ -864,7 +864,7 @@ static void store_texel_al88_rev(struct gl_texture_image *texImage,
static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff );

View File

@@ -2197,17 +2197,21 @@ _mesa_texstore_al1616(TEXSTORE_PARAMS)
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == MESA_FORMAT_AL1616) {
for (col = 0; col < srcWidth; col++) {
/* src[0] is luminance, src[1] is alpha */
dstUI[col] = PACK_COLOR_1616( FLOAT_TO_USHORT(src[1]),
FLOAT_TO_USHORT(src[0]) );
GLushort l, a;
UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
dstUI[col] = PACK_COLOR_1616(a, l);
src += 2;
}
}
else {
for (col = 0; col < srcWidth; col++) {
/* src[0] is luminance, src[1] is alpha */
dstUI[col] = PACK_COLOR_1616_REV( FLOAT_TO_UBYTE(src[1]),
FLOAT_TO_UBYTE(src[0]) );
GLushort l, a;
UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
dstUI[col] = PACK_COLOR_1616_REV(a, l);
src += 2;
}
}

View File

@@ -278,7 +278,7 @@ static struct ureg_src swizzle_4v( struct ureg_src src,
/**
* Translate SWZ instructions into a single MAD. EG:
* Translate a SWZ instruction into a MOV, MUL or MAD instruction. EG:
*
* SWZ dst, src.x-y10
*

View File

@@ -138,6 +138,10 @@ struct vbo_exec_context
*/
const struct gl_client_array *inputs[VERT_ATTRIB_MAX];
} array;
#ifdef DEBUG
GLint flush_call_depth;
#endif
};

View File

@@ -876,9 +876,8 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags )
#ifdef DEBUG
/* debug check: make sure we don't get called recursively */
static GLuint callDepth = 0;
callDepth++;
assert(callDepth == 1);
exec->flush_call_depth++;
assert(exec->flush_call_depth == 1);
#endif
if (0) _mesa_printf("%s\n", __FUNCTION__);
@@ -886,7 +885,8 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags )
if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
if (0) _mesa_printf("%s - inside begin/end\n", __FUNCTION__);
#ifdef DEBUG
callDepth--;
exec->flush_call_depth--;
assert(exec->flush_call_depth == 0);
#endif
return;
}
@@ -903,7 +903,8 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags )
exec->ctx->Driver.NeedFlush &= ~flags;
#ifdef DEBUG
callDepth--;
exec->flush_call_depth--;
assert(exec->flush_call_depth == 0);
#endif
}