Compare commits

..

76 Commits

Author SHA1 Message Date
Brian Paul
068039eec1 no change 2005-03-23 03:34:24 +00:00
Brian Paul
05bbafa01a use $(*_LIB) in the *_LIB_NAME definitions 2005-03-23 02:12:21 +00:00
Keith Whitwell
8fb17f5b3f rename mesaVis to try and improve clarity 2005-03-22 14:30:30 +00:00
Keith Whitwell
3e62d3a8d8 add FreeTexImageData hook to help single-copy texturing in drivers 2005-03-22 14:27:10 +00:00
Keith Whitwell
050b77a9ac merge unichrome changes from branch 2005-03-22 14:25:55 +00:00
Keith Whitwell
59b4b7e07e Remove test for defined(DRM_USE_MALLOC) around definition of
drmSIGIOHandler().
2005-03-22 13:34:27 +00:00
Keith Whitwell
46d50d9e8e Add more formats to test. 2005-03-22 13:32:35 +00:00
Keith Whitwell
de4fe1e3c5 Add DRM_USE_MALLOC flag 2005-03-22 13:31:35 +00:00
Keith Whitwell
7f8e10f96c Calculate haveAccumBuffer, haveDepthBuffer and haveStencilBuffer in
driFillInModes().
2005-03-22 13:16:20 +00:00
Michel Dänzer
e7c7a0f353 Add support for production version of ATI RN50/ES1000. (ATI Technologies
Inc.)
2005-03-18 23:05:07 +00:00
Aapo Tahkola
6bd390743d Misc fixes. 2005-03-18 14:44:27 +00:00
Michal Krol
2fb2e27e28 update against 03-Feb-2005 release 2005-03-18 14:28:02 +00:00
Michal Krol
5b641a516e enable all 3dlabs front-end compiler sources 2005-03-18 14:21:07 +00:00
Michal Krol
706bb1c714 a little program to change // comments to /* */ ones 2005-03-18 14:07:47 +00:00
Michal Krol
1d5c727bba glslang flex and bison sources:
flex glslang.l
bison -t -v -d glslang.y
mv glslang.tab.c Gen_glslang_tab.cpp (shouldn't be .c?)
mv glslang.tab.h glslang_tab.h
2005-03-18 12:18:00 +00:00
Aapo Tahkola
a890ceee63 Fix to get doom3 started. 2005-03-17 22:28:06 +00:00
Ian Romanick
8a7dcd97bd xmllint fixes. Revert 'note_unflushed' changes that were accidetnally
committed in the last version.
2005-03-17 22:01:39 +00:00
Aapo Tahkola
a78bbd0816 Simple TCL stage and ability to disable vps. 2005-03-17 21:50:01 +00:00
Ian Romanick
80a939cafb Enable the generation of server-side __glGetBooleanv_size and related
functions.  There are two parts to this.  First, a size element with a name
"Get" is shorthand for having four separate size elements with names
"GetIntegerv", "GetDoublev", "GetFloatv", and "GetBooleanv".  Additionally,
a count of "?" is treated specially.  This causes a call to a handcoded
function named "__gl<base name>_variable_size".  This is *only* needed to
support GL_COMPRESSED_TEXTURE_FORMATS.  That enum can return a variable
number of values depending how many compressed texture formats are supported
by the implementation.

Fix a problem with glGetProgram{Local,Env}Parameter[df]vARB,
glAreProgramsResidentNV, and glGetVertexAttribivNV.  These changes only
affect code generated for the server-side.

The changes to enum.c are caused by enums added for the server-side
__glGetBooleanv_size functions.
2005-03-17 21:48:37 +00:00
Ian Romanick
6af6a69312 Minor refactoring and code tweaking. The only notable chage is that
FilterGLAPISpecBase::xref is replaced by
FilterGLAPISpecBase::functions_by_name.  The notable difference between the
two is that ::functions_by_name includes all functions, whether they have an
assigned offset or not.  This feature will be useful (necessary) when more
server-side code is generated.
2005-03-17 20:56:13 +00:00
Ian Romanick
979f35fb78 Minor vertex array support tweaks. These are in preparation for the
(eventual) addition of support for ARB_vertex_buffer_object.  Elminitate the
need for array_state_vector::large_header.  Make some very minor tweaks to
the handling of the indices pointer in emit_DrawElements_old.
2005-03-17 20:36:20 +00:00
Ian Romanick
b81efaaa1a Minor vertex array support tweaks. Most of these are in preparation for the
(eventual) addition of support for ARB_vertex_buffer_object.

Move all the private vertex array data structures out of
indirect_vertex_array.c and into indirect_va_private.h.

Rename array_state_vector::enabled_array_count to
array_state_vector::enabled_client_array_count.

Make sure that both the GL extension string and the server GL version are
available when __glXInitVertexState is called.

Make sure that array_state::normalized is set correctly in the array's
gl*Pointer function.
2005-03-17 20:13:09 +00:00
Ian Romanick
00e760c971 Refactored some of the code for PrintGlxReqSize_[ch]. This ensures that the
same set of functions will be iterated for both the generated C-source file
and the generated header file.
2005-03-17 01:50:32 +00:00
Ian Romanick
3f35fbbf66 Fix the handling of zero-sized output parameters (i.e., those with type
'GLvoid *').  This fixes the GLX protocol for glGetProgramStringARB.  This
fixes bugzilla #2747.

Remove the 'ignore="true"' from glVertexAttrib4bvARB.  This fixes bugzilla
#2746.
2005-03-17 01:48:11 +00:00
Ian Romanick
9eae0b9f19 Hard-code the client-side maximum GL version. It turns out that there are
some flaws in the calculation code when the highest version listed in
known_gl_extensions is supported.  This code would also have some problems
with some of the new features (that don't have an associated extension) on
GL 2.0.
2005-03-17 01:36:24 +00:00
Aapo Tahkola
c1aa3d1e6f Proper VAP output configuration as R300_RS_ROUTE_0_COLOR became optional and broke arbvptorus(takes no input color but produces output color). Also removing some useless code. 2005-03-16 22:32:48 +00:00
Ben Skeggs
dd9da8cdb5 Fixed some strangeness when mixing textured/flat primitives. Skipping texture units should render correctly also. Aapo, I dont think I broke glxgears again on you... 2005-03-16 00:54:09 +00:00
Roland Scheidegger
fbe5296d14 add support for user-configurable brilinear filtering on r200 2005-03-15 22:23:29 +00:00
Aapo Tahkola
7541794373 Fix to get glxgears display anything. 2005-03-15 20:55:29 +00:00
Ben Skeggs
3c4c86aff2 For some reason the Makefile didn't commit.. 2005-03-15 17:09:35 +00:00
Ben Skeggs
34dd4843d7 Initial multitexturing support. Old behaviour can be re-enabled by changing ifdefs in r300_setup_rs_unit and r300SetupPixelShader in r300_state.c\nRequires DRM update. 2005-03-15 17:00:44 +00:00
Ian Romanick
7457a648d2 If setting GL_PACK_INVERT_MESA results in a GL error, log it. 2005-03-14 22:09:31 +00:00
Felix Kuehling
bd5bba8470 When timestamping textures, need to emit the event with SAVAGE_WAIT_3D
set. Otherwise the 3D engine may still be using a texture that is
being overwritten. In order to minimize the cost of waiting, timestamp
textures only when needed: when a texture image changes, when a
different texture is bound to a texture unit or when a texture unit is
disabled. (Used to be after flushing every command buffer.)
2005-03-14 21:52:46 +00:00
Peter Zubaj
e2e4a5c992 Stencil support
Reflex from mesa demos doesn't work
TODO - double side stencil
I hope that I didn't break anything
2005-03-14 20:35:00 +00:00
Michal Krol
02eb36fa8d re-enable slang sources 2005-03-14 12:43:59 +00:00
Michal Krol
0c7d2fff1e make it compile under linux 2005-03-14 12:24:32 +00:00
Michal Krol
5c9d21df3d make it compile under gcc 3.3.2 2005-03-14 12:23:14 +00:00
Michal Krol
8998de569c fix enum comma 2005-03-14 12:19:36 +00:00
Aapo Tahkola
278c6025f9 Replacing alpha test bits with values that give desired results as compaired to software rendering. Alpha test in textures is still completely broken as can be seen in progs/demos/fire and various games. 2005-03-13 12:23:08 +00:00
Felix Kuehling
4f05e61543 Updated savage_dri.h from Xorg CVS. This removes definitions that are
not part of the DDX->DRI interface and should never have been in this
file in the first place.
2005-03-13 00:20:03 +00:00
Felix Kuehling
45f26f9979 Removed savagedma.[ch]. They have been unused for a while and were only
kept around for reference. Now that command DMA is implemented in the
DRM module they are no longer needed.
2005-03-12 23:00:53 +00:00
Aapo Tahkola
203bd3e8ec Unlike radeon and r200 drivers r300AllocCmdBuf allocs dwords not bytes. 2005-03-12 10:14:09 +00:00
Ian Romanick
91c219d906 Add support for ARB_draw_buffers and ARB_occlusion_query. The GLX protocol
for these extensions (as well as ARB_vertex_program and ARB_matrix_palette)
was just approved by the ARB on 8-Mar-2005.  Now the only extension missing
for 1.5 support is ARB_vertex_buffer_object.

The opcodes for ARB_matrix_palette were also added to gl_API.xml.  Since
this extension isn't supported by Mesa, no code is generated for it.  Some
tabs were also converted to spaces in the comment for
GetCompressedTexImageARB.
2005-03-11 20:55:03 +00:00
Brian Paul
522ea42718 add MAT_DIRTY_FLAGS in _math_matrix_mul_floats(), (bug 2696) 2005-03-11 14:54:51 +00:00
Paul Mackerras
e24a9c10b5 Add suitable definitions for the _REV formats, plus a comment
explaining why they are the same as the non-REV formats now that
textures don't get byte-swapped on their way to the chip.
Fix the ARGB4444 and L8 formats.
Add entries for the A8 and RGB332 formats.
2005-03-11 11:38:23 +00:00
Felix Kuehling
96035d54f3 - Flush before updating the timestamp of a texture heap from a bound texture.
- Flush before using a new texture or before disabling a texture unit,
  because savageFlushCmdBuf can only update the timestamp of the last
  used texture. This fixes corruption in quake2 with single-textured
  lighting.
2005-03-10 22:45:00 +00:00
Felix Kuehling
746df56717 If the texture image changed force emitting the texture address, even
if it didn't change. This seems to flush texture cashes. Fixes
multi-textured lighting in quake2.
2005-03-09 15:28:47 +00:00
Vladimir Dergachev
5737fda093 Don't use R200 texture constants - R300 fields are all different. 2005-03-09 05:31:31 +00:00
Vladimir Dergachev
439f7feab1 Deal with texture formats in a more robust way. 2005-03-09 00:40:55 +00:00
Aapo Tahkola
f0d484fa5a Replacing some RADEON cmd types with r300 counterparts. 2005-03-08 22:29:45 +00:00
Aapo Tahkola
2579c32a5f Improving Vladimirs alpha test fix a bit as it turns out r300Enable didnt correctly disable alpha test. Vertex programs with high vertex count now run a lot faster as software fallback is no longer on. Also disabling 'temp to result'-instructions as they probably violate the spec and dont seem to be something thats needed. 2005-03-08 03:29:46 +00:00
Ian Romanick
0bd5373d94 Actually *use* the count_scale value associated with a parameter. 2005-03-06 08:55:39 +00:00
Felix Kuehling
9d05d3dd30 Don't synchronize after each frame. Allow the GPU to be one frame
ahead of the CPU for more parallelism of CPU and GPU. Unfortunately
there seems to be some broken hardware (like my ProSavageDDR) on which
status register updates are delayed sometimes. This leads to very
jerky animation if the hardware can buffer more than the current
frame. A new option "sync_frames" can be used as a remedy on such
broken hardware.
2005-03-06 03:52:01 +00:00
Felix Kuehling
e6aa21156a - Fixed two bugs related to DMA buffer handling that showed up with the
new DRM version 2.4 and command DMA.
- Flush less.
- Bumped the driver date.
2005-03-06 01:28:30 +00:00
Vladimir Dergachev
a30402b56a Add format 15. It turned out to be X,X,X,X,X8. 2005-03-05 22:20:57 +00:00
Dave Airlie
07561c6b32 Fixing memset on ia64 & other archs
From: Stephane Marchesin
2005-03-05 06:38:59 +00:00
Vladimir Dergachev
a4296239d4 Enable VB mode rendering by default. If anyone thinks this is wrong, *please* feel free to change it back.
My reasons:

    * immediate mode is broken
    * vb mode is faster
    * vb mode is the right way to do it.
2005-03-05 06:31:36 +00:00
Vladimir Dergachev
3f9467c946 Do properly initialize ALPHA_TEST register instead of carefully preserving bogus value. This fixes many, many rendering issues which I wrongly blamed on texture programming or performance.. 2005-03-05 06:10:09 +00:00
Dave Airlie
1bb14ad90c fix for solo to set the mode, and make solo gcc2 friendly...
From: Stephane Marchesin
2005-03-05 04:00:09 +00:00
Roland Scheidegger
87030f6618 remove one of the two _tnl_isolate_materials function calls 2005-03-05 00:04:20 +00:00
Adam Jackson
8ff72e9723 Add preliminary EGL headers. 2005-03-04 20:18:55 +00:00
Ian Romanick
b47731f24d Import fixes from X.org tree (Søren Sandmann <sandmann@redhat.com>). 2005-03-04 17:53:24 +00:00
Rune Petersen
bc6bf401f5 Set pipes for R420 cards. Gives a nice speedup. This needs to be tested on r420 cards with less than 16 pipes. 2005-03-04 15:48:40 +00:00
Vladimir Dergachev
984d527626 Add a couple of helper functions for completeness. 2005-03-03 23:18:19 +00:00
Ian Romanick
fdb5a87f91 Fix some errors in the parameter descriptions in serveral vertex / fragment
program related functions.
2005-03-03 21:22:46 +00:00
Ian Romanick
ce77d37264 Check for some common function parameter description errors in the
endElement handler for <function>.  This catches the errors as early as
possible and makes debugging other code easier.
2005-03-03 21:21:59 +00:00
Ian Romanick
6e776f25fd When building in the X-Server, attr.depth doesn't exist. Instead, use
(XMesaDrawable)w)->depth in the error message.
2005-03-03 19:56:11 +00:00
Brian Paul
c1f2f9090b change gl_buffer_object's Size field to GLsizeiptrARB type 2005-03-03 02:05:33 +00:00
Brian Paul
7644bfb536 Added linux-x86-32 config to force building 32-bit objects in a 64-bit environment. 2005-03-03 01:44:42 +00:00
Brian Paul
3e1961839e if building 32-bit objects in 64-bit environment, use -m32 flag 2005-03-03 01:38:13 +00:00
Alan Hourihane
fff3b2f318 use COPY_CLEAN_4V macro to replace using both ASSIGN_4V & COPY_SZ_4V 2005-03-02 18:57:01 +00:00
Brian Paul
b960c14cbb Added a bunch of new comments, minor code clean-ups. 2005-03-02 16:37:24 +00:00
Brian Paul
3db7ae3a38 Using glColor3 commands to update materials could result in an undefined
alpha value.  Fixed.
2005-03-02 16:31:58 +00:00
Brian Paul
7cd2ae9d97 added stub functions for GLX_MESA_allocate_memory 2005-03-01 02:51:07 +00:00
Ian Romanick
03dc437363 Clean-up some warnings caused by the addition of vertex / fragment program
protocol support (reported by Adam Jackson).  Added code to validate the
'type' parameter to the draw element functions.
2005-02-28 19:37:10 +00:00
Brian Paul
80875253ce additional parenthesis in TNL_CONTEXT macro (Nicolai Haehnle) 2005-02-28 17:45:11 +00:00
169 changed files with 24464 additions and 18032 deletions

View File

@@ -105,6 +105,7 @@ linux-ultrasparc \
linux-tcc \
linux-x86 \
linux-x86-debug \
linux-x86-32 \
linux-x86-64 \
linux-x86-64-static \
linux-x86-glide \

View File

@@ -173,6 +173,15 @@ case $ARCH in
OPTS="${OPTS} -Xlinker --version-script=exptmp"
# exptmp is removed below
fi
# Check if objects are 32-bit and we're running in 64-bit
# environment. If so, pass -m32 flag to linker.
set ${OBJECTS}
ABI32=`file $1 | grep 32-bit`
if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
OPTS="-m32 ${OPTS}"
fi
if [ x${PATCH} = "x" ] ; then
VERSION="${MAJOR}.${MINOR}"
else

View File

@@ -35,11 +35,11 @@ OSMESA_LIB = OSMesa
# Library names (actual file names)
GL_LIB_NAME = libGL.so
GLU_LIB_NAME = libGLU.so
GLUT_LIB_NAME = libglut.so
GLW_LIB_NAME = libGLw.so
OSMESA_LIB_NAME = libOSMesa.so
GL_LIB_NAME = lib$(GL_LIB).so
GLU_LIB_NAME = lib$(GLU_LIB).so
GLUT_LIB_NAME = lib$(GLUT_LIB).so
GLW_LIB_NAME = lib$(GLW_LIB).so
OSMESA_LIB_NAME = lib$(OSMesa).so
# Optional assembly language optimization files for libGL

View File

@@ -8,7 +8,7 @@ CONFIG_NAME = linux-solo
CC = gcc
CXX = g++
DEFINES = -DDRI_NEW_INTERFACE_ONLY -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE -DUSE_EXTERNAL_DXTN_LIB=1
DEFINES = -DDRI_NEW_INTERFACE_ONLY -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE -DUSE_EXTERNAL_DXTN_LIB=1 -DDRM_USE_MALLOC
CFLAGS = $(DEFINES) -Wmissing-prototypes -g -std=c99 -Wundef -fPIC -ffast-math

View File

@@ -8,7 +8,7 @@ CONFIG_NAME = linux-solo-ia64
CC = gcc
CXX = g++
DEFINES = -DDRI_NEW_INTERFACE_ONLY -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE
DEFINES = -DDRI_NEW_INTERFACE_ONLY -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE -DDRM_USE_MALLOC
CFLAGS = $(DEFINES) -Wmissing-prototypes -g -std=c99 -Wundef -fPIC -ffast-math

View File

@@ -8,7 +8,7 @@ CONFIG_NAME = linux-solo-x86
CC = gcc
CXX = g++
DEFINES = -DDRI_NEW_INTERFACE_ONLY -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1
DEFINES = -DDRI_NEW_INTERFACE_ONLY -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DDRM_USE_MALLOC
CFLAGS = $(DEFINES) -Wmissing-prototypes -O3 -g -std=c99 -Wundef -fPIC -ffast-math

13
configs/linux-x86-32 Normal file
View File

@@ -0,0 +1,13 @@
# To build Linux x86 32-bit in an x86-64 environment
include $(TOP)/configs/linux-x86
CONFIG_NAME = linux-x86-32
# Other than -m32, these are the same as in linux-x86, which we included above.
CFLAGS = -m32 -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include
CXXFLAGS = -m32 -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE

232
include/GLES/egl.h Normal file
View File

@@ -0,0 +1,232 @@
#ifndef _EGL_H
#define _EGL_H
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.0 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
*/
#include <GL/gl.h>
#include <GLES/egltypes.h>
/* XXX should go in eglext.h */
#define GL_OES_VERSION_1_0 1
#define GL_OES_read_format 1
#define GL_OES_compressed_paletted_texture 1
#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
#define GL_PALETTE4_RGB8_OES 0x8B90
#define GL_PALETTE4_RGBA8_OES 0x8B91
#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
#define GL_PALETTE4_RGBA4_OES 0x8B93
#define GL_PALETTE4_RGB5_A1_OES 0x8B94
#define GL_PALETTE8_RGB8_OES 0x8B95
#define GL_PALETTE8_RGBA8_OES 0x8B96
#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
#define GL_PALETTE8_RGBA4_OES 0x8B98
#define GL_PALETTE8_RGB5_A1_OES 0x8B99
/* XXX */
/*
** Versioning and extensions
*/
#define EGL_VERSION_1_0 1
#if 0
#define EGL_VERSION_1_1 1
#endif
/*
** Boolean
*/
#define EGL_FALSE 0
#define EGL_TRUE 1
/*
** Errors
*/
#define EGL_SUCCESS 0x3000
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_BAD_ACCESS 0x3002
#define EGL_BAD_ALLOC 0x3003
#define EGL_BAD_ATTRIBUTE 0x3004
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300A
#define EGL_BAD_NATIVE_WINDOW 0x300B
#define EGL_BAD_PARAMETER 0x300C
#define EGL_BAD_SURFACE 0x300D
#define EGL_CONTEXT_LOST 0x300E
/* 0x300F - 0x301F reserved for additional errors. */
/*
** Config attributes
*/
#define EGL_BUFFER_SIZE 0x3020
#define EGL_ALPHA_SIZE 0x3021
#define EGL_BLUE_SIZE 0x3022
#define EGL_GREEN_SIZE 0x3023
#define EGL_RED_SIZE 0x3024
#define EGL_DEPTH_SIZE 0x3025
#define EGL_STENCIL_SIZE 0x3026
#define EGL_CONFIG_CAVEAT 0x3027
#define EGL_CONFIG_ID 0x3028
#define EGL_LEVEL 0x3029
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
#define EGL_MAX_PBUFFER_PIXELS 0x302B
#define EGL_MAX_PBUFFER_WIDTH 0x302C
#define EGL_NATIVE_RENDERABLE 0x302D
#define EGL_NATIVE_VISUAL_ID 0x302E
#define EGL_NATIVE_VISUAL_TYPE 0x302F
/*#define EGL_PRESERVED_RESOURCES 0x3030*/
#define EGL_SAMPLES 0x3031
#define EGL_SAMPLE_BUFFERS 0x3032
#define EGL_SURFACE_TYPE 0x3033
#define EGL_TRANSPARENT_TYPE 0x3034
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
#define EGL_TRANSPARENT_RED_VALUE 0x3037
#define EGL_NONE 0x3038 /* Also a config value */
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
#define EGL_MIN_SWAP_INTERVAL 0x303B
#define EGL_MAX_SWAP_INTERVAL 0x303C
/*
** Config values
*/
#define EGL_DONT_CARE ((EGLint) -1)
#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */
#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* " */
#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */
#define EGL_NO_TEXTURE 0x305C /* EGL_TEXTURE_FORMAT/TARGET value */
#define EGL_TEXTURE_RGB 0x305D /* EGL_TEXTURE_FORMAT value */
#define EGL_TEXTURE_RGBA 0x305E /* " */
#define EGL_TEXTURE_2D 0x305F /* EGL_TEXTURE_TARGET value */
/*
** Config attribute mask bits
*/
#define EGL_PBUFFER_BIT 0x01 /* EGL_SURFACE_TYPE mask bit */
#define EGL_PIXMAP_BIT 0x02 /* " */
#define EGL_WINDOW_BIT 0x04 /* " */
/*
** String names
*/
#define EGL_VENDOR 0x3053 /* eglQueryString target */
#define EGL_VERSION 0x3054 /* " */
#define EGL_EXTENSIONS 0x3055 /* " */
/*
** Surface attributes
*/
#define EGL_HEIGHT 0x3056
#define EGL_WIDTH 0x3057
#define EGL_LARGEST_PBUFFER 0x3058
#define EGL_TEXTURE_FORMAT 0x3080 /* For pbuffers bound as textures */
#define EGL_TEXTURE_TARGET 0x3081 /* " */
#define EGL_MIPMAP_TEXTURE 0x3082 /* " */
#define EGL_MIPMAP_LEVEL 0x3083 /* " */
/*
** BindTexImage / ReleaseTexImage buffer target
*/
#define EGL_BACK_BUFFER 0x3084
/*
** Current surfaces
*/
#define EGL_DRAW 0x3059
#define EGL_READ 0x305A
/*
** Engines
*/
#define EGL_CORE_NATIVE_ENGINE 0x305B
/* 0x305C-0x3FFFF reserved for future use */
/*
** Functions
*/
#ifdef __cplusplus
extern "C" {
#endif
GLAPI EGLint APIENTRY eglGetError (void);
GLAPI EGLDisplay APIENTRY eglGetDisplay (NativeDisplayType display);
GLAPI EGLBoolean APIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
GLAPI EGLBoolean APIENTRY eglTerminate (EGLDisplay dpy);
GLAPI const char * APIENTRY eglQueryString (EGLDisplay dpy, EGLint name);
GLAPI void (* APIENTRY eglGetProcAddress (const char *procname))();
GLAPI EGLBoolean APIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
GLAPI EGLBoolean APIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
GLAPI EGLBoolean APIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
GLAPI EGLSurface APIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
GLAPI EGLSurface APIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list);
GLAPI EGLSurface APIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
GLAPI EGLBoolean APIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
GLAPI EGLBoolean APIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
/* EGL 1.1 render-to-texture APIs */
GLAPI EGLBoolean APIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
GLAPI EGLBoolean APIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
GLAPI EGLBoolean APIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
/* EGL 1.1 swap control API */
GLAPI EGLBoolean APIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
GLAPI EGLContext APIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
GLAPI EGLBoolean APIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
GLAPI EGLBoolean APIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
GLAPI EGLContext APIENTRY eglGetCurrentContext (void);
GLAPI EGLSurface APIENTRY eglGetCurrentSurface (EGLint readdraw);
GLAPI EGLDisplay APIENTRY eglGetCurrentDisplay (void);
GLAPI EGLBoolean APIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
GLAPI EGLBoolean APIENTRY eglWaitGL (void);
GLAPI EGLBoolean APIENTRY eglWaitNative (EGLint engine);
GLAPI EGLBoolean APIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface draw);
GLAPI EGLBoolean APIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, NativePixmapType target);
#ifdef __cplusplus
}
#endif
#endif /* _EGL_H */

48
include/GLES/egltypes.h Normal file
View File

@@ -0,0 +1,48 @@
/*
* egltypes.h - EGL API compatibility
*
* The intention here is to support multiple EGL implementations for the
* various backends - GLX, AGL, WGL, Solo - so we define the EGL types as
* opaque handles. We also define the Native types as opaque handles for
* now, which should be fine for GLX and Solo but the others who knows.
* They can extend this later.
*
* We require that 'int' be 32 bits. Other than that this should be pretty
* portable.
*
* Derived from the OpenGL|ES 1.1 egl.h on the Khronos website:
* http://www.khronos.org/opengles/spec_headers/opengles1_1/egl.h
*
*/
#ifndef _EGLTYPES_H
#define _EGLTYPES_H
#include <sys/types.h>
/*
* Native types
*/
typedef void *NativeDisplayType;
typedef void *NativePixmapType;
typedef void *NativeWindowType;
/*
* Types and resources
*/
typedef GLboolean EGLBoolean;
typedef GLint EGLint;
typedef void *EGLDisplay;
typedef void *EGLConfig;
typedef void *EGLSurface;
typedef void *EGLContext;
/*
* EGL and native handle values
*/
#define EGL_DEFAULT_DISPLAY ((NativeDisplayType)0)
#define EGL_NO_CONTEXT ((EGLContext)0)
#define EGL_NO_DISPLAY ((EGLDisplay)0)
#define EGL_NO_SURFACE ((EGLSurface)0)
#endif /* _EGLTYPES_H */

View File

@@ -47,7 +47,6 @@ static GLdouble DownloadRate = 0.0; /* texels/sec */
static GLuint Mode = 0;
#define NUM_FORMATS 4
struct FormatRec {
GLenum Format;
GLenum Type;
@@ -56,15 +55,20 @@ struct FormatRec {
};
static const struct FormatRec FormatTable[NUM_FORMATS] = {
static const struct FormatRec FormatTable[] = {
/* Format Type IntFormat TexelSize */
{ GL_BGRA, GL_UNSIGNED_BYTE, GL_RGBA, 4 },
{ GL_RGB, GL_UNSIGNED_BYTE, GL_RGB, 3 },
{ GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA, 4 },
{ GL_RGBA, GL_UNSIGNED_BYTE, GL_RGB, 4 },
{ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB, 2 },
{ GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE, 1 },
{ GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE_ALPHA, 2 },
{ GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA, 1 },
};
static GLint Format;
#define NUM_FORMATS (sizeof(FormatTable)/sizeof(FormatTable[0]))
static int
BytesPerTexel(GLint format)
@@ -81,6 +85,14 @@ FormatStr(GLenum format)
return "GL_RGB";
case GL_RGBA:
return "GL_RGBA";
case GL_BGRA:
return "GL_BGRA";
case GL_LUMINANCE:
return "GL_LUMINANCE";
case GL_LUMINANCE_ALPHA:
return "GL_LUMINANCE_ALPHA";
case GL_ALPHA:
return "GL_ALPHA";
default:
return "";
}
@@ -314,6 +326,11 @@ Key(unsigned char key, int x, int y)
Format = (Format + 1) % NUM_FORMATS;
Mode = 0;
break;
case 'F':
/* change format */
Format = (Format - 1) % NUM_FORMATS;
Mode = 0;
break;
case 'p':
/* toggle border */
ScaleAndBias = !ScaleAndBias;

View File

@@ -56,6 +56,9 @@ PFNGLWINDOWPOS2IPROC win_pos_2i = NULL;
static void Display( void )
{
GLint err;
glClearColor(0.2, 0.2, 0.8, 0);
glClear( GL_COLOR_BUFFER_BIT );
@@ -67,11 +70,23 @@ static void Display( void )
glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, image );
glPixelStorei( GL_PACK_INVERT_MESA, GL_FALSE );
err = glGetError();
if ( err != GL_NO_ERROR ) {
printf( "Setting PACK_INVERT_MESA to false generated an error (0x%04x).\n",
err );
}
glReadPixels( 5, 5, img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image );
(*win_pos_2i)( 5 + 1 * (10 + img_width), 5 );
glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image );
glPixelStorei( GL_PACK_INVERT_MESA, GL_TRUE );
err = glGetError();
if ( err != GL_NO_ERROR ) {
printf( "Setting PACK_INVERT_MESA to true generated an error (0x%04x).\n",
err );
}
glReadPixels( 5, 5, img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image );
(*win_pos_2i)( 5 + 2 * (10 + img_width), 5 );
glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image );

View File

@@ -1103,6 +1103,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc)
drmVersionPtr version;
drm_handle_t hFB;
int junk;
drm_magic_t magic;
err_msg = "XF86DRIOpenConnection";
err_extra = NULL;
@@ -1117,8 +1118,6 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc)
if (fd < 0) goto done;
drm_magic_t magic;
err_msg = "drmGetMagic";
err_extra = NULL;
@@ -2053,6 +2052,7 @@ glXCreateContext( Display *dpy, XVisualInfo *vis,
else
sharePriv = NULL;
ctx->driContext.mode = vis->visual->mode;
ctx->driContext.private = dpy->driScreen.createNewContext(dpy, vis->visual->mode,
GLX_WINDOW_BIT, sharePriv, &ctx->driContext);

View File

@@ -278,14 +278,16 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
{
xGLXCreateWindowReq * req;
CARD32 * data;
unsigned int i;
unsigned int i;
for ( i = 0 ; attrib_list[i * 2] != None ; i++ )
/* empty */ ;
i = 0;
if (attrib_list) {
while (attrib_list[i * 2] != None)
i++;
}
LockDisplay(dpy);
GetReqExtra( GLXCreateWindow, 20 + (8 * i), req );
GetReqExtra( GLXCreateWindow, 8 * i, req );
data = (CARD32 *) (req + 1);
req->reqType = __glXSetupForCommand(dpy);
@@ -293,12 +295,15 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
req->screen = (CARD32) fbconfig->screen;
req->fbconfig = fbconfig->fbconfigID;
req->window = (GLXPbuffer) drawable;
req->glxwindow = (GLXWindow) XAllocID(dpy);
req->numAttribs = (CARD32) i;
memcpy( data, attrib_list, 8 * i );
UnlockDisplay(dpy);
SyncHandle();
return drawable;
return (GLXDrawable)req->glxwindow;
}
@@ -355,10 +360,11 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
CARD32 * data;
unsigned int i;
for ( i = 0 ; attrib_list[i * 2] != None ; i++ )
/* empty */ ;
i = 0;
if (attrib_list) {
while (attrib_list[i * 2])
i++;
}
LockDisplay(dpy);
id = XAllocID(dpy);

View File

@@ -1768,6 +1768,7 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
gc->currentContextTag = reply.contextTag;
if ( state->array_state == NULL ) {
(void) glGetString( GL_EXTENSIONS );
(void) glGetString( GL_VERSION );
__glXInitVertexArrayState(gc);
}
}

View File

@@ -112,12 +112,13 @@ static const struct extension_info known_glx_extensions[] = {
static const struct extension_info known_gl_extensions[] = {
{ GL(ARB_depth_texture), VER(1,4), Y, N, N, N },
{ GL(ARB_draw_buffers), VER(0,0), Y, N, N, N },
{ GL(ARB_fragment_program), VER(0,0), Y, N, N, N },
{ GL(ARB_fragment_program_shadow), VER(0,0), Y, N, N, N },
{ GL(ARB_imaging), VER(0,0), Y, N, N, N },
{ GL(ARB_multisample), VER(1,3), Y, N, N, N },
{ GL(ARB_multitexture), VER(1,3), Y, N, N, N },
{ GL(ARB_occlusion_query), VER(1,5), N, N, N, N },
{ GL(ARB_occlusion_query), VER(1,5), Y, N, N, N },
{ GL(ARB_point_parameters), VER(1,4), Y, N, N, N },
{ GL(ARB_point_sprite), VER(0,0), Y, N, N, N },
{ GL(ARB_shadow), VER(1,4), Y, N, N, N },
@@ -184,6 +185,7 @@ static const struct extension_info known_gl_extensions[] = {
{ GL(3DFX_texture_compression_FXT1), VER(0,0), Y, N, N, N },
{ GL(APPLE_packed_pixels), VER(1,2), Y, N, N, N },
{ GL(APPLE_ycbcr_422), VER(0,0), Y, N, N, N },
{ GL(ATI_draw_buffers), VER(0,0), Y, N, N, N },
{ GL(ATI_text_fragment_shader), VER(0,0), Y, N, N, N },
{ GL(ATI_texture_env_combine3), VER(0,0), Y, N, N, N },
{ GL(ATI_texture_float), VER(0,0), Y, N, N, N },
@@ -264,8 +266,8 @@ static unsigned char direct_glx_support[8];
/**
* Highest core GL version that can be supported for indirect rendering.
*/
static unsigned gl_major = 0;
static unsigned gl_minor = 0;
static const unsigned gl_major = 1;
static const unsigned gl_minor = 4;
/* client extensions string */
static const char * __glXGLXClientExtensions = NULL;
@@ -384,11 +386,8 @@ __glXScrEnableExtension( __GLXscreenConfigs *psc, const char * name )
static void
__glXExtensionsCtr( void )
{
static const char major_table[32] = { 1, 1, 1, 1, 1, 1, 2, };
static const char minor_table[32] = { 0, 1, 2, 3, 4, 5, 0, };
unsigned i;
static GLboolean ext_list_first_time = GL_TRUE;
unsigned full_support = ~0;
if ( ext_list_first_time ) {
@@ -428,31 +427,12 @@ __glXExtensionsCtr( void )
if ( known_gl_extensions[i].client_support ) {
SET_BIT( client_gl_support, bit );
}
else if ( known_gl_extensions[i].version_major != 0 ) {
/* If an extension that is required for some core GL version is
* not supported, clear the bit for that core GL version as well.
*/
unsigned ver_bit = (6 * (known_gl_extensions[i].version_major - 1))
+ (known_gl_extensions[i].version_minor);
full_support &= ~(1U << ver_bit);
}
if ( known_gl_extensions[i].client_only ) {
SET_BIT( client_gl_only, bit );
}
}
/* Determine the lowest unsupported core GL version. The version before
* that is, therefore, the highest supported core GL version.
*/
for ( i = 0 ; (full_support & (1 << i)) != 0 ; i++ )
/* empty */ ;
i--;
gl_major = major_table[i];
gl_minor = minor_table[i];
#if 0
fprintf( stderr, "[%s:%u] Maximum client library version: %u.%u\n",
__func__, __LINE__, gl_major, gl_minor );

View File

@@ -74,6 +74,7 @@ enum {
enum {
GL_ARB_depth_texture_bit = 0,
GL_ARB_draw_buffers_bit,
GL_ARB_fragment_program_bit,
GL_ARB_fragment_program_shadow_bit,
GL_ARB_imaging_bit,
@@ -212,6 +213,7 @@ enum {
*/
GL_ATI_blend_equation_separate_bit = GL_EXT_blend_equation_separate_bit,
GL_ATI_draw_buffers_bit = GL_ARB_draw_buffers_bit,
GL_ATIX_texture_env_combine3_bit = GL_ATI_texture_env_combine3_bit,
GL_EXT_point_parameters_bit = GL_ARB_point_parameters_bit,
GL_EXT_texture_env_add_bit = GL_ARB_texture_env_add_bit,

View File

@@ -5451,6 +5451,35 @@ __indirect_glSampleCoverageARB(GLclampf value, GLboolean invert)
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
#define X_GLrop_DrawBuffersARB 233
void
__indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ( (gc->pc + cmdlen) > gc->bufEnd ) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
}
emit_header(gc->pc, X_GLrop_DrawBuffersARB, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(bufs), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
else {
const GLint op = X_GLrop_DrawBuffersARB;
const GLuint cmdlenLarge = cmdlen + 4;
GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
(void) memcpy((void *)(pc + 4), (void *)(&op), 4);
(void) memcpy((void *)(pc + 8), (void *)(&n), 4);
__glXSendLargeCommand(gc, pc, 12, bufs, (n * 4));
}
}
}
#define X_GLvop_AreTexturesResidentEXT 11
GLboolean
__indirect_glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, GLboolean * residences)
@@ -6062,14 +6091,16 @@ void
__indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 16 + __GLX_PAD((num * 8));
emit_header(gc->pc, X_GLrop_ProgramParameters4dvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(&num), 4);
(void) memcpy((void *)(gc->pc + 16), (void *)(params), (num * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 16 + __GLX_PAD(((num * 4) * 8));
if (__builtin_expect(num >= 0, 1)) {
emit_header(gc->pc, X_GLrop_ProgramParameters4dvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(&num), 4);
(void) memcpy((void *)(gc->pc + 16), (void *)(params), ((num * 4) * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_ProgramParameters4fvNV 4186
@@ -6077,13 +6108,13 @@ void
__indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 16 + __GLX_PAD((num * 4));
const GLuint cmdlen = 16 + __GLX_PAD(((num * 4) * 4));
if (__builtin_expect(num >= 0, 1)) {
emit_header(gc->pc, X_GLrop_ProgramParameters4fvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(&num), 4);
(void) memcpy((void *)(gc->pc + 16), (void *)(params), (num * 4));
(void) memcpy((void *)(gc->pc + 16), (void *)(params), ((num * 4) * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
@@ -6531,13 +6562,15 @@ void
__indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 2) * 8));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 2) * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs2fvNV 4207
@@ -6545,13 +6578,15 @@ void
__indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 2) * 4));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 2) * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs2svNV 4203
@@ -6559,13 +6594,15 @@ void
__indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 2));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 2) * 2));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 2) * 2));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs3dvNV 4212
@@ -6573,13 +6610,15 @@ void
__indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 3) * 8));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 3) * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs3fvNV 4208
@@ -6587,13 +6626,15 @@ void
__indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 3) * 4));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 3) * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs3svNV 4204
@@ -6601,13 +6642,15 @@ void
__indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 2));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 3) * 2));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 3) * 2));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs4dvNV 4213
@@ -6615,13 +6658,15 @@ void
__indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 4) * 8));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 4) * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs4fvNV 4209
@@ -6629,13 +6674,15 @@ void
__indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 4) * 4));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 4) * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs4svNV 4205
@@ -6643,13 +6690,15 @@ void
__indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 2));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 4) * 2));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 4) * 2));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_VertexAttribs4ubvNV 4214
@@ -6657,13 +6706,15 @@ void
__indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12 + __GLX_PAD((n * 1));
emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 1));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
const GLuint cmdlen = 12 + __GLX_PAD(((n * 4) * 1));
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
(void) memcpy((void *)(gc->pc + 12), (void *)(v), ((n * 4) * 1));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
}
#define X_GLrop_PointParameteriNV 4221
@@ -6705,6 +6756,19 @@ __indirect_glActiveStencilFaceEXT(GLenum face)
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
#define X_GLrop_VertexAttrib4bvARB 4230
void
__indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte * v)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12;
emit_header(gc->pc, X_GLrop_VertexAttrib4bvARB, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
#define X_GLrop_VertexAttrib4ivARB 4231
void
__indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v)
@@ -7007,7 +7071,7 @@ __indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string)
GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramStringARB, cmdlen);
(void) memcpy((void *)(pc + 0), (void *)(&target), 4);
(void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
(void) __glXReadReply(dpy, 0, string, GL_TRUE);
(void) __glXReadReply(dpy, 1, string, GL_TRUE);
UnlockDisplay(dpy); SyncHandle();
}
return;
@@ -7123,6 +7187,131 @@ __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte
return;
}
#define X_GLsop_GenQueriesARB 162
void
__indirect_glGenQueriesARB(GLsizei n, GLuint * ids)
{
__GLXcontext * const gc = __glXGetCurrentContext();
Display * const dpy = gc->currentDpy;
const GLuint cmdlen = 4;
if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GenQueriesARB, cmdlen);
(void) memcpy((void *)(pc + 0), (void *)(&n), 4);
(void) __glXReadReply(dpy, 4, ids, GL_FALSE);
UnlockDisplay(dpy); SyncHandle();
}
return;
}
#define X_GLsop_DeleteQueriesARB 161
void
__indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids)
{
__GLXcontext * const gc = __glXGetCurrentContext();
Display * const dpy = gc->currentDpy;
const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_DeleteQueriesARB, cmdlen);
(void) memcpy((void *)(pc + 0), (void *)(&n), 4);
(void) memcpy((void *)(pc + 4), (void *)(ids), (n * 4));
UnlockDisplay(dpy); SyncHandle();
}
return;
}
#define X_GLsop_IsQueryARB 163
GLboolean
__indirect_glIsQueryARB(GLuint id)
{
__GLXcontext * const gc = __glXGetCurrentContext();
Display * const dpy = gc->currentDpy;
GLboolean retval = (GLboolean) 0;
const GLuint cmdlen = 4;
if (__builtin_expect(dpy != NULL, 1)) {
GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_IsQueryARB, cmdlen);
(void) memcpy((void *)(pc + 0), (void *)(&id), 4);
retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE);
UnlockDisplay(dpy); SyncHandle();
}
return retval;
}
#define X_GLrop_BeginQueryARB 231
void
__indirect_glBeginQueryARB(GLenum target, GLuint id)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 12;
emit_header(gc->pc, X_GLrop_BeginQueryARB, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
(void) memcpy((void *)(gc->pc + 8), (void *)(&id), 4);
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
#define X_GLrop_EndQueryARB 232
void
__indirect_glEndQueryARB(GLenum target)
{
__GLXcontext * const gc = __glXGetCurrentContext();
const GLuint cmdlen = 8;
emit_header(gc->pc, X_GLrop_EndQueryARB, cmdlen);
(void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
}
#define X_GLsop_GetQueryivARB 164
void
__indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params)
{
__GLXcontext * const gc = __glXGetCurrentContext();
Display * const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
if (__builtin_expect(dpy != NULL, 1)) {
GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetQueryivARB, cmdlen);
(void) memcpy((void *)(pc + 0), (void *)(&target), 4);
(void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
(void) __glXReadReply(dpy, 4, params, GL_FALSE);
UnlockDisplay(dpy); SyncHandle();
}
return;
}
#define X_GLsop_GetQueryObjectivARB 165
void
__indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params)
{
__GLXcontext * const gc = __glXGetCurrentContext();
Display * const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
if (__builtin_expect(dpy != NULL, 1)) {
GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetQueryObjectivARB, cmdlen);
(void) memcpy((void *)(pc + 0), (void *)(&id), 4);
(void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
(void) __glXReadReply(dpy, 4, params, GL_FALSE);
UnlockDisplay(dpy); SyncHandle();
}
return;
}
#define X_GLsop_GetQueryObjectuivARB 166
void
__indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params)
{
__GLXcontext * const gc = __glXGetCurrentContext();
Display * const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
if (__builtin_expect(dpy != NULL, 1)) {
GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetQueryObjectuivARB, cmdlen);
(void) memcpy((void *)(pc + 0), (void *)(&id), 4);
(void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
(void) __glXReadReply(dpy, 4, params, GL_FALSE);
UnlockDisplay(dpy); SyncHandle();
}
return;
}
#define X_GLvop_GetVertexAttribdvNV 1301
void
__indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble * params)

View File

@@ -482,6 +482,7 @@ extern HIDDEN void __indirect_glLoadTransposeMatrixdARB(const GLdouble * m);
extern HIDDEN void __indirect_glMultTransposeMatrixfARB(const GLfloat * m);
extern HIDDEN void __indirect_glMultTransposeMatrixdARB(const GLdouble * m);
extern HIDDEN void __indirect_glSampleCoverageARB(GLclampf value, GLboolean invert);
extern HIDDEN void __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs);
extern HIDDEN GLboolean __indirect_glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, GLboolean * residences);
extern HIDDEN void __indirect_glGenTexturesEXT(GLsizei n, GLuint * textures);
extern HIDDEN GLboolean __indirect_glIsTextureEXT(GLuint texture);
@@ -610,6 +611,7 @@ extern HIDDEN void __indirect_glPointParameterivNV(GLenum pname, const GLint * p
extern HIDDEN void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount);
extern HIDDEN void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount);
extern HIDDEN void __indirect_glActiveStencilFaceEXT(GLenum face);
extern HIDDEN void __indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte * v);
extern HIDDEN void __indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v);
extern HIDDEN void __indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte * v);
extern HIDDEN void __indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v);
@@ -643,6 +645,14 @@ extern HIDDEN void __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei le
extern HIDDEN void __indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v);
extern HIDDEN void __indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params);
extern HIDDEN void __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params);
extern HIDDEN void __indirect_glGenQueriesARB(GLsizei n, GLuint * ids);
extern HIDDEN void __indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids);
extern HIDDEN GLboolean __indirect_glIsQueryARB(GLuint id);
extern HIDDEN void __indirect_glBeginQueryARB(GLenum target, GLuint id);
extern HIDDEN void __indirect_glEndQueryARB(GLenum target);
extern HIDDEN void __indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params);
extern HIDDEN void __indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble * params);
extern HIDDEN void __indirect_glGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat * params);
extern HIDDEN void __indirect_glGetVertexAttribivNV(GLuint index, GLenum pname, GLint * params);

View File

@@ -503,6 +503,10 @@ __GLapi * __glXNewIndirectAPI( void )
glAPI->SampleCoverageARB = __indirect_glSampleCoverageARB;
/* GL_ARB_draw_buffers */
glAPI->DrawBuffersARB = __indirect_glDrawBuffersARB;
/* GL_EXT_texture_object */
glAPI->AreTexturesResidentEXT = __indirect_glAreTexturesResidentEXT;
@@ -684,6 +688,7 @@ __GLapi * __glXNewIndirectAPI( void )
/* GL_ARB_vertex_program */
glAPI->VertexAttrib4bvARB = __indirect_glVertexAttrib4bvARB;
glAPI->VertexAttrib4ivARB = __indirect_glVertexAttrib4ivARB;
glAPI->VertexAttrib4ubvARB = __indirect_glVertexAttrib4ubvARB;
glAPI->VertexAttrib4usvARB = __indirect_glVertexAttrib4usvARB;
@@ -721,6 +726,17 @@ __GLapi * __glXNewIndirectAPI( void )
glAPI->GetProgramNamedParameterfvNV = __indirect_glGetProgramNamedParameterfvNV;
glAPI->GetProgramNamedParameterdvNV = __indirect_glGetProgramNamedParameterdvNV;
/* GL_ARB_occlusion_query */
glAPI->GenQueriesARB = __indirect_glGenQueriesARB;
glAPI->DeleteQueriesARB = __indirect_glDeleteQueriesARB;
glAPI->IsQueryARB = __indirect_glIsQueryARB;
glAPI->BeginQueryARB = __indirect_glBeginQueryARB;
glAPI->EndQueryARB = __indirect_glEndQueryARB;
glAPI->GetQueryivARB = __indirect_glGetQueryivARB;
glAPI->GetQueryObjectivARB = __indirect_glGetQueryObjectivARB;
glAPI->GetQueryObjectuivARB = __indirect_glGetQueryObjectuivARB;
/* GL_NV_vertex_program */
glAPI->GetVertexAttribdvNV = __indirect_glGetVertexAttribdvNV;

View File

@@ -0,0 +1,306 @@
/*
* (C) Copyright IBM Corporation 2004, 2005
* 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
* IBM,
* AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef _INDIRECT_VA_PRIVATE_
#define _INDIRECT_VA_PRIVATE_
/**
* \file indirect_va_private.h
*
* \author Ian Romanick <idr@us.ibm.com>
*/
#include <inttypes.h>
#include "glxclient.h"
#include "indirect.h"
#include <GL/glxproto.h>
/**
* State descriptor for a single array of vertex data.
*/
struct array_state {
/**
* Pointer to the application supplied data.
*/
const void * data;
/**
* Enum representing the type of the application supplied data.
*/
GLenum data_type;
/**
* Stride value supplied by the application. This value is not used
* internally. It is only kept so that it can be queried by the
* application using glGet*v.
*/
GLsizei user_stride;
/**
* Calculated size, in bytes, of a single element in the array. This
* is calculated based on \c count and the size of the data type
* represented by \c data_type.
*/
GLsizei element_size;
/**
* Actual byte-stride from one element to the next. This value will
* be equal to either \c user_stride or \c element_stride.
*/
GLsizei true_stride;
/**
* Number of data values in each element.
*/
GLint count;
/**
* "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed).
* This is used for mapping integral types to floating point types.
*/
GLboolean normalized;
/**
* Pre-calculated GLX protocol command header.
*/
uint32_t header[2];
/**
* Size of the header data. For simple data, like glColorPointerfv,
* this is 4. For complex data that requires either a count (e.g.,
* glWeightfvARB), an index (e.g., glVertexAttrib1fvARB), or a
* selector enum (e.g., glMultiTexCoord2fv) this is 8.
*/
unsigned header_size;
/**
* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
* to \c GL_FALSE.
*/
GLboolean enabled;
/**
* For multi-arrayed data (e.g., texture coordinates, generic vertex
* program attributes, etc.), this specifies which array this is.
*/
unsigned index;
/**
* Per-array-type key. For most arrays, this will be the GL enum for
* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
* etc.).
*/
GLenum key;
/**
* If this array can be used with the "classic" \c glDrawArrays protocol,
* this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE.
*/
GLboolean old_DrawArrays_possible;
};
/**
* Array state that is pushed / poped by \c glPushClientAttrib and
* \c glPopClientAttrib.
*/
struct array_stack_state {
/**
* Pointer to the application supplied data.
*/
const void * data;
/**
* Enum representing the type of the application supplied data.
*/
GLenum data_type;
/**
* Stride value supplied by the application. This value is not used
* internally. It is only kept so that it can be queried by the
* application using glGet*v.
*/
GLsizei user_stride;
/**
* Number of data values in each element.
*/
GLint count;
/**
* Per-array-type key. For most arrays, this will be the GL enum for
* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
* etc.).
*/
GLenum key;
/**
* For multi-arrayed data (e.g., texture coordinates, generic vertex
* program attributes, etc.), this specifies which array this is.
*/
unsigned index;
/**
* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
* to \c GL_FALSE.
*/
GLboolean enabled;
};
/**
* Collection of all the vertex array state.
*/
struct array_state_vector {
/**
* Number of arrays tracked by \c ::arrays.
*/
size_t num_arrays;
/**
* Array of vertex array state. This array contains all of the valid
* vertex arrays. If a vertex array isn't in this array, then it isn't
* valid. For example, if an implementation does not support
* EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this
* array.
*/
struct array_state * arrays;
/**
* Number of currently enabled client-side arrays. The value of this
* field is only valid if \c array_info_cache_valid is true.
*/
size_t enabled_client_array_count;
/**
* \name ARRAY_INFO cache.
*
* These fields track the state of the ARRAY_INFO cache. The
* \c array_info_cache_size is the size of the actual data stored in
* \c array_info_cache. \c array_info_cache_buffer_size is the size of
* the buffer. This will always be greater than or equal to
* \c array_info_cache_size.
*
* \note
* There are some bytes of extra data before \c array_info_cache that is
* used to hold the header for RenderLarge commands. This is
* \b not included in \c array_info_cache_size or
* \c array_info_cache_buffer_size.
*/
/*@{*/
size_t array_info_cache_size;
size_t array_info_cache_buffer_size;
void * array_info_cache;
/*@}*/
/**
* Is the cache of ARRAY_INFO data valid? The cache can become invalid
* when one of several state changes occur. Among these chages are
* modifying the array settings for an enabled array and enabling /
* disabling an array.
*/
GLboolean array_info_cache_valid;
/**
* Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use
* of this protocol is disabled with really old servers (i.e., servers
* that don't support GL 1.1 or EXT_vertex_arrays) or when an environment
* variable is set.
*
* \todo
* GL 1.1 and EXT_vertex_arrays use identical protocol, but have different
* opcodes for \c glDrawArrays. For servers that advertise one or the
* other, there should be a way to select which opcode to use.
*/
GLboolean old_DrawArrays_possible;
/**
* Is it possible to use the new GL X.X / ARB_vertex_buffer_object
* protocol?
*
* \todo
* This protocol has not yet been defined by the ARB, but is currently a
* work in progress. This field is a place-holder.
*/
GLboolean new_DrawArrays_possible;
/**
* Active texture unit set by \c glClientActiveTexture.
*
* \sa __glXGetActiveTextureUnit
*/
unsigned active_texture_unit;
/**
* Number of supported texture units. Even if ARB_multitexture /
* GL 1.3 are not supported, this will be at least 1. When multitexture
* is supported, this will be the value queried by calling
* \c glGetIntegerv with \c GL_MAX_TEXTURE_UNITS.
*
* \todo
* Investigate if this should be the value of \c GL_MAX_TEXTURE_COORDS
* instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program /
* NV_fragment_program are supported).
*/
unsigned num_texture_units;
/**
* Number of generic vertex program attribs. If GL_ARB_vertex_program
* is not supported, this will be zero. Otherwise it will be the value
* queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB
* and \c GL_MAX_PROGRAM_ATTRIBS_ARB.
*/
unsigned num_vertex_program_attribs;
/**
* \n Methods for implementing various GL functions.
*
* These method pointers are only valid \c array_info_cache_valid is set.
* When each function starts, it much check \c array_info_cache_valid.
* If it is not set, it must call \c fill_array_info_cache and call
* the new method.
*
* \sa fill_array_info_cache
*
* \todo
* Write code to plug these functions directly into the dispatch table.
*/
/*@{*/
void (*DrawArrays)( GLenum, GLint, GLsizei );
void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices );
/*@}*/
struct array_stack_state * stack;
unsigned active_texture_unit_stack[ __GL_CLIENT_ATTRIB_STACK_DEPTH ];
unsigned stack_index;
};
#endif /* _INDIRECT_VA_PRIVATE_ */

View File

@@ -25,14 +25,16 @@
#include <inttypes.h>
#include <assert.h>
#include "glxclient.h"
#include "packrender.h"
#include "indirect.h"
#include <string.h>
#include "glxclient.h"
#include "indirect.h"
#include <GL/glxproto.h>
#include "glxextensions.h"
#include "indirect_vertex_array.h"
#include "indirect_va_private.h"
#define __GLX_PAD(n) (((n)+3) & ~3)
/**
* \file indirect_vertex_array.c
@@ -63,278 +65,6 @@
* \author Ian Romanick <idr@us.ibm.com>
*/
/**
* State descriptor for a single array of vertex data.
*/
struct array_state {
/**
* Pointer to the application supplied data.
*/
const void * data;
/**
* Enum representing the type of the application supplied data.
*/
GLenum data_type;
/**
* Stride value supplied by the application. This value is not used
* internally. It is only kept so that it can be queried by the
* application using glGet*v.
*/
GLsizei user_stride;
/**
* Calculated size, in bytes, of a single element in the array. This
* is calculated based on \c count and the size of the data type
* represented by \c data_type.
*/
GLsizei element_size;
/**
* Actual byte-stride from one element to the next. This value will
* be equal to either \c user_stride or \c element_stride.
*/
GLsizei true_stride;
/**
* Number of data values in each element.
*/
GLint count;
/**
* "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed).
* This is used for mapping integral types to floating point types.
*/
GLboolean normalized;
/**
* Pre-calculated GLX protocol command header.
*/
uint32_t header[2];
/**
* Size of the header data. For simple data, like glColorPointerfv,
* this is 4. For complex data that requires either a count (e.g.,
* glWeightfvARB), an index (e.g., glVertexAttrib1fvARB), or a
* selector enum (e.g., glMultiTexCoord2fv) this is 8.
*/
unsigned header_size;
/**
* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
* to \c GL_FALSE.
*/
GLboolean enabled;
/**
* For multi-arrayed data (e.g., texture coordinates, generic vertex
* program attributes, etc.), this specifies which array this is.
*/
unsigned index;
/**
* Per-array-type key. For most arrays, this will be the GL enum for
* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
* etc.).
*/
GLenum key;
/**
* If this array can be used with the "classic" \c glDrawArrays protocol,
* this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE.
*/
GLboolean old_DrawArrays_possible;
};
/**
* Array state that is pushed / poped by \c glPushClientAttrib and
* \c glPopClientAttrib.
*/
struct array_stack_state {
/**
* Pointer to the application supplied data.
*/
const void * data;
/**
* Enum representing the type of the application supplied data.
*/
GLenum data_type;
/**
* Stride value supplied by the application. This value is not used
* internally. It is only kept so that it can be queried by the
* application using glGet*v.
*/
GLsizei user_stride;
/**
* Number of data values in each element.
*/
GLint count;
/**
* Per-array-type key. For most arrays, this will be the GL enum for
* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
* etc.).
*/
GLenum key;
/**
* For multi-arrayed data (e.g., texture coordinates, generic vertex
* program attributes, etc.), this specifies which array this is.
*/
unsigned index;
/**
* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
* to \c GL_FALSE.
*/
GLboolean enabled;
};
/**
* Collection of all the vertex array state.
*/
struct array_state_vector {
/**
* Number of arrays tracked by \c ::arrays.
*/
size_t num_arrays;
/**
* Array of vertex array state. This array contains all of the valid
* vertex arrays. If a vertex array isn't in this array, then it isn't
* valid. For example, if an implementation does not support
* EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this
* array.
*/
struct array_state * arrays;
/**
* Number of currently enabled arrays. The value of this field is
* only valid if \c array_info_cache_valid is true.
*/
size_t enabled_array_count;
/**
* \name ARRAY_INFO cache.
*
* These fields track the state of the ARRAY_INFO cache. The
* \c array_info_cache_size is the size of the actual data stored in
* \c array_info_cache. \c array_info_cache_buffer_size is the size of
* the buffer. This will always be greater than or equal to
* \c array_info_cache_size.
*
* \c large_header doesn't completely belong in this group. This is a
* pointer to a buffer to hold the header information for DrawArrays in
* a RenderLarge command. This buffer is immediately before
* \c array_info_cache. The idea is that the header data will be written
* to \c large_header and a single call to \c __glXSendLargeChunk can be
* made to send the header and the ARRAY_INFO data.
*
* \note
* \c array_info_cache_size and \c array_info_cache_buffer_size do
* NOT include the size of \c large_header.
*/
/*@{*/
size_t array_info_cache_size;
size_t array_info_cache_buffer_size;
void * array_info_cache;
GLubyte * large_header;
/*@}*/
/**
* Is the cache of ARRAY_INFO data valid? The cache can become invalid
* when one of several state changes occur. Among these chages are
* modifying the array settings for an enabled array and enabling /
* disabling an array.
*/
GLboolean array_info_cache_valid;
/**
* Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use
* of this protocol is disabled with really old servers (i.e., servers
* that don't support GL 1.1 or EXT_vertex_arrays) or when an environment
* variable is set.
*
* \todo
* GL 1.1 and EXT_vertex_arrays use identical protocol, but have different
* opcodes for \c glDrawArrays. For servers that advertise one or the
* other, there should be a way to select which opcode to use.
*/
GLboolean old_DrawArrays_possible;
/**
* Is it possible to use the new GL X.X / ARB_vertex_buffer_object
* protocol?
*
* \todo
* This protocol has not yet been defined by the ARB, but is currently a
* work in progress. This field is a place-holder.
*/
GLboolean new_DrawArrays_possible;
/**
* Active texture unit set by \c glClientActiveTexture.
*
* \sa __glXGetActiveTextureUnit
*/
unsigned active_texture_unit;
/**
* Number of supported texture units. Even if ARB_multitexture /
* GL 1.3 are not supported, this will be at least 1. When multitexture
* is supported, this will be the value queried by calling
* \c glGetIntegerv with \c GL_MAX_TEXTURE_UNITS.
*
* \todo
* Investigate if this should be the value of \c GL_MAX_TEXTURE_COORDS
* instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program /
* NV_fragment_program are supported).
*/
unsigned num_texture_units;
/**
* Number of generic vertex program attribs. If GL_ARB_vertex_program
* is not supported, this will be zero. Otherwise it will be the value
* queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB
* and \c GL_MAX_PROGRAM_ATTRIBS_ARB.
*/
unsigned num_vertex_program_attribs;
/**
* \n Methods for implementing various GL functions.
*
* These method pointers are only valid \c array_info_cache_valid is set.
* When each function starts, it much check \c array_info_cache_valid.
* If it is not set, it must call \c fill_array_info_cache and call
* the new method.
*
* \sa fill_array_info_cache
*
* \todo
* Write code to plug these functions directly into the dispatch table.
*/
/*@{*/
void (*DrawArrays)( GLenum, GLint, GLsizei );
void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices );
/*@}*/
struct array_stack_state * stack;
unsigned active_texture_unit_stack[ __GL_CLIENT_ATTRIB_STACK_DEPTH ];
unsigned stack_index;
};
static void emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count );
static void emit_DrawArrays_old ( GLenum mode, GLint first, GLsizei count );
@@ -353,6 +83,7 @@ static struct array_state * get_array_entry(
static void fill_array_info_cache( struct array_state_vector * arrays );
static GLboolean validate_mode(__GLXcontext *gc, GLenum mode);
static GLboolean validate_count(__GLXcontext *gc, GLsizei count);
static GLboolean validate_type(__GLXcontext *gc, GLenum type);
/**
@@ -395,19 +126,14 @@ __glXInitVertexArrayState( __GLXcontext * gc )
unsigned texture_units = 1;
unsigned i;
unsigned j;
unsigned vertex_program_attribs;
unsigned vertex_program_attribs = 0;
GLboolean got_fog = GL_FALSE;
GLboolean got_secondary_color = GL_FALSE;
arrays = malloc( sizeof( struct array_state_vector ) );
arrays = calloc( 1, sizeof( struct array_state_vector ) );
state->array_state = arrays;
arrays->enabled_array_count = 0;
arrays->array_info_cache = NULL;
arrays->array_info_cache_size = 0;
arrays->array_info_cache_buffer_size = 0;
arrays->array_info_cache_valid= GL_FALSE;
arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol;
arrays->new_DrawArrays_possible = GL_FALSE;
@@ -425,7 +151,7 @@ __glXInitVertexArrayState( __GLXcontext * gc )
* GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY, and
* GL_EDGE_FLAG_ARRAY are supported.
*/
array_count = 5;
if ( __glExtensionBitIsEnabled( gc, GL_EXT_fog_coord_bit )
@@ -442,26 +168,20 @@ __glXInitVertexArrayState( __GLXcontext * gc )
if ( __glExtensionBitIsEnabled( gc, GL_ARB_multitexture_bit )
|| (gc->server_major > 1) || (gc->server_minor >= 3) ) {
glGetIntegerv( GL_MAX_TEXTURE_UNITS, & texture_units );
}
else {
texture_units = 1;
__indirect_glGetIntegerv( GL_MAX_TEXTURE_UNITS, & texture_units );
}
if ( __glExtensionBitIsEnabled( gc, GL_ARB_vertex_program_bit ) ) {
glGetProgramivARB( GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ATTRIBS_ARB,
& vertex_program_attribs );
__indirect_glGetProgramivARB( GL_VERTEX_PROGRAM_ARB,
GL_MAX_PROGRAM_ATTRIBS_ARB,
& vertex_program_attribs );
}
arrays->num_texture_units = texture_units;
arrays->num_vertex_program_attribs = vertex_program_attribs;
array_count += texture_units + vertex_program_attribs;
arrays->num_arrays = array_count;
arrays->arrays = malloc( sizeof( struct array_state ) * array_count );
(void) memset( arrays->arrays, 0,
sizeof( struct array_state ) * array_count );
arrays->arrays = calloc( array_count, sizeof( struct array_state ) );
arrays->arrays[0].data_type = GL_FLOAT;
arrays->arrays[0].count = 3;
@@ -542,6 +262,7 @@ __glXInitVertexArrayState( __GLXcontext * gc )
arrays->arrays[i].key = GL_VERTEX_ARRAY;
arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
assert( (i + 1) == arrays->num_arrays );
arrays->stack_index = 0;
arrays->stack = malloc( sizeof( struct array_stack_state )
@@ -659,15 +380,16 @@ static GLboolean
allocate_array_info_cache( struct array_state_vector * arrays,
size_t required_size )
{
#define MAX_HEADER_SIZE 20
if ( arrays->array_info_cache_buffer_size < required_size ) {
GLubyte * temp = realloc( arrays->array_info_cache, required_size + 20 );
GLubyte * temp = realloc( arrays->array_info_cache, required_size
+ MAX_HEADER_SIZE );
if ( temp == NULL ) {
return GL_FALSE;
}
arrays->large_header = temp;
arrays->array_info_cache = temp + 20;
arrays->array_info_cache = temp + MAX_HEADER_SIZE;
arrays->array_info_cache_buffer_size = required_size;
}
@@ -688,11 +410,11 @@ fill_array_info_cache( struct array_state_vector * arrays )
/* Determine how many arrays are enabled.
*/
arrays->enabled_array_count = 0;
arrays->enabled_client_array_count = 0;
old_DrawArrays_possible = arrays->old_DrawArrays_possible;
for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
if ( arrays->arrays[i].enabled ) {
arrays->enabled_array_count++;
arrays->enabled_client_array_count++;
old_DrawArrays_possible &= arrays->arrays[i].old_DrawArrays_possible;
}
}
@@ -702,7 +424,7 @@ fill_array_info_cache( struct array_state_vector * arrays )
assert( ! arrays->new_DrawArrays_possible );
}
else if ( old_DrawArrays_possible ) {
const size_t required_size = arrays->enabled_array_count * 12;
const size_t required_size = arrays->enabled_client_array_count * 12;
uint32_t * info;
@@ -720,7 +442,6 @@ fill_array_info_cache( struct array_state_vector * arrays )
}
}
arrays->array_info_cache_valid = GL_TRUE;
arrays->DrawArrays = emit_DrawArrays_old;
arrays->DrawElements = emit_DrawElements_old;
}
@@ -728,6 +449,8 @@ fill_array_info_cache( struct array_state_vector * arrays )
arrays->DrawArrays = emit_DrawArrays_none;
arrays->DrawElements = emit_DrawElements_none;
}
arrays->array_info_cache_valid = GL_TRUE;
}
@@ -868,11 +591,11 @@ emit_DrawArrays_header_old( __GLXcontext * gc,
command_size += 4;
pc = arrays->large_header;
pc = ((GLubyte *) arrays->array_info_cache) - (header_size + 4);
*(uint32_t *)(pc + 0) = command_size;
*(uint32_t *)(pc + 4) = X_GLrop_DrawArrays;
*(uint32_t *)(pc + 8) = count;
*(uint32_t *)(pc + 12) = arrays->enabled_array_count;
*(uint32_t *)(pc + 12) = arrays->enabled_client_array_count;
*(uint32_t *)(pc + 16) = mode;
__glXSendLargeChunk( gc, 1, *total_requests, pc,
@@ -889,7 +612,7 @@ emit_DrawArrays_header_old( __GLXcontext * gc,
*(uint16_t *)(pc + 0) = command_size;
*(uint16_t *)(pc + 2) = X_GLrop_DrawArrays;
*(uint32_t *)(pc + 4) = count;
*(uint32_t *)(pc + 8) = arrays->enabled_array_count;
*(uint32_t *)(pc + 8) = arrays->enabled_client_array_count;
*(uint32_t *)(pc + 12) = mode;
pc += header_size;
@@ -897,7 +620,7 @@ emit_DrawArrays_header_old( __GLXcontext * gc,
(void) memcpy( pc, arrays->array_info_cache,
arrays->array_info_cache_size );
pc += arrays->array_info_cache_size;
*elements_per_request = count;
*total_requests = 0;
}
@@ -1002,7 +725,7 @@ emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
pc += 8;
for ( i = 0 ; i < count ; i++ ) {
unsigned index;
unsigned index = 0;
if ( (pc + single_vertex_size) >= gc->bufEnd ) {
pc = __glXFlushRenderBuffer(gc, gc->pc);
@@ -1052,9 +775,6 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
unsigned total_requests = 0;
unsigned i;
unsigned req;
const GLuint * ui_ptr = (const GLuint *) indices;
const GLushort * us_ptr = (const GLushort *) indices;
const GLubyte * ub_ptr = (const GLubyte *) indices;
pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
@@ -1071,25 +791,34 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
}
switch( type ) {
case GL_UNSIGNED_INT:
case GL_UNSIGNED_INT: {
const GLuint * ui_ptr = (const GLuint *) indices;
for ( i = 0 ; i < elements_per_request ; i++ ) {
const GLint index = (GLint) *(ui_ptr++);
pc = emit_element_old( pc, arrays, index );
}
break;
case GL_UNSIGNED_SHORT:
}
case GL_UNSIGNED_SHORT: {
const GLushort * us_ptr = (const GLushort *) indices;
for ( i = 0 ; i < elements_per_request ; i++ ) {
const GLint index = (GLint) *(us_ptr++);
pc = emit_element_old( pc, arrays, index );
}
break;
case GL_UNSIGNED_BYTE:
}
case GL_UNSIGNED_BYTE: {
const GLubyte * ub_ptr = (const GLubyte *) indices;
for ( i = 0 ; i < elements_per_request ; i++ ) {
const GLint index = (GLint) *(ub_ptr++);
pc = emit_element_old( pc, arrays, index );
}
break;
}
}
if ( total_requests != 0 ) {
__glXSendLargeChunk( gc, req, total_requests, gc->pc,
@@ -1166,6 +895,28 @@ validate_count(__GLXcontext *gc, GLsizei count)
}
/**
* Validate that the \c type parameter to \c glDrawElements, et. al. is
* valid. Only \c GL_UNSIGNED_BYTE, \c GL_UNSIGNED_SHORT, and
* \c GL_UNSIGNED_INT are valid.
*
* \returns
* \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not.
*/
static GLboolean validate_type(__GLXcontext *gc, GLenum type)
{
switch( type ) {
case GL_UNSIGNED_INT:
case GL_UNSIGNED_SHORT:
case GL_UNSIGNED_BYTE:
return GL_TRUE;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return GL_FALSE;
}
}
void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
__GLXcontext *gc = __glXGetCurrentContext();
@@ -1217,7 +968,8 @@ void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type,
struct array_state_vector * arrays = state->array_state;
if ( validate_mode(gc, mode) && validate_count(gc, count) ) {
if ( validate_mode(gc, mode) && validate_count(gc, count)
&& validate_type(gc, type) ) {
if ( ! arrays->array_info_cache_valid ) {
fill_array_info_cache( arrays );
}
@@ -1237,7 +989,8 @@ void __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end,
struct array_state_vector * arrays = state->array_state;
if ( validate_mode(gc, mode) && validate_count(gc, count) ) {
if ( validate_mode(gc, mode) && validate_count(gc, count)
&& validate_type(gc, type) ) {
if (end < start) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -1287,7 +1040,7 @@ void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei *count,
GLsizei i;
if ( validate_mode(gc, mode) ) {
if ( validate_mode(gc, mode) && validate_type(gc, type) ) {
if ( ! arrays->array_info_cache_valid ) {
fill_array_info_cache( arrays );
}
@@ -1301,12 +1054,13 @@ void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei *count,
}
#define COMMON_ARRAY_DATA_INIT(a, PTR, TYPE, STRIDE, COUNT, HDR_SIZE, OPCODE) \
#define COMMON_ARRAY_DATA_INIT(a, PTR, TYPE, STRIDE, COUNT, NORMALIZED, HDR_SIZE, OPCODE) \
do { \
(a)->data = PTR; \
(a)->data_type = TYPE; \
(a)->user_stride = STRIDE; \
(a)->count = COUNT; \
(a)->normalized = NORMALIZED; \
\
(a)->element_size = __glXTypeSize( TYPE ) * COUNT; \
(a)->true_stride = (STRIDE == 0) \
@@ -1357,7 +1111,8 @@ void __indirect_glVertexPointer( GLint size, GLenum type, GLsizei stride,
a = get_array_entry( arrays, GL_VERTEX_ARRAY, 0 );
assert( a != NULL );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, 4, opcode );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_FALSE, 4,
opcode );
if ( a->enabled ) {
arrays->array_info_cache_valid = GL_FALSE;
@@ -1379,7 +1134,7 @@ void __indirect_glNormalPointer( GLenum type, GLsizei stride,
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
switch ( type ) {
case GL_BYTE: opcode = X_GLrop_Normal3bv; break;
case GL_SHORT: opcode = X_GLrop_Normal3sv; break;
@@ -1393,7 +1148,8 @@ void __indirect_glNormalPointer( GLenum type, GLsizei stride,
a = get_array_entry( arrays, GL_NORMAL_ARRAY, 0 );
assert( a != NULL );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 3, 4, opcode );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 3, GL_TRUE, 4,
opcode );
if ( a->enabled ) {
arrays->array_info_cache_valid = GL_FALSE;
@@ -1456,7 +1212,8 @@ void __indirect_glColorPointer( GLint size, GLenum type, GLsizei stride,
a = get_array_entry( arrays, GL_COLOR_ARRAY, 0 );
assert( a != NULL );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, 4, opcode );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_TRUE, 4,
opcode );
if ( a->enabled ) {
arrays->array_info_cache_valid = GL_FALSE;
@@ -1492,7 +1249,8 @@ void __indirect_glIndexPointer( GLenum type, GLsizei stride,
a = get_array_entry( arrays, GL_INDEX_ARRAY, 0 );
assert( a != NULL );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 1, 4, opcode );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 1, GL_FALSE, 4,
opcode );
if ( a->enabled ) {
arrays->array_info_cache_valid = GL_FALSE;
@@ -1516,7 +1274,8 @@ void __indirect_glEdgeFlagPointer( GLsizei stride, const GLvoid * pointer )
a = get_array_entry( arrays, GL_EDGE_FLAG_ARRAY, 0 );
assert( a != NULL );
COMMON_ARRAY_DATA_INIT( a, pointer, GL_UNSIGNED_BYTE, stride, 1, 4, X_GLrop_EdgeFlagv );
COMMON_ARRAY_DATA_INIT( a, pointer, GL_UNSIGNED_BYTE, stride, 1, GL_FALSE,
4, X_GLrop_EdgeFlagv );
if ( a->enabled ) {
arrays->array_info_cache_valid = GL_FALSE;
@@ -1597,7 +1356,8 @@ void __indirect_glTexCoordPointer( GLint size, GLenum type, GLsizei stride,
a = get_array_entry( arrays, GL_TEXTURE_COORD_ARRAY, index );
assert( a != NULL );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, header_size, opcode );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_FALSE,
header_size, opcode );
if ( a->enabled ) {
arrays->array_info_cache_valid = GL_FALSE;
@@ -1640,7 +1400,8 @@ void __indirect_glSecondaryColorPointerEXT( GLint size, GLenum type, GLsizei str
return;
}
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, 4, opcode );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_TRUE, 4,
opcode );
if ( a->enabled ) {
arrays->array_info_cache_valid = GL_FALSE;
@@ -1662,7 +1423,7 @@ void __indirect_glFogCoordPointerEXT( GLenum type, GLsizei stride,
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
switch ( type ) {
case GL_FLOAT: opcode = 4124; break;
case GL_DOUBLE: opcode = 4125; break;
@@ -1677,7 +1438,8 @@ void __indirect_glFogCoordPointerEXT( GLenum type, GLsizei stride,
return;
}
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 1, 4, opcode );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 1, GL_FALSE, 4,
opcode );
if ( a->enabled ) {
arrays->array_info_cache_valid = GL_FALSE;
@@ -1725,6 +1487,8 @@ void __indirect_glVertexAttribPointerARB(GLuint index, GLint size,
true_immediate_count = 4;
}
else {
true_immediate_count = size;
switch( type ) {
case GL_BYTE:
opcode = X_GLrop_VertexAttrib4bvARB;
@@ -1767,7 +1531,8 @@ void __indirect_glVertexAttribPointerARB(GLuint index, GLint size,
return;
}
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, 8, opcode );
COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, normalized, 8,
opcode );
true_immediate_size = __glXTypeSize(type) * true_immediate_count;
((uint16_t *) (a)->header)[0] = __GLX_PAD(a->header_size
@@ -2076,5 +1841,6 @@ __glXPopArrayState( __GLXattribute * state )
stack[i].enabled );
}
arrays->active_texture_unit = arrays->active_texture_unit_stack[ arrays->stack_index ];
arrays->active_texture_unit =
arrays->active_texture_unit_stack[ arrays->stack_index ];
}

View File

@@ -56,7 +56,7 @@ void __indirect_glDisableVertexAttribArrayARB( GLuint index )
static void
get_parameter( unsigned opcode, unsigned size, GLenum target, GLuint index,
GLfloat * params )
void * params )
{
__GLXcontext * const gc = __glXGetCurrentContext();
Display * const dpy = gc->currentDpy;

View File

@@ -103,6 +103,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->NewTextureObject = _mesa_new_texture_object;
driver->DeleteTexture = _mesa_delete_texture_object;
driver->NewTextureImage = _mesa_new_texture_image;
driver->FreeTexImageData = _mesa_free_texture_image_data;
driver->IsTextureResident = NULL;
driver->PrioritizeTexture = NULL;
driver->ActiveTexture = NULL;

View File

@@ -0,0 +1,17 @@
#ifndef DRIMEMSETIO_H
#define DRIMEMSETIO_H
/*
* memset an area in I/O space
* We need to be careful about this on some archs
*/
static __inline__ void drimemsetio(void* address, int c, int size)
{
#if defined(__powerpc__) || defined(__ia64__)
int i;
for(i=0;i<size;i++)
*((char *)address + i)=c;
#else
memset(address,c,size);
#endif
}
#endif

View File

@@ -593,6 +593,13 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
modes->swapMethod = db_modes[i];
}
modes->haveAccumBuffer = ((modes->accumRedBits +
modes->accumGreenBits +
modes->accumBlueBits +
modes->accumAlphaBits) > 0);
modes->haveDepthBuffer = (modes->depthBits > 0);
modes->haveStencilBuffer = (modes->stencilBits > 0);
modes = modes->next;
}
}

View File

@@ -298,6 +298,12 @@ DRI_CONF_OPT_BEGIN(texture_level_hack,bool,def) \
DRI_CONF_DESC(en,"Enable texture level hack for radeon/r200 for playing games with compressed textures") \
DRI_CONF_OPT_END
#define DRI_CONF_TEXTURE_BLEND_QUALITY(def,range) \
DRI_CONF_OPT_BEGIN_V(texture_blend_quality,float,def,range) \
DRI_CONF_DESC(en, "texture blend quality, aka brilinear texture filtering") \
DRI_CONF_DESC(de, "Texturfilterqualität, auch bekannt als brilineare Texturfilterung") \
DRI_CONF_OPT_END
#define DRI_CONF_TEXTURE_HEAPS_ALL 0
#define DRI_CONF_TEXTURE_HEAPS_CARD 1
#define DRI_CONF_TEXTURE_HEAPS_GART 2

View File

@@ -62,8 +62,6 @@
# ifdef DRM_USE_MALLOC
# define _DRM_MALLOC malloc
# define _DRM_FREE free
extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
extern int xf86RemoveSIGIOHandler(int fd);
# else
# include <X11/Xlibint.h>
# define _DRM_MALLOC Xmalloc
@@ -2268,7 +2266,7 @@ int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
return 0;
}
#if defined(XFree86Server) || defined(DRM_USE_MALLOC)
#if defined(XFree86Server)
static void drmSIGIOHandler(int interrupt, void *closure)
{
unsigned long key;

View File

@@ -36,6 +36,7 @@
#include "driver.h"
#include "drm.h"
#include "memops.h"
#include "mga_reg.h"
#include "mga.h"
@@ -805,11 +806,11 @@ static int MGAScreenInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
* the clear ioctl to do this, but would need to setup hw state
* first.
*/
memset((char *)ctx->FBAddress + pMga->frontOffset,
drimemsetio((char *)ctx->FBAddress + pMga->frontOffset,
0,
pMga->frontPitch * ctx->shared.virtualHeight );
memset((char *)ctx->FBAddress + pMga->backOffset,
drimemsetio((char *)ctx->FBAddress + pMga->backOffset,
0,
pMga->backPitch * ctx->shared.virtualHeight );

View File

@@ -47,6 +47,7 @@
#include "driver.h"
#include "drm.h"
#include "memops.h"
#include "r128.h"
#include "r128_dri.h"
@@ -826,11 +827,11 @@ static GLboolean R128DRIScreenInit(DRIDriverContext *ctx)
* the clear ioctl to do this, but would need to setup hw state
* first.
*/
memset((char *)ctx->FBAddress + info->frontOffset,
drimemsetio((char *)ctx->FBAddress + info->frontOffset,
0,
info->frontPitch * ctx->cpp * ctx->shared.virtualHeight );
memset((char *)ctx->FBAddress + info->backOffset,
drimemsetio((char *)ctx->FBAddress + info->backOffset,
0,
info->backPitch * ctx->cpp * ctx->shared.virtualHeight );

View File

@@ -105,6 +105,8 @@ void r200SetUpAtomList( r200ContextPtr rmesa )
insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.mtl[i] );
for (i = 0; i < 6; ++i)
insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.ucp[i] );
/* FIXME: is this a good place to insert that atom ? */
insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.prf );
}
static void r200SaveHwState( r200ContextPtr rmesa )

View File

@@ -488,7 +488,10 @@ struct r200_state_atom {
#define CST_SE_TCL_INPUT_VTX_3 17
#define CST_STATE_SIZE 18
#define PRF_CMD_0 0
#define PRF_PP_TRI_PERF 1
#define PRF_PP_PERF_CNTL 2
#define PRF_STATE_SIZE 3
struct r200_hw_state {
@@ -518,15 +521,16 @@ struct r200_hw_state {
struct r200_state_atom tex[6];
struct r200_state_atom cube[6];
struct r200_state_atom zbs;
struct r200_state_atom mtl[2];
struct r200_state_atom mat[9];
struct r200_state_atom mtl[2];
struct r200_state_atom mat[9];
struct r200_state_atom lit[8]; /* includes vec, scl commands */
struct r200_state_atom ucp[6];
struct r200_state_atom pix[6]; /* pixshader stages */
struct r200_state_atom eye; /* eye pos */
struct r200_state_atom grd; /* guard band clipping */
struct r200_state_atom fog;
struct r200_state_atom glt;
struct r200_state_atom fog;
struct r200_state_atom glt;
struct r200_state_atom prf;
int max_state_size; /* Number of bytes necessary for a full state emit. */
GLboolean is_dirty, all_dirty;

View File

@@ -971,6 +971,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* gap */
#define R200_PP_CNTL_X 0x2cc4
/* gap */
#define R200_PP_TRI_PERF 0x2cf8
#define R200_TRI_CUTOFF_MASK (0x1f << 0)
#define R200_PP_PERF_CNTL 0x2cfc
#define R200_PP_TXOFFSET_0 0x2d00
#define R200_TXO_ENDIAN_NO_SWAP (0 << 0)
#define R200_TXO_ENDIAN_BYTE_SWAP (1 << 0)

View File

@@ -150,6 +150,7 @@ static struct {
{ RADEON_PP_CUBIC_OFFSET_T1_0, 5, "RADEON_PP_CUBIC_OFFSET_T1_0" },
{ RADEON_PP_CUBIC_FACES_2, 1, "RADEON_PP_CUBIC_FACES_2" },
{ RADEON_PP_CUBIC_OFFSET_T2_0, 5, "RADEON_PP_CUBIC_OFFSET_T2_0" },
{ R200_PP_TRI_PERF, 2, "R200_PP_TRI_PERF" },
};
struct reg_names {
@@ -475,11 +476,13 @@ static struct reg_names reg_names[] = {
{ R200_RB3D_CBLENDCNTL, "R200_RB3D_CBLENDCNTL" },
{ R200_SE_TCL_OUTPUT_VTX_COMP_SEL, "R200_SE_TCL_OUTPUT_VTX_COMP_SEL" },
{ R200_PP_CNTL_X, "R200_PP_CNTL_X" },
{ R200_SE_VAP_CNTL_STATUS, "R200_SE_VAP_CNTL_STATUS" },
{ R200_SE_VAP_CNTL_STATUS, "R200_SE_VAP_CNTL_STATUS" },
{ R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0" },
{ R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_1, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_1" },
{ R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_2, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_2" },
{ R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_3, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_3" },
{ R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_1, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_1" },
{ R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_2, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_2" },
{ R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_3, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_3" },
{ R200_PP_TRI_PERF, "R200_PP_TRI_PERF" },
{ R200_PP_PERF_CNTL, "R200_PP_PERF_CNTL" },
};
static struct reg_names scalar_names[] = {

View File

@@ -74,6 +74,7 @@ DRI_CONF_BEGIN
DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
DRI_CONF_TEXTURE_LEVEL_HACK(false)
DRI_CONF_TEXTURE_BLEND_QUALITY(1.0,"0.0:1.0")
DRI_CONF_SECTION_END
DRI_CONF_SECTION_DEBUG
DRI_CONF_NO_RAST(false)
@@ -83,7 +84,7 @@ DRI_CONF_BEGIN
DRI_CONF_NV_VERTEX_PROGRAM(false)
DRI_CONF_SECTION_END
DRI_CONF_END;
static const GLuint __driNConfigOptions = 16;
static const GLuint __driNConfigOptions = 17;
#if 1
/* Including xf86PciInfo.h introduces a bunch of errors...
@@ -345,6 +346,8 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
/* Check if kernel module is new enough to support blend color and
separate blend functions/equations */
screen->drmSupportsBlendColor = (sPriv->drmMinor >= 11);
screen->drmSupportsTriPerf = (sPriv->drmMinor >= 16);
}
/* Check if ddx has set up a surface reg to cover depth buffer */
screen->depthHasSurface = (sPriv->ddxMajor > 4);

View File

@@ -96,6 +96,7 @@ typedef struct {
GLboolean drmSupportsCubeMaps; /* need radeon kernel module >=1.7 */
GLboolean drmSupportsBlendColor; /* need radeon kernel module >= 1.11 */
GLboolean drmSupportsTriPerf; /* need radeon kernel module >= 1.16 */
GLboolean depthHasSurface;
/* Configuration cache with default values for all contexts */

View File

@@ -305,6 +305,12 @@ void r200InitState( r200ContextPtr rmesa )
ALLOC_STATE( pix[3], tex, PIX_STATE_SIZE, "PIX/pixstage-3", 3 );
ALLOC_STATE( pix[4], tex, PIX_STATE_SIZE, "PIX/pixstage-4", 4 );
ALLOC_STATE( pix[5], tex, PIX_STATE_SIZE, "PIX/pixstage-5", 5 );
if (rmesa->r200Screen->drmSupportsTriPerf) {
ALLOC_STATE( prf, always, PRF_STATE_SIZE, "PRF/performance-tri", 0 );
}
else {
ALLOC_STATE( prf, never, PRF_STATE_SIZE, "PRF/performance-tri", 0 );
}
r200SetUpAtomList( rmesa );
@@ -370,6 +376,7 @@ void r200InitState( r200ContextPtr rmesa )
rmesa->hw.vtx.cmd[VTX_CMD_1] = cmdpkt(R200_EMIT_OUTPUT_VTX_COMP_SEL);
rmesa->hw.vtx.cmd[VTX_CMD_2] = cmdpkt(R200_EMIT_SE_VTX_STATE_CNTL);
rmesa->hw.vte.cmd[VTE_CMD_0] = cmdpkt(R200_EMIT_VTE_CNTL);
rmesa->hw.prf.cmd[PRF_CMD_0] = cmdpkt(R200_EMIT_PP_TRI_PERF_CNTL);
rmesa->hw.mtl[0].cmd[MTL_CMD_0] =
cmdvec( R200_VS_MAT_0_EMISS, 1, 16 );
rmesa->hw.mtl[0].cmd[MTL_CMD_1] =
@@ -504,6 +511,10 @@ void r200InitState( r200ContextPtr rmesa )
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
}
rmesa->hw.prf.cmd[PRF_PP_TRI_PERF] = R200_TRI_CUTOFF_MASK - R200_TRI_CUTOFF_MASK *
driQueryOptionf (&rmesa->optionCache,"texture_blend_quality");
rmesa->hw.prf.cmd[PRF_PP_PERF_CNTL] = 0;
rmesa->hw.set.cmd[SET_SE_CNTL] = (R200_FFACE_CULL_CCW |
R200_BFACE_SOLID |
R200_FFACE_SOLID |

View File

@@ -35,6 +35,7 @@ DRIVER_SOURCES = \
r300_texmem.c \
r300_tex.c \
r300_texstate.c \
r300_texprog.c \
r300_vertexprog.c \
r300_maos.c \
\

View File

@@ -601,10 +601,10 @@ void r300EmitBlit(r300ContextPtr rmesa,
assert(h < (1 << 16));
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 8 * sizeof(int),
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 8,
__FUNCTION__);
cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
cmd[0].header.cmd_type = R300_CMD_PACKET3;
cmd[1].i = R200_CP_CMD_BITBLT_MULTI | (5 << 16);
cmd[2].i = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
RADEON_GMC_DST_PITCH_OFFSET_CNTL |
@@ -627,14 +627,14 @@ void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
if (rmesa->radeon.dri.drmMinor >= 6) {
drm_radeon_cmd_header_t *cmd;
assert(!(flags & ~(RADEON_WAIT_2D | RADEON_WAIT_3D)));
assert(!(flags & ~(R300_WAIT_2D | R300_WAIT_3D)));
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
1 * sizeof(int),
1,
__FUNCTION__);
cmd[0].i = 0;
cmd[0].wait.cmd_type = RADEON_CMD_WAIT;
cmd[0].wait.cmd_type = R300_CMD_WAIT;
cmd[0].wait.flags = flags;
}
}

View File

@@ -102,12 +102,13 @@ static const char *const card_extensions[] = {
};
extern struct tnl_pipeline_stage _r300_render_stage;
extern struct tnl_pipeline_stage _r300_tcl_stage;
static const struct tnl_pipeline_stage *r300_pipeline[] = {
/* Try and go straight to t&l
*/
// &_r300_tcl_stage,
&_r300_tcl_stage,
/* Catch any t&l fallbacks
*/
@@ -117,7 +118,7 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = {
&_tnl_fog_coordinate_stage,
&_tnl_texgen_stage,
&_tnl_texture_transform_stage,
&_tnl_vertex_program_stage,
//&_tnl_vertex_program_stage,
/* Try again to go to tcl?
* - no good for asymmetric-twoside (do with multipass)
@@ -267,12 +268,12 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
_mesa_enable_extension( ctx, "GL_NV_vertex_program");
#endif
/* currently bogus data */
ctx->Const.MaxVertexProgramInstructions=128;
ctx->Const.MaxVertexProgramAttribs=64;
ctx->Const.MaxVertexProgramTemps=64;
ctx->Const.MaxVertexProgramLocalParams=64;
ctx->Const.MaxVertexProgramEnvParams=64;
ctx->Const.MaxVertexProgramAddressRegs=8;
ctx->Const.MaxVertexProgramInstructions=VSF_MAX_FRAGMENT_LENGTH;
ctx->Const.MaxVertexProgramAttribs=16; // r420
ctx->Const.MaxVertexProgramTemps=VSF_MAX_FRAGMENT_TEMPS;
ctx->Const.MaxVertexProgramLocalParams=256; // r420
ctx->Const.MaxVertexProgramEnvParams=256; // r420
ctx->Const.MaxVertexProgramAddressRegs=1;
driInitExtensions(ctx, card_extensions, GL_TRUE);

View File

@@ -500,6 +500,12 @@ struct r300_depthbuffer_state {
GLfloat scale;
};
struct r300_stencilbuffer_state {
GLuint clear;
GLboolean hw_stencil;
};
struct r300_vap_reg_state {
/* input register assigments */
int i_coords;
@@ -513,8 +519,11 @@ struct r300_vap_reg_state {
/* Vertex shader state */
/* 64 appears to be the maximum */
#define VSF_MAX_FRAGMENT_LENGTH (64*4)
/* Tested with rv350 and verified from misc web pages. */
#define VSF_MAX_FRAGMENT_LENGTH (256*4)
/* Tested with rv350 and verified from misc web pages. */
#define VSF_MAX_FRAGMENT_TEMPS (32)
struct r300_vertex_shader_fragment {
@@ -557,6 +566,9 @@ struct r300_vertex_shader_state {
int unknown_ptr3; /* pointer within program space */
};
#define VERTPROG_ACTIVE(ctx) ( ctx->VertexProgram._Enabled && (R300_CONTEXT(ctx)->current_vp != NULL) && \
(R300_CONTEXT(ctx)->current_vp->translated) )
/* r300_vertex_shader_state and r300_vertex_program should probably be merged together someday.
* Keeping them them seperate for now should ensure fixed pipeline keeps functioning properly.
*/
@@ -570,6 +582,7 @@ struct r300_vertex_program {
int t2rs;
unsigned long num_temporaries; /* Number of temp vars used by program */
int inputs[VERT_ATTRIB_MAX];
GLuint outputs;
};
/* 64 appears to be the maximum */
@@ -621,7 +634,12 @@ struct r300_pixel_shader_program {
#define MAX_PIXEL_SHADER_PARAMS 32
struct r300_pixel_shader_state {
struct r300_pixel_shader_program program;
int translated;
int have_sample;
GLuint color_reg;
GLuint src_previous;
/* parameters */
int param_length; /* to limit the number of unnecessary writes */
struct {
@@ -675,7 +693,9 @@ struct r300_state {
struct {
int transform_offset; /* Transform matrix offset, -1 if none */
} vap_param; /* vertex processor parameter allocation - tells where to write parameters */
int hw_stencil;
struct r300_stencilbuffer_state stencil;
};

View File

@@ -107,6 +107,25 @@ static __inline__ uint32_t cmdcpdelay(unsigned short count)
return cmd.u;
}
static __inline__ uint32_t cmdwait(unsigned char flags)
{
drm_r300_cmd_header_t cmd;
cmd.wait.cmd_type = R300_CMD_WAIT;
cmd.wait.flags = flags;
return cmd.u;
}
static __inline__ uint32_t cmdpacify(void)
{
drm_r300_cmd_header_t cmd;
cmd.header.cmd_type = R300_CMD_END3D;
return cmd.u;
}
/* Prepare to write a register value to register at address reg.
If num_extra > 0 then the following extra values are written
to registers with address +4, +8 and so on.. */
@@ -181,13 +200,14 @@ static __inline__ uint32_t cmdcpdelay(unsigned short count)
}
/* must be sent to switch to 2d commands */
/*
void static inline end_3d(PREFIX_VOID)
{
LOCAL_VARS
(void)cmd_reserved; (void)cmd_written;
cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
0, \
0, \ // ??!
__FUNCTION__); \
cmd[0].header.cmd_type=R300_CMD_END3D;
@@ -199,11 +219,12 @@ LOCAL_VARS
(void)cmd_reserved; (void)cmd_written;
cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
0, \
0, \ // ??!
__FUNCTION__); \
cmd[0].i=cmdcpdelay(count);
}
*/
/* fire vertex buffer */
static void inline fire_AOS(PREFIX int vertex_count, int type)

View File

@@ -58,6 +58,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define CLEARBUFFER_COLOR 0x1
#define CLEARBUFFER_DEPTH 0x2
#define CLEARBUFFER_STENCIL 0x4
static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
{
@@ -205,8 +206,10 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
R300_STATECHANGE(r300, zs);
if (flags & CLEARBUFFER_DEPTH) {
r300->hw.zs.cmd[R300_ZS_CNTL_0] = 0x6; // test and write
r300->hw.zs.cmd[R300_ZS_CNTL_1] = (R300_ZS_ALWAYS<<R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
r300->hw.zs.cmd[R300_ZS_CNTL_0] |= 0x6; // test and write
r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
r300->hw.zs.cmd[R300_ZS_CNTL_1] |= (R300_ZS_ALWAYS<<R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
/*
R300_STATECHANGE(r300, zb);
r300->hw.zb.cmd[R300_ZB_OFFSET] =
@@ -217,8 +220,27 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
r300->radeon.radeonScreen->depthPitch;
*/
} else {
r300->hw.zs.cmd[R300_ZS_CNTL_0] = 0; // disable
r300->hw.zs.cmd[R300_ZS_CNTL_1] = 0;
r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_DISABLED_1; // disable
r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
}
R300_STATECHANGE(r300, zs);
if (flags & CLEARBUFFER_STENCIL) {
r300->hw.zs.cmd[R300_ZS_CNTL_0] &= ~R300_RB3D_STENCIL_ENABLE;
r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_STENCIL_ENABLE;
r300->hw.zs.cmd[R300_ZS_CNTL_1] &=
~((R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT));
r300->hw.zs.cmd[R300_ZS_CNTL_1] |=
(R300_ZS_ALWAYS<<R300_RB3D_ZS1_FRONT_FUNC_SHIFT) |
(R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |
(R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) |
(R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) |
(R300_ZS_ALWAYS<<R300_RB3D_ZS1_BACK_FUNC_SHIFT) |
(R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) |
(R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT) |
(R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT) ;
r300->hw.zs.cmd[R300_ZS_CNTL_2] = r300->state.stencil.clear;
}
/* Make sure we have enough space */
@@ -314,6 +336,11 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask, GLboolean all,
bits |= CLEARBUFFER_DEPTH;
mask &= ~DD_DEPTH_BIT;
}
if ( (mask & DD_STENCIL_BIT) && r300->state.stencil.hw_stencil) {
bits |= CLEARBUFFER_STENCIL;
mask &= ~DD_STENCIL_BIT;
}
if (mask) {
if (RADEON_DEBUG & DEBUG_FALLBACKS)

View File

@@ -243,7 +243,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
GLuint vic_1 = 0; /* R300_VAP_INPUT_CNTL_1 */
GLuint aa_vap_reg = 0; /* VAP register assignment */
GLuint i;
GLuint inputs = 0;
GLuint inputs = 0, outputs = 0;
#define CONFIGURE_AOS(r, f, v, sz, cn) { \
@@ -254,7 +254,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
exit(-1); \
} \
\
if (rmesa->current_vp == NULL) \
if (VERTPROG_ACTIVE(ctx) == GL_FALSE) \
rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++; \
rmesa->state.aos[nr-1].aos_format = f; \
if (immd) { \
@@ -272,7 +272,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
} \
}
if (rmesa->current_vp != NULL) {
if (VERTPROG_ACTIVE(ctx)) {
if (rmesa->current_vp->inputs[VERT_ATTRIB_POS] != -1) {
inputs |= _TNL_BIT_POS;
rmesa->state.aos[nr++].aos_reg = rmesa->current_vp->inputs[VERT_ATTRIB_POS];
@@ -306,6 +306,14 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
nr = 0;
} else {
inputs = TNL_CONTEXT(ctx)->render_inputs;
/* Hack to see what would happen if we would enable tex units according to their enabled values.
Why arent we doing this?
As for vertex programs tex coords should be passed if program wants them as some programs might deliver
some other values to the program with them. Futher more some programs might generate output tex coords
without taking them as inputs. */
/*for (i=0;i<ctx->Const.MaxTextureUnits;i++)
if(ctx->Texture.Unit[i].Enabled == 0)
inputs &= ~ (_TNL_BIT_TEX0<<i);*/
}
rmesa->state.render_inputs = inputs;
@@ -489,13 +497,22 @@ drm_radeon_cmd_header_t *cmd = NULL;
#endif
/* Stage 3: VAP output */
if (VERTPROG_ACTIVE(ctx))
outputs = rmesa->current_vp->outputs;
else
outputs = inputs;
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_0]=0;
if(outputs & _TNL_BIT_POS)
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
if(outputs & _TNL_BIT_COLOR0)
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= 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(r300->state.render_inputs & (_TNL_BIT_TEX0<<i))
if(outputs & (_TNL_BIT_TEX0<<i))
r300->hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i));
rmesa->state.aos_count = nr;

View File

@@ -336,6 +336,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
# define R300_GB_TILE_ENABLE (1<<0)
# define R300_GB_TILE_PIPE_COUNT_RV300 0
# define R300_GB_TILE_PIPE_COUNT_R300 (3<<1)
# define R300_GB_TILE_PIPE_COUNT_R420 (7<<1)
# define R300_GB_TILE_SIZE_8 0
# define R300_GB_TILE_SIZE_16 (1<<4)
# define R300_GB_TILE_SIZE_32 (2<<4)
@@ -535,8 +536,8 @@ I am fairly certain that they are correct unless stated otherwise in comments.
// the ROUTE_0_COLOR bit is set and ROUTE_0_COLOR_DEST contains the
// color register index. */
# define R300_RS_ROUTE_0_COLOR (1 << 14)
# define R300_RS_ROUTE_0_COLOR_DEST_SHIFT (1 << 17)
# define R300_RS_ROUTE_0_COLOR_DEST_MASK (31 << 6) /* GUESS */
# define R300_RS_ROUTE_0_COLOR_DEST_SHIFT 17
# define R300_RS_ROUTE_0_COLOR_DEST_MASK (31 << 17) /* GUESS */
/* END */
/* BEGIN: Scissors and cliprects
@@ -999,19 +1000,12 @@ I am fairly certain that they are correct unless stated otherwise in comments.
# define R300_REF_ALPHA_MASK 0x000000ff
# define R300_ALPHA_TEST_FAIL (0 << 8)
# define R300_ALPHA_TEST_LESS (1 << 8)
# define R300_ALPHA_TEST_LEQUAL (2 << 8)
# define R300_ALPHA_TEST_EQUAL (3 << 8)
# define R300_ALPHA_TEST_GEQUAL (4 << 8)
# define R300_ALPHA_TEST_GREATER (5 << 8)
# define R300_ALPHA_TEST_NEQUAL (6 << 8)
# define R300_ALPHA_TEST_PASS (7 << 8)
/* // Possibly more correct values:
# define R300_ALPHA_TEST_LEQUAL (3 << 8)
# define R300_ALPHA_TEST_EQUAL (2 << 8)
# define R300_ALPHA_TEST_GEQUAL (6 << 8)
# define R300_ALPHA_TEST_GREATER (4 << 8)
# define R300_ALPHA_TEST_NEQUAL (5 << 8)
*/
# define R300_ALPHA_TEST_PASS (7 << 8)
# define R300_ALPHA_TEST_OP_MASK (7 << 8)
# define R300_ALPHA_TEST_ENABLE (1 << 11)
@@ -1115,7 +1109,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
# define R300_RB3D_Z_TEST 0x00000012
# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016
# define R300_RB3D_Z_WRITE_ONLY 0x00000006
# define R300_RB3D_STENCIL_ENABLE (0<<1) /* UNKNOWN yet.. */
# define R300_RB3D_STENCIL_ENABLE 0x00000001
#define R300_RB3D_ZSTENCIL_CNTL_1 0x4F04
/* functions */
@@ -1154,6 +1148,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
#define R300_RB3D_ZSTENCIL_CNTL_2 0x4F08
# define R300_RB3D_ZS2_STENCIL_REF_SHIFT 0
# define R300_RB3D_ZS2_STENCIL_MASK 0xFF
# define R300_RB3D_ZS2_STENCIL_MASK_SHIFT 8
# define R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT 16

View File

@@ -513,6 +513,7 @@ static void r300_render_vb_primitive(r300ContextPtr rmesa,
}
if(num_verts > 65535){ /* not implemented yet */
WARN_ONCE("Too many elts\n");
return;
}
r300EmitElts(ctx, rmesa->state.Elts+start, num_verts);
@@ -596,7 +597,7 @@ static GLboolean r300_run_render(GLcontext *ctx,
#if 1
#if 1
#if 0
return r300_run_immediate_render(ctx, stage);
#else
return r300_run_vb_render(ctx, stage);
@@ -671,7 +672,7 @@ static void r300_check_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
stage->active = GL_FALSE;
return;
}
/* I'm almost certain I forgot something here */
#if 0 /* These should work now.. */
@@ -730,3 +731,50 @@ const struct tnl_pipeline_stage _r300_render_stage = {
r300_check_render, /* check */
r300_run_render /* run */
};
static GLboolean r300_run_tcl_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;
if (RADEON_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
return r300_run_vb_render(ctx, stage);
}
static void r300_check_tcl_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int i;
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s\n", __FUNCTION__);
/* We only support rendering in hardware for now */
if (ctx->RenderMode != GL_RENDER) {
stage->active = GL_FALSE;
return;
}
if(VERTPROG_ACTIVE(ctx)) {
stage->active = GL_TRUE;
stage->inputs = ctx->VertexProgram.Current->InputsRead;
} else {
stage->active = GL_FALSE;
}
}
const struct tnl_pipeline_stage _r300_tcl_stage = {
"r300 tcl",
_NEW_ALL, /* re-check (always re-check for now) */
0, /* re-run (always runs) */
GL_TRUE, /* active */
0, 0, /* inputs (set in check_render), outputs */
0, 0, /* changed_inputs, private */
dtr, /* destructor */
r300_check_tcl_render, /* check */
r300_run_tcl_render /* run */
};

View File

@@ -61,6 +61,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_fixed_pipelines.h"
#include "r300_tex.h"
#include "r300_maos.h"
#include "r300_texprog.h"
static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
{
@@ -69,7 +70,7 @@ static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
GLubyte refByte;
CLAMPED_FLOAT_TO_UBYTE(refByte, ref);
R300_STATECHANGE(rmesa, at);
pp_misc &= ~(R300_ALPHA_TEST_OP_MASK | R300_REF_ALPHA_MASK);
@@ -459,12 +460,12 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state)
break;
case GL_ALPHA_TEST:
R200_STATECHANGE(r300, at);
R300_STATECHANGE(r300, at);
if (state) {
r300->hw.at.cmd[R300_AT_ALPHA_TEST] |=
R300_ALPHA_TEST_ENABLE;
} else {
r300->hw.at.cmd[R300_AT_ALPHA_TEST] |=
r300->hw.at.cmd[R300_AT_ALPHA_TEST] &=
~R300_ALPHA_TEST_ENABLE;
}
break;
@@ -483,17 +484,15 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state)
else
newval = R300_RB3D_Z_TEST;
} else
newval = 0;
newval = R300_RB3D_Z_DISABLED_1;
r300->hw.zs.cmd[R300_ZS_CNTL_0] = newval;
r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
r300->hw.zs.cmd[R300_ZS_CNTL_0] |= newval;
break;
case GL_STENCIL_TEST:
WARN_ONCE("Do not know how to enable stencil. Help me !\n");
if (r300->state.hw_stencil) {
//fprintf(stderr, "Stencil %s\n", state ? "enabled" : "disabled");
WARN_ONCE("TODO - double side stencil !\n");
if (r300->state.stencil.hw_stencil) {
R300_STATECHANGE(r300, zs);
if (state) {
r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
@@ -609,7 +608,6 @@ static void r300DepthFunc(GLcontext* ctx, GLenum func)
r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_ALWAYS << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
break;
}
}
@@ -626,8 +624,9 @@ static void r300DepthMask(GLcontext* ctx, GLboolean mask)
return;
R300_STATECHANGE(r300, zs);
r300->hw.zs.cmd[R300_ZS_CNTL_0] = mask
? R300_RB3D_Z_TEST_AND_WRITE : R300_RB3D_Z_TEST;
r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
r300->hw.zs.cmd[R300_ZS_CNTL_0] |= mask
? R300_RB3D_Z_TEST_AND_WRITE : R300_RB3D_Z_TEST;
}
@@ -866,8 +865,8 @@ static void r300StencilFunc(GLcontext * ctx, GLenum func,
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
GLuint refmask = ((ctx->Stencil.Ref[0] << R300_RB3D_ZS2_STENCIL_REF_SHIFT) |
(ctx->Stencil.
ValueMask[0] << R300_RB3D_ZS2_STENCIL_MASK_SHIFT));
(ctx->Stencil.ValueMask[0] << R300_RB3D_ZS2_STENCIL_MASK_SHIFT));
GLuint flag;
R300_STATECHANGE(rmesa, zs);
@@ -875,9 +874,10 @@ static void r300StencilFunc(GLcontext * ctx, GLenum func,
rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(
(R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT)
| (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT));
rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~((R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_REF_SHIFT) |
(R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT));
rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~((R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_REF_SHIFT) |
(R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT));
flag = translate_stencil_func(ctx->Stencil.Function[0]);
rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= (flag << R300_RB3D_ZS1_FRONT_FUNC_SHIFT)
@@ -890,7 +890,7 @@ static void r300StencilMask(GLcontext * ctx, GLuint mask)
r300ContextPtr rmesa = R300_CONTEXT(ctx);
R300_STATECHANGE(rmesa, zs);
rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~(R300_ZS_MASK << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT);
rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~(R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT);
rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= ctx->Stencil.WriteMask[0] << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT;
}
@@ -902,7 +902,10 @@ static void r300StencilOp(GLcontext * ctx, GLenum fail,
R300_STATECHANGE(rmesa, zs);
/* It is easier to mask what's left.. */
rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= (R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &=
(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT) |
(R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) |
(R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT);
rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |=
(translate_stencil_op(ctx->Stencil.FailFunc[0]) << R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT)
@@ -911,19 +914,16 @@ static void r300StencilOp(GLcontext * ctx, GLenum fail,
|(translate_stencil_op(ctx->Stencil.FailFunc[0]) << R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT)
|(translate_stencil_op(ctx->Stencil.ZFailFunc[0]) << R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT)
|(translate_stencil_op(ctx->Stencil.ZPassFunc[0]) << R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT);
}
static void r300ClearStencil(GLcontext * ctx, GLint s)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
/* Not sure whether this is correct.. */
R300_STATECHANGE(rmesa, zs);
rmesa->hw.zs.cmd[R300_ZS_CNTL_2] =
rmesa->state.stencil.clear =
((GLuint) ctx->Stencil.Clear |
(0xff << R200_STENCIL_MASK_SHIFT) |
(ctx->Stencil.WriteMask[0] << R200_STENCIL_WRITEMASK_SHIFT));
(R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT) |
(ctx->Stencil.WriteMask[0] << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT));
}
/* =============================================================
@@ -1353,9 +1353,11 @@ void r300_setup_textures(GLcontext *ctx)
}
for(i=0; i < mtu; i++) {
/*if(ctx->Texture.Unit[i].Enabled == 0)
continue;*/
if( ((r300->state.render_inputs & (_TNL_BIT_TEX0<<i))!=0) != ((ctx->Texture.Unit[i].Enabled)!=0) ) {
WARN_ONCE("Mismatch between render_inputs and ctx->Texture.Unit[i].Enabled value.\n");
WARN_ONCE("Mismatch between render_inputs and ctx->Texture.Unit[i].Enabled value(%d vs %d).\n",
((r300->state.render_inputs & (_TNL_BIT_TEX0<<i))!=0), ((ctx->Texture.Unit[i].Enabled)!=0));
}
if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)) {
@@ -1380,7 +1382,7 @@ void r300_setup_textures(GLcontext *ctx)
max_texture_unit=i;
r300->hw.txe.cmd[R300_TXE_ENABLE]|=(1<<i);
r300->hw.tex.filter.cmd[R300_TEX_VALUE_0+i]=gen_fixed_filter(t->filter);
r300->hw.tex.filter.cmd[R300_TEX_VALUE_0+i]=gen_fixed_filter(t->filter) | (i << 28);
r300->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+i]=0x0;
/* No idea why linear filtered textures shake when puting random data */
@@ -1409,14 +1411,76 @@ void r300_setup_textures(GLcontext *ctx)
void r300_setup_rs_unit(GLcontext *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int i;
int i, cur_reg;
/* I'm still unsure if these are needed */
GLuint interp_magic[8] = {
0x00,
0x40,
0x80,
0xC0,
0x00,
0x00,
0x00,
0x00
};
GLuint vap_outputs;
/* This needs to be rewritten - it is a hack at best */
R300_STATECHANGE(r300, ri);
R300_STATECHANGE(r300, rc);
R300_STATECHANGE(r300, rr);
#if 1
cur_reg = 0;
r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0;
if (VERTPROG_ACTIVE(ctx))
vap_outputs = r300->current_vp->outputs;
else
vap_outputs = r300->state.render_inputs;
for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
r300->hw.ri.cmd[R300_RI_INTERP_0+i] = 0
| R300_RS_INTERP_USED
| (cur_reg << R300_RS_INTERP_SRC_SHIFT)
| interp_magic[i];
// fprintf(stderr, "RS_INTERP[%d] = 0x%x\n", i, r300->hw.ri.cmd[R300_RI_INTERP_0+i]);
if (r300->state.render_inputs & (_TNL_BIT_TEX0<<i)) {
assert(r300->state.texture.tc_count != 0);
r300->hw.rr.cmd[R300_RR_ROUTE_0 + cur_reg] = 0
| R300_RS_ROUTE_ENABLE
| i /* source INTERP */
| (cur_reg << R300_RS_ROUTE_DEST_SHIFT);
// fprintf(stderr, "RS_ROUTE[%d] = 0x%x\n", cur_reg, r300->hw.rr.cmd[R300_RR_ROUTE_0 + cur_reg]);
cur_reg++;
}
}
if (vap_outputs & _TNL_BIT_COLOR0)
r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0
| R300_RS_ROUTE_0_COLOR
| (cur_reg << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
// fprintf(stderr, "ADJ_RR0 = 0x%x\n", r300->hw.rr.cmd[R300_RR_ROUTE_0]);
r300->hw.rc.cmd[1] = 0
| (cur_reg /* count */ << R300_RS_CNTL_TC_CNT_SHIFT)
| R300_RS_CNTL_0_UNKNOWN_7
| R300_RS_CNTL_0_UNKNOWN_18;
if (r300->state.texture.tc_count > 0) {
r300->hw.rr.cmd[R300_RR_CMD_0] = cmducs(R300_RS_ROUTE_0, cur_reg);
r300->hw.rc.cmd[2] = 0xC0 | (cur_reg-1); /* index of highest */
} else {
r300->hw.rr.cmd[R300_RR_CMD_0] = cmducs(R300_RS_ROUTE_0, 1);
r300->hw.rc.cmd[2] = 0x0;
}
// fprintf(stderr, "rendering with %d texture co-ordinate sets\n", cur_reg);
#else
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;
@@ -1455,6 +1519,7 @@ void r300_setup_rs_unit(GLcontext *ctx)
r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0x4000;
}
#endif
}
#define vpucount(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
@@ -1513,6 +1578,7 @@ void r300SetupVertexProgram(r300ContextPtr rmesa);
void r300GenerateSimpleVertexShader(r300ContextPtr r300)
{
int i;
GLuint o_reg = 0;
/* Allocate parameters */
r300->state.vap_param.transform_offset=0x0; /* transform matrix */
@@ -1580,13 +1646,14 @@ void r300GenerateSimpleVertexShader(r300ContextPtr r300)
VSF_ATTR_X(0),
VSF_TMP(0)
)
o_reg += 2;
/* Pass through texture coordinates, if any */
for(i=0;i < r300->radeon.glCtx->Const.MaxTextureUnits;i++)
if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)){
// fprintf(stderr, "i_tex[%d]=%d\n", i, r300->state.vap_reg.i_tex[i]);
WRITE_OP(
EASY_VSF_OP(MUL, 2+i, ALL, RESULT),
EASY_VSF_OP(MUL, o_reg++ /* 2+i */, ALL, RESULT),
VSF_REG(r300->state.vap_reg.i_tex[i]),
VSF_ATTR_UNITY(r300->state.vap_reg.i_tex[i]),
VSF_UNITY(r300->state.vap_reg.i_tex[i])
@@ -1606,18 +1673,30 @@ void r300GenerateSimpleVertexShader(r300ContextPtr r300)
void r300SetupVertexShader(r300ContextPtr rmesa)
{
GLcontext* ctx = rmesa->radeon.glCtx;
struct r300_vertex_shader_fragment unk4={
length: 4,
body: { f: {
/*0.0*/(rand()%100)/10.0,
/*0.0*/(rand()%100)/10.0,
/*1.0*/(rand()%100)/10.0,
/*0.0*/(rand()%100)/10.0
} }
};
LOCAL_VARS
if(rmesa->current_vp != NULL){
r300SetupVertexProgram(rmesa);
return ;
}
/* Reset state, in case we don't use something */
((drm_r300_cmd_header_t*)rmesa->hw.vpp.cmd)->vpu.count = 0;
((drm_r300_cmd_header_t*)rmesa->hw.vpi.cmd)->vpu.count = 0;
((drm_r300_cmd_header_t*)rmesa->hw.vps.cmd)->vpu.count = 0;
/* Not sure why this doesnt work...
0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
//setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
if(VERTPROG_ACTIVE(ctx)){
r300SetupVertexProgram(rmesa);
return ;
}
/* This needs to be replaced by vertex shader generation code */
@@ -1803,7 +1882,7 @@ void r300GenerateTexturePixelShader(r300ContextPtr r300)
alu_inst++;
}
r300->state.pixel_shader.program.tex.length=tex_inst;
r300->state.pixel_shader.program.tex_offset=0;
r300->state.pixel_shader.program.tex_end=tex_inst-1;
@@ -1827,12 +1906,16 @@ int i,k;
/* textures enabled ? */
if(rmesa->state.texture.tc_count>0){
#if 1
r300GenerateTextureFragmentShader(rmesa);
#else
rmesa->state.pixel_shader=SINGLE_TEXTURE_PIXEL_SHADER;
r300GenerateTexturePixelShader(rmesa);
#endif
} else {
rmesa->state.pixel_shader=FLAT_COLOR_PIXEL_SHADER;
}
R300_STATECHANGE(rmesa, fpt);
for(i=0;i<rmesa->state.pixel_shader.program.tex.length;i++)
rmesa->hw.fpt.cmd[R300_FPT_INSTR_0+i]=rmesa->state.pixel_shader.program.tex.inst[i];
@@ -1965,9 +2048,18 @@ void r300ResetHwState(r300ContextPtr r300)
have bitfields accessed by different functions
and not all bits are used */
#if 0
/* initialize similiar to r200 */
r300->hw.zs.cmd[R300_ZS_CNTL_0] = 0;
r300->hw.zs.cmd[R300_ZS_CNTL_1] = 0;
r300->hw.zs.cmd[R300_ZS_CNTL_2] = 0xffff00;
r300->hw.zs.cmd[R300_ZS_CNTL_1] =
(R300_ZS_ALWAYS << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) |
(R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |
(R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) |
(R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) |
(R300_ZS_ALWAYS << R300_RB3D_ZS1_BACK_FUNC_SHIFT) |
(R300_ZS_KEEP << R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) |
(R300_ZS_KEEP << R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT) |
(R300_ZS_KEEP << R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT);
r300->hw.zs.cmd[R300_ZS_CNTL_2] = 0x00ffff00;
#endif
/* go and compute register values from GL state */
@@ -1983,6 +2075,12 @@ void r300ResetHwState(r300ContextPtr r300)
r300Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
r300DepthMask(ctx, ctx->Depth.Mask);
r300DepthFunc(ctx, ctx->Depth.Func);
/* stencil */
r300Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
r300StencilMask(ctx, ctx->Stencil.WriteMask[0]);
r300StencilFunc(ctx, ctx->Stencil.Function[0], ctx->Stencil.Ref[0], ctx->Stencil.ValueMask[0]);
r300StencilOp(ctx, ctx->Stencil.FailFunc[0], ctx->Stencil.ZFailFunc[0], ctx->Stencil.ZPassFunc[0]);
r300UpdateCulling(ctx);
@@ -1997,8 +2095,10 @@ void r300ResetHwState(r300ContextPtr r300)
r300SetupPixelShader(r300);
r300_set_blend_state(ctx);
r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
r300Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
/* Initialize magic registers
TODO : learn what they really do, or get rid of
those we don't have to touch */
@@ -2067,6 +2167,10 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE
| R300_GB_TILE_PIPE_COUNT_R300
| R300_GB_TILE_SIZE_16;
else if (GET_CHIP(r300->radeon.radeonScreen) == RADEON_CHIP_R420)
r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE
| R300_GB_TILE_PIPE_COUNT_R420
| R300_GB_TILE_SIZE_16;
else
r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE
| R300_GB_TILE_PIPE_COUNT_RV300
@@ -2163,10 +2267,6 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk4BC8.cmd[2] = 0;
r300->hw.unk4BC8.cmd[3] = 0;
//r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
#if 0
r300->hw.at.cmd[R300_AT_ALPHA_TEST] = 0;
#endif
r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
r300->hw.unk4BD8.cmd[1] = 0;
@@ -2278,12 +2378,12 @@ void r300InitState(r300ContextPtr r300)
case 16:
r300->state.depth.scale = 1.0 / (GLfloat) 0xffff;
depth_fmt = R200_DEPTH_FORMAT_16BIT_INT_Z;
//r300->state.stencil.clear = 0x00000000;
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;
r300->state.stencil.clear = 0x00ff0000;
break;
default:
fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
@@ -2292,7 +2392,7 @@ void r300InitState(r300ContextPtr r300)
}
/* Only have hw stencil when depth buffer is 24 bits deep */
r300->state.hw_stencil = (ctx->Visual.stencilBits > 0 &&
r300->state.stencil.hw_stencil = (ctx->Visual.stencilBits > 0 &&
ctx->Visual.depthBits == 24);
memset(&(r300->state.texture), 0, sizeof(r300->state.texture));

View File

@@ -140,7 +140,7 @@ static void r300UploadGARTClientSubImage(r300ContextPtr rmesa,
width = texImage->Width;
height = texImage->Height;
r300EmitWait(rmesa, RADEON_WAIT_3D);
r300EmitWait(rmesa, R300_WAIT_3D);
r300EmitBlit(rmesa, blit_format,
srcPitch,
@@ -152,7 +152,7 @@ static void r300UploadGARTClientSubImage(r300ContextPtr rmesa,
t->image[0][hwlevel].x + x,
t->image[0][hwlevel].y + y, width, height);
r300EmitWait(rmesa, RADEON_WAIT_2D);
r300EmitWait(rmesa, R300_WAIT_2D);
}
static void r300UploadRectSubImage(r300ContextPtr rmesa,
@@ -254,7 +254,7 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa,
}
}
r300EmitWait(rmesa, RADEON_WAIT_3D);
r300EmitWait(rmesa, R300_WAIT_3D);
/* Blit to framebuffer
*/
@@ -264,7 +264,7 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa,
dstPitch, t->bufAddr,
0, 0, 0, done, width, lines);
r300EmitWait(rmesa, RADEON_WAIT_2D);
r300EmitWait(rmesa, R300_WAIT_2D);
r300ReleaseDmaRegion(rmesa, &region, __FUNCTION__);
done += lines;

View File

@@ -0,0 +1,264 @@
#include "glheader.h"
#include "state.h"
#include "imports.h"
#include "enums.h"
#include "macros.h"
#include "context.h"
#include "dd.h"
#include "simple_list.h"
#include "api_arrayelt.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "array_cache/acache.h"
#include "tnl/tnl.h"
#include "texformat.h"
#include "radeon_ioctl.h"
#include "radeon_state.h"
#include "r300_context.h"
#include "r300_ioctl.h"
#include "r300_state.h"
#include "r300_reg.h"
#include "r300_program.h"
#include "r300_emit.h"
#include "r300_fixed_pipelines.h"
#include "r300_tex.h"
#include "pixel_shader.h"
#include "r300_texprog.h"
/* TODO: we probably should have a better way to emit alu instructions */
#define INST0 p->alu.inst[p->alu.length].inst0 =
#define INST1 p->alu.inst[p->alu.length].inst1 =
#define INST2 p->alu.inst[p->alu.length].inst2 =
#define INST3 p->alu.inst[p->alu.length].inst3 =
#define EMIT_INST p->alu.length++
void emit_tex(struct r300_pixel_shader_program *p, GLuint dest, GLuint unit, GLuint src)
{
p->tex.inst[p->tex.length++] = 0
| (src << R300_FPITX_SRC_SHIFT)
| (dest << R300_FPITX_DST_SHIFT)
| (unit << R300_FPITX_IMAGE_SHIFT)
/* I don't know if this is needed, but the hardcoded 0x18000 set it, so I will too */
| (3 << 15);
// fprintf(stderr, "emit texinst: 0x%x\n", p->tex.inst[p->tex.length-1]);
}
GLuint get_source(struct r300_pixel_shader_state *ps, GLenum src, GLuint unit, GLuint tc_reg) {
switch (src) {
case GL_TEXTURE:
if (!ps->have_sample) {
emit_tex(&ps->program, tc_reg, unit, tc_reg);
ps->have_sample = 1;
}
return tc_reg;
case GL_CONSTANT:
WARN_ONCE("TODO: Implement envcolor\n");
return ps->color_reg;
case GL_PRIMARY_COLOR:
return ps->color_reg;
case GL_PREVIOUS:
return ps->src_previous;
default:
WARN_ONCE("Unknown source enum\n");
return ps->src_previous;
}
}
GLuint get_temp(struct r300_pixel_shader_program *p)
{
return p->temp_register_count++;
}
inline void emit_texenv_color(r300ContextPtr r300, struct r300_pixel_shader_state *ps,
GLuint out, GLenum envmode, GLenum format, GLuint unit, GLuint tc_reg) {
struct r300_pixel_shader_program *p = &ps->program;
const GLuint Cp = get_source(ps, GL_PREVIOUS, unit, tc_reg);
const GLuint Cs = get_source(ps, GL_TEXTURE, unit, tc_reg);
switch(envmode) {
case GL_DECAL: /* TODO */
case GL_BLEND: /* TODO */
case GL_REPLACE:
INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
switch (format) {
case GL_ALPHA:
// Cv = Cp
INST1 EASY_PFS_INSTR1(out, Cp, PFS_FLAG_CONST, PFS_FLAG_CONST, ALL, NONE);
break;
default:
// Cv = Cs
INST1 EASY_PFS_INSTR1(out, Cs, PFS_FLAG_CONST, PFS_FLAG_CONST, ALL, NONE);
break;
}
break;
case GL_MODULATE:
switch (format) {
case GL_ALPHA:
// Cv = Cp
INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
INST1 EASY_PFS_INSTR1(out, Cp, PFS_FLAG_CONST, PFS_FLAG_CONST, ALL, NONE);
break;
default:
// Cv = CpCs
INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, SRC1C_XYZ, ZERO);
INST1 EASY_PFS_INSTR1(out, Cp, Cs, PFS_FLAG_CONST, ALL, NONE);
break;
}
break;
case GL_ADD:
switch (format) {
case GL_ALPHA:
// Cv = Cp
INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
INST1 EASY_PFS_INSTR1(out, Cp, PFS_FLAG_CONST, PFS_FLAG_CONST, ALL, NONE);
break;
default:
// Cv = Cp + Cs
INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, SRC1C_XYZ);
INST1 EASY_PFS_INSTR1(out, Cp, Cs, PFS_FLAG_CONST, ALL, NONE);
break;
}
break;
default:
fprintf(stderr, "%s: should never get here!\n", __func__);
break;
}
return;
}
inline void emit_texenv_alpha(r300ContextPtr r300, struct r300_pixel_shader_state *ps,
GLuint out, GLenum envmode, GLenum format, GLuint unit, GLuint tc_reg) {
struct r300_pixel_shader_program *p = &ps->program;
const GLuint Ap = get_source(ps, GL_PREVIOUS, unit, tc_reg);
const GLuint As = get_source(ps, GL_TEXTURE, unit, tc_reg);
switch(envmode) {
case GL_DECAL: /* TODO */
case GL_BLEND: /* TODO */
case GL_REPLACE:
INST2 EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
switch (format) {
case GL_LUMINANCE:
case GL_RGB:
// Av = Ap
INST3 EASY_PFS_INSTR3(out, Ap, PFS_FLAG_CONST, PFS_FLAG_CONST, REG);
break;
default:
INST3 EASY_PFS_INSTR3(out, As, PFS_FLAG_CONST, PFS_FLAG_CONST, REG);
break;
}
break;
case GL_MODULATE:
case GL_ADD:
switch (format) {
case GL_LUMINANCE:
case GL_RGB:
// Av = Ap
INST2 EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
INST3 EASY_PFS_INSTR3(out, Ap, PFS_FLAG_CONST, PFS_FLAG_CONST, REG);
break;
default:
// Av = ApAs
INST2 EASY_PFS_INSTR2(MAD, SRC0A, SRC1A, ZERO);
INST3 EASY_PFS_INSTR3(out, Ap, As, PFS_FLAG_CONST, REG);
break;
}
break;
default:
fprintf(stderr, "%s: should never get here!\n", __func__);
break;
}
return;
}
GLuint emit_texenv(r300ContextPtr r300, GLuint tc_reg, GLuint unit)
{
struct r300_pixel_shader_state *ps = &r300->state.pixel_shader;
struct r300_pixel_shader_program *p = &ps->program;
GLcontext *ctx = r300->radeon.glCtx;
struct gl_texture_object *texobj = ctx->Texture.Unit[unit]._Current;
GLenum envmode = ctx->Texture.Unit[unit].EnvMode;
GLenum format = texobj->Image[0][texobj->BaseLevel]->Format;
const GLuint out = tc_reg;
const GLuint Cf = get_source(ps, GL_PRIMARY_COLOR, unit, tc_reg);
WARN_ONCE("Texture environments are currently incomplete / wrong! Help me!\n");
// fprintf(stderr, "EnvMode = %s\n", _mesa_lookup_enum_by_nr(ctx->Texture.Unit[unit].EnvMode));
switch (envmode) {
case GL_REPLACE:
case GL_MODULATE:
case GL_DECAL:
case GL_BLEND:
case GL_ADD:
/* Maybe these should be combined? I thought it'd be messy */
emit_texenv_color(r300, ps, out, envmode, format, unit, tc_reg);
emit_texenv_alpha(r300, ps, out, envmode, format, unit, tc_reg);
EMIT_INST;
return out;
break;
case GL_COMBINE:
WARN_ONCE("EnvMode == GL_COMBINE unsupported! Help Me!!\n");
return Cf;
break;
default:
WARN_ONCE("Unknown EnvMode == %d, name=%d\n", envmode,
_mesa_lookup_enum_by_nr(envmode));
return Cf;
break;
}
}
void r300GenerateTextureFragmentShader(r300ContextPtr r300)
{
struct r300_pixel_shader_state *ps = &r300->state.pixel_shader;
struct r300_pixel_shader_program *p = &ps->program;
GLcontext *ctx = r300->radeon.glCtx;
int i, tc_reg;
p->tex.length = 0;
p->alu.length = 0;
p->active_nodes = 1;
p->first_node_has_tex = 1;
p->temp_register_count = r300->state.texture.tc_count + 1; /* texcoords and colour reg */
ps->color_reg = r300->state.texture.tc_count;
ps->src_previous = ps->color_reg;
tc_reg = 0;
for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
if (r300->state.render_inputs & (_TNL_BIT_TEX0<<i)) {
ps->have_sample = 0;
ps->src_previous = emit_texenv(r300, tc_reg, i);
tc_reg++;
}
}
/* Do a MOV from last output, to destination reg.. This won't be needed when we
* have a better way of emitting alu instructions
*/
INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
INST1 EASY_PFS_INSTR1(0, ps->src_previous, PFS_FLAG_CONST, PFS_FLAG_CONST, NONE, ALL);
INST2 EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
INST3 EASY_PFS_INSTR3(0, ps->src_previous, PFS_FLAG_CONST, PFS_FLAG_CONST, OUTPUT);
EMIT_INST;
p->node[3].tex_end = ps->program.tex.length - 1;
p->node[3].tex_offset = 0;
p->node[3].alu_end = ps->program.alu.length - 1;
p->node[3].alu_offset = 0;
p->tex_end = ps->program.tex.length - 1;
p->tex_offset = 0;
p->alu_end = ps->program.alu.length - 1;
p->alu_offset = 0;
}

View File

@@ -0,0 +1,9 @@
#ifndef __R300_TEXPROG_H_
#define __R300_TEXPROG_H_
#include "r300_context.h"
void r300GenerateTextureFragmentShader(r300ContextPtr r300);
#endif

View File

@@ -68,7 +68,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define _INVALID(f) \
[ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_YCBCR_REV) \
&& (tx_table[f].format != 0xffffffff) )
&& tx_table[f].flag )
#define _ASSIGN(entry, format) \
[ MESA_FORMAT_ ## entry ] = { format, 0, 1}
static const struct {
GLuint format, filter;
@@ -95,60 +98,43 @@ static const struct {
};
static const struct {
GLuint format, filter;
GLuint format, filter, flag;
} tx_table[] = {
#ifdef MESA_BIG_ENDIAN
/*
* NOTE: As we can't do swapping (RBBM_GUI_CNTL doesn't seems to work
* on r300) we declare the texture format in swapped form. We
* should better find a way to ask the hardware to do the swapping.
* Jerome Glisse
*/
{R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8), 0},
{R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8), 0},
{0xffffff02, 0},
{0xffffff03, 0},
{0xffffff04, 0},
{0xffffff05, 0},
{0xffffff06, 0},
{0xffffff07, 0},
{0xffffff08, 0},
{0xffffff09, 0},
{0xffffff10, 0},
{0xffffff11, 0},
{R300_EASY_TX_FORMAT(Y, Y, Y, X, Y8X8), 0},
{0xffffff13, 0},
{0xffffff14, 0},
{0xffffff15, 0},
{0xffffff16, 0},
{0xffffff17, 0},
/*
* Note that the _REV formats are the same as the non-REV formats.
* This is because the REV and non-REV formats are identical as a
* byte string, but differ when accessed as 16-bit or 32-bit words
* depending on the endianness of the host. Since the textures are
* transferred to the R300 as a byte string (i.e. without any
* byte-swapping), the R300 sees the REV and non-REV formats
* identically. -- paulus
*/
_ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
_ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
_ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
_ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
_ASSIGN(RGB888, 0xffffffff),
_ASSIGN(RGB565, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
_ASSIGN(RGB565_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
_ASSIGN(ARGB4444, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
_ASSIGN(ARGB4444_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
_ASSIGN(ARGB1555, R300_EASY_TX_FORMAT(Z, Y, X, W, W1Z5Y5X5)),
_ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(Z, Y, X, W, W1Z5Y5X5)),
_ASSIGN(AL88, R300_EASY_TX_FORMAT(Y, Y, Y, X, Y8X8)),
_ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(Y, Y, Y, X, Y8X8)),
_ASSIGN(RGB332, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z3Y3X2)),
_ASSIGN(A8, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X8)),
_ASSIGN(L8, R300_EASY_TX_FORMAT(X, X, X, ONE, X8)),
_ASSIGN(I8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
_ASSIGN(CI8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
_ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE ),
_ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE),
};
#else
{R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8), 0},
{0xffffff01, 0},
{0xffffff02, 0},
{0xffffff03, 0},
{0xffffff04, 0},
{0xffffff05, 0},
{R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5), 0},
{0xffffff07, 0},
{R300_EASY_TX_FORMAT(Y, Z, W, X, W4Z4Y4X4), 0},
{0xffffff09, 0},
{0xffffff10, 0},
{0xffffff11, 0},
{R300_EASY_TX_FORMAT(Y, Y, Y, X, Y8X8), 0},
{0xffffff13, 0},
{0xffffff14, 0},
{0xffffff15, 0},
{0xffffff16, 0},
{0xffffff17, 0},
};
#endif
#undef _COLOR
#undef _ALPHA
#undef _INVALID
#undef _ASSIGN
/**
@@ -1119,10 +1105,12 @@ static GLboolean enable_tex_2d(GLcontext * ctx, int unit)
/* Need to load the 2d images associated with this unit.
*/
#if 0
if (t->format & R200_TXFORMAT_NON_POWER2) {
t->format &= ~R200_TXFORMAT_NON_POWER2;
t->base.dirty_images[0] = ~0;
}
#endif
ASSERT(tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_1D);
@@ -1223,10 +1211,12 @@ static GLboolean enable_tex_rect(GLcontext * ctx, int unit)
struct gl_texture_object *tObj = texUnit->_Current;
r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
#if 0
if (!(t->format & R200_TXFORMAT_NON_POWER2)) {
t->format |= R200_TXFORMAT_NON_POWER2;
t->base.dirty_images[0] = ~0;
}
#endif
ASSERT(tObj->Target == GL_TEXTURE_RECTANGLE_NV);

View File

@@ -357,8 +357,10 @@ void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
{
int i;
if(vp == NULL)
if(vp == NULL){
fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__, caller);
return ;
}
fprintf(stderr, "%s:<", caller);
for(i=0; i < VERT_ATTRIB_MAX; i++)
@@ -373,16 +375,6 @@ static unsigned long t_src_index(struct r300_vertex_program *vp, struct vp_src_r
int max_reg=-1;
if(src->File == PROGRAM_INPUT){
/*
switch(src->Index){
case 0: return 0;
case 3: return 1;
case 2: return 2;
case 8: return 8;
default: printf("unknown input index %d\n", src->Index); exit(0); break;
}*/
if(vp->inputs[src->Index] != -1)
return vp->inputs[src->Index];
@@ -412,6 +404,18 @@ static unsigned long t_src(struct r300_vertex_program *vp, struct vp_src_registe
src->Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
}
static unsigned long t_src_scalar(struct r300_vertex_program *vp, struct vp_src_register *src)
{
return MAKE_VSF_SOURCE(t_src_index(vp, src),
t_swizzle(src->Swizzle[0]),
t_swizzle(src->Swizzle[0]),
t_swizzle(src->Swizzle[0]),
t_swizzle(src->Swizzle[0]),
t_src_class(src->File),
src->Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
}
static unsigned long t_opcode(enum vp_opcode opcode)
{
@@ -422,7 +426,6 @@ static unsigned long t_opcode(enum vp_opcode opcode)
case VP_OPCODE_EXP: return R300_VPI_OUT_OP_EXP;
case VP_OPCODE_FRC: return R300_VPI_OUT_OP_FRC;
case VP_OPCODE_LG2: return R300_VPI_OUT_OP_LG2;
case VP_OPCODE_LIT: return R300_VPI_OUT_OP_LIT;
case VP_OPCODE_LOG: return R300_VPI_OUT_OP_LOG;
case VP_OPCODE_MAD: return R300_VPI_OUT_OP_MAD;
case VP_OPCODE_MAX: return R300_VPI_OUT_OP_MAX;
@@ -472,7 +475,11 @@ static void translate_program(struct r300_vertex_program *vp)
VERTEX_SHADER_INSTRUCTION t2rs[1024];
VERTEX_SHADER_INSTRUCTION *o_inst;
unsigned long operands;
int u_temp_i=63; /* Initial value should be last tmp reg that hw supports */
int are_srcs_scalar;
/* Initial value should be last tmp reg that hw supports.
Strangely enough r300 doesnt mind even though these would be out of range.
Smart enough to realize that it doesnt need it? */
int u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1;
#ifdef SRCS_WRITABLE
struct vp_src_register src[3];
#else
@@ -485,14 +492,33 @@ static void translate_program(struct r300_vertex_program *vp)
for(i=0; i < VERT_ATTRIB_MAX; i++)
vp->inputs[i]=-1;
vp->outputs = 0;
/* FIXME: hardcoded values in arbprogparse.c:parse_result_binding ()
We might want to use these constants for VAP output in general as well once they have been added to
mesa headers.
*/
if(mesa_vp->OutputsWritten & (1<<0))
vp->outputs |= _TNL_BIT_POS;
if(mesa_vp->OutputsWritten & (1<<1))
vp->outputs |= _TNL_BIT_COLOR0;
if(mesa_vp->OutputsWritten & (1<<2))
vp->outputs |= _TNL_BIT_COLOR1;
for(i=0; i < 8/*ctx->Const.MaxTextureUnits*/; i++)
if(mesa_vp->OutputsWritten & (1<<(7+i)))
vp->outputs |= _TNL_BIT_TEX(i);
if(mesa_vp->OutputsWritten & ~(0x7 | 0x3f80))
fprintf(stderr, "%s:Odd bits(0x%08x)\n", __FUNCTION__, mesa_vp->OutputsWritten);
o_inst=vp->program.body.i;
for(vpi=mesa_vp->Instructions; vpi->Opcode != VP_OPCODE_END; vpi++, o_inst++){
operands=op_operands(vpi->Opcode);
are_srcs_scalar=operands & SCALAR_FLAG;
operands &= ~SCALAR_FLAG;
for(i=0; i < operands; i++)
src[i]=vpi->SrcReg[i];
#if 1
if(operands == 3){ /* TODO: scalars */
if( CMP_SRCS(src[1], src[2]) || CMP_SRCS(src[0], src[2]) ){
o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
@@ -501,12 +527,12 @@ static void translate_program(struct r300_vertex_program *vp)
o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
SWIZZLE_X, SWIZZLE_Y,
SWIZZLE_Z, SWIZZLE_W,
t_src_class(src[0].File), VSF_FLAG_NONE);
t_src_class(src[2].File), VSF_FLAG_NONE);
o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
SWIZZLE_ZERO, SWIZZLE_ZERO,
SWIZZLE_ZERO, SWIZZLE_ZERO,
t_src_class(src[0].File), VSF_FLAG_NONE);
t_src_class(src[2].File), VSF_FLAG_NONE);
o_inst->src3=0;
o_inst++;
@@ -538,7 +564,7 @@ static void translate_program(struct r300_vertex_program *vp)
u_temp_i--;
}
}
#endif
/* these ops need special handling.
Ops that need temp vars should probably be given reg indexes starting at the end of tmp area. */
switch(vpi->Opcode){
@@ -601,7 +627,8 @@ static void translate_program(struct r300_vertex_program *vp)
#ifdef SRCS_WRITABLE
vpi->Opcode=VP_OPCODE_MAX;
src[1]=src[0];
src[1].Negate=GL_TRUE;
src[1].Negate=!src[0].Negate;
operands=op_operands(vpi->Opcode);
break;
#else
o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, vpi->DstReg.Index,
@@ -647,6 +674,33 @@ static void translate_program(struct r300_vertex_program *vp)
u_temp_i--;
goto next;
case VP_OPCODE_LIT://LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, vpi->DstReg.Index,
t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
/* NOTE: Users swizzling might not work. */
o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
t_swizzle(src[0].Swizzle[0]), // x
t_swizzle(src[0].Swizzle[3]), // w
t_swizzle(src[0].Swizzle[2]), // z
t_swizzle(src[0].Swizzle[1]), // y
t_src_class(src[0].File),
src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
t_swizzle(src[0].Swizzle[1]), // y
t_swizzle(src[0].Swizzle[3]), // w
t_swizzle(src[0].Swizzle[2]), // z
t_swizzle(src[0].Swizzle[0]), // x
t_src_class(src[0].File),
src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
o_inst->src3=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
t_swizzle(src[0].Swizzle[1]), // y
t_swizzle(src[0].Swizzle[0]), // x
t_swizzle(src[0].Swizzle[2]), // z
t_swizzle(src[0].Swizzle[3]), // w
t_src_class(src[0].File),
src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
goto next;
case VP_OPCODE_DPH://DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, vpi->DstReg.Index,
t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
@@ -662,7 +716,7 @@ static void translate_program(struct r300_vertex_program *vp)
o_inst->src3=0;
goto next;
case VP_OPCODE_XPD:
case VP_OPCODE_XPD: /* Broken due to swizzling */
/* ADD TMP 0.X Y Z PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
MUL TMP 1.X Y Z W TMP 0{} {Z X Y ZERO} PARAM 1{} {Y Z X ZERO}
MAD RESULT 1.X Y Z W TMP 0{} {Y Z X ONE} PARAM 1{} {Z X Y ONE} TMP 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W*/
@@ -734,33 +788,60 @@ static void translate_program(struct r300_vertex_program *vp)
o_inst->op=MAKE_VSF_OP(t_opcode(vpi->Opcode), vpi->DstReg.Index,
t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
switch(operands){
case 1:
o_inst->src1=t_src(vp, &src[0]);
o_inst->src2=0;
o_inst->src3=0;
break;
case 2:
o_inst->src1=t_src(vp, &src[0]);
o_inst->src2=t_src(vp, &src[1]);
o_inst->src3=0;
break;
case 3:
o_inst->src1=t_src(vp, &src[0]);
o_inst->src2=t_src(vp, &src[1]);
o_inst->src3=t_src(vp, &src[2]);
break;
default:
fprintf(stderr, "scalars and op RCC not handled yet");
exit(-1);
break;
}
next:
if(are_srcs_scalar){
switch(operands){
case 1:
o_inst->src1=t_src_scalar(vp, &src[0]);
o_inst->src2=0;
o_inst->src3=0;
break;
case 2:
o_inst->src1=t_src_scalar(vp, &src[0]);
o_inst->src2=t_src_scalar(vp, &src[1]);
o_inst->src3=0;
break;
case 3:
o_inst->src1=t_src_scalar(vp, &src[0]);
o_inst->src2=t_src_scalar(vp, &src[1]);
o_inst->src3=t_src_scalar(vp, &src[2]);
break;
default:
fprintf(stderr, "scalars and op RCC not handled yet");
exit(-1);
break;
}
}else{
switch(operands){
case 1:
o_inst->src1=t_src(vp, &src[0]);
o_inst->src2=0;
o_inst->src3=0;
break;
case 2:
o_inst->src1=t_src(vp, &src[0]);
o_inst->src2=t_src(vp, &src[1]);
o_inst->src3=0;
break;
case 3:
o_inst->src1=t_src(vp, &src[0]);
o_inst->src2=t_src(vp, &src[1]);
o_inst->src3=t_src(vp, &src[2]);
break;
default:
fprintf(stderr, "scalars and op RCC not handled yet");
exit(-1);
break;
}
}
next: ;
#if 0
/* If instruction writes to result and one of the inputs is tmp, we move it at the end of program */
if(vpi->DstReg.File == PROGRAM_OUTPUT){
for(operand_index=0; operand_index < operands; operand_index++)
@@ -770,13 +851,13 @@ static void translate_program(struct r300_vertex_program *vp)
break;
}
}
#endif
}
#if 0
/* Put "tmp to result" instructions in */
for(i=0; i < vp->t2rs; i++, o_inst++)
*o_inst=t2rs[i];
#endif
vp->program.length=(o_inst - vp->program.body.i) * 4;
if(u_temp_i < vp->num_temporaries)
@@ -853,13 +934,16 @@ static void r300ProgramStringNotify(GLcontext *ctx, GLenum target,
struct program *prog)
{
struct r300_vertex_program *vp=(void *)prog;
#if 0
#if 0
fprintf(stderr, "r300ProgramStringNotify\n");
#endif
switch(target) {
case GL_VERTEX_PROGRAM_ARB:
vp->translated=GL_FALSE;
break;
case GL_FRAGMENT_PROGRAM_ARB:
return ;
break;
}

View File

@@ -393,14 +393,8 @@ radeonCreateContext( const __GLcontextModes *glVisual,
*/
_tnl_isolate_materials( ctx, GL_TRUE );
/* _mesa_allow_light_in_model( ctx, GL_FALSE ); */
/* Try and keep materials and vertices separate:
*/
_tnl_isolate_materials( ctx, GL_TRUE );
/* Configure swrast and T&L to match hardware characteristics:
*/
_swrast_allow_pixel_fog( ctx, GL_FALSE );

View File

@@ -146,6 +146,7 @@ static struct {
{ RADEON_PP_CUBIC_OFFSET_T1_0, 5, "RADEON_PP_CUBIC_OFFSET_T1_0" },
{ RADEON_PP_CUBIC_FACES_2, 1, "RADEON_PP_CUBIC_FACES_2" },
{ RADEON_PP_CUBIC_OFFSET_T2_0, 5, "RADEON_PP_CUBIC_OFFSET_T2_0" },
{ 0, 2, "R200_PP_TRI_PERF" },
};
struct reg_names {

View File

@@ -89,6 +89,7 @@ static const GLuint __driNConfigOptions = 13;
#define PCI_CHIP_RADEON_QY 0x5159
#define PCI_CHIP_RADEON_QZ 0x515A
#define PCI_CHIP_RN50_515E 0x515E
#define PCI_CHIP_RN50_5969 0x5969
#define PCI_CHIP_RADEON_LW 0x4C57 /* mobility 7 - has tcl */
@@ -325,6 +326,7 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
screen->chipset |= RADEON_CHIPSET_TCL;
case PCI_CHIP_RADEON_QY:
case PCI_CHIP_RADEON_QZ:
case PCI_CHIP_RN50_515E:
case PCI_CHIP_RN50_5969:
case PCI_CHIP_RADEON_LY:
case PCI_CHIP_RADEON_LZ:

View File

@@ -16,6 +16,7 @@
#include "driver.h"
#include "drm.h"
#include "memops.h"
#include "radeon.h"
#include "radeon_dri.h"
@@ -981,11 +982,11 @@ static int RADEONScreenInit( DRIDriverContext *ctx, RADEONInfoPtr info )
* the clear ioctl to do this, but would need to setup hw state
* first.
*/
memset((char *)ctx->FBAddress + info->frontOffset,
drimemsetio((char *)ctx->FBAddress + info->frontOffset,
0,
info->frontPitch * ctx->cpp * ctx->shared.virtualHeight );
memset((char *)ctx->FBAddress + info->backOffset,
drimemsetio((char *)ctx->FBAddress + info->backOffset,
0,
info->backPitch * ctx->cpp * ctx->shared.virtualHeight );

View File

@@ -69,6 +69,11 @@ DRI_CONF_OPT_BEGIN(enable_fastpath,bool,def) \
DRI_CONF_DESC(en,"Use fast path for unclipped primitives") \
DRI_CONF_DESC(de,"Schneller Codepfad für ungeschnittene Polygone") \
DRI_CONF_OPT_END
#define SAVAGE_SYNC_FRAMES(def) \
DRI_CONF_OPT_BEGIN(sync_frames,bool,def) \
DRI_CONF_DESC(en,"Synchronize with graphics hardware after each frame") \
DRI_CONF_DESC(de,"Synchronisiere nach jedem Frame mit Grafikhardware") \
DRI_CONF_OPT_END
/* Configuration
*/
@@ -80,16 +85,17 @@ DRI_CONF_BEGIN
DRI_CONF_FLOAT_DEPTH(false)
DRI_CONF_SECTION_END
DRI_CONF_SECTION_PERFORMANCE
DRI_CONF_MAX_TEXTURE_UNITS(2,1,2)
SAVAGE_ENABLE_VDMA(true)
SAVAGE_ENABLE_FASTPATH(true)
SAVAGE_SYNC_FRAMES(false)
DRI_CONF_MAX_TEXTURE_UNITS(2,1,2)
DRI_CONF_TEXTURE_HEAPS(DRI_CONF_TEXTURE_HEAPS_ALL)
DRI_CONF_SECTION_END
DRI_CONF_SECTION_DEBUG
DRI_CONF_NO_RAST(false)
DRI_CONF_SECTION_END
DRI_CONF_END;
static const GLuint __driNConfigOptions = 8;
static const GLuint __driNConfigOptions = 9;
#ifdef USE_NEW_INTERFACE
static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
@@ -247,7 +253,8 @@ savageDestroyScreen(__DRIscreenPrivate *sPriv)
{
savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
drmUnmapBufs(savageScreen->bufs);
if (savageScreen->bufs)
drmUnmapBufs(savageScreen->bufs);
/* free all option information */
driDestroyOptionInfo (&savageScreen->optionCache);
@@ -492,16 +499,13 @@ savageCreateContext( const __GLcontextModes *mesaVis,
"version 2.2.\n");
imesa->enable_fastpath = GL_FALSE;
}
imesa->enable_vdma = driQueryOptionb(&imesa->optionCache, "enable_vdma");
if (imesa->enable_vdma && savageScreen->chipset == S3_SUPERSAVAGE) {
fprintf (stderr,
"*** Disabling vertex DMA on SuperSavage. Someone has to "
"find out, how to make\n*** it work without locking up. "
"To disable this message set option enable_vdma\n"
"*** to \"false\" in DRIConf.\n");
if (!savageScreen->bufs || savageScreen->chipset == S3_SUPERSAVAGE)
imesa->enable_vdma = GL_FALSE;
}
else
imesa->enable_vdma = driQueryOptionb(&imesa->optionCache, "enable_vdma");
imesa->sync_frames = driQueryOptionb(&imesa->optionCache, "sync_frames");
/* Configure swrast to match hardware characteristics:
*/

View File

@@ -86,7 +86,6 @@ typedef struct savage_texture_object_t *savageTextureObjectPtr;
/* Don't make it too big. We don't want to buffer up a whole frame
* that would force the application to wait later. */
#define SAVAGE_CMDBUF_SIZE 1024
#define SAVAGE_MAX_VERTS_PENDING 1024
/* Use the templated vertex formats:
*/
@@ -226,7 +225,6 @@ struct savage_context_t {
GLfloat hw_viewport[16];
/* DRI stuff */
GLuint bufferSize;
GLuint vertsPending;
GLframebuffer *glBuffer;
@@ -303,6 +301,7 @@ struct savage_context_t {
GLboolean float_depth;
GLboolean enable_fastpath;
GLboolean enable_vdma;
GLboolean sync_frames;
};
#define SAVAGE_CONTEXT(ctx) ((savageContextPtr)(ctx->DriverCtx))

View File

@@ -41,7 +41,7 @@
#include "utils.h"
#define DRIVER_DATE "20050120"
#define DRIVER_DATE "20050305"
/***************************************
* Mesa's Driver Functions

View File

@@ -1,209 +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 <X11/Xlibint.h>
#include <stdio.h>
#include "savageioctl.h"
#include "savagedma.h"
#include "savage_bci.h"
#include <time.h>
#include <unistd.h>
#if 0
/* flag =
0 return -1 if no available page
1 wait until a page be available */
static GLuint getDMAPage (savageContextPtr imesa, int flag) {
DMABufferPtr dmaBuff = &imesa->DMABuf;
GLuint page;
GLuint eventTag1;
if (dmaBuff->kickFlag == GL_FALSE)
return dmaBuff->usingPage;
page = dmaBuff->usingPage + 1;
/* overflow */
if (page >= (dmaBuff->buf->size * dmaBuff->buf->type)/DMA_PAGE_SIZE)
page = 0;
eventTag1 = GET_EVENTTAG;
if ( eventTag1 == page) { /* is kicking off */
if (flag == 1)
while (GET_EVENTTAG == page); /* FIXME: add a max loop count? */
else
return -1;
}
/* ok, that's it */
dmaBuff->usingPage = page;
dmaBuff->start = dmaBuff->end = dmaBuff->allocEnd =
(dmaBuff->buf->linear + DMA_PAGE_SIZE * page);
dmaBuff->kickFlag = GL_FALSE;
return page;
}
/* Allocate space in a real DMA buffer */
void *savageDMAAlloc (savageContextPtr imesa, GLuint size) {
DMABufferPtr dmaBuff = &imesa->DMABuf;
/* make sure that everything has been filled in and committed */
assert (dmaBuff->end == dmaBuff->allocEnd);
size *= sizeof (u_int32_t); /* size in bytes */
if (dmaBuff->kickFlag == GL_TRUE) {
if (size > DMA_PAGE_SIZE)
return NULL;
getDMAPage (imesa, 1);
} else if (dmaBuff->end + size >=
dmaBuff->buf->linear + DMA_PAGE_SIZE*(dmaBuff->usingPage+1)) {
/* need kick off */
savageDMAFlush (imesa);
getDMAPage (imesa, 1);
}
dmaBuff->allocEnd = dmaBuff->end + size;
return (void *)dmaBuff->end;
}
/* Flush DMA buffer via DMA */
void savageDMAFlush (savageContextPtr imesa) {
volatile u_int32_t* BCIbase;
DMABufferPtr dmaBuff = &imesa->DMABuf;
u_int32_t phyAddress;
GLuint dmaCount, dmaCount1, remain;
int i;
/* make sure that everything has been filled in and committed */
assert (dmaBuff->allocEnd == dmaBuff->end);
if (dmaBuff->kickFlag == GL_TRUE) /* has been kicked off? */
return;
if (dmaBuff->start == dmaBuff->end) /* no command? */
return;
/* get bci base */
BCIbase = (volatile u_int32_t *)SAVAGE_GET_BCI_POINTER(imesa,4);
/* set the eventtag */
*BCIbase = (dmaBuff->usingPage & 0xffffL) | (CMD_UpdateShadowStat << 27)
| (1 << 22);
*BCIbase = 0x96010051; /* set register x51*/
/* set the DMA buffer address */
phyAddress = (dmaBuff->buf->phyaddress + dmaBuff->usingPage*DMA_PAGE_SIZE)
& MDT_SRCADD_ALIGMENT;
if (dmaBuff->buf->location == DRM_SAVAGE_MEM_LOCATION_AGP)
*BCIbase = (phyAddress) | MDT_SRC_AGP;
else
*BCIbase = (phyAddress) | MDT_SRC_PCI;
/* pad with noops to multiple of 32 bytes */
dmaCount = (GLuint)(dmaBuff->end - dmaBuff->start);
dmaCount1 = (dmaCount + 31UL) & ~31UL;
remain = (dmaCount1 - dmaCount) >> 2;
for (i = 0; i < remain; i++) {
*((u_int32_t *)dmaBuff->end) = 0x40000000L;
dmaBuff->end+=4;
}
dmaCount = (dmaCount1 >> 3) - 1;
dmaBuff->allocEnd = dmaBuff->end;
/* kick off */
*BCIbase = (0xA8000000L)|dmaCount;
dmaBuff->kickFlag = GL_TRUE;
}
/* Init real DMA */
int savageDMAInit (savageContextPtr imesa)
{
DMABufferPtr dmaBuff = &imesa->DMABuf;
drm_savage_alloc_cont_mem_t * req;
int i;
long ret;
req = (drm_savage_alloc_cont_mem_t *)
malloc (sizeof(drm_savage_alloc_cont_mem_t));
if (!req)
return GL_FALSE;
req->type = DRM_SAVAGE_MEM_PAGE;
req->linear = 0;
/* try agp first */
req->phyaddress = imesa->sarea->agp_offset;
if (req->phyaddress) {
if (drmMap (imesa->driFd,
req->phyaddress,
DRM_SAVAGE_DMA_AGP_SIZE,
(drmAddressPtr)&req->linear) < 0) {
fprintf (stderr, "AGP map error.\n");
goto dma;
}
if (0) fprintf (stderr,"Using AGP dma|\n");
req->location = DRM_SAVAGE_MEM_LOCATION_AGP;
req->size = DRM_SAVAGE_DMA_AGP_SIZE/DRM_SAVAGE_MEM_PAGE;
}
dma:
if (!req->linear) {
req->size = DMA_BUFFER_SIZE/DRM_SAVAGE_MEM_PAGE;
for (i = 0; i < DMA_TRY_COUNT; i++) {
if ((ret = savageAllocDMABuffer (imesa, req)) != 0)
break;
req->size = req->size/2;
}
if (ret <= 0) {
fprintf(stderr, "Can't alloc DMA memory(system and agp)\n");
return GL_FALSE;
}
req->location = DRM_SAVAGE_MEM_LOCATION_PCI;
}
dmaBuff->buf = req;
dmaBuff->start = dmaBuff->end = dmaBuff->allocEnd = req->linear;
dmaBuff->usingPage = 0;
dmaBuff->kickFlag = GL_FALSE;
return GL_TRUE;
}
/* Close real DMA */
int savageDMAClose (savageContextPtr imesa)
{
DMABufferPtr dmaBuff = &imesa->DMABuf;
drm_savage_alloc_cont_mem_t * req = dmaBuff->buf;
if(req->location == DRM_SAVAGE_MEM_LOCATION_PCI)
savageFreeDMABuffer (imesa, req);
else { /* AGP memory */
drmUnmap ((drmAddress)req->linear, req->size*req->type);
drmRmMap (imesa->driFd, req->phyaddress);
}
free (req);
return GL_TRUE;
}
#endif

View File

@@ -1,52 +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 SAVAGEDMA
#define SAVAGEDMA
/* Whether use DMA to transfer the 3d commands and data */
/* Need to fix the drm driver first though */
#define SAVAGE_CMD_DMA 0
#define DMA_BUFFER_SIZE (4*1024*1024) /*4M*/
#define MAX_DMA_BUFFER_SIZE (16*1024*1024)
#define DMA_PAGE_SIZE (4*1024) /* savage4 , twister, prosavage,...*/
#define DMA_TRY_COUNT 4
#define MAX_SHADOWCOUNTER (MAX_DMA_BUFFER_SIZE / DMA_PAGE_SIZE)
typedef struct DMABuffer{
drm_savage_alloc_cont_mem_t * buf;
GLuint start, end, allocEnd;
GLuint usingPage; /*current page */
unsigned int kickFlag; /* usingPage is kicked off ?*/
} DMABuffer_t, * DMABufferPtr;
void *savageDMAAlloc (savageContextPtr imesa, GLuint size);
void savageDMACommit (savageContextPtr imesa, void *end);
void savageDMAFlush (savageContextPtr imesa);
int savageDMAInit (savageContextPtr imesa);
int savageDMAClose (savageContextPtr);
#endif

View File

@@ -57,6 +57,8 @@ void savageGetDMABuffer( savageContextPtr imesa )
int retcode;
drmBufPtr buf;
assert (imesa->savageScreen->bufs);
if (SAVAGE_DEBUG & DEBUG_DMA)
fprintf(stderr, "Getting dma buffer\n");
@@ -421,13 +423,6 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
_swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
}
/* This is necessary as to prevent annyoing stuttering effects with
* some games, though it does reduce the frame rate (glxgears)
* slightly. I believe this is due to texture uploads which do not go
* through the Savage command pipeline yet. */
#define SYNC_FRAMES 1
/*
* Copy the back buffer to the front buffer.
*/
@@ -448,9 +443,9 @@ void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
FLUSH_BATCH(imesa);
#if SYNC_FRAMES
imesa->lastSwap = savageEmitEvent( imesa, 0 );
#endif
if (imesa->sync_frames)
imesa->lastSwap = savageEmitEvent( imesa, 0 );
if (imesa->lastSwap != 0)
savageWaitEvent( imesa, imesa->lastSwap );
@@ -462,9 +457,9 @@ void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
imesa->inSwap = GL_FALSE;
}
#if !SYNC_FRAMES
imesa->lastSwap = savageEmitEvent( imesa, 0 );
#endif
if (!imesa->sync_frames)
/* don't sync, but limit the lag to one frame. */
imesa->lastSwap = savageEmitEvent( imesa, 0 );
}
unsigned int savageEmitEventLocked( savageContextPtr imesa, unsigned int flags )
@@ -530,13 +525,6 @@ void savageFlushVertices( savageContextPtr imesa )
cmd->prim.start = buffer->flushed / imesa->HwVertexSize;
cmd->prim.count = buffer->used / imesa->HwVertexSize - cmd->prim.start;
buffer->flushed = buffer->used;
/* Make sure we don't buffer too many vertices without
* telling the hardware. */
imesa->vertsPending += cmd->prim.count;
if (imesa->vertsPending > SAVAGE_MAX_VERTS_PENDING) {
savageFlushCmdBuf(imesa, GL_FALSE);
imesa->vertsPending = 0;
}
}
}
@@ -617,18 +605,6 @@ void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard )
imesa->cmdBuf.write = imesa->cmdBuf.base;
savageEmitOldState(imesa);
imesa->cmdBuf.start = imesa->cmdBuf.write;
/* Timestamp current texture objects for texture heap aging.
* Only useful with long-lived 32-bit event tags available
* with Savage DRM 2.3.x or later. */
if ((imesa->CurrentTexObj[0] || imesa->CurrentTexObj[1]) &&
imesa->savageScreen->driScrnPriv->drmMinor >= 3) {
unsigned int e = savageEmitEventLocked(imesa, 0);
if (imesa->CurrentTexObj[0])
imesa->CurrentTexObj[0]->timestamp = e;
if (imesa->CurrentTexObj[1])
imesa->CurrentTexObj[1]->timestamp = e;
}
}
if (discard) {

View File

@@ -1445,8 +1445,16 @@ static void savageEmitChangedRegChunk (savageContextPtr imesa,
}
static void savageUpdateRegister_s4(savageContextPtr imesa)
{
/* the savage4 uses the contiguous range of BCI registers 0x1e-0x39
* 0x1e-0x27 are local, no need to check them for global changes */
/* In case the texture image was changed without changing the
* texture address as well, we need to force emitting the texture
* address in order to flush texture cashes. */
if ((imesa->dirty & SAVAGE_UPLOAD_TEX0) &&
imesa->oldRegs.s4.texAddr[0].ui == imesa->regs.s4.texAddr[0].ui)
imesa->oldRegs.s4.texAddr[0].ui = 0xffffffff;
if ((imesa->dirty & SAVAGE_UPLOAD_TEX1) &&
imesa->oldRegs.s4.texAddr[1].ui == imesa->regs.s4.texAddr[1].ui)
imesa->oldRegs.s4.texAddr[1].ui = 0xffffffff;
savageEmitChangedRegs (imesa, 0x1e, 0x39);
imesa->dirty=0;

View File

@@ -767,17 +767,19 @@ static void savageUploadTexImages( savageContextPtr imesa, savageTexObjPtr t )
if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX)
fprintf(stderr, "Texture upload: |");
savageFlushVertices (imesa);
LOCK_HARDWARE(imesa);
savageFlushCmdBufLocked (imesa, GL_FALSE);
/* Heap timestamps are only reliable with Savage DRM 2.3.x or
* later. Earlier versions had only 16 bit time stamps which
* would wrap too frequently. */
if (imesa->savageScreen->driScrnPriv->drmMinor >= 3) {
unsigned int heap = t->base.heap->heapId;
LOCK_HARDWARE(imesa);
savageWaitEvent (imesa, imesa->textureHeaps[heap]->timestamp);
} else
} else {
savageFlushVertices (imesa);
LOCK_HARDWARE(imesa);
savageFlushCmdBufLocked (imesa, GL_FALSE);
WAIT_IDLE_EMPTY_LOCKED(imesa);
}
for (i = 0 ; i < numLevels ; i++) {
const GLint j = t->base.firstLevel + i; /* the texObj's level */
@@ -1403,10 +1405,40 @@ static void savageUpdateTexState_s3d( GLcontext *ctx )
}
static void savageTimestampTextures( savageContextPtr imesa )
{
/* Timestamp current texture objects for texture heap aging.
* Only useful with long-lived 32-bit event tags available
* with Savage DRM 2.3.x or later. */
if ((imesa->CurrentTexObj[0] || imesa->CurrentTexObj[1]) &&
imesa->savageScreen->driScrnPriv->drmMinor >= 3) {
unsigned int e;
FLUSH_BATCH(imesa);
e = savageEmitEvent(imesa, SAVAGE_WAIT_3D);
if (imesa->CurrentTexObj[0])
imesa->CurrentTexObj[0]->timestamp = e;
if (imesa->CurrentTexObj[1])
imesa->CurrentTexObj[1]->timestamp = e;
}
}
static void savageUpdateTextureState_s4( GLcontext *ctx )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
/* When a texture is about to change or be disabled, timestamp the
* old texture(s). We'll have to wait for this time stamp before
* uploading anything to the same texture heap.
*/
if ((imesa->CurrentTexObj[0] && ctx->Texture.Unit[0]._ReallyEnabled &&
ctx->Texture.Unit[0]._Current->DriverData != imesa->CurrentTexObj[0]) ||
(imesa->CurrentTexObj[1] && ctx->Texture.Unit[1]._ReallyEnabled &&
ctx->Texture.Unit[1]._Current->DriverData != imesa->CurrentTexObj[1]) ||
(imesa->CurrentTexObj[0] && !ctx->Texture.Unit[0]._ReallyEnabled) ||
(imesa->CurrentTexObj[1] && !ctx->Texture.Unit[1]._ReallyEnabled))
savageTimestampTextures(imesa);
if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->bound &= ~2;
imesa->CurrentTexObj[0] = 0;
@@ -1419,6 +1451,16 @@ static void savageUpdateTextureState_s4( GLcontext *ctx )
static void savageUpdateTextureState_s3d( GLcontext *ctx )
{
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
/* When a texture is about to change or be disabled, timestamp the
* old texture(s). We'll have to wait for this time stamp before
* uploading anything to the same texture heap.
*/
if ((imesa->CurrentTexObj[0] && ctx->Texture.Unit[0]._ReallyEnabled &&
ctx->Texture.Unit[0]._Current->DriverData != imesa->CurrentTexObj[0]) ||
(imesa->CurrentTexObj[0] && !ctx->Texture.Unit[0]._ReallyEnabled))
savageTimestampTextures(imesa);
if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
imesa->CurrentTexObj[0] = 0;
savageUpdateTexState_s3d( ctx );
@@ -1470,15 +1512,18 @@ static void savageTexEnv( GLcontext *ctx, GLenum target,
}
}
/* Update a heap's timestamp when a texture image is modified, so the
* new image is not uploaded while the old one is still in use.
* FIXME: this should be moved to ../common/texmem.c
*/
/* Update the heap's time stamp, so the new image is not uploaded
* while the old one is still in use. If the texture that is going to
* be changed is currently bound, we need to timestamp the texture
* first. */
static void savageTexImageChanged (savageTexObjPtr t) {
/* Update the heap's time stamp, so the new image is not uploaded
* while the old one is still in use. */
if (t->base.heap && t->base.timestamp > t->base.heap->timestamp)
t->base.heap->timestamp = t->base.timestamp;
if (t->base.heap) {
if (t->base.bound)
savageTimestampTextures(
(savageContextPtr)t->base.heap->driverContext);
if (t->base.timestamp > t->base.heap->timestamp)
t->base.heap->timestamp = t->base.timestamp;
}
}
static void savageTexImage1D( GLcontext *ctx, GLenum target, GLint level,
@@ -1644,9 +1689,8 @@ static void savageDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
if (t) {
if (t->bound) {
FLUSH_BATCH(imesa);
}
if (t->bound)
savageTimestampTextures(imesa);
driDestroyTextureObject(t);
}

View File

@@ -1192,11 +1192,8 @@ static void savageRenderStart( GLcontext *ctx )
static void savageRenderFinish( GLcontext *ctx )
{
/* Flush the last primitive now, before any state is changed.
* Alternatively state could be emitted in all state-changing
* functions in savagestate.c and when changing the vertex format
* above. */
FLUSH_BATCH(SAVAGE_CONTEXT(ctx));
/* Flush the last primitive now, before any state is changed. */
savageFlushVertices(SAVAGE_CONTEXT(ctx));
if (SAVAGE_CONTEXT(ctx)->RenderIndex & SAVAGE_FALLBACK_BIT)
_swrast_flush( ctx );

View File

@@ -26,89 +26,8 @@
#ifndef __SAVAGE_DRI_H__
#define __SAVAGE_DRI_H__
#include "xf86drm.h"
#include "drm.h"
/* Totals 2 Mbytes which equals 2^16 32-byte vertices divided among up
* to 32 clients. */
#define SAVAGE_NUM_BUFFERS 32
#define SAVAGE_BUFFER_SIZE (1 << 16) /* 64k */
#define SAVAGE_DEFAULT_AGP_MODE 1
#define SAVAGE_MAX_AGP_MODE 4
/* Buffer are aligned on 4096 byte boundaries.
*/
/* this is used for backbuffer, depthbuffer, etc..*/
/* alignment */
#define SAVAGE_BUFFER_ALIGN 0x00000fff
typedef struct{
drm_context_t ctxOwner;
unsigned long agp_offset;
unsigned long agp_handle;
unsigned long map_handle;
int flags;
} savageAgpBuffer , *savageAgpBufferPtr;
typedef struct _server{
int reserved_map_agpstart;
int reserved_map_idx;
#if 0
int buffer_map_idx;
#endif
int sarea_priv_offset;
#if 0
int primary_size;
int warp_ucode_size;
#endif
int chipset;
int sgram; /* seems no use */
unsigned int frontOffset;
unsigned int frontPitch;
unsigned int frontbufferSize;
unsigned int frontBitmapDesc;
unsigned int backOffset;
unsigned int backPitch;
unsigned int backbufferSize;
unsigned int backBitmapDesc;
unsigned int depthOffset;
unsigned int depthPitch;
unsigned int depthbufferSize;
unsigned int depthBitmapDesc;
unsigned int textureOffset;
int textureSize;
int logTextureGranularity;
drmRegion agp;
/* PCI mappings */
drmRegion aperture;
drmRegion registers;
drmRegion status;
/* AGP mappings */
drmRegion buffers;
drmRegion agpTextures;
int logAgpTextureGranularity;
#if 0
drmBufMapPtr drmBuffers;
#endif
/*for agp*/
int numBuffer;
savageAgpBufferPtr agpBuffer;
} SAVAGEDRIServerPrivateRec, *SAVAGEDRIServerPrivatePtr;
typedef struct {
int chipset;
int width;

View File

@@ -20,16 +20,14 @@ COMMON_SOURCES = \
DRIVER_SOURCES = \
via_context.c \
via_fb.c \
via_tex.c \
via_ioctl.c \
via_render.c \
via_screen.c \
via_span.c \
via_state.c \
via_tex.c \
via_texmem.c \
via_texstate.c \
via_tris.c \
via_texcombine.c
via_texcombine.c \
via_tris.c
C_SOURCES = \
$(COMMON_SOURCES) \

View File

@@ -317,7 +317,7 @@ static int VIADRIScreenInit(DRIDriverContext * ctx)
#if 0
ctx->shared.SAREASize = ((sizeof(drm_sarea_t) + 0xfff) & 0x1000);
#else
if (sizeof(drm_sarea_t)+sizeof(VIASAREAPriv) > SAREA_MAX) {
if (sizeof(drm_sarea_t)+sizeof(drm_via_sarea_t) > SAREA_MAX) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Data does not fit in SAREA\n");
return GL_FALSE;
@@ -446,10 +446,6 @@ static int VIADRIScreenInit(DRIDriverContext * ctx)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] frame buffer initialized.\n" );
/*pVIADRI->drixinerama = pVia->drixinerama;*/
/*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/
pVIADRI->VQEnable = pVia->VQEnable;
return VIADRIFinishScreenInit(ctx);
}
@@ -503,13 +499,13 @@ VIADRIFinishScreenInit(DRIDriverContext * ctx)
/* set SAREA value */
{
VIASAREAPriv *saPriv;
drm_via_sarea_t *saPriv;
saPriv=(VIASAREAPriv*)(((char*)ctx->pSAREA) +
saPriv=(drm_via_sarea_t*)(((char*)ctx->pSAREA) +
sizeof(drm_sarea_t));
assert(saPriv);
memset(saPriv, 0, sizeof(*saPriv));
saPriv->CtxOwner = -1;
saPriv->ctxOwner = -1;
}
pVIADRI=(VIADRIPtr)pVia->devPrivate;
pVIADRI->deviceID=pVia->Chipset;
@@ -1218,7 +1214,7 @@ static int viaInitFBDev(DRIDriverContext *ctx)
pVia->FBFreeStart = ctx->shared.virtualWidth * ctx->cpp *
ctx->shared.virtualHeight;
#if 0
#if 1
/* Alloc a second framebuffer for the second head */
pVia->FBFreeStart += ctx->shared.virtualWidth * ctx->cpp *
ctx->shared.virtualHeight;

View File

@@ -99,8 +99,13 @@
#define VIA_BACK 0x2
#define VIA_DEPTH 0x4
#define VIA_STENCIL 0x8
#define VIDEO 0
#define AGP 1
#define VIA_MEM_VIDEO 0 /* matches drm constant */
#define VIA_MEM_AGP 1 /* matches drm constant */
#define VIA_MEM_SYSTEM 2
#define VIA_MEM_MIXED 3
#define VIA_MEM_UNKNOWN 4
typedef struct {
u_int32_t offset;
u_int32_t size;
@@ -172,7 +177,6 @@ typedef struct _drm_via_sarea {
unsigned int nbox;
drm_clip_rect_t boxes[VIA_NR_SAREA_CLIPRECTS];
drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
int texAge; /* last time texture was uploaded */
int ctxOwner; /* last context to upload state */
int vertexPrim;
@@ -188,6 +192,10 @@ typedef struct _drm_via_sarea {
unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */
/* Used by the 3d driver only at this point, for pageflipping:
*/
unsigned int pfCurrentOffset;
} drm_via_sarea_t;
typedef struct _drm_via_cmdbuf_size {

View File

@@ -64,10 +64,7 @@
#include "vblank.h"
#include "utils.h"
#ifdef DEBUG
GLuint VIA_DEBUG = 0;
#endif
/**
* Return various strings for \c glGetString.
@@ -92,8 +89,8 @@ static const GLubyte *viaGetString(GLcontext *ctx, GLenum name)
"UniChrome (K8M800)",
"UniChrome (PM8x0/CN400)",
};
const viaContext * const via = VIA_CONTEXT(ctx);
const unsigned id = via->viaScreen->deviceID;
struct via_context *vmesa = VIA_CONTEXT(ctx);
unsigned id = vmesa->viaScreen->deviceID;
offset = driGetRendererString( buffer,
chipset_names[(id > VIA_PM800) ? 0 : id],
@@ -134,7 +131,7 @@ buffer_align( unsigned width )
* \sa AllocateBuffer
*/
static GLboolean
calculate_buffer_parameters( viaContextPtr vmesa )
calculate_buffer_parameters( struct via_context *vmesa )
{
const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16;
const unsigned extra = 32;
@@ -155,15 +152,17 @@ calculate_buffer_parameters( viaContextPtr vmesa )
if (!via_alloc_draw_buffer(vmesa, &vmesa->front))
return GL_FALSE;
}
else {
} else {
w = vmesa->viaScreen->width;
h = vmesa->viaScreen->height;
vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel;
vmesa->front.pitch = buffer_align( w ) << shift;
vmesa->front.size = vmesa->front.pitch * h;
vmesa->front.offset = 0;
if (getenv("ALTERNATE_SCREEN"))
vmesa->front.offset = vmesa->front.size;
else
vmesa->front.offset = 0;
vmesa->front.map = (char *) vmesa->driScreen->pFB;
}
@@ -171,7 +170,9 @@ calculate_buffer_parameters( viaContextPtr vmesa )
/* Allocate back-buffer */
if (vmesa->hasBack) {
vmesa->back.bpp = vmesa->viaScreen->bitsPerPixel;
vmesa->back.pitch = (buffer_align( vmesa->driDrawable->w ) << shift) + extra;
vmesa->back.pitch = (buffer_align( vmesa->driDrawable->w ) << shift);
vmesa->back.pitch += extra;
vmesa->back.pitch = MIN2(vmesa->back.pitch, vmesa->front.pitch);
vmesa->back.size = vmesa->back.pitch * vmesa->driDrawable->h;
if (vmesa->back.map)
via_free_draw_buffer(vmesa, &vmesa->back);
@@ -191,7 +192,8 @@ calculate_buffer_parameters( viaContextPtr vmesa )
if (vmesa->depth.bpp == 24)
vmesa->depth.bpp = 32;
vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) * (vmesa->depth.bpp/8)) + extra;
vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) *
(vmesa->depth.bpp/8)) + extra;
vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h;
if (vmesa->depth.map)
@@ -206,17 +208,10 @@ calculate_buffer_parameters( viaContextPtr vmesa )
(void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) );
}
/*=* John Sheng [2003.5.31] flip *=*/
if( vmesa->viaScreen->width == vmesa->driDrawable->w &&
vmesa->viaScreen->height == vmesa->driDrawable->h ) {
#define ALLOW_EXPERIMENTAL_PAGEFLIP 0
#if ALLOW_EXPERIMENTAL_PAGEFLIP
vmesa->doPageFlip = GL_TRUE;
/* vmesa->currentPage = 0; */
vmesa->doPageFlip = vmesa->allowPageFlip;
assert(vmesa->back.pitch == vmesa->front.pitch);
#else
vmesa->doPageFlip = GL_FALSE;
#endif
}
else
vmesa->doPageFlip = GL_FALSE;
@@ -228,7 +223,7 @@ calculate_buffer_parameters( viaContextPtr vmesa )
void viaReAllocateBuffers(GLframebuffer *drawbuffer)
{
GET_CURRENT_CONTEXT(ctx);
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
_swrast_alloc_buffers( drawbuffer );
calculate_buffer_parameters( vmesa );
@@ -237,7 +232,7 @@ void viaReAllocateBuffers(GLframebuffer *drawbuffer)
static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
{
GET_CURRENT_CONTEXT(ctx);
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
*width = vmesa->driDrawable->w;
*height = vmesa->driDrawable->h;
}
@@ -281,8 +276,28 @@ static const struct tnl_pipeline_stage *via_pipeline[] = {
};
static const struct dri_debug_control debug_control[] =
{
{ "fall", DEBUG_FALLBACKS },
{ "tex", DEBUG_TEXTURE },
{ "ioctl", DEBUG_IOCTL },
{ "prim", DEBUG_PRIMS },
{ "vert", DEBUG_VERTS },
{ "state", DEBUG_STATE },
{ "verb", DEBUG_VERBOSE },
{ "dri", DEBUG_DRI },
{ "dma", DEBUG_DMA },
{ "san", DEBUG_SANITY },
{ "sync", DEBUG_SYNC },
{ "sleep", DEBUG_SLEEP },
{ "pix", DEBUG_PIXEL },
{ "2d", DEBUG_2D },
{ NULL, 0 }
};
static GLboolean
AllocateDmaBuffer(const GLvisual *visual, viaContextPtr vmesa)
AllocateDmaBuffer(struct via_context *vmesa)
{
if (vmesa->dma)
via_free_dma_buffer(vmesa);
@@ -296,7 +311,7 @@ AllocateDmaBuffer(const GLvisual *visual, viaContextPtr vmesa)
}
static void
FreeBuffer(viaContextPtr vmesa)
FreeBuffer(struct via_context *vmesa)
{
if (vmesa->front.map && vmesa->drawType == GLX_PBUFFER_BIT)
via_free_draw_buffer(vmesa, &vmesa->front);
@@ -307,6 +322,9 @@ FreeBuffer(viaContextPtr vmesa)
if (vmesa->depth.map)
via_free_draw_buffer(vmesa, &vmesa->depth);
if (vmesa->breadcrumb.map)
via_free_draw_buffer(vmesa, &vmesa->breadcrumb);
if (vmesa->dma)
via_free_dma_buffer(vmesa);
}
@@ -319,12 +337,12 @@ get_ust_nop( int64_t * ust )
}
GLboolean
viaCreateContext(const __GLcontextModes *mesaVis,
viaCreateContext(const __GLcontextModes *visual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
{
GLcontext *ctx, *shareCtx;
viaContextPtr vmesa;
struct via_context *vmesa;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private;
drm_via_sarea_t *saPriv = (drm_via_sarea_t *)
@@ -332,11 +350,10 @@ viaCreateContext(const __GLcontextModes *mesaVis,
struct dd_function_table functions;
/* Allocate via context */
vmesa = (viaContextPtr) CALLOC_STRUCT(via_context_t);
vmesa = (struct via_context *) CALLOC_STRUCT(via_context);
if (!vmesa) {
return GL_FALSE;
}
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
/* Parse configuration files.
*/
@@ -344,9 +361,9 @@ viaCreateContext(const __GLcontextModes *mesaVis,
sPriv->myNum, "via");
/* pick back buffer */
vmesa->hasBack = mesaVis->doubleBufferMode;
vmesa->hasBack = visual->doubleBufferMode;
switch(mesaVis->depthBits) {
switch(visual->depthBits) {
case 0:
vmesa->hasDepth = GL_FALSE;
vmesa->depthBits = 0;
@@ -354,7 +371,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
break;
case 16:
vmesa->hasDepth = GL_TRUE;
vmesa->depthBits = mesaVis->depthBits;
vmesa->depthBits = visual->depthBits;
vmesa->have_hw_stencil = GL_FALSE;
vmesa->depth_max = (GLfloat)0xffff;
vmesa->depth_clear_mask = 0xf << 28;
@@ -363,23 +380,23 @@ viaCreateContext(const __GLcontextModes *mesaVis,
break;
case 24:
vmesa->hasDepth = GL_TRUE;
vmesa->depthBits = mesaVis->depthBits;
vmesa->depthBits = visual->depthBits;
vmesa->depth_max = (GLfloat) 0xffffff;
vmesa->depth_clear_mask = 0xe << 28;
vmesa->ClearDepth = 0xffffff00;
assert(mesaVis->haveStencilBuffer);
assert(mesaVis->stencilBits == 8);
assert(visual->haveStencilBuffer);
assert(visual->stencilBits == 8);
vmesa->have_hw_stencil = GL_TRUE;
vmesa->stencilBits = mesaVis->stencilBits;
vmesa->stencilBits = visual->stencilBits;
vmesa->stencil_clear_mask = 0x1 << 28;
vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max;
break;
case 32:
vmesa->hasDepth = GL_TRUE;
vmesa->depthBits = mesaVis->depthBits;
assert(!mesaVis->haveStencilBuffer);
vmesa->depthBits = visual->depthBits;
assert(!visual->haveStencilBuffer);
vmesa->have_hw_stencil = GL_FALSE;
vmesa->depth_max = (GLfloat)0xffffffff;
vmesa->depth_clear_mask = 0xf << 28;
@@ -391,17 +408,22 @@ viaCreateContext(const __GLcontextModes *mesaVis,
break;
}
make_empty_list(&vmesa->freed_tex_buffers);
make_empty_list(&vmesa->tex_image_list[VIA_MEM_VIDEO]);
make_empty_list(&vmesa->tex_image_list[VIA_MEM_AGP]);
make_empty_list(&vmesa->tex_image_list[VIA_MEM_SYSTEM]);
_mesa_init_driver_functions(&functions);
viaInitTextureFuncs(&functions);
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((viaContextPtr) sharedContextPrivate)->glCtx;
shareCtx = ((struct via_context *) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
vmesa->glCtx = _mesa_create_context(mesaVis, shareCtx, &functions, (void*) vmesa);
vmesa->glCtx = _mesa_create_context(visual, shareCtx, &functions,
(void*) vmesa);
vmesa->shareCtx = shareCtx;
@@ -466,9 +488,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->viaScreen = viaScreen;
vmesa->driScreen = sPriv;
vmesa->sarea = saPriv;
vmesa->glBuffer = NULL;
vmesa->texHeap = mmInit(0, viaScreen->textureSize);
vmesa->renderIndex = ~0;
vmesa->setupIndex = ~0;
vmesa->hwPrimitive = GL_POLYGON+1;
@@ -479,44 +499,44 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->drawType = GLX_WINDOW_BIT;
make_empty_list(&vmesa->TexObjList);
make_empty_list(&vmesa->SwappedOut);
vmesa->CurrentTexObj[0] = 0;
vmesa->CurrentTexObj[1] = 0;
_math_matrix_ctr(&vmesa->ViewportMatrix);
/* Do this early, before VIA_FLUSH_DMA can be called:
*/
if (!AllocateDmaBuffer(mesaVis, vmesa)) {
if (!AllocateDmaBuffer(vmesa)) {
fprintf(stderr ,"AllocateDmaBuffer fail\n");
FreeBuffer(vmesa);
FREE(vmesa);
return GL_FALSE;
}
/* Allocate a small piece of fb memory for synchronization:
*/
vmesa->breadcrumb.bpp = 32;
vmesa->breadcrumb.pitch = buffer_align( 64 ) << 2;
vmesa->breadcrumb.size = vmesa->breadcrumb.pitch;
if (!via_alloc_draw_buffer(vmesa, &vmesa->breadcrumb)) {
fprintf(stderr ,"AllocateDmaBuffer fail\n");
FreeBuffer(vmesa);
FREE(vmesa);
return GL_FALSE;
}
driInitExtensions( ctx, card_extensions, GL_TRUE );
viaInitStateFuncs(ctx);
viaInitTextures(ctx);
viaInitTriFuncs(ctx);
viaInitSpanFuncs(ctx);
viaInitIoctlFuncs(ctx);
viaInitState(ctx);
#ifdef DEBUG
if (getenv("VIA_DEBUG"))
VIA_DEBUG = 1;
else
VIA_DEBUG = 0;
#endif
VIA_DEBUG = driParseDebugString( getenv( "VIA_DEBUG" ),
debug_control );
if (getenv("VIA_NO_RAST"))
FALLBACK(vmesa, VIA_FALLBACK_USER_DISABLE, 1);
if (getenv("VIA_CONFORM"))
vmesa->strictConformance = 1;
/* I don't understand why this isn't working:
*/
vmesa->vblank_flags =
@@ -525,10 +545,14 @@ viaCreateContext(const __GLcontextModes *mesaVis,
/* Hack this up in its place:
*/
vmesa->vblank_flags = getenv("VIA_VSYNC") ? VBLANK_FLAG_SYNC : VBLANK_FLAG_NO_IRQ;
vmesa->vblank_flags = (getenv("VIA_VSYNC") ?
VBLANK_FLAG_SYNC : VBLANK_FLAG_NO_IRQ);
vmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( (const GLubyte *) "__glXGetUST" );
if (getenv("VIA_PAGEFLIP"))
vmesa->allowPageFlip = 1;
vmesa->get_ust =
(PFNGLXGETUSTPROC) glXGetProcAddress( (const GLubyte *) "__glXGetUST" );
if ( vmesa->get_ust == NULL ) {
vmesa->get_ust = get_ust_nop;
}
@@ -541,11 +565,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->regTranSet = (GLuint *)((GLuint)viaScreen->reg + 0x43C);
vmesa->regTranSpace = (GLuint *)((GLuint)viaScreen->reg + 0x440);
vmesa->agpBase = viaScreen->agpBase;
if (VIA_DEBUG) {
fprintf(stderr, "regEngineStatus = %x\n", *vmesa->regEngineStatus);
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return GL_TRUE;
}
@@ -553,9 +573,9 @@ void
viaDestroyContext(__DRIcontextPrivate *driContextPriv)
{
GET_CURRENT_CONTEXT(ctx);
viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate;
viaContextPtr current = ctx ? VIA_CONTEXT(ctx) : NULL;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
struct via_context *vmesa =
(struct via_context *)driContextPriv->driverPrivate;
struct via_context *current = ctx ? VIA_CONTEXT(ctx) : NULL;
assert(vmesa); /* should never be null */
/* check if we're deleting the currently bound context */
@@ -565,25 +585,36 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv)
}
if (vmesa) {
/*=* John Sheng [2003.5.31] agp tex *=*/
WAIT_IDLE(vmesa);
if(VIA_DEBUG) fprintf(stderr, "agpFullCount = %d\n", vmesa->agpFullCount);
viaWaitIdle(vmesa);
if (vmesa->doPageFlip) {
LOCK_HARDWARE(vmesa);
if (vmesa->pfCurrentOffset != 0) {
fprintf(stderr, "%s - reset pf\n", __FUNCTION__);
viaResetPageFlippingLocked(vmesa);
}
UNLOCK_HARDWARE(vmesa);
}
_swsetup_DestroyContext(vmesa->glCtx);
_tnl_DestroyContext(vmesa->glCtx);
_ac_DestroyContext(vmesa->glCtx);
_swrast_DestroyContext(vmesa->glCtx);
FreeBuffer(vmesa);
/* free the Mesa context */
_mesa_destroy_context(vmesa->glCtx);
/* release our data */
FreeBuffer(vmesa);
assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_AGP]));
assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_VIDEO]));
assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_SYSTEM]));
assert (is_empty_list(&vmesa->freed_tex_buffers));
FREE(vmesa);
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
void viaXMesaWindowMoved(viaContextPtr vmesa)
void viaXMesaWindowMoved(struct via_context *vmesa)
{
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
@@ -615,7 +646,8 @@ void viaXMesaWindowMoved(viaContextPtr vmesa)
vmesa->drawH != dPriv->h)
calculate_buffer_parameters( vmesa );
vmesa->drawXoff = (GLuint)(((dPriv->x * bytePerPixel) & 0x1f) / bytePerPixel);
vmesa->drawXoff = (GLuint)(((dPriv->x * bytePerPixel) & 0x1f) /
bytePerPixel);
vmesa->drawX = dPriv->x - vmesa->drawXoff;
vmesa->drawY = dPriv->y;
vmesa->drawW = dPriv->w;
@@ -640,8 +672,6 @@ void viaXMesaWindowMoved(viaContextPtr vmesa)
GLboolean
viaUnbindContext(__DRIcontextPrivate *driContextPriv)
{
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return GL_TRUE;
}
@@ -650,16 +680,15 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv)
{
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (VIA_DEBUG) {
if (VIA_DEBUG & DEBUG_DRI) {
fprintf(stderr, "driContextPriv = %08x\n", (GLuint)driContextPriv);
fprintf(stderr, "driDrawPriv = %08x\n", (GLuint)driDrawPriv);
fprintf(stderr, "driReadPriv = %08x\n", (GLuint)driReadPriv);
}
if (driContextPriv) {
viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate;
struct via_context *vmesa =
(struct via_context *)driContextPriv->driverPrivate;
GLcontext *ctx = vmesa->glCtx;
if ( vmesa->driDrawable != driDrawPriv ) {
@@ -670,12 +699,10 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
}
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
}
if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent: w = %d\n", vmesa->driDrawable->w);
_mesa_make_current2(vmesa->glCtx,
(GLframebuffer *)driDrawPriv->driverPrivate,
(GLframebuffer *)driReadPriv->driverPrivate);
if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext);
viaXMesaWindowMoved(vmesa);
ctx->Driver.Scissor(vmesa->glCtx,
@@ -688,11 +715,10 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current(0,0);
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return GL_TRUE;
}
void viaGetLock(viaContextPtr vmesa, GLuint flags)
void viaGetLock(struct via_context *vmesa, GLuint flags)
{
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
__DRIscreenPrivate *sPriv = vmesa->driScreen;
@@ -710,6 +736,12 @@ void viaGetLock(viaContextPtr vmesa, GLuint flags)
viaXMesaWindowMoved(vmesa);
vmesa->lastStamp = dPriv->lastStamp;
}
if (vmesa->doPageFlip &&
vmesa->pfCurrentOffset != vmesa->sarea->pfCurrentOffset) {
fprintf(stderr, "%s - reset pf\n", __FUNCTION__);
viaResetPageFlippingLocked(vmesa);
}
}
@@ -717,13 +749,14 @@ void
viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
{
__DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *)drawablePrivate;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (dPriv && dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
viaContextPtr vmesa;
GLcontext *ctx;
vmesa = (viaContextPtr)dPriv->driContextPriv->driverPrivate;
ctx = vmesa->glCtx;
if (dPriv &&
dPriv->driContextPriv &&
dPriv->driContextPriv->driverPrivate) {
struct via_context *vmesa =
(struct via_context *)dPriv->driContextPriv->driverPrivate;
GLcontext *ctx = vmesa->glCtx;
if (ctx->Visual.doubleBufferMode) {
_mesa_notifySwapBuffers(ctx);
if (vmesa->doPageFlip) {
@@ -739,5 +772,4 @@ viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
else {
_mesa_problem(NULL, "viaSwapBuffers: drawable has no context!\n");
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}

View File

@@ -26,10 +26,6 @@
#ifndef _VIACONTEXT_H
#define _VIACONTEXT_H
typedef struct via_context_t viaContext;
typedef struct via_context_t *viaContextPtr;
typedef struct via_texture_object_t *viaTextureObjectPtr;
#include "dri_util.h"
#include "mtypes.h"
@@ -41,6 +37,8 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
#include "via_tex.h"
#include "via_common.h"
struct via_context;
/* Chip tags. These are used to group the adapters into
* related families.
*/
@@ -79,39 +77,84 @@ enum VIACHIPTAGS {
#include "tnl_dd/t_dd_vertex.h"
#undef TAG
typedef void (*via_tri_func)(viaContextPtr, viaVertex *, viaVertex *,
typedef void (*via_tri_func)(struct via_context *, viaVertex *, viaVertex *,
viaVertex *);
typedef void (*via_line_func)(viaContextPtr, viaVertex *, viaVertex *);
typedef void (*via_point_func)(viaContextPtr, viaVertex *);
typedef void (*via_line_func)(struct via_context *, viaVertex *, viaVertex *);
typedef void (*via_point_func)(struct via_context *, viaVertex *);
typedef struct {
drm_handle_t handle;
drmSize size;
GLuint offset;
GLuint index;
GLuint pitch;
GLuint bpp;
char *map;
GLuint orig; /* The drawing origin,
* at (drawX,drawY) in screen space.
*/
char *origMap;
} viaBuffer, *viaBufferPtr;
struct via_buffer {
drm_handle_t handle;
drmSize size;
GLuint offset;
GLuint index;
GLuint pitch;
GLuint bpp;
char *map;
GLuint orig; /* The drawing origin,
* at (drawX,drawY) in screen space.
*/
char *origMap;
};
struct via_context_t {
GLint refcount;
GLcontext *glCtx;
GLcontext *shareCtx;
viaBuffer front;
viaBuffer back;
viaBuffer depth;
GLboolean hasBack;
GLboolean hasDepth;
GLboolean hasStencil;
GLboolean hasAccum;
GLuint depthBits;
GLuint stencilBits;
#define VIA_MAX_TEXLEVELS 10
struct via_tex_buffer {
struct via_tex_buffer *next, *prev;
struct via_texture_image *image;
GLuint index;
GLuint offset;
GLuint size;
GLuint memType;
unsigned char *bufAddr;
GLuint texBase;
GLuint lastUsed;
};
struct via_texture_image {
struct gl_texture_image image;
struct via_tex_buffer *texMem;
GLint pitchLog2;
};
struct via_texture_object {
struct gl_texture_object obj; /* The "parent" object */
GLuint texelBytes;
GLuint memType;
GLuint regTexFM;
GLuint regTexWidthLog2[2];
GLuint regTexHeightLog2[2];
GLuint regTexBaseH[4];
struct {
GLuint baseL;
GLuint pitchLog2;
} regTexBaseAndPitch[12];
GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */
};
struct via_context {
GLint refcount;
GLcontext *glCtx;
GLcontext *shareCtx;
struct via_buffer front;
struct via_buffer back;
struct via_buffer depth;
struct via_buffer breadcrumb;
GLboolean hasBack;
GLboolean hasDepth;
GLboolean hasStencil;
GLboolean hasAccum;
GLuint depthBits;
GLuint stencilBits;
GLboolean have_hw_stencil;
GLuint ClearDepth;
@@ -120,174 +163,148 @@ struct via_context_t {
GLfloat depth_max;
GLfloat polygon_offset_scale;
GLubyte *dma;
viaRegion tex;
GLubyte *dma;
viaRegion tex;
GLuint isAGP;
/* Textures
/* Bit flag to keep 0track of fallbacks.
*/
viaTextureObjectPtr CurrentTexObj[2];
struct via_texture_object_t TexObjList;
struct via_texture_object_t SwappedOut;
memHeap_t *texHeap;
GLuint Fallback;
/* Bit flag to keep 0track of fallbacks.
*/
GLuint Fallback;
/* State for via_tris.c.
*/
GLuint newState; /* _NEW_* flags */
GLuint newEmitState; /* _NEW_* flags */
GLuint newRenderState; /* _NEW_* flags */
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
GLuint vertex_attr_count;
GLuint setupIndex;
GLuint renderIndex;
GLmatrix ViewportMatrix;
GLenum renderPrimitive;
GLenum hwPrimitive;
unsigned char *verts;
/* drmBufPtr dma_buffer;
/* State for via_tris.c.
*/
GLuint dmaLow;
GLuint dmaCliprectAddr;
GLuint dmaLastPrim;
GLboolean useAgp;
GLuint newState; /* _NEW_* flags */
GLuint newEmitState; /* _NEW_* flags */
GLuint newRenderState; /* _NEW_* flags */
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
GLuint vertex_attr_count;
GLuint setupIndex;
GLuint renderIndex;
GLmatrix ViewportMatrix;
GLenum renderPrimitive;
GLenum hwPrimitive;
unsigned char *verts;
/* drmBufPtr dma_buffer;
*/
GLuint dmaLow;
GLuint dmaCliprectAddr;
GLuint dmaLastPrim;
GLboolean useAgp;
/* Fallback rasterization functions
*/
via_point_func drawPoint;
via_line_func drawLine;
via_tri_func drawTri;
/* Fallback rasterization functions
*/
via_point_func drawPoint;
via_line_func drawLine;
via_tri_func drawTri;
/* Hardware register
*/
GLuint regCmdA_End;
GLuint regCmdB;
/* Hardware register
*/
GLuint regCmdA_End;
GLuint regCmdB;
GLuint regEnable;
GLuint regHFBBMSKL;
GLuint regHROP;
GLuint regEnable;
GLuint regHFBBMSKL;
GLuint regHROP;
GLuint regHZWTMD;
GLuint regHSTREF;
GLuint regHSTMD;
GLuint regHZWTMD;
GLuint regHSTREF;
GLuint regHSTMD;
GLuint regHATMD;
GLuint regHABLCsat;
GLuint regHABLCop;
GLuint regHABLAsat;
GLuint regHABLAop;
GLuint regHABLRCa;
GLuint regHABLRFCa;
GLuint regHABLRCbias;
GLuint regHABLRCb;
GLuint regHABLRFCb;
GLuint regHABLRAa;
GLuint regHABLRAb;
GLuint regHFogLF;
GLuint regHFogCL;
GLuint regHFogCH;
GLuint regHATMD;
GLuint regHABLCsat;
GLuint regHABLCop;
GLuint regHABLAsat;
GLuint regHABLAop;
GLuint regHABLRCa;
GLuint regHABLRFCa;
GLuint regHABLRCbias;
GLuint regHABLRCb;
GLuint regHABLRFCb;
GLuint regHABLRAa;
GLuint regHABLRAb;
GLuint regHFogLF;
GLuint regHFogCL;
GLuint regHFogCH;
GLuint regHLP;
GLuint regHLPRF;
GLuint regHLP;
GLuint regHLPRF;
GLuint regHTXnCLOD[2];
GLuint regHTXnTB[2];
GLuint regHTXnMPMD[2];
GLuint regHTXnTBLCsat[2];
GLuint regHTXnTBLCop[2];
GLuint regHTXnTBLMPfog[2];
GLuint regHTXnTBLAsat[2];
GLuint regHTXnTBLRCb[2];
GLuint regHTXnTBLRAa[2];
GLuint regHTXnTBLRFog[2];
GLuint regHTXnTBLRCa[2];
GLuint regHTXnTBLRCc[2];
GLuint regHTXnTBLRCbias[2];
GLuint regHTXnTBC[2];
GLuint regHTXnTRAH[2];
GLuint regHTXnTB_0;
GLuint regHTXnMPMD_0;
GLuint regHTXnTBLCsat_0;
GLuint regHTXnTBLCop_0;
GLuint regHTXnTBLMPfog_0;
GLuint regHTXnTBLAsat_0;
GLuint regHTXnTBLRCb_0;
GLuint regHTXnTBLRAa_0;
GLuint regHTXnTBLRFog_0;
/*=* John Sheng [2003.7.18] texture combine *=*/
GLuint regHTXnTBLRCa_0;
GLuint regHTXnTBLRCc_0;
GLuint regHTXnTBLRCbias_0;
int vertexSize;
int hwVertexSize;
GLboolean ptexHack;
int coloroffset;
int specoffset;
GLuint regHTXnTB_1;
GLuint regHTXnMPMD_1;
GLuint regHTXnTBLCsat_1;
GLuint regHTXnTBLCop_1;
GLuint regHTXnTBLMPfog_1;
GLuint regHTXnTBLAsat_1;
GLuint regHTXnTBLRCb_1;
GLuint regHTXnTBLRAa_1;
GLuint regHTXnTBLRFog_1;
GLuint regHTXnTBLRCa_1;
GLuint regHTXnTBLRCc_1;
GLuint regHTXnTBLRCbias_1;
GLint lastStamp;
int vertexSize;
int hwVertexSize;
GLboolean ptexHack;
int coloroffset;
int specoffset;
GLuint ClearColor;
GLuint ClearMask;
GLint lastStamp;
/* DRI stuff
*/
GLboolean doPageFlip;
GLenum TexEnvImageFmt[2];
GLuint ClearColor;
GLuint ClearMask;
struct via_buffer *drawBuffer;
struct via_buffer *readBuffer;
/* DRI stuff
*/
GLuint needClip;
GLframebuffer *glBuffer;
GLboolean doPageFlip;
/*=* John Sheng [2003.5.31] flip *=*/
GLuint currentPage;
int drawX; /* origin of drawable in draw buffer */
int drawY;
int drawW;
int drawH;
viaBuffer *drawBuffer;
viaBuffer *readBuffer;
int drawX; /* origin of drawable in draw buffer */
int drawY;
int drawW;
int drawH;
int drawXoff;
GLuint numClipRects; /* cliprects for that buffer */
drm_clip_rect_t *pClipRects;
int drawXoff; /* drawX is 32byte aligned - this is
* the delta to the real origin, in
* pixel units.
*/
int lastSwap;
int texAge;
int ctxAge;
int dirtyAge;
GLuint numClipRects; /* cliprects for that buffer */
drm_clip_rect_t *pClipRects;
GLboolean scissor;
drm_clip_rect_t drawRect;
drm_clip_rect_t scissorRect;
GLboolean scissor;
drm_clip_rect_t drawRect;
drm_clip_rect_t scissorRect;
drm_context_t hHWContext;
drm_hw_lock_t *driHwLock;
int driFd;
__DRInativeDisplay *display;
drm_context_t hHWContext;
drm_hw_lock_t *driHwLock;
int driFd;
__DRInativeDisplay *display;
__DRIdrawablePrivate *driDrawable;
__DRIscreenPrivate *driScreen;
viaScreenPrivate *viaScreen;
drm_via_sarea_t *sarea;
volatile GLuint* regMMIOBase;
volatile GLuint* pnGEMode;
volatile GLuint* regEngineStatus;
volatile GLuint* regTranSet;
volatile GLuint* regTranSpace;
GLuint* agpBase;
GLuint drawType;
__DRIdrawablePrivate *driDrawable;
__DRIscreenPrivate *driScreen;
viaScreenPrivate *viaScreen;
drm_via_sarea_t *sarea;
volatile GLuint* regMMIOBase;
volatile GLuint* pnGEMode;
volatile GLuint* regEngineStatus;
volatile GLuint* regTranSet;
volatile GLuint* regTranSpace;
GLuint* agpBase;
GLuint drawType;
GLuint nDoneFirstFlip;
GLuint agpFullCount;
GLboolean strictConformance;
GLboolean clearTexCache;
GLboolean thrashing;
/* Configuration cache
*/
@@ -304,14 +321,25 @@ struct via_context_t {
PFNGLXGETUSTPROC get_ust;
GLuint pfCurrentOffset;
GLboolean allowPageFlip;
GLuint lastBreadcrumbRead;
GLuint lastBreadcrumbWrite;
GLuint lastSwap[2];
GLuint lastDma;
GLuint total_alloc[VIA_MEM_SYSTEM+1];
struct via_tex_buffer tex_image_list[VIA_MEM_SYSTEM+1];
struct via_tex_buffer freed_tex_buffers;
};
#define VIA_CONTEXT(ctx) ((viaContextPtr)(ctx->DriverCtx))
#define VIA_CONTEXT(ctx) ((struct via_context *)(ctx->DriverCtx))
#define GET_DISPATCH_AGE(vmesa) vmesa->sarea->lastDispatch
#define GET_ENQUEUE_AGE(vmesa) vmesa->sarea->lastEnqueue
/* Lock the hardware and validate our state.
@@ -331,31 +359,37 @@ struct via_context_t {
#define UNLOCK_HARDWARE(vmesa) \
DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext);
#define WAIT_IDLE(vmesa) \
do { \
if ((((GLuint)*vmesa->regEngineStatus) & 0xFFFEFFFF) == 0x00020000) \
break; \
} while (1)
#ifdef DEBUG
extern GLuint VIA_DEBUG;
#else
#define VIA_DEBUG 0
#endif
#define DEBUG_TEXTURE 0x1
#define DEBUG_STATE 0x2
#define DEBUG_IOCTL 0x4
#define DEBUG_PRIMS 0x8
#define DEBUG_VERTS 0x10
#define DEBUG_FALLBACKS 0x20
#define DEBUG_VERBOSE 0x40
#define DEBUG_DRI 0x80
#define DEBUG_DMA 0x100
#define DEBUG_SANITY 0x200
#define DEBUG_SYNC 0x400
#define DEBUG_SLEEP 0x800
#define DEBUG_PIXEL 0x1000
#define DEBUG_2D 0x2000
extern void viaGetLock(viaContextPtr vmesa, GLuint flags);
extern void viaLock(viaContextPtr vmesa, GLuint flags);
extern void viaUnLock(viaContextPtr vmesa, GLuint flags);
extern void viaEmitHwStateLocked(viaContextPtr vmesa);
extern void viaEmitScissorValues(viaContextPtr vmesa, int box_nr, int emit);
extern void viaXMesaSetBackClipRects(viaContextPtr vmesa);
extern void viaXMesaSetFrontClipRects(viaContextPtr vmesa);
extern void viaGetLock(struct via_context *vmesa, GLuint flags);
extern void viaLock(struct via_context *vmesa, GLuint flags);
extern void viaUnLock(struct via_context *vmesa, GLuint flags);
extern void viaEmitHwStateLocked(struct via_context *vmesa);
extern void viaEmitScissorValues(struct via_context *vmesa, int box_nr, int emit);
extern void viaXMesaSetBackClipRects(struct via_context *vmesa);
extern void viaXMesaSetFrontClipRects(struct via_context *vmesa);
extern void viaReAllocateBuffers(GLframebuffer *drawbuffer);
extern void viaXMesaWindowMoved(viaContextPtr vmesa);
extern void viaXMesaWindowMoved(struct via_context *vmesa);
extern GLboolean viaTexCombineState(viaContextPtr vmesa,
extern GLboolean viaTexCombineState(struct via_context *vmesa,
const struct gl_tex_env_combine_state * combine,
unsigned unit );

View File

@@ -8,10 +8,6 @@
#define VIA_VERSION_MAJOR 4
#define VIA_VERSION_MINOR 1
typedef struct {
int CtxOwner;
} VIASAREAPriv;
typedef struct {
drm_handle_t handle;
drmSize size;
@@ -29,6 +25,7 @@ typedef struct {
int priv2;
int fbOffset;
int fbSize;
char drixinerama;
int backOffset;
int depthOffset;
int textureOffset;
@@ -36,10 +33,8 @@ typedef struct {
int irqEnabled;
unsigned int scrnX, scrnY;
int sarea_priv_offset;
/*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/
int VQEnable;
int DRIIrqEnable;
int ringBufActive;
unsigned int reg_pause_addr;
} VIADRIRec, *VIADRIPtr;
typedef struct {
@@ -50,13 +45,4 @@ typedef struct {
int dummy;
} VIADRIContextRec, *VIADRIContextPtr;
#ifdef XFree86Server
#include "screenint.h"
Bool VIADRIScreenInit(ScreenPtr pScreen);
void VIADRICloseScreen(ScreenPtr pScreen);
Bool VIADRIFinishScreenInit(ScreenPtr pScreen);
#endif
#endif

View File

@@ -28,15 +28,19 @@
#include "via_ioctl.h"
#include "via_fb.h"
#include "xf86drm.h"
#include "imports.h"
#include "simple_list.h"
#include <sys/ioctl.h>
GLboolean
via_alloc_draw_buffer(viaContextPtr vmesa, viaBuffer *buf)
via_alloc_draw_buffer(struct via_context *vmesa, struct via_buffer *buf)
{
drm_via_mem_t mem;
mem.context = vmesa->hHWContext;
mem.size = buf->size;
mem.type = VIDEO;
mem.type = VIA_MEM_VIDEO;
mem.offset = 0;
mem.index = 0;
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &mem))
return GL_FALSE;
@@ -49,7 +53,7 @@ via_alloc_draw_buffer(viaContextPtr vmesa, viaBuffer *buf)
}
void
via_free_draw_buffer(viaContextPtr vmesa, viaBuffer *buf)
via_free_draw_buffer(struct via_context *vmesa, struct via_buffer *buf)
{
drm_via_mem_t mem;
@@ -57,135 +61,183 @@ via_free_draw_buffer(viaContextPtr vmesa, viaBuffer *buf)
mem.context = vmesa->hHWContext;
mem.index = buf->index;
mem.type = VIDEO;
mem.type = VIA_MEM_VIDEO;
mem.offset = buf->offset;
mem.size = buf->size;
ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &mem);
buf->map = NULL;
}
GLboolean
via_alloc_dma_buffer(viaContextPtr vmesa)
via_alloc_dma_buffer(struct via_context *vmesa)
{
drm_via_dma_init_t init;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
vmesa->dma = (GLubyte *) malloc(VIA_DMA_BUFSIZ);
/*
* Check whether AGP DMA has been initialized.
*/
memset(&init, 0, sizeof(init));
init.func = VIA_DMA_INITIALIZED;
vmesa->useAgp =
( 0 == drmCommandWrite(vmesa->driFd, DRM_VIA_DMA_INIT,
&init, sizeof(init)));
if (VIA_DEBUG) {
if (VIA_DEBUG & DEBUG_DMA) {
if (vmesa->useAgp)
fprintf(stderr, "unichrome_dri.so: Using AGP.\n");
else
fprintf(stderr, "unichrome_dri.so: Using PCI.\n");
fprintf(stderr, "%s - out\n", __FUNCTION__);
}
return ((vmesa->dma) ? GL_TRUE : GL_FALSE);
}
void
via_free_dma_buffer(viaContextPtr vmesa)
via_free_dma_buffer(struct via_context *vmesa)
{
if (!vmesa) return;
free(vmesa->dma);
vmesa->dma = 0;
}
GLboolean
via_alloc_texture(viaContextPtr vmesa, viaTextureObjectPtr t)
/* These functions now allocate and free the via_tex_buffer struct as well:
*/
struct via_tex_buffer *
via_alloc_texture(struct via_context *vmesa,
GLuint size,
GLuint memType)
{
drm_via_mem_t fb;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
fb.context = vmesa->hHWContext;
fb.size = t->texMem.size;
fb.type = VIDEO;
if (VIA_DEBUG) {
fprintf(stderr, "texture size = %d\n", fb.size);
fprintf(stderr, "texture type = %d\n", fb.type);
}
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb)) {
fprintf(stderr, "via_alloc_texture fail\n");
return GL_FALSE;
}
t->texMem.offset = fb.offset;
t->texMem.index = fb.index;
if (VIA_DEBUG) fprintf(stderr, "texture index = %d\n", (GLuint)fb.index);
t->bufAddr = (unsigned char *)(fb.offset + (GLuint)vmesa->driScreen->pFB);
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return GL_TRUE;
struct via_tex_buffer *t = CALLOC_STRUCT(via_tex_buffer);
if (!t)
goto cleanup;
t->size = size;
t->memType = memType;
insert_at_tail(&vmesa->tex_image_list[memType], t);
if (t->memType == VIA_MEM_AGP ||
t->memType == VIA_MEM_VIDEO) {
drm_via_mem_t fb;
fb.context = vmesa->hHWContext;
fb.size = t->size;
fb.type = t->memType;
fb.offset = 0;
fb.index = 0;
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb) != 0 ||
fb.index == 0)
goto cleanup;
if (0)
fprintf(stderr, "offset %lx index %lx\n", fb.offset, fb.index);
t->offset = fb.offset;
t->index = fb.index;
if (t->memType == VIA_MEM_AGP) {
t->bufAddr = (GLubyte *)((GLuint)vmesa->viaScreen->agpLinearStart +
fb.offset);
t->texBase = (GLuint)vmesa->agpBase + fb.offset;
}
else {
t->bufAddr = (GLubyte *)(fb.offset + (GLuint)vmesa->driScreen->pFB);
t->texBase = fb.offset;
}
vmesa->total_alloc[t->memType] += t->size;
return t;
}
else if (t->memType == VIA_MEM_SYSTEM) {
t->bufAddr = MESA_PBUFFER_ALLOC(t->size);
if (!t->bufAddr)
goto cleanup;
vmesa->total_alloc[t->memType] += t->size;
return t;
}
cleanup:
if (t) {
remove_from_list(t);
FREE(t);
}
return NULL;
}
/*=* John Sheng [2003.5.31] agp tex *=*/
GLboolean
via_alloc_texture_agp(viaContextPtr vmesa, viaTextureObjectPtr t)
static void
via_do_free_texture(struct via_context *vmesa, struct via_tex_buffer *t)
{
drm_via_mem_t fb;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
fb.context = vmesa->hHWContext;
fb.size = t->texMem.size;
fb.type = AGP;
if (VIA_DEBUG) {
fprintf(stderr, "texture_agp size = %d\n", fb.size);
fprintf(stderr, "texture type = %d\n", fb.type);
}
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb)) {
fprintf(stderr, "via_alloc_texture_agp fail\n");
return GL_FALSE;
}
t->texMem.offset = fb.offset;
t->texMem.index = fb.index;
if (VIA_DEBUG) fprintf(stderr, "texture agp index = %d\n", (GLuint)fb.index);
t->bufAddr = (unsigned char *)((GLuint)vmesa->viaScreen->agpLinearStart + fb.offset);
/*=* John Sheng [2003.5.31] agp tex *=*/
t->inAGP = GL_TRUE;
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return GL_TRUE;
drm_via_mem_t fb;
remove_from_list( t );
vmesa->total_alloc[t->memType] -= t->size;
fb.context = vmesa->hHWContext;
fb.index = t->index;
fb.offset = t->offset;
fb.type = t->memType;
fb.size = t->size;
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb)) {
fprintf(stderr, "via_free_texture fail\n");
}
FREE(t);
}
/* Release textures which were potentially still being referenced by
* hardware at the time when they were originally freed.
*/
void
via_release_pending_textures( struct via_context *vmesa )
{
struct via_tex_buffer *s, *tmp;
foreach_s( s, tmp, &vmesa->freed_tex_buffers ) {
if (s->lastUsed < vmesa->lastBreadcrumbRead) {
if (VIA_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: release tex sz %d lastUsed %x\n",
__FUNCTION__, s->size, s->lastUsed);
via_do_free_texture(vmesa, s);
}
}
}
void
via_free_texture(viaContextPtr vmesa, viaTextureObjectPtr t)
via_free_texture(struct via_context *vmesa, struct via_tex_buffer *t)
{
drm_via_mem_t fb;
if (VIA_DEBUG) {
fprintf(stderr, "via_free_texture: index = %d\n",
t->texMem.index);
fprintf(stderr, "via_free_texture: size = %d\n",
t->texMem.size);
}
if (!vmesa) {
fprintf(stderr, "!mesa\n");
return;
}
fb.context = vmesa->hHWContext;
fb.index = t->texMem.index;
/*=* John Sheng [2003.5.31] agp tex *=*/
if(t->inAGP)
fb.type = AGP;
else
fb.type = VIDEO;
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb)) {
if(vmesa->shareCtx) {
fb.context = ((viaContextPtr)((GLcontext *)(vmesa->shareCtx)->DriverCtx))->hHWContext;
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb)) {
fprintf(stderr, "via_free_texture fail\n");
}
}
else
fprintf(stderr, "via_free_texture fail\n");
}
if (!t) {
return;
}
else if (t->memType == VIA_MEM_SYSTEM) {
remove_from_list(t);
vmesa->total_alloc[t->memType] -= t->size;
MESA_PBUFFER_FREE(t->bufAddr);
FREE(t);
}
else if (t->index && viaCheckBreadcrumb(vmesa, t->lastUsed)) {
via_do_free_texture( vmesa, t );
}
else {
/* Close current breadcrumb so that we can free this eventually:
*/
if (t->lastUsed == vmesa->lastBreadcrumbWrite)
viaEmitBreadcrumb(vmesa);
t->bufAddr = NULL;
move_to_tail( &vmesa->freed_tex_buffers, t );
}
}

View File

@@ -27,12 +27,16 @@
#include "via_context.h"
extern GLboolean via_alloc_draw_buffer(viaContextPtr vmesa, viaBuffer *buf);
extern GLboolean via_alloc_dma_buffer(viaContextPtr vmesa);
extern GLboolean via_alloc_texture(viaContextPtr vmesa, viaTextureObjectPtr t);
extern GLboolean via_alloc_texture_agp(viaContextPtr vmesa, viaTextureObjectPtr t);
extern GLboolean via_alloc_draw_buffer(struct via_context *vmesa, struct via_buffer *buf);
extern GLboolean via_alloc_dma_buffer(struct via_context *vmesa);
extern void via_free_draw_buffer(viaContextPtr vmesa, viaBuffer *buf);
extern void via_free_dma_buffer(viaContextPtr vmesa);
extern void via_free_texture(viaContextPtr vmesa, viaTextureObjectPtr t);
struct via_tex_buffer *
via_alloc_texture(struct via_context *vmesa,
GLuint size,
GLuint memType);
extern void via_free_draw_buffer(struct via_context *vmesa, struct via_buffer *buf);
extern void via_free_dma_buffer(struct via_context *vmesa);
extern void via_free_texture(struct via_context *vmesa, struct via_tex_buffer *t);
void via_release_pending_textures( struct via_context *vmesa );
#endif

View File

@@ -35,6 +35,8 @@
#include "via_tris.h"
#include "via_ioctl.h"
#include "via_state.h"
#include "via_fb.h"
#include "via_3d_reg.h"
#include "vblank.h"
#include "drm.h"
@@ -73,7 +75,7 @@
#define VIA_BLIT_FILL 0xF0
#define VIA_BLIT_SET 0xFF
static void dump_dma( viaContextPtr vmesa )
static void dump_dma( struct via_context *vmesa )
{
GLuint i;
GLuint *data = (GLuint *)vmesa->dma;
@@ -89,7 +91,7 @@ static void dump_dma( viaContextPtr vmesa )
void viaCheckDma(viaContextPtr vmesa, GLuint bytes)
void viaCheckDma(struct via_context *vmesa, GLuint bytes)
{
VIA_FINISH_PRIM( vmesa );
if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
@@ -105,7 +107,7 @@ void viaCheckDma(viaContextPtr vmesa, GLuint bytes)
} while (0)
static void viaBlit(viaContextPtr vmesa, GLuint bpp,
static void viaBlit(struct via_context *vmesa, GLuint bpp,
GLuint srcBase, GLuint srcPitch,
GLuint dstBase, GLuint dstPitch,
GLuint w, GLuint h,
@@ -116,9 +118,12 @@ static void viaBlit(viaContextPtr vmesa, GLuint bpp,
GLuint dwGEMode, srcX, dstX, cmd;
RING_VARS;
if (VIA_DEBUG)
fprintf(stderr, "%s bpp %d src %x/%x dst %x/%x w %d h %d mode: %x color: 0x%08x mask 0x%08x\n",
__FUNCTION__, bpp, srcBase, srcPitch, dstBase, dstPitch, w,h, blitMode, color, nMask);
if (VIA_DEBUG & DEBUG_2D)
fprintf(stderr,
"%s bpp %d src %x/%x dst %x/%x w %d h %d "
" mode: %x color: 0x%08x mask 0x%08x\n",
__FUNCTION__, bpp, srcBase, srcPitch, dstBase,
dstPitch, w,h, blitMode, color, nMask);
if (!w || !h)
@@ -166,8 +171,8 @@ static void viaBlit(viaContextPtr vmesa, GLuint bpp,
ADVANCE_RING();
}
static void viaFillBuffer(viaContextPtr vmesa,
viaBuffer *buffer,
static void viaFillBuffer(struct via_context *vmesa,
struct via_buffer *buffer,
drm_clip_rect_t *pbox,
int nboxes,
GLuint pixel,
@@ -200,7 +205,7 @@ static void viaFillBuffer(viaContextPtr vmesa,
static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
int flag = 0;
GLuint i = 0;
@@ -236,8 +241,8 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
mask &= ~DD_STENCIL_BIT;
}
else {
if (VIA_DEBUG)
fprintf(stderr, "XXX: Clear stencil writemask %x -- need triangles (or a ROP?)\n",
if (VIA_DEBUG & DEBUG_2D)
fprintf(stderr, "Clear stencil writemask %x\n",
ctx->Stencil.WriteMask[0]);
}
}
@@ -267,8 +272,9 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
if (!all) {
drm_clip_rect_t *b = vmesa->pClipRects;
boxes = tmp_boxes = (drm_clip_rect_t *)malloc(vmesa->numClipRects *
sizeof(drm_clip_rect_t));
boxes = tmp_boxes =
(drm_clip_rect_t *)malloc(vmesa->numClipRects *
sizeof(drm_clip_rect_t));
if (!boxes) {
UNLOCK_HARDWARE(vmesa);
return;
@@ -300,15 +306,18 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
}
if (flag & VIA_FRONT) {
viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor, vmesa->ClearMask);
viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor,
vmesa->ClearMask);
}
if (flag & VIA_BACK) {
viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor, vmesa->ClearMask);
viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor,
vmesa->ClearMask);
}
if (flag & VIA_DEPTH) {
viaFillBuffer(vmesa, &vmesa->depth, boxes, nr, clear_depth, clear_depth_mask);
viaFillBuffer(vmesa, &vmesa->depth, boxes, nr, clear_depth,
clear_depth_mask);
}
viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS);
@@ -325,13 +334,13 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
static void viaDoSwapBuffers(viaContextPtr vmesa,
static void viaDoSwapBuffers(struct via_context *vmesa,
drm_clip_rect_t *b,
GLuint nbox)
{
GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
viaBuffer *front = &vmesa->front;
viaBuffer *back = &vmesa->back;
struct via_buffer *front = &vmesa->front;
struct via_buffer *back = &vmesa->back;
GLuint i;
for (i = 0; i < nbox; i++, b++) {
@@ -350,9 +359,218 @@ static void viaDoSwapBuffers(viaContextPtr vmesa,
w, h,
VIA_BLIT_COPY, 0, 0);
}
viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* redundant */
}
static void viaEmitBreadcrumbLocked( struct via_context *vmesa )
{
struct via_buffer *buffer = &vmesa->breadcrumb;
GLuint value = vmesa->lastBreadcrumbWrite + 1;
if (VIA_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s %d\n", __FUNCTION__, value);
assert(!vmesa->dmaLow);
viaBlit(vmesa,
buffer->bpp,
buffer->offset, buffer->pitch,
buffer->offset, buffer->pitch,
1, 1,
VIA_BLIT_FILL, value, 0);
viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* often redundant */
vmesa->lastBreadcrumbWrite = value;
}
void viaEmitBreadcrumb( struct via_context *vmesa )
{
LOCK_HARDWARE(vmesa);
if (vmesa->dmaLow)
viaFlushDmaLocked(vmesa, 0);
viaEmitBreadcrumbLocked( vmesa );
UNLOCK_HARDWARE(vmesa);
}
static GLboolean viaCheckIdle( struct via_context *vmesa )
{
if ((vmesa->regEngineStatus[0] & 0xFFFEFFFF) == 0x00020000) {
return GL_TRUE;
}
return GL_FALSE;
}
GLboolean viaCheckBreadcrumb( struct via_context *vmesa, GLuint value )
{
GLuint *buf = (GLuint *)vmesa->breadcrumb.map;
vmesa->lastBreadcrumbRead = *buf;
if (VIA_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s %d < %d: %d\n", __FUNCTION__, value,
vmesa->lastBreadcrumbRead,
value < vmesa->lastBreadcrumbRead);
return value < vmesa->lastBreadcrumbRead;
}
static void viaWaitBreadcrumb( struct via_context *vmesa, GLuint value )
{
if (VIA_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s %d\n", __FUNCTION__, value);
assert(value < vmesa->lastBreadcrumbWrite);
while (!viaCheckBreadcrumb( vmesa, value )) {
viaSwapOutWork( vmesa );
via_release_pending_textures( vmesa );
}
}
void viaWaitIdle( struct via_context *vmesa )
{
VIA_FLUSH_DMA(vmesa);
if (VIA_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s lastDma %d lastBreadcrumbWrite %d\n",
__FUNCTION__, vmesa->lastDma, vmesa->lastBreadcrumbWrite);
/* Need to emit a new breadcrumb?
*/
if (vmesa->lastDma == vmesa->lastBreadcrumbWrite) {
LOCK_HARDWARE(vmesa);
viaEmitBreadcrumbLocked( vmesa );
UNLOCK_HARDWARE(vmesa);
}
/* Need to wait?
*/
if (vmesa->lastDma >= vmesa->lastBreadcrumbRead)
viaWaitBreadcrumb( vmesa, vmesa->lastDma );
while(!viaCheckIdle(vmesa))
;
via_release_pending_textures(vmesa);
}
void viaWaitIdleLocked( struct via_context *vmesa )
{
if (vmesa->dmaLow)
viaFlushDmaLocked(vmesa, 0);
if (VIA_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s lastDma %d lastBreadcrumbWrite %d\n",
__FUNCTION__, vmesa->lastDma, vmesa->lastBreadcrumbWrite);
/* Need to emit a new breadcrumb?
*/
if (vmesa->lastDma == vmesa->lastBreadcrumbWrite) {
viaEmitBreadcrumbLocked( vmesa );
}
/* Need to wait?
*/
if (vmesa->lastDma >= vmesa->lastBreadcrumbRead)
viaWaitBreadcrumb( vmesa, vmesa->lastDma );
while(!viaCheckIdle(vmesa))
;
via_release_pending_textures(vmesa);
}
/* Wait for command stream to be processed *and* the next vblank to
* occur. Equivalent to calling WAIT_IDLE() and then WaitVBlank,
* except that WAIT_IDLE() will spin the CPU polling, while this is
* IRQ driven.
*/
static void viaWaitIdleVBlank( const __DRIdrawablePrivate *dPriv,
struct via_context *vmesa,
GLuint value )
{
GLboolean missed_target;
VIA_FLUSH_DMA(vmesa);
if (!value)
return;
do {
if (value < vmesa->lastBreadcrumbRead ||
vmesa->thrashing)
viaSwapOutWork(vmesa);
driWaitForVBlank( dPriv, & vmesa->vbl_seq,
vmesa->vblank_flags, & missed_target );
if ( missed_target ) {
vmesa->swap_missed_count++;
vmesa->get_ust( &vmesa->swap_missed_ust );
}
}
while (!viaCheckBreadcrumb(vmesa, value));
vmesa->thrashing = 0; /* reset flag on swap */
vmesa->swap_count++;
via_release_pending_textures( vmesa );
}
static void viaDoPageFlipLocked(struct via_context *vmesa, GLuint offset)
{
RING_VARS;
if (VIA_DEBUG & DEBUG_2D)
fprintf(stderr, "%s %x\n", __FUNCTION__, offset);
if (!vmesa->nDoneFirstFlip) {
vmesa->nDoneFirstFlip = GL_TRUE;
BEGIN_RING(4);
OUT_RING(HALCYON_HEADER2);
OUT_RING(0x00fe0000);
OUT_RING(0x0000000e);
OUT_RING(0x0000000e);
ADVANCE_RING();
}
BEGIN_RING(4);
OUT_RING( HALCYON_HEADER2 );
OUT_RING( 0x00fe0000 );
OUT_RING((HC_SubA_HFBBasL << 24) | (offset & 0xFFFFF8) | 0x2);
OUT_RING((HC_SubA_HFBDrawFirst << 24) |
((offset & 0xFF000000) >> 24) | 0x0100);
ADVANCE_RING();
vmesa->pfCurrentOffset = vmesa->sarea->pfCurrentOffset = offset;
viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* often redundant */
}
void viaResetPageFlippingLocked(struct via_context *vmesa)
{
if (VIA_DEBUG & DEBUG_2D)
fprintf(stderr, "%s\n", __FUNCTION__);
viaDoPageFlipLocked( vmesa, 0 );
if (vmesa->front.offset != 0) {
struct via_buffer buffer_tmp;
memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_buffer));
memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_buffer));
memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_buffer));
}
assert(vmesa->front.offset == 0);
vmesa->doPageFlip = vmesa->allowPageFlip = 0;
}
/*
@@ -360,86 +578,76 @@ static void viaDoSwapBuffers(viaContextPtr vmesa,
*/
void viaCopyBuffer(const __DRIdrawablePrivate *dPriv)
{
viaContextPtr vmesa = (viaContextPtr)dPriv->driContextPriv->driverPrivate;
GLboolean missed_target;
struct via_context *vmesa =
(struct via_context *)dPriv->driContextPriv->driverPrivate;
if (VIA_DEBUG & DEBUG_IOCTL)
fprintf(stderr,
"%s: lastSwap[1] %d lastSwap[0] %d lastWrite %d lastRead %d\n",
__FUNCTION__,
vmesa->lastSwap[1],
vmesa->lastSwap[0],
vmesa->lastBreadcrumbWrite,
vmesa->lastBreadcrumbRead);
VIA_FLUSH_DMA(vmesa);
driWaitForVBlank( dPriv, & vmesa->vbl_seq, vmesa->vblank_flags, & missed_target );
if ( missed_target ) {
vmesa->swap_missed_count++;
vmesa->get_ust( &vmesa->swap_missed_ust );
}
if (vmesa->vblank_flags == VBLANK_FLAG_SYNC &&
vmesa->lastBreadcrumbWrite > 1)
viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastBreadcrumbWrite-1);
else
viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastSwap[1]);
LOCK_HARDWARE(vmesa);
viaDoSwapBuffers(vmesa, dPriv->pClipRects, dPriv->numClipRects);
viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS);
/* Catch and cleanup situation where we were pageflipping but have
* stopped.
*/
if (dPriv->numClipRects && vmesa->sarea->pfCurrentOffset != 0) {
viaResetPageFlippingLocked(vmesa);
UNLOCK_HARDWARE(vmesa);
return;
}
viaDoSwapBuffers(vmesa, dPriv->pClipRects, dPriv->numClipRects);
vmesa->lastSwap[1] = vmesa->lastSwap[0];
vmesa->lastSwap[0] = vmesa->lastBreadcrumbWrite;
viaEmitBreadcrumbLocked(vmesa);
UNLOCK_HARDWARE(vmesa);
vmesa->swap_count++;
vmesa->get_ust( &vmesa->swap_ust );
}
/*
* XXX implement when full-screen extension is done.
*/
void viaPageFlip(const __DRIdrawablePrivate *dPriv)
{
viaContextPtr vmesa = (viaContextPtr)dPriv->driContextPriv->driverPrivate;
viaBuffer buffer_tmp;
GLboolean missed_target;
struct via_context *vmesa =
(struct via_context *)dPriv->driContextPriv->driverPrivate;
struct via_buffer buffer_tmp;
VIA_FLUSH_DMA(vmesa);
driWaitForVBlank( dPriv, &vmesa->vbl_seq, vmesa->vblank_flags, &missed_target );
if ( missed_target ) {
vmesa->swap_missed_count++;
vmesa->get_ust( &vmesa->swap_missed_ust );
}
if (vmesa->vblank_flags == VBLANK_FLAG_SYNC &&
vmesa->lastBreadcrumbWrite > 1)
viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastBreadcrumbWrite - 1);
else
viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastSwap[0]);
LOCK_HARDWARE(vmesa);
{
RING_VARS;
if (!vmesa->nDoneFirstFlip) {
vmesa->nDoneFirstFlip = GL_FALSE; /* XXX: FIXME LATER!!! */
BEGIN_RING(4);
OUT_RING(HALCYON_HEADER2);
OUT_RING(0x00fe0000);
OUT_RING(0x0000000e);
OUT_RING(0x0000000e);
ADVANCE_RING();
}
BEGIN_RING(4);
OUT_RING( HALCYON_HEADER2 );
OUT_RING( 0x00fe0000 );
OUT_RING((HC_SubA_HFBBasL << 24) | (vmesa->back.offset & 0xFFFFF8) | 0x2);
OUT_RING((HC_SubA_HFBDrawFirst << 24) |
((vmesa->back.offset & 0xFF000000) >> 24) | 0x0100);
ADVANCE_RING();
}
viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS);
viaDoPageFlipLocked(vmesa, vmesa->back.offset);
vmesa->lastSwap[1] = vmesa->lastSwap[0];
vmesa->lastSwap[0] = vmesa->lastBreadcrumbWrite;
viaEmitBreadcrumbLocked(vmesa);
UNLOCK_HARDWARE(vmesa);
vmesa->swap_count++;
vmesa->get_ust( &vmesa->swap_ust );
/* KW: FIXME: When buffers are freed, could free frontbuffer by
* accident:
*/
memcpy(&buffer_tmp, &vmesa->back, sizeof(viaBuffer));
memcpy(&vmesa->back, &vmesa->front, sizeof(viaBuffer));
memcpy(&vmesa->front, &buffer_tmp, sizeof(viaBuffer));
if(vmesa->currentPage) {
vmesa->currentPage = 0;
}
else {
vmesa->currentPage = 1;
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_buffer));
memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_buffer));
memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_buffer));
}
@@ -447,7 +655,7 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv)
#define VIA_CMDBUF_MAX_LAG 50000
static int fire_buffer(viaContextPtr vmesa)
static int fire_buffer(struct via_context *vmesa)
{
drm_via_cmdbuffer_t bufI;
int ret;
@@ -469,7 +677,8 @@ static int fire_buffer(viaContextPtr vmesa)
} while (ret == -EAGAIN);
if (ret) {
UNLOCK_HARDWARE(vmesa);
fprintf(stderr, "%s: DRM_VIA_CMDBUF_SIZE returned %d\n", __FUNCTION__, ret);
fprintf(stderr, "%s: DRM_VIA_CMDBUF_SIZE returned %d\n",
__FUNCTION__, ret);
abort();
return ret;
}
@@ -482,7 +691,8 @@ static int fire_buffer(viaContextPtr vmesa)
} while (ret == -EAGAIN);
if (ret) {
UNLOCK_HARDWARE(vmesa);
fprintf(stderr, "%s: DRM_VIA_CMDBUFFER returned %d\n", __FUNCTION__, ret);
fprintf(stderr, "%s: DRM_VIA_CMDBUFFER returned %d\n",
__FUNCTION__, ret);
abort();
/* If this fails, the original code fell back to the PCI path.
*/
@@ -492,14 +702,14 @@ static int fire_buffer(viaContextPtr vmesa)
/* Fall through to PCI handling?!?
*/
WAIT_IDLE(vmesa);
viaWaitIdleLocked(vmesa);
}
ret = drmCommandWrite(vmesa->driFd, DRM_VIA_PCICMD, &bufI, sizeof(bufI));
if (ret) {
UNLOCK_HARDWARE(vmesa);
dump_dma(vmesa);
fprintf(stderr, "%s: DRM_VIA_PCICMD returned %d\n", __FUNCTION__, ret);
fprintf(stderr, "%s: DRM_VIA_PCICMD returned %d\n", __FUNCTION__, ret);
abort();
}
@@ -511,10 +721,10 @@ static int fire_buffer(viaContextPtr vmesa)
* into the head of the DMA buffer being flushed. Fires the buffer
* for each cliprect.
*/
static void via_emit_cliprect(viaContextPtr vmesa,
static void via_emit_cliprect(struct via_context *vmesa,
drm_clip_rect_t *b)
{
viaBuffer *buffer = vmesa->drawBuffer;
struct via_buffer *buffer = vmesa->drawBuffer;
GLuint *vb = (GLuint *)(vmesa->dma + vmesa->dmaCliprectAddr);
GLuint format = (vmesa->viaScreen->bitsPerPixel == 0x20
@@ -525,7 +735,8 @@ static void via_emit_cliprect(viaContextPtr vmesa,
GLuint offset = buffer->orig;
if (0)
fprintf(stderr, "emit cliprect for box %d,%d %d,%d\n", b->x1, b->y1, b->x2, b->y2);
fprintf(stderr, "emit cliprect for box %d,%d %d,%d\n",
b->x1, b->y1, b->x2, b->y2);
vb[0] = HC_HEADER2;
vb[1] = (HC_ParaType_NotTex << 16);
@@ -539,11 +750,11 @@ static void via_emit_cliprect(viaContextPtr vmesa,
vb[3] = (HC_SubA_HClipLR << 24) | (b->x1 << 12) | b->x2;
}
vb[4] = ((HC_SubA_HDBBasL << 24) | (offset & 0xFFFFFF));
vb[5] = ((HC_SubA_HDBBasH << 24) | ((offset & 0xFF000000)) >> 24);
vb[4] = (HC_SubA_HDBBasL << 24) | (offset & 0xFFFFFF);
vb[5] = (HC_SubA_HDBBasH << 24) | ((offset & 0xFF000000) >> 24);
vb[6] = ((HC_SubA_HSPXYOS << 24) | ((31 - vmesa->drawXoff) << HC_HSPXOS_SHIFT));
vb[7] = ((HC_SubA_HDBFM << 24) | HC_HDBLoc_Local | format | pitch);
vb[6] = (HC_SubA_HSPXYOS << 24) | ((31-vmesa->drawXoff) << HC_HSPXOS_SHIFT);
vb[7] = (HC_SubA_HDBFM << 24) | HC_HDBLoc_Local | format | pitch;
}
@@ -570,16 +781,17 @@ static int intersect_rect(drm_clip_rect_t *out,
return 1;
}
void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
void viaFlushDmaLocked(struct via_context *vmesa, GLuint flags)
{
int i;
RING_VARS;
if (VIA_DEBUG)
if (VIA_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
fprintf(stderr, "%s\n", __FUNCTION__);
if (*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|vmesa->hHWContext) &&
*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) {
*(GLuint *)vmesa->driHwLock !=
(DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) {
fprintf(stderr, "%s called without lock held\n", __FUNCTION__);
abort();
}
@@ -633,13 +845,14 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
case 0:
break;
default:
if (VIA_DEBUG)
if (VIA_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s: unaligned value for vmesa->dmaLow: %x\n",
__FUNCTION__, vmesa->dmaLow);
}
vmesa->lastDma = vmesa->lastBreadcrumbWrite;
if (VIA_DEBUG)
if (VIA_DEBUG & DEBUG_DMA)
dump_dma( vmesa );
if (flags & VIA_NO_CLIPRECTS) {
@@ -655,7 +868,6 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
}
else if (vmesa->numClipRects) {
drm_clip_rect_t *pbox = vmesa->pClipRects;
if (0) fprintf(stderr, "%s: %d cliprects\n", __FUNCTION__, vmesa->numClipRects);
for (i = 0; i < vmesa->numClipRects; i++) {
drm_clip_rect_t b;
@@ -694,12 +906,12 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
vmesa->newEmitState = ~0;
}
void viaWrapPrimitive( viaContextPtr vmesa )
void viaWrapPrimitive( struct via_context *vmesa )
{
GLenum renderPrimitive = vmesa->renderPrimitive;
GLenum hwPrimitive = vmesa->hwPrimitive;
if (VIA_DEBUG) fprintf(stderr, "%s\n", __FUNCTION__);
if (VIA_DEBUG & DEBUG_PRIMS) fprintf(stderr, "%s\n", __FUNCTION__);
if (vmesa->dmaLastPrim)
viaFinishPrimitive( vmesa );
@@ -713,7 +925,7 @@ void viaWrapPrimitive( viaContextPtr vmesa )
}
void viaFlushDma(viaContextPtr vmesa)
void viaFlushDma(struct via_context *vmesa)
{
if (vmesa->dmaLow) {
assert(!vmesa->dmaLastPrim);
@@ -726,15 +938,15 @@ void viaFlushDma(viaContextPtr vmesa)
static void viaFlush(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
VIA_FLUSH_DMA(vmesa);
}
static void viaFinish(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
VIA_FLUSH_DMA(vmesa);
WAIT_IDLE(vmesa);
viaWaitIdle(vmesa);
}
static void viaClearStencil(GLcontext *ctx, int s)

View File

@@ -28,14 +28,21 @@
#include "via_context.h"
void viaFinishPrimitive(viaContextPtr vmesa);
void viaFlushDma(viaContextPtr vmesa);
void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags);
void viaFinishPrimitive(struct via_context *vmesa);
void viaFlushDma(struct via_context *vmesa);
void viaFlushDmaLocked(struct via_context *vmesa, GLuint flags);
void viaInitIoctlFuncs(GLcontext *ctx);
void viaCopyBuffer(const __DRIdrawablePrivate *dpriv);
void viaPageFlip(const __DRIdrawablePrivate *dpriv);
void viaCheckDma(viaContextPtr vmesa, GLuint bytes);
void viaCheckDma(struct via_context *vmesa, GLuint bytes);
void viaResetPageFlippingLocked(struct via_context *vmesa);
void viaWaitIdle(struct via_context *vmesa);
void viaWaitIdleLocked(struct via_context *vmesa);
GLboolean viaCheckBreadcrumb( struct via_context *vmesa, GLuint value );
void viaEmitBreadcrumb( struct via_context *vmesa );
#define VIA_FINISH_PRIM(vmesa) do { \
if (vmesa->dmaLastPrim) \
@@ -49,9 +56,9 @@ void viaCheckDma(viaContextPtr vmesa, GLuint bytes);
} while (0)
void viaWrapPrimitive( viaContextPtr vmesa );
void viaWrapPrimitive( struct via_context *vmesa );
static __inline__ GLuint *viaAllocDma(viaContextPtr vmesa, int bytes)
static __inline__ GLuint *viaAllocDma(struct via_context *vmesa, int bytes)
{
if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
viaFlushDma(vmesa);
@@ -65,7 +72,7 @@ static __inline__ GLuint *viaAllocDma(viaContextPtr vmesa, int bytes)
}
static GLuint __inline__ *viaExtendPrimitive(viaContextPtr vmesa, int bytes)
static GLuint __inline__ *viaExtendPrimitive(struct via_context *vmesa, int bytes)
{
if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
viaWrapPrimitive(vmesa);

View File

@@ -59,7 +59,7 @@
#define HAVE_ELTS 0
#define LOCAL_VARS viaContextPtr vmesa = VIA_CONTEXT(ctx)
#define LOCAL_VARS struct via_context *vmesa = VIA_CONTEXT(ctx)
#define INIT(prim) do { \
viaRasterPrimitive(ctx, prim, prim); \
} while (0)
@@ -88,7 +88,7 @@
static GLboolean via_run_fastrender(GLcontext *ctx,
struct tnl_pipeline_stage *stage)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
GLuint i;
@@ -119,7 +119,8 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
}
static void via_check_fastrender(GLcontext *ctx, struct tnl_pipeline_stage *stage)
static void via_check_fastrender(GLcontext *ctx,
struct tnl_pipeline_stage *stage)
{
stage->inputs = TNL_CONTEXT(ctx)->render_inputs;
}

View File

@@ -83,12 +83,21 @@ static drmBufMapPtr via_create_empty_buffers(void)
return retval;
}
static void via_free_empty_buffers( drmBufMapPtr bufs )
{
if (bufs && bufs->list)
FREE(bufs->list);
if (bufs)
FREE(bufs);
}
static GLboolean
viaInitDriver(__DRIscreenPrivate *sPriv)
{
viaScreenPrivate *viaScreen;
VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
/* Allocate the private area */
@@ -117,20 +126,13 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
viaScreen->irqEnabled = gDRIPriv->irqEnabled;
viaScreen->irqEnabled = 1;
if (VIA_DEBUG) {
if (VIA_DEBUG & DEBUG_DRI) {
fprintf(stderr, "deviceID = %08x\n", viaScreen->deviceID);
fprintf(stderr, "width = %08x\n", viaScreen->width);
fprintf(stderr, "height = %08x\n", viaScreen->height);
fprintf(stderr, "cpp = %08x\n", viaScreen->cpp);
fprintf(stderr, "fbOffset = %08x\n", viaScreen->fbOffset);
}
/* DBG */
/*
if (gDRIPriv->bitsPerPixel == 15)
viaScreen->fbFormat = DV_PF_555;
else
viaScreen->fbFormat = DV_PF_565;
*/
viaScreen->bufs = via_create_empty_buffers();
if (viaScreen->bufs == NULL) {
@@ -170,7 +172,8 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
if ( driCompareGLXAPIVersion( 20030813 ) >= 0 ) {
PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
(PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress( (const GLubyte *) "__glXScrEnableExtension" );
(PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress(
(const GLubyte *) "__glXScrEnableExtension" );
void * const psc = sPriv->psc->screenConfigs;
if ( glx_enable_extension != NULL ) {
@@ -190,9 +193,6 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
}
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return GL_TRUE;
}
@@ -201,11 +201,13 @@ viaDestroyScreen(__DRIscreenPrivate *sPriv)
{
viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private;
VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
drmUnmap(viaScreen->reg, gDRIPriv->regs.size);
if (gDRIPriv->agp.size)
drmUnmap(viaScreen->agpLinearStart, gDRIPriv->agp.size);
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
via_free_empty_buffers(viaScreen->bufs);
FREE(viaScreen);
sPriv->private = NULL;
}
@@ -231,7 +233,6 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
mesaVis->accumRedBits > 0,
GL_FALSE /* s/w alpha planes */);
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return (driDrawPriv->driverPrivate != NULL);
#endif
return GL_FALSE;
@@ -333,7 +334,8 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
modes = (*create_context_modes)( num_modes, sizeof( __GLcontextModes ) );
m = modes;
if ( ! driFillInModes( & m, fb_format, fb_type,
depth_bits_array, stencil_bits_array, depth_buffer_factor,
depth_bits_array, stencil_bits_array,
depth_buffer_factor,
back_buffer_modes, back_buffer_factor,
GLX_TRUE_COLOR ) ) {
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
@@ -342,7 +344,8 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
}
if ( ! driFillInModes( & m, fb_format, fb_type,
depth_bits_array, stencil_bits_array, depth_buffer_factor,
depth_bits_array, stencil_bits_array,
depth_buffer_factor,
back_buffer_modes, back_buffer_factor,
GLX_DIRECT_COLOR ) ) {
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
@@ -367,7 +370,8 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
*/
#ifdef USE_NEW_INTERFACE
PUBLIC
void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn,
__DRIscreen *psc,
const __GLcontextModes * modes,
const __DRIversion * ddx_version,
const __DRIversion * dri_version,
@@ -416,7 +420,7 @@ void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc
static int
getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
{
viaContextPtr vmesa;
struct via_context *vmesa;
if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)
|| (dPriv->driContextPriv->driverPrivate == NULL)
@@ -424,7 +428,7 @@ getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
return -1;
}
vmesa = (viaContextPtr) dPriv->driContextPriv->driverPrivate;
vmesa = (struct via_context *) dPriv->driContextPriv->driverPrivate;
sInfo->swap_count = vmesa->swap_count;
sInfo->swap_ust = vmesa->swap_ust;
sInfo->swap_missed_count = vmesa->swap_missed_count;

View File

@@ -51,15 +51,15 @@
#define Y_FLIP(_y) (height - _y - 1)
#define HW_LOCK()
#define HW_CLIPLOOP() \
do { \
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
int _nc = dPriv->numClipRects; \
while (_nc--) { \
int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
#define HW_CLIPLOOP() \
do { \
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
int _nc = dPriv->numClipRects; \
while (_nc--) { \
int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
#define HW_ENDCLIPLOOP() \
@@ -70,7 +70,7 @@
#undef LOCAL_VARS
#define LOCAL_VARS \
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
struct via_context *vmesa = VIA_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
GLuint draw_pitch = vmesa->drawBuffer->pitch; \
GLuint read_pitch = vmesa->readBuffer->pitch; \
@@ -111,7 +111,7 @@
/* 16 bit depthbuffer functions.
*/
#define LOCAL_DEPTH_VARS \
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
struct via_context *vmesa = VIA_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
GLuint depth_pitch = vmesa->depth.pitch; \
GLuint height = dPriv->h; \
@@ -176,7 +176,7 @@
static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
GLuint bufferBit)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (bufferBit == DD_FRONT_LEFT_BIT) {
vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
@@ -193,23 +193,21 @@ static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
*/
void viaSpanRenderStart( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
VIA_FINISH_PRIM(vmesa);
struct via_context *vmesa = VIA_CONTEXT(ctx);
viaWaitIdle(vmesa);
LOCK_HARDWARE(vmesa);
viaFlushDmaLocked(vmesa, 0);
WAIT_IDLE(vmesa);
}
void viaSpanRenderFinish( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
_swrast_flush( ctx );
UNLOCK_HARDWARE( vmesa );
}
void viaInitSpanFuncs(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
swdd->SetBuffer = viaSetBuffer;

View File

@@ -38,6 +38,7 @@
#include "via_tex.h"
#include "via_tris.h"
#include "via_ioctl.h"
#include "via_3d_reg.h"
#include "swrast/swrast.h"
#include "array_cache/acache.h"
@@ -66,17 +67,26 @@ static GLuint ROP[16] = {
HC_HROP_WHITE /* GL_SET 1 */
};
/*
* Compute the 'S5.5' lod bias factor from the floating point OpenGL bias.
*/
static GLuint viaComputeLodBias(GLfloat bias)
{
int b = (int) (bias * 32.0);
if (b > 511)
b = 511;
else if (b < -512)
b = -512;
return (GLuint) b;
}
void viaEmitState(viaContextPtr vmesa)
void viaEmitState(struct via_context *vmesa)
{
GLcontext *ctx = vmesa->glCtx;
GLuint i = 0;
GLuint j = 0;
RING_VARS;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
viaCheckDma(vmesa, 0x110);
BEGIN_RING(5);
@@ -95,27 +105,23 @@ void viaEmitState(viaContextPtr vmesa)
pitch = vmesa->depth.pitch;
BEGIN_RING(6);
OUT_RING( ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)) );
OUT_RING( ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)) );
OUT_RING( ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
format | pitch) );
OUT_RING( ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD) );
OUT_RING( ((HC_SubA_HSTREF << 24) | vmesa->regHSTREF) );
OUT_RING( ((HC_SubA_HSTMD << 24) | vmesa->regHSTMD) );
OUT_RING( (HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF) );
OUT_RING( (HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24) );
OUT_RING( (HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
format | pitch );
OUT_RING( (HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD );
OUT_RING( (HC_SubA_HSTREF << 24) | vmesa->regHSTREF );
OUT_RING( (HC_SubA_HSTMD << 24) | vmesa->regHSTMD );
ADVANCE_RING();
}
else if (vmesa->hasDepth) {
GLuint pitch, format, offset;
if (vmesa->depthBits == 16) {
/* We haven't support 16bit depth yet */
format = HC_HZWBFM_16;
/*format = HC_HZWBFM_32;*/
if (VIA_DEBUG) fprintf(stderr, "z format = 16\n");
}
else {
format = HC_HZWBFM_32;
if (VIA_DEBUG) fprintf(stderr, "z format = 32\n");
}
@@ -123,60 +129,54 @@ void viaEmitState(viaContextPtr vmesa)
pitch = vmesa->depth.pitch;
BEGIN_RING(4);
OUT_RING( ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)) );
OUT_RING( ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)) );
OUT_RING( ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
format | pitch) );
OUT_RING( ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD) );
OUT_RING( (HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF) );
OUT_RING( (HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24) );
OUT_RING( (HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
format | pitch );
OUT_RING( (HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD );
ADVANCE_RING();
}
if (ctx->Color.AlphaEnabled) {
BEGIN_RING(1);
OUT_RING( ((HC_SubA_HATMD << 24) | vmesa->regHATMD) );
OUT_RING( (HC_SubA_HATMD << 24) | vmesa->regHATMD );
ADVANCE_RING();
i++;
}
if (ctx->Color.BlendEnabled) {
BEGIN_RING(11);
OUT_RING( ((HC_SubA_HABLCsat << 24) | vmesa->regHABLCsat) );
OUT_RING( ((HC_SubA_HABLCop << 24) | vmesa->regHABLCop) );
OUT_RING( ((HC_SubA_HABLAsat << 24) | vmesa->regHABLAsat) );
OUT_RING( ((HC_SubA_HABLAop << 24) | vmesa->regHABLAop) );
OUT_RING( ((HC_SubA_HABLRCa << 24) | vmesa->regHABLRCa) );
OUT_RING( ((HC_SubA_HABLRFCa << 24) | vmesa->regHABLRFCa) );
OUT_RING( ((HC_SubA_HABLRCbias << 24) | vmesa->regHABLRCbias) );
OUT_RING( ((HC_SubA_HABLRCb << 24) | vmesa->regHABLRCb) );
OUT_RING( ((HC_SubA_HABLRFCb << 24) | vmesa->regHABLRFCb) );
OUT_RING( ((HC_SubA_HABLRAa << 24) | vmesa->regHABLRAa) );
OUT_RING( ((HC_SubA_HABLRAb << 24) | vmesa->regHABLRAb) );
OUT_RING( (HC_SubA_HABLCsat << 24) | vmesa->regHABLCsat );
OUT_RING( (HC_SubA_HABLCop << 24) | vmesa->regHABLCop );
OUT_RING( (HC_SubA_HABLAsat << 24) | vmesa->regHABLAsat );
OUT_RING( (HC_SubA_HABLAop << 24) | vmesa->regHABLAop );
OUT_RING( (HC_SubA_HABLRCa << 24) | vmesa->regHABLRCa );
OUT_RING( (HC_SubA_HABLRFCa << 24) | vmesa->regHABLRFCa );
OUT_RING( (HC_SubA_HABLRCbias << 24) | vmesa->regHABLRCbias );
OUT_RING( (HC_SubA_HABLRCb << 24) | vmesa->regHABLRCb );
OUT_RING( (HC_SubA_HABLRFCb << 24) | vmesa->regHABLRFCb );
OUT_RING( (HC_SubA_HABLRAa << 24) | vmesa->regHABLRAa );
OUT_RING( (HC_SubA_HABLRAb << 24) | vmesa->regHABLRAb );
ADVANCE_RING();
}
if (ctx->Fog.Enabled) {
BEGIN_RING(3);
OUT_RING( ((HC_SubA_HFogLF << 24) | vmesa->regHFogLF) );
OUT_RING( ((HC_SubA_HFogCL << 24) | vmesa->regHFogCL) );
OUT_RING( ((HC_SubA_HFogCH << 24) | vmesa->regHFogCH) );
OUT_RING( (HC_SubA_HFogLF << 24) | vmesa->regHFogLF );
OUT_RING( (HC_SubA_HFogCL << 24) | vmesa->regHFogCL );
OUT_RING( (HC_SubA_HFogCH << 24) | vmesa->regHFogCH );
ADVANCE_RING();
}
if (ctx->Line.StippleFlag) {
BEGIN_RING(2);
OUT_RING( ((HC_SubA_HLP << 24) | ctx->Line.StipplePattern) );
OUT_RING( ((HC_SubA_HLPRF << 24) | ctx->Line.StippleFactor) );
ADVANCE_RING();
}
else {
BEGIN_RING(2);
OUT_RING( ((HC_SubA_HLP << 24) | 0xFFFF) );
OUT_RING( ((HC_SubA_HLPRF << 24) | 0xFFFF) );
OUT_RING( (HC_SubA_HLP << 24) | ctx->Line.StipplePattern );
OUT_RING( (HC_SubA_HLPRF << 24) | ctx->Line.StippleFactor );
ADVANCE_RING();
}
BEGIN_RING(1);
OUT_RING( ((HC_SubA_HPixGC << 24) | 0x0) );
OUT_RING( (HC_SubA_HPixGC << 24) | 0x0 );
ADVANCE_RING();
QWORD_PAD_RING();
@@ -195,12 +195,9 @@ void viaEmitState(viaContextPtr vmesa)
OUT_RING( (HC_ParaType_Tex << 16) | (HC_SubType_TexGeneral << 24) );
if (texUnit0->Enabled && texUnit1->Enabled) {
if (VIA_DEBUG) fprintf(stderr, "multi texture\n");
nDummyValue = (HC_SubA_HTXSMD << 24) | (1 << 3);
nDummyValue = (HC_SubA_HTXSMD << 24) | (1 << 3);
}
else {
if (VIA_DEBUG) fprintf(stderr, "single texture\n");
nDummyValue = (HC_SubA_HTXSMD << 24) | 0;
}
@@ -223,11 +220,10 @@ void viaEmitState(viaContextPtr vmesa)
if (texUnit0->Enabled) {
struct gl_texture_object *texObj = texUnit0->_Current;
viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
struct via_texture_object *t = (struct via_texture_object *)texObj;
GLuint numLevels = t->lastLevel - t->firstLevel + 1;
if (VIA_DEBUG) {
if (VIA_DEBUG & DEBUG_STATE) {
fprintf(stderr, "texture0 enabled\n");
fprintf(stderr, "texture level %d\n", t->actualLevel);
}
if (numLevels == 8) {
BEGIN_RING(27);
@@ -312,31 +308,26 @@ void viaEmitState(viaContextPtr vmesa)
ADVANCE_RING();
}
BEGIN_RING(12);
OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB_0 );
OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD_0 );
OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat_0 );
OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop_0 );
OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog_0 );
OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat_0 );
OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb_0 );
OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa_0 );
OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog_0 );
OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa_0 );
OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc_0 );
OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias_0 );
if (0) {
fprintf(stderr, "emitted Ca_0 %08x\n", vmesa->regHTXnTBLRCa_0);
fprintf(stderr, "emitted Cb_0 %08x\n", vmesa->regHTXnTBLRCb_0);
fprintf(stderr, "emitted Cc_0 %08x\n", vmesa->regHTXnTBLRCc_0);
fprintf(stderr, "emitted Cbias_0 %08x\n", vmesa->regHTXnTBLRCbias_0);
fprintf(stderr, "emitted Aa_0 %08x\n", vmesa->regHTXnTBLRAa_0);
fprintf(stderr, "emitted Fog_0 %08x\n", vmesa->regHTXnTBLRFog_0);
}
BEGIN_RING(15);
OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB[0] );
OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD[0] );
OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat[0] );
OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop[0] );
OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog[0] );
OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat[0] );
OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb[0] );
OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa[0] );
OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog[0] );
OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa[0] );
OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc[0] );
OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias[0] );
OUT_RING( (HC_SubA_HTXnTBC << 24) | vmesa->regHTXnTBC[0] );
OUT_RING( (HC_SubA_HTXnTRAH << 24) | vmesa->regHTXnTRAH[0] );
OUT_RING( (HC_SubA_HTXnCLODu << 24) | vmesa->regHTXnCLOD[0] );
ADVANCE_RING();
/* KW: This test never succeeds:
*/
if (t->regTexFM == HC_HTXnFM_Index8) {
struct gl_color_table *table = &texObj->Palette;
GLfloat *tableF = (GLfloat *)table->Table;
@@ -355,12 +346,11 @@ void viaEmitState(viaContextPtr vmesa)
if (texUnit1->Enabled) {
struct gl_texture_object *texObj = texUnit1->_Current;
viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
struct via_texture_object *t = (struct via_texture_object *)texObj;
GLuint numLevels = t->lastLevel - t->firstLevel + 1;
int texunit = (texUnit0->Enabled ? 1 : 0);
if (VIA_DEBUG) {
if (VIA_DEBUG & DEBUG_STATE) {
fprintf(stderr, "texture1 enabled\n");
fprintf(stderr, "texture level %d\n", t->actualLevel);
}
if (numLevels == 8) {
BEGIN_RING(27);
@@ -443,21 +433,26 @@ void viaEmitState(viaContextPtr vmesa)
ADVANCE_RING();
}
BEGIN_RING(12);
OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB_1 );
OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD_1 );
OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat_1 );
OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop_1 );
OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog_1 );
OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat_1 );
OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb_1 );
OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa_1 );
OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog_1 );
OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa_1 );
OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc_1 );
OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias_1 );
BEGIN_RING(15);
OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB[1] );
OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD[1] );
OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat[1] );
OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop[1] );
OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog[1] );
OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat[1] );
OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb[1] );
OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa[1] );
OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog[1] );
OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa[1] );
OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc[1] );
OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias[1] );
OUT_RING( (HC_SubA_HTXnTBC << 24) | vmesa->regHTXnTBC[1] );
OUT_RING( (HC_SubA_HTXnTRAH << 24) | vmesa->regHTXnTRAH[1] );
OUT_RING( (HC_SubA_HTXnCLODu << 24) | vmesa->regHTXnCLOD[1] );
ADVANCE_RING();
/* KW: This test never succeeds:
*/
if (t->regTexFM == HC_HTXnFM_Index8) {
struct gl_color_table *table = &texObj->Palette;
GLfloat *tableF = (GLfloat *)table->Table;
@@ -515,41 +510,45 @@ void viaEmitState(viaContextPtr vmesa)
OUT_RING( stipple[0] );
OUT_RING( HC_HEADER2 );
OUT_RING( (HC_ParaType_NotTex << 16) );
OUT_RING( ((HC_SubA_HSPXYOS << 24) | (((31 - vmesa->drawX) & 0x1f) << HC_HSPXOS_SHIFT)));
OUT_RING( ((HC_SubA_HSPXYOS << 24) | (((31 - vmesa->drawX) & 0x1f) << HC_HSPXOS_SHIFT)));
OUT_RING( (HC_SubA_HSPXYOS << 24) |
(((31 - vmesa->drawX) & 0x1f) << HC_HSPXOS_SHIFT));
OUT_RING( (HC_SubA_HSPXYOS << 24) |
(((31 - vmesa->drawX) & 0x1f) << HC_HSPXOS_SHIFT));
ADVANCE_RING();
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
vmesa->newEmitState = 0;
}
static __inline__ GLuint viaPackColor(GLuint format,
static __inline__ GLuint viaPackColor(GLuint bpp,
GLubyte r, GLubyte g,
GLubyte b, GLubyte a)
{
switch (format) {
case 0x10:
switch (bpp) {
case 16:
return PACK_COLOR_565(r, g, b);
case 0x20:
case 32:
return PACK_COLOR_8888(a, r, g, b);
default:
if (VIA_DEBUG) fprintf(stderr, "unknown format %d\n", (int)format);
return PACK_COLOR_8888(a, r, g, b);
assert(0);
return 0;
}
}
static void viaBlendEquationSeparate(GLcontext *ctx, GLenum rgbMode, GLenum aMode)
static void viaBlendEquationSeparate(GLcontext *ctx,
GLenum rgbMode,
GLenum aMode)
{
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
if (VIA_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s in\n", __FUNCTION__);
/* GL_EXT_blend_equation_separate not supported */
ASSERT(rgbMode == aMode);
/* Can only do GL_ADD equation in hardware */
FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_BLEND_EQ, rgbMode != GL_FUNC_ADD_EXT);
FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_BLEND_EQ,
rgbMode != GL_FUNC_ADD_EXT);
/* BlendEquation sets ColorLogicOpEnabled in an unexpected
* manner.
@@ -557,14 +556,14 @@ static void viaBlendEquationSeparate(GLcontext *ctx, GLenum rgbMode, GLenum aMod
FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_LOGICOP,
(ctx->Color.ColorLogicOpEnabled &&
ctx->Color.LogicOp != GL_COPY));
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
}
static void viaBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
GLboolean fallback = GL_FALSE;
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
if (VIA_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s in\n", __FUNCTION__);
switch (ctx->Color.BlendSrcRGB) {
case GL_SRC_ALPHA_SATURATE:
@@ -590,7 +589,6 @@ static void viaBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
}
FALLBACK(vmesa, VIA_FALLBACK_BLEND_FUNC, fallback);
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
}
/* Shouldn't be called as the extension is disabled.
@@ -615,13 +613,14 @@ static void viaBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
static void viaScissor(GLcontext *ctx, GLint x, GLint y,
GLsizei w, GLsizei h)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (!vmesa->driDrawable)
return;
if (VIA_DEBUG)
fprintf(stderr, "%s %d,%d %dx%d, drawH %d\n", __FUNCTION__, x,y,w,h, vmesa->driDrawable->h);
if (VIA_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s %d,%d %dx%d, drawH %d\n", __FUNCTION__,
x,y,w,h, vmesa->driDrawable->h);
if (vmesa->scissor) {
VIA_FLUSH_DMA(vmesa); /* don't pipeline cliprect changes */
@@ -631,13 +630,11 @@ static void viaScissor(GLcontext *ctx, GLint x, GLint y,
vmesa->scissorRect.y1 = vmesa->driDrawable->h - y - h;
vmesa->scissorRect.x2 = x + w;
vmesa->scissorRect.y2 = vmesa->driDrawable->h - y;
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
}
static void viaEnable(GLcontext *ctx, GLenum cap, GLboolean state)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
switch (cap) {
case GL_SCISSOR_TEST:
@@ -661,8 +658,11 @@ static void viaRenderMode(GLcontext *ctx, GLenum mode)
static void viaDrawBuffer(GLcontext *ctx, GLenum mode)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (VIA_DEBUG & (DEBUG_DRI|DEBUG_STATE))
fprintf(stderr, "%s in\n", __FUNCTION__);
if (mode == GL_FRONT) {
VIA_FLUSH_DMA(vmesa);
vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
@@ -686,14 +686,11 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode)
* gets called.
*/
_swrast_DrawBuffer(ctx, mode);
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
}
static void viaClearColor(GLcontext *ctx, const GLfloat color[4])
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
GLubyte pcolor[4];
CLAMPED_FLOAT_TO_UBYTE(pcolor[0], color[0]);
CLAMPED_FLOAT_TO_UBYTE(pcolor[1], color[1]);
@@ -702,7 +699,6 @@ static void viaClearColor(GLcontext *ctx, const GLfloat color[4])
vmesa->ClearColor = viaPackColor(vmesa->viaScreen->bitsPerPixel,
pcolor[0], pcolor[1],
pcolor[2], pcolor[3]);
}
#define WRITEMASK_ALPHA_SHIFT 31
@@ -714,9 +710,9 @@ static void viaColorMask(GLcontext *ctx,
GLboolean r, GLboolean g,
GLboolean b, GLboolean a)
{
viaContextPtr vmesa = VIA_CONTEXT( ctx );
struct via_context *vmesa = VIA_CONTEXT( ctx );
if (VIA_DEBUG)
if (VIA_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a);
vmesa->ClearMask = (((!r) << WRITEMASK_RED_SHIFT) |
@@ -736,7 +732,7 @@ static void viaColorMask(GLcontext *ctx,
*/
void viaCalcViewport(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
const GLfloat *v = ctx->Viewport._WindowMap.m;
GLfloat *m = vmesa->ViewportMatrix.m;
@@ -765,30 +761,9 @@ static void viaDepthRange(GLcontext *ctx,
viaCalcViewport(ctx);
}
#if 0
static void
flip_bytes( GLubyte *p, GLuint n )
{
register GLuint i, a, b;
for (i=0;i<n;i++) {
b = (GLuint) p[i]; /* words are often faster than bytes */
a = ((b & 0x01) << 7) |
((b & 0x02) << 5) |
((b & 0x04) << 3) |
((b & 0x08) << 1) |
((b & 0x10) >> 1) |
((b & 0x20) >> 3) |
((b & 0x40) >> 5) |
((b & 0x80) >> 7);
p[i] = (GLubyte) a;
}
}
#endif
void viaInitState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
vmesa->regCmdB = HC_ACMD_HCmdB;
vmesa->regEnable = HC_HenCW_MASK;
@@ -850,199 +825,164 @@ get_wrap_mode( GLenum sWrap, GLenum tWrap )
return v;
}
static u_int32_t
get_minmag_filter( GLenum min, GLenum mag )
{
u_int32_t v = 0;
switch (min) {
case GL_NEAREST:
v = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
break;
case GL_LINEAR:
v = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
break;
case GL_NEAREST_MIPMAP_NEAREST:
v = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
v |= HC_HTXnFLDs_Nearest;
break;
case GL_LINEAR_MIPMAP_NEAREST:
v = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
v |= HC_HTXnFLDs_Nearest;
break;
case GL_NEAREST_MIPMAP_LINEAR:
v = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
v |= HC_HTXnFLDs_Linear;
break;
case GL_LINEAR_MIPMAP_LINEAR:
v = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
v |= HC_HTXnFLDs_Linear;
break;
default:
break;
}
switch (mag) {
case GL_LINEAR:
v |= HC_HTXnFLSe_Linear |
HC_HTXnFLTe_Linear;
break;
case GL_NEAREST:
v |= HC_HTXnFLSe_Nearest |
HC_HTXnFLTe_Nearest;
break;
default:
break;
}
return v;
}
static GLboolean viaChooseTextureState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0];
struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1];
/*=* John Sheng [2003.7.18] texture combine *=*/
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (texUnit0->_ReallyEnabled || texUnit1->_ReallyEnabled) {
if (VIA_DEBUG) {
fprintf(stderr, "Texture._ReallyEnabled - in\n");
fprintf(stderr, "texUnit0->_ReallyEnabled = %x\n",texUnit0->_ReallyEnabled);
}
if (VIA_DEBUG) {
struct gl_texture_object *texObj0 = texUnit0->_Current;
struct gl_texture_object *texObj1 = texUnit1->_Current;
fprintf(stderr, "env mode: 0x%04x / 0x%04x\n", texUnit0->EnvMode, texUnit1->EnvMode);
if ( (texObj0 != NULL) && (texObj0->Image[0][0] != NULL) )
fprintf(stderr, "format 0: 0x%04x\n", texObj0->Image[0][0]->Format);
if ( (texObj1 != NULL) && (texObj1->Image[0][0] != NULL) )
fprintf(stderr, "format 1: 0x%04x\n", texObj1->Image[0][0]->Format);
}
vmesa->regEnable |= HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK;
if (texUnit0->_ReallyEnabled) {
struct gl_texture_object *texObj = texUnit0->_Current;
if (VIA_DEBUG) fprintf(stderr, "texUnit0->_ReallyEnabled\n");
vmesa->regEnable |= HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK;
switch (texObj->MinFilter) {
case GL_NEAREST:
vmesa->regHTXnTB_0 = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
break;
case GL_LINEAR:
vmesa->regHTXnTB_0 = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
break;
case GL_NEAREST_MIPMAP_NEAREST:
vmesa->regHTXnTB_0 = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
vmesa->regHTXnTB_0 |= HC_HTXnFLDs_Nearest;
break;
case GL_LINEAR_MIPMAP_NEAREST:
vmesa->regHTXnTB_0 = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
vmesa->regHTXnTB_0 |= HC_HTXnFLDs_Nearest;
break;
case GL_NEAREST_MIPMAP_LINEAR:
vmesa->regHTXnTB_0 = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
vmesa->regHTXnTB_0 |= HC_HTXnFLDs_Linear;
break;
case GL_LINEAR_MIPMAP_LINEAR:
vmesa->regHTXnTB_0 = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
vmesa->regHTXnTB_0 |= HC_HTXnFLDs_Linear;
break;
default:
break;
}
vmesa->regHTXnTB[0] = get_minmag_filter( texObj->MinFilter,
texObj->MagFilter );
switch (texObj->MagFilter) {
case GL_LINEAR:
vmesa->regHTXnTB_0 |= HC_HTXnFLSe_Linear |
HC_HTXnFLTe_Linear;
break;
case GL_NEAREST:
vmesa->regHTXnTB_0 |= HC_HTXnFLSe_Nearest |
HC_HTXnFLTe_Nearest;
break;
default:
break;
}
vmesa->regHTXnMPMD_0 &= ~(HC_HTXnMPMD_SMASK | HC_HTXnMPMD_TMASK);
vmesa->regHTXnMPMD_0 |= get_wrap_mode( texObj->WrapS,
vmesa->regHTXnMPMD[0] &= ~(HC_HTXnMPMD_SMASK | HC_HTXnMPMD_TMASK);
vmesa->regHTXnMPMD[0] |= get_wrap_mode( texObj->WrapS,
texObj->WrapT );
if (VIA_DEBUG) fprintf(stderr, "texUnit0->EnvMode %x\n",texUnit0->EnvMode);
vmesa->regHTXnTB[0] &= ~(HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
if (texObj->Image[0][texObj->BaseLevel]->Border > 0) {
vmesa->regHTXnTB[0] |= (HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
vmesa->regHTXnTBC[0] =
PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->BorderColor[0]),
FLOAT_TO_UBYTE(texObj->BorderColor[1]),
FLOAT_TO_UBYTE(texObj->BorderColor[2]));
vmesa->regHTXnTRAH[0] = FLOAT_TO_UBYTE(texObj->BorderColor[3]);
}
if (!viaTexCombineState( vmesa, texUnit0->_CurrentCombine, 0 ))
if (texUnit0->LodBias != 0.0f) {
GLuint b = viaComputeLodBias(texUnit0->LodBias);
vmesa->regHTXnTB[0] &= ~HC_HTXnFLDs_MASK;
vmesa->regHTXnTB[0] |= HC_HTXnFLDs_ConstLOD;
vmesa->regHTXnCLOD[0] = b | ((~b&0x1f)<<10); /* FIXME */
}
if (!viaTexCombineState( vmesa, texUnit0->_CurrentCombine, 0 )) {
if (VIA_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "viaTexCombineState failed for unit 0\n");
return GL_FALSE;
}
}
if (texUnit1->_ReallyEnabled) {
struct gl_texture_object *texObj = texUnit1->_Current;
vmesa->regEnable |= HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK;
switch (texObj->MinFilter) {
case GL_NEAREST:
vmesa->regHTXnTB_1 = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
break;
case GL_LINEAR:
vmesa->regHTXnTB_1 = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
break;
case GL_NEAREST_MIPMAP_NEAREST:
vmesa->regHTXnTB_1 = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
vmesa->regHTXnTB_1 |= HC_HTXnFLDs_Nearest;
break ;
case GL_LINEAR_MIPMAP_NEAREST:
vmesa->regHTXnTB_1 = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
vmesa->regHTXnTB_1 |= HC_HTXnFLDs_Nearest;
break ;
case GL_NEAREST_MIPMAP_LINEAR:
vmesa->regHTXnTB_1 = HC_HTXnFLSs_Nearest |
HC_HTXnFLTs_Nearest;
vmesa->regHTXnTB_1 |= HC_HTXnFLDs_Linear;
break ;
case GL_LINEAR_MIPMAP_LINEAR:
vmesa->regHTXnTB_1 = HC_HTXnFLSs_Linear |
HC_HTXnFLTs_Linear;
vmesa->regHTXnTB_1 |= HC_HTXnFLDs_Linear;
break ;
default:
break;
}
switch(texObj->MagFilter) {
case GL_LINEAR:
vmesa->regHTXnTB_1 |= HC_HTXnFLSe_Linear |
HC_HTXnFLTe_Linear;
break;
case GL_NEAREST:
vmesa->regHTXnTB_1 |= HC_HTXnFLSe_Nearest |
HC_HTXnFLTe_Nearest;
break;
default:
break;
}
vmesa->regHTXnMPMD_1 &= ~(HC_HTXnMPMD_SMASK | HC_HTXnMPMD_TMASK);
vmesa->regHTXnMPMD_1 |= get_wrap_mode( texObj->WrapS,
vmesa->regHTXnTB[1] = get_minmag_filter( texObj->MinFilter,
texObj->MagFilter );
vmesa->regHTXnMPMD[1] &= ~(HC_HTXnMPMD_SMASK | HC_HTXnMPMD_TMASK);
vmesa->regHTXnMPMD[1] |= get_wrap_mode( texObj->WrapS,
texObj->WrapT );
if (!viaTexCombineState( vmesa, texUnit1->_CurrentCombine, 1 ))
vmesa->regHTXnTB[1] &= ~(HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
if (texObj->Image[0][texObj->BaseLevel]->Border > 0) {
vmesa->regHTXnTB[1] |= (HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
vmesa->regHTXnTBC[1] =
PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->BorderColor[0]),
FLOAT_TO_UBYTE(texObj->BorderColor[1]),
FLOAT_TO_UBYTE(texObj->BorderColor[2]));
vmesa->regHTXnTRAH[1] = FLOAT_TO_UBYTE(texObj->BorderColor[3]);
}
if (texUnit1->LodBias != 0.0f) {
GLuint b = viaComputeLodBias(texUnit1->LodBias);
vmesa->regHTXnTB[1] &= ~HC_HTXnFLDs_MASK;
vmesa->regHTXnTB[1] |= HC_HTXnFLDs_ConstLOD;
vmesa->regHTXnCLOD[1] = b | ((~b&0x1f)<<10); /* FIXME */
}
if (!viaTexCombineState( vmesa, texUnit1->_CurrentCombine, 1 )) {
if (VIA_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "viaTexCombineState failed for unit 1\n");
return GL_FALSE;
}
}
if (VIA_DEBUG) {
fprintf( stderr, "Csat_0 / Cop_0 = 0x%08x / 0x%08x\n",
vmesa->regHTXnTBLCsat_0, vmesa->regHTXnTBLCop_0 );
fprintf( stderr, "Asat_0 = 0x%08x\n",
vmesa->regHTXnTBLAsat_0 );
fprintf( stderr, "RCb_0 / RAa_0 = 0x%08x / 0x%08x\n",
vmesa->regHTXnTBLRCb_0, vmesa->regHTXnTBLRAa_0 );
fprintf( stderr, "RCa_0 / RCc_0 = 0x%08x / 0x%08x\n",
vmesa->regHTXnTBLRCa_0, vmesa->regHTXnTBLRCc_0 );
fprintf( stderr, "RCbias_0 = 0x%08x\n",
vmesa->regHTXnTBLRCbias_0 );
}
}
else {
vmesa->regEnable &= (~(HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK));
vmesa->regEnable &= ~(HC_HenTXMP_MASK | HC_HenTXCH_MASK |
HC_HenTXPP_MASK);
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
return GL_TRUE;
}
static void viaChooseColorState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
GLenum s = ctx->Color.BlendSrcRGB;
GLenum d = ctx->Color.BlendDstRGB;
/* The HW's blending equation is:
* (Ca * FCa + Cbias + Cb * FCb) << Cshift
*/
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (ctx->Color.BlendEnabled) {
vmesa->regEnable |= HC_HenABL_MASK;
/* Ca -- always from source color.
*/
vmesa->regHABLCsat = HC_HABLCsat_MASK | HC_HABLCa_OPC |
HC_HABLCa_Csrc;
vmesa->regHABLCsat = HC_HABLCsat_MASK | HC_HABLCa_OPC | HC_HABLCa_Csrc;
/* Aa -- always from source alpha.
*/
vmesa->regHABLAsat = HC_HABLAsat_MASK | HC_HABLAa_OPA |
HC_HABLAa_Asrc;
vmesa->regHABLAsat = HC_HABLAsat_MASK | HC_HABLAa_OPA | HC_HABLAa_Asrc;
/* FCa -- depend on following condition.
* FAa -- depend on following condition.
*/
@@ -1104,8 +1044,10 @@ static void viaChooseColorState(GLcontext *ctx)
if (vmesa->viaScreen->bitsPerPixel == 16) {
/* (1, 1, 1, 1)
*/
vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_HABLRCa;
vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_HABLFRA;
vmesa->regHABLCsat |= (HC_HABLFCa_InvOPC |
HC_HABLFCa_HABLRCa);
vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA |
HC_HABLFAa_HABLFRA);
vmesa->regHABLRFCa = 0x0;
vmesa->regHABLRAa = 0x0;
}
@@ -1142,15 +1084,18 @@ static void viaChooseColorState(GLcontext *ctx)
* So (f, f, f, 1) = (0, 0, 0, 1)
*/
vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_HABLRCa;
vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_HABLFRA;
vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA |
HC_HABLFAa_HABLFRA);
vmesa->regHABLRFCa = 0x0;
vmesa->regHABLRAa = 0x0;
}
else {
/* (f, f, f, 1), f = min(As, 1 - Ad)
*/
vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_mimAsrcInvAdst;
vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_HABLFRA;
vmesa->regHABLCsat |= (HC_HABLFCa_OPC |
HC_HABLFCa_mimAsrcInvAdst);
vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA |
HC_HABLFAa_HABLFRA);
vmesa->regHABLRFCa = 0x0;
vmesa->regHABLRAa = 0x0;
}
@@ -1314,13 +1259,11 @@ static void viaChooseColorState(GLcontext *ctx)
vmesa->regEnable |= HC_HenAW_MASK;
else
vmesa->regEnable &= ~HC_HenAW_MASK;
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
static void viaChooseFogState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (ctx->Fog.Enabled) {
GLubyte r, g, b, a;
@@ -1345,7 +1288,7 @@ static void viaChooseFogState(GLcontext *ctx)
static void viaChooseDepthState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (ctx->Depth.Test) {
vmesa->regEnable |= HC_HenZT_MASK;
if (ctx->Depth.Mask)
@@ -1369,16 +1312,7 @@ static void viaChooseDepthState(GLcontext *ctx)
static void viaChooseLineState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (ctx->Line.SmoothFlag) {
vmesa->regEnable |= HC_HenAA_MASK;
}
else {
if (!ctx->Polygon.SmoothFlag) {
vmesa->regEnable &= ~HC_HenAA_MASK;
}
}
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (ctx->Line.StippleFlag) {
vmesa->regEnable |= HC_HenLP_MASK;
@@ -1392,18 +1326,7 @@ static void viaChooseLineState(GLcontext *ctx)
static void viaChoosePolygonState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
/* KW: FIXME: this should be in viaRasterPrimitive (somehow)
*/
if (ctx->Polygon.SmoothFlag) {
vmesa->regEnable |= HC_HenAA_MASK;
}
else {
if (!ctx->Line.SmoothFlag) {
vmesa->regEnable &= ~HC_HenAA_MASK;
}
}
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (ctx->Polygon.StippleFlag) {
vmesa->regEnable |= HC_HenSP_MASK;
@@ -1422,8 +1345,7 @@ static void viaChoosePolygonState(GLcontext *ctx)
static void viaChooseStencilState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (ctx->Stencil.Enabled) {
GLuint temp;
@@ -1503,23 +1425,14 @@ static void viaChooseStencilState(GLcontext *ctx)
else {
vmesa->regEnable &= ~HC_HenST_MASK;
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
static void viaChooseTriangle(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (VIA_DEBUG) {
fprintf(stderr, "%s - in\n", __FUNCTION__);
fprintf(stderr, "GL_CULL_FACE = %x\n", GL_CULL_FACE);
fprintf(stderr, "ctx->Polygon.CullFlag = %x\n", ctx->Polygon.CullFlag);
fprintf(stderr, "GL_FRONT = %x\n", GL_FRONT);
fprintf(stderr, "ctx->Polygon.CullFaceMode = %x\n", ctx->Polygon.CullFaceMode);
fprintf(stderr, "GL_CCW = %x\n", GL_CCW);
fprintf(stderr, "ctx->Polygon.FrontFace = %x\n", ctx->Polygon.FrontFace);
}
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (ctx->Polygon.CullFlag == GL_TRUE) {
switch (ctx->Polygon.CullFaceMode) {
case GL_FRONT:
@@ -1538,13 +1451,12 @@ static void viaChooseTriangle(GLcontext *ctx)
return;
}
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
void viaValidateState( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (vmesa->newState & _NEW_TEXTURE) {
GLboolean ok = (viaChooseTextureState(ctx) &&
viaUpdateTextureState(ctx));
@@ -1577,13 +1489,20 @@ void viaValidateState( GLcontext *ctx )
else
vmesa->regEnable &= ~HC_HenCS_MASK;
if (ctx->Point.SmoothFlag ||
ctx->Line.SmoothFlag ||
ctx->Polygon.SmoothFlag)
vmesa->regEnable |= HC_HenAA_MASK;
else
vmesa->regEnable &= ~HC_HenAA_MASK;
vmesa->newEmitState |= vmesa->newState;
vmesa->newState = 0;
}
static void viaInvalidateState(GLcontext *ctx, GLuint newState)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
VIA_FINISH_PRIM( vmesa );
vmesa->newState |= newState;

View File

@@ -31,9 +31,9 @@ extern void viaInitState(GLcontext *ctx);
extern void viaInitStateFuncs(GLcontext *ctx);
extern void viaCalcViewport(GLcontext *ctx);
extern void viaValidateState(GLcontext *ctx);
extern void viaEmitState(viaContextPtr vmesa);
extern void viaEmitState(struct via_context *vmesa);
extern void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode);
extern void viaFallback(struct via_context *vmesa, GLuint bit, GLboolean mode);
#define FALLBACK(vmesa, bit, mode) viaFallback(vmesa, bit, mode)
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -27,86 +27,11 @@
#define _VIATEX_H
#include "mtypes.h"
#include "mm.h"
#include "via_context.h"
#include "via_3d_reg.h"
struct via_context;
#define VIA_TEX_MAXLEVELS 10
/* For shared texture space managment, these texture objects may also
* be used as proxies for regions of texture memory containing other
* client's textures. Such proxy textures (not to be confused with GL
* proxy textures) are subject to the same LRU aging we use for our
* own private textures, and thus we have a mechanism where we can
* fairly decide between kicking out our own textures and those of
* other clients.
*
* Non-local texture objects have a valid MemBlock to describe the
* region managed by the other client, and can be identified by
* 't->globj == 0'
*/
struct via_texture_object_t {
struct via_texture_object_t *next, *prev;
GLuint age;
struct gl_texture_object *globj;
int texelBytes;
int totalSize;
struct {
GLuint index;
GLuint offset;
GLuint size;
} texMem;
unsigned char* bufAddr;
GLuint inAGP;
GLuint needClearCache;
GLuint actualLevel;
GLuint maxLevel;
GLuint dirtyImages;
struct {
const struct gl_texture_image *image;
int offset; /* into bufAddr */
int height;
int internalFormat;
} image[VIA_TEX_MAXLEVELS];
GLuint dirty;
GLuint regTexFM;
GLuint regTexWidthLog2[2];
GLuint regTexHeightLog2[2];
GLuint regTexBaseH[4];
struct {
GLuint baseL;
GLuint pitchLog2;
} regTexBaseAndPitch[12];
GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */
};
viaTextureObjectPtr viaAllocTextureObject(struct gl_texture_object *texObj);
GLboolean viaUpdateTextureState(GLcontext *ctx);
void viaInitTextureFuncs(struct dd_function_table * functions);
void viaInitTextures(GLcontext *ctx);
void viaDestroyTexObj(viaContextPtr vmesa, viaTextureObjectPtr t);
void viaSwapOutTexObj(viaContextPtr vmesa, viaTextureObjectPtr t);
void viaUploadTexImages(viaContextPtr vmesa, viaTextureObjectPtr t);
void viaResetGlobalLRU(viaContextPtr vmesa);
void viaTexturesGone(viaContextPtr vmesa,
GLuint start, GLuint end,
GLuint in_use);
void viaPrintLocalLRU(viaContextPtr vmesa);
void viaPrintGlobalLRU(viaContextPtr vmesa);
void viaUpdateTexLRU(viaContextPtr vmesa, viaTextureObjectPtr t);
GLboolean viaSwapOutWork( struct via_context *vmesa );
#endif

View File

@@ -36,21 +36,12 @@
#include "macros.h"
#include "colormac.h"
#include "enums.h"
#include "dd.h"
#include "mm.h"
#include "via_context.h"
#include "via_state.h"
#include "via_tex.h"
#include "via_tris.h"
#include "via_ioctl.h"
#include "via_3d_reg.h"
#include "swrast/swrast.h"
#include "array_cache/acache.h"
#include "tnl/tnl.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/t_pipeline.h"
#define VIA_USE_ALPHA (HC_XTC_Adif - HC_XTC_Dif)
@@ -90,24 +81,18 @@ static const unsigned a_shift_table[3] = {
* Calculate the hardware state for the specified texture combine mode
*
* \bug
* For the alpha combine, \c GL_CONSTANT is still probably wrong.
*
* \bug
* All forms of DOT3 bumpmapping are completely untested, and are most
* likely wrong.
*
* \bug
* This code still fails progs/demos/texenv for all modes with \c GL_ALPHA
* textures. This was also the case with the code that Via supplied. It
* also fails for \c GL_REPLACE with \c GL_RGBA textures. Everything else
* that texenv tests looks good.
* likely wrong. KW: Looks like it will never be quite right as the
* hardware seems to experience overflow in color calculation at the
* 4x shift levels, which need to be programed for DOT3. Maybe newer
* hardware fixes these issues.
*
* \bug
* KW: needs attention to the case where texunit 1 is enabled but
* texunit 0 is not.
*/
GLboolean
viaTexCombineState( viaContextPtr vmesa,
viaTexCombineState( struct via_context *vmesa,
const struct gl_tex_env_combine_state * combine,
unsigned unit )
{
@@ -126,7 +111,8 @@ viaTexCombineState( viaContextPtr vmesa,
unsigned constant_alpha[3];
unsigned bias_alpha = 0;
unsigned abc_alpha = 0;
const struct gl_texture_unit const * texUnit = & vmesa->glCtx->Texture.Unit[unit];
const struct gl_texture_unit const * texUnit =
&vmesa->glCtx->Texture.Unit[unit];
unsigned env_color[4];
/* It seems that the color clamping can be overwhelmed at the 4x
@@ -329,7 +315,9 @@ viaTexCombineState( viaContextPtr vmesa,
case GL_PREVIOUS:
alpha_arg[i] = (unit == 0) ? HC_XTA_Adif : HC_XTA_Acur;
alpha_arg[i] += alpha_operand_modifier[op];
bias_alpha_arg[i] = (unit == 0) ? HC_HTXnTBLAbias_Adif : HC_HTXnTBLAbias_Acur;
bias_alpha_arg[i] = (unit == 0 ?
HC_HTXnTBLAbias_Adif :
HC_HTXnTBLAbias_Acur);
bias_alpha_arg[i] += bias_alpha_operand_modifier[op];
break;
}
@@ -418,34 +406,18 @@ viaTexCombineState( viaContextPtr vmesa,
op |= c_shift_table[ c_shift ] | a_shift_table[ a_shift ];
if ( unit == 0 ) {
vmesa->regHTXnTBLMPfog_0 = HC_HTXnTBLMPfog_Fog;
vmesa->regHTXnTBLMPfog[unit] = HC_HTXnTBLMPfog_Fog;
vmesa->regHTXnTBLCsat_0 = color;
vmesa->regHTXnTBLAsat_0 = alpha;
vmesa->regHTXnTBLCop_0 = op | bias;
vmesa->regHTXnTBLRAa_0 = abc_alpha;
vmesa->regHTXnTBLRFog_0 = bias_alpha;
vmesa->regHTXnTBLCsat[unit] = color;
vmesa->regHTXnTBLAsat[unit] = alpha;
vmesa->regHTXnTBLCop[unit] = op | bias;
vmesa->regHTXnTBLRAa[unit] = abc_alpha;
vmesa->regHTXnTBLRFog[unit] = bias_alpha;
vmesa->regHTXnTBLRCa_0 = ordered_constant_color[0];
vmesa->regHTXnTBLRCb_0 = ordered_constant_color[1];
vmesa->regHTXnTBLRCc_0 = ordered_constant_color[2];
vmesa->regHTXnTBLRCbias_0 = ordered_constant_color[3];
}
else {
vmesa->regHTXnTBLMPfog_1 = HC_HTXnTBLMPfog_Fog;
vmesa->regHTXnTBLCsat_1 = color;
vmesa->regHTXnTBLAsat_1 = alpha;
vmesa->regHTXnTBLCop_1 = op | bias;
vmesa->regHTXnTBLRAa_1 = abc_alpha;
vmesa->regHTXnTBLRFog_1 = bias_alpha;
vmesa->regHTXnTBLRCa_1 = ordered_constant_color[0];
vmesa->regHTXnTBLRCb_1 = ordered_constant_color[1];
vmesa->regHTXnTBLRCc_1 = ordered_constant_color[2];
vmesa->regHTXnTBLRCbias_1 = ordered_constant_color[3];
}
vmesa->regHTXnTBLRCa[unit] = ordered_constant_color[0];
vmesa->regHTXnTBLRCb[unit] = ordered_constant_color[1];
vmesa->regHTXnTBLRCc[unit] = ordered_constant_color[2];
vmesa->regHTXnTBLRCbias[unit] = ordered_constant_color[3];
return GL_TRUE;
}

View File

@@ -1,453 +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 <stdlib.h>
#include <stdio.h>
#include "glheader.h"
#include "macros.h"
#include "mtypes.h"
#include "simple_list.h"
#include "enums.h"
#include "texformat.h"
#include "mm.h"
#include "via_context.h"
#include "via_tex.h"
#include "via_state.h"
#include "via_ioctl.h"
#include "via_fb.h"
/*=* John Sheng [2003.5.31] agp tex *=*/
void viaDestroyTexObj(viaContextPtr vmesa, viaTextureObjectPtr t)
{
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (!t)
return;
/* This is sad - need to sync *in case* we upload a texture
* to this newly free memory...
*/
if (t->bufAddr) {
via_free_texture(vmesa, t);
if (vmesa && t->age > vmesa->dirtyAge)
vmesa->dirtyAge = t->age;
}
if (t->globj)
t->globj->DriverData = 0;
if (vmesa) {
if (vmesa->CurrentTexObj[0] == t) {
vmesa->CurrentTexObj[0] = 0;
}
if (vmesa->CurrentTexObj[1] == t) {
vmesa->CurrentTexObj[1] = 0;
}
}
remove_from_list(t);
free(t);
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
void viaSwapOutTexObj(viaContextPtr vmesa, viaTextureObjectPtr t)
{
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
if (t->bufAddr) {
via_free_texture(vmesa, t);
if (t->age > vmesa->dirtyAge)
vmesa->dirtyAge = t->age;
}
t->dirtyImages = ~0;
move_to_tail(&(vmesa->SwappedOut), t);
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
/* Upload an image from mesa's internal copy.
*/
static void viaUploadTexLevel(viaTextureObjectPtr t, int level)
{
const struct gl_texture_image *image = t->image[level].image;
int i, j;
if (VIA_DEBUG) {
fprintf(stderr, "%s - in\n", __FUNCTION__);
fprintf(stderr, "width = %d, height = %d \n", image->Width, image->Height);
}
switch (t->image[level].internalFormat) {
case GL_RGB:
{
if (image->TexFormat->MesaFormat == MESA_FORMAT_ARGB8888) {
GLuint *dst = (GLuint *)(t->bufAddr + t->image[level].offset);
GLuint *src = (GLuint *)image->Data;
if (VIA_DEBUG) fprintf(stderr, "GL_RGB MESA_FORMAT_ARGB8888\n");
if (image->Width < 8) {
for (i = 0; i < image->Height ; i++) {
for (j = 0; j < image->Width ; j++) {
dst[j] = *src;
src++;
}
dst += 8;
}
}
else {
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
dst++;
src++;
}
}
/*memcpy(dst, src, image->Height * image->Width * sizeof(GLuint));*/
}
else {
GLushort *dst = (GLushort *)(t->bufAddr + t->image[level].offset);
GLushort *src = (GLushort *)image->Data;
if (VIA_DEBUG) fprintf(stderr, "GL_RGB !MESA_FORMAT_ARGB8888\n");
if (image->Width < 16) {
for (i = 0; i < image->Height ; i++) {
for (j = 0; j < image->Width ; j++) {
dst[j] = *src;
src++;
}
dst += 16;
}
}
else {
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
dst++;
src++;
}
}
/*memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));*/
}
}
break;
case GL_RGBA:
{
if (image->TexFormat->MesaFormat == MESA_FORMAT_ARGB4444) {
GLushort *dst = (GLushort *)(t->bufAddr + t->image[level].offset);
GLushort *src = (GLushort *)image->Data;
if (image->Width < 16) {
for (i = 0; i < image->Height ; i++) {
for (j = 0; j < image->Width ; j++) {
dst[j] = *src;
src++;
}
dst += 16;
}
}
else {
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
src++;
dst++;
}
}
/*memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));*/
if (VIA_DEBUG) fprintf(stderr, "GL_RGBA MESA_FORMAT_ARGB4444\n");
}
else if(image->TexFormat->MesaFormat == MESA_FORMAT_ARGB8888) {
GLuint *dst = (GLuint *)(t->bufAddr + t->image[level].offset);
GLuint *src = (GLuint *)image->Data;
if (VIA_DEBUG) fprintf(stderr, "GL_RGBA !MESA_FORMAT_ARGB4444\n");
if (image->Width < 8) {
for (i = 0; i < image->Height ; i++) {
for (j = 0; j < image->Width ; j++) {
dst[j] = *src;
src++;
}
dst += 8;
}
}
else {
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
dst++;
src++;
}
}
/*memcpy(dst, src, image->Height * image->Width * sizeof(GLuint));*/
}
else if(image->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) {
GLushort *dst = (GLushort *)(t->bufAddr + t->image[level].offset);
GLushort *src = (GLushort *)image->Data;
if (image->Width < 16) {
for (i = 0; i < image->Height ; i++) {
for (j = 0; j < image->Width ; j++) {
dst[j] = *src;
src++;
}
dst += 16;
}
}
else {
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
src++;
dst++;
}
}
/*memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));*/
if (VIA_DEBUG) fprintf(stderr, "GL_RGBA MESA_FORMAT_ARGB1555\n");
}
}
break;
case GL_LUMINANCE:
{
GLubyte *dst = (GLubyte *)(t->bufAddr + t->image[level].offset);
GLubyte *src = (GLubyte *)image->Data;
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
dst++;
src++;
}
}
break;
case GL_INTENSITY:
{
GLubyte *dst = (GLubyte *)(t->bufAddr + t->image[level].offset);
GLubyte *src = (GLubyte *)image->Data;
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
dst++;
src++;
}
}
break;
case GL_LUMINANCE_ALPHA:
{
GLushort *dst = (GLushort *)(t->bufAddr + t->image[level].offset);
GLushort *src = (GLushort *)image->Data;
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
dst++;
src++;
}
}
break;
case GL_ALPHA:
{
GLubyte *dst = (GLubyte *)(t->bufAddr + t->image[level].offset);
GLubyte *src = (GLubyte *)image->Data;
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
dst++;
src++;
}
}
break;
/* TODO: Translate color indices *now*:
*/
case GL_COLOR_INDEX:
{
GLubyte *dst = (GLubyte *)(t->bufAddr + t->image[level].offset);
GLubyte *src = (GLubyte *)image->Data;
for (j = 0; j < image->Height * image->Width; j++) {
*dst = *src;
dst++;
src++;
}
}
break;
default:;
if (VIA_DEBUG) fprintf(stderr, "Not supported texture format %s\n",
_mesa_lookup_enum_by_nr(image->Format));
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
void viaPrintLocalLRU(viaContextPtr vmesa)
{
viaTextureObjectPtr t;
foreach (t, &vmesa->TexObjList) {
if (!t->globj) {
if (VIA_DEBUG) {
fprintf(stderr, "offset = %x, index = %x, size = %x\n",
t->texMem.offset,
t->texMem.index,
t->texMem.size);
}
else {
if (VIA_DEBUG) {
fprintf(stderr, "offset = %x, siez = %x\n",
t->texMem.offset,
t->texMem.size);
}
}
}
}
}
void viaPrintGlobalLRU(viaContextPtr vmesa)
{
int i, j;
drm_via_tex_region_t *list = vmesa->sarea->texList;
for (i = 0, j = VIA_NR_TEX_REGIONS; i < VIA_NR_TEX_REGIONS; i++) {
if (VIA_DEBUG) fprintf(stderr, "list[%d] age %d next %d prev %d\n",
j, list[j].age, list[j].next, list[j].prev);
j = list[j].next;
if (j == VIA_NR_TEX_REGIONS) break;
}
if (j != VIA_NR_TEX_REGIONS)
if (VIA_DEBUG) fprintf(stderr, "Loop detected in global LRU\n");
}
void viaResetGlobalLRU(viaContextPtr vmesa)
{
drm_via_tex_region_t *list = vmesa->sarea->texList;
int sz = 1 << vmesa->viaScreen->logTextureGranularity;
int i;
/* (Re)initialize the global circular LRU list. The last element
* in the array (VIA_NR_TEX_REGIONS) is the sentinal. Keeping it
* at the end of the array allows it to be addressed rationally
* when looking up objects at a particular location in texture
* memory.
*/
for (i = 0; (i + 1) * sz <= vmesa->viaScreen->textureSize; i++) {
list[i].prev = i - 1;
list[i].next = i + 1;
list[i].age = 0;
}
i--;
list[0].prev = VIA_NR_TEX_REGIONS;
list[i].prev = i - 1;
list[i].next = VIA_NR_TEX_REGIONS;
list[VIA_NR_TEX_REGIONS].prev = i;
list[VIA_NR_TEX_REGIONS].next = 0;
vmesa->sarea->texAge = 0;
}
void viaUpdateTexLRU(viaContextPtr vmesa, viaTextureObjectPtr t)
{
vmesa->texAge = ++vmesa->sarea->texAge;
move_to_head(&(vmesa->TexObjList), t);
}
/* Called for every shared texture region which has increased in age
* since we last held the lock.
*
* Figures out which of our textures have been ejected by other clients,
* and pushes a placeholder texture onto the LRU list to represent
* the other client's textures.
*/
void viaTexturesGone(viaContextPtr vmesa,
GLuint offset,
GLuint size,
GLuint inUse)
{
viaTextureObjectPtr t, tmp;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
foreach_s (t, tmp, &vmesa->TexObjList) {
viaSwapOutTexObj(vmesa, t);
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
/* This is called with the lock held. May have to eject our own and/or
* other client's texture objects to make room for the upload.
*/
void viaUploadTexImages(viaContextPtr vmesa, viaTextureObjectPtr t)
{
int i, j;
int numLevels;
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
LOCK_HARDWARE(vmesa);
j = 0;
if (!t->bufAddr) {
while (1) {
/*=* John Sheng [2003.5.31] agp tex *=*/
if (via_alloc_texture_agp(vmesa, t))
break;
if (via_alloc_texture(vmesa, t))
break;
vmesa->agpFullCount++;
if (vmesa->TexObjList.prev == vmesa->CurrentTexObj[0] ||
vmesa->TexObjList.prev == vmesa->CurrentTexObj[1]) {
if (VIA_DEBUG) fprintf(stderr, "Hit bound texture in upload\n");
viaPrintLocalLRU(vmesa);
UNLOCK_HARDWARE(vmesa);
return;
}
if (vmesa->TexObjList.prev == &(vmesa->TexObjList)) {
if (VIA_DEBUG) fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
mmDumpMemInfo(vmesa->texHeap);
UNLOCK_HARDWARE(vmesa);
return;
}
viaSwapOutTexObj(vmesa, vmesa->TexObjList.prev);
}
/*=* John Sheng [2003.5.31] agp tex *=*/
/*t->bufAddr = (char *)((GLuint)vmesa->driScreen->pFB + t->texMem.offset);*/
if (t == vmesa->CurrentTexObj[0])
VIA_FLUSH_DMA(vmesa);
if (t == vmesa->CurrentTexObj[1])
VIA_FLUSH_DMA(vmesa);
viaUpdateTexLRU(vmesa, t);
j++;
}
numLevels = t->lastLevel - t->firstLevel + 1;
for (i = 0; i < numLevels; i++)
if (t->dirtyImages & (1 << i))
viaUploadTexLevel(t, i);
t->dirtyImages = 0;
vmesa->clearTexCache = 1;
UNLOCK_HARDWARE(vmesa);
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}

View File

@@ -42,6 +42,7 @@
#include "via_state.h"
#include "via_span.h"
#include "via_ioctl.h"
#include "via_3d_reg.h"
/***********************************************************************
* Emit primitives as inline vertices *
@@ -68,7 +69,7 @@
} while (0)
#endif
static void via_draw_triangle(viaContextPtr vmesa,
static void via_draw_triangle(struct via_context *vmesa,
viaVertexPtr v0,
viaVertexPtr v1,
viaVertexPtr v2)
@@ -82,7 +83,7 @@ static void via_draw_triangle(viaContextPtr vmesa,
}
static void via_draw_quad(viaContextPtr vmesa,
static void via_draw_quad(struct via_context *vmesa,
viaVertexPtr v0,
viaVertexPtr v1,
viaVertexPtr v2,
@@ -99,7 +100,7 @@ static void via_draw_quad(viaContextPtr vmesa,
COPY_DWORDS(vb, vertsize, v3);
}
static void via_draw_line(viaContextPtr vmesa,
static void via_draw_line(struct via_context *vmesa,
viaVertexPtr v0,
viaVertexPtr v1)
{
@@ -110,7 +111,7 @@ static void via_draw_line(viaContextPtr vmesa,
}
static void via_draw_point(viaContextPtr vmesa,
static void via_draw_point(struct via_context *vmesa,
viaVertexPtr v0)
{
GLuint vertsize = vmesa->vertexSize;
@@ -132,7 +133,7 @@ do { \
tmp.f[vertex_size-1] *= rhw; \
} while (0)
static void via_ptex_tri (viaContextPtr vmesa,
static void via_ptex_tri (struct via_context *vmesa,
viaVertexPtr v0,
viaVertexPtr v1,
viaVertexPtr v2)
@@ -146,7 +147,7 @@ static void via_ptex_tri (viaContextPtr vmesa,
PTEX_VERTEX(tmp, vertsize, v2); COPY_DWORDS(vb, vertsize, &tmp);
}
static void via_ptex_line (viaContextPtr vmesa,
static void via_ptex_line (struct via_context *vmesa,
viaVertexPtr v0,
viaVertexPtr v1)
{
@@ -158,7 +159,7 @@ static void via_ptex_line (viaContextPtr vmesa,
PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp);
}
static void via_ptex_point (viaContextPtr vmesa,
static void via_ptex_point (struct via_context *vmesa,
viaVertexPtr v0)
{
GLuint vertsize = vmesa->hwVertexSize;
@@ -312,7 +313,7 @@ do { \
#define LOCAL_VARS(n) \
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
struct via_context *vmesa = VIA_CONTEXT(ctx); \
GLuint color[n], spec[n]; \
GLuint coloroffset = vmesa->coloroffset; \
GLuint specoffset = vmesa->specoffset; \
@@ -447,7 +448,7 @@ static void init_rast_tab(void)
* primitives.
*/
static void
via_fallback_tri(viaContextPtr vmesa,
via_fallback_tri(struct via_context *vmesa,
viaVertex *v0,
viaVertex *v1,
viaVertex *v2)
@@ -464,7 +465,7 @@ via_fallback_tri(viaContextPtr vmesa,
static void
via_fallback_line(viaContextPtr vmesa,
via_fallback_line(struct via_context *vmesa,
viaVertex *v0,
viaVertex *v1)
{
@@ -479,7 +480,7 @@ via_fallback_line(viaContextPtr vmesa,
static void
via_fallback_point(viaContextPtr vmesa,
via_fallback_point(struct via_context *vmesa,
viaVertex *v0)
{
GLcontext *ctx = vmesa->glCtx;
@@ -492,7 +493,7 @@ via_fallback_point(viaContextPtr vmesa,
static void viaResetLineStipple( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
vmesa->regCmdB |= HC_HLPrst_MASK;
}
@@ -509,7 +510,7 @@ static void viaResetLineStipple( GLcontext *ctx )
#define INIT(x) viaRasterPrimitive(ctx, x, hwPrim[x])
#undef LOCAL_VARS
#define LOCAL_VARS \
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
struct via_context *vmesa = VIA_CONTEXT(ctx); \
GLubyte *vertptr = (GLubyte *)vmesa->verts; \
const GLuint vertsize = vmesa->vertexSize; \
const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
@@ -572,7 +573,7 @@ static void viaRenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj)
static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
GLuint n)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
GLuint vertsize = vmesa->vertexSize;
GLuint *vb = viaExtendPrimitive(vmesa, (n - 2) * 3 * 4 * vertsize);
GLubyte *vertptr = (GLubyte *)vmesa->verts;
@@ -615,7 +616,7 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
static void viaChooseRenderState(GLcontext *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
GLuint flags = ctx->_TriangleCaps;
GLuint index = 0;
@@ -702,7 +703,7 @@ do { \
static void viaChooseVertexState( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *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;
@@ -723,13 +724,15 @@ static void viaChooseVertexState( GLcontext *ctx )
}
/* t_context.c always includes a diffuse color */
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VIA_EMIT_RGBA, HC_HVPMSK_Cd );
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 );
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VIA_EMIT_SPEC,
HC_HVPMSK_Cs );
}
else
EMIT_PAD( 3 );
@@ -742,13 +745,16 @@ static void viaChooseVertexState( GLcontext *ctx )
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) );
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) );
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, (HC_HVPMSK_S | HC_HVPMSK_T) );
EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, VIA_EMIT_TEX1,
(HC_HVPMSK_S | HC_HVPMSK_T) );
}
if (setupIndex != vmesa->setupIndex) {
@@ -806,7 +812,7 @@ static GLboolean viaCheckPTexHack( GLcontext *ctx )
static void viaRenderStart(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
@@ -852,20 +858,22 @@ void viaRasterPrimitive(GLcontext *ctx,
GLenum glprim,
GLenum hwprim)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
GLuint regCmdB;
RING_VARS;
if (VIA_DEBUG)
fprintf(stderr, "%s: %s/%s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(glprim),
if (VIA_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s: %s/%s\n",
__FUNCTION__, _mesa_lookup_enum_by_nr(glprim),
_mesa_lookup_enum_by_nr(hwprim));
vmesa->renderPrimitive = glprim;
if (hwprim != vmesa->hwPrimitive) {
VIA_FINISH_PRIM(vmesa);
viaCheckDma( vmesa, 1024 ); /* Ensure no wrapping inside this function */
/* Ensure no wrapping inside this function */
viaCheckDma( vmesa, 1024 );
if (vmesa->newEmitState) {
viaEmitState(vmesa);
@@ -882,10 +890,12 @@ void viaRasterPrimitive(GLcontext *ctx,
switch (hwprim) {
case GL_POINTS:
vmesa->regCmdA_End |= HC_HPMType_Point | HC_HVCycle_Full;
vmesa->regCmdA_End |= HC_HShading_Gouraud; /* always Gouraud shade points?!? */
vmesa->regCmdA_End |= HC_HShading_Gouraud; /* always Gouraud
shade points?!? */
break;
case GL_LINES:
vmesa->regCmdA_End |= HC_HPMType_Line | HC_HVCycle_Full;
regCmdB |= HC_HLPrst_MASK;
if (ctx->Light.ShadeModel == GL_FLAT)
vmesa->regCmdA_End |= HC_HShading_FlatB;
break;
@@ -937,7 +947,8 @@ void viaRasterPrimitive(GLcontext *ctx,
/* assert((vmesa->dmaLow & 0x4) == 0); */
if (vmesa->dmaCliprectAddr == ~0) {
if (VIA_DEBUG) fprintf(stderr, "reserve cliprect space at %x\n", vmesa->dmaLow);
if (VIA_DEBUG & DEBUG_DMA)
fprintf(stderr, "reserve cliprect space at %x\n", vmesa->dmaLow);
vmesa->dmaCliprectAddr = vmesa->dmaLow;
BEGIN_RING(8);
OUT_RING( HC_HEADER2 );
@@ -981,16 +992,17 @@ static void viaRenderPrimitive( GLcontext *ctx, GLuint prim )
}
void viaFinishPrimitive(viaContextPtr vmesa)
void viaFinishPrimitive(struct via_context *vmesa)
{
if (VIA_DEBUG)
if (VIA_DEBUG & (DEBUG_DMA|DEBUG_PRIMS))
fprintf(stderr, "%s\n", __FUNCTION__);
if (!vmesa->dmaLastPrim || vmesa->dmaCliprectAddr == ~0) {
assert(0);
}
else if (vmesa->dmaLow != vmesa->dmaLastPrim) {
GLuint cmdA = vmesa->regCmdA_End | HC_HPLEND_MASK | HC_HPMValidN_MASK | HC_HE3Fire_MASK;
GLuint cmdA = (vmesa->regCmdA_End | HC_HPLEND_MASK |
HC_HPMValidN_MASK | HC_HE3Fire_MASK);
RING_VARS;
vmesa->dmaLastPrim = 0;
@@ -1013,7 +1025,7 @@ void viaFinishPrimitive(viaContextPtr vmesa)
viaFlushDma( vmesa );
}
else {
if (VIA_DEBUG)
if (VIA_DEBUG & (DEBUG_DMA|DEBUG_PRIMS))
fprintf(stderr, "remove empty primitive\n");
/* Remove the primitive header:
@@ -1040,19 +1052,20 @@ void viaFinishPrimitive(viaContextPtr vmesa)
/**********************************************************************/
void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
void viaFallback(struct via_context *vmesa, GLuint bit, GLboolean mode)
{
GLcontext *ctx = vmesa->glCtx;
TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint oldfallback = vmesa->Fallback;
if (VIA_DEBUG) fprintf(stderr, "%s old %x bit %x mode %d\n", __FUNCTION__,
vmesa->Fallback, bit, mode);
if (mode) {
vmesa->Fallback |= bit;
if (oldfallback == 0) {
VIA_FLUSH_DMA(vmesa);
if (0) fprintf(stderr, "ENTER FALLBACK %x\n", bit);
if (VIA_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "ENTER FALLBACK %x\n", bit);
_swsetup_Wakeup(ctx);
vmesa->renderIndex = ~0;
}
@@ -1062,7 +1075,8 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
if (oldfallback == bit) {
_swrast_flush( ctx );
if (0) fprintf(stderr, "LEAVE FALLBACK %x\n", bit);
if (VIA_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "LEAVE FALLBACK %x\n", bit);
tnl->Driver.Render.Start = viaRenderStart;
tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
@@ -1087,7 +1101,7 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
static void viaRunPipeline( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
if (vmesa->newState) {
vmesa->newRenderState |= vmesa->newState;
@@ -1105,7 +1119,7 @@ static void viaRunPipeline( GLcontext *ctx )
void viaInitTriFuncs(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
static int firsttime = 1;

View File

@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* 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"),
@@ -1092,6 +1092,8 @@ glXFreeMemoryNV( GLvoid *pointer )
}
/*** GLX_MESA_agp_offset */
GLuint PUBLIC
@@ -1106,6 +1108,32 @@ glXGetAGPOffsetMESA( const GLvoid *pointer )
}
/*** GLX_MESA_allocate_memory */
void *
glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size,
float readfreq, float writefreq, float priority)
{
/* dummy */
return NULL;
}
void
glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
{
/* dummy */
}
GLuint
glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer)
{
/* dummy */
return 0;
}
/**********************************************************************/
/* GLX API management functions */
/**********************************************************************/
@@ -1148,9 +1176,6 @@ _glxapi_get_extensions(void)
#endif
#ifdef GLX_SGIX_pbuffer
"GLX_SGIX_pbuffer",
#endif
#ifdef GLX_ARB_render_texture
"GLX_ARB_render_texture",
#endif
NULL
};
@@ -1332,6 +1357,11 @@ static struct name_address_pair GLX_functions[] = {
/*** GLX_MESA_agp_offset ***/
{ "glXGetAGPOffsetMESA", (__GLXextFuncPtr) glXGetAGPOffsetMESA },
/*** GLX_MESA_allocate_memory ***/
{ "glXAllocateMemoryMESA", (__GLXextFuncPtr) glXAllocateMemoryMESA },
{ "glXFreeMemoryMESA", (__GLXextFuncPtr) glXFreeMemoryMESA },
{ "glXGetMemoryOffsetMESA", (__GLXextFuncPtr) glXGetMemoryOffsetMESA },
{ NULL, NULL } /* end of list */
};

View File

@@ -1740,14 +1740,17 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
#ifdef XFree86Server
if (GET_VISUAL_DEPTH(v) != ((XMesaDrawable)w)->depth) {
_mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual and window! (%d != %d)\n", GET_VISUAL_DEPTH(v) , ((XMesaDrawable)w)->depth );
return NULL;
}
#else
XGetWindowAttributes( v->display, w, &attr );
if (GET_VISUAL_DEPTH(v) != attr.depth) {
#endif
_mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual and window! (%d != %d)\n", GET_VISUAL_DEPTH(v) , attr.depth );
return NULL;
}
#endif
b->xm_visual = v;
b->type = WINDOW;

View File

@@ -125,6 +125,9 @@ class glXEnumFunction:
for a in self.enums:
count += 1
if self.count.has_key(-1):
return 0
# Determine if there is some mask M, such that M = (2^N) - 1,
# that will generate unique values for all of the enums.
@@ -176,7 +179,7 @@ class glXEnumFunction:
else:
return 0;
def PrintUsingSwitch(self):
def PrintUsingSwitch(self, name):
"""Emit the body of the __gl*_size function using a
switch-statement."""
@@ -200,7 +203,10 @@ class glXEnumFunction:
else:
print '/* case %s:*/' % (j)
print ' return %u;' % (c)
if c == -1:
print ' return __gl%s_variable_size( e );' % (name)
else:
print ' return %u;' % (c)
print ' default: return 0;'
print ' }'
@@ -212,7 +218,7 @@ class glXEnumFunction:
print '{'
if not self.PrintUsingTable():
self.PrintUsingSwitch()
self.PrintUsingSwitch(name)
print '}'
print ''
@@ -226,14 +232,20 @@ class glXEnum(gl_XML.glEnum):
def startElement(self, name, attrs):
if name == "size":
[n, c, mode] = self.process_attributes(attrs)
[temp_n, c, mode] = self.process_attributes(attrs)
if not self.context.glx_enum_functions.has_key( n ):
f = self.context.createEnumFunction( n )
f.set_mode( mode )
self.context.glx_enum_functions[ f.name ] = f
if temp_n == "Get":
names = ["GetIntegerv", "GetBooleanv", "GetFloatv", "GetDoublev" ]
else:
names = [ temp_n ]
self.context.glx_enum_functions[ n ].append( c, self.value, self.name )
for n in names:
if not self.context.glx_enum_functions.has_key( n ):
f = self.context.createEnumFunction( n )
f.set_mode( mode )
self.context.glx_enum_functions[ f.name ] = f
self.context.glx_enum_functions[ n ].append( c, self.value, self.name )
else:
gl_XML.glEnum.startElement(self, context, name, attrs)
return
@@ -416,10 +428,9 @@ class glXFunction(gl_XML.glFunction):
def variable_length_parameter(self):
for param in self.fn_parameters:
if param.is_variable_length_array():
return param
if len(self.variable_length_parameters):
return self.variable_length_parameters[0]
return None

View File

@@ -449,7 +449,11 @@ generic_%u_byte( GLint rop, const void * ptr )
print " __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, f.image.img_format, f.image.img_type, f.image.name)
else:
if f.output != None:
output_size = f.output.p_type.size
if f.output.p_type.size == 0:
output_size = 1
else:
output_size = f.output.p_type.size
output_str = f.output.name
else:
output_size = 0

View File

@@ -161,8 +161,11 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
def printRealHeader(self):
print ''
print '#include <GL/gl.h>'
print '#include "indirect_size.h"'
if self.which_functions & self.do_get:
print '#include "indirect_size_get.h"'
print '#include "indirect_size.h"'
print ''
self.printHaveAlias()
print ''
@@ -227,13 +230,45 @@ class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common):
print 'extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (f.name)
class PrintGlxReqSize_h(glX_XML.GlxProto):
class PrintGlxReqSize_common(glX_XML.GlxProto):
"""Common base class for PrintGlxSizeReq_h and PrintGlxSizeReq_h.
The main purpose of this common base class is to provide the infrastructure
for the derrived classes to iterate over the same set of functions.
"""
def __init__(self):
glX_XML.GlxProto.__init__(self)
self.name = "glX_proto_size.py (from Mesa)"
self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2005", "IBM")
self.aliases = []
self.glx_enum_sigs = {}
self.size_functions = []
def endElement(self, name):
if name == "function":
f = self.current_object
if f.glx_rop and not f.ignore and f.fn_alias == None and f.vectorequiv == None:
if self.glx_enum_functions.has_key(f.name) or f.image or f.server_handcode:
self.size_functions.append( f )
else:
for p in f.parameterIterator(1,2):
if p.counter and not p.is_output:
self.size_functions.append( f )
break
glX_XML.GlxProto.endElement(self, name)
def functionIterator(self):
return self.size_functions
class PrintGlxReqSize_h(PrintGlxReqSize_common):
def __init__(self):
PrintGlxReqSize_common.__init__(self)
self.header_tag = "_INDIRECT_REQSIZE_H_"
@@ -245,25 +280,12 @@ class PrintGlxReqSize_h(glX_XML.GlxProto):
def printFunction(self, f):
if f.glx_rop == 0: return
has_counter = 0
for p in f.parameterIterator(1,2):
if p.is_counter:
has_counter = 1
break
if self.glx_enum_functions.has_key(f.name) or f.image or has_counter:
print 'extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (f.name)
print 'extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (f.name)
class PrintGlxReqSize_c(glX_XML.GlxProto):
class PrintGlxReqSize_c(PrintGlxReqSize_common):
def __init__(self):
glX_XML.GlxProto.__init__(self)
self.name = "glX_proto_size.py (from Mesa)"
self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2005", "IBM")
self.aliases = []
self.glx_enum_sigs = {}
PrintGlxReqSize_common.__init__(self)
self.counter_sigs = {}
@@ -304,7 +326,13 @@ class PrintGlxReqSize_c(glX_XML.GlxProto):
def printFunction(self, f):
if f.glx_rop == 0 or f.server_handcode: return
# Even though server-handcode fuctions are on "the list",
# and prototypes are generated for them, there isn't enough
# information to generate a size function. If there was
# enough information, they probably wouldn't need to be
# handcoded in the first place!
if f.server_handcode: return
if self.glx_enum_functions.has_key(f.name):
ef = self.glx_enum_functions[f.name]
@@ -425,7 +453,7 @@ class PrintGlxReqSize_c(glX_XML.GlxProto):
offset += p.size()
# If the calculate signature matches a function that has
# If the calculated signature matches a function that has
# already be emitted, don't emit this function. Instead, add
# it to the list of function aliases.

File diff suppressed because it is too large Load Diff

View File

@@ -91,9 +91,10 @@ class glEnum( glItem ):
glItem.__init__(self, name, enum_name, context)
temp = attrs.get('count', None)
if temp == None:
self.default_count = 0
else:
self.default_count = 0
if temp == "?":
self.default_count = -1
elif temp:
try:
c = int(temp)
except Exception,e:
@@ -175,6 +176,8 @@ class glParameter( glItem ):
self.p_count = 0
self.counter = c
self.count_scale = int(attrs.get('count_scale', "1"))
if attrs.get('counter', "false") == "true":
self.is_counter = 1
else:
@@ -296,7 +299,7 @@ class glParameter( glItem ):
elif self.p_count == 0:
return self.p_type.size
else:
return self.p_type.size * self.p_count
return self.p_type.size * self.p_count * self.count_scale
def size_string(self):
s = self.size()
@@ -310,11 +313,17 @@ class glParameter( glItem ):
if b_prod == 0: b_prod = 1
if not self.count_parameter_list and self.counter != None:
a_prod = self.counter
if self.count_scale > 1:
a_prod = '(%s * %u)' % (self.counter, self.count_scale)
else:
a_prod = self.counter
elif self.count_parameter_list and self.counter == None:
pass
elif self.count_parameter_list and self.counter != None:
b_prod = self.counter
if self.count_scale > 1:
b_prod = '(%s * %u)' % (self.counter, self.count_scale)
else:
b_prod = self.counter
elif self.width:
return "compsize"
else:
@@ -367,6 +376,9 @@ class glFunction( glItem ):
else:
self.real_name = fn_name
self.parameters_by_name = {}
self.variable_length_parameters = []
glItem.__init__(self, name, fn_name, context)
return
@@ -387,6 +399,32 @@ class glFunction( glItem ):
self.set_return_type(attrs.get('type', None))
def endElement(self, name):
"""Handle the end of a <function> element.
At the end of a <function> element, there is some semantic
checking that can be done. This prevents some possible
exceptions from being thrown elsewhere in the code.
"""
if name == "function":
for p in self.variable_length_parameters:
if p.counter:
counter = self.parameters_by_name[ p.counter ]
if not self.parameters_by_name.has_key( p.counter ):
raise RuntimeError("Parameter '%s' of function '%s' has counter '%s', but function has no such parameter." % (p.name, self.name, p.counter))
elif not self.parameters_by_name[ p.counter ].is_counter:
raise RuntimeError("Parameter '%s' of function '%s' has counter '%s', but '%s' is not marked as a counter." % (p.name, self.name, p.counter, p.counter))
for n in p.count_parameter_list:
if not self.parameters_by_name.has_key( n ):
raise RuntimeError("Parameter '%s' of function '%s' has size parameter '%s', but function has no such parameter." % (p.name, self.name, n))
return 1
else:
return 0
def append(self, tag_name, p):
if tag_name != "param":
raise RuntimeError("Trying to append '%s' to parameter list of function '%s'." % (tag_name, self.name))
@@ -398,6 +436,11 @@ class glFunction( glItem ):
if p.count_parameter_list != []:
self.count_parameter_list.extend( p.count_parameter_list )
if p.is_variable_length_array():
self.variable_length_parameters.append(p)
self.parameters_by_name[ p.name ] = p
def set_return_type(self, t):
self.fn_return_type = t
@@ -487,22 +530,18 @@ class glFunctionIterator:
class FilterGLAPISpecBase(saxutils.XMLFilterBase):
name = "a"
license = "The license for this file is unspecified."
functions = {}
next_alias = -2
types = {}
xref = {}
current_object = None
factory = None
current_category = ""
def __init__(self):
saxutils.XMLFilterBase.__init__(self)
self.functions = {}
self.types = {}
self.xref = {}
self.functions_by_name = {}
self.factory = glItemFactory()
self.header_tag = None
self.undef_list = []
self.current_category = ""
def find_type(self,type_name):
@@ -514,8 +553,7 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase):
def find_function(self,function_name):
index = self.xref[function_name]
return self.functions[index]
return self.functions_by_name[function_name]
def functionIterator(self):
@@ -584,7 +622,9 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase):
self.next_alias -= 1
self.functions[index] = obj
self.xref[obj.name] = index
self.functions_by_name[obj.name] = obj
elif object_type == "type":
self.types[obj.name] = obj

View File

@@ -310,7 +310,7 @@ _mesa_buffer_get_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
{
(void) ctx; (void) target;
if (bufObj->Data && ((GLuint) (size + offset) <= bufObj->Size)) {
if (bufObj->Data && ((GLsizeiptrARB) (size + offset) <= bufObj->Size)) {
_mesa_memcpy( data, (GLubyte *) bufObj->Data + offset, size );
}
}

View File

@@ -1536,6 +1536,7 @@ _mesa_initialize_context( GLcontext *ctx,
{
ASSERT(driverContext);
assert(driverFunctions->NewTextureObject);
assert(driverFunctions->FreeTexImageData);
/* If the driver wants core Mesa to use special imports, it'll have to
* override these defaults.

View File

@@ -511,6 +511,11 @@ struct dd_function_table {
*/
struct gl_texture_image * (*NewTextureImage)( GLcontext *ctx );
/**
* Called to free tImage->Data.
*/
void (*FreeTexImageData)( GLcontext *ctx, struct gl_texture_image *tImage );
/**
* Called by glAreTextureResident().
*/

File diff suppressed because it is too large Load Diff

View File

@@ -1471,7 +1471,7 @@ struct gl_buffer_object
GLenum Usage;
GLenum Access;
GLvoid *Pointer; /**< Only valid while buffer is mapped */
GLuint Size; /**< Size of storage in bytes */
GLsizeiptrARB Size; /**< Size of storage in bytes */
GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
GLboolean OnCard; /**< Is buffer in VRAM? (hardware drivers) */
};

View File

@@ -570,22 +570,40 @@ _mesa_new_texture_image( GLcontext *ctx )
}
/**
* Free texture image data.
*
* \param teximage texture image.
*
* Free the texture image data if it's not marked as client data.
*/
void
_mesa_free_texture_image_data( GLcontext *ctx, struct gl_texture_image *texImage )
{
if (texImage->Data && !texImage->IsClientData) {
/* free the old texture data */
MESA_PBUFFER_FREE(texImage->Data);
}
texImage->Data = NULL;
}
/**
* Free texture image.
*
* \param teximage texture image.
*
* Free the texture image structure and the associated image data if it's not
* marked as client data.
* Free the texture image structure and the associated image data.
*/
void
_mesa_delete_texture_image( struct gl_texture_image *teximage )
_mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *texImage )
{
if (teximage->Data && !teximage->IsClientData) {
MESA_PBUFFER_FREE( teximage->Data );
teximage->Data = NULL;
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
FREE( teximage );
ASSERT(texImage->Data == NULL);
FREE( texImage );
}
@@ -2024,11 +2042,10 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
return;
}
else if (texImage->Data && !texImage->IsClientData) {
/* free the old texture data */
MESA_PBUFFER_FREE(texImage->Data);
else if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
texImage->Data = NULL;
ASSERT(texImage->Data == NULL);
clear_teximage_fields(texImage); /* not really needed, but helpful */
_mesa_init_teximage_fields(ctx, target, texImage,
postConvWidth, 1, 1,
@@ -2124,11 +2141,10 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
return;
}
else if (texImage->Data && !texImage->IsClientData) {
/* free the old texture data */
MESA_PBUFFER_FREE(texImage->Data);
else if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
texImage->Data = NULL;
ASSERT(texImage->Data == NULL);
clear_teximage_fields(texImage); /* not really needed, but helpful */
_mesa_init_teximage_fields(ctx, target, texImage,
postConvWidth, postConvHeight, 1,
@@ -2220,10 +2236,10 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
return;
}
else if (texImage->Data && !texImage->IsClientData) {
MESA_PBUFFER_FREE(texImage->Data);
else if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
texImage->Data = NULL;
ASSERT(texImage->Data == NULL);
clear_teximage_fields(texImage); /* not really needed, but helpful */
_mesa_init_teximage_fields(ctx, target, texImage,
width, height, depth,
@@ -2460,11 +2476,10 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D");
return;
}
else if (texImage->Data && !texImage->IsClientData) {
/* free the old texture data */
MESA_PBUFFER_FREE(texImage->Data);
else if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
texImage->Data = NULL;
ASSERT(texImage->Data == NULL);
clear_teximage_fields(texImage); /* not really needed, but helpful */
_mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, 1, 1,
@@ -2523,11 +2538,10 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D");
return;
}
else if (texImage->Data && !texImage->IsClientData) {
/* free the old texture data */
MESA_PBUFFER_FREE(texImage->Data);
else if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
texImage->Data = NULL;
ASSERT(texImage->Data == NULL);
clear_teximage_fields(texImage); /* not really needed, but helpful */
_mesa_init_teximage_fields(ctx, target, texImage,
@@ -2873,10 +2887,10 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1D");
return;
}
else if (texImage->Data && !texImage->IsClientData) {
MESA_PBUFFER_FREE(texImage->Data);
else if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
texImage->Data = NULL;
ASSERT(texImage->Data == NULL);
_mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
border, internalFormat);
@@ -2956,10 +2970,10 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
return;
}
else if (texImage->Data && !texImage->IsClientData) {
MESA_PBUFFER_FREE(texImage->Data);
else if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
texImage->Data = NULL;
ASSERT(texImage->Data == NULL);
_mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
border, internalFormat);
@@ -3038,10 +3052,10 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3D");
return;
}
else if (texImage->Data && !texImage->IsClientData) {
MESA_PBUFFER_FREE(texImage->Data);
else if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
texImage->Data = NULL;
ASSERT(texImage->Data == NULL);
_mesa_init_teximage_fields(ctx, target, texImage, width, height, depth,
border, internalFormat);

View File

@@ -47,7 +47,12 @@ _mesa_new_texture_image( GLcontext *ctx );
extern void
_mesa_delete_texture_image( struct gl_texture_image *teximage );
_mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *teximage );
extern void
_mesa_free_texture_image_data( GLcontext *ctx,
struct gl_texture_image *texImage );
extern void

View File

@@ -144,7 +144,7 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
for (face = 0; face < 6; face++) {
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
if (texObj->Image[face][i]) {
_mesa_delete_texture_image( texObj->Image[face][i] );
_mesa_delete_texture_image( ctx, texObj->Image[face][i] );
}
}
}

Some files were not shown because too many files have changed in this diff Show More