Merge branch 'master' into r500test
Conflicts: src/mesa/drivers/dri/r300/r300_cmdbuf.c src/mesa/drivers/dri/r300/r300_ioctl.c
This commit is contained in:
@@ -107,6 +107,9 @@ do
|
||||
-L*)
|
||||
DEPS="$DEPS $1"
|
||||
;;
|
||||
-Wl*)
|
||||
DEPS="$DEPS $1"
|
||||
;;
|
||||
-pthread)
|
||||
# this is a special case (see bugzilla 10876)
|
||||
DEPS="$DEPS $1"
|
||||
@@ -198,7 +201,7 @@ fi
|
||||
#
|
||||
case $ARCH in
|
||||
|
||||
'Linux' | 'OpenBSD' | 'GNU' | GNU/*)
|
||||
'Linux' | 'OpenBSD' | 'DragonFly' | 'GNU' | GNU/*)
|
||||
# we assume gcc
|
||||
|
||||
if [ "x$LINK" = "x" ] ; then
|
||||
|
||||
@@ -87,6 +87,7 @@ APP_LIB_DEPS = $(EXTRA_LIB_PATH) @APP_LIB_DEPS@
|
||||
DRI_LIB_DEPS = $(EXTRA_LIB_PATH) @DRI_LIB_DEPS@
|
||||
LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
|
||||
LIBDRM_LIB = @LIBDRM_LIBS@
|
||||
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
|
||||
EXPAT_INCLUDES = @EXPAT_INCLUDES@
|
||||
|
||||
# Autoconf directories
|
||||
|
||||
+15
-9
@@ -26,7 +26,7 @@ dnl Check for progs
|
||||
AC_PROG_CPP
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PATH_PROG(MAKE, make)
|
||||
AC_CHECK_PROGS(MAKE, [gmake make])
|
||||
AC_PATH_PROG(MKDEP, makedepend)
|
||||
AC_PATH_PROG(SED, sed)
|
||||
|
||||
@@ -40,6 +40,11 @@ if test "x$GCC" = xyes; then
|
||||
fi
|
||||
AC_SUBST(MKDEP_OPTIONS)
|
||||
|
||||
dnl Check to see if dlopen is in default libraries (like Solaris, which
|
||||
dnl has it in libc), or if libdl is needed to get it.
|
||||
AC_CHECK_FUNC([dlopen], [],
|
||||
AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
|
||||
|
||||
dnl Make sure the pkg-config macros are defined
|
||||
m4_ifdef([PKG_PROG_PKG_CONFIG],,[
|
||||
AC_MSG_ERROR([The pkg-config autoconf macros are not defined.
|
||||
@@ -64,11 +69,11 @@ AC_SUBST(X11_INCLUDES)
|
||||
dnl Compiler macros
|
||||
DEFINES=""
|
||||
AC_SUBST(DEFINES)
|
||||
if test "x$GCC" = xyes; then
|
||||
DEFINES="-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
|
||||
fi
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
if test "x$GCC" = xyes; then
|
||||
DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
|
||||
fi
|
||||
DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS -DHAVE_POSIX_MEMALIGN"
|
||||
;;
|
||||
esac
|
||||
@@ -383,6 +388,7 @@ dri)
|
||||
|
||||
# Check for libdrm
|
||||
PKG_CHECK_MODULES(LIBDRM, libdrm)
|
||||
PKG_CHECK_MODULES(DRI2PROTO, dri2proto >= 1.1)
|
||||
|
||||
# find the DRI deps for libGL
|
||||
if test "$x11_pkgconfig" = yes; then
|
||||
@@ -396,7 +402,7 @@ dri)
|
||||
fi
|
||||
|
||||
# need DRM libs, -lpthread, etc.
|
||||
GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread -ldl"
|
||||
GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
|
||||
;;
|
||||
osmesa)
|
||||
# No libGL for osmesa
|
||||
@@ -504,7 +510,7 @@ if test "$mesa_driver" = dri; then
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
freebsd*)
|
||||
freebsd* | dragonfly*)
|
||||
DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
|
||||
DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
|
||||
DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
|
||||
@@ -547,7 +553,7 @@ if test "$mesa_driver" = dri; then
|
||||
AC_MSG_ERROR([Expat required for DRI.]))
|
||||
|
||||
# put all the necessary libs together
|
||||
DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread -ldl"
|
||||
DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
|
||||
fi
|
||||
AC_SUBST(DRI_DIRS)
|
||||
AC_SUBST(EXPAT_INCLUDES)
|
||||
@@ -804,7 +810,7 @@ linux*)
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
freebsd*)
|
||||
freebsd* | dragonfly*)
|
||||
PIC_FLAGS="-fPIC"
|
||||
case "$host_cpu" in
|
||||
i*86)
|
||||
@@ -893,5 +899,5 @@ echo " CXXFLAGS: $cxxflags"
|
||||
echo " Macros: $defines"
|
||||
|
||||
echo ""
|
||||
echo " Run 'make' to build Mesa"
|
||||
echo " Run '${MAKE-make}' to build Mesa"
|
||||
echo ""
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
<H1>Downloading</H1>
|
||||
|
||||
<p>
|
||||
Last stable release: <b>7.0</b>
|
||||
Last stable release: <b>7.0.3</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
<H1>News</H1>
|
||||
|
||||
|
||||
<h2>April 4, 2008</h2>
|
||||
<p>
|
||||
<a href="relnotes-7.0.3.html">Mesa 7.0.3</a> is released.
|
||||
This is a bug-fix release.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>January 24, 2008</h2>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<HTML>
|
||||
|
||||
<TITLE>Mesa Release Notes</TITLE>
|
||||
|
||||
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.0.3 Release Notes / April 4, 2008</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.0.3 is a stable release with bug fixes since version 7.0.2.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
3fd1cb76531b2515ef7db92d9a93dbf8 MesaLib-7.0.3.tar.gz
|
||||
e6e6379d7793af40a6bc3ce1bace572e MesaLib-7.0.3.tar.bz2
|
||||
97882bac195229ee0b78cab82e0e3be1 MesaLib-7.0.3.zip
|
||||
8abf6bbcb1661e7dd4ce73b3fbb85898 MesaDemos-7.0.3.tar.gz
|
||||
47fd6863621d3c9c7dbb870ab7f0c303 MesaDemos-7.0.3.tar.bz2
|
||||
99e442e14da1928f76a7297bb421a3af MesaDemos-7.0.3.zip
|
||||
2b50fe9fadc4709b57c52adef09fce3c MesaGLUT-7.0.3.tar.gz
|
||||
0ff23c4e91b238abae63a5fc9fa003e7 MesaGLUT-7.0.3.tar.bz2
|
||||
70e83554a4462dad28e0d6e20f79aada MesaGLUT-7.0.3.zip
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>Bug fixes</h2>
|
||||
<ul>
|
||||
<li>Added missing glw.pc.in file to release tarball
|
||||
<li>Fix GLUT/Fortran issues
|
||||
<li>GLSL gl_FrontLightModelProduct.sceneColor variable wasn't defined
|
||||
<li>Fix crash upon GLSL variable array indexes (not yet supported)
|
||||
<li>Two-sided stencil test didn't work in software rendering
|
||||
<li>Fix two-sided lighting bugs/crashes (bug 13368)
|
||||
<li>GLSL gl_FrontFacing didn't work properly
|
||||
<li>glGetActiveUniform returned incorrect sizes (bug 13751)
|
||||
<li>Fix several bugs relating to uniforms and attributes in GLSL API (Bruce Merry, bug 13753)
|
||||
<li>glTexImage3D(GL_PROXY_TEXTURE_3D) mis-set teximage depth field
|
||||
<li>Fixed GLX indirect vertex array rendering bug (14197)
|
||||
<li>Fixed crash when deleting framebuffer objects (bugs 13507, 14293)
|
||||
<li>User-defined clip planes enabled for R300 (bug 9871)
|
||||
<li>Fixed glBindTexture() crash upon bad target (bug 14514)
|
||||
<li>Fixed potential crash in glDrawPixels(GL_DEPTH_COMPONENT) (bug 13915)
|
||||
<li>Bad strings given to glProgramStringARB() didn't generate GL_INVALID_OPERATION
|
||||
<li>Fixed minor point rasterization regression (bug 11016)
|
||||
<li>state.texenv.color state var didn't work in GL_ARB_fragment_program (bug 14931)
|
||||
<li>glBitmap from a PBO didn't always work
|
||||
<li>glGetTexImage into a PBO didn't always work
|
||||
<li>Comments at the end of ARB vertex/fragment programs crashed the parser
|
||||
</ul>
|
||||
|
||||
<h2>Changes</h2>
|
||||
<ul>
|
||||
<li>Updated glext.h to version 40
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Driver Status</h2>
|
||||
|
||||
<pre>
|
||||
Driver Status
|
||||
---------------------- ----------------------
|
||||
DRI drivers varies with the driver
|
||||
XMesa/GLX (on Xlib) implements OpenGL 2.1
|
||||
OSMesa (off-screen) implements OpenGL 2.1
|
||||
Windows/Win32 implements OpenGL 2.1
|
||||
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
|
||||
SVGA unsupported
|
||||
Wind River UGL unsupported
|
||||
DJGPP unsupported
|
||||
GGI unsupported
|
||||
BeOS unsupported
|
||||
Allegro unsupported
|
||||
D3D unsupported
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -21,6 +21,9 @@ The release notes summarize what's new or changed in each Mesa release.
|
||||
|
||||
<UL>
|
||||
<LI><A HREF="relnotes-7.1.html">7.1 release notes</A>
|
||||
<LI><A HREF="relnotes-7.0.3.html">7.0.3 release notes</A>
|
||||
<LI><A HREF="relnotes-7.0.2.html">7.0.2 release notes</A>
|
||||
<LI><A HREF="relnotes-7.0.1.html">7.0.1 release notes</A>
|
||||
<LI><A HREF="relnotes-7.0.html">7.0 release notes</A>
|
||||
<LI><A HREF="relnotes-6.5.3.html">6.5.3 release notes</A>
|
||||
<LI><A HREF="relnotes-6.5.2.html">6.5.2 release notes</A>
|
||||
|
||||
+15
-4
@@ -46,9 +46,9 @@ extern "C" {
|
||||
/*************************************************************/
|
||||
|
||||
/* Header file version number, required by OpenGL ABI for Linux */
|
||||
/* glext.h last updated 2007/02/12 */
|
||||
/* glext.h last updated 2008/03/24 */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define GL_GLEXT_VERSION 39
|
||||
#define GL_GLEXT_VERSION 40
|
||||
|
||||
#ifndef GL_VERSION_1_2
|
||||
#define GL_UNSIGNED_BYTE_3_3_2 0x8032
|
||||
@@ -3091,8 +3091,8 @@ extern "C" {
|
||||
#ifndef GL_EXT_framebuffer_blit
|
||||
#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
|
||||
#define GL_READ_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT
|
||||
#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CAA
|
||||
#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT
|
||||
#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_framebuffer_multisample
|
||||
@@ -3379,6 +3379,9 @@ extern "C" {
|
||||
#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E
|
||||
#endif
|
||||
|
||||
#ifndef GL_GREMEDY_frame_terminator
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
@@ -7252,6 +7255,14 @@ typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint
|
||||
typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha);
|
||||
#endif
|
||||
|
||||
#ifndef GL_GREMEDY_frame_terminator
|
||||
#define GL_GREMEDY_frame_terminator 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glFrameTerminatorGREMEDY (void);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+208
-201
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* Copyright 2007-2008 Red Hat, Inc.
|
||||
* (C) Copyright IBM Corporation 2004
|
||||
* All Rights Reserved.
|
||||
*
|
||||
@@ -33,12 +34,12 @@
|
||||
*
|
||||
* \author Kevin E. Martin <kevin@precisioninsight.com>
|
||||
* \author Ian Romanick <idr@us.ibm.com>
|
||||
* \author Kristian Høgsberg <krh@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef DRI_INTERFACE_H
|
||||
#define DRI_INTERFACE_H
|
||||
|
||||
#include <GL/internal/glcore.h>
|
||||
#include <drm.h>
|
||||
|
||||
/**
|
||||
@@ -52,10 +53,11 @@ typedef struct __DRIdisplayRec __DRIdisplay;
|
||||
typedef struct __DRIscreenRec __DRIscreen;
|
||||
typedef struct __DRIcontextRec __DRIcontext;
|
||||
typedef struct __DRIdrawableRec __DRIdrawable;
|
||||
typedef struct __DRIdriverRec __DRIdriver;
|
||||
typedef struct __DRIconfigRec __DRIconfig;
|
||||
typedef struct __DRIframebufferRec __DRIframebuffer;
|
||||
typedef struct __DRIversionRec __DRIversion;
|
||||
|
||||
typedef struct __DRIcoreExtensionRec __DRIcoreExtension;
|
||||
typedef struct __DRIextensionRec __DRIextension;
|
||||
typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
|
||||
typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
|
||||
@@ -64,16 +66,13 @@ typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
|
||||
typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
|
||||
typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
|
||||
typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
|
||||
typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Extension struct. Drivers 'inherit' from this struct by embedding
|
||||
* it as the first element in the extension struct. The
|
||||
* __DRIscreen::getExtensions entry point will return a list of these
|
||||
* structs and the loader can use the extensions it knows about by
|
||||
* casting it to a more specific extension and optionally advertising
|
||||
* the GLX extension. See below for examples.
|
||||
* it as the first element in the extension struct.
|
||||
*
|
||||
* We never break API in for a DRI extension. If we need to change
|
||||
* the way things work in a non-backwards compatible manner, we
|
||||
@@ -95,6 +94,14 @@ struct __DRIextensionRec {
|
||||
int version;
|
||||
};
|
||||
|
||||
/**
|
||||
* The first set of extension are the screen extensions, returned by
|
||||
* __DRIcore::getExtensions(). This entry point will return a list of
|
||||
* extensions and the loader can use the ones it knows about by
|
||||
* casting them to more specific extensions and advertising any GLX
|
||||
* extensions the DRI extensions enables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used by drivers to indicate support for setting the read drawable.
|
||||
*/
|
||||
@@ -227,52 +234,6 @@ struct __DRItexBufferExtensionRec {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Macros for building symbol and strings. Standard CPP two step...
|
||||
*/
|
||||
|
||||
#define __DRI_REAL_STRINGIFY(x) # x
|
||||
#define __DRI_STRINGIFY(x) __DRI_REAL_STRINGIFY(x)
|
||||
#define __DRI_REAL_MAKE_VERSION(name, version) name ## _ ## version
|
||||
#define __DRI_MAKE_VERSION(name, version) __DRI_REAL_MAKE_VERSION(name, version)
|
||||
|
||||
/**
|
||||
* \name Functions and data provided by the driver.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
#define __DRI_INTERFACE_VERSION 20080310
|
||||
|
||||
typedef void *(CREATENEWSCREENFUNC)(int scr, __DRIscreen *psc,
|
||||
const __DRIversion * ddx_version, const __DRIversion * dri_version,
|
||||
const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer,
|
||||
void * pSAREA, int fd, const __DRIextension ** extensions,
|
||||
__GLcontextModes ** driver_modes);
|
||||
typedef CREATENEWSCREENFUNC* PFNCREATENEWSCREENFUNC;
|
||||
|
||||
#define __DRI_CREATE_NEW_SCREEN \
|
||||
__DRI_MAKE_VERSION(__driCreateNewScreen, __DRI_INTERFACE_VERSION)
|
||||
|
||||
#define __DRI_CREATE_NEW_SCREEN_STRING \
|
||||
__DRI_STRINGIFY(__DRI_CREATE_NEW_SCREEN)
|
||||
|
||||
extern CREATENEWSCREENFUNC __DRI_CREATE_NEW_SCREEN;
|
||||
|
||||
|
||||
/* DRI2 Entry point */
|
||||
|
||||
typedef void *(__DRI2_CREATE_NEW_SCREEN_FUNC)(int scr, __DRIscreen *psc,
|
||||
int fd, unsigned int sarea_handle,
|
||||
const __DRIextension **extensions, __GLcontextModes ** driver_modes);
|
||||
#define __DRI2_CREATE_NEW_SCREEN \
|
||||
__DRI_MAKE_VERSION(__dri2CreateNewScreen, __DRI_INTERFACE_VERSION)
|
||||
|
||||
#define __DRI2_CREATE_NEW_SCREEN_STRING \
|
||||
__DRI_STRINGIFY(__DRI2_CREATE_NEW_SCREEN)
|
||||
|
||||
extern __DRI2_CREATE_NEW_SCREEN_FUNC __DRI2_CREATE_NEW_SCREEN;
|
||||
|
||||
|
||||
/**
|
||||
* XML document describing the configuration options supported by the
|
||||
* driver.
|
||||
@@ -281,60 +242,20 @@ extern const char __driConfigOptions[];
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* Stored version of some component (i.e., server-side DRI module, kernel-side
|
||||
* DRM, etc.).
|
||||
*
|
||||
* \todo
|
||||
* There are several data structures that explicitly store a major version,
|
||||
* minor version, and patch level. These structures should be modified to
|
||||
* have a \c __DRIversionRec instead.
|
||||
*/
|
||||
struct __DRIversionRec {
|
||||
int major; /**< Major version number. */
|
||||
int minor; /**< Minor version number. */
|
||||
int patch; /**< Patch-level. */
|
||||
};
|
||||
|
||||
/**
|
||||
* The following extensions describe loader features that the DRI
|
||||
* driver can make use of. Some of these are mandatory, such as the
|
||||
* getDrawableInfo extension for DRI and the coreDRI2 extensions for
|
||||
* getDrawableInfo extension for DRI and the DRI Loader extensions for
|
||||
* DRI2, while others are optional, and if present allow the driver to
|
||||
* expose certain features. The loader pass in a NULL terminated
|
||||
* array of these extensions to the driver in the createNewScreen
|
||||
* constructor.
|
||||
*/
|
||||
|
||||
typedef struct __DRIcontextModesExtensionRec __DRIcontextModesExtension;
|
||||
typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
|
||||
typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
|
||||
typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
|
||||
typedef struct __DRIcoreDRI2ExtensionRec __DRIcoreDRI2Extension;
|
||||
|
||||
/**
|
||||
* Memory management for __GLcontextModes
|
||||
*/
|
||||
#define __DRI_CONTEXT_MODES "DRI_ContextModes"
|
||||
#define __DRI_CONTEXT_MODES_VERSION 1
|
||||
struct __DRIcontextModesExtensionRec {
|
||||
__DRIextension base;
|
||||
|
||||
/**
|
||||
* Create a list of \c __GLcontextModes structures.
|
||||
*/
|
||||
__GLcontextModes * (*createContextModes)(unsigned count,
|
||||
size_t minimum_bytes_per_struct);
|
||||
|
||||
/**
|
||||
* Destroy a list of \c __GLcontextModes structures.
|
||||
*
|
||||
* \todo
|
||||
* Determine if the drivers actually need to call this.
|
||||
*/
|
||||
void (*destroyContextModes)( __GLcontextModes * modes );
|
||||
};
|
||||
typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
|
||||
|
||||
|
||||
/**
|
||||
@@ -354,7 +275,8 @@ struct __DRIgetDrawableInfoExtensionRec {
|
||||
int * x, int * y, int * width, int * height,
|
||||
int * numClipRects, drm_clip_rect_t ** pClipRects,
|
||||
int * backX, int * backY,
|
||||
int * numBackClipRects, drm_clip_rect_t ** pBackClipRects );
|
||||
int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
|
||||
void *loaderPrivate);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -378,7 +300,8 @@ struct __DRIsystemTimeExtensionRec {
|
||||
* the frame refresh rate of the display.
|
||||
*/
|
||||
GLboolean (*getMSCRate)(__DRIdrawable *draw,
|
||||
int32_t * numerator, int32_t * denominator);
|
||||
int32_t * numerator, int32_t * denominator,
|
||||
void *loaderPrivate);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -402,19 +325,22 @@ struct __DRIdamageExtensionRec {
|
||||
* \param front_buffer boolean flag for whether the drawing to the
|
||||
* drawable was actually done directly to the front buffer (instead
|
||||
* of backing storage, for example)
|
||||
* \param loaderPrivate the data passed in at createNewDrawable time
|
||||
*/
|
||||
void (*reportDamage)(__DRIdrawable *draw,
|
||||
int x, int y,
|
||||
drm_clip_rect_t *rects, int num_rects,
|
||||
GLboolean front_buffer);
|
||||
GLboolean front_buffer,
|
||||
void *loaderPrivate);
|
||||
};
|
||||
|
||||
/**
|
||||
* DRI2 core
|
||||
* DRI2 Loader extension. This extension describes the basic
|
||||
* functionality the loader needs to provide for the DRI driver.
|
||||
*/
|
||||
#define __DRI_CORE_DRI2 "DRI_CoreDRI2"
|
||||
#define __DRI_CORE_DRI2_VERSION 1
|
||||
struct __DRIcoreDRI2ExtensionRec {
|
||||
#define __DRI_LOADER "DRI_Loader"
|
||||
#define __DRI_LOADER_VERSION 1
|
||||
struct __DRIloaderExtensionRec {
|
||||
__DRIextension base;
|
||||
|
||||
/**
|
||||
@@ -424,11 +350,162 @@ struct __DRIcoreDRI2ExtensionRec {
|
||||
* \param draw the drawable for which to request info
|
||||
* \param tail the new event buffer tail pointer
|
||||
*/
|
||||
void (*reemitDrawableInfo)(__DRIdrawable *draw, unsigned int *tail);
|
||||
void (*reemitDrawableInfo)(__DRIdrawable *draw, unsigned int *tail,
|
||||
void *loaderPrivate);
|
||||
|
||||
void (*postDamage)(__DRIdrawable *draw, struct drm_clip_rect *rects,
|
||||
int num_rects, void *loaderPrivate);
|
||||
};
|
||||
|
||||
/**
|
||||
* The remaining extensions describe driver extensions, immediately
|
||||
* available interfaces provided by the driver. To start using the
|
||||
* driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
|
||||
* the extension you need in the array.
|
||||
*/
|
||||
#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
|
||||
|
||||
/**
|
||||
* Tokens for __DRIconfig attribs. A number of attributes defined by
|
||||
* GLX or EGL standards are not in the table, as they must be provided
|
||||
* by the loader. For example, FBConfig ID or visual ID, drawable type.
|
||||
*/
|
||||
|
||||
#define __DRI_ATTRIB_BUFFER_SIZE 1
|
||||
#define __DRI_ATTRIB_LEVEL 2
|
||||
#define __DRI_ATTRIB_RED_SIZE 3
|
||||
#define __DRI_ATTRIB_GREEN_SIZE 4
|
||||
#define __DRI_ATTRIB_BLUE_SIZE 5
|
||||
#define __DRI_ATTRIB_LUMINANCE_SIZE 6
|
||||
#define __DRI_ATTRIB_ALPHA_SIZE 7
|
||||
#define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
|
||||
#define __DRI_ATTRIB_DEPTH_SIZE 9
|
||||
#define __DRI_ATTRIB_STENCIL_SIZE 10
|
||||
#define __DRI_ATTRIB_ACCUM_RED_SIZE 11
|
||||
#define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
|
||||
#define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
|
||||
#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
|
||||
#define __DRI_ATTRIB_SAMPLE_BUFFERS 15
|
||||
#define __DRI_ATTRIB_SAMPLES 16
|
||||
#define __DRI_ATTRIB_RENDER_TYPE 17
|
||||
#define __DRI_ATTRIB_CONFIG_CAVEAT 18
|
||||
#define __DRI_ATTRIB_CONFORMANT 19
|
||||
#define __DRI_ATTRIB_DOUBLE_BUFFER 20
|
||||
#define __DRI_ATTRIB_STEREO 21
|
||||
#define __DRI_ATTRIB_AUX_BUFFERS 22
|
||||
#define __DRI_ATTRIB_TRANSPARENT_TYPE 23
|
||||
#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
|
||||
#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
|
||||
#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
|
||||
#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
|
||||
#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
|
||||
#define __DRI_ATTRIB_FLOAT_MODE 29
|
||||
#define __DRI_ATTRIB_RED_MASK 30
|
||||
#define __DRI_ATTRIB_GREEN_MASK 31
|
||||
#define __DRI_ATTRIB_BLUE_MASK 32
|
||||
#define __DRI_ATTRIB_ALPHA_MASK 33
|
||||
#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
|
||||
#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
|
||||
#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
|
||||
#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
|
||||
#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
|
||||
#define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
|
||||
#define __DRI_ATTRIB_SWAP_METHOD 40
|
||||
#define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
|
||||
#define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
|
||||
#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
|
||||
#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
|
||||
#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
|
||||
#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
|
||||
#define __DRI_ATTRIB_YINVERTED 47
|
||||
|
||||
/* __DRI_ATTRIB_RENDER_TYPE */
|
||||
#define __DRI_ATTRIB_RGBA_BIT 0x01
|
||||
#define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
|
||||
#define __DRI_ATTRIB_LUMINANCE_BIT 0x04
|
||||
|
||||
/* __DRI_ATTRIB_CONFIG_CAVEAT */
|
||||
#define __DRI_ATTRIB_SLOW_BIT 0x01
|
||||
#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
|
||||
|
||||
/* __DRI_ATTRIB_TRANSPARENT_TYPE */
|
||||
#define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
|
||||
#define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
|
||||
|
||||
/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
|
||||
#define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
|
||||
#define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
|
||||
#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
|
||||
|
||||
/**
|
||||
* This extension defines the core DRI functionality.
|
||||
*/
|
||||
#define __DRI_CORE "DRI_Core"
|
||||
#define __DRI_CORE_VERSION 1
|
||||
|
||||
struct __DRIcoreExtensionRec {
|
||||
__DRIextension base;
|
||||
|
||||
__DRIscreen *(*createNewScreen)(int screen, int fd,
|
||||
unsigned int sarea_handle,
|
||||
const __DRIextension **extensions,
|
||||
const __DRIconfig ***driverConfigs,
|
||||
void *loaderPrivate);
|
||||
|
||||
void (*destroyScreen)(__DRIscreen *screen);
|
||||
|
||||
const __DRIextension **(*getExtensions)(__DRIscreen *screen);
|
||||
|
||||
int (*getConfigAttrib)(const __DRIconfig *config,
|
||||
unsigned int attrib,
|
||||
unsigned int *value);
|
||||
|
||||
int (*indexConfigAttrib)(const __DRIconfig *config, int index,
|
||||
unsigned int *attrib, unsigned int *value);
|
||||
|
||||
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
|
||||
const __DRIconfig *config,
|
||||
unsigned int drawable_id,
|
||||
unsigned int head,
|
||||
void *loaderPrivate);
|
||||
|
||||
void (*destroyDrawable)(__DRIdrawable *drawable);
|
||||
|
||||
void (*swapBuffers)(__DRIdrawable *drawable);
|
||||
|
||||
__DRIcontext *(*createNewContext)(__DRIscreen *screen,
|
||||
const __DRIconfig *config,
|
||||
__DRIcontext *shared,
|
||||
void *loaderPrivate);
|
||||
|
||||
int (*copyContext)(__DRIcontext *dest,
|
||||
__DRIcontext *src,
|
||||
unsigned long mask);
|
||||
|
||||
void (*destroyContext)(__DRIcontext *context);
|
||||
|
||||
int (*bindContext)(__DRIcontext *ctx,
|
||||
__DRIdrawable *pdraw,
|
||||
__DRIdrawable *pread);
|
||||
|
||||
int (*unbindContext)(__DRIcontext *ctx);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stored version of some component (i.e., server-side DRI module, kernel-side
|
||||
* DRM, etc.).
|
||||
*
|
||||
* \todo
|
||||
* There are several data structures that explicitly store a major version,
|
||||
* minor version, and patch level. These structures should be modified to
|
||||
* have a \c __DRIversionRec instead.
|
||||
*/
|
||||
struct __DRIversionRec {
|
||||
int major; /**< Major version number. */
|
||||
int minor; /**< Minor version number. */
|
||||
int patch; /**< Patch-level. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Framebuffer information record. Used by libGL to communicate information
|
||||
* about the framebuffer to the driver's \c __driCreateNewScreen function.
|
||||
@@ -458,108 +535,38 @@ struct __DRIframebufferRec {
|
||||
|
||||
|
||||
/**
|
||||
* Screen dependent methods. This structure is initialized during the
|
||||
* \c __DRIdisplayRec::createScreen call.
|
||||
* This extension provides alternative screen, drawable and context
|
||||
* constructors for legacy DRI functionality. This is used in
|
||||
* conjunction with the core extension.
|
||||
*/
|
||||
struct __DRIscreenRec {
|
||||
/**
|
||||
* Method to destroy the private DRI screen data.
|
||||
*/
|
||||
void (*destroyScreen)(__DRIscreen *screen);
|
||||
#define __DRI_LEGACY "DRI_Legacy"
|
||||
#define __DRI_LEGACY_VERSION 1
|
||||
|
||||
/**
|
||||
* Method to get screen extensions.
|
||||
*/
|
||||
const __DRIextension **(*getExtensions)(__DRIscreen *screen);
|
||||
struct __DRIlegacyExtensionRec {
|
||||
__DRIextension base;
|
||||
|
||||
/**
|
||||
* Method to create the private DRI drawable data and initialize the
|
||||
* drawable dependent methods.
|
||||
*/
|
||||
void *(*createNewDrawable)(__DRIscreen *screen,
|
||||
const __GLcontextModes *modes,
|
||||
__DRIdrawable *pdraw,
|
||||
drm_drawable_t hwDrawable,
|
||||
unsigned int head,
|
||||
int renderType, const int *attrs);
|
||||
__DRIscreen *(*createNewScreen)(int screen,
|
||||
const __DRIversion *ddx_version,
|
||||
const __DRIversion *dri_version,
|
||||
const __DRIversion *drm_version,
|
||||
const __DRIframebuffer *frame_buffer,
|
||||
void *pSAREA, int fd,
|
||||
const __DRIextension **extensions,
|
||||
const __DRIconfig ***driver_configs,
|
||||
void *loaderPrivate);
|
||||
|
||||
/**
|
||||
* Opaque pointer to private per screen direct rendering data. \c NULL
|
||||
* if direct rendering is not supported on this screen. Never
|
||||
* dereferenced in libGL.
|
||||
*/
|
||||
void *private;
|
||||
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
|
||||
const __DRIconfig *config,
|
||||
drm_drawable_t hwDrawable,
|
||||
int renderType, const int *attrs,
|
||||
void *loaderPrivate);
|
||||
|
||||
/**
|
||||
* Method to create the private DRI context data and initialize the
|
||||
* context dependent methods.
|
||||
*
|
||||
* \since Internal API version 20031201.
|
||||
*/
|
||||
void * (*createNewContext)(__DRIscreen *screen,
|
||||
const __GLcontextModes *modes,
|
||||
int render_type,
|
||||
__DRIcontext *shared,
|
||||
drm_context_t hwContext, __DRIcontext *pctx);
|
||||
};
|
||||
|
||||
/**
|
||||
* Context dependent methods. This structure is initialized during the
|
||||
* \c __DRIscreenRec::createContext call.
|
||||
*/
|
||||
struct __DRIcontextRec {
|
||||
/**
|
||||
* Method to destroy the private DRI context data.
|
||||
*/
|
||||
void (*destroyContext)(__DRIcontext *context);
|
||||
|
||||
/**
|
||||
* Opaque pointer to private per context direct rendering data.
|
||||
* \c NULL if direct rendering is not supported on the display or
|
||||
* screen used to create this context. Never dereferenced in libGL.
|
||||
*/
|
||||
void *private;
|
||||
|
||||
/**
|
||||
* Method to bind a DRI drawable to a DRI graphics context.
|
||||
*
|
||||
* \since Internal API version 20050727.
|
||||
*/
|
||||
GLboolean (*bindContext)(__DRIcontext *ctx,
|
||||
__DRIdrawable *pdraw,
|
||||
__DRIdrawable *pread);
|
||||
|
||||
/**
|
||||
* Method to unbind a DRI drawable from a DRI graphics context.
|
||||
*
|
||||
* \since Internal API version 20050727.
|
||||
*/
|
||||
GLboolean (*unbindContext)(__DRIcontext *ctx);
|
||||
};
|
||||
|
||||
/**
|
||||
* Drawable dependent methods. This structure is initialized during the
|
||||
* \c __DRIscreenRec::createDrawable call. \c createDrawable is not called
|
||||
* by libGL at this time. It's currently used via the dri_util.c utility code
|
||||
* instead.
|
||||
*/
|
||||
struct __DRIdrawableRec {
|
||||
/**
|
||||
* Method to destroy the private DRI drawable data.
|
||||
*/
|
||||
void (*destroyDrawable)(__DRIdrawable *drawable);
|
||||
|
||||
/**
|
||||
* Method to swap the front and back buffers.
|
||||
*/
|
||||
void (*swapBuffers)(__DRIdrawable *drawable);
|
||||
|
||||
/**
|
||||
* Opaque pointer to private per drawable direct rendering data.
|
||||
* \c NULL if direct rendering is not supported on the display or
|
||||
* screen used to create this drawable. Never dereferenced in libGL.
|
||||
*/
|
||||
void *private;
|
||||
__DRIcontext *(*createNewContext)(__DRIscreen *screen,
|
||||
const __DRIconfig *config,
|
||||
int render_type,
|
||||
__DRIcontext *shared,
|
||||
drm_context_t hwContext,
|
||||
void *loaderPrivate);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -56,6 +56,9 @@ typedef struct __DRIBufferAttachEvent __DRIBufferAttachEvent;
|
||||
struct __DRILock {
|
||||
unsigned int block_header;
|
||||
drm_hw_lock_t lock;
|
||||
|
||||
/* We use this with DRM_CAS to allocate lock IDs for the real lock.*/
|
||||
unsigned int next_id;
|
||||
};
|
||||
|
||||
struct __DRIEventBuffer {
|
||||
@@ -113,7 +116,7 @@ struct __DRIDrawableBuffer {
|
||||
|
||||
struct __DRIDrawableConfigEvent {
|
||||
unsigned int event_header;
|
||||
drm_drawable_t drawable;
|
||||
unsigned int drawable;
|
||||
short x;
|
||||
short y;
|
||||
unsigned int width;
|
||||
@@ -124,7 +127,7 @@ struct __DRIDrawableConfigEvent {
|
||||
|
||||
struct __DRIBufferAttachEvent {
|
||||
unsigned int event_header;
|
||||
drm_drawable_t drawable;
|
||||
unsigned int drawable;
|
||||
__DRIDrawableBuffer buffer;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
|
||||
|
||||
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) -lX11 -lXi -lXmu
|
||||
|
||||
PROGS = \
|
||||
arbfplight \
|
||||
|
||||
+84
-9
@@ -45,6 +45,7 @@ default: $(PROGS)
|
||||
extfuncs.h: $(TOP)/progs/util/extfuncs.h
|
||||
cp $< .
|
||||
|
||||
|
||||
readtex.c: $(TOP)/progs/util/readtex.c
|
||||
cp $< .
|
||||
|
||||
@@ -54,26 +55,100 @@ readtex.h: $(TOP)/progs/util/readtex.h
|
||||
readtex.o: readtex.c readtex.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c
|
||||
|
||||
bitmap.c: extfuncs.h
|
||||
|
||||
brick.c: extfuncs.h
|
||||
shaderutil.c: $(TOP)/progs/util/shaderutil.c
|
||||
cp $< .
|
||||
|
||||
bump.c: extfuncs.h
|
||||
shaderutil.h: $(TOP)/progs/util/shaderutil.h
|
||||
cp $< .
|
||||
|
||||
mandelbrot.c: extfuncs.h
|
||||
shaderutil.o: shaderutil.c shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) shaderutil.c
|
||||
|
||||
points.c: extfuncs.h
|
||||
|
||||
toyball.c: extfuncs.h
|
||||
|
||||
texdemo1: texdemo1.o readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o $(LIBS) -o $@
|
||||
bitmap.o: bitmap.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) bitmap.c
|
||||
|
||||
texdemo1.o: texdemo1.c readtex.h extfuncs.h
|
||||
bitmap: bitmap.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bitmap.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
brick.o: brick.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) brick.c
|
||||
|
||||
brick: brick.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) brick.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
bump.o: bump.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) bump.c
|
||||
|
||||
bump: bump.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bump.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
deriv.o: deriv.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) deriv.c
|
||||
|
||||
deriv: deriv.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c
|
||||
|
||||
mandelbrot: mandelbrot.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) mandelbrot.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
noise.o: noise.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) noise.c
|
||||
|
||||
noise: noise.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) noise.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
points.o: points.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) points.c
|
||||
|
||||
points: points.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) points.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
texdemo1.o: texdemo1.c readtex.h extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
|
||||
|
||||
texdemo1: texdemo1.o readtex.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
toyball.o: toyball.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) toyball.c
|
||||
|
||||
toyball: toyball.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) toyball.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
twoside.o: twoside.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) twoside.c
|
||||
|
||||
twoside: twoside.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) twoside.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
trirast.o: trirast.c extfuncs.h shaderutil.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) trirast.c
|
||||
|
||||
trirast: trirast.o shaderutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
-rm -f $(PROGS)
|
||||
-rm -f *.o *~
|
||||
-rm -f extfuncs.h
|
||||
-rm -f shaderutil.*
|
||||
|
||||
+5
-50
@@ -13,6 +13,7 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static GLuint FragShader;
|
||||
@@ -246,40 +247,6 @@ MakeBitmapTextures(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
@@ -306,28 +273,16 @@ Init(void)
|
||||
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
|
||||
" gl_FrontColor = gl_Color; \n"
|
||||
"}\n";
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
FragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
LoadAndCompileShader(FragShader, fragShaderText);
|
||||
VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||
FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||
Program = LinkShaders(VertShader, FragShader);
|
||||
|
||||
VertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
LoadAndCompileShader(VertShader, vertShaderText);
|
||||
|
||||
Program = glCreateProgram_func();
|
||||
glAttachShader_func(Program, FragShader);
|
||||
glAttachShader_func(Program, VertShader);
|
||||
glLinkProgram_func(Program);
|
||||
CheckLink(Program);
|
||||
glUseProgram_func(Program);
|
||||
|
||||
uScale = glGetUniformLocation_func(Program, "scale");
|
||||
|
||||
+13
-121
@@ -13,6 +13,7 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static char *FragProgFile = "CH06-brick.frag.txt";
|
||||
@@ -23,23 +24,15 @@ static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
/* vert */
|
||||
{ "LightPosition", 3, -1, { 0.1, 0.1, 9.0, 0} },
|
||||
{ "LightPosition", 3, GL_FLOAT, { 0.1, 0.1, 9.0, 0}, -1 },
|
||||
/* frag */
|
||||
{ "BrickColor", 3, -1, { 0.8, 0.2, 0.2, 0 } },
|
||||
{ "MortarColor", 3, -1, { 0.6, 0.6, 0.6, 0 } },
|
||||
{ "BrickSize", 2, -1, { 1.0, 0.3, 0, 0 } },
|
||||
{ "BrickPct", 2, -1, { 0.9, 0.8, 0, 0 } },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
{ "BrickColor", 3, GL_FLOAT, { 0.8, 0.2, 0.2, 0 }, -1 },
|
||||
{ "MortarColor", 3, GL_FLOAT, { 0.6, 0.6, 0.6, 0 }, -1 },
|
||||
{ "BrickSize", 2, GL_FLOAT, { 1.0, 0.3, 0, 0 }, -1 },
|
||||
{ "BrickPct", 2, GL_FLOAT, { 0.9, 0.8, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
static GLint win = 0;
|
||||
@@ -145,122 +138,21 @@ SpecialKey(int key, int x, int y)
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "brick: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("brick: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
InitUniforms(program, Uniforms);
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
|
||||
+13
-122
@@ -13,6 +13,7 @@
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static char *FragProgFile = "CH11-bumpmap.frag.txt";
|
||||
@@ -24,20 +25,13 @@ static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "LightPosition", 3, -1, { 0.57737, 0.57735, 0.57735, 0.0 } },
|
||||
{ "SurfaceColor", 3, -1, { 0.8, 0.8, 0.2, 0 } },
|
||||
{ "BumpDensity", 1, -1, { 10.0, 0, 0, 0 } },
|
||||
{ "BumpSize", 1, -1, { 0.125, 0, 0, 0 } },
|
||||
{ "SpecularFactor", 1, -1, { 0.5, 0, 0, 0 } },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
{ "LightPosition", 3, GL_FLOAT, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
|
||||
{ "SurfaceColor", 3, GL_FLOAT, { 0.8, 0.8, 0.2, 0 }, -1 },
|
||||
{ "BumpDensity", 1, GL_FLOAT, { 10.0, 0, 0, 0 }, -1 },
|
||||
{ "BumpSize", 1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
|
||||
{ "SpecularFactor", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
static GLint win = 0;
|
||||
@@ -232,100 +226,18 @@ SpecialKey(int key, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "bump: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "bump: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("bump: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
@@ -336,28 +248,7 @@ Init(void)
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
InitUniforms(program, Uniforms);
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
|
||||
+5
-83
@@ -17,6 +17,7 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static char *FragProgFile = NULL;
|
||||
@@ -159,68 +160,6 @@ MakeRect(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "fslight: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("fslight: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
@@ -234,33 +173,16 @@ Init(void)
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
|
||||
"}\n";
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
}
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
if (FragProgFile)
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
else
|
||||
LoadAndCompileShader(fragShader, fragShaderText);
|
||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
if (VertProgFile)
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
else
|
||||
LoadAndCompileShader(vertShader, vertShaderText);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
/*assert(glGetError() == 0);*/
|
||||
|
||||
+19
-127
@@ -13,6 +13,7 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static char *FragProgFile = "CH18-mandel.frag.txt";
|
||||
@@ -24,28 +25,21 @@ static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
/* vert */
|
||||
{ "LightPosition", 3, -1, { 0.1, 0.1, 9.0, 0} },
|
||||
{ "SpecularContribution", 1, -1, { 0.5, 0, 0, 0 } },
|
||||
{ "DiffuseContribution", 1, -1, { 0.5, 0, 0, 0 } },
|
||||
{ "Shininess", 1, -1, { 20.0, 0, 0, 0 } },
|
||||
{ "LightPosition", 3, GL_FLOAT, { 0.1, 0.1, 9.0, 0}, -1 },
|
||||
{ "SpecularContribution", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
|
||||
{ "DiffuseContribution", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
|
||||
{ "Shininess", 1, GL_FLOAT, { 20.0, 0, 0, 0 }, -1 },
|
||||
/* frag */
|
||||
{ "MaxIterations", 1, -1, { 12, 0, 0, 0 } },
|
||||
{ "Zoom", 1, -1, { 0.125, 0, 0, 0 } },
|
||||
{ "Xcenter", 1, -1, { -1.5, 0, 0, 0 } },
|
||||
{ "Ycenter", 1, -1, { .005, 0, 0, 0 } },
|
||||
{ "InnerColor", 3, -1, { 1, 0, 0, 0 } },
|
||||
{ "OuterColor1", 3, -1, { 0, 1, 0, 0 } },
|
||||
{ "OuterColor2", 3, -1, { 0, 0, 1, 0 } },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
{ "MaxIterations", 1, GL_FLOAT, { 12, 0, 0, 0 }, -1 },
|
||||
{ "Zoom", 1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
|
||||
{ "Xcenter", 1, GL_FLOAT, { -1.5, 0, 0, 0 }, -1 },
|
||||
{ "Ycenter", 1, GL_FLOAT, { .005, 0, 0, 0 }, -1 },
|
||||
{ "InnerColor", 3, GL_FLOAT, { 1, 0, 0, 0 }, -1 },
|
||||
{ "OuterColor1", 3, GL_FLOAT, { 0, 1, 0, 0 }, -1 },
|
||||
{ "OuterColor2", 3, GL_FLOAT, { 0, 0, 1, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
static GLint win = 0;
|
||||
@@ -157,123 +151,21 @@ SpecialKey(int key, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "mandelbrot: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "mandelbrot: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("mandelbrot: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
InitUniforms(program, Uniforms);
|
||||
|
||||
uZoom = glGetUniformLocation_func(program, "Zoom");
|
||||
uXcenter = glGetUniformLocation_func(program, "Xcenter");
|
||||
|
||||
+11
-91
@@ -12,6 +12,7 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static const char *VertShaderText =
|
||||
@@ -34,18 +35,11 @@ static const char *FragShaderText =
|
||||
"}\n";
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "Scale", 4, -1, { 0.5, 0.4, 0.0, 0} },
|
||||
{ "Bias", 4, -1, { 0.5, 0.3, 0.0, 0} },
|
||||
{ "Slice", 1, -1, { 0.5, 0, 0, 0} },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
{ "Scale", 4, GL_FLOAT, { 0.5, 0.4, 0.0, 0}, -1 },
|
||||
{ "Bias", 4, GL_FLOAT, { 0.5, 0.3, 0.0, 0}, -1 },
|
||||
{ "Slice", 1, GL_FLOAT, { 0.5, 0, 0, 0}, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
/* program/shader objects */
|
||||
@@ -174,95 +168,21 @@ SpecialKey(int key, int x, int y)
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "noise: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
LoadAndCompileShader(vertShader, VertShaderText);
|
||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
|
||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
LoadAndCompileShader(fragShader, FragShaderText);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
InitUniforms(program, Uniforms);
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
|
||||
+5
-50
@@ -14,6 +14,7 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static GLuint FragShader;
|
||||
@@ -181,40 +182,6 @@ SpecialKey(int key, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
@@ -254,28 +221,16 @@ Init(void)
|
||||
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
|
||||
" gl_FrontColor = gl_Color; \n"
|
||||
"}\n";
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
FragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
LoadAndCompileShader(FragShader, fragShaderText);
|
||||
VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||
FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||
Program = LinkShaders(VertShader, FragShader);
|
||||
|
||||
VertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
LoadAndCompileShader(VertShader, vertShaderText);
|
||||
|
||||
Program = glCreateProgram_func();
|
||||
glAttachShader_func(Program, FragShader);
|
||||
glAttachShader_func(Program, VertShader);
|
||||
glLinkProgram_func(Program);
|
||||
CheckLink(Program);
|
||||
glUseProgram_func(Program);
|
||||
|
||||
uViewportInv = glGetUniformLocation_func(Program, "viewportInv");
|
||||
|
||||
+12
-143
@@ -31,6 +31,7 @@
|
||||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
static const char *Demo = "texdemo1";
|
||||
|
||||
@@ -50,38 +51,19 @@ static GLfloat EyeDist = 10;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLenum type; /**< GL_FLOAT or GL_INT */
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info ReflectUniforms[] = {
|
||||
{ "cubeTex", 1, -1, GL_INT, { 0, 0, 0, 0 } },
|
||||
{ "lightPos", 3, -1, GL_FLOAT, { 10, 10, 20, 0 } },
|
||||
{ NULL, 0, 0, 0, { 0, 0, 0, 0 } }
|
||||
{ "cubeTex", 1, GL_INT, { 0, 0, 0, 0 }, -1 },
|
||||
{ "lightPos", 3, GL_FLOAT, { 10, 10, 20, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
static struct uniform_info SimpleUniforms[] = {
|
||||
{ "tex2d", 1, -1, GL_INT, { 1, 0, 0, 0 } },
|
||||
{ "lightPos", 3, -1, GL_FLOAT, { 10, 10, 20, 0 } },
|
||||
{ NULL, 0, 0, 0, { 0, 0, 0, 0 } }
|
||||
{ "tex2d", 1, GL_INT, { 1, 0, 0, 0 }, -1 },
|
||||
{ "lightPos", 3, GL_FLOAT, { 10, 10, 20, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
CheckError(int line)
|
||||
{
|
||||
GLenum err = glGetError();
|
||||
if (err) {
|
||||
printf("GL Error %s (0x%x) at line %d\n",
|
||||
gluErrorString(err), (int) err, line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawGround(GLfloat size)
|
||||
{
|
||||
@@ -386,132 +368,19 @@ InitTextures(GLboolean useImageFiles)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "%s: problem compiling shader: %s\n", Demo, log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "%s: Unable to open shader file %s\n", Demo, filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("%s: read %d bytes from shader file %s\n", Demo, n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GLuint
|
||||
CreateProgram(const char *vertProgFile, const char *fragProgFile,
|
||||
struct uniform_info *uniforms)
|
||||
{
|
||||
GLuint fragShader = 0, vertShader = 0, program = 0;
|
||||
GLint i;
|
||||
GLuint fragShader, vertShader, program;
|
||||
|
||||
program = glCreateProgram_func();
|
||||
if (vertProgFile) {
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, vertProgFile);
|
||||
glAttachShader_func(program, vertShader);
|
||||
}
|
||||
|
||||
if (fragProgFile) {
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, fragProgFile);
|
||||
glAttachShader_func(program, fragShader);
|
||||
}
|
||||
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, vertProgFile);
|
||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, fragProgFile);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
glUseProgram_func(program);
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
CheckError(__LINE__);
|
||||
for (i = 0; uniforms[i].name; i++) {
|
||||
uniforms[i].location
|
||||
= glGetUniformLocation_func(program, uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", uniforms[i].name,
|
||||
uniforms[i].location);
|
||||
|
||||
switch (uniforms[i].size) {
|
||||
case 1:
|
||||
if (uniforms[i].type == GL_INT)
|
||||
glUniform1i_func(uniforms[i].location,
|
||||
(GLint) uniforms[i].value[0]);
|
||||
else
|
||||
glUniform1fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
CheckError(__LINE__);
|
||||
InitUniforms(program, uniforms);
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
+23
-136
@@ -13,6 +13,7 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static char *FragProgFile = "CH11-toyball.frag.txt";
|
||||
@@ -24,30 +25,23 @@ static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "LightDir", 4, -1, { 0.57737, 0.57735, 0.57735, 0.0 } },
|
||||
{ "HVector", 4, -1, { 0.32506, 0.32506, 0.88808, 0.0 } },
|
||||
{ "BallCenter", 4, -1, { 0.0, 0.0, 0.0, 1.0 } },
|
||||
{ "SpecularColor", 4, -1, { 0.4, 0.4, 0.4, 60.0 } },
|
||||
{ "Red", 4, -1, { 0.6, 0.0, 0.0, 1.0 } },
|
||||
{ "Blue", 4, -1, { 0.0, 0.3, 0.6, 1.0 } },
|
||||
{ "Yellow", 4, -1, { 0.6, 0.5, 0.0, 1.0 } },
|
||||
{ "HalfSpace0", 4, -1, { 1.0, 0.0, 0.0, 0.2 } },
|
||||
{ "HalfSpace1", 4, -1, { 0.309016994, 0.951056516, 0.0, 0.2 } },
|
||||
{ "HalfSpace2", 4, -1, { -0.809016994, 0.587785252, 0.0, 0.2 } },
|
||||
{ "HalfSpace3", 4, -1, { -0.809016994, -0.587785252, 0.0, 0.2 } },
|
||||
{ "HalfSpace4", 4, -1, { 0.309116994, -0.951056516, 0.0, 0.2 } },
|
||||
{ "InOrOutInit", 1, -1, { -3.0, 0, 0, 0 } },
|
||||
{ "StripeWidth", 1, -1, { 0.3, 0, 0, 0 } },
|
||||
{ "FWidth", 1, -1, { 0.005, 0, 0, 0 } },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
{ "LightDir", 4, GL_FLOAT, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
|
||||
{ "HVector", 4, GL_FLOAT, { 0.32506, 0.32506, 0.88808, 0.0 }, -1 },
|
||||
{ "BallCenter", 4, GL_FLOAT, { 0.0, 0.0, 0.0, 1.0 }, -1 },
|
||||
{ "SpecularColor", 4, GL_FLOAT, { 0.4, 0.4, 0.4, 60.0 }, -1 },
|
||||
{ "Red", 4, GL_FLOAT, { 0.6, 0.0, 0.0, 1.0 }, -1 },
|
||||
{ "Blue", 4, GL_FLOAT, { 0.0, 0.3, 0.6, 1.0 }, -1 },
|
||||
{ "Yellow", 4, GL_FLOAT, { 0.6, 0.5, 0.0, 1.0 }, -1 },
|
||||
{ "HalfSpace0", 4, GL_FLOAT, { 1.0, 0.0, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace1", 4, GL_FLOAT, { 0.309016994, 0.951056516, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace2", 4, GL_FLOAT, { -0.809016994, 0.587785252, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace3", 4, GL_FLOAT, { -0.809016994, -0.587785252, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace4", 4, GL_FLOAT, { 0.309116994, -0.951056516, 0.0, 0.2 }, -1 },
|
||||
{ "InOrOutInit", 1, GL_FLOAT, { -3.0, 0, 0, 0 }, -1 },
|
||||
{ "StripeWidth", 1, GL_FLOAT, { 0.3, 0, 0, 0 }, -1 },
|
||||
{ "FWidth", 1, GL_FLOAT, { 0.005, 0, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
static GLint win = 0;
|
||||
@@ -171,128 +165,21 @@ SpecialKey(int key, int x, int y)
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "toyball: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "toyball: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("toyball: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
InitUniforms(program, Uniforms);
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
|
||||
+5
-82
@@ -19,6 +19,7 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static GLint WinWidth = 300, WinHeight = 300;
|
||||
@@ -168,67 +169,6 @@ Key(unsigned char key, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "fslight: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("fslight: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
@@ -252,33 +192,16 @@ Init(void)
|
||||
"void main() {\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
"}\n";
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
}
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
if (FragProgFile)
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
else
|
||||
LoadAndCompileShader(fragShader, fragShaderText);
|
||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
if (VertProgFile)
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
else
|
||||
LoadAndCompileShader(vertShader, vertShaderText);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
uv0 = glGetUniformLocation_func(program, "v0");
|
||||
|
||||
+5
-83
@@ -16,9 +16,9 @@
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static const char *Prog = "twoside";
|
||||
static GLint WinWidth = 300, WinHeight = 300;
|
||||
static char *FragProgFile = NULL;
|
||||
static char *VertProgFile = NULL;
|
||||
@@ -167,67 +167,6 @@ Key(unsigned char key, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "%s: problem compiling shader:\n%s\n", Prog, log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "%s: Unable to open shader file %s\n", Prog, filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("%s: read %d bytes from shader file %s\n", Prog, n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
@@ -255,33 +194,16 @@ Init(void)
|
||||
" } \n"
|
||||
" gl_Position = ftransform(); \n"
|
||||
"} \n";
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
}
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
if (FragProgFile)
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
else
|
||||
LoadAndCompileShader(fragShader, fragShaderText);
|
||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||
program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
if (VertProgFile)
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
else
|
||||
LoadAndCompileShader(vertShader, vertShaderText);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
u_fragface = glGetUniformLocation_func(program, "fragface");
|
||||
|
||||
@@ -38,6 +38,7 @@ getproclist.h
|
||||
interleave
|
||||
invert
|
||||
jkrahntest
|
||||
lineclip
|
||||
manytex
|
||||
mipmap_limits
|
||||
multipal
|
||||
@@ -66,6 +67,7 @@ texline
|
||||
texobjshare
|
||||
texrect
|
||||
texwrap
|
||||
unfilledclip
|
||||
vao-01
|
||||
vao-02
|
||||
vparray
|
||||
|
||||
@@ -48,6 +48,7 @@ SOURCES = \
|
||||
interleave.c \
|
||||
invert.c \
|
||||
jkrahntest.c \
|
||||
lineclip.c \
|
||||
manytex.c \
|
||||
minmag.c \
|
||||
mipmap_limits.c \
|
||||
@@ -73,6 +74,7 @@ SOURCES = \
|
||||
texobjshare.c \
|
||||
texrect.c \
|
||||
texwrap.c \
|
||||
unfilledclip.c \
|
||||
vao-01.c \
|
||||
vao-02.c \
|
||||
vparray.c \
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright © 2008 Intel Corporation
|
||||
*
|
||||
* 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 (including the next
|
||||
* paragraph) 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.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
static int win_width, win_height;
|
||||
|
||||
static void
|
||||
line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(x1, y1);
|
||||
glVertex2f(x2, y2);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void
|
||||
line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(x1, y1, z1);
|
||||
glVertex3f(x2, y2, z2);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void
|
||||
display(void)
|
||||
{
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glColor3f(1.0, 0.0, 0.0);
|
||||
/* 2 lines clipped along xmin */
|
||||
line(-20, win_height / 2 - 20,
|
||||
20, win_height / 2 - 20);
|
||||
line( 20, win_height / 2 + 20,
|
||||
-20, win_height / 2 + 20);
|
||||
|
||||
glColor3f(0.0, 1.0, 0.0);
|
||||
/* 2 lines clipped along ymax */
|
||||
line(win_width / 2 - 20, win_height + 20,
|
||||
win_width / 2 - 20, win_height - 20);
|
||||
line(win_width / 2 + 20, win_height - 20,
|
||||
win_width / 2 + 20, win_height + 20);
|
||||
|
||||
glColor3f(0.0, 0.0, 1.0);
|
||||
/* 2 lines clipped along xmax */
|
||||
line(win_width - 20, win_height / 2 - 20,
|
||||
win_width + 20, win_height / 2 - 20);
|
||||
line(win_width + 20, win_height / 2 + 20,
|
||||
win_width - 20, win_height / 2 + 20);
|
||||
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
/* 2 lines clipped along ymin */
|
||||
line(win_width / 2 - 20, 20,
|
||||
win_width / 2 - 20, -20);
|
||||
line(win_width / 2 + 20, -20,
|
||||
win_width / 2 + 20, 20);
|
||||
|
||||
/* 2 lines clipped along near */
|
||||
glColor3f(1.0, 0.0, 1.0);
|
||||
line3(win_width / 2 - 20 - 20, win_height / 2, 0.5,
|
||||
win_width / 2 - 20 + 20, win_height / 2, -0.5);
|
||||
line3(win_width / 2 - 20, win_height / 2 - 20, -0.5,
|
||||
win_width / 2 - 20, win_height / 2 + 20, 0.5);
|
||||
|
||||
/* 2 lines clipped along far */
|
||||
glColor3f(0.0, 1.0, 1.0);
|
||||
line3(win_width / 2 + 20 - 20, win_height / 2, 1.5,
|
||||
win_width / 2 + 20 + 20, win_height / 2, 0.5);
|
||||
line3(win_width / 2 + 20, win_height / 2 - 20, 0.5,
|
||||
win_width / 2 + 20, win_height / 2 + 20, 1.5);
|
||||
|
||||
/* entirely clipped along near/far */
|
||||
glColor3f(.5, .5, .5);
|
||||
line3(win_width / 2, win_height / 2 - 20, -0.5,
|
||||
win_width / 2, win_height / 2 + 20, -0.5);
|
||||
glColor3f(.5, .5, .5);
|
||||
line3(win_width / 2, win_height / 2 - 20, 1.5,
|
||||
win_width / 2, win_height / 2 + 20, 1.5);
|
||||
|
||||
glColor3f(1.0, 1.0, 0.0);
|
||||
/* lines clipped along both x and y limits */
|
||||
line(-5, 20,
|
||||
20, -5); /* xmin, ymin */
|
||||
line(-5, win_height - 20,
|
||||
20, win_height + 5); /* xmin, ymax */
|
||||
line(win_width - 20, -5,
|
||||
win_width + 5, 20); /* xmax, ymin */
|
||||
line(win_width - 20, win_height + 5,
|
||||
win_width + 5, win_height - 20); /* xmax, ymax */
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
win_width = width;
|
||||
win_height = height;
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, win_width, 0, win_height, 0.0, -1.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(.25, .25, 0);
|
||||
}
|
||||
|
||||
static void key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch (key) {
|
||||
case 27: /* esc */
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
win_width = 200;
|
||||
win_height = 200;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition(0, 0);
|
||||
glutInitWindowSize(win_width, win_height);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutDisplayFunc(display);
|
||||
|
||||
init();
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright © 2008 Intel Corporation
|
||||
*
|
||||
* 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 (including the next
|
||||
* paragraph) 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.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
static int win_width, win_height;
|
||||
|
||||
static void
|
||||
line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(x1, y1);
|
||||
glVertex2f(x2, y2);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void
|
||||
line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(x1, y1, z1);
|
||||
glVertex3f(x2, y2, z2);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void
|
||||
display(void)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glColor3f(1.0, 0.0, 0.0);
|
||||
/* clipped along xmin */
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(-20, win_height / 2 - 20);
|
||||
glVertex2f(20, win_height / 2);
|
||||
glVertex2f(-20, win_height / 2 + 20);
|
||||
glEnd();
|
||||
|
||||
glColor3f(0.0, 1.0, 0.0);
|
||||
/* clipped along ymax */
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(win_height / 2 - 20, win_height + 20);
|
||||
glVertex2f(win_height / 2, win_height - 20);
|
||||
glVertex2f(win_height / 2 + 20, win_height + 20);
|
||||
glEnd();
|
||||
|
||||
glColor3f(0.0, 0.0, 1.0);
|
||||
/* clipped along xmax */
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(win_height + 20, win_height / 2 - 20);
|
||||
glVertex2f(win_height - 20, win_height / 2);
|
||||
glVertex2f(win_height + 20, win_height / 2 + 20);
|
||||
glEnd();
|
||||
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
/* clipped along ymin */
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(win_height / 2 - 20, -20);
|
||||
glVertex2f(win_height / 2, 20);
|
||||
glVertex2f(win_height / 2 + 20, -20);
|
||||
glEnd();
|
||||
|
||||
/* clipped along near */
|
||||
glColor3f(1.0, 0.0, 1.0);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f(win_width / 2 - 20, win_height / 2 - 20, 0.5);
|
||||
glVertex3f(win_width / 2 - 40, win_height / 2, -0.5);
|
||||
glVertex3f(win_width / 2 - 20, win_height / 2 + 20, 0.5);
|
||||
glEnd();
|
||||
|
||||
/* clipped along far */
|
||||
glColor3f(0.0, 1.0, 1.0);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f(win_width / 2 + 20, win_height / 2 - 20, 0.5);
|
||||
glVertex3f(win_width / 2 + 40, win_height / 2, 1.5);
|
||||
glVertex3f(win_width / 2 + 20, win_height / 2 + 20, 0.5);
|
||||
glEnd();
|
||||
|
||||
/* entirely clipped along near/far */
|
||||
glColor3f(.5, .5, .5);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f(win_width / 2 - 20, win_height / 2 + 20, -0.5);
|
||||
glVertex3f(win_width / 2, win_height / 2 + 40, -0.5);
|
||||
glVertex3f(win_width / 2 + 20, win_height / 2 + 20, -0.5);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f(win_width / 2 - 20, win_height / 2 - 20, 1.5);
|
||||
glVertex3f(win_width / 2, win_height / 2 - 40, 1.5);
|
||||
glVertex3f(win_width / 2 + 20, win_height / 2 - 20, 1.5);
|
||||
glEnd();
|
||||
|
||||
glColor3f(.5, .5, .5);
|
||||
line3(win_width / 2, win_height / 2 - 20, 1.5,
|
||||
win_width / 2, win_height / 2 + 20, 1.5);
|
||||
|
||||
glColor3f(1.0, 1.0, 0.0);
|
||||
/* clipped along both x and y limits */
|
||||
glBegin(GL_TRIANGLES); /* xmin, ymin */
|
||||
glVertex2f(-5, 20);
|
||||
glVertex2f(20, 20);
|
||||
glVertex2f(20, -5);
|
||||
glEnd();
|
||||
glBegin(GL_TRIANGLES); /* xmin, ymax */
|
||||
glVertex2f(-5, win_height - 20);
|
||||
glVertex2f(20, win_height - 20);
|
||||
glVertex2f(20, win_height + 5);
|
||||
glEnd();
|
||||
glBegin(GL_TRIANGLES); /* xmax, ymax */
|
||||
glVertex2f(win_width - 20, win_height + 5);
|
||||
glVertex2f(win_width - 20, win_height - 20);
|
||||
glVertex2f(win_width + 5, win_height - 20);
|
||||
glEnd();
|
||||
glBegin(GL_TRIANGLES); /* xmax, ymin */
|
||||
glVertex2f(win_width + 5, 20);
|
||||
glVertex2f(win_width - 20, 20);
|
||||
glVertex2f(win_width - 20, -5);
|
||||
glEnd();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
win_width = width;
|
||||
win_height = height;
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, win_width, 0, win_height, 0.0, -1.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(.25, .25, 0);
|
||||
}
|
||||
|
||||
static void key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch (key) {
|
||||
case 27: /* esc */
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
win_width = 200;
|
||||
win_height = 200;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition(0, 0);
|
||||
glutInitWindowSize(win_width, win_height);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutDisplayFunc(display);
|
||||
|
||||
init();
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
@@ -88,6 +88,7 @@ static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glColor3f(0,.9,0);
|
||||
glEdgeFlag(0);
|
||||
glCallList(list);
|
||||
@@ -95,6 +96,7 @@ static void Draw(void)
|
||||
glRotatef(45,0,0,1);
|
||||
glColor3f(1,0,1);
|
||||
glCallList(list);
|
||||
glPopMatrix();
|
||||
|
||||
glFlush();
|
||||
|
||||
|
||||
@@ -93,12 +93,14 @@ static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glColor3f(0,.9,0);
|
||||
glCallList(list);
|
||||
|
||||
glRotatef(45,0,0,1);
|
||||
glColor3f(1,0,1);
|
||||
glCallList(list);
|
||||
glPopMatrix();
|
||||
|
||||
glFlush();
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ static PFNGLCREATESHADERPROC glCreateShader_func = NULL;
|
||||
static PFNGLDELETEPROGRAMPROC glDeleteProgram_func = NULL;
|
||||
static PFNGLDELETESHADERPROC glDeleteShader_func = NULL;
|
||||
static PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib_func = NULL;
|
||||
static PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform_func = NULL;
|
||||
static PFNGLGETATTACHEDSHADERSPROC glGetAttachedShaders_func = NULL;
|
||||
static PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation_func = NULL;
|
||||
static PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog_func = NULL;
|
||||
@@ -91,6 +92,7 @@ GetExtensionFuncs(void)
|
||||
glDeleteProgram_func = (PFNGLDELETEPROGRAMPROC) glutGetProcAddress("glDeleteProgram");
|
||||
glDeleteShader_func = (PFNGLDELETESHADERPROC) glutGetProcAddress("glDeleteShader");
|
||||
glGetActiveAttrib_func = (PFNGLGETACTIVEATTRIBPROC) glutGetProcAddress("glGetActiveAttrib");
|
||||
glGetActiveUniform_func = (PFNGLGETACTIVEUNIFORMPROC) glutGetProcAddress("glGetActiveUniform");
|
||||
glGetAttachedShaders_func = (PFNGLGETATTACHEDSHADERSPROC) glutGetProcAddress("glGetAttachedShaders");
|
||||
glGetAttribLocation_func = (PFNGLGETATTRIBLOCATIONPROC) glutGetProcAddress("glGetAttribLocation");
|
||||
glGetProgramInfoLog_func = (PFNGLGETPROGRAMINFOLOGPROC) glutGetProcAddress("glGetProgramInfoLog");
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* Utilities for OpenGL shading language
|
||||
*
|
||||
* Brian Paul
|
||||
* 9 April 2008
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
static GLboolean firstCall = GL_TRUE;
|
||||
if (firstCall) {
|
||||
GetExtensionFuncs();
|
||||
firstCall = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GLboolean
|
||||
ShadersSupported(void)
|
||||
{
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
return GL_FALSE;
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
GLuint
|
||||
CompileShaderText(GLenum shaderType, const char *text)
|
||||
{
|
||||
GLuint shader;
|
||||
GLint stat;
|
||||
|
||||
Init();
|
||||
|
||||
shader = glCreateShader_func(shaderType);
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
glCompileShader_func(shader);
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "Error: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
/*printf("Shader compiled OK\n");*/
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
GLuint
|
||||
CompileShaderFile(GLenum shaderType, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
GLuint shader;
|
||||
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
/*printf("read %d bytes from shader file %s\n", n, filename);*/
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
shader = CompileShaderText(shaderType, buffer);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
|
||||
GLuint
|
||||
LinkShaders(GLuint vertShader, GLuint fragShader)
|
||||
{
|
||||
GLuint program = glCreateProgram_func();
|
||||
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
|
||||
/* check link */
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(program, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(program, 1000, &len, log);
|
||||
fprintf(stderr, "Shader link error:\n%s\n", log);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InitUniforms(GLuint program, struct uniform_info uniforms[])
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
for (i = 0; uniforms[i].name; i++) {
|
||||
uniforms[i].location
|
||||
= glGetUniformLocation_func(program, uniforms[i].name);
|
||||
|
||||
printf("Uniform %s location: %d\n", uniforms[i].name,
|
||||
uniforms[i].location);
|
||||
|
||||
switch (uniforms[i].size) {
|
||||
case 1:
|
||||
if (uniforms[i].type == GL_INT)
|
||||
glUniform1i_func(uniforms[i].location,
|
||||
(GLint) uniforms[i].value[0]);
|
||||
else
|
||||
glUniform1fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef SHADER_UTIL_H
|
||||
#define SHADER_UTIL_H
|
||||
|
||||
|
||||
|
||||
struct uniform_info
|
||||
{
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLenum type; /**< GL_FLOAT or GL_INT */
|
||||
GLfloat value[4];
|
||||
GLint location; /**< filled in by InitUniforms() */
|
||||
};
|
||||
|
||||
#define END_OF_UNIFORMS { NULL, 0, GL_NONE, { 0, 0, 0, 0 }, -1 }
|
||||
|
||||
|
||||
extern GLboolean
|
||||
ShadersSupported(void);
|
||||
|
||||
extern GLuint
|
||||
CompileShaderText(GLenum shaderType, const char *text);
|
||||
|
||||
extern GLuint
|
||||
CompileShaderFile(GLenum shaderType, const char *filename);
|
||||
|
||||
extern GLuint
|
||||
LinkShaders(GLuint vertShader, GLuint fragShader);
|
||||
|
||||
extern void
|
||||
InitUniforms(GLuint program, struct uniform_info uniforms[]);
|
||||
|
||||
|
||||
#endif /* SHADER_UTIL_H */
|
||||
@@ -71,6 +71,8 @@ ShowDepthBuffer( GLsizei winWidth, GLsizei winHeight,
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glViewport(0, 0, winWidth, winHeight);
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glRasterPos2f(0, 0);
|
||||
@@ -120,6 +122,8 @@ ShowAlphaBuffer( GLsizei winWidth, GLsizei winHeight )
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glViewport(0, 0, winWidth, winHeight);
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glRasterPos2f(0, 0);
|
||||
@@ -170,6 +174,8 @@ ShowStencilBuffer( GLsizei winWidth, GLsizei winHeight,
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glViewport(0, 0, winWidth, winHeight);
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glRasterPos2f(0, 0);
|
||||
|
||||
@@ -505,7 +505,7 @@ main(int argc, char *argv[])
|
||||
for (i = 0; i < numThreads; i++) {
|
||||
pthread_create(&WinThreads[i].Thread, NULL, thread_function,
|
||||
(void*) &WinThreads[i]);
|
||||
printf("glthreads: Created thread %p\n", WinThreads[i].Thread);
|
||||
printf("glthreads: Created thread %p\n", (void *) WinThreads[i].Thread);
|
||||
}
|
||||
|
||||
if (MultiDisplays)
|
||||
|
||||
+1
-1
@@ -27,12 +27,12 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include "ipc.h"
|
||||
|
||||
|
||||
@@ -6627,7 +6627,7 @@ typedef void (GLAPIENTRY *TexImage3Dproc)( GLenum target, GLint level,
|
||||
|
||||
static TexImage3Dproc pTexImage3D = 0;
|
||||
|
||||
#ifndef _WIN32
|
||||
#if !defined(_WIN32) && !defined(__WIN32__)
|
||||
# include <dlfcn.h>
|
||||
# include <sys/types.h>
|
||||
#else
|
||||
@@ -6642,7 +6642,7 @@ static void gluTexImage3D( GLenum target, GLint level,
|
||||
const GLvoid *pixels )
|
||||
{
|
||||
if (!pTexImage3D) {
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3D");
|
||||
if (!pTexImage3D)
|
||||
pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3DEXT");
|
||||
|
||||
@@ -126,6 +126,6 @@ depend: $(SOURCES)
|
||||
@ echo "running $(MKDEP)"
|
||||
@ touch depend
|
||||
@ $(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(SOURCES) \
|
||||
> /dev/null
|
||||
$(X11_INCLUDES) > /dev/null
|
||||
|
||||
include depend
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME): $(OBJECTS)
|
||||
depend: $(GLW_SOURCES)
|
||||
touch depend
|
||||
$(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(GLW_SOURCES) \
|
||||
> /dev/null
|
||||
$(X11_INCLUDES) > /dev/null
|
||||
|
||||
|
||||
include depend
|
||||
|
||||
@@ -32,7 +32,9 @@ SOURCES = \
|
||||
glx_texture_compression.c \
|
||||
dri_glx.c \
|
||||
XF86dri.c \
|
||||
glxhash.c
|
||||
glxhash.c \
|
||||
dri2_glx.c \
|
||||
dri2.c
|
||||
|
||||
include $(TOP)/src/mesa/sources
|
||||
|
||||
@@ -48,6 +50,7 @@ INCLUDES = -I. \
|
||||
-I$(TOP)/src/mesa/main \
|
||||
-I$(TOP)/src/mesa/glapi \
|
||||
$(LIBDRM_CFLAGS) \
|
||||
$(DRI2PROTO_CFLAGS) \
|
||||
$(X11_INCLUDES)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Copyright © 2008 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Soft-
|
||||
* ware"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, provided that the above copyright
|
||||
* notice(s) and this permission notice appear in all copies of the Soft-
|
||||
* ware and that both the above copyright notice(s) and this permission
|
||||
* notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
||||
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
||||
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
||||
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
|
||||
* MANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization of
|
||||
* the copyright holder.
|
||||
*
|
||||
* Authors:
|
||||
* Kristian Høgsberg (krh@redhat.com)
|
||||
*/
|
||||
|
||||
|
||||
#define NEED_REPLIES
|
||||
#include <X11/Xlibint.h>
|
||||
#include <X11/extensions/Xext.h>
|
||||
#include <X11/extensions/extutil.h>
|
||||
#include <X11/extensions/dri2proto.h>
|
||||
#include "glheader.h"
|
||||
#include "xf86drm.h"
|
||||
#include "dri2.h"
|
||||
|
||||
static char dri2ExtensionName[] = DRI2_NAME;
|
||||
static XExtensionInfo *dri2Info;
|
||||
static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
|
||||
static /* const */ XExtensionHooks dri2ExtensionHooks = {
|
||||
NULL, /* create_gc */
|
||||
NULL, /* copy_gc */
|
||||
NULL, /* flush_gc */
|
||||
NULL, /* free_gc */
|
||||
NULL, /* create_font */
|
||||
NULL, /* free_font */
|
||||
DRI2CloseDisplay, /* close_display */
|
||||
NULL, /* wire_to_event */
|
||||
NULL, /* event_to_wire */
|
||||
NULL, /* error */
|
||||
NULL, /* error_string */
|
||||
};
|
||||
|
||||
static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, dri2Info,
|
||||
dri2ExtensionName,
|
||||
&dri2ExtensionHooks,
|
||||
0, NULL)
|
||||
|
||||
Bool DRI2QueryExtension(Display *dpy, int *eventBase, int *errorBase)
|
||||
{
|
||||
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
|
||||
|
||||
if (XextHasExtension(info)) {
|
||||
*eventBase = info->codes->first_event;
|
||||
*errorBase = info->codes->first_error;
|
||||
return True;
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
Bool DRI2QueryVersion(Display *dpy, int *major, int *minor)
|
||||
{
|
||||
XExtDisplayInfo *info = DRI2FindDisplay (dpy);
|
||||
xDRI2QueryVersionReply rep;
|
||||
xDRI2QueryVersionReq *req;
|
||||
|
||||
XextCheckExtension (dpy, info, dri2ExtensionName, False);
|
||||
|
||||
LockDisplay(dpy);
|
||||
GetReq(DRI2QueryVersion, req);
|
||||
req->reqType = info->codes->major_opcode;
|
||||
req->dri2ReqType = X_DRI2QueryVersion;
|
||||
req->majorVersion = DRI2_MAJOR;
|
||||
req->minorVersion = DRI2_MINOR;
|
||||
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
return False;
|
||||
}
|
||||
*major = rep.majorVersion;
|
||||
*minor = rep.minorVersion;
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
Bool DRI2Connect(Display *dpy, int screen,
|
||||
char **driverName, char **busId, unsigned int *sareaHandle)
|
||||
{
|
||||
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
|
||||
xDRI2ConnectReply rep;
|
||||
xDRI2ConnectReq *req;
|
||||
|
||||
XextCheckExtension (dpy, info, dri2ExtensionName, False);
|
||||
|
||||
LockDisplay(dpy);
|
||||
GetReq(DRI2Connect, req);
|
||||
req->reqType = info->codes->major_opcode;
|
||||
req->dri2ReqType = X_DRI2Connect;
|
||||
req->screen = screen;
|
||||
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
return False;
|
||||
}
|
||||
|
||||
*sareaHandle = rep.sareaHandle;
|
||||
|
||||
*driverName = Xmalloc(rep.driverNameLength + 1);
|
||||
if (*driverName == NULL) {
|
||||
_XEatData(dpy,
|
||||
((rep.driverNameLength + 3) & ~3) +
|
||||
((rep.busIdLength + 3) & ~3));
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
return False;
|
||||
}
|
||||
_XReadPad(dpy, *driverName, rep.driverNameLength);
|
||||
(*driverName)[rep.driverNameLength] = '\0';
|
||||
|
||||
*busId = Xmalloc(rep.busIdLength + 1);
|
||||
if (*busId == NULL) {
|
||||
Xfree(*driverName);
|
||||
_XEatData(dpy, ((rep.busIdLength + 3) & ~3));
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
return False;
|
||||
}
|
||||
_XReadPad(dpy, *busId, rep.busIdLength);
|
||||
(*busId)[rep.busIdLength] = '\0';
|
||||
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
|
||||
return rep.sareaHandle != 0;
|
||||
}
|
||||
|
||||
Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic)
|
||||
{
|
||||
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
|
||||
xDRI2AuthConnectionReq *req;
|
||||
xDRI2AuthConnectionReply rep;
|
||||
|
||||
XextCheckExtension (dpy, info, dri2ExtensionName, False);
|
||||
|
||||
LockDisplay(dpy);
|
||||
GetReq(DRI2AuthConnection, req);
|
||||
req->reqType = info->codes->major_opcode;
|
||||
req->dri2ReqType = X_DRI2AuthConnection;
|
||||
req->screen = screen;
|
||||
req->magic = magic;
|
||||
rep.authenticated = 0;
|
||||
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
return False;
|
||||
}
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
|
||||
return rep.authenticated;
|
||||
}
|
||||
|
||||
Bool DRI2CreateDrawable(Display *dpy, XID drawable,
|
||||
unsigned int *handle, unsigned int *head)
|
||||
{
|
||||
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
|
||||
xDRI2CreateDrawableReply rep;
|
||||
xDRI2CreateDrawableReq *req;
|
||||
|
||||
XextCheckExtension (dpy, info, dri2ExtensionName, False);
|
||||
|
||||
LockDisplay(dpy);
|
||||
GetReq(DRI2CreateDrawable, req);
|
||||
req->reqType = info->codes->major_opcode;
|
||||
req->dri2ReqType = X_DRI2CreateDrawable;
|
||||
req->drawable = drawable;
|
||||
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
return False;
|
||||
}
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
|
||||
*handle = rep.handle;
|
||||
*head = rep.head;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
void DRI2DestroyDrawable(Display *dpy, XID drawable)
|
||||
{
|
||||
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
|
||||
xDRI2DestroyDrawableReq *req;
|
||||
|
||||
XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
|
||||
|
||||
XSync(dpy, GL_FALSE);
|
||||
|
||||
LockDisplay(dpy);
|
||||
GetReq(DRI2DestroyDrawable, req);
|
||||
req->reqType = info->codes->major_opcode;
|
||||
req->dri2ReqType = X_DRI2DestroyDrawable;
|
||||
req->drawable = drawable;
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
}
|
||||
|
||||
Bool DRI2ReemitDrawableInfo(Display *dpy, XID drawable, unsigned int *head)
|
||||
{
|
||||
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
|
||||
xDRI2ReemitDrawableInfoReply rep;
|
||||
xDRI2ReemitDrawableInfoReq *req;
|
||||
|
||||
XextCheckExtension (dpy, info, dri2ExtensionName, False);
|
||||
|
||||
LockDisplay(dpy);
|
||||
GetReq(DRI2ReemitDrawableInfo, req);
|
||||
req->reqType = info->codes->major_opcode;
|
||||
req->dri2ReqType = X_DRI2ReemitDrawableInfo;
|
||||
req->drawable = drawable;
|
||||
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
return False;
|
||||
}
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
|
||||
*head = rep.head;
|
||||
|
||||
return True;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright © 2007,2008 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Soft-
|
||||
* ware"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, provided that the above copyright
|
||||
* notice(s) and this permission notice appear in all copies of the Soft-
|
||||
* ware and that both the above copyright notice(s) and this permission
|
||||
* notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
||||
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
||||
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
||||
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
|
||||
* MANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization of
|
||||
* the copyright holder.
|
||||
*
|
||||
* Authors:
|
||||
* Kristian Høgsberg (krh@redhat.com)
|
||||
*/
|
||||
|
||||
#ifndef _DRI2_H_
|
||||
#define _DRI2_H_
|
||||
|
||||
extern Bool
|
||||
DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
|
||||
extern Bool
|
||||
DRI2QueryVersion(Display *display, int *major, int *minor);
|
||||
extern Bool
|
||||
DRI2Connect(Display *display, int screen,
|
||||
char **driverName, char **busId, unsigned int *sareaHandle);
|
||||
extern Bool
|
||||
DRI2AuthConnection(Display *display, int screen, drm_magic_t magic);
|
||||
extern Bool
|
||||
DRI2CreateDrawable(Display *display, XID drawable,
|
||||
unsigned int *handle, unsigned int *head);
|
||||
extern void
|
||||
DRI2DestroyDrawable(Display *display, XID handle);
|
||||
extern Bool
|
||||
DRI2ReemitDrawableInfo(Display *dpy, XID handle, unsigned int *head);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,471 @@
|
||||
/*
|
||||
* Copyright © 2008 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Soft-
|
||||
* ware"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, provided that the above copyright
|
||||
* notice(s) and this permission notice appear in all copies of the Soft-
|
||||
* ware and that both the above copyright notice(s) and this permission
|
||||
* notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
||||
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
||||
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
||||
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
|
||||
* MANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization of
|
||||
* the copyright holder.
|
||||
*
|
||||
* Authors:
|
||||
* Kristian Høgsberg (krh@redhat.com)
|
||||
*/
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
#include <unistd.h>
|
||||
#include <X11/Xlibint.h>
|
||||
#include <X11/extensions/Xext.h>
|
||||
#include <X11/extensions/extutil.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#include <X11/extensions/Xdamage.h>
|
||||
#include "glheader.h"
|
||||
#include "glxclient.h"
|
||||
#include "xf86dri.h"
|
||||
#include "sarea.h"
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#include "glcontextmodes.h"
|
||||
#include <sys/mman.h>
|
||||
#include "xf86drm.h"
|
||||
#include "dri2.h"
|
||||
|
||||
|
||||
#ifndef RTLD_NOW
|
||||
#define RTLD_NOW 0
|
||||
#endif
|
||||
#ifndef RTLD_GLOBAL
|
||||
#define RTLD_GLOBAL 0
|
||||
#endif
|
||||
|
||||
typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
|
||||
typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
|
||||
typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate;
|
||||
|
||||
struct __GLXDRIdisplayPrivateRec {
|
||||
__GLXDRIdisplay base;
|
||||
|
||||
/*
|
||||
** XFree86-DRI version information
|
||||
*/
|
||||
int driMajor;
|
||||
int driMinor;
|
||||
int driPatch;
|
||||
};
|
||||
|
||||
struct __GLXDRIcontextPrivateRec {
|
||||
__GLXDRIcontext base;
|
||||
__DRIcontext *driContext;
|
||||
__GLXscreenConfigs *psc;
|
||||
};
|
||||
|
||||
struct __GLXDRIconfigPrivateRec {
|
||||
__GLcontextModes modes;
|
||||
const __DRIconfig *driConfig;
|
||||
};
|
||||
|
||||
static void dri2DestroyContext(__GLXDRIcontext *context,
|
||||
__GLXscreenConfigs *psc, Display *dpy)
|
||||
{
|
||||
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
|
||||
const __DRIcoreExtension *core = pcp->psc->core;
|
||||
|
||||
(*core->destroyContext)(pcp->driContext);
|
||||
|
||||
Xfree(pcp);
|
||||
}
|
||||
|
||||
static Bool dri2BindContext(__GLXDRIcontext *context,
|
||||
__GLXDRIdrawable *draw, __GLXDRIdrawable *read)
|
||||
{
|
||||
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
|
||||
const __DRIcoreExtension *core = pcp->psc->core;
|
||||
|
||||
return (*core->bindContext)(pcp->driContext,
|
||||
draw->driDrawable,
|
||||
read->driDrawable);
|
||||
}
|
||||
|
||||
static void dri2UnbindContext(__GLXDRIcontext *context)
|
||||
{
|
||||
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
|
||||
const __DRIcoreExtension *core = pcp->psc->core;
|
||||
|
||||
(*core->unbindContext)(pcp->driContext);
|
||||
}
|
||||
|
||||
static __GLXDRIcontext *dri2CreateContext(__GLXscreenConfigs *psc,
|
||||
const __GLcontextModes *mode,
|
||||
GLXContext gc,
|
||||
GLXContext shareList, int renderType)
|
||||
{
|
||||
__GLXDRIcontextPrivate *pcp, *pcp_shared;
|
||||
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
|
||||
const __DRIcoreExtension *core = psc->core;
|
||||
__DRIcontext *shared = NULL;
|
||||
|
||||
if (shareList) {
|
||||
pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
|
||||
shared = pcp_shared->driContext;
|
||||
}
|
||||
|
||||
pcp = Xmalloc(sizeof *pcp);
|
||||
if (pcp == NULL)
|
||||
return NULL;
|
||||
|
||||
pcp->psc = psc;
|
||||
pcp->driContext =
|
||||
(*core->createNewContext)(psc->__driScreen,
|
||||
config->driConfig, shared, pcp);
|
||||
gc->__driContext = pcp->driContext;
|
||||
|
||||
if (pcp->driContext == NULL) {
|
||||
Xfree(pcp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcp->base.destroyContext = dri2DestroyContext;
|
||||
pcp->base.bindContext = dri2BindContext;
|
||||
pcp->base.unbindContext = dri2UnbindContext;
|
||||
|
||||
return &pcp->base;
|
||||
}
|
||||
|
||||
static void dri2DestroyDrawable(__GLXDRIdrawable *pdraw)
|
||||
{
|
||||
const __DRIcoreExtension *core = pdraw->psc->core;
|
||||
|
||||
(*core->destroyDrawable)(pdraw->driDrawable);
|
||||
DRI2DestroyDrawable(pdraw->psc->dpy, pdraw->drawable);
|
||||
Xfree(pdraw);
|
||||
}
|
||||
|
||||
static __GLXDRIdrawable *dri2CreateDrawable(__GLXscreenConfigs *psc,
|
||||
XID xDrawable,
|
||||
GLXDrawable drawable,
|
||||
const __GLcontextModes *modes)
|
||||
{
|
||||
__GLXDRIdrawable *pdraw;
|
||||
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
|
||||
unsigned int handle, head;
|
||||
const __DRIcoreExtension *core = psc->core;
|
||||
|
||||
pdraw = Xmalloc(sizeof(*pdraw));
|
||||
if (!pdraw)
|
||||
return NULL;
|
||||
|
||||
pdraw->destroyDrawable = dri2DestroyDrawable;
|
||||
pdraw->xDrawable = xDrawable;
|
||||
pdraw->drawable = drawable;
|
||||
pdraw->psc = psc;
|
||||
|
||||
fprintf(stderr, "calling DRI2CreateDrawable, XID 0x%lx, GLX ID 0x%lx\n",
|
||||
xDrawable, drawable);
|
||||
|
||||
if (!DRI2CreateDrawable(psc->dpy, xDrawable, &handle, &head)) {
|
||||
Xfree(pdraw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fprintf(stderr, "success, head 0x%x, handle 0x%x\n", head, handle);
|
||||
|
||||
/* Create a new drawable */
|
||||
pdraw->driDrawable =
|
||||
(*core->createNewDrawable)(psc->__driScreen,
|
||||
config->driConfig,
|
||||
handle,
|
||||
head,
|
||||
pdraw);
|
||||
|
||||
if (!pdraw->driDrawable) {
|
||||
DRI2DestroyDrawable(psc->dpy, drawable);
|
||||
Xfree(pdraw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pdraw;
|
||||
}
|
||||
|
||||
static void dri2DestroyScreen(__GLXscreenConfigs *psc)
|
||||
{
|
||||
/* Free the direct rendering per screen data */
|
||||
(*psc->core->destroyScreen)(psc->__driScreen);
|
||||
drmClose(psc->fd);
|
||||
psc->__driScreen = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void dri2ReemitDrawableInfo(__DRIdrawable *draw, unsigned int *tail,
|
||||
void *loaderPrivate)
|
||||
{
|
||||
__GLXDRIdrawable *pdraw = loaderPrivate;
|
||||
|
||||
DRI2ReemitDrawableInfo(pdraw->psc->dpy, pdraw->drawable, tail);
|
||||
}
|
||||
|
||||
static void dri2PostDamage(__DRIdrawable *draw,
|
||||
struct drm_clip_rect *rects,
|
||||
int numRects, void *loaderPrivate)
|
||||
{
|
||||
XRectangle *xrects;
|
||||
XserverRegion region;
|
||||
__GLXDRIdrawable *glxDraw = loaderPrivate;
|
||||
__GLXscreenConfigs *psc = glxDraw->psc;
|
||||
Display *dpy = psc->dpy;
|
||||
int i;
|
||||
|
||||
xrects = malloc(sizeof(XRectangle) * numRects);
|
||||
if (xrects == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < numRects; i++) {
|
||||
xrects[i].x = rects[i].x1;
|
||||
xrects[i].y = rects[i].y1;
|
||||
xrects[i].width = rects[i].x2 - rects[i].x1;
|
||||
xrects[i].height = rects[i].y2 - rects[i].y1;
|
||||
}
|
||||
region = XFixesCreateRegion(dpy, xrects, numRects);
|
||||
free(xrects);
|
||||
XDamageAdd(dpy, glxDraw->xDrawable, region);
|
||||
XFixesDestroyRegion(dpy, region);
|
||||
}
|
||||
|
||||
static const __DRIloaderExtension dri2LoaderExtension = {
|
||||
{ __DRI_LOADER, __DRI_LOADER_VERSION },
|
||||
dri2ReemitDrawableInfo,
|
||||
dri2PostDamage
|
||||
};
|
||||
|
||||
_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension;
|
||||
|
||||
static const __DRIextension *loader_extensions[] = {
|
||||
&dri2LoaderExtension.base,
|
||||
&systemTimeExtension.base,
|
||||
NULL
|
||||
};
|
||||
|
||||
/* We need a dri_common.h type-of-thing. */
|
||||
|
||||
extern void ErrorMessageF(const char *f, ...);
|
||||
|
||||
extern void *driOpenDriver(const char *driverName);
|
||||
|
||||
extern __GLcontextModes *
|
||||
driConvertConfigs(const __DRIcoreExtension *core,
|
||||
__GLcontextModes *modes, const __DRIconfig **configs);
|
||||
|
||||
extern void driBindExtensions(__GLXscreenConfigs *psc);
|
||||
|
||||
void
|
||||
driBindExtensions(__GLXscreenConfigs *psc)
|
||||
{
|
||||
const __DRIextension **extensions;
|
||||
int i;
|
||||
|
||||
extensions = psc->core->getExtensions(psc->__driScreen);
|
||||
|
||||
for (i = 0; extensions[i]; i++) {
|
||||
#ifdef __DRI_COPY_SUB_BUFFER
|
||||
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
|
||||
psc->copySubBuffer = (__DRIcopySubBufferExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer_bit");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_SWAP_CONTROL
|
||||
if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
|
||||
psc->swapControl = (__DRIswapControlExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(psc, "GLX_SGI_swap_control");
|
||||
__glXEnableDirectExtension(psc, "GLX_MESA_swap_control");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_ALLOCATE
|
||||
if (strcmp(extensions[i]->name, __DRI_ALLOCATE) == 0) {
|
||||
psc->allocate = (__DRIallocateExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(psc, "GLX_MESA_allocate_memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_FRAME_TRACKING
|
||||
if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) {
|
||||
psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(psc, "GLX_MESA_swap_frame_usage");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_MEDIA_STREAM_COUNTER
|
||||
if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
|
||||
psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(psc, "GLX_SGI_video_sync");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_SWAP_BUFFER_COUNTER
|
||||
/* No driver supports this at this time and the extension is
|
||||
* not defined in dri_interface.h. Will enable
|
||||
* GLX_OML_sync_control if implemented. */
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_READ_DRAWABLE
|
||||
if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
|
||||
__glXEnableDirectExtension(psc, "GLX_SGI_make_current_read");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_TEX_BUFFER
|
||||
if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) {
|
||||
psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
|
||||
__glXEnableDirectExtension(psc, "GLX_EXT_texture_from_pixmap");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Ignore unknown extensions */
|
||||
}
|
||||
}
|
||||
|
||||
static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
|
||||
__GLXdisplayPrivate *priv)
|
||||
{
|
||||
const __DRIconfig **driver_configs;
|
||||
const __DRIextension **extensions;
|
||||
__GLXDRIscreen *psp;
|
||||
unsigned int sareaHandle;
|
||||
char *driverName, *busID;
|
||||
drm_magic_t magic;
|
||||
int i;
|
||||
|
||||
psp = Xmalloc(sizeof *psp);
|
||||
if (psp == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Initialize per screen dynamic client GLX extensions */
|
||||
psc->ext_list_first_time = GL_TRUE;
|
||||
|
||||
if (!DRI2Connect(psc->dpy, screen, &driverName, &busID, &sareaHandle))
|
||||
return NULL;
|
||||
|
||||
psc->driver = driOpenDriver(driverName);
|
||||
if (psc->driver == NULL)
|
||||
goto handle_error;
|
||||
|
||||
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
|
||||
if (extensions == NULL) {
|
||||
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
for (i = 0; extensions[i]; i++) {
|
||||
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
|
||||
psc->core = (__DRIcoreExtension *) extensions[i];
|
||||
}
|
||||
|
||||
if (psc->core == NULL) {
|
||||
ErrorMessageF("core dri extension not found\n");
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
psc->fd = drmOpen(NULL, busID);
|
||||
if (psc->fd < 0) {
|
||||
ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (drmGetMagic(psc->fd, &magic))
|
||||
return NULL;
|
||||
|
||||
if (!DRI2AuthConnection(psc->dpy, screen, magic)) {
|
||||
ErrorMessageF("failed to authenticate drm access\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
psc->__driScreen =
|
||||
psc->core->createNewScreen(screen, psc->fd, sareaHandle,
|
||||
loader_extensions, &driver_configs, psc);
|
||||
if (psc->__driScreen == NULL) {
|
||||
ErrorMessageF("failed to create dri screen\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
driBindExtensions(psc);
|
||||
|
||||
psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
|
||||
psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
|
||||
|
||||
psp->destroyScreen = dri2DestroyScreen;
|
||||
psp->createContext = dri2CreateContext;
|
||||
psp->createDrawable = dri2CreateDrawable;
|
||||
|
||||
Xfree(driverName);
|
||||
Xfree(busID);
|
||||
|
||||
return psp;
|
||||
|
||||
handle_error:
|
||||
Xfree(driverName);
|
||||
Xfree(busID);
|
||||
|
||||
/* FIXME: clean up here */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Called from __glXFreeDisplayPrivate.
|
||||
*/
|
||||
static void dri2DestroyDisplay(__GLXDRIdisplay *dpy)
|
||||
{
|
||||
Xfree(dpy);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate, initialize and return a __DRIdisplayPrivate object.
|
||||
* This is called from __glXInitialize() when we are given a new
|
||||
* display pointer.
|
||||
*/
|
||||
_X_HIDDEN __GLXDRIdisplay *dri2CreateDisplay(Display *dpy)
|
||||
{
|
||||
__GLXDRIdisplayPrivate *pdp;
|
||||
int eventBase, errorBase;
|
||||
|
||||
if (!DRI2QueryExtension(dpy, &eventBase, &errorBase))
|
||||
return NULL;
|
||||
|
||||
pdp = Xmalloc(sizeof *pdp);
|
||||
if (pdp == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!DRI2QueryVersion(dpy, &pdp->driMajor, &pdp->driMinor)) {
|
||||
Xfree(pdp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdp->driPatch = 0;
|
||||
|
||||
pdp->base.destroyDisplay = dri2DestroyDisplay;
|
||||
pdp->base.createScreen = dri2CreateScreen;
|
||||
|
||||
return &pdp->base;
|
||||
}
|
||||
|
||||
#endif /* GLX_DIRECT_RENDERING */
|
||||
+302
-92
@@ -52,7 +52,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include <sys/mman.h>
|
||||
#include "xf86drm.h"
|
||||
|
||||
|
||||
#ifndef RTLD_NOW
|
||||
#define RTLD_NOW 0
|
||||
#endif
|
||||
@@ -62,6 +61,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
|
||||
typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
|
||||
typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate;
|
||||
|
||||
struct __GLXDRIdisplayPrivateRec {
|
||||
__GLXDRIdisplay base;
|
||||
@@ -76,8 +76,14 @@ struct __GLXDRIdisplayPrivateRec {
|
||||
|
||||
struct __GLXDRIcontextPrivateRec {
|
||||
__GLXDRIcontext base;
|
||||
__DRIcontext driContext;
|
||||
__DRIcontext *driContext;
|
||||
XID hwContextID;
|
||||
__GLXscreenConfigs *psc;
|
||||
};
|
||||
|
||||
struct __GLXDRIconfigPrivateRec {
|
||||
__GLcontextModes modes;
|
||||
const __DRIconfig *driConfig;
|
||||
};
|
||||
|
||||
#ifndef DEFAULT_DRIVER_DIR
|
||||
@@ -98,10 +104,12 @@ static void InfoMessageF(const char *f, ...)
|
||||
}
|
||||
}
|
||||
|
||||
extern void ErrorMessageF(const char *f, ...);
|
||||
|
||||
/**
|
||||
* Print error to stderr, unless LIBGL_DEBUG=="quiet".
|
||||
*/
|
||||
static void ErrorMessageF(const char *f, ...)
|
||||
_X_HIDDEN void ErrorMessageF(const char *f, ...)
|
||||
{
|
||||
va_list args;
|
||||
const char *env;
|
||||
@@ -114,16 +122,7 @@ static void ErrorMessageF(const char *f, ...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Versioned name of the expected \c __driCreateNewScreen function.
|
||||
*
|
||||
* The version of the last incompatible loader/driver inteface change is
|
||||
* appended to the name of the \c __driCreateNewScreen function. This
|
||||
* prevents loaders from trying to load drivers that are too old.
|
||||
*/
|
||||
static const char createNewScreenName[] = __DRI_CREATE_NEW_SCREEN_STRING;
|
||||
|
||||
extern void *driOpenDriver(const char *driverName);
|
||||
|
||||
/**
|
||||
* Try to \c dlopen the named driver.
|
||||
@@ -137,7 +136,7 @@ static const char createNewScreenName[] = __DRI_CREATE_NEW_SCREEN_STRING;
|
||||
* \returns
|
||||
* A handle from \c dlopen, or \c NULL if driver file not found.
|
||||
*/
|
||||
static void *OpenDriver(const char *driverName)
|
||||
_X_HIDDEN void *driOpenDriver(const char *driverName)
|
||||
{
|
||||
void *glhandle, *handle;
|
||||
const char *libPaths, *p, *next;
|
||||
@@ -244,7 +243,7 @@ static void *driGetDriver(Display *dpy, int scrNum)
|
||||
void *ret;
|
||||
|
||||
if (GetDriverName(dpy, scrNum, &driverName)) {
|
||||
ret = OpenDriver(driverName);
|
||||
ret = driOpenDriver(driverName);
|
||||
if (driverName)
|
||||
Xfree(driverName);
|
||||
return ret;
|
||||
@@ -287,17 +286,22 @@ PUBLIC const char *glXGetScreenDriver (Display *dpy, int scrNum) {
|
||||
*
|
||||
* Note: The driver remains opened after this function returns.
|
||||
*/
|
||||
PUBLIC const char *glXGetDriverConfig (const char *driverName) {
|
||||
void *handle = OpenDriver (driverName);
|
||||
PUBLIC const char *glXGetDriverConfig (const char *driverName)
|
||||
{
|
||||
void *handle = driOpenDriver (driverName);
|
||||
if (handle)
|
||||
return dlsym (handle, "__driConfigOptions");
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
filter_modes( __GLcontextModes ** server_modes,
|
||||
const __GLcontextModes * driver_modes )
|
||||
extern void
|
||||
driFilterModes(__GLcontextModes ** server_modes,
|
||||
const __GLcontextModes * driver_modes);
|
||||
|
||||
_X_HIDDEN void
|
||||
driFilterModes(__GLcontextModes ** server_modes,
|
||||
const __GLcontextModes * driver_modes)
|
||||
{
|
||||
__GLcontextModes * m;
|
||||
__GLcontextModes ** prev_next;
|
||||
@@ -349,6 +353,7 @@ filter_modes( __GLcontextModes ** server_modes,
|
||||
}
|
||||
|
||||
#ifdef XDAMAGE_1_1_INTERFACE
|
||||
|
||||
static GLboolean has_damage_post(Display *dpy)
|
||||
{
|
||||
static GLboolean inited = GL_FALSE;
|
||||
@@ -369,20 +374,18 @@ static GLboolean has_damage_post(Display *dpy)
|
||||
|
||||
return has_damage;
|
||||
}
|
||||
#endif /* XDAMAGE_1_1_INTERFACE */
|
||||
|
||||
static void __glXReportDamage(__DRIdrawable *driDraw,
|
||||
int x, int y,
|
||||
drm_clip_rect_t *rects, int num_rects,
|
||||
GLboolean front_buffer)
|
||||
GLboolean front_buffer,
|
||||
void *loaderPrivate)
|
||||
{
|
||||
#ifdef XDAMAGE_1_1_INTERFACE
|
||||
XRectangle *xrects;
|
||||
XserverRegion region;
|
||||
int i;
|
||||
int x_off, y_off;
|
||||
__GLXDRIdrawable *glxDraw =
|
||||
containerOf(driDraw, __GLXDRIdrawable, driDrawable);
|
||||
__GLXDRIdrawable *glxDraw = loaderPrivate;
|
||||
__GLXscreenConfigs *psc = glxDraw->psc;
|
||||
Display *dpy = psc->dpy;
|
||||
Drawable drawable;
|
||||
@@ -397,7 +400,7 @@ static void __glXReportDamage(__DRIdrawable *driDraw,
|
||||
} else{
|
||||
x_off = 0;
|
||||
y_off = 0;
|
||||
drawable = glxDraw->drawable;
|
||||
drawable = glxDraw->xDrawable;
|
||||
}
|
||||
|
||||
xrects = malloc(sizeof(XRectangle) * num_rects);
|
||||
@@ -414,19 +417,25 @@ static void __glXReportDamage(__DRIdrawable *driDraw,
|
||||
free(xrects);
|
||||
XDamageAdd(dpy, drawable, region);
|
||||
XFixesDestroyRegion(dpy, region);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const __DRIdamageExtension damageExtension = {
|
||||
{ __DRI_DAMAGE, __DRI_DAMAGE_VERSION },
|
||||
__glXReportDamage,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static GLboolean
|
||||
__glXDRIGetDrawableInfo(__DRIdrawable *drawable,
|
||||
unsigned int *index, unsigned int *stamp,
|
||||
int *X, int *Y, int *W, int *H,
|
||||
int *numClipRects, drm_clip_rect_t ** pClipRects,
|
||||
int *backX, int *backY,
|
||||
int *numBackClipRects, drm_clip_rect_t **pBackClipRects)
|
||||
int *numBackClipRects, drm_clip_rect_t **pBackClipRects,
|
||||
void *loaderPrivate)
|
||||
{
|
||||
__GLXDRIdrawable *glxDraw =
|
||||
containerOf(drawable, __GLXDRIdrawable, driDrawable);
|
||||
__GLXDRIdrawable *glxDraw = loaderPrivate;
|
||||
__GLXscreenConfigs *psc = glxDraw->psc;
|
||||
Display *dpy = psc->dpy;
|
||||
|
||||
@@ -437,17 +446,7 @@ __glXDRIGetDrawableInfo(__DRIdrawable *drawable,
|
||||
numBackClipRects, pBackClipRects);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Table of functions exported by the loader to the driver.
|
||||
*/
|
||||
static const __DRIcontextModesExtension contextModesExtension = {
|
||||
{ __DRI_CONTEXT_MODES, __DRI_CONTEXT_MODES_VERSION },
|
||||
_gl_context_modes_create,
|
||||
_gl_context_modes_destroy,
|
||||
};
|
||||
|
||||
static const __DRIsystemTimeExtension systemTimeExtension = {
|
||||
_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = {
|
||||
{ __DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION },
|
||||
__glXGetUST,
|
||||
__driGetMscRateOML,
|
||||
@@ -458,19 +457,187 @@ static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = {
|
||||
__glXDRIGetDrawableInfo
|
||||
};
|
||||
|
||||
static const __DRIdamageExtension damageExtension = {
|
||||
{ __DRI_DAMAGE, __DRI_DAMAGE_VERSION },
|
||||
__glXReportDamage,
|
||||
};
|
||||
|
||||
static const __DRIextension *loader_extensions[] = {
|
||||
&contextModesExtension.base,
|
||||
&systemTimeExtension.base,
|
||||
&getDrawableInfoExtension.base,
|
||||
|
||||
#ifdef XDAMAGE_1_1_INTERFACE
|
||||
&damageExtension.base,
|
||||
#endif
|
||||
|
||||
NULL
|
||||
};
|
||||
|
||||
#define __ATTRIB(attrib, field) \
|
||||
{ attrib, offsetof(__GLcontextModes, field) }
|
||||
|
||||
static const struct { unsigned int attrib, offset; } attribMap[] = {
|
||||
__ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits),
|
||||
__ATTRIB(__DRI_ATTRIB_LEVEL, level),
|
||||
__ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits),
|
||||
__ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits),
|
||||
__ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits),
|
||||
__ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits),
|
||||
__ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits),
|
||||
__ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers),
|
||||
__ATTRIB(__DRI_ATTRIB_SAMPLES, samples),
|
||||
__ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode),
|
||||
__ATTRIB(__DRI_ATTRIB_STEREO, stereoMode),
|
||||
__ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers),
|
||||
#if 0
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentIndex),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
|
||||
__ATTRIB(__DRI_ATTRIB_RED_MASK, redMask),
|
||||
__ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask),
|
||||
__ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask),
|
||||
__ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask),
|
||||
#endif
|
||||
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
|
||||
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
|
||||
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
|
||||
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
|
||||
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
|
||||
#if 0
|
||||
__ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
|
||||
#endif
|
||||
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
|
||||
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
|
||||
__ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, bindToMipmapTexture),
|
||||
__ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
|
||||
};
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
|
||||
static int
|
||||
scalarEqual(__GLcontextModes *mode, unsigned int attrib, unsigned int value)
|
||||
{
|
||||
unsigned int glxValue;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(attribMap); i++)
|
||||
if (attribMap[i].attrib == attrib) {
|
||||
glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset);
|
||||
return glxValue == GLX_DONT_CARE || glxValue == value;
|
||||
}
|
||||
|
||||
return GL_TRUE; /* Is a non-existing attribute equal to value? */
|
||||
}
|
||||
|
||||
static int
|
||||
driConfigEqual(const __DRIcoreExtension *core,
|
||||
__GLcontextModes *modes, const __DRIconfig *driConfig)
|
||||
{
|
||||
unsigned int attrib, value, glxValue;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
|
||||
switch (attrib) {
|
||||
case __DRI_ATTRIB_RENDER_TYPE:
|
||||
glxValue = 0;
|
||||
if (value & __DRI_ATTRIB_RGBA_BIT) {
|
||||
glxValue |= GLX_RGBA_BIT;
|
||||
} else if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) {
|
||||
glxValue |= GLX_COLOR_INDEX_BIT;
|
||||
}
|
||||
if (glxValue != modes->renderType)
|
||||
return GL_FALSE;
|
||||
break;
|
||||
|
||||
case __DRI_ATTRIB_CONFIG_CAVEAT:
|
||||
if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
|
||||
glxValue = GLX_NON_CONFORMANT_CONFIG;
|
||||
else if (value & __DRI_ATTRIB_SLOW_BIT)
|
||||
glxValue = GLX_SLOW_CONFIG;
|
||||
else
|
||||
glxValue = GLX_NONE;
|
||||
if (glxValue != modes->visualRating)
|
||||
return GL_FALSE;
|
||||
break;
|
||||
|
||||
case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS:
|
||||
glxValue = 0;
|
||||
if (value & __DRI_ATTRIB_TEXTURE_1D_BIT)
|
||||
glxValue |= GLX_TEXTURE_1D_BIT_EXT;
|
||||
if (value & __DRI_ATTRIB_TEXTURE_2D_BIT)
|
||||
glxValue |= GLX_TEXTURE_2D_BIT_EXT;
|
||||
if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
|
||||
glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
|
||||
if (modes->bindToTextureTargets != GLX_DONT_CARE &&
|
||||
glxValue != modes->bindToTextureTargets)
|
||||
return GL_FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!scalarEqual(modes, attrib, value))
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static __GLcontextModes *
|
||||
createDriMode(const __DRIcoreExtension *core,
|
||||
__GLcontextModes *modes, const __DRIconfig **driConfigs)
|
||||
{
|
||||
__GLXDRIconfigPrivate *config;
|
||||
int i;
|
||||
|
||||
for (i = 0; driConfigs[i]; i++) {
|
||||
if (driConfigEqual(core, modes, driConfigs[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (driConfigs[i] == NULL)
|
||||
return NULL;
|
||||
|
||||
config = Xmalloc(sizeof *config);
|
||||
if (config == NULL)
|
||||
return NULL;
|
||||
|
||||
config->modes = *modes;
|
||||
config->driConfig = driConfigs[i];
|
||||
|
||||
return &config->modes;
|
||||
}
|
||||
|
||||
extern __GLcontextModes *
|
||||
driConvertConfigs(const __DRIcoreExtension *core,
|
||||
__GLcontextModes *modes, const __DRIconfig **configs);
|
||||
|
||||
_X_HIDDEN __GLcontextModes *
|
||||
driConvertConfigs(const __DRIcoreExtension *core,
|
||||
__GLcontextModes *modes, const __DRIconfig **configs)
|
||||
{
|
||||
__GLcontextModes head, *tail, *m;
|
||||
|
||||
tail = &head;
|
||||
head.next = NULL;
|
||||
for (m = modes; m; m = m->next) {
|
||||
tail->next = createDriMode(core, m, configs);
|
||||
if (tail->next == NULL) {
|
||||
/* no matching dri config for m */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
tail = tail->next;
|
||||
}
|
||||
|
||||
_gl_context_modes_destroy(modes);
|
||||
|
||||
return head.next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the required libGL-side initialization and call the client-side
|
||||
@@ -491,8 +658,7 @@ static const __DRIextension *loader_extensions[] = {
|
||||
*/
|
||||
static void *
|
||||
CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
|
||||
__GLXDRIdisplayPrivate * driDpy,
|
||||
PFNCREATENEWSCREENFUNC createNewScreen)
|
||||
__GLXDRIdisplayPrivate * driDpy)
|
||||
{
|
||||
void *psp = NULL;
|
||||
#ifndef GLX_USE_APPLEGL
|
||||
@@ -507,12 +673,12 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
|
||||
int status;
|
||||
const char * err_msg;
|
||||
const char * err_extra;
|
||||
const __DRIconfig **driver_configs;
|
||||
|
||||
dri_version.major = driDpy->driMajor;
|
||||
dri_version.minor = driDpy->driMinor;
|
||||
dri_version.patch = driDpy->driPatch;
|
||||
|
||||
|
||||
err_msg = "XF86DRIOpenConnection";
|
||||
err_extra = NULL;
|
||||
|
||||
@@ -608,12 +774,9 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
|
||||
err_extra = strerror( -status );
|
||||
|
||||
if ( status == 0 ) {
|
||||
__GLcontextModes * driver_modes = NULL;
|
||||
|
||||
err_msg = "InitDriver";
|
||||
err_extra = NULL;
|
||||
psp = (*createNewScreen)(scrn,
|
||||
&psc->__driScreen,
|
||||
psp = (*psc->legacy->createNewScreen)(scrn,
|
||||
& ddx_version,
|
||||
& dri_version,
|
||||
& drm_version,
|
||||
@@ -621,11 +784,19 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
|
||||
pSAREA,
|
||||
fd,
|
||||
loader_extensions,
|
||||
& driver_modes );
|
||||
& driver_configs,
|
||||
psc);
|
||||
|
||||
filter_modes(&psc->configs, driver_modes);
|
||||
filter_modes(&psc->visuals, driver_modes);
|
||||
_gl_context_modes_destroy(driver_modes);
|
||||
if (psp) {
|
||||
psc->configs =
|
||||
driConvertConfigs(psc->core,
|
||||
psc->configs,
|
||||
driver_configs);
|
||||
psc->visuals =
|
||||
driConvertConfigs(psc->core,
|
||||
psc->visuals,
|
||||
driver_configs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -674,7 +845,7 @@ static void driDestroyContext(__GLXDRIcontext *context,
|
||||
{
|
||||
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
|
||||
|
||||
(*pcp->driContext.destroyContext)(&pcp->driContext);
|
||||
(*psc->core->destroyContext)(pcp->driContext);
|
||||
|
||||
XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
|
||||
}
|
||||
@@ -683,17 +854,19 @@ static Bool driBindContext(__GLXDRIcontext *context,
|
||||
__GLXDRIdrawable *draw, __GLXDRIdrawable *read)
|
||||
{
|
||||
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
|
||||
const __DRIcoreExtension *core = pcp->psc->core;
|
||||
|
||||
return (*pcp->driContext.bindContext)(&pcp->driContext,
|
||||
&draw->driDrawable,
|
||||
&read->driDrawable);
|
||||
return (*core->bindContext)(pcp->driContext,
|
||||
draw->driDrawable,
|
||||
read->driDrawable);
|
||||
}
|
||||
|
||||
static void driUnbindContext(__GLXDRIcontext *context)
|
||||
{
|
||||
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
|
||||
const __DRIcoreExtension *core = pcp->psc->core;
|
||||
|
||||
(*pcp->driContext.unbindContext)(&pcp->driContext);
|
||||
(*core->unbindContext)(pcp->driContext);
|
||||
}
|
||||
|
||||
static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
|
||||
@@ -704,17 +877,19 @@ static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
|
||||
__GLXDRIcontextPrivate *pcp, *pcp_shared;
|
||||
drm_context_t hwContext;
|
||||
__DRIcontext *shared = NULL;
|
||||
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
|
||||
|
||||
if (psc && psc->driScreen) {
|
||||
if (shareList) {
|
||||
pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
|
||||
shared = &pcp_shared->driContext;
|
||||
shared = pcp_shared->driContext;
|
||||
}
|
||||
|
||||
pcp = Xmalloc(sizeof *pcp);
|
||||
if (pcp == NULL)
|
||||
return NULL;
|
||||
|
||||
pcp->psc = psc;
|
||||
if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr,
|
||||
mode->visualID,
|
||||
&pcp->hwContextID, &hwContext)) {
|
||||
@@ -722,13 +897,14 @@ static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcp->driContext.private =
|
||||
(*psc->__driScreen.createNewContext)(&psc->__driScreen,
|
||||
mode, renderType,
|
||||
shared,
|
||||
hwContext,
|
||||
&pcp->driContext);
|
||||
if (pcp->driContext.private == NULL) {
|
||||
pcp->driContext =
|
||||
(*psc->legacy->createNewContext)(psc->__driScreen,
|
||||
config->driConfig,
|
||||
renderType,
|
||||
shared,
|
||||
hwContext,
|
||||
pcp);
|
||||
if (pcp->driContext == NULL) {
|
||||
XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
|
||||
Xfree(pcp);
|
||||
return NULL;
|
||||
@@ -748,18 +924,24 @@ static void driDestroyDrawable(__GLXDRIdrawable *pdraw)
|
||||
{
|
||||
__GLXscreenConfigs *psc = pdraw->psc;
|
||||
|
||||
(*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable);
|
||||
(*psc->core->destroyDrawable)(pdraw->driDrawable);
|
||||
XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable);
|
||||
Xfree(pdraw);
|
||||
}
|
||||
|
||||
static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
|
||||
XID xDrawable,
|
||||
GLXDrawable drawable,
|
||||
GLXContext gc)
|
||||
const __GLcontextModes *modes)
|
||||
{
|
||||
__GLXDRIdrawable *pdraw;
|
||||
drm_drawable_t hwDrawable;
|
||||
void *empty_attribute_list = NULL;
|
||||
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
|
||||
|
||||
/* Old dri can't handle GLX 1.3+ drawable constructors. */
|
||||
if (xDrawable != drawable)
|
||||
return NULL;
|
||||
|
||||
pdraw = Xmalloc(sizeof(*pdraw));
|
||||
if (!pdraw)
|
||||
@@ -772,16 +954,15 @@ static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
|
||||
return NULL;
|
||||
|
||||
/* Create a new drawable */
|
||||
pdraw->driDrawable.private =
|
||||
(*psc->__driScreen.createNewDrawable)(&psc->__driScreen,
|
||||
gc->mode,
|
||||
&pdraw->driDrawable,
|
||||
hwDrawable,
|
||||
GLX_WINDOW_BIT,
|
||||
0,
|
||||
empty_attribute_list);
|
||||
pdraw->driDrawable =
|
||||
(*psc->legacy->createNewDrawable)(psc->__driScreen,
|
||||
config->driConfig,
|
||||
hwDrawable,
|
||||
GLX_WINDOW_BIT,
|
||||
empty_attribute_list,
|
||||
pdraw);
|
||||
|
||||
if (!pdraw->driDrawable.private) {
|
||||
if (!pdraw->driDrawable) {
|
||||
XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);
|
||||
Xfree(pdraw);
|
||||
return NULL;
|
||||
@@ -795,19 +976,23 @@ static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
|
||||
static void driDestroyScreen(__GLXscreenConfigs *psc)
|
||||
{
|
||||
/* Free the direct rendering per screen data */
|
||||
if (psc->__driScreen.private)
|
||||
(*psc->__driScreen.destroyScreen)(&psc->__driScreen);
|
||||
psc->__driScreen.private = NULL;
|
||||
if (psc->__driScreen)
|
||||
(*psc->core->destroyScreen)(psc->__driScreen);
|
||||
psc->__driScreen = NULL;
|
||||
if (psc->driver)
|
||||
dlclose(psc->driver);
|
||||
}
|
||||
|
||||
void
|
||||
driBindExtensions(__GLXscreenConfigs *psc);
|
||||
|
||||
static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
|
||||
__GLXdisplayPrivate *priv)
|
||||
{
|
||||
PFNCREATENEWSCREENFUNC createNewScreen;
|
||||
__GLXDRIdisplayPrivate *pdp;
|
||||
__GLXDRIscreen *psp;
|
||||
const __DRIextension **extensions;
|
||||
int i;
|
||||
|
||||
psp = Xmalloc(sizeof *psp);
|
||||
if (psp == NULL)
|
||||
@@ -817,15 +1002,40 @@ static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
|
||||
psc->ext_list_first_time = GL_TRUE;
|
||||
|
||||
psc->driver = driGetDriver(priv->dpy, screen);
|
||||
createNewScreen = dlsym(psc->driver, createNewScreenName);
|
||||
if (createNewScreen == NULL)
|
||||
if (psc->driver == NULL) {
|
||||
Xfree(psp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
|
||||
if (extensions == NULL) {
|
||||
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
|
||||
Xfree(psp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; extensions[i]; i++) {
|
||||
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
|
||||
psc->core = (__DRIcoreExtension *) extensions[i];
|
||||
if (strcmp(extensions[i]->name, __DRI_LEGACY) == 0)
|
||||
psc->legacy = (__DRIlegacyExtension *) extensions[i];
|
||||
}
|
||||
|
||||
if (psc->core == NULL || psc->legacy == NULL) {
|
||||
Xfree(psp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay;
|
||||
psc->__driScreen.private =
|
||||
CallCreateNewScreen(psc->dpy, screen, psc, pdp, createNewScreen);
|
||||
if (psc->__driScreen.private != NULL)
|
||||
__glXScrEnableDRIExtension(psc);
|
||||
psc->__driScreen =
|
||||
CallCreateNewScreen(psc->dpy, screen, psc, pdp);
|
||||
if (psc->__driScreen == NULL) {
|
||||
dlclose(psc->driver);
|
||||
Xfree(psp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
driBindExtensions(psc);
|
||||
|
||||
psp->destroyScreen = driDestroyScreen;
|
||||
psp->createContext = driCreateContext;
|
||||
|
||||
@@ -415,7 +415,7 @@ _gl_context_modes_create( unsigned count, size_t minimum_size )
|
||||
(*next)->bindToTextureRgb = GLX_DONT_CARE;
|
||||
(*next)->bindToTextureRgba = GLX_DONT_CARE;
|
||||
(*next)->bindToMipmapTexture = GLX_DONT_CARE;
|
||||
(*next)->bindToTextureTargets = 0;
|
||||
(*next)->bindToTextureTargets = GLX_DONT_CARE;
|
||||
(*next)->yInverted = GLX_DONT_CARE;
|
||||
|
||||
next = & ((*next)->next);
|
||||
|
||||
@@ -164,6 +164,33 @@ DestroyPbuffer( Display * dpy, GLXDrawable drawable )
|
||||
}
|
||||
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
extern __GLXDRIdrawable *
|
||||
GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num);
|
||||
|
||||
static GLenum
|
||||
determineTextureTarget(const int *attribs, int numAttribs)
|
||||
{
|
||||
GLenum target = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numAttribs; i++) {
|
||||
if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
|
||||
switch (attribs[2 * i + 1]) {
|
||||
case GLX_TEXTURE_2D_EXT:
|
||||
target = GL_TEXTURE_2D;
|
||||
break;
|
||||
case GLX_TEXTURE_RECTANGLE_EXT:
|
||||
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get a drawable's attribute.
|
||||
*
|
||||
@@ -261,6 +288,16 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
{
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
|
||||
|
||||
if (pdraw != NULL && !pdraw->textureTarget)
|
||||
pdraw->textureTarget = determineTextureTarget(data,
|
||||
num_attributes);
|
||||
}
|
||||
#endif
|
||||
|
||||
Xfree( data );
|
||||
}
|
||||
}
|
||||
@@ -271,7 +308,6 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a non-pbuffer GLX drawable.
|
||||
*
|
||||
@@ -306,7 +342,7 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
|
||||
req->glxCode = glxCode;
|
||||
req->screen = (CARD32) fbconfig->screen;
|
||||
req->fbconfig = fbconfig->fbconfigID;
|
||||
req->window = (GLXPbuffer) drawable;
|
||||
req->window = (CARD32) drawable;
|
||||
req->glxwindow = (GLXWindow) XAllocID(dpy);
|
||||
req->numAttribs = (CARD32) i;
|
||||
|
||||
@@ -315,6 +351,34 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
do {
|
||||
/* FIXME: Maybe delay __DRIdrawable creation until the drawable
|
||||
* is actually bound to a context... */
|
||||
|
||||
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
|
||||
__GLXDRIdrawable *pdraw;
|
||||
__GLXscreenConfigs *psc;
|
||||
|
||||
psc = &priv->screenConfigs[fbconfig->screen];
|
||||
if (psc->driScreen == NULL)
|
||||
break;
|
||||
pdraw = psc->driScreen->createDrawable(psc, drawable,
|
||||
req->glxwindow, fbconfig);
|
||||
if (pdraw == NULL) {
|
||||
fprintf(stderr, "failed to create drawable\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) {
|
||||
(*pdraw->destroyDrawable)(pdraw);
|
||||
return None; /* FIXME: Check what we're supposed to do here... */
|
||||
}
|
||||
|
||||
pdraw->textureTarget = determineTextureTarget(attrib_list, i);
|
||||
} while (0);
|
||||
#endif
|
||||
|
||||
return (GLXDrawable)req->glxwindow;
|
||||
}
|
||||
|
||||
@@ -350,6 +414,20 @@ DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
{
|
||||
int screen;
|
||||
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
|
||||
__GLXscreenConfigs *psc = &priv->screenConfigs[screen];
|
||||
|
||||
if (pdraw != NULL) {
|
||||
(*pdraw->destroyDrawable)(pdraw);
|
||||
__glxHashDelete(psc->drawHash, drawable);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+31
-12
@@ -59,7 +59,6 @@
|
||||
#include "GL/glxproto.h"
|
||||
#include "GL/internal/glcore.h"
|
||||
#include "glapitable.h"
|
||||
#include "glxextensions.h"
|
||||
#include "glxhash.h"
|
||||
#if defined( USE_XTHREADS )
|
||||
# include <X11/Xthreads.h>
|
||||
@@ -97,6 +96,8 @@ typedef struct __GLXDRIscreenRec __GLXDRIscreen;
|
||||
typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
|
||||
typedef struct __GLXDRIcontextRec __GLXDRIcontext;
|
||||
|
||||
#include "glxextensions.h"
|
||||
|
||||
struct __GLXDRIdisplayRec {
|
||||
/**
|
||||
* Method to destroy the private DRI display data.
|
||||
@@ -117,8 +118,9 @@ struct __GLXDRIscreenRec {
|
||||
GLXContext shareList, int renderType);
|
||||
|
||||
__GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
|
||||
GLXDrawable drawable,
|
||||
GLXContext gc);
|
||||
XID drawable,
|
||||
GLXDrawable glxDrawable,
|
||||
const __GLcontextModes *modes);
|
||||
};
|
||||
|
||||
struct __GLXDRIcontextRec {
|
||||
@@ -134,9 +136,11 @@ struct __GLXDRIcontextRec {
|
||||
struct __GLXDRIdrawableRec {
|
||||
void (*destroyDrawable)(__GLXDRIdrawable *drawable);
|
||||
|
||||
XID xDrawable;
|
||||
XID drawable;
|
||||
__GLXscreenConfigs *psc;
|
||||
__DRIdrawable driDrawable;
|
||||
__DRIdrawable *driDrawable;
|
||||
GLenum textureTarget;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -144,6 +148,7 @@ struct __GLXDRIdrawableRec {
|
||||
** dependent methods.
|
||||
*/
|
||||
extern __GLXDRIdisplay *driCreateDisplay(Display *dpy);
|
||||
extern __GLXDRIdisplay *dri2CreateDisplay(Display *dpy);
|
||||
|
||||
extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
|
||||
|
||||
@@ -309,6 +314,11 @@ struct __GLXcontextRec {
|
||||
*/
|
||||
GLenum error;
|
||||
|
||||
/**
|
||||
* Whether this context does direct rendering.
|
||||
*/
|
||||
Bool isDirect;
|
||||
|
||||
/**
|
||||
* \c dpy of current display for this context. Will be \c NULL if not
|
||||
* current to any display, or if this is the "dummy context".
|
||||
@@ -359,6 +369,7 @@ struct __GLXcontextRec {
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
__GLXDRIcontext *driContext;
|
||||
__DRIcontext *__driContext;
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -453,32 +464,38 @@ struct __GLXscreenConfigsRec {
|
||||
/**
|
||||
* Per screen direct rendering interface functions and data.
|
||||
*/
|
||||
__DRIscreen __driScreen;
|
||||
__DRIscreen *__driScreen;
|
||||
const __DRIcoreExtension *core;
|
||||
const __DRIlegacyExtension *legacy;
|
||||
__glxHashTable *drawHash;
|
||||
Display *dpy;
|
||||
int scr;
|
||||
int scr, fd;
|
||||
void *driver;
|
||||
|
||||
__GLXDRIscreen *driScreen;
|
||||
|
||||
#ifdef __DRI_COPY_SUB_BUFFER
|
||||
__DRIcopySubBufferExtension *copySubBuffer;
|
||||
const __DRIcopySubBufferExtension *copySubBuffer;
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_SWAP_CONTROL
|
||||
__DRIswapControlExtension *swapControl;
|
||||
const __DRIswapControlExtension *swapControl;
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_ALLOCATE
|
||||
__DRIallocateExtension *allocate;
|
||||
const __DRIallocateExtension *allocate;
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_FRAME_TRACKING
|
||||
__DRIframeTrackingExtension *frameTracking;
|
||||
const __DRIframeTrackingExtension *frameTracking;
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_MEDIA_STREAM_COUNTER
|
||||
__DRImediaStreamCounterExtension *msc;
|
||||
const __DRImediaStreamCounterExtension *msc;
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_TEX_BUFFER
|
||||
const __DRItexBufferExtension *texBuffer;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -550,6 +567,7 @@ struct __GLXdisplayPrivateRec {
|
||||
* Per display direct rendering interface functions and data.
|
||||
*/
|
||||
__GLXDRIdisplay *driDisplay;
|
||||
__GLXDRIdisplay *dri2Display;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -715,7 +733,8 @@ extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
GLboolean
|
||||
__driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator);
|
||||
__driGetMscRateOML(__DRIdrawable *draw,
|
||||
int32_t *numerator, int32_t *denominator, void *private);
|
||||
#endif
|
||||
|
||||
#endif /* !__GLX_client_h__ */
|
||||
|
||||
+81
-61
@@ -109,6 +109,9 @@ static void GarbageCollectDRIDrawables(Display *dpy, __GLXscreenConfigs *sc)
|
||||
XSetErrorHandler(oldXErrorHandler);
|
||||
}
|
||||
|
||||
extern __GLXDRIdrawable *
|
||||
GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num);
|
||||
|
||||
/**
|
||||
* Get the __DRIdrawable for the drawable associated with a GLXContext
|
||||
*
|
||||
@@ -118,24 +121,27 @@ static void GarbageCollectDRIDrawables(Display *dpy, __GLXscreenConfigs *sc)
|
||||
* \returns A pointer to the context's __DRIdrawable on success, or NULL if
|
||||
* the drawable is not associated with a direct-rendering context.
|
||||
*/
|
||||
static __DRIdrawable *
|
||||
GetDRIDrawable( Display *dpy, GLXDrawable drawable, int * const scrn_num )
|
||||
_X_HIDDEN __GLXDRIdrawable *
|
||||
GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num)
|
||||
{
|
||||
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
|
||||
__GLXDRIdrawable * const pdraw;
|
||||
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
|
||||
__GLXDRIdrawable *pdraw;
|
||||
const unsigned screen_count = ScreenCount(dpy);
|
||||
unsigned i;
|
||||
__GLXscreenConfigs *sc;
|
||||
__GLXscreenConfigs *psc;
|
||||
|
||||
if (priv == NULL || priv->driDisplay == NULL)
|
||||
if (priv == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < screen_count; i++) {
|
||||
sc = &priv->screenConfigs[i];
|
||||
if (__glxHashLookup(sc->drawHash, drawable, (void *) &pdraw) == 0) {
|
||||
psc = &priv->screenConfigs[i];
|
||||
if (psc->drawHash == NULL)
|
||||
continue;
|
||||
|
||||
if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) {
|
||||
if (scrn_num != NULL)
|
||||
*scrn_num = i;
|
||||
return &pdraw->driDrawable;
|
||||
return pdraw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,6 +319,7 @@ GLXContext AllocateGLXContext( Display *dpy )
|
||||
gc->fillImage = __glFillImage;
|
||||
gc->pc = gc->buf;
|
||||
gc->bufEnd = gc->buf + bufSize;
|
||||
gc->isDirect = GL_FALSE;
|
||||
if (__glXDebug) {
|
||||
/*
|
||||
** Set limit register so that there will be one command per packet
|
||||
@@ -404,6 +411,7 @@ CreateContext(Display *dpy, XVisualInfo *vis,
|
||||
gc->screen = mode->screen;
|
||||
gc->psc = psc;
|
||||
gc->mode = mode;
|
||||
gc->isDirect = GL_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -835,10 +843,10 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
|
||||
GLXContextTag tag;
|
||||
CARD8 opcode;
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
__DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, NULL );
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
|
||||
|
||||
if ( pdraw != NULL ) {
|
||||
(*pdraw->swapBuffers)(pdraw);
|
||||
if (pdraw != NULL) {
|
||||
(*pdraw->psc->core->swapBuffers)(pdraw->driDrawable);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -1719,11 +1727,11 @@ static int __glXSwapIntervalSGI(int interval)
|
||||
if (gc->driContext) {
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
|
||||
gc->screen );
|
||||
__DRIdrawable * const pdraw = GetDRIDrawable( gc->currentDpy,
|
||||
gc->currentDrawable,
|
||||
NULL );
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
|
||||
gc->currentDrawable,
|
||||
NULL);
|
||||
if (psc->swapControl != NULL && pdraw != NULL) {
|
||||
psc->swapControl->setSwapInterval(pdraw, interval);
|
||||
psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
@@ -1773,10 +1781,10 @@ static int __glXSwapIntervalMESA(unsigned int interval)
|
||||
gc->screen );
|
||||
|
||||
if ( (psc != NULL) && (psc->driScreen != NULL) ) {
|
||||
__DRIdrawable * const pdraw =
|
||||
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
|
||||
__GLXDRIdrawable *pdraw =
|
||||
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
|
||||
if (psc->swapControl != NULL && pdraw != NULL) {
|
||||
psc->swapControl->setSwapInterval(pdraw, interval);
|
||||
psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1799,10 +1807,10 @@ static int __glXGetSwapIntervalMESA(void)
|
||||
gc->screen );
|
||||
|
||||
if ( (psc != NULL) && (psc->driScreen != NULL) ) {
|
||||
__DRIdrawable * const pdraw =
|
||||
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
|
||||
__GLXDRIdrawable *pdraw =
|
||||
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
|
||||
if (psc->swapControl != NULL && pdraw != NULL) {
|
||||
return psc->swapControl->getSwapInterval(pdraw);
|
||||
return psc->swapControl->getSwapInterval(pdraw->driDrawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1821,11 +1829,11 @@ static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
|
||||
int status = GLX_BAD_CONTEXT;
|
||||
#ifdef __DRI_FRAME_TRACKING
|
||||
int screen;
|
||||
__DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
|
||||
|
||||
if (pdraw != NULL && psc->frameTracking != NULL)
|
||||
status = psc->frameTracking->frameTracking(pdraw, GL_TRUE);
|
||||
status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE);
|
||||
#else
|
||||
(void) dpy;
|
||||
(void) drawable;
|
||||
@@ -1839,11 +1847,12 @@ static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
|
||||
int status = GLX_BAD_CONTEXT;
|
||||
#ifdef __DRI_FRAME_TRACKING
|
||||
int screen;
|
||||
__DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, & screen);
|
||||
__GLXscreenConfigs *psc = GetGLXScreenConfigs(dpy, screen);
|
||||
|
||||
if (pdraw != NULL && psc->frameTracking != NULL)
|
||||
status = psc->frameTracking->frameTracking(pdraw, GL_FALSE);
|
||||
status = psc->frameTracking->frameTracking(pdraw->driDrawable,
|
||||
GL_FALSE);
|
||||
#else
|
||||
(void) dpy;
|
||||
(void) drawable;
|
||||
@@ -1858,14 +1867,15 @@ static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable,
|
||||
int status = GLX_BAD_CONTEXT;
|
||||
#ifdef __DRI_FRAME_TRACKING
|
||||
int screen;
|
||||
__DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
|
||||
__GLXDRIdrawable * const pdraw = GetGLXDRIDrawable(dpy, drawable, & screen);
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
|
||||
|
||||
if (pdraw != NULL && psc->frameTracking != NULL) {
|
||||
int64_t sbc, missedFrames;
|
||||
float lastMissedUsage;
|
||||
|
||||
status = psc->frameTracking->queryFrameTracking(pdraw, &sbc,
|
||||
status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable,
|
||||
&sbc,
|
||||
&missedFrames,
|
||||
&lastMissedUsage,
|
||||
usage);
|
||||
@@ -1886,13 +1896,14 @@ static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable,
|
||||
int status = GLX_BAD_CONTEXT;
|
||||
#ifdef __DRI_FRAME_TRACKING
|
||||
int screen;
|
||||
__DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, & screen);
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
|
||||
|
||||
if (pdraw != NULL && psc->frameTracking != NULL) {
|
||||
float usage;
|
||||
|
||||
status = psc->frameTracking->queryFrameTracking(pdraw, sbc, missedFrames,
|
||||
status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable,
|
||||
sbc, missedFrames,
|
||||
lastMissedUsage, &usage);
|
||||
}
|
||||
#else
|
||||
@@ -1923,12 +1934,13 @@ static int __glXGetVideoSyncSGI(unsigned int *count)
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
|
||||
gc->screen );
|
||||
if ( psc->msc && psc->driScreen ) {
|
||||
__DRIdrawable * const pdraw =
|
||||
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
|
||||
__GLXDRIdrawable *pdraw =
|
||||
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
|
||||
int64_t temp;
|
||||
int ret;
|
||||
|
||||
ret = (*psc->msc->getDrawableMSC)(&psc->__driScreen, pdraw, &temp);
|
||||
ret = (*psc->msc->getDrawableMSC)(psc->__driScreen,
|
||||
pdraw->driDrawable, &temp);
|
||||
*count = (unsigned) temp;
|
||||
|
||||
return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
|
||||
@@ -1952,14 +1964,14 @@ static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
|
||||
gc->screen );
|
||||
if (psc->msc != NULL && psc->driScreen ) {
|
||||
__DRIdrawable * const pdraw =
|
||||
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
|
||||
__GLXDRIdrawable *pdraw =
|
||||
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
|
||||
int ret;
|
||||
int64_t msc;
|
||||
int64_t sbc;
|
||||
|
||||
ret = (*psc->msc->waitForMSC)(pdraw, 0, divisor, remainder, &msc,
|
||||
&sbc);
|
||||
ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0,
|
||||
divisor, remainder, &msc, &sbc);
|
||||
*count = (unsigned) msc;
|
||||
return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
|
||||
}
|
||||
@@ -2118,13 +2130,13 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
|
||||
|
||||
if ( priv != NULL ) {
|
||||
int i;
|
||||
__DRIdrawable * const pdraw = GetDRIDrawable( dpy, drawable, & i );
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &i);
|
||||
__GLXscreenConfigs * const psc = &priv->screenConfigs[i];
|
||||
|
||||
assert( (pdraw == NULL) || (i != -1) );
|
||||
return ( (pdraw && psc->sbc && psc->msc)
|
||||
&& ((*psc->msc->getMSC)(&psc->driScreen, msc) == 0)
|
||||
&& ((*psc->sbc->getSBC)(pdraw, sbc) == 0)
|
||||
&& ((*psc->msc->getMSC)(psc->driScreen, msc) == 0)
|
||||
&& ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0)
|
||||
&& (__glXGetUST(ust) == 0) );
|
||||
}
|
||||
#else
|
||||
@@ -2139,16 +2151,16 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
_X_HIDDEN GLboolean
|
||||
__driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator)
|
||||
__driGetMscRateOML(__DRIdrawable *draw,
|
||||
int32_t *numerator, int32_t *denominator, void *private)
|
||||
{
|
||||
#ifdef XF86VIDMODE
|
||||
__GLXscreenConfigs *psc;
|
||||
XF86VidModeModeLine mode_line;
|
||||
int dot_clock;
|
||||
int i;
|
||||
__GLXDRIdrawable *glxDraw;
|
||||
__GLXDRIdrawable *glxDraw = private;
|
||||
|
||||
glxDraw = containerOf(draw, __GLXDRIdrawable, driDrawable);
|
||||
psc = glxDraw->psc;
|
||||
if (XF86VidModeQueryVersion(psc->dpy, &i, &i) &&
|
||||
XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line) ) {
|
||||
@@ -2221,12 +2233,12 @@ _X_HIDDEN GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
|
||||
int32_t * denominator)
|
||||
{
|
||||
#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE )
|
||||
__DRIdrawable *driDraw = GetDRIDrawable(dpy, drawable, NULL);
|
||||
__GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL);
|
||||
|
||||
if (driDraw == NULL)
|
||||
if (draw == NULL)
|
||||
return False;
|
||||
|
||||
return __driGetMscRateOML(driDraw, numerator, denominator);
|
||||
return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw);
|
||||
#else
|
||||
(void) dpy;
|
||||
(void) drawable;
|
||||
@@ -2243,7 +2255,7 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
|
||||
{
|
||||
#ifdef __DRI_SWAP_BUFFER_COUNTER
|
||||
int screen;
|
||||
__DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
|
||||
|
||||
/* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
|
||||
@@ -2257,7 +2269,7 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
|
||||
return -1;
|
||||
|
||||
if (pdraw != NULL && psc->counters != NULL)
|
||||
return (*psc->sbc->swapBuffersMSC)(pdraw, target_msc,
|
||||
return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc,
|
||||
divisor, remainder);
|
||||
|
||||
#else
|
||||
@@ -2278,7 +2290,7 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
|
||||
{
|
||||
#ifdef __DRI_MEDIA_STREAM_COUNTER
|
||||
int screen;
|
||||
__DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
|
||||
int ret;
|
||||
|
||||
@@ -2291,7 +2303,7 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
|
||||
return False;
|
||||
|
||||
if (pdraw != NULL && psc->msc != NULL) {
|
||||
ret = (*psc->msc->waitForMSC)(pdraw, target_msc,
|
||||
ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, target_msc,
|
||||
divisor, remainder, msc, sbc);
|
||||
|
||||
/* __glXGetUST returns zero on success and non-zero on failure.
|
||||
@@ -2319,7 +2331,7 @@ static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
|
||||
{
|
||||
#ifdef __DRI_SWAP_BUFFER_COUNTER
|
||||
int screen;
|
||||
__DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
|
||||
int ret;
|
||||
|
||||
@@ -2330,7 +2342,7 @@ static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
|
||||
return False;
|
||||
|
||||
if (pdraw != NULL && psc->sbc != NULL) {
|
||||
ret = (*psc->sbc->waitForSBC)(pdraw, target_sbc, msc, sbc);
|
||||
ret = (*psc->sbc->waitForSBC)(pdraw->driDrawable, target_sbc, msc, sbc);
|
||||
|
||||
/* __glXGetUST returns zero on success and non-zero on failure.
|
||||
* This function returns True on success and False on failure.
|
||||
@@ -2362,9 +2374,8 @@ PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn,
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
|
||||
|
||||
if (psc && psc->allocate)
|
||||
return (*psc->allocate->allocateMemory)( &psc->__driScreen, size,
|
||||
readFreq, writeFreq,
|
||||
priority );
|
||||
return (*psc->allocate->allocateMemory)(psc->__driScreen, size,
|
||||
readFreq, writeFreq, priority);
|
||||
|
||||
#else
|
||||
(void) dpy;
|
||||
@@ -2385,7 +2396,7 @@ PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
|
||||
|
||||
if (psc && psc->allocate)
|
||||
(*psc->allocate->freeMemory)( &psc->__driScreen, pointer );
|
||||
(*psc->allocate->freeMemory)(psc->__driScreen, pointer);
|
||||
|
||||
#else
|
||||
(void) dpy;
|
||||
@@ -2402,7 +2413,7 @@ PUBLIC GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn,
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
|
||||
|
||||
if (psc && psc->allocate)
|
||||
return (*psc->allocate->memoryOffset)( &psc->__driScreen, pointer );
|
||||
return (*psc->allocate->memoryOffset)(psc->__driScreen, pointer);
|
||||
|
||||
#else
|
||||
(void) dpy;
|
||||
@@ -2478,11 +2489,12 @@ static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
|
||||
|
||||
#ifdef __DRI_COPY_SUB_BUFFER
|
||||
int screen;
|
||||
__DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
|
||||
if ( pdraw != NULL ) {
|
||||
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
|
||||
if (psc->copySubBuffer != NULL) {
|
||||
(*psc->copySubBuffer->copySubBuffer)(pdraw, x, y, width, height);
|
||||
(*psc->copySubBuffer->copySubBuffer)(pdraw->driDrawable,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -2558,8 +2570,16 @@ static void __glXBindTexImageEXT(Display *dpy,
|
||||
}
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
if (gc->driContext)
|
||||
if (gc->driContext) {
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
|
||||
|
||||
if (pdraw != NULL)
|
||||
(*pdraw->psc->texBuffer->setTexBuffer)(gc->__driContext,
|
||||
pdraw->textureTarget,
|
||||
pdraw->driDrawable);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
opcode = __glXSetupForCommand(dpy);
|
||||
|
||||
+44
-26
@@ -107,9 +107,6 @@ static int _mesa_sparc_needs_init = 1;
|
||||
#define INIT_MESA_SPARC
|
||||
#endif
|
||||
|
||||
static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
|
||||
GLXDrawable read, GLXContext gc);
|
||||
|
||||
/*
|
||||
** We setup some dummy structures here so that the API can be used
|
||||
** even if no context is current.
|
||||
@@ -348,10 +345,10 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
|
||||
Xfree((char*) psc->serverGLXexts);
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
if (psc->driScreen)
|
||||
if (psc->driScreen) {
|
||||
psc->driScreen->destroyScreen(psc);
|
||||
if (psc->drawHash)
|
||||
__glxHashDestroy(psc->drawHash);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
XFree((char*) priv->screenConfigs);
|
||||
@@ -381,6 +378,9 @@ static int __glXFreeDisplayPrivate(XExtData *extension)
|
||||
if (priv->driDisplay)
|
||||
(*priv->driDisplay->destroyDisplay)(priv->driDisplay);
|
||||
priv->driDisplay = NULL;
|
||||
if (priv->dri2Display)
|
||||
(*priv->dri2Display->destroyDisplay)(priv->dri2Display);
|
||||
priv->dri2Display = NULL;
|
||||
#endif
|
||||
|
||||
Xfree((char*) priv);
|
||||
@@ -774,14 +774,16 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
|
||||
psc->scr = i;
|
||||
psc->dpy = dpy;
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
if (priv->driDisplay) {
|
||||
/* Create drawable hash */
|
||||
psc->drawHash = __glxHashCreate();
|
||||
if (psc->drawHash == NULL)
|
||||
continue;
|
||||
psc->drawHash = __glxHashCreate();
|
||||
if (psc->drawHash == NULL)
|
||||
continue;
|
||||
if (priv->dri2Display)
|
||||
psc->driScreen = (*priv->dri2Display->createScreen)(psc, i, priv);
|
||||
if (psc->driScreen == NULL && priv->driDisplay)
|
||||
psc->driScreen = (*priv->driDisplay->createScreen)(psc, i, priv);
|
||||
if (psc->driScreen == NULL)
|
||||
__glxHashDestroy(psc->drawHash);
|
||||
if (psc->driScreen == NULL) {
|
||||
__glxHashDestroy(psc->drawHash);
|
||||
psc->drawHash = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -872,7 +874,8 @@ _X_HIDDEN __GLXdisplayPrivate *__glXInitialize(Display* dpy)
|
||||
** (e.g., those called in AllocAndFetchScreenConfigs).
|
||||
*/
|
||||
if (getenv("LIBGL_ALWAYS_INDIRECT") == NULL) {
|
||||
dpyPriv->driDisplay = driCreateDisplay(dpy);
|
||||
dpyPriv->dri2Display = dri2CreateDisplay(dpy);
|
||||
dpyPriv->driDisplay = driCreateDisplay(dpy);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1188,21 +1191,35 @@ static Bool SendMakeCurrentRequest(Display *dpy, CARD8 opcode,
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
static __GLXDRIdrawable *
|
||||
FetchDRIDrawable(Display *dpy, GLXDrawable drawable, GLXContext gc)
|
||||
FetchDRIDrawable(Display *dpy,
|
||||
GLXDrawable glxDrawable, GLXContext gc, Bool pre13)
|
||||
{
|
||||
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
|
||||
__GLXDRIdrawable *pdraw;
|
||||
__GLXscreenConfigs *psc;
|
||||
XID drawable;
|
||||
|
||||
if (priv == NULL || priv->driDisplay == NULL)
|
||||
if (priv == NULL)
|
||||
return NULL;
|
||||
|
||||
psc = &priv->screenConfigs[gc->screen];
|
||||
if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0)
|
||||
if (psc->drawHash == NULL)
|
||||
return NULL;
|
||||
|
||||
if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
|
||||
return pdraw;
|
||||
|
||||
pdraw = psc->driScreen->createDrawable(psc, drawable, gc);
|
||||
if (__glxHashInsert(psc->drawHash, drawable, pdraw)) {
|
||||
/* If this is glXMakeCurrent (pre GLX 1.3) we allow creating the
|
||||
* GLX drawable on the fly. Otherwise we pass None as the X
|
||||
* drawable */
|
||||
if (pre13)
|
||||
drawable = glxDrawable;
|
||||
else
|
||||
drawable = None;
|
||||
|
||||
pdraw = psc->driScreen->createDrawable(psc, drawable,
|
||||
glxDrawable, gc->mode);
|
||||
if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
|
||||
(*pdraw->destroyDrawable)(pdraw);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1218,7 +1235,8 @@ FetchDRIDrawable(Display *dpy, GLXDrawable drawable, GLXContext gc)
|
||||
* \note This is in this file so that it can access dummyContext.
|
||||
*/
|
||||
static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
|
||||
GLXDrawable read, GLXContext gc)
|
||||
GLXDrawable read, GLXContext gc,
|
||||
Bool pre13)
|
||||
{
|
||||
xGLXMakeCurrentReply reply;
|
||||
const GLXContext oldGC = __glXGetCurrentContext();
|
||||
@@ -1245,8 +1263,8 @@ static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
/* Bind the direct rendering context to the drawable */
|
||||
if (gc && gc->driContext) {
|
||||
__GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc);
|
||||
__GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc);
|
||||
__GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc, pre13);
|
||||
__GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc, pre13);
|
||||
|
||||
bindReturnValue =
|
||||
(gc->driContext->bindContext) (gc->driContext, pdraw, pread);
|
||||
@@ -1256,7 +1274,7 @@ static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
|
||||
/* Send a glXMakeCurrent request to bind the new context. */
|
||||
bindReturnValue =
|
||||
SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
|
||||
((dpy != oldGC->currentDpy) || oldGC->driContext)
|
||||
((dpy != oldGC->currentDpy) || oldGC->isDirect)
|
||||
? None : oldGC->currentContextTag,
|
||||
draw, read, &reply);
|
||||
}
|
||||
@@ -1267,7 +1285,7 @@ static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
|
||||
}
|
||||
|
||||
if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
|
||||
!oldGC->driContext && oldGC != &dummyContext) {
|
||||
!oldGC->isDirect && oldGC != &dummyContext) {
|
||||
xGLXMakeCurrentReply dummy_reply;
|
||||
|
||||
/* We are either switching from one dpy to another and have to
|
||||
@@ -1368,16 +1386,16 @@ static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
|
||||
|
||||
PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc)
|
||||
{
|
||||
return MakeContextCurrent( dpy, draw, draw, gc );
|
||||
return MakeContextCurrent(dpy, draw, draw, gc, True);
|
||||
}
|
||||
|
||||
PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
|
||||
(Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
|
||||
(dpy, d, r, ctx), MakeContextCurrent)
|
||||
(dpy, d, r, ctx, False), MakeContextCurrent)
|
||||
|
||||
PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
|
||||
(Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
|
||||
(dpy, d, r, ctx), MakeContextCurrent)
|
||||
(dpy, d, r, ctx, False), MakeContextCurrent)
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -356,72 +356,16 @@ __glXProcessServerString( const struct extension_info * ext,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
void
|
||||
__glXScrEnableDRIExtension(__GLXscreenConfigs *psc)
|
||||
__glXEnableDirectExtension(__GLXscreenConfigs *psc, const char *name)
|
||||
{
|
||||
const __DRIextension **extensions;
|
||||
int i;
|
||||
|
||||
__glXExtensionsCtr();
|
||||
__glXExtensionsCtrScreen(psc);
|
||||
|
||||
extensions = psc->__driScreen.getExtensions(&psc->__driScreen);
|
||||
for (i = 0; extensions[i]; i++) {
|
||||
#ifdef __DRI_COPY_SUB_BUFFER
|
||||
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
|
||||
psc->copySubBuffer = (__DRIcopySubBufferExtension *) extensions[i];
|
||||
SET_BIT(psc->direct_support, MESA_copy_sub_buffer_bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_SWAP_CONTROL
|
||||
if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
|
||||
psc->swapControl = (__DRIswapControlExtension *) extensions[i];
|
||||
SET_BIT(psc->direct_support, SGI_swap_control_bit);
|
||||
SET_BIT(psc->direct_support, MESA_swap_control_bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_ALLOCATE
|
||||
if (strcmp(extensions[i]->name, __DRI_ALLOCATE) == 0) {
|
||||
psc->allocate = (__DRIallocateExtension *) extensions[i];
|
||||
SET_BIT(psc->direct_support, MESA_allocate_memory_bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_FRAME_TRACKING
|
||||
if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) {
|
||||
psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i];
|
||||
SET_BIT(psc->direct_support, MESA_swap_frame_usage_bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_MEDIA_STREAM_COUNTER
|
||||
if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
|
||||
psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
|
||||
SET_BIT(psc->direct_support, SGI_video_sync_bit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_SWAP_BUFFER_COUNTER
|
||||
/* No driver supports this at this time and the extension is
|
||||
* not defined in dri_interface.h. Will enable
|
||||
* GLX_OML_sync_control if implemented. */
|
||||
#endif
|
||||
|
||||
#ifdef __DRI_READ_DRAWABLE
|
||||
if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
|
||||
SET_BIT(psc->direct_support, SGI_make_current_read_bit);
|
||||
}
|
||||
#endif
|
||||
/* Ignore unknown extensions */
|
||||
}
|
||||
set_glx_extension(known_glx_extensions,
|
||||
name, strlen(name), GL_TRUE, psc->direct_support);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize global extension support tables.
|
||||
*/
|
||||
|
||||
@@ -235,10 +235,6 @@ extern const char * __glXGetClientExtensions( void );
|
||||
extern void __glXCalculateUsableExtensions( struct __GLXscreenConfigsRec *psc,
|
||||
GLboolean display_is_direct_capable, int server_minor_version );
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
extern void __glXScrEnableDRIExtension( struct __GLXscreenConfigsRec *psc );
|
||||
#endif
|
||||
|
||||
extern void __glXCalculateUsableGLExtensions( struct __GLXcontextRec * gc,
|
||||
const char * server_string, int major_version, int minor_version );
|
||||
extern void __glXGetGLVersion( int * major_version, int * minor_version );
|
||||
@@ -247,6 +243,8 @@ extern char * __glXGetClientGLExtensionString( void );
|
||||
extern GLboolean __glExtensionBitIsEnabled( const struct __GLXcontextRec * gc,
|
||||
unsigned bit );
|
||||
|
||||
extern void
|
||||
__glXEnableDirectExtension(__GLXscreenConfigs *psc, const char *name);
|
||||
|
||||
/* Source-level backwards compatibility with old drivers. They won't
|
||||
* find the respective functions, though.
|
||||
|
||||
@@ -142,10 +142,10 @@ dri_bufmgr_destroy(dri_bufmgr *bufmgr)
|
||||
}
|
||||
|
||||
|
||||
void dri_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
int dri_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
GLuint offset, dri_bo *target_buf)
|
||||
{
|
||||
reloc_buf->bufmgr->emit_reloc(reloc_buf, flags, delta, offset, target_buf);
|
||||
return reloc_buf->bufmgr->emit_reloc(reloc_buf, flags, delta, offset, target_buf);
|
||||
}
|
||||
|
||||
void *dri_process_relocs(dri_bo *batch_buf, GLuint *count)
|
||||
@@ -163,3 +163,9 @@ dri_bufmgr_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug)
|
||||
{
|
||||
bufmgr->debug = enable_debug;
|
||||
}
|
||||
|
||||
int
|
||||
dri_bufmgr_check_aperture_space(dri_bo *bo)
|
||||
{
|
||||
return bo->bufmgr->check_aperture_space(bo);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ struct _dri_bufmgr {
|
||||
* \param target Buffer whose offset should be written into the relocation
|
||||
* entry.
|
||||
*/
|
||||
void (*emit_reloc)(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
int (*emit_reloc)(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
GLuint offset, dri_bo *target);
|
||||
|
||||
/**
|
||||
@@ -176,6 +176,7 @@ struct _dri_bufmgr {
|
||||
|
||||
void (*post_submit)(dri_bo *batch_buf, dri_fence **fence);
|
||||
|
||||
int (*check_aperture_space)(dri_bo *bo);
|
||||
GLboolean debug; /**< Enables verbose debugging printouts */
|
||||
};
|
||||
|
||||
@@ -211,9 +212,11 @@ void dri_bo_fake_disable_backing_store(dri_bo *bo,
|
||||
void *ptr);
|
||||
void dri_bufmgr_destroy(dri_bufmgr *bufmgr);
|
||||
|
||||
void dri_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
GLuint offset, dri_bo *target_buf);
|
||||
int dri_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
GLuint offset, dri_bo *target_buf);
|
||||
void *dri_process_relocs(dri_bo *batch_buf, uint32_t *count);
|
||||
void dri_post_process_relocs(dri_bo *batch_buf);
|
||||
void dri_post_submit(dri_bo *batch_buf, dri_fence **last_fence);
|
||||
int dri_bufmgr_check_aperture_space(dri_bo *bo);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -133,6 +133,9 @@ typedef struct _bufmgr_fake {
|
||||
GLboolean debug;
|
||||
|
||||
GLboolean performed_rendering;
|
||||
|
||||
/* keep track of the current total size of objects we have relocs for */
|
||||
unsigned long current_total_size;
|
||||
} dri_bufmgr_fake;
|
||||
|
||||
typedef struct _dri_bo_fake {
|
||||
@@ -142,6 +145,8 @@ typedef struct _dri_bo_fake {
|
||||
const char *name;
|
||||
|
||||
unsigned dirty:1;
|
||||
unsigned size_accounted:1; /*this buffers size has been accounted against the aperture */
|
||||
unsigned card_dirty:1; /* has the card written to this buffer - we make need to copy it back */
|
||||
unsigned int refcount;
|
||||
/* Flags may consist of any of the DRM_BO flags, plus
|
||||
* DRM_BO_NO_BACKING_STORE and BM_NO_FENCE_SUBDATA, which are the first two
|
||||
@@ -177,6 +182,8 @@ typedef struct _dri_fence_fake {
|
||||
static int clear_fenced(dri_bufmgr_fake *bufmgr_fake,
|
||||
unsigned int fence_cookie);
|
||||
|
||||
static int dri_fake_check_aperture_space(dri_bo *bo);
|
||||
|
||||
#define MAXFENCE 0x7fffffff
|
||||
|
||||
static GLboolean FENCE_LTE( unsigned a, unsigned b )
|
||||
@@ -231,7 +238,7 @@ alloc_block(dri_bo *bo)
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
dri_bufmgr_fake *bufmgr_fake= (dri_bufmgr_fake *)bo->bufmgr;
|
||||
struct block *block = (struct block *)calloc(sizeof *block, 1);
|
||||
unsigned int align_log2 = ffs(bo_fake->alignment);
|
||||
unsigned int align_log2 = _mesa_ffs(bo_fake->alignment);
|
||||
GLuint sz;
|
||||
|
||||
if (!block)
|
||||
@@ -264,11 +271,19 @@ alloc_block(dri_bo *bo)
|
||||
*/
|
||||
static void free_block(dri_bufmgr_fake *bufmgr_fake, struct block *block)
|
||||
{
|
||||
dri_bo_fake *bo_fake;
|
||||
DBG("free block %p\n", block);
|
||||
|
||||
if (!block)
|
||||
return;
|
||||
|
||||
bo_fake = (dri_bo_fake *)block->bo;
|
||||
if (bo_fake->card_dirty == GL_TRUE) {
|
||||
memcpy(bo_fake->backing_store, block->virtual, block->bo->size);
|
||||
bo_fake->card_dirty = GL_FALSE;
|
||||
bo_fake->dirty = GL_TRUE;
|
||||
}
|
||||
|
||||
if (block->on_hardware) {
|
||||
block->bo = NULL;
|
||||
}
|
||||
@@ -287,11 +302,15 @@ static void free_block(dri_bufmgr_fake *bufmgr_fake, struct block *block)
|
||||
static void
|
||||
alloc_backing_store(dri_bo *bo)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
assert(!bo_fake->backing_store);
|
||||
assert(!(bo_fake->flags & (BM_PINNED|BM_NO_BACKING_STORE)));
|
||||
|
||||
bo_fake->backing_store = ALIGN_MALLOC(bo->size, 64);
|
||||
|
||||
DBG("alloc_backing - buf %d %p %d\n", bo_fake->id, bo_fake->backing_store, bo->size);
|
||||
assert(bo_fake->backing_store);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -495,9 +514,6 @@ static GLboolean evict_and_alloc_block(dri_bo *bo)
|
||||
|
||||
DBG("%s 0x%x bytes failed\n", __FUNCTION__, bo->size);
|
||||
|
||||
assert(is_empty_list(&bufmgr_fake->on_hardware));
|
||||
assert(is_empty_list(&bufmgr_fake->fenced));
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -660,10 +676,12 @@ dri_fake_bo_unreference(dri_bo *bo)
|
||||
|
||||
for (i = 0; i < bo_fake->nr_relocs; i++)
|
||||
dri_bo_unreference(bo_fake->relocs[i].target_buf);
|
||||
free(bo_fake->relocs);
|
||||
|
||||
DBG("drm_bo_unreference: free buf %d %s\n", bo_fake->id, bo_fake->name);
|
||||
|
||||
free(bo_fake->relocs);
|
||||
free(bo);
|
||||
DBG("drm_bo_unreference: free %s\n", bo_fake->name);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -782,6 +800,26 @@ dri_fake_bo_unmap(dri_bo *bo)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
dri_fake_kick_all(dri_bufmgr_fake *bufmgr_fake)
|
||||
{
|
||||
struct block *block, *tmp;
|
||||
|
||||
bufmgr_fake->performed_rendering = GL_FALSE;
|
||||
/* okay for ever BO that is on the HW kick it off.
|
||||
seriously not afraid of the POLICE right now */
|
||||
foreach_s(block, tmp, &bufmgr_fake->on_hardware) {
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)block->bo;
|
||||
|
||||
block->on_hardware = 0;
|
||||
free_block(bufmgr_fake, block);
|
||||
bo_fake->block = NULL;
|
||||
bo_fake->validated = GL_FALSE;
|
||||
bo_fake->dirty = GL_TRUE;
|
||||
block->bo->offset = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
dri_fake_bo_validate(dri_bo *bo, uint64_t flags)
|
||||
{
|
||||
@@ -808,6 +846,9 @@ dri_fake_bo_validate(dri_bo *bo, uint64_t flags)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* reset size accounted */
|
||||
bo_fake->size_accounted = 0;
|
||||
|
||||
/* Allocate the card memory */
|
||||
if (!bo_fake->block && !evict_and_alloc_block(bo)) {
|
||||
bufmgr_fake->fail = 1;
|
||||
@@ -834,7 +875,13 @@ dri_fake_bo_validate(dri_bo *bo, uint64_t flags)
|
||||
*/
|
||||
dri_bufmgr_fake_wait_idle(bufmgr_fake);
|
||||
|
||||
memcpy(bo_fake->block->virtual, bo_fake->backing_store, bo->size);
|
||||
/* we may never have mapped this BO so it might not have any backing store */
|
||||
/* if this happens it should be rare, but 0 the card memory in any case */
|
||||
if (bo_fake->backing_store)
|
||||
memcpy(bo_fake->block->virtual, bo_fake->backing_store, bo->size);
|
||||
else
|
||||
memset(bo_fake->block->virtual, 0, bo->size);
|
||||
|
||||
bo_fake->dirty = 0;
|
||||
}
|
||||
|
||||
@@ -915,14 +962,24 @@ dri_fake_destroy(dri_bufmgr *bufmgr)
|
||||
free(bufmgr);
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
dri_fake_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
GLuint offset, dri_bo *target_buf)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)reloc_buf->bufmgr;
|
||||
struct fake_buffer_reloc *r;
|
||||
dri_bo_fake *reloc_fake = (dri_bo_fake *)reloc_buf;
|
||||
int i;
|
||||
dri_bo_fake *target_fake = (dri_bo_fake *)target_buf;
|
||||
int ret, i;
|
||||
|
||||
assert(reloc_buf);
|
||||
assert(target_buf);
|
||||
|
||||
if (!target_fake->is_static && !target_fake->size_accounted) {
|
||||
ret = dri_fake_check_aperture_space(target_buf);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (reloc_fake->relocs == NULL) {
|
||||
reloc_fake->relocs = malloc(sizeof(struct fake_buffer_reloc) *
|
||||
@@ -950,7 +1007,7 @@ dri_fake_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1004,8 +1061,11 @@ dri_fake_reloc_and_validate_buffer(dri_bo *bo)
|
||||
/* Validate the target buffer if that hasn't been done. */
|
||||
if (!target_fake->validated) {
|
||||
ret = dri_fake_reloc_and_validate_buffer(r->target_buf);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
if (bo->virtual != NULL)
|
||||
dri_bo_unmap(bo);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate the value of the relocation entry. */
|
||||
@@ -1024,8 +1084,15 @@ dri_fake_reloc_and_validate_buffer(dri_bo *bo)
|
||||
if (bo->virtual != NULL)
|
||||
dri_bo_unmap(bo);
|
||||
|
||||
if (bo_fake->validate_flags & DRM_BO_FLAG_WRITE)
|
||||
if (bo_fake->validate_flags & DRM_BO_FLAG_WRITE) {
|
||||
if (!(bo_fake->flags & (BM_NO_BACKING_STORE|BM_PINNED))) {
|
||||
if (bo_fake->backing_store == 0)
|
||||
alloc_backing_store(bo);
|
||||
|
||||
bo_fake->card_dirty = GL_TRUE;
|
||||
}
|
||||
bufmgr_fake->performed_rendering = GL_TRUE;
|
||||
}
|
||||
|
||||
return dri_fake_bo_validate(bo, bo_fake->validate_flags);
|
||||
}
|
||||
@@ -1036,17 +1103,30 @@ dri_fake_process_relocs(dri_bo *batch_buf, GLuint *count_p)
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)batch_buf->bufmgr;
|
||||
dri_bo_fake *batch_fake = (dri_bo_fake *)batch_buf;
|
||||
int ret;
|
||||
int retry_count = 0;
|
||||
|
||||
bufmgr_fake->performed_rendering = GL_FALSE;
|
||||
|
||||
dri_fake_calculate_validate_flags(batch_buf);
|
||||
|
||||
batch_fake->validate_flags = DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ;
|
||||
|
||||
/* we've ran out of RAM so blow the whole lot away and retry */
|
||||
restart:
|
||||
ret = dri_fake_reloc_and_validate_buffer(batch_buf);
|
||||
if (bufmgr_fake->fail == 1) {
|
||||
if (retry_count == 0) {
|
||||
retry_count++;
|
||||
dri_fake_kick_all(bufmgr_fake);
|
||||
bufmgr_fake->fail = 0;
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
assert(ret == 0);
|
||||
|
||||
*count_p = 0; /* junk */
|
||||
|
||||
bufmgr_fake->current_total_size = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1093,6 +1173,29 @@ dri_fake_post_submit(dri_bo *batch_buf, dri_fence **last_fence)
|
||||
dri_bo_fake_post_submit(batch_buf);
|
||||
}
|
||||
|
||||
static int
|
||||
dri_fake_check_aperture_space(dri_bo *bo)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
GLuint sz;
|
||||
|
||||
sz = (bo->size + bo_fake->alignment - 1) & ~(bo_fake->alignment - 1);
|
||||
|
||||
if (bo_fake->size_accounted || bo_fake->is_static)
|
||||
return 0;
|
||||
|
||||
if (bufmgr_fake->current_total_size + sz > bufmgr_fake->size) {
|
||||
DBG("check_space: bo %d %d overflowed bufmgr\n", bo_fake->id, sz);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bufmgr_fake->current_total_size += sz;
|
||||
bo_fake->size_accounted = 1;
|
||||
DBG("check_space: bo %d %d %d\n", bo_fake->id, bo->size, bufmgr_fake->current_total_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dri_bufmgr *
|
||||
dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
|
||||
unsigned long size,
|
||||
@@ -1128,6 +1231,7 @@ dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
|
||||
bufmgr_fake->bufmgr.emit_reloc = dri_fake_emit_reloc;
|
||||
bufmgr_fake->bufmgr.process_relocs = dri_fake_process_relocs;
|
||||
bufmgr_fake->bufmgr.post_submit = dri_fake_post_submit;
|
||||
bufmgr_fake->bufmgr.check_aperture_space = dri_fake_check_aperture_space;
|
||||
bufmgr_fake->bufmgr.debug = GL_FALSE;
|
||||
|
||||
bufmgr_fake->fence_emit = fence_emit;
|
||||
@@ -1136,3 +1240,4 @@ dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
|
||||
|
||||
return &bufmgr_fake->bufmgr;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifndef MAP_FAILED
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
@@ -45,16 +44,6 @@ const __DRIextension driReadDrawableExtension = {
|
||||
__DRI_READ_DRAWABLE, __DRI_READ_DRAWABLE_VERSION
|
||||
};
|
||||
|
||||
static void *driCreateNewDrawable(__DRIscreen *screen,
|
||||
const __GLcontextModes *modes,
|
||||
__DRIdrawable *pdraw,
|
||||
drm_drawable_t hwDrawable,
|
||||
unsigned int head,
|
||||
int renderType, const int *attrs);
|
||||
|
||||
static void driDestroyDrawable(__DRIdrawable *drawable);
|
||||
|
||||
|
||||
/**
|
||||
* Print message to \c stderr if the \c LIBGL_DEBUG environment variable
|
||||
* is set.
|
||||
@@ -99,25 +88,23 @@ __driUtilMessage(const char *f, ...)
|
||||
* While casting the opaque private pointers associated with the parameters
|
||||
* into their respective real types it also assures they are not \c NULL.
|
||||
*/
|
||||
static GLboolean driUnbindContext(__DRIcontext *ctx)
|
||||
static int driUnbindContext(__DRIcontext *pcp)
|
||||
{
|
||||
__DRIcontextPrivate *pcp;
|
||||
__DRIscreenPrivate *psp;
|
||||
__DRIdrawablePrivate *pdp;
|
||||
__DRIdrawablePrivate *prp;
|
||||
__DRIscreen *psp;
|
||||
__DRIdrawable *pdp;
|
||||
__DRIdrawable *prp;
|
||||
|
||||
/*
|
||||
** Assume error checking is done properly in glXMakeCurrent before
|
||||
** calling driUnbindContext.
|
||||
*/
|
||||
|
||||
if (ctx == NULL)
|
||||
if (pcp == NULL)
|
||||
return GL_FALSE;
|
||||
|
||||
pcp = (__DRIcontextPrivate *)ctx->private;
|
||||
psp = (__DRIscreenPrivate *)pcp->driScreenPriv;
|
||||
pdp = (__DRIdrawablePrivate *)pcp->driDrawablePriv;
|
||||
prp = (__DRIdrawablePrivate *)pcp->driReadablePriv;
|
||||
psp = pcp->driScreenPriv;
|
||||
pdp = pcp->driDrawablePriv;
|
||||
prp = pcp->driReadablePriv;
|
||||
|
||||
/* Let driver unbind drawable from context */
|
||||
(*psp->DriverAPI.UnbindContext)(pcp);
|
||||
@@ -158,13 +145,10 @@ static GLboolean driUnbindContext(__DRIcontext *ctx)
|
||||
* for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent
|
||||
* function.
|
||||
*/
|
||||
static GLboolean driBindContext(__DRIcontext * ctx,
|
||||
__DRIdrawable *pdraw,
|
||||
__DRIdrawable *pread)
|
||||
static int driBindContext(__DRIcontext *pcp,
|
||||
__DRIdrawable *pdp,
|
||||
__DRIdrawable *prp)
|
||||
{
|
||||
__DRIdrawablePrivate *pdp;
|
||||
__DRIdrawablePrivate *prp;
|
||||
__DRIcontextPrivate * const pcp = ctx->private;
|
||||
__DRIscreenPrivate *psp = pcp->driScreenPriv;
|
||||
|
||||
/*
|
||||
@@ -172,12 +156,9 @@ static GLboolean driBindContext(__DRIcontext * ctx,
|
||||
** calling driBindContext.
|
||||
*/
|
||||
|
||||
if (ctx == NULL || pdraw == None || pread == None)
|
||||
if (pcp == NULL || pdp == None || prp == None)
|
||||
return GL_FALSE;
|
||||
|
||||
pdp = (__DRIdrawablePrivate *) pdraw->private;
|
||||
prp = (__DRIdrawablePrivate *) pread->private;
|
||||
|
||||
/* Bind the drawable to the context */
|
||||
pcp->driDrawablePriv = pdp;
|
||||
pcp->driReadablePriv = prp;
|
||||
@@ -261,14 +242,15 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
|
||||
|
||||
DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
|
||||
|
||||
if (! (*psp->getDrawableInfo->getDrawableInfo)(pdp->pdraw,
|
||||
if (! (*psp->getDrawableInfo->getDrawableInfo)(pdp,
|
||||
&pdp->index, &pdp->lastStamp,
|
||||
&pdp->x, &pdp->y, &pdp->w, &pdp->h,
|
||||
&pdp->numClipRects, &pdp->pClipRects,
|
||||
&pdp->backX,
|
||||
&pdp->backY,
|
||||
&pdp->numBackClipRects,
|
||||
&pdp->pBackClipRects )) {
|
||||
&pdp->pBackClipRects,
|
||||
pdp->loaderPrivate)) {
|
||||
/* Error -- eg the window may have been destroyed. Keep going
|
||||
* with no cliprects.
|
||||
*/
|
||||
@@ -301,7 +283,8 @@ __driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp)
|
||||
* server overwrote it and we have to reset our tail
|
||||
* pointer. */
|
||||
DRM_UNLOCK(psp->fd, psp->lock, pcp->hHWContext);
|
||||
(*psp->dri2.core->reemitDrawableInfo)(pdp->pdraw, &pdp->dri2.tail);
|
||||
(*psp->dri2.loader->reemitDrawableInfo)(pdp, &pdp->dri2.tail,
|
||||
pdp->loaderPrivate);
|
||||
DRM_LIGHT_LOCK(psp->fd, psp->lock, pcp->hHWContext);
|
||||
}
|
||||
|
||||
@@ -326,13 +309,13 @@ __driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp)
|
||||
switch (DRI2_EVENT_TYPE(*p)) {
|
||||
case DRI2_EVENT_DRAWABLE_CONFIG:
|
||||
dc = (__DRIDrawableConfigEvent *) p;
|
||||
if (dc->drawable == pdp->hHWDrawable)
|
||||
if (dc->drawable == pdp->dri2.drawable_id)
|
||||
last_dc = dc;
|
||||
break;
|
||||
|
||||
case DRI2_EVENT_BUFFER_ATTACH:
|
||||
ba = (__DRIBufferAttachEvent *) p;
|
||||
if (ba->drawable == pdp->hHWDrawable &&
|
||||
if (ba->drawable == pdp->dri2.drawable_id &&
|
||||
ba->buffer.attachment == DRI_DRAWABLE_BUFFER_FRONT_LEFT)
|
||||
last_ba = ba;
|
||||
break;
|
||||
@@ -361,11 +344,12 @@ __driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp)
|
||||
rect_size = last_dc->num_rects * sizeof last_dc->rects[0];
|
||||
pdp->pClipRects = _mesa_malloc(rect_size);
|
||||
memcpy(pdp->pClipRects, last_dc->rects, rect_size);
|
||||
|
||||
if (changed)
|
||||
(*psp->DriverAPI.HandleDrawableConfig)(pdp, pcp, last_dc);
|
||||
}
|
||||
|
||||
/* We only care about the most recent drawable config. */
|
||||
if (last_dc && changed)
|
||||
(*psp->DriverAPI.HandleDrawableConfig)(pdp, pcp, last_dc);
|
||||
|
||||
/* Front buffer attachments are special, they typically mean that
|
||||
* we're rendering to a redirected window (or a child window of a
|
||||
* redirected window) and that it got resized. Resizing the root
|
||||
@@ -382,11 +366,6 @@ __driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp)
|
||||
if (last_ba)
|
||||
(*psp->DriverAPI.HandleBufferAttach)(pdp, pcp, last_ba);
|
||||
|
||||
/* Like for buffer attachments, we only care about the most recent
|
||||
* drawable config. */
|
||||
if (last_dc)
|
||||
(*psp->DriverAPI.HandleDrawableConfig)(pdp, pcp, last_dc);
|
||||
|
||||
/* If there was a drawable config event in the buffer and it
|
||||
* changed the size of the window, all buffer auxillary buffer
|
||||
* attachments prior to that are invalid (as opposed to the front
|
||||
@@ -406,21 +385,18 @@ __driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp)
|
||||
|
||||
if (DRI2_EVENT_TYPE(ba->event_header) != DRI2_EVENT_BUFFER_ATTACH)
|
||||
continue;
|
||||
if (ba->drawable != pdp->hHWDrawable)
|
||||
if (ba->drawable != pdp->dri2.drawable_id)
|
||||
continue;
|
||||
if (last_ba == ba)
|
||||
continue;
|
||||
|
||||
(*psp->DriverAPI.HandleBufferAttach)(pdp, pcp, ba);
|
||||
changed = 1;
|
||||
}
|
||||
|
||||
pdp->dri2.tail = tail;
|
||||
|
||||
/* FIXME: Return whether we changed anything. This check always
|
||||
* returns true if we received events, but we could refine the
|
||||
* check to only return TRUE if the drawable actually changed. */
|
||||
|
||||
return total > 0;
|
||||
return changed || last_ba;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -430,6 +406,30 @@ __driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp)
|
||||
/*****************************************************************/
|
||||
/*@{*/
|
||||
|
||||
static void driReportDamage(__DRIdrawable *pdp,
|
||||
struct drm_clip_rect *pClipRects, int numClipRects)
|
||||
{
|
||||
__DRIscreen *psp = pdp->driScreenPriv;
|
||||
|
||||
/* Check that we actually have the new damage report method */
|
||||
if (psp->dri2.enabled) {
|
||||
(*psp->dri2.loader->postDamage)(pdp,
|
||||
pClipRects,
|
||||
numClipRects,
|
||||
pdp->loaderPrivate);
|
||||
} else if (psp->damage) {
|
||||
/* Report the damage. Currently, all our drivers draw
|
||||
* directly to the front buffer, so we report the damage there
|
||||
* rather than to the backing storein (if any).
|
||||
*/
|
||||
(*psp->damage->reportDamage)(pdp,
|
||||
pdp->x, pdp->y,
|
||||
pClipRects, numClipRects,
|
||||
GL_TRUE, pdp->loaderPrivate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Swap buffers.
|
||||
*
|
||||
@@ -440,49 +440,28 @@ __driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp)
|
||||
*
|
||||
* Is called directly from glXSwapBuffers().
|
||||
*/
|
||||
static void driSwapBuffers(__DRIdrawable *drawable)
|
||||
static void driSwapBuffers(__DRIdrawable *dPriv)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = drawable->private;
|
||||
__DRIscreenPrivate *psp = dPriv->driScreenPriv;
|
||||
drm_clip_rect_t rect;
|
||||
__DRIscreen *psp = dPriv->driScreenPriv;
|
||||
|
||||
if (!dPriv->numClipRects)
|
||||
return;
|
||||
|
||||
dPriv->swapBuffers(dPriv);
|
||||
psp->DriverAPI.SwapBuffers(dPriv);
|
||||
|
||||
/* Check that we actually have the new damage report method */
|
||||
if (psp->damage == NULL)
|
||||
return;
|
||||
|
||||
/* Assume it's affecting the whole drawable for now */
|
||||
rect.x1 = 0;
|
||||
rect.y1 = 0;
|
||||
rect.x2 = rect.x1 + dPriv->w;
|
||||
rect.y2 = rect.y1 + dPriv->h;
|
||||
|
||||
/* Report the damage. Currently, all our drivers draw directly to the
|
||||
* front buffer, so we report the damage there rather than to the backing
|
||||
* store (if any).
|
||||
*/
|
||||
(*psp->damage->reportDamage)(dPriv->pdraw,
|
||||
dPriv->x, dPriv->y, &rect, 1, GL_TRUE);
|
||||
driReportDamage(dPriv, dPriv->pClipRects, dPriv->numClipRects);
|
||||
}
|
||||
|
||||
static int driDrawableGetMSC( __DRIscreen *screen, __DRIdrawable *drawable,
|
||||
static int driDrawableGetMSC( __DRIscreen *sPriv, __DRIdrawable *dPriv,
|
||||
int64_t *msc )
|
||||
{
|
||||
__DRIscreenPrivate *sPriv = screen->private;
|
||||
__DRIdrawablePrivate *dPriv = drawable->private;
|
||||
|
||||
return sPriv->DriverAPI.GetDrawableMSC(sPriv, dPriv, msc);
|
||||
}
|
||||
|
||||
static int driWaitForMSC(__DRIdrawable *drawable, int64_t target_msc,
|
||||
static int driWaitForMSC(__DRIdrawable *dPriv, int64_t target_msc,
|
||||
int64_t divisor, int64_t remainder,
|
||||
int64_t * msc, int64_t * sbc)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = drawable->private;
|
||||
__DRIswapInfo sInfo;
|
||||
int status;
|
||||
|
||||
@@ -510,11 +489,18 @@ const __DRImediaStreamCounterExtension driMediaStreamCounterExtension = {
|
||||
driDrawableGetMSC,
|
||||
};
|
||||
|
||||
static void driCopySubBuffer(__DRIdrawable *drawable,
|
||||
static void driCopySubBuffer(__DRIdrawable *dPriv,
|
||||
int x, int y, int w, int h)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = drawable->private;
|
||||
drm_clip_rect_t rect;
|
||||
|
||||
dPriv->driScreenPriv->DriverAPI.CopySubBuffer(dPriv, x, y, w, h);
|
||||
|
||||
rect.x1 = x;
|
||||
rect.y1 = y;
|
||||
rect.x2 = x + w;
|
||||
rect.y2 = y + w;
|
||||
driReportDamage(dPriv, &rect, 1);
|
||||
}
|
||||
|
||||
const __DRIcopySubBufferExtension driCopySubBufferExtension = {
|
||||
@@ -522,18 +508,14 @@ const __DRIcopySubBufferExtension driCopySubBufferExtension = {
|
||||
driCopySubBuffer
|
||||
};
|
||||
|
||||
static void driSetSwapInterval(__DRIdrawable *drawable, unsigned int interval)
|
||||
static void driSetSwapInterval(__DRIdrawable *dPriv, unsigned int interval)
|
||||
{
|
||||
__DRIdrawablePrivate *dpriv = drawable->private;
|
||||
|
||||
dpriv->swap_interval = interval;
|
||||
dPriv->swap_interval = interval;
|
||||
}
|
||||
|
||||
static unsigned int driGetSwapInterval(__DRIdrawable *drawable)
|
||||
static unsigned int driGetSwapInterval(__DRIdrawable *dPriv)
|
||||
{
|
||||
__DRIdrawablePrivate *dpriv = drawable->private;
|
||||
|
||||
return dpriv->swap_interval;
|
||||
return dPriv->swap_interval;
|
||||
}
|
||||
|
||||
const __DRIswapControlExtension driSwapControlExtension = {
|
||||
@@ -546,31 +528,25 @@ const __DRIswapControlExtension driSwapControlExtension = {
|
||||
/**
|
||||
* This is called via __DRIscreenRec's createNewDrawable pointer.
|
||||
*/
|
||||
static void *driCreateNewDrawable(__DRIscreen *screen,
|
||||
const __GLcontextModes *modes,
|
||||
__DRIdrawable *pdraw,
|
||||
drm_drawable_t hwDrawable,
|
||||
unsigned int head,
|
||||
int renderType,
|
||||
const int *attrs)
|
||||
static __DRIdrawable *
|
||||
driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
|
||||
drm_drawable_t hwDrawable, int renderType,
|
||||
const int *attrs, void *data)
|
||||
{
|
||||
__DRIscreenPrivate *psp;
|
||||
__DRIdrawablePrivate *pdp;
|
||||
|
||||
pdraw->private = NULL;
|
||||
__DRIdrawable *pdp;
|
||||
|
||||
/* Since pbuffers are not yet supported, no drawable attributes are
|
||||
* supported either.
|
||||
*/
|
||||
(void) attrs;
|
||||
|
||||
pdp = (__DRIdrawablePrivate *)_mesa_malloc(sizeof(__DRIdrawablePrivate));
|
||||
pdp = _mesa_malloc(sizeof *pdp);
|
||||
if (!pdp) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdp->loaderPrivate = data;
|
||||
pdp->hHWDrawable = hwDrawable;
|
||||
pdp->pdraw = pdraw;
|
||||
pdp->refcount = 0;
|
||||
pdp->pStamp = NULL;
|
||||
pdp->lastStamp = 0;
|
||||
@@ -586,19 +562,15 @@ static void *driCreateNewDrawable(__DRIscreen *screen,
|
||||
pdp->vblSeq = 0;
|
||||
pdp->vblFlags = 0;
|
||||
|
||||
psp = (__DRIscreenPrivate *)screen->private;
|
||||
pdp->driScreenPriv = psp;
|
||||
pdp->driContextPriv = &psp->dummyContextPriv;
|
||||
|
||||
if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, modes,
|
||||
if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes,
|
||||
renderType == GLX_PIXMAP_BIT)) {
|
||||
_mesa_free(pdp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdraw->private = pdp;
|
||||
pdraw->destroyDrawable = driDestroyDrawable;
|
||||
pdraw->swapBuffers = driSwapBuffers; /* called by glXSwapBuffers() */
|
||||
pdp->msc_base = 0;
|
||||
|
||||
/* This special default value is replaced with the configured
|
||||
@@ -607,20 +579,28 @@ static void *driCreateNewDrawable(__DRIscreen *screen,
|
||||
*/
|
||||
pdp->swap_interval = (unsigned)-1;
|
||||
|
||||
pdp->swapBuffers = psp->DriverAPI.SwapBuffers;
|
||||
|
||||
if (psp->dri2.enabled) {
|
||||
pdp->dri2.tail = head;
|
||||
pdp->pBackClipRects = _mesa_malloc(sizeof *pdp->pBackClipRects);
|
||||
}
|
||||
|
||||
return (void *) pdp;
|
||||
return pdp;
|
||||
}
|
||||
|
||||
static void
|
||||
driDestroyDrawable(__DRIdrawable *drawable)
|
||||
static __DRIdrawable *
|
||||
dri2CreateNewDrawable(__DRIscreen *screen, const __DRIconfig *config,
|
||||
unsigned int drawable_id, unsigned int head, void *data)
|
||||
{
|
||||
__DRIdrawable *pdraw;
|
||||
|
||||
pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, data);
|
||||
|
||||
pdraw->dri2.drawable_id = drawable_id;
|
||||
pdraw->dri2.tail = head;
|
||||
pdraw->pBackClipRects = _mesa_malloc(sizeof *pdraw->pBackClipRects);
|
||||
|
||||
return pdraw;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
driDestroyDrawable(__DRIdrawable *pdp)
|
||||
{
|
||||
__DRIdrawablePrivate *pdp = drawable->private;
|
||||
__DRIscreenPrivate *psp;
|
||||
|
||||
if (pdp) {
|
||||
@@ -656,10 +636,8 @@ driDestroyDrawable(__DRIdrawable *drawable)
|
||||
* drmDestroyContext(), and finally frees \p contextPrivate.
|
||||
*/
|
||||
static void
|
||||
driDestroyContext(__DRIcontext *context)
|
||||
driDestroyContext(__DRIcontext *pcp)
|
||||
{
|
||||
__DRIcontextPrivate *pcp = context->private;
|
||||
|
||||
if (pcp) {
|
||||
(*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp);
|
||||
_mesa_free(pcp);
|
||||
@@ -688,24 +666,18 @@ driDestroyContext(__DRIcontext *context)
|
||||
* context.
|
||||
*
|
||||
*/
|
||||
static void *
|
||||
driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes,
|
||||
static __DRIcontext *
|
||||
driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
|
||||
int render_type, __DRIcontext *shared,
|
||||
drm_context_t hwContext, __DRIcontext *pctx)
|
||||
drm_context_t hwContext, void *data)
|
||||
{
|
||||
__DRIcontextPrivate *pcp;
|
||||
__DRIcontextPrivate *pshare = (shared != NULL) ? shared->private : NULL;
|
||||
__DRIscreenPrivate *psp;
|
||||
void * const shareCtx = (pshare != NULL) ? pshare->driverPrivate : NULL;
|
||||
__DRIcontext *pcp;
|
||||
void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
|
||||
|
||||
psp = (__DRIscreenPrivate *)screen->private;
|
||||
|
||||
pcp = (__DRIcontextPrivate *)_mesa_malloc(sizeof(__DRIcontextPrivate));
|
||||
if (!pcp) {
|
||||
pcp = _mesa_malloc(sizeof *pcp);
|
||||
if (!pcp)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcp->hHWContext = hwContext;
|
||||
pcp->driScreenPriv = psp;
|
||||
pcp->driDrawablePriv = NULL;
|
||||
|
||||
@@ -721,28 +693,43 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes,
|
||||
/* No other fields should be used! */
|
||||
}
|
||||
|
||||
pctx->destroyContext = driDestroyContext;
|
||||
pctx->bindContext = driBindContext;
|
||||
pctx->unbindContext = driUnbindContext;
|
||||
pcp->hHWContext = hwContext;
|
||||
|
||||
if ( !(*psp->DriverAPI.CreateContext)(modes, pcp, shareCtx) ) {
|
||||
if ( !(*psp->DriverAPI.CreateContext)(&config->modes, pcp, shareCtx) ) {
|
||||
_mesa_free(pcp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pcp;
|
||||
}
|
||||
|
||||
static __DRIcontext *
|
||||
dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
|
||||
__DRIcontext *shared, void *data)
|
||||
{
|
||||
drm_context_t hwContext;
|
||||
DRM_CAS_RESULT(ret);
|
||||
|
||||
/* DRI2 doesn't use kernel with context IDs, we just need an ID that's
|
||||
* different from the kernel context ID to make drmLock() happy. */
|
||||
|
||||
do {
|
||||
hwContext = screen->dri2.lock->next_id;
|
||||
DRM_CAS(&screen->dri2.lock->next_id, hwContext, hwContext + 1, ret);
|
||||
} while (ret);
|
||||
|
||||
return driCreateNewContext(screen, config, 0, shared, hwContext, data);
|
||||
}
|
||||
|
||||
static int
|
||||
driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask)
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
static const __DRIextension **
|
||||
driGetExtensions(__DRIscreen *screen)
|
||||
{
|
||||
__DRIscreenPrivate *psp = screen->private;
|
||||
|
||||
return psp->extensions;
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
/** \name Screen handling functions */
|
||||
/*****************************************************************/
|
||||
@@ -759,10 +746,8 @@ driGetExtensions(__DRIscreen *screen)
|
||||
* This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls
|
||||
* drmClose(), and finally frees \p screenPrivate.
|
||||
*/
|
||||
static void driDestroyScreen(__DRIscreen *screen)
|
||||
static void driDestroyScreen(__DRIscreen *psp)
|
||||
{
|
||||
__DRIscreenPrivate *psp = screen->private;
|
||||
|
||||
if (psp) {
|
||||
/* No interaction with the X-server is possible at this point. This
|
||||
* routine is called after XCloseDisplay, so there is no protocol
|
||||
@@ -786,22 +771,20 @@ static void driDestroyScreen(__DRIscreen *screen)
|
||||
}
|
||||
|
||||
static void
|
||||
setupLoaderExtensions(__DRIscreenPrivate *psp,
|
||||
setupLoaderExtensions(__DRIscreen *psp,
|
||||
const __DRIextension **extensions)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; extensions[i]; i++) {
|
||||
if (strcmp(extensions[i]->name, __DRI_CONTEXT_MODES) == 0)
|
||||
psp->contextModes = (__DRIcontextModesExtension *) extensions[i];
|
||||
if (strcmp(extensions[i]->name, __DRI_GET_DRAWABLE_INFO) == 0)
|
||||
psp->getDrawableInfo = (__DRIgetDrawableInfoExtension *) extensions[i];
|
||||
if (strcmp(extensions[i]->name, __DRI_DAMAGE) == 0)
|
||||
psp->damage = (__DRIdamageExtension *) extensions[i];
|
||||
if (strcmp(extensions[i]->name, __DRI_SYSTEM_TIME) == 0)
|
||||
psp->systemTime = (__DRIsystemTimeExtension *) extensions[i];
|
||||
if (strcmp(extensions[i]->name, __DRI_CORE_DRI2) == 0)
|
||||
psp->dri2.core = (__DRIcoreDRI2Extension *) extensions[i];
|
||||
if (strcmp(extensions[i]->name, __DRI_LOADER) == 0)
|
||||
psp->dri2.loader = (__DRIloaderExtension *) extensions[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -836,26 +819,24 @@ setupLoaderExtensions(__DRIscreenPrivate *psp,
|
||||
* function. Since the name of this function is versioned, it is
|
||||
* impossible for a loader that is too old to even load this driver.
|
||||
*/
|
||||
PUBLIC
|
||||
void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc,
|
||||
const __DRIversion * ddx_version,
|
||||
const __DRIversion * dri_version,
|
||||
const __DRIversion * drm_version,
|
||||
const __DRIframebuffer * frame_buffer,
|
||||
drmAddress pSAREA, int fd,
|
||||
const __DRIextension ** extensions,
|
||||
__GLcontextModes ** driver_modes )
|
||||
|
||||
static __DRIscreen *
|
||||
driCreateNewScreen(int scrn,
|
||||
const __DRIversion *ddx_version,
|
||||
const __DRIversion *dri_version,
|
||||
const __DRIversion *drm_version,
|
||||
const __DRIframebuffer *frame_buffer,
|
||||
drmAddress pSAREA, int fd,
|
||||
const __DRIextension **extensions,
|
||||
const __DRIconfig ***driver_modes,
|
||||
void *loaderPrivate)
|
||||
{
|
||||
__DRIscreenPrivate *psp;
|
||||
static const __DRIextension *emptyExtensionList[] = { NULL };
|
||||
__DRIscreen *psp;
|
||||
|
||||
psp = _mesa_malloc(sizeof(*psp));
|
||||
psp = _mesa_malloc(sizeof *psp);
|
||||
if (!psp)
|
||||
return NULL;
|
||||
|
||||
psp->psc = psc;
|
||||
|
||||
setupLoaderExtensions(psp, extensions);
|
||||
|
||||
/*
|
||||
@@ -893,12 +874,9 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc,
|
||||
*/
|
||||
psp->dummyContextPriv.driScreenPriv = NULL;
|
||||
|
||||
psc->destroyScreen = driDestroyScreen;
|
||||
psc->getExtensions = driGetExtensions;
|
||||
psc->createNewDrawable = driCreateNewDrawable;
|
||||
psc->createNewContext = driCreateNewContext;
|
||||
psp->DriverAPI = driDriverAPI;
|
||||
|
||||
*driver_modes = __driDriverInitScreen(psp);
|
||||
*driver_modes = driDriverAPI.InitScreen(psp);
|
||||
if (*driver_modes == NULL) {
|
||||
_mesa_free(psp);
|
||||
return NULL;
|
||||
@@ -907,20 +885,18 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc,
|
||||
return psp;
|
||||
}
|
||||
|
||||
PUBLIC void *
|
||||
__DRI2_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
|
||||
int fd, unsigned int sarea_handle,
|
||||
const __DRIextension **extensions,
|
||||
__GLcontextModes **driver_modes)
|
||||
|
||||
static __DRIscreen *
|
||||
dri2CreateNewScreen(int scrn, int fd, unsigned int sarea_handle,
|
||||
const __DRIextension **extensions,
|
||||
const __DRIconfig ***driver_configs, void *data)
|
||||
{
|
||||
__DRIscreenPrivate *psp;
|
||||
static const __DRIextension *emptyExtensionList[] = { NULL };
|
||||
__DRIscreen *psp;
|
||||
unsigned int *p;
|
||||
drmVersionPtr version;
|
||||
__GLcontextModes *(*initScreen)(__DRIscreenPrivate *psc);
|
||||
|
||||
initScreen = dlsym(NULL, "__dri2DriverInitScreen");
|
||||
if (initScreen == NULL)
|
||||
if (driDriverAPI.InitScreen2 == NULL)
|
||||
return NULL;
|
||||
|
||||
psp = _mesa_malloc(sizeof(*psp));
|
||||
@@ -929,8 +905,6 @@ __DRI2_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
|
||||
|
||||
setupLoaderExtensions(psp, extensions);
|
||||
|
||||
psp->psc = psc;
|
||||
|
||||
version = drmGetVersion(fd);
|
||||
if (version) {
|
||||
psp->drm_version.major = version->version_major;
|
||||
@@ -972,22 +946,167 @@ __DRI2_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
|
||||
|
||||
psp->lock = (drmLock *) &psp->dri2.lock->lock;
|
||||
|
||||
psc->destroyScreen = driDestroyScreen;
|
||||
psc->getExtensions = driGetExtensions;
|
||||
psc->createNewDrawable = driCreateNewDrawable;
|
||||
psc->createNewContext = driCreateNewContext;
|
||||
|
||||
*driver_modes = initScreen(psp);
|
||||
if (*driver_modes == NULL) {
|
||||
psp->DriverAPI = driDriverAPI;
|
||||
*driver_configs = driDriverAPI.InitScreen2(psp);
|
||||
if (*driver_configs == NULL) {
|
||||
drmBOUnmap(psp->fd, &psp->dri2.sareaBO);
|
||||
drmBOUnreference(psp->fd, &psp->dri2.sareaBO);
|
||||
_mesa_free(psp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
psp->DriverAPI = driDriverAPI;
|
||||
|
||||
return psp;
|
||||
}
|
||||
|
||||
static const __DRIextension **driGetExtensions(__DRIscreen *psp)
|
||||
{
|
||||
return psp->extensions;
|
||||
}
|
||||
|
||||
#define __ATTRIB(attrib, field) \
|
||||
{ attrib, offsetof(__GLcontextModes, field) }
|
||||
|
||||
static const struct { unsigned int attrib, offset; } attribMap[] = {
|
||||
__ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits),
|
||||
__ATTRIB(__DRI_ATTRIB_LEVEL, level),
|
||||
__ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits),
|
||||
__ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits),
|
||||
__ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits),
|
||||
__ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits),
|
||||
__ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits),
|
||||
__ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits),
|
||||
__ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers),
|
||||
__ATTRIB(__DRI_ATTRIB_SAMPLES, samples),
|
||||
__ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode),
|
||||
__ATTRIB(__DRI_ATTRIB_STEREO, stereoMode),
|
||||
__ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentPixel),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue),
|
||||
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
|
||||
__ATTRIB(__DRI_ATTRIB_FLOAT_MODE, floatMode),
|
||||
__ATTRIB(__DRI_ATTRIB_RED_MASK, redMask),
|
||||
__ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask),
|
||||
__ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask),
|
||||
__ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask),
|
||||
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
|
||||
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
|
||||
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
|
||||
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
|
||||
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
|
||||
__ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
|
||||
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
|
||||
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
|
||||
__ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, bindToMipmapTexture),
|
||||
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS, bindToTextureTargets),
|
||||
__ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
|
||||
|
||||
/* The struct field doesn't matter here, these are handled by the
|
||||
* switch in driGetConfigAttribIndex. We need them in the array
|
||||
* so the iterator includes them though.*/
|
||||
__ATTRIB(__DRI_ATTRIB_RENDER_TYPE, level),
|
||||
__ATTRIB(__DRI_ATTRIB_CONFIG_CAVEAT, level),
|
||||
__ATTRIB(__DRI_ATTRIB_SWAP_METHOD, level)
|
||||
};
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
|
||||
static int
|
||||
driGetConfigAttribIndex(const __DRIconfig *config,
|
||||
unsigned int index, unsigned int *value)
|
||||
{
|
||||
switch (attribMap[index].attrib) {
|
||||
case __DRI_ATTRIB_RENDER_TYPE:
|
||||
if (config->modes.rgbMode)
|
||||
*value = __DRI_ATTRIB_RGBA_BIT;
|
||||
else
|
||||
*value = __DRI_ATTRIB_COLOR_INDEX_BIT;
|
||||
break;
|
||||
case __DRI_ATTRIB_CONFIG_CAVEAT:
|
||||
if (config->modes.visualRating == GLX_NON_CONFORMANT_CONFIG)
|
||||
*value = __DRI_ATTRIB_NON_CONFORMANT_CONFIG;
|
||||
else if (config->modes.visualRating == GLX_SLOW_CONFIG)
|
||||
*value = __DRI_ATTRIB_SLOW_BIT;
|
||||
else
|
||||
*value = 0;
|
||||
break;
|
||||
case __DRI_ATTRIB_SWAP_METHOD:
|
||||
break;
|
||||
|
||||
default:
|
||||
*value = *(unsigned int *)
|
||||
((char *) &config->modes + attribMap[index].offset);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
driGetConfigAttrib(const __DRIconfig *config,
|
||||
unsigned int attrib, unsigned int *value)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(attribMap); i++)
|
||||
if (attribMap[i].attrib == attrib)
|
||||
return driGetConfigAttribIndex(config, i, value);
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
driIndexConfigAttrib(const __DRIconfig *config, int index,
|
||||
unsigned int *attrib, unsigned int *value)
|
||||
{
|
||||
if (index >= 0 && index < ARRAY_SIZE(attribMap)) {
|
||||
*attrib = attribMap[index].attrib;
|
||||
return driGetConfigAttribIndex(config, index, value);
|
||||
}
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
const __DRIlegacyExtension driLegacyExtension = {
|
||||
{ __DRI_LEGACY, __DRI_LEGACY_VERSION },
|
||||
driCreateNewScreen,
|
||||
driCreateNewDrawable,
|
||||
driCreateNewContext
|
||||
};
|
||||
|
||||
const __DRIcoreExtension driCoreExtension = {
|
||||
{ __DRI_CORE, __DRI_CORE_VERSION },
|
||||
dri2CreateNewScreen,
|
||||
driDestroyScreen,
|
||||
driGetExtensions,
|
||||
driGetConfigAttrib,
|
||||
driIndexConfigAttrib,
|
||||
dri2CreateNewDrawable,
|
||||
driDestroyDrawable,
|
||||
driSwapBuffers,
|
||||
dri2CreateNewContext,
|
||||
driCopyContext,
|
||||
driDestroyContext,
|
||||
driBindContext,
|
||||
driUnbindContext
|
||||
};
|
||||
|
||||
/* This is the table of extensions that the loader will dlsym() for. */
|
||||
PUBLIC const __DRIextension *__driDriverExtensions[] = {
|
||||
&driCoreExtension.base,
|
||||
&driLegacyExtension.base,
|
||||
NULL
|
||||
};
|
||||
|
||||
static int
|
||||
driFrameTracking(__DRIdrawable *drawable, GLboolean enable)
|
||||
{
|
||||
@@ -995,14 +1114,13 @@ driFrameTracking(__DRIdrawable *drawable, GLboolean enable)
|
||||
}
|
||||
|
||||
static int
|
||||
driQueryFrameTracking(__DRIdrawable *drawable,
|
||||
driQueryFrameTracking(__DRIdrawable *dpriv,
|
||||
int64_t * sbc, int64_t * missedFrames,
|
||||
float * lastMissedUsage, float * usage)
|
||||
{
|
||||
__DRIswapInfo sInfo;
|
||||
int status;
|
||||
int64_t ust;
|
||||
__DRIdrawablePrivate * dpriv = drawable->private;
|
||||
__DRIscreenPrivate *psp = dpriv->driScreenPriv;
|
||||
|
||||
status = dpriv->driScreenPriv->DriverAPI.GetSwapInfo( dpriv, & sInfo );
|
||||
@@ -1062,7 +1180,7 @@ driCalculateSwapUsage( __DRIdrawablePrivate *dPriv, int64_t last_swap_ust,
|
||||
float usage = 1.0;
|
||||
__DRIscreenPrivate *psp = dPriv->driScreenPriv;
|
||||
|
||||
if ( (*psp->systemTime->getMSCRate)(dPriv->pdraw, &n, &d) ) {
|
||||
if ( (*psp->systemTime->getMSCRate)(dPriv, &n, &d, dPriv->loaderPrivate) ) {
|
||||
interval = (dPriv->swap_interval != 0) ? dPriv->swap_interval : 1;
|
||||
|
||||
|
||||
|
||||
@@ -59,27 +59,19 @@
|
||||
|
||||
#define GLX_BAD_CONTEXT 5
|
||||
|
||||
typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
|
||||
typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
|
||||
typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
|
||||
typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
|
||||
typedef struct __DRIswapInfoRec __DRIswapInfo;
|
||||
typedef struct __DRIutilversionRec2 __DRIutilversion2;
|
||||
|
||||
|
||||
/**
|
||||
* Driver specific entry point. Implemented by the driver. Called
|
||||
* from the top level createNewScreen entry point to initialize the
|
||||
* __DRIscreenPrivate struct.
|
||||
*/
|
||||
extern __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp);
|
||||
|
||||
/** Ditto for DRI2 capable drivers. */
|
||||
extern __GLcontextModes *__dri2DriverInitScreen(__DRIscreenPrivate *psp);
|
||||
/* Typedefs to avoid rewriting the world. */
|
||||
typedef struct __DRIscreenRec __DRIscreenPrivate;
|
||||
typedef struct __DRIdrawableRec __DRIdrawablePrivate;
|
||||
typedef struct __DRIcontextRec __DRIcontextPrivate;
|
||||
|
||||
/**
|
||||
* Extensions.
|
||||
*/
|
||||
extern const __DRIlegacyExtension driLegacyExtension;
|
||||
extern const __DRIcoreExtension driCoreExtension;
|
||||
extern const __DRIextension driReadDrawableExtension;
|
||||
extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
|
||||
extern const __DRIswapControlExtension driSwapControlExtension;
|
||||
@@ -100,7 +92,7 @@ extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension;
|
||||
/**
|
||||
* Utility macro to validate the drawable information.
|
||||
*
|
||||
* See __DRIdrawablePrivate::pStamp and __DRIdrawablePrivate::lastStamp.
|
||||
* See __DRIdrawable::pStamp and __DRIdrawable::lastStamp.
|
||||
*/
|
||||
#define DRI_VALIDATE_DRAWABLE_INFO(psp, pdp) \
|
||||
do { \
|
||||
@@ -129,74 +121,76 @@ do { \
|
||||
* this structure.
|
||||
*/
|
||||
struct __DriverAPIRec {
|
||||
const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
|
||||
|
||||
/**
|
||||
* Screen destruction callback
|
||||
*/
|
||||
void (*DestroyScreen)(__DRIscreenPrivate *driScrnPriv);
|
||||
void (*DestroyScreen)(__DRIscreen *driScrnPriv);
|
||||
|
||||
/**
|
||||
* Context creation callback
|
||||
*/
|
||||
GLboolean (*CreateContext)(const __GLcontextModes *glVis,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
__DRIcontext *driContextPriv,
|
||||
void *sharedContextPrivate);
|
||||
|
||||
/**
|
||||
* Context destruction callback
|
||||
*/
|
||||
void (*DestroyContext)(__DRIcontextPrivate *driContextPriv);
|
||||
void (*DestroyContext)(__DRIcontext *driContextPriv);
|
||||
|
||||
/**
|
||||
* Buffer (drawable) creation callback
|
||||
*/
|
||||
GLboolean (*CreateBuffer)(__DRIscreenPrivate *driScrnPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
|
||||
__DRIdrawable *driDrawPriv,
|
||||
const __GLcontextModes *glVis,
|
||||
GLboolean pixmapBuffer);
|
||||
|
||||
/**
|
||||
* Buffer (drawable) destruction callback
|
||||
*/
|
||||
void (*DestroyBuffer)(__DRIdrawablePrivate *driDrawPriv);
|
||||
void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
|
||||
|
||||
/**
|
||||
* Buffer swapping callback
|
||||
*/
|
||||
void (*SwapBuffers)(__DRIdrawablePrivate *driDrawPriv);
|
||||
void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
|
||||
|
||||
/**
|
||||
* Context activation callback
|
||||
*/
|
||||
GLboolean (*MakeCurrent)(__DRIcontextPrivate *driContextPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
__DRIdrawablePrivate *driReadPriv);
|
||||
GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
|
||||
__DRIdrawable *driDrawPriv,
|
||||
__DRIdrawable *driReadPriv);
|
||||
|
||||
/**
|
||||
* Context unbinding callback
|
||||
*/
|
||||
GLboolean (*UnbindContext)(__DRIcontextPrivate *driContextPriv);
|
||||
GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
|
||||
|
||||
/**
|
||||
* Retrieves statistics about buffer swap operations. Required if
|
||||
* GLX_OML_sync_control or GLX_MESA_swap_frame_usage is supported.
|
||||
*/
|
||||
int (*GetSwapInfo)( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
|
||||
int (*GetSwapInfo)( __DRIdrawable *dPriv, __DRIswapInfo * sInfo );
|
||||
|
||||
|
||||
/**
|
||||
* These are required if GLX_OML_sync_control is supported.
|
||||
*/
|
||||
/*@{*/
|
||||
int (*WaitForMSC)( __DRIdrawablePrivate *priv, int64_t target_msc,
|
||||
int (*WaitForMSC)( __DRIdrawable *priv, int64_t target_msc,
|
||||
int64_t divisor, int64_t remainder,
|
||||
int64_t * msc );
|
||||
int (*WaitForSBC)( __DRIdrawablePrivate *priv, int64_t target_sbc,
|
||||
int (*WaitForSBC)( __DRIdrawable *priv, int64_t target_sbc,
|
||||
int64_t * msc, int64_t * sbc );
|
||||
|
||||
int64_t (*SwapBuffersMSC)( __DRIdrawablePrivate *priv, int64_t target_msc,
|
||||
int64_t (*SwapBuffersMSC)( __DRIdrawable *priv, int64_t target_msc,
|
||||
int64_t divisor, int64_t remainder );
|
||||
/*@}*/
|
||||
void (*CopySubBuffer)(__DRIdrawablePrivate *driDrawPriv,
|
||||
void (*CopySubBuffer)(__DRIdrawable *driDrawPriv,
|
||||
int x, int y, int w, int h);
|
||||
|
||||
/**
|
||||
@@ -204,21 +198,26 @@ struct __DriverAPIRec {
|
||||
* level DRM driver (e.g. pipe info). Required if
|
||||
* GLX_SGI_video_sync or GLX_OML_sync_control is supported.
|
||||
*/
|
||||
int (*GetDrawableMSC) ( __DRIscreenPrivate * priv,
|
||||
__DRIdrawablePrivate *drawablePrivate,
|
||||
int (*GetDrawableMSC) ( __DRIscreen * priv,
|
||||
__DRIdrawable *drawablePrivate,
|
||||
int64_t *count);
|
||||
|
||||
|
||||
|
||||
/* DRI2 Entry points */
|
||||
void (*HandleDrawableConfig)(__DRIdrawablePrivate *dPriv,
|
||||
__DRIcontextPrivate *pcp,
|
||||
const __DRIconfig **(*InitScreen2) (__DRIscreen * priv);
|
||||
void (*HandleDrawableConfig)(__DRIdrawable *dPriv,
|
||||
__DRIcontext *pcp,
|
||||
__DRIDrawableConfigEvent *event);
|
||||
|
||||
void (*HandleBufferAttach)(__DRIdrawablePrivate *dPriv,
|
||||
__DRIcontextPrivate *pcp,
|
||||
void (*HandleBufferAttach)(__DRIdrawable *dPriv,
|
||||
__DRIcontext *pcp,
|
||||
__DRIBufferAttachEvent *ba);
|
||||
|
||||
};
|
||||
|
||||
extern const struct __DriverAPIRec driDriverAPI;
|
||||
|
||||
|
||||
struct __DRIswapInfoRec {
|
||||
/**
|
||||
@@ -254,7 +253,7 @@ struct __DRIswapInfoRec {
|
||||
/**
|
||||
* Per-drawable private DRI driver information.
|
||||
*/
|
||||
struct __DRIdrawablePrivateRec {
|
||||
struct __DRIdrawableRec {
|
||||
/**
|
||||
* Kernel drawable handle
|
||||
*/
|
||||
@@ -268,9 +267,10 @@ struct __DRIdrawablePrivateRec {
|
||||
void *driverPrivate;
|
||||
|
||||
/**
|
||||
* X's drawable ID associated with this private drawable.
|
||||
* Private data from the loader. We just hold on to it and pass
|
||||
* it back when calling into loader provided functions.
|
||||
*/
|
||||
__DRIdrawable *pdraw;
|
||||
void *loaderPrivate;
|
||||
|
||||
/**
|
||||
* Reference count for number of context's currently bound to this
|
||||
@@ -295,7 +295,7 @@ struct __DRIdrawablePrivateRec {
|
||||
/**
|
||||
* Last value of the stamp.
|
||||
*
|
||||
* If this differs from the value stored at __DRIdrawablePrivate::pStamp,
|
||||
* If this differs from the value stored at __DRIdrawable::pStamp,
|
||||
* then the drawable information has been modified by the X server, and the
|
||||
* drawable information (below) should be retrieved from the X server.
|
||||
*/
|
||||
@@ -357,17 +357,12 @@ struct __DRIdrawablePrivateRec {
|
||||
/**
|
||||
* Pointer to context to which this drawable is currently bound.
|
||||
*/
|
||||
__DRIcontextPrivate *driContextPriv;
|
||||
__DRIcontext *driContextPriv;
|
||||
|
||||
/**
|
||||
* Pointer to screen on which this drawable was created.
|
||||
*/
|
||||
__DRIscreenPrivate *driScreenPriv;
|
||||
|
||||
/**
|
||||
* Called via glXSwapBuffers().
|
||||
*/
|
||||
void (*swapBuffers)( __DRIdrawablePrivate *dPriv );
|
||||
__DRIscreen *driScreenPriv;
|
||||
|
||||
/**
|
||||
* Controls swap interval as used by GLX_SGI_swap_control and
|
||||
@@ -376,13 +371,14 @@ struct __DRIdrawablePrivateRec {
|
||||
unsigned int swap_interval;
|
||||
struct {
|
||||
unsigned int tail;
|
||||
unsigned int drawable_id;
|
||||
} dri2;
|
||||
};
|
||||
|
||||
/**
|
||||
* Per-context private driver information.
|
||||
*/
|
||||
struct __DRIcontextPrivateRec {
|
||||
struct __DRIcontextRec {
|
||||
/**
|
||||
* Kernel context handle used to access the device lock.
|
||||
*/
|
||||
@@ -401,23 +397,23 @@ struct __DRIcontextPrivateRec {
|
||||
/**
|
||||
* Pointer to drawable currently bound to this context for drawing.
|
||||
*/
|
||||
__DRIdrawablePrivate *driDrawablePriv;
|
||||
__DRIdrawable *driDrawablePriv;
|
||||
|
||||
/**
|
||||
* Pointer to drawable currently bound to this context for reading.
|
||||
*/
|
||||
__DRIdrawablePrivate *driReadablePriv;
|
||||
__DRIdrawable *driReadablePriv;
|
||||
|
||||
/**
|
||||
* Pointer to screen on which this context was created.
|
||||
*/
|
||||
__DRIscreenPrivate *driScreenPriv;
|
||||
__DRIscreen *driScreenPriv;
|
||||
};
|
||||
|
||||
/**
|
||||
* Per-screen private driver information.
|
||||
*/
|
||||
struct __DRIscreenPrivateRec {
|
||||
struct __DRIscreenRec {
|
||||
/**
|
||||
* Current screen's number
|
||||
*/
|
||||
@@ -428,6 +424,7 @@ struct __DRIscreenPrivateRec {
|
||||
*/
|
||||
struct __DriverAPIRec DriverAPI;
|
||||
|
||||
const __DRIextension **extensions;
|
||||
/**
|
||||
* DDX / 2D driver version information.
|
||||
*/
|
||||
@@ -504,7 +501,7 @@ struct __DRIscreenPrivateRec {
|
||||
* context is created when the first "real" context is created on this
|
||||
* screen.
|
||||
*/
|
||||
__DRIcontextPrivate dummyContextPriv;
|
||||
__DRIcontext dummyContextPriv;
|
||||
|
||||
/**
|
||||
* Device-dependent private information (not stored in the SAREA).
|
||||
@@ -518,13 +515,7 @@ struct __DRIscreenPrivateRec {
|
||||
*/
|
||||
__DRIscreen *psc;
|
||||
|
||||
/**
|
||||
* Extensions provided by this driver.
|
||||
*/
|
||||
const __DRIextension **extensions;
|
||||
|
||||
/* Extensions provided by the loader. */
|
||||
const __DRIcontextModesExtension *contextModes;
|
||||
const __DRIgetDrawableInfoExtension *getDrawableInfo;
|
||||
const __DRIsystemTimeExtension *systemTime;
|
||||
const __DRIdamageExtension *damage;
|
||||
@@ -537,13 +528,16 @@ struct __DRIscreenPrivateRec {
|
||||
void *sarea;
|
||||
__DRIEventBuffer *buffer;
|
||||
__DRILock *lock;
|
||||
__DRIcoreDRI2Extension *core;
|
||||
__DRIloaderExtension *loader;
|
||||
} dri2;
|
||||
|
||||
/* The lock actually in use, old sarea or DRI2 */
|
||||
drmLock *lock;
|
||||
};
|
||||
|
||||
struct __DRIconfigRec {
|
||||
__GLcontextModes modes;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to store a version which includes a major range instead of a single
|
||||
@@ -562,13 +556,13 @@ __driUtilMessage(const char *f, ...);
|
||||
|
||||
|
||||
extern void
|
||||
__driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp);
|
||||
__driUtilUpdateDrawableInfo(__DRIdrawable *pdp);
|
||||
|
||||
extern int
|
||||
__driParseEvents(__DRIcontextPrivate *psp, __DRIdrawablePrivate *pdp);
|
||||
__driParseEvents(__DRIcontext *psp, __DRIdrawable *pdp);
|
||||
|
||||
extern float
|
||||
driCalculateSwapUsage( __DRIdrawablePrivate *dPriv,
|
||||
driCalculateSwapUsage( __DRIdrawable *dPriv,
|
||||
int64_t last_swap_ust, int64_t current_ust );
|
||||
|
||||
#endif /* _DRI_UTIL_H_ */
|
||||
|
||||
@@ -467,8 +467,6 @@ GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a set of \c __GLcontextModes that a driver will expose.
|
||||
*
|
||||
@@ -536,13 +534,11 @@ GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
|
||||
* \c GL_UNSIGNED_3BYTE_8_8_8, \c GL_4FLOAT_32_32_32_32,
|
||||
* \c GL_4HALF_16_16_16_16, etc. We can cross that bridge when we come to it.
|
||||
*/
|
||||
GLboolean
|
||||
driFillInModes( __GLcontextModes ** ptr_to_modes,
|
||||
GLenum fb_format, GLenum fb_type,
|
||||
const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
|
||||
unsigned num_depth_stencil_bits,
|
||||
const GLenum * db_modes, unsigned num_db_modes,
|
||||
int visType )
|
||||
__DRIconfig **
|
||||
driCreateConfigs(GLenum fb_format, GLenum fb_type,
|
||||
const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
|
||||
unsigned num_depth_stencil_bits,
|
||||
const GLenum * db_modes, unsigned num_db_modes)
|
||||
{
|
||||
static const u_int8_t bits_table[3][4] = {
|
||||
/* R G B A */
|
||||
@@ -606,16 +602,18 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
|
||||
const u_int8_t * bits;
|
||||
const u_int32_t * masks;
|
||||
const int index = fb_type & 0x07;
|
||||
__GLcontextModes * modes = *ptr_to_modes;
|
||||
__DRIconfig **configs, **c;
|
||||
__GLcontextModes *modes;
|
||||
unsigned i;
|
||||
unsigned j;
|
||||
unsigned k;
|
||||
|
||||
unsigned num_modes;
|
||||
unsigned num_accum_bits = 2;
|
||||
|
||||
if ( bytes_per_pixel[ index ] == 0 ) {
|
||||
fprintf( stderr, "[%s:%u] Framebuffer type 0x%04x has 0 bytes per pixel.\n",
|
||||
__FUNCTION__, __LINE__, fb_type );
|
||||
return GL_FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -653,14 +651,23 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
|
||||
default:
|
||||
fprintf( stderr, "[%s:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.\n",
|
||||
__FUNCTION__, __LINE__, fb_format );
|
||||
return GL_FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits;
|
||||
configs = _mesa_calloc((num_modes + 1) * sizeof *configs);
|
||||
if (configs == NULL)
|
||||
return NULL;
|
||||
|
||||
c = configs;
|
||||
for ( k = 0 ; k < num_depth_stencil_bits ; k++ ) {
|
||||
for ( i = 0 ; i < num_db_modes ; i++ ) {
|
||||
for ( j = 0 ; j < 2 ; j++ ) {
|
||||
for ( j = 0 ; j < num_accum_bits ; j++ ) {
|
||||
*c = _mesa_malloc (sizeof **c);
|
||||
modes = &(*c)->modes;
|
||||
c++;
|
||||
|
||||
memset(modes, 0, sizeof *modes);
|
||||
modes->redBits = bits[0];
|
||||
modes->greenBits = bits[1];
|
||||
modes->blueBits = bits[2];
|
||||
@@ -681,7 +688,13 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
|
||||
modes->stencilBits = stencil_bits[k];
|
||||
modes->depthBits = depth_bits[k];
|
||||
|
||||
modes->visualType = visType;
|
||||
modes->transparentPixel = GLX_NONE;
|
||||
modes->transparentRed = GLX_DONT_CARE;
|
||||
modes->transparentGreen = GLX_DONT_CARE;
|
||||
modes->transparentBlue = GLX_DONT_CARE;
|
||||
modes->transparentAlpha = GLX_DONT_CARE;
|
||||
modes->transparentIndex = GLX_DONT_CARE;
|
||||
modes->visualType = GLX_DONT_CARE;
|
||||
modes->renderType = GLX_RGBA_BIT;
|
||||
modes->drawableType = GLX_WINDOW_BIT;
|
||||
modes->rgbMode = GL_TRUE;
|
||||
@@ -701,11 +714,44 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
|
||||
modes->haveDepthBuffer = (modes->depthBits > 0);
|
||||
modes->haveStencilBuffer = (modes->stencilBits > 0);
|
||||
|
||||
modes = modes->next;
|
||||
modes->bindToTextureRgb = GL_TRUE;
|
||||
modes->bindToTextureRgba = GL_TRUE;
|
||||
modes->bindToMipmapTexture = GL_FALSE;
|
||||
modes->bindToTextureTargets = modes->rgbMode ?
|
||||
__DRI_ATTRIB_TEXTURE_1D_BIT |
|
||||
__DRI_ATTRIB_TEXTURE_2D_BIT |
|
||||
__DRI_ATTRIB_TEXTURE_RECTANGLE_BIT :
|
||||
0;
|
||||
}
|
||||
}
|
||||
}
|
||||
*c = NULL;
|
||||
|
||||
*ptr_to_modes = modes;
|
||||
return GL_TRUE;
|
||||
return configs;
|
||||
}
|
||||
|
||||
const __DRIconfig **driConcatConfigs(__DRIconfig **a, __DRIconfig **b)
|
||||
{
|
||||
const __DRIconfig **all;
|
||||
int i, j, index;
|
||||
|
||||
i = 0;
|
||||
while (a[i] != NULL)
|
||||
i++;
|
||||
j = 0;
|
||||
while (b[j] != NULL)
|
||||
j++;
|
||||
|
||||
all = _mesa_malloc((i + j + 1) * sizeof *all);
|
||||
index = 0;
|
||||
for (i = 0; a[i] != NULL; i++)
|
||||
all[index++] = a[i];
|
||||
for (j = 0; b[j] != NULL; j++)
|
||||
all[index++] = b[j];
|
||||
all[index++] = NULL;
|
||||
|
||||
_mesa_free(a);
|
||||
_mesa_free(b);
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
@@ -112,10 +112,12 @@ extern GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
|
||||
GLint *x, GLint *y,
|
||||
GLsizei *width, GLsizei *height );
|
||||
|
||||
extern GLboolean driFillInModes( __GLcontextModes ** modes,
|
||||
GLenum fb_format, GLenum fb_type,
|
||||
const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
|
||||
unsigned num_depth_stencil_bits,
|
||||
const GLenum * db_modes, unsigned num_db_modes, int visType );
|
||||
extern __DRIconfig **
|
||||
driCreateConfigs(GLenum fb_format, GLenum fb_type,
|
||||
const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
|
||||
unsigned num_depth_stencil_bits,
|
||||
const GLenum * db_modes, unsigned num_db_modes);
|
||||
|
||||
const __DRIconfig **driConcatConfigs(__DRIconfig **a, __DRIconfig **b);
|
||||
|
||||
#endif /* DRI_DEBUG_H */
|
||||
|
||||
@@ -604,35 +604,18 @@ void ffbXMesaUpdateState(ffbContextPtr fmesa)
|
||||
}
|
||||
}
|
||||
|
||||
static const struct __DriverAPIRec ffbAPI = {
|
||||
.DestroyScreen = ffbDestroyScreen,
|
||||
.CreateContext = ffbCreateContext,
|
||||
.DestroyContext = ffbDestroyContext,
|
||||
.CreateBuffer = ffbCreateBuffer,
|
||||
.DestroyBuffer = ffbDestroyBuffer,
|
||||
.SwapBuffers = ffbSwapBuffers,
|
||||
.MakeCurrent = ffbMakeCurrent,
|
||||
.UnbindContext = ffbUnbindContext,
|
||||
.GetSwapInfo = NULL,
|
||||
.GetDrawableMSC = NULL,
|
||||
.WaitForMSC = NULL,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
|
||||
static __GLcontextModes *
|
||||
static const __DRIconfig **
|
||||
ffbFillInModes( __DRIscreenPrivate *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer )
|
||||
{
|
||||
__GLcontextModes * modes;
|
||||
__GLcontextModes * m;
|
||||
unsigned num_modes;
|
||||
__DRIconfig **configs;
|
||||
__GLcontextModes *m;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
GLenum fb_format;
|
||||
GLenum fb_type;
|
||||
int i;
|
||||
|
||||
/* GLX_SWAP_COPY_OML is only supported because the FFB driver doesn't
|
||||
* support pageflipping at all.
|
||||
@@ -644,7 +627,6 @@ ffbFillInModes( __DRIscreenPrivate *psp,
|
||||
u_int8_t depth_bits_array[3];
|
||||
u_int8_t stencil_bits_array[3];
|
||||
|
||||
|
||||
depth_bits_array[0] = 0;
|
||||
depth_bits_array[1] = depth_bits;
|
||||
depth_bits_array[2] = depth_bits;
|
||||
@@ -660,8 +642,6 @@ ffbFillInModes( __DRIscreenPrivate *psp,
|
||||
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
|
||||
back_buffer_factor = (have_back_buffer) ? 3 : 1;
|
||||
|
||||
num_modes = depth_buffer_factor * back_buffer_factor * 4;
|
||||
|
||||
if ( pixel_bits == 16 ) {
|
||||
fb_format = GL_RGB;
|
||||
fb_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
@@ -671,35 +651,26 @@ ffbFillInModes( __DRIscreenPrivate *psp,
|
||||
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
|
||||
m = modes;
|
||||
if ( ! driFillInModes( & m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array, depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_TRUE_COLOR ) ) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
configs = driCreateConfigs(fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor);
|
||||
if (configs == NULL) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
|
||||
__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
if ( ! driFillInModes( & m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array, depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_DIRECT_COLOR ) ) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for ( m = modes ; m != NULL ; m = m->next ) {
|
||||
if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
for (i = 0; configs[i]; i++) {
|
||||
m = &configs[i]->modes;
|
||||
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
return (const __DRIconfig **) configs;
|
||||
}
|
||||
|
||||
|
||||
@@ -710,7 +681,8 @@ ffbFillInModes( __DRIscreenPrivate *psp,
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
static const __DRIconfig **
|
||||
ffbInitScreen(__DRIscreen *psp)
|
||||
{
|
||||
static const __DRIversion ddx_expected = { 0, 1, 1 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
@@ -722,10 +694,25 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
&psp->drm_version, & drm_expected ) )
|
||||
return NULL;
|
||||
|
||||
psp->DriverAPI = ffbAPI;
|
||||
|
||||
if (!ffbInitDriver(psp))
|
||||
return NULL;
|
||||
|
||||
return ffbFillInModes( psp, 32, 16, 0, GL_TRUE );
|
||||
}
|
||||
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
.InitScreen = ffbInitScreen,
|
||||
.DestroyScreen = ffbDestroyScreen,
|
||||
.CreateContext = ffbCreateContext,
|
||||
.DestroyContext = ffbDestroyContext,
|
||||
.CreateBuffer = ffbCreateBuffer,
|
||||
.DestroyBuffer = ffbDestroyBuffer,
|
||||
.SwapBuffers = ffbSwapBuffers,
|
||||
.MakeCurrent = ffbMakeCurrent,
|
||||
.UnbindContext = ffbUnbindContext,
|
||||
.GetSwapInfo = NULL,
|
||||
.GetDrawableMSC = NULL,
|
||||
.WaitForMSC = NULL,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
@@ -238,7 +238,7 @@ gammaUnbindContext( __DRIcontextPrivate *driContextPriv )
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static struct __DriverAPIRec gammaAPI = {
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
gammaInitDriver,
|
||||
gammaDestroyScreen,
|
||||
gammaCreateContext,
|
||||
|
||||
@@ -56,78 +56,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
extern const struct dri_extension card_extensions[];
|
||||
|
||||
static __GLcontextModes *fill_in_modes( __GLcontextModes *modes,
|
||||
unsigned pixel_bits,
|
||||
unsigned depth_bits,
|
||||
unsigned stencil_bits,
|
||||
const GLenum * db_modes,
|
||||
unsigned num_db_modes,
|
||||
int visType )
|
||||
{
|
||||
static const u_int8_t bits[1][4] = {
|
||||
{ 5, 6, 5, 0 }
|
||||
};
|
||||
|
||||
static const u_int32_t masks[1][4] = {
|
||||
{ 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }
|
||||
};
|
||||
|
||||
unsigned i;
|
||||
unsigned j;
|
||||
const unsigned index = 0;
|
||||
|
||||
for ( i = 0 ; i < num_db_modes ; i++ ) {
|
||||
for ( j = 0 ; j < 2 ; j++ ) {
|
||||
|
||||
modes->redBits = bits[index][0];
|
||||
modes->greenBits = bits[index][1];
|
||||
modes->blueBits = bits[index][2];
|
||||
modes->alphaBits = bits[index][3];
|
||||
modes->redMask = masks[index][0];
|
||||
modes->greenMask = masks[index][1];
|
||||
modes->blueMask = masks[index][2];
|
||||
modes->alphaMask = masks[index][3];
|
||||
modes->rgbBits = modes->redBits + modes->greenBits
|
||||
+ modes->blueBits + modes->alphaBits;
|
||||
|
||||
modes->accumRedBits = 16 * j;
|
||||
modes->accumGreenBits = 16 * j;
|
||||
modes->accumBlueBits = 16 * j;
|
||||
modes->accumAlphaBits = (masks[index][3] != 0) ? 16 * j : 0;
|
||||
modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
|
||||
|
||||
modes->stencilBits = stencil_bits;
|
||||
modes->depthBits = depth_bits;
|
||||
|
||||
modes->visualType = visType;
|
||||
modes->renderType = GLX_RGBA_BIT;
|
||||
modes->drawableType = GLX_WINDOW_BIT;
|
||||
modes->rgbMode = GL_TRUE;
|
||||
|
||||
if ( db_modes[i] == GLX_NONE ) {
|
||||
modes->doubleBufferMode = GL_FALSE;
|
||||
}
|
||||
else {
|
||||
modes->doubleBufferMode = GL_TRUE;
|
||||
modes->swapMethod = db_modes[i];
|
||||
}
|
||||
|
||||
modes = modes->next;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static __GLcontextModes *
|
||||
static const __DRIconfig **
|
||||
i810FillInModes( __DRIscreenPrivate *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer )
|
||||
{ __GLcontextModes * modes;
|
||||
{
|
||||
__DRIconfig **configs;
|
||||
__GLcontextModes * m;
|
||||
unsigned num_modes;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
unsigned i;
|
||||
@@ -141,50 +76,42 @@ i810FillInModes( __DRIscreenPrivate *psp,
|
||||
GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
|
||||
};
|
||||
|
||||
int depth_buffer_modes[2][2];
|
||||
u_int8_t depth_bits_array[2];
|
||||
u_int8_t stencil_bits_array[2];
|
||||
|
||||
|
||||
depth_buffer_modes[0][0] = depth_bits;
|
||||
depth_buffer_modes[1][0] = depth_bits;
|
||||
depth_bits_array[0] = depth_bits;
|
||||
depth_bits_array[1] = depth_bits;
|
||||
|
||||
/* Just like with the accumulation buffer, always provide some modes
|
||||
* with a stencil buffer. It will be a sw fallback, but some apps won't
|
||||
* care about that.
|
||||
*/
|
||||
depth_buffer_modes[0][1] = 0;
|
||||
depth_buffer_modes[1][1] = (stencil_bits == 0) ? 8 : stencil_bits;
|
||||
stencil_bits_array[0] = 0;
|
||||
stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
|
||||
|
||||
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
|
||||
back_buffer_factor = (have_back_buffer) ? 2 : 1;
|
||||
|
||||
num_modes = depth_buffer_factor * back_buffer_factor * 4;
|
||||
|
||||
modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
|
||||
m = modes;
|
||||
for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
|
||||
m = fill_in_modes( m, pixel_bits,
|
||||
depth_buffer_modes[i][0], depth_buffer_modes[i][1],
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_TRUE_COLOR );
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
|
||||
m = fill_in_modes( m, pixel_bits,
|
||||
depth_buffer_modes[i][0], depth_buffer_modes[i][1],
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_DIRECT_COLOR );
|
||||
configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor);
|
||||
if (configs == NULL) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for ( m = modes ; m != NULL ; m = m->next ) {
|
||||
if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
|
||||
for (i = 0; configs[i]; i++) {
|
||||
m = &configs[i]->modes;
|
||||
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
|
||||
return (const __DRIconfig **) configs;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,12 +147,24 @@ static drmBufMapPtr i810_create_empty_buffers(void)
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
i810InitDriver(__DRIscreenPrivate *sPriv)
|
||||
static const __DRIconfig **
|
||||
i810InitScreen(__DRIscreen *sPriv)
|
||||
{
|
||||
static const __DRIversion ddx_expected = { 1, 0, 0 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
static const __DRIversion drm_expected = { 1, 2, 0 };
|
||||
i810ScreenPrivate *i810Screen;
|
||||
I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv;
|
||||
|
||||
if ( ! driCheckDriDdxDrmVersions2( "i810",
|
||||
&sPriv->dri_version, & dri_expected,
|
||||
&sPriv->ddx_version, & ddx_expected,
|
||||
&sPriv->drm_version, & drm_expected ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
driInitExtensions( NULL, card_extensions, GL_TRUE );
|
||||
|
||||
if (sPriv->devPrivSize != sizeof(I810DRIRec)) {
|
||||
fprintf(stderr,"\nERROR! sizeof(I810DRIRec) does not match passed size from device driver\n");
|
||||
return GL_FALSE;
|
||||
@@ -313,7 +252,7 @@ i810InitDriver(__DRIscreenPrivate *sPriv)
|
||||
|
||||
i810Screen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
|
||||
|
||||
return GL_TRUE;
|
||||
return i810FillInModes(sPriv, 16, 16, 0, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -402,8 +341,8 @@ i810DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
|
||||
_mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));
|
||||
}
|
||||
|
||||
|
||||
static const struct __DriverAPIRec i810API = {
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
.InitScreen = i810InitScreen,
|
||||
.DestroyScreen = i810DestroyScreen,
|
||||
.CreateContext = i810CreateContext,
|
||||
.DestroyContext = i810DestroyContext,
|
||||
@@ -418,33 +357,3 @@ static const struct __DriverAPIRec i810API = {
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This is the driver specific part of the createNewScreen entry point.
|
||||
*
|
||||
* \todo maybe fold this into intelInitDriver
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
{
|
||||
static const __DRIversion ddx_expected = { 1, 0, 0 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
static const __DRIversion drm_expected = { 1, 2, 0 };
|
||||
|
||||
if ( ! driCheckDriDdxDrmVersions2( "i810",
|
||||
&psp->dri_version, & dri_expected,
|
||||
&psp->ddx_version, & ddx_expected,
|
||||
&psp->drm_version, & drm_expected ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
psp->DriverAPI = i810API;
|
||||
driInitExtensions( NULL, card_extensions, GL_TRUE );
|
||||
|
||||
if (!i810InitDriver(psp))
|
||||
return NULL;
|
||||
|
||||
return i810FillInModes(psp, 16, 16, 0, 1);
|
||||
}
|
||||
|
||||
@@ -96,5 +96,7 @@ i830TexEnv(GLcontext * ctx, GLenum target,
|
||||
void
|
||||
i830InitTextureFuncs(struct dd_function_table *functions)
|
||||
{
|
||||
/*
|
||||
functions->TexEnv = i830TexEnv;
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -114,10 +114,12 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
||||
{
|
||||
GLcontext *ctx = &intel->ctx;
|
||||
struct i830_context *i830 = i830_context(ctx);
|
||||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
||||
struct gl_texture_unit *tUnit = &ctx->Texture.Unit[unit];
|
||||
struct gl_texture_object *tObj = tUnit->_Current;
|
||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||
struct gl_texture_image *firstImage;
|
||||
GLuint *state = i830->state.Tex[unit], format, pitch;
|
||||
GLint lodbias;
|
||||
|
||||
memset(state, 0, sizeof(state));
|
||||
|
||||
@@ -243,8 +245,14 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
||||
}
|
||||
}
|
||||
|
||||
state[I830_TEXREG_TM0S3] = i830->lodbias_tm0s3[unit];
|
||||
|
||||
lodbias = (int) ((tUnit->LodBias + tObj->LodBias) * 16.0);
|
||||
if (lodbias < -64)
|
||||
lodbias = -64;
|
||||
if (lodbias > 63)
|
||||
lodbias = 63;
|
||||
|
||||
state[I830_TEXREG_TM0S3] = ((lodbias << TM0S3_LOD_BIAS_SHIFT) &
|
||||
TM0S3_LOD_BIAS_MASK);
|
||||
#if 0
|
||||
/* YUV conversion:
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "glapi.h"
|
||||
|
||||
#include "i830_context.h"
|
||||
#include "i830_reg.h"
|
||||
@@ -418,8 +419,9 @@ i830_emit_state(struct intel_context *intel)
|
||||
{
|
||||
struct i830_context *i830 = i830_context(&intel->ctx);
|
||||
struct i830_hw_state *state = i830->current;
|
||||
int i;
|
||||
int i, ret, count;
|
||||
GLuint dirty;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
BATCH_LOCALS;
|
||||
|
||||
/* We don't hold the lock at this point, so want to make sure that
|
||||
@@ -435,6 +437,34 @@ i830_emit_state(struct intel_context *intel)
|
||||
*/
|
||||
intel_batchbuffer_require_space(intel->batch, get_state_size(state) + 8,
|
||||
LOOP_CLIPRECTS);
|
||||
count = 0;
|
||||
again:
|
||||
dirty = get_dirty(state);
|
||||
|
||||
ret = 0;
|
||||
if (dirty & I830_UPLOAD_BUFFERS) {
|
||||
ret |= dri_bufmgr_check_aperture_space(state->draw_region->buffer);
|
||||
ret |= dri_bufmgr_check_aperture_space(state->depth_region->buffer);
|
||||
}
|
||||
|
||||
for (i = 0; i < I830_TEX_UNITS; i++)
|
||||
if (dirty & I830_UPLOAD_TEX(i)) {
|
||||
if (state->tex_buffer[i]) {
|
||||
ret |= dri_bufmgr_check_aperture_space(state->tex_buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
if (count == 0) {
|
||||
count++;
|
||||
intel_batchbuffer_flush(intel->batch);
|
||||
goto again;
|
||||
} else {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "i830 emit state");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Do this here as we may have flushed the batchbuffer above,
|
||||
* causing more state to be dirty!
|
||||
@@ -666,6 +696,11 @@ i830_assert_not_dirty( struct intel_context *intel )
|
||||
assert(!get_dirty(state));
|
||||
}
|
||||
|
||||
static void
|
||||
i830_note_unlock( struct intel_context *intel )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void
|
||||
i830InitVtbl(struct i830_context *i830)
|
||||
@@ -681,4 +716,5 @@ i830InitVtbl(struct i830_context *i830)
|
||||
i830->intel.vtbl.render_start = i830_render_start;
|
||||
i830->intel.vtbl.render_prevalidate = i830_render_prevalidate;
|
||||
i830->intel.vtbl.assert_not_dirty = i830_assert_not_dirty;
|
||||
i830->intel.vtbl.note_unlock = i830_note_unlock;
|
||||
}
|
||||
|
||||
@@ -74,5 +74,7 @@ i915TexEnv(GLcontext * ctx, GLenum target,
|
||||
void
|
||||
i915InitTextureFuncs(struct dd_function_table *functions)
|
||||
{
|
||||
/*
|
||||
functions->TexEnv = i915TexEnv;
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/* Code to layout images in a mipmap tree for i915 and i945
|
||||
* respectively.
|
||||
/** @file i915_tex_layout.c
|
||||
* Code to layout images in a mipmap tree for i830M-GM915 and G945 and beyond.
|
||||
*/
|
||||
|
||||
#include "intel_mipmap_tree.h"
|
||||
@@ -36,141 +36,206 @@
|
||||
|
||||
#define FILE_DEBUG_FLAG DEBUG_TEXTURE
|
||||
|
||||
static GLint initial_offsets[6][2] = { {0, 0},
|
||||
{0, 2},
|
||||
{1, 0},
|
||||
{1, 2},
|
||||
{1, 1},
|
||||
{1, 3}
|
||||
static GLint initial_offsets[6][2] = {
|
||||
[FACE_POS_X] = {0, 0},
|
||||
[FACE_POS_Y] = {1, 0},
|
||||
[FACE_POS_Z] = {1, 1},
|
||||
[FACE_NEG_X] = {0, 2},
|
||||
[FACE_NEG_Y] = {1, 2},
|
||||
[FACE_NEG_Z] = {1, 3},
|
||||
};
|
||||
|
||||
|
||||
static GLint step_offsets[6][2] = { {0, 2},
|
||||
{0, 2},
|
||||
{-1, 2},
|
||||
{-1, 2},
|
||||
{-1, 1},
|
||||
{-1, 1}
|
||||
static GLint step_offsets[6][2] = {
|
||||
[FACE_POS_X] = {0, 2},
|
||||
[FACE_POS_Y] = {-1, 2},
|
||||
[FACE_POS_Z] = {-1, 1},
|
||||
[FACE_NEG_X] = {0, 2},
|
||||
[FACE_NEG_Y] = {-1, 2},
|
||||
[FACE_NEG_Z] = {-1, 1},
|
||||
};
|
||||
|
||||
/**
|
||||
* Cube texture map layout for i830M-GM915.
|
||||
*
|
||||
* Hardware layout looks like:
|
||||
*
|
||||
* +-------+-------+
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | +x | +y |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* +---+---+-------+
|
||||
* | | | |
|
||||
* | +x| +y| |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +-+-+---+ +z |
|
||||
* | | | | |
|
||||
* +-+-+ +z| |
|
||||
* | | | |
|
||||
* +-+-+---+-------+
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | -x | -y |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* +---+---+-------+
|
||||
* | | | |
|
||||
* | -x| -y| |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +-+-+---+ -z |
|
||||
* | | | | |
|
||||
* +-+-+ -z| |
|
||||
* | | | |
|
||||
* +-+---+-------+
|
||||
*
|
||||
*/
|
||||
static void
|
||||
i915_miptree_layout_cube(struct intel_context *intel,
|
||||
struct intel_mipmap_tree * mt)
|
||||
{
|
||||
const GLuint dim = mt->width0;
|
||||
GLuint face;
|
||||
GLuint lvlWidth = mt->width0, lvlHeight = mt->height0;
|
||||
GLint level;
|
||||
|
||||
assert(lvlWidth == lvlHeight); /* cubemap images are square */
|
||||
|
||||
/* double pitch for cube layouts */
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, dim * 2);
|
||||
mt->total_height = dim * 4;
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_level_info(mt, level, 6,
|
||||
0, 0,
|
||||
/*OLD: mt->pitch, mt->total_height,*/
|
||||
lvlWidth, lvlHeight,
|
||||
1);
|
||||
lvlWidth /= 2;
|
||||
lvlHeight /= 2;
|
||||
}
|
||||
|
||||
for (face = 0; face < 6; face++) {
|
||||
GLuint x = initial_offsets[face][0] * dim;
|
||||
GLuint y = initial_offsets[face][1] * dim;
|
||||
GLuint d = dim;
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_image_offset(mt, level, face, x, y);
|
||||
|
||||
if (d == 0)
|
||||
_mesa_printf("cube mipmap %d/%d (%d..%d) is 0x0\n",
|
||||
face, level, mt->first_level, mt->last_level);
|
||||
|
||||
d >>= 1;
|
||||
x += step_offsets[face][0] * d;
|
||||
y += step_offsets[face][1] * d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
i915_miptree_layout_3d(struct intel_context *intel,
|
||||
struct intel_mipmap_tree * mt)
|
||||
{
|
||||
GLuint width = mt->width0;
|
||||
GLuint height = mt->height0;
|
||||
GLuint depth = mt->depth0;
|
||||
GLuint stack_height = 0;
|
||||
GLint level;
|
||||
|
||||
/* Calculate the size of a single slice. */
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
|
||||
|
||||
/* XXX: hardware expects/requires 9 levels at minimum. */
|
||||
for (level = mt->first_level; level <= MAX2(8, mt->last_level); level++) {
|
||||
intel_miptree_set_level_info(mt, level, depth, 0, mt->total_height,
|
||||
width, height, depth);
|
||||
|
||||
stack_height += MAX2(2, height);
|
||||
|
||||
width = minify(width);
|
||||
height = minify(height);
|
||||
depth = minify(depth);
|
||||
}
|
||||
|
||||
/* Fixup depth image_offsets: */
|
||||
depth = mt->depth0;
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
GLuint i;
|
||||
for (i = 0; i < depth; i++) {
|
||||
intel_miptree_set_image_offset(mt, level, i,
|
||||
0, i * stack_height);
|
||||
}
|
||||
|
||||
depth = minify(depth);
|
||||
}
|
||||
|
||||
/* Multiply slice size by texture depth for total size. It's
|
||||
* remarkable how wasteful of memory the i915 texture layouts
|
||||
* are. They are largely fixed in the i945.
|
||||
*/
|
||||
mt->total_height = stack_height * mt->depth0;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_miptree_layout_2d(struct intel_context *intel,
|
||||
struct intel_mipmap_tree * mt)
|
||||
{
|
||||
GLuint width = mt->width0;
|
||||
GLuint height = mt->height0;
|
||||
GLuint img_height;
|
||||
GLint level;
|
||||
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
|
||||
mt->total_height = 0;
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_level_info(mt, level, 1,
|
||||
0, mt->total_height,
|
||||
width, height, 1);
|
||||
|
||||
if (mt->compressed)
|
||||
img_height = MAX2(1, height / 4);
|
||||
else
|
||||
img_height = (MAX2(2, height) + 1) & ~1;
|
||||
|
||||
mt->total_height += img_height;
|
||||
|
||||
width = minify(width);
|
||||
height = minify(height);
|
||||
}
|
||||
}
|
||||
|
||||
GLboolean
|
||||
i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
|
||||
{
|
||||
GLint level;
|
||||
|
||||
switch (mt->target) {
|
||||
case GL_TEXTURE_CUBE_MAP:{
|
||||
const GLuint dim = mt->width0;
|
||||
GLuint face;
|
||||
GLuint lvlWidth = mt->width0, lvlHeight = mt->height0;
|
||||
|
||||
assert(lvlWidth == lvlHeight); /* cubemap images are square */
|
||||
|
||||
/* double pitch for cube layouts */
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, dim * 2);
|
||||
mt->total_height = dim * 4;
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_level_info(mt, level, 6,
|
||||
0, 0,
|
||||
/*OLD: mt->pitch, mt->total_height,*/
|
||||
lvlWidth, lvlHeight,
|
||||
1);
|
||||
lvlWidth /= 2;
|
||||
lvlHeight /= 2;
|
||||
}
|
||||
|
||||
for (face = 0; face < 6; face++) {
|
||||
GLuint x = initial_offsets[face][0] * dim;
|
||||
GLuint y = initial_offsets[face][1] * dim;
|
||||
GLuint d = dim;
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_image_offset(mt, level, face, x, y);
|
||||
|
||||
if (d == 0)
|
||||
_mesa_printf("cube mipmap %d/%d (%d..%d) is 0x0\n",
|
||||
face, level, mt->first_level, mt->last_level);
|
||||
|
||||
d >>= 1;
|
||||
x += step_offsets[face][0] * d;
|
||||
y += step_offsets[face][1] * d;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GL_TEXTURE_3D:{
|
||||
GLuint width = mt->width0;
|
||||
GLuint height = mt->height0;
|
||||
GLuint depth = mt->depth0;
|
||||
GLuint stack_height = 0;
|
||||
|
||||
/* Calculate the size of a single slice.
|
||||
*/
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
|
||||
|
||||
/* XXX: hardware expects/requires 9 levels at minimum.
|
||||
*/
|
||||
for (level = mt->first_level; level <= MAX2(8, mt->last_level);
|
||||
level++) {
|
||||
intel_miptree_set_level_info(mt, level, depth, 0, mt->total_height,
|
||||
width, height, depth);
|
||||
|
||||
|
||||
stack_height += MAX2(2, height);
|
||||
|
||||
width = minify(width);
|
||||
height = minify(height);
|
||||
depth = minify(depth);
|
||||
}
|
||||
|
||||
/* Fixup depth image_offsets:
|
||||
*/
|
||||
depth = mt->depth0;
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
GLuint i;
|
||||
for (i = 0; i < depth; i++)
|
||||
intel_miptree_set_image_offset(mt, level, i,
|
||||
0, i * stack_height);
|
||||
|
||||
depth = minify(depth);
|
||||
}
|
||||
|
||||
|
||||
/* Multiply slice size by texture depth for total size. It's
|
||||
* remarkable how wasteful of memory the i915 texture layouts
|
||||
* are. They are largely fixed in the i945.
|
||||
*/
|
||||
mt->total_height = stack_height * mt->depth0;
|
||||
break;
|
||||
}
|
||||
|
||||
default:{
|
||||
GLuint width = mt->width0;
|
||||
GLuint height = mt->height0;
|
||||
GLuint img_height;
|
||||
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
|
||||
mt->total_height = 0;
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_level_info(mt, level, 1,
|
||||
0, mt->total_height,
|
||||
width, height, 1);
|
||||
|
||||
if (mt->compressed)
|
||||
img_height = MAX2(1, height / 4);
|
||||
else
|
||||
img_height = (MAX2(2, height) + 1) & ~1;
|
||||
|
||||
mt->total_height += img_height;
|
||||
|
||||
width = minify(width);
|
||||
height = minify(height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
i915_miptree_layout_cube(intel, mt);
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
i915_miptree_layout_3d(intel, mt);
|
||||
break;
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_RECTANGLE_ARB:
|
||||
i915_miptree_layout_2d(intel, mt);
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(NULL, "Unexpected tex target in i915_miptree_layout()");
|
||||
break;
|
||||
}
|
||||
|
||||
DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
|
||||
mt->pitch,
|
||||
mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp);
|
||||
@@ -179,160 +244,229 @@ i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cube texture map layout for GM945 and later.
|
||||
*
|
||||
* The hardware layout looks like the 830-915 layout, except for the small
|
||||
* sizes. A zoomed in view of the layout for 945 is:
|
||||
*
|
||||
* +-------+-------+
|
||||
* | 8x8 | 8x8 |
|
||||
* | | |
|
||||
* | | |
|
||||
* | +x | +y |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* +---+---+-------+
|
||||
* |4x4| | 8x8 |
|
||||
* | +x| | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +---+ | +z |
|
||||
* |4x4| | |
|
||||
* | +y| | |
|
||||
* | | | |
|
||||
* +---+ +-------+
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* +-------+-------+
|
||||
* | 8x8 | 8x8 |
|
||||
* | | |
|
||||
* | | |
|
||||
* | -x | -y |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* +---+---+-------+
|
||||
* |4x4| | 8x8 |
|
||||
* | -x| | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +---+ | -z |
|
||||
* |4x4| | |
|
||||
* | -y| | |
|
||||
* | | | |
|
||||
* +---+ +---+---+---+---+---+---+---+---+---+
|
||||
* |4x4| |4x4| |2x2| |2x2| |2x2| |2x2|
|
||||
* | +z| | -z| | +x| | +y| | +z| | -x| ...
|
||||
* | | | | | | | | | | | |
|
||||
* +---+ +---+ +---+ +---+ +---+ +---+
|
||||
*
|
||||
* The bottom row continues with the remaining 2x2 then the 1x1 mip contents
|
||||
* in order, with each of them aligned to a 4x4 block boundary. Thus, for
|
||||
* 32x32 cube maps and smaller, the bottom row layout is going to dictate the
|
||||
* pitch of the tree. For a tree with 4x4 images, the pitch is at least
|
||||
* 14 * 8 = 112 texels, for 2x2 it is at least 12 * 8 texels, and for 1x1
|
||||
* it is 6 * 8 texels.
|
||||
*/
|
||||
|
||||
static void
|
||||
i945_miptree_layout_cube(struct intel_context *intel,
|
||||
struct intel_mipmap_tree * mt)
|
||||
{
|
||||
const GLuint dim = mt->width0;
|
||||
GLuint face;
|
||||
GLuint lvlWidth = mt->width0, lvlHeight = mt->height0;
|
||||
GLint level;
|
||||
|
||||
assert(lvlWidth == lvlHeight); /* cubemap images are square */
|
||||
|
||||
/* Depending on the size of the largest images, pitch can be
|
||||
* determined either by the old-style packing of cubemap faces,
|
||||
* or the final row of 4x4, 2x2 and 1x1 faces below this.
|
||||
*/
|
||||
if (dim > 32)
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, dim * 2);
|
||||
else
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, 14 * 8);
|
||||
|
||||
if (dim >= 4)
|
||||
mt->total_height = dim * 4 + 4;
|
||||
else
|
||||
mt->total_height = 4;
|
||||
|
||||
/* Set all the levels to effectively occupy the whole rectangular region. */
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_level_info(mt, level, 6,
|
||||
0, 0,
|
||||
lvlWidth, lvlHeight, 1);
|
||||
lvlWidth /= 2;
|
||||
lvlHeight /= 2;
|
||||
}
|
||||
|
||||
for (face = 0; face < 6; face++) {
|
||||
GLuint x = initial_offsets[face][0] * dim;
|
||||
GLuint y = initial_offsets[face][1] * dim;
|
||||
GLuint d = dim;
|
||||
|
||||
if (dim == 4 && face >= 4) {
|
||||
y = mt->total_height - 4;
|
||||
x = (face - 4) * 8;
|
||||
} else if (dim < 4 && (face > 0 || mt->first_level > 0)) {
|
||||
y = mt->total_height - 4;
|
||||
x = face * 8;
|
||||
}
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_image_offset(mt, level, face, x, y);
|
||||
|
||||
d >>= 1;
|
||||
|
||||
switch (d) {
|
||||
case 4:
|
||||
switch (face) {
|
||||
case FACE_POS_X:
|
||||
case FACE_NEG_X:
|
||||
x += step_offsets[face][0] * d;
|
||||
y += step_offsets[face][1] * d;
|
||||
break;
|
||||
case FACE_POS_Y:
|
||||
case FACE_NEG_Y:
|
||||
y += 12;
|
||||
x -= 8;
|
||||
break;
|
||||
case FACE_POS_Z:
|
||||
case FACE_NEG_Z:
|
||||
y = mt->total_height - 4;
|
||||
x = (face - 4) * 8;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
y = mt->total_height - 4;
|
||||
x = 16 + face * 8;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
x += 48;
|
||||
break;
|
||||
|
||||
default:
|
||||
x += step_offsets[face][0] * d;
|
||||
y += step_offsets[face][1] * d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
i945_miptree_layout_3d(struct intel_context *intel,
|
||||
struct intel_mipmap_tree * mt)
|
||||
{
|
||||
GLuint width = mt->width0;
|
||||
GLuint height = mt->height0;
|
||||
GLuint depth = mt->depth0;
|
||||
GLuint pack_x_pitch, pack_x_nr;
|
||||
GLuint pack_y_pitch;
|
||||
GLuint level;
|
||||
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
|
||||
mt->total_height = 0;
|
||||
|
||||
pack_y_pitch = MAX2(mt->height0, 2);
|
||||
pack_x_pitch = mt->pitch;
|
||||
pack_x_nr = 1;
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
GLint x = 0;
|
||||
GLint y = 0;
|
||||
GLint q, j;
|
||||
|
||||
intel_miptree_set_level_info(mt, level, depth,
|
||||
0, mt->total_height,
|
||||
width, height, depth);
|
||||
|
||||
for (q = 0; q < depth;) {
|
||||
for (j = 0; j < pack_x_nr && q < depth; j++, q++) {
|
||||
intel_miptree_set_image_offset(mt, level, q, x, y);
|
||||
x += pack_x_pitch;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y += pack_y_pitch;
|
||||
}
|
||||
|
||||
mt->total_height += y;
|
||||
|
||||
if (pack_x_pitch > 4) {
|
||||
pack_x_pitch >>= 1;
|
||||
pack_x_nr <<= 1;
|
||||
assert(pack_x_pitch * pack_x_nr <= mt->pitch);
|
||||
}
|
||||
|
||||
if (pack_y_pitch > 2) {
|
||||
pack_y_pitch >>= 1;
|
||||
}
|
||||
|
||||
width = minify(width);
|
||||
height = minify(height);
|
||||
depth = minify(depth);
|
||||
}
|
||||
}
|
||||
|
||||
GLboolean
|
||||
i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
|
||||
{
|
||||
GLint level;
|
||||
|
||||
switch (mt->target) {
|
||||
case GL_TEXTURE_CUBE_MAP:{
|
||||
const GLuint dim = mt->width0;
|
||||
GLuint face;
|
||||
GLuint lvlWidth = mt->width0, lvlHeight = mt->height0;
|
||||
|
||||
assert(lvlWidth == lvlHeight); /* cubemap images are square */
|
||||
|
||||
/* Depending on the size of the largest images, pitch can be
|
||||
* determined either by the old-style packing of cubemap faces,
|
||||
* or the final row of 4x4, 2x2 and 1x1 faces below this.
|
||||
*/
|
||||
if (dim > 32)
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, dim);
|
||||
else
|
||||
mt->pitch = 14 * 8;
|
||||
|
||||
mt->total_height = dim * 4 + 4;
|
||||
|
||||
/* Set all the levels to effectively occupy the whole rectangular region.
|
||||
*/
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_level_info(mt, level, 6,
|
||||
0, 0,
|
||||
lvlWidth, lvlHeight, 1);
|
||||
lvlWidth /= 2;
|
||||
lvlHeight /= 2;
|
||||
}
|
||||
|
||||
|
||||
for (face = 0; face < 6; face++) {
|
||||
GLuint x = initial_offsets[face][0] * dim;
|
||||
GLuint y = initial_offsets[face][1] * dim;
|
||||
GLuint d = dim;
|
||||
|
||||
if (dim == 4 && face >= 4) {
|
||||
y = mt->total_height - 4;
|
||||
x = (face - 4) * 8;
|
||||
}
|
||||
else if (dim < 4 && (face > 0 || mt->first_level > 0)) {
|
||||
y = mt->total_height - 4;
|
||||
x = face * 8;
|
||||
}
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
intel_miptree_set_image_offset(mt, level, face, x, y);
|
||||
|
||||
d >>= 1;
|
||||
|
||||
switch (d) {
|
||||
case 4:
|
||||
switch (face) {
|
||||
case FACE_POS_X:
|
||||
case FACE_NEG_X:
|
||||
x += step_offsets[face][0] * d;
|
||||
y += step_offsets[face][1] * d;
|
||||
break;
|
||||
case FACE_POS_Y:
|
||||
case FACE_NEG_Y:
|
||||
y += 12;
|
||||
x -= 8;
|
||||
break;
|
||||
case FACE_POS_Z:
|
||||
case FACE_NEG_Z:
|
||||
y = mt->total_height - 4;
|
||||
x = (face - 4) * 8;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
y = mt->total_height - 4;
|
||||
x = 16 + face * 8;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
x += 48;
|
||||
break;
|
||||
|
||||
default:
|
||||
x += step_offsets[face][0] * d;
|
||||
y += step_offsets[face][1] * d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GL_TEXTURE_3D:{
|
||||
GLuint width = mt->width0;
|
||||
GLuint height = mt->height0;
|
||||
GLuint depth = mt->depth0;
|
||||
GLuint pack_x_pitch, pack_x_nr;
|
||||
GLuint pack_y_pitch;
|
||||
GLuint level;
|
||||
|
||||
mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
|
||||
mt->total_height = 0;
|
||||
|
||||
pack_y_pitch = MAX2(mt->height0, 2);
|
||||
pack_x_pitch = mt->pitch;
|
||||
pack_x_nr = 1;
|
||||
|
||||
for (level = mt->first_level; level <= mt->last_level; level++) {
|
||||
GLuint nr_images = mt->target == GL_TEXTURE_3D ? depth : 6;
|
||||
GLint x = 0;
|
||||
GLint y = 0;
|
||||
GLint q, j;
|
||||
|
||||
intel_miptree_set_level_info(mt, level, nr_images,
|
||||
0, mt->total_height,
|
||||
width, height, depth);
|
||||
|
||||
for (q = 0; q < nr_images;) {
|
||||
for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) {
|
||||
intel_miptree_set_image_offset(mt, level, q, x, y);
|
||||
x += pack_x_pitch;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y += pack_y_pitch;
|
||||
}
|
||||
|
||||
|
||||
mt->total_height += y;
|
||||
|
||||
if (pack_x_pitch > 4) {
|
||||
pack_x_pitch >>= 1;
|
||||
pack_x_nr <<= 1;
|
||||
assert(pack_x_pitch * pack_x_nr <= mt->pitch);
|
||||
}
|
||||
|
||||
if (pack_y_pitch > 2) {
|
||||
pack_y_pitch >>= 1;
|
||||
}
|
||||
|
||||
width = minify(width);
|
||||
height = minify(height);
|
||||
depth = minify(depth);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
i945_miptree_layout_cube(intel, mt);
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
i945_miptree_layout_3d(intel, mt);
|
||||
break;
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_RECTANGLE_ARB:
|
||||
i945_miptree_layout_2d(intel, mt);
|
||||
break;
|
||||
i945_miptree_layout_2d(intel, mt);
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(NULL, "Unexpected tex target in i945_miptree_layout()");
|
||||
break;
|
||||
}
|
||||
|
||||
DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
|
||||
static GLuint
|
||||
translate_texture_format(GLuint mesa_format)
|
||||
translate_texture_format(GLuint mesa_format, GLenum DepthMode)
|
||||
{
|
||||
switch (mesa_format) {
|
||||
case MESA_FORMAT_L8:
|
||||
@@ -65,7 +65,7 @@ translate_texture_format(GLuint mesa_format)
|
||||
case MESA_FORMAT_RGBA_FXT1:
|
||||
return (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1);
|
||||
case MESA_FORMAT_Z16:
|
||||
return (MAPSURF_16BIT | MT_16BIT_L16);
|
||||
return (MAPSURF_16BIT | (DepthMode==GL_ALPHA?MT_16BIT_A16:MT_16BIT_L16));
|
||||
case MESA_FORMAT_RGBA_DXT1:
|
||||
case MESA_FORMAT_RGB_DXT1:
|
||||
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
|
||||
@@ -119,10 +119,12 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
||||
{
|
||||
GLcontext *ctx = &intel->ctx;
|
||||
struct i915_context *i915 = i915_context(ctx);
|
||||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
||||
struct gl_texture_unit *tUnit = &ctx->Texture.Unit[unit];
|
||||
struct gl_texture_object *tObj = tUnit->_Current;
|
||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||
struct gl_texture_image *firstImage;
|
||||
GLuint *state = i915->state.Tex[unit], format, pitch;
|
||||
GLint lodbias;
|
||||
|
||||
memset(state, 0, sizeof(state));
|
||||
|
||||
@@ -166,7 +168,8 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
||||
0, intelObj->
|
||||
firstLevel);
|
||||
|
||||
format = translate_texture_format(firstImage->TexFormat->MesaFormat);
|
||||
format = translate_texture_format(firstImage->TexFormat->MesaFormat,
|
||||
tObj->DepthMode);
|
||||
pitch = intelObj->mt->pitch * intelObj->mt->cpp;
|
||||
}
|
||||
|
||||
@@ -231,7 +234,13 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
||||
}
|
||||
}
|
||||
|
||||
state[I915_TEXREG_SS2] = i915->lodbias_ss2[unit];
|
||||
lodbias = (int) ((tUnit->LodBias + tObj->LodBias) * 16.0);
|
||||
if (lodbias < -256)
|
||||
lodbias = -256;
|
||||
if (lodbias > 255)
|
||||
lodbias = 255;
|
||||
state[I915_TEXREG_SS2] = ((lodbias << SS2_LOD_BIAS_SHIFT) &
|
||||
SS2_LOD_BIAS_MASK);
|
||||
|
||||
/* YUV conversion:
|
||||
*/
|
||||
@@ -248,8 +257,13 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
||||
(SS2_SHADOW_ENABLE |
|
||||
intel_translate_shadow_compare_func(tObj->CompareFunc));
|
||||
|
||||
minFilt = FILTER_4X4_FLAT;
|
||||
magFilt = FILTER_4X4_FLAT;
|
||||
if (tObj->Target == GL_TEXTURE_1D) {
|
||||
minFilt = FILTER_NEAREST;
|
||||
magFilt = FILTER_NEAREST;
|
||||
} else {
|
||||
minFilt = FILTER_4X4_FLAT;
|
||||
magFilt = FILTER_4X4_FLAT;
|
||||
}
|
||||
}
|
||||
|
||||
state[I915_TEXREG_SS2] |= ((minFilt << SS2_MIN_FILTER_SHIFT) |
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
#include "i915_reg.h"
|
||||
#include "i915_context.h"
|
||||
|
||||
#include "glapi.h"
|
||||
|
||||
static void
|
||||
i915_render_prevalidate(struct intel_context *intel)
|
||||
{
|
||||
@@ -295,7 +297,9 @@ i915_emit_state(struct intel_context *intel)
|
||||
struct i915_context *i915 = i915_context(&intel->ctx);
|
||||
struct i915_hw_state *state = i915->current;
|
||||
int i;
|
||||
int ret, count;
|
||||
GLuint dirty;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
BATCH_LOCALS;
|
||||
|
||||
/* We don't hold the lock at this point, so want to make sure that
|
||||
@@ -311,7 +315,37 @@ i915_emit_state(struct intel_context *intel)
|
||||
*/
|
||||
intel_batchbuffer_require_space(intel->batch, get_state_size(state) + 8,
|
||||
LOOP_CLIPRECTS);
|
||||
count = 0;
|
||||
again:
|
||||
dirty = get_dirty(state);
|
||||
|
||||
ret = 0;
|
||||
if (dirty & I915_UPLOAD_BUFFERS) {
|
||||
ret |= dri_bufmgr_check_aperture_space(state->draw_region->buffer);
|
||||
ret |= dri_bufmgr_check_aperture_space(state->depth_region->buffer);
|
||||
}
|
||||
|
||||
if (dirty & I915_UPLOAD_TEX_ALL) {
|
||||
for (i = 0; i < I915_TEX_UNITS; i++)
|
||||
if (dirty & I915_UPLOAD_TEX(i)) {
|
||||
if (state->tex_buffer[i]) {
|
||||
ret |= dri_bufmgr_check_aperture_space(state->tex_buffer[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret) {
|
||||
if (count == 0) {
|
||||
count++;
|
||||
intel_batchbuffer_flush(intel->batch);
|
||||
goto again;
|
||||
} else {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "i915 emit state");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* work out list of buffers to emit */
|
||||
|
||||
/* Do this here as we may have flushed the batchbuffer above,
|
||||
* causing more state to be dirty!
|
||||
*/
|
||||
@@ -572,6 +606,12 @@ i915_assert_not_dirty( struct intel_context *intel )
|
||||
assert(!dirty);
|
||||
}
|
||||
|
||||
static void
|
||||
i915_note_unlock( struct intel_context *intel )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
i915InitVtbl(struct i915_context *i915)
|
||||
@@ -587,4 +627,5 @@ i915InitVtbl(struct i915_context *i915)
|
||||
i915->intel.vtbl.update_texture_state = i915UpdateTextureState;
|
||||
i915->intel.vtbl.flush_cmd = i915_flush_cmd;
|
||||
i915->intel.vtbl.assert_not_dirty = i915_assert_not_dirty;
|
||||
i915->intel.vtbl.note_unlock = i915_note_unlock;
|
||||
}
|
||||
|
||||
@@ -311,10 +311,18 @@ intel_wpos_triangle(struct intel_context *intel,
|
||||
{
|
||||
GLuint offset = intel->wpos_offset;
|
||||
GLuint size = intel->wpos_size;
|
||||
GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
|
||||
GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
|
||||
GLfloat *v2_wpos = (GLfloat *)((char *)v2 + offset);
|
||||
|
||||
__memcpy(v0_wpos, v0, size);
|
||||
__memcpy(v1_wpos, v1, size);
|
||||
__memcpy(v2_wpos, v2, size);
|
||||
|
||||
v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
|
||||
v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h;
|
||||
v2_wpos[1] = -v2_wpos[1] + intel->driDrawable->h;
|
||||
|
||||
__memcpy(((char *) v0) + offset, v0, size);
|
||||
__memcpy(((char *) v1) + offset, v1, size);
|
||||
__memcpy(((char *) v2) + offset, v2, size);
|
||||
|
||||
intel_draw_triangle(intel, v0, v1, v2);
|
||||
}
|
||||
@@ -326,9 +334,14 @@ intel_wpos_line(struct intel_context *intel,
|
||||
{
|
||||
GLuint offset = intel->wpos_offset;
|
||||
GLuint size = intel->wpos_size;
|
||||
GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
|
||||
GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
|
||||
|
||||
__memcpy(((char *) v0) + offset, v0, size);
|
||||
__memcpy(((char *) v1) + offset, v1, size);
|
||||
__memcpy(v0_wpos, v0, size);
|
||||
__memcpy(v1_wpos, v1, size);
|
||||
|
||||
v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
|
||||
v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h;
|
||||
|
||||
intel_draw_line(intel, v0, v1);
|
||||
}
|
||||
@@ -339,8 +352,10 @@ intel_wpos_point(struct intel_context *intel, intelVertexPtr v0)
|
||||
{
|
||||
GLuint offset = intel->wpos_offset;
|
||||
GLuint size = intel->wpos_size;
|
||||
GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
|
||||
|
||||
__memcpy(((char *) v0) + offset, v0, size);
|
||||
__memcpy(v0_wpos, v0, size);
|
||||
v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
|
||||
|
||||
intel_draw_point(intel, v0);
|
||||
}
|
||||
|
||||
@@ -168,12 +168,10 @@ static void upload_clip_prog( struct brw_context *brw )
|
||||
offset_front = 0;
|
||||
break;
|
||||
case GL_LINE:
|
||||
key.do_unfilled = 1;
|
||||
fill_front = CLIP_LINE;
|
||||
offset_front = brw->attribs.Polygon->OffsetLine;
|
||||
break;
|
||||
case GL_POINT:
|
||||
key.do_unfilled = 1;
|
||||
fill_front = CLIP_POINT;
|
||||
offset_front = brw->attribs.Polygon->OffsetPoint;
|
||||
break;
|
||||
@@ -188,26 +186,23 @@ static void upload_clip_prog( struct brw_context *brw )
|
||||
offset_back = 0;
|
||||
break;
|
||||
case GL_LINE:
|
||||
key.do_unfilled = 1;
|
||||
fill_back = CLIP_LINE;
|
||||
offset_back = brw->attribs.Polygon->OffsetLine;
|
||||
break;
|
||||
case GL_POINT:
|
||||
key.do_unfilled = 1;
|
||||
fill_back = CLIP_POINT;
|
||||
offset_back = brw->attribs.Polygon->OffsetPoint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (brw->attribs.Polygon->BackMode != GL_FILL ||
|
||||
brw->attribs.Polygon->FrontMode != GL_FILL)
|
||||
key.do_unfilled = 1;
|
||||
if (brw->attribs.Polygon->BackMode != GL_FILL ||
|
||||
brw->attribs.Polygon->FrontMode != GL_FILL) {
|
||||
key.do_unfilled = 1;
|
||||
|
||||
/* Most cases the fixed function units will handle. Cases where
|
||||
* one or more polygon faces are unfilled will require help:
|
||||
*/
|
||||
if (key.do_unfilled) {
|
||||
/* Most cases the fixed function units will handle. Cases where
|
||||
* one or more polygon faces are unfilled will require help:
|
||||
*/
|
||||
key.clip_mode = BRW_CLIPMODE_CLIP_NON_REJECTED;
|
||||
|
||||
if (offset_back || offset_front) {
|
||||
|
||||
@@ -220,8 +220,8 @@ static void apply_one_offset( struct brw_clip_compile *c,
|
||||
struct brw_indirect vert )
|
||||
{
|
||||
struct brw_compile *p = &c->func;
|
||||
struct brw_reg pos = deref_4f(vert, c->offset[VERT_RESULT_HPOS]);
|
||||
struct brw_reg z = get_element(pos, 2);
|
||||
struct brw_reg z = deref_1f(vert, c->header_position_offset +
|
||||
2 * type_sz(BRW_REGISTER_TYPE_F));
|
||||
|
||||
brw_ADD(p, z, z, vec1(c->reg.offset));
|
||||
}
|
||||
|
||||
@@ -146,12 +146,12 @@ struct brw_context;
|
||||
struct brw_state_flags {
|
||||
/** State update flags signalled by mesa internals */
|
||||
GLuint mesa;
|
||||
/** State update flags signalled by brw_state_cache.c searches */
|
||||
GLuint cache;
|
||||
/**
|
||||
* State update flags signalled as the result of brw_tracked_state updates
|
||||
*/
|
||||
GLuint brw;
|
||||
/** State update flags signalled by brw_state_cache.c searches */
|
||||
GLuint cache;
|
||||
};
|
||||
|
||||
struct brw_vertex_program {
|
||||
|
||||
@@ -124,6 +124,9 @@ static void brwProgramStringNotify( GLcontext *ctx,
|
||||
struct brw_vertex_program *vp = (struct brw_vertex_program *)brw->vertex_program;
|
||||
if (p == vp)
|
||||
brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM;
|
||||
if (p->program.IsPositionInvariant) {
|
||||
_mesa_insert_mvp_code(ctx, &p->program);
|
||||
}
|
||||
p->id = brw->program_id++;
|
||||
p->param_state = p->program.Base.Parameters->StateFlags;
|
||||
|
||||
|
||||
@@ -224,11 +224,11 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
|
||||
sf.sf6.line_width = 0;
|
||||
|
||||
/* _NEW_POINT */
|
||||
sf.sf6.point_rast_rule = 1; /* opengl conventions */
|
||||
sf.sf6.point_rast_rule = BRW_RASTRULE_UPPER_RIGHT; /* opengl conventions */
|
||||
/* XXX clamp max depends on AA vs. non-AA */
|
||||
|
||||
sf.sf7.sprite_point = key->point_sprite;
|
||||
sf.sf7.point_size = CLAMP(key->point_size, 1.0, 255.0) * (1<<3);
|
||||
sf.sf7.point_size = CLAMP(nearbyint(key->point_size), 1, 255) * (1<<3);
|
||||
sf.sf7.use_point_size_state = !key->point_attenuated;
|
||||
sf.sf7.aa_line_distance_mode = 0;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ static GLuint hash_key( const void *key, GLuint key_size,
|
||||
}
|
||||
|
||||
/* Include the BO pointers as key data as well */
|
||||
ikey = (void *)reloc_bufs;
|
||||
ikey = (GLuint *)reloc_bufs;
|
||||
key_size = nr_reloc_bufs * sizeof(dri_bo *);
|
||||
for (i = 0; i < key_size/4; i++) {
|
||||
hash ^= ikey[i];
|
||||
@@ -102,6 +102,9 @@ static void
|
||||
update_cache_last(struct brw_cache *cache, enum brw_cache_id cache_id,
|
||||
dri_bo *bo)
|
||||
{
|
||||
if (bo == cache->last_bo[cache_id])
|
||||
return; /* no change */
|
||||
|
||||
dri_bo_unreference(cache->last_bo[cache_id]);
|
||||
cache->last_bo[cache_id] = bo;
|
||||
dri_bo_reference(cache->last_bo[cache_id]);
|
||||
@@ -255,7 +258,7 @@ brw_upload_cache( struct brw_cache *cache,
|
||||
if (INTEL_DEBUG & DEBUG_STATE)
|
||||
_mesa_printf("upload %s: %d bytes to cache id %d\n",
|
||||
cache->name[cache_id],
|
||||
data_size);
|
||||
data_size, cache_id);
|
||||
|
||||
/* Copy data to the buffer */
|
||||
dri_bo_subdata(bo, 0, data_size, data);
|
||||
@@ -282,6 +285,7 @@ brw_cache_data_sz(struct brw_cache *cache,
|
||||
item = search_cache(cache, cache_id, hash, data, data_size,
|
||||
reloc_bufs, nr_reloc_bufs);
|
||||
if (item) {
|
||||
update_cache_last(cache, cache_id, item->bo);
|
||||
dri_bo_reference(item->bo);
|
||||
return item->bo;
|
||||
}
|
||||
|
||||
@@ -199,6 +199,7 @@ struct brw_wm_compile {
|
||||
GLuint nr_fp_insns;
|
||||
GLuint fp_temp;
|
||||
GLuint fp_interp_emitted;
|
||||
GLuint fp_fragcolor_emitted;
|
||||
GLuint fp_deriv_emitted;
|
||||
|
||||
struct prog_src_register pixel_xy;
|
||||
|
||||
@@ -137,7 +137,7 @@ static void emit_wpos_xy(struct brw_wm_compile *c,
|
||||
brw_ADD(p,
|
||||
dst[0],
|
||||
retype(arg0[0], BRW_REGISTER_TYPE_W),
|
||||
brw_imm_d(- c->key.origin_x));
|
||||
brw_imm_d(0 - c->key.origin_x));
|
||||
}
|
||||
|
||||
if (mask & WRITEMASK_Y) {
|
||||
@@ -223,6 +223,10 @@ static void emit_pinterp( struct brw_compile *p,
|
||||
if (mask & (1<<i)) {
|
||||
brw_LINE(p, brw_null_reg(), interp[i], deltas[0]);
|
||||
brw_MAC(p, dst[i], suboffset(interp[i],1), deltas[1]);
|
||||
}
|
||||
}
|
||||
for(i = 0; i < 4; i++ ) {
|
||||
if (mask & (1<<i)) {
|
||||
brw_MUL(p, dst[i], dst[i], w[3]);
|
||||
}
|
||||
}
|
||||
@@ -500,6 +504,9 @@ static void emit_dp3( struct brw_compile *p,
|
||||
const struct brw_reg *arg0,
|
||||
const struct brw_reg *arg1 )
|
||||
{
|
||||
if (!(mask & WRITEMASK_XYZW))
|
||||
return; /* Do not emit dead code*/
|
||||
|
||||
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
|
||||
|
||||
brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
|
||||
@@ -517,6 +524,9 @@ static void emit_dp4( struct brw_compile *p,
|
||||
const struct brw_reg *arg0,
|
||||
const struct brw_reg *arg1 )
|
||||
{
|
||||
if (!(mask & WRITEMASK_XYZW))
|
||||
return; /* Do not emit dead code*/
|
||||
|
||||
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
|
||||
|
||||
brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
|
||||
@@ -535,6 +545,9 @@ static void emit_dph( struct brw_compile *p,
|
||||
const struct brw_reg *arg0,
|
||||
const struct brw_reg *arg1 )
|
||||
{
|
||||
if (!(mask & WRITEMASK_XYZW))
|
||||
return; /* Do not emit dead code*/
|
||||
|
||||
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
|
||||
|
||||
brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
|
||||
@@ -578,6 +591,9 @@ static void emit_math1( struct brw_compile *p,
|
||||
GLuint mask,
|
||||
const struct brw_reg *arg0 )
|
||||
{
|
||||
if (!(mask & WRITEMASK_XYZW))
|
||||
return; /* Do not emit dead code*/
|
||||
|
||||
//assert((mask & WRITEMASK_XYZW) == WRITEMASK_X ||
|
||||
// function == BRW_MATH_FUNCTION_SINCOS);
|
||||
|
||||
@@ -602,6 +618,9 @@ static void emit_math2( struct brw_compile *p,
|
||||
const struct brw_reg *arg0,
|
||||
const struct brw_reg *arg1)
|
||||
{
|
||||
if (!(mask & WRITEMASK_XYZW))
|
||||
return; /* Do not emit dead code*/
|
||||
|
||||
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
|
||||
|
||||
brw_push_insn_state(p);
|
||||
|
||||
@@ -144,7 +144,7 @@ static struct prog_dst_register dst_undef( void )
|
||||
|
||||
static struct prog_dst_register get_temp( struct brw_wm_compile *c )
|
||||
{
|
||||
int bit = ffs( ~c->fp_temp );
|
||||
int bit = _mesa_ffs( ~c->fp_temp );
|
||||
|
||||
if (!bit) {
|
||||
_mesa_printf("%s: out of temporaries\n", __FILE__);
|
||||
@@ -158,7 +158,7 @@ static struct prog_dst_register get_temp( struct brw_wm_compile *c )
|
||||
|
||||
static void release_temp( struct brw_wm_compile *c, struct prog_dst_register temp )
|
||||
{
|
||||
c->fp_temp &= ~1<<(temp.Index + 1 - FIRST_INTERNAL_TEMP);
|
||||
c->fp_temp &= ~(1 << (temp.Index - FIRST_INTERNAL_TEMP));
|
||||
}
|
||||
|
||||
|
||||
@@ -494,17 +494,20 @@ static void precalc_dst( struct brw_wm_compile *c,
|
||||
|
||||
|
||||
if (dst.WriteMask & WRITEMASK_XZ) {
|
||||
struct prog_instruction *swz;
|
||||
GLuint z = GET_SWZ(src0.Swizzle, Z);
|
||||
|
||||
/* dst.xz = swz src0.1zzz
|
||||
*/
|
||||
emit_op(c,
|
||||
OPCODE_SWZ,
|
||||
dst_mask(dst, WRITEMASK_XZ),
|
||||
inst->SaturateMode, 0, 0,
|
||||
src_swizzle(src0, SWIZZLE_ONE, z, z, z),
|
||||
src_undef(),
|
||||
src_undef());
|
||||
swz = emit_op(c,
|
||||
OPCODE_SWZ,
|
||||
dst_mask(dst, WRITEMASK_XZ),
|
||||
inst->SaturateMode, 0, 0,
|
||||
src_swizzle(src0, SWIZZLE_ONE, z, z, z),
|
||||
src_undef(),
|
||||
src_undef());
|
||||
/* Avoid letting negation flag of src0 affect our 1 constant. */
|
||||
swz->SrcReg[0].NegateBase &= ~NEGATE_X;
|
||||
}
|
||||
if (dst.WriteMask & WRITEMASK_W) {
|
||||
/* dst.w = mov src1.w
|
||||
@@ -527,15 +530,19 @@ static void precalc_lit( struct brw_wm_compile *c,
|
||||
struct prog_dst_register dst = inst->DstReg;
|
||||
|
||||
if (dst.WriteMask & WRITEMASK_XW) {
|
||||
struct prog_instruction *swz;
|
||||
|
||||
/* dst.xw = swz src0.1111
|
||||
*/
|
||||
emit_op(c,
|
||||
OPCODE_SWZ,
|
||||
dst_mask(dst, WRITEMASK_XW),
|
||||
0, 0, 0,
|
||||
src_swizzle1(src0, SWIZZLE_ONE),
|
||||
src_undef(),
|
||||
src_undef());
|
||||
swz = emit_op(c,
|
||||
OPCODE_SWZ,
|
||||
dst_mask(dst, WRITEMASK_XW),
|
||||
0, 0, 0,
|
||||
src_swizzle1(src0, SWIZZLE_ONE),
|
||||
src_undef(),
|
||||
src_undef());
|
||||
/* Avoid letting the negation flag of src0 affect our 1 constant. */
|
||||
swz->SrcReg[0].NegateBase = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -863,25 +870,31 @@ static void emit_fb_write( struct brw_wm_compile *c )
|
||||
struct prog_src_register outdepth = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_DEPR);
|
||||
GLuint i;
|
||||
|
||||
struct prog_instruction *inst;
|
||||
struct prog_instruction *inst, *last_inst;
|
||||
struct brw_context *brw = c->func.brw;
|
||||
|
||||
/* inst->Sampler is not used by backend,
|
||||
use it for fb write target and eot */
|
||||
|
||||
inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(),0),
|
||||
0, 0, 0, outcolor, payload_r0_depth, outdepth);
|
||||
inst->Sampler = (brw->state.nr_draw_regions > 1 ? 0: 1)|(0<<1);
|
||||
|
||||
if (brw->state.nr_draw_regions > 1) {
|
||||
for (i = 0 ; i < brw->state.nr_draw_regions; i++) {
|
||||
outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i);
|
||||
inst = emit_op(c,
|
||||
last_inst = inst = emit_op(c,
|
||||
WM_FB_WRITE, dst_mask(dst_undef(),0), 0, 0, 0,
|
||||
outcolor, payload_r0_depth, outdepth);
|
||||
inst->Sampler = ((i == brw->state.nr_draw_regions - 1) ? 1: 0);
|
||||
inst->Sampler |= (i<<1);
|
||||
inst->Sampler = (i<<1);
|
||||
if (c->fp_fragcolor_emitted) {
|
||||
outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLR);
|
||||
last_inst = inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(),0),
|
||||
0, 0, 0, outcolor, payload_r0_depth, outdepth);
|
||||
inst->Sampler = (i<<1);
|
||||
}
|
||||
}
|
||||
last_inst->Sampler |= 1; //eot
|
||||
}else {
|
||||
inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(),0),
|
||||
0, 0, 0, outcolor, payload_r0_depth, outdepth);
|
||||
inst->Sampler = 1|(0<<1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -908,7 +921,15 @@ static void validate_src_regs( struct brw_wm_compile *c,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void validate_dst_regs( struct brw_wm_compile *c,
|
||||
const struct prog_instruction *inst )
|
||||
{
|
||||
if (inst->DstReg.File == PROGRAM_OUTPUT) {
|
||||
GLuint idx = inst->DstReg.Index;
|
||||
if (idx == FRAG_RESULT_COLR)
|
||||
c->fp_fragcolor_emitted = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void print_insns( const struct prog_instruction *insn,
|
||||
GLuint nr )
|
||||
@@ -951,6 +972,11 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
|
||||
*/
|
||||
|
||||
|
||||
for (insn = 0; insn < fp->program.Base.NumInstructions; insn++) {
|
||||
const struct prog_instruction *inst = &fp->program.Base.Instructions[insn];
|
||||
validate_src_regs(c, inst);
|
||||
validate_dst_regs(c, inst);
|
||||
}
|
||||
for (insn = 0; insn < fp->program.Base.NumInstructions; insn++) {
|
||||
const struct prog_instruction *inst = &fp->program.Base.Instructions[insn];
|
||||
struct prog_instruction *out;
|
||||
@@ -958,7 +984,6 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
|
||||
/* Check for INPUT values, emit INTERP instructions where
|
||||
* necessary:
|
||||
*/
|
||||
validate_src_regs(c, inst);
|
||||
|
||||
|
||||
switch (inst->Opcode) {
|
||||
|
||||
@@ -150,6 +150,7 @@ void brw_wm_pass1( struct brw_wm_compile *c )
|
||||
case OPCODE_FLR:
|
||||
case OPCODE_FRC:
|
||||
case OPCODE_MOV:
|
||||
case OPCODE_SWZ:
|
||||
read0 = writemask;
|
||||
break;
|
||||
|
||||
@@ -257,7 +258,6 @@ void brw_wm_pass1( struct brw_wm_compile *c )
|
||||
read0 = WRITEMASK_XYW;
|
||||
break;
|
||||
|
||||
case OPCODE_SWZ:
|
||||
case OPCODE_DST:
|
||||
case OPCODE_TXP:
|
||||
default:
|
||||
|
||||
@@ -257,6 +257,8 @@ brw_update_region_surface(struct brw_context *brw, struct intel_region *region,
|
||||
GLboolean tiled, color_blend;
|
||||
} key;
|
||||
|
||||
memset(&key, 0, sizeof(key));
|
||||
|
||||
if (region != NULL) {
|
||||
region_bo = region->buffer;
|
||||
|
||||
|
||||
@@ -87,6 +87,10 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
|
||||
batch->ptr = batch->map;
|
||||
batch->dirty_state = ~0;
|
||||
batch->cliprect_mode = IGNORE_CLIPRECTS;
|
||||
|
||||
/* account batchbuffer in aperture */
|
||||
dri_bufmgr_check_aperture_space(batch->buf);
|
||||
|
||||
}
|
||||
|
||||
struct intel_batchbuffer *
|
||||
@@ -264,7 +268,11 @@ intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
|
||||
dri_bo *buffer,
|
||||
GLuint flags, GLuint delta)
|
||||
{
|
||||
dri_emit_reloc(batch->buf, flags, delta, batch->ptr - batch->map, buffer);
|
||||
int ret;
|
||||
int count = 0;
|
||||
|
||||
ret = dri_emit_reloc(batch->buf, flags, delta, batch->ptr - batch->map, buffer);
|
||||
|
||||
/*
|
||||
* Using the old buffer offset, write in what the right data would be, in case
|
||||
* the buffer doesn't move and we can short-circuit the relocation processing
|
||||
|
||||
@@ -54,6 +54,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
|
||||
|
||||
struct intel_context *intel;
|
||||
const intelScreenPrivate *intelScreen;
|
||||
int ret;
|
||||
|
||||
DBG("%s\n", __FUNCTION__);
|
||||
|
||||
@@ -123,6 +124,15 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
|
||||
}
|
||||
#endif
|
||||
|
||||
again:
|
||||
ret = dri_bufmgr_check_aperture_space(dst->buffer);
|
||||
ret |= dri_bufmgr_check_aperture_space(src->buffer);
|
||||
|
||||
if (ret) {
|
||||
intel_batchbuffer_flush(intel->batch);
|
||||
goto again;
|
||||
}
|
||||
|
||||
for (i = 0; i < nbox; i++, pbox++) {
|
||||
drm_clip_rect_t box = *pbox;
|
||||
|
||||
|
||||
@@ -354,8 +354,8 @@ intel_setup_reloc_list(dri_bo *bo)
|
||||
dri_bo_ttm *bo_ttm = (dri_bo_ttm *)bo;
|
||||
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bo->bufmgr;
|
||||
|
||||
bo_ttm->relocs = malloc(sizeof(struct dri_ttm_reloc) *
|
||||
bufmgr_ttm->max_relocs);
|
||||
bo_ttm->relocs = calloc(bufmgr_ttm->max_relocs,
|
||||
sizeof(struct dri_ttm_reloc));
|
||||
bo_ttm->reloc_buf_data = calloc(1, RELOC_BUF_SIZE(bufmgr_ttm->max_relocs));
|
||||
|
||||
/* Initialize the relocation list with the header:
|
||||
@@ -817,7 +817,7 @@ dri_bufmgr_ttm_destroy(dri_bufmgr *bufmgr)
|
||||
* the relocation entry write when the buffer hasn't moved from the
|
||||
* last known offset in target_buf.
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
dri_ttm_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
GLuint offset, dri_bo *target_buf)
|
||||
{
|
||||
@@ -851,6 +851,7 @@ dri_ttm_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
|
||||
reloc_buf_ttm->reloc_buf_data[0]++; /* Increment relocation count */
|
||||
/* Check wraparound */
|
||||
assert(reloc_buf_ttm->reloc_buf_data[0] != 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1039,6 +1040,15 @@ intel_ttm_enable_bo_reuse(dri_bufmgr *bufmgr)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
static int
|
||||
dri_ttm_check_aperture_space(dri_bo *bo)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the TTM buffer manager, which uses the kernel to allocate, map,
|
||||
* and manage map buffer objections.
|
||||
@@ -1082,7 +1092,7 @@ intel_bufmgr_ttm_init(int fd, unsigned int fence_type,
|
||||
bufmgr_ttm->bufmgr.process_relocs = dri_ttm_process_reloc;
|
||||
bufmgr_ttm->bufmgr.post_submit = dri_ttm_post_submit;
|
||||
bufmgr_ttm->bufmgr.debug = GL_FALSE;
|
||||
|
||||
bufmgr_ttm->bufmgr.check_aperture_space = dri_ttm_check_aperture_space;
|
||||
/* Initialize the linked lists for BO reuse cache. */
|
||||
for (i = 0; i < INTEL_TTM_BO_BUCKETS; i++)
|
||||
bufmgr_ttm->cache_bucket[i].tail = &bufmgr_ttm->cache_bucket[i].head;
|
||||
|
||||
@@ -205,7 +205,6 @@ static const struct dri_extension card_extensions[] = {
|
||||
{"GL_ARB_texture_rectangle", NULL},
|
||||
{"GL_NV_texture_rectangle", NULL},
|
||||
{"GL_EXT_texture_rectangle", NULL},
|
||||
{"GL_ARB_point_sprite", NULL},
|
||||
{"GL_ARB_point_parameters", NULL},
|
||||
{"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
|
||||
{"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
|
||||
@@ -247,6 +246,7 @@ static const struct dri_extension brw_extensions[] = {
|
||||
{ "GL_ARB_shading_language_120", GL_VERSION_2_1_functions},
|
||||
{ "GL_ARB_shader_objects", GL_ARB_shader_objects_functions},
|
||||
{ "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions},
|
||||
{ "GL_ARB_point_sprite", NULL},
|
||||
{ "GL_ARB_fragment_shader", NULL },
|
||||
{ "GL_ARB_draw_buffers", NULL },
|
||||
{ "GL_ARB_depth_texture", NULL },
|
||||
@@ -848,7 +848,6 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
|
||||
__DRIdrawablePrivate *dPriv = intel->driDrawable;
|
||||
__DRIscreenPrivate *sPriv = intel->driScreen;
|
||||
volatile struct drm_i915_sarea *sarea = intel->sarea;
|
||||
int drawable_changed = 0;
|
||||
int me = intel->hHWContext;
|
||||
|
||||
drmGetLock(intel->driFd, intel->hHWContext, flags);
|
||||
@@ -862,12 +861,8 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
|
||||
* NOTE: This releases and regains the hw lock, so all state
|
||||
* checking must be done *after* this call:
|
||||
*/
|
||||
if (dPriv) {
|
||||
if (sPriv->dri2.enabled)
|
||||
drawable_changed = __driParseEvents(dPriv->driContextPriv, dPriv);
|
||||
else
|
||||
DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
|
||||
}
|
||||
if (dPriv)
|
||||
DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
|
||||
|
||||
if (sarea && sarea->ctxOwner != me) {
|
||||
if (INTEL_DEBUG & DEBUG_BUFMGR) {
|
||||
@@ -892,48 +887,43 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
|
||||
sarea->ctxOwner, intel->hHWContext);
|
||||
}
|
||||
|
||||
if (!sPriv->dri2.enabled) {
|
||||
if (sarea->width != intel->width || sarea->height != intel->height) {
|
||||
int numClipRects = intel->numClipRects;
|
||||
if (sarea->width != intel->width || sarea->height != intel->height) {
|
||||
int numClipRects = intel->numClipRects;
|
||||
|
||||
/*
|
||||
* FIXME: Really only need to do this when drawing to a
|
||||
* common back- or front buffer.
|
||||
*/
|
||||
/*
|
||||
* FIXME: Really only need to do this when drawing to a
|
||||
* common back- or front buffer.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This will essentially drop the outstanding batchbuffer on
|
||||
* the floor.
|
||||
*/
|
||||
intel->numClipRects = 0;
|
||||
/*
|
||||
* This will essentially drop the outstanding batchbuffer on
|
||||
* the floor.
|
||||
*/
|
||||
intel->numClipRects = 0;
|
||||
|
||||
if (intel->Fallback)
|
||||
_swrast_flush(&intel->ctx);
|
||||
if (intel->Fallback)
|
||||
_swrast_flush(&intel->ctx);
|
||||
|
||||
if (!IS_965(intel->intelScreen->deviceID))
|
||||
INTEL_FIREVERTICES(intel);
|
||||
if (!IS_965(intel->intelScreen->deviceID))
|
||||
INTEL_FIREVERTICES(intel);
|
||||
|
||||
if (intel->batch->map != intel->batch->ptr)
|
||||
intel_batchbuffer_flush(intel->batch);
|
||||
if (intel->batch->map != intel->batch->ptr)
|
||||
intel_batchbuffer_flush(intel->batch);
|
||||
|
||||
intel->numClipRects = numClipRects;
|
||||
intel->numClipRects = numClipRects;
|
||||
|
||||
/* force window update */
|
||||
intel->lastStamp = 0;
|
||||
/* force window update */
|
||||
intel->lastStamp = 0;
|
||||
|
||||
intel->width = sarea->width;
|
||||
intel->height = sarea->height;
|
||||
}
|
||||
intel->width = sarea->width;
|
||||
intel->height = sarea->height;
|
||||
}
|
||||
|
||||
/* Drawable changed?
|
||||
*/
|
||||
if (dPriv && intel->lastStamp != dPriv->lastStamp) {
|
||||
intelWindowMoved(intel);
|
||||
intel->lastStamp = dPriv->lastStamp;
|
||||
}
|
||||
} else if (drawable_changed) {
|
||||
intelWindowMoved(intel);
|
||||
intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
|
||||
/* Drawable changed?
|
||||
*/
|
||||
if (dPriv && intel->lastStamp != dPriv->lastStamp) {
|
||||
intelWindowMoved(intel);
|
||||
intel->lastStamp = dPriv->lastStamp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -944,13 +934,15 @@ _glthread_DECLARE_STATIC_MUTEX(lockMutex);
|
||||
*/
|
||||
void LOCK_HARDWARE( struct intel_context *intel )
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = intel->driDrawable;
|
||||
__DRIdrawable *dPriv = intel->driDrawable;
|
||||
__DRIscreen *sPriv = intel->driScreen;
|
||||
char __ret = 0;
|
||||
struct intel_framebuffer *intel_fb = NULL;
|
||||
struct intel_renderbuffer *intel_rb = NULL;
|
||||
|
||||
_glthread_LOCK_MUTEX(lockMutex);
|
||||
assert(!intel->locked);
|
||||
intel->locked = 1;
|
||||
|
||||
if (intel->driDrawable) {
|
||||
intel_fb = intel->driDrawable->driverPrivate;
|
||||
@@ -980,10 +972,18 @@ void LOCK_HARDWARE( struct intel_context *intel )
|
||||
DRM_CAS(intel->driHwLock, intel->hHWContext,
|
||||
(DRM_LOCK_HELD|intel->hHWContext), __ret);
|
||||
|
||||
if (__ret)
|
||||
if (sPriv->dri2.enabled) {
|
||||
if (__ret)
|
||||
drmGetLock(intel->driFd, intel->hHWContext, 0);
|
||||
if (__driParseEvents(dPriv->driContextPriv, dPriv)) {
|
||||
intelWindowMoved(intel);
|
||||
intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
|
||||
}
|
||||
} else if (__ret) {
|
||||
intelContendedLock( intel, 0 );
|
||||
}
|
||||
|
||||
|
||||
intel->locked = 1;
|
||||
if (INTEL_DEBUG & DEBUG_LOCK)
|
||||
_mesa_printf("%s - locked\n", __progname);
|
||||
}
|
||||
@@ -993,6 +993,7 @@ void LOCK_HARDWARE( struct intel_context *intel )
|
||||
*/
|
||||
void UNLOCK_HARDWARE( struct intel_context *intel )
|
||||
{
|
||||
intel->vtbl.note_unlock( intel );
|
||||
intel->locked = 0;
|
||||
|
||||
DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
|
||||
|
||||
@@ -326,7 +326,7 @@ intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
|
||||
|
||||
assert(img < mt->level[level].nr_images);
|
||||
|
||||
mt->level[level].image_offset[img] = (x + y * mt->pitch);
|
||||
mt->level[level].image_offset[img] = (x + y * mt->pitch) * mt->cpp;
|
||||
|
||||
DBG("%s level %d img %d pos %d,%d image_offset %x\n",
|
||||
__FUNCTION__, level, img, x, y, mt->level[level].image_offset[img]);
|
||||
@@ -357,7 +357,7 @@ intel_miptree_image_offset(struct intel_mipmap_tree *mt,
|
||||
{
|
||||
if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
|
||||
return (mt->level[level].level_offset +
|
||||
mt->level[level].image_offset[face] * mt->cpp);
|
||||
mt->level[level].image_offset[face]);
|
||||
else
|
||||
return mt->level[level].level_offset;
|
||||
}
|
||||
@@ -368,6 +368,8 @@ intel_miptree_image_offset(struct intel_mipmap_tree *mt,
|
||||
* Map a teximage in a mipmap tree.
|
||||
* \param row_stride returns row stride in bytes
|
||||
* \param image_stride returns image stride in bytes (for 3D textures).
|
||||
* \param image_offsets pointer to array of pixel offsets from the returned
|
||||
* pointer to each depth image
|
||||
* \return address of mapping
|
||||
*/
|
||||
GLubyte *
|
||||
@@ -382,12 +384,16 @@ intel_miptree_image_map(struct intel_context * intel,
|
||||
if (row_stride)
|
||||
*row_stride = mt->pitch * mt->cpp;
|
||||
|
||||
if (image_offsets) {
|
||||
if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
|
||||
memset(image_offsets, 0, mt->level[level].depth * sizeof(GLuint));
|
||||
else
|
||||
memcpy(image_offsets, mt->level[level].image_offset,
|
||||
mt->level[level].depth * sizeof(GLuint));
|
||||
if (mt->target == GL_TEXTURE_3D) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mt->level[level].depth; i++)
|
||||
image_offsets[i] = mt->level[level].image_offset[i] / mt->cpp;
|
||||
} else {
|
||||
assert(mt->level[level].depth == 1);
|
||||
assert(mt->target == GL_TEXTURE_CUBE_MAP ||
|
||||
mt->level[level].image_offset[0] == 0);
|
||||
image_offsets[0] = 0;
|
||||
}
|
||||
|
||||
return (intel_region_map(intel, mt->region) +
|
||||
|
||||
@@ -62,18 +62,29 @@
|
||||
*/
|
||||
struct intel_mipmap_level
|
||||
{
|
||||
/**
|
||||
* Byte offset to the base of this level.
|
||||
*
|
||||
* This is used for mipmap levels of 1D/2D/3D textures. However, CUBE
|
||||
* layouts spread images around the whole tree, so the level offset is
|
||||
* always zero in that case.
|
||||
*/
|
||||
GLuint level_offset;
|
||||
GLuint width;
|
||||
GLuint height;
|
||||
/** Depth of the mipmap at this level: 1 for 1D/2D/CUBE, n for 3D. */
|
||||
GLuint depth;
|
||||
/** Number of images at this level: 1 for 1D/2D, 6 for CUBE, depth for 3D */
|
||||
GLuint nr_images;
|
||||
|
||||
/* Explicitly store the offset of each image for each cube face or
|
||||
* depth value. Pretty much have to accept that hardware formats
|
||||
/**
|
||||
* Byte offset from level_offset to the image for each cube face or depth
|
||||
* level.
|
||||
*
|
||||
* Pretty much have to accept that hardware formats
|
||||
* are going to be so diverse that there is no unified way to
|
||||
* compute the offsets of depth/cube images within a mipmap level,
|
||||
* so have to store them as a lookup table:
|
||||
* NOTE level_offset is a byte offset, but the image_offsets are _pixel_ offsets!!!
|
||||
* so have to store them as a lookup table.
|
||||
*/
|
||||
GLuint *image_offset;
|
||||
};
|
||||
|
||||
@@ -394,7 +394,7 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
|
||||
intelSetTexBuffer,
|
||||
};
|
||||
|
||||
static const __DRIextension *intelExtensions[] = {
|
||||
static const __DRIextension *intelScreenExtensions[] = {
|
||||
&driReadDrawableExtension,
|
||||
&driCopySubBufferExtension.base,
|
||||
&driSwapControlExtension.base,
|
||||
@@ -479,7 +479,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
|
||||
&intelScreen->allow_batchbuffer))
|
||||
return GL_FALSE;
|
||||
|
||||
sPriv->extensions = intelExtensions;
|
||||
sPriv->extensions = intelScreenExtensions;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@@ -653,39 +653,18 @@ intelCreateContext(const __GLcontextModes * mesaVis,
|
||||
}
|
||||
|
||||
|
||||
static const struct __DriverAPIRec intelAPI = {
|
||||
.DestroyScreen = intelDestroyScreen,
|
||||
.CreateContext = intelCreateContext,
|
||||
.DestroyContext = intelDestroyContext,
|
||||
.CreateBuffer = intelCreateBuffer,
|
||||
.DestroyBuffer = intelDestroyBuffer,
|
||||
.SwapBuffers = intelSwapBuffers,
|
||||
.MakeCurrent = intelMakeCurrent,
|
||||
.UnbindContext = intelUnbindContext,
|
||||
.GetSwapInfo = intelGetSwapInfo,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL,
|
||||
.CopySubBuffer = intelCopySubBuffer,
|
||||
|
||||
.HandleDrawableConfig = intelHandleDrawableConfig,
|
||||
.HandleBufferAttach = intelHandleBufferAttach,
|
||||
};
|
||||
|
||||
|
||||
static __GLcontextModes *
|
||||
static __DRIconfig **
|
||||
intelFillInModes(__DRIscreenPrivate *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer)
|
||||
{
|
||||
__GLcontextModes *modes;
|
||||
__DRIconfig **configs;
|
||||
__GLcontextModes *m;
|
||||
unsigned num_modes;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
GLenum fb_format;
|
||||
GLenum fb_type;
|
||||
int i;
|
||||
|
||||
/* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
|
||||
* support pageflipping at all.
|
||||
@@ -697,7 +676,6 @@ intelFillInModes(__DRIscreenPrivate *psp,
|
||||
u_int8_t depth_bits_array[3];
|
||||
u_int8_t stencil_bits_array[3];
|
||||
|
||||
|
||||
depth_bits_array[0] = 0;
|
||||
depth_bits_array[1] = depth_bits;
|
||||
depth_bits_array[2] = depth_bits;
|
||||
@@ -716,8 +694,6 @@ intelFillInModes(__DRIscreenPrivate *psp,
|
||||
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
|
||||
back_buffer_factor = (have_back_buffer) ? 3 : 1;
|
||||
|
||||
num_modes = depth_buffer_factor * back_buffer_factor * 4;
|
||||
|
||||
if (pixel_bits == 16) {
|
||||
fb_format = GL_RGB;
|
||||
fb_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
@@ -727,36 +703,26 @@ intelFillInModes(__DRIscreenPrivate *psp,
|
||||
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
modes =
|
||||
(*psp->contextModes->createContextModes) (num_modes,
|
||||
sizeof(__GLcontextModes));
|
||||
m = modes;
|
||||
if (!driFillInModes(&m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor, GLX_TRUE_COLOR)) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
|
||||
__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
if (!driFillInModes(&m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor, GLX_DIRECT_COLOR)) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
|
||||
configs = driCreateConfigs(fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor);
|
||||
if (configs == NULL) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
|
||||
__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for (m = modes; m != NULL; m = m->next) {
|
||||
for (i = 0; configs[i]; i++) {
|
||||
m = &configs[i]->modes;
|
||||
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
return configs;
|
||||
}
|
||||
|
||||
|
||||
@@ -767,7 +733,7 @@ intelFillInModes(__DRIscreenPrivate *psp,
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
|
||||
{
|
||||
#ifdef I915
|
||||
static const __DRIversion ddx_expected = { 1, 5, 0 };
|
||||
@@ -778,8 +744,6 @@ PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
static const __DRIversion drm_expected = { 1, 5, 0 };
|
||||
I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
|
||||
|
||||
psp->DriverAPI = intelAPI;
|
||||
|
||||
if (!driCheckDriDdxDrmVersions2("i915",
|
||||
&psp->dri_version, &dri_expected,
|
||||
&psp->ddx_version, &ddx_expected,
|
||||
@@ -802,9 +766,12 @@ PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
if (!intelInitDriver(psp))
|
||||
return NULL;
|
||||
|
||||
return intelFillInModes(psp, dri_priv->cpp * 8,
|
||||
(dri_priv->cpp == 2) ? 16 : 24,
|
||||
(dri_priv->cpp == 2) ? 0 : 8, 1);
|
||||
psp->extensions = intelScreenExtensions;
|
||||
|
||||
return (const __DRIconfig **)
|
||||
intelFillInModes(psp, dri_priv->cpp * 8,
|
||||
(dri_priv->cpp == 2) ? 16 : 24,
|
||||
(dri_priv->cpp == 2) ? 0 : 8, 1);
|
||||
}
|
||||
|
||||
struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
|
||||
@@ -827,12 +794,10 @@ struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
PUBLIC __GLcontextModes *__dri2DriverInitScreen(__DRIscreenPrivate *psp)
|
||||
static const
|
||||
__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
|
||||
{
|
||||
intelScreenPrivate *intelScreen;
|
||||
__GLcontextModes *modes, *m;
|
||||
|
||||
psp->DriverAPI = intelAPI;
|
||||
|
||||
/* Calling driInitExtensions here, with a NULL context pointer,
|
||||
* does not actually enable the extensions. It just makes sure
|
||||
@@ -881,12 +846,28 @@ PUBLIC __GLcontextModes *__dri2DriverInitScreen(__DRIscreenPrivate *psp)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
psp->extensions = intelExtensions;
|
||||
psp->extensions = intelScreenExtensions;
|
||||
|
||||
modes = intelFillInModes(psp, 16, 16, 0, 1);
|
||||
for (m = modes; m->next != NULL; m = m->next)
|
||||
;
|
||||
m->next = intelFillInModes(psp, 32, 24, 8, 1);
|
||||
|
||||
return modes;
|
||||
return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
|
||||
intelFillInModes(psp, 32, 24, 8, 1));
|
||||
}
|
||||
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
.InitScreen = intelInitScreen,
|
||||
.DestroyScreen = intelDestroyScreen,
|
||||
.CreateContext = intelCreateContext,
|
||||
.DestroyContext = intelDestroyContext,
|
||||
.CreateBuffer = intelCreateBuffer,
|
||||
.DestroyBuffer = intelDestroyBuffer,
|
||||
.SwapBuffers = intelSwapBuffers,
|
||||
.MakeCurrent = intelMakeCurrent,
|
||||
.UnbindContext = intelUnbindContext,
|
||||
.GetSwapInfo = intelGetSwapInfo,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.CopySubBuffer = intelCopySubBuffer,
|
||||
|
||||
.InitScreen2 = intelInitScreen2,
|
||||
.HandleDrawableConfig = intelHandleDrawableConfig,
|
||||
.HandleBufferAttach = intelHandleBufferAttach,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "swrast/swrast.h"
|
||||
#include "texobj.h"
|
||||
#include "teximage.h"
|
||||
#include "mipmap.h"
|
||||
#include "intel_context.h"
|
||||
#include "intel_mipmap_tree.h"
|
||||
@@ -71,7 +72,7 @@ intelFreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage)
|
||||
}
|
||||
|
||||
if (texImage->Data) {
|
||||
free(texImage->Data);
|
||||
_mesa_free_texmemory(texImage->Data);
|
||||
texImage->Data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,8 @@ intelTexImage(GLcontext * ctx,
|
||||
assert(!texImage->Data);
|
||||
}
|
||||
else if (texImage->Data) {
|
||||
_mesa_align_free(texImage->Data);
|
||||
_mesa_free_texmemory(texImage->Data);
|
||||
texImage->Data = NULL;
|
||||
}
|
||||
|
||||
/* If this is the only texture image in the tree, could call
|
||||
@@ -481,7 +482,7 @@ intelTexImage(GLcontext * ctx,
|
||||
sizeInBytes = depth * dstRowStride * postConvHeight;
|
||||
}
|
||||
|
||||
texImage->Data = malloc(sizeInBytes);
|
||||
texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
|
||||
}
|
||||
|
||||
DBG("Upload image %dx%dx%d row_len %d "
|
||||
@@ -675,8 +676,7 @@ void
|
||||
intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
|
||||
unsigned long long offset, GLint depth, GLuint pitch)
|
||||
{
|
||||
struct intel_context *intel = (struct intel_context*)
|
||||
((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
|
||||
struct intel_context *intel = pDRICtx->driverPrivate;
|
||||
struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
|
||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||
|
||||
@@ -695,12 +695,10 @@ intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
|
||||
}
|
||||
|
||||
void
|
||||
intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *pDraw)
|
||||
intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
|
||||
{
|
||||
__DRIcontextPrivate *driContext = pDRICtx->private;
|
||||
__DRIdrawablePrivate *dPriv = pDraw->private;
|
||||
struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
|
||||
struct intel_context *intel = driContext->driverPrivate;
|
||||
struct intel_context *intel = pDRICtx->driverPrivate;
|
||||
struct intel_texture_object *intelObj;
|
||||
struct intel_texture_image *intelImage;
|
||||
struct intel_mipmap_tree *mt;
|
||||
@@ -717,7 +715,7 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *pDraw)
|
||||
if (!intelObj)
|
||||
return;
|
||||
|
||||
__driParseEvents(driContext, dPriv);
|
||||
__driParseEvents(pDRICtx, dPriv);
|
||||
|
||||
rb = intel_fb->color_rb[0];
|
||||
type = GL_BGRA;
|
||||
|
||||
@@ -69,80 +69,15 @@ static const GLuint __driNConfigOptions = 2;
|
||||
|
||||
extern const struct dri_extension card_extensions[];
|
||||
|
||||
static __GLcontextModes * fill_in_modes( __GLcontextModes * modes,
|
||||
unsigned pixel_bits,
|
||||
unsigned depth_bits,
|
||||
unsigned stencil_bits,
|
||||
const GLenum * db_modes,
|
||||
unsigned num_db_modes,
|
||||
int visType )
|
||||
{
|
||||
static const u_int8_t bits[2][4] = {
|
||||
{ 5, 6, 5, 0 },
|
||||
{ 8, 8, 8, 0 }
|
||||
};
|
||||
|
||||
static const u_int32_t masks[2][4] = {
|
||||
{ 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 },
|
||||
{ 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }
|
||||
};
|
||||
|
||||
unsigned i;
|
||||
unsigned j;
|
||||
const unsigned index = ((pixel_bits + 15) / 16) - 1;
|
||||
|
||||
for ( i = 0 ; i < num_db_modes ; i++ ) {
|
||||
for ( j = 0 ; j < 2 ; j++ ) {
|
||||
|
||||
modes->redBits = bits[index][0];
|
||||
modes->greenBits = bits[index][1];
|
||||
modes->blueBits = bits[index][2];
|
||||
modes->alphaBits = bits[index][3];
|
||||
modes->redMask = masks[index][0];
|
||||
modes->greenMask = masks[index][1];
|
||||
modes->blueMask = masks[index][2];
|
||||
modes->alphaMask = masks[index][3];
|
||||
modes->rgbBits = modes->redBits + modes->greenBits
|
||||
+ modes->blueBits + modes->alphaBits;
|
||||
|
||||
modes->accumRedBits = 16 * j;
|
||||
modes->accumGreenBits = 16 * j;
|
||||
modes->accumBlueBits = 16 * j;
|
||||
modes->accumAlphaBits = 0;
|
||||
modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
|
||||
modes->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
|
||||
modes->stencilBits = stencil_bits;
|
||||
modes->depthBits = depth_bits;
|
||||
|
||||
modes->visualType = visType;
|
||||
modes->renderType = GLX_RGBA_BIT;
|
||||
modes->rgbMode = GL_TRUE;
|
||||
|
||||
if ( db_modes[i] == GLX_NONE ) {
|
||||
|
||||
modes->doubleBufferMode = GL_FALSE;
|
||||
}
|
||||
else {
|
||||
modes->doubleBufferMode = GL_TRUE;
|
||||
modes->swapMethod = db_modes[i];
|
||||
}
|
||||
|
||||
modes = modes->next;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
|
||||
static __GLcontextModes *
|
||||
static const __DRIconfig **
|
||||
mach64FillInModes( __DRIscreenPrivate *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer )
|
||||
{
|
||||
__GLcontextModes * modes;
|
||||
__DRIconfig **configs;
|
||||
__GLcontextModes * m;
|
||||
unsigned num_modes;
|
||||
GLenum fb_format;
|
||||
GLenum fb_type;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
unsigned i;
|
||||
@@ -156,49 +91,51 @@ mach64FillInModes( __DRIscreenPrivate *psp,
|
||||
GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
|
||||
};
|
||||
|
||||
int depth_buffer_modes[2][2];
|
||||
u_int8_t depth_bits_array[2];
|
||||
u_int8_t stencil_bits_array[2];
|
||||
|
||||
|
||||
depth_buffer_modes[0][0] = depth_bits;
|
||||
depth_buffer_modes[1][0] = depth_bits;
|
||||
depth_bits_array[0] = depth_bits;
|
||||
depth_bits_array[1] = depth_bits;
|
||||
|
||||
/* Just like with the accumulation buffer, always provide some modes
|
||||
* with a stencil buffer. It will be a sw fallback, but some apps won't
|
||||
* care about that.
|
||||
*/
|
||||
depth_buffer_modes[0][1] = 0;
|
||||
depth_buffer_modes[1][1] = (stencil_bits == 0) ? 8 : stencil_bits;
|
||||
stencil_bits_array[0] = 0;
|
||||
stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
|
||||
|
||||
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
|
||||
back_buffer_factor = (have_back_buffer) ? 2 : 1;
|
||||
|
||||
num_modes = depth_buffer_factor * back_buffer_factor * 4;
|
||||
|
||||
modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
|
||||
m = modes;
|
||||
for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
|
||||
m = fill_in_modes( m, pixel_bits,
|
||||
depth_buffer_modes[i][0], depth_buffer_modes[i][1],
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_TRUE_COLOR );
|
||||
if (pixel_bits == 16) {
|
||||
fb_format = GL_RGB;
|
||||
fb_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
}
|
||||
else {
|
||||
fb_format = GL_BGRA;
|
||||
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
|
||||
m = fill_in_modes( m, pixel_bits,
|
||||
depth_buffer_modes[i][0], depth_buffer_modes[i][1],
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_DIRECT_COLOR );
|
||||
configs = driCreateConfigs(fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor);
|
||||
if (configs == NULL) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for ( m = modes ; m != NULL ; m = m->next ) {
|
||||
if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ){
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
for (i = 0; configs[i]; i++) {
|
||||
m = &configs[i]->modes;
|
||||
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
return (const __DRIconfig **) configs;
|
||||
}
|
||||
|
||||
|
||||
@@ -473,24 +410,6 @@ mach64InitDriver( __DRIscreenPrivate *driScreen )
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static struct __DriverAPIRec mach64API = {
|
||||
.DestroyScreen = mach64DestroyScreen,
|
||||
.CreateContext = mach64CreateContext,
|
||||
.DestroyContext = mach64DestroyContext,
|
||||
.CreateBuffer = mach64CreateBuffer,
|
||||
.DestroyBuffer = mach64DestroyBuffer,
|
||||
.SwapBuffers = mach64SwapBuffers,
|
||||
.MakeCurrent = mach64MakeCurrent,
|
||||
.UnbindContext = mach64UnbindContext,
|
||||
.GetSwapInfo = NULL,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This is the driver specific part of the createNewScreen entry point.
|
||||
*
|
||||
@@ -498,14 +417,14 @@ static struct __DriverAPIRec mach64API = {
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
static const __DRIconfig **
|
||||
mach64InitScreen(__DRIscreenPrivate *psp)
|
||||
{
|
||||
static const __DRIversion ddx_expected = { 6, 4, 0 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
static const __DRIversion drm_expected = { 2, 0, 0 };
|
||||
ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv;
|
||||
|
||||
psp->DriverAPI = mach64API;
|
||||
if ( ! driCheckDriDdxDrmVersions2( "Mach64",
|
||||
&psp->dri_version, & dri_expected,
|
||||
&psp->ddx_version, & ddx_expected,
|
||||
@@ -530,3 +449,21 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
|
||||
return mach64FillInModes( psp, dri_priv->cpp * 8, 16, 0, 1);
|
||||
}
|
||||
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
.InitScreen = mach64InitScreen,
|
||||
.DestroyScreen = mach64DestroyScreen,
|
||||
.CreateContext = mach64CreateContext,
|
||||
.DestroyContext = mach64DestroyContext,
|
||||
.CreateBuffer = mach64CreateBuffer,
|
||||
.DestroyBuffer = mach64DestroyBuffer,
|
||||
.SwapBuffers = mach64SwapBuffers,
|
||||
.MakeCurrent = mach64MakeCurrent,
|
||||
.UnbindContext = mach64UnbindContext,
|
||||
.GetSwapInfo = NULL,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -112,20 +112,18 @@ static const GLuint __driNConfigOptions = 6;
|
||||
int MGA_DEBUG = 0;
|
||||
#endif
|
||||
|
||||
static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
|
||||
|
||||
static __GLcontextModes *
|
||||
static const __DRIconfig **
|
||||
mgaFillInModes( __DRIscreenPrivate *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer )
|
||||
{
|
||||
__GLcontextModes * modes;
|
||||
__DRIconfig **configs;
|
||||
__GLcontextModes * m;
|
||||
unsigned num_modes;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
GLenum fb_format;
|
||||
GLenum fb_type;
|
||||
int i;
|
||||
|
||||
/* GLX_SWAP_COPY_OML is only supported because the MGA driver doesn't
|
||||
* support pageflipping at all.
|
||||
@@ -153,8 +151,6 @@ mgaFillInModes( __DRIscreenPrivate *psp,
|
||||
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
|
||||
back_buffer_factor = (have_back_buffer) ? 2 : 1;
|
||||
|
||||
num_modes = depth_buffer_factor * back_buffer_factor * 4;
|
||||
|
||||
if ( pixel_bits == 16 ) {
|
||||
fb_format = GL_RGB;
|
||||
fb_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
@@ -164,39 +160,29 @@ mgaFillInModes( __DRIscreenPrivate *psp,
|
||||
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
|
||||
m = modes;
|
||||
if ( ! driFillInModes( & m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array, depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_TRUE_COLOR ) ) {
|
||||
configs = driCreateConfigs(fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor);
|
||||
if (configs == NULL) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ! driFillInModes( & m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array, depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_DIRECT_COLOR ) ) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for (i = 0; configs[i]; i++) {
|
||||
m = &configs[i]->modes;
|
||||
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for ( m = modes ; m != NULL ; m = m->next ) {
|
||||
if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
return (const __DRIconfig **) configs;
|
||||
}
|
||||
|
||||
|
||||
static const __DRIextension *mgaExtensions[] = {
|
||||
const __DRIextension *mgaScreenExtensions[] = {
|
||||
&driReadDrawableExtension,
|
||||
&driSwapControlExtension.base,
|
||||
&driFrameTrackingExtension.base,
|
||||
@@ -243,7 +229,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
|
||||
}
|
||||
}
|
||||
|
||||
sPriv->extensions = mgaExtensions;
|
||||
sPriv->extensions = mgaScreenExtensions;
|
||||
|
||||
if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
|
||||
serverInfo->chipset != MGA_CARD_TYPE_G400) {
|
||||
@@ -941,23 +927,6 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
|
||||
}
|
||||
|
||||
|
||||
static const struct __DriverAPIRec mgaAPI = {
|
||||
.DestroyScreen = mgaDestroyScreen,
|
||||
.CreateContext = mgaCreateContext,
|
||||
.DestroyContext = mgaDestroyContext,
|
||||
.CreateBuffer = mgaCreateBuffer,
|
||||
.DestroyBuffer = mgaDestroyBuffer,
|
||||
.SwapBuffers = mgaSwapBuffers,
|
||||
.MakeCurrent = mgaMakeCurrent,
|
||||
.UnbindContext = mgaUnbindContext,
|
||||
.GetSwapInfo = getSwapInfo,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This is the driver specific part of the createNewScreen entry point.
|
||||
*
|
||||
@@ -965,14 +934,13 @@ static const struct __DriverAPIRec mgaAPI = {
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
static const __DRIconfig **mgaInitScreen(__DRIscreen *psp)
|
||||
{
|
||||
static const __DRIversion ddx_expected = { 1, 2, 0 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
static const __DRIversion drm_expected = { 3, 0, 0 };
|
||||
MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv;
|
||||
|
||||
psp->DriverAPI = mgaAPI;
|
||||
if ( ! driCheckDriDdxDrmVersions2( "MGA",
|
||||
&psp->dri_version, & dri_expected,
|
||||
&psp->ddx_version, & ddx_expected,
|
||||
@@ -1032,3 +1000,20 @@ getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
.InitScreen = mgaInitScreen,
|
||||
.DestroyScreen = mgaDestroyScreen,
|
||||
.CreateContext = mgaCreateContext,
|
||||
.DestroyContext = mgaDestroyContext,
|
||||
.CreateBuffer = mgaCreateBuffer,
|
||||
.DestroyBuffer = mgaDestroyBuffer,
|
||||
.SwapBuffers = mgaSwapBuffers,
|
||||
.MakeCurrent = mgaMakeCurrent,
|
||||
.UnbindContext = mgaUnbindContext,
|
||||
.GetSwapInfo = getSwapInfo,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
@@ -195,44 +195,13 @@ nouveauGetSwapInfo(__DRIdrawablePrivate *dpriv, __DRIswapInfo *sInfo)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const struct __DriverAPIRec nouveauAPI = {
|
||||
.DestroyScreen = nouveauDestroyScreen,
|
||||
.CreateContext = nouveauCreateContext,
|
||||
.DestroyContext = nouveauDestroyContext,
|
||||
.CreateBuffer = nouveauCreateBuffer,
|
||||
.DestroyBuffer = nouveauDestroyBuffer,
|
||||
.SwapBuffers = nouveauSwapBuffers,
|
||||
.MakeCurrent = nouveauMakeCurrent,
|
||||
.UnbindContext = nouveauUnbindContext,
|
||||
.GetSwapInfo = nouveauGetSwapInfo,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL,
|
||||
.CopySubBuffer = nouveauCopySubBuffer
|
||||
};
|
||||
|
||||
|
||||
static __GLcontextModes *
|
||||
static __DRIconfig **
|
||||
nouveauFillInModes( __DRIscreenPrivate *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer )
|
||||
{
|
||||
__GLcontextModes * modes;
|
||||
__GLcontextModes * m;
|
||||
unsigned num_modes;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
int i;
|
||||
|
||||
static const struct {
|
||||
GLenum format;
|
||||
GLenum type;
|
||||
} fb_format_array[] = {
|
||||
{ GL_RGB , GL_UNSIGNED_SHORT_5_6_5 },
|
||||
{ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV },
|
||||
{ GL_BGR , GL_UNSIGNED_INT_8_8_8_8_REV },
|
||||
};
|
||||
|
||||
/* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
|
||||
* support pageflipping at all.
|
||||
@@ -247,41 +216,22 @@ nouveauFillInModes( __DRIscreenPrivate *psp,
|
||||
depth_buffer_factor = 4;
|
||||
back_buffer_factor = (have_back_buffer) ? 3 : 1;
|
||||
|
||||
num_modes = ((pixel_bits==16) ? 1 : 2) *
|
||||
depth_buffer_factor * back_buffer_factor * 4;
|
||||
modes = (*psp->contextModes->createContextModes)(num_modes,
|
||||
sizeof(__GLcontextModes));
|
||||
m = modes;
|
||||
|
||||
for (i=((pixel_bits==16)?0:1);i<((pixel_bits==16)?1:3);i++) {
|
||||
if (!driFillInModes(&m, fb_format_array[i].format,
|
||||
fb_format_array[i].type,
|
||||
depth_bits_array,
|
||||
stencil_bits_array,
|
||||
depth_buffer_factor,
|
||||
back_buffer_modes,
|
||||
back_buffer_factor,
|
||||
GLX_TRUE_COLOR)) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!driFillInModes(&m, fb_format_array[i].format,
|
||||
fb_format_array[i].type,
|
||||
depth_bits_array,
|
||||
stencil_bits_array,
|
||||
depth_buffer_factor,
|
||||
back_buffer_modes,
|
||||
back_buffer_factor,
|
||||
GLX_DIRECT_COLOR)) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
if (pixel_bits == 16)
|
||||
return driCreateConfigs(GL_RGB,
|
||||
GL_UNSIGNED_SHORT_5_6_5,
|
||||
depth_bits_array,
|
||||
stencil_bits_array,
|
||||
depth_buffer_factor,
|
||||
back_buffer_modes,
|
||||
back_buffer_factor);
|
||||
else
|
||||
return driCreateConfigs(GL_RGBA,
|
||||
GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
depth_bits_array,
|
||||
stencil_bits_array,
|
||||
depth_buffer_factor,
|
||||
back_buffer_modes,
|
||||
back_buffer_factor);
|
||||
}
|
||||
|
||||
|
||||
@@ -292,7 +242,8 @@ nouveauFillInModes( __DRIscreenPrivate *psp,
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
static const __DRIconfig **
|
||||
nouveauInitScreen(__DRIscreenPrivate *psp)
|
||||
{
|
||||
static const __DRIversion ddx_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
@@ -321,8 +272,6 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
psp->DriverAPI = nouveauAPI;
|
||||
|
||||
/* Calling driInitExtensions here, with a NULL context
|
||||
* pointer, does not actually enable the extensions. It just
|
||||
* makes sure that all the dispatch offsets for all the
|
||||
@@ -343,10 +292,34 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
if (!nouveauInitDriver(psp))
|
||||
return NULL;
|
||||
|
||||
return nouveauFillInModes(psp,
|
||||
dri_priv->bpp,
|
||||
(dri_priv->bpp == 16) ? 16 : 24,
|
||||
(dri_priv->bpp == 16) ? 0 : 8,
|
||||
1);
|
||||
return (const __DRIconfig **)
|
||||
nouveauFillInModes(psp,
|
||||
dri_priv->bpp,
|
||||
(dri_priv->bpp == 16) ? 16 : 24,
|
||||
(dri_priv->bpp == 16) ? 0 : 8,
|
||||
1);
|
||||
}
|
||||
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
.InitScreen = nouveauInitScreen,
|
||||
.DestroyScreen = nouveauDestroyScreen,
|
||||
.CreateContext = nouveauCreateContext,
|
||||
.DestroyContext = nouveauDestroyContext,
|
||||
.CreateBuffer = nouveauCreateBuffer,
|
||||
.DestroyBuffer = nouveauDestroyBuffer,
|
||||
.SwapBuffers = nouveauSwapBuffers,
|
||||
.MakeCurrent = nouveauMakeCurrent,
|
||||
.UnbindContext = nouveauUnbindContext,
|
||||
.GetSwapInfo = nouveauGetSwapInfo,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL,
|
||||
.CopySubBuffer = nouveauCopySubBuffer
|
||||
};
|
||||
|
||||
const __DRIextension *__driDriverExtensions[] = {
|
||||
&driCoreExtension.base,
|
||||
&driLegacyExtension.base,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -399,37 +399,18 @@ r128InitDriver( __DRIscreenPrivate *sPriv )
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static struct __DriverAPIRec r128API = {
|
||||
.DestroyScreen = r128DestroyScreen,
|
||||
.CreateContext = r128CreateContext,
|
||||
.DestroyContext = r128DestroyContext,
|
||||
.CreateBuffer = r128CreateBuffer,
|
||||
.DestroyBuffer = r128DestroyBuffer,
|
||||
.SwapBuffers = r128SwapBuffers,
|
||||
.MakeCurrent = r128MakeCurrent,
|
||||
.UnbindContext = r128UnbindContext,
|
||||
.GetSwapInfo = NULL,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
|
||||
};
|
||||
|
||||
|
||||
static __GLcontextModes *
|
||||
static const __DRIconfig **
|
||||
r128FillInModes( __DRIscreenPrivate *psp,
|
||||
unsigned pixel_bits, unsigned depth_bits,
|
||||
unsigned stencil_bits, GLboolean have_back_buffer )
|
||||
{
|
||||
__GLcontextModes * modes;
|
||||
__DRIconfig **configs;
|
||||
__GLcontextModes * m;
|
||||
unsigned num_modes;
|
||||
unsigned depth_buffer_factor;
|
||||
unsigned back_buffer_factor;
|
||||
GLenum fb_format;
|
||||
GLenum fb_type;
|
||||
int i;
|
||||
|
||||
/* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
|
||||
* enough to add support. Basically, if a context is created with an
|
||||
@@ -457,8 +438,6 @@ r128FillInModes( __DRIscreenPrivate *psp,
|
||||
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
|
||||
back_buffer_factor = (have_back_buffer) ? 2 : 1;
|
||||
|
||||
num_modes = depth_buffer_factor * back_buffer_factor * 4;
|
||||
|
||||
if ( pixel_bits == 16 ) {
|
||||
fb_format = GL_RGB;
|
||||
fb_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
@@ -468,35 +447,26 @@ r128FillInModes( __DRIscreenPrivate *psp,
|
||||
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
|
||||
m = modes;
|
||||
if ( ! driFillInModes( & m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array, depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_TRUE_COLOR ) ) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
configs = driCreateConfigs(fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor);
|
||||
if (configs == NULL) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
|
||||
__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ! driFillInModes( & m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array, depth_buffer_factor,
|
||||
back_buffer_modes, back_buffer_factor,
|
||||
GLX_DIRECT_COLOR ) ) {
|
||||
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
|
||||
__func__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for (i = 0; configs[i]; i++) {
|
||||
m = &configs[i]->modes;
|
||||
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
/* Mark the visual as slow if there are "fake" stencil bits.
|
||||
*/
|
||||
for ( m = modes ; m != NULL ; m = m->next ) {
|
||||
if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
|
||||
m->visualRating = GLX_SLOW_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
return modes;
|
||||
return (const __DRIconfig **) configs;
|
||||
}
|
||||
|
||||
|
||||
@@ -507,14 +477,14 @@ r128FillInModes( __DRIscreenPrivate *psp,
|
||||
*
|
||||
* \return the __GLcontextModes supported by this driver
|
||||
*/
|
||||
__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
static const __DRIconfig **
|
||||
r128InitScreen(__DRIscreenPrivate *psp)
|
||||
{
|
||||
static const __DRIversion ddx_expected = { 4, 0, 0 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
static const __DRIversion drm_expected = { 2, 2, 0 };
|
||||
R128DRIPtr dri_priv = (R128DRIPtr) psp->pDevPriv;
|
||||
|
||||
psp->DriverAPI = r128API;
|
||||
if ( ! driCheckDriDdxDrmVersions2( "Rage128",
|
||||
&psp->dri_version, & dri_expected,
|
||||
&psp->ddx_version, & ddx_expected,
|
||||
@@ -542,3 +512,20 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
|
||||
(dri_priv->bpp == 16) ? 0 : 8,
|
||||
(dri_priv->backOffset != dri_priv->depthOffset) );
|
||||
}
|
||||
|
||||
const struct __DriverAPIRec driDriverAPI = {
|
||||
.InitScreen = r128InitScreen,
|
||||
.DestroyScreen = r128DestroyScreen,
|
||||
.CreateContext = r128CreateContext,
|
||||
.DestroyContext = r128DestroyContext,
|
||||
.CreateBuffer = r128CreateBuffer,
|
||||
.DestroyBuffer = r128DestroyBuffer,
|
||||
.SwapBuffers = r128SwapBuffers,
|
||||
.MakeCurrent = r128MakeCurrent,
|
||||
.UnbindContext = r128UnbindContext,
|
||||
.GetSwapInfo = NULL,
|
||||
.GetDrawableMSC = driDrawableGetMSC32,
|
||||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL
|
||||
};
|
||||
|
||||
@@ -979,9 +979,7 @@ static GLboolean r200UpdateTextureEnv( GLcontext *ctx, int unit, int slot, GLuin
|
||||
void r200SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
|
||||
unsigned long long offset, GLint depth, GLuint pitch)
|
||||
{
|
||||
r200ContextPtr rmesa =
|
||||
(r200ContextPtr) ((__DRIcontextPrivate *) pDRICtx->private)->
|
||||
driverPrivate;
|
||||
r200ContextPtr rmesa = pDRICtx->driverPrivate;
|
||||
struct gl_texture_object *tObj =
|
||||
_mesa_lookup_texture(rmesa->glCtx, texname);
|
||||
r200TexObjPtr t;
|
||||
|
||||
@@ -745,9 +745,16 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte
|
||||
goto next;
|
||||
|
||||
case OPCODE_MAD:
|
||||
/* only 2 read ports into temp memory thus may need the macro op MAD_2
|
||||
instead (requiring 2 clocks) if all inputs are in temp memory
|
||||
(and, only if they actually reference 3 distinct temps) */
|
||||
hw_op=(src[0].File == PROGRAM_TEMPORARY &&
|
||||
src[1].File == PROGRAM_TEMPORARY &&
|
||||
src[2].File == PROGRAM_TEMPORARY) ? R200_VPI_OUT_OP_MAD_2 : R200_VPI_OUT_OP_MAD;
|
||||
src[2].File == PROGRAM_TEMPORARY &&
|
||||
(((src[0].RelAddr << 8) | src[0].Index) != ((src[1].RelAddr << 8) | src[1].Index)) &&
|
||||
(((src[0].RelAddr << 8) | src[0].Index) != ((src[2].RelAddr << 8) | src[2].Index)) &&
|
||||
(((src[1].RelAddr << 8) | src[1].Index) != ((src[2].RelAddr << 8) | src[2].Index))) ?
|
||||
R200_VPI_OUT_OP_MAD_2 : R200_VPI_OUT_OP_MAD;
|
||||
|
||||
o_inst->op = MAKE_VSF_OP(hw_op, t_dst(&dst),
|
||||
t_dst_mask(dst.WriteMask));
|
||||
@@ -875,8 +882,11 @@ else {
|
||||
case OPCODE_XPD:
|
||||
/* mul r0, r1.yzxw, r2.zxyw
|
||||
mad r0, -r2.yzxw, r1.zxyw, r0
|
||||
NOTE: might need MAD_2
|
||||
*/
|
||||
hw_op=(src[0].File == PROGRAM_TEMPORARY &&
|
||||
src[1].File == PROGRAM_TEMPORARY &&
|
||||
(((src[0].RelAddr << 8) | src[0].Index) != ((src[1].RelAddr << 8) | src[1].Index))) ?
|
||||
R200_VPI_OUT_OP_MAD_2 : R200_VPI_OUT_OP_MAD;
|
||||
|
||||
o_inst->op = MAKE_VSF_OP(R200_VPI_OUT_OP_MUL,
|
||||
(u_temp_i << R200_VPI_OUT_REG_INDEX_SHIFT) | R200_VSF_OUT_CLASS_TMP,
|
||||
@@ -902,7 +912,7 @@ else {
|
||||
o_inst++;
|
||||
u_temp_i--;
|
||||
|
||||
o_inst->op = MAKE_VSF_OP(R200_VPI_OUT_OP_MAD, t_dst(&dst),
|
||||
o_inst->op = MAKE_VSF_OP(hw_op, t_dst(&dst),
|
||||
t_dst_mask(dst.WriteMask));
|
||||
|
||||
o_inst->src0 = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
|
||||
|
||||
@@ -402,7 +402,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
|
||||
ALLOC_STATE(ri, always, R300_RI_CMDSIZE, 0);
|
||||
r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R300_RS_IP_0, 8);
|
||||
ALLOC_STATE(rr, variable, R300_RR_CMDSIZE, 0);
|
||||
r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, 1);
|
||||
r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_INST_0, 1);
|
||||
}
|
||||
ALLOC_STATE(sc_hyperz, always, 3, 0);
|
||||
r300->hw.sc_hyperz.cmd[0] = cmdpacket0(R300_SC_HYPERZ, 2);
|
||||
|
||||
@@ -333,14 +333,14 @@ struct r300_state_atom {
|
||||
#define R500_RI_CMDSIZE 17
|
||||
|
||||
#define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */
|
||||
#define R300_RR_ROUTE_0 1
|
||||
#define R300_RR_ROUTE_1 2
|
||||
#define R300_RR_ROUTE_2 3
|
||||
#define R300_RR_ROUTE_3 4
|
||||
#define R300_RR_ROUTE_4 5
|
||||
#define R300_RR_ROUTE_5 6
|
||||
#define R300_RR_ROUTE_6 7
|
||||
#define R300_RR_ROUTE_7 8
|
||||
#define R300_RR_INST_0 1
|
||||
#define R300_RR_INST_1 2
|
||||
#define R300_RR_INST_2 3
|
||||
#define R300_RR_INST_3 4
|
||||
#define R300_RR_INST_4 5
|
||||
#define R300_RR_INST_5 6
|
||||
#define R300_RR_INST_6 7
|
||||
#define R300_RR_INST_7 8
|
||||
#define R300_RR_CMDSIZE 9
|
||||
|
||||
#define R300_FP_CMD_0 0
|
||||
|
||||
@@ -213,21 +213,22 @@ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
|
||||
GLuint i, dw;
|
||||
|
||||
/* type, inputs, stop bit, size */
|
||||
for (i = 0; i + 1 < nr; i += 2) {
|
||||
for (i = 0; i < nr; i += 2) {
|
||||
/* make sure input is valid, would lockup the gpu */
|
||||
assert(inputs[tab[i]] != -1);
|
||||
dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[i]] << 8) | (attribptr[tab[i]]->size - 1);
|
||||
dw |= (R300_INPUT_ROUTE_FLOAT | (inputs[tab[i + 1]] << 8) | (attribptr[tab[i + 1]]->size - 1)) << 16;
|
||||
if (i + 2 == nr) {
|
||||
dw |= (R300_VAP_INPUT_ROUTE_END << 16);
|
||||
if (i + 1 == nr) {
|
||||
dw |= R300_VAP_INPUT_ROUTE_END;
|
||||
} else {
|
||||
assert(inputs[tab[i + 1]] != -1);
|
||||
dw |= (R300_INPUT_ROUTE_FLOAT | (inputs[tab[i + 1]] << 8) | (attribptr[tab[i + 1]]->size - 1)) << 16;
|
||||
if (i + 2 == nr) {
|
||||
dw |= (R300_VAP_INPUT_ROUTE_END << 16);
|
||||
}
|
||||
}
|
||||
dst[i >> 1] = dw;
|
||||
}
|
||||
|
||||
if (nr & 1) {
|
||||
dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[nr - 1]] << 8) | (attribptr[tab[nr - 1]]->size - 1);
|
||||
dw |= R300_VAP_INPUT_ROUTE_END;
|
||||
dst[nr >> 1] = dw;
|
||||
}
|
||||
|
||||
return (nr + 1) >> 1;
|
||||
}
|
||||
|
||||
@@ -241,15 +242,14 @@ static GLuint r300VAPInputRoute1Swizzle(int swizzle[4])
|
||||
|
||||
GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr)
|
||||
{
|
||||
GLuint i;
|
||||
GLuint i, dw;
|
||||
|
||||
for (i = 0; i + 1 < nr; i += 2) {
|
||||
dst[i >> 1] = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
|
||||
dst[i >> 1] |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16;
|
||||
}
|
||||
|
||||
if (nr & 1) {
|
||||
dst[nr >> 1] = r300VAPInputRoute1Swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
|
||||
for (i = 0; i < nr; i += 2) {
|
||||
dw = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
|
||||
if (i + 1 < nr) {
|
||||
dw |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16;
|
||||
}
|
||||
dst[i >> 1] = dw;
|
||||
}
|
||||
|
||||
return (nr + 1) >> 1;
|
||||
|
||||
@@ -736,6 +736,7 @@ static GLuint t_src(struct r300_fragment_program *fp,
|
||||
break;
|
||||
case PROGRAM_STATE_VAR:
|
||||
case PROGRAM_NAMED_PARAM:
|
||||
case PROGRAM_CONSTANT:
|
||||
r = emit_const4fv(fp,
|
||||
fp->mesa_program.Base.Parameters->
|
||||
ParameterValues[fpsrc.Index]);
|
||||
|
||||
@@ -96,6 +96,66 @@ typedef struct r300_fragment_program_swizzle {
|
||||
#define DRI_CONF_FP_OPTIMIZATION_SPEED 0
|
||||
#define DRI_CONF_FP_OPTIMIZATION_QUALITY 1
|
||||
|
||||
#if 1
|
||||
|
||||
/**
|
||||
* Fragment program helper macros
|
||||
*/
|
||||
|
||||
/* Produce unshifted source selectors */
|
||||
#define FP_TMP(idx) (idx)
|
||||
#define FP_CONST(idx) ((idx) | (1 << 5))
|
||||
|
||||
/* Produce source/dest selector dword */
|
||||
#define FP_SELC_MASK_NO 0
|
||||
#define FP_SELC_MASK_X 1
|
||||
#define FP_SELC_MASK_Y 2
|
||||
#define FP_SELC_MASK_XY 3
|
||||
#define FP_SELC_MASK_Z 4
|
||||
#define FP_SELC_MASK_XZ 5
|
||||
#define FP_SELC_MASK_YZ 6
|
||||
#define FP_SELC_MASK_XYZ 7
|
||||
|
||||
#define FP_SELC(destidx,regmask,outmask,src0,src1,src2) \
|
||||
(((destidx) << R300_FPI1_DSTC_SHIFT) | \
|
||||
(FP_SELC_MASK_##regmask << 23) | \
|
||||
(FP_SELC_MASK_##outmask << 26) | \
|
||||
((src0) << R300_FPI1_SRC0C_SHIFT) | \
|
||||
((src1) << R300_FPI1_SRC1C_SHIFT) | \
|
||||
((src2) << R300_FPI1_SRC2C_SHIFT))
|
||||
|
||||
#define FP_SELA_MASK_NO 0
|
||||
#define FP_SELA_MASK_W 1
|
||||
|
||||
#define FP_SELA(destidx,regmask,outmask,src0,src1,src2) \
|
||||
(((destidx) << R300_FPI3_DSTA_SHIFT) | \
|
||||
(FP_SELA_MASK_##regmask << 23) | \
|
||||
(FP_SELA_MASK_##outmask << 24) | \
|
||||
((src0) << R300_FPI3_SRC0A_SHIFT) | \
|
||||
((src1) << R300_FPI3_SRC1A_SHIFT) | \
|
||||
((src2) << R300_FPI3_SRC2A_SHIFT))
|
||||
|
||||
/* Produce unshifted argument selectors */
|
||||
#define FP_ARGC(source) R300_FPI0_ARGC_##source
|
||||
#define FP_ARGA(source) R300_FPI2_ARGA_##source
|
||||
#define FP_ABS(arg) ((arg) | (1 << 6))
|
||||
#define FP_NEG(arg) ((arg) ^ (1 << 5))
|
||||
|
||||
/* Produce instruction dword */
|
||||
#define FP_INSTRC(opcode,arg0,arg1,arg2) \
|
||||
(R300_FPI0_OUTC_##opcode | \
|
||||
((arg0) << R300_FPI0_ARG0C_SHIFT) | \
|
||||
((arg1) << R300_FPI0_ARG1C_SHIFT) | \
|
||||
((arg2) << R300_FPI0_ARG2C_SHIFT))
|
||||
|
||||
#define FP_INSTRA(opcode,arg0,arg1,arg2) \
|
||||
(R300_FPI2_OUTA_##opcode | \
|
||||
((arg0) << R300_FPI2_ARG0A_SHIFT) | \
|
||||
((arg1) << R300_FPI2_ARG1A_SHIFT) | \
|
||||
((arg2) << R300_FPI2_ARG2A_SHIFT))
|
||||
|
||||
#endif
|
||||
|
||||
struct r300_fragment_program;
|
||||
|
||||
extern void r300TranslateFragmentShader(r300ContextPtr r300,
|
||||
|
||||
@@ -51,7 +51,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include "r300_ioctl.h"
|
||||
#include "r300_cmdbuf.h"
|
||||
#include "r300_state.h"
|
||||
#include "r300_program.h"
|
||||
#include "r300_vertprog.h"
|
||||
#include "radeon_reg.h"
|
||||
#include "r300_emit.h"
|
||||
|
||||
@@ -290,8 +290,8 @@ static void r300EmitClearState(GLcontext * ctx)
|
||||
e32(0x0);
|
||||
|
||||
R300_STATECHANGE(r300, rr);
|
||||
reg_start(R300_RS_ROUTE_0, 0);
|
||||
e32(R300_RS_ROUTE_0_COLOR);
|
||||
reg_start(R300_RS_INST_0, 0);
|
||||
e32(R300_RS_INST_COL_CN_WRITE);
|
||||
} else {
|
||||
|
||||
R300_STATECHANGE(r300, ri);
|
||||
@@ -413,6 +413,7 @@ static void r300EmitClearState(GLcontext * ctx)
|
||||
if (has_tcl) {
|
||||
R300_STATECHANGE(r300, pvs);
|
||||
reg_start(R300_VAP_PVS_CNTL_1, 2);
|
||||
|
||||
e32((0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
|
||||
(0 << R300_PVS_CNTL_1_POS_END_SHIFT) |
|
||||
(1 << R300_PVS_CNTL_1_PROGRAM_END_SHIFT));
|
||||
@@ -421,14 +422,15 @@ static void r300EmitClearState(GLcontext * ctx)
|
||||
|
||||
R300_STATECHANGE(r300, vpi);
|
||||
vsf_start_fragment(0x0, 8);
|
||||
e32(VP_OUT(ADD, OUT, 0, XYZW));
|
||||
e32(VP_IN(IN, 0));
|
||||
e32(VP_ZERO());
|
||||
|
||||
e32(PVS_OP_DST_OPERAND(VE_ADD, GL_FALSE, GL_FALSE, 0, 0xf, PVS_DST_REG_OUT));
|
||||
e32(PVS_SRC_OPERAND(0, PVS_SRC_SELECT_X, PVS_SRC_SELECT_Y, PVS_SRC_SELECT_Z, PVS_SRC_SELECT_W, PVS_SRC_REG_INPUT, VSF_FLAG_NONE));
|
||||
e32(PVS_SRC_OPERAND(0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_REG_INPUT, VSF_FLAG_NONE));
|
||||
e32(0x0);
|
||||
|
||||
e32(VP_OUT(ADD, OUT, 1, XYZW));
|
||||
e32(VP_IN(IN, 1));
|
||||
e32(VP_ZERO());
|
||||
e32(PVS_OP_DST_OPERAND(VE_ADD, GL_FALSE, GL_FALSE, 1, 0xf, PVS_DST_REG_OUT));
|
||||
e32(PVS_SRC_OPERAND(1, PVS_SRC_SELECT_X, PVS_SRC_SELECT_Y, PVS_SRC_SELECT_Z, PVS_SRC_SELECT_W, PVS_SRC_REG_INPUT, VSF_FLAG_NONE));
|
||||
e32(PVS_SRC_OPERAND(1, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_REG_INPUT, VSF_FLAG_NONE));
|
||||
e32(0x0);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user