Compare commits
81 Commits
mesa-7.3-r
...
mesa-7.3-r
Author | SHA1 | Date | |
---|---|---|---|
|
f5c47105db | ||
|
f1939c8685 | ||
|
3ac4d678ef | ||
|
fcfec66865 | ||
|
53426d7113 | ||
|
39e6d0d810 | ||
|
b5da7feee0 | ||
|
0f548dbc98 | ||
|
9d216be8cf | ||
|
eb26cc6cf5 | ||
|
bb63a663b1 | ||
|
dace4e3e2a | ||
|
bbda892c55 | ||
|
61a387dca1 | ||
|
437fa85ba3 | ||
|
b00477acf3 | ||
|
7374285f07 | ||
|
5c84a1032c | ||
|
dbda49a9e6 | ||
|
11351f0c8a | ||
|
a5b5bc9f95 | ||
|
f97792421b | ||
|
396711b840 | ||
|
dbd8e4066b | ||
|
b7f802eca2 | ||
|
1d4756de06 | ||
|
c1abb821f9 | ||
|
a61a1a8181 | ||
|
345a08a77f | ||
|
12c6d28cc7 | ||
|
e442fe5ba5 | ||
|
66a4f5cf9a | ||
|
a740858fc0 | ||
|
e7c988d065 | ||
|
4a8356209d | ||
|
e1ba29ea19 | ||
|
fbf13bcb8a | ||
|
8f8435637d | ||
|
7d08091767 | ||
|
b5f32e1d5a | ||
|
0dffd22349 | ||
|
947d1c5b2a | ||
|
c7f43543af | ||
|
5912cdff3e | ||
|
03188b09e0 | ||
|
fae9604727 | ||
|
aac4a0509e | ||
|
b5f89e5f17 | ||
|
c12d24b513 | ||
|
2549c26a8b | ||
|
a98dccca36 | ||
|
1b3e3e6b84 | ||
|
49b53407c7 | ||
|
d911e3e24f | ||
|
658ab3c3ae | ||
|
8f7349dbb4 | ||
|
d687476edd | ||
|
c157a5bb91 | ||
|
14eca6b573 | ||
|
ef0e0f2550 | ||
|
34d17d2bdc | ||
|
01a0938776 | ||
|
1f47388dfe | ||
|
34500a6da5 | ||
|
00c02626d8 | ||
|
eeeed45c2c | ||
|
3a5463d158 | ||
|
de35989cde | ||
|
29f603a270 | ||
|
7f7fc3e3af | ||
|
a0318d7f8e | ||
|
06fdb6a74c | ||
|
88fdddcbbe | ||
|
1598be5083 | ||
|
436024561a | ||
|
0f0922f93c | ||
|
33f6dc3c33 | ||
|
356428d4e4 | ||
|
b4866f8a52 | ||
|
297a9606ea | ||
|
44557bf065 |
18
Makefile
18
Makefile
@@ -174,10 +174,10 @@ ultrix-gcc:
|
||||
|
||||
# Rules for making release tarballs
|
||||
|
||||
DIRECTORY = Mesa-7.3-rc1
|
||||
LIB_NAME = MesaLib-7.3-rc1
|
||||
DEMO_NAME = MesaDemos-7.3-rc1
|
||||
GLUT_NAME = MesaGLUT-7.3-rc1
|
||||
DIRECTORY = Mesa-7.3-rc3
|
||||
LIB_NAME = MesaLib-7.3-rc3
|
||||
DEMO_NAME = MesaDemos-7.3-rc3
|
||||
GLUT_NAME = MesaGLUT-7.3-rc3
|
||||
|
||||
MAIN_FILES = \
|
||||
$(DIRECTORY)/Makefile* \
|
||||
@@ -223,6 +223,7 @@ MAIN_FILES = \
|
||||
$(DIRECTORY)/src/mesa/sources \
|
||||
$(DIRECTORY)/src/mesa/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/gl.pc.in \
|
||||
$(DIRECTORY)/src/mesa/osmesa.pc.in \
|
||||
$(DIRECTORY)/src/mesa/depend \
|
||||
$(DIRECTORY)/src/mesa/main/*.[chS] \
|
||||
$(DIRECTORY)/src/mesa/main/descrip.mms \
|
||||
@@ -297,14 +298,7 @@ MAIN_FILES = \
|
||||
$(DIRECTORY)/vms/analyze_map.com \
|
||||
$(DIRECTORY)/vms/xlib.opt \
|
||||
$(DIRECTORY)/vms/xlib_share.opt \
|
||||
$(DIRECTORY)/windows/VC8/mesa/mesa.sln \
|
||||
$(DIRECTORY)/windows/VC8/mesa/gdi/gdi.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/mesa/glu/glu.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/mesa/mesa/mesa.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/mesa/osmesa/osmesa.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/progs/progs.sln \
|
||||
$(DIRECTORY)/windows/VC8/progs/demos/gears.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/progs/glut/glut.vcproj
|
||||
$(DIRECTORY)/windows/VC8/
|
||||
|
||||
|
||||
DRI_FILES = \
|
||||
|
@@ -22,7 +22,7 @@ AC_CONFIG_AUX_DIR([bin])
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
dnl Versions for external dependencies
|
||||
LIBDRM_REQUIRED=2.3.1
|
||||
LIBDRM_REQUIRED=2.4.3
|
||||
DRI2PROTO_REQUIRED=1.99.3
|
||||
|
||||
dnl Check for progs
|
||||
@@ -83,11 +83,8 @@ dnl Compiler macros
|
||||
DEFINES=""
|
||||
AC_SUBST([DEFINES])
|
||||
case "$host_os" in
|
||||
*-gnu)
|
||||
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"
|
||||
*-gnu*)
|
||||
DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS"
|
||||
;;
|
||||
solaris*)
|
||||
DEFINES="$DEFINES -DPTHREADS -DSVR4"
|
||||
|
10
debian/changelog
vendored
10
debian/changelog
vendored
@@ -1,3 +1,13 @@
|
||||
mesa (7.3~rc3-1) experimental; urgency=low
|
||||
|
||||
[ Timo Aaltonen ]
|
||||
* New upstream release candidate.
|
||||
|
||||
[ Julien Cristau ]
|
||||
* Refresh patches 03 and 04.
|
||||
|
||||
-- Julien Cristau <jcristau@debian.org> Wed, 21 Jan 2009 19:01:21 +0100
|
||||
|
||||
mesa (7.3~rc1-1) experimental; urgency=low
|
||||
|
||||
* New upstream release candidate.
|
||||
|
@@ -12,8 +12,8 @@ and we don't actually build it at this point.
|
||||
|
||||
Index: mesa/progs/xdemos/Makefile
|
||||
===================================================================
|
||||
--- mesa.orig/progs/xdemos/Makefile 2008-07-01 15:26:56.000000000 +0300
|
||||
+++ mesa/progs/xdemos/Makefile 2008-07-01 15:48:47.000000000 +0300
|
||||
--- mesa.orig/progs/xdemos/Makefile
|
||||
+++ mesa/progs/xdemos/Makefile
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
@@ -21,9 +21,9 @@ Index: mesa/progs/xdemos/Makefile
|
||||
-PROGS = \
|
||||
+PROGS ?= \
|
||||
corender \
|
||||
glsync \
|
||||
glthreads \
|
||||
glxdemo \
|
||||
@@ -60,6 +60,11 @@
|
||||
@@ -61,6 +61,11 @@
|
||||
extra: $(EXTRA_PROGS)
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ Index: mesa/progs/xdemos/Makefile
|
||||
-rm -f *.o *~
|
||||
Index: mesa/progs/Makefile
|
||||
===================================================================
|
||||
--- mesa.orig/progs/Makefile 2008-07-01 15:26:56.000000000 +0300
|
||||
+++ mesa/progs/Makefile 2008-07-01 15:48:07.000000000 +0300
|
||||
--- mesa.orig/progs/Makefile
|
||||
+++ mesa/progs/Makefile
|
||||
@@ -21,8 +21,12 @@
|
||||
fi \
|
||||
done
|
||||
|
10
debian/patches/04_osmesa_version.diff
vendored
10
debian/patches/04_osmesa_version.diff
vendored
@@ -1,17 +1,17 @@
|
||||
Index: mesa/src/mesa/drivers/osmesa/Makefile
|
||||
===================================================================
|
||||
--- mesa.orig/src/mesa/drivers/osmesa/Makefile 2008-09-12 10:44:02.000000000 +0300
|
||||
+++ mesa/src/mesa/drivers/osmesa/Makefile 2008-09-23 16:07:40.000000000 +0300
|
||||
@@ -46,7 +46,7 @@
|
||||
--- mesa.orig/src/mesa/drivers/osmesa/Makefile
|
||||
+++ mesa/src/mesa/drivers/osmesa/Makefile
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
$(TOP)/lib/$(OSMESA_LIB_NAME): $(OBJECTS)
|
||||
$(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OBJECTS)
|
||||
$(MKLIB) -o $(OSMESA_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
- -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
|
||||
+ -major 6 -minor 5 -patch 3 \
|
||||
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
|
||||
-id $(INSTALL_LIB_DIR)/lib$(OSMESA_LIB).$(MESA_MAJOR).dylib \
|
||||
$(OSMESA_LIB_DEPS) $(OBJECTS)
|
||||
@@ -58,7 +58,7 @@
|
||||
@@ -57,7 +57,7 @@
|
||||
# with all the other Mesa sources (compiled with -DCHAN_BITS=16/32
|
||||
osmesa16: $(OBJECTS) $(CORE_MESA)
|
||||
$(MKLIB) -o $(OSMESA_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
|
@@ -16,7 +16,7 @@ Status
|
||||
|
||||
Version
|
||||
|
||||
Last Modified Date: 8 June 2000
|
||||
Last Modified Date: 12 January 2009
|
||||
|
||||
Number
|
||||
|
||||
@@ -69,6 +69,12 @@ Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
|
||||
<width> and <height> indicate the size in pixels. Coordinate (0,0)
|
||||
corresponds to the lower-left pixel of the window, like glReadPixels.
|
||||
|
||||
If dpy and drawable are the display and drawable for the calling
|
||||
thread's current context, glXCopySubBufferMESA performs an
|
||||
implicit glFlush before it returns. Subsequent OpenGL commands
|
||||
may be issued immediately after calling glXCopySubBufferMESA, but
|
||||
are not executed until the copy is completed.
|
||||
|
||||
GLX Protocol
|
||||
|
||||
None at this time. The extension is implemented in terms of ordinary
|
||||
@@ -84,5 +90,7 @@ New State
|
||||
|
||||
Revision History
|
||||
|
||||
8 June 2000 - initial specification
|
||||
12 January 2009 Ian Romanick - Added language about implicit flush
|
||||
and command completion.
|
||||
8 June 2000 Brian Paul - initial specification
|
||||
|
||||
|
@@ -43,6 +43,10 @@ tbd
|
||||
<ul>
|
||||
<li>Assorted GLSL bug fixes
|
||||
<li>Assorted i965 driver fixes
|
||||
<li>Fix for wglCreateLayerContext() in WGL/Windows driver
|
||||
<li>Build fixes for OpenBSD and gcc 2.95
|
||||
<li>GLSL preprocessor handles #pragma now
|
||||
<li>Fix incorrect transformation of GL_SPOT_DIRECTION
|
||||
</ul>
|
||||
|
||||
<h2>Changes</h2>
|
||||
|
@@ -624,6 +624,8 @@ struct __DRIswrastExtensionRec {
|
||||
#define __DRI_BUFFER_DEPTH 4
|
||||
#define __DRI_BUFFER_STENCIL 5
|
||||
#define __DRI_BUFFER_ACCUM 6
|
||||
#define __DRI_BUFFER_FAKE_FRONT_LEFT 7
|
||||
#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
|
||||
|
||||
struct __DRIbufferRec {
|
||||
unsigned int attachment;
|
||||
|
@@ -113,7 +113,7 @@ swrastGetDrawableInfo(__DRIdrawable * draw,
|
||||
int *x, int *y, int *w, int *h, void *loaderPrivate)
|
||||
{
|
||||
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
|
||||
__GLXDRIdrawable *pdraw = &(pdp->base);;
|
||||
__GLXDRIdrawable *pdraw = &(pdp->base);
|
||||
Display *dpy = pdraw->psc->dpy;
|
||||
Drawable drawable;
|
||||
|
||||
@@ -141,7 +141,7 @@ swrastPutImage(__DRIdrawable * draw, int op,
|
||||
int x, int y, int w, int h, char *data, void *loaderPrivate)
|
||||
{
|
||||
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
|
||||
__GLXDRIdrawable *pdraw = &(pdp->base);;
|
||||
__GLXDRIdrawable *pdraw = &(pdp->base);
|
||||
Display *dpy = pdraw->psc->dpy;
|
||||
Drawable drawable;
|
||||
XImage *ximage;
|
||||
@@ -176,7 +176,7 @@ swrastGetImage(__DRIdrawable * draw,
|
||||
int x, int y, int w, int h, char *data, void *loaderPrivate)
|
||||
{
|
||||
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
|
||||
__GLXDRIdrawable *pdraw = &(pdp->base);;
|
||||
__GLXDRIdrawable *pdraw = &(pdp->base);
|
||||
Display *dpy = pdraw->psc->dpy;
|
||||
Drawable drawable;
|
||||
XImage *ximage;
|
||||
|
@@ -220,14 +220,14 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
|
||||
unsigned int length;
|
||||
unsigned int i;
|
||||
unsigned int num_attributes;
|
||||
GLboolean use_glx_1_3;
|
||||
|
||||
if ((dpy == NULL) || (drawable == 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
priv = __glXInitialize(dpy);
|
||||
GLboolean use_glx_1_3 = ((priv->majorVersion > 1)
|
||||
|| (priv->minorVersion >= 3));
|
||||
use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3));
|
||||
|
||||
*value = 0;
|
||||
|
||||
|
@@ -864,6 +864,12 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
|
||||
GLXContext gc;
|
||||
GLXContextTag tag;
|
||||
CARD8 opcode;
|
||||
#ifdef USE_XCB
|
||||
xcb_connection_t *c;
|
||||
#else
|
||||
xGLXSwapBuffersReq *req;
|
||||
#endif
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
|
||||
|
||||
@@ -892,12 +898,10 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
|
||||
}
|
||||
|
||||
#ifdef USE_XCB
|
||||
xcb_connection_t* c = XGetXCBConnection(dpy);
|
||||
c = XGetXCBConnection(dpy);
|
||||
xcb_glx_swap_buffers(c, tag, drawable);
|
||||
xcb_flush(c);
|
||||
#else
|
||||
xGLXSwapBuffersReq *req;
|
||||
|
||||
/* Send the glXSwapBuffers request */
|
||||
LockDisplay(dpy);
|
||||
GetReq(GLXSwapBuffers,req);
|
||||
|
@@ -365,7 +365,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
|
||||
const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext))
|
||||
? opcode : __glXSetupForCommand(oldGC->currentDpy);
|
||||
Bool bindReturnValue;
|
||||
|
||||
__GLXattribute *state;
|
||||
|
||||
if (!opcode || !oldOpcode) {
|
||||
return GL_FALSE;
|
||||
@@ -489,8 +489,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
|
||||
} while (0);
|
||||
#endif
|
||||
|
||||
__GLXattribute *state =
|
||||
(__GLXattribute *) (gc->client_state_private);
|
||||
state = (__GLXattribute *) (gc->client_state_private);
|
||||
|
||||
gc->currentContextTag = reply.contextTag;
|
||||
if (state->array_state == NULL) {
|
||||
|
@@ -108,6 +108,28 @@ do { \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Same as above, but for two drawables simultaneously.
|
||||
*
|
||||
*/
|
||||
|
||||
#define DRI_VALIDATE_TWO_DRAWABLES_INFO(psp, pdp, prp) \
|
||||
do { \
|
||||
while (*((pdp)->pStamp) != (pdp)->lastStamp || \
|
||||
*((prp)->pStamp) != (prp)->lastStamp) { \
|
||||
register unsigned int hwContext = (psp)->pSAREA->lock.lock & \
|
||||
~(DRM_LOCK_HELD | DRM_LOCK_CONT); \
|
||||
DRM_UNLOCK((psp)->fd, &(psp)->pSAREA->lock, hwContext); \
|
||||
\
|
||||
DRM_SPINLOCK(&(psp)->pSAREA->drawable_lock, (psp)->drawLockID); \
|
||||
DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
|
||||
DRI_VALIDATE_DRAWABLE_INFO_ONCE(prp); \
|
||||
DRM_SPINUNLOCK(&(psp)->pSAREA->drawable_lock, (psp)->drawLockID); \
|
||||
\
|
||||
DRM_LIGHT_LOCK((psp)->fd, &(psp)->pSAREA->lock, hwContext); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Driver callback functions.
|
||||
|
@@ -143,6 +143,9 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
|
||||
ctx->Const.MaxCubeTextureLevels = 12;
|
||||
ctx->Const.MaxTextureRectSize = (1<<11);
|
||||
|
||||
/* if conformance mode is set, swrast can handle any size AA point */
|
||||
ctx->Const.MaxPointSizeAA = 255.0;
|
||||
|
||||
/* ctx->Const.MaxNativeVertexProgramTemps = 32; */
|
||||
|
||||
brw_init_attribs( brw );
|
||||
|
@@ -111,9 +111,15 @@ static void brwProgramStringNotify( GLcontext *ctx,
|
||||
struct gl_program *prog )
|
||||
{
|
||||
if (target == GL_FRAGMENT_PROGRAM_ARB) {
|
||||
struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog;
|
||||
struct brw_context *brw = brw_context(ctx);
|
||||
struct brw_fragment_program *p = (struct brw_fragment_program *)prog;
|
||||
struct brw_fragment_program *fp = (struct brw_fragment_program *)brw->fragment_program;
|
||||
if (fprog->FogOption) {
|
||||
_mesa_append_fog_code(ctx, fprog);
|
||||
fprog->FogOption = GL_NONE;
|
||||
}
|
||||
|
||||
if (p == fp)
|
||||
brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM;
|
||||
p->id = brw->program_id++;
|
||||
|
@@ -73,10 +73,12 @@ static void compile_sf_prog( struct brw_context *brw,
|
||||
c.attr_to_idx[i] = idx;
|
||||
c.idx_to_attr[idx] = i;
|
||||
if (i >= VERT_RESULT_TEX0 && i <= VERT_RESULT_TEX7) {
|
||||
c.point_attrs[i].CoordReplace =
|
||||
brw->attribs.Point->CoordReplace[i - VERT_RESULT_TEX0];
|
||||
} else
|
||||
c.point_attrs[i].CoordReplace = GL_FALSE;
|
||||
c.point_attrs[i].CoordReplace =
|
||||
brw->attribs.Point->CoordReplace[i - VERT_RESULT_TEX0];
|
||||
}
|
||||
else {
|
||||
c.point_attrs[i].CoordReplace = GL_FALSE;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
@@ -106,7 +108,6 @@ static void compile_sf_prog( struct brw_context *brw,
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* get the program
|
||||
*/
|
||||
|
@@ -42,22 +42,15 @@ static void upload_sf_vp(struct brw_context *brw)
|
||||
GLcontext *ctx = &brw->intel.ctx;
|
||||
const GLfloat depth_scale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
|
||||
struct brw_sf_viewport sfv;
|
||||
struct intel_renderbuffer *irb =
|
||||
intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
|
||||
GLfloat y_scale, y_bias;
|
||||
|
||||
memset(&sfv, 0, sizeof(sfv));
|
||||
|
||||
if (ctx->DrawBuffer->Name) {
|
||||
/* User-created FBO */
|
||||
if (irb && !irb->RenderToTexture) {
|
||||
y_scale = -1.0;
|
||||
y_bias = ctx->DrawBuffer->Height;
|
||||
} else {
|
||||
y_scale = 1.0;
|
||||
y_bias = 0;
|
||||
}
|
||||
} else {
|
||||
if (intel_rendering_to_texture(ctx)) {
|
||||
y_scale = 1.0;
|
||||
y_bias = 0;
|
||||
}
|
||||
else {
|
||||
y_scale = -1.0;
|
||||
y_bias = ctx->DrawBuffer->Height;
|
||||
}
|
||||
@@ -120,6 +113,7 @@ struct brw_sf_unit_key {
|
||||
GLboolean scissor, line_smooth, point_sprite, point_attenuated;
|
||||
float line_width;
|
||||
float point_size;
|
||||
GLboolean render_to_texture;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -150,6 +144,8 @@ sf_unit_populate_key(struct brw_context *brw, struct brw_sf_unit_key *key)
|
||||
key->point_sprite = brw->attribs.Point->PointSprite;
|
||||
key->point_size = brw->attribs.Point->Size;
|
||||
key->point_attenuated = brw->attribs.Point->_Attenuated;
|
||||
|
||||
key->render_to_texture = intel_rendering_to_texture(&brw->intel.ctx);
|
||||
}
|
||||
|
||||
static dri_bo *
|
||||
@@ -196,6 +192,11 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
|
||||
else
|
||||
sf.sf5.front_winding = BRW_FRONTWINDING_CW;
|
||||
|
||||
/* The viewport is inverted for rendering to texture, and that inverts
|
||||
* polygon front/back orientation.
|
||||
*/
|
||||
sf.sf5.front_winding ^= key->render_to_texture;
|
||||
|
||||
switch (key->cull_face) {
|
||||
case GL_FRONT:
|
||||
sf.sf6.cull_mode = BRW_CULLMODE_FRONT;
|
||||
@@ -229,7 +230,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
|
||||
/* XXX clamp max depends on AA vs. non-AA */
|
||||
|
||||
sf.sf7.sprite_point = key->point_sprite;
|
||||
sf.sf7.point_size = CLAMP(nearbyint(key->point_size), 1, 255) * (1<<3);
|
||||
sf.sf7.point_size = CLAMP(rint(key->point_size), 1, 255) * (1<<3);
|
||||
sf.sf7.use_point_size_state = !key->point_attenuated;
|
||||
sf.sf7.aa_line_distance_mode = 0;
|
||||
|
||||
|
@@ -811,57 +811,6 @@ static void precalc_txp( struct brw_wm_compile *c,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Add instructions to perform fog blending
|
||||
*/
|
||||
|
||||
static void fog_blend( struct brw_wm_compile *c,
|
||||
struct prog_src_register fog_factor )
|
||||
{
|
||||
struct prog_dst_register outcolor = dst_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLR);
|
||||
struct prog_src_register fogcolor = search_or_add_param5( c, STATE_FOG_COLOR, 0,0,0,0 );
|
||||
|
||||
/* color.xyz = LRP fog_factor.xxxx, output_color, fog_color */
|
||||
|
||||
emit_op(c,
|
||||
OPCODE_LRP,
|
||||
dst_mask(outcolor, WRITEMASK_XYZ),
|
||||
0, 0, 0,
|
||||
fog_factor,
|
||||
src_reg_from_dst(outcolor),
|
||||
fogcolor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* This one is simple - just take the interpolated fog coordinate and
|
||||
* use it as the fog blend factor.
|
||||
*/
|
||||
static void fog_interpolated( struct brw_wm_compile *c )
|
||||
{
|
||||
struct prog_src_register fogc = src_reg(PROGRAM_INPUT, FRAG_ATTRIB_FOGC);
|
||||
|
||||
if (!(c->fp_interp_emitted & (1<<FRAG_ATTRIB_FOGC)))
|
||||
emit_interp(c, FRAG_ATTRIB_FOGC);
|
||||
|
||||
fog_blend( c, src_swizzle1(fogc, GET_SWZ(fogc.Swizzle,X)));
|
||||
}
|
||||
|
||||
static void emit_fog( struct brw_wm_compile *c )
|
||||
{
|
||||
if (!c->fp->program.FogOption)
|
||||
return;
|
||||
|
||||
if (1)
|
||||
fog_interpolated( c );
|
||||
else {
|
||||
/* TODO: per-pixel fog */
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void emit_fb_write( struct brw_wm_compile *c )
|
||||
{
|
||||
struct prog_src_register payload_r0_depth = src_reg(PROGRAM_PAYLOAD, PAYLOAD_DEPTH);
|
||||
@@ -1059,7 +1008,6 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
|
||||
emit_ddy(c, inst);
|
||||
break;
|
||||
case OPCODE_END:
|
||||
emit_fog(c);
|
||||
emit_fb_write(c);
|
||||
break;
|
||||
case OPCODE_PRINT:
|
||||
|
@@ -892,15 +892,19 @@ static void emit_lrp(struct brw_wm_compile *c,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For GLSL shaders, this KIL will be unconditional.
|
||||
* It may be contained inside an IF/ENDIF structure of course.
|
||||
*/
|
||||
static void emit_kil(struct brw_wm_compile *c)
|
||||
{
|
||||
struct brw_compile *p = &c->func;
|
||||
struct brw_reg depth = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
|
||||
brw_push_insn_state(p);
|
||||
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
||||
brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK
|
||||
brw_AND(p, depth, c->emit_mask_reg, depth);
|
||||
brw_pop_insn_state(p);
|
||||
struct brw_compile *p = &c->func;
|
||||
struct brw_reg depth = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
|
||||
brw_push_insn_state(p);
|
||||
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
||||
brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK
|
||||
brw_AND(p, depth, c->emit_mask_reg, depth);
|
||||
brw_pop_insn_state(p);
|
||||
}
|
||||
|
||||
static void emit_mad(struct brw_wm_compile *c,
|
||||
|
@@ -244,7 +244,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
|
||||
entry->minfilter = texObj->MinFilter;
|
||||
entry->magfilter = texObj->MagFilter;
|
||||
entry->comparemode = texObj->CompareMode;
|
||||
entry->comparefunc = texObj->CompareFunc;
|
||||
entry->comparefunc = texObj->CompareFunc;
|
||||
|
||||
dri_bo_unreference(brw->wm.sdc_bo[unit]);
|
||||
if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
|
||||
|
@@ -192,21 +192,27 @@ brw_create_texture_surface( struct brw_context *brw,
|
||||
if (key->bo)
|
||||
surf.ss0.surface_format = translate_tex_format(key->format, key->depthmode);
|
||||
else {
|
||||
switch(key->depth) {
|
||||
case 32: surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM; break;
|
||||
default:
|
||||
case 24: surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8X8_UNORM; break;
|
||||
case 16: surf.ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM; break;
|
||||
}
|
||||
switch (key->depth) {
|
||||
case 32:
|
||||
surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
|
||||
break;
|
||||
default:
|
||||
case 24:
|
||||
surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8X8_UNORM;
|
||||
break;
|
||||
case 16:
|
||||
surf.ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is ok for all textures with channel width 8bit or less:
|
||||
*/
|
||||
/* surf.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */
|
||||
if (key->bo)
|
||||
surf.ss1.base_addr = key->bo->offset; /* reloc */
|
||||
surf.ss1.base_addr = key->bo->offset; /* reloc */
|
||||
else
|
||||
surf.ss1.base_addr = key->offset;
|
||||
surf.ss1.base_addr = key->offset;
|
||||
|
||||
surf.ss2.mip_count = key->last_level - key->first_level;
|
||||
surf.ss2.width = key->width - 1;
|
||||
|
@@ -544,7 +544,6 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
|
||||
_mesa_debug(ctx, "hardware blit clear buf %d rb id %d\n",
|
||||
buf, irb->Base.Name);
|
||||
*/
|
||||
intel_wait_flips(intel);
|
||||
|
||||
assert(b.x1 < b.x2);
|
||||
assert(b.y1 < b.y2);
|
||||
|
@@ -43,22 +43,6 @@
|
||||
#include "vblank.h"
|
||||
#include "i915_drm.h"
|
||||
|
||||
/* This block can be removed when libdrm >= 2.3.1 is required */
|
||||
|
||||
#ifndef DRM_IOCTL_I915_FLIP
|
||||
|
||||
#define DRM_VBLANK_FLIP 0x8000000
|
||||
|
||||
typedef struct drm_i915_flip {
|
||||
int pipes;
|
||||
} drm_i915_flip_t;
|
||||
|
||||
#undef DRM_IOCTL_I915_FLIP
|
||||
#define DRM_IOCTL_I915_FLIP DRM_IOW(DRM_COMMAND_BASE + DRM_I915_FLIP, \
|
||||
drm_i915_flip_t)
|
||||
|
||||
#endif
|
||||
|
||||
#define FILE_DEBUG_FLAG DEBUG_BLIT
|
||||
|
||||
/**
|
||||
@@ -143,8 +127,7 @@ intel_get_cliprects(struct intel_context *intel,
|
||||
*num_cliprects = 1;
|
||||
*x_off = 0;
|
||||
*y_off = 0;
|
||||
} else if (intel->front_cliprects ||
|
||||
intel_fb->pf_active || dPriv->numBackClipRects == 0) {
|
||||
} else if (intel->front_cliprects || dPriv->numBackClipRects == 0) {
|
||||
/* use the front clip rects */
|
||||
*cliprects = dPriv->pClipRects;
|
||||
*num_cliprects = dPriv->numClipRects;
|
||||
@@ -160,76 +143,6 @@ intel_get_cliprects(struct intel_context *intel,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
intelUpdatePageFlipping(struct intel_context *intel,
|
||||
GLint areaA, GLint areaB)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = intel->driDrawable;
|
||||
struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
|
||||
GLboolean pf_active;
|
||||
GLint pf_planes;
|
||||
|
||||
/* Update page flipping info */
|
||||
pf_planes = 0;
|
||||
|
||||
if (areaA > 0)
|
||||
pf_planes |= 1;
|
||||
|
||||
if (areaB > 0)
|
||||
pf_planes |= 2;
|
||||
|
||||
intel_fb->pf_current_page = (intel->sarea->pf_current_page >>
|
||||
(intel_fb->pf_planes & 0x2)) & 0x3;
|
||||
|
||||
intel_fb->pf_num_pages = 2;
|
||||
|
||||
pf_active = pf_planes && (pf_planes & intel->sarea->pf_active) == pf_planes;
|
||||
|
||||
if (INTEL_DEBUG & DEBUG_LOCK)
|
||||
if (pf_active != intel_fb->pf_active)
|
||||
_mesa_printf("%s - Page flipping %sactive\n", __progname,
|
||||
pf_active ? "" : "in");
|
||||
|
||||
if (pf_active) {
|
||||
/* Sync pages between planes if flipping on both at the same time */
|
||||
if (pf_planes == 0x3 && pf_planes != intel_fb->pf_planes &&
|
||||
(intel->sarea->pf_current_page & 0x3) !=
|
||||
(((intel->sarea->pf_current_page) >> 2) & 0x3)) {
|
||||
drm_i915_flip_t flip;
|
||||
|
||||
if (intel_fb->pf_current_page ==
|
||||
(intel->sarea->pf_current_page & 0x3)) {
|
||||
/* XXX: This is ugly, but emitting two flips 'in a row' can cause
|
||||
* lockups for unknown reasons.
|
||||
*/
|
||||
intel->sarea->pf_current_page =
|
||||
intel->sarea->pf_current_page & 0x3;
|
||||
intel->sarea->pf_current_page |=
|
||||
((intel_fb->pf_current_page + intel_fb->pf_num_pages - 1) %
|
||||
intel_fb->pf_num_pages) << 2;
|
||||
|
||||
flip.pipes = 0x2;
|
||||
} else {
|
||||
intel->sarea->pf_current_page =
|
||||
intel->sarea->pf_current_page & (0x3 << 2);
|
||||
intel->sarea->pf_current_page |=
|
||||
(intel_fb->pf_current_page + intel_fb->pf_num_pages - 1) %
|
||||
intel_fb->pf_num_pages;
|
||||
|
||||
flip.pipes = 0x1;
|
||||
}
|
||||
|
||||
drmCommandWrite(intel->driFd, DRM_I915_FLIP, &flip, sizeof(flip));
|
||||
}
|
||||
|
||||
intel_fb->pf_planes = pf_planes;
|
||||
}
|
||||
|
||||
intel_fb->pf_active = pf_active;
|
||||
intel_flip_renderbuffers(intel_fb);
|
||||
intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will be called whenever the currently bound window is moved/resized.
|
||||
* XXX: actually, it seems to NOT be called when the window is only moved (BP).
|
||||
@@ -243,7 +156,7 @@ intelWindowMoved(struct intel_context *intel)
|
||||
|
||||
if (!intel->intelScreen->driScrnPriv->dri2.enabled &&
|
||||
intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) {
|
||||
volatile struct drm_i915_sarea *sarea = intel->sarea;
|
||||
volatile drm_i915_sarea_t *sarea = intel->sarea;
|
||||
drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w,
|
||||
.y1 = dPriv->y, .y2 = dPriv->y + dPriv->h };
|
||||
drm_clip_rect_t planeA_rect = { .x1 = sarea->planeA_x, .y1 = sarea->planeA_y,
|
||||
@@ -256,8 +169,6 @@ intelWindowMoved(struct intel_context *intel)
|
||||
GLint areaB = driIntersectArea( drw_rect, planeB_rect );
|
||||
GLuint flags = dPriv->vblFlags;
|
||||
|
||||
intelUpdatePageFlipping(intel, areaA, areaB);
|
||||
|
||||
/* Update vblank info
|
||||
*/
|
||||
if (areaB > areaA || (areaA == areaB && areaB > 0)) {
|
||||
@@ -282,7 +193,7 @@ intelWindowMoved(struct intel_context *intel)
|
||||
vbl.request.type |= DRM_VBLANK_SECONDARY;
|
||||
}
|
||||
|
||||
for (i = 0; i < intel_fb->pf_num_pages; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!intel_fb->color_rb[i] ||
|
||||
(intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <=
|
||||
(1<<23))
|
||||
@@ -306,7 +217,7 @@ intelWindowMoved(struct intel_context *intel)
|
||||
|
||||
intel_fb->vbl_waited = dPriv->vblSeq;
|
||||
|
||||
for (i = 0; i < intel_fb->pf_num_pages; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (intel_fb->color_rb[i])
|
||||
intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_waited;
|
||||
}
|
||||
@@ -545,176 +456,6 @@ intelClear(GLcontext *ctx, GLbitfield mask)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Emit wait for pending flips */
|
||||
void
|
||||
intel_wait_flips(struct intel_context *intel)
|
||||
{
|
||||
struct intel_framebuffer *intel_fb =
|
||||
(struct intel_framebuffer *) intel->ctx.DrawBuffer;
|
||||
struct intel_renderbuffer *intel_rb =
|
||||
intel_get_renderbuffer(&intel_fb->Base,
|
||||
intel_fb->Base._ColorDrawBufferIndexes[0] ==
|
||||
BUFFER_FRONT_LEFT ? BUFFER_FRONT_LEFT :
|
||||
BUFFER_BACK_LEFT);
|
||||
|
||||
if (intel->intelScreen->driScrnPriv->dri2.enabled)
|
||||
return;
|
||||
|
||||
if (intel_fb->Base.Name == 0 && intel_rb &&
|
||||
intel_rb->pf_pending == intel_fb->pf_seq) {
|
||||
GLint pf_planes = intel_fb->pf_planes;
|
||||
BATCH_LOCALS;
|
||||
|
||||
/* Wait for pending flips to take effect */
|
||||
BEGIN_BATCH(2, NO_LOOP_CLIPRECTS);
|
||||
OUT_BATCH(pf_planes & 0x1 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP)
|
||||
: 0);
|
||||
OUT_BATCH(pf_planes & 0x2 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_B_FLIP)
|
||||
: 0);
|
||||
ADVANCE_BATCH();
|
||||
|
||||
intel_rb->pf_pending--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Flip the front & back buffers
|
||||
*/
|
||||
static GLboolean
|
||||
intelPageFlip(const __DRIdrawablePrivate * dPriv)
|
||||
{
|
||||
struct intel_context *intel;
|
||||
int ret;
|
||||
struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
|
||||
|
||||
if (INTEL_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
assert(dPriv);
|
||||
assert(dPriv->driContextPriv);
|
||||
assert(dPriv->driContextPriv->driverPrivate);
|
||||
|
||||
intel = (struct intel_context *) dPriv->driContextPriv->driverPrivate;
|
||||
|
||||
if (intel->intelScreen->drmMinor < 9)
|
||||
return GL_FALSE;
|
||||
|
||||
intelFlush(&intel->ctx);
|
||||
|
||||
ret = 0;
|
||||
|
||||
LOCK_HARDWARE(intel);
|
||||
|
||||
if (dPriv->numClipRects && intel_fb->pf_active) {
|
||||
drm_i915_flip_t flip;
|
||||
|
||||
flip.pipes = intel_fb->pf_planes;
|
||||
|
||||
ret = drmCommandWrite(intel->driFd, DRM_I915_FLIP, &flip, sizeof(flip));
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE(intel);
|
||||
|
||||
if (ret || !intel_fb->pf_active)
|
||||
return GL_FALSE;
|
||||
|
||||
if (!dPriv->numClipRects) {
|
||||
usleep(10000); /* throttle invisible client 10ms */
|
||||
}
|
||||
|
||||
intel_fb->pf_current_page = (intel->sarea->pf_current_page >>
|
||||
(intel_fb->pf_planes & 0x2)) & 0x3;
|
||||
|
||||
if (dPriv->numClipRects != 0) {
|
||||
intel_get_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT)->pf_pending =
|
||||
intel_get_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT)->pf_pending =
|
||||
++intel_fb->pf_seq;
|
||||
}
|
||||
|
||||
intel_flip_renderbuffers(intel_fb);
|
||||
intel_draw_buffer(&intel->ctx, &intel_fb->Base);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
intelScheduleSwap(__DRIdrawablePrivate * dPriv, GLboolean *missed_target)
|
||||
{
|
||||
struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
|
||||
unsigned int interval;
|
||||
struct intel_context *intel =
|
||||
intelScreenContext(dPriv->driScreenPriv->private);
|
||||
const intelScreenPrivate *intelScreen = intel->intelScreen;
|
||||
unsigned int target;
|
||||
drm_i915_vblank_swap_t swap;
|
||||
GLboolean ret;
|
||||
|
||||
if (!dPriv->vblFlags ||
|
||||
(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ) ||
|
||||
intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6))
|
||||
return GL_FALSE;
|
||||
|
||||
interval = driGetVBlankInterval(dPriv);
|
||||
|
||||
swap.seqtype = DRM_VBLANK_ABSOLUTE;
|
||||
|
||||
if (dPriv->vblFlags & VBLANK_FLAG_SYNC) {
|
||||
swap.seqtype |= DRM_VBLANK_NEXTONMISS;
|
||||
} else if (interval == 0)
|
||||
return GL_FALSE;
|
||||
|
||||
swap.drawable = dPriv->hHWDrawable;
|
||||
target = swap.sequence = dPriv->vblSeq + interval;
|
||||
|
||||
if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
|
||||
swap.seqtype |= DRM_VBLANK_SECONDARY;
|
||||
}
|
||||
|
||||
LOCK_HARDWARE(intel);
|
||||
|
||||
intel_batchbuffer_flush(intel->batch);
|
||||
|
||||
if ( intel_fb->pf_active ) {
|
||||
swap.seqtype |= DRM_VBLANK_FLIP;
|
||||
|
||||
intel_fb->pf_current_page = (((intel->sarea->pf_current_page >>
|
||||
(intel_fb->pf_planes & 0x2)) & 0x3) + 1) %
|
||||
intel_fb->pf_num_pages;
|
||||
}
|
||||
|
||||
if (!drmCommandWriteRead(intel->driFd, DRM_I915_VBLANK_SWAP, &swap,
|
||||
sizeof(swap))) {
|
||||
dPriv->vblSeq = swap.sequence;
|
||||
swap.sequence -= target;
|
||||
*missed_target = swap.sequence > 0 && swap.sequence <= (1 << 23);
|
||||
|
||||
intel_get_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT)->vbl_pending =
|
||||
intel_get_renderbuffer(&intel_fb->Base,
|
||||
BUFFER_FRONT_LEFT)->vbl_pending =
|
||||
dPriv->vblSeq;
|
||||
|
||||
if (swap.seqtype & DRM_VBLANK_FLIP) {
|
||||
intel_flip_renderbuffers(intel_fb);
|
||||
intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
|
||||
}
|
||||
|
||||
ret = GL_TRUE;
|
||||
} else {
|
||||
if (swap.seqtype & DRM_VBLANK_FLIP) {
|
||||
intel_fb->pf_current_page = ((intel->sarea->pf_current_page >>
|
||||
(intel_fb->pf_planes & 0x2)) & 0x3) %
|
||||
intel_fb->pf_num_pages;
|
||||
}
|
||||
|
||||
ret = GL_FALSE;
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE(intel);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
intelSwapBuffers(__DRIdrawablePrivate * dPriv)
|
||||
{
|
||||
@@ -736,22 +477,22 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv)
|
||||
|
||||
_mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */
|
||||
|
||||
if (!intelScheduleSwap(dPriv, &missed_target)) {
|
||||
driWaitForVBlank(dPriv, &missed_target);
|
||||
/*
|
||||
* The old swapping ioctl was incredibly racy, just wait for vblank
|
||||
* and do the swap ourselves.
|
||||
*/
|
||||
driWaitForVBlank(dPriv, &missed_target);
|
||||
|
||||
/*
|
||||
* Update each buffer's vbl_pending so we don't get too out of
|
||||
* sync
|
||||
*/
|
||||
intel_get_renderbuffer(&intel_fb->Base,
|
||||
BUFFER_BACK_LEFT)->vbl_pending =
|
||||
intel_get_renderbuffer(&intel_fb->Base,
|
||||
BUFFER_FRONT_LEFT)->vbl_pending =
|
||||
dPriv->vblSeq;
|
||||
if (!intelPageFlip(dPriv)) {
|
||||
intelCopyBuffer(dPriv, NULL);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Update each buffer's vbl_pending so we don't get too out of
|
||||
* sync
|
||||
*/
|
||||
intel_get_renderbuffer(&intel_fb->Base,
|
||||
BUFFER_BACK_LEFT)->vbl_pending = dPriv->vblSeq;
|
||||
intel_get_renderbuffer(&intel_fb->Base,
|
||||
BUFFER_FRONT_LEFT)->vbl_pending = dPriv->vblSeq;
|
||||
|
||||
intelCopyBuffer(dPriv, NULL);
|
||||
|
||||
intel_fb->swap_count++;
|
||||
(*psp->systemTime->getUST) (&ust);
|
||||
|
@@ -45,8 +45,6 @@ extern struct intel_region *intel_readbuf_region(struct intel_context *intel);
|
||||
|
||||
extern struct intel_region *intel_drawbuf_region(struct intel_context *intel);
|
||||
|
||||
extern void intel_wait_flips(struct intel_context *intel);
|
||||
|
||||
extern void intelSwapBuffers(__DRIdrawablePrivate * dPriv);
|
||||
|
||||
extern void intelWindowMoved(struct intel_context *intel);
|
||||
|
@@ -95,7 +95,7 @@ int INTEL_DEBUG = (0);
|
||||
|
||||
#include "extension_helper.h"
|
||||
|
||||
#define DRIVER_DATE "20080716"
|
||||
#define DRIVER_DATE "20090114"
|
||||
#define DRIVER_DATE_GEM "GEM " DRIVER_DATE
|
||||
|
||||
static const GLubyte *
|
||||
@@ -886,7 +886,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = intel->driDrawable;
|
||||
__DRIscreenPrivate *sPriv = intel->driScreen;
|
||||
volatile struct drm_i915_sarea *sarea = intel->sarea;
|
||||
volatile drm_i915_sarea_t *sarea = intel->sarea;
|
||||
int me = intel->hHWContext;
|
||||
|
||||
drmGetLock(intel->driFd, intel->hHWContext, flags);
|
||||
|
@@ -110,7 +110,10 @@ intel_unpair_depth_stencil(GLcontext *ctx, struct intel_renderbuffer *irb)
|
||||
ASSERT(stencilIrb->PairedDepth == rb->Name);
|
||||
intel_renderbuffer_map(intel, rb);
|
||||
intel_renderbuffer_map(intel, stencilRb);
|
||||
#if 0
|
||||
/* disable for now */
|
||||
_mesa_extract_stencil(ctx, rb, stencilRb);
|
||||
#endif
|
||||
intel_renderbuffer_unmap(intel, stencilRb);
|
||||
intel_renderbuffer_unmap(intel, rb);
|
||||
stencilIrb->PairedDepth = 0;
|
||||
@@ -132,7 +135,10 @@ intel_unpair_depth_stencil(GLcontext *ctx, struct intel_renderbuffer *irb)
|
||||
ASSERT(depthIrb->PairedStencil == rb->Name);
|
||||
intel_renderbuffer_map(intel, rb);
|
||||
intel_renderbuffer_map(intel, depthRb);
|
||||
#if 0
|
||||
/* disable for now */
|
||||
_mesa_extract_stencil(ctx, depthRb, rb);
|
||||
#endif
|
||||
intel_renderbuffer_unmap(intel, depthRb);
|
||||
intel_renderbuffer_unmap(intel, rb);
|
||||
depthIrb->PairedStencil = 0;
|
||||
@@ -177,8 +183,11 @@ intel_validate_paired_depth_stencil(GLcontext * ctx,
|
||||
}
|
||||
else {
|
||||
/* Separate depth/stencil buffers, need to interleave now */
|
||||
ASSERT(depthRb->Base._BaseFormat == GL_DEPTH_COMPONENT);
|
||||
ASSERT(stencilRb->Base._BaseFormat == GL_STENCIL_INDEX);
|
||||
ASSERT(depthRb->Base._BaseFormat == GL_DEPTH_COMPONENT ||
|
||||
depthRb->Base._BaseFormat == GL_DEPTH_STENCIL);
|
||||
ASSERT(stencilRb->Base._BaseFormat == GL_STENCIL_INDEX ||
|
||||
stencilRb->Base._BaseFormat == GL_DEPTH_STENCIL);
|
||||
|
||||
/* may need to interleave depth/stencil now */
|
||||
if (depthRb->PairedStencil == stencilRb->Base.Name) {
|
||||
/* OK, the depth and stencil buffers are already interleaved */
|
||||
|
@@ -77,43 +77,6 @@ intel_get_renderbuffer(struct gl_framebuffer *fb, int attIndex)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
intel_flip_renderbuffers(struct intel_framebuffer *intel_fb)
|
||||
{
|
||||
int current_page = intel_fb->pf_current_page;
|
||||
int next_page = (current_page + 1) % intel_fb->pf_num_pages;
|
||||
struct gl_renderbuffer *tmp_rb;
|
||||
|
||||
/* Exchange renderbuffers if necessary but make sure their reference counts
|
||||
* are preserved.
|
||||
*/
|
||||
if (intel_fb->color_rb[current_page] &&
|
||||
intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer !=
|
||||
&intel_fb->color_rb[current_page]->Base) {
|
||||
tmp_rb = NULL;
|
||||
_mesa_reference_renderbuffer(&tmp_rb,
|
||||
intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
|
||||
tmp_rb = &intel_fb->color_rb[current_page]->Base;
|
||||
_mesa_reference_renderbuffer(
|
||||
&intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer, tmp_rb);
|
||||
_mesa_reference_renderbuffer(&tmp_rb, NULL);
|
||||
}
|
||||
|
||||
if (intel_fb->color_rb[next_page] &&
|
||||
intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer !=
|
||||
&intel_fb->color_rb[next_page]->Base) {
|
||||
tmp_rb = NULL;
|
||||
_mesa_reference_renderbuffer(&tmp_rb,
|
||||
intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
|
||||
tmp_rb = &intel_fb->color_rb[next_page]->Base;
|
||||
_mesa_reference_renderbuffer(
|
||||
&intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer, tmp_rb);
|
||||
_mesa_reference_renderbuffer(&tmp_rb, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct intel_region *
|
||||
intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex)
|
||||
{
|
||||
@@ -248,11 +211,18 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
|
||||
cpp = 4;
|
||||
break;
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
#if 0
|
||||
rb->_ActualFormat = GL_DEPTH_COMPONENT16;
|
||||
rb->DataType = GL_UNSIGNED_SHORT;
|
||||
rb->DepthBits = 16;
|
||||
cpp = 2;
|
||||
break;
|
||||
#else
|
||||
/* fall-through.
|
||||
* 16bpp depth renderbuffer can't be paired with a stencil buffer so
|
||||
* always used combined depth/stencil format.
|
||||
*/
|
||||
#endif
|
||||
case GL_DEPTH_COMPONENT:
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
@@ -344,7 +314,7 @@ intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
|
||||
}
|
||||
|
||||
/* Make sure all window system renderbuffers are up to date */
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
struct gl_renderbuffer *rb = &intel_fb->color_rb[i]->Base;
|
||||
|
||||
/* only resize if size is changing */
|
||||
@@ -529,20 +499,25 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
|
||||
if (texImage->TexFormat == &_mesa_texformat_argb8888) {
|
||||
irb->Base._ActualFormat = GL_RGBA8;
|
||||
irb->Base._BaseFormat = GL_RGBA;
|
||||
irb->Base.DataType = GL_UNSIGNED_BYTE;
|
||||
DBG("Render to RGBA8 texture OK\n");
|
||||
}
|
||||
else if (texImage->TexFormat == &_mesa_texformat_rgb565) {
|
||||
irb->Base._ActualFormat = GL_RGB5;
|
||||
irb->Base._BaseFormat = GL_RGB;
|
||||
irb->Base.DataType = GL_UNSIGNED_SHORT;
|
||||
DBG("Render to RGB5 texture OK\n");
|
||||
}
|
||||
else if (texImage->TexFormat == &_mesa_texformat_z16) {
|
||||
irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
|
||||
irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
|
||||
irb->Base.DataType = GL_UNSIGNED_SHORT;
|
||||
DBG("Render to DEPTH16 texture OK\n");
|
||||
} else if (texImage->TexFormat == &_mesa_texformat_s8_z24) {
|
||||
}
|
||||
else if (texImage->TexFormat == &_mesa_texformat_s8_z24) {
|
||||
irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
|
||||
irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
|
||||
irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
|
||||
DBG("Render to DEPTH_STENCIL texture OK\n");
|
||||
}
|
||||
else {
|
||||
@@ -554,7 +529,6 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
|
||||
irb->Base.InternalFormat = irb->Base._ActualFormat;
|
||||
irb->Base.Width = texImage->Width;
|
||||
irb->Base.Height = texImage->Height;
|
||||
irb->Base.DataType = GL_UNSIGNED_BYTE; /* FBO XXX fix */
|
||||
irb->Base.RedBits = texImage->TexFormat->RedBits;
|
||||
irb->Base.GreenBits = texImage->TexFormat->GreenBits;
|
||||
irb->Base.BlueBits = texImage->TexFormat->BlueBits;
|
||||
|
@@ -39,14 +39,7 @@ struct intel_framebuffer
|
||||
{
|
||||
struct gl_framebuffer Base;
|
||||
|
||||
struct intel_renderbuffer *color_rb[3];
|
||||
|
||||
/* Drawable page flipping state */
|
||||
GLboolean pf_active;
|
||||
GLuint pf_seq;
|
||||
GLint pf_planes;
|
||||
GLint pf_current_page;
|
||||
GLint pf_num_pages;
|
||||
struct intel_renderbuffer *color_rb[2];
|
||||
|
||||
/* VBI
|
||||
*/
|
||||
@@ -76,8 +69,6 @@ struct intel_renderbuffer
|
||||
GLuint PairedDepth; /**< only used if this is a depth renderbuffer */
|
||||
GLuint PairedStencil; /**< only used if this is a stencil renderbuffer */
|
||||
|
||||
GLuint pf_pending; /**< sequence number of pending flip */
|
||||
|
||||
GLuint vbl_pending; /**< vblank sequence number of pending flip */
|
||||
|
||||
uint8_t *span_cache;
|
||||
@@ -111,5 +102,22 @@ extern struct intel_region *intel_get_rb_region(struct gl_framebuffer *fb,
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Are we currently rendering into a texture?
|
||||
*/
|
||||
static INLINE GLboolean
|
||||
intel_rendering_to_texture(const GLcontext *ctx)
|
||||
{
|
||||
if (ctx->DrawBuffer->Name) {
|
||||
/* User-created FBO */
|
||||
const struct intel_renderbuffer *irb =
|
||||
intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
|
||||
return irb && irb->RenderToTexture;
|
||||
}
|
||||
else {
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* INTEL_FBO_H */
|
||||
|
@@ -204,6 +204,14 @@ do_blit_bitmap( GLcontext *ctx,
|
||||
/* Update draw buffer bounds */
|
||||
_mesa_update_state(ctx);
|
||||
|
||||
if (ctx->Depth.Test) {
|
||||
/* The blit path produces incorrect results when depth testing is on.
|
||||
* It seems the blit Z coord is always 1.0 (the far plane) so fragments
|
||||
* will likely be obscured by other, closer geometry.
|
||||
*/
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (!dst)
|
||||
return GL_FALSE;
|
||||
|
||||
@@ -357,6 +365,7 @@ intel_texture_bitmap(GLcontext * ctx,
|
||||
GLubyte *unpacked_bitmap;
|
||||
GLubyte *a8_bitmap;
|
||||
int x, y;
|
||||
GLfloat dst_z;
|
||||
|
||||
/* We need a fragment program for the KIL effect */
|
||||
if (!ctx->Extensions.ARB_fragment_program ||
|
||||
@@ -456,21 +465,24 @@ intel_texture_bitmap(GLcontext * ctx,
|
||||
intel_meta_set_passthrough_vertex_program(intel);
|
||||
intel_meta_set_passthrough_transform(intel);
|
||||
|
||||
/* convert rasterpos Z from [0,1] to NDC coord in [-1,1] */
|
||||
dst_z = -1.0 + 2.0 * ctx->Current.RasterPos[2];
|
||||
|
||||
vertices[0][0] = dst_x;
|
||||
vertices[0][1] = dst_y;
|
||||
vertices[0][2] = ctx->Current.RasterPos[2];
|
||||
vertices[0][2] = dst_z;
|
||||
vertices[0][3] = 1.0;
|
||||
vertices[1][0] = dst_x + width;
|
||||
vertices[1][1] = dst_y;
|
||||
vertices[1][2] = ctx->Current.RasterPos[2];
|
||||
vertices[1][2] = dst_z;
|
||||
vertices[1][3] = 1.0;
|
||||
vertices[2][0] = dst_x + width;
|
||||
vertices[2][1] = dst_y + height;
|
||||
vertices[2][2] = ctx->Current.RasterPos[2];
|
||||
vertices[2][2] = dst_z;
|
||||
vertices[2][3] = 1.0;
|
||||
vertices[3][0] = dst_x;
|
||||
vertices[3][1] = dst_y + height;
|
||||
vertices[3][2] = ctx->Current.RasterPos[2];
|
||||
vertices[3][2] = dst_z;
|
||||
vertices[3][3] = 1.0;
|
||||
|
||||
texcoords[0][0] = 0.0;
|
||||
|
@@ -119,6 +119,12 @@ do_texture_copypixels(GLcontext * ctx,
|
||||
if (!src || !dst || type != GL_COLOR)
|
||||
return GL_FALSE;
|
||||
|
||||
if (ctx->_ImageTransferState) {
|
||||
if (INTEL_DEBUG & DEBUG_PIXEL)
|
||||
fprintf(stderr, "%s: check_color failed\n", __FUNCTION__);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Can't handle overlapping regions. Don't have sufficient control
|
||||
* over rasterization to pull it off in-place. Punt on these for
|
||||
* now.
|
||||
|
@@ -71,6 +71,7 @@ intel_texture_drawpixels(GLcontext * ctx,
|
||||
GLuint texname;
|
||||
GLfloat vertices[4][4];
|
||||
GLfloat texcoords[4][2];
|
||||
GLfloat z;
|
||||
|
||||
/* We're going to mess with texturing with no regard to existing texture
|
||||
* state, so if there is some set up we have to bail.
|
||||
@@ -140,6 +141,9 @@ intel_texture_drawpixels(GLcontext * ctx,
|
||||
|
||||
intel_meta_set_passthrough_transform(intel);
|
||||
|
||||
/* convert rasterpos Z from [0,1] to NDC coord in [-1,1] */
|
||||
z = -1.0 + 2.0 * ctx->Current.RasterPos[2];
|
||||
|
||||
/* Create the vertex buffer based on the current raster pos. The x and y
|
||||
* we're handed are ctx->Current.RasterPos[0,1] rounded to integers.
|
||||
* We also apply the depth. However, the W component is already multiplied
|
||||
@@ -147,19 +151,19 @@ intel_texture_drawpixels(GLcontext * ctx,
|
||||
*/
|
||||
vertices[0][0] = x;
|
||||
vertices[0][1] = y;
|
||||
vertices[0][2] = ctx->Current.RasterPos[2];
|
||||
vertices[0][2] = z;
|
||||
vertices[0][3] = 1.0;
|
||||
vertices[1][0] = x + width * ctx->Pixel.ZoomX;
|
||||
vertices[1][1] = y;
|
||||
vertices[1][2] = ctx->Current.RasterPos[2];
|
||||
vertices[1][2] = z;
|
||||
vertices[1][3] = 1.0;
|
||||
vertices[2][0] = x + width * ctx->Pixel.ZoomX;
|
||||
vertices[2][1] = y + height * ctx->Pixel.ZoomY;
|
||||
vertices[2][2] = ctx->Current.RasterPos[2];
|
||||
vertices[2][2] = z;
|
||||
vertices[2][3] = 1.0;
|
||||
vertices[3][0] = x;
|
||||
vertices[3][1] = y + height * ctx->Pixel.ZoomY;
|
||||
vertices[3][2] = ctx->Current.RasterPos[2];
|
||||
vertices[3][2] = z;
|
||||
vertices[3][3] = 1.0;
|
||||
|
||||
texcoords[0][0] = 0.0;
|
||||
|
@@ -134,7 +134,7 @@ intelPrintDRIInfo(intelScreenPrivate * intelScreen,
|
||||
|
||||
|
||||
static void
|
||||
intelPrintSAREA(const struct drm_i915_sarea * sarea)
|
||||
intelPrintSAREA(const drm_i915_sarea_t * sarea)
|
||||
{
|
||||
fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width,
|
||||
sarea->height);
|
||||
@@ -161,7 +161,7 @@ intelPrintSAREA(const struct drm_i915_sarea * sarea)
|
||||
*/
|
||||
void
|
||||
intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
|
||||
struct drm_i915_sarea * sarea)
|
||||
drm_i915_sarea_t * sarea)
|
||||
{
|
||||
intelScreen->width = sarea->width;
|
||||
intelScreen->height = sarea->height;
|
||||
@@ -244,7 +244,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
|
||||
{
|
||||
intelScreenPrivate *intelScreen;
|
||||
I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
|
||||
struct drm_i915_sarea *sarea;
|
||||
drm_i915_sarea_t *sarea;
|
||||
|
||||
if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
|
||||
fprintf(stderr,
|
||||
@@ -264,7 +264,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
|
||||
|
||||
intelScreen->driScrnPriv = sPriv;
|
||||
sPriv->private = (void *) intelScreen;
|
||||
sarea = (struct drm_i915_sarea *)
|
||||
sarea = (drm_i915_sarea_t *)
|
||||
(((GLubyte *) sPriv->pSAREA) + gDRIPriv->sarea_priv_offset);
|
||||
intelScreen->sarea = sarea;
|
||||
|
||||
|
@@ -68,7 +68,7 @@ typedef struct
|
||||
|
||||
__DRIscreenPrivate *driScrnPriv;
|
||||
|
||||
volatile struct drm_i915_sarea *sarea;
|
||||
volatile drm_i915_sarea_t *sarea;
|
||||
|
||||
int drmMinor;
|
||||
|
||||
@@ -94,7 +94,7 @@ extern void intelUnmapScreenRegions(intelScreenPrivate * intelScreen);
|
||||
|
||||
extern void
|
||||
intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
|
||||
struct drm_i915_sarea * sarea);
|
||||
drm_i915_sarea_t * sarea);
|
||||
|
||||
extern void intelDestroyContext(__DRIcontextPrivate * driContextPriv);
|
||||
|
||||
|
@@ -633,7 +633,7 @@ intelSpanRenderStart(GLcontext * ctx)
|
||||
intelFlush(&intel->ctx);
|
||||
LOCK_HARDWARE(intel);
|
||||
|
||||
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
|
||||
for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
|
||||
if (ctx->Texture.Unit[i]._ReallyEnabled) {
|
||||
struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
|
||||
intel_tex_map_images(intel, intel_texture_object(texObj));
|
||||
@@ -655,7 +655,7 @@ intelSpanRenderFinish(GLcontext * ctx)
|
||||
|
||||
_swrast_flush(ctx);
|
||||
|
||||
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
|
||||
for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
|
||||
if (ctx->Texture.Unit[i]._ReallyEnabled) {
|
||||
struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
|
||||
intel_tex_unmap_images(intel, intel_texture_object(texObj));
|
||||
|
@@ -134,8 +134,14 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
#if 0
|
||||
return &_mesa_texformat_z16;
|
||||
|
||||
#else
|
||||
/* fall-through.
|
||||
* 16bpp depth texture can't be paired with a stencil buffer so
|
||||
* always used combined depth/stencil format.
|
||||
*/
|
||||
#endif
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
return &_mesa_texformat_s8_z24;
|
||||
@@ -158,7 +164,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||
return &_mesa_texformat_srgb_dxt1;
|
||||
return &_mesa_texformat_srgb_dxt1;
|
||||
#endif
|
||||
|
||||
default:
|
||||
|
@@ -294,7 +294,13 @@ extern GLboolean mach64UnbindContext( __DRIcontextPrivate *driContextPriv );
|
||||
#define LE32_OUT( x, y ) do { *(GLuint *)(x) = (y); } while (0)
|
||||
#define LE32_OUT_FLOAT( x, y ) do { *(GLfloat *)(x) = (y); } while (0)
|
||||
#else
|
||||
#ifndef __OpenBSD__
|
||||
#include <byteswap.h>
|
||||
#else
|
||||
#include <machine/endian.h>
|
||||
#define bswap_32 bswap32
|
||||
#endif
|
||||
|
||||
#define LE32_IN( x ) bswap_32( *(GLuint *)(x) )
|
||||
#define LE32_IN_FLOAT( x ) \
|
||||
({ \
|
||||
|
@@ -1675,6 +1675,13 @@ static void r300SetupRSUnit(GLcontext * ctx)
|
||||
rs_col_count += count;
|
||||
}
|
||||
|
||||
if (InputsRead & FRAG_BIT_FOGC) {
|
||||
/* XXX FIX THIS
|
||||
* Just turn off the bit for now.
|
||||
* Need to do something similar to the color/texcoord inputs.
|
||||
*/
|
||||
InputsRead &= ~FRAG_BIT_FOGC;
|
||||
}
|
||||
|
||||
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
|
||||
int swiz;
|
||||
|
@@ -473,6 +473,11 @@ static void allocate_input_registers(struct pair_state *s)
|
||||
alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL1, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_COL1;
|
||||
|
||||
/* Fog coordinate */
|
||||
if (InputsRead & FRAG_BIT_FOGC)
|
||||
alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_FOGC, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_FOGC;
|
||||
|
||||
/* Anything else */
|
||||
if (InputsRead)
|
||||
error("Don't know how to handle inputs 0x%x\n", InputsRead);
|
||||
|
@@ -33,7 +33,7 @@ default: $(PROGRAM)
|
||||
|
||||
|
||||
glslcompiler: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -lm -lpthread -o $@
|
||||
$(CC) $(OBJECTS) $(GL_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
glslcompiler.o: glslcompiler.c
|
||||
|
@@ -867,6 +867,7 @@ EXPORTS
|
||||
_glapi_get_proc_address
|
||||
_mesa_add_soft_renderbuffers
|
||||
_mesa_add_renderbuffer
|
||||
_mesa_begin_query
|
||||
_mesa_buffer_data
|
||||
_mesa_buffer_get_subdata
|
||||
_mesa_buffer_map
|
||||
@@ -881,6 +882,7 @@ EXPORTS
|
||||
_mesa_delete_array_object
|
||||
_mesa_delete_buffer_object
|
||||
_mesa_delete_program
|
||||
_mesa_delete_query
|
||||
_mesa_delete_texture_object
|
||||
_mesa_destroy_framebuffer
|
||||
_mesa_destroy_visual
|
||||
@@ -890,6 +892,7 @@ EXPORTS
|
||||
_mesa_enable_2_0_extensions
|
||||
_mesa_enable_2_1_extensions
|
||||
_mesa_enable_sw_extensions
|
||||
_mesa_end_query
|
||||
_mesa_error
|
||||
_mesa_finish_render_texture
|
||||
_mesa_framebuffer_renderbuffer
|
||||
@@ -941,6 +944,7 @@ EXPORTS
|
||||
_mesa_update_framebuffer_visual
|
||||
_mesa_use_program
|
||||
_mesa_Viewport
|
||||
_mesa_wait_query
|
||||
_swrast_Accum
|
||||
_swrast_Bitmap
|
||||
_swrast_BlitFramebuffer
|
||||
@@ -973,3 +977,4 @@ EXPORTS
|
||||
_tnl_InvalidateState
|
||||
_tnl_run_pipeline
|
||||
_tnl_program_string
|
||||
_tnl_RasterPos
|
@@ -601,8 +601,9 @@ WINGDIAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc,
|
||||
WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,
|
||||
int iLayerPlane)
|
||||
{
|
||||
(void) hdc; (void) iLayerPlane;
|
||||
SetLastError(0);
|
||||
if (iLayerPlane == 0)
|
||||
return wglCreateContext( hdc );
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,292 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GLDirect Direct3D 7.0a header file
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _GLD_DX7_H
|
||||
#define _GLD_DX7_H
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Windows includes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#define DIRECTDRAW_VERSION 0x0700
|
||||
#define DIRECT3D_VERSION 0x0700
|
||||
#include <d3d.h>
|
||||
#include <d3dx.h>
|
||||
|
||||
// Typedef for obtaining function from d3d7.dll
|
||||
//typedef IDirect3D7* (WINAPI *FNDIRECT3DCREATE7) (UINT);
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Defines
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Debug build tests the return value of D3D calls
|
||||
#define _GLD_TEST_HRESULT(h) \
|
||||
{ \
|
||||
HRESULT _hr = (h); \
|
||||
if (FAILED(_hr)) { \
|
||||
gldLogError(GLDLOG_ERROR, #h, _hr); \
|
||||
} \
|
||||
}
|
||||
#define _GLD_DX7(func) _GLD_TEST_HRESULT(IDirect3D7_##func##)
|
||||
#define _GLD_DX7_DEV(func) _GLD_TEST_HRESULT(IDirect3DDevice7_##func##)
|
||||
#define _GLD_DX7_VB(func) _GLD_TEST_HRESULT(IDirect3DVertexBuffer7_##func##)
|
||||
#define _GLD_DX7_TEX(func) _GLD_TEST_HRESULT(IDirectDrawSurface7_##func##)
|
||||
#else
|
||||
#define _GLD_DX7(func) IDirect3D7_##func
|
||||
#define _GLD_DX7_DEV(func) IDirect3DDevice7_##func
|
||||
#define _GLD_DX7_VB(func) IDirect3DVertexBuffer7_##func
|
||||
#define _GLD_DX7_TEX(func) IDirectDrawSurface7_##func
|
||||
#endif
|
||||
|
||||
#define SAFE_RELEASE(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
(p)->lpVtbl->Release(p); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_RELEASE_VB7(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
IDirect3DVertexBuffer7_Release((p)); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_RELEASE_SURFACE7(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
IDirectDrawSurface7_Release((p)); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
// Emulate some DX8 defines
|
||||
#define D3DCOLOR_ARGB(a,r,g,b) ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
|
||||
#define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b)
|
||||
#define D3DCOLOR_COLORVALUE(r,g,b,a) D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f))
|
||||
|
||||
|
||||
// Setup index.
|
||||
enum {
|
||||
GLD_SI_FLAT = 0,
|
||||
GLD_SI_SMOOTH = 1,
|
||||
GLD_SI_FLAT_EXTRAS = 2,
|
||||
GLD_SI_SMOOTH_EXTRAS = 3,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Vertex definitions for Fixed-Function pipeline
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// NOTE: If the number of texture units is altered then most of
|
||||
// the texture code will need to be revised.
|
||||
//
|
||||
|
||||
#define GLD_MAX_TEXTURE_UNITS_DX7 2
|
||||
|
||||
//
|
||||
// 2D vertex transformed by Mesa
|
||||
//
|
||||
#define GLD_FVF_2D_VERTEX ( D3DFVF_XYZRHW | \
|
||||
D3DFVF_DIFFUSE | \
|
||||
D3DFVF_SPECULAR | \
|
||||
D3DFVF_TEX2)
|
||||
typedef struct {
|
||||
FLOAT x, y; // 2D raster coords
|
||||
FLOAT sz; // Screen Z (depth)
|
||||
FLOAT rhw; // Reciprocal homogenous W
|
||||
DWORD diffuse; // Diffuse colour
|
||||
DWORD specular; // For separate-specular support
|
||||
FLOAT t0_u, t0_v; // 1st set of texture coords
|
||||
FLOAT t1_u, t1_v; // 2nd set of texture coords
|
||||
} GLD_2D_VERTEX;
|
||||
|
||||
|
||||
//
|
||||
// 3D vertex transformed by Direct3D
|
||||
//
|
||||
#define GLD_FVF_3D_VERTEX ( D3DFVF_XYZ | \
|
||||
D3DFVF_DIFFUSE | \
|
||||
D3DFVF_TEX2)
|
||||
|
||||
typedef struct {
|
||||
D3DXVECTOR3 Position; // XYZ Vector in object space
|
||||
D3DCOLOR Diffuse; // Diffuse colour
|
||||
D3DXVECTOR2 TexUnit0; // Texture unit 0
|
||||
D3DXVECTOR2 TexUnit1; // Texture unit 1
|
||||
} GLD_3D_VERTEX;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Structs
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// This keeps a count of how many times we choose each individual internal
|
||||
// pathway. Useful for seeing if a certain pathway was ever used by an app, and
|
||||
// how much each pathway is biased.
|
||||
// Zero the members at context creation and dump stats at context deletion.
|
||||
typedef struct {
|
||||
// Note: DWORD is probably too small
|
||||
ULARGE_INTEGER qwMesa; // Mesa TnL pipeline
|
||||
ULARGE_INTEGER qwD3DFVF; // Direct3D Fixed-Function pipeline
|
||||
} GLD_pipeline_usage;
|
||||
|
||||
// GLDirect Primitive Buffer (points, lines, triangles and quads)
|
||||
typedef struct {
|
||||
// Data for IDirect3D7::CreateVertexBuffer()
|
||||
DWORD dwStride; // Stride of vertex
|
||||
DWORD dwCreateFlags; // Create flags
|
||||
DWORD dwFVF; // Direct3D Flexible Vertex Format
|
||||
|
||||
IDirect3DVertexBuffer7 *pVB; // Holds points, lines, tris and quads.
|
||||
|
||||
// Point list is assumed to be at start of buffer
|
||||
DWORD iFirstLine; // Index of start of line list
|
||||
DWORD iFirstTriangle; // Index of start of triangle list
|
||||
|
||||
BYTE *pPoints; // Pointer to next free point
|
||||
BYTE *pLines; // Pointer to next free line
|
||||
BYTE *pTriangles; // Pointer to next free triangle
|
||||
|
||||
DWORD nPoints; // Number of points ready to render
|
||||
DWORD nLines; // Number of lines ready to render
|
||||
DWORD nTriangles; // Number of triangles ready to render
|
||||
} GLD_pb_dx7;
|
||||
|
||||
// GLDirect DX7 driver data
|
||||
typedef struct {
|
||||
// GLDirect vars
|
||||
BOOL bDoublebuffer; // Doublebuffer (otherwise single-buffered)
|
||||
BOOL bDepthStencil; // Depth buffer needed (stencil optional)
|
||||
D3DX_SURFACEFORMAT RenderFormat; // Format of back/front buffer
|
||||
D3DX_SURFACEFORMAT DepthFormat; // Format of depth/stencil
|
||||
|
||||
// Direct3D vars
|
||||
DDCAPS ddCaps;
|
||||
D3DDEVICEDESC7 d3dCaps;
|
||||
BOOL bHasHWTnL; // Device has Hardware Transform/Light?
|
||||
ID3DXContext *pD3DXContext; // Base D3DX context
|
||||
IDirectDraw7 *pDD; // DirectDraw7 interface
|
||||
IDirect3D7 *pD3D; // Base Direct3D7 interface
|
||||
IDirect3DDevice7 *pDev; // Direct3D7 Device interface
|
||||
GLD_pb_dx7 PB2d; // Vertices transformed by Mesa
|
||||
GLD_pb_dx7 PB3d; // Vertices transformed by Direct3D
|
||||
D3DPRIMITIVETYPE d3dpt; // Current Direct3D primitive type
|
||||
D3DMATRIX matProjection; // Projection matrix for D3D TnL
|
||||
D3DMATRIX matModelView; // Model/View matrix for D3D TnL
|
||||
int iSetupFunc; // Which setup functions to use
|
||||
BOOL bUseMesaTnL; // Whether to use Mesa or D3D for TnL
|
||||
|
||||
GLD_pipeline_usage PipelineUsage;
|
||||
} GLD_driver_dx7;
|
||||
|
||||
#define GLD_GET_DX7_DRIVER(c) (GLD_driver_dx7*)(c)->glPriv
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
PROC gldGetProcAddress_DX7(LPCSTR a);
|
||||
void gldEnableExtensions_DX7(GLcontext *ctx);
|
||||
void gldInstallPipeline_DX7(GLcontext *ctx);
|
||||
void gldSetupDriverPointers_DX7(GLcontext *ctx);
|
||||
void gldResizeBuffers_DX7(GLframebuffer *fb);
|
||||
|
||||
|
||||
// Texture functions
|
||||
|
||||
void gldCopyTexImage1D_DX7(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);
|
||||
void gldCopyTexImage2D_DX7(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
|
||||
void gldCopyTexSubImage1D_DX7(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width );
|
||||
void gldCopyTexSubImage2D_DX7(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
void gldCopyTexSubImage3D_DX7(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
|
||||
void gld_NEW_TEXTURE_DX7(GLcontext *ctx);
|
||||
void gld_DrawPixels_DX7(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels);
|
||||
void gld_ReadPixels_DX7(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, GLvoid *dest);
|
||||
void gld_CopyPixels_DX7(GLcontext *ctx, GLint srcx, GLint srcy, GLsizei width, GLsizei height, GLint dstx, GLint dsty, GLenum type);
|
||||
void gld_Bitmap_DX7(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap);
|
||||
const struct gl_texture_format* gld_ChooseTextureFormat_DX7(GLcontext *ctx, GLint internalFormat, GLenum srcFormat, GLenum srcType);
|
||||
void gld_TexImage2D_DX7(GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *tObj, struct gl_texture_image *texImage);
|
||||
void gld_TexImage1D_DX7(GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage );
|
||||
void gld_TexSubImage2D_DX7( GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage );
|
||||
void gld_TexSubImage1D_DX7(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage);
|
||||
void gld_DeleteTexture_DX7(GLcontext *ctx, struct gl_texture_object *tObj);
|
||||
void gld_ResetLineStipple_DX7(GLcontext *ctx);
|
||||
|
||||
// 2D primitive functions
|
||||
|
||||
void gld_Points2D_DX7(GLcontext *ctx, GLuint first, GLuint last);
|
||||
|
||||
void gld_Line2DFlat_DX7(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Line2DSmooth_DX7(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
|
||||
void gld_Triangle2DFlat_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmooth_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DFlatExtras_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmoothExtras_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
|
||||
void gld_Quad2DFlat_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmooth_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DFlatExtras_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmoothExtras_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
// 3D primitive functions
|
||||
|
||||
void gld_Points3D_DX7(GLcontext *ctx, GLuint first, GLuint last);
|
||||
void gld_Line3DFlat_DX7(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle3DFlat_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad3DFlat_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Line3DSmooth_DX7(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle3DSmooth_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad3DSmooth_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
// Primitive functions for Two-sided-lighting Vertex Shader
|
||||
|
||||
void gld_Points2DTwoside_DX7(GLcontext *ctx, GLuint first, GLuint last);
|
||||
void gld_Line2DFlatTwoside_DX7(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Line2DSmoothTwoside_DX7(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle2DFlatTwoside_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmoothTwoside_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad2DFlatTwoside_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmoothTwoside_DX7(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
#endif
|
@@ -1,77 +0,0 @@
|
||||
/*==========================================================================;
|
||||
*
|
||||
*
|
||||
* File: dxerr8.h
|
||||
* Content: DirectX Error Library Include File
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _GLD_DXERR7_H_
|
||||
#define _GLD_DXERR7_H_
|
||||
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
//
|
||||
// DXGetErrorString8
|
||||
//
|
||||
// Desc: Converts an DirectX HRESULT to a string
|
||||
//
|
||||
// Args: HRESULT hr Can be any error code from
|
||||
// DPLAY D3D8 D3DX8 DMUSIC DSOUND
|
||||
//
|
||||
// Return: Converted string
|
||||
//
|
||||
const char* __stdcall DXGetErrorString8A(HRESULT hr);
|
||||
const WCHAR* __stdcall DXGetErrorString8W(HRESULT hr);
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DXGetErrorString8 DXGetErrorString8W
|
||||
#else
|
||||
#define DXGetErrorString8 DXGetErrorString8A
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// DXTrace
|
||||
//
|
||||
// Desc: Outputs a formatted error message to the debug stream
|
||||
//
|
||||
// Args: CHAR* strFile The current file, typically passed in using the
|
||||
// __FILE__ macro.
|
||||
// DWORD dwLine The current line number, typically passed in using the
|
||||
// __LINE__ macro.
|
||||
// HRESULT hr An HRESULT that will be traced to the debug stream.
|
||||
// CHAR* strMsg A string that will be traced to the debug stream (may be NULL)
|
||||
// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info.
|
||||
//
|
||||
// Return: The hr that was passed in.
|
||||
//
|
||||
//HRESULT __stdcall DXTraceA( char* strFile, DWORD dwLine, HRESULT hr, char* strMsg, BOOL bPopMsgBox = FALSE );
|
||||
//HRESULT __stdcall DXTraceW( char* strFile, DWORD dwLine, HRESULT hr, WCHAR* strMsg, BOOL bPopMsgBox = FALSE );
|
||||
HRESULT __stdcall DXTraceA( char* strFile, DWORD dwLine, HRESULT hr, char* strMsg, BOOL bPopMsgBox);
|
||||
HRESULT __stdcall DXTraceW( char* strFile, DWORD dwLine, HRESULT hr, WCHAR* strMsg, BOOL bPopMsgBox);
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DXTrace DXTraceW
|
||||
#else
|
||||
#define DXTrace DXTraceA
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Helper macros
|
||||
//
|
||||
#if defined(DEBUG) | defined(_DEBUG)
|
||||
#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE )
|
||||
#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE )
|
||||
#define DXTRACE_ERR_NOMSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE )
|
||||
#else
|
||||
#define DXTRACE_MSG(str) (0L)
|
||||
#define DXTRACE_ERR(str,hr) (hr)
|
||||
#define DXTRACE_ERR_NOMSGBOX(str,hr) (hr)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -1,346 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GL extensions
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
//#include "../gld_log.h"
|
||||
//#include "../gld_settings.h"
|
||||
|
||||
#include <windows.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
//#include "ddlog.h"
|
||||
//#include "gld_dx8.h"
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "colormac.h"
|
||||
#include "depth.h"
|
||||
#include "extensions.h"
|
||||
#include "macros.h"
|
||||
#include "matrix.h"
|
||||
// #include "mem.h"
|
||||
//#include "mmath.h"
|
||||
#include "mtypes.h"
|
||||
#include "texformat.h"
|
||||
#include "texstore.h"
|
||||
#include "vbo/vbo.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "swrast_setup/ss_context.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "extensions.h"
|
||||
|
||||
// For some reason this is not defined in an above header...
|
||||
extern void _mesa_enable_imaging_extensions(GLcontext *ctx);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Hack for the SGIS_multitexture extension that was removed from Mesa
|
||||
// NOTE: SGIS_multitexture enums also clash with GL_SGIX_async_pixel
|
||||
|
||||
// NOTE: Quake2 ran *slower* with this enabled, so I've
|
||||
// disabled it for now.
|
||||
// To enable, uncomment:
|
||||
// _mesa_add_extension(ctx, GL_TRUE, szGL_SGIS_multitexture, 0);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
/* Quake2 GL_SGIS_multitexture */
|
||||
GL_SELECTED_TEXTURE_SGIS = 0x835B,
|
||||
GL_SELECTED_TEXTURE_COORD_SET_SGIS = 0x835C,
|
||||
GL_MAX_TEXTURES_SGIS = 0x835D,
|
||||
GL_TEXTURE0_SGIS = 0x835E,
|
||||
GL_TEXTURE1_SGIS = 0x835F,
|
||||
GL_TEXTURE2_SGIS = 0x8360,
|
||||
GL_TEXTURE3_SGIS = 0x8361,
|
||||
GL_TEXTURE_COORD_SET_SOURCE_SGIS = 0x8363,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldSelectTextureSGIS(
|
||||
GLenum target)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glActiveTextureARB(ARB_target);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldMTexCoord2fSGIS(
|
||||
GLenum target,
|
||||
GLfloat s,
|
||||
GLfloat t)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glMultiTexCoord2fARB(ARB_target, s, t);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldMTexCoord2fvSGIS(
|
||||
GLenum target,
|
||||
const GLfloat *v)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glMultiTexCoord2fvARB(ARB_target, v);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Extensions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
PROC proc;
|
||||
char *name;
|
||||
} GLD_extension;
|
||||
|
||||
GLD_extension GLD_extList[] = {
|
||||
#ifdef GL_EXT_polygon_offset
|
||||
{ (PROC)glPolygonOffsetEXT, "glPolygonOffsetEXT" },
|
||||
#endif
|
||||
{ (PROC)glBlendEquationEXT, "glBlendEquationEXT" },
|
||||
{ (PROC)glBlendColorEXT, "glBlendColorExt" },
|
||||
{ (PROC)glVertexPointerEXT, "glVertexPointerEXT" },
|
||||
{ (PROC)glNormalPointerEXT, "glNormalPointerEXT" },
|
||||
{ (PROC)glColorPointerEXT, "glColorPointerEXT" },
|
||||
{ (PROC)glIndexPointerEXT, "glIndexPointerEXT" },
|
||||
{ (PROC)glTexCoordPointerEXT, "glTexCoordPointer" },
|
||||
{ (PROC)glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT" },
|
||||
{ (PROC)glGetPointervEXT, "glGetPointervEXT" },
|
||||
{ (PROC)glArrayElementEXT, "glArrayElementEXT" },
|
||||
{ (PROC)glDrawArraysEXT, "glDrawArrayEXT" },
|
||||
{ (PROC)glAreTexturesResidentEXT, "glAreTexturesResidentEXT" },
|
||||
{ (PROC)glBindTextureEXT, "glBindTextureEXT" },
|
||||
{ (PROC)glDeleteTexturesEXT, "glDeleteTexturesEXT" },
|
||||
{ (PROC)glGenTexturesEXT, "glGenTexturesEXT" },
|
||||
{ (PROC)glIsTextureEXT, "glIsTextureEXT" },
|
||||
{ (PROC)glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT" },
|
||||
{ (PROC)glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT" },
|
||||
{ (PROC)glTexImage3DEXT, "glTexImage3DEXT" },
|
||||
{ (PROC)glTexSubImage3DEXT, "glTexSubImage3DEXT" },
|
||||
{ (PROC)glPointParameterfEXT, "glPointParameterfEXT" },
|
||||
{ (PROC)glPointParameterfvEXT, "glPointParameterfvEXT" },
|
||||
|
||||
{ (PROC)glLockArraysEXT, "glLockArraysEXT" },
|
||||
{ (PROC)glUnlockArraysEXT, "glUnlockArraysEXT" },
|
||||
{ NULL, "\0" }
|
||||
};
|
||||
|
||||
GLD_extension GLD_multitexList[] = {
|
||||
/*
|
||||
{ (PROC)glMultiTexCoord1dSGIS, "glMTexCoord1dSGIS" },
|
||||
{ (PROC)glMultiTexCoord1dvSGIS, "glMTexCoord1dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord1fSGIS, "glMTexCoord1fSGIS" },
|
||||
{ (PROC)glMultiTexCoord1fvSGIS, "glMTexCoord1fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord1iSGIS, "glMTexCoord1iSGIS" },
|
||||
{ (PROC)glMultiTexCoord1ivSGIS, "glMTexCoord1ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord1sSGIS, "glMTexCoord1sSGIS" },
|
||||
{ (PROC)glMultiTexCoord1svSGIS, "glMTexCoord1svSGIS" },
|
||||
{ (PROC)glMultiTexCoord2dSGIS, "glMTexCoord2dSGIS" },
|
||||
{ (PROC)glMultiTexCoord2dvSGIS, "glMTexCoord2dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord2fSGIS, "glMTexCoord2fSGIS" },
|
||||
{ (PROC)glMultiTexCoord2fvSGIS, "glMTexCoord2fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord2iSGIS, "glMTexCoord2iSGIS" },
|
||||
{ (PROC)glMultiTexCoord2ivSGIS, "glMTexCoord2ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord2sSGIS, "glMTexCoord2sSGIS" },
|
||||
{ (PROC)glMultiTexCoord2svSGIS, "glMTexCoord2svSGIS" },
|
||||
{ (PROC)glMultiTexCoord3dSGIS, "glMTexCoord3dSGIS" },
|
||||
{ (PROC)glMultiTexCoord3dvSGIS, "glMTexCoord3dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord3fSGIS, "glMTexCoord3fSGIS" },
|
||||
{ (PROC)glMultiTexCoord3fvSGIS, "glMTexCoord3fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord3iSGIS, "glMTexCoord3iSGIS" },
|
||||
{ (PROC)glMultiTexCoord3ivSGIS, "glMTexCoord3ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord3sSGIS, "glMTexCoord3sSGIS" },
|
||||
{ (PROC)glMultiTexCoord3svSGIS, "glMTexCoord3svSGIS" },
|
||||
{ (PROC)glMultiTexCoord4dSGIS, "glMTexCoord4dSGIS" },
|
||||
{ (PROC)glMultiTexCoord4dvSGIS, "glMTexCoord4dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord4fSGIS, "glMTexCoord4fSGIS" },
|
||||
{ (PROC)glMultiTexCoord4fvSGIS, "glMTexCoord4fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord4iSGIS, "glMTexCoord4iSGIS" },
|
||||
{ (PROC)glMultiTexCoord4ivSGIS, "glMTexCoord4ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord4sSGIS, "glMTexCoord4sSGIS" },
|
||||
{ (PROC)glMultiTexCoord4svSGIS, "glMTexCoord4svSGIS" },
|
||||
{ (PROC)glMultiTexCoordPointerSGIS, "glMTexCoordPointerSGIS" },
|
||||
{ (PROC)glSelectTextureSGIS, "glSelectTextureSGIS" },
|
||||
{ (PROC)glSelectTextureCoordSetSGIS, "glSelectTextureCoordSetSGIS" },
|
||||
*/
|
||||
{ (PROC)glActiveTextureARB, "glActiveTextureARB" },
|
||||
{ (PROC)glClientActiveTextureARB, "glClientActiveTextureARB" },
|
||||
{ (PROC)glMultiTexCoord1dARB, "glMultiTexCoord1dARB" },
|
||||
{ (PROC)glMultiTexCoord1dvARB, "glMultiTexCoord1dvARB" },
|
||||
{ (PROC)glMultiTexCoord1fARB, "glMultiTexCoord1fARB" },
|
||||
{ (PROC)glMultiTexCoord1fvARB, "glMultiTexCoord1fvARB" },
|
||||
{ (PROC)glMultiTexCoord1iARB, "glMultiTexCoord1iARB" },
|
||||
{ (PROC)glMultiTexCoord1ivARB, "glMultiTexCoord1ivARB" },
|
||||
{ (PROC)glMultiTexCoord1sARB, "glMultiTexCoord1sARB" },
|
||||
{ (PROC)glMultiTexCoord1svARB, "glMultiTexCoord1svARB" },
|
||||
{ (PROC)glMultiTexCoord2dARB, "glMultiTexCoord2dARB" },
|
||||
{ (PROC)glMultiTexCoord2dvARB, "glMultiTexCoord2dvARB" },
|
||||
{ (PROC)glMultiTexCoord2fARB, "glMultiTexCoord2fARB" },
|
||||
{ (PROC)glMultiTexCoord2fvARB, "glMultiTexCoord2fvARB" },
|
||||
{ (PROC)glMultiTexCoord2iARB, "glMultiTexCoord2iARB" },
|
||||
{ (PROC)glMultiTexCoord2ivARB, "glMultiTexCoord2ivARB" },
|
||||
{ (PROC)glMultiTexCoord2sARB, "glMultiTexCoord2sARB" },
|
||||
{ (PROC)glMultiTexCoord2svARB, "glMultiTexCoord2svARB" },
|
||||
{ (PROC)glMultiTexCoord3dARB, "glMultiTexCoord3dARB" },
|
||||
{ (PROC)glMultiTexCoord3dvARB, "glMultiTexCoord3dvARB" },
|
||||
{ (PROC)glMultiTexCoord3fARB, "glMultiTexCoord3fARB" },
|
||||
{ (PROC)glMultiTexCoord3fvARB, "glMultiTexCoord3fvARB" },
|
||||
{ (PROC)glMultiTexCoord3iARB, "glMultiTexCoord3iARB" },
|
||||
{ (PROC)glMultiTexCoord3ivARB, "glMultiTexCoord3ivARB" },
|
||||
{ (PROC)glMultiTexCoord3sARB, "glMultiTexCoord3sARB" },
|
||||
{ (PROC)glMultiTexCoord3svARB, "glMultiTexCoord3svARB" },
|
||||
{ (PROC)glMultiTexCoord4dARB, "glMultiTexCoord4dARB" },
|
||||
{ (PROC)glMultiTexCoord4dvARB, "glMultiTexCoord4dvARB" },
|
||||
{ (PROC)glMultiTexCoord4fARB, "glMultiTexCoord4fARB" },
|
||||
{ (PROC)glMultiTexCoord4fvARB, "glMultiTexCoord4fvARB" },
|
||||
{ (PROC)glMultiTexCoord4iARB, "glMultiTexCoord4iARB" },
|
||||
{ (PROC)glMultiTexCoord4ivARB, "glMultiTexCoord4ivARB" },
|
||||
{ (PROC)glMultiTexCoord4sARB, "glMultiTexCoord4sARB" },
|
||||
{ (PROC)glMultiTexCoord4svARB, "glMultiTexCoord4svARB" },
|
||||
|
||||
// Descent3 doesn't use correct string, hence this hack
|
||||
{ (PROC)glMultiTexCoord4fARB, "glMultiTexCoord4f" },
|
||||
|
||||
// Quake2 SGIS multitexture
|
||||
{ (PROC)gldSelectTextureSGIS, "glSelectTextureSGIS" },
|
||||
{ (PROC)gldMTexCoord2fSGIS, "glMTexCoord2fSGIS" },
|
||||
{ (PROC)gldMTexCoord2fvSGIS, "glMTexCoord2fvSGIS" },
|
||||
|
||||
{ NULL, "\0" }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
PROC gldGetProcAddress_DX(
|
||||
LPCSTR a)
|
||||
{
|
||||
int i;
|
||||
PROC proc = NULL;
|
||||
|
||||
for (i=0; GLD_extList[i].proc; i++) {
|
||||
if (!strcmp(a, GLD_extList[i].name)) {
|
||||
proc = GLD_extList[i].proc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (glb.bMultitexture) {
|
||||
for (i=0; GLD_multitexList[i].proc; i++) {
|
||||
if (!strcmp(a, GLD_multitexList[i].name)) {
|
||||
proc = GLD_multitexList[i].proc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gldLogPrintf(GLDLOG_INFO, "GetProcAddress: %s (%s)", a, proc ? "OK" : "Failed");
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void gldEnableExtensions_DX7(
|
||||
GLcontext *ctx)
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
// Mesa enables some extensions by default.
|
||||
// This table decides which ones we want to switch off again.
|
||||
|
||||
// NOTE: GL_EXT_compiled_vertex_array appears broken.
|
||||
|
||||
const char *gld_disable_extensions[] = {
|
||||
// "GL_ARB_transpose_matrix",
|
||||
// "GL_EXT_compiled_vertex_array",
|
||||
// "GL_EXT_polygon_offset",
|
||||
// "GL_EXT_rescale_normal",
|
||||
"GL_EXT_texture3D",
|
||||
// "GL_NV_texgen_reflection",
|
||||
"GL_EXT_abgr",
|
||||
"GL_EXT_bgra",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *gld_multitex_extensions[] = {
|
||||
"GL_ARB_multitexture", // Quake 3
|
||||
NULL
|
||||
};
|
||||
|
||||
// Quake 2 engines
|
||||
const char *szGL_SGIS_multitexture = "GL_SGIS_multitexture";
|
||||
|
||||
const char *gld_enable_extensions[] = {
|
||||
"GL_EXT_texture_env_add", // Quake 3
|
||||
"GL_ARB_texture_env_add", // Quake 3
|
||||
NULL
|
||||
};
|
||||
|
||||
for (i=0; gld_disable_extensions[i]; i++) {
|
||||
_mesa_disable_extension(ctx, gld_disable_extensions[i]);
|
||||
}
|
||||
|
||||
for (i=0; gld_enable_extensions[i]; i++) {
|
||||
_mesa_enable_extension(ctx, gld_enable_extensions[i]);
|
||||
}
|
||||
|
||||
if (glb.bMultitexture) {
|
||||
for (i=0; gld_multitex_extensions[i]; i++) {
|
||||
_mesa_enable_extension(ctx, gld_multitex_extensions[i]);
|
||||
}
|
||||
|
||||
// GL_SGIS_multitexture
|
||||
// NOTE: Quake2 ran *slower* with this enabled, so I've
|
||||
// disabled it for now.
|
||||
// Fair bit slower on GeForce256,
|
||||
// Much slower on 3dfx Voodoo5 5500.
|
||||
// _mesa_add_extension(ctx, GL_TRUE, szGL_SGIS_multitexture, 0);
|
||||
|
||||
}
|
||||
|
||||
_mesa_enable_imaging_extensions(ctx);
|
||||
_mesa_enable_1_3_extensions(ctx);
|
||||
_mesa_enable_1_4_extensions(ctx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: Mesa transformation pipeline with GLDirect fastpath
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx7.h"
|
||||
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
extern struct tnl_pipeline_stage _gld_d3d_render_stage;
|
||||
extern struct tnl_pipeline_stage _gld_mesa_render_stage;
|
||||
|
||||
static const struct tnl_pipeline_stage *gld_pipeline[] = {
|
||||
&_gld_d3d_render_stage, // Direct3D TnL
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
&_tnl_fog_coordinate_stage, /* TODO: Omit fog stage. ??? */
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
&_tnl_point_attenuation_stage,
|
||||
&_gld_mesa_render_stage, // Mesa TnL, D3D rendering
|
||||
0,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void gldInstallPipeline_DX7(
|
||||
GLcontext *ctx)
|
||||
{
|
||||
// Remove any existing pipeline stages,
|
||||
// then install GLDirect pipeline stages.
|
||||
|
||||
_tnl_destroy_pipeline(ctx);
|
||||
_tnl_install_pipeline(ctx, gld_pipeline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,257 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GLDirect fastpath pipeline stage
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
//#include "../gld_log.h"
|
||||
//#include "gld_dx8.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx7.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
// #include "mem.h"
|
||||
#include "mtypes.h"
|
||||
//#include "mmath.h"
|
||||
|
||||
#include "math/m_matrix.h"
|
||||
#include "math/m_xform.h"
|
||||
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/*
|
||||
__inline void _gldSetVertexShaderConstants(
|
||||
GLcontext *ctx,
|
||||
GLD_driver_dx8 *gld)
|
||||
{
|
||||
D3DXMATRIX mat, matView, matProj;
|
||||
GLfloat *pM;
|
||||
|
||||
// Mesa 5: Altered to a Stack
|
||||
//pM = ctx->ModelView.m;
|
||||
pM = ctx->ModelviewMatrixStack.Top->m;
|
||||
matView._11 = pM[0];
|
||||
matView._12 = pM[1];
|
||||
matView._13 = pM[2];
|
||||
matView._14 = pM[3];
|
||||
matView._21 = pM[4];
|
||||
matView._22 = pM[5];
|
||||
matView._23 = pM[6];
|
||||
matView._24 = pM[7];
|
||||
matView._31 = pM[8];
|
||||
matView._32 = pM[9];
|
||||
matView._33 = pM[10];
|
||||
matView._34 = pM[11];
|
||||
matView._41 = pM[12];
|
||||
matView._42 = pM[13];
|
||||
matView._43 = pM[14];
|
||||
matView._44 = pM[15];
|
||||
|
||||
// Mesa 5: Altered to a Stack
|
||||
//pM = ctx->ProjectionMatrix.m;
|
||||
pM = ctx->ProjectionMatrixStack.Top->m;
|
||||
matProj._11 = pM[0];
|
||||
matProj._12 = pM[1];
|
||||
matProj._13 = pM[2];
|
||||
matProj._14 = pM[3];
|
||||
matProj._21 = pM[4];
|
||||
matProj._22 = pM[5];
|
||||
matProj._23 = pM[6];
|
||||
matProj._24 = pM[7];
|
||||
matProj._31 = pM[8];
|
||||
matProj._32 = pM[9];
|
||||
matProj._33 = pM[10];
|
||||
matProj._34 = pM[11];
|
||||
matProj._41 = pM[12];
|
||||
matProj._42 = pM[13];
|
||||
matProj._43 = pM[14];
|
||||
matProj._44 = pM[15];
|
||||
|
||||
D3DXMatrixMultiply( &mat, &matView, &matProj );
|
||||
D3DXMatrixTranspose( &mat, &mat );
|
||||
|
||||
_GLD_DX8_DEV(SetVertexShaderConstant(gld->pDev, 0, &mat, 4));
|
||||
}
|
||||
*/
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static GLboolean gld_d3d_render_stage_run(
|
||||
GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
|
||||
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
|
||||
|
||||
TNLcontext *tnl;
|
||||
struct vertex_buffer *VB;
|
||||
tnl_render_func *tab;
|
||||
GLint pass;
|
||||
GLD_pb_dx7 *gldPB = &gld->PB3d;
|
||||
DWORD dwFlags;
|
||||
|
||||
/*
|
||||
static int count = 0;
|
||||
count++;
|
||||
if (count != 2)
|
||||
return GL_FALSE;
|
||||
*/
|
||||
// The "check" function should disable this stage,
|
||||
// but we'll test gld->bUseMesaTnL anyway.
|
||||
if (gld->bUseMesaTnL) {
|
||||
// Do nothing in this stage, but continue pipeline
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
tnl = TNL_CONTEXT(ctx);
|
||||
VB = &tnl->vb;
|
||||
pass = 0;
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
#if 0
|
||||
// For debugging: Useful to see if an app passes colour data in
|
||||
// an unusual format.
|
||||
switch (VB->ColorPtr[0]->Type) {
|
||||
case GL_FLOAT:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_FLOAT\n");
|
||||
break;
|
||||
case GL_UNSIGNED_BYTE:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_UNSIGNED_BYTE\n");
|
||||
break;
|
||||
default:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: *?*\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
tnl->Driver.Render.Points = gld_Points3D_DX7;
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
tnl->Driver.Render.Line = gld_Line3DFlat_DX7;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle3DFlat_DX7;
|
||||
tnl->Driver.Render.Quad = gld_Quad3DFlat_DX7;
|
||||
} else {
|
||||
tnl->Driver.Render.Line = gld_Line3DSmooth_DX7;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle3DSmooth_DX7;
|
||||
tnl->Driver.Render.Quad = gld_Quad3DSmooth_DX7;
|
||||
}
|
||||
|
||||
// _GLD_DX7_VB(Lock(gldPB->pVB, 0, 0, &gldPB->pPoints, D3DLOCK_DISCARD));
|
||||
dwFlags = DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY;
|
||||
_GLD_DX7_VB(Lock(gldPB->pVB, dwFlags, &gldPB->pPoints, NULL));
|
||||
gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0;
|
||||
// Allocate primitive pointers
|
||||
// gldPB->pPoints is always first
|
||||
gldPB->pLines = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine);
|
||||
gldPB->pTriangles = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle);
|
||||
|
||||
ASSERT(tnl->Driver.Render.BuildVertices);
|
||||
ASSERT(tnl->Driver.Render.PrimitiveNotify);
|
||||
ASSERT(tnl->Driver.Render.Points);
|
||||
ASSERT(tnl->Driver.Render.Line);
|
||||
ASSERT(tnl->Driver.Render.Triangle);
|
||||
ASSERT(tnl->Driver.Render.Quad);
|
||||
ASSERT(tnl->Driver.Render.ResetLineStipple);
|
||||
ASSERT(tnl->Driver.Render.Interp);
|
||||
ASSERT(tnl->Driver.Render.CopyPV);
|
||||
ASSERT(tnl->Driver.Render.ClippedLine);
|
||||
ASSERT(tnl->Driver.Render.ClippedPolygon);
|
||||
ASSERT(tnl->Driver.Render.Finish);
|
||||
|
||||
tab = (VB->Elts ? tnl->Driver.Render.PrimTabElts : tnl->Driver.Render.PrimTabVerts);
|
||||
|
||||
do {
|
||||
GLuint i, length, flags = 0;
|
||||
for (i = 0 ; !(flags & PRIM_END) ; i += length)
|
||||
{
|
||||
flags = VB->Primitive[i].mode;
|
||||
length= VB->Primitive[i].count;
|
||||
ASSERT(length || (flags & PRIM_END));
|
||||
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
|
||||
if (length)
|
||||
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
|
||||
}
|
||||
} while (tnl->Driver.Render.Multipass &&
|
||||
tnl->Driver.Render.Multipass( ctx, ++pass ));
|
||||
|
||||
_GLD_DX7_VB(Unlock(gldPB->pVB));
|
||||
|
||||
// _GLD_DX7_DEV(SetStreamSource(gld->pDev, 0, gldPB->pVB, gldPB->dwStride));
|
||||
|
||||
_GLD_DX7_DEV(SetTransform(gld->pDev, D3DTRANSFORMSTATE_PROJECTION, &gld->matProjection));
|
||||
_GLD_DX7_DEV(SetTransform(gld->pDev, D3DTRANSFORMSTATE_WORLD, &gld->matModelView));
|
||||
|
||||
if (gldPB->nPoints) {
|
||||
// _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_POINTLIST, 0, gldPB->nPoints));
|
||||
_GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_POINTLIST, gldPB->pVB, 0, gldPB->nPoints, 0));
|
||||
gldPB->nPoints = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nLines) {
|
||||
// _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_LINELIST, gldPB->iFirstLine, gldPB->nLines));
|
||||
_GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_LINELIST, gldPB->pVB, gldPB->iFirstLine, gldPB->nLines, 0));
|
||||
gldPB->nLines = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nTriangles) {
|
||||
// _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_TRIANGLELIST, gldPB->iFirstTriangle, gldPB->nTriangles));
|
||||
_GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_TRIANGLELIST, gldPB->pVB, gldPB->iFirstTriangle, gldPB->nTriangles, 0));
|
||||
gldPB->nTriangles = 0;
|
||||
}
|
||||
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const struct tnl_pipeline_stage _gld_d3d_render_stage =
|
||||
{
|
||||
"gld_d3d_render_stage",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
gld_d3d_render_stage_run /* run */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
@@ -1,422 +0,0 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL 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:
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Render whole vertex buffers, including projection of vertices from
|
||||
* clip space and clipping of primitives.
|
||||
*
|
||||
* This file makes calls to project vertices and to the point, line
|
||||
* and triangle rasterizers via the function pointers:
|
||||
*
|
||||
* context->Driver.Render.*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
//#include "../gld_log.h"
|
||||
//#include "gld_dx8.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx7.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
// #include "mem.h"
|
||||
#include "mtypes.h"
|
||||
//#include "mmath.h"
|
||||
|
||||
#include "math/m_matrix.h"
|
||||
#include "math/m_xform.h"
|
||||
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip single primitives */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#if defined(USE_IEEE)
|
||||
#define NEGATIVE(x) (GET_FLOAT_BITS(x) & (1<<31))
|
||||
//#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
|
||||
#else
|
||||
#define NEGATIVE(x) (x < 0)
|
||||
//#define DIFFERENT_SIGNS(x,y) (x * y <= 0 && x - y != 0)
|
||||
/* Could just use (x*y<0) except for the flatshading requirements.
|
||||
* Maybe there's a better way?
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#define W(i) coord[i][3]
|
||||
#define Z(i) coord[i][2]
|
||||
#define Y(i) coord[i][1]
|
||||
#define X(i) coord[i][0]
|
||||
#define SIZE 4
|
||||
#define TAG(x) x##_4
|
||||
#include "tnl/t_vb_cliptmp.h"
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip and render whole begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
|
||||
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
|
||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
||||
|
||||
|
||||
/* Vertices, with the possibility of clipping.
|
||||
*/
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
tnl->Driver.Render.Points( ctx, start, count )
|
||||
|
||||
#define RENDER_LINE( v1, v2 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2]; \
|
||||
GLubyte ormask = c1|c2; \
|
||||
if (!ormask) \
|
||||
LineFunc( ctx, v1, v2 ); \
|
||||
else if (!(c1 & c2 & 0x3f)) \
|
||||
clip_line_4( ctx, v1, v2, ormask ); \
|
||||
} while (0)
|
||||
|
||||
#define RENDER_TRI( v1, v2, v3 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2], c3 = mask[v3]; \
|
||||
GLubyte ormask = c1|c2|c3; \
|
||||
if (!ormask) \
|
||||
TriangleFunc( ctx, v1, v2, v3 ); \
|
||||
else if (!(c1 & c2 & c3 & 0x3f)) \
|
||||
clip_tri_4( ctx, v1, v2, v3, ormask ); \
|
||||
} while (0)
|
||||
|
||||
#define RENDER_QUAD( v1, v2, v3, v4 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2]; \
|
||||
GLubyte c3 = mask[v3], c4 = mask[v4]; \
|
||||
GLubyte ormask = c1|c2|c3|c4; \
|
||||
if (!ormask) \
|
||||
QuadFunc( ctx, v1, v2, v3, v4 ); \
|
||||
else if (!(c1 & c2 & c3 & c4 & 0x3f)) \
|
||||
clip_quad_4( ctx, v1, v2, v3, v4, ormask ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LOCAL_VARS \
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx); \
|
||||
struct vertex_buffer *VB = &tnl->vb; \
|
||||
const GLuint * const elt = VB->Elts; \
|
||||
const GLubyte *mask = VB->ClipMask; \
|
||||
const GLuint sz = VB->ClipPtr->size; \
|
||||
const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
|
||||
const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
|
||||
const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
|
||||
const GLboolean stipple = ctx->Line.StippleFlag; \
|
||||
(void) (LineFunc && TriangleFunc && QuadFunc); \
|
||||
(void) elt; (void) mask; (void) sz; (void) stipple;
|
||||
|
||||
#define TAG(x) clip_##x##_verts
|
||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
||||
#define PRESERVE_VB_DEFS
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
|
||||
/* Elts, with the possibility of clipping.
|
||||
*/
|
||||
#undef ELT
|
||||
#undef TAG
|
||||
#define ELT(x) elt[x]
|
||||
#define TAG(x) clip_##x##_elts
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
/* TODO: do this for all primitives, verts and elts:
|
||||
*/
|
||||
static void clip_elt_triangles( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl_render_func render_tris = tnl->Driver.Render.PrimTabElts[GL_TRIANGLES];
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
const GLuint * const elt = VB->Elts;
|
||||
GLubyte *mask = VB->ClipMask;
|
||||
GLuint last = count-2;
|
||||
GLuint j;
|
||||
(void) flags;
|
||||
|
||||
tnl->Driver.Render.PrimitiveNotify( ctx, GL_TRIANGLES );
|
||||
|
||||
for (j=start; j < last; j+=3 ) {
|
||||
GLubyte c1 = mask[elt[j]];
|
||||
GLubyte c2 = mask[elt[j+1]];
|
||||
GLubyte c3 = mask[elt[j+2]];
|
||||
GLubyte ormask = c1|c2|c3;
|
||||
if (ormask) {
|
||||
if (start < j)
|
||||
render_tris( ctx, start, j, 0 );
|
||||
if (!(c1&c2&c3&0x3f))
|
||||
clip_tri_4( ctx, elt[j], elt[j+1], elt[j+2], ormask );
|
||||
start = j+3;
|
||||
}
|
||||
}
|
||||
|
||||
if (start < j)
|
||||
render_tris( ctx, start, j, 0 );
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render whole begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
|
||||
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
|
||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
||||
|
||||
|
||||
/* Vertices, no clipping.
|
||||
*/
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
tnl->Driver.Render.Points( ctx, start, count )
|
||||
|
||||
#define RENDER_LINE( v1, v2 ) \
|
||||
LineFunc( ctx, v1, v2 )
|
||||
|
||||
#define RENDER_TRI( v1, v2, v3 ) \
|
||||
TriangleFunc( ctx, v1, v2, v3 )
|
||||
|
||||
#define RENDER_QUAD( v1, v2, v3, v4 ) \
|
||||
QuadFunc( ctx, v1, v2, v3, v4 )
|
||||
|
||||
#define TAG(x) _gld_tnl_##x##_verts
|
||||
|
||||
#define LOCAL_VARS \
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx); \
|
||||
struct vertex_buffer *VB = &tnl->vb; \
|
||||
const GLuint * const elt = VB->Elts; \
|
||||
const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
|
||||
const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
|
||||
const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
|
||||
(void) (LineFunc && TriangleFunc && QuadFunc); \
|
||||
(void) elt;
|
||||
|
||||
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||
#define RENDER_TAB_QUALIFIER
|
||||
#define PRESERVE_VB_DEFS
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
/* Elts, no clipping.
|
||||
*/
|
||||
#undef ELT
|
||||
#define TAG(x) _gld_tnl_##x##_elts
|
||||
#define ELT(x) elt[x]
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Helper functions for drivers */
|
||||
/**********************************************************************/
|
||||
/*
|
||||
void _tnl_RenderClippedPolygon( GLcontext *ctx, const GLuint *elts, GLuint n )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint *tmp = VB->Elts;
|
||||
|
||||
VB->Elts = (GLuint *)elts;
|
||||
tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
|
||||
VB->Elts = tmp;
|
||||
}
|
||||
|
||||
void _tnl_RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.Line( ctx, ii, jj );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip and render whole vertex buffers */
|
||||
/**********************************************************************/
|
||||
|
||||
tnl_points_func _gldSetupPoints[4] = {
|
||||
gld_Points2D_DX7,
|
||||
gld_Points2D_DX7,
|
||||
gld_Points2D_DX7,
|
||||
gld_Points2D_DX7
|
||||
};
|
||||
tnl_line_func _gldSetupLine[4] = {
|
||||
gld_Line2DFlat_DX7,
|
||||
gld_Line2DSmooth_DX7,
|
||||
gld_Line2DFlat_DX7,
|
||||
gld_Line2DSmooth_DX7,
|
||||
};
|
||||
tnl_triangle_func _gldSetupTriangle[4] = {
|
||||
gld_Triangle2DFlat_DX7,
|
||||
gld_Triangle2DSmooth_DX7,
|
||||
gld_Triangle2DFlatExtras_DX7,
|
||||
gld_Triangle2DSmoothExtras_DX7
|
||||
};
|
||||
tnl_quad_func _gldSetupQuad[4] = {
|
||||
gld_Quad2DFlat_DX7,
|
||||
gld_Quad2DSmooth_DX7,
|
||||
gld_Quad2DFlatExtras_DX7,
|
||||
gld_Quad2DSmoothExtras_DX7
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static GLboolean _gld_mesa_render_stage_run(
|
||||
GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
|
||||
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
|
||||
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
tnl_render_func *tab;
|
||||
GLint pass = 0;
|
||||
GLD_pb_dx7 *gldPB;
|
||||
DWORD dwFlags;
|
||||
|
||||
/* Allow the drivers to lock before projected verts are built so
|
||||
* that window coordinates are guarenteed not to change before
|
||||
* rendering.
|
||||
*/
|
||||
ASSERT(tnl->Driver.Render.Start);
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
gldPB = &gld->PB2d;
|
||||
tnl->Driver.Render.Points = _gldSetupPoints[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Line = _gldSetupLine[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Triangle = _gldSetupTriangle[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Quad = _gldSetupQuad[gld->iSetupFunc];
|
||||
|
||||
dwFlags = DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY;
|
||||
_GLD_DX7_VB(Lock(gldPB->pVB, dwFlags, &gldPB->pPoints, NULL));
|
||||
gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0;
|
||||
|
||||
// Allocate primitive pointers - gldPB->pPoints is always first
|
||||
gldPB->pLines = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine);
|
||||
gldPB->pTriangles = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle);
|
||||
|
||||
ASSERT(tnl->Driver.Render.BuildVertices);
|
||||
ASSERT(tnl->Driver.Render.PrimitiveNotify);
|
||||
ASSERT(tnl->Driver.Render.Points);
|
||||
ASSERT(tnl->Driver.Render.Line);
|
||||
ASSERT(tnl->Driver.Render.Triangle);
|
||||
ASSERT(tnl->Driver.Render.Quad);
|
||||
ASSERT(tnl->Driver.Render.ResetLineStipple);
|
||||
ASSERT(tnl->Driver.Render.Interp);
|
||||
ASSERT(tnl->Driver.Render.CopyPV);
|
||||
ASSERT(tnl->Driver.Render.ClippedLine);
|
||||
ASSERT(tnl->Driver.Render.ClippedPolygon);
|
||||
ASSERT(tnl->Driver.Render.Finish);
|
||||
|
||||
tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 );
|
||||
|
||||
if (VB->ClipOrMask) {
|
||||
tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts;
|
||||
clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles;
|
||||
}
|
||||
else {
|
||||
tab = (VB->Elts ?
|
||||
tnl->Driver.Render.PrimTabElts :
|
||||
tnl->Driver.Render.PrimTabVerts);
|
||||
}
|
||||
|
||||
do {
|
||||
GLuint i, length, flags = 0;
|
||||
for (i = 0 ; !(flags & PRIM_END) ; i += length) {
|
||||
flags = VB->Primitive[i].mode;
|
||||
length= VB->Primitive[i].count;
|
||||
ASSERT(length || (flags & PRIM_END));
|
||||
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
|
||||
if (length)
|
||||
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
|
||||
}
|
||||
} while (tnl->Driver.Render.Multipass &&
|
||||
tnl->Driver.Render.Multipass( ctx, ++pass ));
|
||||
|
||||
|
||||
// tnl->Driver.Render.Finish( ctx );
|
||||
|
||||
_GLD_DX7_VB(Unlock(gldPB->pVB));
|
||||
|
||||
if (gldPB->nPoints) {
|
||||
_GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_POINTLIST, gldPB->pVB, 0, gldPB->nPoints, 0));
|
||||
gldPB->nPoints = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nLines) {
|
||||
_GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_LINELIST, gldPB->pVB, gldPB->iFirstLine, gldPB->nLines*2, 0));
|
||||
gldPB->nLines = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nTriangles) {
|
||||
_GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_TRIANGLELIST, gldPB->pVB, gldPB->iFirstTriangle, gldPB->nTriangles*3, 0));
|
||||
gldPB->nTriangles = 0;
|
||||
}
|
||||
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render pipeline stage */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
|
||||
const struct tnl_pipeline_stage _gld_mesa_render_stage =
|
||||
{
|
||||
"gld_mesa_render_stage",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
_gld_mesa_render_stage_run /* run */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,324 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GLDirect Direct3D 8.0 header file
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _GLD_DX8_H
|
||||
#define _GLD_DX8_H
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Windows includes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//#ifndef STRICT
|
||||
//#define STRICT
|
||||
//#endif
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
//#include <windows.h>
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
// MS screwed up with the DX8.1 SDK - there's no compile-time
|
||||
// method of compiling for 8.0 via the 8.1 SDK unless you
|
||||
// "make sure you don't use any 8.1 interfaces".
|
||||
// We CAN use 8.1 D3DX static functions, though - just not new 8.1 interfaces.
|
||||
//
|
||||
// D3D_SDK_VERSION is 120 for 8.0 (supported by Windows 95).
|
||||
// D3D_SDK_VERSION is 220 for 8.1 (NOT supported by Windows 95).
|
||||
//
|
||||
#define D3D_SDK_VERSION_DX8_SUPPORT_WIN95 120
|
||||
|
||||
// Typedef for obtaining function from d3d8.dll
|
||||
typedef IDirect3D8* (WINAPI *FNDIRECT3DCREATE8) (UINT);
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Defines
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _GLD_TEST_HRESULT(h) \
|
||||
{ \
|
||||
HRESULT _hr = (h); \
|
||||
if (FAILED(_hr)) { \
|
||||
gldLogError(GLDLOG_ERROR, #h, _hr); \
|
||||
} \
|
||||
}
|
||||
#define _GLD_DX8(func) _GLD_TEST_HRESULT(IDirect3D8_##func##)
|
||||
#define _GLD_DX8_DEV(func) _GLD_TEST_HRESULT(IDirect3DDevice8_##func##)
|
||||
#define _GLD_DX8_VB(func) _GLD_TEST_HRESULT(IDirect3DVertexBuffer8_##func##)
|
||||
#define _GLD_DX8_TEX(func) _GLD_TEST_HRESULT(IDirect3DTexture8_##func##)
|
||||
#else
|
||||
#define _GLD_DX8(func) IDirect3D8_##func
|
||||
#define _GLD_DX8_DEV(func) IDirect3DDevice8_##func
|
||||
#define _GLD_DX8_VB(func) IDirect3DVertexBuffer8_##func
|
||||
#define _GLD_DX8_TEX(func) IDirect3DTexture8_##func
|
||||
#endif
|
||||
|
||||
#define SAFE_RELEASE(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
(p)->lpVtbl->Release(p); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_RELEASE_VB8(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
IDirect3DVertexBuffer8_Release((p)); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_RELEASE_SURFACE8(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
IDirect3DSurface8_Release((p)); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
// Setup index.
|
||||
enum {
|
||||
GLD_SI_FLAT = 0,
|
||||
GLD_SI_SMOOTH = 1,
|
||||
GLD_SI_FLAT_EXTRAS = 2,
|
||||
GLD_SI_SMOOTH_EXTRAS = 3,
|
||||
};
|
||||
/*
|
||||
// Internal pipeline
|
||||
typedef enum {
|
||||
GLD_PIPELINE_MESA = 0, // Mesa pipeline
|
||||
GLD_PIPELINE_D3D_FVF = 1, // Direct3D Fixed-function pipeline
|
||||
GLD_PIPELINE_D3D_VS_TWOSIDE = 2 // Direct3D two-sided-lighting vertex shader
|
||||
} GLD_tnl_pipeline;
|
||||
*/
|
||||
//---------------------------------------------------------------------------
|
||||
// Vertex definitions for Fixed-Function pipeline
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// NOTE: If the number of texture units is altered then most of
|
||||
// the texture code will need to be revised.
|
||||
//
|
||||
|
||||
#define GLD_MAX_TEXTURE_UNITS_DX8 2
|
||||
|
||||
//
|
||||
// 2D vertex transformed by Mesa
|
||||
//
|
||||
#define GLD_FVF_2D_VERTEX ( D3DFVF_XYZRHW | \
|
||||
D3DFVF_DIFFUSE | \
|
||||
D3DFVF_SPECULAR | \
|
||||
D3DFVF_TEX2)
|
||||
typedef struct {
|
||||
FLOAT x, y; // 2D raster coords
|
||||
FLOAT sz; // Screen Z (depth)
|
||||
FLOAT rhw; // Reciprocal homogenous W
|
||||
DWORD diffuse; // Diffuse colour
|
||||
DWORD specular; // For separate-specular support
|
||||
FLOAT t0_u, t0_v; // 1st set of texture coords
|
||||
FLOAT t1_u, t1_v; // 2nd set of texture coords
|
||||
} GLD_2D_VERTEX;
|
||||
|
||||
|
||||
//
|
||||
// 3D vertex transformed by Direct3D
|
||||
//
|
||||
#define GLD_FVF_3D_VERTEX ( D3DFVF_XYZ | \
|
||||
D3DFVF_DIFFUSE | \
|
||||
D3DFVF_TEX2)
|
||||
|
||||
typedef struct {
|
||||
D3DXVECTOR3 Position; // XYZ Vector in object space
|
||||
D3DCOLOR Diffuse; // Diffuse colour
|
||||
D3DXVECTOR2 TexUnit0; // Texture unit 0
|
||||
D3DXVECTOR2 TexUnit1; // Texture unit 1
|
||||
} GLD_3D_VERTEX;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Vertex Shaders
|
||||
//---------------------------------------------------------------------------
|
||||
/*
|
||||
// DX8 Vertex Shader
|
||||
typedef struct {
|
||||
DWORD hShader; // If NULL, shader is invalid and cannot be used
|
||||
BOOL bHardware; // If TRUE then shader was created for hardware,
|
||||
// otherwise shader was created for software.
|
||||
} GLD_vertexShader;
|
||||
*/
|
||||
//---------------------------------------------------------------------------
|
||||
// Structs
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// This keeps a count of how many times we choose each individual internal
|
||||
// pathway. Useful for seeing if a certain pathway was ever used by an app, and
|
||||
// how much each pathway is biased.
|
||||
// Zero the members at context creation and dump stats at context deletion.
|
||||
typedef struct {
|
||||
// Note: DWORD is probably too small
|
||||
ULARGE_INTEGER qwMesa; // Mesa TnL pipeline
|
||||
ULARGE_INTEGER qwD3DFVF; // Direct3D Fixed-Function pipeline
|
||||
// ULARGE_INTEGER dwD3D2SVS; // Direct3D Two-Sided Vertex Shader pipeline
|
||||
} GLD_pipeline_usage;
|
||||
|
||||
// GLDirect Primitive Buffer (points, lines, triangles and quads)
|
||||
typedef struct {
|
||||
// Data for IDirect3DDevice8::CreateVertexBuffer()
|
||||
DWORD dwStride; // Stride of vertex
|
||||
DWORD dwUsage; // Usage flags
|
||||
DWORD dwFVF; // Direct3D Flexible Vertex Format
|
||||
DWORD dwPool; // Pool flags
|
||||
|
||||
IDirect3DVertexBuffer8 *pVB; // Holds points, lines, tris and quads.
|
||||
|
||||
// Point list is assumed to be at start of buffer
|
||||
DWORD iFirstLine; // Index of start of line list
|
||||
DWORD iFirstTriangle; // Index of start of triangle list
|
||||
|
||||
BYTE *pPoints; // Pointer to next free point
|
||||
BYTE *pLines; // Pointer to next free line
|
||||
BYTE *pTriangles; // Pointer to next free triangle
|
||||
|
||||
DWORD nPoints; // Number of points ready to render
|
||||
DWORD nLines; // Number of lines ready to render
|
||||
DWORD nTriangles; // Number of triangles ready to render
|
||||
} GLD_pb_dx8;
|
||||
|
||||
// GLDirect DX8 driver data
|
||||
typedef struct {
|
||||
// GLDirect vars
|
||||
BOOL bDoublebuffer; // Doublebuffer (otherwise single-buffered)
|
||||
BOOL bDepthStencil; // Depth buffer needed (stencil optional)
|
||||
D3DFORMAT RenderFormat; // Format of back/front buffer
|
||||
D3DFORMAT DepthFormat; // Format of depth/stencil
|
||||
// float fFlipWindowY; // Value for flipping viewport Y coord
|
||||
|
||||
// Direct3D vars
|
||||
D3DCAPS8 d3dCaps8;
|
||||
BOOL bHasHWTnL; // Device has Hardware Transform/Light?
|
||||
IDirect3D8 *pD3D; // Base Direct3D8 interface
|
||||
IDirect3DDevice8 *pDev; // Direct3D8 Device interface
|
||||
GLD_pb_dx8 PB2d; // Vertices transformed by Mesa
|
||||
GLD_pb_dx8 PB3d; // Vertices transformed by Direct3D
|
||||
D3DPRIMITIVETYPE d3dpt; // Current Direct3D primitive type
|
||||
D3DXMATRIX matProjection; // Projection matrix for D3D TnL
|
||||
D3DXMATRIX matModelView; // Model/View matrix for D3D TnL
|
||||
int iSetupFunc; // Which setup functions to use
|
||||
BOOL bUseMesaTnL; // Whether to use Mesa or D3D for TnL
|
||||
|
||||
// Direct3D vars for two-sided lighting
|
||||
// GLD_vertexShader VStwosidelight; // Vertex Shader for two-sided lighting
|
||||
// D3DXMATRIX matWorldViewProj;// World/View/Projection matrix for shaders
|
||||
|
||||
|
||||
// GLD_tnl_pipeline TnLPipeline; // Index of current internal pipeline
|
||||
GLD_pipeline_usage PipelineUsage;
|
||||
} GLD_driver_dx8;
|
||||
|
||||
#define GLD_GET_DX8_DRIVER(c) (GLD_driver_dx8*)(c)->glPriv
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
PROC gldGetProcAddress_DX8(LPCSTR a);
|
||||
void gldEnableExtensions_DX8(GLcontext *ctx);
|
||||
void gldInstallPipeline_DX8(GLcontext *ctx);
|
||||
void gldSetupDriverPointers_DX8(GLcontext *ctx);
|
||||
//void gldResizeBuffers_DX8(GLcontext *ctx);
|
||||
void gldResizeBuffers_DX8(GLframebuffer *fb);
|
||||
|
||||
|
||||
// Texture functions
|
||||
|
||||
void gldCopyTexImage1D_DX8(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);
|
||||
void gldCopyTexImage2D_DX8(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
|
||||
void gldCopyTexSubImage1D_DX8(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width );
|
||||
void gldCopyTexSubImage2D_DX8(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
void gldCopyTexSubImage3D_DX8(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
|
||||
void gld_NEW_TEXTURE_DX8(GLcontext *ctx);
|
||||
void gld_DrawPixels_DX8(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels);
|
||||
void gld_ReadPixels_DX8(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, GLvoid *dest);
|
||||
void gld_CopyPixels_DX8(GLcontext *ctx, GLint srcx, GLint srcy, GLsizei width, GLsizei height, GLint dstx, GLint dsty, GLenum type);
|
||||
void gld_Bitmap_DX8(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap);
|
||||
const struct gl_texture_format* gld_ChooseTextureFormat_DX8(GLcontext *ctx, GLint internalFormat, GLenum srcFormat, GLenum srcType);
|
||||
void gld_TexImage2D_DX8(GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *tObj, struct gl_texture_image *texImage);
|
||||
void gld_TexImage1D_DX8(GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage );
|
||||
void gld_TexSubImage2D_DX8( GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage );
|
||||
void gld_TexSubImage1D_DX8(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage);
|
||||
void gld_DeleteTexture_DX8(GLcontext *ctx, struct gl_texture_object *tObj);
|
||||
void gld_ResetLineStipple_DX8(GLcontext *ctx);
|
||||
|
||||
// 2D primitive functions
|
||||
|
||||
void gld_Points2D_DX8(GLcontext *ctx, GLuint first, GLuint last);
|
||||
|
||||
void gld_Line2DFlat_DX8(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Line2DSmooth_DX8(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
|
||||
void gld_Triangle2DFlat_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmooth_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DFlatExtras_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmoothExtras_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
|
||||
void gld_Quad2DFlat_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmooth_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DFlatExtras_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmoothExtras_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
// 3D primitive functions
|
||||
|
||||
void gld_Points3D_DX8(GLcontext *ctx, GLuint first, GLuint last);
|
||||
void gld_Line3DFlat_DX8(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle3DFlat_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad3DFlat_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Line3DSmooth_DX8(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle3DSmooth_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad3DSmooth_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
// Primitive functions for Two-sided-lighting Vertex Shader
|
||||
|
||||
void gld_Points2DTwoside_DX8(GLcontext *ctx, GLuint first, GLuint last);
|
||||
void gld_Line2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Line2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
#endif
|
@@ -1,77 +0,0 @@
|
||||
/*==========================================================================;
|
||||
*
|
||||
*
|
||||
* File: dxerr8.h
|
||||
* Content: DirectX Error Library Include File
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _GLD_DXERR8_H_
|
||||
#define _GLD_DXERR8_H_
|
||||
|
||||
|
||||
#include <d3d8.h>
|
||||
|
||||
//
|
||||
// DXGetErrorString8
|
||||
//
|
||||
// Desc: Converts an DirectX HRESULT to a string
|
||||
//
|
||||
// Args: HRESULT hr Can be any error code from
|
||||
// DPLAY D3D8 D3DX8 DMUSIC DSOUND
|
||||
//
|
||||
// Return: Converted string
|
||||
//
|
||||
const char* __stdcall DXGetErrorString8A(HRESULT hr);
|
||||
const WCHAR* __stdcall DXGetErrorString8W(HRESULT hr);
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DXGetErrorString8 DXGetErrorString8W
|
||||
#else
|
||||
#define DXGetErrorString8 DXGetErrorString8A
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// DXTrace
|
||||
//
|
||||
// Desc: Outputs a formatted error message to the debug stream
|
||||
//
|
||||
// Args: CHAR* strFile The current file, typically passed in using the
|
||||
// __FILE__ macro.
|
||||
// DWORD dwLine The current line number, typically passed in using the
|
||||
// __LINE__ macro.
|
||||
// HRESULT hr An HRESULT that will be traced to the debug stream.
|
||||
// CHAR* strMsg A string that will be traced to the debug stream (may be NULL)
|
||||
// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info.
|
||||
//
|
||||
// Return: The hr that was passed in.
|
||||
//
|
||||
//HRESULT __stdcall DXTraceA( char* strFile, DWORD dwLine, HRESULT hr, char* strMsg, BOOL bPopMsgBox = FALSE );
|
||||
//HRESULT __stdcall DXTraceW( char* strFile, DWORD dwLine, HRESULT hr, WCHAR* strMsg, BOOL bPopMsgBox = FALSE );
|
||||
HRESULT __stdcall DXTraceA( char* strFile, DWORD dwLine, HRESULT hr, char* strMsg, BOOL bPopMsgBox);
|
||||
HRESULT __stdcall DXTraceW( char* strFile, DWORD dwLine, HRESULT hr, WCHAR* strMsg, BOOL bPopMsgBox);
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DXTrace DXTraceW
|
||||
#else
|
||||
#define DXTrace DXTraceA
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Helper macros
|
||||
//
|
||||
#if defined(DEBUG) | defined(_DEBUG)
|
||||
#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE )
|
||||
#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE )
|
||||
#define DXTRACE_ERR_NOMSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE )
|
||||
#else
|
||||
#define DXTRACE_MSG(str) (0L)
|
||||
#define DXTRACE_ERR(str,hr) (hr)
|
||||
#define DXTRACE_ERR_NOMSGBOX(str,hr) (hr)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -1,344 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GL extensions
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
//#include "../gld_log.h"
|
||||
//#include "../gld_settings.h"
|
||||
|
||||
#include <windows.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
//#include "ddlog.h"
|
||||
//#include "gld_dx8.h"
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "colormac.h"
|
||||
#include "depth.h"
|
||||
#include "extensions.h"
|
||||
#include "macros.h"
|
||||
#include "matrix.h"
|
||||
// #include "mem.h"
|
||||
//#include "mmath.h"
|
||||
#include "mtypes.h"
|
||||
#include "texformat.h"
|
||||
#include "texstore.h"
|
||||
#include "vbo/vbo.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "swrast_setup/ss_context.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "extensions.h"
|
||||
|
||||
// For some reason this is not defined in an above header...
|
||||
extern void _mesa_enable_imaging_extensions(GLcontext *ctx);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Hack for the SGIS_multitexture extension that was removed from Mesa
|
||||
// NOTE: SGIS_multitexture enums also clash with GL_SGIX_async_pixel
|
||||
|
||||
// NOTE: Quake2 ran *slower* with this enabled, so I've
|
||||
// disabled it for now.
|
||||
// To enable, uncomment:
|
||||
// _mesa_add_extension(ctx, GL_TRUE, szGL_SGIS_multitexture, 0);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
/* Quake2 GL_SGIS_multitexture */
|
||||
GL_SELECTED_TEXTURE_SGIS = 0x835B,
|
||||
GL_SELECTED_TEXTURE_COORD_SET_SGIS = 0x835C,
|
||||
GL_MAX_TEXTURES_SGIS = 0x835D,
|
||||
GL_TEXTURE0_SGIS = 0x835E,
|
||||
GL_TEXTURE1_SGIS = 0x835F,
|
||||
GL_TEXTURE2_SGIS = 0x8360,
|
||||
GL_TEXTURE3_SGIS = 0x8361,
|
||||
GL_TEXTURE_COORD_SET_SOURCE_SGIS = 0x8363,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldSelectTextureSGIS(
|
||||
GLenum target)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glActiveTextureARB(ARB_target);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldMTexCoord2fSGIS(
|
||||
GLenum target,
|
||||
GLfloat s,
|
||||
GLfloat t)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glMultiTexCoord2fARB(ARB_target, s, t);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldMTexCoord2fvSGIS(
|
||||
GLenum target,
|
||||
const GLfloat *v)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glMultiTexCoord2fvARB(ARB_target, v);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Extensions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
PROC proc;
|
||||
char *name;
|
||||
} GLD_extension;
|
||||
|
||||
GLD_extension GLD_extList[] = {
|
||||
#ifdef GL_EXT_polygon_offset
|
||||
{ (PROC)glPolygonOffsetEXT, "glPolygonOffsetEXT" },
|
||||
#endif
|
||||
{ (PROC)glBlendEquationEXT, "glBlendEquationEXT" },
|
||||
{ (PROC)glBlendColorEXT, "glBlendColorExt" },
|
||||
{ (PROC)glVertexPointerEXT, "glVertexPointerEXT" },
|
||||
{ (PROC)glNormalPointerEXT, "glNormalPointerEXT" },
|
||||
{ (PROC)glColorPointerEXT, "glColorPointerEXT" },
|
||||
{ (PROC)glIndexPointerEXT, "glIndexPointerEXT" },
|
||||
{ (PROC)glTexCoordPointerEXT, "glTexCoordPointer" },
|
||||
{ (PROC)glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT" },
|
||||
{ (PROC)glGetPointervEXT, "glGetPointervEXT" },
|
||||
{ (PROC)glArrayElementEXT, "glArrayElementEXT" },
|
||||
{ (PROC)glDrawArraysEXT, "glDrawArrayEXT" },
|
||||
{ (PROC)glAreTexturesResidentEXT, "glAreTexturesResidentEXT" },
|
||||
{ (PROC)glBindTextureEXT, "glBindTextureEXT" },
|
||||
{ (PROC)glDeleteTexturesEXT, "glDeleteTexturesEXT" },
|
||||
{ (PROC)glGenTexturesEXT, "glGenTexturesEXT" },
|
||||
{ (PROC)glIsTextureEXT, "glIsTextureEXT" },
|
||||
{ (PROC)glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT" },
|
||||
{ (PROC)glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT" },
|
||||
{ (PROC)glTexImage3DEXT, "glTexImage3DEXT" },
|
||||
{ (PROC)glTexSubImage3DEXT, "glTexSubImage3DEXT" },
|
||||
{ (PROC)glPointParameterfEXT, "glPointParameterfEXT" },
|
||||
{ (PROC)glPointParameterfvEXT, "glPointParameterfvEXT" },
|
||||
|
||||
{ (PROC)glLockArraysEXT, "glLockArraysEXT" },
|
||||
{ (PROC)glUnlockArraysEXT, "glUnlockArraysEXT" },
|
||||
{ NULL, "\0" }
|
||||
};
|
||||
|
||||
GLD_extension GLD_multitexList[] = {
|
||||
/*
|
||||
{ (PROC)glMultiTexCoord1dSGIS, "glMTexCoord1dSGIS" },
|
||||
{ (PROC)glMultiTexCoord1dvSGIS, "glMTexCoord1dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord1fSGIS, "glMTexCoord1fSGIS" },
|
||||
{ (PROC)glMultiTexCoord1fvSGIS, "glMTexCoord1fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord1iSGIS, "glMTexCoord1iSGIS" },
|
||||
{ (PROC)glMultiTexCoord1ivSGIS, "glMTexCoord1ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord1sSGIS, "glMTexCoord1sSGIS" },
|
||||
{ (PROC)glMultiTexCoord1svSGIS, "glMTexCoord1svSGIS" },
|
||||
{ (PROC)glMultiTexCoord2dSGIS, "glMTexCoord2dSGIS" },
|
||||
{ (PROC)glMultiTexCoord2dvSGIS, "glMTexCoord2dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord2fSGIS, "glMTexCoord2fSGIS" },
|
||||
{ (PROC)glMultiTexCoord2fvSGIS, "glMTexCoord2fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord2iSGIS, "glMTexCoord2iSGIS" },
|
||||
{ (PROC)glMultiTexCoord2ivSGIS, "glMTexCoord2ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord2sSGIS, "glMTexCoord2sSGIS" },
|
||||
{ (PROC)glMultiTexCoord2svSGIS, "glMTexCoord2svSGIS" },
|
||||
{ (PROC)glMultiTexCoord3dSGIS, "glMTexCoord3dSGIS" },
|
||||
{ (PROC)glMultiTexCoord3dvSGIS, "glMTexCoord3dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord3fSGIS, "glMTexCoord3fSGIS" },
|
||||
{ (PROC)glMultiTexCoord3fvSGIS, "glMTexCoord3fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord3iSGIS, "glMTexCoord3iSGIS" },
|
||||
{ (PROC)glMultiTexCoord3ivSGIS, "glMTexCoord3ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord3sSGIS, "glMTexCoord3sSGIS" },
|
||||
{ (PROC)glMultiTexCoord3svSGIS, "glMTexCoord3svSGIS" },
|
||||
{ (PROC)glMultiTexCoord4dSGIS, "glMTexCoord4dSGIS" },
|
||||
{ (PROC)glMultiTexCoord4dvSGIS, "glMTexCoord4dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord4fSGIS, "glMTexCoord4fSGIS" },
|
||||
{ (PROC)glMultiTexCoord4fvSGIS, "glMTexCoord4fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord4iSGIS, "glMTexCoord4iSGIS" },
|
||||
{ (PROC)glMultiTexCoord4ivSGIS, "glMTexCoord4ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord4sSGIS, "glMTexCoord4sSGIS" },
|
||||
{ (PROC)glMultiTexCoord4svSGIS, "glMTexCoord4svSGIS" },
|
||||
{ (PROC)glMultiTexCoordPointerSGIS, "glMTexCoordPointerSGIS" },
|
||||
{ (PROC)glSelectTextureSGIS, "glSelectTextureSGIS" },
|
||||
{ (PROC)glSelectTextureCoordSetSGIS, "glSelectTextureCoordSetSGIS" },
|
||||
*/
|
||||
{ (PROC)glActiveTextureARB, "glActiveTextureARB" },
|
||||
{ (PROC)glClientActiveTextureARB, "glClientActiveTextureARB" },
|
||||
{ (PROC)glMultiTexCoord1dARB, "glMultiTexCoord1dARB" },
|
||||
{ (PROC)glMultiTexCoord1dvARB, "glMultiTexCoord1dvARB" },
|
||||
{ (PROC)glMultiTexCoord1fARB, "glMultiTexCoord1fARB" },
|
||||
{ (PROC)glMultiTexCoord1fvARB, "glMultiTexCoord1fvARB" },
|
||||
{ (PROC)glMultiTexCoord1iARB, "glMultiTexCoord1iARB" },
|
||||
{ (PROC)glMultiTexCoord1ivARB, "glMultiTexCoord1ivARB" },
|
||||
{ (PROC)glMultiTexCoord1sARB, "glMultiTexCoord1sARB" },
|
||||
{ (PROC)glMultiTexCoord1svARB, "glMultiTexCoord1svARB" },
|
||||
{ (PROC)glMultiTexCoord2dARB, "glMultiTexCoord2dARB" },
|
||||
{ (PROC)glMultiTexCoord2dvARB, "glMultiTexCoord2dvARB" },
|
||||
{ (PROC)glMultiTexCoord2fARB, "glMultiTexCoord2fARB" },
|
||||
{ (PROC)glMultiTexCoord2fvARB, "glMultiTexCoord2fvARB" },
|
||||
{ (PROC)glMultiTexCoord2iARB, "glMultiTexCoord2iARB" },
|
||||
{ (PROC)glMultiTexCoord2ivARB, "glMultiTexCoord2ivARB" },
|
||||
{ (PROC)glMultiTexCoord2sARB, "glMultiTexCoord2sARB" },
|
||||
{ (PROC)glMultiTexCoord2svARB, "glMultiTexCoord2svARB" },
|
||||
{ (PROC)glMultiTexCoord3dARB, "glMultiTexCoord3dARB" },
|
||||
{ (PROC)glMultiTexCoord3dvARB, "glMultiTexCoord3dvARB" },
|
||||
{ (PROC)glMultiTexCoord3fARB, "glMultiTexCoord3fARB" },
|
||||
{ (PROC)glMultiTexCoord3fvARB, "glMultiTexCoord3fvARB" },
|
||||
{ (PROC)glMultiTexCoord3iARB, "glMultiTexCoord3iARB" },
|
||||
{ (PROC)glMultiTexCoord3ivARB, "glMultiTexCoord3ivARB" },
|
||||
{ (PROC)glMultiTexCoord3sARB, "glMultiTexCoord3sARB" },
|
||||
{ (PROC)glMultiTexCoord3svARB, "glMultiTexCoord3svARB" },
|
||||
{ (PROC)glMultiTexCoord4dARB, "glMultiTexCoord4dARB" },
|
||||
{ (PROC)glMultiTexCoord4dvARB, "glMultiTexCoord4dvARB" },
|
||||
{ (PROC)glMultiTexCoord4fARB, "glMultiTexCoord4fARB" },
|
||||
{ (PROC)glMultiTexCoord4fvARB, "glMultiTexCoord4fvARB" },
|
||||
{ (PROC)glMultiTexCoord4iARB, "glMultiTexCoord4iARB" },
|
||||
{ (PROC)glMultiTexCoord4ivARB, "glMultiTexCoord4ivARB" },
|
||||
{ (PROC)glMultiTexCoord4sARB, "glMultiTexCoord4sARB" },
|
||||
{ (PROC)glMultiTexCoord4svARB, "glMultiTexCoord4svARB" },
|
||||
|
||||
// Descent3 doesn't use correct string, hence this hack
|
||||
{ (PROC)glMultiTexCoord4fARB, "glMultiTexCoord4f" },
|
||||
|
||||
// Quake2 SGIS multitexture
|
||||
{ (PROC)gldSelectTextureSGIS, "glSelectTextureSGIS" },
|
||||
{ (PROC)gldMTexCoord2fSGIS, "glMTexCoord2fSGIS" },
|
||||
{ (PROC)gldMTexCoord2fvSGIS, "glMTexCoord2fvSGIS" },
|
||||
|
||||
{ NULL, "\0" }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
PROC gldGetProcAddress_DX(
|
||||
LPCSTR a)
|
||||
{
|
||||
int i;
|
||||
PROC proc = NULL;
|
||||
|
||||
for (i=0; GLD_extList[i].proc; i++) {
|
||||
if (!strcmp(a, GLD_extList[i].name)) {
|
||||
proc = GLD_extList[i].proc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (glb.bMultitexture) {
|
||||
for (i=0; GLD_multitexList[i].proc; i++) {
|
||||
if (!strcmp(a, GLD_multitexList[i].name)) {
|
||||
proc = GLD_multitexList[i].proc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gldLogPrintf(GLDLOG_INFO, "GetProcAddress: %s (%s)", a, proc ? "OK" : "Failed");
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void gldEnableExtensions_DX8(
|
||||
GLcontext *ctx)
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
// Mesa enables some extensions by default.
|
||||
// This table decides which ones we want to switch off again.
|
||||
|
||||
// NOTE: GL_EXT_compiled_vertex_array appears broken.
|
||||
|
||||
const char *gld_disable_extensions[] = {
|
||||
// "GL_ARB_transpose_matrix",
|
||||
// "GL_EXT_compiled_vertex_array",
|
||||
// "GL_EXT_polygon_offset",
|
||||
// "GL_EXT_rescale_normal",
|
||||
"GL_EXT_texture3D",
|
||||
// "GL_NV_texgen_reflection",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *gld_multitex_extensions[] = {
|
||||
"GL_ARB_multitexture", // Quake 3
|
||||
NULL
|
||||
};
|
||||
|
||||
// Quake 2 engines
|
||||
const char *szGL_SGIS_multitexture = "GL_SGIS_multitexture";
|
||||
|
||||
const char *gld_enable_extensions[] = {
|
||||
"GL_EXT_texture_env_add", // Quake 3
|
||||
"GL_ARB_texture_env_add", // Quake 3
|
||||
NULL
|
||||
};
|
||||
|
||||
for (i=0; gld_disable_extensions[i]; i++) {
|
||||
_mesa_disable_extension(ctx, gld_disable_extensions[i]);
|
||||
}
|
||||
|
||||
for (i=0; gld_enable_extensions[i]; i++) {
|
||||
_mesa_enable_extension(ctx, gld_enable_extensions[i]);
|
||||
}
|
||||
|
||||
if (glb.bMultitexture) {
|
||||
for (i=0; gld_multitex_extensions[i]; i++) {
|
||||
_mesa_enable_extension(ctx, gld_multitex_extensions[i]);
|
||||
}
|
||||
|
||||
// GL_SGIS_multitexture
|
||||
// NOTE: Quake2 ran *slower* with this enabled, so I've
|
||||
// disabled it for now.
|
||||
// Fair bit slower on GeForce256,
|
||||
// Much slower on 3dfx Voodoo5 5500.
|
||||
// _mesa_add_extension(ctx, GL_TRUE, szGL_SGIS_multitexture, 0);
|
||||
|
||||
}
|
||||
|
||||
_mesa_enable_imaging_extensions(ctx);
|
||||
_mesa_enable_1_3_extensions(ctx);
|
||||
_mesa_enable_1_4_extensions(ctx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: Mesa transformation pipeline with GLDirect fastpath
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx8.h"
|
||||
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
extern struct tnl_pipeline_stage _gld_d3d_render_stage;
|
||||
extern struct tnl_pipeline_stage _gld_mesa_render_stage;
|
||||
|
||||
static const struct tnl_pipeline_stage *gld_pipeline[] = {
|
||||
&_gld_d3d_render_stage, // Direct3D TnL
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
&_tnl_fog_coordinate_stage, /* TODO: Omit fog stage. ??? */
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
&_tnl_point_attenuation_stage,
|
||||
&_gld_mesa_render_stage, // Mesa TnL, D3D rendering
|
||||
0,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void gldInstallPipeline_DX8(
|
||||
GLcontext *ctx)
|
||||
{
|
||||
// Remove any existing pipeline stages,
|
||||
// then install GLDirect pipeline stages.
|
||||
|
||||
_tnl_destroy_pipeline(ctx);
|
||||
_tnl_install_pipeline(ctx, gld_pipeline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,249 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GLDirect fastpath pipeline stage
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
//#include "../gld_log.h"
|
||||
//#include "gld_dx8.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx8.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
// #include "mem.h"
|
||||
#include "mtypes.h"
|
||||
//#include "mmath.h"
|
||||
|
||||
#include "math/m_matrix.h"
|
||||
#include "math/m_xform.h"
|
||||
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
__inline void _gldSetVertexShaderConstants(
|
||||
GLcontext *ctx,
|
||||
GLD_driver_dx8 *gld)
|
||||
{
|
||||
D3DXMATRIX mat, matView, matProj;
|
||||
GLfloat *pM;
|
||||
|
||||
// Mesa 5: Altered to a Stack
|
||||
//pM = ctx->ModelView.m;
|
||||
pM = ctx->ModelviewMatrixStack.Top->m;
|
||||
matView._11 = pM[0];
|
||||
matView._12 = pM[1];
|
||||
matView._13 = pM[2];
|
||||
matView._14 = pM[3];
|
||||
matView._21 = pM[4];
|
||||
matView._22 = pM[5];
|
||||
matView._23 = pM[6];
|
||||
matView._24 = pM[7];
|
||||
matView._31 = pM[8];
|
||||
matView._32 = pM[9];
|
||||
matView._33 = pM[10];
|
||||
matView._34 = pM[11];
|
||||
matView._41 = pM[12];
|
||||
matView._42 = pM[13];
|
||||
matView._43 = pM[14];
|
||||
matView._44 = pM[15];
|
||||
|
||||
// Mesa 5: Altered to a Stack
|
||||
//pM = ctx->ProjectionMatrix.m;
|
||||
pM = ctx->ProjectionMatrixStack.Top->m;
|
||||
matProj._11 = pM[0];
|
||||
matProj._12 = pM[1];
|
||||
matProj._13 = pM[2];
|
||||
matProj._14 = pM[3];
|
||||
matProj._21 = pM[4];
|
||||
matProj._22 = pM[5];
|
||||
matProj._23 = pM[6];
|
||||
matProj._24 = pM[7];
|
||||
matProj._31 = pM[8];
|
||||
matProj._32 = pM[9];
|
||||
matProj._33 = pM[10];
|
||||
matProj._34 = pM[11];
|
||||
matProj._41 = pM[12];
|
||||
matProj._42 = pM[13];
|
||||
matProj._43 = pM[14];
|
||||
matProj._44 = pM[15];
|
||||
|
||||
D3DXMatrixMultiply( &mat, &matView, &matProj );
|
||||
D3DXMatrixTranspose( &mat, &mat );
|
||||
|
||||
_GLD_DX8_DEV(SetVertexShaderConstant(gld->pDev, 0, &mat, 4));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static GLboolean gld_d3d_render_stage_run(
|
||||
GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
|
||||
GLD_driver_dx8 *gld = GLD_GET_DX8_DRIVER(gldCtx);
|
||||
|
||||
TNLcontext *tnl;
|
||||
struct vertex_buffer *VB;
|
||||
tnl_render_func *tab;
|
||||
GLint pass;
|
||||
GLD_pb_dx8 *gldPB = &gld->PB3d;
|
||||
/*
|
||||
static int count = 0;
|
||||
count++;
|
||||
if (count != 2)
|
||||
return GL_FALSE;
|
||||
*/
|
||||
// The "check" function should disable this stage,
|
||||
// but we'll test gld->bUseMesaTnL anyway.
|
||||
if (gld->bUseMesaTnL) {
|
||||
// Do nothing in this stage, but continue pipeline
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
tnl = TNL_CONTEXT(ctx);
|
||||
VB = &tnl->vb;
|
||||
pass = 0;
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
#if 0
|
||||
// For debugging: Useful to see if an app passes colour data in
|
||||
// an unusual format.
|
||||
switch (VB->ColorPtr[0]->Type) {
|
||||
case GL_FLOAT:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_FLOAT\n");
|
||||
break;
|
||||
case GL_UNSIGNED_BYTE:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_UNSIGNED_BYTE\n");
|
||||
break;
|
||||
default:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: *?*\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
tnl->Driver.Render.Points = gld_Points3D_DX8;
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
tnl->Driver.Render.Line = gld_Line3DFlat_DX8;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle3DFlat_DX8;
|
||||
tnl->Driver.Render.Quad = gld_Quad3DFlat_DX8;
|
||||
} else {
|
||||
tnl->Driver.Render.Line = gld_Line3DSmooth_DX8;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle3DSmooth_DX8;
|
||||
tnl->Driver.Render.Quad = gld_Quad3DSmooth_DX8;
|
||||
}
|
||||
|
||||
_GLD_DX8_VB(Lock(gldPB->pVB, 0, 0, &gldPB->pPoints, D3DLOCK_DISCARD));
|
||||
gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0;
|
||||
// Allocate primitive pointers
|
||||
// gldPB->pPoints is always first
|
||||
gldPB->pLines = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine);
|
||||
gldPB->pTriangles = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle);
|
||||
|
||||
ASSERT(tnl->Driver.Render.BuildVertices);
|
||||
ASSERT(tnl->Driver.Render.PrimitiveNotify);
|
||||
ASSERT(tnl->Driver.Render.Points);
|
||||
ASSERT(tnl->Driver.Render.Line);
|
||||
ASSERT(tnl->Driver.Render.Triangle);
|
||||
ASSERT(tnl->Driver.Render.Quad);
|
||||
ASSERT(tnl->Driver.Render.ResetLineStipple);
|
||||
ASSERT(tnl->Driver.Render.Interp);
|
||||
ASSERT(tnl->Driver.Render.CopyPV);
|
||||
ASSERT(tnl->Driver.Render.ClippedLine);
|
||||
ASSERT(tnl->Driver.Render.ClippedPolygon);
|
||||
ASSERT(tnl->Driver.Render.Finish);
|
||||
|
||||
tab = (VB->Elts ? tnl->Driver.Render.PrimTabElts : tnl->Driver.Render.PrimTabVerts);
|
||||
|
||||
do {
|
||||
GLuint i, length, flags = 0;
|
||||
for (i = 0 ; !(flags & PRIM_END) ; i += length)
|
||||
{
|
||||
flags = VB->Primitive[i].mode;
|
||||
length= VB->Primitive[i].count;
|
||||
ASSERT(length || (flags & PRIM_END));
|
||||
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
|
||||
if (length)
|
||||
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
|
||||
}
|
||||
} while (tnl->Driver.Render.Multipass &&
|
||||
tnl->Driver.Render.Multipass( ctx, ++pass ));
|
||||
|
||||
_GLD_DX8_VB(Unlock(gldPB->pVB));
|
||||
|
||||
_GLD_DX8_DEV(SetStreamSource(gld->pDev, 0, gldPB->pVB, gldPB->dwStride));
|
||||
|
||||
_GLD_DX8_DEV(SetTransform(gld->pDev, D3DTS_PROJECTION, &gld->matProjection));
|
||||
_GLD_DX8_DEV(SetTransform(gld->pDev, D3DTS_WORLD, &gld->matModelView));
|
||||
|
||||
if (gldPB->nPoints) {
|
||||
_GLD_DX8_DEV(DrawPrimitive(gld->pDev, D3DPT_POINTLIST, 0, gldPB->nPoints));
|
||||
gldPB->nPoints = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nLines) {
|
||||
_GLD_DX8_DEV(DrawPrimitive(gld->pDev, D3DPT_LINELIST, gldPB->iFirstLine, gldPB->nLines));
|
||||
gldPB->nLines = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nTriangles) {
|
||||
_GLD_DX8_DEV(DrawPrimitive(gld->pDev, D3DPT_TRIANGLELIST, gldPB->iFirstTriangle, gldPB->nTriangles));
|
||||
gldPB->nTriangles = 0;
|
||||
}
|
||||
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const struct tnl_pipeline_stage _gld_d3d_render_stage =
|
||||
{
|
||||
"gld_d3d_render_stage",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
gld_d3d_render_stage_run /* run */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
@@ -1,448 +0,0 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL 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:
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Render whole vertex buffers, including projection of vertices from
|
||||
* clip space and clipping of primitives.
|
||||
*
|
||||
* This file makes calls to project vertices and to the point, line
|
||||
* and triangle rasterizers via the function pointers:
|
||||
*
|
||||
* context->Driver.Render.*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
//#include "../gld_log.h"
|
||||
//#include "gld_dx8.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx8.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
// #include "mem.h"
|
||||
#include "mtypes.h"
|
||||
//#include "mmath.h"
|
||||
|
||||
#include "math/m_matrix.h"
|
||||
#include "math/m_xform.h"
|
||||
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip single primitives */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#if defined(USE_IEEE)
|
||||
#define NEGATIVE(x) (GET_FLOAT_BITS(x) & (1<<31))
|
||||
//#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
|
||||
#else
|
||||
#define NEGATIVE(x) (x < 0)
|
||||
//#define DIFFERENT_SIGNS(x,y) (x * y <= 0 && x - y != 0)
|
||||
/* Could just use (x*y<0) except for the flatshading requirements.
|
||||
* Maybe there's a better way?
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#define W(i) coord[i][3]
|
||||
#define Z(i) coord[i][2]
|
||||
#define Y(i) coord[i][1]
|
||||
#define X(i) coord[i][0]
|
||||
#define SIZE 4
|
||||
#define TAG(x) x##_4
|
||||
#include "tnl/t_vb_cliptmp.h"
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip and render whole begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
|
||||
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
|
||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
||||
|
||||
|
||||
/* Vertices, with the possibility of clipping.
|
||||
*/
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
tnl->Driver.Render.Points( ctx, start, count )
|
||||
|
||||
#define RENDER_LINE( v1, v2 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2]; \
|
||||
GLubyte ormask = c1|c2; \
|
||||
if (!ormask) \
|
||||
LineFunc( ctx, v1, v2 ); \
|
||||
else if (!(c1 & c2 & 0x3f)) \
|
||||
clip_line_4( ctx, v1, v2, ormask ); \
|
||||
} while (0)
|
||||
|
||||
#define RENDER_TRI( v1, v2, v3 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2], c3 = mask[v3]; \
|
||||
GLubyte ormask = c1|c2|c3; \
|
||||
if (!ormask) \
|
||||
TriangleFunc( ctx, v1, v2, v3 ); \
|
||||
else if (!(c1 & c2 & c3 & 0x3f)) \
|
||||
clip_tri_4( ctx, v1, v2, v3, ormask ); \
|
||||
} while (0)
|
||||
|
||||
#define RENDER_QUAD( v1, v2, v3, v4 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2]; \
|
||||
GLubyte c3 = mask[v3], c4 = mask[v4]; \
|
||||
GLubyte ormask = c1|c2|c3|c4; \
|
||||
if (!ormask) \
|
||||
QuadFunc( ctx, v1, v2, v3, v4 ); \
|
||||
else if (!(c1 & c2 & c3 & c4 & 0x3f)) \
|
||||
clip_quad_4( ctx, v1, v2, v3, v4, ormask ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LOCAL_VARS \
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx); \
|
||||
struct vertex_buffer *VB = &tnl->vb; \
|
||||
const GLuint * const elt = VB->Elts; \
|
||||
const GLubyte *mask = VB->ClipMask; \
|
||||
const GLuint sz = VB->ClipPtr->size; \
|
||||
const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
|
||||
const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
|
||||
const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
|
||||
const GLboolean stipple = ctx->Line.StippleFlag; \
|
||||
(void) (LineFunc && TriangleFunc && QuadFunc); \
|
||||
(void) elt; (void) mask; (void) sz; (void) stipple;
|
||||
|
||||
#define TAG(x) clip_##x##_verts
|
||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
||||
#define PRESERVE_VB_DEFS
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
|
||||
/* Elts, with the possibility of clipping.
|
||||
*/
|
||||
#undef ELT
|
||||
#undef TAG
|
||||
#define ELT(x) elt[x]
|
||||
#define TAG(x) clip_##x##_elts
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
/* TODO: do this for all primitives, verts and elts:
|
||||
*/
|
||||
static void clip_elt_triangles( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl_render_func render_tris = tnl->Driver.Render.PrimTabElts[GL_TRIANGLES];
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
const GLuint * const elt = VB->Elts;
|
||||
GLubyte *mask = VB->ClipMask;
|
||||
GLuint last = count-2;
|
||||
GLuint j;
|
||||
(void) flags;
|
||||
|
||||
tnl->Driver.Render.PrimitiveNotify( ctx, GL_TRIANGLES );
|
||||
|
||||
for (j=start; j < last; j+=3 ) {
|
||||
GLubyte c1 = mask[elt[j]];
|
||||
GLubyte c2 = mask[elt[j+1]];
|
||||
GLubyte c3 = mask[elt[j+2]];
|
||||
GLubyte ormask = c1|c2|c3;
|
||||
if (ormask) {
|
||||
if (start < j)
|
||||
render_tris( ctx, start, j, 0 );
|
||||
if (!(c1&c2&c3&0x3f))
|
||||
clip_tri_4( ctx, elt[j], elt[j+1], elt[j+2], ormask );
|
||||
start = j+3;
|
||||
}
|
||||
}
|
||||
|
||||
if (start < j)
|
||||
render_tris( ctx, start, j, 0 );
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render whole begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
|
||||
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
|
||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
||||
|
||||
|
||||
/* Vertices, no clipping.
|
||||
*/
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
tnl->Driver.Render.Points( ctx, start, count )
|
||||
|
||||
#define RENDER_LINE( v1, v2 ) \
|
||||
LineFunc( ctx, v1, v2 )
|
||||
|
||||
#define RENDER_TRI( v1, v2, v3 ) \
|
||||
TriangleFunc( ctx, v1, v2, v3 )
|
||||
|
||||
#define RENDER_QUAD( v1, v2, v3, v4 ) \
|
||||
QuadFunc( ctx, v1, v2, v3, v4 )
|
||||
|
||||
#define TAG(x) _gld_tnl_##x##_verts
|
||||
|
||||
#define LOCAL_VARS \
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx); \
|
||||
struct vertex_buffer *VB = &tnl->vb; \
|
||||
const GLuint * const elt = VB->Elts; \
|
||||
const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
|
||||
const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
|
||||
const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
|
||||
(void) (LineFunc && TriangleFunc && QuadFunc); \
|
||||
(void) elt;
|
||||
|
||||
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||
#define RENDER_TAB_QUALIFIER
|
||||
#define PRESERVE_VB_DEFS
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
/* Elts, no clipping.
|
||||
*/
|
||||
#undef ELT
|
||||
#define TAG(x) _gld_tnl_##x##_elts
|
||||
#define ELT(x) elt[x]
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Helper functions for drivers */
|
||||
/**********************************************************************/
|
||||
/*
|
||||
void _tnl_RenderClippedPolygon( GLcontext *ctx, const GLuint *elts, GLuint n )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint *tmp = VB->Elts;
|
||||
|
||||
VB->Elts = (GLuint *)elts;
|
||||
tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
|
||||
VB->Elts = tmp;
|
||||
}
|
||||
|
||||
void _tnl_RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.Line( ctx, ii, jj );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip and render whole vertex buffers */
|
||||
/**********************************************************************/
|
||||
|
||||
tnl_points_func _gldSetupPoints[4] = {
|
||||
gld_Points2D_DX8,
|
||||
gld_Points2D_DX8,
|
||||
gld_Points2D_DX8,
|
||||
gld_Points2D_DX8
|
||||
};
|
||||
tnl_line_func _gldSetupLine[4] = {
|
||||
gld_Line2DFlat_DX8,
|
||||
gld_Line2DSmooth_DX8,
|
||||
gld_Line2DFlat_DX8,
|
||||
gld_Line2DSmooth_DX8,
|
||||
};
|
||||
tnl_triangle_func _gldSetupTriangle[4] = {
|
||||
gld_Triangle2DFlat_DX8,
|
||||
gld_Triangle2DSmooth_DX8,
|
||||
gld_Triangle2DFlatExtras_DX8,
|
||||
gld_Triangle2DSmoothExtras_DX8
|
||||
};
|
||||
tnl_quad_func _gldSetupQuad[4] = {
|
||||
gld_Quad2DFlat_DX8,
|
||||
gld_Quad2DSmooth_DX8,
|
||||
gld_Quad2DFlatExtras_DX8,
|
||||
gld_Quad2DSmoothExtras_DX8
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static GLboolean _gld_mesa_render_stage_run(
|
||||
GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
|
||||
GLD_driver_dx8 *gld = GLD_GET_DX8_DRIVER(gldCtx);
|
||||
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
tnl_render_func *tab;
|
||||
GLint pass = 0;
|
||||
GLD_pb_dx8 *gldPB;
|
||||
|
||||
/* Allow the drivers to lock before projected verts are built so
|
||||
* that window coordinates are guarenteed not to change before
|
||||
* rendering.
|
||||
*/
|
||||
ASSERT(tnl->Driver.Render.Start);
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
// NOTE: Setting D3DRS_SOFTWAREVERTEXPROCESSING for a mixed-mode device resets
|
||||
// stream, indices and shader to default values of NULL or 0.
|
||||
/* if ((ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) &&
|
||||
gld->VStwosidelight.hShader &&
|
||||
!ctx->Fog.Enabled)
|
||||
{
|
||||
IDirect3DDevice8_SetRenderState(gld->pDev, D3DRS_SOFTWAREVERTEXPROCESSING, !gld->VStwosidelight.bHardware);
|
||||
_GLD_DX8_DEV(SetVertexShader(gld->pDev, gld->VStwosidelight.hShader));
|
||||
gldPB = &gld->PBtwosidelight;
|
||||
tnl->Driver.Render.Points = gld_Points2DTwoside_DX8;
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
tnl->Driver.Render.Line = gld_Line2DFlatTwoside_DX8;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle2DFlatTwoside_DX8;
|
||||
tnl->Driver.Render.Quad = gld_Quad2DFlatTwoside_DX8;
|
||||
} else {
|
||||
tnl->Driver.Render.Line = gld_Line2DSmoothTwoside_DX8;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle2DSmoothTwoside_DX8;
|
||||
tnl->Driver.Render.Quad = gld_Quad2DSmoothTwoside_DX8;
|
||||
}
|
||||
} else {*/
|
||||
IDirect3DDevice8_SetRenderState(gld->pDev, D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
|
||||
gldPB = &gld->PB2d;
|
||||
_GLD_DX8_DEV(SetVertexShader(gld->pDev, gldPB->dwFVF));
|
||||
tnl->Driver.Render.Points = _gldSetupPoints[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Line = _gldSetupLine[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Triangle = _gldSetupTriangle[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Quad = _gldSetupQuad[gld->iSetupFunc];
|
||||
// }
|
||||
|
||||
_GLD_DX8_VB(Lock(gldPB->pVB, 0, 0, &gldPB->pPoints, D3DLOCK_DISCARD));
|
||||
gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0;
|
||||
// Allocate primitive pointers
|
||||
// gldPB->pPoints is always first
|
||||
gldPB->pLines = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine);
|
||||
gldPB->pTriangles = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle);
|
||||
|
||||
ASSERT(tnl->Driver.Render.BuildVertices);
|
||||
ASSERT(tnl->Driver.Render.PrimitiveNotify);
|
||||
ASSERT(tnl->Driver.Render.Points);
|
||||
ASSERT(tnl->Driver.Render.Line);
|
||||
ASSERT(tnl->Driver.Render.Triangle);
|
||||
ASSERT(tnl->Driver.Render.Quad);
|
||||
ASSERT(tnl->Driver.Render.ResetLineStipple);
|
||||
ASSERT(tnl->Driver.Render.Interp);
|
||||
ASSERT(tnl->Driver.Render.CopyPV);
|
||||
ASSERT(tnl->Driver.Render.ClippedLine);
|
||||
ASSERT(tnl->Driver.Render.ClippedPolygon);
|
||||
ASSERT(tnl->Driver.Render.Finish);
|
||||
|
||||
tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 );
|
||||
|
||||
if (VB->ClipOrMask) {
|
||||
tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts;
|
||||
clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles;
|
||||
}
|
||||
else {
|
||||
tab = (VB->Elts ?
|
||||
tnl->Driver.Render.PrimTabElts :
|
||||
tnl->Driver.Render.PrimTabVerts);
|
||||
}
|
||||
|
||||
do {
|
||||
GLuint i, length, flags = 0;
|
||||
for (i = 0 ; !(flags & PRIM_END) ; i += length) {
|
||||
flags = VB->Primitive[i].mode;
|
||||
length= VB->Primitive[i].count;
|
||||
ASSERT(length || (flags & PRIM_END));
|
||||
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
|
||||
if (length)
|
||||
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
|
||||
}
|
||||
} while (tnl->Driver.Render.Multipass &&
|
||||
tnl->Driver.Render.Multipass( ctx, ++pass ));
|
||||
|
||||
|
||||
// tnl->Driver.Render.Finish( ctx );
|
||||
|
||||
_GLD_DX8_VB(Unlock(gldPB->pVB));
|
||||
|
||||
_GLD_DX8_DEV(SetStreamSource(gld->pDev, 0, gldPB->pVB, gldPB->dwStride));
|
||||
|
||||
if (gldPB->nPoints) {
|
||||
_GLD_DX8_DEV(DrawPrimitive(gld->pDev, D3DPT_POINTLIST, 0, gldPB->nPoints));
|
||||
gldPB->nPoints = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nLines) {
|
||||
_GLD_DX8_DEV(DrawPrimitive(gld->pDev, D3DPT_LINELIST, gldPB->iFirstLine, gldPB->nLines));
|
||||
gldPB->nLines = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nTriangles) {
|
||||
_GLD_DX8_DEV(DrawPrimitive(gld->pDev, D3DPT_TRIANGLELIST, gldPB->iFirstTriangle, gldPB->nTriangles));
|
||||
gldPB->nTriangles = 0;
|
||||
}
|
||||
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render pipeline stage */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const struct tnl_pipeline_stage _gld_mesa_render_stage =
|
||||
{
|
||||
"gld_mesa_render_stage",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
_gld_mesa_render_stage_run /* run */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,327 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GLDirect Direct3D 9.0 header file
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _GLD_DX9_H
|
||||
#define _GLD_DX9_H
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Windows includes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//#ifndef STRICT
|
||||
//#define STRICT
|
||||
//#endif
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
//#include <windows.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
|
||||
// MS screwed up with the DX8.1 SDK - there's no compile-time
|
||||
// method of compiling for 8.0 via the 8.1 SDK unless you
|
||||
// "make sure you don't use any 8.1 interfaces".
|
||||
// We CAN use 8.1 D3DX static functions, though - just not new 8.1 interfaces.
|
||||
//
|
||||
// D3D_SDK_VERSION is 120 for 8.0 (supported by Windows 95).
|
||||
// D3D_SDK_VERSION is 220 for 8.1 (NOT supported by Windows 95).
|
||||
//
|
||||
//#define D3D_SDK_VERSION_DX9_SUPPORT_WIN95 120
|
||||
//#define D3D_SDK_VERSION_DX91 220
|
||||
|
||||
// Typedef for obtaining function from d3d8.dll
|
||||
typedef IDirect3D9* (WINAPI *FNDIRECT3DCREATE9) (UINT);
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Defines
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _GLD_TEST_HRESULT(h) \
|
||||
{ \
|
||||
HRESULT _hr = (h); \
|
||||
if (FAILED(_hr)) { \
|
||||
gldLogError(GLDLOG_ERROR, #h, _hr); \
|
||||
} \
|
||||
}
|
||||
#define _GLD_DX9(func) _GLD_TEST_HRESULT(IDirect3D9_##func##)
|
||||
#define _GLD_DX9_DEV(func) _GLD_TEST_HRESULT(IDirect3DDevice9_##func##)
|
||||
#define _GLD_DX9_VB(func) _GLD_TEST_HRESULT(IDirect3DVertexBuffer9_##func##)
|
||||
#define _GLD_DX9_TEX(func) _GLD_TEST_HRESULT(IDirect3DTexture9_##func##)
|
||||
#else
|
||||
#define _GLD_DX9(func) IDirect3D9_##func
|
||||
#define _GLD_DX9_DEV(func) IDirect3DDevice9_##func
|
||||
#define _GLD_DX9_VB(func) IDirect3DVertexBuffer9_##func
|
||||
#define _GLD_DX9_TEX(func) IDirect3DTexture9_##func
|
||||
#endif
|
||||
|
||||
#define SAFE_RELEASE(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
(p)->lpVtbl->Release(p); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_RELEASE_VB9(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
IDirect3DVertexBuffer9_Release((p)); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_RELEASE_SURFACE9(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
IDirect3DSurface9_Release((p)); \
|
||||
(p) = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
// Setup index.
|
||||
enum {
|
||||
GLD_SI_FLAT = 0,
|
||||
GLD_SI_SMOOTH = 1,
|
||||
GLD_SI_FLAT_EXTRAS = 2,
|
||||
GLD_SI_SMOOTH_EXTRAS = 3,
|
||||
};
|
||||
/*
|
||||
// Internal pipeline
|
||||
typedef enum {
|
||||
GLD_PIPELINE_MESA = 0, // Mesa pipeline
|
||||
GLD_PIPELINE_D3D_FVF = 1, // Direct3D Fixed-function pipeline
|
||||
GLD_PIPELINE_D3D_VS_TWOSIDE = 2 // Direct3D two-sided-lighting vertex shader
|
||||
} GLD_tnl_pipeline;
|
||||
*/
|
||||
//---------------------------------------------------------------------------
|
||||
// Vertex definitions for Fixed-Function pipeline
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// NOTE: If the number of texture units is altered then most of
|
||||
// the texture code will need to be revised.
|
||||
//
|
||||
|
||||
#define GLD_MAX_TEXTURE_UNITS_DX9 2
|
||||
|
||||
//
|
||||
// 2D vertex transformed by Mesa
|
||||
//
|
||||
#define GLD_FVF_2D_VERTEX ( D3DFVF_XYZRHW | \
|
||||
D3DFVF_DIFFUSE | \
|
||||
D3DFVF_SPECULAR | \
|
||||
D3DFVF_TEX2)
|
||||
typedef struct {
|
||||
FLOAT x, y; // 2D raster coords
|
||||
FLOAT sz; // Screen Z (depth)
|
||||
FLOAT rhw; // Reciprocal homogenous W
|
||||
DWORD diffuse; // Diffuse colour
|
||||
DWORD specular; // For separate-specular support
|
||||
FLOAT t0_u, t0_v; // 1st set of texture coords
|
||||
FLOAT t1_u, t1_v; // 2nd set of texture coords
|
||||
} GLD_2D_VERTEX;
|
||||
|
||||
|
||||
//
|
||||
// 3D vertex transformed by Direct3D
|
||||
//
|
||||
#define GLD_FVF_3D_VERTEX ( D3DFVF_XYZ | \
|
||||
D3DFVF_DIFFUSE | \
|
||||
D3DFVF_TEX2)
|
||||
|
||||
typedef struct {
|
||||
D3DXVECTOR3 Position; // XYZ Vector in object space
|
||||
D3DCOLOR Diffuse; // Diffuse colour
|
||||
D3DXVECTOR2 TexUnit0; // Texture unit 0
|
||||
D3DXVECTOR2 TexUnit1; // Texture unit 1
|
||||
} GLD_3D_VERTEX;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Vertex Shaders
|
||||
//---------------------------------------------------------------------------
|
||||
/*
|
||||
// DX8 Vertex Shader
|
||||
typedef struct {
|
||||
DWORD hShader; // If NULL, shader is invalid and cannot be used
|
||||
BOOL bHardware; // If TRUE then shader was created for hardware,
|
||||
// otherwise shader was created for software.
|
||||
} GLD_vertexShader;
|
||||
*/
|
||||
//---------------------------------------------------------------------------
|
||||
// Structs
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// This keeps a count of how many times we choose each individual internal
|
||||
// pathway. Useful for seeing if a certain pathway was ever used by an app, and
|
||||
// how much each pathway is biased.
|
||||
// Zero the members at context creation and dump stats at context deletion.
|
||||
typedef struct {
|
||||
// Note: DWORD is probably too small
|
||||
ULARGE_INTEGER qwMesa; // Mesa TnL pipeline
|
||||
ULARGE_INTEGER qwD3DFVF; // Direct3D Fixed-Function pipeline
|
||||
// ULARGE_INTEGER dwD3D2SVS; // Direct3D Two-Sided Vertex Shader pipeline
|
||||
} GLD_pipeline_usage;
|
||||
|
||||
// GLDirect Primitive Buffer (points, lines, triangles and quads)
|
||||
typedef struct {
|
||||
// Data for IDirect3DDevice9::CreateVertexBuffer()
|
||||
DWORD dwStride; // Stride of vertex
|
||||
DWORD dwUsage; // Usage flags
|
||||
DWORD dwFVF; // Direct3D Flexible Vertex Format
|
||||
DWORD dwPool; // Pool flags
|
||||
|
||||
IDirect3DVertexBuffer9 *pVB; // Holds points, lines, tris and quads.
|
||||
|
||||
// Point list is assumed to be at start of buffer
|
||||
DWORD iFirstLine; // Index of start of line list
|
||||
DWORD iFirstTriangle; // Index of start of triangle list
|
||||
|
||||
BYTE *pPoints; // Pointer to next free point
|
||||
BYTE *pLines; // Pointer to next free line
|
||||
BYTE *pTriangles; // Pointer to next free triangle
|
||||
|
||||
DWORD nPoints; // Number of points ready to render
|
||||
DWORD nLines; // Number of lines ready to render
|
||||
DWORD nTriangles; // Number of triangles ready to render
|
||||
} GLD_pb_dx9;
|
||||
|
||||
// GLDirect DX9 driver data
|
||||
typedef struct {
|
||||
// GLDirect vars
|
||||
BOOL bDoublebuffer; // Doublebuffer (otherwise single-buffered)
|
||||
BOOL bDepthStencil; // Depth buffer needed (stencil optional)
|
||||
D3DFORMAT RenderFormat; // Format of back/front buffer
|
||||
D3DFORMAT DepthFormat; // Format of depth/stencil
|
||||
// float fFlipWindowY; // Value for flipping viewport Y coord
|
||||
|
||||
// Direct3D vars
|
||||
D3DCAPS9 d3dCaps9;
|
||||
BOOL bHasHWTnL; // Device has Hardware Transform/Light?
|
||||
IDirect3D9 *pD3D; // Base Direct3D9 interface
|
||||
IDirect3DDevice9 *pDev; // Direct3D9 Device interface
|
||||
GLD_pb_dx9 PB2d; // Vertices transformed by Mesa
|
||||
GLD_pb_dx9 PB3d; // Vertices transformed by Direct3D
|
||||
D3DPRIMITIVETYPE d3dpt; // Current Direct3D primitive type
|
||||
D3DXMATRIX matProjection; // Projection matrix for D3D TnL
|
||||
D3DXMATRIX matModelView; // Model/View matrix for D3D TnL
|
||||
int iSetupFunc; // Which setup functions to use
|
||||
BOOL bUseMesaTnL; // Whether to use Mesa or D3D for TnL
|
||||
|
||||
// Direct3D vars for two-sided lighting
|
||||
// GLD_vertexShader VStwosidelight; // Vertex Shader for two-sided lighting
|
||||
// D3DXMATRIX matWorldViewProj;// World/View/Projection matrix for shaders
|
||||
|
||||
|
||||
// GLD_tnl_pipeline TnLPipeline; // Index of current internal pipeline
|
||||
GLD_pipeline_usage PipelineUsage;
|
||||
|
||||
BOOL bCanScissor; // Scissor test - new for DX9
|
||||
} GLD_driver_dx9;
|
||||
|
||||
#define GLD_GET_DX9_DRIVER(c) (GLD_driver_dx9*)(c)->glPriv
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
PROC gldGetProcAddress_DX9(LPCSTR a);
|
||||
void gldEnableExtensions_DX9(GLcontext *ctx);
|
||||
void gldInstallPipeline_DX9(GLcontext *ctx);
|
||||
void gldSetupDriverPointers_DX9(GLcontext *ctx);
|
||||
//void gldResizeBuffers_DX9(GLcontext *ctx);
|
||||
void gldResizeBuffers_DX9(GLframebuffer *fb);
|
||||
|
||||
|
||||
// Texture functions
|
||||
|
||||
void gldCopyTexImage1D_DX9(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);
|
||||
void gldCopyTexImage2D_DX9(GLcontext *ctx, GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
|
||||
void gldCopyTexSubImage1D_DX9(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width );
|
||||
void gldCopyTexSubImage2D_DX9(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
void gldCopyTexSubImage3D_DX9(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
|
||||
void gld_NEW_TEXTURE_DX9(GLcontext *ctx);
|
||||
void gld_DrawPixels_DX9(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels);
|
||||
void gld_ReadPixels_DX9(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, GLvoid *dest);
|
||||
void gld_CopyPixels_DX9(GLcontext *ctx, GLint srcx, GLint srcy, GLsizei width, GLsizei height, GLint dstx, GLint dsty, GLenum type);
|
||||
void gld_Bitmap_DX9(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap);
|
||||
const struct gl_texture_format* gld_ChooseTextureFormat_DX9(GLcontext *ctx, GLint internalFormat, GLenum srcFormat, GLenum srcType);
|
||||
void gld_TexImage2D_DX9(GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *tObj, struct gl_texture_image *texImage);
|
||||
void gld_TexImage1D_DX9(GLcontext *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage );
|
||||
void gld_TexSubImage2D_DX9( GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage );
|
||||
void gld_TexSubImage1D_DX9(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage);
|
||||
void gld_DeleteTexture_DX9(GLcontext *ctx, struct gl_texture_object *tObj);
|
||||
void gld_ResetLineStipple_DX9(GLcontext *ctx);
|
||||
|
||||
// 2D primitive functions
|
||||
|
||||
void gld_Points2D_DX9(GLcontext *ctx, GLuint first, GLuint last);
|
||||
|
||||
void gld_Line2DFlat_DX9(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Line2DSmooth_DX9(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
|
||||
void gld_Triangle2DFlat_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmooth_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DFlatExtras_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmoothExtras_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
|
||||
void gld_Quad2DFlat_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmooth_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DFlatExtras_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmoothExtras_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
// 3D primitive functions
|
||||
|
||||
void gld_Points3D_DX9(GLcontext *ctx, GLuint first, GLuint last);
|
||||
void gld_Line3DFlat_DX9(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle3DFlat_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad3DFlat_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Line3DSmooth_DX9(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle3DSmooth_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad3DSmooth_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
// Primitive functions for Two-sided-lighting Vertex Shader
|
||||
|
||||
void gld_Points2DTwoside_DX9(GLcontext *ctx, GLuint first, GLuint last);
|
||||
void gld_Line2DFlatTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Line2DSmoothTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1);
|
||||
void gld_Triangle2DFlatTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Triangle2DSmoothTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2);
|
||||
void gld_Quad2DFlatTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
void gld_Quad2DSmoothTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
|
||||
|
||||
#endif
|
@@ -1,77 +0,0 @@
|
||||
/*==========================================================================;
|
||||
*
|
||||
*
|
||||
* File: dxerr9.h
|
||||
* Content: DirectX Error Library Include File
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _GLD_DXERR9_H_
|
||||
#define _GLD_DXERR9_H_
|
||||
|
||||
|
||||
#include <d3d9.h>
|
||||
|
||||
//
|
||||
// DXGetErrorString9
|
||||
//
|
||||
// Desc: Converts an DirectX HRESULT to a string
|
||||
//
|
||||
// Args: HRESULT hr Can be any error code from
|
||||
// DPLAY D3D8 D3DX8 DMUSIC DSOUND
|
||||
//
|
||||
// Return: Converted string
|
||||
//
|
||||
const char* __stdcall DXGetErrorString9A(HRESULT hr);
|
||||
const WCHAR* __stdcall DXGetErrorString9W(HRESULT hr);
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DXGetErrorString9 DXGetErrorString9W
|
||||
#else
|
||||
#define DXGetErrorString9 DXGetErrorString9A
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// DXTrace
|
||||
//
|
||||
// Desc: Outputs a formatted error message to the debug stream
|
||||
//
|
||||
// Args: CHAR* strFile The current file, typically passed in using the
|
||||
// __FILE__ macro.
|
||||
// DWORD dwLine The current line number, typically passed in using the
|
||||
// __LINE__ macro.
|
||||
// HRESULT hr An HRESULT that will be traced to the debug stream.
|
||||
// CHAR* strMsg A string that will be traced to the debug stream (may be NULL)
|
||||
// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info.
|
||||
//
|
||||
// Return: The hr that was passed in.
|
||||
//
|
||||
//HRESULT __stdcall DXTraceA( char* strFile, DWORD dwLine, HRESULT hr, char* strMsg, BOOL bPopMsgBox = FALSE );
|
||||
//HRESULT __stdcall DXTraceW( char* strFile, DWORD dwLine, HRESULT hr, WCHAR* strMsg, BOOL bPopMsgBox = FALSE );
|
||||
HRESULT __stdcall DXTraceA( char* strFile, DWORD dwLine, HRESULT hr, char* strMsg, BOOL bPopMsgBox);
|
||||
HRESULT __stdcall DXTraceW( char* strFile, DWORD dwLine, HRESULT hr, WCHAR* strMsg, BOOL bPopMsgBox);
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DXTrace DXTraceW
|
||||
#else
|
||||
#define DXTrace DXTraceA
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Helper macros
|
||||
//
|
||||
#if defined(DEBUG) | defined(_DEBUG)
|
||||
#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE )
|
||||
#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE )
|
||||
#define DXTRACE_ERR_NOMSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE )
|
||||
#else
|
||||
#define DXTRACE_MSG(str) (0L)
|
||||
#define DXTRACE_ERR(str,hr) (hr)
|
||||
#define DXTRACE_ERR_NOMSGBOX(str,hr) (hr)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -1,344 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GL extensions
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
//#include "../gld_log.h"
|
||||
//#include "../gld_settings.h"
|
||||
|
||||
#include <windows.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
//#include "ddlog.h"
|
||||
//#include "gld_dx8.h"
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "colormac.h"
|
||||
#include "depth.h"
|
||||
#include "extensions.h"
|
||||
#include "macros.h"
|
||||
#include "matrix.h"
|
||||
// #include "mem.h"
|
||||
//#include "mmath.h"
|
||||
#include "mtypes.h"
|
||||
#include "texformat.h"
|
||||
#include "texstore.h"
|
||||
#include "vbo/vbo.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "swrast_setup/ss_context.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "extensions.h"
|
||||
|
||||
// For some reason this is not defined in an above header...
|
||||
extern void _mesa_enable_imaging_extensions(GLcontext *ctx);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Hack for the SGIS_multitexture extension that was removed from Mesa
|
||||
// NOTE: SGIS_multitexture enums also clash with GL_SGIX_async_pixel
|
||||
|
||||
// NOTE: Quake2 ran *slower* with this enabled, so I've
|
||||
// disabled it for now.
|
||||
// To enable, uncomment:
|
||||
// _mesa_add_extension(ctx, GL_TRUE, szGL_SGIS_multitexture, 0);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
/* Quake2 GL_SGIS_multitexture */
|
||||
GL_SELECTED_TEXTURE_SGIS = 0x835B,
|
||||
GL_SELECTED_TEXTURE_COORD_SET_SGIS = 0x835C,
|
||||
GL_MAX_TEXTURES_SGIS = 0x835D,
|
||||
GL_TEXTURE0_SGIS = 0x835E,
|
||||
GL_TEXTURE1_SGIS = 0x835F,
|
||||
GL_TEXTURE2_SGIS = 0x8360,
|
||||
GL_TEXTURE3_SGIS = 0x8361,
|
||||
GL_TEXTURE_COORD_SET_SOURCE_SGIS = 0x8363,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldSelectTextureSGIS(
|
||||
GLenum target)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glActiveTextureARB(ARB_target);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldMTexCoord2fSGIS(
|
||||
GLenum target,
|
||||
GLfloat s,
|
||||
GLfloat t)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glMultiTexCoord2fARB(ARB_target, s, t);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void APIENTRY gldMTexCoord2fvSGIS(
|
||||
GLenum target,
|
||||
const GLfloat *v)
|
||||
{
|
||||
GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
|
||||
glMultiTexCoord2fvARB(ARB_target, v);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Extensions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
PROC proc;
|
||||
char *name;
|
||||
} GLD_extension;
|
||||
|
||||
GLD_extension GLD_extList[] = {
|
||||
#ifdef GL_EXT_polygon_offset
|
||||
{ (PROC)glPolygonOffsetEXT, "glPolygonOffsetEXT" },
|
||||
#endif
|
||||
{ (PROC)glBlendEquationEXT, "glBlendEquationEXT" },
|
||||
{ (PROC)glBlendColorEXT, "glBlendColorExt" },
|
||||
{ (PROC)glVertexPointerEXT, "glVertexPointerEXT" },
|
||||
{ (PROC)glNormalPointerEXT, "glNormalPointerEXT" },
|
||||
{ (PROC)glColorPointerEXT, "glColorPointerEXT" },
|
||||
{ (PROC)glIndexPointerEXT, "glIndexPointerEXT" },
|
||||
{ (PROC)glTexCoordPointerEXT, "glTexCoordPointer" },
|
||||
{ (PROC)glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT" },
|
||||
{ (PROC)glGetPointervEXT, "glGetPointervEXT" },
|
||||
{ (PROC)glArrayElementEXT, "glArrayElementEXT" },
|
||||
{ (PROC)glDrawArraysEXT, "glDrawArrayEXT" },
|
||||
{ (PROC)glAreTexturesResidentEXT, "glAreTexturesResidentEXT" },
|
||||
{ (PROC)glBindTextureEXT, "glBindTextureEXT" },
|
||||
{ (PROC)glDeleteTexturesEXT, "glDeleteTexturesEXT" },
|
||||
{ (PROC)glGenTexturesEXT, "glGenTexturesEXT" },
|
||||
{ (PROC)glIsTextureEXT, "glIsTextureEXT" },
|
||||
{ (PROC)glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT" },
|
||||
{ (PROC)glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT" },
|
||||
{ (PROC)glTexImage3DEXT, "glTexImage3DEXT" },
|
||||
{ (PROC)glTexSubImage3DEXT, "glTexSubImage3DEXT" },
|
||||
{ (PROC)glPointParameterfEXT, "glPointParameterfEXT" },
|
||||
{ (PROC)glPointParameterfvEXT, "glPointParameterfvEXT" },
|
||||
|
||||
{ (PROC)glLockArraysEXT, "glLockArraysEXT" },
|
||||
{ (PROC)glUnlockArraysEXT, "glUnlockArraysEXT" },
|
||||
{ NULL, "\0" }
|
||||
};
|
||||
|
||||
GLD_extension GLD_multitexList[] = {
|
||||
/*
|
||||
{ (PROC)glMultiTexCoord1dSGIS, "glMTexCoord1dSGIS" },
|
||||
{ (PROC)glMultiTexCoord1dvSGIS, "glMTexCoord1dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord1fSGIS, "glMTexCoord1fSGIS" },
|
||||
{ (PROC)glMultiTexCoord1fvSGIS, "glMTexCoord1fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord1iSGIS, "glMTexCoord1iSGIS" },
|
||||
{ (PROC)glMultiTexCoord1ivSGIS, "glMTexCoord1ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord1sSGIS, "glMTexCoord1sSGIS" },
|
||||
{ (PROC)glMultiTexCoord1svSGIS, "glMTexCoord1svSGIS" },
|
||||
{ (PROC)glMultiTexCoord2dSGIS, "glMTexCoord2dSGIS" },
|
||||
{ (PROC)glMultiTexCoord2dvSGIS, "glMTexCoord2dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord2fSGIS, "glMTexCoord2fSGIS" },
|
||||
{ (PROC)glMultiTexCoord2fvSGIS, "glMTexCoord2fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord2iSGIS, "glMTexCoord2iSGIS" },
|
||||
{ (PROC)glMultiTexCoord2ivSGIS, "glMTexCoord2ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord2sSGIS, "glMTexCoord2sSGIS" },
|
||||
{ (PROC)glMultiTexCoord2svSGIS, "glMTexCoord2svSGIS" },
|
||||
{ (PROC)glMultiTexCoord3dSGIS, "glMTexCoord3dSGIS" },
|
||||
{ (PROC)glMultiTexCoord3dvSGIS, "glMTexCoord3dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord3fSGIS, "glMTexCoord3fSGIS" },
|
||||
{ (PROC)glMultiTexCoord3fvSGIS, "glMTexCoord3fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord3iSGIS, "glMTexCoord3iSGIS" },
|
||||
{ (PROC)glMultiTexCoord3ivSGIS, "glMTexCoord3ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord3sSGIS, "glMTexCoord3sSGIS" },
|
||||
{ (PROC)glMultiTexCoord3svSGIS, "glMTexCoord3svSGIS" },
|
||||
{ (PROC)glMultiTexCoord4dSGIS, "glMTexCoord4dSGIS" },
|
||||
{ (PROC)glMultiTexCoord4dvSGIS, "glMTexCoord4dvSGIS" },
|
||||
{ (PROC)glMultiTexCoord4fSGIS, "glMTexCoord4fSGIS" },
|
||||
{ (PROC)glMultiTexCoord4fvSGIS, "glMTexCoord4fvSGIS" },
|
||||
{ (PROC)glMultiTexCoord4iSGIS, "glMTexCoord4iSGIS" },
|
||||
{ (PROC)glMultiTexCoord4ivSGIS, "glMTexCoord4ivSGIS" },
|
||||
{ (PROC)glMultiTexCoord4sSGIS, "glMTexCoord4sSGIS" },
|
||||
{ (PROC)glMultiTexCoord4svSGIS, "glMTexCoord4svSGIS" },
|
||||
{ (PROC)glMultiTexCoordPointerSGIS, "glMTexCoordPointerSGIS" },
|
||||
{ (PROC)glSelectTextureSGIS, "glSelectTextureSGIS" },
|
||||
{ (PROC)glSelectTextureCoordSetSGIS, "glSelectTextureCoordSetSGIS" },
|
||||
*/
|
||||
{ (PROC)glActiveTextureARB, "glActiveTextureARB" },
|
||||
{ (PROC)glClientActiveTextureARB, "glClientActiveTextureARB" },
|
||||
{ (PROC)glMultiTexCoord1dARB, "glMultiTexCoord1dARB" },
|
||||
{ (PROC)glMultiTexCoord1dvARB, "glMultiTexCoord1dvARB" },
|
||||
{ (PROC)glMultiTexCoord1fARB, "glMultiTexCoord1fARB" },
|
||||
{ (PROC)glMultiTexCoord1fvARB, "glMultiTexCoord1fvARB" },
|
||||
{ (PROC)glMultiTexCoord1iARB, "glMultiTexCoord1iARB" },
|
||||
{ (PROC)glMultiTexCoord1ivARB, "glMultiTexCoord1ivARB" },
|
||||
{ (PROC)glMultiTexCoord1sARB, "glMultiTexCoord1sARB" },
|
||||
{ (PROC)glMultiTexCoord1svARB, "glMultiTexCoord1svARB" },
|
||||
{ (PROC)glMultiTexCoord2dARB, "glMultiTexCoord2dARB" },
|
||||
{ (PROC)glMultiTexCoord2dvARB, "glMultiTexCoord2dvARB" },
|
||||
{ (PROC)glMultiTexCoord2fARB, "glMultiTexCoord2fARB" },
|
||||
{ (PROC)glMultiTexCoord2fvARB, "glMultiTexCoord2fvARB" },
|
||||
{ (PROC)glMultiTexCoord2iARB, "glMultiTexCoord2iARB" },
|
||||
{ (PROC)glMultiTexCoord2ivARB, "glMultiTexCoord2ivARB" },
|
||||
{ (PROC)glMultiTexCoord2sARB, "glMultiTexCoord2sARB" },
|
||||
{ (PROC)glMultiTexCoord2svARB, "glMultiTexCoord2svARB" },
|
||||
{ (PROC)glMultiTexCoord3dARB, "glMultiTexCoord3dARB" },
|
||||
{ (PROC)glMultiTexCoord3dvARB, "glMultiTexCoord3dvARB" },
|
||||
{ (PROC)glMultiTexCoord3fARB, "glMultiTexCoord3fARB" },
|
||||
{ (PROC)glMultiTexCoord3fvARB, "glMultiTexCoord3fvARB" },
|
||||
{ (PROC)glMultiTexCoord3iARB, "glMultiTexCoord3iARB" },
|
||||
{ (PROC)glMultiTexCoord3ivARB, "glMultiTexCoord3ivARB" },
|
||||
{ (PROC)glMultiTexCoord3sARB, "glMultiTexCoord3sARB" },
|
||||
{ (PROC)glMultiTexCoord3svARB, "glMultiTexCoord3svARB" },
|
||||
{ (PROC)glMultiTexCoord4dARB, "glMultiTexCoord4dARB" },
|
||||
{ (PROC)glMultiTexCoord4dvARB, "glMultiTexCoord4dvARB" },
|
||||
{ (PROC)glMultiTexCoord4fARB, "glMultiTexCoord4fARB" },
|
||||
{ (PROC)glMultiTexCoord4fvARB, "glMultiTexCoord4fvARB" },
|
||||
{ (PROC)glMultiTexCoord4iARB, "glMultiTexCoord4iARB" },
|
||||
{ (PROC)glMultiTexCoord4ivARB, "glMultiTexCoord4ivARB" },
|
||||
{ (PROC)glMultiTexCoord4sARB, "glMultiTexCoord4sARB" },
|
||||
{ (PROC)glMultiTexCoord4svARB, "glMultiTexCoord4svARB" },
|
||||
|
||||
// Descent3 doesn't use correct string, hence this hack
|
||||
{ (PROC)glMultiTexCoord4fARB, "glMultiTexCoord4f" },
|
||||
|
||||
// Quake2 SGIS multitexture
|
||||
{ (PROC)gldSelectTextureSGIS, "glSelectTextureSGIS" },
|
||||
{ (PROC)gldMTexCoord2fSGIS, "glMTexCoord2fSGIS" },
|
||||
{ (PROC)gldMTexCoord2fvSGIS, "glMTexCoord2fvSGIS" },
|
||||
|
||||
{ NULL, "\0" }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
PROC gldGetProcAddress_DX(
|
||||
LPCSTR a)
|
||||
{
|
||||
int i;
|
||||
PROC proc = NULL;
|
||||
|
||||
for (i=0; GLD_extList[i].proc; i++) {
|
||||
if (!strcmp(a, GLD_extList[i].name)) {
|
||||
proc = GLD_extList[i].proc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (glb.bMultitexture) {
|
||||
for (i=0; GLD_multitexList[i].proc; i++) {
|
||||
if (!strcmp(a, GLD_multitexList[i].name)) {
|
||||
proc = GLD_multitexList[i].proc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gldLogPrintf(GLDLOG_INFO, "GetProcAddress: %s (%s)", a, proc ? "OK" : "Failed");
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void gldEnableExtensions_DX9(
|
||||
GLcontext *ctx)
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
// Mesa enables some extensions by default.
|
||||
// This table decides which ones we want to switch off again.
|
||||
|
||||
// NOTE: GL_EXT_compiled_vertex_array appears broken.
|
||||
|
||||
const char *gld_disable_extensions[] = {
|
||||
// "GL_ARB_transpose_matrix",
|
||||
// "GL_EXT_compiled_vertex_array",
|
||||
// "GL_EXT_polygon_offset",
|
||||
// "GL_EXT_rescale_normal",
|
||||
"GL_EXT_texture3D",
|
||||
// "GL_NV_texgen_reflection",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *gld_multitex_extensions[] = {
|
||||
"GL_ARB_multitexture", // Quake 3
|
||||
NULL
|
||||
};
|
||||
|
||||
// Quake 2 engines
|
||||
const char *szGL_SGIS_multitexture = "GL_SGIS_multitexture";
|
||||
|
||||
const char *gld_enable_extensions[] = {
|
||||
"GL_EXT_texture_env_add", // Quake 3
|
||||
"GL_ARB_texture_env_add", // Quake 3
|
||||
NULL
|
||||
};
|
||||
|
||||
for (i=0; gld_disable_extensions[i]; i++) {
|
||||
_mesa_disable_extension(ctx, gld_disable_extensions[i]);
|
||||
}
|
||||
|
||||
for (i=0; gld_enable_extensions[i]; i++) {
|
||||
_mesa_enable_extension(ctx, gld_enable_extensions[i]);
|
||||
}
|
||||
|
||||
if (glb.bMultitexture) {
|
||||
for (i=0; gld_multitex_extensions[i]; i++) {
|
||||
_mesa_enable_extension(ctx, gld_multitex_extensions[i]);
|
||||
}
|
||||
|
||||
// GL_SGIS_multitexture
|
||||
// NOTE: Quake2 ran *slower* with this enabled, so I've
|
||||
// disabled it for now.
|
||||
// Fair bit slower on GeForce256,
|
||||
// Much slower on 3dfx Voodoo5 5500.
|
||||
// _mesa_add_extension(ctx, GL_TRUE, szGL_SGIS_multitexture, 0);
|
||||
|
||||
}
|
||||
|
||||
_mesa_enable_imaging_extensions(ctx);
|
||||
_mesa_enable_1_3_extensions(ctx);
|
||||
_mesa_enable_1_4_extensions(ctx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: Mesa transformation pipeline with GLDirect fastpath
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx9.h"
|
||||
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
extern struct tnl_pipeline_stage _gld_d3d_render_stage;
|
||||
extern struct tnl_pipeline_stage _gld_mesa_render_stage;
|
||||
|
||||
static const struct tnl_pipeline_stage *gld_pipeline[] = {
|
||||
&_gld_d3d_render_stage, // Direct3D TnL
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
&_tnl_fog_coordinate_stage, /* TODO: Omit fog stage. ??? */
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
&_tnl_point_attenuation_stage,
|
||||
&_gld_mesa_render_stage, // Mesa TnL, D3D rendering
|
||||
0,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void gldInstallPipeline_DX9(
|
||||
GLcontext *ctx)
|
||||
{
|
||||
// Remove any existing pipeline stages,
|
||||
// then install GLDirect pipeline stages.
|
||||
|
||||
_tnl_destroy_pipeline(ctx);
|
||||
_tnl_install_pipeline(ctx, gld_pipeline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,263 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Mesa 3-D graphics library
|
||||
* Direct3D Driver Interface
|
||||
*
|
||||
* ========================================================================
|
||||
*
|
||||
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SCITECH SOFTWARE INC 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.
|
||||
*
|
||||
* ======================================================================
|
||||
*
|
||||
* Language: ANSI C
|
||||
* Environment: Windows 9x/2000/XP/XBox (Win32)
|
||||
*
|
||||
* Description: GLDirect fastpath pipeline stage
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//#include "../GLDirect.h"
|
||||
//#include "../gld_log.h"
|
||||
//#include "gld_dx8.h"
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx9.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
// #include "mem.h"
|
||||
#include "mtypes.h"
|
||||
//#include "mmath.h"
|
||||
|
||||
#include "math/m_matrix.h"
|
||||
#include "math/m_xform.h"
|
||||
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
__inline void _gldSetVertexShaderConstants(
|
||||
GLcontext *ctx,
|
||||
GLD_driver_dx9 *gld)
|
||||
{
|
||||
D3DXMATRIX mat, matView, matProj;
|
||||
GLfloat *pM;
|
||||
|
||||
// Mesa 5: Altered to a Stack
|
||||
//pM = ctx->ModelView.m;
|
||||
pM = ctx->ModelviewMatrixStack.Top->m;
|
||||
matView._11 = pM[0];
|
||||
matView._12 = pM[1];
|
||||
matView._13 = pM[2];
|
||||
matView._14 = pM[3];
|
||||
matView._21 = pM[4];
|
||||
matView._22 = pM[5];
|
||||
matView._23 = pM[6];
|
||||
matView._24 = pM[7];
|
||||
matView._31 = pM[8];
|
||||
matView._32 = pM[9];
|
||||
matView._33 = pM[10];
|
||||
matView._34 = pM[11];
|
||||
matView._41 = pM[12];
|
||||
matView._42 = pM[13];
|
||||
matView._43 = pM[14];
|
||||
matView._44 = pM[15];
|
||||
|
||||
// Mesa 5: Altered to a Stack
|
||||
//pM = ctx->ProjectionMatrix.m;
|
||||
pM = ctx->ProjectionMatrixStack.Top->m;
|
||||
matProj._11 = pM[0];
|
||||
matProj._12 = pM[1];
|
||||
matProj._13 = pM[2];
|
||||
matProj._14 = pM[3];
|
||||
matProj._21 = pM[4];
|
||||
matProj._22 = pM[5];
|
||||
matProj._23 = pM[6];
|
||||
matProj._24 = pM[7];
|
||||
matProj._31 = pM[8];
|
||||
matProj._32 = pM[9];
|
||||
matProj._33 = pM[10];
|
||||
matProj._34 = pM[11];
|
||||
matProj._41 = pM[12];
|
||||
matProj._42 = pM[13];
|
||||
matProj._43 = pM[14];
|
||||
matProj._44 = pM[15];
|
||||
|
||||
D3DXMatrixMultiply( &mat, &matView, &matProj );
|
||||
D3DXMatrixTranspose( &mat, &mat );
|
||||
|
||||
_GLD_DX9_DEV(SetVertexShaderConstantF(gld->pDev, 0, (float*)&mat, 4));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static GLboolean gld_d3d_render_stage_run(
|
||||
GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
|
||||
GLD_driver_dx9 *gld = GLD_GET_DX9_DRIVER(gldCtx);
|
||||
|
||||
TNLcontext *tnl;
|
||||
struct vertex_buffer *VB;
|
||||
tnl_render_func *tab;
|
||||
GLint pass;
|
||||
GLD_pb_dx9 *gldPB = &gld->PB3d;
|
||||
/*
|
||||
static int count = 0;
|
||||
count++;
|
||||
if (count != 2)
|
||||
return GL_FALSE;
|
||||
*/
|
||||
// The "check" function should disable this stage,
|
||||
// but we'll test gld->bUseMesaTnL anyway.
|
||||
if (gld->bUseMesaTnL) {
|
||||
// Do nothing in this stage, but continue pipeline
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
tnl = TNL_CONTEXT(ctx);
|
||||
VB = &tnl->vb;
|
||||
pass = 0;
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
#if 0
|
||||
// For debugging: Useful to see if an app passes colour data in
|
||||
// an unusual format.
|
||||
switch (VB->ColorPtr[0]->Type) {
|
||||
case GL_FLOAT:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_FLOAT\n");
|
||||
break;
|
||||
case GL_UNSIGNED_BYTE:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_UNSIGNED_BYTE\n");
|
||||
break;
|
||||
default:
|
||||
ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: *?*\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
tnl->Driver.Render.Points = gld_Points3D_DX9;
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
tnl->Driver.Render.Line = gld_Line3DFlat_DX9;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle3DFlat_DX9;
|
||||
tnl->Driver.Render.Quad = gld_Quad3DFlat_DX9;
|
||||
} else {
|
||||
tnl->Driver.Render.Line = gld_Line3DSmooth_DX9;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle3DSmooth_DX9;
|
||||
tnl->Driver.Render.Quad = gld_Quad3DSmooth_DX9;
|
||||
}
|
||||
|
||||
_GLD_DX9_VB(Lock(gldPB->pVB, 0, 0, &gldPB->pPoints, D3DLOCK_DISCARD));
|
||||
gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0;
|
||||
// Allocate primitive pointers
|
||||
// gldPB->pPoints is always first
|
||||
gldPB->pLines = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine);
|
||||
gldPB->pTriangles = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle);
|
||||
|
||||
ASSERT(tnl->Driver.Render.BuildVertices);
|
||||
ASSERT(tnl->Driver.Render.PrimitiveNotify);
|
||||
ASSERT(tnl->Driver.Render.Points);
|
||||
ASSERT(tnl->Driver.Render.Line);
|
||||
ASSERT(tnl->Driver.Render.Triangle);
|
||||
ASSERT(tnl->Driver.Render.Quad);
|
||||
ASSERT(tnl->Driver.Render.ResetLineStipple);
|
||||
ASSERT(tnl->Driver.Render.Interp);
|
||||
ASSERT(tnl->Driver.Render.CopyPV);
|
||||
ASSERT(tnl->Driver.Render.ClippedLine);
|
||||
ASSERT(tnl->Driver.Render.ClippedPolygon);
|
||||
ASSERT(tnl->Driver.Render.Finish);
|
||||
|
||||
tab = (VB->Elts ? tnl->Driver.Render.PrimTabElts : tnl->Driver.Render.PrimTabVerts);
|
||||
|
||||
do {
|
||||
GLuint i, length, flags = 0;
|
||||
for (i = 0 ; !(flags & PRIM_END) ; i += length)
|
||||
{
|
||||
flags = VB->Primitive[i].mode;
|
||||
length= VB->Primitive[i].count;
|
||||
ASSERT(length || (flags & PRIM_END));
|
||||
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
|
||||
if (length)
|
||||
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
|
||||
}
|
||||
} while (tnl->Driver.Render.Multipass &&
|
||||
tnl->Driver.Render.Multipass( ctx, ++pass ));
|
||||
|
||||
_GLD_DX9_VB(Unlock(gldPB->pVB));
|
||||
|
||||
_GLD_DX9_DEV(SetStreamSource(gld->pDev, 0, gldPB->pVB, 0, gldPB->dwStride));
|
||||
|
||||
_GLD_DX9_DEV(SetTransform(gld->pDev, D3DTS_PROJECTION, &gld->matProjection));
|
||||
_GLD_DX9_DEV(SetTransform(gld->pDev, D3DTS_WORLD, &gld->matModelView));
|
||||
|
||||
if (gldPB->nPoints) {
|
||||
_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_POINTLIST, 0, gldPB->nPoints));
|
||||
gldPB->nPoints = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nLines) {
|
||||
_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_LINELIST, gldPB->iFirstLine, gldPB->nLines));
|
||||
gldPB->nLines = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nTriangles) {
|
||||
_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_TRIANGLELIST, gldPB->iFirstTriangle, gldPB->nTriangles));
|
||||
gldPB->nTriangles = 0;
|
||||
}
|
||||
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void gld_d3d_render_stage_check(
|
||||
GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
|
||||
GLD_driver_dx9 *gld = GLD_GET_DX9_DRIVER(gldCtx);
|
||||
// Is this thread safe?
|
||||
stage->active = (gld->bUseMesaTnL) ? GL_FALSE : GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const struct tnl_pipeline_stage _gld_d3d_render_stage =
|
||||
{
|
||||
"gld_d3d_render_stage",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
gld_d3d_render_stage_run /* run */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
@@ -1,443 +0,0 @@
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL 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:
|
||||
* Keith Whitwell <keithw@valinux.com>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Render whole vertex buffers, including projection of vertices from
|
||||
* clip space and clipping of primitives.
|
||||
*
|
||||
* This file makes calls to project vertices and to the point, line
|
||||
* and triangle rasterizers via the function pointers:
|
||||
*
|
||||
* context->Driver.Render.*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "dglcontext.h"
|
||||
#include "ddlog.h"
|
||||
#include "gld_dx9.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
//#include "mmath.h"
|
||||
|
||||
#include "math/m_matrix.h"
|
||||
#include "math/m_xform.h"
|
||||
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip single primitives */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#if defined(USE_IEEE)
|
||||
#define NEGATIVE(x) (GET_FLOAT_BITS(x) & (1<<31))
|
||||
//#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
|
||||
#else
|
||||
#define NEGATIVE(x) (x < 0)
|
||||
//#define DIFFERENT_SIGNS(x,y) (x * y <= 0 && x - y != 0)
|
||||
/* Could just use (x*y<0) except for the flatshading requirements.
|
||||
* Maybe there's a better way?
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#define W(i) coord[i][3]
|
||||
#define Z(i) coord[i][2]
|
||||
#define Y(i) coord[i][1]
|
||||
#define X(i) coord[i][0]
|
||||
#define SIZE 4
|
||||
#define TAG(x) x##_4
|
||||
#include "tnl/t_vb_cliptmp.h"
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip and render whole begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
|
||||
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
|
||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
||||
|
||||
|
||||
/* Vertices, with the possibility of clipping.
|
||||
*/
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
tnl->Driver.Render.Points( ctx, start, count )
|
||||
|
||||
#define RENDER_LINE( v1, v2 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2]; \
|
||||
GLubyte ormask = c1|c2; \
|
||||
if (!ormask) \
|
||||
LineFunc( ctx, v1, v2 ); \
|
||||
else if (!(c1 & c2 & 0x3f)) \
|
||||
clip_line_4( ctx, v1, v2, ormask ); \
|
||||
} while (0)
|
||||
|
||||
#define RENDER_TRI( v1, v2, v3 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2], c3 = mask[v3]; \
|
||||
GLubyte ormask = c1|c2|c3; \
|
||||
if (!ormask) \
|
||||
TriangleFunc( ctx, v1, v2, v3 ); \
|
||||
else if (!(c1 & c2 & c3 & 0x3f)) \
|
||||
clip_tri_4( ctx, v1, v2, v3, ormask ); \
|
||||
} while (0)
|
||||
|
||||
#define RENDER_QUAD( v1, v2, v3, v4 ) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2]; \
|
||||
GLubyte c3 = mask[v3], c4 = mask[v4]; \
|
||||
GLubyte ormask = c1|c2|c3|c4; \
|
||||
if (!ormask) \
|
||||
QuadFunc( ctx, v1, v2, v3, v4 ); \
|
||||
else if (!(c1 & c2 & c3 & c4 & 0x3f)) \
|
||||
clip_quad_4( ctx, v1, v2, v3, v4, ormask ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LOCAL_VARS \
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx); \
|
||||
struct vertex_buffer *VB = &tnl->vb; \
|
||||
const GLuint * const elt = VB->Elts; \
|
||||
const GLubyte *mask = VB->ClipMask; \
|
||||
const GLuint sz = VB->ClipPtr->size; \
|
||||
const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
|
||||
const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
|
||||
const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
|
||||
const GLboolean stipple = ctx->Line.StippleFlag; \
|
||||
(void) (LineFunc && TriangleFunc && QuadFunc); \
|
||||
(void) elt; (void) mask; (void) sz; (void) stipple;
|
||||
|
||||
#define TAG(x) clip_##x##_verts
|
||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
||||
#define PRESERVE_VB_DEFS
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
|
||||
/* Elts, with the possibility of clipping.
|
||||
*/
|
||||
#undef ELT
|
||||
#undef TAG
|
||||
#define ELT(x) elt[x]
|
||||
#define TAG(x) clip_##x##_elts
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
/* TODO: do this for all primitives, verts and elts:
|
||||
*/
|
||||
static void clip_elt_triangles( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl_render_func render_tris = tnl->Driver.Render.PrimTabElts[GL_TRIANGLES];
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
const GLuint * const elt = VB->Elts;
|
||||
GLubyte *mask = VB->ClipMask;
|
||||
GLuint last = count-2;
|
||||
GLuint j;
|
||||
(void) flags;
|
||||
|
||||
tnl->Driver.Render.PrimitiveNotify( ctx, GL_TRIANGLES );
|
||||
|
||||
for (j=start; j < last; j+=3 ) {
|
||||
GLubyte c1 = mask[elt[j]];
|
||||
GLubyte c2 = mask[elt[j+1]];
|
||||
GLubyte c3 = mask[elt[j+2]];
|
||||
GLubyte ormask = c1|c2|c3;
|
||||
if (ormask) {
|
||||
if (start < j)
|
||||
render_tris( ctx, start, j, 0 );
|
||||
if (!(c1&c2&c3&0x3f))
|
||||
clip_tri_4( ctx, elt[j], elt[j+1], elt[j+2], ormask );
|
||||
start = j+3;
|
||||
}
|
||||
}
|
||||
|
||||
if (start < j)
|
||||
render_tris( ctx, start, j, 0 );
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render whole begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
|
||||
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
|
||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
||||
|
||||
|
||||
/* Vertices, no clipping.
|
||||
*/
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
tnl->Driver.Render.Points( ctx, start, count )
|
||||
|
||||
#define RENDER_LINE( v1, v2 ) \
|
||||
LineFunc( ctx, v1, v2 )
|
||||
|
||||
#define RENDER_TRI( v1, v2, v3 ) \
|
||||
TriangleFunc( ctx, v1, v2, v3 )
|
||||
|
||||
#define RENDER_QUAD( v1, v2, v3, v4 ) \
|
||||
QuadFunc( ctx, v1, v2, v3, v4 )
|
||||
|
||||
#define TAG(x) _gld_tnl_##x##_verts
|
||||
|
||||
#define LOCAL_VARS \
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx); \
|
||||
struct vertex_buffer *VB = &tnl->vb; \
|
||||
const GLuint * const elt = VB->Elts; \
|
||||
const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
|
||||
const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
|
||||
const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
|
||||
(void) (LineFunc && TriangleFunc && QuadFunc); \
|
||||
(void) elt;
|
||||
|
||||
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||
#define RENDER_TAB_QUALIFIER
|
||||
#define PRESERVE_VB_DEFS
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
/* Elts, no clipping.
|
||||
*/
|
||||
#undef ELT
|
||||
#define TAG(x) _gld_tnl_##x##_elts
|
||||
#define ELT(x) elt[x]
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Helper functions for drivers */
|
||||
/**********************************************************************/
|
||||
/*
|
||||
void _tnl_RenderClippedPolygon( GLcontext *ctx, const GLuint *elts, GLuint n )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint *tmp = VB->Elts;
|
||||
|
||||
VB->Elts = (GLuint *)elts;
|
||||
tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
|
||||
VB->Elts = tmp;
|
||||
}
|
||||
|
||||
void _tnl_RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.Line( ctx, ii, jj );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip and render whole vertex buffers */
|
||||
/**********************************************************************/
|
||||
|
||||
tnl_points_func _gldSetupPoints[4] = {
|
||||
gld_Points2D_DX9,
|
||||
gld_Points2D_DX9,
|
||||
gld_Points2D_DX9,
|
||||
gld_Points2D_DX9
|
||||
};
|
||||
tnl_line_func _gldSetupLine[4] = {
|
||||
gld_Line2DFlat_DX9,
|
||||
gld_Line2DSmooth_DX9,
|
||||
gld_Line2DFlat_DX9,
|
||||
gld_Line2DSmooth_DX9,
|
||||
};
|
||||
tnl_triangle_func _gldSetupTriangle[4] = {
|
||||
gld_Triangle2DFlat_DX9,
|
||||
gld_Triangle2DSmooth_DX9,
|
||||
gld_Triangle2DFlatExtras_DX9,
|
||||
gld_Triangle2DSmoothExtras_DX9
|
||||
};
|
||||
tnl_quad_func _gldSetupQuad[4] = {
|
||||
gld_Quad2DFlat_DX9,
|
||||
gld_Quad2DSmooth_DX9,
|
||||
gld_Quad2DFlatExtras_DX9,
|
||||
gld_Quad2DSmoothExtras_DX9
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static GLboolean _gld_mesa_render_stage_run(
|
||||
GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
|
||||
GLD_driver_dx9 *gld = GLD_GET_DX9_DRIVER(gldCtx);
|
||||
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
tnl_render_func *tab;
|
||||
GLint pass = 0;
|
||||
GLD_pb_dx9 *gldPB;
|
||||
|
||||
/* Allow the drivers to lock before projected verts are built so
|
||||
* that window coordinates are guarenteed not to change before
|
||||
* rendering.
|
||||
*/
|
||||
ASSERT(tnl->Driver.Render.Start);
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
// NOTE: Setting D3DRS_SOFTWAREVERTEXPROCESSING for a mixed-mode device resets
|
||||
// stream, indices and shader to default values of NULL or 0.
|
||||
/* if ((ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) &&
|
||||
gld->VStwosidelight.hShader &&
|
||||
!ctx->Fog.Enabled)
|
||||
{
|
||||
IDirect3DDevice8_SetRenderState(gld->pDev, D3DRS_SOFTWAREVERTEXPROCESSING, !gld->VStwosidelight.bHardware);
|
||||
_GLD_DX9_DEV(SetVertexShader(gld->pDev, gld->VStwosidelight.hShader));
|
||||
gldPB = &gld->PBtwosidelight;
|
||||
tnl->Driver.Render.Points = gld_Points2DTwoside_DX9;
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
tnl->Driver.Render.Line = gld_Line2DFlatTwoside_DX9;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle2DFlatTwoside_DX9;
|
||||
tnl->Driver.Render.Quad = gld_Quad2DFlatTwoside_DX9;
|
||||
} else {
|
||||
tnl->Driver.Render.Line = gld_Line2DSmoothTwoside_DX9;
|
||||
tnl->Driver.Render.Triangle = gld_Triangle2DSmoothTwoside_DX9;
|
||||
tnl->Driver.Render.Quad = gld_Quad2DSmoothTwoside_DX9;
|
||||
}
|
||||
} else {*/
|
||||
// IDirect3DDevice8_SetRenderState(gld->pDev, D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
|
||||
IDirect3DDevice9_SetSoftwareVertexProcessing(gld->pDev, TRUE);
|
||||
gldPB = &gld->PB2d;
|
||||
_GLD_DX9_DEV(SetVertexShader(gld->pDev, NULL));
|
||||
_GLD_DX9_DEV(SetFVF(gld->pDev, gldPB->dwFVF));
|
||||
tnl->Driver.Render.Points = _gldSetupPoints[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Line = _gldSetupLine[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Triangle = _gldSetupTriangle[gld->iSetupFunc];
|
||||
tnl->Driver.Render.Quad = _gldSetupQuad[gld->iSetupFunc];
|
||||
// }
|
||||
|
||||
_GLD_DX9_VB(Lock(gldPB->pVB, 0, 0, &gldPB->pPoints, D3DLOCK_DISCARD));
|
||||
gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0;
|
||||
// Allocate primitive pointers
|
||||
// gldPB->pPoints is always first
|
||||
gldPB->pLines = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine);
|
||||
gldPB->pTriangles = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle);
|
||||
|
||||
ASSERT(tnl->Driver.Render.BuildVertices);
|
||||
ASSERT(tnl->Driver.Render.PrimitiveNotify);
|
||||
ASSERT(tnl->Driver.Render.Points);
|
||||
ASSERT(tnl->Driver.Render.Line);
|
||||
ASSERT(tnl->Driver.Render.Triangle);
|
||||
ASSERT(tnl->Driver.Render.Quad);
|
||||
ASSERT(tnl->Driver.Render.ResetLineStipple);
|
||||
ASSERT(tnl->Driver.Render.Interp);
|
||||
ASSERT(tnl->Driver.Render.CopyPV);
|
||||
ASSERT(tnl->Driver.Render.ClippedLine);
|
||||
ASSERT(tnl->Driver.Render.ClippedPolygon);
|
||||
ASSERT(tnl->Driver.Render.Finish);
|
||||
|
||||
tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 );
|
||||
|
||||
if (VB->ClipOrMask) {
|
||||
tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts;
|
||||
clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles;
|
||||
}
|
||||
else {
|
||||
tab = (VB->Elts ?
|
||||
tnl->Driver.Render.PrimTabElts :
|
||||
tnl->Driver.Render.PrimTabVerts);
|
||||
}
|
||||
|
||||
do {
|
||||
GLuint i, length, flags = 0;
|
||||
for (i = 0 ; !(flags & PRIM_END) ; i += length) {
|
||||
flags = VB->Primitive[i].mode;
|
||||
length= VB->Primitive[i].count;
|
||||
ASSERT(length || (flags & PRIM_END));
|
||||
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
|
||||
if (length)
|
||||
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
|
||||
}
|
||||
} while (tnl->Driver.Render.Multipass &&
|
||||
tnl->Driver.Render.Multipass( ctx, ++pass ));
|
||||
|
||||
|
||||
// tnl->Driver.Render.Finish( ctx );
|
||||
|
||||
_GLD_DX9_VB(Unlock(gldPB->pVB));
|
||||
|
||||
_GLD_DX9_DEV(SetStreamSource(gld->pDev, 0, gldPB->pVB, 0, gldPB->dwStride));
|
||||
|
||||
if (gldPB->nPoints) {
|
||||
_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_POINTLIST, 0, gldPB->nPoints));
|
||||
gldPB->nPoints = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nLines) {
|
||||
_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_LINELIST, gldPB->iFirstLine, gldPB->nLines));
|
||||
gldPB->nLines = 0;
|
||||
}
|
||||
|
||||
if (gldPB->nTriangles) {
|
||||
_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_TRIANGLELIST, gldPB->iFirstTriangle, gldPB->nTriangles));
|
||||
gldPB->nTriangles = 0;
|
||||
}
|
||||
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render pipeline stage */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
const struct tnl_pipeline_stage _gld_mesa_render_stage =
|
||||
{
|
||||
"gld_mesa_render_stage",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
_gld_mesa_render_stage_run /* run */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
File diff suppressed because it is too large
Load Diff
@@ -298,6 +298,10 @@ _glthread_GetTSD(_glthread_TSD *);
|
||||
extern void
|
||||
_glthread_SetTSD(_glthread_TSD *, void *);
|
||||
|
||||
#if !defined __GNUC__ || __GNUC__ < 3
|
||||
# define __builtin_expect(x, y) x
|
||||
#endif
|
||||
|
||||
#if defined(GLX_USE_TLS)
|
||||
|
||||
extern __thread struct _glapi_table * _glapi_tls_Dispatch
|
||||
|
@@ -78,6 +78,23 @@ max_buffer_index(GLcontext *ctx, GLuint count, GLenum type,
|
||||
return max;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
check_valid_to_render(GLcontext *ctx, char *function)
|
||||
{
|
||||
if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
_mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
|
||||
"glDraw%s(incomplete framebuffer)", function);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Always need vertex positions, unless a vertex program is in use */
|
||||
if (!ctx->VertexProgram._Current &&
|
||||
!ctx->Array.ArrayObj->Vertex.Enabled &&
|
||||
!ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
|
||||
return GL_FALSE;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
_mesa_validate_DrawElements(GLcontext *ctx,
|
||||
@@ -108,10 +125,7 @@ _mesa_validate_DrawElements(GLcontext *ctx,
|
||||
if (ctx->NewState)
|
||||
_mesa_update_state(ctx);
|
||||
|
||||
/* Always need vertex positions, unless a vertex program is in use */
|
||||
if (!ctx->VertexProgram._Current &&
|
||||
!ctx->Array.ArrayObj->Vertex.Enabled &&
|
||||
!ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
|
||||
if (!check_valid_to_render(ctx, "Elements"))
|
||||
return GL_FALSE;
|
||||
|
||||
/* Vertex buffer object tests */
|
||||
@@ -155,7 +169,6 @@ _mesa_validate_DrawElements(GLcontext *ctx,
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
GLboolean
|
||||
_mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
|
||||
GLuint start, GLuint end,
|
||||
@@ -190,10 +203,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
|
||||
if (ctx->NewState)
|
||||
_mesa_update_state(ctx);
|
||||
|
||||
/* Always need vertex positions, unless a vertex program is in use */
|
||||
if (!ctx->VertexProgram._Current &&
|
||||
!ctx->Array.ArrayObj->Vertex.Enabled &&
|
||||
!ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
|
||||
if (!check_valid_to_render(ctx, "RangeElements"))
|
||||
return GL_FALSE;
|
||||
|
||||
/* Vertex buffer object tests */
|
||||
@@ -261,10 +271,7 @@ _mesa_validate_DrawArrays(GLcontext *ctx,
|
||||
if (ctx->NewState)
|
||||
_mesa_update_state(ctx);
|
||||
|
||||
/* Always need vertex positions, unless a vertex program is in use */
|
||||
if (!ctx->VertexProgram._Current &&
|
||||
!ctx->Array.ArrayObj->Vertex.Enabled &&
|
||||
!ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
|
||||
if (!check_valid_to_render(ctx, "Arrays"))
|
||||
return GL_FALSE;
|
||||
|
||||
if (ctx->Const.CheckArrayBounds) {
|
||||
|
@@ -195,6 +195,10 @@ do { \
|
||||
#define PACK_COLOR_565_REV( X, Y, Z ) \
|
||||
(((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5))
|
||||
|
||||
#define PACK_COLOR_5551( R, G, B, A ) \
|
||||
((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \
|
||||
((A) ? 1 : 0))
|
||||
|
||||
#define PACK_COLOR_1555( A, B, G, R ) \
|
||||
((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \
|
||||
((A) ? 0x8000 : 0))
|
||||
|
@@ -341,10 +341,6 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
|
||||
ctx->Transform.CullVertexFlag = state;
|
||||
break;
|
||||
case GL_DEPTH_TEST:
|
||||
if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
|
||||
_mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
|
||||
return;
|
||||
}
|
||||
if (ctx->Depth.Test == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_DEPTH);
|
||||
|
@@ -146,7 +146,8 @@
|
||||
#include <byteswap.h>
|
||||
#define CPU_TO_LE32( x ) bswap_32( x )
|
||||
#else /*__linux__*/
|
||||
#define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
|
||||
#include <sys/endian.h>
|
||||
#define CPU_TO_LE32( x ) bswap32( x )
|
||||
#endif /*__linux__*/
|
||||
#define MESA_BIG_ENDIAN 1
|
||||
#else
|
||||
|
@@ -208,7 +208,8 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
|
||||
if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
|
||||
_math_matrix_analyse(ctx->ModelviewMatrixStack.Top);
|
||||
}
|
||||
TRANSFORM_NORMAL(temp, params, ctx->ModelviewMatrixStack.Top->inv);
|
||||
TRANSFORM_DIRECTION(temp, params, ctx->ModelviewMatrixStack.Top->m);
|
||||
NORMALIZE_3FV(temp);
|
||||
params = temp;
|
||||
break;
|
||||
case GL_SPOT_EXPONENT:
|
||||
|
@@ -2094,6 +2094,13 @@ struct gl_query_state
|
||||
};
|
||||
|
||||
|
||||
/** Set by #pragma directives */
|
||||
struct gl_sl_pragmas
|
||||
{
|
||||
GLboolean Optimize; /**< defaults on */
|
||||
GLboolean Debug; /**< defaults off */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A GLSL vertex or fragment shader object.
|
||||
@@ -2104,12 +2111,12 @@ struct gl_shader
|
||||
GLuint Name; /**< AKA the handle */
|
||||
GLint RefCount; /**< Reference count */
|
||||
GLboolean DeletePending;
|
||||
|
||||
const GLchar *Source; /**< Source code string */
|
||||
GLboolean CompileStatus;
|
||||
GLboolean Main; /**< shader defines main() */
|
||||
const GLchar *Source; /**< Source code string */
|
||||
struct gl_program *Program; /**< Post-compile assembly code */
|
||||
GLchar *InfoLog;
|
||||
GLboolean Main; /**< shader defines main() */
|
||||
struct gl_sl_pragmas Pragmas;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -871,6 +871,30 @@ const struct gl_texture_format _mesa_texformat_rgb565_rev = {
|
||||
store_texel_rgb565_rev /* StoreTexel */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba4444 = {
|
||||
MESA_FORMAT_RGBA4444, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /* RedBits */
|
||||
4, /* GreenBits */
|
||||
4, /* BlueBits */
|
||||
4, /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* StencilBits */
|
||||
2, /* TexelBytes */
|
||||
_mesa_texstore_rgba4444, /* StoreTexImageFunc */
|
||||
fetch_texel_1d_rgba4444, /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba4444, /* FetchTexel2D */
|
||||
fetch_texel_3d_rgba4444, /* FetchTexel3D */
|
||||
NULL, /* FetchTexel1Df */
|
||||
NULL, /* FetchTexel2Df */
|
||||
NULL, /* FetchTexel3Df */
|
||||
store_texel_rgba4444 /* StoreTexel */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_argb4444 = {
|
||||
MESA_FORMAT_ARGB4444, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
@@ -919,6 +943,30 @@ const struct gl_texture_format _mesa_texformat_argb4444_rev = {
|
||||
store_texel_argb4444_rev /* StoreTexel */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba5551 = {
|
||||
MESA_FORMAT_RGBA5551, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
5, /* RedBits */
|
||||
5, /* GreenBits */
|
||||
5, /* BlueBits */
|
||||
1, /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* StencilBits */
|
||||
2, /* TexelBytes */
|
||||
_mesa_texstore_rgba5551, /* StoreTexImageFunc */
|
||||
fetch_texel_1d_rgba5551, /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba5551, /* FetchTexel2D */
|
||||
fetch_texel_3d_rgba5551, /* FetchTexel3D */
|
||||
NULL, /* FetchTexel1Df */
|
||||
NULL, /* FetchTexel2Df */
|
||||
NULL, /* FetchTexel3Df */
|
||||
store_texel_rgba5551 /* StoreTexel */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_argb1555 = {
|
||||
MESA_FORMAT_ARGB1555, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
|
@@ -70,8 +70,10 @@ enum _format {
|
||||
MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
|
||||
MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
|
||||
MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */
|
||||
MESA_FORMAT_RGBA4444, /* RRRR GGGG BBBB AAAA */
|
||||
MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
|
||||
MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */
|
||||
MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */
|
||||
MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
|
||||
MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */
|
||||
MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
|
||||
@@ -200,10 +202,12 @@ extern const struct gl_texture_format _mesa_texformat_rgb888;
|
||||
extern const struct gl_texture_format _mesa_texformat_bgr888;
|
||||
extern const struct gl_texture_format _mesa_texformat_rgb565;
|
||||
extern const struct gl_texture_format _mesa_texformat_rgb565_rev;
|
||||
extern const struct gl_texture_format _mesa_texformat_rgba4444;
|
||||
extern const struct gl_texture_format _mesa_texformat_argb4444;
|
||||
extern const struct gl_texture_format _mesa_texformat_argb4444_rev;
|
||||
extern const struct gl_texture_format _mesa_texformat_argb1555;
|
||||
extern const struct gl_texture_format _mesa_texformat_argb1555_rev;
|
||||
extern const struct gl_texture_format _mesa_texformat_rgba5551;
|
||||
extern const struct gl_texture_format _mesa_texformat_al88;
|
||||
extern const struct gl_texture_format _mesa_texformat_al88_rev;
|
||||
extern const struct gl_texture_format _mesa_texformat_rgb332;
|
||||
|
@@ -694,7 +694,7 @@ static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
|
||||
{
|
||||
const GLubyte *rgba = (const GLubyte *) texel;
|
||||
GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
|
||||
*dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
|
||||
*dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -803,6 +803,30 @@ static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
|
||||
}
|
||||
#endif
|
||||
|
||||
/* MESA_FORMAT_RGBA4444 ******************************************************/
|
||||
|
||||
/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
|
||||
static void FETCH(rgba4444)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
|
||||
const GLushort s = *src;
|
||||
texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) );
|
||||
texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) | ((s >> 4) & 0xf0) );
|
||||
texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) | ((s ) & 0xf0) );
|
||||
texel[ACOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) | ((s << 4) & 0xf0) );
|
||||
}
|
||||
|
||||
#if DIM == 3
|
||||
static void store_texel_rgba4444(struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, const void *texel)
|
||||
{
|
||||
const GLubyte *rgba = (const GLubyte *) texel;
|
||||
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
|
||||
*dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* MESA_FORMAT_ARGB4444 ******************************************************/
|
||||
|
||||
@@ -824,7 +848,7 @@ static void store_texel_argb4444(struct gl_texture_image *texImage,
|
||||
{
|
||||
const GLubyte *rgba = (const GLubyte *) texel;
|
||||
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
|
||||
*dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
|
||||
*dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -852,6 +876,29 @@ static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
|
||||
}
|
||||
#endif
|
||||
|
||||
/* MESA_FORMAT_RGBA5551 ******************************************************/
|
||||
|
||||
/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
|
||||
static void FETCH(rgba5551)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
|
||||
const GLushort s = *src;
|
||||
texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
|
||||
texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xf8) | ((s >> 8) & 0x7) );
|
||||
texel[BCOMP] = UBYTE_TO_CHAN( ((s << 2) & 0xf8) | ((s >> 3) & 0x7) );
|
||||
texel[ACOMP] = UBYTE_TO_CHAN( ((s) & 0x01) ? 255 : 0);
|
||||
}
|
||||
|
||||
#if DIM == 3
|
||||
static void store_texel_rgba5551(struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, const void *texel)
|
||||
{
|
||||
const GLubyte *rgba = (const GLubyte *) texel;
|
||||
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
|
||||
*dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* MESA_FORMAT_ARGB1555 ******************************************************/
|
||||
|
||||
|
@@ -1898,6 +1898,60 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
_mesa_texstore_rgba4444(TEXSTORE_PARAMS)
|
||||
{
|
||||
ASSERT(dstFormat == &_mesa_texformat_rgba4444);
|
||||
ASSERT(dstFormat->TexelBytes == 2);
|
||||
|
||||
if (!ctx->_ImageTransferState &&
|
||||
!srcPacking->SwapBytes &&
|
||||
dstFormat == &_mesa_texformat_rgba4444 &&
|
||||
baseInternalFormat == GL_RGBA &&
|
||||
srcFormat == GL_RGBA &&
|
||||
srcType == GL_UNSIGNED_SHORT_4_4_4_4){
|
||||
/* simple memcpy path */
|
||||
memcpy_texture(ctx, dims,
|
||||
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
|
||||
dstRowStride,
|
||||
dstImageOffsets,
|
||||
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
|
||||
srcAddr, srcPacking);
|
||||
}
|
||||
else {
|
||||
/* general path */
|
||||
const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
dstFormat->BaseFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
const GLchan *src = tempImage;
|
||||
GLint img, row, col;
|
||||
if (!tempImage)
|
||||
return GL_FALSE;
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
for (img = 0; img < srcDepth; img++) {
|
||||
GLubyte *dstRow = (GLubyte *) dstAddr
|
||||
+ dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
|
||||
+ dstYoffset * dstRowStride
|
||||
+ dstXoffset * dstFormat->TexelBytes;
|
||||
for (row = 0; row < srcHeight; row++) {
|
||||
GLushort *dstUS = (GLushort *) dstRow;
|
||||
for (col = 0; col < srcWidth; col++) {
|
||||
dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[RCOMP]),
|
||||
CHAN_TO_UBYTE(src[GCOMP]),
|
||||
CHAN_TO_UBYTE(src[BCOMP]),
|
||||
CHAN_TO_UBYTE(src[ACOMP]) );
|
||||
src += 4;
|
||||
}
|
||||
dstRow += dstRowStride;
|
||||
}
|
||||
}
|
||||
_mesa_free((void *) tempImage);
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
_mesa_texstore_argb4444(TEXSTORE_PARAMS)
|
||||
@@ -1966,7 +2020,60 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
_mesa_texstore_rgba5551(TEXSTORE_PARAMS)
|
||||
{
|
||||
ASSERT(dstFormat == &_mesa_texformat_rgba5551);
|
||||
ASSERT(dstFormat->TexelBytes == 2);
|
||||
|
||||
if (!ctx->_ImageTransferState &&
|
||||
!srcPacking->SwapBytes &&
|
||||
dstFormat == &_mesa_texformat_rgba5551 &&
|
||||
baseInternalFormat == GL_RGBA &&
|
||||
srcFormat == GL_RGBA &&
|
||||
srcType == GL_UNSIGNED_SHORT_5_5_5_1) {
|
||||
/* simple memcpy path */
|
||||
memcpy_texture(ctx, dims,
|
||||
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
|
||||
dstRowStride,
|
||||
dstImageOffsets,
|
||||
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
|
||||
srcAddr, srcPacking);
|
||||
}
|
||||
else {
|
||||
/* general path */
|
||||
const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
dstFormat->BaseFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
const GLchan *src =tempImage;
|
||||
GLint img, row, col;
|
||||
if (!tempImage)
|
||||
return GL_FALSE;
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
for (img = 0; img < srcDepth; img++) {
|
||||
GLubyte *dstRow = (GLubyte *) dstAddr
|
||||
+ dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
|
||||
+ dstYoffset * dstRowStride
|
||||
+ dstXoffset * dstFormat->TexelBytes;
|
||||
for (row = 0; row < srcHeight; row++) {
|
||||
GLushort *dstUS = (GLushort *) dstRow;
|
||||
for (col = 0; col < srcWidth; col++) {
|
||||
dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]),
|
||||
CHAN_TO_UBYTE(src[GCOMP]),
|
||||
CHAN_TO_UBYTE(src[BCOMP]),
|
||||
CHAN_TO_UBYTE(src[ACOMP]) );
|
||||
src += 4;
|
||||
}
|
||||
dstRow += dstRowStride;
|
||||
}
|
||||
}
|
||||
_mesa_free((void *) tempImage);
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
_mesa_texstore_argb1555(TEXSTORE_PARAMS)
|
||||
|
@@ -46,8 +46,10 @@ extern GLboolean _mesa_texstore_rgb888(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_bgr888(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb565(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb565_rev(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba4444(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb4444(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb4444_rev(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba5551(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb1555(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb1555_rev(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_al88(TEXSTORE_PARAMS);
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#define MESA_MAJOR 7
|
||||
#define MESA_MINOR 3
|
||||
#define MESA_PATCH 0
|
||||
#define MESA_VERSION_STRING "7.3-rc1"
|
||||
#define MESA_VERSION_STRING "7.3-rc3"
|
||||
|
||||
/* To make version comparison easy */
|
||||
#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||
|
@@ -189,6 +189,18 @@ do { \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Transform a direction by a matrix.
|
||||
*/
|
||||
#define TRANSFORM_DIRECTION( TO, DIR, MAT ) \
|
||||
do { \
|
||||
TO[0] = DIR[0] * MAT[0] + DIR[1] * MAT[4] + DIR[2] * MAT[8]; \
|
||||
TO[1] = DIR[0] * MAT[1] + DIR[1] * MAT[5] + DIR[2] * MAT[9]; \
|
||||
TO[2] = DIR[0] * MAT[2] + DIR[1] * MAT[6] + DIR[2] * MAT[10];\
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
@@ -963,6 +963,8 @@ parse_output_color_num (GLcontext * ctx, const GLubyte ** inst,
|
||||
|
||||
|
||||
/**
|
||||
* Validate the index of a texture coordinate
|
||||
*
|
||||
* \param coord The texture unit index
|
||||
* \return 0 on sucess, 1 on error
|
||||
*/
|
||||
@@ -972,8 +974,8 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst,
|
||||
{
|
||||
GLint i = parse_integer (inst, Program);
|
||||
|
||||
if ((i < 0) || (i >= (int)ctx->Const.MaxTextureUnits)) {
|
||||
program_error(ctx, Program->Position, "Invalid texture unit index");
|
||||
if ((i < 0) || (i >= (int)ctx->Const.MaxTextureCoordUnits)) {
|
||||
program_error(ctx, Program->Position, "Invalid texture coordinate index");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -981,6 +983,29 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate the index of a texture image unit
|
||||
*
|
||||
* \param coord The texture unit index
|
||||
* \return 0 on sucess, 1 on error
|
||||
*/
|
||||
static GLuint
|
||||
parse_teximage_num (GLcontext * ctx, const GLubyte ** inst,
|
||||
struct arb_program *Program, GLuint * coord)
|
||||
{
|
||||
GLint i = parse_integer (inst, Program);
|
||||
|
||||
if ((i < 0) || (i >= (int)ctx->Const.MaxTextureImageUnits)) {
|
||||
program_error(ctx, Program->Position, "Invalid texture image index");
|
||||
return 1;
|
||||
}
|
||||
|
||||
*coord = (GLuint) i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \param coord The weight index
|
||||
* \return 0 on sucess, 1 on error
|
||||
@@ -3003,7 +3028,7 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst,
|
||||
return 1;
|
||||
|
||||
/* texImageUnit */
|
||||
if (parse_texcoord_num (ctx, inst, Program, &texcoord))
|
||||
if (parse_teximage_num (ctx, inst, Program, &texcoord))
|
||||
return 1;
|
||||
fp->TexSrcUnit = texcoord;
|
||||
|
||||
|
@@ -807,6 +807,7 @@ _mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index,
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLfloat floatParams[4];
|
||||
ASSIGN_4V(floatParams, 0.0F, 0.0F, 0.0F, 0.0F);
|
||||
_mesa_GetProgramLocalParameterfvARB(target, index, floatParams);
|
||||
if (ctx->ErrorValue == GL_NO_ERROR) {
|
||||
COPY_4V(params, floatParams);
|
||||
|
@@ -1,8 +1,9 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
* Version: 7.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -157,7 +158,7 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
|
||||
{ OPCODE_AND, "AND", 2, 1 },
|
||||
{ OPCODE_ARA, "ARA", 1, 1 },
|
||||
{ OPCODE_ARL, "ARL", 1, 1 },
|
||||
{ OPCODE_ARL_NV, "ARL", 1, 1 },
|
||||
{ OPCODE_ARL_NV, "ARL_NV", 1, 1 },
|
||||
{ OPCODE_ARR, "ARL", 1, 1 },
|
||||
{ OPCODE_BGNLOOP,"BGNLOOP", 0, 0 },
|
||||
{ OPCODE_BGNSUB, "BGNSUB", 0, 0 },
|
||||
@@ -186,7 +187,7 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
|
||||
{ OPCODE_FRC, "FRC", 1, 1 },
|
||||
{ OPCODE_IF, "IF", 1, 0 },
|
||||
{ OPCODE_KIL, "KIL", 1, 0 },
|
||||
{ OPCODE_KIL_NV, "KIL", 0, 0 },
|
||||
{ OPCODE_KIL_NV, "KIL_NV", 0, 0 },
|
||||
{ OPCODE_LG2, "LG2", 1, 1 },
|
||||
{ OPCODE_LIT, "LIT", 1, 1 },
|
||||
{ OPCODE_LOG, "LOG", 1, 1 },
|
||||
@@ -235,7 +236,7 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
|
||||
{ OPCODE_TXD, "TXD", 3, 1 },
|
||||
{ OPCODE_TXL, "TXL", 1, 1 },
|
||||
{ OPCODE_TXP, "TXP", 1, 1 },
|
||||
{ OPCODE_TXP_NV, "TXP", 1, 1 },
|
||||
{ OPCODE_TXP_NV, "TXP_NV", 1, 1 },
|
||||
{ OPCODE_TRUNC, "TRUNC", 1, 1 },
|
||||
{ OPCODE_UP2H, "UP2H", 1, 1 },
|
||||
{ OPCODE_UP2US, "UP2US", 1, 1 },
|
||||
|
@@ -79,6 +79,12 @@
|
||||
.emtcode BEHAVIOR_WARN 3
|
||||
.emtcode BEHAVIOR_DISABLE 4
|
||||
|
||||
/*
|
||||
* The PRAGMA_* symbols follow TOKEN_PRAGMA
|
||||
*/
|
||||
.emtcode PRAGMA_NO_PARAM 0
|
||||
.emtcode PRAGMA_PARAM 1
|
||||
|
||||
source
|
||||
optional_directive .and .loop source_element .and '\0' .emit ESCAPE_TOKEN .emit TOKEN_END;
|
||||
|
||||
@@ -153,6 +159,7 @@ directive
|
||||
dir_elif .emit TOKEN_ELIF .or
|
||||
dir_endif .emit TOKEN_ENDIF .or
|
||||
dir_ext .emit TOKEN_EXTENSION .or
|
||||
dir_pragma .emit TOKEN_PRAGMA .or
|
||||
dir_line .emit TOKEN_LINE;
|
||||
|
||||
dir_define
|
||||
@@ -187,6 +194,19 @@ dir_ext
|
||||
dir_line
|
||||
optional_space .and '#' .and optional_space .and "line" .and expression;
|
||||
|
||||
dir_pragma
|
||||
optional_space .and '#' .and optional_space .and "pragma" .and symbol .and opt_pragma_param;
|
||||
|
||||
|
||||
opt_pragma_param
|
||||
pragma_param .or .true .emit PRAGMA_NO_PARAM;
|
||||
|
||||
pragma_param
|
||||
optional_space .and '(' .emit PRAGMA_PARAM .and optional_space .and symbol_no_space .and optional_space .and ')';
|
||||
|
||||
symbol_no_space
|
||||
symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0';
|
||||
|
||||
symbol
|
||||
space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0';
|
||||
|
||||
|
@@ -20,6 +20,8 @@
|
||||
".emtcode BEHAVIOR_ENABLE 2\n"
|
||||
".emtcode BEHAVIOR_WARN 3\n"
|
||||
".emtcode BEHAVIOR_DISABLE 4\n"
|
||||
".emtcode PRAGMA_NO_PARAM 0\n"
|
||||
".emtcode PRAGMA_PARAM 1\n"
|
||||
"source\n"
|
||||
" optional_directive .and .loop source_element .and '\\0' .emit ESCAPE_TOKEN .emit TOKEN_END;\n"
|
||||
"source_element\n"
|
||||
@@ -76,6 +78,7 @@
|
||||
" dir_elif .emit TOKEN_ELIF .or\n"
|
||||
" dir_endif .emit TOKEN_ENDIF .or\n"
|
||||
" dir_ext .emit TOKEN_EXTENSION .or\n"
|
||||
" dir_pragma .emit TOKEN_PRAGMA .or\n"
|
||||
" dir_line .emit TOKEN_LINE;\n"
|
||||
"dir_define\n"
|
||||
" optional_space .and '#' .and optional_space .and \"define\" .and symbol .and opt_parameters .and\n"
|
||||
@@ -99,6 +102,14 @@
|
||||
" optional_space .and ':' .and optional_space .and extension_behavior;\n"
|
||||
"dir_line\n"
|
||||
" optional_space .and '#' .and optional_space .and \"line\" .and expression;\n"
|
||||
"dir_pragma\n"
|
||||
" optional_space .and '#' .and optional_space .and \"pragma\" .and symbol .and opt_pragma_param;\n"
|
||||
"opt_pragma_param\n"
|
||||
" pragma_param .or .true .emit PRAGMA_NO_PARAM;\n"
|
||||
"pragma_param\n"
|
||||
" optional_space .and '(' .emit PRAGMA_PARAM .and optional_space .and symbol_no_space .and optional_space .and ')';\n"
|
||||
"symbol_no_space\n"
|
||||
" symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n"
|
||||
"symbol\n"
|
||||
" space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n"
|
||||
"opt_parameters\n"
|
||||
|
@@ -1161,13 +1161,6 @@ compound_statement_2
|
||||
compound_statement_3
|
||||
lbrace .and statement_list .and rbrace;
|
||||
|
||||
/*
|
||||
* <statement_no_new_scope> ::= <compound_statement_no_new_scope>
|
||||
* | <simple_statement>
|
||||
*/
|
||||
statement_no_new_scope
|
||||
compound_statement_no_new_scope .or simple_statement;
|
||||
|
||||
/*
|
||||
* <compound_statement_no_new_scope> ::= "{" "}"
|
||||
* | "{" <statement_list> "}"
|
||||
@@ -1181,6 +1174,7 @@ compound_statement_no_new_scope_2
|
||||
compound_statement_no_new_scope_3
|
||||
lbrace .and statement_list .and rbrace;
|
||||
|
||||
|
||||
/*
|
||||
* <statement_list> ::= <statement>
|
||||
* | <statement_list> <statement>
|
||||
@@ -1242,8 +1236,7 @@ condition_3
|
||||
/*
|
||||
* <iteration_statement> ::= "while" "(" <condition> ")" <statement>
|
||||
* | "do" <statement> "while" "(" <expression> ")" ";"
|
||||
* | "for" "(" <for_init_statement> <for_rest_statement> ")"
|
||||
* <statement_no_new_scope>
|
||||
* | "for" "(" <for_init_statement> <for_rest_statement> ")" <statement>
|
||||
*/
|
||||
iteration_statement
|
||||
iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;
|
||||
@@ -1255,7 +1248,7 @@ iteration_statement_2
|
||||
expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;
|
||||
iteration_statement_3
|
||||
"for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and
|
||||
for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;
|
||||
for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement;
|
||||
|
||||
/*
|
||||
* <for_init_statement> ::= <expression_statement>
|
||||
|
@@ -566,8 +566,6 @@
|
||||
" lbrace .and rbrace;\n"
|
||||
"compound_statement_3\n"
|
||||
" lbrace .and statement_list .and rbrace;\n"
|
||||
"statement_no_new_scope\n"
|
||||
" compound_statement_no_new_scope .or simple_statement;\n"
|
||||
"compound_statement_no_new_scope\n"
|
||||
" compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;\n"
|
||||
"compound_statement_no_new_scope_1\n"
|
||||
@@ -617,7 +615,7 @@
|
||||
" expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;\n"
|
||||
"iteration_statement_3\n"
|
||||
" \"for\" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and\n"
|
||||
" for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;\n"
|
||||
" for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement;\n"
|
||||
"for_init_statement\n"
|
||||
" expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;\n"
|
||||
"conditionopt\n"
|
||||
|
@@ -4238,6 +4238,21 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the given type specifier is a rectangular texture sampler.
|
||||
*/
|
||||
static GLboolean
|
||||
is_rect_sampler_spec(const slang_type_specifier *spec)
|
||||
{
|
||||
while (spec->_array) {
|
||||
spec = spec->_array;
|
||||
}
|
||||
return spec->type == SLANG_SPEC_SAMPLER2DRECT ||
|
||||
spec->type == SLANG_SPEC_SAMPLER2DRECTSHADOW;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called by compiler when a global variable has been parsed/compiled.
|
||||
* Here we examine the variable's type to determine what kind of register
|
||||
@@ -4261,10 +4276,14 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
|
||||
slang_ir_storage *store = NULL;
|
||||
int dbg = 0;
|
||||
const GLenum datatype = _slang_gltype_from_specifier(&var->type.specifier);
|
||||
const GLint texIndex = sampler_to_texture_index(var->type.specifier.type);
|
||||
const GLint size = _slang_sizeof_type_specifier(&var->type.specifier);
|
||||
const GLint arrayLen = _slang_array_length(var);
|
||||
const GLint totalSize = _slang_array_size(size, arrayLen);
|
||||
GLint texIndex = sampler_to_texture_index(var->type.specifier.type);
|
||||
|
||||
/* check for sampler2D arrays */
|
||||
if (texIndex == -1 && var->type.specifier._array)
|
||||
texIndex = sampler_to_texture_index(var->type.specifier._array->type);
|
||||
|
||||
if (texIndex != -1) {
|
||||
/* This is a texture sampler variable...
|
||||
@@ -4278,15 +4297,32 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
|
||||
}
|
||||
#if FEATURE_es2_glsl /* XXX should use FEATURE_texture_rect */
|
||||
/* disallow rect samplers */
|
||||
if (var->type.specifier.type == SLANG_SPEC_SAMPLER2DRECT ||
|
||||
var->type.specifier.type == SLANG_SPEC_SAMPLER2DRECTSHADOW) {
|
||||
if (is_rect_sampler_spec(&var->type.specifier)) {
|
||||
slang_info_log_error(A->log, "invalid sampler type for '%s'", varName);
|
||||
return GL_FALSE;
|
||||
}
|
||||
#else
|
||||
(void) is_rect_sampler_spec; /* silence warning */
|
||||
#endif
|
||||
{
|
||||
GLint sampNum = _mesa_add_sampler(prog->Parameters, varName, datatype);
|
||||
store = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, texIndex);
|
||||
store = _slang_new_ir_storage_sampler(sampNum, texIndex, totalSize);
|
||||
|
||||
/* If we have a sampler array, then we need to allocate the
|
||||
* additional samplers to ensure we don't allocate them elsewhere.
|
||||
* We can't directly use _mesa_add_sampler() as that checks the
|
||||
* varName and gets a match, so we call _mesa_add_parameter()
|
||||
* directly and use the last sampler number from the call above.
|
||||
*/
|
||||
if (arrayLen > 0) {
|
||||
GLint a = arrayLen - 1;
|
||||
GLint i;
|
||||
for (i = 0; i < a; i++) {
|
||||
GLfloat value = (GLfloat)(i + sampNum + 1);
|
||||
(void) _mesa_add_parameter(prog->Parameters, PROGRAM_SAMPLER,
|
||||
varName, 1, datatype, &value, NULL, 0x0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dbg) printf("SAMPLER ");
|
||||
}
|
||||
@@ -4470,7 +4506,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
|
||||
n = _slang_gen_var_decl(A, var, var->initializer);
|
||||
|
||||
/* emit GPU instructions */
|
||||
success = _slang_emit_code(n, A->vartable, A->program, GL_FALSE, A->log);
|
||||
success = _slang_emit_code(n, A->vartable, A->program, A->pragmas, GL_FALSE, A->log);
|
||||
|
||||
_slang_free_ir_tree(n);
|
||||
}
|
||||
@@ -4580,7 +4616,7 @@ _slang_codegen_function(slang_assemble_ctx * A, slang_function * fun)
|
||||
#endif
|
||||
|
||||
/* Emit program instructions */
|
||||
success = _slang_emit_code(n, A->vartable, A->program, GL_TRUE, A->log);
|
||||
success = _slang_emit_code(n, A->vartable, A->program, A->pragmas, GL_TRUE, A->log);
|
||||
_slang_free_ir_tree(n);
|
||||
|
||||
/* free codegen context */
|
||||
|
@@ -36,6 +36,7 @@ typedef struct slang_assemble_ctx_
|
||||
slang_atom_pool *atoms;
|
||||
slang_name_space space;
|
||||
struct gl_program *program;
|
||||
struct gl_sl_pragmas *pragmas;
|
||||
slang_var_table *vartable;
|
||||
slang_info_log *log;
|
||||
struct slang_label_ *curFuncEndLabel;
|
||||
|
@@ -144,6 +144,7 @@ typedef struct slang_output_ctx_
|
||||
slang_function_scope *funs;
|
||||
slang_struct_scope *structs;
|
||||
struct gl_program *program;
|
||||
struct gl_sl_pragmas *pragmas;
|
||||
slang_var_table *vartable;
|
||||
GLuint default_precision[TYPE_SPECIFIER_COUNT];
|
||||
GLboolean allow_precision;
|
||||
@@ -1138,26 +1139,8 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O,
|
||||
RETURN0;
|
||||
if (!parse_child_operation(C, &o, oper, GL_FALSE))
|
||||
RETURN0;
|
||||
#if 0
|
||||
if (!parse_child_operation(C, &o, oper, GL_TRUE))
|
||||
RETURN0;
|
||||
#else
|
||||
/* force creation of new scope for loop body */
|
||||
{
|
||||
slang_operation *ch;
|
||||
slang_output_ctx oo = o;
|
||||
|
||||
/* grow child array */
|
||||
ch = slang_operation_grow(&oper->num_children, &oper->children);
|
||||
ch->type = SLANG_OPER_BLOCK_NEW_SCOPE;
|
||||
|
||||
ch->locals->outer_scope = o.vars;
|
||||
oo.vars = ch->locals;
|
||||
|
||||
if (!parse_child_operation(C, &oo, ch, GL_TRUE))
|
||||
RETURN0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case OP_PRECISION:
|
||||
@@ -1488,9 +1471,9 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O,
|
||||
RETURN0;
|
||||
}
|
||||
else {
|
||||
array_constructor = GL_TRUE;
|
||||
/* parse the array constructor size */
|
||||
slang_operation array_size;
|
||||
array_constructor = GL_TRUE;
|
||||
slang_operation_construct(&array_size);
|
||||
if (!parse_expression(C, O, &array_size)) {
|
||||
slang_operation_destruct(&array_size);
|
||||
@@ -2077,6 +2060,7 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O,
|
||||
A.space.structs = O->structs;
|
||||
A.space.vars = O->vars;
|
||||
A.program = O->program;
|
||||
A.pragmas = O->pragmas;
|
||||
A.vartable = O->vartable;
|
||||
A.log = C->L;
|
||||
A.curFuncEndLabel = NULL;
|
||||
@@ -2367,6 +2351,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
|
||||
o.structs = &unit->structs;
|
||||
o.vars = &unit->vars;
|
||||
o.program = shader ? shader->Program : NULL;
|
||||
o.pragmas = shader ? &shader->Pragmas : NULL;
|
||||
o.vartable = _slang_new_var_table(maxRegs);
|
||||
_slang_push_var_table(o.vartable);
|
||||
|
||||
@@ -2435,6 +2420,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
|
||||
A.space.structs = o.structs;
|
||||
A.space.vars = o.vars;
|
||||
A.program = o.program;
|
||||
A.pragmas = &shader->Pragmas;
|
||||
A.vartable = o.vartable;
|
||||
A.log = C->L;
|
||||
|
||||
@@ -2493,7 +2479,8 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit,
|
||||
slang_unit_type type, slang_info_log * infolog,
|
||||
slang_code_unit * builtin,
|
||||
struct gl_shader *shader,
|
||||
const struct gl_extensions *extensions)
|
||||
const struct gl_extensions *extensions,
|
||||
struct gl_sl_pragmas *pragmas)
|
||||
{
|
||||
byte *prod;
|
||||
GLuint size, start, version;
|
||||
@@ -2522,7 +2509,7 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit,
|
||||
/* Now preprocess the source string. */
|
||||
slang_string_init(&preprocessed);
|
||||
if (!_slang_preprocess_directives(&preprocessed, &source[start],
|
||||
infolog, extensions)) {
|
||||
infolog, extensions, pragmas)) {
|
||||
slang_string_free(&preprocessed);
|
||||
slang_info_log_error(infolog, "failed to preprocess the source.");
|
||||
return GL_FALSE;
|
||||
@@ -2596,7 +2583,8 @@ static GLboolean
|
||||
compile_object(grammar * id, const char *source, slang_code_object * object,
|
||||
slang_unit_type type, slang_info_log * infolog,
|
||||
struct gl_shader *shader,
|
||||
const struct gl_extensions *extensions)
|
||||
const struct gl_extensions *extensions,
|
||||
struct gl_sl_pragmas *pragmas)
|
||||
{
|
||||
slang_code_unit *builtins = NULL;
|
||||
GLuint base_version = 110;
|
||||
@@ -2695,7 +2683,7 @@ compile_object(grammar * id, const char *source, slang_code_object * object,
|
||||
|
||||
/* compile the actual shader - pass-in built-in library for external shader */
|
||||
return compile_with_grammar(*id, source, &object->unit, type, infolog,
|
||||
builtins, shader, extensions);
|
||||
builtins, shader, extensions, pragmas);
|
||||
}
|
||||
|
||||
|
||||
@@ -2719,7 +2707,7 @@ compile_shader(GLcontext *ctx, slang_code_object * object,
|
||||
_slang_code_object_ctr(object);
|
||||
|
||||
success = compile_object(&id, shader->Source, object, type, infolog, shader,
|
||||
&ctx->Extensions);
|
||||
&ctx->Extensions, &shader->Pragmas);
|
||||
if (id != 0)
|
||||
grammar_destroy(id);
|
||||
if (!success)
|
||||
|
@@ -1271,6 +1271,20 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n)
|
||||
opcode = OPCODE_TXP;
|
||||
}
|
||||
|
||||
if (n->Children[0]->Opcode == IR_ELEMENT) {
|
||||
/* array is the sampler (a uniform which'll indicate the texture unit) */
|
||||
assert(n->Children[0]->Children[0]->Store);
|
||||
assert(n->Children[0]->Children[0]->Store->File == PROGRAM_SAMPLER);
|
||||
|
||||
emit(emitInfo, n->Children[0]);
|
||||
|
||||
n->Children[0]->Var = n->Children[0]->Children[0]->Var;
|
||||
} else {
|
||||
/* this is the sampler (a uniform which'll indicate the texture unit) */
|
||||
assert(n->Children[0]->Store);
|
||||
assert(n->Children[0]->Store->File == PROGRAM_SAMPLER);
|
||||
}
|
||||
|
||||
/* emit code for the texcoord operand */
|
||||
(void) emit(emitInfo, n->Children[1]);
|
||||
|
||||
@@ -1286,17 +1300,10 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n)
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* Child[0] is the sampler (a uniform which'll indicate the texture unit) */
|
||||
assert(n->Children[0]->Store);
|
||||
assert(n->Children[0]->Store->File == PROGRAM_SAMPLER);
|
||||
/* Store->Index is the sampler index */
|
||||
/* Store->Index is the uniform/sampler index */
|
||||
assert(n->Children[0]->Store->Index >= 0);
|
||||
/* Store->Size is the texture target */
|
||||
assert(n->Children[0]->Store->Size >= TEXTURE_1D_INDEX);
|
||||
assert(n->Children[0]->Store->Size <= TEXTURE_RECT_INDEX);
|
||||
|
||||
inst->TexSrcTarget = n->Children[0]->Store->Size;
|
||||
inst->TexSrcUnit = n->Children[0]->Store->Index; /* i.e. uniform's index */
|
||||
inst->TexSrcUnit = n->Children[0]->Store->Index;
|
||||
inst->TexSrcTarget = n->Children[0]->Store->TexTarget;
|
||||
|
||||
/* mark the sampler as being used */
|
||||
_mesa_use_uniform(emitInfo->prog->Parameters,
|
||||
@@ -1342,9 +1349,10 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
|
||||
|
||||
if (n->Store->File == PROGRAM_SAMPLER) {
|
||||
/* no code generated for sampler assignments,
|
||||
* just copy the sampler index at compile time.
|
||||
* just copy the sampler index/target at compile time.
|
||||
*/
|
||||
n->Store->Index = n->Children[1]->Store->Index;
|
||||
n->Store->TexTarget = n->Children[1]->Store->TexTarget;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2370,10 +2378,20 @@ _slang_resolve_subroutines(slang_emit_info *emitInfo)
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert the IR tree into GPU instructions.
|
||||
* \param n root of IR tree
|
||||
* \param vt variable table
|
||||
* \param prog program to put GPU instructions into
|
||||
* \param pragmas controls codegen options
|
||||
* \param withEnd if true, emit END opcode at end
|
||||
* \param log log for emitting errors/warnings/info
|
||||
*/
|
||||
GLboolean
|
||||
_slang_emit_code(slang_ir_node *n, slang_var_table *vt,
|
||||
struct gl_program *prog, GLboolean withEnd,
|
||||
struct gl_program *prog,
|
||||
const struct gl_sl_pragmas *pragmas,
|
||||
GLboolean withEnd,
|
||||
slang_info_log *log)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
@@ -2390,7 +2408,7 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt,
|
||||
|
||||
emitInfo.EmitHighLevelInstructions = ctx->Shader.EmitHighLevelInstructions;
|
||||
emitInfo.EmitCondCodes = ctx->Shader.EmitCondCodes;
|
||||
emitInfo.EmitComments = ctx->Shader.EmitComments;
|
||||
emitInfo.EmitComments = ctx->Shader.EmitComments || pragmas->Debug;
|
||||
emitInfo.EmitBeginEndSub = GL_TRUE;
|
||||
|
||||
if (!emitInfo.EmitCondCodes) {
|
||||
|
@@ -46,7 +46,9 @@ _slang_var_swizzle(GLint size, GLint comp);
|
||||
|
||||
extern GLboolean
|
||||
_slang_emit_code(slang_ir_node *n, slang_var_table *vartable,
|
||||
struct gl_program *prog, GLboolean withEnd,
|
||||
struct gl_program *prog,
|
||||
const struct gl_sl_pragmas *pragmas,
|
||||
GLboolean withEnd,
|
||||
slang_info_log *log);
|
||||
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 7.1
|
||||
*
|
||||
* Copyright (C) 2005-2008 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -216,6 +216,26 @@ _slang_new_ir_storage_indirect(enum register_file file,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allocate IR storage for a texture sampler.
|
||||
* \param sampNum the sampler number/index
|
||||
* \param texTarget one of TEXTURE_x_INDEX values
|
||||
* \param size number of samplers (in case of sampler array)
|
||||
*/
|
||||
slang_ir_storage *
|
||||
_slang_new_ir_storage_sampler(GLint sampNum, GLuint texTarget, GLint size)
|
||||
{
|
||||
slang_ir_storage *st;
|
||||
assert(texTarget < NUM_TEXTURE_TARGETS);
|
||||
st = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, size);
|
||||
if (st) {
|
||||
st->TexTarget = texTarget;
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* XXX temporary function */
|
||||
void
|
||||
_slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 2005-2007 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 2005-2008 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -168,8 +168,8 @@ typedef enum
|
||||
struct slang_ir_storage_
|
||||
{
|
||||
enum register_file File; /**< PROGRAM_TEMPORARY, PROGRAM_INPUT, etc */
|
||||
GLint Index; /**< -1 means unallocated */
|
||||
GLint Size; /**< number of floats */
|
||||
GLint Index; /**< -1 means unallocated */
|
||||
GLint Size; /**< number of floats or ints */
|
||||
GLuint Swizzle; /**< Swizzle AND writemask info */
|
||||
GLint RefCount; /**< Used during IR tree delete */
|
||||
|
||||
@@ -179,6 +179,7 @@ struct slang_ir_storage_
|
||||
enum register_file IndirectFile;
|
||||
GLint IndirectIndex;
|
||||
GLuint IndirectSwizzle;
|
||||
GLuint TexTarget; /**< If File==PROGRAM_SAMPLER, one of TEXTURE_x_INDEX */
|
||||
|
||||
/** If Parent is non-null, Index is relative to parent.
|
||||
* The other fields are ignored.
|
||||
@@ -254,6 +255,10 @@ _slang_new_ir_storage_indirect(enum register_file file,
|
||||
GLint indirectIndex,
|
||||
GLuint indirectSwizzle);
|
||||
|
||||
extern slang_ir_storage *
|
||||
_slang_new_ir_storage_sampler(GLint sampNum, GLuint texTarget, GLint size);
|
||||
|
||||
|
||||
extern void
|
||||
_slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src);
|
||||
|
||||
|
@@ -260,8 +260,8 @@ link_uniform_vars(GLcontext *ctx,
|
||||
GLuint newSampNum = *numSamplers;
|
||||
if (newSampNum >= ctx->Const.MaxTextureImageUnits) {
|
||||
char s[100];
|
||||
sprintf(s, "Too many texture samplers (%u, max is %u)",
|
||||
newSampNum, ctx->Const.MaxTextureImageUnits);
|
||||
_mesa_sprintf(s, "Too many texture samplers (%u, max is %u)",
|
||||
newSampNum, ctx->Const.MaxTextureImageUnits);
|
||||
link_error(shProg, s);
|
||||
return GL_FALSE;
|
||||
}
|
||||
@@ -282,12 +282,14 @@ link_uniform_vars(GLcontext *ctx,
|
||||
for (i = 0; i < prog->NumInstructions; i++) {
|
||||
struct prog_instruction *inst = prog->Instructions + i;
|
||||
if (_mesa_is_tex_instruction(inst->Opcode)) {
|
||||
/*
|
||||
printf("====== remap sampler from %d to %d\n",
|
||||
inst->Sampler, map[ inst->Sampler ]);
|
||||
*/
|
||||
/* here, texUnit is really samplerUnit */
|
||||
const GLint oldSampNum = inst->TexSrcUnit;
|
||||
|
||||
#if 0
|
||||
printf("====== remap sampler from %d to %d\n",
|
||||
inst->TexSrcUnit, samplerMap[ inst->TexSrcUnit ]);
|
||||
#endif
|
||||
|
||||
/* here, texUnit is really samplerUnit */
|
||||
if (oldSampNum < Elements(samplerMap)) {
|
||||
const GLuint newSampNum = samplerMap[oldSampNum];
|
||||
inst->TexSrcUnit = newSampNum;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user