Compare commits

..

41 Commits

Author SHA1 Message Date
Vladimir Dergachev
380ba2daec Reduce the amount of debug output, while still printing important messages.
Make guessing texture formats easier.
2005-01-05 04:56:23 +00:00
Vladimir Dergachev
e99f390ff6 Play a little bit with texture formats.
Get NeHe demos 06, 07 and 19 working.
2005-01-05 00:18:46 +00:00
Vladimir Dergachev
065f725672 Sync with master copy. 2005-01-04 22:52:53 +00:00
Vladimir Dergachev
6b185aaedf Port code from r200 that implements color blending. Seems to work.
This can be tested with lesson19 from NeHe.
This has also shown that the alpha code does not work - we pick up a red tint
for transparent pixels somewhere.
2005-01-04 20:25:11 +00:00
Vladimir Dergachev
55ee1daaf9 Unify rendering of textured and non-textured primitives. 2005-01-04 19:15:37 +00:00
Vladimir Dergachev
638faa92fc Major code restructuring:
* move proven code into the r300_state.c
  * update ClearBuffer to cope with more dynamic state
  * cleanup !
2005-01-04 18:59:47 +00:00
Brian Paul
85edffd5ff added GLX_NV_float_buffer 2005-01-04 14:48:14 +00:00
Brian Paul
932dee87e3 use HIDDEN macro to export fewer symbols (bug 2210) 2005-01-04 14:33:47 +00:00
Brian Paul
bdbdab837e directfb changes (Claudio Ciccani) 2005-01-04 14:19:25 +00:00
Keith Whitwell
6650264802 Add GL_EXT_fog_coord 2005-01-04 12:57:02 +00:00
Keith Whitwell
31c25f2edc Add GL_EXT_secondary_color 2005-01-04 12:56:17 +00:00
Keith Whitwell
e024cae14b Turn specular lighting state on/off appropriately. 2005-01-04 12:53:41 +00:00
Keith Whitwell
b6ab7a1bf1 Change to use the t_vertex.c mechanisms for building vertices,
including Felix's ptex code.

Re-enable some assembly for performance.
2005-01-04 12:18:05 +00:00
Brian Paul
f72e4424d9 Use the GLX 1.3 pbuffer/fbconfig functions in preference to the SGIX ones.
Added more functions to pbutil.[ch] to better isolate API differences.
2005-01-04 00:58:29 +00:00
Felix Kuehling
e3748eb19b Added support for floating point depth buffers on Savage4-based
hardware. By also reversing the depth range this can compensate the loss
of accuracy of far objects caused by the projective transformation.
Software fallbacks work but are slightly slower since floats in a custom
(non IEEE) format have to be encoded and decoded. I havn't done anything
about polygon offsets yet. There doesn't seem to be an easy way do get
it right except making the offset unit as big as the lowest resolution
of depth values. For now float depth is disabled by default but can be
enabled through driconf (though I have seen only positive effects so
far).
2005-01-03 22:24:44 +00:00
Felix Kuehling
87889aeab4 Added a boolean option for a floating-point depth buffer. 2005-01-03 22:15:41 +00:00
Ian Romanick
3276c192b7 The opcode and command length fields of RenderLarge commands were
mistakenly emitted in the wrong order.
2005-01-03 21:03:03 +00:00
Brian Paul
dd1a817c50 latest updates 2005-01-03 15:55:51 +00:00
Vladimir Dergachev
a5039af357 Add structs describing vertex and pixel shader state to r300_state.
Take apart program_pipeline() and move it into appropriate pieces within the driver.
Test the framework on run_flat_render()
2005-01-03 15:45:10 +00:00
Brian Paul
8e73b14228 bump version to 6.3, etc. 2005-01-03 15:36:27 +00:00
Brian Paul
81ca616e7e DirectFB driver (Claudio Ciccani) 2005-01-03 15:35:00 +00:00
Brian Paul
6563c16e38 updates from Jouk 2005-01-03 15:01:26 +00:00
Vladimir Dergachev
25faa2d56e Turns out I left flat primitives in vertex buffer mode. Switch them back to immediate which works correctly.. 2005-01-03 06:53:38 +00:00
Vladimir Dergachev
63473a8e76 Enable code to compute other constants that were used by R200 code.
Add fprintf to print these constants.
Correct t->size computation, so it works now.
2005-01-03 06:48:50 +00:00
Vladimir Dergachev
2fc9351ee7 Port texture allocation code from R200.
Hook it up, so lesson06 displays red colored textures.
2005-01-03 05:44:20 +00:00
Vladimir Dergachev
63fd67e561 Add texture units registers 2005-01-02 21:53:53 +00:00
Vladimir Dergachev
f50a1964d1 Cleanup !
I can not trigger any lockups now..
2005-01-02 06:16:44 +00:00
Vladimir Dergachev
d6be8dd651 I think I fixed the lockups issue. 2005-01-02 05:57:15 +00:00
Vladimir Dergachev
9a04b25c60 Get textures to work with NeHe lesson06.
The code is still disabled since we are displaying random image data instead of actual texture and because I had to put a sleep(1) in lesson06 drawing loop to prevent lockups.
2005-01-02 04:46:25 +00:00
Adam Jackson
3c80f5c56b linux-dri-x86 build fix from Andreas Stenglein. 2005-01-02 03:36:53 +00:00
Felix Kuehling
7a231da442 Improved the performance of software fallbacks by not waiting for idle
in every single span function. Instead flush and wait in the
SpanRenderStart hook and in wrappers around _swrast_Copy/Draw/ReadPixels.
Misc. cleanups in savagespan.c while I'm there.
2005-01-02 01:22:10 +00:00
Felix Kuehling
1067ce0cea Removed all direct hardware access (MMIO, BCI) from the Savage DRI
driver. It uses the new DRM version 2.0.x now, which has just been
committed to DRM CVS.
2005-01-01 20:40:14 +00:00
Felix Kuehling
467d64a177 Use DRM headers from $(DRM_SOURCE_PATH)/shared-core instead of .../shared. 2005-01-01 20:33:45 +00:00
Vladimir Dergachev
404d925b58 Add a convenience function to issue CP delays. 2005-01-01 18:41:43 +00:00
Vladimir Dergachev
e443d1ec47 Qualify the magic 20B0 register as SE_VTE_CNTL similar to R200. Looks like disabling Z offset and scaling displays gears properly, not sure why. Perhaps the meaning of the bits has changed ?
Cleanup code a bit.
2004-12-31 21:28:36 +00:00
Vladimir Dergachev
92d47e79f1 Sync with master copy. 2004-12-31 20:57:48 +00:00
Vladimir Dergachev
11374bdb86 Add texture drawing code. Note: it is broken at the moment and is disabled in CVS. However, all hooks are there.
Fix vertex buffer drawing code.
2004-12-31 19:39:03 +00:00
Vladimir Dergachev
24b5e49141 Rework slightly r300_get_primitive_type - make it clearer and more compact.. 2004-12-30 20:24:30 +00:00
Keith Whitwell
179cc373f1 Get scissor test working again. Passes glean scissor test. 2004-12-30 17:47:08 +00:00
Keith Whitwell
c664f0c515 Calculate DEPTH_SCALE correctly for polygon offset. 2004-12-30 16:30:26 +00:00
Keith Whitwell
8be4747fd6 Simplify viaBlit a bit more.
Implement masked clears.
2004-12-30 16:13:35 +00:00
84 changed files with 7804 additions and 2082 deletions

View File

@@ -33,7 +33,11 @@ realclean:
install:
@echo "Installing"
$(TOP)/bin/installmesa
$(TOP)/bin/installmesa
# DirectFBGL module installation
linux-directfb-install:
cd src/mesa/drivers/directfb && $(MAKE) install
# If there's no current configuration file
$(TOP)/configs/current:
@@ -78,6 +82,7 @@ linux \
linux-alpha \
linux-alpha-static \
linux-debug \
linux-directfb \
linux-dri \
linux-dri-x86 \
linux-dri-x86-64 \
@@ -122,9 +127,9 @@ ultrix-gcc:
# Rules for making release tarballs
DIRECTORY = Mesa-6.2
LIB_NAME = MesaLib-6.2
DEMO_NAME = MesaDemos-6.2
DIRECTORY = Mesa-6.3
LIB_NAME = MesaLib-6.3
DEMO_NAME = MesaDemos-6.3
LIB_FILES = \
$(DIRECTORY)/Makefile* \
@@ -201,6 +206,8 @@ LIB_FILES = \
$(DIRECTORY)/src/mesa/drivers/beos/Makefile \
$(DIRECTORY)/src/mesa/drivers/common/*.[ch] \
$(DIRECTORY)/src/mesa/drivers/common/descrip.mms \
$(DIRECTORY)/src/mesa/drivers/directfb/*.[ch] \
$(DIRECTORY)/src/mesa/drivers/directfb/Makefile \
$(DIRECTORY)/src/mesa/drivers/dos/*.[chS] \
$(DIRECTORY)/src/mesa/drivers/dri/common/*.[ch] \
$(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c \
@@ -270,7 +277,7 @@ LIB_FILES = \
$(DIRECTORY)/vms/xlib_share.opt
DEMO_FILES = \
GLUT_FILES = \
$(DIRECTORY)/include/GL/glut.h \
$(DIRECTORY)/include/GL/glutf90.h \
$(DIRECTORY)/src/glut/glx/Makefile* \
@@ -287,7 +294,10 @@ DEMO_FILES = \
$(DIRECTORY)/src/glut/dos/Makefile.DJ \
$(DIRECTORY)/src/glut/dos/PC_HW/*.[chS] \
$(DIRECTORY)/src/glut/ggi/*.[ch] \
$(DIRECTORY)/src/glut/ggi/Makefile \
$(DIRECTORY)/src/glut/ggi/Makefile
DEMO_FILES = \
$(DIRECTORY)/progs/beos/*.cpp \
$(DIRECTORY)/progs/beos/Makefile \
$(DIRECTORY)/progs/images/*.rgb \
@@ -344,7 +354,7 @@ lib_gz:
demo_gz:
cd .. ; \
tar -cvf $(DEMO_NAME).tar $(DEMO_FILES) ; \
tar -cvf $(DEMO_NAME).tar $(DEMO_FILES) $(GLUT_FILES) ; \
gzip $(DEMO_NAME).tar ; \
mv $(DEMO_NAME).tar.gz $(DIRECTORY)
@@ -357,7 +367,7 @@ lib_bz2:
demo_bz2:
cd .. ; \
tar -cvf $(DEMO_NAME).tar $(DEMO_FILES) ; \
tar -cvf $(DEMO_NAME).tar $(DEMO_FILES) $(GLUT_FILES) ; \
bzip2 $(DEMO_NAME).tar ; \
mv $(DEMO_NAME).tar.bz2 $(DIRECTORY)
@@ -371,7 +381,7 @@ lib_zip:
demo_zip:
-rm $(DEMO_NAME).zip ; \
cd .. ; \
zip -r $(DEMO_NAME).zip $(DEMO_FILES) ; \
zip -r $(DEMO_NAME).zip $(DEMO_FILES) $(GLUT_FILES) ; \
mv $(DEMO_NAME).zip $(DIRECTORY)
md5:

29
configs/linux-directfb Normal file
View File

@@ -0,0 +1,29 @@
# Configuration for DirectFB
include $(TOP)/configs/default
CONFIG_NAME = linux-directfb
# Compiler and flags
CC = gcc
CXX = g++
CFLAGS = -Wall -O3 -ffast-math -fPIC -std=c99 -D_GNU_SOURCE -D_POSIX_SOURCE -D_SVID_SOURCE \
-D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DPTHREADS
CXXFLAGS = -Wall -O3 -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
HAVE_X86 = $(shell uname -m | grep 'i[3-6]86' >/dev/null && echo yes)
ifeq ($(HAVE_X86), yes)
CFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
CXXFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
ASM_SOURCES = $(X86_SOURCES) $(X86_API)
endif
# Directories
SRC_DIRS = mesa glu
DRIVER_DIRS = directfb
PROGRAM_DIRS = # disabled
# Library/program dependencies
GL_LIB_DEPS = -lm -lpthread

28
docs/README.directfb Normal file
View File

@@ -0,0 +1,28 @@
Mesa DirectFB Information
Requirements
============
To build Mesa with DirectFB (DirectFBGL) support you need:
- DirectFB at least 0.9.21 (http://directfb.org)
- pkg-config at least 0.9 (http://pkgconfig.sf.net)
Installation
============
Run
make linux-directfb
to build Mesa and DirectFBGL module,
make install
to install OpenGL libraries and
make linux-directfb-install
to install DirectFBGL module in the proper location.

View File

@@ -25,6 +25,19 @@ GL_ARB_draw_buffers - allows a fragment program to write to a number of
GL_OES_read_format - allows one to query the fastest glReadPixels format
and datatype.
GL_ARB_pixel_buffer_object - buffer objects for pixel read/write functions.
DirectFB driver, contributed by Claudio Ciccani. See docs/README.directfb
for details.
Vertex/Fragment Program PRINT Instruction
-----------------------------------------
The GL_NV_vertex_program and GL_NV_fragment_program languages have been
extended with a PRINT instruction.
To Do before release
@@ -53,4 +66,4 @@ D3D needs updating
----------------------------------------------------------------------
$Id: RELNOTES-6.3,v 3.6 2004/12/09 23:21:36 brianp Exp $
$Id: RELNOTES-6.3,v 3.7 2005/01/03 15:55:51 brianp Exp $

View File

@@ -1317,11 +1317,12 @@ Mesa Version History
6.3 Month day, 2004
New:
- GL_ARB_draw_buffers extension
- GL_ARB_pixel_buffer_object extension
- GL_OES_read_format extension (Ian Romanick)
- full support for GL_EXT_pixel_buffer_object (convolution filters,
polygon stipple, colormaps, etc)
- DirectFB driver (Claudio Ciccani)
Changes:
- added -stereo option for glxgears demo (Jacek Rosik)
Bug fixes:
fixes from 6.2.1, plus:
-
- some functions didn't support PBO functionality
- glGetTexImage didn't convert color index images to RGBA as required

89
include/GL/directfbgl.h Normal file
View File

@@ -0,0 +1,89 @@
/*
(c) Copyright 2001 convergence integrated media GmbH.
All rights reserved.
Written by Denis Oliver Kropp <dok@convergence.de> and
Andreas Hundt <andi@convergence.de>.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __DIRECTFBGL_H__
#define __DIRECTFBGL_H__
#include <directfb.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct {
int buffer_size;
int depth_size;
int stencil_size;
int aux_buffers;
int red_size;
int green_size;
int blue_size;
int alpha_size;
int accum_red_size;
int accum_green_size;
int accum_blue_size;
int accum_alpha_size;
DFBBoolean double_buffer;
DFBBoolean stereo;
} DFBGLAttributes;
DEFINE_INTERFACE( IDirectFBGL,
/** Context handling **/
/*
* Acquire the hardware lock.
*/
DFBResult (*Lock) (
IDirectFBGL *thiz
);
/*
* Release the lock.
*/
DFBResult (*Unlock) (
IDirectFBGL *thiz
);
/*
* Query the OpenGL attributes.
*/
DFBResult (*GetAttributes) (
IDirectFBGL *thiz,
DFBGLAttributes *attributes
);
)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
* Version: 6.2
* Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2005 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"),
@@ -495,6 +495,17 @@ extern Bool glXDrawableAttribARB(Display *dpy, GLXDrawable draw, const int *attr
#endif /* GLX_ARB_render_texture */
/*
* Remove this when glxext.h is updated.
*/
#ifndef GLX_NV_float_buffer
#define GLX_NV_float_buffer 1
#define GLX_FLOAT_COMPONENTS_NV 0x20B0
#endif /* GLX_NV_float_buffer */
#ifdef __cplusplus
}

View File

@@ -41,22 +41,23 @@
/* Some ugly global vars */
static GLXFBConfigSGIX gFBconfig = 0;
static Display *gDpy = NULL;
static int gScreen = 0;
static GLXPbufferSGIX gPBuffer = 0;
static FBCONFIG gFBconfig = 0;
static PBUFFER gPBuffer = 0;
static int gWidth, gHeight;
static GLXContext glCtx;
/*
* Create the pbuffer and return a GLXPbufferSGIX handle.
* Create the pbuffer and return a GLXPbuffer handle.
*
* We loop over a list of fbconfigs trying to create
* a pixel buffer. We return the first pixel buffer which we successfully
* create.
*/
static GLXPbufferSGIX
static PBUFFER
MakePbuffer( Display *dpy, int screen, int width, int height )
{
#define NUM_FB_CONFIGS 4
@@ -69,8 +70,8 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
int fbAttribs[NUM_FB_CONFIGS][100] = {
{
/* Single buffered, with depth buffer */
GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
GLX_DRAWABLE_TYPE_SGIX, GLX_PBUFFER_BIT_SGIX,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
@@ -81,8 +82,8 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
},
{
/* Double buffered, with depth buffer */
GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
GLX_DRAWABLE_TYPE_SGIX, GLX_PBUFFER_BIT_SGIX,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
@@ -93,8 +94,8 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
},
{
/* Single bufferd, without depth buffer */
GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
GLX_DRAWABLE_TYPE_SGIX, GLX_PBUFFER_BIT_SGIX,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
@@ -105,8 +106,8 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
},
{
/* Double bufferd, without depth buffer */
GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
GLX_DRAWABLE_TYPE_SGIX, GLX_PBUFFER_BIT_SGIX,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
@@ -116,13 +117,10 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
None
}
};
int pbAttribs[] = {
GLX_LARGEST_PBUFFER_SGIX, True,
GLX_PRESERVED_CONTENTS_SGIX, False,
None
};
GLXFBConfigSGIX *fbConfigs;
GLXPbufferSGIX pBuffer = None;
Bool largest = True;
Bool preserve = False;
FBCONFIG *fbConfigs;
PBUFFER pBuffer = None;
int nConfigs;
int i;
int attempt;
@@ -130,23 +128,23 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
for (attempt=0; attempt<NUM_FB_CONFIGS; attempt++) {
/* Get list of possible frame buffer configurations */
fbConfigs = glXChooseFBConfigSGIX(dpy, screen, fbAttribs[attempt], &nConfigs);
fbConfigs = ChooseFBConfig(dpy, screen, fbAttribs[attempt], &nConfigs);
if (nConfigs==0 || !fbConfigs) {
printf("Error: glxChooseFBConfigSGIX failed\n");
printf("Error: glXChooseFBConfig failed\n");
XCloseDisplay(dpy);
return 0;
}
#ifdef DEBUG
#if 0 /*DEBUG*/
for (i=0;i<nConfigs;i++) {
printf("Config %d\n", i);
PrintFBConfigInfo(dpy, fbConfigs[i], 0);
PrintFBConfigInfo(dpy, screen, fbConfigs[i], 0);
}
#endif
/* Create the pbuffer using first fbConfig in the list that works. */
for (i=0;i<nConfigs;i++) {
pBuffer = CreatePbuffer(dpy, fbConfigs[i], width, height, pbAttribs);
pBuffer = CreatePbuffer(dpy, screen, fbConfigs[i], width, height, preserve, largest);
if (pBuffer) {
gFBconfig = fbConfigs[i];
gWidth = width;
@@ -178,9 +176,8 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
static int
Setup(int width, int height)
{
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
int pbSupport;
XVisualInfo *visInfo;
GLXContext glCtx;
/* Open the X display */
gDpy = XOpenDisplay(NULL);
@@ -193,7 +190,14 @@ Setup(int width, int height)
gScreen = DefaultScreen(gDpy);
/* Test that pbuffers are available */
if (!QueryPbuffers(gDpy, gScreen)) {
pbSupport = QueryPbuffers(gDpy, gScreen);
if (pbSupport == 1) {
printf("Using GLX 1.3 Pbuffers\n");
}
else if (pbSupport == 2) {
printf("Using SGIX Pbuffers\n");
}
else {
printf("Error: pbuffers not available on this screen\n");
XCloseDisplay(gDpy);
return 0;
@@ -208,7 +212,7 @@ Setup(int width, int height)
}
/* Get corresponding XVisualInfo */
visInfo = glXGetVisualFromFBConfigSGIX(gDpy, gFBconfig);
visInfo = GetVisualFromFBConfig(gDpy, gScreen, gFBconfig);
if (!visInfo) {
printf("Error: can't get XVisualInfo from FBconfig\n");
XCloseDisplay(gDpy);
@@ -240,11 +244,6 @@ Setup(int width, int height)
}
return 1; /* Success!! */
#else
printf("Error: GLX_SGIX_fbconfig and/or GLX_SGIX_pbuffer extensions not"
" available at compile-time.\n");
return 0;
#endif
}
@@ -360,7 +359,6 @@ Render(void)
int NumBoxes = 100;
int i;
InitGL();
glClearColor(0.2, 0.2, 0.9, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -470,9 +468,10 @@ main(int argc, char *argv[])
if (!Setup(width, height)) {
return 1;
}
InitGL();
Render();
WriteFile(fileName);
glXDestroyGLXPbufferSGIX( gDpy, gPBuffer );
DestroyPbuffer(gDpy, gScreen, gPBuffer);
}
return 0;
}

View File

@@ -20,18 +20,18 @@
static void
PrintConfigs(Display *dpy, int screen, Bool horizFormat)
{
GLXFBConfigSGIX *fbConfigs;
FBCONFIG *fbConfigs;
int nConfigs;
int i;
/* Note: you may want to tweek the attribute list to select a different
* set of fbconfigs.
*/
int fbAttribs[] = {
GLX_RENDER_TYPE_SGIX, 0,
GLX_DRAWABLE_TYPE_SGIX, 0,
GLX_RENDER_TYPE, 0,
GLX_DRAWABLE_TYPE, 0,
#if 0
GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
GLX_DRAWABLE_TYPE_SGIX, GLX_PIXMAP_BIT_SGIX,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
@@ -43,17 +43,9 @@ PrintConfigs(Display *dpy, int screen, Bool horizFormat)
/* Get list of possible frame buffer configurations */
#if 0
/* SGIX method */
fbConfigs = glXChooseFBConfigSGIX(dpy, screen, fbAttribs, &nConfigs);
#else
/* GLX 1.3 method */
(void) fbAttribs;
fbConfigs = glXGetFBConfigs(dpy, screen, &nConfigs);
#endif
if (nConfigs==0 || !fbConfigs) {
printf("Error: glxChooseFBConfigSGIX failed\n");
fbConfigs = ChooseFBConfig(dpy, screen, fbAttribs, &nConfigs);
if (!nConfigs || !fbConfigs) {
printf("Error: glxChooseFBConfig failed\n");
return;
}
@@ -61,12 +53,12 @@ PrintConfigs(Display *dpy, int screen, Bool horizFormat)
if (horizFormat) {
printf(" ID VisualType Depth Lvl RGB CI DB Stereo R G B A");
printf(" Z S AR AG AB AA MSbufs MSnum Pbuffer\n");
printf(" Z S AR AG AB AA MSbufs MSnum Pbuffer Float\n");
}
/* Print config info */
for (i=0;i<nConfigs;i++) {
PrintFBConfigInfo(dpy, fbConfigs[i], horizFormat);
PrintFBConfigInfo(dpy, screen, fbConfigs[i], horizFormat);
}
/* free the list */

View File

@@ -3,8 +3,10 @@
* OpenGL pbuffers utility functions.
*
* Brian Paul
* April 1997
* Original code: April 1997
* Updated on 5 October 2002
* Updated again on 3 January 2005 to use GLX 1.3 functions in preference
* to the GLX_SGIX_fbconfig/pbuffer extensions.
*/
@@ -13,51 +15,140 @@
#include "pbutil.h"
/*
/**
* Test if we pixel buffers are available for a particular X screen.
* Input: dpy - the X display
* screen - screen number
* Return: 0 = pixel buffers not available.
* 1 = pixel buffers are available.
* 1 = pixel buffers are available via GLX 1.3.
* 2 = pixel buffers are available via GLX_SGIX_fbconfig/pbuffer.
*/
int
QueryPbuffers(Display *dpy, int screen)
{
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
char *extensions;
extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS);
if (!strstr(extensions,"GLX_SGIX_fbconfig")) {
return 0;
#if defined(GLX_VERSION_1_3)
{
/* GLX 1.3 supports pbuffers */
int glxVersionMajor, glxVersionMinor;
if (!glXQueryVersion(dpy, &glxVersionMajor, &glxVersionMinor)) {
/* GLX not available! */
return 0;
}
if (glxVersionMajor * 100 + glxVersionMinor >= 103) {
return 1;
}
/* fall-through */
}
if (!strstr(extensions,"GLX_SGIX_pbuffer")) {
return 0;
}
return 1;
#else
return 0;
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
/* Try the SGIX extensions */
{
char *extensions;
extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS);
if (!extensions ||
!strstr(extensions,"GLX_SGIX_fbconfig") ||
!strstr(extensions,"GLX_SGIX_pbuffer")) {
return 0;
}
return 2;
}
#endif
return 0;
}
#ifdef GLX_SGIX_fbconfig
FBCONFIG *
ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs)
{
int pbSupport = QueryPbuffers(dpy, screen);
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
return glXChooseFBConfig(dpy, screen, attribs, nConfigs);
}
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
return glXChooseFBConfigSGIX(dpy, screen, (int *) attribs, nConfigs);
}
#endif
return NULL;
}
/*
XVisualInfo *
GetVisualFromFBConfig(Display *dpy, int screen, FBCONFIG config)
{
int pbSupport = QueryPbuffers(dpy, screen);
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
return glXGetVisualFromFBConfig(dpy, config);
}
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
return glXGetVisualFromFBConfigSGIX(dpy, config);
}
#endif
return NULL;
}
/**
* Either use glXGetFBConfigAttrib() or glXGetFBConfigAttribSGIX()
* to query an fbconfig attribute.
*/
static int
GetFBConfigAttrib(Display *dpy,
#if defined(GLX_VERSION_1_3)
const GLXFBConfig config,
#elif defined(GLX_SGIX_fbconfig)
const GLXFBConfigSGIX config,
#endif
int attrib
)
{
int value;
#if defined(GLX_VERSION_1_3)
int glxVersionMajor, glxVersionMinor;
if (glXQueryVersion(dpy, &glxVersionMajor, &glxVersionMinor)
&& glxVersionMajor * 100 + glxVersionMinor >= 103) {
/* ok */
if (glXGetFBConfigAttrib(dpy, config, attrib, &value) != 0) {
value = 0;
}
return value;
}
/* fall-through */
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (glXGetFBConfigAttribSGIX(dpy, config, attrib, &value) != 0) {
value = 0;
}
return value;
#endif
return 0;
}
/**
* Print parameters for a GLXFBConfig to stdout.
* Input: dpy - the X display
* screen - the X screen number
* fbConfig - the fbconfig handle
* horizFormat - if true, print in horizontal format
*/
void
PrintFBConfigInfo(Display *dpy, GLXFBConfigSGIX fbConfig, Bool horizFormat)
PrintFBConfigInfo(Display *dpy, int screen, FBCONFIG config, Bool horizFormat)
{
int pbAttribs[] = {GLX_LARGEST_PBUFFER_SGIX, True,
GLX_PRESERVED_CONTENTS_SGIX, False,
None};
GLXPbufferSGIX pBuffer;
PBUFFER pBuffer;
int width=2, height=2;
int bufferSize, level, doubleBuffer, stereo, auxBuffers;
int redSize, greenSize, blueSize, alphaSize;
@@ -67,44 +158,49 @@ PrintFBConfigInfo(Display *dpy, GLXFBConfigSGIX fbConfig, Bool horizFormat)
int drawableType, renderType, xRenderable, xVisual, id;
int maxWidth, maxHeight, maxPixels;
int optWidth, optHeight;
int floatComponents;
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_BUFFER_SIZE, &bufferSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_LEVEL, &level);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_DOUBLEBUFFER, &doubleBuffer);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_STEREO, &stereo);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_AUX_BUFFERS, &auxBuffers);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_RED_SIZE, &redSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_GREEN_SIZE, &greenSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_BLUE_SIZE, &blueSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_ALPHA_SIZE, &alphaSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_DEPTH_SIZE, &depthSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_STENCIL_SIZE, &stencilSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_ACCUM_RED_SIZE, &accumRedSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_ACCUM_GREEN_SIZE, &accumGreenSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_ACCUM_BLUE_SIZE, &accumBlueSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_ACCUM_ALPHA_SIZE, &accumAlphaSize);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_SAMPLE_BUFFERS_SGIS, &sampleBuffers);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_SAMPLES_SGIS, &samples);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_DRAWABLE_TYPE_SGIX, &drawableType);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_RENDER_TYPE_SGIX, &renderType);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_X_RENDERABLE_SGIX, &xRenderable);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_X_VISUAL_TYPE_EXT, &xVisual);
/* do queries using the GLX 1.3 tokens (same as the SGIX tokens) */
bufferSize = GetFBConfigAttrib(dpy, config, GLX_BUFFER_SIZE);
level = GetFBConfigAttrib(dpy, config, GLX_LEVEL);
doubleBuffer = GetFBConfigAttrib(dpy, config, GLX_DOUBLEBUFFER);
stereo = GetFBConfigAttrib(dpy, config, GLX_STEREO);
auxBuffers = GetFBConfigAttrib(dpy, config, GLX_AUX_BUFFERS);
redSize = GetFBConfigAttrib(dpy, config, GLX_RED_SIZE);
greenSize = GetFBConfigAttrib(dpy, config, GLX_GREEN_SIZE);
blueSize = GetFBConfigAttrib(dpy, config, GLX_BLUE_SIZE);
alphaSize = GetFBConfigAttrib(dpy, config, GLX_ALPHA_SIZE);
depthSize = GetFBConfigAttrib(dpy, config, GLX_DEPTH_SIZE);
stencilSize = GetFBConfigAttrib(dpy, config, GLX_STENCIL_SIZE);
accumRedSize = GetFBConfigAttrib(dpy, config, GLX_ACCUM_RED_SIZE);
accumGreenSize = GetFBConfigAttrib(dpy, config, GLX_ACCUM_GREEN_SIZE);
accumBlueSize = GetFBConfigAttrib(dpy, config, GLX_ACCUM_BLUE_SIZE);
accumAlphaSize = GetFBConfigAttrib(dpy, config, GLX_ACCUM_ALPHA_SIZE);
sampleBuffers = GetFBConfigAttrib(dpy, config, GLX_SAMPLE_BUFFERS);
samples = GetFBConfigAttrib(dpy, config, GLX_SAMPLES);
drawableType = GetFBConfigAttrib(dpy, config, GLX_DRAWABLE_TYPE);
renderType = GetFBConfigAttrib(dpy, config, GLX_RENDER_TYPE);
xRenderable = GetFBConfigAttrib(dpy, config, GLX_X_RENDERABLE);
xVisual = GetFBConfigAttrib(dpy, config, GLX_X_VISUAL_TYPE);
if (!xRenderable || !(drawableType & GLX_WINDOW_BIT_SGIX))
xVisual = -1;
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_FBCONFIG_ID_SGIX, &id);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_MAX_PBUFFER_WIDTH_SGIX,
&maxWidth);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_MAX_PBUFFER_HEIGHT_SGIX,
&maxHeight);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_MAX_PBUFFER_PIXELS_SGIX,
&maxPixels);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_OPTIMAL_PBUFFER_WIDTH_SGIX,
&optWidth);
glXGetFBConfigAttribSGIX(dpy, fbConfig, GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX,
&optHeight);
id = GetFBConfigAttrib(dpy, config, GLX_FBCONFIG_ID);
maxWidth = GetFBConfigAttrib(dpy, config, GLX_MAX_PBUFFER_WIDTH);
maxHeight = GetFBConfigAttrib(dpy, config, GLX_MAX_PBUFFER_HEIGHT);
maxPixels = GetFBConfigAttrib(dpy, config, GLX_MAX_PBUFFER_PIXELS);
#if defined(GLX_SGIX_pbuffer)
optWidth = GetFBConfigAttrib(dpy, config, GLX_OPTIMAL_PBUFFER_WIDTH_SGIX);
optHeight = GetFBConfigAttrib(dpy, config, GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX);
#else
optWidth = optHeight = 0;
#endif
#if defined(GLX_NV_float_buffer)
floatComponents = GetFBConfigAttrib(dpy, config, GLX_FLOAT_COMPONENTS_NV);
#endif
pBuffer = CreatePbuffer(dpy, fbConfig, width, height, pbAttribs);
/* See if we can create a pbuffer with this config */
pBuffer = CreatePbuffer(dpy, screen, config, width, height, False, False);
if (horizFormat) {
printf("0x%03x ", id);
@@ -125,7 +221,8 @@ PrintFBConfigInfo(Display *dpy, GLXFBConfigSGIX fbConfig, Bool horizFormat)
printf("%2d %2d %2d %2d", accumRedSize, accumGreenSize, accumBlueSize,
accumAlphaSize);
printf(" %2d %2d", sampleBuffers, samples);
printf(" %s", pBuffer ? "y" : "n");
printf(" %s %c", pBuffer ? "y" : "n",
"ny"[floatComponents]);
printf("\n");
}
else {
@@ -148,27 +245,28 @@ PrintFBConfigInfo(Display *dpy, GLXFBConfigSGIX fbConfig, Bool horizFormat)
printf(" Sample Buffers: %d\n", sampleBuffers);
printf(" Samples/Pixel: %d\n", samples);
printf(" Drawable Types: ");
if (drawableType & GLX_WINDOW_BIT_SGIX) printf("Window ");
if (drawableType & GLX_PIXMAP_BIT_SGIX) printf("Pixmap ");
if (drawableType & GLX_PBUFFER_BIT_SGIX) printf("PBuffer");
if (drawableType & GLX_WINDOW_BIT) printf("Window ");
if (drawableType & GLX_PIXMAP_BIT) printf("Pixmap ");
if (drawableType & GLX_PBUFFER_BIT) printf("PBuffer");
printf("\n");
printf(" Render Types: ");
if (renderType & GLX_RGBA_BIT_SGIX) printf("RGBA ");
if (renderType & GLX_COLOR_INDEX_BIT_SGIX) printf("CI ");
printf("\n");
printf(" X Renderable: %s\n", xRenderable ? "yes" : "no");
/*
printf(" Max width: %d\n", maxWidth);
printf(" Max height: %d\n", maxHeight);
printf(" Max pixels: %d\n", maxPixels);
printf(" Optimum width: %d\n", optWidth);
printf(" Optimum height: %d\n", optHeight);
*/
printf(" Pbuffer: %s\n", pBuffer ? "yes" : "no");
printf(" Max Pbuffer width: %d\n", maxWidth);
printf(" Max Pbuffer height: %d\n", maxHeight);
printf(" Max Pbuffer pixels: %d\n", maxPixels);
printf(" Optimum Pbuffer width: %d\n", optWidth);
printf(" Optimum Pbuffer height: %d\n", optHeight);
printf(" Float Components: %s\n", floatComponents ? "yes" : "no");
}
if (pBuffer) {
glXDestroyGLXPbufferSGIX(dpy, pBuffer);
DestroyPbuffer(dpy, screen, pBuffer);
}
}
@@ -176,42 +274,73 @@ PrintFBConfigInfo(Display *dpy, GLXFBConfigSGIX fbConfig, Bool horizFormat)
/* This is only used by CreatePbuffer() */
static int XErrorFlag = 0;
static int HandleXError( Display *dpy, XErrorEvent *event )
static int HandleXError(Display *dpy, XErrorEvent *event)
{
XErrorFlag = 1;
return 0;
}
/*
/**
* Create a Pbuffer. Use an X error handler to deal with potential
* BadAlloc errors.
*
* Input: dpy - the X display
* fbConfig - an FBConfig as returned by glXChooseFBConfigSGIX().
* width, height - size of pixel buffer to request, in pixels.
* pbAttribs - list of pixel buffer attributes as used by
* glXCreateGLXPbufferSGIX().
* Return: a pixel buffer or None.
* pbAttribs - list of optional pixel buffer attributes
* Return: a Pbuffer or None.
*/
GLXPbufferSGIX
CreatePbuffer( Display *dpy, GLXFBConfigSGIX fbConfig,
int width, int height, int *pbAttribs )
PBUFFER
CreatePbuffer(Display *dpy, int screen, FBCONFIG config,
int width, int height, Bool largest, Bool preserve)
{
int (*oldHandler)( Display *, XErrorEvent * );
GLXPbufferSGIX pBuffer = None;
int (*oldHandler)(Display *, XErrorEvent *);
PBUFFER pBuffer = None;
int pbSupport = QueryPbuffers(dpy, screen);
/* Catch X protocol errors with our own error handler */
oldHandler = XSetErrorHandler( HandleXError );
oldHandler = XSetErrorHandler(HandleXError);
XErrorFlag = 0;
pBuffer = glXCreateGLXPbufferSGIX(dpy, fbConfig, width, height, pbAttribs);
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
/* GLX 1.3 */
int attribs[100], i = 0;
attribs[i++] = GLX_PBUFFER_WIDTH;
attribs[i++] = width;
attribs[i++] = GLX_PBUFFER_HEIGHT;
attribs[i++] = height;
attribs[i++] = GLX_PRESERVED_CONTENTS;
attribs[i++] = preserve;
attribs[i++] = GLX_LARGEST_PBUFFER;
attribs[i++] = largest;
attribs[i++] = 0;
pBuffer = glXCreatePbuffer(dpy, config, attribs);
}
else
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
int attribs[100], i = 0;
attribs[i++] = GLX_PRESERVED_CONTENTS;
attribs[i++] = preserve;
attribs[i++] = GLX_LARGEST_PBUFFER;
attribs[i++] = largest;
attribs[i++] = 0;
pBuffer = glXCreateGLXPbufferSGIX(dpy, config, width, height, attribs);
}
else
#endif
{
pBuffer = None;
}
/* Restore original X error handler */
(void) XSetErrorHandler( oldHandler );
(void) XSetErrorHandler(oldHandler);
/* Return pbuffer (may be None) */
if (!XErrorFlag && pBuffer!=None) {
if (!XErrorFlag && pBuffer != None) {
/*printf("config %d worked!\n", i);*/
return pBuffer;
}
@@ -221,7 +350,20 @@ CreatePbuffer( Display *dpy, GLXFBConfigSGIX fbConfig,
}
#endif /*GLX_SGIX_fbconfig*/
void
DestroyPbuffer(Display *dpy, int screen, PBUFFER pbuffer)
{
int pbSupport = QueryPbuffers(dpy, screen);
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
glXDestroyPbuffer(dpy, pbuffer);
return;
}
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
glXDestroyGLXPbufferSGIX(dpy, pbuffer);
return;
}
#endif
}

View File

@@ -1,4 +1,3 @@
/*
* OpenGL pbuffers utility functions.
*
@@ -15,23 +14,41 @@
#include <GL/glx.h>
#if defined(GLX_VERSION_1_3)
#define PBUFFER GLXPbuffer
#define FBCONFIG GLXFBConfig
#elif defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
#define PBUFFER GLXPbufferSGIX
#define FBCONFIG GLXFBConfigSGIX
#else
#define PBUFFER int
#define FBCONFIG int
#endif
extern int
QueryPbuffers(Display *dpy, int screen);
#ifdef GLX_SGIX_fbconfig
extern void
PrintFBConfigInfo(Display *dpy, int screen, FBCONFIG config, Bool horizFormat);
extern FBCONFIG *
ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs);
extern XVisualInfo *
GetVisualFromFBConfig(Display *dpy, int screen, FBCONFIG config);
extern PBUFFER
CreatePbuffer(Display *dpy, int screen, FBCONFIG config,
int width, int height, Bool preserve, Bool largest);
extern void
PrintFBConfigInfo(Display *dpy, GLXFBConfigSGIX fbConfig, Bool horizFormat);
extern GLXPbufferSGIX
CreatePbuffer( Display *dpy, GLXFBConfigSGIX fbConfig,
int width, int height, int *pbAttribs );
#endif /*GLX_SGIX_fbconfig*/
DestroyPbuffer(Display *dpy, int screen, PBUFFER pbuffer);
#endif /*PBUTIL_H*/

View File

@@ -276,8 +276,8 @@ __indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists)
const GLint op = X_GLrop_CallLists;
const GLuint cmdlenLarge = cmdlen + 4;
GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
(void) memcpy((void *)(pc + 0), (void *)(&op), 4);
(void) memcpy((void *)(pc + 4), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 4), (void *)(&op), 4);
(void) memcpy((void *)(pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(pc + 12), (void *)(&type), 4);
__glXSendLargeCommand(gc, pc, 16, lists, (compsize * n));
@@ -2992,8 +2992,8 @@ __indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values)
const GLint op = X_GLrop_PixelMapfv;
const GLuint cmdlenLarge = cmdlen + 4;
GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
(void) memcpy((void *)(pc + 0), (void *)(&op), 4);
(void) memcpy((void *)(pc + 4), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 4), (void *)(&op), 4);
(void) memcpy((void *)(pc + 8), (void *)(&map), 4);
(void) memcpy((void *)(pc + 12), (void *)(&mapsize), 4);
__glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4));
@@ -3023,8 +3023,8 @@ __indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values)
const GLint op = X_GLrop_PixelMapuiv;
const GLuint cmdlenLarge = cmdlen + 4;
GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
(void) memcpy((void *)(pc + 0), (void *)(&op), 4);
(void) memcpy((void *)(pc + 4), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 4), (void *)(&op), 4);
(void) memcpy((void *)(pc + 8), (void *)(&map), 4);
(void) memcpy((void *)(pc + 12), (void *)(&mapsize), 4);
__glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4));
@@ -3054,8 +3054,8 @@ __indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values)
const GLint op = X_GLrop_PixelMapusv;
const GLuint cmdlenLarge = cmdlen + 4;
GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
(void) memcpy((void *)(pc + 0), (void *)(&op), 4);
(void) memcpy((void *)(pc + 4), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 4), (void *)(&op), 4);
(void) memcpy((void *)(pc + 8), (void *)(&map), 4);
(void) memcpy((void *)(pc + 12), (void *)(&mapsize), 4);
__glXSendLargeCommand(gc, pc, 16, values, (mapsize * 2));

View File

@@ -26,6 +26,8 @@ default:
$(MAKE) osmesa-only ; \
elif [ "$(DRIVER_DIRS)" = "beos" ]; then \
$(MAKE) beos ; \
elif [ "$(DRIVER_DIRS)" = "directfb" ]; then \
$(MAKE) directfb; \
else \
$(MAKE) stand-alone ; \
fi
@@ -69,6 +71,30 @@ drivers-dri:
cd drivers/dri ; $(MAKE)
#####################################################################
# Stand-alone Mesa libGL, no built-in drivers (DirectFB)
LIBGL_CORE_SOURCES = \
$(CORE_SOURCES) \
$(ASM_SOURCES)
LIBGL_CORE_OBJECTS = \
$(CORE_OBJECTS) \
$(ASM_SOURCES:.S=.o)
# Make libGL from core object files
libgl-core: $(LIBGL_CORE_OBJECTS)
@ CC=$(CC) CXX=$(CXX) $(TOP)/bin/mklib -o $(GL_LIB) \
-major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-install $(LIB_DIR) $(MKLIB_OPTIONS) $(LIBGL_CORE_OBJECTS) $(GL_LIB_DEPS)
# DirectFB driver target
directfb: depend subdirs libgl-core
cd drivers/directfb; $(MAKE)
######################################################################
# Stand-alone Mesa libGL and libOSMesa

View File

@@ -0,0 +1,53 @@
# src/mesa/drivers/directfb/Makefile
TOP = ../../../..
include $(TOP)/configs/current
INCLUDE_DIRS = \
-I$(TOP)/include \
-I$(TOP)/src/mesa \
-I$(TOP)/src/mesa/main \
-I$(TOP)/src/mesa/glapi \
-I$(TOP)/src/mesa/math \
-I$(TOP)/src/mesa/tnl \
-I$(TOP)/src/mesa/shader \
-I$(TOP)/src/mesa/swrast \
-I$(TOP)/src/mesa/swrast_setup
DFB_CFLAGS = $(shell pkg-config --cflags directfb)
DFB_MODULEDIR = $(shell pkg-config --variable=moduledir directfb-internal)
DIRECTFBGL_MESA_SOURCES = ../common/driverfuncs.c idirectfbgl_mesa.c
DIRECTFBGL_MESA_OBJECTS = $(DIRECTFBGL_MESA_SOURCES:.c=.o)
DIRECTFBGL_MESA = libidirectfbgl_mesa.so
.c.o:
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(DFB_CFLAGS) $< -o $@
default: directfbgl_mesa
# Mesa DirectFBGL module
directfbgl_mesa: $(DIRECTFBGL_MESA_OBJECTS)
$(CC) -shared $(CFLAGS) $(DIRECTFBGL_MESA_OBJECTS) -o $(DIRECTFBGL_MESA) \
-Wl,-soname -Wl,$(DIRECTFBGL_MESA) -L$(TOP)/lib -lGL -lm
install:
@if test -d $(DFB_MODULEDIR); then \
echo "Installing DirectFBGL module."; \
else \
echo "*** Failed to determine DirectFB module's directory."; \
echo "*** Installation aborted."; \
exit 1; \
fi;
install -m 0755 $(DIRECTFBGL_MESA) $(DFB_MODULEDIR)/interfaces/IDirectFBGL/
clean:
rm -f *.o *.so

View File

@@ -0,0 +1,642 @@
/*
* Copyright (C) 2004 Claudio Ciccani <klan@users.sf.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* Based on glfbdev.c, written by Brian Paul.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <directfb.h>
#include <direct/messages.h>
#include <direct/interface.h>
#include <direct/mem.h>
#ifdef CLAMP
# undef CLAMP
#endif
#include "GL/directfbgl.h"
#include "glheader.h"
#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
#include "texformat.h"
#include "teximage.h"
#include "texstore.h"
#include "array_cache/acache.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#include "drivers/common/driverfuncs.h"
static DFBResult
Probe( void *data );
static DFBResult
Construct( IDirectFBGL *thiz,
IDirectFBSurface *surface );
#include <direct/interface_implementation.h>
DIRECT_INTERFACE_IMPLEMENTATION( IDirectFBGL, Mesa )
/*
* private data struct of IDirectFBGL
*/
typedef struct {
int ref; /* reference counter */
bool locked;
IDirectFBSurface *surface;
DFBSurfacePixelFormat format;
int width;
int height;
struct {
__u8 *start;
__u8 *end;
int pitch;
} video;
GLvisual visual;
GLframebuffer framebuffer;
GLcontext context;
} IDirectFBGL_data;
static bool dfb_mesa_setup_visual ( GLvisual *visual,
DFBSurfacePixelFormat format );
static bool dfb_mesa_create_context ( GLcontext *context,
GLframebuffer *framebuffer,
GLvisual *visual,
DFBSurfacePixelFormat format,
void *data );
static void dfb_mesa_destroy_context( GLcontext *context,
GLframebuffer *framebuffer );
static void
IDirectFBGL_Destruct( IDirectFBGL *thiz )
{
IDirectFBGL_data *data = (IDirectFBGL_data*) thiz->priv;
dfb_mesa_destroy_context( &data->context, &data->framebuffer );
data->surface->Release( data->surface );
DIRECT_DEALLOCATE_INTERFACE( thiz );
}
static DFBResult
IDirectFBGL_AddRef( IDirectFBGL *thiz )
{
DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
data->ref++;
return DFB_OK;
}
static DFBResult
IDirectFBGL_Release( IDirectFBGL *thiz )
{
DIRECT_INTERFACE_GET_DATA( IDirectFBGL )
if (--data->ref == 0) {
IDirectFBGL_Destruct( thiz );
}
return DFB_OK;
}
static DFBResult
IDirectFBGL_Lock( IDirectFBGL *thiz )
{
IDirectFBSurface *surface;
int width = 0;
int height = 0;
DFBResult err;
DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
if (data->locked)
return DFB_LOCKED;
surface = data->surface;
surface->GetSize( surface, &width, &height );
err = surface->Lock( surface, DSLF_READ | DSLF_WRITE,
(void**) &data->video.start, &data->video.pitch );
if (err != DFB_OK) {
D_ERROR( "DirectFBGL/Mesa: couldn't lock surface.\n" );
return err;
}
data->video.end = data->video.start + (height-1) * data->video.pitch;
if (data->width != width || data->height != height) {
data->width = width;
data->height = height;
_mesa_ResizeBuffersMESA();
}
data->locked = true;
return DFB_OK;
}
static DFBResult
IDirectFBGL_Unlock( IDirectFBGL *thiz )
{
DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
if (!data->locked)
return DFB_OK;
data->surface->Unlock( data->surface );
data->video.start = NULL;
data->video.end = NULL;
data->locked = false;
return DFB_OK;
}
static DFBResult
IDirectFBGL_GetAttributes( IDirectFBGL *thiz,
DFBGLAttributes *attributes )
{
GLvisual *visual;
DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
if (!attributes)
return DFB_INVARG;
visual = &data->visual;
attributes->buffer_size = visual->rgbBits ? : visual->indexBits;
attributes->depth_size = visual->depthBits;
attributes->stencil_size = visual->stencilBits;
attributes->aux_buffers = visual->numAuxBuffers;
attributes->red_size = visual->redBits;
attributes->green_size = visual->greenBits;
attributes->blue_size = visual->blueBits;
attributes->alpha_size = visual->alphaBits;
attributes->accum_red_size = visual->accumRedBits;
attributes->accum_green_size = visual->accumGreenBits;
attributes->accum_blue_size = visual->accumBlueBits;
attributes->accum_alpha_size = visual->accumAlphaBits;
attributes->double_buffer = (visual->doubleBufferMode != 0);
attributes->stereo = (visual->stereoMode != 0);
return DFB_OK;
}
/* exported symbols */
static DFBResult
Probe( void *data )
{
return DFB_OK;
}
static DFBResult
Construct( IDirectFBGL *thiz,
IDirectFBSurface *surface )
{
/* Allocate interface data. */
DIRECT_ALLOCATE_INTERFACE_DATA( thiz, IDirectFBGL );
/* Initialize interface data. */
data->ref = 1;
data->surface = surface;
surface->AddRef( surface );
surface->GetPixelFormat( surface, &data->format );
surface->GetSize( surface, &data->width, &data->height );
/* Configure visual. */
if (!dfb_mesa_setup_visual( &data->visual, data->format )) {
D_ERROR( "DirectFBGL/Mesa: failed to initialize visual.\n" );
surface->Release( surface );
return DFB_UNSUPPORTED;
}
/* Create context. */
if (!dfb_mesa_create_context( &data->context, &data->framebuffer,
&data->visual, data->format, (void*) data )) {
D_ERROR( "DirectFBGL/Mesa: failed to create context.\n" );
surface->Release( surface );
return DFB_UNSUPPORTED;
}
/* Assign interface pointers. */
thiz->AddRef = IDirectFBGL_AddRef;
thiz->Release = IDirectFBGL_Release;
thiz->Lock = IDirectFBGL_Lock;
thiz->Unlock = IDirectFBGL_Unlock;
thiz->GetAttributes = IDirectFBGL_GetAttributes;
return DFB_OK;
}
/* internal functions */
static const GLubyte*
get_string( GLcontext *ctx, GLenum pname )
{
switch (pname) {
case GL_VENDOR:
return "Claudio Ciccani";
case GL_VERSION:
return "1.0";
default:
return NULL;
}
}
static void
update_state( GLcontext *ctx, GLuint new_state )
{
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
_ac_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
}
static void
get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
GLcontext *ctx = _mesa_get_current_context();
IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
*width = (GLuint) data->width;
*height = (GLuint) data->height;
}
static void
set_viewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h )
{
_mesa_ResizeBuffersMESA();
}
/* required but not used */
static void
set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
{
return;
}
/* RGB332 */
#define NAME(PREFIX) PREFIX##_RGB332
#define SPAN_VARS \
IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \
GLubyte *P = data->video.end - (Y) * data->video.pitch + (X)
#define INC_PIXEL_PTR(P) P += 1
#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( (((R) & 0xe0)) | (((G) & 0xe0) >> 3) | ((B) >> 6) )
#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( (((R) & 0xe0)) | (((G) & 0xe0) >> 3) | ((B) >> 6) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ((*P & 0xe0) ); \
G = ((*P & 0x1c) << 3); \
B = ((*P & 0x03) << 6); \
A = CHAN_MAX
#include "swrast/s_spantemp.h"
/* ARGB1555 */
#define NAME(PREFIX) PREFIX##_ARGB1555
#define SPAN_VARS \
IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( (((A) & 0x80) << 8) | (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ((*P & 0x7c00) >> 7); \
G = ((*P & 0x03e0) >> 2); \
B = ((*P & 0x001f) << 3); \
A = ((*P & 0x8000) ? 0xff : 0)
#include "swrast/s_spantemp.h"
/* RGB16 */
#define NAME(PREFIX) PREFIX##_RGB16
#define SPAN_VARS \
IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ((*P & 0xf800) >> 8); \
G = ((*P & 0x07e0) >> 3); \
B = ((*P & 0x001f) << 3); \
A = CHAN_MAX
#include "swrast/s_spantemp.h"
/* RGB24 */
#define NAME(PREFIX) PREFIX##_RGB24
#define SPAN_VARS \
IDirectFBGL_data *data = ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \
GLubyte *P = data->video.end - (Y) * data->video.pitch + (X) * 3
#define INC_PIXEL_PTR(P) P += 3
#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = B; P[1] = G; P[2] = R
#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = B; P[1] = G; P[2] = R
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = P[2]; G = P[1]; B = P[0]; A = CHAN_MAX
#include "swrast/s_spantemp.h"
/* RGB32 */
#define NAME(PREFIX) PREFIX##_RGB32
#define SPAN_VARS \
IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \
GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4)
#define INC_PIXEL_PTR(P) P += 1
#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( ((R) << 16) | ((G) << 8) | (B) )
#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( ((R) << 16) | ((G) << 8) | (B) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ((*P & 0x00ff0000) >> 16); \
G = ((*P & 0x0000ff00) >> 8); \
B = ((*P & 0x000000ff) ); \
A = CHAN_MAX
#include "swrast/s_spantemp.h"
/* ARGB */
#define NAME(PREFIX) PREFIX##_ARGB
#define SPAN_VARS \
IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \
GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4)
#define INC_PIXEL_PTR(P) P += 1
#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( 0xff000000 | ((R) << 16) | ((G) << 8) | (B) )
#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( ((A) << 24) | ((R) << 16) | ((G) << 8) | (B) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ((*P & 0x00ff0000) >> 16); \
G = ((*P & 0x0000ff00) >> 8); \
B = ((*P & 0x000000ff) ); \
A = ((*P & 0xff000000) >> 24)
#include "swrast/s_spantemp.h"
/* AiRGB */
#define NAME(PREFIX) PREFIX##_AiRGB
#define SPAN_VARS \
IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \
GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4)
#define INC_PIXEL_PTR(P) P += 1
#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( ((R) << 16) | ((G) << 8) | (B) )
#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( ((0xff - (A)) << 24) | ((R) << 16) | ((G) << 8) | (B) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ((*P & 0x00ff0000) >> 16); \
G = ((*P & 0x0000ff00) >> 8); \
B = ((*P & 0x000000ff) ); \
A = (0xff - ((*P & 0xff000000) >> 24))
#include "swrast/s_spantemp.h"
static bool
dfb_mesa_setup_visual( GLvisual *visual,
DFBSurfacePixelFormat format )
{
GLboolean rgbFlag = GL_TRUE;
GLboolean dbFlag = GL_FALSE;
GLboolean stereoFlag = GL_FALSE;
GLint redBits = 0;
GLint blueBits = 0;
GLint greenBits = 0;
GLint alphaBits = 0;
GLint indexBits = 0;
GLint depthBits = 0;
GLint stencilBits = 0;
GLint accumRedBits = 0;
GLint accumGreenBits = 0;
GLint accumBlueBits = 0;
GLint accumAlphaBits = 0;
GLint numSamples = 0;
/* FIXME: LUT8 support. */
switch (format) {
case DSPF_RGB332:
redBits = 3;
greenBits = 3;
blueBits = 2;
break;
case DSPF_ARGB1555:
redBits = 5;
greenBits = 5;
blueBits = 5;
alphaBits = 1;
break;
case DSPF_RGB16:
redBits = 5;
greenBits = 6;
blueBits = 5;
break;
case DSPF_ARGB:
case DSPF_AiRGB:
alphaBits = 8;
case DSPF_RGB24:
case DSPF_RGB32:
redBits = 8;
greenBits = 8;
blueBits = 8;
break;
default:
D_WARN( "unsupported pixelformat" );
return false;
}
if (rgbFlag) {
accumRedBits = redBits;
accumGreenBits = greenBits;
accumBlueBits = blueBits;
accumAlphaBits = alphaBits;
depthBits = redBits + greenBits + blueBits;
stencilBits = alphaBits;
} else
depthBits = 8;
return _mesa_initialize_visual( visual,
rgbFlag, dbFlag, stereoFlag,
redBits, greenBits, blueBits, alphaBits,
indexBits, depthBits, stencilBits,
accumRedBits, accumGreenBits,
accumBlueBits, accumAlphaBits,
numSamples );
}
static bool
dfb_mesa_create_context( GLcontext *context,
GLframebuffer *framebuffer,
GLvisual *visual,
DFBSurfacePixelFormat format,
void *data )
{
struct dd_function_table functions;
struct swrast_device_driver *swdd;
_mesa_initialize_framebuffer( framebuffer, visual,
visual->haveDepthBuffer,
visual->haveStencilBuffer,
visual->haveAccumBuffer,
visual->accumAlphaBits > 0 );
_mesa_init_driver_functions( &functions );
functions.GetString = get_string;
functions.UpdateState = update_state;
functions.GetBufferSize = get_buffer_size;
functions.Viewport = set_viewport;
if (!_mesa_initialize_context( context, visual, NULL,
&functions, data )) {
D_DEBUG( "DirectFBGL/Mesa: _mesa_initialize_context() failed.\n" );
_mesa_free_framebuffer_data( framebuffer );
return false;
}
_swrast_CreateContext( context );
_ac_CreateContext( context );
_tnl_CreateContext( context );
_swsetup_CreateContext( context );
_swsetup_Wakeup( context );
swdd = _swrast_GetDeviceDriverReference( context );
swdd->SetBuffer = set_buffer;
switch (format) {
case DSPF_RGB332:
swdd->WriteRGBASpan = write_rgba_span_RGB332;
swdd->WriteRGBSpan = write_rgb_span_RGB332;
swdd->WriteMonoRGBASpan = write_monorgba_span_RGB332;
swdd->WriteRGBAPixels = write_rgba_pixels_RGB332;
swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB332;
swdd->ReadRGBASpan = read_rgba_span_RGB332;
swdd->ReadRGBAPixels = read_rgba_pixels_RGB332;
break;
case DSPF_ARGB1555:
swdd->WriteRGBASpan = write_rgba_span_ARGB1555;
swdd->WriteRGBSpan = write_rgb_span_ARGB1555;
swdd->WriteMonoRGBASpan = write_monorgba_span_ARGB1555;
swdd->WriteRGBAPixels = write_rgba_pixels_ARGB1555;
swdd->WriteMonoRGBAPixels = write_monorgba_pixels_ARGB1555;
swdd->ReadRGBASpan = read_rgba_span_ARGB1555;
swdd->ReadRGBAPixels = read_rgba_pixels_ARGB1555;
break;
case DSPF_RGB16:
swdd->WriteRGBASpan = write_rgba_span_RGB16;
swdd->WriteRGBSpan = write_rgb_span_RGB16;
swdd->WriteMonoRGBASpan = write_monorgba_span_RGB16;
swdd->WriteRGBAPixels = write_rgba_pixels_RGB16;
swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB16;
swdd->ReadRGBASpan = read_rgba_span_RGB16;
swdd->ReadRGBAPixels = read_rgba_pixels_RGB16;
break;
case DSPF_RGB24:
swdd->WriteRGBASpan = write_rgba_span_RGB24;
swdd->WriteRGBSpan = write_rgb_span_RGB24;
swdd->WriteMonoRGBASpan = write_monorgba_span_RGB24;
swdd->WriteRGBAPixels = write_rgba_pixels_RGB24;
swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB24;
swdd->ReadRGBASpan = read_rgba_span_RGB24;
swdd->ReadRGBAPixels = read_rgba_pixels_RGB24;
break;
case DSPF_RGB32:
swdd->WriteRGBASpan = write_rgba_span_RGB32;
swdd->WriteRGBSpan = write_rgb_span_RGB32;
swdd->WriteMonoRGBASpan = write_monorgba_span_RGB32;
swdd->WriteRGBAPixels = write_rgba_pixels_RGB32;
swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB32;
swdd->ReadRGBASpan = read_rgba_span_RGB32;
swdd->ReadRGBAPixels = read_rgba_pixels_RGB32;
break;
case DSPF_ARGB:
swdd->WriteRGBASpan = write_rgba_span_ARGB;
swdd->WriteRGBSpan = write_rgb_span_ARGB;
swdd->WriteMonoRGBASpan = write_monorgba_span_ARGB;
swdd->WriteRGBAPixels = write_rgba_pixels_ARGB;
swdd->WriteMonoRGBAPixels = write_monorgba_pixels_ARGB;
swdd->ReadRGBASpan = read_rgba_span_ARGB;
swdd->ReadRGBAPixels = read_rgba_pixels_ARGB;
break;
case DSPF_AiRGB:
swdd->WriteRGBASpan = write_rgba_span_AiRGB;
swdd->WriteRGBSpan = write_rgb_span_AiRGB;
swdd->WriteMonoRGBASpan = write_monorgba_span_AiRGB;
swdd->WriteRGBAPixels = write_rgba_pixels_AiRGB;
swdd->WriteMonoRGBAPixels = write_monorgba_pixels_AiRGB;
swdd->ReadRGBASpan = read_rgba_span_AiRGB;
swdd->ReadRGBAPixels = read_rgba_pixels_AiRGB;
break;
default:
D_BUG( "unexpected pixelformat" );
return false;
}
TNL_CONTEXT( context )->Driver.RunPipeline = _tnl_run_pipeline;
_mesa_enable_sw_extensions( context );
_mesa_make_current( context, framebuffer );
return true;
}
static void
dfb_mesa_destroy_context( GLcontext *context,
GLframebuffer *framebuffer )
{
_mesa_make_current( NULL, NULL );
_mesa_free_framebuffer_data( framebuffer );
_mesa_notifyDestroy( context );
_mesa_free_context_data( context );
}

View File

@@ -18,7 +18,7 @@ WINOBJ=
WINLIB=-L$(MESA)/src/glx/mini
MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini
INCLUDES = $(MINIGLX_INCLUDES) \
-I$(DRM_SOURCE_PATH)/shared \
-I$(DRM_SOURCE_PATH)/shared-core \
-I$(DRM_SOURCE_PATH)/libdrm \
$(SHARED_INCLUDES)
@@ -36,8 +36,7 @@ SHARED_INCLUDES = \
-I. \
-I$(TOP)/src/mesa/drivers/dri/common \
-Iserver \
-I$(DRM_SOURCE_PATH)/shared \
-I$(DRM_SOURCE_PATH)/linux \
-I$(DRM_SOURCE_PATH)/shared-core \
-I$(TOP)/include \
-I$(TOP)/include/GL/internal \
-I$(TOP)/src/mesa \
@@ -95,7 +94,7 @@ tags:
# Remove .o and backup files
clean:
-rm -f *.o */*.o *~ *.o *~ *.so server/*.o $(SYMLINKS)
-rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
-rm -f depend depend.bak
include depend

View File

@@ -210,6 +210,12 @@ DRI_CONF_OPT_BEGIN_V(dither_mode,enum,def,"0:2") \
DRI_CONF_DESC_END \
DRI_CONF_OPT_END
#define DRI_CONF_FLOAT_DEPTH(def) \
DRI_CONF_OPT_BEGIN(float_depth,bool,def) \
DRI_CONF_DESC(en,"Floating point depth buffer") \
DRI_CONF_DESC(de,"Fließkomma z-Puffer") \
DRI_CONF_OPT_END
/** \brief Performance-related options */
#define DRI_CONF_SECTION_PERFORMANCE \
DRI_CONF_SECTION_BEGIN \

View File

@@ -33,6 +33,9 @@ DRIVER_SOURCES = \
r300_state.c \
r300_render.c \
r300_lib.c \
r300_texmem.c \
r300_tex.c \
r300_texstate.c \
\
r200_context.c \
r200_ioctl.c \
@@ -52,6 +55,7 @@ DRIVER_SOURCES = \
r200_vtxfmt_sse.c \
r200_vtxfmt_x86.c
C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
X86_SOURCES = r200_vtxtmp_x86.S

View File

@@ -46,8 +46,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_ioctl.h"
#include "r300_context.h"
#include "r300_ioctl.h"
#include "radeon_reg.h"
#include "r300_reg.h"
#include "r300_cmdbuf.h"
#include "r300_emit.h"
// Set this to 1 for extremely verbose debugging of command buffers
@@ -212,6 +214,7 @@ void r300EmitState(r300ContextPtr r300)
r300->hw.all_dirty = GL_FALSE;
}
#if 0
static __inline__ uint32_t cmducs(int reg, int count)
{
@@ -236,6 +239,7 @@ static __inline__ uint32_t cmdvpu(int addr, int count)
return cmd.u;
}
#endif
#define CHECK( NM, COUNT ) \
static int check_##NM( r300ContextPtr r300, \
@@ -273,9 +277,12 @@ CHECK( vpu, vpucount(atom->cmd) ? (1 + vpucount(atom->cmd)*4) : 0 )
*/
void r300InitCmdBuf(r300ContextPtr r300)
{
int size;
int size, i, mtu;
r300->hw.max_state_size = 0;
mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
fprintf(stderr, "Using %d maximum texture units..\n", mtu);
/* Initialize state atoms */
ALLOC_STATE( vpt, always, R300_VPT_CMDSIZE, "vpt", 0 );
@@ -284,8 +291,8 @@ void r300InitCmdBuf(r300ContextPtr r300)
r300->hw.unk2080.cmd[0] = cmducs(0x2080, 1);
ALLOC_STATE( ovf, always, R300_OVF_CMDSIZE, "ovf", 0 );
r300->hw.ovf.cmd[R300_OVF_CMD_0] = cmducs(R300_VAP_OUTPUT_VTX_FMT_0, 2);
ALLOC_STATE( unk20B0, always, 3, "unk20B0", 0 );
r300->hw.unk20B0.cmd[0] = cmducs(0x20B0, 2);
ALLOC_STATE( vte, always, 3, "vte", 0 );
r300->hw.vte.cmd[0] = cmducs(R300_SE_VTE_CNTL, 2);
ALLOC_STATE( unk2134, always, 3, "unk2134", 0 );
r300->hw.unk2134.cmd[0] = cmducs(0x2134, 2);
ALLOC_STATE( unk2140, always, 2, "unk2140", 0 );
@@ -408,6 +415,29 @@ void r300InitCmdBuf(r300ContextPtr r300)
ALLOC_STATE( vps, vpu, R300_VPS_CMDSIZE, "vps", 0 );
r300->hw.vps.cmd[R300_VPS_CMD_0] = cmdvpu(R300_PVS_UPLOAD_POINTSIZE, 1);
/* Textures */
ALLOC_STATE( tex.filter, variable, mtu+1, "tex_filter", 0 );
r300->hw.tex.filter.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_FILTER_0, 0);
ALLOC_STATE( tex.unknown1, variable, mtu+1, "tex_unknown1", 0 );
r300->hw.tex.unknown1.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_UNK1_0, 0);
ALLOC_STATE( tex.size, variable, mtu+1, "tex_size", 0 );
r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_SIZE_0, 0);
ALLOC_STATE( tex.format, variable, mtu+1, "tex_format", 0 );
r300->hw.tex.format.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_FORMAT_0, 0);
ALLOC_STATE( tex.offset, variable, mtu+1, "tex_offset", 0 );
r300->hw.tex.offset.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_OFFSET_0, 0);
ALLOC_STATE( tex.unknown4, variable, mtu+1, "tex_unknown4", 0 );
r300->hw.tex.unknown4.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_UNK4_0, 0);
ALLOC_STATE( tex.unknown5, variable, mtu+1, "tex_unknown5", 0 );
r300->hw.tex.unknown5.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_UNK5_0, 0);
/* Setup the atom linked list */
make_empty_list(&r300->hw.atomlist);
r300->hw.atomlist.name = "atom-list";
@@ -415,7 +445,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
insert_at_tail(&r300->hw.atomlist, &r300->hw.vpt);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2080);
insert_at_tail(&r300->hw.atomlist, &r300->hw.ovf);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk20B0);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vte);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2134);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2140);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vir[0]);
@@ -477,6 +507,14 @@ void r300InitCmdBuf(r300ContextPtr r300)
insert_at_tail(&r300->hw.atomlist, &r300->hw.vpp);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vps);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.filter);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.unknown1);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.size);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.format);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.offset);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.unknown4);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.unknown5);
r300->hw.is_dirty = GL_TRUE;
r300->hw.all_dirty = GL_TRUE;
@@ -511,3 +549,206 @@ void r300DestroyCmdBuf(r300ContextPtr r300)
}
}
void r300EmitBlit(r300ContextPtr rmesa,
GLuint color_fmt,
GLuint src_pitch,
GLuint src_offset,
GLuint dst_pitch,
GLuint dst_offset,
GLint srcx, GLint srcy,
GLint dstx, GLint dsty, GLuint w, GLuint h)
{
drm_radeon_cmd_header_t *cmd;
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr,
"%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
__FUNCTION__, src_pitch, src_offset, srcx, srcy,
dst_pitch, dst_offset, dstx, dsty, w, h);
assert((src_pitch & 63) == 0);
assert((dst_pitch & 63) == 0);
assert((src_offset & 1023) == 0);
assert((dst_offset & 1023) == 0);
assert(w < (1 << 16));
assert(h < (1 << 16));
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 8 * sizeof(int),
__FUNCTION__);
cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
cmd[1].i = R200_CP_CMD_BITBLT_MULTI | (5 << 16);
cmd[2].i = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
RADEON_GMC_DST_PITCH_OFFSET_CNTL |
RADEON_GMC_BRUSH_NONE |
(color_fmt << 8) |
RADEON_GMC_SRC_DATATYPE_COLOR |
RADEON_ROP3_S |
RADEON_DP_SRC_SOURCE_MEMORY |
RADEON_GMC_CLR_CMP_CNTL_DIS | RADEON_GMC_WR_MSK_DIS);
cmd[3].i = ((src_pitch / 64) << 22) | (src_offset >> 10);
cmd[4].i = ((dst_pitch / 64) << 22) | (dst_offset >> 10);
cmd[5].i = (srcx << 16) | srcy;
cmd[6].i = (dstx << 16) | dsty; /* dst */
cmd[7].i = (w << 16) | h;
}
void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
{
if (rmesa->radeon.dri.drmMinor >= 6) {
drm_radeon_cmd_header_t *cmd;
assert(!(flags & ~(RADEON_WAIT_2D | RADEON_WAIT_3D)));
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
1 * sizeof(int),
__FUNCTION__);
cmd[0].i = 0;
cmd[0].wait.cmd_type = RADEON_CMD_WAIT;
cmd[0].wait.flags = flags;
}
}
void r300EmitLOAD_VBPNTR(r300ContextPtr rmesa, int start)
{
int i, a, count;
GLuint dw;
LOCAL_VARS
count=rmesa->state.aos_count;
a=1+(count>>1)*3+(count & 1)*2;
start_packet3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, a-1);
e32(count);
for(i=0;i+1<count;i+=2){
e32( (rmesa->state.aos[i].element_size << 0)
|(rmesa->state.aos[i].stride << 8)
|(rmesa->state.aos[i+1].element_size << 16)
|(rmesa->state.aos[i+1].stride << 24)
);
e32(rmesa->state.aos[i].offset+start*4*rmesa->state.aos[i].stride);
e32(rmesa->state.aos[i+1].offset+start*4*rmesa->state.aos[i+1].stride);
}
if(count & 1){
e32( (rmesa->state.aos[count-1].element_size << 0)
|(rmesa->state.aos[count-1].stride << 8)
);
e32(rmesa->state.aos[count-1].offset+start*4*rmesa->state.aos[count-1].stride);
}
/* delay ? */
#if 0
e32(RADEON_CP_PACKET2);
e32(RADEON_CP_PACKET2);
#endif
}
void static inline upload_vertex_shader_fragment(PREFIX int dest, struct r300_vertex_shader_fragment *vsf)
{
int i;
LOCAL_VARS
if(vsf->length==0)return;
if(vsf->length & 0x3){
fprintf(stderr,"VERTEX_SHADER_FRAGMENT must have length divisible by 4\n");
exit(-1);
}
vsf_start_fragment(dest, vsf->length);
for(i=0;i<vsf->length;i++)
e32(vsf->body.d[i]);
}
void r300EmitVertexShader(r300ContextPtr rmesa)
{
LOCAL_VARS
upload_vertex_shader_fragment(PASS_PREFIX VSF_DEST_PROGRAM, &(rmesa->state.vertex_shader.program));
upload_vertex_shader_fragment(PASS_PREFIX VSF_DEST_MATRIX0, &(rmesa->state.vertex_shader.matrix[0]));
upload_vertex_shader_fragment(PASS_PREFIX VSF_DEST_MATRIX1, &(rmesa->state.vertex_shader.matrix[0]));
upload_vertex_shader_fragment(PASS_PREFIX VSF_DEST_MATRIX2, &(rmesa->state.vertex_shader.matrix[0]));
upload_vertex_shader_fragment(PASS_PREFIX VSF_DEST_VECTOR0, &(rmesa->state.vertex_shader.vector[0]));
upload_vertex_shader_fragment(PASS_PREFIX VSF_DEST_VECTOR1, &(rmesa->state.vertex_shader.vector[1]));
upload_vertex_shader_fragment(PASS_PREFIX VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1));
upload_vertex_shader_fragment(PASS_PREFIX VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2));
reg_start(R300_VAP_PVS_CNTL_1, 2);
e32( (rmesa->state.vertex_shader.program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT)
| (rmesa->state.vertex_shader.unknown_ptr1 << R300_PVS_CNTL_1_UNKNOWN_SHIFT)
| (rmesa->state.vertex_shader.program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT)
);
e32( (rmesa->state.vertex_shader.param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT)
| (rmesa->state.vertex_shader.param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT)
);
e32( (rmesa->state.vertex_shader.unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT)
| (rmesa->state.vertex_shader.unknown_ptr3 << 0));
reg_start(R300_VAP_PVS_WAITIDLE,0);
e32(0x00000000);
}
void r300EmitPixelShader(r300ContextPtr rmesa)
{
int i,k;
LOCAL_VARS
if(rmesa->state.pixel_shader.program.tex.length>0){
reg_start(R300_PFS_TEXI_0, rmesa->state.pixel_shader.program.tex.length-1);
for(i=0;i<rmesa->state.pixel_shader.program.tex.length;i++)
e32(rmesa->state.pixel_shader.program.tex.inst[i]);
}
if(rmesa->state.pixel_shader.program.alu.length>0){
#define OUTPUT_FIELD(reg, field) \
reg_start(reg,rmesa->state.pixel_shader.program.alu.length-1); \
for(i=0;i<rmesa->state.pixel_shader.program.alu.length;i++) \
e32(rmesa->state.pixel_shader.program.alu.inst[i].field);
OUTPUT_FIELD(R300_PFS_INSTR0_0, inst0);
OUTPUT_FIELD(R300_PFS_INSTR1_0, inst1);
OUTPUT_FIELD(R300_PFS_INSTR2_0, inst2);
OUTPUT_FIELD(R300_PFS_INSTR3_0, inst3);
#undef OUTPUT_FIELD
}
reg_start(R300_PFS_NODE_0, 3);
for(i=0;i<4;i++){
e32( (rmesa->state.pixel_shader.program.node[i].alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT)
| (rmesa->state.pixel_shader.program.node[i].alu_end << R300_PFS_NODE_ALU_END_SHIFT)
| (rmesa->state.pixel_shader.program.node[i].tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT)
| (rmesa->state.pixel_shader.program.node[i].tex_end << R300_PFS_NODE_TEX_END_SHIFT)
| ( (i==3) ? R300_PFS_NODE_LAST_NODE : 0)
);
}
reg_start(R300_PFS_CNTL_0, 2);
/* PFS_CNTL_0 */
e32((rmesa->state.pixel_shader.program.active_nodes-1) | (rmesa->state.pixel_shader.program.first_node_has_tex<<3));
/* PFS_CNTL_1 */
e32(rmesa->state.pixel_shader.program.temp_register_count);
/* PFS_CNTL_2 */
e32( (rmesa->state.pixel_shader.program.alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT)
| (rmesa->state.pixel_shader.program.alu_end << R300_PFS_CNTL_ALU_END_SHIFT)
| (rmesa->state.pixel_shader.program.tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT)
| (rmesa->state.pixel_shader.program.tex_end << R300_PFS_CNTL_TEX_END_SHIFT)
);
if(rmesa->state.pixel_shader.param_length>0){
reg_start(R300_PFS_PARAM_0_X, rmesa->state.pixel_shader.param_length*4-1);
for(i=0;i<rmesa->state.pixel_shader.param_length;i++){
efloat(rmesa->state.pixel_shader.param[i].x);
efloat(rmesa->state.pixel_shader.param[i].y);
efloat(rmesa->state.pixel_shader.param[i].z);
efloat(rmesa->state.pixel_shader.param[i].w);
}
}
}

View File

@@ -98,5 +98,18 @@ static __inline__ uint32_t* r300AllocCmdBuf(r300ContextPtr r300,
return ptr;
}
extern void r300EmitBlit(r300ContextPtr rmesa,
GLuint color_fmt,
GLuint src_pitch,
GLuint src_offset,
GLuint dst_pitch,
GLuint dst_offset,
GLint srcx, GLint srcy,
GLint dstx, GLint dsty, GLuint w, GLuint h);
extern void r300EmitWait(r300ContextPtr rmesa, GLuint flags);
extern void r300EmitLOAD_VBPNTR(r300ContextPtr rmesa, int start);
extern void r300EmitVertexShader(r300ContextPtr rmesa);
extern void r300EmitPixelShader(r300ContextPtr rmesa);
#endif /* __R300_CMDBUF_H__ */

View File

@@ -57,6 +57,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_cmdbuf.h"
#include "r300_state.h"
#include "r300_ioctl.h"
#include "r300_tex.h"
#include "vblank.h"
#include "utils.h"
@@ -147,7 +148,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
struct dd_function_table functions;
r300ContextPtr r300;
GLcontext *ctx;
int tcl_mode;
int tcl_mode, i;
assert(glVisual);
assert(driContextPriv);
@@ -171,7 +172,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
_mesa_init_driver_functions(&functions);
r300InitIoctlFuncs(&functions);
r300InitStateFuncs(&functions);
//r200InitTextureFuncs(&functions);
r300InitTextureFuncs(&functions);
if (!radeonInitContext(&r300->radeon, &functions,
glVisual, driContextPriv, sharedContextPrivate)) {
@@ -180,6 +181,35 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
}
/* Init r300 context data */
r300->dma.buf0_address = r300->radeon.radeonScreen->buffers->list[0].address;
(void)memset(r300->texture_heaps, 0, sizeof(r300->texture_heaps));
make_empty_list(&r300->swapped);
r300->nr_heaps = 1 /* screen->numTexHeaps */ ;
assert(r300->nr_heaps < R200_NR_TEX_HEAPS);
for (i = 0; i < r300->nr_heaps; i++) {
r300->texture_heaps[i] = driCreateTextureHeap(i, r300,
screen->
texSize[i], 12,
RADEON_NR_TEX_REGIONS,
(drmTextureRegionPtr)
r300->radeon.sarea->
tex_list[i],
&r300->radeon.sarea->
tex_age[i],
&r300->swapped,
sizeof
(r300TexObj),
(destroy_texture_object_t
*)
r300DestroyTexObj);
}
r300->texture_depth = driQueryOptioni(&r300->radeon.optionCache,
"texture_depth");
if (r300->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
r300->texture_depth = (screen->cpp == 4) ?
DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
/* Set the maximum texture size small enough that we can guarentee that
* all texture units can bind a maximal texture and have them both in
@@ -239,8 +269,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
#if 0
/* plug in a few more device driver functions */
/* XXX these should really go right after _mesa_init_driver_functions() */
r200InitPixelFuncs(ctx);
r200InitSwtcl(ctx);
r300InitPixelFuncs(ctx);
r300InitSwtcl(ctx);
#endif
TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;

View File

@@ -54,9 +54,16 @@ typedef struct r300_context *r300ContextPtr;
#include "radeon_lock.h"
#include "mm.h"
typedef GLuint uint32_t;
typedef GLubyte uint8_t;
/* We should probably change types within vertex_shader
and pixel_shader structure later on */
#define CARD32 GLuint
#include "vertex_shader.h"
#include "pixel_shader.h"
#undef CARD32
static __inline__ uint32_t r300PackFloat32(float fl)
{
@@ -66,6 +73,114 @@ static __inline__ uint32_t r300PackFloat32(float fl)
return u.u;
}
/************ DMA BUFFERS **************/
/* Need refcounting on dma buffers:
*/
struct r300_dma_buffer {
int refcount; /* the number of retained regions in buf */
drmBufPtr buf;
};
#define GET_START(rvb) (rmesa->radeon.radeonScreen->gart_buffer_offset + \
(rvb)->address - rmesa->dma.buf0_address + \
(rvb)->start)
/* A retained region, eg vertices for indexed vertices.
*/
struct r300_dma_region {
struct r300_dma_buffer *buf;
char *address; /* == buf->address */
int start, end, ptr; /* offsets from start of buf */
int aos_start;
int aos_stride;
int aos_size;
};
struct r300_dma {
/* Active dma region. Allocations for vertices and retained
* regions come from here. Also used for emitting random vertices,
* these may be flushed by calling flush_current();
*/
struct r300_dma_region current;
void (*flush) (r300ContextPtr);
char *buf0_address; /* start of buf[0], for index calcs */
GLuint nr_released_bufs; /* flush after so many buffers released */
};
/* Texture related */
#define TEX_0 0x1
#define TEX_1 0x2
#define TEX_2 0x4
#define TEX_3 0x8
#define TEX_4 0x10
#define TEX_5 0x20
#define TEX_6 0x40
#define TEX_7 0x80
#define TEX_ALL 0xff
typedef struct r300_tex_obj r300TexObj, *r300TexObjPtr;
/* Texture object in locally shared texture space.
*/
struct r300_tex_obj {
driTextureObject base;
GLuint bufAddr; /* Offset to start of locally
shared texture block */
GLuint dirty_state; /* Flags (1 per texunit) for
whether or not this texobj
has dirty hardware state
(pp_*) that needs to be
brought into the
texunit. */
drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
/* Six, for the cube faces */
/* hardware register values */
/* Note that R200 has 8 registers per texture and R300 only 7 */
GLuint filter;
GLuint pitch; /* one of the unknown registers.. unknown 1 ?*/
GLuint size; /* npot only */
GLuint format;
GLuint offset; /* Image location in texmem.
All cube faces follow. */
GLuint unknown4;
GLuint unknown5;
/* end hardware registers */
/* registers computed by r200 code - keep them here to
compare against what is actually written.
to be removed later.. */
GLuint pp_border_color;
GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
GLuint format_x;
GLboolean border_fallback;
};
struct r300_texture_env_state {
r300TexObjPtr texobj;
GLenum format;
GLenum envMode;
};
#define R300_MAX_TEXTURE_UNITS 8
struct r300_texture_state {
struct r300_texture_env_state unit[R300_MAX_TEXTURE_UNITS];
int tc_count; /* number of incoming texture coordinates from VAP */
};
/**
* A block of hardware state.
*
@@ -233,6 +348,13 @@ struct r300_state_atom {
#define R300_VPS_ZERO_3 4
#define R300_VPS_CMDSIZE 5
/* the layout is common for all fields inside tex */
#define R300_TEX_CMD_0 0
#define R300_TEX_VALUE_0 1
/* We don't really use this, instead specify mtu+1 dynamically
#define R300_TEX_CMDSIZE (MAX_TEXTURE_UNITS+1)
*/
/**
* Cache for hardware register state.
*/
@@ -246,7 +368,7 @@ struct r300_hw_state {
struct r300_state_atom vpt; /* viewport (1D98) */
struct r300_state_atom unk2080; /* (2080) */
struct r300_state_atom ovf; /* output vertex format (2090) */
struct r300_state_atom unk20B0; /* (20B0) */
struct r300_state_atom vte; /* (20B0) */
struct r300_state_atom unk2134; /* (2134) */
struct r300_state_atom unk2140; /* (2140) */
struct r300_state_atom vir[2]; /* vap input route (2150/21E0) */
@@ -259,7 +381,6 @@ struct r300_hw_state {
struct r300_state_atom vof; /* VAP output format register 0x4000 */
struct r300_state_atom gb_enable; /* (4008) */
struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */
struct r300_state_atom txe; /* tex enable (4104) */
struct r300_state_atom unk4200; /* (4200) */
struct r300_state_atom unk4214; /* (4214) */
struct r300_state_atom ps; /* pointsize (421C) */
@@ -303,6 +424,22 @@ struct r300_hw_state {
struct r300_state_atom vpi; /* vp instructions */
struct r300_state_atom vpp; /* vp parameters */
struct r300_state_atom vps; /* vertex point size (?) */
/* 8 texture units */
/* the state is grouped by function and not by
texture unit. This makes single unit updates
really awkward - we are much better off
updating the whole thing at once */
struct {
struct r300_state_atom filter;
struct r300_state_atom unknown1;
struct r300_state_atom size;
struct r300_state_atom format;
struct r300_state_atom offset;
struct r300_state_atom unknown4;
struct r300_state_atom unknown5;
} tex;
struct r300_state_atom txe; /* tex enable (4104) */
};
@@ -329,8 +466,151 @@ struct r300_depthbuffer_state {
GLfloat scale;
};
struct r300_vap_reg_state {
/* input register assigments */
int i_coords;
int i_color[2];
int i_tex[R300_MAX_TEXTURE_UNITS];
};
/* Vertex shader state */
/* 64 appears to be the maximum */
#define VSF_MAX_FRAGMENT_LENGTH 64
struct r300_vertex_shader_fragment {
int length;
union {
GLuint d[VSF_MAX_FRAGMENT_LENGTH];
float f[VSF_MAX_FRAGMENT_LENGTH];
VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH/4];
} body;
};
#define VSF_DEST_PROGRAM 0x0
#define VSF_DEST_MATRIX0 0x200
#define VSF_DEST_MATRIX1 0x204
#define VSF_DEST_MATRIX2 0x208
#define VSF_DEST_VECTOR0 0x20c
#define VSF_DEST_VECTOR1 0x20d
#define VSF_DEST_UNKNOWN1 0x400
#define VSF_DEST_UNKNOWN2 0x406
struct r300_vertex_shader_state {
struct r300_vertex_shader_fragment program;
/* a bit of a waste - each uses only a subset of allocated space..
but easier to program */
struct r300_vertex_shader_fragment matrix[3];
struct r300_vertex_shader_fragment vector[2];
struct r300_vertex_shader_fragment unknown1;
struct r300_vertex_shader_fragment unknown2;
int program_start;
int unknown_ptr1; /* pointer within program space */
int program_end;
int param_offset;
int param_count;
int unknown_ptr2; /* pointer within program space */
int unknown_ptr3; /* pointer within program space */
};
/* 64 appears to be the maximum */
#define PSF_MAX_PROGRAM_LENGTH 64
struct r300_pixel_shader_program {
struct {
int length;
GLuint inst[PSF_MAX_PROGRAM_LENGTH];
} tex;
/* ALU intructions (logic and integer) */
struct {
int length;
struct {
GLuint inst0;
GLuint inst1;
GLuint inst2;
GLuint inst3;
} inst[PSF_MAX_PROGRAM_LENGTH];
} alu;
/* node information */
/* nodes are used to synchronize ALU and TEX streams */
/* There could be up to 4 nodes each consisting of
a number of TEX instructions followed by some ALU
instructions */
/* the last node of a program should always be node3 */
struct {
int tex_offset;
int tex_end;
int alu_offset;
int alu_end;
} node[4];
int active_nodes; /* must be between 1 and 4, inclusive */
int first_node_has_tex; /* other nodes always have it */
int temp_register_count; /* magic value goes into PFS_CNTL_1 */
/* entire program */
int tex_offset;
int tex_end;
int alu_offset;
int alu_end;
};
#define MAX_PIXEL_SHADER_PARAMS 32
struct r300_pixel_shader_state {
struct r300_pixel_shader_program program;
/* parameters */
int param_length; /* to limit the number of unnecessary writes */
struct {
float x;
float y;
float z;
float w;
} param[MAX_PIXEL_SHADER_PARAMS];
};
/* 8 is somewhat bogus... it is probably something like 24 */
#define R300_MAX_AOS_ARRAYS 8
struct r300_aos_rec {
GLuint offset;
int element_size; /* in dwords */
int stride; /* distance between elements, in dwords */
#define AOS_FORMAT_FLOAT 1
#define AOS_FORMAT_UBYTE 2
#define AOS_FORMAT_FLOAT_COLOR 3
int format;
int ncomponents; /* number of components - between 1 and 4, inclusive */
/* just guesses */
#define REG_COORDS 0
#define REG_COLOR0 1
#define REG_TEX0 2
int reg; /* which register they are assigned to. */
};
struct r300_state {
struct r300_depthbuffer_state depth;
struct r300_texture_state texture;
struct r300_vap_reg_state vap_reg;
struct r300_vertex_shader_state vertex_shader;
struct r300_pixel_shader_state pixel_shader;
struct r300_aos_rec aos[R300_MAX_AOS_ARRAYS];
int aos_count;
};
@@ -348,6 +628,38 @@ struct r300_context {
int elt_count; /* size of the buffer for vertices */
int attrib_count; /* size of the buffer for vertex attributes.. Somehow it can be different ? */
/* Vertex buffers
*/
#if 0 /* we'll need it later, but not now */
struct r300_ioctl ioctl;
#endif
struct r300_dma dma;
GLboolean save_on_next_unlock;
/* Texture object bookkeeping
*/
unsigned nr_heaps;
driTexHeap *texture_heaps[R200_NR_TEX_HEAPS];
driTextureObject swapped;
int texture_depth;
float initialMaxAnisotropy;
/* Clientdata textures;
*/
GLuint prefer_gart_client_texturing;
/* TCL stuff
*/
GLmatrix TexGenMatrix[R300_MAX_TEXTURE_UNITS];
GLboolean recheck_texgen[R300_MAX_TEXTURE_UNITS];
GLboolean TexGenNeedNormals[R300_MAX_TEXTURE_UNITS];
GLuint TexMatEnabled;
GLuint TexMatCompSel;
GLuint TexGenEnabled;
GLuint TexGenInputs;
GLuint TexGenCompSel;
GLmatrix tmpmat;
};
#define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx))

View File

@@ -96,6 +96,16 @@ static __inline__ uint32_t cmdpacket3(int packet)
return cmd.u;
}
static __inline__ uint32_t cmdcpdelay(unsigned short count)
{
drm_r300_cmd_header_t cmd;
cmd.delay.cmd_type = R300_CMD_CP_DELAY;
cmd.delay.count = count;
return cmd.u;
}
/* Prepare to write a register value to register at address reg.
If num_extra > 0 then the following extra values are written
to registers with address +4, +8 and so on.. */
@@ -181,4 +191,15 @@ cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
cmd[0].header.cmd_type=R300_CMD_END3D;
}
void static inline cp_delay(PREFIX unsigned short count)
{
LOCAL_VARS
cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
0, \
__FUNCTION__); \
cmd[0].i=cmdcpdelay(count);
}
#endif

View File

@@ -81,6 +81,26 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
cboffset += r300->radeon.radeonScreen->fbLocation;
R300_STATECHANGE(r300, vir[0]);
((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->unchecked_state.count = 1;
r300->hw.vir[0].cmd[1] = 0x21030003;
R300_STATECHANGE(r300, vir[1]);
((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->unchecked_state.count = 1;
r300->hw.vir[1].cmd[1] = 0xF688F688;
R300_STATECHANGE(r300, vic);
r300->hw.vic.cmd[R300_VIR_CNTL_0] = 0x00000001;
r300->hw.vic.cmd[R300_VIR_CNTL_1] = 0x00000405;
R300_STATECHANGE(r300, vof);
r300->hw.vof.cmd[R300_VOF_CNTL_0] = R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT
| R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0; /* no textures */
R300_STATECHANGE(r300, txe);
r300->hw.txe.cmd[R300_TXE_ENABLE] = 0;
R300_STATECHANGE(r300, vpt);
r300->hw.vpt.cmd[R300_VPT_XSCALE] = r300PackFloat32(1.0);
r300->hw.vpt.cmd[R300_VPT_XOFFSET] = r300PackFloat32(dPriv->x);
@@ -89,6 +109,13 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
r300->hw.vpt.cmd[R300_VPT_ZSCALE] = r300PackFloat32(1.0);
r300->hw.vpt.cmd[R300_VPT_ZOFFSET] = r300PackFloat32(0.0);
R300_STATECHANGE(r300, at);
r300->hw.at.cmd[R300_AT_ALPHA_TEST] = 0;
R300_STATECHANGE(r300, bld);
r300->hw.bld.cmd[R300_BLD_CBLEND] = 0;
r300->hw.bld.cmd[R300_BLD_ABLEND] = 0;
R300_STATECHANGE(r300, cb);
r300->hw.cb.cmd[R300_CB_OFFSET] = cboffset;
r300->hw.cb.cmd[R300_CB_PITCH] = cbpitch | R300_COLOR_UNKNOWN_22_23;
@@ -105,6 +132,11 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
for(i = 1; i <= 8; ++i)
r300->hw.ri.cmd[i] = R300_RS_INTERP_USED;
R300_STATECHANGE(r300, rc);
/* The second constant is needed to get glxgears display anything .. */
r300->hw.rc.cmd[1] = R300_RS_CNTL_0_UNKNOWN_7 | R300_RS_CNTL_0_UNKNOWN_18;
r300->hw.rc.cmd[2] = 0;
R300_STATECHANGE(r300, rr);
((drm_r300_cmd_header_t*)r300->hw.rr.cmd)->unchecked_state.count = 1;
r300->hw.rr.cmd[1] = 0x00004000;
@@ -282,6 +314,195 @@ void r300Flush(GLcontext * ctx)
r300FlushCmdBuf(r300, __FUNCTION__);
}
void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
{
struct r200_dma_buffer *dmabuf;
int fd = rmesa->radeon.dri.fd;
int index = 0;
int size = 0;
drmDMAReq dma;
int ret;
if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
fprintf(stderr, "%s\n", __FUNCTION__);
if (rmesa->dma.flush) {
rmesa->dma.flush(rmesa);
}
if (rmesa->dma.current.buf)
r300ReleaseDmaRegion(rmesa, &rmesa->dma.current, __FUNCTION__);
if (rmesa->dma.nr_released_bufs > 4)
r300FlushCmdBuf(rmesa, __FUNCTION__);
dma.context = rmesa->radeon.dri.hwContext;
dma.send_count = 0;
dma.send_list = NULL;
dma.send_sizes = NULL;
dma.flags = 0;
dma.request_count = 1;
dma.request_size = RADEON_BUFFER_SIZE;
dma.request_list = &index;
dma.request_sizes = &size;
dma.granted_count = 0;
LOCK_HARDWARE(&rmesa->radeon); /* no need to validate */
while (1) {
ret = drmDMA(fd, &dma);
if (ret == 0)
break;
if (rmesa->dma.nr_released_bufs) {
r200FlushCmdBufLocked(rmesa, __FUNCTION__);
}
if (rmesa->radeon.do_usleeps) {
UNLOCK_HARDWARE(&rmesa->radeon);
DO_USLEEP(1);
LOCK_HARDWARE(&rmesa->radeon);
}
}
UNLOCK_HARDWARE(&rmesa->radeon);
if (RADEON_DEBUG & DEBUG_DMA)
fprintf(stderr, "Allocated buffer %d\n", index);
dmabuf = CALLOC_STRUCT(r300_dma_buffer);
dmabuf->buf = &rmesa->radeon.radeonScreen->buffers->list[index];
dmabuf->refcount = 1;
rmesa->dma.current.buf = dmabuf;
rmesa->dma.current.address = dmabuf->buf->address;
rmesa->dma.current.end = dmabuf->buf->total;
rmesa->dma.current.start = 0;
rmesa->dma.current.ptr = 0;
}
void r300ReleaseDmaRegion(r300ContextPtr rmesa,
struct r300_dma_region *region, const char *caller)
{
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
if (!region->buf)
return;
if (rmesa->dma.flush)
rmesa->dma.flush(rmesa);
if (--region->buf->refcount == 0) {
drm_radeon_cmd_header_t *cmd;
if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
region->buf->buf->idx);
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
sizeof(*cmd),
__FUNCTION__);
cmd->dma.cmd_type = RADEON_CMD_DMA_DISCARD;
cmd->dma.buf_idx = region->buf->buf->idx;
FREE(region->buf);
rmesa->dma.nr_released_bufs++;
}
region->buf = 0;
region->start = 0;
}
/* Allocates a region from rmesa->dma.current. If there isn't enough
* space in current, grab a new buffer (and discard what was left of current)
*/
void r300AllocDmaRegion(r300ContextPtr rmesa,
struct r300_dma_region *region,
int bytes, int alignment)
{
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
if (rmesa->dma.flush)
rmesa->dma.flush(rmesa);
if (region->buf)
r300ReleaseDmaRegion(rmesa, region, __FUNCTION__);
alignment--;
rmesa->dma.current.start = rmesa->dma.current.ptr =
(rmesa->dma.current.ptr + alignment) & ~alignment;
if (rmesa->dma.current.ptr + bytes > rmesa->dma.current.end)
r300RefillCurrentDmaRegion(rmesa);
region->start = rmesa->dma.current.start;
region->ptr = rmesa->dma.current.start;
region->end = rmesa->dma.current.start + bytes;
region->address = rmesa->dma.current.address;
region->buf = rmesa->dma.current.buf;
region->buf->refcount++;
rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
rmesa->dma.current.start =
rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;
assert(rmesa->dma.current.ptr <= rmesa->dma.current.end);
}
/* Called via glXGetMemoryOffsetMESA() */
GLuint r300GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
const GLvoid * pointer)
{
GET_CURRENT_CONTEXT(ctx);
r300ContextPtr rmesa;
GLuint card_offset;
if (!ctx || !(rmesa = R300_CONTEXT(ctx))) {
fprintf(stderr, "%s: no context\n", __FUNCTION__);
return ~0;
}
if (!r300IsGartMemory(rmesa, pointer, 0))
return ~0;
if (rmesa->radeon.dri.drmMinor < 6)
return ~0;
card_offset = r300GartOffsetFromVirtual(rmesa, pointer);
return card_offset - rmesa->radeon.radeonScreen->gart_base;
}
GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
GLint size)
{
int offset =
(char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
int valid = (size >= 0 && offset >= 0
&& offset + size < rmesa->radeon.radeonScreen->gartTextures.size);
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "r300IsGartMemory( %p ) : %d\n", pointer,
valid);
return valid;
}
GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa, const GLvoid * pointer)
{
int offset =
(char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
fprintf(stderr, "offset=%08x\n", offset);
if (offset < 0 || offset > rmesa->radeon.radeonScreen->gartTextures.size)
return ~0;
else
return rmesa->radeon.radeonScreen->gart_texture_offset + offset;
}
void r300InitIoctlFuncs(struct dd_function_table *functions)
{
functions->Clear = r300Clear;

View File

@@ -36,7 +36,27 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __R300_IOCTL_H__
#define __R300_IOCTL_H__
#include "r300_context.h"
#include "radeon_drm.h"
extern GLuint r300GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
const GLvoid * pointer);
extern GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
GLint size);
extern GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa,
const GLvoid * pointer);
extern void r300Flush(GLcontext * ctx);
extern void r300RefillCurrentDmaRegion(r300ContextPtr rmesa);
extern void r300ReleaseDmaRegion(r300ContextPtr rmesa,
struct r300_dma_region *region, const char *caller);
extern void r300AllocDmaRegion(r300ContextPtr rmesa,
struct r300_dma_region *region,
int bytes, int alignment);
extern void r300InitIoctlFuncs(struct dd_function_table *functions);
#endif /* __R300_IOCTL_H__ */

View File

@@ -70,6 +70,19 @@ I am fairly certain that they are correct unless stated otherwise in comments.
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
/* END */
#define R300_SE_VTE_CNTL 0x20b0
# define R300_VPORT_X_SCALE_ENA 0x00000001
# define R300_VPORT_X_OFFSET_ENA 0x00000002
# define R300_VPORT_Y_SCALE_ENA 0x00000004
# define R300_VPORT_Y_OFFSET_ENA 0x00000008
# define R300_VPORT_Z_SCALE_ENA 0x00000010
# define R300_VPORT_Z_OFFSET_ENA 0x00000020
# define R300_VTX_XY_FMT 0x00000100
# define R300_VTX_Z_FMT 0x00000200
# define R300_VTX_W0_FMT 0x00000400
# define R300_VTX_W0_NORMALIZE 0x00000800
# define R300_VTX_ST_DENORMALIZED 0x00001000
/* BEGIN: Vertex data assembly - lots of uncertainties */
/* gap */
/* Where do we get our vertex data?
@@ -574,6 +587,11 @@ I am fairly certain that they are correct unless stated otherwise in comments.
# define R300_TX_SIZE_SHIFT 26 /* largest of width, height */
# define R300_TX_SIZE_MASK (15 << 26)
#define R300_TX_FORMAT_0 0x44C0
/* Note - other bits are not known yet.. */
# define R300_TX_FORMAT_WIDTH_SHIFT 12
# define R300_TX_FORMAT_WIDTH_MASK (0xf<<R300_TX_FORMAT_WIDTH_SHIFT)
# define R300_TX_FORMAT_HEIGHT_SHIFT 16
# define R300_TX_FORMAT_HEIGHT_MASK (0xf<<R300_TX_FORMAT_HEIGHT_SHIFT)
#define R300_TX_OFFSET_0 0x4540
/* BEGIN: Guess from R200 */
# define R300_TXO_ENDIAN_NO_SWAP (0 << 0)

View File

@@ -45,6 +45,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "array_cache/acache.h"
#include "tnl/tnl.h"
#include "radeon_reg.h"
#include "radeon_macros.h"
#include "radeon_ioctl.h"
#include "radeon_state.h"
#include "r300_context.h"
@@ -52,6 +54,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_state.h"
#include "r300_reg.h"
#include "r300_program.h"
#include "r300_tex.h"
#include "r300_lib.h"
@@ -72,84 +75,90 @@ static int r300_get_primitive_type(r300ContextPtr rmesa,
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
GLuint i;
int type=-1;
int type=-1, min_vertices=0;
char *name="UNKNOWN";
if(end<=start)return -1; /* do we need to watch for this ? */
fprintf(stderr, "[%d-%d]", start, end);
switch (prim & PRIM_MODE_MASK) {
case GL_LINES:
fprintf(stderr, "L ");
case GL_POINTS:
name="P";
type=R300_VAP_VF_CNTL__PRIM_POINTS;
min_vertices=1;
break;
case GL_LINES:
name="L";
type=R300_VAP_VF_CNTL__PRIM_LINES;
if(end<start+2){
fprintf(stderr, "Not enough vertices\n");
return -1; /* need enough vertices for Q */
}
break;
case GL_LINE_STRIP:
fprintf(stderr, "LS ");
min_vertices=2;
break;
case GL_LINE_STRIP:
name="LS";
type=R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
if(end<start+2){
fprintf(stderr, "Not enough vertices\n");
return -1; /* need enough vertices for Q */
}
min_vertices=2;
break;
case GL_LINE_LOOP:
fprintf(stderr, "LL ");
case GL_LINE_LOOP:
name="LL";
min_vertices=2;
return -1;
if(end<start+2){
fprintf(stderr, "Not enough vertices\n");
return -1; /* need enough vertices for Q */
}
break;
case GL_TRIANGLES:
fprintf(stderr, "T ");
case GL_TRIANGLES:
name="T";
type=R300_VAP_VF_CNTL__PRIM_TRIANGLES;
if(end<start+3){
fprintf(stderr, "Not enough vertices\n");
return -1; /* need enough vertices for Q */
}
min_vertices=3;
break;
case GL_TRIANGLE_STRIP:
fprintf(stderr, "TS ");
case GL_TRIANGLE_STRIP:
name="TS";
type=R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
if(end<start+3){
fprintf(stderr, "Not enough vertices\n");
return -1; /* need enough vertices for Q */
}
min_vertices=3;
break;
case GL_TRIANGLE_FAN:
fprintf(stderr, "TF ");
case GL_TRIANGLE_FAN:
name="TF";
type=R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
if(end<start+3){
fprintf(stderr, "Not enough vertices\n");
return -1; /* need enough vertices for Q */
}
min_vertices=3;
break;
case GL_QUADS:
fprintf(stderr, "Q ");
case GL_QUADS:
name="Q";
type=R300_VAP_VF_CNTL__PRIM_QUADS;
if(end<start+4){
fprintf(stderr, "Not enough vertices\n");
return -1; /* need enough vertices for Q */
}
min_vertices=4;
break;
case GL_QUAD_STRIP:
fprintf(stderr, "QS ");
case GL_QUAD_STRIP:
name="QS";
type=R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
if(end<start+4){
fprintf(stderr, "Not enough vertices\n");
return -1; /* need enough vertices for Q */
}
min_vertices=4;
break;
default:
fprintf(stderr, "Cannot handle primitive %02x ", prim & PRIM_MODE_MASK);
default:
fprintf(stderr, "%s:%s Do not know how to handle primitive %02x - help me !\n",
__FILE__, __FUNCTION__,
prim & PRIM_MODE_MASK);
return -1;
break;
}
}
#if 0
fprintf(stderr, "[%d-%d]%s ", start, end, name);
#endif
if(start+min_vertices>=end){
static int warn_once=1;
if(warn_once){
fprintf(stderr, "%s:%s Not enough vertices to draw primitive %02x - help me !\n",
__FILE__, __FUNCTION__,
prim & PRIM_MODE_MASK);
warn_once=0;
}
return -1;
}
return type;
}
/* This function compiles GL context into state registers that
describe data routing inside of R300 pipeline.
In particular, it programs input_route, output_vtx_fmt, texture
unit configuration and gb_output_vtx_fmt
This function encompasses setup_AOS() from r300_lib.c
*/
/* Immediate implementation - vertex data is sent via command stream */
@@ -167,7 +176,9 @@ static GLfloat default_vector[4]={0.0, 0.0, 0.0, 1.0};
} \
}
static void r300_render_flat_primitive(r300ContextPtr rmesa,
/* Immediate implementation - vertex data is sent via command stream */
static void r300_render_immediate_primitive(r300ContextPtr rmesa,
GLcontext *ctx,
int start,
int end,
@@ -180,10 +191,20 @@ static void r300_render_flat_primitive(r300ContextPtr rmesa,
LOCAL_VARS
type=r300_get_primitive_type(rmesa, ctx, start, end, prim);
#if 0
fprintf(stderr,"ObjPtr: size=%d stride=%d\n",
VB->ObjPtr->size, VB->ObjPtr->stride);
fprintf(stderr,"ColorPtr[0]: size=%d stride=%d\n",
VB->ColorPtr[0]->size, VB->ColorPtr[0]->stride);
fprintf(stderr,"TexCoordPtr[0]: size=%d stride=%d\n",
VB->TexCoordPtr[0]->size, VB->TexCoordPtr[0]->stride);
#endif
if(type<0)return;
start_immediate_packet(end-start, type, 8);
start_immediate_packet(end-start, type, 8+4*rmesa->state.texture.tc_count);
for(i=start;i<end;i++){
#if 0
@@ -206,44 +227,58 @@ static void r300_render_flat_primitive(r300ContextPtr rmesa,
/* color components */
output_vector(VB->ColorPtr[0], i);
/* texture coordinates */
for(k=0;k < ctx->Const.MaxTextureUnits;k++)
if(ctx->Texture.Unit[k].Enabled)
output_vector(VB->TexCoordPtr[k], i);
}
}
static GLboolean r300_run_flat_render(GLcontext *ctx,
static void assign_pipeline(r300ContextPtr rmesa, R300_PIPELINE *p)
{
/* Watch out ! This is buggy .. but will do for now */
/* At least one sanity check is in order */
if(sizeof(rmesa->state.vertex_shader) != sizeof(p->vertex_shader)){
fprintf(stderr, "Aieee ! vertex_shader sizes don't match.\n");
exit(-1);
}
if(sizeof(rmesa->state.pixel_shader) != sizeof(p->pixel_shader)){
fprintf(stderr, "Aieee ! vertex_shader sizes don't match.\n");
exit(-1);
}
memcpy(&rmesa->state.vertex_shader, &(p->vertex_shader), sizeof(rmesa->state.vertex_shader));
memcpy(&rmesa->state.pixel_shader, &(p->pixel_shader), sizeof(rmesa->state.pixel_shader));
}
static GLboolean r300_run_immediate_render(GLcontext *ctx,
struct tnl_pipeline_stage *stage)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
GLuint i;
AOS_DATA vb_arrays[2];
/* Only do 2d textures */
struct gl_texture_object *to=ctx->Texture.Unit[0].Current2D;
r300TexObjPtr t=to->DriverData;
LOCAL_VARS
/* Update texture state - needs to be done only when actually changed..
All the time for now.. */
/* Flush state - make sure command buffer is nice and large */
r300Flush(ctx);
if (RADEON_DEBUG == DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
/* setup array of structures data */
/* Note: immediate vertex data includes all coordinates.
To save bandwidth use either VBUF or state-based vertex generation */
/* xyz */
vb_arrays[0].element_size=4;
vb_arrays[0].stride=4;
vb_arrays[0].offset=0; /* Not used */
vb_arrays[0].format=AOS_FORMAT_FLOAT;
vb_arrays[0].ncomponents=4;
vb_arrays[0].reg=REG_COORDS;
/* color */
vb_arrays[1].element_size=4;
vb_arrays[1].stride=4;
vb_arrays[1].offset=0; /* Not used */
vb_arrays[1].format=AOS_FORMAT_FLOAT_COLOR;
vb_arrays[1].ncomponents=4;
vb_arrays[1].reg=REG_COLOR0;
/* needed before starting 3d operation .. */
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(0x0000000a);
@@ -251,43 +286,75 @@ static GLboolean r300_run_flat_render(GLcontext *ctx,
reg_start(0x4f18,0);
e32(0x00000003);
#if 0 /* looks like the Z offset issue got fixed */
rmesa->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
| R300_VPORT_X_OFFSET_ENA
| R300_VPORT_Y_SCALE_ENA
| R300_VPORT_Y_OFFSET_ENA
| R300_VTX_W0_FMT;
#endif
R300_STATECHANGE(rmesa, vte);
r300EmitState(rmesa);
reg_start(0x20b0,0);
e32(0x0000043f);
FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].length=16;
memcpy(FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4);
/* Magic register - note it is right after 20b0 */
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.length=4;
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[0]=0.0;
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[1]=0.0;
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[2]=1.0;
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[3]=0.0;
if(rmesa->state.texture.tc_count>0){
reg_start(0x20b4,0);
e32(0x0000000c);
program_pipeline(PASS_PREFIX &FLAT_COLOR_PIPELINE);
assign_pipeline(rmesa, &SINGLE_TEXTURE_PIPELINE);
} else {
assign_pipeline(rmesa, &FLAT_COLOR_PIPELINE);
}
rmesa->state.vertex_shader.matrix[0].length=16;
memcpy(rmesa->state.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4);
rmesa->state.vertex_shader.unknown2.length=4;
rmesa->state.vertex_shader.unknown2.body.f[0]=0.0;
rmesa->state.vertex_shader.unknown2.body.f[1]=0.0;
rmesa->state.vertex_shader.unknown2.body.f[2]=1.0;
rmesa->state.vertex_shader.unknown2.body.f[3]=0.0;
r300EmitVertexShader(rmesa);
r300EmitPixelShader(rmesa);
#if 0
reg_start(R300_RB3D_COLORMASK, 0);
e32(0xf);
#endif
/* ----------------------------------- */
/* We need LOAD_VBPNTR to setup AOS_ATTR fields.. the offsets are irrelevant */
setup_AOS(PASS_PREFIX vb_arrays, 2);
r300EmitLOAD_VBPNTR(rmesa, 0);
for(i=0; i < VB->PrimitiveCount; i++){
GLuint prim = VB->Primitive[i].mode;
GLuint start = VB->Primitive[i].start;
GLuint length = VB->Primitive[i].count;
r300_render_flat_primitive(rmesa, ctx, start, start + length, prim);
r300_render_immediate_primitive(rmesa, ctx, start, start + length, prim);
}
end_3d(PASS_PREFIX_VOID);
/* This sequence is required after any 3d drawing packet
I suspect it work arounds a bug (or deficiency) in hardware */
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(0x0000000a);
fprintf(stderr, "\n");
reg_start(0x4f18,0);
e32(0x00000003);
return GL_FALSE;
}
/* vertex buffer implementation */
/* We use the start part of GART texture buffer for vertices */
#define R300_MAX_AOS_ARRAYS 16
static void upload_vertex_buffer(r300ContextPtr rmesa,
GLcontext *ctx, AOS_DATA *array, int *n_arrays)
@@ -312,7 +379,7 @@ static void upload_vertex_buffer(r300ContextPtr rmesa,
} else { \
for(i=0;i<VB->Count;i++){ \
/* copy one vertex at a time*/ \
memcpy(rsp->gartTextures.map+offset, VEC_ELT(v, GLfloat, i), v->size*4); \
memcpy(rsp->gartTextures.map+offset+i*v->size*4, VEC_ELT(v, GLfloat, i), v->size*4); \
} \
} \
/* v->flags &= ~((1<<v->size)-1);*/ \
@@ -325,24 +392,8 @@ static void upload_vertex_buffer(r300ContextPtr rmesa,
array[idx].reg=r; \
offset+=v->size*4*VB->Count; \
idx++; \
/* Fill in the rest with the components of default_vector */\
/* \
if(v->size<4){ \
array[idx].element_size=4-v->size; \
array[idx].stride=0; \
array[idx].format=(f); \
array[idx].ncomponents=4-v->size; \
array[idx].offset=rsp->gartTextures.handle+v->size*4;\
array[idx].reg=r; \
idx++; \
} \
*/\
}
/* Put a copy of default vector */
memcpy(rsp->gartTextures.map, default_vector, 16);
offset+=16;
UPLOAD_VECTOR(VB->ObjPtr, REG_COORDS, AOS_FORMAT_FLOAT);
UPLOAD_VECTOR(VB->ColorPtr[0], REG_COLOR0, AOS_FORMAT_FLOAT_COLOR);
@@ -373,13 +424,6 @@ static void r300_render_vb_flat_primitive(r300ContextPtr rmesa,
fire_AOS(PASS_PREFIX end-start, type);
}
static VERTEX_SHADER_FRAGMENT default_vector_vsf={
length: 4,
body: {
f: {0.0, 0.0, 0.0, 1.0}
}
};
static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
struct tnl_pipeline_stage *stage)
{
@@ -405,11 +449,10 @@ static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
reg_start(0x4f18,0);
e32(0x00000003);
r300_setup_routing(rmesa, ctx, GL_FALSE);
r300EmitState(rmesa);
reg_start(0x20b0,0);
e32(0x0000043f);
FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].length=16;
memcpy(FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4);
@@ -418,12 +461,9 @@ static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[1]=0.0;
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[2]=1.0;
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[3]=0.0;
program_pipeline(PASS_PREFIX &FLAT_COLOR_PIPELINE);
reg_start(R300_RE_OCCLUSION_CNTL, 0);
e32(R300_OCCLUSION_ON);
set_quad0(PASS_PREFIX 1.0,1.0,1.0,1.0);
set_init21(PASS_PREFIX 0.0,1.0);
@@ -435,7 +475,7 @@ static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
/* copy arrays */
memcpy(vb_arrays2, vb_arrays, sizeof(AOS_DATA)*n_arrays);
for(j=0;j<n_arrays;j++){
vb_arrays2[j].offset+=vb_arrays2[j].stride*start;
vb_arrays2[j].offset+=vb_arrays2[j].stride*start*4;
}
setup_AOS(PASS_PREFIX vb_arrays2, n_arrays);
@@ -443,6 +483,15 @@ static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
r300_render_vb_flat_primitive(rmesa, ctx, start, start + length, prim);
}
/* This sequence is required after any 3d drawing packet
I suspect it work arounds a bug (or deficiency) in hardware */
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(0x0000000a);
reg_start(0x4f18,0);
e32(0x00000003);
end_3d(PASS_PREFIX_VOID);
/* Flush state - we are done drawing.. */
@@ -451,6 +500,7 @@ static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
return GL_FALSE;
}
/**
* Called by the pipeline manager to render a batch of primitives.
* We can return true to pass on to the next stage (i.e. software
@@ -468,8 +518,10 @@ static GLboolean r300_run_render(GLcontext *ctx,
if (RADEON_DEBUG == DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
#if 1
return r300_run_flat_render(ctx, stage);
return r300_run_immediate_render(ctx, stage);
#else
return GL_TRUE;
#endif
@@ -546,8 +598,10 @@ static void r300_check_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
//FALLBACK_IF(ctx->Color.DitherFlag);
/* I'm almost certain I forgot something here */
#if 0 /* This should work now.. */
FALLBACK_IF(ctx->Color.AlphaEnabled); // GL_ALPHA_TEST
FALLBACK_IF(ctx->Color.BlendEnabled); // GL_BLEND
#endif
//FALLBACK_IF(ctx->Color.BlendEnabled); // GL_BLEND
FALLBACK_IF(ctx->Fog.Enabled); // GL_FOG
FALLBACK_IF(ctx->Line.SmoothFlag); // GL_LINE_SMOOTH
FALLBACK_IF(ctx->Line.StippleFlag); // GL_LINE_STIPPLE
@@ -562,7 +616,8 @@ static void r300_check_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
FALLBACK_IF(ctx->Stencil.Enabled); // GL_STENCIL_TEST
FALLBACK_IF(ctx->Multisample.Enabled); // GL_MULTISAMPLE_ARB
for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
/* One step at a time - let one texture pass.. */
for (i = 1; i < ctx->Const.MaxTextureUnits; i++)
FALLBACK_IF(ctx->Texture.Unit[i].Enabled);

View File

@@ -57,6 +57,315 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_reg.h"
#include "r300_program.h"
static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
int pp_misc = rmesa->hw.at.cmd[R300_AT_ALPHA_TEST];
GLubyte refByte;
CLAMPED_FLOAT_TO_UBYTE(refByte, ref);
R300_STATECHANGE(rmesa, at);
pp_misc &= ~(R300_ALPHA_TEST_OP_MASK | R300_REF_ALPHA_MASK);
pp_misc |= (refByte & R300_REF_ALPHA_MASK);
switch (func) {
case GL_NEVER:
pp_misc |= R300_ALPHA_TEST_FAIL;
break;
case GL_LESS:
pp_misc |= R300_ALPHA_TEST_LESS;
break;
case GL_EQUAL:
pp_misc |= R300_ALPHA_TEST_EQUAL;
break;
case GL_LEQUAL:
pp_misc |= R300_ALPHA_TEST_LEQUAL;
break;
case GL_GREATER:
pp_misc |= R300_ALPHA_TEST_GREATER;
break;
case GL_NOTEQUAL:
pp_misc |= R300_ALPHA_TEST_NEQUAL;
break;
case GL_GEQUAL:
pp_misc |= R300_ALPHA_TEST_GEQUAL;
break;
case GL_ALWAYS:
pp_misc |= R300_ALPHA_TEST_PASS;
break;
}
rmesa->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc;
}
static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
{
GLubyte color[4];
r300ContextPtr rmesa = R300_CONTEXT(ctx);
fprintf(stderr, "%s:%s is not implemented yet. Fixme !\n", __FILE__, __FUNCTION__);
#if 0
R200_STATECHANGE(rmesa, ctx);
CLAMPED_FLOAT_TO_UBYTE(color[0], cf[0]);
CLAMPED_FLOAT_TO_UBYTE(color[1], cf[1]);
CLAMPED_FLOAT_TO_UBYTE(color[2], cf[2]);
CLAMPED_FLOAT_TO_UBYTE(color[3], cf[3]);
if (rmesa->radeon.radeonScreen->drmSupportsBlendColor)
rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCOLOR] =
radeonPackColor(4, color[0], color[1], color[2], color[3]);
#endif
}
/**
* Calculate the hardware blend factor setting. This same function is used
* for source and destination of both alpha and RGB.
*
* \returns
* The hardware register value for the specified blend factor. This value
* will need to be shifted into the correct position for either source or
* destination factor.
*
* \todo
* Since the two cases where source and destination are handled differently
* are essentially error cases, they should never happen. Determine if these
* cases can be removed.
*/
static int blend_factor(GLenum factor, GLboolean is_src)
{
int func;
switch (factor) {
case GL_ZERO:
func = R200_BLEND_GL_ZERO;
break;
case GL_ONE:
func = R200_BLEND_GL_ONE;
break;
case GL_DST_COLOR:
func = R200_BLEND_GL_DST_COLOR;
break;
case GL_ONE_MINUS_DST_COLOR:
func = R200_BLEND_GL_ONE_MINUS_DST_COLOR;
break;
case GL_SRC_COLOR:
func = R200_BLEND_GL_SRC_COLOR;
break;
case GL_ONE_MINUS_SRC_COLOR:
func = R200_BLEND_GL_ONE_MINUS_SRC_COLOR;
break;
case GL_SRC_ALPHA:
func = R200_BLEND_GL_SRC_ALPHA;
break;
case GL_ONE_MINUS_SRC_ALPHA:
func = R200_BLEND_GL_ONE_MINUS_SRC_ALPHA;
break;
case GL_DST_ALPHA:
func = R200_BLEND_GL_DST_ALPHA;
break;
case GL_ONE_MINUS_DST_ALPHA:
func = R200_BLEND_GL_ONE_MINUS_DST_ALPHA;
break;
case GL_SRC_ALPHA_SATURATE:
func =
(is_src) ? R200_BLEND_GL_SRC_ALPHA_SATURATE :
R200_BLEND_GL_ZERO;
break;
case GL_CONSTANT_COLOR:
func = R200_BLEND_GL_CONST_COLOR;
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
func = R200_BLEND_GL_ONE_MINUS_CONST_COLOR;
break;
case GL_CONSTANT_ALPHA:
func = R200_BLEND_GL_CONST_ALPHA;
break;
case GL_ONE_MINUS_CONSTANT_ALPHA:
func = R200_BLEND_GL_ONE_MINUS_CONST_ALPHA;
break;
default:
func = (is_src) ? R200_BLEND_GL_ONE : R200_BLEND_GL_ZERO;
}
return func;
}
/**
* Sets both the blend equation and the blend function.
* This is done in a single
* function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
* change the interpretation of the blend function.
* Also, make sure that blend function and blend equation are set to their default
* value if color blending is not enabled, since at least blend equations GL_MIN
* and GL_FUNC_REVERSE_SUBTRACT will cause wrong results otherwise for
* unknown reasons.
*/
static void r300_set_blend_state(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
#if 0
GLuint cntl = rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &
~(R300_ROP_ENABLE | R300_ALPHA_BLEND_ENABLE |
R300_SEPARATE_ALPHA_ENABLE);
#endif
int func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
(R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT);
int eqn = R200_COMB_FCN_ADD_CLAMP;
int funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
(R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT);
int eqnA = R200_COMB_FCN_ADD_CLAMP;
R300_STATECHANGE(rmesa, bld);
if (rmesa->radeon.radeonScreen->drmSupportsBlendColor) {
if (ctx->Color._LogicOpEnabled) {
#if 0
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] =
cntl | R300_ROP_ENABLE;
#endif
rmesa->hw.bld.cmd[R300_BLD_ABLEND] = eqn | func;
rmesa->hw.bld.cmd[R300_BLD_CBLEND] = eqn | func;
return;
} else if (ctx->Color.BlendEnabled) {
#if 0
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] =
cntl | R300_ALPHA_BLEND_ENABLE |
R300_SEPARATE_ALPHA_ENABLE;
#endif
} else {
#if 0
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = cntl;
#endif
rmesa->hw.bld.cmd[R300_BLD_ABLEND] = eqn | func;
rmesa->hw.bld.cmd[R300_BLD_CBLEND] = eqn | func;
return;
}
} else {
if (ctx->Color._LogicOpEnabled) {
#if 0
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] =
cntl | R300_ROP_ENABLE;
rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = eqn | func;
#endif
return;
} else if (ctx->Color.BlendEnabled) {
#if 0
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] =
cntl | R300_ALPHA_BLEND_ENABLE;
#endif
} else {
#if 0
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = cntl;
rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = eqn | func;
#endif
return;
}
}
func =
(blend_factor(ctx->Color.BlendSrcRGB, GL_TRUE) <<
R200_SRC_BLEND_SHIFT) | (blend_factor(ctx->Color.BlendDstRGB,
GL_FALSE) <<
R200_DST_BLEND_SHIFT);
switch (ctx->Color.BlendEquationRGB) {
case GL_FUNC_ADD:
eqn = R300_COMB_FCN_ADD_CLAMP;
break;
case GL_FUNC_SUBTRACT:
eqn = R300_COMB_FCN_SUB_CLAMP;
break;
case GL_FUNC_REVERSE_SUBTRACT:
eqn = R200_COMB_FCN_RSUB_CLAMP;
break;
case GL_MIN:
eqn = R200_COMB_FCN_MIN;
func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
(R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
break;
case GL_MAX:
eqn = R200_COMB_FCN_MAX;
func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
(R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
break;
default:
fprintf(stderr,
"[%s:%u] Invalid RGB blend equation (0x%04x).\n",
__func__, __LINE__, ctx->Color.BlendEquationRGB);
return;
}
if (!rmesa->radeon.radeonScreen->drmSupportsBlendColor) {
#if 0
rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = eqn | func;
#endif
return;
}
funcA =
(blend_factor(ctx->Color.BlendSrcA, GL_TRUE) <<
R200_SRC_BLEND_SHIFT) | (blend_factor(ctx->Color.BlendDstA,
GL_FALSE) <<
R200_DST_BLEND_SHIFT);
switch (ctx->Color.BlendEquationA) {
case GL_FUNC_ADD:
eqnA = R300_COMB_FCN_ADD_CLAMP;
break;
case GL_FUNC_SUBTRACT:
eqnA = R300_COMB_FCN_SUB_CLAMP;
break;
case GL_FUNC_REVERSE_SUBTRACT:
eqnA = R200_COMB_FCN_RSUB_CLAMP;
break;
case GL_MIN:
eqnA = R200_COMB_FCN_MIN;
funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
(R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
break;
case GL_MAX:
eqnA = R200_COMB_FCN_MAX;
funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
(R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
break;
default:
fprintf(stderr, "[%s:%u] Invalid A blend equation (0x%04x).\n",
__func__, __LINE__, ctx->Color.BlendEquationA);
return;
}
rmesa->hw.bld.cmd[R300_BLD_ABLEND] = eqnA | funcA;
rmesa->hw.bld.cmd[R300_BLD_CBLEND] = eqn | func ;
if(rmesa->hw.bld.cmd[R300_BLD_ABLEND] == rmesa->hw.bld.cmd[R300_BLD_CBLEND]){
rmesa->hw.bld.cmd[R300_BLD_CBLEND] |= R300_BLEND_UNKNOWN | R300_BLEND_ENABLE | R300_BLEND_NO_SEPARATE;
} else {
rmesa->hw.bld.cmd[R300_BLD_CBLEND] |= R300_BLEND_UNKNOWN | R300_BLEND_ENABLE;
}
}
static void r300BlendEquationSeparate(GLcontext * ctx,
GLenum modeRGB, GLenum modeA)
{
r300_set_blend_state(ctx);
}
static void r300BlendFuncSeparate(GLcontext * ctx,
GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA)
{
r300_set_blend_state(ctx);
}
/**
* Update our tracked culling state based on Mesa's state.
@@ -225,6 +534,18 @@ static void r300ColorMask(GLcontext* ctx,
}
}
/* =============================================================
* Point state
*/
static void r300PointSize(GLcontext * ctx, GLfloat size)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
/* This might need fixing later */
R300_STATECHANGE(r300, vps);
r300->hw.vps.cmd[R300_VPS_POINTSIZE] = r300PackFloat32(1.0);
}
/* =============================================================
* Window position and viewport transformation
*/
@@ -277,6 +598,331 @@ static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
r300UpdateWindow(ctx);
}
/* Routing and texture-related */
void r300_setup_routing(GLcontext *ctx, GLboolean immediate)
{
int i, count=0,reg=0;
GLuint dw, mask;
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
r300ContextPtr r300 = R300_CONTEXT(ctx);
/* Stage 1 - input to VAP */
/* Assign register number automatically, retaining it in rmesa->state.reg */
/* Note: immediate vertex data includes all coordinates.
To save bandwidth use either VBUF or state-based vertex generation */
#define CONFIGURE_AOS(v, o, r, f) \
{\
if(immediate){ \
r300->state.aos[count].element_size=4; \
r300->state.aos[count].stride=4; \
r300->state.aos[count].ncomponents=4; \
} else { \
r300->state.aos[count].element_size=v->size; \
r300->state.aos[count].stride=v->size; \
r300->state.aos[count].ncomponents=v->size; \
} \
r300->state.aos[count].offset=o; \
r300->state.aos[count].reg=reg; \
r300->state.aos[count].format=(f); \
r300->state.vap_reg.r=reg; \
count++; \
reg++; \
}
/* All offsets are 0 - for use by immediate mode.
Should change later to handle vertex buffers */
CONFIGURE_AOS(VB->ObjPtr, 0, i_coords, AOS_FORMAT_FLOAT);
CONFIGURE_AOS(VB->ColorPtr[0], 0, i_color[0], AOS_FORMAT_FLOAT_COLOR);
for(i=0;i < ctx->Const.MaxTextureUnits;i++)
if(ctx->Texture.Unit[i].Enabled)
CONFIGURE_AOS(VB->TexCoordPtr[i], 0, i_tex[i], AOS_FORMAT_FLOAT);
r300->state.aos_count=count;
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "aos_count=%d\n", count);
if(count>R300_MAX_AOS_ARRAYS){
fprintf(stderr, "Aieee ! AOS array count exceeded !\n");
exit(-1);
}
/* Implement AOS */
/* setup INPUT_ROUTE */
R300_STATECHANGE(r300, vir[0]);
for(i=0;i+1<count;i+=2){
dw=(r300->state.aos[i].ncomponents-1)
| ((r300->state.aos[i].reg)<<8)
| (r300->state.aos[i].format<<14)
| (((r300->state.aos[i+1].ncomponents-1)
| ((r300->state.aos[i+1].reg)<<8)
| (r300->state.aos[i+1].format<<14))<<16);
if(i+2==count){
dw|=(1<<(13+16));
}
r300->hw.vir[0].cmd[R300_VIR_CNTL_0+(i>>1)]=dw;
}
if(count & 1){
dw=(r300->state.aos[count-1].ncomponents-1)
| (r300->state.aos[count-1].format<<14)
| ((r300->state.aos[count-1].reg)<<8)
| (1<<13);
r300->hw.vir[0].cmd[R300_VIR_CNTL_0+(count>>1)]=dw;
//fprintf(stderr, "vir0 dw=%08x\n", dw);
}
/* Set the rest of INPUT_ROUTE_0 to 0 */
//for(i=((count+1)>>1); i<8; i++)r300->hw.vir[0].cmd[R300_VIR_CNTL_0+i]=(0x0);
((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->unchecked_state.count = (count+1)>>1;
/* Mesa assumes that all missing components are from (0, 0, 0, 1) */
#define ALL_COMPONENTS ((R300_INPUT_ROUTE_SELECT_X<<R300_INPUT_ROUTE_X_SHIFT) \
| (R300_INPUT_ROUTE_SELECT_Y<<R300_INPUT_ROUTE_Y_SHIFT) \
| (R300_INPUT_ROUTE_SELECT_Z<<R300_INPUT_ROUTE_Z_SHIFT) \
| (R300_INPUT_ROUTE_SELECT_W<<R300_INPUT_ROUTE_W_SHIFT))
#define ALL_DEFAULT ((R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_X_SHIFT) \
| (R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_Y_SHIFT) \
| (R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_Z_SHIFT) \
| (R300_INPUT_ROUTE_SELECT_ONE<<R300_INPUT_ROUTE_W_SHIFT))
R300_STATECHANGE(r300, vir[1]);
for(i=0;i+1<count;i+=2){
/* do i first.. */
mask=(1<<(r300->state.aos[i].ncomponents*3))-1;
dw=(ALL_COMPONENTS & mask)
| (ALL_DEFAULT & ~mask)
| R300_INPUT_ROUTE_ENABLE;
/* i+1 */
mask=(1<<(r300->state.aos[i+1].ncomponents*3))-1;
dw|=(
(ALL_COMPONENTS & mask)
| (ALL_DEFAULT & ~mask)
| R300_INPUT_ROUTE_ENABLE
)<<16;
r300->hw.vir[1].cmd[R300_VIR_CNTL_0+(i>>1)]=dw;
}
if(count & 1){
mask=(1<<(r300->state.aos[count-1].ncomponents*3))-1;
dw=(ALL_COMPONENTS & mask)
| (ALL_DEFAULT & ~mask)
| R300_INPUT_ROUTE_ENABLE;
r300->hw.vir[1].cmd[R300_VIR_CNTL_0+(count>>1)]=dw;
//fprintf(stderr, "vir1 dw=%08x\n", dw);
}
/* Set the rest of INPUT_ROUTE_1 to 0 */
//for(i=((count+1)>>1); i<8; i++)r300->hw.vir[1].cmd[R300_VIR_CNTL_0+i]=0x0;
((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->unchecked_state.count = (count+1)>>1;
/* Set up input_cntl */
R300_STATECHANGE(r300, vic);
r300->hw.vic.cmd[R300_VIC_CNTL_0]=0x5555; /* Hard coded value, no idea what it means */
r300->hw.vic.cmd[R300_VIC_CNTL_1]=R300_INPUT_CNTL_POS
| R300_INPUT_CNTL_COLOR;
for(i=0;i < ctx->Const.MaxTextureUnits;i++)
if(ctx->Texture.Unit[i].Enabled)
r300->hw.vic.cmd[R300_VIC_CNTL_1]|=(R300_INPUT_CNTL_TC0<<i);
/* Stage 3: VAP output */
R300_STATECHANGE(r300, vof);
r300->hw.vof.cmd[R300_VOF_CNTL_0]=R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT
| R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
r300->hw.vof.cmd[R300_VOF_CNTL_1]=0;
for(i=0;i < ctx->Const.MaxTextureUnits;i++)
if(ctx->Texture.Unit[i].Enabled)
r300->hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i));
}
static r300TexObj default_tex_obj={
filter:R300_TX_MAG_FILTER_LINEAR | R300_TX_MIN_FILTER_LINEAR,
pitch: 0x8000,
size: (0xff << R300_TX_WIDTHMASK_SHIFT)
| (0xff << R300_TX_HEIGHTMASK_SHIFT)
| (0x8 << R300_TX_SIZE_SHIFT),
format: 0x88a0c,
offset: 0x0,
unknown4: 0x0,
unknown5: 0x0
};
/* there is probably a system to these value, but, for now,
we just try by hand */
static GLuint translate_texture_format(GLuint format)
{
switch(format){
case 0x88047:
case 0x55047:
return 0x53a0c;
default:
{
static int warn_once=1;
if(warn_once){
fprintf(stderr, "%s:%s Do not know how to translate texture format %08x - help me !\n",
__FILE__, __FUNCTION__,
format);
warn_once=0;
}
}
return 0;
}
}
void r300_setup_textures(GLcontext *ctx)
{
int i, mtu;
struct r300_tex_obj *t;
r300ContextPtr r300 = R300_CONTEXT(ctx);
int max_texture_unit=-1; /* -1 translates into no setup costs for fields */
R300_STATECHANGE(r300, txe);
R300_STATECHANGE(r300, tex.filter);
R300_STATECHANGE(r300, tex.unknown1);
R300_STATECHANGE(r300, tex.size);
R300_STATECHANGE(r300, tex.format);
R300_STATECHANGE(r300, tex.offset);
R300_STATECHANGE(r300, tex.unknown4);
R300_STATECHANGE(r300, tex.unknown5);
r300->state.texture.tc_count=0;
r300->hw.txe.cmd[R300_TXE_ENABLE]=0x0;
mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "mtu=%d\n", mtu);
if(mtu>R300_MAX_TEXTURE_UNITS){
fprintf(stderr, "Aiiee ! mtu=%d is greater than R300_MAX_TEXTURE_UNITS=%d\n",
mtu, R300_MAX_TEXTURE_UNITS);
exit(-1);
}
for(i=0;i<mtu;i++){
if(ctx->Texture.Unit[i].Enabled){
t=r300->state.texture.unit[i].texobj;
r300->state.texture.tc_count++;
if(t==NULL){
fprintf(stderr, "Texture unit %d enabled, but corresponding texobj is NULL, using default object.\n", i);
//exit(-1);
t=&default_tex_obj;
}
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "Activating texture unit %d\n", i);
max_texture_unit=i;
r300->hw.txe.cmd[R300_TXE_ENABLE]|=(1<<i);
r300->hw.tex.filter.cmd[R300_TEX_VALUE_0+i]=t->filter;
r300->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+i]=t->pitch;
r300->hw.tex.size.cmd[R300_TEX_VALUE_0+i]=t->size;
r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=t->format;
r300->hw.tex.offset.cmd[R300_TEX_VALUE_0+i]=r300->radeon.radeonScreen->fbLocation+t->offset;
r300->hw.tex.unknown4.cmd[R300_TEX_VALUE_0+i]=0x0;
r300->hw.tex.unknown5.cmd[R300_TEX_VALUE_0+i]=0x0;
/* We don't know how to set this yet */
//value from r300_lib.c for RGB24
//r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=0x88a0c;
r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=translate_texture_format(t->format);
/* Use the code below to quickly find matching texture
formats. Requires an app that displays the same texture
repeatedly */
#if 1
if(r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]==0){
static int fmt=0;
static int k=0;
k++;
if(k>200){
k=0;
fmt++;
fprintf(stderr, "Want to set format %08x\n", t->format);
if(fmt>0xff){
//exit(-1);
fmt=0;
}
//sleep(1);
fprintf(stderr, "Instead trying format %08x\n",
0x00a0c | (fmt<<12));
}
r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=0x00a0c | (fmt<<12);
}
#endif
}
}
((drm_r300_cmd_header_t*)r300->hw.tex.filter.cmd)->unchecked_state.count = max_texture_unit+1;
((drm_r300_cmd_header_t*)r300->hw.tex.unknown1.cmd)->unchecked_state.count = max_texture_unit+1;
((drm_r300_cmd_header_t*)r300->hw.tex.size.cmd)->unchecked_state.count = max_texture_unit+1;
((drm_r300_cmd_header_t*)r300->hw.tex.format.cmd)->unchecked_state.count = max_texture_unit+1;
((drm_r300_cmd_header_t*)r300->hw.tex.offset.cmd)->unchecked_state.count = max_texture_unit+1;
((drm_r300_cmd_header_t*)r300->hw.tex.unknown4.cmd)->unchecked_state.count = max_texture_unit+1;
((drm_r300_cmd_header_t*)r300->hw.tex.unknown5.cmd)->unchecked_state.count = max_texture_unit+1;
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "TX_ENABLE: %08x max_texture_unit=%d\n", r300->hw.txe.cmd[R300_TXE_ENABLE], max_texture_unit);
}
void r300_setup_rs_unit(GLcontext *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int i;
/* This needs to be rewritten - it is a hack at best */
R300_STATECHANGE(r300, ri);
R300_STATECHANGE(r300, rc);
R300_STATECHANGE(r300, rr);
for(i = 1; i <= 8; ++i)
r300->hw.ri.cmd[i] = 0x00d10000;
r300->hw.ri.cmd[R300_RI_INTERP_1] |= R300_RS_INTERP_1_UNKNOWN;
r300->hw.ri.cmd[R300_RI_INTERP_2] |= R300_RS_INTERP_2_UNKNOWN;
r300->hw.ri.cmd[R300_RI_INTERP_3] |= R300_RS_INTERP_3_UNKNOWN;
for(i = 1; i <= 8; ++i)
r300->hw.rr.cmd[i] = 0;
/* textures enabled ? */
if(r300->state.texture.tc_count>0){
/* This code only really works with one set of texture coordinates */
/* The second constant is needed to get glxgears display anything .. */
r300->hw.rc.cmd[1] = R300_RS_CNTL_0_UNKNOWN_7
| R300_RS_CNTL_0_UNKNOWN_18
| (r300->state.texture.tc_count<<R300_RS_CNTL_TC_CNT_SHIFT);
r300->hw.rc.cmd[2] = 0xc0;
((drm_r300_cmd_header_t*)r300->hw.rr.cmd)->unchecked_state.count = 1;
r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0x24008;
} else {
/* The second constant is needed to get glxgears display anything .. */
r300->hw.rc.cmd[1] = R300_RS_CNTL_0_UNKNOWN_7 | R300_RS_CNTL_0_UNKNOWN_18;
r300->hw.rc.cmd[2] = 0;
((drm_r300_cmd_header_t*)r300->hw.rr.cmd)->unchecked_state.count = 1;
r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0x4000;
}
}
/**
* Called by Mesa after an internal state update.
@@ -320,6 +966,16 @@ void r300ResetHwState(r300ContextPtr r300)
r300DepthFunc(ctx, ctx->Depth.Func);
r300UpdateCulling(ctx);
r300_setup_routing(ctx, GL_TRUE);
r300UpdateTextureState(ctx);
r300_setup_textures(ctx);
r300_setup_rs_unit(ctx);
r300_set_blend_state(ctx);
r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
//BEGIN: TODO
r300->hw.unk2080.cmd[1] = 0x0030045A;
@@ -327,14 +983,21 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.ovf.cmd[R300_OVF_FMT_0] = 0x00000003;
r300->hw.ovf.cmd[R300_OVF_FMT_1] = 0x00000000;
r300->hw.unk20B0.cmd[1] = 0x0000040A;
r300->hw.unk20B0.cmd[2] = 0x00000008;
r300->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
| R300_VPORT_X_OFFSET_ENA
| R300_VPORT_Y_SCALE_ENA
| R300_VPORT_Y_OFFSET_ENA
| R300_VPORT_Z_SCALE_ENA
| R300_VPORT_Z_OFFSET_ENA
| R300_VTX_W0_FMT;
r300->hw.vte.cmd[2] = 0x00000008;
r300->hw.unk2134.cmd[1] = 0x00FFFFFF;
r300->hw.unk2134.cmd[2] = 0x00000000;
r300->hw.unk2140.cmd[1] = 0x00000000;
#if 0 /* Done in setup routing */
((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->unchecked_state.count = 1;
r300->hw.vir[0].cmd[1] = 0x21030003;
@@ -343,7 +1006,8 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.vic.cmd[R300_VIR_CNTL_0] = 0x00000001;
r300->hw.vic.cmd[R300_VIR_CNTL_1] = 0x00000405;
#endif
r300->hw.unk21DC.cmd[1] = 0xAAAAAAAA;
r300->hw.unk221C.cmd[1] = R300_221C_NORMAL;
@@ -358,10 +1022,12 @@ void r300ResetHwState(r300ContextPtr r300)
else
r300->hw.unk2288.cmd[1] = R300_2288_RV350;
#if 0
r300->hw.vof.cmd[R300_VOF_CNTL_0] = R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT
| R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0; /* no textures */
#endif
r300->hw.pvs.cmd[R300_PVS_CNTL_1] = 0;
r300->hw.pvs.cmd[R300_PVS_CNTL_2] = 0;
r300->hw.pvs.cmd[R300_PVS_CNTL_3] = 0;
@@ -383,7 +1049,7 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = 0x00000000;
r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = 0x00000000; /* No antialiasing */
r300->hw.txe.cmd[R300_TXE_ENABLE] = 0;
//r300->hw.txe.cmd[R300_TXE_ENABLE] = 0;
r300->hw.unk4200.cmd[1] = r300PackFloat32(0.0);
r300->hw.unk4200.cmd[2] = r300PackFloat32(0.0);
@@ -421,20 +1087,6 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF;
r300->hw.unk42C0.cmd[2] = 0x00000000;
/* The second constant is needed to get glxgears display anything .. */
r300->hw.rc.cmd[1] = R300_RS_CNTL_0_UNKNOWN_7 | R300_RS_CNTL_0_UNKNOWN_18;
r300->hw.rc.cmd[2] = 0;
for(i = 1; i <= 8; ++i)
r300->hw.ri.cmd[i] = 0x00d10000;
r300->hw.ri.cmd[R300_RI_INTERP_1] |= R300_RS_INTERP_1_UNKNOWN;
r300->hw.ri.cmd[R300_RI_INTERP_2] |= R300_RS_INTERP_2_UNKNOWN;
r300->hw.ri.cmd[R300_RI_INTERP_3] |= R300_RS_INTERP_3_UNKNOWN;
((drm_r300_cmd_header_t*)r300->hw.rr.cmd)->unchecked_state.count = 1;
for(i = 1; i <= 8; ++i)
r300->hw.rr.cmd[i] = 0;
r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0x4000;
r300->hw.unk43A4.cmd[1] = 0x0000001C;
r300->hw.unk43A4.cmd[2] = 0x2DA49525;
@@ -469,14 +1121,18 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk4BC8.cmd[2] = 0;
r300->hw.unk4BC8.cmd[3] = 0;
#if 0
r300->hw.at.cmd[R300_AT_ALPHA_TEST] = 0;
#endif
r300->hw.unk4BD8.cmd[1] = 0;
r300->hw.unk4E00.cmd[1] = 0;
#if 0
r300->hw.bld.cmd[R300_BLD_CBLEND] = 0;
r300->hw.bld.cmd[R300_BLD_ABLEND] = 0;
#endif
r300->hw.unk4E10.cmd[1] = 0;
r300->hw.unk4E10.cmd[2] = 0;
@@ -541,8 +1197,9 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.vps.cmd[R300_VPS_ZERO_1] = 0;
r300->hw.vps.cmd[R300_VPS_POINTSIZE] = r300PackFloat32(1.0);
r300->hw.vps.cmd[R300_VPS_ZERO_3] = 0;
//END: TODO
r300->hw.all_dirty = GL_TRUE;
}
@@ -555,9 +1212,29 @@ void r300ResetHwState(r300ContextPtr r300)
*/
void r300InitState(r300ContextPtr r300)
{
GLcontext *ctx = r300->radeon.glCtx;
GLuint depth_fmt;
radeonInitState(&r300->radeon);
r300->state.depth.scale = 1.0 / (GLfloat) 0xffff;
switch (ctx->Visual.depthBits) {
case 16:
r300->state.depth.scale = 1.0 / (GLfloat) 0xffff;
depth_fmt = R200_DEPTH_FORMAT_16BIT_INT_Z;
//r300->state.stencil.clear = 0x00000000;
break;
case 24:
r300->state.depth.scale = 1.0 / (GLfloat) 0xffffff;
depth_fmt = R200_DEPTH_FORMAT_24BIT_INT_Z;
//r300->state.stencil.clear = 0xff000000;
break;
default:
fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
ctx->Visual.depthBits);
exit(-1);
}
memset(&(r300->state.texture), 0, sizeof(r300->state.texture));
r300ResetHwState(r300);
}
@@ -572,6 +1249,10 @@ void r300InitStateFuncs(struct dd_function_table* functions)
radeonInitStateFuncs(functions);
functions->UpdateState = r300InvalidateState;
//functions->AlphaFunc = r300AlphaFunc;
functions->BlendColor = r300BlendColor;
functions->BlendEquationSeparate = r300BlendEquationSeparate;
functions->BlendFuncSeparate = r300BlendFuncSeparate;
functions->Enable = r300Enable;
functions->ColorMask = r300ColorMask;
functions->DepthFunc = r300DepthFunc;
@@ -582,5 +1263,6 @@ void r300InitStateFuncs(struct dd_function_table* functions)
/* Viewport related */
functions->Viewport = r300Viewport;
functions->DepthRange = r300DepthRange;
functions->PointSize = r300PointSize;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,53 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r300/r300_tex.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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 <keith@tungstengraphics.com>
*/
#ifndef __r300_TEX_H__
#define __r300_TEX_H__
#ifdef GLX_DIRECT_RENDERING
extern void r300UpdateTextureState(GLcontext * ctx);
extern int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t,
GLuint face);
extern void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t);
extern void r300InitTextureFuncs(struct dd_function_table *functions);
extern void r300UpdateTextureState(GLcontext * ctx);
#endif
#endif /* __r300_TEX_H__ */

View File

@@ -0,0 +1,490 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r300/r300_texmem.c,v 1.5 2002/12/17 00:32:56 dawes Exp $ */
/**************************************************************************
Copyright (C) Tungsten Graphics 2002. All Rights Reserved.
The Weather Channel, Inc. funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86
license. This notice must be preserved.
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 on the rights to use, copy, modify, merge, publish,
distribute, sub license, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR THEIR
SUPPLIERS 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:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*
*/
#include <errno.h>
#include "glheader.h"
#include "imports.h"
#include "context.h"
#include "colormac.h"
#include "macros.h"
#include "simple_list.h"
#include "radeon_reg.h" /* gets definition for usleep */
#include "r300_context.h"
#include "r300_state.h"
#include "radeon_ioctl.h"
/*
#include "r300_swtcl.h"
*/
#include "r300_tex.h"
#include <unistd.h> /* for usleep() */
/**
* Destroy any device-dependent state associated with the texture. This may
* include NULLing out hardware state that points to the texture.
*/
void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t)
{
if (RADEON_DEBUG & DEBUG_TEXTURE) {
fprintf(stderr, "%s( %p, %p )\n", __FUNCTION__,
(void *)t, (void *)t->base.tObj);
}
if (rmesa != NULL) {
unsigned i;
for (i = 0; i < rmesa->radeon.glCtx->Const.MaxTextureUnits; i++) {
if (t == rmesa->state.texture.unit[i].texobj) {
rmesa->state.texture.unit[i].texobj = NULL;
/* This code below is meant to shorten state
pushed to the hardware by not programming
unneeded units.
This does not appear to be worthwhile on R300 */
#if 0
remove_from_list(&rmesa->hw.tex[i]);
make_empty_list(&rmesa->hw.tex[i]);
remove_from_list(&rmesa->hw.cube[i]);
make_empty_list(&rmesa->hw.cube[i]);
#endif
}
}
}
}
/* ------------------------------------------------------------
* Texture image conversions
*/
static void r300UploadGARTClientSubImage(r300ContextPtr rmesa,
r300TexObjPtr t,
struct gl_texture_image *texImage,
GLint hwlevel,
GLint x, GLint y,
GLint width, GLint height)
{
const struct gl_texture_format *texFormat = texImage->TexFormat;
GLuint srcPitch, dstPitch;
int blit_format;
int srcOffset;
/*
* XXX it appears that we always upload the full image, not a subimage.
* I.e. x==0, y==0, width=texWidth, height=texWidth. If this is ever
* changed, the src pitch will have to change.
*/
switch (texFormat->TexelBytes) {
case 1:
blit_format = R200_CP_COLOR_FORMAT_CI8;
srcPitch = t->image[0][0].width * texFormat->TexelBytes;
dstPitch = t->image[0][0].width * texFormat->TexelBytes;
break;
case 2:
blit_format = R200_CP_COLOR_FORMAT_RGB565;
srcPitch = t->image[0][0].width * texFormat->TexelBytes;
dstPitch = t->image[0][0].width * texFormat->TexelBytes;
break;
case 4:
blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
srcPitch = t->image[0][0].width * texFormat->TexelBytes;
dstPitch = t->image[0][0].width * texFormat->TexelBytes;
break;
default:
return;
}
t->image[0][hwlevel].data = texImage->Data;
srcOffset = r300GartOffsetFromVirtual(rmesa, texImage->Data);
assert(srcOffset != ~0);
/* Don't currently need to cope with small pitches?
*/
width = texImage->Width;
height = texImage->Height;
r300EmitWait(rmesa, RADEON_WAIT_3D);
r300EmitBlit(rmesa, blit_format,
srcPitch,
srcOffset,
dstPitch,
t->bufAddr,
x,
y,
t->image[0][hwlevel].x + x,
t->image[0][hwlevel].y + y, width, height);
r300EmitWait(rmesa, RADEON_WAIT_2D);
}
static void r300UploadRectSubImage(r300ContextPtr rmesa,
r300TexObjPtr t,
struct gl_texture_image *texImage,
GLint x, GLint y, GLint width, GLint height)
{
const struct gl_texture_format *texFormat = texImage->TexFormat;
int blit_format, dstPitch, done;
switch (texFormat->TexelBytes) {
case 1:
blit_format = R200_CP_COLOR_FORMAT_CI8;
break;
case 2:
blit_format = R200_CP_COLOR_FORMAT_RGB565;
break;
case 4:
blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
break;
default:
return;
}
t->image[0][0].data = texImage->Data;
/* Currently don't need to cope with small pitches.
*/
width = texImage->Width;
height = texImage->Height;
dstPitch = t->pitch + 32;
if (rmesa->prefer_gart_client_texturing && texImage->IsClientData) {
/* In this case, could also use GART texturing. This is
* currently disabled, but has been tested & works.
*/
t->offset =
r300GartOffsetFromVirtual(rmesa, texImage->Data);
t->pitch =
texImage->RowStride * texFormat->TexelBytes - 32;
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr,
"Using GART texturing for rectangular client texture\n");
/* Release FB memory allocated for this image:
*/
/* FIXME This may not be correct as driSwapOutTextureObject sets
* FIXME dirty_images. It may be fine, though.
*/
if (t->base.memBlock) {
driSwapOutTextureObject((driTextureObject *) t);
}
} else if (texImage->IsClientData) {
/* Data already in GART memory, with usable pitch.
*/
GLuint srcPitch;
srcPitch = texImage->RowStride * texFormat->TexelBytes;
r300EmitBlit(rmesa,
blit_format,
srcPitch,
r300GartOffsetFromVirtual(rmesa, texImage->Data),
dstPitch, t->bufAddr, 0, 0, 0, 0, width, height);
} else {
/* Data not in GART memory, or bad pitch.
*/
for (done = 0; done < height;) {
struct r300_dma_region region;
int lines =
MIN2(height - done, RADEON_BUFFER_SIZE / dstPitch);
int src_pitch;
char *tex;
src_pitch = texImage->RowStride * texFormat->TexelBytes;
tex = (char *)texImage->Data + done * src_pitch;
memset(&region, 0, sizeof(region));
r300AllocDmaRegion(rmesa, &region, lines * dstPitch,
1024);
/* Copy texdata to dma:
*/
if (0)
fprintf(stderr,
"%s: src_pitch %d dst_pitch %d\n",
__FUNCTION__, src_pitch, dstPitch);
if (src_pitch == dstPitch) {
memcpy(region.address + region.start, tex,
lines * src_pitch);
} else {
char *buf = region.address + region.start;
int i;
for (i = 0; i < lines; i++) {
memcpy(buf, tex, src_pitch);
buf += dstPitch;
tex += src_pitch;
}
}
r300EmitWait(rmesa, RADEON_WAIT_3D);
/* Blit to framebuffer
*/
r300EmitBlit(rmesa,
blit_format,
dstPitch, GET_START(&region),
dstPitch, t->bufAddr,
0, 0, 0, done, width, lines);
r300EmitWait(rmesa, RADEON_WAIT_2D);
r300ReleaseDmaRegion(rmesa, &region, __FUNCTION__);
done += lines;
}
}
}
/**
* Upload the texture image associated with texture \a t at the specified
* level at the address relative to \a start.
*/
static void uploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
GLint hwlevel,
GLint x, GLint y, GLint width, GLint height,
GLuint face)
{
struct gl_texture_image *texImage = NULL;
GLuint offset;
GLint imageWidth, imageHeight;
GLint ret;
drm_radeon_texture_t tex;
drm_radeon_tex_image_t tmp;
const int level = hwlevel + t->base.firstLevel;
if (RADEON_DEBUG & DEBUG_TEXTURE) {
fprintf(stderr,
"%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n",
__FUNCTION__, (void *)t, (void *)t->base.tObj, level,
width, height, face);
}
ASSERT(face < 6);
/* Ensure we have a valid texture to upload */
if ((hwlevel < 0) || (hwlevel >= RADEON_MAX_TEXTURE_LEVELS)) {
_mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
return;
}
texImage = t->base.tObj->Image[face][level];
if (!texImage) {
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: texImage %d is NULL!\n",
__FUNCTION__, level);
return;
}
if (!texImage->Data) {
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: image data is NULL!\n",
__FUNCTION__);
return;
}
if (t->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
assert(level == 0);
assert(hwlevel == 0);
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: image data is rectangular\n",
__FUNCTION__);
r300UploadRectSubImage(rmesa, t, texImage, x, y, width, height);
return;
} else if (texImage->IsClientData) {
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr,
"%s: image data is in GART client storage\n",
__FUNCTION__);
r300UploadGARTClientSubImage(rmesa, t, texImage, hwlevel, x, y,
width, height);
return;
} else if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: image data is in normal memory\n",
__FUNCTION__);
imageWidth = texImage->Width;
imageHeight = texImage->Height;
offset = t->bufAddr;
if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
GLint imageX = 0;
GLint imageY = 0;
GLint blitX = t->image[face][hwlevel].x;
GLint blitY = t->image[face][hwlevel].y;
GLint blitWidth = t->image[face][hwlevel].width;
GLint blitHeight = t->image[face][hwlevel].height;
fprintf(stderr, " upload image: %d,%d at %d,%d\n",
imageWidth, imageHeight, imageX, imageY);
fprintf(stderr, " upload blit: %d,%d at %d,%d\n",
blitWidth, blitHeight, blitX, blitY);
fprintf(stderr, " blit ofs: 0x%07x level: %d/%d\n",
(GLuint) offset, hwlevel, level);
}
t->image[face][hwlevel].data = texImage->Data;
/* Init the DRM_RADEON_TEXTURE command / drm_radeon_texture_t struct.
* NOTE: we're always use a 1KB-wide blit and I8 texture format.
* We used to use 1, 2 and 4-byte texels and used to use the texture
* width to dictate the blit width - but that won't work for compressed
* textures. (Brian)
*/
tex.offset = offset;
tex.pitch = BLIT_WIDTH_BYTES / 64;
tex.format = R200_TXFORMAT_I8; /* any 1-byte texel format */
if (texImage->TexFormat->TexelBytes) {
tex.width = imageWidth * texImage->TexFormat->TexelBytes; /* in bytes */
tex.height = imageHeight;
} else {
tex.width = imageWidth; /* compressed */
tex.height = imageHeight;
if (tex.height < 4)
tex.height = 4;
}
tex.image = &tmp;
/* copy (x,y,width,height,data) */
memcpy(&tmp, &t->image[face][hwlevel], sizeof(tmp));
LOCK_HARDWARE(&rmesa->radeon);
do {
ret = drmCommandWriteRead(rmesa->radeon.dri.fd, DRM_RADEON_TEXTURE,
&tex, sizeof(drm_radeon_texture_t));
if (ret) {
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr,
"DRM_RADEON_TEXTURE: again!\n");
usleep(1);
}
} while (ret && errno == EAGAIN);
UNLOCK_HARDWARE(&rmesa->radeon);
if (ret) {
fprintf(stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret);
fprintf(stderr, " offset=0x%08x\n", offset);
fprintf(stderr, " image width=%d height=%d\n",
imageWidth, imageHeight);
fprintf(stderr, " blit width=%d height=%d data=%p\n",
t->image[face][hwlevel].width,
t->image[face][hwlevel].height,
t->image[face][hwlevel].data);
exit(1);
}
}
/**
* Upload the texture images associated with texture \a t. This might
* require the allocation of texture memory.
*
* \param rmesa Context pointer
* \param t Texture to be uploaded
* \param face Cube map face to be uploaded. Zero for non-cube maps.
*/
int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
{
const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
fprintf(stderr, "%s( %p, %p ) sz=%d lvls=%d-%d\n", __FUNCTION__,
(void *)rmesa->radeon.glCtx, (void *)t->base.tObj,
t->base.totalSize, t->base.firstLevel,
t->base.lastLevel);
}
if (!t || t->base.totalSize == 0)
return 0;
if (RADEON_DEBUG & DEBUG_SYNC) {
fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
radeonFinish(rmesa->radeon.glCtx);
}
LOCK_HARDWARE(&rmesa->radeon);
if (t->base.memBlock == NULL) {
int heap;
heap = driAllocateTexture(rmesa->texture_heaps, rmesa->nr_heaps,
(driTextureObject *) t);
if (heap == -1) {
UNLOCK_HARDWARE(&rmesa->radeon);
return -1;
}
/* Set the base offset of the texture image */
t->bufAddr = rmesa->radeon.radeonScreen->texOffset[heap]
+ t->base.memBlock->ofs;
t->offset = t->bufAddr;
/* Mark this texobj as dirty on all units:
*/
t->dirty_state = TEX_ALL;
}
/* Let the world know we've used this memory recently.
*/
driUpdateTextureLRU((driTextureObject *) t);
UNLOCK_HARDWARE(&rmesa->radeon);
/* Upload any images that are new */
if (t->base.dirty_images[face]) {
int i;
for (i = 0; i < numLevels; i++) {
if ((t->base.
dirty_images[face] & (1 <<
(i + t->base.firstLevel))) !=
0) {
uploadSubImage(rmesa, t, i, 0, 0,
t->image[face][i].width,
t->image[face][i].height, face);
}
}
t->base.dirty_images[face] = 0;
}
if (RADEON_DEBUG & DEBUG_SYNC) {
fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
radeonFinish(rmesa->radeon.glCtx);
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@
#include "matrix.h"
#include "extensions.h"
#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#include "x86/common_x86_asm.h"
#endif
#include "simple_list.h"
#include "mm.h"

View File

@@ -6,7 +6,7 @@
#include "s3v_vb.h"
#include "s3v_lock.h"
#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#include "x86/common_x86_asm.h"
#endif
#include "context.h"

View File

@@ -25,8 +25,7 @@ DRIVER_SOURCES = \
savagetex.c \
savagetris.c \
savageioctl.c \
savagespan.c \
savagedma.c
savagespan.c
C_SOURCES = \
$(COMMON_SOURCES) \

View File

@@ -341,8 +341,8 @@ typedef enum
TPS_256
} TexPaletteSize;
#define MAX_MIPMAP_LOD_BIAS 255
#define MIN_MIPMAP_LOD_BIAS -255
#define MAX_MIPMAP_LOD_BIAS 255
#define MIN_MIPMAP_LOD_BIAS -255
typedef enum
{
@@ -627,107 +627,6 @@ typedef union {
#define SAVAGE_HW_NO_UV1 ((1<<6) | (1<<7))
#define SAVAGE_HW_SKIPFLAGS 0x000000ff
#define SAVAGE_HW_TRIANGLE_TYPE (3UL<<25)
#define SAVAGE_HW_TRIANGLE_CONT (1UL<<24)
#define SAVAGE_HW_TRIANGLE_LIST (0<<25)
#define SAVAGE_HW_TRIANGLE_STRIP (1<<25)
#define SAVAGE_HW_TRIANGLE_FAN (2<<25)
#define SAVAGE_HW_QUAD (3<<25)
#define __HW_TEXTURE_CHANGED 0x00002FE
#define __HW_HAS_SCISSORS_CHANGED 0x00001800
#define __HW_ALL_CHANGED 0x1FFFFFF
/*Frank 2001/11/14 Wait commands*/
#define WAIT_3D_IDLE 0xC0010000
#define WAIT_3D_2D_IDLE 0xC0030000
#define SET_REGISTER(index, count) \
((CMD_SetRegister << 27) | (0x6000000) | ((count) << 16) | (index))
/*frank 2001/11/20 */
#define MAXLOOP 0xFFFFFF
/*#define MAXFIFO 0x7F00*/
#define MAXFIFO 0x1FF00
/* get eventtag from shadow status */
/* here we use eventTag1 because eventTag0 is used by HWXvMC*/
#define GET_EVENTTAG \
(((*(volatile GLuint *)(imesa->MMIO_BASE+0x48c04)) & 0xffff0000L)>>16)
#define SHADOW_WAIT(imesa ) do \
{ \
int loop=0; \
imesa->shadowCounter = (imesa->shadowCounter + 1) & 0xffff;\
if(imesa->shadowCounter == 0)\
imesa->shadowCounter = MAX_SHADOWCOUNTER;\
*(volatile GLuint *)imesa->BCIBase = imesa->shadowCounter | 0x98400000L;\
while(\
(GET_EVENTTAG) != imesa->shadowCounter &&\
(loop++ < MAXLOOP));\
}while(0);
#define SHADOW_WAIT_IDLE(imesa ) do \
{ \
int loop=0; \
imesa->shadowCounter = (imesa->shadowCounter + 1) & 0xffff;\
if(imesa->shadowCounter == 0)\
imesa->shadowCounter = MAX_SHADOWCOUNTER;\
/* *(volatile GLuint *)imesa->BCIBase = WAIT_3D_IDLE;\*/\
*(volatile GLuint *)imesa->BCIBase = imesa->shadowCounter | 0x98400000L;\
while ( \
(GET_EVENTTAG) != imesa->shadowCounter && \
(loop++ < MAXLOOP)); \
}while(0);
#if 0
#define ALT_STATUS_WORD0 (* (volatile GLuint *)(imesa->MMIO_BASE+0x48c60))
#define PAGE_PENDING(result) do{\
result=((ALT_STATUS_WORD0 & 0x08000000)?GL_TRUE:GL_FALSE);\
}while(0)
#define WAIT_FOR_FIFO(count) do{\
int loop = 0; \
int slots = MAXFIFO-count; \
while(((ALT_STATUS_WORD0 &0x001fffff)>slots)&&(loop++<MAXLOOP)); \
}while(0)
#define WAIT_IDLE_EMPTY do{\
int loop = 0; \
if (/*imesa->shadowStatus*/0)\
{\
SHADOW_WAIT_IDLE(imesa);\
}\
else\
{ \
while(((ALT_STATUS_WORD0 &0x00ffffff)!=0x00E00000L)&&(loop++<MAXLOOP));\
}\
}while(0)
#define WAIT_IDLE do{\
int loop = 0; \
if (imesa->shadowStatus)\
while((((*imesa->shadowPointer) & 0x0E000000L)!=0x0E000000L)&&(loop++<MAXLOOP));\
else\
while(((ALT_STATUS_WORD0 &0x00E00000)!=0x00E00000L)&&(loop++<MAXLOOP)); \
}while(0)
#endif /* 0 */
#define SAVAGE_DRAW_PRIMITIVE(count, typeandvertexSkip, isCont) \
( ((count)<<16) | (typeandvertexSkip) | (isCont | (1<<31)));
static __inline volatile GLuint * SAVAGE_GET_BCI_POINTER(savageContextPtr imesa, GLuint count)
{
WAIT_FOR_FIFO(count);
return (volatile GLuint *)(imesa->BCIBase);
}
/*use this set bci cmd now!*/
#define WRITE_CMD(buf,cmd,type) do {\
*((type*)buf)=cmd;\
buf++;\
}while(0)
#endif

View File

@@ -41,11 +41,6 @@ typedef struct {
} savageRegion, *savageRegionPtr;
typedef struct {
savageRegion front;
savageRegion back;
savageRegion depth;
savageRegion aperture;
int chipset;
int width;
int height;
@@ -53,31 +48,34 @@ typedef struct {
int cpp; /* for front and back buffers */
int zpp;
int agpMode;
unsigned int bufferSize;
#if 0
int bitsPerPixel;
#endif
unsigned int frontFormat;
unsigned int frontOffset;
unsigned int frontPitch;
unsigned int frontBitmapDesc;
unsigned int backOffset;
unsigned int backBitmapDesc;
unsigned int depthOffset;
unsigned int depthBitmapDesc;
unsigned int backPitch;
unsigned int backPitchBits;
unsigned int aperturePitch;
unsigned int textureOffset[SAVAGE_NR_TEX_HEAPS];
unsigned int textureSize[SAVAGE_NR_TEX_HEAPS];
unsigned int logTextureGranularity[SAVAGE_NR_TEX_HEAPS];
drmAddress texVirtual[SAVAGE_NR_TEX_HEAPS];
__DRIscreenPrivate *driScrnPriv;
drmBufMapPtr bufs;
int use_copy_buf;
unsigned int sarea_priv_offset;
__DRIscreenPrivate *driScrnPriv;
savageRegion aperture;
savageRegion agpTextures;
drmBufMapPtr bufs;
unsigned int sarea_priv_offset;
/* Configuration cache with default values for all contexts */
driOptionCache optionCache;
@@ -87,7 +85,6 @@ typedef struct {
#include "savagecontext.h"
extern void savageGetLock( savageContextPtr imesa, GLuint flags );
extern void savageEmitHwStateLocked( savageContextPtr imesa );
extern void savageEmitScissorValues( savageContextPtr imesa, int box_nr, int emit );
extern void savageEmitDrawingRectangle( savageContextPtr imesa );
extern void savageXMesaSetBackClipRects( savageContextPtr imesa );

View File

@@ -55,8 +55,6 @@
#include "savage_dri.h"
#include "savagedma.h"
#include "xmlpool.h"
/* Configuration
@@ -66,6 +64,7 @@ DRI_CONF_BEGIN
DRI_CONF_SECTION_QUALITY
DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
DRI_CONF_FLOAT_DEPTH(false)
DRI_CONF_SECTION_END
DRI_CONF_SECTION_PERFORMANCE
DRI_CONF_MAX_TEXTURE_UNITS(2,1,2)
@@ -74,7 +73,7 @@ DRI_CONF_BEGIN
DRI_CONF_NO_RAST(false)
DRI_CONF_SECTION_END
DRI_CONF_END;
static const GLuint __driNConfigOptions = 4;
static const GLuint __driNConfigOptions = 5;
#ifdef USE_NEW_INTERFACE
static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
@@ -85,6 +84,8 @@ static const struct dri_debug_control debug_control[] =
{ "fall", DEBUG_FALLBACKS },
{ "api", DEBUG_VERBOSE_API },
{ "lru", DEBUG_VERBOSE_LRU },
{ "verb", DEBUG_VERBOSE_MSG },
{ "dma", DEBUG_DMA },
{ NULL, 0 }
};
#ifndef SAVAGE_DEBUG
@@ -131,7 +132,6 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
savageScreenPrivate *savageScreen;
SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
/* Allocate the private area */
savageScreen = (savageScreenPrivate *)Xmalloc(sizeof(savageScreenPrivate));
if (!savageScreen)
@@ -146,23 +146,19 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
savageScreen->mem=gDRIPriv->mem;
savageScreen->cpp=gDRIPriv->cpp;
savageScreen->zpp=gDRIPriv->zpp;
savageScreen->frontPitch=gDRIPriv->frontPitch;
savageScreen->frontOffset=gDRIPriv->frontOffset;
savageScreen->frontBitmapDesc = gDRIPriv->frontBitmapDesc;
savageScreen->agpMode=gDRIPriv->agpMode;
savageScreen->bufferSize=gDRIPriv->bufferSize;
if (gDRIPriv->cpp == 4)
savageScreen->frontFormat = DV_PF_8888;
else
savageScreen->frontFormat = DV_PF_565;
savageScreen->frontOffset=gDRIPriv->frontOffset;
savageScreen->backOffset = gDRIPriv->backOffset;
savageScreen->backBitmapDesc = gDRIPriv->backBitmapDesc;
savageScreen->depthOffset=gDRIPriv->depthOffset;
savageScreen->depthBitmapDesc = gDRIPriv->depthBitmapDesc;
#if 0
savageScreen->backPitch = gDRIPriv->auxPitch;
savageScreen->backPitchBits = gDRIPriv->auxPitchBits;
#endif
savageScreen->textureOffset[SAVAGE_CARD_HEAP] =
gDRIPriv->textureOffset;
savageScreen->textureSize[SAVAGE_CARD_HEAP] =
@@ -171,57 +167,32 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
gDRIPriv->logTextureGranularity;
savageScreen->textureOffset[SAVAGE_AGP_HEAP] =
gDRIPriv->agpTextures.handle;
gDRIPriv->agpTextureHandle;
savageScreen->textureSize[SAVAGE_AGP_HEAP] =
gDRIPriv->agpTextures.size;
gDRIPriv->agpTextureSize;
savageScreen->logTextureGranularity[SAVAGE_AGP_HEAP] =
gDRIPriv->logAgpTextureGranularity;
savageScreen->back.handle = gDRIPriv->backbuffer;
savageScreen->back.size = gDRIPriv->backbufferSize;
savageScreen->back.map =
(drmAddress)(((unsigned int)sPriv->pFB)+gDRIPriv->backOffset);
savageScreen->depth.handle = gDRIPriv->depthbuffer;
savageScreen->depth.size = gDRIPriv->depthbufferSize;
savageScreen->depth.map =
(drmAddress)(((unsigned int)sPriv->pFB)+gDRIPriv->depthOffset);
savageScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
savageScreen->agpTextures.handle = gDRIPriv->agpTextureHandle;
savageScreen->agpTextures.size = gDRIPriv->agpTextureSize;
if (drmMap(sPriv->fd,
savageScreen->agpTextures.handle,
savageScreen->agpTextures.size,
(drmAddress *)&(savageScreen->agpTextures.map)) != 0)
{
Xfree(savageScreen);
sPriv->private = NULL;
return GL_FALSE;
}
savageScreen->texVirtual[SAVAGE_CARD_HEAP] =
(drmAddress)(((unsigned int)sPriv->pFB)+gDRIPriv->textureOffset);
if (drmMap(sPriv->fd,
gDRIPriv->registers.handle,
gDRIPriv->registers.size,
(drmAddress *)&(gDRIPriv->registers.map)) != 0)
{
Xfree(savageScreen);
sPriv->private = NULL;
return GL_FALSE;
}
if (drmMap(sPriv->fd,
gDRIPriv->agpTextures.handle,
gDRIPriv->agpTextures.size,
(drmAddress *)&(gDRIPriv->agpTextures.map)) != 0)
{
Xfree(savageScreen);
sPriv->private = NULL;
return GL_FALSE;
}
/* agp texture*/
savageScreen->texVirtual[SAVAGE_AGP_HEAP] =
(drmAddress)(gDRIPriv->agpTextures.map);
(drmAddress)(savageScreen->agpTextures.map);
gDRIPriv->BCIcmdBuf.map = (drmAddress *)
((unsigned int)gDRIPriv->registers.map+0x00010000);
savageScreen->aperture.handle = gDRIPriv->aperture.handle;
savageScreen->aperture.size = gDRIPriv->aperture.size;
savageScreen->aperture.handle = gDRIPriv->apertureHandle;
savageScreen->aperture.size = gDRIPriv->apertureSize;
savageScreen->aperturePitch = gDRIPriv->aperturePitch;
if (drmMap(sPriv->fd,
savageScreen->aperture.handle,
savageScreen->aperture.size,
@@ -230,8 +201,12 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
Xfree(savageScreen);
sPriv->private = NULL;
return GL_FALSE;
}
}
savageScreen->bufs = drmMapBufs(sPriv->fd);
savageScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
/* parse information in __driConfigOptions */
driParseOptionInfo (&savageScreen->optionCache,
__driConfigOptions, __driNConfigOptions);
@@ -251,6 +226,8 @@ savageDestroyScreen(__DRIscreenPrivate *sPriv)
{
savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
drmUnmapBufs(savageScreen->bufs);
/* free all option information */
driDestroyOptionInfo (&savageScreen->optionCache);
@@ -295,7 +272,6 @@ savageCreateContext( const __GLcontextModes *mesaVis,
savageContextPtr imesa;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
struct dd_function_table functions;
SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
drm_savage_sarea_t *saPriv=(drm_savage_sarea_t *)(((char*)sPriv->pSAREA)+
savageScreen->sarea_priv_offset);
@@ -323,10 +299,19 @@ savageCreateContext( const __GLcontextModes *mesaVis,
}
driContextPriv->driverPrivate = imesa;
imesa->cmdBuf.size = SAVAGE_CMDBUF_SIZE;
imesa->cmdBuf.base = imesa->cmdBuf.write =
malloc(SAVAGE_CMDBUF_SIZE * sizeof(drm_savage_cmd_header_t));
if (!imesa->cmdBuf.base)
return GL_FALSE;
/* Parse configuration files */
driParseConfigFiles (&imesa->optionCache, &savageScreen->optionCache,
sPriv->myNum, "savage");
imesa->float_depth = driQueryOptionb(&imesa->optionCache, "float_depth") &&
savageScreen->chipset >= S3_SAVAGE4;
imesa->no_rast = driQueryOptionb(&imesa->optionCache, "no_rast");
imesa->texture_depth = driQueryOptioni (&imesa->optionCache,
"texture_depth");
if (imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
@@ -398,26 +383,14 @@ savageCreateContext( const __GLcontextModes *mesaVis,
/* DMA buffer */
/*The shadow pointer*/
imesa->shadowPointer =
(volatile GLuint *)((((GLuint)(&saPriv->shadow_status)) + 31) & 0xffffffe0L) ;
/* here we use eventTag1 because eventTag0 is used by HWXvMC*/
imesa->eventTag1 = (volatile GLuint *)(imesa->shadowPointer + 6);
/* imesa->eventTag1=(volatile GLuint *)(imesa->MMIO_BASE+0x48c04);*/
imesa->shadowCounter = MAX_SHADOWCOUNTER;
imesa->shadowStatus = GL_TRUE;/*Will judge by 2d message */
imesa->MMIO_BASE = (GLuint)gDRIPriv->registers.map;
imesa->BCIBase= (GLuint)gDRIPriv->BCIcmdBuf.map;
for(i=0;i<5;i++)
{
imesa->apertureBase[i] = ((GLuint)savageScreen->aperture.map +
0x01000000 * i );
}
imesa->aperturePitch = gDRIPriv->aperturePitch;
imesa->aperturePitch = savageScreen->aperturePitch;
/* change texHeap initialize to support two kind of texture heap*/
/* here is some parts of initialization, others in InitDriver() */
@@ -438,9 +411,19 @@ savageCreateContext( const __GLcontextModes *mesaVis,
imesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
imesa->depth_scale = (imesa->savageScreen->zpp == 2) ?
(1.0F/0x10000):(1.0F/0x1000000);
(1.0F/0xffff):(1.0F/0xffffff);
imesa->vertex_dma_buffer = NULL;
imesa->bufferSize = savageScreen->bufferSize;
imesa->dmaVtxBuf.total = 0;
imesa->dmaVtxBuf.used = 0;
imesa->dmaVtxBuf.flushed = 0;
imesa->clientVtxBuf.total = 16384;
imesa->clientVtxBuf.used = 0;
imesa->clientVtxBuf.flushed = 0;
imesa->clientVtxBuf.buf = (u_int32_t *)malloc(16384*4);
imesa->vtxBuf = &imesa->clientVtxBuf;
/* Uninitialized vertex format. Force setting the vertex state in
* savageRenderStart.
@@ -450,6 +433,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
/* Utah stuff
*/
imesa->new_state = ~0;
imesa->new_gl_state = ~0;
imesa->RenderIndex = ~0;
imesa->dirty = ~0;
imesa->lostContext = GL_TRUE;
@@ -483,8 +467,6 @@ savageCreateContext( const __GLcontextModes *mesaVis,
ctx->DriverCtx = (void *) imesa;
imesa->glCtx = ctx;
if (savageDMAInit(imesa) == GL_FALSE)
return GL_FALSE;
#ifndef SAVAGE_DEBUG
SAVAGE_DEBUG = driParseDebugString( getenv( "SAVAGE_DEBUG" ),
@@ -501,9 +483,6 @@ savageCreateContext( const __GLcontextModes *mesaVis,
savageDDInitState( imesa );
if (driQueryOptionb(&imesa->optionCache, "no_rast"))
FALLBACK(ctx, SAVAGE_FALLBACK_NORAST, GL_TRUE);
driContextPriv->driverPrivate = (void *) imesa;
return GL_TRUE;
@@ -529,8 +508,10 @@ savageDestroyContext(__DRIcontextPrivate *driContextPriv)
}
foreach_s (t, next_t, &(imesa->SwappedOut))
savageDestroyTexObj(imesa, t);
/*free the dma buffer*/
savageDMAClose(imesa);
free(imesa->cmdBuf.base);
free(imesa->clientVtxBuf.buf);
_swsetup_DestroyContext(imesa->glCtx );
_tnl_DestroyContext( imesa->glCtx );
_ac_DestroyContext( imesa->glCtx );
@@ -753,10 +734,13 @@ void savageGetLock( savageContextPtr imesa, GLuint flags )
* more broken than usual.
*/
if (sarea->ctxOwner != me) {
imesa->dirty |= (SAVAGE_UPLOAD_CTX |
SAVAGE_UPLOAD_CLIPRECTS |
imesa->dirty |= (SAVAGE_UPLOAD_LOCAL |
SAVAGE_UPLOAD_GLOBAL |
SAVAGE_UPLOAD_FOGTBL |
SAVAGE_UPLOAD_TEX0 |
SAVAGE_UPLOAD_TEX1);
SAVAGE_UPLOAD_TEX1 |
SAVAGE_UPLOAD_TEXGLOBAL |
SAVAGE_UPLOAD_CLIPRECTS);
imesa->lostContext = GL_TRUE;
sarea->ctxOwner = me;
}
@@ -794,8 +778,6 @@ void savageGetLock( savageContextPtr imesa, GLuint flags )
savageResetGlobalLRU( imesa , heap );
}
imesa->dirty |= SAVAGE_UPLOAD_TEX0IMAGE;
imesa->dirty |= SAVAGE_UPLOAD_TEX1IMAGE;
imesa->texAge[heap] = sarea->texAge[heap];
}
} /* end of for loop */
@@ -948,10 +930,9 @@ void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc
{
__DRIscreenPrivate *psp;
static const __DRIversion ddx_expected = { 1, 0, 0 };
static const __DRIversion ddx_expected = { 2, 0, 0 };
static const __DRIversion dri_expected = { 4, 0, 0 };
static const __DRIversion drm_expected = { 1, 0, 0 };
static const __DRIversion drm_expected = { 2, 0, 0 };
if ( ! driCheckDriDdxDrmVersions2( "Savage",
dri_version, & dri_expected,

View File

@@ -42,7 +42,6 @@ typedef struct savage_texture_object_t *savageTextureObjectPtr;
#include "tnl/t_vertex.h"
#include "savagetex.h"
#include "savagedma.h"
#include "xmlconfig.h"
@@ -69,10 +68,26 @@ typedef struct savage_texture_object_t *savageTextureObjectPtr;
#define SAVAGE_NEW_TEXTURE 0x1
#define SAVAGE_NEW_CULL 0x2
/* What needs to be changed for the current vertex dma buffer?
* This will go away!
*/
#define SAVAGE_UPLOAD_LOCAL 0x1 /* DrawLocalCtrl (S4) or
DrawCtrl and ZBufCtrl (S3D) */
#define SAVAGE_UPLOAD_TEX0 0x2 /* texture unit 0 */
#define SAVAGE_UPLOAD_TEX1 0x4 /* texture unit 1 (S4 only) */
#define SAVAGE_UPLOAD_FOGTBL 0x8 /* fog table */
#define SAVAGE_UPLOAD_GLOBAL 0x10 /* most global regs */
#define SAVAGE_UPLOAD_TEXGLOBAL 0x20 /* TexBlendColor (S4 only) */
#define SAVAGE_UPLOAD_CLIPRECTS 0x1000 /* FIXME: get rid of this */
/*define the max numer of vertex in vertex buf*/
#define SAVAGE_MAX_VERTEXS 0x10000
/* Don't make it too big. We don't want to buffer up a whole frame
* that would force the application to wait later. */
#define SAVAGE_CMDBUF_SIZE 1024
#define SAVAGE_MAX_VERTS_PENDING 1024
/* Use the templated vertex formats:
*/
#define TAG(x) savage##x
@@ -113,6 +128,18 @@ typedef void (*savage_point_func)( savageContextPtr, savageVertex * );
imesa->savageScreen->deviceID == CHIP_S3TRISTAR64CDDR )
struct savage_vtxbuf_t {
GLuint total, used, flushed; /* in 32 bit units */
GLuint idx; /* for DMA buffers */
u_int32_t *buf;
};
struct savage_cmdbuf_t {
GLuint size; /* size in qwords */
drm_savage_cmd_header_t *base; /* initial state starts here */
drm_savage_cmd_header_t *start; /* drawing/state commands start here */
drm_savage_cmd_header_t *write; /* append stuff here */
};
struct savage_context_t {
@@ -143,11 +170,12 @@ struct savage_context_t {
GLuint new_gl_state;
GLboolean ptexHack;
GLuint BCIBase;
GLuint MMIO_BASE;
/* Command buffer */
struct savage_cmdbuf_t cmdBuf;
/* DMA command buffer */
DMABuffer_t DMABuf;
/* Vertex buffers */
struct savage_vtxbuf_t dmaVtxBuf, clientVtxBuf;
struct savage_vtxbuf_t *vtxBuf;
/* aperture base */
GLuint apertureBase[5];
@@ -179,7 +207,8 @@ struct savage_context_t {
GLenum raster_primitive;
GLenum render_primitive;
GLuint DrawPrimitiveCmd;
GLuint skip;
GLubyte HwPrim;
GLuint HwVertexSize;
/* Fallback rasterization functions
@@ -194,8 +223,9 @@ struct savage_context_t {
GLuint ClearColor;
GLfloat depth_scale;
GLfloat hw_viewport[16];
/* DRI stuff */
drmBufPtr vertex_dma_buffer;
/* DRI stuff */
GLuint bufferSize;
GLuint vertsPending;
GLframebuffer *glBuffer;
@@ -225,8 +255,8 @@ struct savage_context_t {
GLuint backup_streamFIFO;
GLuint NotFirstFrame;
GLboolean inSwap;
GLuint lastSwap;
GLuint secondLastSwap;
GLuint ctxAge;
GLuint dirtyAge;
GLuint any_contend; /* throttle me harder */
@@ -235,7 +265,7 @@ struct savage_context_t {
GLboolean scissorChanged;
drm_clip_rect_t draw_rect;
drm_clip_rect_t scissor_rect;
drm_clip_rect_t tmp_boxes[2][SAVAGE_NR_SAREA_CLIPRECTS];
/*Texture aging and DMA based aging*/
unsigned int texAge[SAVAGE_NR_TEX_HEAPS];
@@ -259,16 +289,12 @@ struct savage_context_t {
GLboolean hw_stencil;
/*shadow pointer*/
volatile GLuint *shadowPointer;
volatile GLuint *eventTag1;
GLuint shadowCounter;
GLboolean shadowStatus;
/* Configuration cache
*/
driOptionCache optionCache;
int texture_depth;
GLint texture_depth;
GLboolean no_rast;
GLboolean float_depth;
};
#define SAVAGE_CONTEXT(ctx) ((savageContextPtr)(ctx->DriverCtx))
@@ -283,6 +309,8 @@ extern int SAVAGE_DEBUG;
#define DEBUG_FALLBACKS 0x001
#define DEBUG_VERBOSE_API 0x002
#define DEBUG_VERBOSE_LRU 0x004
#define DEBUG_VERBOSE_MSG 0x008
#define DEBUG_DMA 0x010
#define TARGET_FRONT 0x0
#define TARGET_BACK 0x1

View File

@@ -38,6 +38,10 @@
#include "savagecontext.h"
#include "extensions.h"
#include "utils.h"
#define DRIVER_DATE "20050101"
/***************************************
* Mesa's Driver Functions
@@ -46,11 +50,33 @@
static const GLubyte *savageDDGetString( GLcontext *ctx, GLenum name )
{
static char *cardNames[S3_LAST] = {
"Unknown",
"Savage3D",
"Savage/MX/IX",
"Savage4",
"ProSavage",
"Twister",
"ProSavageDDR",
"SuperSavage",
"Savage2000"
};
static char buffer[128];
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
savageScreenPrivate *screen = imesa->savageScreen;
enum S3CHIPTAGS chipset = screen->chipset;
unsigned offset;
if (chipset < S3_SAVAGE3D || chipset >= S3_LAST)
chipset = S3_UNKNOWN; /* should not happen */
switch (name) {
case GL_VENDOR:
return (GLubyte *)"S3 Graphics Inc.";
case GL_RENDERER:
return (GLubyte *)"Mesa DRI SAVAGE Linux_1.1.18";
offset = driGetRendererString( buffer, cardNames[chipset], DRIVER_DATE,
screen->agpMode );
return (GLubyte *)buffer;
default:
return 0;
}

View File

@@ -30,20 +30,7 @@
#include <time.h>
#include <unistd.h>
/* Commit does not depend on whether we use real DMA or fake it via the BCI */
void savageDMACommit (savageContextPtr imesa, void *endPtr) {
DMABufferPtr dmaBuff = &imesa->DMABuf;
GLuint end = (GLuint)endPtr;
/* make sure that enough space was allocated */
assert (end <= dmaBuff->allocEnd);
dmaBuff->allocEnd = dmaBuff->end = end;
/* TODO: check commands, either here or in flush */
}
#if SAVAGE_CMD_DMA
#if 0
/* flag =
0 return -1 if no available page
1 wait until a page be available */
@@ -219,139 +206,4 @@ int savageDMAClose (savageContextPtr imesa)
return GL_TRUE;
}
#else
/* Allocate space in faked DMA buffer */
void *savageDMAAlloc (savageContextPtr imesa, GLuint size) {
DMABufferPtr dmaBuff = &imesa->DMABuf;
/* make sure that everything has been filled in and committed */
assert (dmaBuff->end == dmaBuff->allocEnd);
size *= sizeof (u_int32_t); /* size in bytes */
if (dmaBuff->end + size >= dmaBuff->buf->linear + DMA_PAGE_SIZE) {
/* need kick off */
savageDMAFlush (imesa);
}
dmaBuff->allocEnd = dmaBuff->end + size;
return (void *)dmaBuff->end;
}
/* Flush DMA buffer via BCI (faked DMA) */
void savageDMAFlush(savageContextPtr imesa) {
volatile u_int32_t* BCIbase;
DMABufferPtr dmaBuff = &imesa->DMABuf;
u_int32_t *entry;
/* make sure that everything has been filled in and committed */
assert (dmaBuff->allocEnd == dmaBuff->end);
if (dmaBuff->start == dmaBuff->end) /* no command? */
return;
/* get bci base */
BCIbase = (volatile u_int32_t *)SAVAGE_GET_BCI_POINTER(
imesa, (dmaBuff->end - dmaBuff->start) / sizeof (u_int32_t));
for (entry = (u_int32_t *)dmaBuff->start;
entry < (u_int32_t *)dmaBuff->end; ++entry)
*BCIbase = *entry;
dmaBuff->end = dmaBuff->allocEnd = dmaBuff->start;
}
/* Init faked DMA */
int savageDMAInit (savageContextPtr imesa) {
DMABufferPtr dmaBuff = &imesa->DMABuf;
drm_savage_alloc_cont_mem_t * req;
req = (drm_savage_alloc_cont_mem_t *)
malloc (sizeof(drm_savage_alloc_cont_mem_t));
if (!req)
return GL_FALSE;
req->linear = (GLuint)malloc (DMA_PAGE_SIZE);
if (!req->linear) {
free (req);
return GL_FALSE;
}
dmaBuff->buf = req;
dmaBuff->start = dmaBuff->end = dmaBuff->allocEnd = req->linear;
dmaBuff->usingPage = 0;
dmaBuff->kickFlag = GL_FALSE;
return GL_TRUE;
}
/* Close faked DMA */
int savageDMAClose (savageContextPtr imesa) {
DMABufferPtr dmaBuff = &imesa->DMABuf;
drm_savage_alloc_cont_mem_t * req = dmaBuff->buf;
free ((void *)req->linear);
free (req);
return GL_TRUE;
}
#endif
/* Faked vertex buffers
*
* This is a dirty hack, knowing that it will go away soon when real
* vertex DMA is implemented and eventually moved to the DRM.
*/
static u_int32_t vertex_data[16384]; /* 64KB */
static drmBuf vertex_buffer = {
0, /* idx */
65536, /* total = 64KB */
0, /* used */
(drmAddress)vertex_data /* address */
};
void savageFakeVertices (savageContextPtr imesa, drmBufPtr buffer) {
GLuint vertexStride = imesa->HwVertexSize; /* stride in dwords */
GLuint vertexSize = imesa->HwVertexSize; /* the real vertex size in dwords */
GLuint nVertices = buffer->used / (vertexStride*4);
u_int32_t *data = (u_int32_t*)buffer->address;
u_int32_t vertexFormat = imesa->DrawPrimitiveCmd & SAVAGE_HW_SKIPFLAGS;
GLuint i, j, left;
/* we have the monopoly on vertex buffers ;-) */
assert (buffer == &vertex_buffer);
assert (buffer->used % (vertexStride*4) == 0); /* whole vertices */
assert (nVertices % 3 == 0); /* triangle lists */
/* Flush (pseodo) DMA before accessing the BCI directly. */
savageDMAFlush(imesa);
left = nVertices;
while (left != 0) {
/* Can emit up to 255 vertices (85 triangles) with one command. */
GLuint count = left > 255 ? 255 : left;
/* Don't go through another buffering mechanism, copy to BCI
* directly. */
volatile u_int32_t *vb = SAVAGE_GET_BCI_POINTER(imesa,
count*vertexSize + 1);
WRITE_CMD (vb, SAVAGE_DRAW_PRIMITIVE(
count, SAVAGE_HW_TRIANGLE_LIST | vertexFormat, 0),
u_int32_t);
for (i = 0; i < count; ++i) {
for (j = 0; j < vertexSize; ++j)
WRITE_CMD (vb, data[j], u_int32_t);
data += vertexStride;
}
left -= count;
}
/* clear the vertex buffer for the next set of vertices */
vertex_buffer.used = 0;
}
drmBufPtr savageFakeGetBuffer (savageContextPtr imesa) {
assert (vertex_buffer.used == 0); /* has been flushed */
return &vertex_buffer;
}

View File

@@ -49,8 +49,4 @@ void savageDMAFlush (savageContextPtr imesa);
int savageDMAInit (savageContextPtr imesa);
int savageDMAClose (savageContextPtr);
/* faked implementation of vertex buffers */
void savageFakeVertices (savageContextPtr imesa, drmBufPtr buffer);
drmBufPtr savageFakeGetBuffer (savageContextPtr imesa);
#endif

View File

@@ -37,16 +37,87 @@
#include "savagecontext.h"
#include "savageioctl.h"
#include "savage_bci.h"
#include "savagedma.h"
#include "savagestate.h"
#include "savagespan.h"
#include "drm.h"
#include <sys/ioctl.h>
#include <sys/timeb.h>
extern GLuint bcicount;
#define DEPTH_SCALE_16 ((1<<16)-1)
#define DEPTH_SCALE_24 ((1<<24)-1)
void savageGetDMABuffer( savageContextPtr imesa )
{
int idx = 0;
int size = 0;
drmDMAReq dma;
int retcode;
drmBufPtr buf;
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf(stderr, "Getting dma buffer\n");
dma.context = imesa->hHWContext;
dma.send_count = 0;
dma.send_list = NULL;
dma.send_sizes = NULL;
dma.flags = 0;
dma.request_count = 1;
dma.request_size = imesa->bufferSize;
dma.request_list = &idx;
dma.request_sizes = &size;
dma.granted_count = 0;
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf(stderr, "drmDMA (get) ctx %d count %d size 0x%x\n",
dma.context, dma.request_count,
dma.request_size);
while (1) {
retcode = drmDMA(imesa->driFd, &dma);
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf(stderr, "retcode %d sz %d idx %d count %d\n",
retcode,
dma.request_sizes[0],
dma.request_list[0],
dma.granted_count);
if (retcode == 0 &&
dma.request_sizes[0] &&
dma.granted_count)
break;
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf(stderr, "\n\nflush");
}
buf = &(imesa->savageScreen->bufs->list[idx]);
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf(stderr,
"drmDMA (get) returns size[0] 0x%x idx[0] %d\n"
"dma_buffer now: buf idx: %d size: %d used: %d addr %p\n",
dma.request_sizes[0], dma.request_list[0],
buf->idx, buf->total,
buf->used, buf->address);
imesa->dmaVtxBuf.total = buf->total / 4;
imesa->dmaVtxBuf.used = 0;
imesa->dmaVtxBuf.flushed = 0;
imesa->dmaVtxBuf.idx = buf->idx;
imesa->dmaVtxBuf.buf = (u_int32_t *)buf->address;
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf(stderr, "finished getbuffer\n");
}
#if 0
/* Still keeping this around because it demonstrates page flipping and
* automatic z-clear. */
static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
@@ -113,7 +184,7 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
imesa->regs.s4.zBufCtrl.ni.frameID =
~imesa->regs.s4.zBufCtrl.ni.frameID;
imesa->dirty |= SAVAGE_UPLOAD_CTX;
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
else
{
@@ -157,8 +228,6 @@ static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
savageDMAFlush (imesa);
}
struct timeb a,b;
static void savage_BCI_swap(savageContextPtr imesa)
{
int nbox = imesa->sarea->nbox;
@@ -186,7 +255,7 @@ static void savage_BCI_swap(savageContextPtr imesa)
imesa->readMap = (char *)imesa->apertureBase[imesa->toggle];
imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
imesa->dirty |= SAVAGE_UPLOAD_CTX;
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
bciptr = SAVAGE_GET_BCI_POINTER(imesa,3);
*(bciptr) = 0x960100B0;
*(bciptr) = (imesa->savageScreen->frontOffset);
@@ -220,97 +289,120 @@ static void savage_BCI_swap(savageContextPtr imesa)
}
}
#endif
static GLboolean intersect_rect( drm_clip_rect_t *out,
const drm_clip_rect_t *a,
const drm_clip_rect_t *b )
{
*out = *a;
if (b->x1 > out->x1) out->x1 = b->x1;
if (b->y1 > out->y1) out->y1 = b->y1;
if (b->x2 < out->x2) out->x2 = b->x2;
if (b->y2 < out->y2) out->y2 = b->y2;
return ((out->x1 < out->x2) && (out->y1 < out->y2));
}
static GLuint savageIntersectClipRects(drm_clip_rect_t *dest,
const drm_clip_rect_t *src,
GLuint nsrc,
const drm_clip_rect_t *clip)
{
GLuint i, ndest;
for (i = 0, ndest = 0; i < nsrc; ++i, ++src) {
if (intersect_rect(dest, src, clip)) {
dest++;
ndest++;
}
}
return ndest;
}
static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch )
{
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
drm_savage_clear_t clear;
int i;
GLuint colorMask, depthMask, clearColor, clearDepth, flags;
clear.flags = 0;
clear.clear_color = imesa->ClearColor;
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "%s\n", __FUNCTION__);
if(imesa->savageScreen->zpp == 2)
clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_16);
else
clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_24);
clearColor = imesa->ClearColor;
if (imesa->float_depth) {
if (imesa->savageScreen->zpp == 2)
clearDepth = savageEncodeFloat16(1.0 - ctx->Depth.Clear);
else
clearDepth = savageEncodeFloat24(1.0 - ctx->Depth.Clear);
} else {
if (imesa->savageScreen->zpp == 2)
clearDepth = (GLuint) ((1.0 - ctx->Depth.Clear) * DEPTH_SCALE_16);
else
clearDepth = (GLuint) ((1.0 - ctx->Depth.Clear) * DEPTH_SCALE_24);
}
FLUSH_BATCH( imesa );
colorMask = *((GLuint *) &ctx->Color.ColorMask);
depthMask = 0;
if ((mask & DD_FRONT_LEFT_BIT) && ((colorMask&0xffffffUL)==0xffffffUL) ){
clear.flags |= SAVAGE_FRONT;
flags = 0;
if (mask & DD_FRONT_LEFT_BIT) {
flags |= SAVAGE_FRONT;
mask &= ~DD_FRONT_LEFT_BIT;
}
if ((mask & DD_BACK_LEFT_BIT) && ((colorMask&0xffffffUL)==0xffffffUL) ) {
clear.flags |= SAVAGE_BACK;
if (mask & DD_BACK_LEFT_BIT) {
flags |= SAVAGE_BACK;
mask &= ~DD_BACK_LEFT_BIT;
}
if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) {
clear.flags |= SAVAGE_DEPTH;
flags |= SAVAGE_DEPTH;
depthMask |=
(imesa->savageScreen->zpp == 2) ? 0xffffffff : 0x00ffffff;
mask &= ~DD_DEPTH_BIT;
}
if((mask & DD_STENCIL_BIT) && imesa->hw_stencil)
{
clear.flags |= SAVAGE_STENCIL;
mask &= ~DD_STENCIL_BIT;
flags |= SAVAGE_DEPTH;
depthMask |= 0xff000000;
mask &= ~DD_STENCIL_BIT;
}
if (clear.flags) {
LOCK_HARDWARE( imesa );
savageFlushVertices(imesa);
/* flip top to bottom */
cy = dPriv->h-cy-ch;
cx += imesa->drawX;
cy += imesa->drawY;
for (i = 0 ; i < imesa->numClipRects ; ) {
int nr = MIN2(i + SAVAGE_NR_SAREA_CLIPRECTS, imesa->numClipRects);
drm_clip_rect_t *box = imesa->pClipRects;
drm_clip_rect_t *b = imesa->sarea->boxes;
int n = 0;
if (!all) {
for ( ; i < nr ; i++) {
GLint x = box[i].x1;
GLint y = box[i].y1;
GLint w = box[i].x2 - x;
GLint h = box[i].y2 - y;
if (x < cx) w -= cx - x, x = cx;
if (y < cy) h -= cy - y, y = cy;
if (x + w > cx + cw) w = cx + cw - x;
if (y + h > cy + ch) h = cy + ch - y;
if (w <= 0) continue;
if (h <= 0) continue;
b->x1 = x;
b->y1 = y;
b->x2 = x + w;
b->y2 = y + h;
b++;
n++;
}
} else {
for ( ; i < nr ; i++) {
*b++ = *(drm_clip_rect_t *)&box[i];
n++;
}
}
imesa->sarea->nbox = n;
savage_BCI_clear(ctx,&clear);
if (flags) {
GLboolean depthCleared = GL_FALSE;
if (flags & (SAVAGE_FRONT|SAVAGE_BACK)) {
drm_savage_cmd_header_t *cmd;
cmd = savageAllocCmdBuf(imesa, sizeof(drm_savage_cmd_header_t));
cmd[0].clear0.cmd = SAVAGE_CMD_CLEAR;
if ((flags & SAVAGE_DEPTH) &&
clearDepth == clearColor && depthMask == colorMask) {
cmd[0].clear0.flags = flags;
depthCleared = GL_TRUE;
} else
cmd[0].clear0.flags = flags & (SAVAGE_FRONT|SAVAGE_BACK);
cmd[1].clear1.mask = colorMask;
cmd[1].clear1.value = clearColor;
}
UNLOCK_HARDWARE( imesa );
imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS|SAVAGE_UPLOAD_CTX;
if ((flags & SAVAGE_DEPTH) && !depthCleared) {
drm_savage_cmd_header_t *cmd;
cmd = savageAllocCmdBuf(imesa, sizeof(drm_savage_cmd_header_t));
cmd[0].clear0.cmd = SAVAGE_CMD_CLEAR;
cmd[0].clear0.flags = SAVAGE_DEPTH;
cmd[1].clear1.mask = depthMask;
cmd[1].clear1.value = clearDepth;
}
imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
}
if (mask)
@@ -318,7 +410,11 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
}
/* This is necessary as to prevent annyoing stuttering effects with
* some games, though it does reduce the frame rate (glxgears)
* slightly. I believe this is due to texture uploads which do not go
* through the Savage command pipeline yet. */
#define SYNC_FRAMES 1
/*
* Copy the back buffer to the front buffer.
@@ -326,11 +422,9 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
{
savageContextPtr imesa;
drm_clip_rect_t *pbox;
int nbox;
int i;
GLboolean pending;
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "%s\n================================\n", __FUNCTION__);
assert(dPriv);
assert(dPriv->driContextPriv);
@@ -342,38 +436,30 @@ void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
FLUSH_BATCH(imesa);
LOCK_HARDWARE( imesa );
WAIT_IDLE_EMPTY;
PAGE_PENDING(pending);
#if SYNC_FRAMES
imesa->lastSwap = savageEmitEvent( imesa, 0 );
#endif
if (imesa->lastSwap != 0)
savageWaitEvent( imesa, imesa->lastSwap );
if(!pending)
{
pbox = dPriv->pClipRects;
nbox = dPriv->numClipRects;
for (i = 0 ; i < nbox ; )
{
int nr = MIN2(i + SAVAGE_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes;
imesa->sarea->nbox = nr - i;
for ( ; i < nr ; i++)
*b++ = pbox[i];
savage_BCI_swap(imesa) ;
drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, 0);
cmd->cmd.cmd = SAVAGE_CMD_SWAP;
imesa->inSwap = GL_TRUE; /* ignore scissors in savageFlushCmdBuf */
savageFlushCmdBuf(imesa, GL_FALSE);
imesa->inSwap = GL_FALSE;
}
}
UNLOCK_HARDWARE( imesa );
#if !SYNC_FRAMES
imesa->lastSwap = savageEmitEvent( imesa, 0 );
#endif
}
/* This waits for *everybody* to finish rendering -- overkill.
*/
void savageDmaFinish( savageContextPtr imesa )
{
savageDMAFlush(imesa);
WAIT_IDLE_EMPTY;
savageWaitEvent( imesa, savageEmitEventLocked( imesa, SAVAGE_WAIT_3D ) );
}
@@ -393,152 +479,189 @@ void savageWaitAge( savageContextPtr imesa, int age )
}
void savageFlushVerticesLocked( savageContextPtr imesa )
unsigned int savageEmitEventLocked( savageContextPtr imesa, unsigned int flags )
{
drmBufPtr buffer = imesa->vertex_dma_buffer;
drm_savage_event_emit_t event;
int ret;
event.count = 0;
event.flags = flags;
ret = drmCommandWriteRead( imesa->driFd, DRM_SAVAGE_BCI_EVENT_EMIT,
&event, sizeof(event) );
if (ret) {
fprintf (stderr, "emit event returned %d\n", ret);
exit (1);
}
return event.count;
}
unsigned int savageEmitEvent( savageContextPtr imesa, unsigned int flags )
{
unsigned int ret;
LOCK_HARDWARE( imesa );
ret = savageEmitEventLocked( imesa, flags );
UNLOCK_HARDWARE( imesa );
return ret;
}
if (!buffer)
return;
imesa->vertex_dma_buffer = NULL;
/* Lot's of stuff to do here. For now there is a fake DMA implementation
* in savagedma.c that emits drawing commands. Cliprects are not handled
* yet. */
if (buffer->used) {
/* State must be updated "per primitive" because hardware
* culling must be disabled for unfilled primitives, points
* and lines. */
savageEmitHwStateLocked (imesa);
savageFakeVertices (imesa, buffer);
void savageWaitEvent( savageContextPtr imesa, unsigned int count )
{
drm_savage_event_wait_t event;
int ret;
event.count = count;
event.flags = 0;
ret = drmCommandWriteRead( imesa->driFd, DRM_SAVAGE_BCI_EVENT_WAIT,
&event, sizeof(event) );
if (ret) {
fprintf (stderr, "wait event returned %d\n", ret);
exit (1);
}
}
void savageFlushVertices( savageContextPtr imesa )
void savageFlushVertices( savageContextPtr imesa )
{
struct savage_vtxbuf_t *buffer = imesa->vtxBuf;
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "%s\n", __FUNCTION__);
if (!buffer->total)
return;
if (buffer->used > buffer->flushed) {
drm_savage_cmd_header_t *cmd;
/* State must be updated "per primitive" because hardware
* culling must be disabled for unfilled primitives, points
* and lines. */
savageEmitChangedState (imesa);
cmd = savageAllocCmdBuf(imesa, 0);
cmd->prim.cmd = buffer == &imesa->dmaVtxBuf ?
SAVAGE_CMD_DMA_PRIM : SAVAGE_CMD_VB_PRIM;
cmd->prim.prim = imesa->HwPrim;
cmd->prim.skip = imesa->skip;
cmd->prim.start = buffer->flushed / imesa->HwVertexSize;
cmd->prim.count = buffer->used / imesa->HwVertexSize - cmd->prim.start;
buffer->flushed = buffer->used;
/* Make sure we don't buffer too many vertices without
* telling the hardware. */
imesa->vertsPending += cmd->prim.count;
if (imesa->vertsPending > SAVAGE_MAX_VERTS_PENDING) {
savageFlushCmdBuf(imesa, GL_FALSE);
imesa->vertsPending = 0;
}
}
}
void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard )
{
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
drm_savage_cmdbuf_t cmdbuf;
drm_savage_cmd_header_t *start;
int ret;
/* If we lost the context we must restore the initial state (at
* the start of the command buffer). */
if (imesa->lostContext) {
start = imesa->cmdBuf.base;
imesa->lostContext = GL_FALSE;
} else
start = imesa->cmdBuf.start;
if (!imesa->dmaVtxBuf.total)
discard = GL_FALSE;
if ((SAVAGE_DEBUG & DEBUG_DMA) && discard)
fprintf (stderr, "Discarding DMA buffer, used=%u\n",
imesa->dmaVtxBuf.used);
cmdbuf.dma_idx = imesa->dmaVtxBuf.idx;
cmdbuf.discard = discard;
cmdbuf.vb_addr = imesa->clientVtxBuf.buf;
cmdbuf.vb_size = imesa->clientVtxBuf.total*4;
cmdbuf.vb_stride = imesa->HwVertexSize;
cmdbuf.cmd_addr = start;
cmdbuf.size = (imesa->cmdBuf.write - start);
if (!imesa->inSwap && imesa->glCtx->Scissor.Enabled) {
drm_clip_rect_t *box = dPriv->pClipRects, *ibox;
GLuint nbox = dPriv->numClipRects, nibox;
ibox = malloc(dPriv->numClipRects*sizeof(drm_clip_rect_t));
if (!ibox) {
fprintf(stderr, "Out of memory.\n");
exit(1);
}
nibox = savageIntersectClipRects(ibox, box, nbox, &imesa->scissor_rect);
cmdbuf.nbox = nibox;
cmdbuf.box_addr = ibox;
} else {
cmdbuf.nbox = dPriv->numClipRects;
cmdbuf.box_addr = dPriv->pClipRects;
}
ret = drmCommandWrite( imesa->driFd, DRM_SAVAGE_BCI_CMDBUF,
&cmdbuf, sizeof(cmdbuf) );
if (ret) {
fprintf (stderr, "cmdbuf ioctl returned %d\n", ret);
exit(1);
}
if (cmdbuf.box_addr != dPriv->pClipRects) {
free(cmdbuf.box_addr);
}
if (discard) {
imesa->dmaVtxBuf.total = 0;
imesa->dmaVtxBuf.used = 0;
imesa->dmaVtxBuf.flushed = 0;
}
imesa->clientVtxBuf.used = 0;
imesa->clientVtxBuf.flushed = 0;
imesa->cmdBuf.write = imesa->cmdBuf.base;
/* Save the current state at the start of the command buffer. That
* state will only be emitted, if the context was lost since the
* last command buffer. */
savageEmitOldState(imesa);
imesa->cmdBuf.start = imesa->cmdBuf.write;
}
void savageFlushCmdBuf( savageContextPtr imesa, GLboolean discard )
{
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "%s\n", __FUNCTION__);
LOCK_HARDWARE(imesa);
savageFlushVerticesLocked (imesa);
savageFlushCmdBufLocked (imesa, discard);
UNLOCK_HARDWARE(imesa);
}
int savage_check_copy(int fd)
{
return 0;
}
static void savageDDFlush( GLcontext *ctx )
{
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "%s\n", __FUNCTION__);
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
savageFlushVertices (imesa);
LOCK_HARDWARE(imesa);
savageFlushVerticesLocked (imesa);
savageDMAFlush (imesa);
savageFlushCmdBufLocked(imesa, GL_FALSE);
UNLOCK_HARDWARE(imesa);
}
static void savageDDFinish( GLcontext *ctx )
{
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "%s\n", __FUNCTION__);
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
savageFlushVertices (imesa);
LOCK_HARDWARE(imesa);
savageFlushVerticesLocked (imesa);
savageFlushCmdBufLocked(imesa, GL_FALSE);
savageDmaFinish (imesa);
UNLOCK_HARDWARE(imesa);
}
#define ALT_STATUS_WORD0 (* (volatile GLuint *)(imesa->MMIO_BASE+0x48c60))
#define STATUS_WORD0 (* (volatile GLuint *)(imesa->MMIO_BASE+0x48c00))
#define MAXFIFO_S4 0x7F00
#define MAXFIFO_S3D 0x7F00
static GLboolean savagePagePending_s4( savageContextPtr imesa ) {
return (ALT_STATUS_WORD0 & 0x08000000) ? GL_TRUE : GL_FALSE;
}
static GLboolean savagePagePending_s3d( savageContextPtr imesa ) {
return GL_FALSE;
}
static void savageWaitForFIFO_s4( savageContextPtr imesa, unsigned count ) {
int loop = 0;
int slots = MAXFIFO_S4-count;
while((ALT_STATUS_WORD0 & 0x001fffff) > slots && loop++ < MAXLOOP);
}
static void savageWaitForFIFO_s3d( savageContextPtr imesa, unsigned count ) {
int loop = 0;
int slots = MAXFIFO_S3D-count;
while((STATUS_WORD0 & 0x0001ffff) > slots && loop++ < MAXLOOP);
}
static void savageWaitIdleEmpty_s4( savageContextPtr imesa ) {
int loop = 0;
while((ALT_STATUS_WORD0 & 0x00ffffff) != 0x00E00000L && loop++ < MAXLOOP);
}
static void savageWaitIdleEmpty_s3d( savageContextPtr imesa ) {
int loop = 0;
while((STATUS_WORD0 & 0x000fffff) != 0x000E0000L && loop++ < MAXLOOP);
}
GLboolean (*savagePagePending)( savageContextPtr imesa ) = NULL;
void (*savageWaitForFIFO)( savageContextPtr imesa, unsigned count ) = NULL;
void (*savageWaitIdleEmpty)( savageContextPtr imesa ) = NULL;
void savageDDInitIoctlFuncs( GLcontext *ctx )
{
ctx->Driver.Clear = savageDDClear;
ctx->Driver.Flush = savageDDFlush;
ctx->Driver.Finish = savageDDFinish;
if (SAVAGE_CONTEXT( ctx )->savageScreen->chipset >= S3_SAVAGE4) {
savagePagePending = savagePagePending_s4;
savageWaitForFIFO = savageWaitForFIFO_s4;
savageWaitIdleEmpty = savageWaitIdleEmpty_s4;
} else {
savagePagePending = savagePagePending_s3d;
savageWaitForFIFO = savageWaitForFIFO_s3d;
savageWaitIdleEmpty = savageWaitIdleEmpty_s3d;
}
}
#if SAVAGE_CMD_DMA
/* Alloc a continuous memory */
/* return: 0 error when kernel alloc pages(can try a half memory size)
>0 sucess
<0 Other error*/
int savageAllocDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req)
{
int ret;
if (req ==NULL)
return 0;
if ((ret=ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_ALLOC_CONTINUOUS_MEM, req)) <=0)
return ret;
return 1;
}
/* get the physics address*/
GLuint savageGetPhyAddress(savageContextPtr imesa,void * pointer)
{
drm_savage_get_physcis_address_t req;
int ret;
req.v_address = (GLuint )pointer;
ret = ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_GET_PHYSICS_ADDRESS,&req);
return req.p_address;
}
/* free the buffer got by savageAllocDMABuffe*/
int savageFreeDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req)
{
GLuint ret;
if (req ==NULL)
return 0;
if ((ret=ioctl(imesa->driFd, DRM_IOCTL_SAVAGE_FREE_CONTINUOUS_MEM, req)) <=0)
return ret;
return 1;
}
#endif

View File

@@ -27,17 +27,22 @@
#define SAVAGE_IOCTL_H
#include "savagecontext.h"
#include "savagedma.h"
void savageGetGeneralDmaBufferLocked( savageContextPtr mmesa );
void savageFlushVertices( savageContextPtr mmesa );
void savageFlushVerticesLocked( savageContextPtr mmesa );
void savageFlushGeneralLocked( savageContextPtr imesa );
void savageWaitAgeLocked( savageContextPtr imesa, int age );
void savageWaitAge( savageContextPtr imesa, int age );
unsigned int savageEmitEventLocked( savageContextPtr imesa, unsigned int flags );
unsigned int savageEmitEvent( savageContextPtr imesa, unsigned int flags );
void savageWaitEvent( savageContextPtr imesa, unsigned int event);
void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard );
void savageFlushCmdBuf( savageContextPtr imesa, GLboolean discard );
void savageDmaFinish( savageContextPtr imesa );
void savageRegetLockQuiescent( savageContextPtr imesa );
@@ -46,54 +51,69 @@ void savageDDInitIoctlFuncs( GLcontext *ctx );
void savageSwapBuffers( __DRIdrawablePrivate *dPriv );
int savage_check_copy(int fd);
extern GLboolean (*savagePagePending)( savageContextPtr imesa );
extern void (*savageWaitForFIFO)( savageContextPtr imesa, unsigned count );
extern void (*savageWaitIdleEmpty)( savageContextPtr imesa );
#define PAGE_PENDING(result) do { \
result = savagePagePending(imesa); \
} while (0)
#define WAIT_FOR_FIFO(count) do { \
savageWaitForFIFO(imesa, count); \
} while (0)
#define WAIT_IDLE_EMPTY do { \
savageWaitIdleEmpty(imesa); \
savageWaitEvent(imesa, \
savageEmitEvent(imesa, SAVAGE_WAIT_3D|SAVAGE_WAIT_2D)); \
} while (0)
#if SAVAGE_CMD_DMA
int savageAllocDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req);
GLuint savageGetPhyAddress(savageContextPtr imesa,void * pointer);
int savageFreeDMABuffer(savageContextPtr, drm_savage_alloc_cont_mem_t*);
#endif
#define FLUSH_BATCH(imesa) do { \
if (imesa->vertex_dma_buffer) savageFlushVertices(imesa); \
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) \
fprintf (stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \
savageFlushVertices(imesa); \
savageFlushCmdBuf(imesa, GL_FALSE); \
} while (0)
extern void savageGetDMABuffer( savageContextPtr imesa );
static __inline
u_int32_t *savageAllocDmaLow( savageContextPtr imesa, GLuint bytes )
u_int32_t *savageAllocVtxBuf( savageContextPtr imesa, GLuint words )
{
struct savage_vtxbuf_t *buffer = imesa->vtxBuf;
u_int32_t *head;
if (!imesa->vertex_dma_buffer) {
LOCK_HARDWARE(imesa);
imesa->vertex_dma_buffer = savageFakeGetBuffer (imesa);
UNLOCK_HARDWARE(imesa);
} else if (imesa->vertex_dma_buffer->used + bytes >
imesa->vertex_dma_buffer->total) {
LOCK_HARDWARE(imesa);
savageFlushVerticesLocked( imesa );
imesa->vertex_dma_buffer = savageFakeGetBuffer (imesa);
UNLOCK_HARDWARE(imesa);
if (buffer == &imesa->dmaVtxBuf) {
if (!buffer->total) {
LOCK_HARDWARE(imesa);
savageGetDMABuffer(imesa);
UNLOCK_HARDWARE(imesa);
} else if (buffer->used + words > buffer->total) {
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "... flushing DMA buffer in %s\n",
__FUNCTION__);
savageFlushVertices( imesa );
LOCK_HARDWARE(imesa);
savageFlushCmdBufLocked(imesa, GL_TRUE); /* discard DMA buffer */
savageGetDMABuffer(imesa);
UNLOCK_HARDWARE(imesa);
}
} else if (buffer->used + words > buffer->total) {
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "... flushing client vertex buffer in %s\n",
__FUNCTION__);
savageFlushVertices( imesa );
LOCK_HARDWARE(imesa);
savageFlushCmdBufLocked(imesa, GL_FALSE); /* free clientVtxBuf */
UNLOCK_HARDWARE(imesa);
}
head = (u_int32_t *)((u_int8_t *)imesa->vertex_dma_buffer->address +
imesa->vertex_dma_buffer->used);
head = &buffer->buf[buffer->used];
imesa->vertex_dma_buffer->used += bytes;
buffer->used += words;
return head;
}
static __inline
drm_savage_cmd_header_t *savageAllocCmdBuf( savageContextPtr imesa, GLuint bytes )
{
drm_savage_cmd_header_t *ret;
GLuint qwords = ((bytes + 7) >> 3) + 1; /* round up */
assert (qwords < imesa->cmdBuf.size);
if (imesa->cmdBuf.write - imesa->cmdBuf.base + qwords > imesa->cmdBuf.size) {
savageFlushCmdBuf(imesa, GL_FALSE);
}
ret = (drm_savage_cmd_header_t *)imesa->cmdBuf.write;
imesa->cmdBuf.write += qwords;
return ret;
}
#endif

View File

@@ -33,6 +33,7 @@
#define DBG 0
#define LOCAL_VARS \
savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
savageScreenPrivate *savageScreen = imesa->savageScreen; \
GLuint cpp = savageScreen->cpp; \
@@ -48,6 +49,7 @@
(void) read_buf; (void) buf; (void) p
#define LOCAL_DEPTH_VARS \
savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
savageScreenPrivate *savageScreen = imesa->savageScreen; \
GLuint zpp = savageScreen->zpp; \
@@ -77,8 +79,7 @@
#define Y_FLIP(_y) (height - _y - 1)
#define HW_LOCK() savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
WAIT_IDLE_EMPTY;\
#define HW_LOCK()
#define HW_CLIPLOOP() \
do { \
@@ -95,11 +96,7 @@
} \
} while (0)
#if 0
#define HW_UNLOCK() \
UNLOCK_HARDWARE(imesa);
#endif
#define HW_UNLOCK() { }
#define HW_UNLOCK()
/* 16 bit, 565 rgb color spanline and pixel functions
@@ -161,58 +158,91 @@ do { \
/* 16 bit depthbuffer functions.
/* 16 bit integer depthbuffer functions
* Depth range is reversed. See also savageCalcViewport.
*/
#define WRITE_DEPTH( _x, _y, d ) \
do{ \
*(GLushort *)(buf + (_x<<1) + _y*pitch) = d; \
}while(0)
*(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = 0xFFFF - d
#define READ_DEPTH( d, _x, _y ) \
do{ \
d = *(GLushort *)(buf + (_x<<1) + _y*pitch); \
}while(0)
/* d = 0xffff; */
d = 0xFFFF - *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch)
#define TAG(x) savage##x##_16
#include "depthtmp.h"
/* 8-bit stencil /24-bit depth depthbuffer functions.
/* 16 bit float depthbuffer functions
*/
#define WRITE_DEPTH( _x, _y, d ) { \
GLuint tmp = *(GLuint *)(buf + (_x<<2) + _y*pitch); \
tmp &= 0xFF000000; \
tmp |= d; \
#define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = \
savageEncodeFloat16( 1.0 - (GLfloat)d/65535.0 )
#define READ_DEPTH( d, _x, _y ) \
d = 65535 - \
savageDecodeFloat16( *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) ) * \
65535.0
#define TAG(x) savage##x##_16f
#include "depthtmp.h"
/* 8-bit stencil /24-bit integer depth depthbuffer functions.
* Depth range is reversed. See also savageCalcViewport.
*/
#define WRITE_DEPTH( _x, _y, d ) do { \
GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \
tmp &= 0xFF000000; \
tmp |= 0x00FFFFFF - d; \
*(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \
}
} while(0)
#define READ_DEPTH( d, _x, _y ) \
d = *(GLuint *)(buf + (_x<<2) + _y*pitch) & 0x00FFFFFF;
/* d = 0x00ffffff; */
d = 0x00FFFFFF - (*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF)
#define TAG(x) savage##x##_8_24
#include "depthtmp.h"
#define WRITE_STENCIL( _x, _y, d ) { \
GLuint tmp = *(GLuint *)(buf + (_x<<2) + _y*pitch); \
tmp &= 0x00FFFFFF; \
tmp |= (((GLuint)d)<<24) & 0xFF000000; \
*(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \
}
#define READ_STENCIL( d, _x, _y ) \
d = (GLstencil)((*(GLuint *)(buf + (_x<<2) + _y*pitch) & 0xFF000000) >> 24);
/* 24 bit float depthbuffer functions
*/
#define WRITE_DEPTH( _x, _y, d ) do { \
GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \
tmp &= 0xFF000000; \
tmp |= savageEncodeFloat24( 1.0 - (GLfloat)d/16777215.0 ); \
*(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \
} while(0)
#define READ_DEPTH( d, _x, _y ) \
d = 16777215 - savageDecodeFloat24( \
*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF) \
* 16777215.0
#define TAG(x) savage##x##_8_24f
#include "depthtmp.h"
#define WRITE_STENCIL( _x, _y, d ) do { \
GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \
tmp &= 0x00FFFFFF; \
tmp |= (((GLuint)d)<<24) & 0xFF000000; \
*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) = tmp; \
} while(0)
#define READ_STENCIL( d, _x, _y ) \
d = (GLstencil)((*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0xFF000000) >> 24)
#define TAG(x) savage##x##_8_24
#include "stenciltmp.h"
/*
* This function is called to specify which buffer to read and write
@@ -241,6 +271,58 @@ static void savageDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
? imesa->driDrawable : imesa->driReadable;
}
/*
* Wrappers around _swrast_Copy/Draw/ReadPixels that make sure all
* primitives are flushed and the hardware is idle before accessing
* the frame buffer.
*/
static void
savageCopyPixels( GLcontext *ctx,
GLint srcx, GLint srcy, GLsizei width, GLsizei height,
GLint destx, GLint desty,
GLenum type )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
FLUSH_BATCH(imesa);
WAIT_IDLE_EMPTY;
_swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type);
}
static void
savageDrawPixels( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
const GLvoid *pixels )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
FLUSH_BATCH(imesa);
WAIT_IDLE_EMPTY;
_swrast_DrawPixels(ctx, x, y, width, height, format, type, packing, pixels);
}
static void
savageReadPixels( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
GLvoid *pixels )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
FLUSH_BATCH(imesa);
WAIT_IDLE_EMPTY;
_swrast_ReadPixels(ctx, x, y, width, height, format, type, packing, pixels);
}
/*
* Make sure the hardware is idle when span-rendering.
*/
static void savageSpanRenderStart( GLcontext *ctx )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
FLUSH_BATCH(imesa);
WAIT_IDLE_EMPTY;
}
void savageDDInitSpanFuncs( GLcontext *ctx )
{
@@ -274,18 +356,36 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
switch (imesa->savageScreen->zpp)
{
case 2:
swdd->ReadDepthSpan = savageReadDepthSpan_16;
swdd->WriteDepthSpan = savageWriteDepthSpan_16;
swdd->ReadDepthPixels = savageReadDepthPixels_16;
swdd->WriteDepthPixels = savageWriteDepthPixels_16;
case 2:
if (imesa->float_depth) {
swdd->ReadDepthSpan = savageReadDepthSpan_16f;
swdd->WriteDepthSpan = savageWriteDepthSpan_16f;
swdd->WriteMonoDepthSpan = savageWriteMonoDepthSpan_16f;
swdd->ReadDepthPixels = savageReadDepthPixels_16f;
swdd->WriteDepthPixels = savageWriteDepthPixels_16f;
} else {
swdd->ReadDepthSpan = savageReadDepthSpan_16;
swdd->WriteDepthSpan = savageWriteDepthSpan_16;
swdd->WriteMonoDepthSpan = savageWriteMonoDepthSpan_16;
swdd->ReadDepthPixels = savageReadDepthPixels_16;
swdd->WriteDepthPixels = savageWriteDepthPixels_16;
}
break;
case 4:
swdd->ReadDepthSpan = savageReadDepthSpan_8_24;
swdd->WriteDepthSpan = savageWriteDepthSpan_8_24;
swdd->ReadDepthPixels = savageReadDepthPixels_8_24;
swdd->WriteDepthPixels = savageWriteDepthPixels_8_24;
if (imesa->float_depth) {
swdd->ReadDepthSpan = savageReadDepthSpan_8_24f;
swdd->WriteDepthSpan = savageWriteDepthSpan_8_24f;
swdd->WriteMonoDepthSpan = savageWriteMonoDepthSpan_8_24f;
swdd->ReadDepthPixels = savageReadDepthPixels_8_24f;
swdd->WriteDepthPixels = savageWriteDepthPixels_8_24f;
} else {
swdd->ReadDepthSpan = savageReadDepthSpan_8_24;
swdd->WriteDepthSpan = savageWriteDepthSpan_8_24;
swdd->WriteMonoDepthSpan = savageWriteMonoDepthSpan_8_24;
swdd->ReadDepthPixels = savageReadDepthPixels_8_24;
swdd->WriteDepthPixels = savageWriteDepthPixels_8_24;
}
swdd->ReadStencilSpan = savageReadStencilSpan_8_24;
swdd->WriteStencilSpan = savageWriteStencilSpan_8_24;
swdd->ReadStencilPixels = savageReadStencilPixels_8_24;
@@ -301,11 +401,13 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
swdd->ReadCI32Span =NULL;
swdd->ReadCI32Pixels =NULL;
swdd->SpanRenderStart = savageSpanRenderStart;
/* Pixel path fallbacks.
*/
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = _swrast_Bitmap;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
ctx->Driver.CopyPixels = savageCopyPixels;
ctx->Driver.DrawPixels = savageDrawPixels;
ctx->Driver.ReadPixels = savageReadPixels;
}

View File

@@ -27,4 +27,102 @@
extern void savageDDInitSpanFuncs( GLcontext *ctx );
/*
* Savage 16-bit float depth format with zExpOffset=16:
* 4 bit unsigned exponent, 12 bit mantissa
*
* The meaning of the mantissa is different from IEEE floatint point
* formats. The same number can't be encoded with different exponents.
* So no bits are wasted.
*
* exponent | range encoded by mantissa | accuracy or mantissa
* ---------+---------------------------+---------------------
* 15 | 2^-1 .. 1 | 2^-13
* 14 | 2^-2 .. 2^-1 | 2^-14
* 13 | 2^-3 .. 2^-2 | 2^-15
* ... | ... |
* 2 | 2^-14 .. 2^-13 | 2^-27
* 1 | 2^-15 .. 2^-14 | 2^-27
* 0 | 2^-16 .. 2^-15 | 2^-28
*
* Note that there is no encoding for numbers < 2^-16.
*/
static __inline GLuint savageEncodeFloat16( GLdouble x )
{
GLint r = (GLint)(x * 0x10000000);
GLint exp = 0;
if (r < 0x1000)
return 0;
while (r - 0x1000 > 0x0fff) {
r >>= 1;
exp++;
}
return exp > 0xf ? 0xffff : (r - 0x1000) | (exp << 12);
}
static __inline GLdouble savageDecodeFloat16( GLuint x )
{
static const GLdouble pow2[16] = {
1.0/(1<<28), 1.0/(1<<27), 1.0/(1<<26), 1.0/(1<<25),
1.0/(1<<24), 1.0/(1<<23), 1.0/(1<<22), 1.0/(1<<21),
1.0/(1<<20), 1.0/(1<<19), 1.0/(1<<18), 1.0/(1<<17),
1.0/(1<<16), 1.0/(1<<15), 1.0/(1<<14), 1.0/(1<<13)
};
static const GLdouble bias[16] = {
1.0/(1<<16), 1.0/(1<<15), 1.0/(1<<14), 1.0/(1<<13),
1.0/(1<<12), 1.0/(1<<11), 1.0/(1<<10), 1.0/(1<< 9),
1.0/(1<< 8), 1.0/(1<< 7), 1.0/(1<< 6), 1.0/(1<< 5),
1.0/(1<< 4), 1.0/(1<< 3), 1.0/(1<< 2), 1.0/(1<< 1)
};
GLuint mant = x & 0x0fff;
GLuint exp = (x >> 12) & 0xf;
return bias[exp] + pow2[exp]*mant;
}
/*
* Savage 24-bit float depth format with zExpOffset=32:
* 5 bit unsigned exponent, 19 bit mantissa
*
* Details analogous to the 16-bit format.
*/
static __inline GLuint savageEncodeFloat24( GLdouble x )
{
int64_t r = (int64_t)(x * ((int64_t)1 << (19+32)));
GLint exp = 0;
if (r < 0x80000)
return 0;
while (r - 0x80000 > 0x7ffff) {
r >>= 1;
exp++;
}
return exp > 0x1f ? 0xffffff : (r - 0x80000) | (exp << 19);
}
#define _1 (int64_t)1
static __inline GLdouble savageDecodeFloat24( GLuint x )
{
static const GLdouble pow2[32] = {
1.0/(_1<<51), 1.0/(_1<<50), 1.0/(_1<<49), 1.0/(_1<<48),
1.0/(_1<<47), 1.0/(_1<<46), 1.0/(_1<<45), 1.0/(_1<<44),
1.0/(_1<<43), 1.0/(_1<<42), 1.0/(_1<<41), 1.0/(_1<<40),
1.0/(_1<<39), 1.0/(_1<<38), 1.0/(_1<<37), 1.0/(_1<<36),
1.0/(_1<<35), 1.0/(_1<<34), 1.0/(_1<<33), 1.0/(_1<<32),
1.0/(_1<<31), 1.0/(_1<<30), 1.0/(_1<<29), 1.0/(_1<<28),
1.0/(_1<<27), 1.0/(_1<<26), 1.0/(_1<<25), 1.0/(_1<<24),
1.0/(_1<<23), 1.0/(_1<<22), 1.0/(_1<<21), 1.0/(_1<<20)
};
static const GLdouble bias[32] = {
1.0/(_1<<32), 1.0/(_1<<31), 1.0/(_1<<30), 1.0/(_1<<29),
1.0/(_1<<28), 1.0/(_1<<27), 1.0/(_1<<26), 1.0/(_1<<25),
1.0/(_1<<24), 1.0/(_1<<23), 1.0/(_1<<22), 1.0/(_1<<21),
1.0/(_1<<20), 1.0/(_1<<19), 1.0/(_1<<18), 1.0/(_1<<17),
1.0/(_1<<16), 1.0/(_1<<15), 1.0/(_1<<14), 1.0/(_1<<13),
1.0/(_1<<12), 1.0/(_1<<11), 1.0/(_1<<10), 1.0/(_1<< 9),
1.0/(_1<< 8), 1.0/(_1<< 7), 1.0/(_1<< 6), 1.0/(_1<< 5),
1.0/(_1<< 4), 1.0/(_1<< 3), 1.0/(_1<< 2), 1.0/(_1<< 1)
};
GLuint mant = x & 0x7ffff;
GLuint exp = (x >> 19) & 0x1f;
return bias[exp] + pow2[exp]*mant;
}
#undef _1
#endif

View File

@@ -69,16 +69,10 @@ static __inline__ GLuint savagePackColor(GLuint format,
static void savageDDAlphaFunc_s4(GLcontext *ctx, GLenum func, GLfloat ref)
{
/* This can be done in BlendFunc*/
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
imesa->dirty |= SAVAGE_UPLOAD_CTX;
savageBlendFunc_s4(ctx);
}
static void savageDDAlphaFunc_s3d(GLcontext *ctx, GLenum func, GLfloat ref)
{
/* This can be done in BlendFunc*/
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
imesa->dirty |= SAVAGE_UPLOAD_CTX;
savageBlendFunc_s3d(ctx);
}
@@ -103,6 +97,9 @@ static void savageDDBlendEquationSeparate(GLcontext *ctx,
static void savageBlendFunc_s4(GLcontext *ctx)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
u_int32_t drawCtrl0 = imesa->regs.s4.drawCtrl0.ui;
u_int32_t drawCtrl1 = imesa->regs.s4.drawCtrl1.ui;
/* set up draw control register (including blending, alpha
* test, and shading model)
@@ -266,11 +263,17 @@ static void savageBlendFunc_s4(GLcontext *ctx)
/*imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn =
~drawLocalCtrl.ni.wrZafterAlphaTst;*/
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
if (drawCtrl0 != imesa->regs.s4.drawCtrl0.ui ||
drawCtrl1 != imesa->regs.s4.drawCtrl1.ui)
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
static void savageBlendFunc_s3d(GLcontext *ctx)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
u_int32_t zBufCtrl = imesa->regs.s3d.zBufCtrl.ui;
/* set up draw control register (including blending, alpha
* test, dithering, and shading model)
@@ -432,7 +435,9 @@ static void savageBlendFunc_s3d(GLcontext *ctx)
imesa->regs.s3d.zBufCtrl.ni.wrZafterAlphaTst =
imesa->regs.s3d.drawCtrl.ni.alphaTestEn;
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (drawCtrl != imesa->regs.s3d.drawCtrl.ui ||
zBufCtrl != imesa->regs.s3d.zBufCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
}
static void savageDDBlendFuncSeparate_s4( GLcontext *ctx, GLenum sfactorRGB,
@@ -456,21 +461,23 @@ static void savageDDDepthFunc_s4(GLcontext *ctx, GLenum func)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
ZCmpFunc zmode;
#define depthIndex 0
u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
u_int32_t zBufCtrl = imesa->regs.s4.zBufCtrl.ui;
u_int32_t zWatermarks = imesa->regs.s4.zWatermarks.ui; /* FIXME: in DRM */
/* set up z-buffer control register (global)
* set up z-buffer offset register (global)
* set up z read/write watermarks register (global)
*/
switch(func) {
switch(func) { /* reversed (see savageCalcViewport) */
case GL_NEVER: zmode = CF_Never; break;
case GL_ALWAYS: zmode = CF_Always; break;
case GL_LESS: zmode = CF_Less; break;
case GL_LEQUAL: zmode = CF_LessEqual; break;
case GL_LESS: zmode = CF_Greater; break;
case GL_LEQUAL: zmode = CF_GreaterEqual; break;
case GL_EQUAL: zmode = CF_Equal; break;
case GL_GREATER: zmode = CF_Greater; break;
case GL_GEQUAL: zmode = CF_GreaterEqual; break;
case GL_GREATER: zmode = CF_Less; break;
case GL_GEQUAL: zmode = CF_LessEqual; break;
case GL_NOTEQUAL: zmode = CF_NotEqual; break;
default:return;
}
@@ -513,27 +520,33 @@ static void savageDDDepthFunc_s4(GLcontext *ctx, GLenum func)
imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_FALSE;
imesa->regs.s4.zWatermarks.ni.wLow = 8;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
if (zBufCtrl != imesa->regs.s4.zBufCtrl.ui ||
zWatermarks != imesa->regs.s4.zWatermarks.ui)
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
static void savageDDDepthFunc_s3d(GLcontext *ctx, GLenum func)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
ZCmpFunc zmode;
#define depthIndex 0
u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
u_int32_t zBufCtrl = imesa->regs.s3d.zBufCtrl.ui;
u_int32_t zWatermarks = imesa->regs.s3d.zWatermarks.ui; /* FIXME: in DRM */
/* set up z-buffer control register (global)
* set up z-buffer offset register (global)
* set up z read/write watermarks register (global)
*/
switch(func) {
switch(func) { /* reversed (see savageCalcViewport) */
case GL_NEVER: zmode = CF_Never; break;
case GL_ALWAYS: zmode = CF_Always; break;
case GL_LESS: zmode = CF_Less; break;
case GL_LEQUAL: zmode = CF_LessEqual; break;
case GL_LESS: zmode = CF_Greater; break;
case GL_LEQUAL: zmode = CF_GreaterEqual; break;
case GL_EQUAL: zmode = CF_Equal; break;
case GL_GREATER: zmode = CF_Greater; break;
case GL_GEQUAL: zmode = CF_GreaterEqual; break;
case GL_GREATER: zmode = CF_Less; break;
case GL_GEQUAL: zmode = CF_LessEqual; break;
case GL_NOTEQUAL: zmode = CF_NotEqual; break;
default:return;
}
@@ -565,14 +578,18 @@ static void savageDDDepthFunc_s3d(GLcontext *ctx, GLenum func)
imesa->regs.s3d.zWatermarks.ni.wLow = 8;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (drawCtrl != imesa->regs.s3d.drawCtrl.ui ||
zBufCtrl != imesa->regs.s3d.zBufCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
if (zWatermarks != imesa->regs.s3d.zWatermarks.ui)
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
static void savageDDDepthMask_s4(GLcontext *ctx, GLboolean flag)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (flag)
{
imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_TRUE;
@@ -582,12 +599,15 @@ static void savageDDDepthMask_s4(GLcontext *ctx, GLboolean flag)
imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_FALSE;
}
savageDDDepthFunc_s4(ctx,ctx->Depth.Func);
if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
}
static void savageDDDepthMask_s3d(GLcontext *ctx, GLboolean flag)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (flag)
{
imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_TRUE;
@@ -597,6 +617,9 @@ static void savageDDDepthMask_s3d(GLcontext *ctx, GLboolean flag)
imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_FALSE;
}
savageDDDepthFunc_s3d(ctx,ctx->Depth.Func);
if (drawCtrl != imesa->regs.s3d.drawCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
}
@@ -629,6 +652,7 @@ static void savageDDScissor( GLcontext *ctx, GLint x, GLint y,
static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
u_int32_t destCtrl = imesa->regs.s4.destCtrl.ui;
/*
* _DrawDestMask is easier to cope with than <mode>.
@@ -641,7 +665,6 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
imesa->readMap = (char *)imesa->apertureBase[TARGET_FRONT];
imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->frontOffset>>11;
imesa->NotFirstFrame = GL_FALSE;
imesa->dirty |= SAVAGE_UPLOAD_BUFFERS | SAVAGE_UPLOAD_CTX;
savageXMesaSetFrontClipRects( imesa );
FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
@@ -651,7 +674,6 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
imesa->readMap = (char *)imesa->apertureBase[TARGET_BACK];
imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
imesa->NotFirstFrame = GL_FALSE;
imesa->dirty |= SAVAGE_UPLOAD_BUFFERS | SAVAGE_UPLOAD_CTX;
savageXMesaSetBackClipRects( imesa );
FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
@@ -664,6 +686,9 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
* gets called.
*/
_swrast_DrawBuffer(ctx, mode);
if (destCtrl != imesa->regs.s4.destCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
static void savageDDReadBuffer(GLcontext *ctx, GLenum mode )
@@ -691,14 +716,22 @@ static void savageCalcViewport( GLcontext *ctx )
const GLfloat *v = ctx->Viewport._WindowMap.m;
GLfloat *m = imesa->hw_viewport;
/* See also mga_translate_vertex.
*/
m[MAT_SX] = v[MAT_SX];
m[MAT_TX] = v[MAT_TX] + imesa->drawX + SUBPIXEL_X;
m[MAT_SY] = - v[MAT_SY];
m[MAT_TY] = - v[MAT_TY] + imesa->driDrawable->h + imesa->drawY + SUBPIXEL_Y;
m[MAT_SZ] = v[MAT_SZ] * imesa->depth_scale;
m[MAT_TZ] = v[MAT_TZ] * imesa->depth_scale;
/* Depth range is reversed (far: 0, near: 1) so that float depth
* compensates for loss of accuracy of far coordinates. */
if (imesa->float_depth && imesa->savageScreen->zpp == 2) {
/* The Savage 16-bit floating point depth format can't encode
* numbers < 2^-16. Make sure all depth values stay greater
* than that. */
m[MAT_SZ] = - v[MAT_SZ] * imesa->depth_scale * (65535.0/65536.0);
m[MAT_TZ] = 1.0 - v[MAT_TZ] * imesa->depth_scale * (65535.0/65536.0);
} else {
m[MAT_SZ] = - v[MAT_SZ] * imesa->depth_scale;
m[MAT_TZ] = 1.0 - v[MAT_TZ] * imesa->depth_scale;
}
imesa->SetupNewInputs = ~0;
}
@@ -800,12 +833,12 @@ static void savageUpdateCull( GLcontext *ctx )
if (imesa->savageScreen->chipset >= S3_SAVAGE4) {
if (imesa->regs.s4.drawCtrl1.ni.cullMode != cullMode) {
imesa->regs.s4.drawCtrl1.ni.cullMode = cullMode;
imesa->dirty |= SAVAGE_UPLOAD_CTX;
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
} else {
if (imesa->regs.s3d.drawCtrl.ni.cullMode != cullMode) {
imesa->regs.s3d.drawCtrl.ni.cullMode = cullMode;
imesa->dirty |= SAVAGE_UPLOAD_CTX;
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
}
}
#endif /* end #if HW_CULL */
@@ -846,7 +879,7 @@ static void savageDDColorMask_s4(GLcontext *ctx,
{
imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn = GL_FALSE;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
/* TODO: need a software fallback */
}
static void savageDDColorMask_s3d(GLcontext *ctx,
@@ -873,7 +906,7 @@ static void savageDDColorMask_s3d(GLcontext *ctx,
{
imesa->regs.s3d.zBufCtrl.ni.drawUpdateEn = GL_FALSE;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
/* TODO: need a software fallback */
}
@@ -886,6 +919,7 @@ static void savageDDColorMask_s3d(GLcontext *ctx,
*/
static void savageUpdateSpecular_s4(GLcontext *ctx) {
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
ctx->Light.Enabled) {
@@ -895,10 +929,13 @@ static void savageUpdateSpecular_s4(GLcontext *ctx) {
imesa->regs.s4.drawLocalCtrl.ni.specShadeEn = GL_FALSE;
/*FALLBACK (ctx, SAVAGE_FALLBACK_SPECULAR, GL_FALSE);*/
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
}
static void savageUpdateSpecular_s3d(GLcontext *ctx) {
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
ctx->Light.Enabled) {
@@ -908,7 +945,9 @@ static void savageUpdateSpecular_s3d(GLcontext *ctx) {
imesa->regs.s3d.drawCtrl.ni.specShadeEn = GL_FALSE;
/*FALLBACK (ctx, SAVAGE_FALLBACK_SPECULAR, GL_FALSE);*/
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (drawCtrl != imesa->regs.s3d.drawCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
}
static void savageDDLightModelfv_s4(GLcontext *ctx, GLenum pname,
@@ -925,6 +964,7 @@ static void savageDDLightModelfv_s3d(GLcontext *ctx, GLenum pname,
static void savageDDShadeModel_s4(GLcontext *ctx, GLuint mod)
{
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
if (mod == GL_SMOOTH)
{
@@ -934,11 +974,14 @@ static void savageDDShadeModel_s4(GLcontext *ctx, GLuint mod)
{
imesa->regs.s4.drawLocalCtrl.ni.flatShadeEn = GL_TRUE;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
}
static void savageDDShadeModel_s3d(GLcontext *ctx, GLuint mod)
{
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
if (mod == GL_SMOOTH)
{
@@ -948,7 +991,9 @@ static void savageDDShadeModel_s3d(GLcontext *ctx, GLuint mod)
{
imesa->regs.s3d.drawCtrl.ni.flatShadeEn = GL_TRUE;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (drawCtrl != imesa->regs.s3d.drawCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
}
@@ -962,6 +1007,7 @@ static void savageDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
GLuint fogClr;
u_int32_t fogCtrl = imesa->regs.s4.fogCtrl.ui;
/*if ((ctx->Fog.Enabled) &&(pname == GL_FOG_COLOR))*/
if (ctx->Fog.Enabled)
@@ -981,17 +1027,19 @@ static void savageDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
imesa->regs.s4.fogCtrl.ni.fogEn = 0;
imesa->regs.s4.fogCtrl.ni.fogMode = 0;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (fogCtrl != imesa->regs.s4.fogCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
static void savageStencilFunc(GLcontext *);
static void savageDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
GLuint mask)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
SCmpFunc a=0;
u_int32_t zBufCtrl = imesa->regs.s4.zBufCtrl.ui;
u_int32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui;
imesa->regs.s4.zBufCtrl.ni.stencilRefVal = ctx->Stencil.Ref[0];
imesa->regs.s4.stencilCtrl.ni.readMask = ctx->Stencil.ValueMask[0];
@@ -1012,22 +1060,26 @@ static void savageDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
imesa->regs.s4.stencilCtrl.ni.cmpFunc = a;
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (zBufCtrl != imesa->regs.s4.zBufCtrl.ui ||
stencilCtrl != imesa->regs.s4.stencilCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
static void savageDDStencilMask(GLcontext *ctx, GLuint mask)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
imesa->regs.s4.stencilCtrl.ni.writeMask = ctx->Stencil.WriteMask[0];
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (imesa->regs.s4.stencilCtrl.ni.writeMask != ctx->Stencil.WriteMask[0]) {
imesa->regs.s4.stencilCtrl.ni.writeMask = ctx->Stencil.WriteMask[0];
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
}
static void savageDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
GLenum zpass)
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
u_int32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui;
switch (ctx->Stencil.FailFunc[0])
{
@@ -1114,7 +1166,8 @@ static void savageDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
break;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (stencilCtrl != imesa->regs.s4.stencilCtrl.ui)
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
}
@@ -1128,11 +1181,9 @@ static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
switch(cap) {
case GL_ALPHA_TEST:
/* we should consider the disable case*/
imesa->dirty |= SAVAGE_UPLOAD_CTX;
savageBlendFunc_s4(ctx);
break;
case GL_BLEND:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
/*Can't find Enable bit in the 3D registers.*/
/* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
*/
@@ -1146,7 +1197,6 @@ static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
savageBlendFunc_s4(ctx);
break;
case GL_DEPTH_TEST:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
savageDDDepthFunc_s4(ctx,ctx->Depth.Func);
break;
case GL_SCISSOR_TEST:
@@ -1154,7 +1204,6 @@ static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
imesa->dirty |= SAVAGE_UPLOAD_CLIPRECTS;
break;
case GL_STENCIL_TEST:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (!imesa->hw_stencil)
FALLBACK (ctx, SAVAGE_FALLBACK_STENCIL, state);
else {
@@ -1167,11 +1216,10 @@ static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE;
imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE;
}
imesa->dirty |= SAVAGE_UPLOAD_CTX;
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL | SAVAGE_UPLOAD_LOCAL;
}
break;
case GL_FOG:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
savageDDFogfv(ctx,0,0);
break;
case GL_CULL_FACE:
@@ -1188,7 +1236,6 @@ static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
#endif
break;
case GL_DITHER:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (state)
{
if ( ctx->Color.DitherFlag )
@@ -1200,6 +1247,7 @@ static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
{
imesa->regs.s4.drawCtrl1.ni.ditherEn=GL_FALSE;
}
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
break;
case GL_LIGHTING:
@@ -1223,11 +1271,9 @@ static void savageDDEnable_s3d(GLcontext *ctx, GLenum cap, GLboolean state)
switch(cap) {
case GL_ALPHA_TEST:
/* we should consider the disable case*/
imesa->dirty |= SAVAGE_UPLOAD_CTX;
savageBlendFunc_s3d(ctx);
break;
case GL_BLEND:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
/*Can't find Enable bit in the 3D registers.*/
/* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
*/
@@ -1241,7 +1287,6 @@ static void savageDDEnable_s3d(GLcontext *ctx, GLenum cap, GLboolean state)
savageBlendFunc_s3d(ctx);
break;
case GL_DEPTH_TEST:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
savageDDDepthFunc_s3d(ctx,ctx->Depth.Func);
break;
case GL_SCISSOR_TEST:
@@ -1252,7 +1297,6 @@ static void savageDDEnable_s3d(GLcontext *ctx, GLenum cap, GLboolean state)
FALLBACK (ctx, SAVAGE_FALLBACK_STENCIL, state);
break;
case GL_FOG:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
savageDDFogfv(ctx,0,0);
break;
case GL_CULL_FACE:
@@ -1269,7 +1313,6 @@ static void savageDDEnable_s3d(GLcontext *ctx, GLenum cap, GLboolean state)
#endif
break;
case GL_DITHER:
imesa->dirty |= SAVAGE_UPLOAD_CTX;
if (state)
{
if ( ctx->Color.DitherFlag )
@@ -1281,6 +1324,7 @@ static void savageDDEnable_s3d(GLcontext *ctx, GLenum cap, GLboolean state)
{
imesa->regs.s3d.drawCtrl.ni.ditherEn=GL_FALSE;
}
imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
break;
case GL_LIGHTING:
@@ -1303,8 +1347,7 @@ void savageDDUpdateHwState( GLcontext *ctx )
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
if (imesa->new_state) {
FLUSH_BATCH(imesa);
savageFlushVertices(imesa);
if (imesa->new_state & SAVAGE_NEW_TEXTURE) {
savageUpdateTextureState( ctx );
}
@@ -1368,20 +1411,20 @@ void savageEmitDrawingRectangle( savageContextPtr imesa )
imesa->regs.ni.changed.ni.fDrawCtrl1Changed=GL_TRUE;*/
savageCalcViewport (imesa->glCtx);
imesa->dirty |= SAVAGE_UPLOAD_BUFFERS;
}
static void savageDDPrintDirty( const char *msg, GLuint state )
{
fprintf(stderr, "%s (0x%x): %s%s%s%s%s\n",
fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s\n",
msg,
(unsigned int) state,
(state & SAVAGE_UPLOAD_TEX0IMAGE) ? "upload-tex0, " : "",
(state & SAVAGE_UPLOAD_TEX1IMAGE) ? "upload-tex1, " : "",
(state & SAVAGE_UPLOAD_CTX) ? "upload-ctx, " : "",
(state & SAVAGE_UPLOAD_BUFFERS) ? "upload-bufs, " : "",
(state & SAVAGE_UPLOAD_LOCAL) ? "upload-local, " : "",
(state & SAVAGE_UPLOAD_TEX0) ? "upload-tex0, " : "",
(state & SAVAGE_UPLOAD_TEX1) ? "upload-tex1, " : "",
(state & SAVAGE_UPLOAD_FOGTBL) ? "upload-fogtbl, " : "",
(state & SAVAGE_UPLOAD_GLOBAL) ? "upload-global, " : "",
(state & SAVAGE_UPLOAD_TEXGLOBAL) ? "upload-texglobal, " : "",
(state & SAVAGE_UPLOAD_CLIPRECTS) ? "upload-cliprects, " : ""
);
}
@@ -1400,18 +1443,32 @@ static GLboolean savageGlobalRegChanged (savageContextPtr imesa,
}
return GL_FALSE;
}
static void savageEmitOldRegs (savageContextPtr imesa,
GLuint first, GLuint last, GLboolean global) {
GLuint n = last-first+1;
drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, n*4);
cmd->state.cmd = SAVAGE_CMD_STATE;
cmd->state.global = global;
cmd->state.count = n;
cmd->state.start = first;
memcpy(cmd+1, &imesa->oldRegs.ui[first-SAVAGE_FIRST_REG], n*4);
}
static void savageEmitContiguousRegs (savageContextPtr imesa,
GLuint first, GLuint last) {
GLuint i;
u_int32_t *pBCIBase;
pBCIBase = savageDMAAlloc (imesa, last - first + 2);
WRITE_CMD (pBCIBase, SET_REGISTER(first, last - first + 1), u_int32_t);
for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i) {
WRITE_CMD (pBCIBase, imesa->regs.ui[i], u_int32_t);
GLuint n = last-first+1;
drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, n*4);
cmd->state.cmd = SAVAGE_CMD_STATE;
cmd->state.global = savageGlobalRegChanged(imesa, first, last);
cmd->state.count = n;
cmd->state.start = first;
memcpy(cmd+1, &imesa->regs.ui[first-SAVAGE_FIRST_REG], n*4);
/* savageAllocCmdBuf may need to flush the cmd buffer and backup
* the current hardware state. It should see the "old" (current)
* state that has actually been emitted to the hardware. Therefore
* this update is done *after* savageAllocCmdBuf. */
for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i)
imesa->oldRegs.ui[i] = imesa->regs.ui[i];
}
savageDMACommit (imesa, pBCIBase);
}
static void savageEmitChangedRegs (savageContextPtr imesa,
GLuint first, GLuint last) {
@@ -1445,8 +1502,6 @@ static void savageEmitChangedRegChunk (savageContextPtr imesa,
}
static void savageUpdateRegister_s4(savageContextPtr imesa)
{
u_int32_t *pBCIBase;
/*
* Scissors updates drawctrl0 and drawctrl 1
*/
@@ -1470,23 +1525,12 @@ static void savageUpdateRegister_s4(savageContextPtr imesa)
/* the savage4 uses the contiguous range of BCI registers 0x1e-0x39
* 0x1e-0x27 are local, no need to check them for global changes */
if (imesa->lostContext || savageGlobalRegChanged (imesa, 0x28, 0x39)) {
pBCIBase = savageDMAAlloc (imesa, 1);
WRITE_CMD (pBCIBase, WAIT_3D_IDLE, u_int32_t);
savageDMACommit (imesa, pBCIBase);
}
if (imesa->lostContext)
savageEmitContiguousRegs (imesa, 0x1e, 0x39);
else
savageEmitChangedRegs (imesa, 0x1e, 0x39);
savageEmitContiguousRegs (imesa, 0x1e, 0x39);
imesa->dirty=0;
imesa->lostContext = GL_FALSE;
}
static void savageUpdateRegister_s3d(savageContextPtr imesa)
{
u_int32_t *pBCIBase;
if (imesa->scissorChanged)
{
if(imesa->scissor)
@@ -1519,63 +1563,55 @@ static void savageUpdateRegister_s3d(savageContextPtr imesa)
imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_TRUE;
/* the savage3d uses two contiguous ranges of BCI registers:
* 0x18-0x1c and 0x20-0x38. The first range is local. */
if (imesa->lostContext || savageGlobalRegChanged (imesa, 0x20, 0x38)) {
pBCIBase = savageDMAAlloc (imesa, 1);
WRITE_CMD (pBCIBase, WAIT_3D_IDLE, u_int32_t);
savageDMACommit (imesa, pBCIBase);
}
* 0x18-0x1c and 0x20-0x38. Some texture registers need to be
* emitted in one chunk or we get some funky rendering errors. */
/* FIXME: watermark registers aren't programmed correctly ATM */
if (imesa->lostContext) {
savageEmitContiguousRegs (imesa, 0x18, 0x1c);
savageEmitContiguousRegs (imesa, 0x20, 0x36);
} else {
/* On the Savage IX texture registers (at least some of them)
* have to be emitted as one chunk. */
savageEmitChangedRegs (imesa, 0x18, 0x19);
savageEmitChangedRegChunk (imesa, 0x1a, 0x1c);
savageEmitChangedRegs (imesa, 0x20, 0x36);
}
savageEmitChangedRegs (imesa, 0x18, 0x19);
savageEmitChangedRegChunk (imesa, 0x1a, 0x1c);
savageEmitChangedRegs (imesa, 0x20, 0x36);
imesa->dirty=0;
imesa->lostContext = GL_FALSE;
}
void savageEmitOldState( savageContextPtr imesa )
{
assert(imesa->cmdBuf.write == imesa->cmdBuf.base);
if (imesa->savageScreen->chipset >= S3_SAVAGE4) {
savageEmitOldRegs (imesa, 0x1e, 0x39, GL_TRUE);
} else {
savageEmitOldRegs (imesa, 0x18, 0x1c, GL_TRUE);
savageEmitOldRegs (imesa, 0x20, 0x36, GL_FALSE);
}
}
/* Push the state into the sarea and/or texture memory.
*/
void savageEmitHwStateLocked( savageContextPtr imesa )
void savageEmitChangedState( savageContextPtr imesa )
{
if (SAVAGE_DEBUG & DEBUG_VERBOSE_API)
savageDDPrintDirty( "\n\n\nsavageEmitHwStateLocked", imesa->dirty );
if (imesa->dirty & ~SAVAGE_UPLOAD_CLIPRECTS)
{
if (imesa->dirty & (SAVAGE_UPLOAD_CTX | SAVAGE_UPLOAD_TEX0 | \
SAVAGE_UPLOAD_TEX1 | SAVAGE_UPLOAD_BUFFERS))
if (imesa->dirty & (SAVAGE_UPLOAD_GLOBAL | SAVAGE_UPLOAD_LOCAL |
SAVAGE_UPLOAD_TEX0 | SAVAGE_UPLOAD_TEX1 |
SAVAGE_UPLOAD_FOGTBL | SAVAGE_UPLOAD_TEXGLOBAL))
{
/*SAVAGE_STATE_COPY(imesa);*/
/* update state to hw*/
if (imesa->driDrawable &&imesa->driDrawable->numClipRects ==0 )
{
return ;
}
if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
fprintf (stderr, "... emitting state\n");
if (imesa->savageScreen->chipset >= S3_SAVAGE4)
savageUpdateRegister_s4(imesa);
else
savageUpdateRegister_s3d(imesa);
}
imesa->sarea->dirty |= (imesa->dirty &
~(SAVAGE_UPLOAD_TEX1|SAVAGE_UPLOAD_TEX0));
imesa->dirty &= SAVAGE_UPLOAD_CLIPRECTS;
}
}
static void savageDDInitState_s4( savageContextPtr imesa )
{
#if 1
@@ -1584,7 +1620,14 @@ static void savageDDInitState_s4( savageContextPtr imesa )
imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Less;
imesa->regs.s4.zBufCtrl.ni.wToZEn = GL_TRUE;
/*imesa->regs.s4.ZBufCtrl.ni.floatZEn = GL_TRUE;*/
if (imesa->float_depth) {
imesa->regs.s4.zBufCtrl.ni.zExpOffset =
imesa->savageScreen->zpp == 2 ? 16 : 32;
imesa->regs.s4.zBufCtrl.ni.floatZEn = GL_TRUE;
} else {
imesa->regs.s4.zBufCtrl.ni.zExpOffset = 0;
imesa->regs.s4.zBufCtrl.ni.floatZEn = GL_FALSE;
}
imesa->regs.s4.texBlendCtrl[0].ui = TBC_NoTexMap;
imesa->regs.s4.texBlendCtrl[1].ui = TBC_NoTexMap1;
imesa->regs.s4.drawCtrl0.ui = 0;
@@ -1719,7 +1762,6 @@ static void savageDDInitState_s3d( savageContextPtr imesa )
}
void savageDDInitState( savageContextPtr imesa ) {
memset (imesa->regs.ui, 0, SAVAGE_NR_REGS*sizeof(u_int32_t));
memset (imesa->oldRegs.ui, 0, SAVAGE_NR_REGS*sizeof(u_int32_t));
memset (imesa->globalRegMask.ui, 0xff, SAVAGE_NR_REGS*sizeof(u_int32_t));
if (imesa->savageScreen->chipset >= S3_SAVAGE4)
savageDDInitState_s4 (imesa);
@@ -1789,6 +1831,13 @@ void savageDDInitState( savageContextPtr imesa ) {
imesa->readMap = (char *)imesa->apertureBase[TARGET_BACK];
}
}
memcpy (imesa->oldRegs.ui, imesa->regs.ui, SAVAGE_NR_REGS*sizeof(u_int32_t));
/* Emit the initial state to the (empty) command buffer. */
assert (imesa->cmdBuf.write == imesa->cmdBuf.base);
savageEmitOldState(imesa);
imesa->cmdBuf.start = imesa->cmdBuf.write;
}

View File

@@ -28,43 +28,13 @@
#include "savagecontext.h"
void savageEmitOldState( savageContextPtr imesa );
void savageEmitChangedState( savageContextPtr imesa );
extern void savageDDUpdateHwState( GLcontext *ctx );
extern void savageDDInitState( savageContextPtr imesa );
extern void savageDDInitStateFuncs( GLcontext *ctx );
extern void savageDDRenderStart(GLcontext *ctx);
extern void savageDDRenderEnd(GLcontext *ctx);
/*frank 2001/11/13 add macro for sarea state copy*/
#if 0
#define SAVAGE_STATE_COPY(ctx) { \
ctx->sarea->setup[0]=ctx->Registers.DrawLocalCtrl.ui; \
ctx->sarea->setup[1]=ctx->Registers.TexPalAddr.ui; \
ctx->sarea->setup[2]=ctx->Registers.TexCtrl[0].ui; \
ctx->sarea->setup[3]=ctx->Registers.TexCtrl[1].ui; \
ctx->sarea->setup[4]=ctx->Registers.TexAddr[0].ui; \
ctx->sarea->setup[5]=ctx->Registers.TexAddr[1].ui; \
ctx->sarea->setup[6]=ctx->Registers.TexBlendCtrl[0].ui; \
ctx->sarea->setup[7]=ctx->Registers.TexBlendCtrl[1].ui; \
ctx->sarea->setup[8]=ctx->Registers.TexXprClr.ui; \
ctx->sarea->setup[9]=ctx->Registers.TexDescr.ui; \
ctx->sarea->setup[10]=ctx->Registers.FogTable.ni.ulEntry[0]; \
ctx->sarea->setup[11]=ctx->Registers.FogTable.ni.ulEntry[1]; \
ctx->sarea->setup[12]=ctx->Registers.FogTable.ni.ulEntry[2]; \
ctx->sarea->setup[13]=ctx->Registers.FogTable.ni.ulEntry[3]; \
ctx->sarea->setup[14]=ctx->Registers.FogTable.ni.ulEntry[4]; \
ctx->sarea->setup[15]=ctx->Registers.FogTable.ni.ulEntry[5]; \
ctx->sarea->setup[16]=ctx->Registers.FogTable.ni.ulEntry[6]; \
ctx->sarea->setup[17]=ctx->Registers.FogTable.ni.ulEntry[7]; \
ctx->sarea->setup[18]=ctx->Registers.FogCtrl.ui; \
ctx->sarea->setup[19]=ctx->Registers.StencilCtrl.ui; \
ctx->sarea->setup[20]=ctx->Registers.ZBufCtrl.ui; \
ctx->sarea->setup[21]=ctx->Registers.ZBufOffset.ui; \
ctx->sarea->setup[22]=ctx->Registers.DestCtrl.ui; \
ctx->sarea->setup[23]=ctx->Registers.DrawCtrl0.ui; \
ctx->sarea->setup[24]=ctx->Registers.DrawCtrl1.ui; \
ctx->sarea->setup[25]=ctx->Registers.ZWatermarks.ui; \
ctx->sarea->setup[26]=ctx->Registers.DestTexWatermarks.ui; \
ctx->sarea->setup[27]=ctx->Registers.TexBlendColor.ui; \
}
#endif
#endif

View File

@@ -606,7 +606,7 @@ void savagePrintGlobalLRU( savageContextPtr imesa , GLuint heap)
{
int i, j;
drm_savage_tex_region_t *list = imesa->sarea->texList[heap];
drm_tex_region_t *list = imesa->sarea->texList[heap];
for (i = 0, j = SAVAGE_NR_TEX_REGIONS ; i < SAVAGE_NR_TEX_REGIONS ; i++) {
@@ -628,7 +628,7 @@ void savagePrintGlobalLRU( savageContextPtr imesa , GLuint heap)
void savageResetGlobalLRU( savageContextPtr imesa, GLuint heap )
{
drm_savage_tex_region_t *list = imesa->sarea->texList[heap];
drm_tex_region_t *list = imesa->sarea->texList[heap];
int sz = 1 << imesa->savageScreen->logTextureGranularity[heap];
int i;
@@ -661,7 +661,7 @@ static void savageUpdateTexLRU( savageContextPtr imesa, savageTextureObjectPtr t
int logsz = imesa->savageScreen->logTextureGranularity[heap];
int start = t->MemBlock->ofs >> logsz;
int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
drm_savage_tex_region_t *list = imesa->sarea->texList[heap];
drm_tex_region_t *list = imesa->sarea->texList[heap];
imesa->texAge[heap] = ++imesa->sarea->texAge[heap];
@@ -787,16 +787,19 @@ int savageUploadTexImages( savageContextPtr imesa, savageTextureObjectPtr t )
ofs = t->MemBlock->ofs;
t->texParams.hwPhysAddress = imesa->savageScreen->textureOffset[heap] + ofs;
t->BufAddr = (char *)((GLuint) imesa->savageScreen->texVirtual[heap] + ofs);
imesa->dirty |= SAVAGE_UPLOAD_CTX;
imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; /* FIXME: really needed? */
}
/* Let the world know we've used this memory recently.
*/
LOCK_HARDWARE(imesa);
savageUpdateTexLRU( imesa, t );
UNLOCK_HARDWARE(imesa);
if (t->dirty_images) {
savageFlushVertices (imesa);
LOCK_HARDWARE(imesa);
savageFlushVerticesLocked (imesa);
savageFlushCmdBufLocked (imesa, GL_FALSE);
savageDmaFinish (imesa);
if (SAVAGE_DEBUG & DEBUG_VERBOSE_LRU)
fprintf(stderr, "*");
@@ -1436,8 +1439,7 @@ static void savageUpdateTextureState_s4( GLcontext *ctx )
imesa->CurrentTexObj[1] = 0;
savageUpdateTex0State_s4( ctx );
savageUpdateTex1State_s4( ctx );
imesa->dirty |= (SAVAGE_UPLOAD_CTX |
SAVAGE_UPLOAD_TEX0 |
imesa->dirty |= (SAVAGE_UPLOAD_TEX0 |
SAVAGE_UPLOAD_TEX1);
}
static void savageUpdateTextureState_s3d( GLcontext *ctx )
@@ -1446,8 +1448,7 @@ static void savageUpdateTextureState_s3d( GLcontext *ctx )
if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
imesa->CurrentTexObj[0] = 0;
savageUpdateTexState_s3d( ctx );
imesa->dirty |= (SAVAGE_UPLOAD_CTX |
SAVAGE_UPLOAD_TEX0);
imesa->dirty |= (SAVAGE_UPLOAD_TEX0);
}
void savageUpdateTextureState( GLcontext *ctx)
{

View File

@@ -100,7 +100,7 @@ static void __inline__ savage_draw_triangle (savageContextPtr imesa,
savageVertexPtr v1,
savageVertexPtr v2) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocDmaLow (imesa, 3*4*vertsize);
u_int32_t *vb = savageAllocVtxBuf (imesa, 3*vertsize);
GLuint j;
EMIT_VERT (j, vb, vertsize, 0, v0);
@@ -114,7 +114,7 @@ static void __inline__ savage_draw_quad (savageContextPtr imesa,
savageVertexPtr v2,
savageVertexPtr v3) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
GLuint j;
EMIT_VERT (j, vb, vertsize, 0, v0);
@@ -128,7 +128,7 @@ static void __inline__ savage_draw_quad (savageContextPtr imesa,
static __inline__ void savage_draw_point (savageContextPtr imesa,
savageVertexPtr tmp) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
const GLfloat x = tmp->v.x;
const GLfloat y = tmp->v.y;
const GLfloat sz = imesa->glCtx->Point._Size * .5;
@@ -163,7 +163,7 @@ static __inline__ void savage_draw_line (savageContextPtr imesa,
savageVertexPtr v0,
savageVertexPtr v1 ) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
GLfloat width = imesa->glCtx->Line._Width;
GLfloat dx, dy, ix, iy;
GLuint j;
@@ -220,7 +220,7 @@ static void __inline__ savage_ptex_tri (savageContextPtr imesa,
savageVertexPtr v1,
savageVertexPtr v2) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocDmaLow (imesa, 3*4*vertsize);
u_int32_t *vb = savageAllocVtxBuf (imesa, 3*vertsize);
savageVertex tmp;
GLuint j;
@@ -233,7 +233,7 @@ static __inline__ void savage_ptex_line (savageContextPtr imesa,
savageVertexPtr v0,
savageVertexPtr v1 ) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
GLfloat width = imesa->glCtx->Line._Width;
GLfloat dx, dy, ix, iy;
savageVertex tmp0, tmp1;
@@ -278,7 +278,7 @@ static __inline__ void savage_ptex_line (savageContextPtr imesa,
static __inline__ void savage_ptex_point (savageContextPtr imesa,
savageVertexPtr v0) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
const GLfloat x = v0->v.x;
const GLfloat y = v0->v.y;
const GLfloat sz = imesa->glCtx->Point._Size * .5;
@@ -428,9 +428,9 @@ do { \
savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
GLuint color[n], spec[n]; \
GLuint coloroffset = \
((imesa->DrawPrimitiveCmd & SAVAGE_HW_NO_W) ? 3 : 4); \
((imesa->skip & SAVAGE_SKIP_W) ? 3 : 4); \
GLboolean specoffset = \
((imesa->DrawPrimitiveCmd & SAVAGE_HW_NO_CS) ? 0 : coloroffset+1);\
((imesa->skip & SAVAGE_SKIP_C1) ? 0 : coloroffset+1); \
(void) color; (void) spec; (void) coloroffset; (void) specoffset;
/***********************************************************************
@@ -756,6 +756,16 @@ static void savageChooseRenderState(GLcontext *ctx)
imesa->RenderIndex = index;
}
if (imesa->savageScreen->chipset < S3_SAVAGE4 && (flags & DD_FLATSHADE)) {
if (imesa->HwPrim != SAVAGE_PRIM_TRILIST_201)
savageFlushVertices(imesa);
imesa->HwPrim = SAVAGE_PRIM_TRILIST_201;
} else {
if (imesa->HwPrim != SAVAGE_PRIM_TRILIST)
savageFlushVertices(imesa);
imesa->HwPrim = SAVAGE_PRIM_TRILIST;
}
}
/**********************************************************************/
@@ -766,6 +776,9 @@ static void savageRunPipeline( GLcontext *ctx )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
if (imesa->no_rast)
FALLBACK(ctx, SAVAGE_FALLBACK_NORAST, GL_TRUE);
if (imesa->new_state)
savageDDUpdateHwState( ctx );
@@ -777,6 +790,9 @@ static void savageRunPipeline( GLcontext *ctx )
}
_tnl_run_pipeline( ctx );
if (imesa->no_rast)
FALLBACK(ctx, SAVAGE_FALLBACK_NORAST, GL_FALSE);
}
/**********************************************************************/
@@ -858,7 +874,7 @@ do { \
imesa->vertex_attrs[imesa->vertex_attr_count].format = (STYLE); \
imesa->vertex_attr_count++; \
setupIndex |= (INDEX); \
drawCmd &= ~(SKIP); \
skip &= ~(SKIP); \
} while (0)
#define EMIT_PAD( N ) \
@@ -891,11 +907,8 @@ static void savageRenderStart( GLcontext *ctx )
struct vertex_buffer *VB = &tnl->vb;
GLuint index = tnl->render_inputs;
GLuint setupIndex = SAVAGE_EMIT_XYZ;
GLuint drawCmd = SAVAGE_HW_SKIPFLAGS;
GLubyte skip;
GLboolean ptexHack;
if (imesa->savageScreen->chipset < S3_SAVAGE4)
drawCmd &= ~SAVAGE_HW_NO_UV1;
drawCmd &= ~SAVAGE_HW_NO_Z; /* all mesa vertices have a z coordinate */
/* Check if we need to apply the ptex hack. Choose a new render
* state if necessary. (Note: this can't be done in
@@ -917,66 +930,115 @@ static void savageRenderStart( GLcontext *ctx )
VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
imesa->vertex_attr_count = 0;
/* EMIT_ATTR's must be in order as they tell t_vertex.c how to
* build up a hardware vertex.
*/
if ((index & _TNL_BITS_TEX_ANY) || !(ctx->_TriangleCaps & DD_FLATSHADE)) {
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, SAVAGE_EMIT_W, SAVAGE_HW_NO_W );
}
else {
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 );
}
if (imesa->savageScreen->chipset < S3_SAVAGE4) {
skip = SAVAGE_SKIP_ALL_S3D;
skip &= ~SAVAGE_SKIP_Z; /* all mesa vertices have a z coordinate */
/* t_context.c always includes a diffuse color */
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, SAVAGE_EMIT_C0, SAVAGE_HW_NO_CD );
/* EMIT_ATTR's must be in order as they tell t_vertex.c how to
* build up a hardware vertex.
*/
if ((index & _TNL_BITS_TEX_ANY) || !(ctx->_TriangleCaps & DD_FLATSHADE)) {
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, SAVAGE_EMIT_W, SAVAGE_SKIP_W );
}
else {
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 );
EMIT_PAD( 4 );
skip &= ~SAVAGE_SKIP_W;
}
/* t_context.c always includes a diffuse color */
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, SAVAGE_EMIT_C0, SAVAGE_SKIP_C0 );
if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
if ((index & _TNL_BIT_COLOR1))
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, SAVAGE_EMIT_C1, SAVAGE_HW_NO_CS );
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, SAVAGE_EMIT_C1, SAVAGE_SKIP_C1 );
else
EMIT_PAD( 3 );
if ((index & _TNL_BIT_FOG))
EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_EMIT_FOG, SAVAGE_HW_NO_CS );
EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_EMIT_FOG, SAVAGE_SKIP_C1 );
else
EMIT_PAD( 1 );
}
skip &= ~SAVAGE_SKIP_C1;
if (index & _TNL_BIT_TEX(0)) {
if (ptexHack)
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, SAVAGE_EMIT_STQ0, SAVAGE_HW_NO_UV0);
else if (VB->TexCoordPtr[0]->size == 4)
assert (0); /* should be caught by savageCheckPTexHack */
else if (VB->TexCoordPtr[0]->size >= 2)
/* The chromium menu emits some 3D tex coords even though no
* 3D texture is enabled. Ignore the 3rd coordinate. */
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, SAVAGE_EMIT_ST0, SAVAGE_HW_NO_UV0 );
if (index & _TNL_BIT_TEX(0)) {
if (ptexHack)
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, SAVAGE_EMIT_STQ0, SAVAGE_SKIP_ST0);
else if (VB->TexCoordPtr[0]->size == 4)
assert (0); /* should be caught by savageCheckPTexHack */
else if (VB->TexCoordPtr[0]->size >= 2)
/* The chromium menu emits some 3D tex coords even though no
* 3D texture is enabled. Ignore the 3rd coordinate. */
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, SAVAGE_EMIT_ST0, SAVAGE_SKIP_ST0 );
else if (VB->TexCoordPtr[0]->size == 1) {
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F, SAVAGE_EMIT_S0, SAVAGE_SKIP_S0 );
EMIT_PAD( 4 );
} else
EMIT_PAD( 8 );
} else
EMIT_PAD( 8 );
skip &= ~SAVAGE_SKIP_ST0;
} else {
skip = SAVAGE_SKIP_ALL_S4;
skip &= ~SAVAGE_SKIP_Z; /* all mesa vertices have a z coordinate */
/* EMIT_ATTR's must be in order as they tell t_vertex.c how to
* build up a hardware vertex.
*/
if ((index & _TNL_BITS_TEX_ANY) || !(ctx->_TriangleCaps & DD_FLATSHADE))
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, SAVAGE_EMIT_W, SAVAGE_SKIP_W );
else
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F, SAVAGE_EMIT_S0, SAVAGE_HW_NO_U0 );
}
if (index & _TNL_BIT_TEX(1)) {
if (VB->TexCoordPtr[1]->size == 4)
/* Projective textures are not supported by the hardware */
assert (0); /* should be caught by savageCheckPTexHack */
else if (VB->TexCoordPtr[1]->size >= 2)
EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, SAVAGE_EMIT_ST1, SAVAGE_HW_NO_UV1 );
else
EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_1F, SAVAGE_EMIT_S1, SAVAGE_HW_NO_U1 );
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 );
/* t_context.c always includes a diffuse color */
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, SAVAGE_EMIT_C0, SAVAGE_SKIP_C0 );
if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
if ((index & _TNL_BIT_COLOR1))
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, SAVAGE_EMIT_C1, SAVAGE_SKIP_C1 );
else
EMIT_PAD( 3 );
if ((index & _TNL_BIT_FOG))
EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_EMIT_FOG, SAVAGE_SKIP_C1 );
else
EMIT_PAD( 1 );
}
if (index & _TNL_BIT_TEX(0)) {
if (ptexHack)
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, SAVAGE_EMIT_STQ0, SAVAGE_SKIP_ST0);
else if (VB->TexCoordPtr[0]->size == 4)
assert (0); /* should be caught by savageCheckPTexHack */
else if (VB->TexCoordPtr[0]->size >= 2)
/* The chromium menu emits some 3D tex coords even though no
* 3D texture is enabled. Ignore the 3rd coordinate. */
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, SAVAGE_EMIT_ST0, SAVAGE_SKIP_ST0 );
else
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F, SAVAGE_EMIT_S0, SAVAGE_SKIP_S0 );
}
if (index & _TNL_BIT_TEX(1)) {
if (VB->TexCoordPtr[1]->size == 4)
/* projective textures are not supported by the hardware */
assert (0); /* should be caught by savageCheckPTexHack */
else if (VB->TexCoordPtr[1]->size >= 2)
EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, SAVAGE_EMIT_ST1, SAVAGE_SKIP_ST1 );
else
EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_1F, SAVAGE_EMIT_S1, SAVAGE_SKIP_S1 );
}
}
/* Need to change the vertex emit code if the SetupIndex changed or
* is set for the first time (indicated by vertex_size == 0). */
if (setupIndex != imesa->SetupIndex || imesa->vertex_size == 0) {
imesa->vertex_size =
GLuint hwVertexSize;
imesa->vertex_size =
_tnl_install_attrs( ctx,
imesa->vertex_attrs,
imesa->vertex_attr_count,
imesa->hw_viewport, 0 );
imesa->vertex_size >>= 2;
imesa->SetupIndex = setupIndex;
imesa->skip = skip;
imesa->DrawPrimitiveCmd = drawCmd;
imesa->HwVertexSize = imesa->vertex_size;
hwVertexSize = imesa->vertex_size;
if (setupIndex & SAVAGE_EMIT_Q0) {
/* The vertex setup code emits homogenous texture
* coordinates. They are converted to normal 2D coords by
@@ -984,10 +1046,28 @@ static void savageRenderStart( GLcontext *ctx )
* vertex sizes. Functions that emit vertices to the hardware
* need to use HwVertexSize, anything that manipulates the
* vertices generated by t_vertex uses vertex_size. */
imesa->HwVertexSize--;
hwVertexSize--;
assert (imesa->ptexHack);
} else
assert (!imesa->ptexHack);
if (hwVertexSize != imesa->HwVertexSize) {
/* Changing the vertex size: flush vertex and command buffer and
* discard the DMA buffer, if we were using one. */
savageFlushVertices(imesa);
savageFlushCmdBuf(imesa, GL_TRUE);
if (hwVertexSize == 8) {
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf (stderr, "Using DMA, skip=0x%02x\n", skip);
/* we can use vertex dma */
imesa->vtxBuf = &imesa->dmaVtxBuf;
} else {
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf (stderr, "Not using DMA, skip=0x%02x\n", skip);
imesa->vtxBuf = &imesa->clientVtxBuf;
}
imesa->HwVertexSize = hwVertexSize;
}
}
/* Update hardware state and get the lock */
@@ -1040,7 +1120,6 @@ void savageFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
imesa->Fallback |= bit;
if (oldfallback == 0) {
/* the first fallback */
FLUSH_BATCH( imesa );
_swsetup_Wakeup( ctx );
imesa->RenderIndex = ~0;
}

View File

@@ -29,6 +29,11 @@
#include "xf86drm.h"
#include "drm.h"
/* Totals 2 Mbytes which equals 2^16 32-byte vertices divided among up
* to 32 clients. */
#define SAVAGE_NUM_BUFFERS 32
#define SAVAGE_BUFFER_SIZE (1 << 16) /* 64k */
#define SAVAGE_DEFAULT_AGP_MODE 1
#define SAVAGE_MAX_AGP_MODE 4
@@ -68,14 +73,17 @@ typedef struct _server{
unsigned int frontOffset;
unsigned int frontPitch;
unsigned int frontbufferSize;
unsigned int frontBitmapDesc;
unsigned int backOffset;
unsigned int backPitch;
unsigned int backbufferSize;
unsigned int backBitmapDesc;
unsigned int depthOffset;
unsigned int depthPitch;
unsigned int depthbufferSize;
unsigned int depthBitmapDesc;
unsigned int textureOffset;
int textureSize;
@@ -89,12 +97,7 @@ typedef struct _server{
drmRegion status;
/* AGP mappings */
#if 0
drmRegion warp;
drmRegion primary;
drmRegion buffers;
#endif
drmRegion agpTextures;
int logAgpTextureGranularity;
@@ -114,71 +117,41 @@ typedef struct {
int cpp;
int zpp;
int agpMode;
int agpMode; /* 0 for PCI cards */
unsigned int sarea_priv_offset;
unsigned int bufferSize; /* size of DMA buffers */
drm_handle_t frontbuffer;
unsigned int frontbufferSize;
unsigned int frontOffset;
unsigned int frontPitch;
unsigned int frontBitmapDesc; /*Bitmap Descriptior*/
unsigned int IsfrontTiled;
drm_handle_t backbuffer;
unsigned int backbufferSize;
unsigned int backOffset;
unsigned int backPitch;
unsigned int backBitmapDesc; /*Bitmap Descriptior*/
drm_handle_t depthbuffer;
unsigned int depthbufferSize;
unsigned int depthOffset;
unsigned int depthPitch;
unsigned int depthBitmapDesc; /*Bitmap Descriptior*/
drm_handle_t textures;
drm_handle_t xvmcSurfHandle;
unsigned int textureOffset;
unsigned int textureSize;
int logTextureGranularity;
/* Allow calculation of setup dma addresses.
*/
unsigned int agpBufferOffset;
unsigned int agpTextureOffset;
unsigned int agpTextureSize;
drmRegion agpTextures;
int logAgpTextureGranularity;
/* unsigned int mAccess;*/
drmRegion aperture;
/* Linear aperture */
drm_handle_t apertureHandle;
unsigned int apertureSize;
unsigned int aperturePitch; /* in byte */
/* Status page (probably not needed, but no harm, read-only) */
drm_handle_t statusHandle;
unsigned int statusSize;
drmRegion registers;
drmRegion BCIcmdBuf;
drmRegion status;
/* AGP textures */
drm_handle_t agpTextureHandle;
unsigned int agpTextureSize;
int logAgpTextureGranularity;
#if 0
drmRegion primary;
drmRegion buffers;
#endif
/*For shadow status*/
unsigned long sareaPhysAddr;
unsigned int sarea_priv_offset;
int shadowStatus;
/* Not sure about this one */
drm_handle_t xvmcSurfHandle; /* ? */
} SAVAGEDRIRec, *SAVAGEDRIPtr;
#endif

View File

@@ -40,7 +40,7 @@
#include "matrix.h"
#include "extensions.h"
#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#include "x86/common_x86_asm.h"
#endif
#include "simple_list.h"
#include "mm.h"

View File

@@ -27,7 +27,7 @@
#include "trident_context.h"
#include "trident_lock.h"
#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#include "x86/common_x86_asm.h"
#endif
#include "swrast/swrast.h"

View File

@@ -29,7 +29,6 @@ DRIVER_SOURCES = \
via_texmem.c \
via_texstate.c \
via_tris.c \
via_vb.c \
via_texcombine.c \
xf86drmVIA.c

View File

@@ -52,7 +52,6 @@
#include "via_tex.h"
#include "via_span.h"
#include "via_tris.h"
#include "via_vb.h"
#include "via_ioctl.h"
#include "via_fb.h"
#include "via_regs.h"
@@ -257,6 +256,8 @@ static const char * const card_extensions[] =
"GL_EXT_texture_env_combine",
"GL_EXT_texture_env_dot3",
"GL_EXT_texture_lod_bias",
"GL_EXT_secondary_color",
"GL_EXT_fog_coord",
"GL_NV_blend_square",
NULL
};
@@ -288,7 +289,7 @@ AllocateDmaBuffer(const GLvisual *visual, viaContextPtr vmesa)
return GL_FALSE;
vmesa->dmaLow = 0;
vmesa->dmaCliprectAddr = 0;
vmesa->dmaCliprectAddr = ~0;
return GL_TRUE;
}
@@ -356,6 +357,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->depth_max = (GLfloat)0xffff;
vmesa->depth_clear_mask = 0xf << 28;
vmesa->ClearDepth = 0xffff;
vmesa->polygon_offset_scale = 1.0 / vmesa->depth_max;
break;
case 24:
vmesa->hasDepth = GL_TRUE;
@@ -370,6 +372,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->have_hw_stencil = GL_TRUE;
vmesa->stencilBits = mesaVis->stencilBits;
vmesa->stencil_clear_mask = 0x1 << 28;
vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max;
break;
case 32:
vmesa->hasDepth = GL_TRUE;
@@ -380,6 +383,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->depth_clear_mask = 0;
vmesa->ClearDepth = 0xffffffff;
vmesa->depth_clear_mask = 0xf << 28;
vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max;
break;
default:
assert(0);
@@ -465,6 +469,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->texHeap = mmInit(0, viaScreen->textureSize);
vmesa->renderIndex = ~0;
vmesa->setupIndex = ~0;
make_empty_list(&vmesa->TexObjList);
make_empty_list(&vmesa->SwappedOut);
@@ -489,7 +494,6 @@ viaCreateContext(const __GLcontextModes *mesaVis,
viaInitTriFuncs(ctx);
viaInitSpanFuncs(ctx);
viaInitIoctlFuncs(ctx);
viaInitVB(ctx);
viaInitState(ctx);
#ifdef DEBUG
@@ -552,7 +556,6 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv)
_tnl_DestroyContext(vmesa->glCtx);
_ac_DestroyContext(vmesa->glCtx);
_swrast_DestroyContext(vmesa->glCtx);
viaFreeVB(vmesa->glCtx);
FreeBuffer(vmesa);
/* free the Mesa context */
_mesa_destroy_context(vmesa->glCtx);
@@ -658,8 +661,16 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
(GLframebuffer *)driDrawPriv->driverPrivate,
(GLframebuffer *)driReadPriv->driverPrivate);
if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext);
viaXMesaWindowMoved(vmesa);
/* These are probably needed only the first time a context is
* made current:
*/
viaXMesaWindowMoved(vmesa);
ctx->Driver.Scissor(ctx,
ctx->Scissor.X,
ctx->Scissor.Y,
ctx->Scissor.Width,
ctx->Scissor.Height);
}
else {

View File

@@ -35,11 +35,13 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
#include "mtypes.h"
#include "drm.h"
#include "mm.h"
#include "tnl/t_vertex.h"
#include "via_screen.h"
#include "via_tex.h"
#include "via_common.h"
#include "xf86drmVIA.h"
#define VIA_FALLBACK_TEXTURE 0x1
#define VIA_FALLBACK_DRAW_BUFFER 0x2
#define VIA_FALLBACK_READ_BUFFER 0x4
@@ -51,9 +53,10 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
#define VIA_FALLBACK_BLEND_EQ 0x200
#define VIA_FALLBACK_BLEND_FUNC 0x400
#define VIA_FALLBACK_USER_DISABLE 0x800
#define VIA_FALLBACK_PROJ_TEXTURE 0x1000
#define VIA_DMA_BUFSIZ 5000
#define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 256)
#define VIA_DMA_BUFSIZ 4096
#define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 128)
#define VIA_NO_CLIPRECTS 0x1
@@ -103,6 +106,7 @@ struct via_context_t {
GLuint depth_clear_mask;
GLuint stencil_clear_mask;
GLfloat depth_max;
GLfloat polygon_offset_scale;
GLubyte *dma;
viaRegion tex;
@@ -120,11 +124,15 @@ struct via_context_t {
*/
GLuint Fallback;
/* State for via_vb.c and via_tris.c.
/* State for via_tris.c.
*/
GLuint newState; /* _NEW_* flags */
GLuint newEmitState; /* _NEW_* flags */
GLuint setupNewInputs;
GLuint newRenderState; /* _NEW_* flags */
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
GLuint vertex_attr_count;
GLuint setupIndex;
GLuint renderIndex;
GLmatrix ViewportMatrix;
@@ -203,15 +211,18 @@ struct via_context_t {
GLuint regHTXnTBLRAa_1;
GLuint regHTXnTBLRFog_1;
/* Hardware state
*/
GLuint dirty;
int vertexSize;
int vertexFormat;
int hwVertexSize;
GLboolean ptexHack;
int coloroffset;
int specoffset;
GLint lastStamp;
GLenum TexEnvImageFmt[2];
GLuint ClearColor;
GLuint ClearMask;
/* DRI stuff
*/
GLuint needClip;

View File

@@ -3,7 +3,7 @@
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
v * copy of this software and associated documentation files (the "Software"),
* 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, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
@@ -90,77 +90,61 @@ void viaCheckDma(viaContextPtr vmesa, GLuint bytes)
} while (0)
static void viaBlit(viaContextPtr vmesa, GLuint bpp,GLuint srcBase,
GLuint srcPitch,GLuint dstBase,GLuint dstPitch,
GLuint w,GLuint h,int xdir,int ydir, GLuint blitMode,
static void viaBlit(viaContextPtr vmesa, GLuint bpp,
GLuint srcBase, GLuint srcPitch,
GLuint dstBase, GLuint dstPitch,
GLuint w, GLuint h,
GLuint blitMode,
GLuint color, GLuint nMask )
{
GLuint dwGEMode = 0, srcY=0, srcX, dstY=0, dstX;
GLuint cmd;
GLuint dwGEMode, srcX, dstX, cmd;
RING_VARS;
if (VIA_DEBUG)
fprintf(stderr, "%s bpp %d src %x/%x dst %x/%x w %d h %d dir %d,%d mode: %x color: 0x%08x mask 0x%08x\n",
__FUNCTION__, bpp, srcBase, srcPitch, dstBase, dstPitch, w,h, xdir, ydir, blitMode, color, nMask);
fprintf(stderr, "%s bpp %d src %x/%x dst %x/%x w %d h %d mode: %x color: 0x%08x mask 0x%08x\n",
__FUNCTION__, bpp, srcBase, srcPitch, dstBase, dstPitch, w,h, blitMode, color, nMask);
if (!w || !h)
return;
srcX = srcBase & 31;
dstX = dstBase & 31;
switch (bpp) {
case 16:
dwGEMode |= VIA_GEM_16bpp;
srcX >>= 1;
dstX >>= 1;
dwGEMode = VIA_GEM_16bpp;
srcX = (srcBase & 0x1f) >> 1;
dstX = (dstBase & 0x1f) >> 1;
break;
case 32:
dwGEMode |= VIA_GEM_32bpp;
srcX >>= 2;
dstX >>= 2;
dwGEMode = VIA_GEM_32bpp;
srcX = (srcBase & 0x1f) >> 2;
dstX = (dstBase & 0x1f) >> 2;
break;
default:
dwGEMode |= VIA_GEM_8bpp;
break;
}
cmd = 0;
if (xdir < 0) {
cmd |= VIA_GEC_DECX;
srcX += (w - 1);
dstX += (w - 1);
}
if (ydir < 0) {
cmd |= VIA_GEC_DECY;
srcY += (h - 1);
dstY += (h - 1);
return;
}
switch(blitMode) {
case VIA_BLIT_FILL:
BEGIN_RING((2 + 9) * 2);
SetReg2DAGP(VIA_REG_GEMODE, dwGEMode);
SetReg2DAGP( VIA_REG_FGCOLOR, color);
cmd |= VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
break;
case VIA_BLIT_COPY:
BEGIN_RING((2 + 9) * 2);
SetReg2DAGP(VIA_REG_GEMODE, dwGEMode);
SetReg2DAGP( VIA_REG_KEYCONTROL, 0x0);
cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
cmd = VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
break;
default:
return;
}
BEGIN_RING(22);
SetReg2DAGP( VIA_REG_GEMODE, dwGEMode);
SetReg2DAGP( VIA_REG_FGCOLOR, color);
SetReg2DAGP( 0x2C, nMask);
SetReg2DAGP( VIA_REG_SRCBASE, (srcBase & ~31) >> 3);
SetReg2DAGP( VIA_REG_DSTBASE, (dstBase & ~31) >> 3);
SetReg2DAGP( VIA_REG_SRCBASE, (srcBase & ~0x1f) >> 3);
SetReg2DAGP( VIA_REG_DSTBASE, (dstBase & ~0x1f) >> 3);
SetReg2DAGP( VIA_REG_PITCH, VIA_PITCH_ENABLE |
(srcPitch >> 3) | (((dstPitch) >> 3) << 16));
SetReg2DAGP( VIA_REG_SRCPOS, ((srcY << 16) | srcX));
SetReg2DAGP( VIA_REG_DSTPOS, ((dstY << 16) | dstX));
(srcPitch >> 3) | ((dstPitch >> 3) << 16));
SetReg2DAGP( VIA_REG_SRCPOS, srcX);
SetReg2DAGP( VIA_REG_DSTPOS, dstX);
SetReg2DAGP( VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
SetReg2DAGP( VIA_REG_GECMD, cmd);
SetReg2DAGP( 0x2C, 0x00000000);
@@ -192,7 +176,6 @@ static void viaFillBuffer(viaContextPtr vmesa,
offset, buffer->pitch,
offset, buffer->pitch,
w, h,
0, 0,
VIA_BLIT_FILL, pixel, mask);
}
}
@@ -204,7 +187,6 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
const GLuint colorMask = *((GLuint *)&ctx->Color.ColorMask);
int flag = 0;
GLuint i = 0;
GLuint clear_depth_mask = 0xf << 28;
@@ -212,12 +194,12 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
VIA_FLUSH_DMA(vmesa);
if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) {
if (mask & DD_FRONT_LEFT_BIT) {
flag |= VIA_FRONT;
mask &= ~DD_FRONT_LEFT_BIT;
}
if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) {
if (mask & DD_BACK_LEFT_BIT) {
flag |= VIA_BACK;
mask &= ~DD_BACK_LEFT_BIT;
}
@@ -239,9 +221,9 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
mask &= ~DD_STENCIL_BIT;
}
else {
fprintf(stderr, "XXX: Clear stencil writemask %x -- need triangles (or a ROP?)\n",
ctx->Stencil.WriteMask[0]);
/* Fixme - clear with triangles */
if (VIA_DEBUG)
fprintf(stderr, "XXX: Clear stencil writemask %x -- need triangles (or a ROP?)\n",
ctx->Stencil.WriteMask[0]);
}
}
}
@@ -293,11 +275,11 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
}
if (flag & VIA_FRONT) {
viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor, 0);
viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor, vmesa->ClearMask);
}
if (flag & VIA_BACK) {
viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor, 0); /* FIXME: masks */
viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor, vmesa->ClearMask);
}
if (flag & VIA_DEPTH) {
@@ -341,7 +323,7 @@ static void viaDoSwapBuffers(viaContextPtr vmesa,
src, back->pitch,
dest, front->pitch,
w, h,
0,0,VIA_BLIT_COPY, 0, 0);
VIA_BLIT_COPY, 0, 0);
}
}
@@ -513,11 +495,9 @@ static void via_emit_cliprect(viaContextPtr vmesa,
GLuint pitch = buffer->pitch;
GLuint offset = buffer->orig;
GLuint clipL = b->x1 - vmesa->drawX;
GLuint clipR = b->x2 - vmesa->drawX;
GLuint clipT = b->y1 - vmesa->drawY;
GLuint clipB = b->y2 - vmesa->drawY;
if (0)
fprintf(stderr, "emit cliprect for box %d,%d %d,%d\n", b->x1, b->y1, b->x2, b->y2);
vb[0] = HC_HEADER2;
vb[1] = (HC_ParaType_NotTex << 16);
@@ -526,8 +506,8 @@ static void via_emit_cliprect(viaContextPtr vmesa,
vb[3] = (HC_SubA_HClipLR << 24) | 0x0;
}
else {
vb[2] = (HC_SubA_HClipTB << 24) | (clipT << 12) | clipB;
vb[3] = (HC_SubA_HClipLR << 24) | (clipL << 12) | clipR;
vb[2] = (HC_SubA_HClipTB << 24) | (b->y1 << 12) | b->y2;
vb[3] = (HC_SubA_HClipLR << 24) | (b->x1 << 12) | b->x2;
}
vb[4] = ((HC_SubA_HDBBasL << 24) | (offset & 0xFFFFFF));
@@ -543,6 +523,11 @@ static int intersect_rect(drm_clip_rect_t *out,
drm_clip_rect_t *b)
{
*out = *a;
if (0)
fprintf(stderr, "intersect %d,%d %d,%d and %d,%d %d,%d\n",
a->x1, a->y1, a->x2, a->y2,
b->x1, b->y1, b->x2, b->y2);
if (b->x1 > out->x1) out->x1 = b->x1;
if (b->x2 < out->x2) out->x2 = b->x2;
@@ -575,6 +560,9 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
int i;
RING_VARS;
if (VIA_DEBUG)
fprintf(stderr, "%s\n", __FUNCTION__);
if (*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|vmesa->hHWContext) &&
*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) {
fprintf(stderr, "%s called without lock held\n", __FUNCTION__);
@@ -640,35 +628,42 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
dump_dma( vmesa );
if (flags & VIA_NO_CLIPRECTS) {
assert(vmesa->dmaCliprectAddr == 0);
if (0) fprintf(stderr, "%s VIA_NO_CLIPRECTS\n", __FUNCTION__);
assert(vmesa->dmaCliprectAddr == ~0);
fire_buffer( vmesa );
}
else if (!vmesa->dmaCliprectAddr) {
else if (vmesa->dmaCliprectAddr == ~0) {
/* Contains only state. Could just dump the packet?
*/
if (0) fprintf(stderr, "no dmaCliprectAddr\n");
if (0) fprintf(stderr, "%s: no dmaCliprectAddr\n", __FUNCTION__);
if (0) fire_buffer( vmesa );
}
else if (vmesa->numClipRects) {
int ret;
drm_clip_rect_t *pbox = vmesa->pClipRects;
if (0) fprintf(stderr, "%s: %d cliprects\n", __FUNCTION__, vmesa->numClipRects);
for (i = 0; i < vmesa->numClipRects; i++) {
if (vmesa->glCtx->Scissor.Enabled) {
drm_clip_rect_t b;
if (!intersect_rect(&b, &pbox[i], &vmesa->scissorRect))
continue;
via_emit_cliprect(vmesa, &b);
}
else {
via_emit_cliprect(vmesa, &pbox[i]);
}
ret = fire_buffer(vmesa);
if (ret)
drm_clip_rect_t b;
b.x1 = pbox[i].x1 - (vmesa->drawX + vmesa->drawXoff);
b.x2 = pbox[i].x2 - (vmesa->drawX + vmesa->drawXoff);
b.y1 = pbox[i].y1 - vmesa->drawY;
b.y2 = pbox[i].y2 - vmesa->drawY;
if (vmesa->glCtx->Scissor.Enabled &&
!intersect_rect(&b, &b, &vmesa->scissorRect))
continue;
b.x1 += vmesa->drawXoff;
b.x2 += vmesa->drawXoff;
via_emit_cliprect(vmesa, &b);
if (fire_buffer(vmesa) != 0)
goto done;
}
} else {
if (0) fprintf(stderr, "%s: no cliprects\n", __FUNCTION__);
UNLOCK_HARDWARE(vmesa);
sched_yield();
LOCK_HARDWARE(vmesa);
@@ -678,7 +673,7 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
/* Reset vmesa vars:
*/
vmesa->dmaLow = 0;
vmesa->dmaCliprectAddr = 0;
vmesa->dmaCliprectAddr = ~0;
vmesa->newEmitState = ~0;
}
@@ -752,6 +747,8 @@ GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int li
{
GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
if (0)
fprintf(stderr, "%s %04x 0x%x bytes\n", func, vmesa->dmaLow, bytes);
vmesa->dmaLow += bytes;
return start;
}
@@ -760,6 +757,9 @@ GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int li
GLuint *viaExtendPrimitive(viaContextPtr vmesa, int bytes)
{
if (0)
fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
assert(vmesa->dmaLastPrim);
if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
viaWrapPrimitive(vmesa);
@@ -767,6 +767,8 @@ GLuint *viaExtendPrimitive(viaContextPtr vmesa, int bytes)
{
GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
if (0)
fprintf(stderr, "%s %04x 0x%x bytes\n", __FUNCTION__, vmesa->dmaLow, bytes);
vmesa->dmaLow += bytes;
return start;
}

View File

@@ -38,7 +38,6 @@
#include "via_context.h"
#include "via_tris.h"
#include "via_state.h"
#include "via_vb.h"
#include "via_ioctl.h"
/*
@@ -52,7 +51,7 @@
#define HAVE_LINE_LOOP 1
#define HAVE_TRIANGLES 1
#define HAVE_TRI_STRIPS 1
#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */
#define HAVE_TRI_STRIP_1 0
#define HAVE_TRI_FANS 1
#define HAVE_POLYGONS 1
#define HAVE_QUADS 0
@@ -73,7 +72,7 @@
viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4)
#define EMIT_VERTS(ctx, j, nr, buf) \
via_emit_contiguous_verts(ctx, j, (j) + (nr), buf)
_tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf )
#define FLUSH() VIA_FINISH_PRIM( vmesa )
@@ -94,24 +93,18 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
struct vertex_buffer *VB = &tnl->vb;
GLuint i;
/* Don't handle clipping or indexed vertices.
*/
if (VB->ClipOrMask ||
vmesa->renderIndex != 0 ||
!via_fastvalidate_render( ctx, VB )) {
if (VIA_DEBUG) {
fprintf(stderr, "slow path\n");
fprintf(stderr, "ClipOrMask = %08x\n", VB->ClipOrMask);
fprintf(stderr, "renderIndex = %08x\n", vmesa->renderIndex);
fprintf(stderr, "Elts = %08x\n", (GLuint)VB->Elts);
}
return GL_TRUE;
}
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
vmesa->setupNewInputs = VERT_BIT_CLIP;
tnl->Driver.Render.Start(ctx);
if (VB->ClipOrMask ||
vmesa->renderIndex != 0 ||
!via_fastvalidate_render( ctx, VB )) {
tnl->Driver.Render.Finish(ctx);
return GL_TRUE;
}
tnl->clipspace.new_inputs |= VERT_BIT_POS;
for (i = 0; i < VB->PrimitiveCount; ++i) {
GLuint mode = VB->Primitive[i].mode;
GLuint start = VB->Primitive[i].start;
@@ -121,31 +114,14 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
}
tnl->Driver.Render.Finish(ctx);
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return GL_FALSE; /* finished the pipe */
}
static void via_check_fastrender(GLcontext *ctx, struct tnl_pipeline_stage *stage)
{
GLuint inputs = VERT_BIT_CLIP | VERT_BIT_COLOR0;
if (ctx->RenderMode == GL_RENDER) {
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
inputs |= VERT_BIT_COLOR1;
if (ctx->Texture.Unit[0]._ReallyEnabled)
inputs |= VERT_BIT_TEX0;
if (ctx->Texture.Unit[1]._ReallyEnabled)
inputs |= VERT_BIT_TEX1;
if (ctx->Fog.Enabled)
inputs |= VERT_BIT_FOG;
}
stage->inputs = inputs;
stage->inputs = TNL_CONTEXT(ctx)->render_inputs;
}

View File

@@ -36,7 +36,6 @@
#include "via_context.h"
#include "via_state.h"
#include "via_tex.h"
#include "via_vb.h"
#include "via_tris.h"
#include "via_ioctl.h"
@@ -615,7 +614,8 @@ static void viaScissor(GLcontext *ctx, GLint x, GLint y,
if (!vmesa->driDrawable)
return;
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
if (VIA_DEBUG)
fprintf(stderr, "%s %d,%d %dx%d, drawH %d\n", __FUNCTION__, x,y,w,h, vmesa->driDrawable->h);
if (ctx->Scissor.Enabled) {
VIA_FLUSH_DMA(vmesa); /* don't pipeline cliprect changes */
@@ -628,6 +628,19 @@ static void viaScissor(GLcontext *ctx, GLint x, GLint y,
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
}
static void viaEnable(GLcontext *ctx, GLenum cap, GLboolean state)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
switch (cap) {
case GL_SCISSOR_TEST:
VIA_FLUSH_DMA(vmesa);
break;
default:
break;
}
}
/* Fallback to swrast for select and feedback.
@@ -684,6 +697,26 @@ static void viaClearColor(GLcontext *ctx, const GLfloat color[4])
}
#define WRITEMASK_ALPHA_SHIFT 31
#define WRITEMASK_RED_SHIFT 30
#define WRITEMASK_GREEN_SHIFT 29
#define WRITEMASK_BLUE_SHIFT 28
static void viaColorMask(GLcontext *ctx,
GLboolean r, GLboolean g,
GLboolean b, GLboolean a)
{
viaContextPtr vmesa = VIA_CONTEXT( ctx );
if (VIA_DEBUG)
fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a);
vmesa->ClearMask = (((!r) << WRITEMASK_RED_SHIFT) |
((!g) << WRITEMASK_GREEN_SHIFT) |
((!b) << WRITEMASK_BLUE_SHIFT) |
((!a) << WRITEMASK_ALPHA_SHIFT));
}
/* =============================================================
*/
@@ -730,7 +763,7 @@ void viaInitState(GLcontext *ctx)
viaContextPtr vmesa = VIA_CONTEXT(ctx);
vmesa->regCmdA = HC_ACMD_HCmdA;
vmesa->regCmdB = HC_ACMD_HCmdB | HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z;
vmesa->regCmdB = HC_ACMD_HCmdB;
vmesa->regEnable = HC_HenCW_MASK;
/* Mesa should do this for us:
@@ -828,7 +861,7 @@ static void viaChooseTextureState(GLcontext *ctx)
FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, GL_TRUE);
return;
}
vmesa->regCmdB |= HC_HVPMSK_S | HC_HVPMSK_T | HC_HVPMSK_W | HC_HVPMSK_Cs;
vmesa->regEnable |= HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK;
switch (texObj->MinFilter) {
@@ -885,9 +918,6 @@ static void viaChooseTextureState(GLcontext *ctx)
viaTexCombineState( vmesa, texUnit0->_CurrentCombine, 0 );
}
else {
/* Should turn Cs off if actually no Cs */
}
if (texUnit1->_ReallyEnabled) {
struct gl_texture_object *texObj = texUnit1->_Current;
@@ -965,10 +995,6 @@ static void viaChooseTextureState(GLcontext *ctx)
}
}
else {
if (ctx->Fog.Enabled)
vmesa->regCmdB &= (~(HC_HVPMSK_S | HC_HVPMSK_T));
else
vmesa->regCmdB &= (~(HC_HVPMSK_S | HC_HVPMSK_T | HC_HVPMSK_W));
vmesa->regEnable &= (~(HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK));
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
@@ -1256,12 +1282,13 @@ static void viaChooseColorState(GLcontext *ctx)
vmesa->regHROP = HC_HROP_P;
vmesa->regHFBBMSKL = (*(GLuint *)&ctx->Color.ColorMask[0]) & 0xFFFFFF;
vmesa->regHROP |= ((*(GLuint *)&ctx->Color.ColorMask[0]) >> 24) & 0xFF;
vmesa->regHROP |= ctx->Color.ColorMask[3];
if ((GLuint)((GLuint *)&ctx->Color.ColorMask[0]) & 0xFF000000)
if (ctx->Color.ColorMask[3])
vmesa->regEnable |= HC_HenAW_MASK;
else
vmesa->regEnable &= (~HC_HenAW_MASK);
vmesa->regEnable &= ~HC_HenAW_MASK;
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
@@ -1272,7 +1299,6 @@ static void viaChooseFogState(GLcontext *ctx)
if (ctx->Fog.Enabled) {
GLubyte r, g, b, a;
vmesa->regCmdB |= (HC_HVPMSK_Cd | HC_HVPMSK_Cs | HC_HVPMSK_W);
vmesa->regEnable |= HC_HenFOG_MASK;
/* Use fog equation 0 (OpenGL's default) & local fog.
@@ -1287,10 +1313,6 @@ static void viaChooseFogState(GLcontext *ctx)
vmesa->regHFogCH = a;
}
else {
if (!ctx->Texture._EnabledUnits) {
vmesa->regCmdB &= ~ HC_HVPMSK_W;
vmesa->regCmdB &= ~ HC_HVPMSK_Cs;
}
vmesa->regEnable &= ~HC_HenFOG_MASK;
}
}
@@ -1299,7 +1321,6 @@ static void viaChooseDepthState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (ctx->Depth.Test) {
vmesa->regCmdB |= HC_HVPMSK_Z;
vmesa->regEnable |= HC_HenZT_MASK;
if (ctx->Depth.Mask)
vmesa->regEnable |= HC_HenZW_MASK;
@@ -1309,10 +1330,6 @@ static void viaChooseDepthState(GLcontext *ctx)
}
else {
/* Still need to send parameter Z.
*/
vmesa->regCmdB |= HC_HVPMSK_Z;
vmesa->regEnable &= ~HC_HenZT_MASK;
/*=* [DBG] racer : can't display cars in car selection menu *=*/
@@ -1330,11 +1347,9 @@ static void viaChooseLightState(GLcontext *ctx)
if (ctx->Light.ShadeModel == GL_SMOOTH) {
vmesa->regCmdA |= HC_HShading_Gouraud;
vmesa->regCmdB |= HC_HVPMSK_Cd;
}
else {
vmesa->regCmdA &= ~HC_HShading_Gouraud;
vmesa->regCmdB |= HC_HVPMSK_Cd;
}
}
@@ -1515,17 +1530,6 @@ static void viaChooseTriangle(GLcontext *ctx)
void viaValidateState( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0];
struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1];
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (texUnit0->_ReallyEnabled || texUnit1->_ReallyEnabled || ctx->Fog.Enabled) {
vmesa->regCmdB |= HC_HVPMSK_Cs;
}
else {
vmesa->regCmdB &= ~ HC_HVPMSK_Cs;
}
if (vmesa->newState & _NEW_TEXTURE) {
viaChooseTextureState(ctx);
@@ -1555,10 +1559,13 @@ void viaValidateState( GLcontext *ctx )
if (vmesa->newState & _NEW_STENCIL)
viaChooseStencilState(ctx);
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
vmesa->regEnable |= HC_HenCS_MASK;
else
vmesa->regEnable &= ~HC_HenCS_MASK;
vmesa->newEmitState |= vmesa->newState;
vmesa->newState = 0;
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
static void viaInvalidateState(GLcontext *ctx, GLuint newState)
@@ -1585,11 +1592,13 @@ void viaInitStateFuncs(GLcontext *ctx)
ctx->Driver.BlendEquationSeparate = viaBlendEquationSeparate;
ctx->Driver.BlendFuncSeparate = viaBlendFuncSeparate;
ctx->Driver.ClearColor = viaClearColor;
ctx->Driver.ColorMask = viaColorMask;
ctx->Driver.DrawBuffer = viaDrawBuffer;
ctx->Driver.RenderMode = viaRenderMode;
ctx->Driver.Scissor = viaScissor;
ctx->Driver.DepthRange = viaDepthRange;
ctx->Driver.Viewport = viaViewport;
ctx->Driver.Enable = viaEnable;
/* Pixel path fallbacks.
*/

View File

@@ -42,7 +42,6 @@
#include "via_context.h"
#include "via_state.h"
#include "via_tex.h"
#include "via_vb.h"
#include "via_tris.h"
#include "via_ioctl.h"

View File

@@ -41,14 +41,13 @@
#include "via_tris.h"
#include "via_state.h"
#include "via_span.h"
#include "via_vb.h"
#include "via_ioctl.h"
/***********************************************************************
* Emit primitives as inline vertices *
***********************************************************************/
#if 0
#if 1
#define COPY_DWORDS(vb, vertsize, v) \
do { \
int j; \
@@ -69,58 +68,108 @@
} while (0)
#endif
static void __inline__ via_draw_triangle(viaContextPtr vmesa,
viaVertexPtr v0,
viaVertexPtr v1,
viaVertexPtr v2)
static void via_draw_triangle(viaContextPtr vmesa,
viaVertexPtr v0,
viaVertexPtr v1,
viaVertexPtr v2)
{
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 3 * 4 * vertsize);
/* fprintf(stderr, "%s: %p %p %p\n", __FUNCTION__, v0, v1, v2); */
COPY_DWORDS(vb, vertsize, v0);
COPY_DWORDS(vb, vertsize, v1);
COPY_DWORDS(vb, vertsize, v2);
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 3 * 4 * vertsize);
COPY_DWORDS(vb, vertsize, v0);
COPY_DWORDS(vb, vertsize, v1);
COPY_DWORDS(vb, vertsize, v2);
}
static void __inline__ via_draw_quad(viaContextPtr vmesa,
viaVertexPtr v0,
viaVertexPtr v1,
viaVertexPtr v2,
viaVertexPtr v3)
static void via_draw_quad(viaContextPtr vmesa,
viaVertexPtr v0,
viaVertexPtr v1,
viaVertexPtr v2,
viaVertexPtr v3)
{
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 6 * 4 * vertsize);
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 6 * 4 * vertsize);
/* fprintf(stderr, "%s: %p %p %p %p\n", __FUNCTION__, v0, v1, v2, v3); */
COPY_DWORDS(vb, vertsize, v0);
COPY_DWORDS(vb, vertsize, v1);
COPY_DWORDS(vb, vertsize, v3);
COPY_DWORDS(vb, vertsize, v1);
COPY_DWORDS(vb, vertsize, v2);
COPY_DWORDS(vb, vertsize, v3);
COPY_DWORDS(vb, vertsize, v0);
COPY_DWORDS(vb, vertsize, v1);
COPY_DWORDS(vb, vertsize, v3);
COPY_DWORDS(vb, vertsize, v1);
COPY_DWORDS(vb, vertsize, v2);
COPY_DWORDS(vb, vertsize, v3);
}
static __inline__ void via_draw_line(viaContextPtr vmesa,
viaVertexPtr v0,
viaVertexPtr v1)
static void via_draw_line(viaContextPtr vmesa,
viaVertexPtr v0,
viaVertexPtr v1)
{
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 2 * 4 * vertsize);
COPY_DWORDS(vb, vertsize, v0);
COPY_DWORDS(vb, vertsize, v1);
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 2 * 4 * vertsize);
COPY_DWORDS(vb, vertsize, v0);
COPY_DWORDS(vb, vertsize, v1);
}
static __inline__ void via_draw_point(viaContextPtr vmesa,
viaVertexPtr v0)
static void via_draw_point(viaContextPtr vmesa,
viaVertexPtr v0)
{
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize);
COPY_DWORDS(vb, vertsize, v0);
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize);
COPY_DWORDS(vb, vertsize, v0);
}
/* Fallback drawing functions for the ptex hack.
*/
#define PTEX_VERTEX( tmp, vertex_size, v) \
do { \
GLuint j; \
GLfloat rhw = 1.0 / v->f[vertex_size]; \
for ( j = 0 ; j < vertex_size ; j++ ) \
tmp.f[j] = v->f[j]; \
tmp.f[3] *= v->f[vertex_size]; \
tmp.f[vertex_size-2] *= rhw; \
tmp.f[vertex_size-1] *= rhw; \
} while (0)
static void via_ptex_tri (viaContextPtr vmesa,
viaVertexPtr v0,
viaVertexPtr v1,
viaVertexPtr v2)
{
GLuint vertsize = vmesa->hwVertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 3*4*vertsize);
viaVertex tmp;
PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp);
PTEX_VERTEX(tmp, vertsize, v2); COPY_DWORDS(vb, vertsize, &tmp);
}
static void via_ptex_line (viaContextPtr vmesa,
viaVertexPtr v0,
viaVertexPtr v1)
{
GLuint vertsize = vmesa->hwVertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 2*4*vertsize);
viaVertex tmp;
PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp);
}
static void via_ptex_point (viaContextPtr vmesa,
viaVertexPtr v0)
{
GLuint vertsize = vmesa->hwVertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, 1*4*vertsize);
viaVertex tmp;
PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
}
/***********************************************************************
@@ -129,7 +178,6 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
#define TRI(a, b, c) \
do { \
if (VIA_DEBUG) fprintf(stderr, "hw TRI\n"); \
if (DO_FALLBACK) \
vmesa->drawTri(vmesa, a, b, c); \
else \
@@ -138,7 +186,6 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
#define QUAD(a, b, c, d) \
do { \
if (VIA_DEBUG) fprintf(stderr, "hw QUAD\n");\
if (DO_FALLBACK) { \
vmesa->drawTri(vmesa, a, b, d); \
vmesa->drawTri(vmesa, b, c, d); \
@@ -149,7 +196,6 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
#define LINE(v0, v1) \
do { \
if(VIA_DEBUG) fprintf(stderr, "hw LINE\n");\
if (DO_FALLBACK) \
vmesa->drawLine(vmesa, v0, v1); \
else \
@@ -158,7 +204,6 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
#define POINT(v0) \
do { \
if (VIA_DEBUG) fprintf(stderr, "hw POINT\n");\
if (DO_FALLBACK) \
vmesa->drawPoint(vmesa, v0); \
else \
@@ -222,7 +267,7 @@ static struct {
} while (0)
#define DEPTH_SCALE (1.0 / 0xffff)
#define DEPTH_SCALE vmesa->polygon_offset_scale
#define UNFILLED_TRI unfilled_tri
#define UNFILLED_QUAD unfilled_quad
#define VERT_X(_v) _v->v.x
@@ -244,7 +289,7 @@ do { \
#define VERT_SET_SPEC( v0, c ) \
do { \
if (havespec) { \
if (specoffset) { \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \
@@ -252,7 +297,7 @@ do { \
} while (0)
#define VERT_COPY_SPEC( v0, v1 ) \
do { \
if (havespec) { \
if (specoffset) { \
v0->v.specular.red = v1->v.specular.red; \
v0->v.specular.green = v1->v.specular.green; \
v0->v.specular.blue = v1->v.specular.blue; \
@@ -262,16 +307,16 @@ do { \
#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset]
#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
#define LOCAL_VARS(n) \
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
GLuint color[n], spec[n]; \
GLuint coloroffset = (vmesa->vertexSize == 4 ? 3 : 4); \
GLboolean havespec = (vmesa->vertexSize > 4); \
(void)color; (void)spec; (void)coloroffset; (void)havespec;
GLuint coloroffset = vmesa->coloroffset; \
GLuint specoffset = vmesa->specoffset; \
(void)color; (void)spec; (void)coloroffset; (void)specoffset;
/***********************************************************************
@@ -409,9 +454,9 @@ via_fallback_tri(viaContextPtr vmesa,
{
GLcontext *ctx = vmesa->glCtx;
SWvertex v[3];
via_translate_vertex(ctx, v0, &v[0]);
via_translate_vertex(ctx, v1, &v[1]);
via_translate_vertex(ctx, v2, &v[2]);
_swsetup_Translate(ctx, v0, &v[0]);
_swsetup_Translate(ctx, v1, &v[1]);
_swsetup_Translate(ctx, v2, &v[2]);
viaSpanRenderStart( ctx );
_swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
viaSpanRenderFinish( ctx );
@@ -425,8 +470,8 @@ via_fallback_line(viaContextPtr vmesa,
{
GLcontext *ctx = vmesa->glCtx;
SWvertex v[2];
via_translate_vertex(ctx, v0, &v[0]);
via_translate_vertex(ctx, v1, &v[1]);
_swsetup_Translate(ctx, v0, &v[0]);
_swsetup_Translate(ctx, v1, &v[1]);
viaSpanRenderStart( ctx );
_swrast_Line(ctx, &v[0], &v[1]);
viaSpanRenderFinish( ctx );
@@ -439,7 +484,7 @@ via_fallback_point(viaContextPtr vmesa,
{
GLcontext *ctx = vmesa->glCtx;
SWvertex v[1];
via_translate_vertex(ctx, v0, &v[0]);
_swsetup_Translate(ctx, v0, &v[0]);
viaSpanRenderStart( ctx );
_swrast_Point(ctx, &v[0]);
viaSpanRenderFinish( ctx );
@@ -540,6 +585,13 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
#define _VIA_NEW_VERTEX (_NEW_TEXTURE | \
_DD_NEW_SEPARATE_SPECULAR | \
_DD_NEW_TRI_UNFILLED | \
_DD_NEW_TRI_LIGHT_TWOSIDE | \
_NEW_FOG)
#define _VIA_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
_DD_NEW_TRI_UNFILLED | \
_DD_NEW_TRI_LIGHT_TWOSIDE | \
@@ -556,71 +608,190 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
void viaChooseRenderState(GLcontext *ctx)
static void viaChooseRenderState(GLcontext *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
viaContextPtr vmesa = VIA_CONTEXT(ctx);
GLuint flags = ctx->_TriangleCaps;
GLuint index = 0;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (VIA_DEBUG) fprintf(stderr, "_TriangleCaps = %x\n", flags);
if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
if (flags & ANY_RASTER_FLAGS) {
if (flags & DD_TRI_LIGHT_TWOSIDE) index |= VIA_TWOSIDE_BIT;
if (flags & DD_TRI_OFFSET) index |= VIA_OFFSET_BIT;
if (flags & DD_TRI_UNFILLED) index |= VIA_UNFILLED_BIT;
}
TNLcontext *tnl = TNL_CONTEXT(ctx);
viaContextPtr vmesa = VIA_CONTEXT(ctx);
GLuint flags = ctx->_TriangleCaps;
GLuint index = 0;
vmesa->drawPoint = via_draw_point;
vmesa->drawLine = via_draw_line;
vmesa->drawTri = via_draw_triangle;
if (vmesa->ptexHack) {
vmesa->drawPoint = via_ptex_point;
vmesa->drawLine = via_ptex_line;
vmesa->drawTri = via_ptex_tri;
index |= VIA_FALLBACK_BIT;
}
else {
vmesa->drawPoint = via_draw_point;
vmesa->drawLine = via_draw_line;
vmesa->drawTri = via_draw_triangle;
}
/* Hook in fallbacks for specific primitives.
*/
if (flags & ANY_FALLBACK_FLAGS) {
if (flags & POINT_FALLBACK)
vmesa->drawPoint = via_fallback_point;
if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
if (flags & DD_TRI_LIGHT_TWOSIDE) index |= VIA_TWOSIDE_BIT;
if (flags & DD_TRI_OFFSET) index |= VIA_OFFSET_BIT;
if (flags & DD_TRI_UNFILLED) index |= VIA_UNFILLED_BIT;
if (flags & ANY_FALLBACK_FLAGS) index |= VIA_FALLBACK_BIT;
if (flags & LINE_FALLBACK)
vmesa->drawLine = via_fallback_line;
/* Hook in fallbacks for specific primitives.
*/
if (flags & POINT_FALLBACK)
vmesa->drawPoint = via_fallback_point;
if (flags & LINE_FALLBACK)
vmesa->drawLine = via_fallback_line;
if (flags & TRI_FALLBACK)
vmesa->drawTri = via_fallback_tri;
if (flags & TRI_FALLBACK)
vmesa->drawTri = via_fallback_tri;
}
index |= VIA_FALLBACK_BIT;
}
}
if (VIA_DEBUG) {
fprintf(stderr, "index = %x\n", index);
fprintf(stderr, "renderIndex = %x\n", vmesa->renderIndex);
}
if (vmesa->renderIndex != index) {
vmesa->renderIndex = index;
if (vmesa->renderIndex != index) {
vmesa->renderIndex = index;
tnl->Driver.Render.Points = rast_tab[index].points;
tnl->Driver.Render.Line = rast_tab[index].line;
tnl->Driver.Render.Triangle = rast_tab[index].triangle;
tnl->Driver.Render.Points = rast_tab[index].points;
tnl->Driver.Render.Line = rast_tab[index].line;
tnl->Driver.Render.Triangle = rast_tab[index].triangle;
tnl->Driver.Render.Quad = rast_tab[index].quad;
tnl->Driver.Render.Quad = rast_tab[index].quad;
if (index == 0) {
tnl->Driver.Render.PrimTabVerts = via_fastrender_tab_verts;
tnl->Driver.Render.PrimTabElts = via_fastrender_tab_elts;
tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
tnl->Driver.Render.ClippedPolygon = viaFastRenderClippedPoly;
}
else {
tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
tnl->Driver.Render.ClippedLine = viaRenderClippedLine;
tnl->Driver.Render.ClippedPolygon = viaRenderClippedPoly;
}
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
if (index == 0) {
tnl->Driver.Render.PrimTabVerts = via_fastrender_tab_verts;
tnl->Driver.Render.PrimTabElts = via_fastrender_tab_elts;
tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
tnl->Driver.Render.ClippedPolygon = viaFastRenderClippedPoly;
}
else {
tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
tnl->Driver.Render.ClippedLine = viaRenderClippedLine;
tnl->Driver.Render.ClippedPolygon = viaRenderClippedPoly;
}
}
}
#define VIA_EMIT_TEX1 0x01
#define VIA_EMIT_TEX0 0x02
#define VIA_EMIT_PTEX0 0x04
#define VIA_EMIT_RGBA 0x08
#define VIA_EMIT_SPEC 0x10
#define VIA_EMIT_FOG 0x20
#define VIA_EMIT_W 0x40
#define EMIT_ATTR( ATTR, STYLE, INDEX, REGB ) \
do { \
vmesa->vertex_attrs[vmesa->vertex_attr_count].attrib = (ATTR); \
vmesa->vertex_attrs[vmesa->vertex_attr_count].format = (STYLE); \
vmesa->vertex_attr_count++; \
setupIndex |= (INDEX); \
regCmdB |= (REGB); \
} while (0)
#define EMIT_PAD( N ) \
do { \
vmesa->vertex_attrs[vmesa->vertex_attr_count].attrib = 0; \
vmesa->vertex_attrs[vmesa->vertex_attr_count].format = EMIT_PAD; \
vmesa->vertex_attrs[vmesa->vertex_attr_count].offset = (N); \
vmesa->vertex_attr_count++; \
} while (0)
static void viaChooseVertexState( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint index = tnl->render_inputs;
GLuint regCmdB = HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z;
GLuint setupIndex = 0;
vmesa->vertex_attr_count = 0;
/* EMIT_ATTR's must be in order as they tell t_vertex.c how to
* build up a hardware vertex.
*/
if (index & (_TNL_BITS_TEX_ANY|_TNL_BIT_FOG)) {
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VIA_EMIT_W, HC_HVPMSK_W );
vmesa->coloroffset = 4;
}
else {
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 );
vmesa->coloroffset = 3;
}
/* t_context.c always includes a diffuse color */
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VIA_EMIT_RGBA, HC_HVPMSK_Cd );
vmesa->specoffset = 0;
if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
if ((index & _TNL_BIT_COLOR1)) {
vmesa->specoffset = vmesa->coloroffset + 1;
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VIA_EMIT_SPEC, HC_HVPMSK_Cs );
}
else
EMIT_PAD( 3 );
if ((index & _TNL_BIT_FOG))
EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VIA_EMIT_FOG, HC_HVPMSK_Cs );
else
EMIT_PAD( 1 );
}
if (index & _TNL_BIT_TEX(0)) {
if (vmesa->ptexHack)
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, VIA_EMIT_PTEX0, (HC_HVPMSK_S | HC_HVPMSK_T) );
else
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, VIA_EMIT_TEX0, (HC_HVPMSK_S | HC_HVPMSK_T) );
}
if (index & _TNL_BIT_TEX(1)) {
EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, VIA_EMIT_TEX1, 0 ); /* how does the hardware find out about this? */
}
if (setupIndex != vmesa->setupIndex) {
vmesa->vertexSize = _tnl_install_attrs( ctx,
vmesa->vertex_attrs,
vmesa->vertex_attr_count,
vmesa->ViewportMatrix.m, 0 );
vmesa->vertexSize >>= 2;
vmesa->setupIndex = setupIndex;
vmesa->regCmdB &= ~HC_HVPMSK_MASK;
vmesa->regCmdB |= regCmdB;
if (vmesa->ptexHack)
vmesa->hwVertexSize = vmesa->vertexSize - 1;
else
vmesa->hwVertexSize = vmesa->vertexSize;
}
}
/* Check if projective texture coordinates are used and if we can fake
* them. Fallback to swrast we can't. Returns GL_TRUE if projective
* texture coordinates must be faked, GL_FALSE otherwise.
*/
static GLboolean viaCheckPTexHack( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
GLuint index = tnl->render_inputs;
GLboolean fallback = GL_FALSE;
GLboolean ptexHack = GL_FALSE;
if (index & _TNL_BIT_TEX(0) && VB->TexCoordPtr[0]->size == 4) {
if ((index & _TNL_BITS_TEX_ANY) == _TNL_BIT_TEX(0))
ptexHack = GL_TRUE;
else
fallback = GL_TRUE;
}
if ((index & _TNL_BIT_TEX(1)) && VB->TexCoordPtr[1]->size == 4)
fallback = GL_TRUE;
FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_PROJ_TEXTURE, fallback);
return ptexHack;
}
@@ -628,27 +799,40 @@ void viaChooseRenderState(GLcontext *ctx)
/* High level hooks for t_vb_render.c */
/**********************************************************************/
static void viaRunPipeline(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (vmesa->newState) {
viaValidateState( ctx );
if (!vmesa->Fallback) {
viaChooseVertexState(ctx);
viaChooseRenderState(ctx);
}
}
_tnl_run_pipeline(ctx);
}
static void viaRenderStart(GLcontext *ctx)
{
/* Check for projective texturing. Make sure all texcoord
* pointers point to something. (fix in mesa?)
*/
viaCheckTexSizes(ctx);
viaContextPtr vmesa = VIA_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
{
GLboolean ptexHack = viaCheckPTexHack( ctx );
if (ptexHack != vmesa->ptexHack) {
vmesa->ptexHack = ptexHack;
vmesa->newRenderState |= _VIA_NEW_RENDERSTATE;
}
}
if (vmesa->newState) {
vmesa->newRenderState |= vmesa->newState;
viaValidateState( ctx );
}
if (vmesa->Fallback) {
tnl->Driver.Render.Start(ctx);
return;
}
if (vmesa->newRenderState) {
viaChooseVertexState(ctx);
viaChooseRenderState(ctx);
vmesa->newRenderState = 0;
}
/* Important:
*/
VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
}
static void viaRenderFinish(GLcontext *ctx)
@@ -745,9 +929,8 @@ void viaRasterPrimitive(GLcontext *ctx,
/* assert((vmesa->dmaLow & 0x4) == 0); */
if (vmesa->dmaCliprectAddr == 0) {
if (vmesa->dmaCliprectAddr == ~0) {
if (VIA_DEBUG) fprintf(stderr, "reserve cliprect space at %x\n", vmesa->dmaLow);
assert(vmesa->dmaLow);
vmesa->dmaCliprectAddr = vmesa->dmaLow;
BEGIN_RING(8);
OUT_RING( HC_HEADER2 );
@@ -790,9 +973,11 @@ static void viaRenderPrimitive( GLcontext *ctx, GLuint prim )
void viaFinishPrimitive(viaContextPtr vmesa)
{
if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__);
if (VIA_DEBUG)
fprintf(stderr, "%s\n", __FUNCTION__);
if (!vmesa->dmaLastPrim) {
if (!vmesa->dmaLastPrim || vmesa->dmaCliprectAddr == ~0) {
assert(0);
}
else if (vmesa->dmaLow != vmesa->dmaLastPrim) {
GLuint cmdA = vmesa->regCmdA_End | HC_HPLEND_MASK | HC_HPMValidN_MASK | HC_HE3Fire_MASK;
@@ -818,6 +1003,9 @@ void viaFinishPrimitive(viaContextPtr vmesa)
viaFlushDma( vmesa );
}
else {
if (VIA_DEBUG)
fprintf(stderr, "remove empty primitive\n");
/* Remove the primitive header:
*/
vmesa->dmaLastPrim = 0;
@@ -827,7 +1015,7 @@ void viaFinishPrimitive(viaContextPtr vmesa)
*/
if (vmesa->dmaCliprectAddr == vmesa->dmaLow - 8 * sizeof(GLuint)) {
vmesa->dmaLow -= 8 * sizeof(GLuint);
vmesa->dmaCliprectAddr = 0;
vmesa->dmaCliprectAddr = ~0;
}
}
@@ -853,7 +1041,6 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
if (mode) {
vmesa->Fallback |= bit;
if (oldfallback == 0) {
if (VIA_DEBUG) fprintf(stderr, "ENTER FALLBACK\n");
VIA_FLUSH_DMA(vmesa);
_swsetup_Wakeup(ctx);
vmesa->renderIndex = ~0;
@@ -862,15 +1049,26 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
else {
vmesa->Fallback &= ~bit;
if (oldfallback == bit) {
if (VIA_DEBUG) fprintf(stderr, "LEAVE FALLBACK\n");
_swrast_flush( ctx );
tnl->Driver.Render.Start = viaRenderStart;
tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
tnl->Driver.Render.Finish = viaRenderFinish;
tnl->Driver.Render.BuildVertices = viaBuildVertices;
tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
tnl->Driver.Render.CopyPV = _tnl_copy_pv;
tnl->Driver.Render.Interp = _tnl_interp;
_tnl_invalidate_vertex_state( ctx, ~0 );
_tnl_invalidate_vertices( ctx, ~0 );
_tnl_install_attrs( ctx,
vmesa->vertex_attrs,
vmesa->vertex_attr_count,
vmesa->ViewportMatrix.m, 0 );
vmesa->newState |= (_VIA_NEW_RENDERSTATE|_VIA_NEW_VERTEX);
}
}
}
}
@@ -881,6 +1079,7 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
void viaInitTriFuncs(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
static int firsttime = 1;
@@ -889,10 +1088,18 @@ void viaInitTriFuncs(GLcontext *ctx)
firsttime = 0;
}
tnl->Driver.RunPipeline = viaRunPipeline;
tnl->Driver.RunPipeline = _tnl_run_pipeline;
tnl->Driver.Render.Start = viaRenderStart;
tnl->Driver.Render.Finish = viaRenderFinish;
tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
tnl->Driver.Render.BuildVertices = viaBuildVertices;
tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
tnl->Driver.Render.CopyPV = _tnl_copy_pv;
tnl->Driver.Render.Interp = _tnl_interp;
_tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
(6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) );
vmesa->verts = (char *)tnl->clipspace.vertex_buf;
}

View File

@@ -1,380 +0,0 @@
/*
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2003 S3 Graphics, 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, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS 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.
*/
#include "glheader.h"
#include "mtypes.h"
#include "imports.h"
#include "macros.h"
#include "colormac.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/t_context.h"
#include "via_context.h"
#include "via_vb.h"
#include "via_ioctl.h"
#include "via_tris.h"
#include "via_state.h"
static struct {
void (*emit)(GLcontext *, GLuint, GLuint, void *, GLuint);
tnl_interp_func interp;
tnl_copy_pv_func copy_pv;
GLboolean (*check_tex_sizes)(GLcontext *ctx);
GLuint vertex_size;
GLuint vertex_format;
} setup_tab[VIA_MAX_SETUP];
#define TINY_VERTEX_FORMAT 1
#define NOTEX_VERTEX_FORMAT 2
#define TEX0_VERTEX_FORMAT 3
#define TEX1_VERTEX_FORMAT 4
#define PROJ_TEX1_VERTEX_FORMAT 0
#define TEX2_VERTEX_FORMAT 0
#define TEX3_VERTEX_FORMAT 0
#define PROJ_TEX3_VERTEX_FORMAT 0
#define DO_XYZW (IND & VIA_XYZW_BIT)
#define DO_RGBA (IND & VIA_RGBA_BIT)
#define DO_SPEC (IND & VIA_SPEC_BIT)
#define DO_FOG (IND & VIA_FOG_BIT)
#define DO_TEX0 (IND & VIA_TEX0_BIT)
#define DO_TEX1 (IND & VIA_TEX1_BIT)
#define DO_TEX2 0
#define DO_TEX3 0
#define DO_PTEX (IND & VIA_PTEX_BIT)
#define VERTEX viaVertex
#define VERTEX_COLOR via_color_t
#define GET_VIEWPORT_MAT() VIA_CONTEXT(ctx)->ViewportMatrix.m
#define GET_TEXSOURCE(n) n
#define GET_VERTEX_FORMAT() VIA_CONTEXT(ctx)->vertexFormat
#define GET_VERTEX_SIZE() VIA_CONTEXT(ctx)->vertexSize * sizeof(GLuint)
#define GET_VERTEX_STORE() VIA_CONTEXT(ctx)->verts
#define INVALIDATE_STORED_VERTICES()
#define HAVE_HW_VIEWPORT 0
#define HAVE_HW_DIVIDE 0
#define HAVE_RGBA_COLOR 0
#define HAVE_TINY_VERTICES 1
#define HAVE_NOTEX_VERTICES 1
#define HAVE_TEX0_VERTICES 1
#define HAVE_TEX1_VERTICES 1
#define HAVE_TEX2_VERTICES 0
#define HAVE_TEX3_VERTICES 0
#define HAVE_PTEX_VERTICES 0
#define UNVIEWPORT_VARS \
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
GLfloat h = vmesa->driDrawable->h, depth_max = vmesa->depth_max, xoff = vmesa->drawXoff;
#define UNVIEWPORT_X(x) x - (SUBPIXEL_X + xoff)
#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y
#define UNVIEWPORT_Z(z) z * (float)depth_max
#define PTEX_FALLBACK() FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_TEXTURE, 1)
#define INTERP_VERTEX setup_tab[VIA_CONTEXT(ctx)->setupIndex].interp
#define COPY_PV_VERTEX setup_tab[VIA_CONTEXT(ctx)->setupIndex].copy_pv
/***********************************************************************
* Generate pv-copying and translation functions *
***********************************************************************/
#define TAG(x) via_##x
#include "tnl_dd/t_dd_vb.c"
/***********************************************************************
* Generate vertex emit and interp functions *
***********************************************************************/
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT)
#define TAG(x) x##_wg
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT)
#define TAG(x) x##_wgs
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT)
#define TAG(x) x##_wgt0
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_TEX1_BIT)
#define TAG(x) x##_wgt0t1
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_PTEX_BIT)
#define TAG(x) x##_wgpt0
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_TEX1_BIT |\
VIA_PTEX_BIT)
#define TAG(x) x##_wgpt0t1
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT)
#define TAG(x) x##_wgst0
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
VIA_TEX1_BIT)
#define TAG(x) x##_wgst0t1
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
VIA_PTEX_BIT)
#define TAG(x) x##_wgspt0
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
VIA_TEX1_BIT | VIA_PTEX_BIT)
#define TAG(x) x##_wgspt0t1
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT)
#define TAG(x) x##_wgf
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT)
#define TAG(x) x##_wgfs
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT)
#define TAG(x) x##_wgft0
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
VIA_TEX1_BIT)
#define TAG(x) x##_wgft0t1
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
VIA_PTEX_BIT)
#define TAG(x) x##_wgfpt0
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
VIA_TEX1_BIT | VIA_PTEX_BIT)
#define TAG(x) x##_wgfpt0t1
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
VIA_TEX0_BIT)
#define TAG(x) x##_wgfst0
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
VIA_TEX0_BIT | VIA_TEX1_BIT)
#define TAG(x) x##_wgfst0t1
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
VIA_TEX0_BIT | VIA_PTEX_BIT)
#define TAG(x) x##_wgfspt0
#include "tnl_dd/t_dd_vbtmp.h"
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
VIA_TEX0_BIT | VIA_TEX1_BIT | VIA_PTEX_BIT)
#define TAG(x) x##_wgfspt0t1
#include "tnl_dd/t_dd_vbtmp.h"
static void init_setup_tab(void) {
init_wg();
init_wgs();
init_wgt0();
init_wgt0t1();
init_wgpt0();
init_wgpt0t1();
init_wgst0();
init_wgst0t1();
init_wgspt0();
init_wgspt0t1();
init_wgf();
init_wgfs();
init_wgft0();
init_wgft0t1();
init_wgfpt0();
init_wgfpt0t1();
init_wgfst0();
init_wgfst0t1();
init_wgfspt0();
init_wgfspt0t1();
}
void viaPrintSetupFlags(char *msg, GLuint flags) {
if (VIA_DEBUG) fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
msg,
(int)flags,
(flags & VIA_XYZW_BIT) ? " xyzw," : "",
(flags & VIA_RGBA_BIT) ? " rgba," : "",
(flags & VIA_SPEC_BIT) ? " spec," : "",
(flags & VIA_FOG_BIT) ? " fog," : "",
(flags & VIA_TEX0_BIT) ? " tex-0," : "",
(flags & VIA_TEX1_BIT) ? " tex-1," : "");
}
void viaCheckTexSizes(GLcontext *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (!setup_tab[vmesa->setupIndex].check_tex_sizes(ctx)) {
/* Invalidate stored verts
*/
vmesa->setupNewInputs = ~0;
vmesa->setupIndex |= VIA_PTEX_BIT;
if (!vmesa->Fallback &&
!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
tnl->Driver.Render.Interp = setup_tab[vmesa->setupIndex].interp;
tnl->Driver.Render.CopyPV = setup_tab[vmesa->setupIndex].copy_pv;
}
if (vmesa->Fallback)
tnl->Driver.Render.Start(ctx);
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
void viaBuildVertices(GLcontext *ctx,
GLuint start,
GLuint count,
GLuint newinputs)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
GLuint stride = vmesa->vertexSize * sizeof(GLuint);
GLubyte *v = (GLubyte *)vmesa->verts + start * stride;
newinputs |= vmesa->setupNewInputs;
vmesa->setupNewInputs = 0;
if (!newinputs)
return;
if (newinputs & VERT_BIT_POS) {
setup_tab[vmesa->setupIndex].emit(ctx, start, count, v, stride);
}
else {
GLuint ind = 0;
if (newinputs & VERT_BIT_COLOR0)
ind |= VIA_RGBA_BIT;
if (newinputs & VERT_BIT_COLOR1)
ind |= VIA_SPEC_BIT;
if (newinputs & VERT_BIT_TEX0)
ind |= VIA_TEX0_BIT;
if (newinputs & VERT_BIT_TEX1)
ind |= VIA_TEX1_BIT;
if (newinputs & VERT_BIT_FOG)
ind |= VIA_FOG_BIT;
if (vmesa->setupIndex & VIA_PTEX_BIT)
ind = ~0;
ind &= vmesa->setupIndex;
ind |= VIA_XYZW_BIT;
if (ind) {
setup_tab[ind].emit(ctx, start, count, v, stride);
}
}
}
void viaChooseVertexState(GLcontext *ctx) {
TNLcontext *tnl = TNL_CONTEXT(ctx);
viaContextPtr vmesa = VIA_CONTEXT(ctx);
GLuint ind = VIA_XYZW_BIT | VIA_RGBA_BIT;
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
ind |= VIA_SPEC_BIT;
if (ctx->Fog.Enabled)
ind |= VIA_FOG_BIT;
if (ctx->Texture._EnabledUnits > 1)
ind |= VIA_TEX1_BIT | VIA_TEX0_BIT;
else if (ctx->Texture._EnabledUnits == 1)
ind |= VIA_TEX0_BIT;
vmesa->setupIndex = ind;
viaPrintSetupFlags(__FUNCTION__, ind);
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
tnl->Driver.Render.Interp = via_interp_extras;
tnl->Driver.Render.CopyPV = via_copy_pv_extras;
}
else {
tnl->Driver.Render.Interp = setup_tab[ind].interp;
tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
}
vmesa->vertexSize = setup_tab[ind].vertex_size;
vmesa->vertexFormat = setup_tab[ind].vertex_format;
if (VIA_DEBUG) fprintf(stderr, "%s, size %d\n", __FUNCTION__, vmesa->vertexSize);
}
void *via_emit_contiguous_verts(GLcontext *ctx,
GLuint start,
GLuint count,
void *dest)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
GLuint stride = vmesa->vertexSize * 4;
setup_tab[vmesa->setupIndex].emit(ctx, start, count, dest, stride);
return (void *)((char *)dest + (count - start) * stride);
}
void viaInitVB(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
vmesa->verts = ALIGN_MALLOC(size * 4 * 16, 32);
{
static int firsttime = 1;
if (firsttime) {
init_setup_tab();
firsttime = 0;
}
}
}
void viaFreeVB(GLcontext *ctx) {
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (vmesa->verts) {
ALIGN_FREE(vmesa->verts);
vmesa->verts = 0;
}
}

View File

@@ -1,70 +0,0 @@
/*
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2003 S3 Graphics, 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, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef _VIAVB_H
#define _VIAVB_H
#include "mtypes.h"
#include "swrast/swrast.h"
#define VIA_TEX1_BIT 0x0001
#define VIA_TEX0_BIT 0x0002
#define VIA_RGBA_BIT 0x0004
#define VIA_SPEC_BIT 0x0008
#define VIA_FOG_BIT 0x0010
#define VIA_XYZW_BIT 0x0020
#define VIA_PTEX_BIT 0x0040
#define VIA_MAX_SETUP 0x0080
#define _VIA_NEW_VERTEX (_NEW_TEXTURE | \
_DD_NEW_SEPARATE_SPECULAR | \
_DD_NEW_TRI_UNFILLED | \
_DD_NEW_TRI_LIGHT_TWOSIDE | \
_NEW_FOG)
extern void viaChooseVertexState(GLcontext *ctx);
extern void viaCheckTexSizes(GLcontext *ctx);
extern void viaBuildVertices(GLcontext *ctx,
GLuint start,
GLuint count,
GLuint newinputs);
extern void *via_emit_contiguous_verts(GLcontext *ctx,
GLuint start,
GLuint count,
void *dest);
extern void via_translate_vertex(GLcontext *ctx,
const viaVertex *src,
SWvertex *dst);
extern void viaInitVB(GLcontext *ctx);
extern void viaFreeVB(GLcontext *ctx);
extern void via_print_vertex(GLcontext *ctx, const viaVertex *v);
extern void viaPrintSetupFlags(char *msg, GLuint flags);
#endif

View File

@@ -181,6 +181,15 @@ generic_%u_byte( GLint rop, const void * ptr )
return offset
def large_emit_begin(self, indent, f):
print '%s const GLint op = %s;' % (indent, f.opcode_real_name())
print '%s const GLuint cmdlenLarge = cmdlen + 4;' % (indent)
print '%s GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);' % (indent)
print '%s (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);' % (indent)
print '%s (void) memcpy((void *)(pc + 4), (void *)(&op), 4);' % (indent)
return
def common_func_print_just_header(self, f):
print '#define %s %d' % (f.opcode_name(), f.opcode_value())
@@ -316,11 +325,8 @@ generic_%u_byte( GLint rop, const void * ptr )
if f.can_be_large:
print '%s}' % (indent)
print '%selse {' % (indent)
print '%s const GLint op = %s;' % (indent, f.opcode_real_name())
print '%s const GLuint cmdlenLarge = cmdlen + 4;' % (indent)
print '%s GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);' % (indent)
print '%s (void) memcpy((void *)(pc + 0), (void *)(&op), 4);' % (indent)
print '%s (void) memcpy((void *)(pc + 4), (void *)(&cmdlenLarge), 4);' % (indent)
self.large_emit_begin(indent, f)
offset = self.common_emit_args(f, "pc", indent, 8, 1)
p = f.variable_length_parameter()

View File

@@ -19,6 +19,7 @@ LIBDIR = [---.lib]
CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
SOURCES = \
atifragshader.c \
arbfragparse.c \
arbprogparse.c \
arbprogram.c \
@@ -32,6 +33,7 @@ SOURCES = \
shaderobjects.c
OBJECTS = \
atifragshader.obj,\
arbfragparse.obj,\
arbprogparse.obj,\
arbprogram.obj,\
@@ -58,7 +60,7 @@ clean :
purge
delete *.obj;*
atifragshader.obj : atifragshader.c
arbfragparse.obj : arbfragparse.c
arbprogparse.obj : arbprogparse.c
arbprogram.obj : arbprogram.c

View File

@@ -24,11 +24,11 @@ SOURCES = s_aaline.c s_aatriangle.c s_accum.c s_alpha.c s_alphabuf.c \
s_drawpix.c s_feedback.c s_fog.c s_imaging.c s_lines.c s_logic.c \
s_masking.c s_nvfragprog.c s_pixeltex.c s_points.c s_readpix.c \
s_span.c s_stencil.c s_texstore.c s_texture.c s_triangle.c s_zoom.c \
s_auxbuffer.c
s_auxbuffer.c s_atifragshader.c
OBJECTS = s_aaline.obj,s_aatriangle.obj,s_accum.obj,s_alpha.obj,\
s_alphabuf.obj,s_auxbuffer.obj,s_bitmap.obj,s_blend.obj,\
s_buffers.obj,s_context.obj,\
s_buffers.obj,s_context.obj,s_atifragshader.obj,\
s_copypix.obj,s_depth.obj,s_drawpix.obj,s_feedback.obj,s_fog.obj,\
s_imaging.obj,s_lines.obj,s_logic.obj,s_masking.obj,s_nvfragprog.obj,\
s_pixeltex.obj,s_points.obj,s_readpix.obj,s_span.obj,s_stencil.obj,\
@@ -47,6 +47,7 @@ clean :
purge
delete *.obj;*
s_atifragshader.obj : s_atifragshader.c
s_aaline.obj : s_aaline.c
s_aatriangle.obj : s_aatriangle.c
s_accum.obj : s_accum.c

View File

@@ -1,4 +1,4 @@
/* $Id: 3dnow_normal.S,v 1.8 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: 3dnow_normal.S,v 1.9 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -41,6 +41,7 @@
ALIGNTEXT16
GLOBL GLNAME(_mesa_3dnow_transform_normalize_normals)
HIDDEN(_mesa_3dnow_transform_normalize_normals)
GLNAME(_mesa_3dnow_transform_normalize_normals):
#define FRAME_OFFSET 12
@@ -218,6 +219,7 @@ LLBL (G3TN_end):
ALIGNTEXT16
GLOBL GLNAME(_mesa_3dnow_transform_normalize_normals_no_rot)
HIDDEN(_mesa_3dnow_transform_normalize_normals_no_rot)
GLNAME(_mesa_3dnow_transform_normalize_normals_no_rot):
#undef FRAME_OFFSET
@@ -357,6 +359,7 @@ LLBL (G3TNNR_end):
ALIGNTEXT16
GLOBL GLNAME(_mesa_3dnow_transform_rescale_normals_no_rot)
HIDDEN(_mesa_3dnow_transform_rescale_normals_no_rot)
GLNAME(_mesa_3dnow_transform_rescale_normals_no_rot):
#undef FRAME_OFFSET
@@ -428,6 +431,7 @@ LLBL (G3TRNR_end):
ALIGNTEXT16
GLOBL GLNAME(_mesa_3dnow_transform_rescale_normals)
HIDDEN(_mesa_3dnow_transform_rescale_normals)
GLNAME(_mesa_3dnow_transform_rescale_normals):
#undef FRAME_OFFSET
@@ -525,6 +529,7 @@ LLBL (G3TR_end):
ALIGNTEXT16
GLOBL GLNAME(_mesa_3dnow_transform_normals_no_rot)
HIDDEN(_mesa_3dnow_transform_normals_no_rot)
GLNAME(_mesa_3dnow_transform_normals_no_rot):
#undef FRAME_OFFSET
@@ -591,6 +596,7 @@ LLBL (G3TNR_end):
ALIGNTEXT16
GLOBL GLNAME(_mesa_3dnow_transform_normals)
HIDDEN(_mesa_3dnow_transform_normals)
GLNAME(_mesa_3dnow_transform_normals):
#undef FRAME_OFFSET
@@ -675,6 +681,7 @@ LLBL (G3T_end):
ALIGNTEXT16
GLOBL GLNAME(_mesa_3dnow_normalize_normals)
HIDDEN(_mesa_3dnow_normalize_normals)
GLNAME(_mesa_3dnow_normalize_normals):
#undef FRAME_OFFSET
@@ -786,6 +793,7 @@ LLBL (G3N_end):
ALIGNTEXT16
GLOBL GLNAME(_mesa_3dnow_rescale_normals)
HIDDEN(_mesa_3dnow_rescale_normals)
GLNAME(_mesa_3dnow_rescale_normals):
#undef FRAME_OFFSET

View File

@@ -1,4 +1,4 @@
/* $Id: 3dnow_xform1.S,v 1.2 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: 3dnow_xform1.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,6 +35,7 @@
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points1_general )
HIDDEN(_mesa_3dnow_transform_points1_general)
GLNAME( _mesa_3dnow_transform_points1_general ):
PUSH_L ( ESI )
@@ -99,6 +100,7 @@ LLBL( G3TPGR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points1_identity )
HIDDEN(_mesa_3dnow_transform_points1_identity)
GLNAME( _mesa_3dnow_transform_points1_identity ):
PUSH_L ( ESI )
@@ -146,6 +148,7 @@ LLBL( G3TPIR_4 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points1_3d_no_rot )
HIDDEN(_mesa_3dnow_transform_points1_3d_no_rot)
GLNAME( _mesa_3dnow_transform_points1_3d_no_rot ):
PUSH_L ( ESI )
@@ -203,6 +206,7 @@ LLBL( G3TP3NRR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points1_perspective )
HIDDEN(_mesa_3dnow_transform_points1_perspective)
GLNAME( _mesa_3dnow_transform_points1_perspective ):
PUSH_L ( ESI )
@@ -256,6 +260,7 @@ LLBL( G3TPPR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points1_2d )
HIDDEN(_mesa_3dnow_transform_points1_2d)
GLNAME( _mesa_3dnow_transform_points1_2d ):
PUSH_L ( ESI )
@@ -311,6 +316,7 @@ LLBL( G3TP2R_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points1_2d_no_rot )
HIDDEN(_mesa_3dnow_transform_points1_2d_no_rot)
GLNAME( _mesa_3dnow_transform_points1_2d_no_rot ):
PUSH_L ( ESI )
@@ -364,6 +370,7 @@ LLBL( G3TP2NRR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points1_3d )
HIDDEN(_mesa_3dnow_transform_points1_3d)
GLNAME( _mesa_3dnow_transform_points1_3d ):
PUSH_L ( ESI )

View File

@@ -1,4 +1,4 @@
/* $Id: 3dnow_xform2.S,v 1.2 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: 3dnow_xform2.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,6 +35,7 @@
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points2_general )
HIDDEN(_mesa_3dnow_transform_points2_general)
GLNAME( _mesa_3dnow_transform_points2_general ):
PUSH_L ( ESI )
@@ -115,6 +116,7 @@ LLBL( G3TPGR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points2_perspective )
HIDDEN(_mesa_3dnow_transform_points2_perspective)
GLNAME( _mesa_3dnow_transform_points2_perspective ):
PUSH_L ( ESI )
@@ -170,6 +172,7 @@ LLBL( G3TPPR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points2_3d )
HIDDEN(_mesa_3dnow_transform_points2_3d)
GLNAME( _mesa_3dnow_transform_points2_3d ):
PUSH_L ( ESI )
@@ -246,6 +249,7 @@ LLBL( G3TP3R_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points2_3d_no_rot )
HIDDEN(_mesa_3dnow_transform_points2_3d_no_rot)
GLNAME( _mesa_3dnow_transform_points2_3d_no_rot ):
PUSH_L ( ESI )
@@ -304,6 +308,7 @@ LLBL( G3TP3NRR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points2_2d )
HIDDEN(_mesa_3dnow_transform_points2_2d)
GLNAME( _mesa_3dnow_transform_points2_2d ):
PUSH_L ( ESI )
@@ -367,6 +372,7 @@ LLBL( G3TP2R_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points2_2d_no_rot )
HIDDEN(_mesa_3dnow_transform_points2_2d_no_rot)
GLNAME( _mesa_3dnow_transform_points2_2d_no_rot ):
PUSH_L ( ESI )
@@ -422,6 +428,7 @@ LLBL( G3TP2NRR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points2_identity )
HIDDEN(_mesa_3dnow_transform_points2_identity)
GLNAME( _mesa_3dnow_transform_points2_identity ):
PUSH_L ( ESI )

View File

@@ -1,4 +1,4 @@
/* $Id: 3dnow_xform3.S,v 1.3 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: 3dnow_xform3.S,v 1.4 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,6 +35,7 @@
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points3_general )
HIDDEN(_mesa_3dnow_transform_points3_general)
GLNAME( _mesa_3dnow_transform_points3_general ):
PUSH_L ( ESI )
@@ -119,6 +120,7 @@ LLBL( G3TPGR_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points3_perspective )
HIDDEN(_mesa_3dnow_transform_points3_perspective)
GLNAME( _mesa_3dnow_transform_points3_perspective ):
PUSH_L ( ESI )
@@ -199,6 +201,7 @@ LLBL( G3TPPR_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points3_3d )
HIDDEN(_mesa_3dnow_transform_points3_3d)
GLNAME( _mesa_3dnow_transform_points3_3d ):
PUSH_L ( ESI )
@@ -286,6 +289,7 @@ LLBL( G3TP3R_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points3_3d_no_rot )
HIDDEN(_mesa_3dnow_transform_points3_3d_no_rot)
GLNAME( _mesa_3dnow_transform_points3_3d_no_rot ):
PUSH_L ( ESI )
@@ -361,6 +365,7 @@ LLBL( G3TP3NRR_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points3_2d )
HIDDEN(_mesa_3dnow_transform_points3_2d)
GLNAME( _mesa_3dnow_transform_points3_2d ):
PUSH_L ( ESI )
@@ -433,6 +438,7 @@ LLBL( G3TP2R_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points3_2d_no_rot )
HIDDEN(_mesa_3dnow_transform_points3_2d_no_rot)
GLNAME( _mesa_3dnow_transform_points3_2d_no_rot ):
PUSH_L ( ESI )
@@ -499,6 +505,7 @@ LLBL( G3TP2NRR_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points3_identity )
HIDDEN(_mesa_3dnow_transform_points3_identity)
GLNAME( _mesa_3dnow_transform_points3_identity ):
PUSH_L ( ESI )

View File

@@ -1,4 +1,4 @@
/* $Id: 3dnow_xform4.S,v 1.3 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: 3dnow_xform4.S,v 1.4 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,6 +35,7 @@
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points4_general )
HIDDEN(_mesa_3dnow_transform_points4_general)
GLNAME( _mesa_3dnow_transform_points4_general ):
PUSH_L ( ESI )
@@ -127,6 +128,7 @@ LLBL( G3TPGR_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points4_perspective )
HIDDEN(_mesa_3dnow_transform_points4_perspective)
GLNAME( _mesa_3dnow_transform_points4_perspective ):
PUSH_L ( ESI )
@@ -206,6 +208,7 @@ LLBL( G3TPPR_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points4_3d )
HIDDEN(_mesa_3dnow_transform_points4_3d)
GLNAME( _mesa_3dnow_transform_points4_3d ):
PUSH_L ( ESI )
@@ -295,6 +298,7 @@ LLBL( G3TP3R_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points4_3d_no_rot )
HIDDEN(_mesa_3dnow_transform_points4_3d_no_rot)
GLNAME( _mesa_3dnow_transform_points4_3d_no_rot ):
PUSH_L ( ESI )
@@ -367,6 +371,7 @@ LLBL( G3TP3NRR_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points4_2d )
HIDDEN(_mesa_3dnow_transform_points4_2d)
GLNAME( _mesa_3dnow_transform_points4_2d ):
PUSH_L ( ESI )
@@ -441,6 +446,7 @@ LLBL( G3TP2R_2 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points4_2d_no_rot )
HIDDEN(_mesa_3dnow_transform_points4_2d_no_rot)
GLNAME( _mesa_3dnow_transform_points4_2d_no_rot ):
PUSH_L ( ESI )
@@ -508,6 +514,7 @@ LLBL( G3TP2NRR_3 ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_3dnow_transform_points4_identity )
HIDDEN(_mesa_3dnow_transform_points4_identity)
GLNAME( _mesa_3dnow_transform_points4_identity ):
PUSH_L ( ESI )

View File

@@ -1730,4 +1730,11 @@ SECTION _DATA public align=16 class=DATA use32 flat
#define TLBL(a) CONCAT(a,$)
#endif
/* hidden symbol visibility support */
#ifdef GNU_ASSEMBLER
#define HIDDEN(a) .hidden a
#else
#define HIDDEN(a)
#endif
#endif /* __ASSYNTAX_H__ */

View File

@@ -46,6 +46,7 @@
ALIGNTEXT4
GLOBL GLNAME(_mesa_x86_has_cpuid)
HIDDEN(_mesa_x86_has_cpuid)
GLNAME(_mesa_x86_has_cpuid):
/* Test for the CPUID command. If the ID Flag bit in EFLAGS
@@ -69,6 +70,7 @@ GLNAME(_mesa_x86_has_cpuid):
ALIGNTEXT4
GLOBL GLNAME(_mesa_x86_cpuid)
HIDDEN(_mesa_x86_cpuid)
GLNAME(_mesa_x86_cpuid):
MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
@@ -92,6 +94,7 @@ GLNAME(_mesa_x86_cpuid):
ALIGNTEXT4
GLOBL GLNAME(_mesa_x86_cpuid_eax)
HIDDEN(_mesa_x86_cpuid_eax)
GLNAME(_mesa_x86_cpuid_eax):
MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
@@ -104,6 +107,7 @@ GLNAME(_mesa_x86_cpuid_eax):
ALIGNTEXT4
GLOBL GLNAME(_mesa_x86_cpuid_ebx)
HIDDEN(_mesa_x86_cpuid_ebx)
GLNAME(_mesa_x86_cpuid_ebx):
MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
@@ -117,6 +121,7 @@ GLNAME(_mesa_x86_cpuid_ebx):
ALIGNTEXT4
GLOBL GLNAME(_mesa_x86_cpuid_ecx)
HIDDEN(_mesa_x86_cpuid_ecx)
GLNAME(_mesa_x86_cpuid_ecx):
MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
@@ -130,6 +135,7 @@ GLNAME(_mesa_x86_cpuid_ecx):
ALIGNTEXT4
GLOBL GLNAME(_mesa_x86_cpuid_edx)
HIDDEN(_mesa_x86_cpuid_edx)
GLNAME(_mesa_x86_cpuid_edx):
MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
@@ -155,6 +161,7 @@ GLNAME(_mesa_x86_cpuid_edx):
*/
ALIGNTEXT4
GLOBL GLNAME( _mesa_test_os_sse_support )
HIDDEN(_mesa_test_os_sse_support)
GLNAME( _mesa_test_os_sse_support ):
XORPS ( XMM0, XMM0 )
@@ -169,6 +176,7 @@ GLNAME( _mesa_test_os_sse_support ):
*/
ALIGNTEXT4
GLOBL GLNAME( _mesa_test_os_sse_exception_support )
HIDDEN(_mesa_test_os_sse_exception_support)
GLNAME( _mesa_test_os_sse_exception_support ):
PUSH_L ( EBP )

View File

@@ -13,7 +13,7 @@
*/
ALIGNTEXT16
GLOBL GLNAME( TAG(_mesa_mmx_blend) )
HIDDEN( TAG(_mesa_mmx_blend) )
GLNAME( TAG(_mesa_mmx_blend) ):
PUSH_L ( EBP )

View File

@@ -76,6 +76,7 @@ mask:
*/
.globl _generic_read_RGBA_span_BGRA8888_REV_MMX
.hidden _generic_read_RGBA_span_BGRA8888_REV_MMX
.type _generic_read_RGBA_span_BGRA8888_REV_MMX, @function
_generic_read_RGBA_span_BGRA8888_REV_MMX:
pushl %ebx
@@ -171,6 +172,7 @@ _generic_read_RGBA_span_BGRA8888_REV_MMX:
*/
.globl _generic_read_RGBA_span_BGRA8888_REV_SSE
.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE
.type _generic_read_RGBA_span_BGRA8888_REV_SSE, @function
_generic_read_RGBA_span_BGRA8888_REV_SSE:
pushl %esi
@@ -330,6 +332,7 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE:
.text
.globl _generic_read_RGBA_span_BGRA8888_REV_SSE2
.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE2
.type _generic_read_RGBA_span_BGRA8888_REV_SSE2, @function
_generic_read_RGBA_span_BGRA8888_REV_SSE2:
pushl %esi
@@ -508,6 +511,7 @@ alpha: .long 0x00000000
.text
.globl _generic_read_RGBA_span_RGB565_MMX
.hidden _generic_read_RGBA_span_RGB565_MMX
.type _generic_read_RGBA_span_RGB565_MMX, @function
_generic_read_RGBA_span_RGB565_MMX:

View File

@@ -1,4 +1,4 @@
/* $Id: sse_normal.S,v 1.4 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: sse_normal.S,v 1.5 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -45,6 +45,7 @@
ALIGNTEXT16
GLOBL GLNAME(_mesa_sse_transform_rescale_normals_no_rot)
HIDDEN(_mesa_sse_transform_rescale_normals_no_rot)
GLNAME(_mesa_sse_transform_rescale_normals_no_rot):
#define FRAME_OFFSET 8
@@ -106,6 +107,7 @@ LLBL(K_G3TRNNRR_finish):
ALIGNTEXT16
GLOBL GLNAME(_mesa_sse_transform_rescale_normals)
HIDDEN(_mesa_sse_transform_rescale_normals)
GLNAME(_mesa_sse_transform_rescale_normals):
#define FRAME_OFFSET 8
@@ -198,6 +200,7 @@ LLBL(K_G3TRNR_finish):
ALIGNTEXT16
GLOBL GLNAME(_mesa_sse_transform_normals_no_rot)
HIDDEN(_mesa_sse_transform_normals_no_rot)
GLNAME(_mesa_sse_transform_normals_no_rot):
#define FRAME_OFFSET 8

View File

@@ -1,4 +1,4 @@
/* $Id: sse_xform1.S,v 1.2 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: sse_xform1.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,6 +44,7 @@
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points1_general)
HIDDEN( _mesa_sse_transform_points1_general )
GLNAME( _mesa_sse_transform_points1_general ):
#define FRAME_OFFSET 8
@@ -100,6 +101,7 @@ LLBL(K_GTP1GR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points1_identity)
HIDDEN(_mesa_sse_transform_points1_identity)
GLNAME( _mesa_sse_transform_points1_identity ):
#define FRAME_OFFSET 8
@@ -151,6 +153,7 @@ LLBL(K_GTP1IR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points1_3d_no_rot)
HIDDEN(_mesa_sse_transform_points1_3d_no_rot)
GLNAME(_mesa_sse_transform_points1_3d_no_rot):
#define FRAME_OFFSET 8
@@ -211,6 +214,7 @@ LLBL(K_GTP13DNRR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points1_perspective)
HIDDEN(_mesa_sse_transform_points1_perspective)
GLNAME(_mesa_sse_transform_points1_perspective):
#define FRAME_OFFSET 8
@@ -269,6 +273,7 @@ LLBL(K_GTP13PR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points1_2d)
HIDDEN(_mesa_sse_transform_points1_2d)
GLNAME(_mesa_sse_transform_points1_2d):
#define FRAME_OFFSET 8
@@ -323,6 +328,7 @@ LLBL(K_GTP13P2DR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points1_2d_no_rot)
HIDDEN(_mesa_sse_transform_points1_2d_no_rot)
GLNAME(_mesa_sse_transform_points1_2d_no_rot):
#define FRAME_OFFSET 8
@@ -379,6 +385,7 @@ LLBL(K_GTP13P2DNRR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points1_3d)
HIDDEN(_mesa_sse_transform_points1_3d)
GLNAME(_mesa_sse_transform_points1_3d):
#define FRAME_OFFSET 8

View File

@@ -1,4 +1,4 @@
/* $Id: sse_xform2.S,v 1.2 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: sse_xform2.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,6 +44,7 @@
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points2_general)
HIDDEN (_mesa_sse_transform_points2_general)
GLNAME( _mesa_sse_transform_points2_general ):
#define FRAME_OFFSET 8
@@ -104,6 +105,7 @@ LLBL(K_GTP2GR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points2_identity)
HIDDEN(_mesa_sse_transform_points2_identity)
GLNAME( _mesa_sse_transform_points2_identity ):
#define FRAME_OFFSET 8
@@ -156,6 +158,7 @@ LLBL(K_GTP2IR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points2_3d_no_rot)
HIDDEN(_mesa_sse_transform_points2_3d_no_rot)
GLNAME(_mesa_sse_transform_points2_3d_no_rot):
#define FRAME_OFFSET 8
@@ -215,6 +218,7 @@ LLBL(K_GTP23DNRR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points2_perspective)
HIDDEN(_mesa_sse_transform_points2_perspective)
GLNAME(_mesa_sse_transform_points2_perspective):
#define FRAME_OFFSET 8
@@ -273,6 +277,7 @@ LLBL(K_GTP23PR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points2_2d)
HIDDEN(_mesa_sse_transform_points2_2d)
GLNAME(_mesa_sse_transform_points2_2d):
#define FRAME_OFFSET 8
@@ -335,6 +340,7 @@ LLBL(K_GTP23P2DR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points2_2d_no_rot)
HIDDEN(_mesa_sse_transform_points2_2d_no_rot)
GLNAME(_mesa_sse_transform_points2_2d_no_rot):
#define FRAME_OFFSET 8
@@ -391,6 +397,7 @@ LLBL(K_GTP23P2DNRR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points2_3d)
HIDDEN(_mesa_sse_transform_points2_3d)
GLNAME(_mesa_sse_transform_points2_3d):
#define FRAME_OFFSET 8

View File

@@ -1,4 +1,4 @@
/* $Id: sse_xform3.S,v 1.2 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: sse_xform3.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,6 +44,7 @@
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points3_general)
HIDDEN(_mesa_sse_transform_points3_general)
GLNAME( _mesa_sse_transform_points3_general ):
#define FRAME_OFFSET 8
@@ -113,6 +114,7 @@ LLBL(K_GTPGR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points3_identity)
HIDDEN(_mesa_sse_transform_points3_identity)
GLNAME( _mesa_sse_transform_points3_identity ):
#define FRAME_OFFSET 8
@@ -167,6 +169,7 @@ LLBL(K_GTPIR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points3_3d_no_rot)
HIDDEN(_mesa_sse_transform_points3_3d_no_rot)
GLNAME(_mesa_sse_transform_points3_3d_no_rot):
#define FRAME_OFFSET 8
@@ -233,6 +236,7 @@ LLBL(K_GTP3DNRR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points3_perspective)
HIDDEN(_mesa_sse_transform_points3_perspective)
GLNAME(_mesa_sse_transform_points3_perspective):
#define FRAME_OFFSET 8
@@ -305,6 +309,7 @@ LLBL(K_GTP3PR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points3_2d)
HIDDEN(_mesa_sse_transform_points3_2d)
GLNAME(_mesa_sse_transform_points3_2d):
#define FRAME_OFFSET 8
@@ -369,6 +374,7 @@ LLBL(K_GTP3P2DR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points3_2d_no_rot)
HIDDEN(_mesa_sse_transform_points3_2d_no_rot)
GLNAME(_mesa_sse_transform_points3_2d_no_rot):
#define FRAME_OFFSET 8
@@ -429,6 +435,7 @@ LLBL(K_GTP3P2DNRR_finish):
ALIGNTEXT4
GLOBL GLNAME(_mesa_sse_transform_points3_3d)
HIDDEN(_mesa_sse_transform_points3_3d)
GLNAME(_mesa_sse_transform_points3_3d):
#define FRAME_OFFSET 8

View File

@@ -1,4 +1,4 @@
/* $Id: sse_xform4.S,v 1.2 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: sse_xform4.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -41,6 +41,7 @@
ALIGNTEXT16
GLOBL GLNAME( _mesa_sse_transform_points4_general )
HIDDEN(_mesa_sse_transform_points4_general)
GLNAME( _mesa_sse_transform_points4_general ):
PUSH_L( ESI )
@@ -112,6 +113,7 @@ LLBL( sse_general_done ):
ALIGNTEXT4
GLOBL GLNAME( _mesa_sse_transform_points4_3d )
HIDDEN(_mesa_sse_transform_points4_3d)
GLNAME( _mesa_sse_transform_points4_3d ):
PUSH_L( ESI )
@@ -183,6 +185,7 @@ LLBL( K_GTP43P3DR_finish ):
ALIGNTEXT16
GLOBL GLNAME( _mesa_sse_transform_points4_identity )
HIDDEN(_mesa_sse_transform_points4_identity)
GLNAME( _mesa_sse_transform_points4_identity ):
PUSH_L( ESI )

View File

@@ -1,4 +1,4 @@
/* $Id: x86_cliptest.S,v 1.10 2002/06/11 01:26:58 brianp Exp $ */
/* $Id: x86_cliptest.S,v 1.11 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -101,6 +101,7 @@ clip_table:
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_cliptest_points4 )
HIDDEN(_mesa_x86_cliptest_points4)
GLNAME( _mesa_x86_cliptest_points4 ):
#ifdef ELFPIC
@@ -275,6 +276,7 @@ LLBL(ctp4_finish):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_cliptest_points4_np )
HIDDEN(_mesa_x86_cliptest_points4_np)
GLNAME( _mesa_x86_cliptest_points4_np ):
#ifdef ELFPIC

View File

@@ -1,4 +1,4 @@
/* $Id: x86_xform2.S,v 1.2 2002/03/07 21:40:08 brianp Exp $ */
/* $Id: x86_xform2.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -66,6 +66,7 @@
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points2_general )
HIDDEN(_mesa_x86_transform_points2_general)
GLNAME( _mesa_x86_transform_points2_general ):
#define FRAME_OFFSET 8
@@ -156,6 +157,7 @@ LLBL(x86_p2_gr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points2_perspective )
HIDDEN(_mesa_x86_transform_points2_perspective)
GLNAME( _mesa_x86_transform_points2_perspective ):
#define FRAME_OFFSET 12
@@ -221,6 +223,7 @@ LLBL(x86_p2_pr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points2_3d )
HIDDEN(_mesa_x86_transform_points2_3d)
GLNAME( _mesa_x86_transform_points2_3d ):
#define FRAME_OFFSET 8
@@ -302,6 +305,7 @@ LLBL(x86_p2_3dr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points2_3d_no_rot )
HIDDEN(_mesa_x86_transform_points2_3d_no_rot)
GLNAME( _mesa_x86_transform_points2_3d_no_rot ):
#define FRAME_OFFSET 12
@@ -371,6 +375,7 @@ LLBL(x86_p2_3dnrr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points2_2d )
HIDDEN(_mesa_x86_transform_points2_2d)
GLNAME( _mesa_x86_transform_points2_2d ):
#define FRAME_OFFSET 8
@@ -443,6 +448,7 @@ LLBL(x86_p2_2dr_done):
ALIGNTEXT4
GLOBL GLNAME( _mesa_x86_transform_points2_2d_no_rot )
HIDDEN(_mesa_x86_transform_points2_2d_no_rot)
GLNAME( _mesa_x86_transform_points2_2d_no_rot ):
#define FRAME_OFFSET 8
@@ -507,6 +513,7 @@ LLBL(x86_p2_2dnrr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points2_identity )
HIDDEN(_mesa_x86_transform_points2_identity)
GLNAME( _mesa_x86_transform_points2_identity ):
#define FRAME_OFFSET 12

View File

@@ -1,4 +1,4 @@
/* $Id: x86_xform3.S,v 1.2 2002/03/07 21:40:08 brianp Exp $ */
/* $Id: x86_xform3.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -66,6 +66,7 @@
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points3_general )
HIDDEN(_mesa_x86_transform_points3_general)
GLNAME( _mesa_x86_transform_points3_general ):
#define FRAME_OFFSET 8
@@ -172,6 +173,7 @@ LLBL(x86_p3_gr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points3_perspective )
HIDDEN(_mesa_x86_transform_points3_perspective)
GLNAME( _mesa_x86_transform_points3_perspective ):
#define FRAME_OFFSET 12
@@ -252,6 +254,7 @@ LLBL(x86_p3_pr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points3_3d )
HIDDEN(_mesa_x86_transform_points3_3d)
GLNAME( _mesa_x86_transform_points3_3d ):
#define FRAME_OFFSET 8
@@ -345,6 +348,7 @@ LLBL(x86_p3_3dr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points3_3d_no_rot )
HIDDEN(_mesa_x86_transform_points3_3d_no_rot)
GLNAME( _mesa_x86_transform_points3_3d_no_rot ):
#define FRAME_OFFSET 8
@@ -417,6 +421,7 @@ LLBL(x86_p3_3dnrr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points3_2d )
HIDDEN(_mesa_x86_transform_points3_2d)
GLNAME( _mesa_x86_transform_points3_2d ):
#define FRAME_OFFSET 12
@@ -494,6 +499,7 @@ LLBL(x86_p3_2dr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points3_2d_no_rot )
HIDDEN(_mesa_x86_transform_points3_2d_no_rot)
GLNAME( _mesa_x86_transform_points3_2d_no_rot ):
#define FRAME_OFFSET 12
@@ -564,6 +570,7 @@ LLBL(x86_p3_2dnrr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points3_identity )
HIDDEN(_mesa_x86_transform_points3_identity)
GLNAME(_mesa_x86_transform_points3_identity ):
#define FRAME_OFFSET 16

View File

@@ -1,4 +1,4 @@
/* $Id: x86_xform4.S,v 1.2 2002/03/07 21:40:08 brianp Exp $ */
/* $Id: x86_xform4.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -66,6 +66,7 @@
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points4_general )
HIDDEN(_mesa_x86_transform_points4_general)
GLNAME( _mesa_x86_transform_points4_general ):
#define FRAME_OFFSET 8
@@ -179,6 +180,7 @@ LLBL(x86_p4_gr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points4_perspective )
HIDDEN(_mesa_x86_transform_points4_perspective)
GLNAME( _mesa_x86_transform_points4_perspective ):
#define FRAME_OFFSET 12
@@ -261,6 +263,7 @@ LLBL(x86_p4_pr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points4_3d )
HIDDEN(_mesa_x86_transform_points4_3d)
GLNAME( _mesa_x86_transform_points4_3d ):
#define FRAME_OFFSET 12
@@ -363,6 +366,7 @@ LLBL(x86_p4_3dr_done):
ALIGNTEXT16
GLOBL GLNAME(_mesa_x86_transform_points4_3d_no_rot)
HIDDEN(_mesa_x86_transform_points4_3d_no_rot)
GLNAME(_mesa_x86_transform_points4_3d_no_rot):
#define FRAME_OFFSET 12
@@ -443,6 +447,7 @@ LLBL(x86_p4_3dnrr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points4_2d )
HIDDEN(_mesa_x86_transform_points4_2d)
GLNAME( _mesa_x86_transform_points4_2d ):
#define FRAME_OFFSET 16
@@ -528,6 +533,7 @@ LLBL(x86_p4_2dr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points4_2d_no_rot )
HIDDEN(_mesa_x86_transform_points4_2d_no_rot)
GLNAME( _mesa_x86_transform_points4_2d_no_rot ):
#define FRAME_OFFSET 16
@@ -605,6 +611,7 @@ LLBL(x86_p4_2dnrr_done):
ALIGNTEXT16
GLOBL GLNAME( _mesa_x86_transform_points4_identity )
HIDDEN(_mesa_x86_transform_points4_identity)
GLNAME( _mesa_x86_transform_points4_identity ):
#define FRAME_OFFSET 12