Compare commits

..

24 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
64 changed files with 3193 additions and 1275 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

@@ -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

@@ -49,6 +49,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#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
@@ -213,6 +214,7 @@ void r300EmitState(r300ContextPtr r300)
r300->hw.all_dirty = GL_FALSE;
}
#if 0
static __inline__ uint32_t cmducs(int reg, int count)
{
@@ -237,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, \
@@ -413,26 +416,26 @@ void r300InitCmdBuf(r300ContextPtr r300)
r300->hw.vps.cmd[R300_VPS_CMD_0] = cmdvpu(R300_PVS_UPLOAD_POINTSIZE, 1);
/* Textures */
ALLOC_STATE( tex.filter, always, mtu, "tex_filter", 0 );
r300->hw.tex.filter.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_FILTER_0, mtu-1);
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, always, mtu, "tex_unknown1", 0 );
r300->hw.tex.unknown1.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_UNK1_0, mtu-1);
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, always, mtu, "tex_size", 0 );
r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_SIZE_0, mtu-1);
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, always, mtu, "tex_format", 0 );
r300->hw.tex.format.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_FORMAT_0, mtu-1);
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, always, mtu, "tex_offset", 0 );
r300->hw.tex.offset.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_OFFSET_0, mtu-1);
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, always, mtu, "tex_unknown4", 0 );
r300->hw.tex.unknown4.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_UNK4_0, mtu-1);
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, always, mtu, "tex_unknown5", 0 );
r300->hw.tex.unknown5.cmd[R300_TEX_CMD_0] = cmducs(R300_TX_UNK5_0, mtu-1);
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 */
@@ -571,7 +574,7 @@ void r300EmitBlit(r300ContextPtr rmesa,
assert(h < (1 << 16));
cmd =
(drm_radeon_cmd_header_t *) r200AllocCmdBuf(rmesa, 8 * sizeof(int),
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 8 * sizeof(int),
__FUNCTION__);
cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
@@ -600,7 +603,7 @@ void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
assert(!(flags & ~(RADEON_WAIT_2D | RADEON_WAIT_3D)));
cmd =
(drm_radeon_cmd_header_t *) r200AllocCmdBuf(rmesa,
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
1 * sizeof(int),
__FUNCTION__);
cmd[0].i = 0;
@@ -608,3 +611,144 @@ void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
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

@@ -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)
{
@@ -149,6 +156,15 @@ struct r300_tex_obj {
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;
};
@@ -158,10 +174,11 @@ struct r300_texture_env_state {
GLenum envMode;
};
#define R300_MAX_TEXTURE_UNITS 6
#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 */
};
/**
@@ -364,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) */
@@ -423,6 +439,7 @@ struct r300_hw_state {
struct r300_state_atom unknown4;
struct r300_state_atom unknown5;
} tex;
struct r300_state_atom txe; /* tex enable (4104) */
};
@@ -449,9 +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;
};

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;

View File

@@ -49,6 +49,14 @@ 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

@@ -587,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"
@@ -124,7 +127,9 @@ static int r300_get_primitive_type(r300ContextPtr rmesa,
min_vertices=4;
break;
default:
fprintf(stderr, "Cannot handle primitive %02x ", prim & PRIM_MODE_MASK);
fprintf(stderr, "%s:%s Do not know how to handle primitive %02x - help me !\n",
__FILE__, __FUNCTION__,
prim & PRIM_MODE_MASK);
return -1;
break;
}
@@ -132,12 +137,28 @@ static int r300_get_primitive_type(r300ContextPtr rmesa,
fprintf(stderr, "[%d-%d]%s ", start, end, name);
#endif
if(start+min_vertices>=end){
fprintf(stderr, "Not enough vertices\n");
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 */
@@ -155,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,
@@ -169,10 +192,19 @@ static void r300_render_flat_primitive(r300ContextPtr rmesa,
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
@@ -195,47 +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);
@@ -243,53 +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);
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);
}
/* This sequence is required after any 3d drawing packet
/* 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);
return GL_FALSE;
}
/* vertex buffer implementation */
/* We use the start part of GART texture buffer for vertices */
/* 8 is somewhat bogus... it is probably something like 24 */
#define R300_MAX_AOS_ARRAYS 8
static void upload_vertex_buffer(r300ContextPtr rmesa,
GLcontext *ctx, AOS_DATA *array, int *n_arrays)
@@ -359,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)
{
@@ -391,6 +449,8 @@ static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
reg_start(0x4f18,0);
e32(0x00000003);
r300_setup_routing(rmesa, ctx, GL_FALSE);
r300EmitState(rmesa);
FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].length=16;
@@ -440,228 +500,6 @@ static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
return GL_FALSE;
}
/* Textures... */
/* Immediate implementation - vertex data is sent via command stream */
static void r300_render_tex_primitive(r300ContextPtr rmesa,
GLcontext *ctx,
int start,
int end,
int prim)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
GLuint i;
int k, type;
LOCAL_VARS
type=r300_get_primitive_type(rmesa, ctx, start, end, prim);
#if 1
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, 12);
for(i=start;i<end;i++){
#if 0
fprintf(stderr, "* (%f %f %f %f) (%f %f %f %f)\n",
VEC_ELT(VB->ObjPtr, GLfloat, i)[0],
VEC_ELT(VB->ObjPtr, GLfloat, i)[1],
VEC_ELT(VB->ObjPtr, GLfloat, i)[2],
VEC_ELT(VB->ObjPtr, GLfloat, i)[3],
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[0],
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[1],
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[2],
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[3]
);
#endif
/* coordinates */
output_vector(VB->ObjPtr, i);
/* color components */
output_vector(VB->ColorPtr[0], i);
/* texture coordinates */
output_vector(VB->TexCoordPtr[0], i);
}
}
static GLboolean r300_run_tex_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[3];
/* 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.. */
r300UpdateTextureState(ctx);
/* Flush state - make sure command buffer is nice and large */
r300Flush(ctx);
//fprintf(stderr, "You can enable texture drawing in %s:%s \n", __FILE__, __FUNCTION__);
//return GL_TRUE;
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 */
/* xyzw */
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;
/* texture coordinates */
vb_arrays[2].element_size=4;
vb_arrays[2].stride=4;
vb_arrays[2].offset=0; /* Not used */
vb_arrays[2].format=AOS_FORMAT_FLOAT;
vb_arrays[2].ncomponents=4;
vb_arrays[2].reg=REG_TEX0;
/* needed before starting 3d operation .. */
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(0x0000000a);
reg_start(0x4f18,0);
e32(0x00000003);
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;
R300_STATECHANGE(rmesa, vte);
r300EmitState(rmesa);
SINGLE_TEXTURE_PIPELINE.vertex_shader.matrix[0].length=16;
memcpy(SINGLE_TEXTURE_PIPELINE.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4);
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.length=4;
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.body.f[0]=0.0;
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.body.f[1]=0.0;
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.body.f[2]=1.0;
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.body.f[3]=0.0;
/* Use actual texture offset */
SINGLE_TEXTURE_PIPELINE.texture_unit[0].offset=rmesa->radeon.radeonScreen->fbLocation+t->offset;
#if 0
SINGLE_TEXTURE_PIPELINE.texture_unit[0].format=t->format;
SINGLE_TEXTURE_PIPELINE.texture_unit[0].size=t->size;
#endif
SINGLE_TEXTURE_PIPELINE.texture_unit[0].filter=t->filter;
SINGLE_TEXTURE_PIPELINE.texture_unit[0].unknown1=t->pitch; /* Unknown 1 is pitch ! */
SINGLE_TEXTURE_PIPELINE.texture_unit[0].filter=t->filter;
/* Upload texture, a hack, really we can do a lot better */
#if 0
memcpy(rsp->gartTextures.map, to->Image[0][0]->Data, to->Image[0][0]->RowStride*to->Image[0][0]->Height*4);
#endif
/* Program RS unit. This needs to be moved into R300 pipeline */
reg_start(R300_RS_CNTL_0,1);
/* R300_RS_CNTL_0(4300) */
e32(0x00040084);
/* RS_INST_COUNT(4304) */
e32(0x000000c0);
reg_start(R300_RS_ROUTE_0,0);
e32(0x00024008);
reg_start(R300_RS_INTERP_0,7);
/* X_MEM0_0(4310) */
e32(0x00d10000);
/* X_MEM0_1(4314) */
e32(0x00d10044);
/* X_MEM0_2(4318) */
e32(0x00d10084);
/* X_MEM0_3(431c) */
e32(0x00d100c4);
/* X_MEM0_4(4320) */
e32(0x00d10004);
/* X_MEM0_5(4324) */
e32(0x00d10004);
/* X_MEM0_6(4328) */
e32(0x00d10004);
/* X_MEM0_7(432c) */
e32(0x00d10004);
reg_start(R300_RS_CNTL_0,0);
e32(0x00040084);
/* Magic register - note it is right after 20b0 */
reg_start(0x20b4,0);
e32(0x0000000c);
program_pipeline(PASS_PREFIX &SINGLE_TEXTURE_PIPELINE);
/* We need LOAD_VBPNTR to setup AOS_ATTR fields.. the offsets are irrelevant */
setup_AOS(PASS_PREFIX vb_arrays, 3);
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_tex_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);
// exit(-1);
fprintf(stderr, "\n");
return GL_FALSE;
}
/**
* Called by the pipeline manager to render a batch of primitives.
@@ -680,12 +518,10 @@ static GLboolean r300_run_render(GLcontext *ctx,
if (RADEON_DEBUG == DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
#if 1
/* Just switch between pipelines.. We could possibly do better.. (?) */
if(ctx->Texture.Unit[0].Enabled)
return r300_run_tex_render(ctx, stage);
else
return r300_run_vb_flat_render(ctx, stage);
return r300_run_immediate_render(ctx, stage);
#else
return GL_TRUE;
#endif
@@ -762,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

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;
@@ -341,6 +997,7 @@ void r300ResetHwState(r300ContextPtr r300)
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;
@@ -349,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;
@@ -364,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;
@@ -389,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);
@@ -427,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;
@@ -475,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;
@@ -548,16 +1198,6 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.vps.cmd[R300_VPS_POINTSIZE] = r300PackFloat32(1.0);
r300->hw.vps.cmd[R300_VPS_ZERO_3] = 0;
/* Initialize texture units */
for(i=0;i<r300->radeon.glCtx->Const.MaxTextureUnits;i++){
r300->hw.tex.filter.cmd[R300_TEX_VALUE_0+i]=0x0;
r300->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+i]=0x0;
r300->hw.tex.size.cmd[R300_TEX_VALUE_0+i]=0x0;
r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=0x0;
r300->hw.tex.offset.cmd[R300_TEX_VALUE_0+i]=0x0;
r300->hw.tex.unknown4.cmd[R300_TEX_VALUE_0+i]=0x0;
r300->hw.tex.unknown5.cmd[R300_TEX_VALUE_0+i]=0x0;
}
//END: TODO
r300->hw.all_dirty = GL_TRUE;
@@ -572,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);
}
@@ -589,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;
@@ -599,5 +1263,6 @@ void r300InitStateFuncs(struct dd_function_table* functions)
/* Viewport related */
functions->Viewport = r300Viewport;
functions->DepthRange = r300DepthRange;
functions->PointSize = r300PointSize;
}

View File

@@ -136,42 +136,40 @@ static void r300SetTexWrap(r300TexObjPtr t, GLenum swrap, GLenum twrap,
_mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
}
#if 0 /* Which field is this ? */
t->pp_txformat_x &= ~R200_CLAMP_Q_MASK;
t->format_x &= ~R200_CLAMP_Q_MASK;
switch (rwrap) {
case GL_REPEAT:
t->pp_txformat_x |= R200_CLAMP_Q_WRAP;
t->format_x |= R200_CLAMP_Q_WRAP;
break;
case GL_CLAMP:
t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_GL;
t->format_x |= R200_CLAMP_Q_CLAMP_GL;
is_clamp = GL_TRUE;
break;
case GL_CLAMP_TO_EDGE:
t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_LAST;
t->format_x |= R200_CLAMP_Q_CLAMP_LAST;
break;
case GL_CLAMP_TO_BORDER:
t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_GL;
t->format_x |= R200_CLAMP_Q_CLAMP_GL;
is_clamp_to_border = GL_TRUE;
break;
case GL_MIRRORED_REPEAT:
t->pp_txformat_x |= R200_CLAMP_Q_MIRROR;
t->format_x |= R200_CLAMP_Q_MIRROR;
break;
case GL_MIRROR_CLAMP_EXT:
t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
t->format_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
is_clamp = GL_TRUE;
break;
case GL_MIRROR_CLAMP_TO_EDGE_EXT:
t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_LAST;
t->format_x |= R200_CLAMP_Q_MIRROR_CLAMP_LAST;
break;
case GL_MIRROR_CLAMP_TO_BORDER_EXT:
t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
t->format_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
is_clamp_to_border = GL_TRUE;
break;
default:
_mesa_problem(NULL, "bad R wrap mode in %s", __FUNCTION__);
}
#endif
if (is_clamp_to_border) {
t->filter |= R200_BORDER_MODE_D3D;
@@ -210,9 +208,7 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
GLuint anisotropy = (t->filter & R200_MAX_ANISO_MASK);
t->filter &= ~(R200_MIN_FILTER_MASK | R200_MAG_FILTER_MASK);
#if 0
t->pp_txformat_x &= ~R200_VOLUME_FILTER_MASK;
#endif
t->format_x &= ~R200_VOLUME_FILTER_MASK;
if (anisotropy == R200_MAX_ANISO_1_TO_1) {
switch (minf) {
@@ -262,24 +258,18 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
switch (magf) {
case GL_NEAREST:
t->filter |= R200_MAG_FILTER_NEAREST;
#if 0
t->pp_txformat_x |= R200_VOLUME_FILTER_NEAREST;
#endif
t->format_x |= R200_VOLUME_FILTER_NEAREST;
break;
case GL_LINEAR:
t->filter |= R200_MAG_FILTER_LINEAR;
#if 0
t->pp_txformat_x |= R200_VOLUME_FILTER_LINEAR;
#endif
t->format_x |= R200_VOLUME_FILTER_LINEAR;
break;
}
}
static void r300SetTexBorderColor(r300TexObjPtr t, GLubyte c[4])
{
#if 0
t->pp_border_color = radeonPackColor(4, c[0], c[1], c[2], c[3]);
#endif
}
/**
@@ -328,7 +318,7 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
const GLboolean force16bpt =
(rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16);
(void)format;
switch (internalFormat) {
case 4:
case GL_RGBA:
@@ -1039,7 +1029,7 @@ void r300InitTextureFuncs(struct dd_function_table *functions)
driInitTextureFormats();
#if 000
#if 0
/* moved or obsolete code */
r300ContextPtr rmesa = R300_CONTEXT(ctx);
driInitTextureObjects(ctx, &rmesa->swapped,

View File

@@ -47,5 +47,7 @@ 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

@@ -46,6 +46,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//#include "r300_swtcl.h"
#include "r300_tex.h"
//#include "r300_tcl.h"
#include "r300_reg.h"
#define R200_TXFORMAT_A8 R200_TXFORMAT_I8
#define R200_TXFORMAT_L8 R200_TXFORMAT_I8
@@ -238,15 +239,14 @@ static void r300SetTexImages(r300ContextPtr rmesa,
t->filter &= ~R200_MAX_MIP_LEVEL_MASK;
t->filter |= (numLevels - 1) << R200_MAX_MIP_LEVEL_SHIFT;
t->format &= ~(R200_TXFORMAT_WIDTH_MASK |
R200_TXFORMAT_HEIGHT_MASK |
t->format &= ~(R300_TX_FORMAT_WIDTH_MASK |
R300_TX_FORMAT_HEIGHT_MASK |
R200_TXFORMAT_CUBIC_MAP_ENABLE |
R200_TXFORMAT_F5_WIDTH_MASK |
R200_TXFORMAT_F5_HEIGHT_MASK);
t->format |= ((log2Width << R200_TXFORMAT_WIDTH_SHIFT) |
(log2Height << R200_TXFORMAT_HEIGHT_SHIFT));
t->format |= ((log2Width << R300_TX_FORMAT_WIDTH_SHIFT) |
(log2Height << R300_TX_FORMAT_HEIGHT_SHIFT));
#if 0
t->format_x &= ~(R200_DEPTH_LOG2_MASK | R200_TEXCOORD_MASK);
if (tObj->Target == GL_TEXTURE_3D) {
t->format_x |= (log2Depth << R200_DEPTH_LOG2_SHIFT);
@@ -266,11 +266,10 @@ static void r300SetTexImages(r300ContextPtr rmesa,
(log2Width << R200_FACE_WIDTH_4_SHIFT) |
(log2Height << R200_FACE_HEIGHT_4_SHIFT));
}
#endif
t->size = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << 0) |
((tObj->Image[0][t->base.firstLevel]->Height -
1) << 16));
t->size = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << R300_TX_WIDTHMASK_SHIFT)
|((tObj->Image[0][t->base.firstLevel]->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)
|((log2Width>log2Height)?log2Width:log2Height)<<R300_TX_SIZE_SHIFT);
/* Only need to round to nearest 32 for textures, but the blitter
* requires 64-byte aligned pitches, and we may/may not need the
@@ -1292,7 +1291,7 @@ void r300UpdateTextureState(GLcontext * ctx)
if (GET_CHIP(rmesa->radeon.radeonScreen) == RADEON_CHIP_REAL_R200) {
/*
* T0 hang workaround -------------
* not needed for r300 derivatives?
* not needed for r200 derivatives?
*/
if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_ENABLE_MASK) ==
R200_TEX_0_ENABLE
@@ -1340,7 +1339,7 @@ void r300UpdateTextureState(GLcontext * ctx)
/*
* Texture cache LRU hang workaround -------------
* not needed for r300 derivatives?
* not needed for r200 derivatives?
*/
dbg = 0x0;

View File

@@ -64,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)
@@ -72,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;
@@ -308,6 +309,9 @@ savageCreateContext( const __GLcontextModes *mesaVis,
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)
@@ -407,7 +411,7 @@ 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->bufferSize = savageScreen->bufferSize;
imesa->dmaVtxBuf.total = 0;
@@ -479,8 +483,6 @@ savageCreateContext( const __GLcontextModes *mesaVis,
savageDDInitState( imesa );
imesa->no_rast = driQueryOptionb(&imesa->optionCache, "no_rast");
driContextPriv->driverPrivate = (void *) imesa;
return GL_TRUE;

View File

@@ -294,6 +294,7 @@ struct savage_context_t {
driOptionCache optionCache;
GLint texture_depth;
GLboolean no_rast;
GLboolean float_depth;
};
#define SAVAGE_CONTEXT(ctx) ((savageContextPtr)(ctx->DriverCtx))

View File

@@ -38,6 +38,7 @@
#include "savageioctl.h"
#include "savage_bci.h"
#include "savagestate.h"
#include "savagespan.h"
#include "drm.h"
#include <sys/ioctl.h>
@@ -333,10 +334,17 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
fprintf (stderr, "%s\n", __FUNCTION__);
clearColor = imesa->ClearColor;
if(imesa->savageScreen->zpp == 2)
clearDepth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_16);
else
clearDepth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_24);
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);
}
colorMask = *((GLuint *) &ctx->Color.ColorMask);
depthMask = 0;

View File

@@ -158,13 +158,14 @@ do { \
/* 16 bit depthbuffer functions.
/* 16 bit integer depthbuffer functions
* Depth range is reversed. See also savageCalcViewport.
*/
#define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = d
*(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = 0xFFFF - d
#define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch)
d = 0xFFFF - *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch)
#define TAG(x) savage##x##_16
#include "depthtmp.h"
@@ -173,22 +174,62 @@ do { \
/* 8-bit stencil /24-bit depth depthbuffer functions.
/* 16 bit float depthbuffer functions
*/
#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 |= d; \
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)
d = 0x00FFFFFF - (*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF)
#define TAG(x) savage##x##_8_24
#include "depthtmp.h"
/* 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; \
@@ -315,20 +356,36 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
switch (imesa->savageScreen->zpp)
{
case 2:
swdd->ReadDepthSpan = savageReadDepthSpan_16;
swdd->WriteDepthSpan = savageWriteDepthSpan_16;
swdd->WriteMonoDepthSpan = savageWriteMonoDepthSpan_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->WriteMonoDepthSpan = savageWriteMonoDepthSpan_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;

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

@@ -470,14 +470,14 @@ static void savageDDDepthFunc_s4(GLcontext *ctx, GLenum func)
* 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;
}
@@ -539,14 +539,14 @@ static void savageDDDepthFunc_s3d(GLcontext *ctx, GLenum func)
* 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;
}
@@ -716,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;
}
@@ -1612,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;

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;
}
@@ -468,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);
@@ -492,7 +494,6 @@ viaCreateContext(const __GLcontextModes *mesaVis,
viaInitTriFuncs(ctx);
viaInitSpanFuncs(ctx);
viaInitIoctlFuncs(ctx);
viaInitVB(ctx);
viaInitState(ctx);
#ifdef DEBUG
@@ -555,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);

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
@@ -121,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;
@@ -204,11 +211,12 @@ 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];

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
@@ -629,10 +629,10 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
if (flags & VIA_NO_CLIPRECTS) {
if (0) fprintf(stderr, "%s VIA_NO_CLIPRECTS\n", __FUNCTION__);
assert(vmesa->dmaCliprectAddr == 0);
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, "%s: no dmaCliprectAddr\n", __FUNCTION__);
@@ -673,7 +673,7 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
/* Reset vmesa vars:
*/
vmesa->dmaLow = 0;
vmesa->dmaCliprectAddr = 0;
vmesa->dmaCliprectAddr = ~0;
vmesa->newEmitState = ~0;
}
@@ -747,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;
}
@@ -765,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"
@@ -764,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:
@@ -862,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) {
@@ -919,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;
@@ -999,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__);
@@ -1307,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.
@@ -1322,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;
}
}
@@ -1334,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;
@@ -1344,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 *=*/
@@ -1365,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;
}
}
@@ -1550,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);
@@ -1590,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)

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 \
@@ -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 );
@@ -793,7 +976,7 @@ void viaFinishPrimitive(viaContextPtr vmesa)
if (VIA_DEBUG)
fprintf(stderr, "%s\n", __FUNCTION__);
if (!vmesa->dmaLastPrim || !vmesa->dmaCliprectAddr) {
if (!vmesa->dmaLastPrim || vmesa->dmaCliprectAddr == ~0) {
assert(0);
}
else if (vmesa->dmaLow != vmesa->dmaLastPrim) {
@@ -832,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;
}
}
@@ -858,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;
@@ -867,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);
}
}
}
}
@@ -886,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;
@@ -894,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